]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
fix examples names .py
authorNicolas RECHATIN <nicolas.rechatin@cea.fr>
Wed, 30 Jun 2021 11:27:34 +0000 (13:27 +0200)
committerNicolas RECHATIN <nicolas.rechatin@cea.fr>
Wed, 30 Jun 2021 12:58:37 +0000 (14:58 +0200)
patch normal to face computation

src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst
src/FeaturesPlugin/doc/examples/createNormalToFace.py [deleted file]
src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py [deleted file]
src/FeaturesPlugin/doc/examples/create_normal_to_face.py [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/create_normal_to_face_at_vertex.py [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp

index 2ae1c6dc3eede9c63a5062d2f3a3255321d1a802..196cebf1d195eba5ba76c313dd625f8e97db3ffa 100644 (file)
@@ -4,19 +4,19 @@
 Create normal to a face
 =======================
 
-.. literalinclude:: examples/createNormalToFace.py 
+.. literalinclude:: examples/create_normal_to_face.py
     :linenos:
     :language: python
 
-:download:`Download this script <examples/createNormalToFace.py>`
+:download:`Download this script <examples/create_normal_to_face.py>`
 
   .. _tui_create_normal_to_face_at_vertex:
 
 Create normal to a face at vertex
 =================================
 
-.. literalinclude:: examples/createNormalToFaceAtVertex.py 
+.. literalinclude:: examples/create_normal_to_face_at_vertex.py
     :linenos:
     :language: python
 
-:download:`Download this script <examples/createNormalToFaceAtVertex.py>`
\ No newline at end of file
+:download:`Download this script <examples/create_normal_to_face_at_vertex.py>`
diff --git a/src/FeaturesPlugin/doc/examples/createNormalToFace.py b/src/FeaturesPlugin/doc/examples/createNormalToFace.py
deleted file mode 100644 (file)
index c89e07c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-from salome.shaper import model
-import os
-
-model.begin()
-Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
-model.do()
-    
-### Create BoundingBox
-Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
-model.do()
-
-model.end()
diff --git a/src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py b/src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py
deleted file mode 100644 (file)
index eb0071e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-
-from salome.shaper import model
-import os
-
-model.begin()
-Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
-model.do()
-    
-Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]"))
-model.do()
-
-model.end()
diff --git a/src/FeaturesPlugin/doc/examples/create_normal_to_face.py b/src/FeaturesPlugin/doc/examples/create_normal_to_face.py
new file mode 100644 (file)
index 0000000..c89e07c
--- /dev/null
@@ -0,0 +1,12 @@
+from salome.shaper import model
+import os
+
+model.begin()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+    
+### Create BoundingBox
+Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "Box_1_1/Top"))
+model.do()
+
+model.end()
diff --git a/src/FeaturesPlugin/doc/examples/create_normal_to_face_at_vertex.py b/src/FeaturesPlugin/doc/examples/create_normal_to_face_at_vertex.py
new file mode 100644 (file)
index 0000000..eb0071e
--- /dev/null
@@ -0,0 +1,12 @@
+
+from salome.shaper import model
+import os
+
+model.begin()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+    
+Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]"))
+model.do()
+
+model.end()
index c7993158222f29f00054c308974e290a6f57287e..19cc7a5be3f14406cc7890237ad7f7a5b7fcd8d8 100644 (file)
@@ -29,6 +29,7 @@
 #include <TopoDS_Iterator.hxx>
 #include <GProp_GProps.hxx>
 #include <BRepGProp.hxx>
+#include <ShapeAnalysis.hxx>
 #include <ShapeAnalysis_Surface.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepBndLib.hxx>
@@ -145,7 +146,17 @@ static bool GeomAlgoAPI_NormalToFace::normal(GeomShapePtr theFace,
 
   // Point
   gp_Pnt p1 (0,0,0);
+  // Point parameters on surface
+  double u1, u2, v1, v2;
+  Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+  Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf);
+  gp_Ax3 aPos = GetPosition(aFace);
+  p1 = aPos.Location();
+  // Set default starting point using UV bounds
+  ShapeAnalysis::GetFaceUVBounds(aFace, u1, u2, v1, v2);
+  gp_Pnt2d pUV ((u2 + u1) * 0.5, (v2 + v1) * 0.5);
 
+  // Change to Vertex coord if selected
   if (theOptionnelPoint.get()) {
     TopoDS_Shape anOptPnt = theOptionnelPoint->impl<TopoDS_Shape>();
     if (anOptPnt.IsNull()) {
@@ -153,16 +164,9 @@ static bool GeomAlgoAPI_NormalToFace::normal(GeomShapePtr theFace,
       return false;
     }
     p1 = BRep_Tool::Pnt(TopoDS::Vertex(anOptPnt));
-  } else {
-    gp_Ax3 aPos = GetPosition(aFace);
-    p1 = aPos.Location();
+    pUV = aSurfAna->ValueOfUV(p1, Precision::Confusion());
   }
 
-  // Point parameters on surface
-  Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
-  Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf);
-  gp_Pnt2d pUV = aSurfAna->ValueOfUV(p1, Precision::Confusion());
-
   // Normal direction
   gp_Vec Vec1,Vec2;
   BRepAdaptor_Surface SF (aFace);