+ for(vtkIdType aPntId = 0; aPntId < aNumPts; aPntId++){
+ double aPntCoord[3];
+ vtkIdType anId = GetPointId(aPntId);
+ aPoints->GetPoint(anId,aPntCoord);
+ double aDist = vtkPlane::Evaluate(aNormal,anOrigin,aPntCoord);
+ if(DEBUG_TRIA_EXECUTE) cout<<"\t\taPntId = "<<anId<<" {"<<aPntCoord[0]<<", "<<aPntCoord[1]<<", "<<aPntCoord[2]<<"}; aDist = "<<aDist<<"\n";
+ if(aDist < -aDistEps)
+ return false;
+ }
+ }
+ }
+
+
+ // To pass resulting set of the polygons to the output
+ {
+ int aNbPolygons = aPolygons.size();
+ for (int aPolygonId = 0; aPolygonId < aNbPolygons; aPolygonId++) {
+ ::TPolygon& aPolygon = aPolygons[aPolygonId];
+ if(DEBUG_TRIA_EXECUTE) cout << "PoilygonId="<<aPolygonId<<" | ";
+ TConnectivities& aConnectivities = aPolygon.myConnectivities;
+ if(DEBUG_TRIA_EXECUTE) {
+ for(size_t i=0;i<aConnectivities.size();i++)
+ cout << aConnectivities[i] << ",";
+ cout << endl;
+ }
+ int aNbPoints = aConnectivities.size();
+ vtkIdType aNewCellId = theOutput->InsertNextCell(VTK_POLYGON,aNbPoints,&aConnectivities[0]);
+ if(theStoreMapping)
+ VTKViewer_GeometryFilter::InsertId( theCellId, VTK_POLYGON, theVTK2ObjIds, theDimension2VTK2ObjIds );
+ theOutputCD->CopyData(thInputCD,theCellId,aNewCellId);
+ }
+ }
+
+ if(DEBUG_TRIA_EXECUTE) cout<<"\tTriangulator - Ok\n";
+
+ return true;
+}
+
+
+//----------------------------------------------------------------------------
+VTKViewer_OrderedTriangulator
+::VTKViewer_OrderedTriangulator():
+ myTriangulator(vtkOrderedTriangulator::New()),
+ myBoundaryTris(vtkCellArray::New()),
+ myTriangle(vtkTriangle::New())
+{
+ myBoundaryTris->Allocate(VTK_CELL_SIZE);
+ myTriangulator->PreSortedOff();
+}
+
+
+//----------------------------------------------------------------------------
+VTKViewer_OrderedTriangulator
+::~VTKViewer_OrderedTriangulator()
+{
+ myTriangle->Delete();
+ myBoundaryTris->Delete();
+ myTriangulator->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+vtkPoints*
+VTKViewer_OrderedTriangulator
+::InitPoints(vtkUnstructuredGrid *theInput,
+ vtkIdType theCellId)
+{
+ myBoundaryTris->Reset();
+
+ vtkPoints* aPoints = VTKViewer_Triangulator::InitPoints(theInput, theCellId);
+ vtkIdType aNumPts = myPoints->GetNumberOfPoints();
+ if ( aNumPts > 0 ) {
+ myTriangulator->InitTriangulation(0.0, 1.0, 0.0, 1.0, 0.0, 1.0, aNumPts);
+
+ double aBounds[6];
+ myPoints->GetBounds(aBounds);
+ double xSize, ySize, zSize;
+ xSize = aBounds[1] - aBounds[0];
+ ySize = aBounds[3] - aBounds[2];
+ zSize = aBounds[5] - aBounds[4];
+ double anAbsoluteCoord[3];
+ double aParamentrucCoord[3];
+ for (int aPntId = 0; aPntId < aNumPts; aPntId++) {
+ myPoints->GetPoint(aPntId, anAbsoluteCoord);
+ aParamentrucCoord[0] = xSize==0. ? 0. : ((anAbsoluteCoord[0] - aBounds[0]) / xSize);
+ aParamentrucCoord[1] = ySize==0. ? 0. : ((anAbsoluteCoord[1] - aBounds[2]) / ySize);
+ aParamentrucCoord[2] = zSize==0. ? 0. : ((anAbsoluteCoord[2] - aBounds[4]) / zSize);
+ myTriangulator->InsertPoint(aPntId, anAbsoluteCoord, aParamentrucCoord, 0);