[vtkusers] Can not show points of STL file

Sebastien Jourdain sebastien.jourdain at kitware.com
Mon Jul 5 13:44:07 EDT 2010


Or create a cell for each point (VTK_VERTEX (=1)) or 1 cell that refer to
each point (VTK_POLY_VERTEX (=2)) on the polydata.

Something like that...

vtkIdList cell = new vtkIdList();
cell.SetNumberOfxx(STLPointData.size());
for(int i=0;i<STLPointData.size();i++) cell.SetId(i,i);
polyData.InsertNextCell(2,cell); // 2:VTK_POLY_VERTEX

I do not remember exactly the methods names, but you should be able to
figure that out.

Seb



On Mon, Jul 5, 2010 at 11:43 AM, David E DeMarle
<dave.demarle at kitware.com>wrote:

> VTK renders cells not points.
>
> Try using a glyph filter to create 1 VTK_VERTEX cell for every point.
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-371-3971 x109
>
>
> On Mon, Jul 5, 2010 at 11:12 AM, Wahyudin Permana <gebe_top at yahoo.com>wrote:
>
>> Dear All,
>>
>> I want to show points of STL file, but it doesn.t work, no error, but the
>> points were not appear.
>> any suggestion?
>>
>> Code:
>>     STLPointData = new STLReading();
>>         STLPointData.readSTL(name);  // IMPORTANT: ONLYREAD STL ASCII FILE
>>
>>         vtkPoints points = new vtkPoints();
>>         vtkPolyData polyData = new vtkPolyData();
>>         vtkUnstructuredGrid unstructuredGrid = new vtkUnstructuredGrid();
>>
>>         int i = 0, j = 0, k = 0;
>>         int n;
>>         n = STLPointData.size();
>>         points.SetNumberOfPoints(n);
>>         System.out.println("Number of points= "+n);
>>         for(i=0;i<n;i++){
>>             double x = 0,y = 0,z = 0;
>>             //for(j=0;j<3;j++){
>>             //}
>>             x=(Double)((Vector)STLPointData.get(i)).get(0);
>>             y=(Double)((Vector)STLPointData.get(i)).get(1);
>>             z=(Double)((Vector)STLPointData.get(i)).get(2);
>>             points.InsertPoint(i, x, y, x);
>>             System.out.println("X= "+x+", Y= "+y+", Z= "+z);
>>         }
>>
>>         vtkConeSource cone = new vtkConeSource();
>>
>>         polyData.SetPoints(points);
>>         polyData.Squeeze();
>>         vtkPolyDataMapper mapper = new vtkPolyDataMapper();
>>         mapper.SetInput(polyData);
>>         //mapper.SetInput(cone.GetOutput());
>>
>>         //unstructuredGrid.SetPoints(points);
>>         //vtkDataSetMapper dataMapper = new vtkDataSetMapper();
>>         //dataMapper.SetInput(unstructuredGrid);
>>         //dataMapper.SetInput(polyData);
>>
>>         vtkActor stlActor = new vtkActor();
>>         vtkProperty property = new vtkProperty();
>>         property.SetColor(0.3, 0.8, 0.3);
>>         stlActor.SetMapper(mapper);
>>         //stlActor.SetMapper(dataMapper);
>>         stlActor.SetProperty(property);
>>
>>         vtkRenderer ren2; //= new vtkRenderer();
>>         ren2 = renWin2.GetRenderer();
>>         ren2.AddActor(stlActor);
>>         ren2.SetBackground(0.1, 0.1, 0.8);
>>
>>         ren2.ResetCameraClippingRange();
>>         ren2.ResetCamera();
>>
>>         ren2.Render();
>>
>>
>> thank you
>>
>> ============================================================
>> regards,
>> Wahyudin Permana
>> Phone:
>> Indonesia (Jakarta): +628151871130
>> Saudi Arabia (Riyadh): +966569143445
>> ============================================================
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100705/8aa03e3d/attachment.htm>


More information about the vtkusers mailing list