]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModuleBase/ModuleBase_ResultPrs.cpp
Salome HOME
bos #29479 Show edges directions
[modules/shaper.git] / src / ModuleBase / ModuleBase_ResultPrs.cpp
index c9cf044731ea893bac90f50417cca39efabb3bbd..ccba3a2071f008092dd64616e85add91ddb700c8 100644 (file)
 #include <TopoDS_Edge.hxx>
 #include <BRepMesh_IncrementalMesh.hxx>
 #include <Standard_Version.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <TopExp.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
 
 #if OCC_VERSION_HEX > 0x070400
 #include <StdPrs_ToolTriangulatedShape.hxx>
@@ -300,6 +304,49 @@ void ModuleBase_ResultPrs::Compute(
   catch (...) {
     return;
   }
+  if (myResult.get() && ModelAPI_Tools::isShowEdgesDirection(myResult))
+  {
+    TopExp_Explorer Exp(myshape, TopAbs_EDGE);
+    for (; Exp.More(); Exp.Next()) {
+      TopoDS_Edge anEdgeE = TopoDS::Edge(Exp.Current());
+      if (anEdgeE.IsNull())
+        continue;
+
+      // draw curve direction (issue 0021087)
+      anEdgeE.Orientation(TopAbs_FORWARD);
+
+      TopoDS_Vertex aV1, aV2;
+      TopExp::Vertices(anEdgeE, aV1, aV2);
+      gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
+      gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
+
+      double fp, lp;
+      gp_Vec aDirVec;
+      Handle(Geom_Curve) C = BRep_Tool::Curve(anEdgeE, fp, lp);
+
+      if (C.IsNull()) continue;
+
+      if (anEdgeE.Orientation() == TopAbs_FORWARD)
+        C->D1(lp, aP2, aDirVec);
+      else {
+        C->D1(fp, aP1, aDirVec);
+        aP2 = aP1;
+      }
+      GeomAdaptor_Curve aAdC;
+      aAdC.Load(C, fp, lp);
+      Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp);
+
+      if (aDist > gp::Resolution()) {
+        gp_Dir aDir;
+        if (anEdgeE.Orientation() == TopAbs_FORWARD)
+          aDir = aDirVec;
+        else
+          aDir = -aDirVec;
+
+        Prs3d_Arrow::Draw(thePresentation->CurrentGroup(), aP2, aDir, M_PI / 180.*5., aDist / 10.);
+      }
+    }
+  }
 
   // visualize hidden sub-shapes transparent
   if (myResult.get()) {