我想在c ++中使用VTK并在3D中绘制分子。我有一个代表原子位置的向量和另一个代表每个原子大小的向量。我怎么能这样做?我是否需要为每个原子创建一个新的sphere_source。
vector< vector <double> > Positions;
vector< double > Sizes;
答案 0 :(得分:5)
看看vtkGlyph3D,这个例子: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/Glyph3D 但是,每个原子SIZE需要单独的球体源,所有具有相同大小的原子都可以使用相同的球体源...
答案 1 :(得分:1)
void VTK_Plotter::Add_Point(vector<double> Position, double Size)
{
Size = floor((log10(Size) + 0.2) * 100.0) / 100.0;
vtkSmartPointer<vtkSphereSource> Current_Sphere_Source;
// Different atomi number have different set of points
vtkSmartPointer<vtkPoints> Current_Point_Group;
// If the point has a size not in the list create a new sphere source with different size
if (Table_Size_Source.find(Size) == Table_Size_Source.end()) {
// Create new source
Current_Sphere_Source = vtkSmartPointer<vtkSphereSource>::New();
Current_Sphere_Source->SetRadius(Size);
Table_Size_Source[Size] = Current_Sphere_Source;
// Create new points
Current_Point_Group = vtkSmartPointer<vtkPoints>::New();
Table_Points_VTK[Size] = Current_Point_Group;
}
else
{
Current_Sphere_Source = Table_Size_Source[Size];
Current_Point_Group = Table_Points_VTK[Size];
}
}