[vtkusers] VTKCenterOfMass does not generate the correct center of VTKPolyDataConnectivityFilter output data

Bill Lorensen bill.lorensen at gmail.com
Tue Apr 21 07:59:52 EDT 2015


I believe that PolyDataConnectivity retains all of its points on
output. CenterOfMass operates on points.

Run CleanPolyDataFilter before running CenterOfMass…


On Mon, Apr 20, 2015 at 10:31 PM, WANGMengjiao
<wangmengjiao at tsinghua.org.cn> wrote:
> Dear All
>   I have encountered a weird problem using VTKPolyDataConnectivityFilter. I
> had a polydata consists of two seperated parts. And I use the
> VTKPolyDataConnectivityFilter to extract the largest region. The code is as
> following:
>      // Extract the feature edges
>      vtkSmartPointer<vtkFeatureEdges> boundaryEdges =
> vtkSmartPointer<vtkFeatureEdges>::New();
> boundaryEdges->SetInputConnection(clipper->GetOutputPort());
>      boundaryEdges->BoundaryEdgesOn();
>      boundaryEdges->FeatureEdgesOff();
>      boundaryEdges->NonManifoldEdgesOff();
>      boundaryEdges->ManifoldEdgesOff();
>      // Converted the boundaryEdges to boundaryStrips
>      vtkSmartPointer<vtkStripper> boundaryStrips =
> vtkSmartPointer<vtkStripper>::New();
> boundaryStrips->SetInputConnection(boundaryEdges->GetOutputPort());
>      boundaryStrips->Update();
>      // Extract the largest region
>      vtkSmartPointer<vtkPolyDataConnectivityFilter> boundaryFilter =
> vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
> boundaryFilter->SetInputConnection(boundaryStrips->GetOutputPort());
>      boundaryFilter->SetExtractionModeToLargestRegion();
>   I used a mapper and actor to visualize the extracted largest region, and
> the result is correct. However, when I tried to compute the center of the
> extracted largest region, the computed center is the same with the center of
> unfiltered poly data (i.e. the poly data consisting of two seperated parts).
> The usage of VTKCenterOfMass is as following:
>      // Compute the center of extracted largest region
>      vtkSmartPointer<vtkCenterOfMass> centerOfMassFilter =
> vtkSmartPointer<vtkCenterOfMass>::New();
> centerOfMassFilter->SetInputConnection(boundaryFilter->GetOutputPort());
>      centerOfMassFilter->Update();
>      double centerOfMass[3];
>      centerOfMassFilter->GetCenter(centerOfMass);
>   Does anyone can help me out? Where I did it wrong?
>   Many Thanks!
>   John
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the vtkusers mailing list