void MorphingWrapper::doLinearMorphing(double *paras, int n_paras)
{
    if (n_paras != meshes.size())
    {
        std::cout<<"Warning: num of control parameters isn't match with internal number of meshes\n";
        return;
    }

    vtkSmartPointer<vtkPolyData> mesh_data = meshes[0]->getMeshData();
    vtkSmartPointer<vtkPoints> new_points = mesh_data->GetPoints();

    Eigen::VectorXd m_result(3*new_points->GetNumberOfPoints());
    m_result.setZero();

    for (size_t i_mesh = 0; i_mesh < meshes.size(); ++i_mesh)
    {
        std::vector<double> &temp_mesh_vec = morphing_handler->getMeshVec(i_mesh);
        Eigen::Map<Eigen::VectorXd>cur_mesh(&temp_mesh_vec[0], temp_mesh_vec.size());

        m_result += paras[i_mesh]*cur_mesh;
    }

    if (new_points->GetNumberOfPoints() == m_result.size()/3)
    {
        for (size_t i = 0; i != new_points->GetNumberOfPoints(); ++i) {
            new_points->SetPoint(i, m_result[3*i], m_result[3*i+1], m_result[3*i+2]);
        }
        new_points->Modified();
        meshes[0]->resetMesh(mesh_data);
        meshes[0]->setMeshCenter();
    }
}
示例#2
0
文件: lmesh.hpp 项目: QuLogic/jot-lib
 virtual CBface_list& cur_faces() const { return cur_mesh()->faces(); }
示例#3
0
文件: lmesh.hpp 项目: QuLogic/jot-lib
 virtual CBedge_list& cur_edges() const { return cur_mesh()->edges(); }
示例#4
0
文件: lmesh.hpp 项目: QuLogic/jot-lib
 // Vertices, edges and faces of the current subdiv mesh:
 virtual CBvert_list& cur_verts() const { return cur_mesh()->verts(); }
示例#5
0
文件: lmesh.hpp 项目: QuLogic/jot-lib
 // The level of the currently drawn mesh:
 virtual int cur_level() const { return cur_mesh()->_subdiv_level; }
示例#6
0
文件: lmesh.hpp 项目: QuLogic/jot-lib
 bool is_cur_mesh() const { return cur_mesh().get() == this; }