Esempio n. 1
0
void AdjList::readInFromFile( string fileName)
{
    //clear the vector
    initForm.clear();
    
    ifstream inFile(fileName,ios::in);
    if (!inFile)
    {
        cerr << endl << "File could not be opened." << endl << endl;
        exit(1);
    }
    
    string line;
    
    while( getline( inFile, line ) )
    {
        istringstream iss(line);
        initForm.push_back(
            vector<int>(
                istream_iterator<int>(iss),
                istream_iterator<int>()
            )
        );
    }
    
    //Build into full structure
    buildAdjList();
    
}
Esempio n. 2
0
//***********************
//Constructor
AdjList::AdjList( vector<vector<int>> initVec )
    :initForm( initVec ), nodePtrs( {} ), firstPtr( 0 ), lastPtr( 0 )
{
    //If we initialize it, build the full structure
    if( initForm.size() != 0)
        buildAdjList();
}
Esempio n. 3
0
void NonRigid::setMesh(Mesh *mesh_data)
{
    this->mesh_data = mesh_data;
    lamd_arap = 10;
    grad_max_iter = 25;
    grad_step = 0.01;

    std::clock_t begin;
    std::clock_t end;
    begin = std::clock();

    buildAdjList();

    end = std::clock();
    std::cout<<"Elapsed time: "<<double(end-begin)/CLOCKS_PER_SEC<<"\n";

    // init mesh data vector to current position
    vtkSmartPointer<vtkMatrix4x4> trans_mat = vtkSmartPointer<vtkMatrix4x4>::New();
    mesh_data->getTransform()->GetMatrix(trans_mat);
    int meshNum = mesh_data->getMeshData()->GetNumberOfPoints();
    temp_mesh_vec.clear();
    for (size_t i = 0; i < meshNum; ++i) {
        double* temp = mesh_data->getMeshData()->GetPoint(i);
        temp_mesh_vec.push_back(temp[0]);
        temp_mesh_vec.push_back(temp[1]);
        temp_mesh_vec.push_back(temp[2]);
    }

    setUserTrans(trans_mat);

    begin = std::clock();

    initOpt();

    end = std::clock();
    std::cout<<"Elapsed time: "<<double(end-begin)/CLOCKS_PER_SEC<<"\n";

}