[vtkusers] Re: Re: newbie question : vtkPlanes to represent a cube
Jean-Marie Normand
normand at lina.univ-nantes.fr
Wed Oct 13 08:32:00 EDT 2004
Hi Goodwin!
And thanks for your help!
With your advices and the code source you provided now my boolean
operations are worlking quite well on my ImplicitCubes which are formed
using vtkPlanes.
But I still have problems to use vtkImplicitDataSet, in fact I don't
know how can I give a set of scalars to it. Do I need to parse all the
vertices from the vtkCubeSource and give them a scalar value?
For the moment I just do this :
vtkCubeSource *cubeS = vtkCubeSource::New();
vtkImplicitDataSet *ImplDS = vtkImplicitDataSet::New();
ImplDS->SetData((vtkDataSet*)(cube->GetOutput()));
But I don't know which value I have to give and to what.
In fact my problem is that I want to "cut" some cubes with planes and
then I'd like to retrieve the parts of the cubes that have been cut to
perform some boolean operations on them with others volumes.
So I try to use vtkClipPolyData and vtkCutter, with a vtkCubeSource and
a vtkPlane as ClipFunction, but the first one returned a part of the
cube which was not closed (mainly a kind of pyramid without its base)
while the second one returns me exactly the part of the cube that is
missing to close (i.e. the part of the plane which was contained in the
original cube).
I don't know which technique I should use but the one based on the
ImplicitBoolean seems to work but produces volumes with ragged edges,
many polygons and seems CPU consuming while the technique based on
Clipping or cutting seems fast and produces simple (in terms of
polygons) meshes but that are opened.
If someone could enlighten me on the use of those techniques, I'd thank
him (her) a lot!
Thanks in advance
Jim
Le lun 11/10/2004 à 23:00, Goodwin Lawlor a écrit :
> Hi Jim,
>
> > ERROR: In /home/jim/VTK/VTK/Filtering/vtkImplicitDataSet.cxx, line 78
> > vtkImplicitDataSet (0x829ae88): Can't evaluate dataset!
>
> This filter needs the input to have a set a scalars, presumably representing
> a distance function.
>
>
> > But if I don't try to display the actor, I
> > don't get any error (which may be normal since I don't yet fully
> > understand how VTK works).
>
> That's because the pipeline hasn't been asked to execute by the renderer.
>
> I had another look at the first method you tried using vtkPlanes... There is
> some unusual behavior here that I dont have time to go through but you can
> play with this code... contour values of -0.75 work but values >-0.75 crash
> the contour filter. Looking at the input data to the contour as an image is
> looks like vtkPlanes has trouble evaluating the function where it is
> equidistant from 3 planes. I am not sure you had the point values correct
> either:
>
> package require vtk
>
> vtkPoints points
> points SetNumberOfPoints 6
> points SetPoint 0 1 0 0
> points SetPoint 1 -1 0 0
> points SetPoint 2 0 1 0
> points SetPoint 3 0 -1 0
> points SetPoint 4 0 0 1
> points SetPoint 5 0 0 -1
> vtkFloatArray norms
> norms SetNumberOfComponents 3
> norms SetNumberOfTuples 6
> norms SetTuple3 0 1 0 0
> norms SetTuple3 1 -1 0 0
> norms SetTuple3 2 0 1 0
> norms SetTuple3 3 0 -1 0
> norms SetTuple3 4 0 0 1
> norms SetTuple3 5 0 0 -1
>
> vtkPlanes planes
> planes SetPoints points
> planes SetNormals norms
>
> vtkSampleFunction sample
> sample SetImplicitFunction planes
> sample SetModelBounds 2 -2 2 -2 2 -2
> sample SetSampleDimensions 40 40 40
> sample Update
>
> vtkImageViewer viewer
> viewer SetInput [sample GetOutput]
> viewer SetColorWindow 2
> viewer SetColorLevel 0
> viewer SetZSlice 2
> viewer Render
>
> scale .s -command cb
> pack .s
>
> proc cb {var} {
> viewer SetZSlice $var
> viewer Render
> }
>
> vtkContourFilter contour
> contour SetInput [sample GetOutput]
> contour SetValue 0 -0.75
> vtkPolyDataMapper mapper
> mapper SetInput [contour GetOutput]
> vtkActor actor
> actor SetMapper mapper
> [actor GetProperty] SetRepresentationToWireframe
> vtkRenderer ren
> ren AddActor actor
> vtkRenderWindow renwin
> renwin AddRenderer ren
> vtkRenderWindowInteractor iren
> iren SetRenderWindow renwin
> iren AddObserver UserEvent {console show}
> iren Initialize
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list