level 3
补上代码:
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