<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Hi David, others,<br></span></div><div><br><span></span></div><div><span>I used the vtkButterflySubdivisionFilter class, which generated a much better result. However it also introduced an error (?), but it proved it was an accuracy issue and not my mistake.<br></span></div><div><br><span></span></div><div><span>Therefore, I created my own source which is working well.</span></div><div><span>I now want to implement an optional transformation to put the model anywhere I want.</span></div><div><br><span></span></div><div><span>So far I coded it like:</span></div><div><br></div><div>vtkPolyData* output = vtkPolyData::SafeDownCast( outInfo-&gt;Get(vtkDataObject::DATA_OBJECT));<br></div><div><br></div><div>&lt; snip &gt;</div><div><br></div><div>output-&gt;SetPoints( pts );</div><div>output-&gt;SetPolys( tris
 );<br><span></span></div><div><span><br></span></div><div><span>if ( this-&gt;Transform )</span></div><div><span>{</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt; transformer = </span><span class="tab">vtkTransformPolyDataFilter::New();</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;SetInput( output );</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;SetTransform( </span><span>this-&gt;Transform </span><span class="tab">);</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;Update();</span></div><div><br><span class="tab"></span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;SetInput( 0 ); // to disconnect input ?</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; output = transformer-&gt;GetOutput();<br></span></div><div><span>}</span></div><div><br><span></span></div><div><span>In other words I try to pass the data
 from input to output to avoid temporarily copies of the data. (ITK has the DisconnectPipeline function for this). The code above however is not working.</span></div><div><br></div><div>The following code does work, however it uses this temporarily copy I try to avoid:</div><div><br><span></span></div><div><span>if ( this-&gt;Transform )</span></div>
<div><span>{</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; </span><span class="tab">vtkSmartPointer&lt;vtkPolyData&gt; temp = </span><span class="tab">vtkPolyData::New();</span></div><div><span class="tab">&nbsp;&nbsp;&nbsp; temp-&gt;ShallowCopy( output );</span></div><div><span class="tab"><br></span></div>
<div><span class="tab">&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkTransformPolyDataFilter&gt; transformer = </span><span class="tab">vtkTransformPolyDataFilter::New();</span></div>
<div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;SetInput( temp);</span></div>
<div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;SetTransform( </span><span>this-&gt;Transform </span><span class="tab">);</span></div>
<div><span class="tab">&nbsp;&nbsp;&nbsp; transformer-&gt;Update();</span></div><span class="tab"><br>&nbsp;&nbsp;&nbsp; output-&gt;ShallowCopy( transformer-&gt;GetOutput() ); // Why is this shallow copy required?<br>
  </span>
<div><span>}</span></div>
<div><br><span></span></div><div><span>Any suggestions?</span></div><div><br><span></span></div><div><span>Maarten<br></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> Wednesday, December 7, 2011 5:03:12 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are unequal?<br> </font> <br><meta http-equiv="x-dns-prefetch-control" content="off"><div
 id="yiv1863592324">Hi Maarten,<div><br></div><div>VTK has lots of subdivision filters in the "Graphics" directory. &nbsp;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. &nbsp;After you have done it once, it is easy</div>

<div>to do over and over again for whatever shape you need. &nbsp;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>&nbsp;- David</div>

<div><br></div><div><br><div class="yiv1863592324gmail_quote">On Wed, Dec 7, 2011 at 2:33 PM, Maarten Beek <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="yiv1863592324gmail_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="yiv1863592324HOEnZb"><font color="#888888"><br>

</font></span></span></div><span class="yiv1863592324HOEnZb"><font color="#888888"><div><br><span></span></div><div><span>Maarten</span></div></font></span><div><br></div><div class="yiv1863592324hm yiv1863592324HOEnZb">  </div><div style="font-family:times new roman, new york, times, serif;font-size:12pt;">

<div class="yiv1863592324hm yiv1863592324HOEnZb"> </div><div style="font-family:times new roman, new york, times, serif;font-size:12pt;"><div class="yiv1863592324hm yiv1863592324HOEnZb"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> David Gobbi &lt;<a rel="nofollow" ymailto="mailto:david.gobbi@gmail.com" target="_blank" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;<br>

 <b><span style="font-weight:bold;">To:</span></b> Maarten Beek &lt;<a rel="nofollow" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt; <br><b><span style="font-weight:bold;">Cc:</span></b> "<a rel="nofollow" ymailto="mailto:vtkusers@vtk.org" target="_blank" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" &lt;<a rel="nofollow" ymailto="mailto:vtkusers@vtk.org" target="_blank" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>&gt; <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="yiv1863592324h5"> <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.&nbsp; 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.&nbsp; 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 &lt;<a rel="nofollow" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>&gt; wrote:<br>

&gt; Hi all,<br>&gt;<br>&gt; See code below.<br>&gt; What I am trying to do is to connect a piece of cone to a cylinder. To do<br>&gt; this I cut the top of the cone using an implicit cylinder with the same<br>&gt; radius as real cylinder.<br>

&gt; However, the radius of the cut cone top is not equal to the radius of the<br>&gt; real cylinder.<br>&gt; What am I doing wrong?<br>&gt;<br>&gt; Does this have to do with how the clip values in the points are<br>&gt; interpolated? And should I refine the triangulation of the cone to get a<br>

&gt; better result?<br>&gt;<br>&gt; Thanks - Maarten<br>&gt;<br>&gt; vtkSmartPointer&lt;vtkConeSource&gt; startcone = vtkConeSource::New();<br>&gt; &nbsp; startcone-&gt;SetResolution( 30 );<br>&gt; &nbsp; startcone-&gt;SetHeight( this-&gt;EntryLength );<br>

&gt; &nbsp; startcone-&gt;SetRadius( this-&gt;EntryRadius );<br>&gt; &nbsp;
 startcone-&gt;SetCenter( 0.0, -0.5*this-&gt;Length + 0.5*this-&gt;EntryLength, 0.0<br>&gt; );<br>&gt; &nbsp; startcone-&gt;SetDirection( 0.0, 1.0, 0.0 );<br>&gt; &nbsp; startcone-&gt;CappingOff();<br>&gt;<br>&gt; &nbsp; vtkSmartPointer&lt;vtkCylinderSource&gt; cylinder = vtkCylinderSource::New();<br>

&gt; &nbsp; cylinder-&gt;SetResolution( 30 );<br>&gt; &nbsp; cylinder-&gt;SetRadius( this-&gt;CylinderRadius );<br>&gt; &nbsp; cylinder-&gt;SetHeight( this-&gt;Length );<br>&gt; &nbsp; cylinder-&gt;SetCenter( 0.0, 0.0, 0.0 );<br>&gt; &nbsp; cylinder-&gt;CappingOff();<br>

&gt;<br>&gt; &nbsp; vtkSmartPointer&lt;vtkCylinder&gt; cyl = vtkCylinder::New();<br>&gt; &nbsp; cyl-&gt;SetRadius( this-&gt;CylinderRadius );<br>&gt; &nbsp; cyl-&gt;SetCenter( 0.0, 0.5*this-&gt;Length, 0.0 );<br>&gt;<br>&gt; &nbsp; vtkSmartPointer&lt;vtkClipPolyData&gt; clipper1 = vtkClipPolyData::New();<br>

&gt; &nbsp; clipper1-&gt;SetClipFunction( cyl );<br>&gt; &nbsp;
 clipper1-&gt;SetInputConnection( startcone-&gt;GetOutputPort() );<br>&gt;<br>&gt; &nbsp; vtkSmartPointer&lt;vtkAppendPolyData&gt; append = vtkAppendPolyData::New();<br>&gt; &nbsp; append-&gt;AddInput( clipper1-&gt;GetOutput() );<br>

&gt; &nbsp; append-&gt;AddInput( cylinder-&gt;GetOutput() );<br><br><br> </div></div></div> </div>  </div></div></blockquote></div><br></div>
</div><meta http-equiv="x-dns-prefetch-control" content="on"><br><br> </div> </div>  </div></body></html>