Hi Maarten,<div><br></div><div>VTK has lots of subdivision filters in the "Graphics" directory. I would not advise</div><div>trying to change the way VTK does clipping.</div><div><br></div><div>Writing your own source is a good idea. After you have done it once, it is easy</div>
<div>to do over and over again for whatever shape you need. I have my own set of</div><div>special-purpose polydata sources and haven't used the ones that come with</div><div>VTK in ages.</div><div><br></div><div> - David</div>
<div><br></div><div><br><div class="gmail_quote">On Wed, Dec 7, 2011 at 2:33 PM, Maarten Beek <span dir="ltr"><<a href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div style="color:#000;background-color:#fff;font-family:times new roman,new york,times,serif;font-size:12pt"><div><span>Thanks David,</span></div><div><br><span></span></div><div><span>Good to know it is an approximating issue, and not me.</span></div>
<div><br><span></span></div><div><span>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...).</span></div>
<div><br><span></span></div><div><span>I guess improving the clipping would involve vtkGenericCell::Clip().</span></div><div><br><span></span></div><div><span>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.</span></div>
<div><br><span></span></div><div><span>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).</span></div><div><br><span></span></div><div><span>I think that creating my own ConeCylinderSource class is easiest...<span class="HOEnZb"><font color="#888888"><br>
</font></span></span></div><span class="HOEnZb"><font color="#888888"><div><br><span></span></div><div><span>Maarten</span></div></font></span><div><br></div><div class="hm HOEnZb"> </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt">
<div class="hm HOEnZb"> </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div class="hm HOEnZb"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold">From:</span></b> David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
<b><span style="font-weight:bold">To:</span></b> Maarten Beek <<a href="mailto:beekmaarten@yahoo.com" target="_blank">beekmaarten@yahoo.com</a>> <br><b><span style="font-weight:bold">Cc:</span></b> "<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>" <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>> <br>
<b><span style="font-weight:bold">Sent:</span></b> Wednesday, December 7, 2011 3:26:42 PM<br>
<b><span style="font-weight:bold">Subject:</span></b> Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are unequal?<br> </font></div><div><div class="h5"> <br>Refining the cone resolution will help, but if you can, you should use<br>
a plane to clip the cone, instead of using a cylinder.<br><br>VTK does clipping by evaluating the implicit function at each end of<br>each line segment, and then it does a linear interpolation along the<br>line segment to find the point where it does the clip. This works<br>
perfectly when the function is a plane function, but it is only<br>approximate if the function is a curved surface.<br><br>The rule is: the lengths of the polygon edges must be much less then<br>the radius of curvature of the implicit function. A plane has an<br>
infinite radius of curvature, so clipping with a plane is always<br>ideal.<br><br> - David<br><br><br>On Wed, Dec 7, 2011 at 12:46 PM, Maarten Beek <<a href="mailto:beekmaarten@yahoo.com" target="_blank">beekmaarten@yahoo.com</a>> wrote:<br>
> Hi all,<br>><br>> See code below.<br>> What I am trying to do is to connect a piece of cone to a cylinder. To do<br>> this I cut the top of the cone using an implicit cylinder with the same<br>> radius as real cylinder.<br>
> However, the radius of the cut cone top is not equal to the radius of the<br>> real cylinder.<br>> What am I doing wrong?<br>><br>> Does this have to do with how the clip values in the points are<br>> interpolated? And should I refine the triangulation of the cone to get a<br>
> better result?<br>><br>> Thanks - Maarten<br>><br>> vtkSmartPointer<vtkConeSource> startcone = vtkConeSource::New();<br>> startcone->SetResolution( 30 );<br>> startcone->SetHeight( this->EntryLength );<br>
> startcone->SetRadius( this->EntryRadius );<br>>
startcone->SetCenter( 0.0, -0.5*this->Length + 0.5*this->EntryLength, 0.0<br>> );<br>> startcone->SetDirection( 0.0, 1.0, 0.0 );<br>> startcone->CappingOff();<br>><br>> vtkSmartPointer<vtkCylinderSource> cylinder = vtkCylinderSource::New();<br>
> cylinder->SetResolution( 30 );<br>> cylinder->SetRadius( this->CylinderRadius );<br>> cylinder->SetHeight( this->Length );<br>> cylinder->SetCenter( 0.0, 0.0, 0.0 );<br>> cylinder->CappingOff();<br>
><br>> vtkSmartPointer<vtkCylinder> cyl = vtkCylinder::New();<br>> cyl->SetRadius( this->CylinderRadius );<br>> cyl->SetCenter( 0.0, 0.5*this->Length, 0.0 );<br>><br>> vtkSmartPointer<vtkClipPolyData> clipper1 = vtkClipPolyData::New();<br>
> clipper1->SetClipFunction( cyl );<br>>
clipper1->SetInputConnection( startcone->GetOutputPort() );<br>><br>> vtkSmartPointer<vtkAppendPolyData> append = vtkAppendPolyData::New();<br>> append->AddInput( clipper1->GetOutput() );<br>
> append->AddInput( cylinder->GetOutput() );<br><br><br> </div></div></div> </div> </div></div></blockquote></div><br></div>