[vtkusers] strange problem while creating a binary mask

David Gobbi dgobbi at atamai.com
Tue Oct 31 11:01:25 EST 2006


Hi Anja,

There is vtkReverseSense for reversing the polygon orientation.

If the polydata forms a convex surface, it is easy to check whether you 
need to reverse:

1) average the points to find a center point inside the polydata
2) find the first point of the first cell
3) find the vector from this point to the center point
4) use vtkPolygon::ComputeNormal() to find the normal of the cell
5) if the dot product of the normal and the vector is positive, the cell 
is reversed

 - David


Anja Ende wrote:
> Hi guys,
>
> I has completely missed this point. I thought the fact that the 
> polygon being closed is the only requirement.
>
> Is there a filter in VTK that will order a given set of points in the 
> given direction?
>
> Cheers and thanks,
> Anja
>
> On 31/10/06, *David Gobbi* <dgobbi at atamai.com 
> <mailto:dgobbi at atamai.com>> wrote:
>
>     Hi Anja,
>
>     The vtkPolyDataToImageStencil calculates the normal of each polygon to
>     find out which face of the polygon is the front (the "outside") and
>     which is the back (the "inside").  The calculation of the normal
>     depends
>     on the ordering of the points.
>
>     You are extruding a polyline to create the the polydata, right?
>     Unfortunately, I don't whether the the front/back orientation of the
>     polygons depends on the ordering of points in the original
>     polyline...
>     Dean might have more experience here.
>
>     When you apply the stencil, most classes that have a SetStencil()
>     method
>     also have a ReverseStencilOn() method to set whether you want to
>     use the
>     region inside the stencil or the region outside the stencil.
>
>     - David
>
>
>     Anja Ende wrote:
>     > Ok, I have clearly missed this part!!!
>     >
>     > So, the points have to be ordered in a counter clockwise fashion???
>     > Why is that???
>     >
>     > Cheers,
>     > Anja
>     >
>     > On 30/10/06, * Dean Inglis* <dean.inglis at sympatico.ca
>     <mailto:dean.inglis at sympatico.ca>
>     > <mailto:dean.inglis at sympatico.ca
>     <mailto:dean.inglis at sympatico.ca> >> wrote:
>     >
>     >     Hi Anja,
>     >
>     >     is your polydata always defined such
>     >     that the points forming a closed loop are
>     >     ordered counter-clockwise or equivalently,
>     >     always clockwise and the vtkImageStencil set
>     >     accordingly?
>     >
>     >     Dean
>     >
>     >
>     >
>     >
>     >
>     > --
>     > Cheers,
>     >
>     > Anja
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > This is the private VTK discussion list.
>     > Please keep messages on-topic. Check the FAQ at:
>     http://www.vtk.org/Wiki/VTK_FAQ <http://www.vtk.org/Wiki/VTK_FAQ>
>     > Follow this link to subscribe/unsubscribe:
>     > http://www.vtk.org/mailman/listinfo/vtkusers
>     >
>
>
>
>
> -- 
> Cheers,
>
> Anja 




More information about the vtkusers mailing list