[vtkusers] How to create a cube with vtkPolyData

Bill Lorensen bill.lorensen at gmail.com
Tue May 18 10:56:23 EDT 2010


If you don't clip it, you will not see the interior.

I am still confused about what you are trying to do.


On Tue, May 18, 2010 at 10:41 AM, Jothy <jothybasu at gmail.com> wrote:
> I have tried it earlier. It works fine when you display it as surface. But I
> want to display it as a wireframe , I mean only the outline.So that you can
> see the dose values and ROIs properly.
>
> (I wonder, there must be someone on the list from the planning system
> developers, but they keep their mouth tight!).
>
> Thanks,
>
> Jothy
>
> On Tue, May 18, 2010 at 3:26 PM, Scott Johnson <Scott.Johnson at neuwave.com>
> wrote:
>>
>> Hello Jothy,
>>
>>
>>
>> It looks like the plane is being rendered as wireframe.  Try rendering it
>> as a semi-transparent surface to see if it goes away.  I’m not sure how to
>> get just the outline.
>>
>>
>>
>>                                 -- Scott
>>
>>
>>
>> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
>> Of Jothy
>> Sent: Tuesday, May 18, 2010 5:15 AM
>> To: David Doria
>> Cc: VTK
>> Subject: Re: [vtkusers] How to create a cube with vtkPolyData
>>
>>
>>
>> Screenshot is here!
>>
>>
>> On Tue, May 18, 2010 at 11:12 AM, Jothy <jothybasu at gmail.com> wrote:
>>
>> Hi David,
>>
>> I tried the vtkHexahedron example. But, when I try to cut this I get a
>> line across the cut plane . see the screenshot and also the code.
>>
>> Could you please figure it out?
>>
>> from vtk import*
>>
>>
>> #Setup the coordinates of eight points
>> #(the two faces must be in counter clockwise order as viewd from the
>> outside)
>> P0 = [0.0, 0.0, 0.0];
>> P1 = [1.0, 0.0, 0.0];
>> P2 = [1.0, 1.0, 0.0];
>> P3 = [0.0, 1.0, 0.0];
>> P4 = [0.0, 0.0, 1.0];
>> P5 = [1.0, 0.0, 1.0];
>> P6 = [1.0, 1.0, 1.0];
>> P7 = [0.0, 1.0, 1.0];
>>
>>
>> #Create the points
>> points = vtkPoints();
>> points.InsertNextPoint(P0);
>> points.InsertNextPoint(P1);
>> points.InsertNextPoint(P2);
>> points.InsertNextPoint(P3);
>> points.InsertNextPoint(P4);
>> points.InsertNextPoint(P5);
>> points.InsertNextPoint(P6);
>> points.InsertNextPoint(P7);
>>
>> #Create a hexahedron from the points
>> hexa = vtkHexahedron();
>> hexa.GetPointIds().SetId(0,0);
>> hexa.GetPointIds().SetId(1,1);
>> hexa.GetPointIds().SetId(2,2);
>> hexa.GetPointIds().SetId(3,3);
>> hexa.GetPointIds().SetId(4,4);
>> hexa.GetPointIds().SetId(5,5);
>> hexa.GetPointIds().SetId(6,6);
>> hexa.GetPointIds().SetId(7,7);
>>
>> #Add the hexahedron to a cell array
>> hexs = vtkCellArray();
>> hexs.InsertNextCell(hexa);
>>
>> #Add the points and hexahedron to an unstructured grid
>> uGrid =vtkUnstructuredGrid();
>> uGrid.SetPoints(points);
>> uGrid.InsertNextCell(hexa.GetCellType(), hexa.GetPointIds());
>> aBeamMapper = vtkDataSetMapper()
>> aBeamMapper.SetInput(uGrid)
>> aBeamActor = vtkActor()
>> aBeamActor.SetMapper(aBeamMapper)
>> aBeamActor.AddPosition(0,0,0)
>> aBeamActor.GetProperty().SetColor(1,1,0)
>> aBeamActor.GetProperty().SetOpacity(0.60)
>> aBeamActor.GetProperty().EdgeVisibilityOn()
>> aBeamActor.GetProperty().SetEdgeColor(1,1,1)
>> aBeamActor.GetProperty().SetLineWidth(1.5)
>>
>> #create a plane to cut,here it cuts in the XZ direction (xz
>> normal=(1,0,0);XY =(0,0,1),YZ =(0,1,0)
>> plane=vtkPlane()
>> plane.SetOrigin(0.5,0,0)
>> plane.SetNormal(1,0,0)
>>
>> #create cutter
>> cutter=vtkCutter()
>> cutter.SetCutFunction(plane)
>> cutter.SetInput(aBeamActor.GetMapper().GetInput())
>> cutter.Update()
>> cutterMapper=vtkPolyDataMapper()
>> cutterMapper.SetInputConnection( cutter.GetOutputPort())
>>
>> #create plane actor
>> planeActor=vtkActor()
>> planeActor.GetProperty().SetColor(1,0.5,0.5)
>> planeActor.GetProperty().SetLineWidth(2)
>> planeActor.SetMapper(cutterMapper)
>>
>> # Setup a renderer, render window, and interactor
>> renderer = vtkRenderer()
>> renderWindow = vtkRenderWindow()
>> #renderWindow.SetWindowName("Test")
>>
>> renderWindow.AddRenderer(renderer);
>> renderWindowInteractor = vtkRenderWindowInteractor()
>> renderWindowInteractor.SetRenderWindow(renderWindow)
>>
>> #Add the actor to the scene
>> renderer.AddActor(aBeamActor)
>> renderer.AddActor(planeActor)
>> renderer.SetBackground(0,0,0) # Background color white
>>
>> #Render and interact
>> renderWindow.Render()
>>
>>
>> I think it has be passed through a filter. But what it's that??
>>
>> Thanks,
>>
>> Jothy
>>
>>
>> On Mon, May 17, 2010 at 10:08 PM, David Doria <daviddoria+vtk at gmail.com>
>> wrote:
>> > On Mon, May 17, 2010 at 5:03 PM, Jothy <jothybasu at gmail.com> wrote:
>> >> Hi all,
>> >>
>> >> I want to create a hexahedron using vtkPolyData. I think there is no
>> >> example in wiki. I created it with a vtkHexaHedron but when I cut it
>> >> it produces a line across the cut section.I don't want this. I am not
>> >> able to solve this problem for many months.I used it passing through
>> >> vtkstripper, vtkTriangle. Finally found that only if the input is of
>> >> vtkPolyData, cutter will not produce that line across the cut section.
>> >> Can some with kind enough :), add an example of how to create cube or
>> >> cone with vtkPoldata.
>> >>
>> >> Many thanks,
>> >>
>> >> Jothy
>> >
>> > I don't really understand your question. The title and your last
>> > sentence talk about cubes and cones
>> >
>> > http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Cube
>> > http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Display/Cone
>> >
>> > but the beginning talks about hexahedrons
>> >
>> > http://www.vtk.org/Wiki/VTK/Examples/GeometricObjects/Hexahedron
>> >
>> > Let us know if these links do not help.
>> >
>> > David
>> >
>>
>>
>
> _______________________________________________
> 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
>
>



More information about the vtkusers mailing list