From 33d63aa0481372cb60d792c51a1cac9a141b1673 Mon Sep 17 00:00:00 2001 From: Nicolas RECHATIN Date: Wed, 30 Jun 2021 13:27:34 +0200 Subject: [PATCH] fix examples names .py patch normal to face computation --- .../doc/TUI_normalToFaceFeature.rst | 8 ++++---- ...rmalToFace.py => create_normal_to_face.py} | 0 ....py => create_normal_to_face_at_vertex.py} | 0 src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp | 20 +++++++++++-------- 4 files changed, 16 insertions(+), 12 deletions(-) rename src/FeaturesPlugin/doc/examples/{createNormalToFace.py => create_normal_to_face.py} (100%) rename src/FeaturesPlugin/doc/examples/{createNormalToFaceAtVertex.py => create_normal_to_face_at_vertex.py} (100%) 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/create_normal_to_face.py similarity index 100% rename from src/FeaturesPlugin/doc/examples/createNormalToFace.py rename to src/FeaturesPlugin/doc/examples/create_normal_to_face.py diff --git a/src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py b/src/FeaturesPlugin/doc/examples/create_normal_to_face_at_vertex.py similarity index 100% rename from src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py rename to src/FeaturesPlugin/doc/examples/create_normal_to_face_at_vertex.py 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); -- 2.39.2