From: Nicolas RECHATIN Date: Wed, 30 Jun 2021 11:27:34 +0000 (+0200) Subject: fix examples names .py X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=33d63aa0481372cb60d792c51a1cac9a141b1673;p=modules%2Fshaper.git fix examples names .py patch normal to face computation --- diff --git a/src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst b/src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst index 2ae1c6dc3..196cebf1d 100644 --- a/src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst +++ b/src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst @@ -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 ` +:download:`Download this script ` .. _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 ` \ No newline at end of file +:download:`Download this script ` diff --git a/src/FeaturesPlugin/doc/examples/createNormalToFace.py b/src/FeaturesPlugin/doc/examples/createNormalToFace.py deleted file mode 100644 index c89e07c6b..000000000 --- a/src/FeaturesPlugin/doc/examples/createNormalToFace.py +++ /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 index eb0071efb..000000000 --- a/src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py +++ /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 index 000000000..c89e07c6b --- /dev/null +++ b/src/FeaturesPlugin/doc/examples/create_normal_to_face.py @@ -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 index 000000000..eb0071efb --- /dev/null +++ b/src/FeaturesPlugin/doc/examples/create_normal_to_face_at_vertex.py @@ -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() diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp index c79931582..19cc7a5be 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -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(); 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);