[vtkusers] newbie ? CADPart and FilterCADPart

pkudrle paul.kudrle at gmail.com
Thu Jul 9 16:19:01 EDT 2009


I am running the CADPart and FilterCADPart example using the 42400-IDGH.stl

But the object rendered is always off camera.  I have verified that the
actor position is at 0,0,0 and the active camera focal point is at 0,0,0 and
the camera position is at 0,0,1

So I am thinking that the object should be centered and when the window is
opened I should be looking directly at it, but it is always off camera.

I am now assuming that the data is being painted off coordinates from the
0,0,0 actor position.  Am I interpreting this correctly?  I am assuming
someone is familiar with this example.

public class FilterCADPart extends JComponent implements VtkPanelContainer {

    private vtkPanel renWin;

    public FilterCADPart() {
        // Setup VTK rendering panel
        renWin = new vtkPanel();

        // This creates a polygonal cylinder model with eight
circumferential
        // facets.
        vtkSTLReader part = new vtkSTLReader();
       
part.SetFileName("C:\\Users\\pkudrle\\SRC\\VTKData\\Data\\42400-IDGH.stl");
        // A filter is a module that takes at least one input and produces
at
        // least one output. The SetInput and GetOutput methods are used to
do
        // the connection. What is returned by GetOutput is a particulat
        // dataset type. If the type is compatible with the SetInput method,
        // then the filters can be connected together.
        //
        // Here we add a filter that computes surface normals from the
geometry.
        vtkShrinkPolyData shrink = new vtkShrinkPolyData();
        shrink.SetInput(part.GetOutput());
        shrink.SetShrinkFactor(0.85);
        // The mapper is responsible for pushing the geometry into the
graphics
        // library. It may also do color mapping, if scalars or other
        // attributes are defined.
        vtkPolyDataMapper partMapper = new vtkPolyDataMapper();
        partMapper.SetInput(shrink.GetOutput());
        // The LOD actor is a special type of actor. It will change
appearance
        // in order to render faster. At the highest resolution, it renders
        // ewverything just like an actor. The middle level is a point
cloud,
        // and the lowest level is a simple bounding box.
        vtkLODActor partActor = new vtkLODActor();
        partActor.SetMapper(partMapper);
        partActor.GetProperty().SetColor(VtkColors.LIGHT_GREY);
//        partActor.RotateX(30.0);
//        partActor.RotateY(-45.0);

        // Add the actors to the renderer, set the background and size
        renWin.GetRenderer().AddActor(partActor);
        renWin.GetRenderer().SetBackground(0.1, 0.2, 0.4);
        VtkPanelUtil.setSize(renWin, 200, 200);
        
        // We'll zoom in a little by accessing the camera and invoking a
"Zoom"
        // method on it.
        renWin.GetRenderer().GetActiveCamera().Zoom(1.5);

        // Place renWin in the center of this panel
        setLayout(new BorderLayout());
        add(renWin, BorderLayout.CENTER);
    }

    public vtkPanel getRenWin() {
        return renWin;
    }

    public static void main(String s[]) {
        FilterCADPart panel = new FilterCADPart();
        JFrame frame = new JFrame("FilterCADPart");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add("Center", panel);
        frame.pack();
        frame.setVisible(true);
    }
}
-- 
View this message in context: http://www.nabble.com/newbie---CADPart-and-FilterCADPart-tp24417120p24417120.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list