[vtkusers] radii of vtkCylinder and vtkCylinderSource are unequal?

David Gobbi david.gobbi at gmail.com
Wed Dec 7 17:03:12 EST 2011


Hi Maarten,

VTK has lots of subdivision filters in the "Graphics" directory.  I would
not advise
trying to change the way VTK does clipping.

Writing your own source is a good idea.  After you have done it once, it is
easy
to do over and over again for whatever shape you need.  I have my own set of
special-purpose polydata sources and haven't used the ones that come with
VTK in ages.

 - David


On Wed, Dec 7, 2011 at 2:33 PM, Maarten Beek <beekmaarten at yahoo.com> wrote:

> Thanks David,
>
> Good to know it is an approximating issue, and not me.
>
> However, I don't really know where the plane is. Although I could
> calculate it, but then I could position the vertices and triangulate
> between them myself (no need for the vtkClipPolyData class...).
>
> I guess improving the clipping would involve vtkGenericCell::Clip().
>
> Also, I made a simple application in which I can change the length of the
> cone relative to the radius of the cylinder; I don't see the clipping
> improve when I do this... so I am not yet convinced regarding your rule.
>
> Does VTK have a class that triangulates the triangles in a vtkPolyData?
> The cone resolution just makes the triangles narrower or wider (they keep
> going from bottom to top).
>
> I think that creating my own ConeCylinderSource class is easiest...
>
> Maarten
>
>   ------------------------------
> *From:* David Gobbi <david.gobbi at gmail.com>
> *To:* Maarten Beek <beekmaarten at yahoo.com>
> *Cc:* "vtkusers at vtk.org" <vtkusers at vtk.org>
> *Sent:* Wednesday, December 7, 2011 3:26:42 PM
> *Subject:* Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are
> unequal?
>
> Refining the cone resolution will help, but if you can, you should use
> a plane to clip the cone, instead of using a cylinder.
>
> VTK does clipping by evaluating the implicit function at each end of
> each line segment, and then it does a linear interpolation along the
> line segment to find the point where it does the clip.  This works
> perfectly when the function is a plane function, but it is only
> approximate if the function is a curved surface.
>
> The rule is: the lengths of the polygon edges must be much less then
> the radius of curvature of the implicit function.  A plane has an
> infinite radius of curvature, so clipping with a plane is always
> ideal.
>
> - David
>
>
> On Wed, Dec 7, 2011 at 12:46 PM, Maarten Beek <beekmaarten at yahoo.com>
> wrote:
> > Hi all,
> >
> > See code below.
> > What I am trying to do is to connect a piece of cone to a cylinder. To do
> > this I cut the top of the cone using an implicit cylinder with the same
> > radius as real cylinder.
> > However, the radius of the cut cone top is not equal to the radius of the
> > real cylinder.
> > What am I doing wrong?
> >
> > Does this have to do with how the clip values in the points are
> > interpolated? And should I refine the triangulation of the cone to get a
> > better result?
> >
> > Thanks - Maarten
> >
> > vtkSmartPointer<vtkConeSource> startcone = vtkConeSource::New();
> >   startcone->SetResolution( 30 );
> >   startcone->SetHeight( this->EntryLength );
> >   startcone->SetRadius( this->EntryRadius );
> >   startcone->SetCenter( 0.0, -0.5*this->Length + 0.5*this->EntryLength,
> 0.0
> > );
> >   startcone->SetDirection( 0.0, 1.0, 0.0 );
> >   startcone->CappingOff();
> >
> >   vtkSmartPointer<vtkCylinderSource> cylinder = vtkCylinderSource::New();
> >   cylinder->SetResolution( 30 );
> >   cylinder->SetRadius( this->CylinderRadius );
> >   cylinder->SetHeight( this->Length );
> >   cylinder->SetCenter( 0.0, 0.0, 0.0 );
> >   cylinder->CappingOff();
> >
> >   vtkSmartPointer<vtkCylinder> cyl = vtkCylinder::New();
> >   cyl->SetRadius( this->CylinderRadius );
> >   cyl->SetCenter( 0.0, 0.5*this->Length, 0.0 );
> >
> >   vtkSmartPointer<vtkClipPolyData> clipper1 = vtkClipPolyData::New();
> >   clipper1->SetClipFunction( cyl );
> >   clipper1->SetInputConnection( startcone->GetOutputPort() );
> >
> >   vtkSmartPointer<vtkAppendPolyData> append = vtkAppendPolyData::New();
> >   append->AddInput( clipper1->GetOutput() );
> >   append->AddInput( cylinder->GetOutput() );
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111207/bad302de/attachment.htm>


More information about the vtkusers mailing list