[vtkusers] vtkCutClosedSurface

sebastian ordas sebastian.ordas at gmail.com
Mon Oct 10 15:02:11 EDT 2011


Hello David,

that made the trick!

here´s how the code would look like:

( ...)

   vtkSmartPointer<vtkPlaneCollection> capPlanes = 
vtkSmartPointer<vtkPlaneCollection>::New();
    capPlanes->AddItem( planeCallback->m_Plane );

    vtkSmartPointer<vtkClipClosedSurface> clipper = 
vtkSmartPointer<vtkClipClosedSurface>::New();
    clipper->SetInputConnection(cleanPolyDataFilter->GetOutputPort());
    clipper->GenerateOutlineOff();
    clipper->GenerateFacesOn();
    clipper->SetClippingPlanes (capPlanes);
    clipper->SetActivePlaneId(0);
    clipper->SetScalarModeToLabels();

    vtkSmartPointer<vtkThreshold> thresholdFilter = 
vtkSmartPointer<vtkThreshold>::New();
    thresholdFilter->SetInputConnection( clipper->GetOutputPort() );
    thresholdFilter->ThresholdByUpper( 1 );
    thresholdFilter->SetInputArrayToProcess(0, 0, 0,
                                    vtkDataObject::FIELD_ASSOCIATION_CELLS,
                                    vtkDataSetAttributes::SCALARS);

    vtkSmartPointer<vtkDataSetSurfaceFilter> extractorFilter = 
vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    extractorFilter->SetInputConnection( 
thresholdFilter->GetOutputPort() );

    vtkSmartPointer<vtkPolyDataMapper> meshedOutlineMapper = 
vtkSmartPointer<vtkPolyDataMapper>::New();
    
meshedOutlineMapper->SetInputConnection(extractorFilter->GetOutputPort());

(...)

thank you,
sebastian

On 10/10/2011 3:26 PM, David Gobbi wrote:
> Hi Sebastien,
>
> Yes, you can use vtkThreshold _after_ using vtkClipClosedSurface.  Use
> SetScalarModeToLabels() on vtkClipLosedSurface, and make sure that you
> threshold the cell scalars (not point scalars).  The cell scalars of
> the cut faces will be set to 1 or higher.
>
>   - David
>
>
> On Mon, Oct 10, 2011 at 6:25 AM, sebastian ordas
> <sebastian.ordas at gmail.com>  wrote:
>> Hello David,
>>
>> vtkClipClosedSurface does exactly what I need
>>
>> http://ScrnSht.com/jyutyz
>> http://ScrnSht.com/kwanbu
>>
>> except that I need the yellow triangulation only ...
>>
>> What would you advice? adding to vtkClipClosedSurface the possibility of
>> getting the "yellow cap" only or writing a vtkCutClosedSurface filter class
>> for that single operation?
>>
>> btw, isn't it possible to pipeline vtkThreshold to vtkClipClosedSurface
>> somehow?
>>
>> thank you,
>> sebastian
>>
>> On 10/07/2011 03:20 PM, David Gobbi wrote:
>>> I can't remember the details of how to apply constraints with
>>> vtkDelaunay2D, but it definitely can be done.
>>>
>>>   - David
>>>
>>>
>>> On Fri, Oct 7, 2011 at 10:35 AM, sebastian ordas
>>> <sebastian.ordas at gmail.com>    wrote:
>>>> Hi David,
>>>>
>>>> sorry, my mistake
>>>> I had a copy and paste typo in one of my actors:
>>>> actor->SetScale(1.01,1.01,1.01);
>>>>
>>>> I tested vtkDelaunay2D. It looks pretty stable but I would like to avoid
>>>> meshing the holes and outside the contour:
>>>> http://ScrnSht.com/grcbwa
>>>>
>>>> For the former, I guess I need to use "SetSourceConnection" right?
>>>> But how to avoid the latter?
>>>>
>>>> best regards,
>>>> sebastian
>>>>
>>>>
>>>> On 10/7/2011 12:00 PM, David Gobbi wrote:
>>>>> Hi Sebastian,
>>>>>
>>>>> The filter does not move any points in the mesh (it just adds/removes
>>>>> points).  Check the transform matrices for your actors, from the
>>>>> picture it looks more like a scale difference than a shift but it is
>>>>> hard to tell.
>>>>>
>>>>>   - David
>>>>>
>>>>>
>>>>> On Fri, Oct 7, 2011 at 7:42 AM, sebastian ordas
>>>>> <sebastian.ordas at gmail.com>      wrote:
>>>>>> Thank you David!
>>>>>>
>>>>>> btw, using vtkClipClosedSurface, I´m getting a small shift between the
>>>>>> original mesh and the closed clipped surface
>>>>>> http://ScrnSht.com/byxsiw
>>>>>>
>>>>>> Is that a visualization issue only?
>>>>>>
>>>>>> regards,
>>>>>> sebastian
>>>>>>
>>>>>>
>>>>>> On 10/7/2011 3:06 AM, David Gobbi wrote:
>>>>>>> On Thu, Oct 6, 2011 at 4:06 PM, sebastian ordas
>>>>>>> <sebastian.ordas at gmail.com>        wrote:
>>>>>>>> Dear VTK developers,
>>>>>>>>
>>>>>>>> Following the explanation in
>>>>>>>> http://www.vtk.org/Wiki/VTK/Closed_Surface_Clipping
>>>>>>>> I was wondering about the current development state of the
>>>>>>>> vtkCutClosedSurface class or a similar one.
>>>>>>> It has not been written.  Eventually I might need it, and when I do,
>>>>>>> I'll write it... but that could be in a few months, a few years, or
>>>>>>> never.
>>>>>>>
>>>>>>>> I´m basically needing the meshing of a contour, possibly with holes,
>>>>>>>> but
>>>>>>>> always closed.
>>>>>>> You can use vtkDelaunay2D for that, but be warned that some inputs
>>>>>>> will cause vtkDelaunay2D to segfault (it is rare, but it does happen
>>>>>>> occasionally).
>>>>>>>
>>>>>>>> I found this interesting:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
>>>>>>> That method is very similar to the one that vtkClipClosedSurface uses.
>>>>>>> It is messy but it is robust.  The fastest triangulation methods are
>>>>>>> randomized Delaunay methods, but they are very sensitive to roundoff
>>>>>>> error, and as a result it is hard to write a robust Delaunay
>>>>>>> algorithm.
>>>>>>>
>>>>>>>> Does anyone know a workaround (has to be fast, for a real time
>>>>>>>> application)
>>>>>>>> with existing VTK classes?
>>>>>>> For now, vtkDelaunay2D is the only class for doing triangulations with
>>>>>>> holes.
>>>>>>>
>>>>>>>   - David
>>




More information about the vtkusers mailing list