[vtkusers] Can not show points of STL file

Wahyudin Permana gebe_top at yahoo.com
Mon Jul 5 11:12:41 EDT 2010


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

============================================================


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100705/33336b9c/attachment.htm>


More information about the vtkusers mailing list