[vtkusers] ply file created is unreadable: help

cerina cerine-baratelli at hotmail.fr
Mon Sep 17 12:46:34 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();

int j=1;
for (int k=0; k<this->Input->GetNumberOfCells();k++)
{
if(PointsNode->GetValue(k)==m)
{
double* x;
vtkIdType pid[1];
this->Input->GetFaceVertices(k,v1,v2,v3);
this->Input->GetPointCoordinates(v1,x);
pid[0] = points->InsertNextPoint ( x );
vertices->InsertNextCell ( j,pid );
this->Input->GetPointCoordinates(v2,x);
pid[0] = points->InsertNextPoint ( x );
vertices->InsertNextCell ( j,pid );
this->Input->GetPointCoordinates(v3,x);
pid[0] = points->InsertNextPoint ( x );
vertices->InsertNextCell ( j,pid );
triangle->GetPointIds()->SetId(v1,v1);
triangle->GetPointIds()->SetId(v2,v2);
triangle->GetPointIds()->SetId(v3,v3);
triangles->InsertNextCell(triangle);

}

}
 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();
}

 when i open the generated file with blocNote i find that they contains
vertex and faces as follow:

format binary_little_endian 1.0
comment VTK generated PLY File
obj_info vtkPolyData points and polygons: vtk4.0
element vertex 945
property float x
property float y
property float z
element face 315
property list uchar int vertex_indices
end_header

but when i try to open it in order to visualize the mesh, it give an empty
window

thanks for help 

Regards,

Cerina



--
View this message in context: http://vtk.1045678.n5.nabble.com/ply-file-created-is-unreadable-help-tp5716143.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list