<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Very good suggestion, David!</span></div><div><br><span></span></div><div><span>But how would I code an optional step for which one does need a filter class (i.e. smoothing, normals)?</span></div><div><span>I am browsing through the vtk code, because I would assume this has been done before, but I have been unlucky so far.</span></div><div><br><span></span></div><div><span>Maarten</span></div><div><br></div>  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> David Gobbi &lt;david.gobbi@gmail.com&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Maarten Beek &lt;beekmaarten@yahoo.com&gt;
 <br><b><span style="font-weight: bold;">Cc:</span></b> "vtkusers@vtk.org" &lt;vtkusers@vtk.org&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, December 15, 2011 9:51:17 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are unequal?<br> </font> <br>Hi Maarten,<br><br>Instead of vtkTransformPolyData, a better method might be to use the<br>TransformPoints method of vtkTransform:<br><br>vtkPoints *newpoints = vtkPoints::New();<br>transform-&gt;TransformPoints(oldpoints, newpoints);<br><br>- David<br><br><br>On Thu, Dec 15, 2011 at 11:40 AM, Maarten Beek &lt;<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt; wrote:<br>&gt; Hi David, others,<br>&gt;<br>&gt; I used the vtkButterflySubdivisionFilter class, which generated a much<br>&gt; better result. However it also introduced an error (?), but it proved it
 was<br>&gt; an accuracy issue and not my mistake.<br>&gt;<br>&gt; Therefore, I created my own source which is working well.<br>&gt; I now want to implement an optional transformation to put the model anywhere<br>&gt; I want.<br>&gt;<br>&gt; So far I coded it like:<br>&gt;<br>&gt; vtkPolyData* output = vtkPolyData::SafeDownCast(<br>&gt; outInfo-&gt;Get(vtkDataObject::DATA_OBJECT));<br>&gt;<br>&gt; &lt; snip &gt;<br>&gt;<br>&gt; output-&gt;SetPoints( pts );<br>&gt; output-&gt;SetPolys( tris );<br>&gt;<br>&gt; if ( this-&gt;Transform )<br>&gt; {<br>&gt; &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt; transformer =<br>&gt; vtkTransformPolyDataFilter::New();<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;SetInput( output );<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;SetTransform( this-&gt;Transform );<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;Update();<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;SetInput( 0 ); // to disconnect input
 ?<br>&gt; &nbsp;&nbsp;&nbsp; output = transformer-&gt;GetOutput();<br>&gt; }<br>&gt;<br>&gt; In other words I try to pass the data from input to output to avoid<br>&gt; temporarily copies of the data. (ITK has the DisconnectPipeline function for<br>&gt; this). The code above however is not working.<br>&gt;<br>&gt; The following code does work, however it uses this temporarily copy I try to<br>&gt; avoid:<br>&gt;<br>&gt; if ( this-&gt;Transform )<br>&gt; {<br>&gt; &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkPolyData&gt; temp = vtkPolyData::New();<br>&gt; &nbsp;&nbsp;&nbsp; temp-&gt;ShallowCopy( output );<br>&gt;<br>&gt; &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt; transformer =<br>&gt; vtkTransformPolyDataFilter::New();<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;SetInput( temp);<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;SetTransform( this-&gt;Transform );<br>&gt; &nbsp;&nbsp;&nbsp; transformer-&gt;Update();<br>&gt;<br>&gt;
 &nbsp;&nbsp;&nbsp; output-&gt;ShallowCopy( transformer-&gt;GetOutput() ); // Why is this shallow<br>&gt; copy required?<br>&gt; }<br>&gt;<br>&gt; Any suggestions?<br>&gt;<br>&gt; Maarten<br>&gt;<br>&gt; ________________________________<br>&gt; From: David Gobbi &lt;<a ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;<br>&gt; To: Maarten Beek &lt;<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt;<br>&gt; Cc: "<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" &lt;<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>&gt;<br>&gt; Sent: Wednesday, December 7, 2011 5:03:12 PM<br>&gt;<br>&gt; Subject: Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are<br>&gt; unequal?<br>&gt;<br>&gt; Hi Maarten,<br>&gt;<br>&gt; VTK has lots of subdivision filters in the "Graphics"
 directory. &nbsp;I would<br>&gt; not advise<br>&gt; trying to change the way VTK does clipping.<br>&gt;<br>&gt; Writing your own source is a good idea. &nbsp;After you have done it once, it is<br>&gt; easy<br>&gt; to do over and over again for whatever shape you need. &nbsp;I have my own set of<br>&gt; special-purpose polydata sources and haven't used the ones that come with<br>&gt; VTK in ages.<br>&gt;<br>&gt; &nbsp;- David<br>&gt;<br>&gt;<br>&gt; On Wed, Dec 7, 2011 at 2:33 PM, Maarten Beek &lt;<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt; wrote:<br>&gt;<br>&gt; Thanks David,<br>&gt;<br>&gt; Good to know it is an approximating issue, and not me.<br>&gt;<br>&gt; However, I don't really know where the plane is. Although I could calculate<br>&gt; it, but then I could position the vertices and triangulate between them<br>&gt; myself (no need for the vtkClipPolyData class...).<br>&gt;<br>&gt; I
 guess improving the clipping would involve vtkGenericCell::Clip().<br>&gt;<br>&gt; Also, I made a simple application in which I can change the length of the<br>&gt; cone relative to the radius of the cylinder; I don't see the clipping<br>&gt; improve when I do this... so I am not yet convinced regarding your rule.<br>&gt;<br>&gt; Does VTK have a class that triangulates the triangles in a vtkPolyData? The<br>&gt; cone resolution just makes the triangles narrower or wider (they keep going<br>&gt; from bottom to top).<br>&gt;<br>&gt; I think that creating my own ConeCylinderSource class is easiest...<br>&gt;<br>&gt; Maarten<br>&gt;<br>&gt; ________________________________<br>&gt; From: David Gobbi &lt;<a ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;<br>&gt; To: Maarten Beek &lt;<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt;<br>&gt; Cc:
 "<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" &lt;<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>&gt;<br>&gt; Sent: Wednesday, December 7, 2011 3:26:42 PM<br>&gt; Subject: Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are<br>&gt; unequal?<br>&gt;<br>&gt; Refining the cone resolution will help, but if you can, you should use<br>&gt; a plane to clip the cone, instead of using a cylinder.<br>&gt;<br>&gt; VTK does clipping by evaluating the implicit function at each end of<br>&gt; each line segment, and then it does a linear interpolation along the<br>&gt; line segment to find the point where it does the clip.&nbsp; This works<br>&gt; perfectly when the function is a plane function, but it is only<br>&gt; approximate if the function is a curved surface.<br>&gt;<br>&gt; The rule is: the lengths of the polygon edges must be much less then<br>&gt; the radius of
 curvature of the implicit function.&nbsp; A plane has an<br>&gt; infinite radius of curvature, so clipping with a plane is always<br>&gt; ideal.<br>&gt;<br>&gt; - David<br>&gt;<br>&gt;<br>&gt; On Wed, Dec 7, 2011 at 12:46 PM, Maarten Beek &lt;<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt; wrote:<br>&gt;&gt; Hi all,<br>&gt;&gt;<br>&gt;&gt; See code below.<br>&gt;&gt; What I am trying to do is to connect a piece of cone to a cylinder. To do<br>&gt;&gt; this I cut the top of the cone using an implicit cylinder with the same<br>&gt;&gt; radius as real cylinder.<br>&gt;&gt; However, the radius of the cut cone top is not equal to the radius of the<br>&gt;&gt; real cylinder.<br>&gt;&gt; What am I doing wrong?<br>&gt;&gt;<br>&gt;&gt; Does this have to do with how the clip values in the points are<br>&gt;&gt; interpolated? And should I refine the triangulation of the cone to get a<br>&gt;&gt; better
 result?<br>&gt;&gt;<br>&gt;&gt; Thanks - Maarten<br>&gt;&gt;<br>&gt;&gt; vtkSmartPointer&lt;vtkConeSource&gt; startcone = vtkConeSource::New();<br>&gt;&gt; &nbsp; startcone-&gt;SetResolution( 30 );<br>&gt;&gt; &nbsp; startcone-&gt;SetHeight( this-&gt;EntryLength );<br>&gt;&gt; &nbsp; startcone-&gt;SetRadius( this-&gt;EntryRadius );<br>&gt;&gt; &nbsp; startcone-&gt;SetCenter( 0.0, -0.5*this-&gt;Length + 0.5*this-&gt;EntryLength,<br>&gt;&gt; 0.0<br>&gt;&gt; );<br>&gt;&gt; &nbsp; startcone-&gt;SetDirection( 0.0, 1.0, 0.0 );<br>&gt;&gt; &nbsp; startcone-&gt;CappingOff();<br>&gt;&gt;<br>&gt;&gt; &nbsp; vtkSmartPointer&lt;vtkCylinderSource&gt; cylinder = vtkCylinderSource::New();<br>&gt;&gt; &nbsp; cylinder-&gt;SetResolution( 30 );<br>&gt;&gt; &nbsp; cylinder-&gt;SetRadius( this-&gt;CylinderRadius );<br>&gt;&gt; &nbsp; cylinder-&gt;SetHeight( this-&gt;Length );<br>&gt;&gt; &nbsp; cylinder-&gt;SetCenter( 0.0, 0.0, 0.0 );<br>&gt;&gt; &nbsp;
 cylinder-&gt;CappingOff();<br>&gt;&gt;<br>&gt;&gt; &nbsp; vtkSmartPointer&lt;vtkCylinder&gt; cyl = vtkCylinder::New();<br>&gt;&gt; &nbsp; cyl-&gt;SetRadius( this-&gt;CylinderRadius );<br>&gt;&gt; &nbsp; cyl-&gt;SetCenter( 0.0, 0.5*this-&gt;Length, 0.0 );<br>&gt;&gt;<br>&gt;&gt; &nbsp; vtkSmartPointer&lt;vtkClipPolyData&gt; clipper1 = vtkClipPolyData::New();<br>&gt;&gt; &nbsp; clipper1-&gt;SetClipFunction( cyl );<br>&gt;&gt; &nbsp; clipper1-&gt;SetInputConnection( startcone-&gt;GetOutputPort() );<br>&gt;&gt;<br>&gt;&gt; &nbsp; vtkSmartPointer&lt;vtkAppendPolyData&gt; append = vtkAppendPolyData::New();<br>&gt;&gt; &nbsp; append-&gt;AddInput( clipper1-&gt;GetOutput() );<br>&gt;&gt; &nbsp; append-&gt;AddInput( cylinder-&gt;GetOutput() );<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br><br><br> </div> </div>  </div></body></html>