求助!vtk渲染有上限 吗? 真的很急!!! 谢谢各位大神了!
vtk吧
全部回复
仅看楼主
level 3
禄冰0gx 楼主
吧主,你好! 很久没来逛了。最近遇到一个问题,困住了几天。 我现在手里有40W条数据,没一条数据包括了4个数值,分别是球心的x,y,z,以及球体的半径。 我使用的方式是将所有的点渲染出来,然后使用glyph3D 进行符号化,将每一个点用球体来代替。 虽然程序在运行过程中内存占用会达到5Gb,但是这个不是需要考虑的问题。程序运行到一半后就会崩溃自动退出。 我认为是vtk自身的限制问题,因为在符号化过程中,如果把符号(即球体)的PhiResolution和thetaResolution设置为4,4的话 40W个球体是可以渲染出来的(但是这样在视觉上看着就不是球体了,而是想一个方体)
所以想请吧主帮我解答下这个问题,或者是有其他的方法来渲染这些球体,或是渲染其他的形状,在视觉上看起来是球体?@rabbitbride
2015年10月23日 07点10分 1
level 3
禄冰0gx 楼主
补上代码:
void vtkWidget::makeObjectFromVtkFile(VtkFile *vtkFile){
int theNum = vtkFile->getVtkState().num;
vtkSmartPointer<vtkPoints> points = vtkPoints::New();
/*points->SetNumberOfPoints(theNum);*/
vtkSmartPointer<vtkSphereSource> par = vtkSphereSource::New();
if (theNum > 70000)
{
par->SetPhiResolution(4);
par->SetThetaResolution(4);
}
int RCount;
for (RCount = 0; RCount < theNum; RCount++)
{
if(vtkFile->getVtkValue()[RCount].radius != 0){
par->SetRadius(vtkFile->getVtkValue()[RCount].radius);
break;
}
}
// par->SetPhiResolution(10);
// par->SetThetaResolution(10);
glyph = vtkGlyph3D::New();
vtkSmartPointer<vtkUnsignedCharArray> colors = vtkUnsignedCharArray::New();
colors->SetName("colors");
colors->SetNumberOfComponents(3);
vtkSmartPointer<vtkDoubleArray> radiuses = vtkDoubleArray::New();
radiuses->SetName("radius");
radiuses->SetNumberOfComponents(3);
infoIndex.clear();
int k = 0;
for (int i = 0; i< theNum; i++)
{
if (vtkFile->getVtkValue()[i].radius != 0)
{
if (subPar)
{
if (inExtent(vtkFile->getVtkValue()[i].pos.x,
vtkFile->getVtkValue()[i].pos.y, vtkFile->getVtkValue()[i].pos.z,0))
{
points->InsertPoint(k,vtkFile->getVtkValue()[i].pos.x,
vtkFile->getVtkValue()[i].pos.y,
vtkFile->getVtkValue()[i].pos.z);
colors->InsertTuple3(k,vtkFile->getVtkValue()[i].color.r*255,
vtkFile->getVtkValue()[i].color.g*255,
vtkFile->getVtkValue()[i].color.b*255);
radiuses->InsertTuple3(k,vtkFile->getVtkValue()[i].radius/vtkFile->getVtkValue()[RCount].radius,0,0);
infoIndex.append(i);
k++;
}
}else{
points->InsertPoint(k,vtkFile->getVtkValue()[i].pos.x,
vtkFile->getVtkValue()[i].pos.y,
vtkFile->getVtkValue()[i].pos.z);
colors->InsertTuple3(k,vtkFile->getVtkValue()[i].color.r*255,
vtkFile->getVtkValue()[i].color.g*255,
vtkFile->getVtkValue()[i].color.b*255);
radiuses->InsertTuple3(k,vtkFile->getVtkValue()[i].radius/vtkFile->getVtkValue()[RCount].radius,0,0);
k++;
}
}
}
vtkPolyData *poly = vtkPolyData::New();
poly->SetPoints(points);
poly->GetPointData()->SetScalars(colors);
poly->GetPointData()->SetVectors(radiuses);
glyph->SetInput(poly);
glyph->SetSource(par->GetOutput());
glyph->SetScaleModeToScaleByVector();//利用向量大小(x*x+y*y+z*z)^0.5 进行多方
glyph->SetColorModeToColorByScalar();
map1->SetInput(glyph->GetOutput());
actor1->SetMapper(map1);
//actor1->GetProperty()->BackfaceCullingOn();
widget_6_Renderer->AddActor(actor1);
vtkwidget->GetRenderWindow()->Render();
map1->ReleaseGraphicsResources(vtkwidget->GetRenderWindow());
actor1->ReleaseGraphicsResources(vtkwidget->GetRenderWindow());
points->Delete();
par->Delete();
colors->Delete();
glyph->Delete();
}
2015年10月23日 07点10分 2
level 12
球体和立方体在图形上其实差不多~so
这种问题直接换X64,一般都会解决的
2015年10月23日 09点10分 3
1