[vtkusers] plyWriter from polydata: help pleaaase

cerina cerine-baratelli at hotmail.fr
Mon Sep 17 11:52:40 EDT 2012


hi,

Ichanged my previous code (using the extraction here :
http://vtk.1045678.n5.nabble.com/vtkPLYWriter-and-polydata-td5716117.html
http://vtk.1045678.n5.nabble.com/vtkPLYWriter-and-polydata-td5716117.html 
to creating a new polydata from a list of points in order to write a *PLY
File* from it.
 i have this code:
// Assign all points to root node	
for (int i=0;i<this->Input->GetNumberOfPoints();i++) 
PointsNode->SetValue(i,0); 

int NumberOfSplitNodes; 
int Level=0; 
for(int h=0;h<8; h++) 
{ 
.................. // subdividing the octree 
} 
for(int m=0; m<NumberOfSplitNodes; m++)// debut de boucle des régions
{ 
vtkIdType v1;
vtkIdType v2;
vtkIdType v3;
vtkIdList *pts=vtkIdList::New();
vtkPoints* points = vtkPoints::New();
vtkSmartPointer&lt;vtkCellArray> vertices =
vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkCellArray> triangles =
vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
vtkSmartPointer<vtkLine> line0 = vtkSmartPointer<vtkLine>::New();
vtkSmartPointer<vtkLine> line1 = vtkSmartPointer<vtkLine>::New();
vtkSmartPointer<vtkLine> line2 = vtkSmartPointer<vtkLine>::New();
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
for (int k=0; k<this->Input->GetNumberOfCells();k++)
{
if(PointsNode->GetValue(k)==m)
{
double* x;
double* y;
double* z;
this->Input->GetFaceVertices(k,v1,v2,v3);
pts->InsertNextId(v1);
pts->InsertNextId(v2);
pts->InsertNextId(v3);
vertices->InsertNextCell(pts);
triangle->GetPointIds()->SetId(v1,v1);
triangle->GetPointIds()->SetId(v2,v2);
triangle->GetPointIds()->SetId(v3,v3);
triangles->InsertNextCell(triangle);
this->Input->GetPointCoordinates(v1,x);
points->InsertNextPoint(x);
this->Input->GetPointCoordinates(v2,y);
points->InsertNextPoint(x);
this->Input->GetPointCoordinates(v3,z);
points->InsertNextPoint(x);
line0->GetPointIds()->SetId ( 0,v1 );
line0->GetPointIds()->SetId ( 1,v2 );
line1->GetPointIds()->SetId ( 0,v2 );
line1->GetPointIds()->SetId ( 1,v3 );
line2->GetPointIds()->SetId ( 0,v1 );
line2->GetPointIds()->SetId ( 1,v3 );
lines->InsertNextCell ( line0 );
lines->InsertNextCell ( line1 );
lines->InsertNextCell ( line2 );
}
}
 vtkSmartPointer<vtkPolyData> newdata =  
vtkSmartPointer<vtkPolyData>::New(); 
newdata->SetPoints(points); 
newdata->SetVerts(vertices);
newdata->SetLines(lines);
newdata->SetPolys(triangles);			
vtkPLYWriter *Writer=vtkPLYWriter::New();

Writer->SetInput(newdata);
std::stringstream strfile;
strfile<<"Region"<<m&lt;&lt;&quot;.ply&quot;;
Writer->SetFileName(strfile.str().c_str());
Writer->Write();
}

one time , it creates ply files which contains just points, an other time,
it crashes, and when i debug it, i didn't find the line that make it crashed

thanks for help 

Regards,

Cerina



--
View this message in context: http://vtk.1045678.n5.nabble.com/plyWriter-from-polydata-help-pleaaase-tp5716139.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list