+}
+
+
+void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId,
+ vtkUnstructuredGrid* input,
+ vtkPolyData *output,
+ TMapOfVectorId& theDimension2VTK2ObjIds,
+ bool triangulate)
+{
+ vtkIdType aCellType = VTK_POLYGON;
+ vtkIdType *aNewPoints = NULL;
+ vtkIdType aNbPoints = 0;
+ vtkIdType newCellId;
+
+ //Input and output cell data
+ vtkCellData *cd = input->GetCellData();
+ vtkCellData *outputCD = output->GetCellData();
+
+ //Input and output scalars on point data
+ vtkDataArray* inputScalars = input->GetPointData()->GetScalars();
+ vtkDataArray* outputScalars = output->GetPointData()->GetScalars();
+
+ std::vector< vtkSmartPointer<vtkPoints> > aCollection;
+ std::vector< std::vector<double> > aScalarCollection;
+
+ vtkCell* aCell = input->GetCell(cellId);
+ switch(aCell->GetCellType()) {
+ case VTK_QUADRATIC_TRIANGLE:
+ case VTK_BIQUADRATIC_TRIANGLE:
+ {
+ //Get All points from input cell
+ Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
+ Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
+ Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
+ Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
+ Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
+ Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
+
+ VTKViewer_ArcBuilder aBuilder1(P0,P3,P1,myMaxArcAngle); //Build arc using 0, 3 and 1 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ VTKViewer_ArcBuilder aBuilder2(P1,P4,P2,myMaxArcAngle); //Build arc using 1, 4 and 2 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ VTKViewer_ArcBuilder aBuilder3(P2,P5,P0,myMaxArcAngle); //Build arc using 2, 5 and 0 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ aCollection.push_back(aBuilder1.GetPoints());
+ aCollection.push_back(aBuilder2.GetPoints());
+ aCollection.push_back(aBuilder3.GetPoints());
+
+ aScalarCollection.push_back(aBuilder1.GetScalarValues());
+ aScalarCollection.push_back(aBuilder2.GetScalarValues());
+ aScalarCollection.push_back(aBuilder3.GetScalarValues());
+ break;
+ }
+ case VTK_QUADRATIC_QUAD:
+ case VTK_BIQUADRATIC_QUAD:
+ {
+ //Get All points from input cell
+ Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
+ Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
+ Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
+ Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
+ Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
+ Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
+ Pnt P6 = CreatePnt( aCell, inputScalars, 6 );
+ Pnt P7 = CreatePnt( aCell, inputScalars, 7 );
+
+ VTKViewer_ArcBuilder aBuilder1(P0,P4,P1,myMaxArcAngle); //Build arc using 0, 4 and 1 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ VTKViewer_ArcBuilder aBuilder2(P1,P5,P2,myMaxArcAngle); //Build arc using 1, 5 and 2 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ VTKViewer_ArcBuilder aBuilder3(P2,P6,P3,myMaxArcAngle); //Build arc using 2, 6 and 3 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ VTKViewer_ArcBuilder aBuilder4(P3,P7,P0,myMaxArcAngle); //Build arc using 3, 7 and 0 points
+#ifdef __MYDEBUG__
+ cout << "Quadrangle arc 4 " << ( aBuilder4.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
+#endif
+
+ aCollection.push_back(aBuilder1.GetPoints());
+ aCollection.push_back(aBuilder2.GetPoints());
+ aCollection.push_back(aBuilder3.GetPoints());
+ aCollection.push_back(aBuilder4.GetPoints());
+
+ aScalarCollection.push_back(aBuilder1.GetScalarValues());
+ aScalarCollection.push_back(aBuilder2.GetScalarValues());
+ aScalarCollection.push_back(aBuilder3.GetScalarValues());
+ aScalarCollection.push_back(aBuilder4.GetScalarValues());
+ break;
+ }
+ case VTK_QUADRATIC_POLYGON:
+ {
+ int nbP = aCell->GetNumberOfPoints();
+ std::vector< Pnt > pVec( nbP + 2 );
+
+ for ( int i = 0; i < nbP/2; ++i )
+ {
+ pVec[i*2 + 0] = CreatePnt( aCell, inputScalars, i );
+ pVec[i*2 + 1] = CreatePnt( aCell, inputScalars, i + nbP/2 );
+ }
+ pVec[ nbP ] = pVec[ 0 ];
+ pVec[ nbP+1 ] = pVec[ 1 ];
+
+ for ( int i = 0; i < nbP; i += 2 )
+ {
+ VTKViewer_ArcBuilder aBuilder( pVec[i], pVec[i+1], pVec[i+2], myMaxArcAngle );
+ aCollection.push_back( aBuilder.GetPoints() );
+ aScalarCollection.push_back( aBuilder.GetScalarValues() );
+ }
+ break;
+ }
+ default: //Unsupported cell type
+ return;
+ }
+
+ if(triangulate){
+ const vtkIdType numFacePts = 3;
+ vtkIdList *pts = vtkIdList::New();
+ vtkPoints *coords = vtkPoints::New();
+ aCellType = VTK_TRIANGLE;
+ vtkIdType aNewPts[numFacePts];
+ vtkIdType aTriangleId;
+
+ vtkPolygon *aPlg = vtkPolygon::New();
+ std::map<int, double> aPntId2ScalarValue;
+ aNbPoints = MergevtkPoints(aCollection, aScalarCollection, aPlg->GetPoints(), aPntId2ScalarValue, aNewPoints);
+ aPlg->GetPointIds()->SetNumberOfIds(aNbPoints);
+
+ for(vtkIdType i = 0; i < aNbPoints;i++) {
+ aPlg->GetPointIds()->SetId(i, aNewPoints[i]);
+ }
+
+ aPlg->Triangulate(0,pts,coords);
+
+ for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) {
+ aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i));
+ aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1));
+ aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2));
+
+ if(outputScalars) {
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]);
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]);
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]);
+ }
+
+ aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+
+ if(myStoreMapping)
+ InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
+ outputCD->CopyData(cd,cellId,aTriangleId);
+ }
+ pts->Delete();
+ coords->Delete();
+ aPlg->Delete();
+ }
+ else {
+ std::map<int, double> aPntId2ScalarValue;
+ aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints);
+ if(outputScalars)
+ for(vtkIdType i = 0; i < aNbPoints; i++)
+ outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]);
+ newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints);
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ if(myStoreMapping)
+ InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
+ }
+
+ if (aNewPoints)
+ delete [] aNewPoints;
+}
+
+
+void VTKViewer_GeometryFilter::SetQuadraticArcMode(bool theFlag)
+{
+ if(myIsBuildArc != theFlag) {
+ myIsBuildArc = theFlag;
+ this->Modified();
+ }
+}
+bool VTKViewer_GeometryFilter::GetQuadraticArcMode() const
+{
+ return myIsBuildArc;
+}
+
+void VTKViewer_GeometryFilter::SetQuadraticArcAngle(double theMaxAngle)
+{
+ if(myMaxArcAngle != theMaxAngle) {
+ myMaxArcAngle = theMaxAngle;
+ this->Modified();
+ }
+}
+
+double VTKViewer_GeometryFilter:: GetQuadraticArcAngle() const
+{
+ return myMaxArcAngle;
+}
+
+int VTKViewer_GeometryFilter::GetAppendCoincident3D() const {
+// VSR 26/10/2012: see description of SHOW_COINCIDING_3D_PAL20314
+// in the top of this file
+#ifdef SHOW_COINCIDING_3D_PAL20314
+ return myAppendCoincident3D;