<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 <david.gobbi@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> Maarten Beek <beekmaarten@yahoo.com>
<br><b><span style="font-weight: bold;">Cc:</span></b> "vtkusers@vtk.org" <vtkusers@vtk.org> <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->TransformPoints(oldpoints, newpoints);<br><br>- David<br><br><br>On Thu, Dec 15, 2011 at 11:40 AM, Maarten Beek <<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br>> Hi David, others,<br>><br>> I used the vtkButterflySubdivisionFilter class, which generated a much<br>> better result. However it also introduced an error (?), but it proved it
was<br>> an accuracy issue and not my mistake.<br>><br>> Therefore, I created my own source which is working well.<br>> I now want to implement an optional transformation to put the model anywhere<br>> I want.<br>><br>> So far I coded it like:<br>><br>> vtkPolyData* output = vtkPolyData::SafeDownCast(<br>> outInfo->Get(vtkDataObject::DATA_OBJECT));<br>><br>> < snip ><br>><br>> output->SetPoints( pts );<br>> output->SetPolys( tris );<br>><br>> if ( this->Transform )<br>> {<br>> vtkSmartPointer<vtkTransformPolyDataFilter> transformer =<br>> vtkTransformPolyDataFilter::New();<br>> transformer->SetInput( output );<br>> transformer->SetTransform( this->Transform );<br>> transformer->Update();<br>><br>> transformer->SetInput( 0 ); // to disconnect input
?<br>> output = transformer->GetOutput();<br>> }<br>><br>> In other words I try to pass the data from input to output to avoid<br>> temporarily copies of the data. (ITK has the DisconnectPipeline function for<br>> this). The code above however is not working.<br>><br>> The following code does work, however it uses this temporarily copy I try to<br>> avoid:<br>><br>> if ( this->Transform )<br>> {<br>> vtkSmartPointer<vtkPolyData> temp = vtkPolyData::New();<br>> temp->ShallowCopy( output );<br>><br>> vtkSmartPointer<vtkTransformPolyDataFilter> transformer =<br>> vtkTransformPolyDataFilter::New();<br>> transformer->SetInput( temp);<br>> transformer->SetTransform( this->Transform );<br>> transformer->Update();<br>><br>>
output->ShallowCopy( transformer->GetOutput() ); // Why is this shallow<br>> copy required?<br>> }<br>><br>> Any suggestions?<br>><br>> Maarten<br>><br>> ________________________________<br>> From: David Gobbi <<a ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>> To: Maarten Beek <<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br>> Cc: "<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" <<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>> Sent: Wednesday, December 7, 2011 5:03:12 PM<br>><br>> Subject: Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are<br>> unequal?<br>><br>> Hi Maarten,<br>><br>> VTK has lots of subdivision filters in the "Graphics"
directory. I would<br>> not advise<br>> trying to change the way VTK does clipping.<br>><br>> Writing your own source is a good idea. After you have done it once, it is<br>> easy<br>> to do over and over again for whatever shape you need. I have my own set of<br>> special-purpose polydata sources and haven't used the ones that come with<br>> VTK in ages.<br>><br>> - David<br>><br>><br>> On Wed, Dec 7, 2011 at 2:33 PM, Maarten Beek <<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br>><br>> Thanks David,<br>><br>> Good to know it is an approximating issue, and not me.<br>><br>> However, I don't really know where the plane is. Although I could calculate<br>> it, but then I could position the vertices and triangulate between them<br>> myself (no need for the vtkClipPolyData class...).<br>><br>> I
guess improving the clipping would involve vtkGenericCell::Clip().<br>><br>> Also, I made a simple application in which I can change the length of the<br>> cone relative to the radius of the cylinder; I don't see the clipping<br>> improve when I do this... so I am not yet convinced regarding your rule.<br>><br>> Does VTK have a class that triangulates the triangles in a vtkPolyData? The<br>> cone resolution just makes the triangles narrower or wider (they keep going<br>> from bottom to top).<br>><br>> I think that creating my own ConeCylinderSource class is easiest...<br>><br>> Maarten<br>><br>> ________________________________<br>> From: David Gobbi <<a ymailto="mailto:david.gobbi@gmail.com" href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>> To: Maarten Beek <<a ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>><br>> Cc:
"<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" <<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>><br>> Sent: Wednesday, December 7, 2011 3:26:42 PM<br>> Subject: Re: [vtkusers] radii of vtkCylinder and vtkCylinderSource are<br>> unequal?<br>><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 ymailto="mailto:beekmaarten@yahoo.com" href="mailto:beekmaarten@yahoo.com">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,<br>>> 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>><br>><br>><br><br><br> </div> </div> </div></body></html>