[Insight-users] How get vertex in stl file

Luis Ibanez luis.ibanez at kitware.com
Sat Jun 9 18:51:52 EDT 2007


Hi Shi,

Your question refers to functionalities
of the Visualization Toolkit VTK.

This list is for the Insight Toolkit ITK.


Please subscribe to the VTK users list at

http://public.kitware.com/mailman/listinfo/vtkusers

You will find better support for your question
in that list.


   Regards,


      Luis




------------------
shi yuan wrote:
> Hi All,
> In my program, I want to import a STL format file and get the vertex in 
> the file, but I cannot get it correctly, I don’t know how to solve it, 
> code segment as follows:
> =====================================================================
> //Create the reader and read a data file
> vtkSmartPointer<vtkSTLReader> sr = vtkSmartPointer<vtkSTLReader>::New();
> sr->SetFileName(strModelPath);
> sr->Update();
>     
> vtkSmartPointer<vtkPolyData> stlPolyData = 
> vtkSmartPointer<vtkPolyData>::New();
> stlPolyData = sr->GetOutput();
> stlPolyData->Update();
>     
> vtkSmartPointer<vtkCellArray> stlCellArray = 
> vtkSmartPointer<vtkCellArray>::New();
> stlCellArray = stlPolyData->GetPolys();
>     
> //Obtaining number of all cells (triangular facets)
> int nCellsNum;
> nCellsNum = stlCellArray->GetNumberOfCells();
>     
> //Definting pointer which is points to vertex in the cell
> double* dpPointA;
> double* dpPointB;
> double* dpPointC;
>     
> for (int nCellID = 0; nCellID < nCellsNum; nCellID++) {
>   vtkCell* cell;
>   cell = stlPolyData->GetCell(nCellID);
>        
>   vtkSmartPointer<vtkPoints> Points = vtkSmartPointer<vtkPoints>::New();
>   Points = cell->GetPoints();
>        
>   vtkSmartPointer<vtkIdList> PointsIDList = 
> vtkSmartPointer<vtkPoints>::New();
>   stlPolyData->GetCellPoints(nCellID,PointsIDList);
>        
>   int a = 0;
>   int b = 0;
>   int c = 0;
>        
>   a = PointsIDList->GetId(0);
>   b = PointsIDList->GetId(1);
>   c = PointsIDList->GetId(2);
> 
>   dpPointA = Points->GetPoint(a);
>   dpPointB = Points->GetPoint(b);
>   dpPointC = Points->GetPoint(c);
> }
> ===================================================================
> I find dpPointA , dpPointB and dpPointC has the same value, Why?
> 
> Thanks in advance for any help.
> 
> Regards,
> Yuan SHI
> 
> _________________________________________________________________
> 与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list