0025814: Visualization, Prs3d_WFShape::AddPolygon() - always use polygonal representa...
[occt.git] / src / Prs3d / Prs3d_WFShape.cxx
index 3c2131c..2d0a7f1 100755 (executable)
@@ -28,6 +28,7 @@
 #include <Poly_Array1OfTriangle.hxx>
 #include <Poly_Polygon3D.hxx>
 #include <Poly_PolygonOnTriangulation.hxx>
+#include <Prs3d.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_IsoAspect.hxx>
 #include <Prs3d_PointAspect.hxx>
@@ -66,35 +67,29 @@ namespace
 // purpose :
 // =========================================================================
 Standard_Boolean Prs3d_WFShape::AddPolygon (const TopoDS_Edge&    theEdge,
-                                            const Standard_Real   theDeflection,
                                             TColgp_SequenceOfPnt& thePoints)
 {
   TopLoc_Location aLocation;
-  Standard_Real aFirst, aLast;
-  Handle(Geom_Curve)     aCurve3d = BRep_Tool::Curve     (theEdge, aFirst, aLast);
   Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
   if (!aPolygon.IsNull())
   {
-    if ((aPolygon->Deflection() <= theDeflection) || aCurve3d.IsNull())
+    const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
+    Standard_Integer anIndex = aPoints.Lower();
+    if (aLocation.IsIdentity())
     {
-      const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
-      Standard_Integer anIndex = aPoints.Lower();
-      if (aLocation.IsIdentity())
+      for (; anIndex <= aPoints.Upper(); ++anIndex)
       {
-        for (; anIndex <= aPoints.Upper(); ++anIndex)
-        {
-          thePoints.Append (aPoints.Value (anIndex));
-        }
+        thePoints.Append (aPoints.Value (anIndex));
       }
-      else
+    }
+    else
+    {
+      for (; anIndex <= aPoints.Upper(); ++anIndex)
       {
-        for (; anIndex <= aPoints.Upper(); ++anIndex)
-        {
-          thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation));
-        }
+        thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation));
       }
-      return Standard_True;
     }
+    return Standard_True;
   }
 
   Handle(Poly_Triangulation)          aTriangulation;
@@ -102,28 +97,25 @@ Standard_Boolean Prs3d_WFShape::AddPolygon (const TopoDS_Edge&    theEdge,
   BRep_Tool::PolygonOnTriangulation (theEdge, aHIndices, aTriangulation, aLocation);
   if (!aHIndices.IsNull())
   {
-    if ((aHIndices->Deflection() <= theDeflection) || aCurve3d.IsNull())
-    {
-      const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
-      const TColgp_Array1OfPnt&      aNodes    = aTriangulation->Nodes();
+    const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
+    const TColgp_Array1OfPnt&      aNodes    = aTriangulation->Nodes();
 
-      Standard_Integer anIndex = anIndices.Lower();
-      if (aLocation.IsIdentity())
+    Standard_Integer anIndex = anIndices.Lower();
+    if (aLocation.IsIdentity())
+    {
+      for (; anIndex <= anIndices.Upper(); ++anIndex)
       {
-        for (; anIndex <= anIndices.Upper(); ++anIndex)
-        {
-          thePoints.Append (aNodes (anIndices (anIndex)));
-        }
+        thePoints.Append (aNodes (anIndices (anIndex)));
       }
-      else
+    }
+    else
+    {
+      for (; anIndex <= anIndices.Upper(); ++anIndex)
       {
-        for (; anIndex <= anIndices.Upper(); ++anIndex)
-        {
-          thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
-        }
+        thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
       }
-      return Standard_True;
     }
+    return Standard_True;
   }
   return Standard_False;
 }
@@ -141,7 +133,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     return;
   }
 
-  Prs3d_ShapeTool aTool (theShape);
+  Prs3d_ShapeTool aTool (theShape, theDrawer->VertexDrawMode() == Prs3d_VDM_All);
   TopTools_ListOfShape aLFree, aLUnFree, aLWire;
   for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
   {
@@ -154,22 +146,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
     }
   }
 
-  Standard_Real aDeflection = theDrawer->MaximalChordialDeviation();
-  if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
-  {
-    // The arrow calculation is based on the global min max
-    Bnd_Box aBndBox;
-    BRepBndLib::Add (theShape, aBndBox);
-    if (!aBndBox.IsVoid())
-    {
-      Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
-      aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
-      aDeflection = Max (aXmax-aXmin, Max (aYmax-aYmin, aZmax-aZmin))
-                       * theDrawer->DeviationCoefficient();
-    }
-  }
-
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
+  Standard_Real aDeflection = Prs3d::GetDeflection(theShape, theDrawer);
 
   Prs3d_NListOfSequenceOfPnt anUIsoCurves;
   Prs3d_NListOfSequenceOfPnt aVIsoCurves;
@@ -247,7 +224,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
             }
             catch (Standard_Failure)
             {
-            #ifdef DEB
+            #ifdef OCCT_DEBUG
               const TopoDS_Face& aFace = aSurface.Face();
               std::cout << "Problem with the face " << (void* ) &(*(aFace).TShape()) << std::endl;
             #endif
@@ -280,7 +257,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
             }
             catch (Standard_Failure)
             {
-            #ifdef DEB
+            #ifdef OCCT_DEBUG
               const TopoDS_Face& aFace = aSurface.Face();
               std::cout << "Problem with the face " << (void* ) &(*(aFace).TShape()) << std::endl;
             #endif
@@ -436,7 +413,6 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
   if (theDrawer->WireDraw())
   {
     // Wire (without any neighbour)
-    aGroup->SetPrimitivesAspect (theDrawer->WireAspect()->Aspect());
     for (anIt.Initialize(aLWire); anIt.More(); anIt.Next())
     {
       const TopoDS_Edge& anEdge = TopoDS::Edge (anIt.Value());
@@ -444,7 +420,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       {
         OCC_CATCH_SIGNALS
         const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
-        if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
+        if (!AddPolygon (anEdge, aPoints->ChangeSequence()))
         {
           if (BRep_Tool::IsGeometric (anEdge))
           {
@@ -461,7 +437,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       }
       catch (Standard_Failure)
       {
-      #ifdef DEB
+      #ifdef OCCT_DEBUG
         std::cout << "probleme sur aLocation'edge " << (void* ) &(*(anEdge).TShape()) << std::endl;
       #endif
       }
@@ -480,7 +456,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
         {
           OCC_CATCH_SIGNALS
           const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
-          if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
+          if (!AddPolygon (anEdge, aPoints->ChangeSequence()))
           {
             if (BRep_Tool::IsGeometric (anEdge))
             {
@@ -497,7 +473,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
         }
         catch (Standard_Failure)
         {
-        #ifdef DEB
+        #ifdef OCCT_DEBUG
           std::cout << "probleme sur aLocation'edge " << (void* ) &(*(anEdge).TShape()) << std::endl;
         #endif
         }
@@ -515,7 +491,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       {
         OCC_CATCH_SIGNALS
         const Handle(TColgp_HSequenceOfPnt)& aPoints = new TColgp_HSequenceOfPnt;
-        if (!AddPolygon (anEdge, aDeflection, aPoints->ChangeSequence()))
+        if (!AddPolygon (anEdge, aPoints->ChangeSequence()))
         {
           if (BRep_Tool::IsGeometric (anEdge))
           {
@@ -531,7 +507,7 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
       }
       catch (Standard_Failure)
       {
-      #ifdef DEB
+      #ifdef OCCT_DEBUG
         std::cout << "probleme sur aLocation'edge " << (void* ) &(*(anEdge).TShape()) << std::endl;
       #endif
       }