[vtkusers] radii of vtkCylinder and vtkCylinderSource are unequal?

David Gobbi david.gobbi at gmail.com
Wed Dec 7 15:26:42 EST 2011


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() );



More information about the vtkusers mailing list