我想在 C++ 中使用 VTK 并在 3D 中绘制一个分子。我有一个代表原子位置的向量和另一个代表每个原子大小的向量。我怎么能做到这一点?我需要为每个原子制作一个新的 sphere_source 吗?
vector< vector <double> > Positions;
vector< double > Sizes;
看看 vtkGlyph3D,这个例子: http ://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/Glyph3D 然而,你需要为每个原子大小单独的球体源,所有具有相同大小的原子可以使用相同的球体源...
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];
}
}