MCPcopy Create free account
hub / github.com/Kitware/VTK / CleanAndCheckSurface

Method CleanAndCheckSurface

Filters/General/vtkIntersectionPolyDataFilter.cxx:2124–2184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2122}
2123
2124void vtkIntersectionPolyDataFilter::CleanAndCheckSurface(
2125 vtkPolyData* pd, double stats[2], double tolerance)
2126{
2127 int badEdges = 0;
2128 int freeEdges = 0;
2129 vtkSmartPointer<vtkCleanPolyData> cleaner = vtkSmartPointer<vtkCleanPolyData>::New();
2130 vtkSmartPointer<vtkIntArray> bad = vtkSmartPointer<vtkIntArray>::New();
2131 vtkSmartPointer<vtkIntArray> freeedge = vtkSmartPointer<vtkIntArray>::New();
2132 vtkSmartPointer<vtkIdList> edgeneighbors = vtkSmartPointer<vtkIdList>::New();
2133
2134 // Clean the input surface
2135 cleaner->SetInputData(pd);
2136 cleaner->ToleranceIsAbsoluteOn();
2137 cleaner->SetAbsoluteTolerance(tolerance);
2138 cleaner->Update();
2139 pd->DeepCopy(cleaner->GetOutput());
2140 pd->BuildLinks();
2141
2142 // Loop through the surface and find edges with cells that have either more
2143 // than one neighbor or no neighbors. No neighbors can be okay,as this can
2144 // indicate a free edge. However, for a polydata surface, multiple neighbors
2145 // indicates a bad cell with possible intersecting facets!
2146 for (int i = 0; i < pd->GetNumberOfCells(); i++)
2147 {
2148 const vtkIdType* pts = nullptr;
2149 vtkIdType npts = 0;
2150 pd->GetCellPoints(i, npts, pts);
2151 int badcell = 0;
2152 int freeedgecell = 0;
2153 for (int j = 0; j < npts; j++)
2154 {
2155 vtkIdType p0 = pts[j];
2156 vtkIdType p1 = pts[(j + 1) % npts];
2157
2158 pd->GetCellEdgeNeighbors(i, p0, p1, edgeneighbors);
2159 if (edgeneighbors->GetNumberOfIds() > 1)
2160 {
2161 badEdges++;
2162 badcell++;
2163 }
2164 else if (edgeneighbors->GetNumberOfIds() < 1)
2165 {
2166 freeEdges++;
2167 freeedgecell++;
2168 }
2169 }
2170 bad->InsertValue(i, badcell);
2171 freeedge->InsertValue(i, freeedgecell);
2172 }
2173
2174 bad->SetName("BadTriangle");
2175 pd->GetCellData()->AddArray(bad);
2176 pd->GetCellData()->SetActiveScalars("BadTriangle");
2177
2178 freeedge->SetName("FreeEdge");
2179 pd->GetCellData()->AddArray(freeedge);
2180 pd->GetCellData()->SetActiveScalars("FreeEdge");
2181

Callers

nothing calls this directly

Calls 15

GetCellEdgeNeighborsMethod · 0.80
SetActiveScalarsMethod · 0.80
NewFunction · 0.50
SetInputDataMethod · 0.45
UpdateMethod · 0.45
DeepCopyMethod · 0.45
GetOutputMethod · 0.45
BuildLinksMethod · 0.45
GetNumberOfCellsMethod · 0.45
GetCellPointsMethod · 0.45
GetNumberOfIdsMethod · 0.45
InsertValueMethod · 0.45

Tested by

no test coverage detected