]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Refactoring code CEA_2020/Lot_2_NormalToFace
authorlucasjerome <jerome.lucas@cegsenslab.fr>
Wed, 20 Jan 2021 11:26:04 +0000 (12:26 +0100)
committerlucasjerome <jerome.lucas@cegsenslab.fr>
Wed, 20 Jan 2021 11:26:04 +0000 (12:26 +0100)
17 files changed:
src/FeaturesAPI/FeaturesAPI_NormalToFace.cpp
src/FeaturesAPI/FeaturesAPI_NormalToFace.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/CreateNormalToFace_widget.xml [deleted file]
src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.cpp
src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.h
src/FeaturesPlugin/FeaturesPlugin_NormalToFace.cpp
src/FeaturesPlugin/FeaturesPlugin_NormalToFace.h
src/FeaturesPlugin/NormalToFace_widget.xml [deleted file]
src/FeaturesPlugin/create_normal_to_face_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/doc/TUI_NormalToFaceFeature.rst [deleted file]
src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/normalToFaceFeature.rst
src/FeaturesPlugin/normal_to_face_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.cpp
src/GeomAlgoAPI/GeomAlgoAPI_NormalToFace.h

index fbc7bd65086e772b725f654e17b802902c790fe4..6906d4cadb8c6b322245c187703c394b0db731ad 100644 (file)
@@ -26,8 +26,8 @@
 #include <ModelHighAPI_Tools.h>
 
 //=================================================================================================
-FeaturesAPI_NormalToFace::
-          FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
+                                    const std::shared_ptr<ModelAPI_Feature>& theFeature)
   : ModelHighAPI_Interface(theFeature)
 {
   initialize();
@@ -37,7 +37,7 @@ FeaturesAPI_NormalToFace::
 FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
                                     const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                     const ModelHighAPI_Selection& theBaseFace,
-                                    const ModelHighAPI_Selection& theOptionnelPoint )
+                                    const ModelHighAPI_Selection& theOptionnelPoint)
 :ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
@@ -94,8 +94,7 @@ NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
                     const ModelHighAPI_Selection& theOptionnelPoint)
 {
 
-  FeaturePtr aFeature =
-      thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
+  FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
 
   NormalPtr aNormalToface;
 
@@ -109,8 +108,7 @@ NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
                     const ModelHighAPI_Selection& theBaseFace)
 {
 
-  FeaturePtr aFeature =
-      thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
+  FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
 
   NormalPtr aNormalToface;
 
index f7c1facc06f55b571c270349489b7203c3058b38..3756ffdac908ea559793c12f1ce4c97ce84612f2 100644 (file)
@@ -43,7 +43,7 @@ public:
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                     const ModelHighAPI_Selection& theBaseFace,
-                                    const ModelHighAPI_Selection& theOptionnelPoint );
+                                    const ModelHighAPI_Selection& theOptionnelPoint);
 
   FEATURESAPI_EXPORT
   explicit FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature,
index 0375dd1d0290b3bafb6c3bfbb86b1cda60b8390c..4b6004472b7e3f61aa98c747091fe7adedcd24ee 100644 (file)
@@ -159,8 +159,8 @@ SET(XML_RESOURCES
   fillet_widget.xml
   fillet1d_widget.xml
   measurement_widget.xml
-  NormalToFace_widget.xml
-  CreateNormalToFace_widget.xml
+  normal_to_face_widget.xml
+  create_normal_to_face_widget.xml
   fusion_faces_widget.xml
   chamfer_widget.xml
   copy_widget.xml
diff --git a/src/FeaturesPlugin/CreateNormalToFace_widget.xml b/src/FeaturesPlugin/CreateNormalToFace_widget.xml
deleted file mode 100644 (file)
index f7fc96d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<source>
-  <shape_selector id="face"
-                  label="Face"
-                  tooltip="Select a face"
-                  shape_types="face"
-                  default=""
-                  geometrical_selection="true">
-    <validator id="PartSet_DifferentObjects"/>
-    <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
-  </shape_selector>
-  <optionalbox id="vertex_option" title="Option">
-    <shape_selector id="vertex"
-                    label="Vertex"
-                    tooltip="Select a vertex"
-                    shape_types="vertex"
-                    default=""
-                    geometrical_selection="true">
-      <validator id="PartSet_DifferentObjects"/>
-    </shape_selector>
-  </optionalbox>
-</source>
index 14c8848ca791b2f3cc0e60f4443d08280af1c476..cc245368ce72043aea8d1472f730edfa91fb8e8a 100644 (file)
@@ -63,8 +63,7 @@ void FeaturesPlugin_CreateNormalToFace::execute()
 
   GeomShapePtr aShape;
   GeomShapePtr aShapePoint;
-  if(!string(VERTEX_OPTION_ID())->value().empty())
-  {
+  if (!string(VERTEX_OPTION_ID())->value().empty()) {
     if (aSelectionPoint && aSelectionPoint->isInitialized()) {
       aShapePoint = aSelectionPoint->value();
       if (!aShapePoint && aSelectionPoint->context())
@@ -81,7 +80,7 @@ void FeaturesPlugin_CreateNormalToFace::execute()
   if (aShape) {
     std::string aError;
     std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
-    if!GeomAlgoAPI_NormalToFace::normal(aShape,
+    if (!GeomAlgoAPI_NormalToFace::normal(aShape,
                                           aShapePoint,
                                           theNormal,
                                           aError))
index 83210022ba51edcd53bc139aef07ceefefca7ce6..f7afaa1cce77120ae10abaed77ffb7be9422d07e 100644 (file)
@@ -39,12 +39,6 @@ public:
     return MY_ID;
   }
 
-  /// \return the kind of a feature.
-  virtual const std::string& getKind()
-  {
-    return ID();
-  }
-
   /// Attribute name for face selected.
   inline static const std::string& FACE_SELECTED_ID()
   {
@@ -66,6 +60,12 @@ public:
     return MY_VERTEX_OPTION_ID;
   }
 
+  /// \return the kind of a feature.
+  virtual const std::string& getKind()
+  {
+    return ID();
+  }
+
   /// Performs the algorithm and stores results it in the data structure.
   FEATURESPLUGIN_EXPORT virtual void execute();
 
index a70e8fd7995ce974e1de536a0d15a10d292b3ee6..78bed79736e48ab72cd19ec55585a5d7a9cb01a5 100644 (file)
@@ -85,7 +85,7 @@ void FeaturesPlugin_NormalToFace::execute()
   if (aShape) {
     std::string aError;
     std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
-    if!GeomAlgoAPI_NormalToFace::normal(aShape,
+    if (!GeomAlgoAPI_NormalToFace::normal(aShape,
                                           aShapePoint,
                                           theNormal,
                                           aError))
@@ -149,16 +149,16 @@ void FeaturesPlugin_NormalToFace::createNormal()
 void FeaturesPlugin_NormalToFace::updateNormal()
 {
   myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::FACE_SELECTED_ID())
-                        ->setValue( selection(FACE_SELECTED_ID())->context() ,
-                                    selection(FACE_SELECTED_ID())->value() );
+                        ->setValue(selection(FACE_SELECTED_ID())->context() ,
+                                    selection(FACE_SELECTED_ID())->value());
 
   myCreateFeature->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())
-                        ->setValue( string(VERTEX_OPTION_ID())->value());
+                        ->setValue(string(VERTEX_OPTION_ID())->value());
 
   if (!string(VERTEX_OPTION_ID())->value().empty()) {
     myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::VERTEX_SELECTED_ID())
-                        ->setValue( selection(VERTEX_SELECTED_ID())->context() ,
-                                    selection(VERTEX_SELECTED_ID())->value() );
+                        ->setValue(selection(VERTEX_SELECTED_ID())->context() ,
+                                    selection(VERTEX_SELECTED_ID())->value());
   }
 
   myCreateFeature->execute();
index 261b297707f7650af9ddac9d5217fd20328944e8..a165e51962280c5516025938dd90c75036c771d0 100644 (file)
@@ -39,12 +39,6 @@ public:
     return MY_ID;
   }
 
-  /// \return the kind of a feature.
-  virtual const std::string& getKind()
-  {
-    return ID();
-  }
-
   /// Attribute name for face selected.
   inline static const std::string& FACE_SELECTED_ID()
   {
@@ -73,6 +67,12 @@ public:
     return MY_VERTEX_OPTION_ID;
   }
 
+  /// \return the kind of a feature.
+  virtual const std::string& getKind()
+  {
+    return ID();
+  }
+
   /// Performs the algorithm and stores results it in the data structure.
   FEATURESPLUGIN_EXPORT virtual void execute();
 
@@ -90,9 +90,11 @@ public:
   FeaturesPlugin_NormalToFace();
 
   private:
-
+  /// Create normal in feature
   void createNormal();
+  /// Update normal in feature
   void updateNormal();
+  /// Feature to create normal
   FeaturePtr myCreateFeature;
 
 };
diff --git a/src/FeaturesPlugin/NormalToFace_widget.xml b/src/FeaturesPlugin/NormalToFace_widget.xml
deleted file mode 100644 (file)
index a0b818a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<source>
-  <shape_selector id="face"
-                  label="Face"
-                  tooltip="Select a face"
-                  shape_types="face"
-                  default=""
-                  geometrical_selection="true">
-    <validator id="PartSet_DifferentObjects"/>
-    <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
-  </shape_selector>
-  <optionalbox id="vertex_option" title="Option">
-    <shape_selector id="vertex"
-                    label="Vertex"
-                    tooltip="Select a vertex"
-                    shape_types="vertex"
-                    default=""
-                    geometrical_selection="true">
-      <validator id="PartSet_DifferentObjects"/>
-    </shape_selector>
-  </optionalbox>
-  <boolvalue id="createnormal" label="Create normal" default="false"/>
-</source>
diff --git a/src/FeaturesPlugin/create_normal_to_face_widget.xml b/src/FeaturesPlugin/create_normal_to_face_widget.xml
new file mode 100644 (file)
index 0000000..82ee3be
--- /dev/null
@@ -0,0 +1,20 @@
+<source>
+  <shape_selector id="face"
+                  label="Face"
+                  tooltip="Select a face"
+                  shape_types="face"
+                  default=""
+                  geometrical_selection="true">
+    <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
+  </shape_selector>
+  <optionalbox id="vertex_option" title="Option">
+    <shape_selector id="vertex"
+                    label="Vertex"
+                    tooltip="Select a vertex"
+                    shape_types="vertex"
+                    default=""
+                    geometrical_selection="true">
+      <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+    </shape_selector>
+  </optionalbox>
+</source>
diff --git a/src/FeaturesPlugin/doc/TUI_NormalToFaceFeature.rst b/src/FeaturesPlugin/doc/TUI_NormalToFaceFeature.rst
deleted file mode 100644 (file)
index eb8b036..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-
-  .. _tui_create_Normal_To_Face:
-
-Create Normal to a face
-=======================
-
-.. literalinclude:: examples/createNormalToFace.py 
-    :linenos:
-    :language: python
-
-:download:`Download this script <examples/createNormalToFace.py>`
-
-  .. _tui_create_Normal_To_Face_At_Vertex:
-
-Create Normal to a face at vertex
-=================================
-
-.. literalinclude:: examples/createNormalToFaceAtVertex.py 
-    :linenos:
-    :language: python
-
-:download:`Download this script <examples/createNormalToFaceAtVertex.py>`
\ No newline at end of file
diff --git a/src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst b/src/FeaturesPlugin/doc/TUI_normalToFaceFeature.rst
new file mode 100644 (file)
index 0000000..2ae1c6d
--- /dev/null
@@ -0,0 +1,22 @@
+
+  .. _tui_create_normal_to_face:
+
+Create normal to a face
+=======================
+
+.. literalinclude:: examples/createNormalToFace.py 
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/createNormalToFace.py>`
+
+  .. _tui_create_normal_to_face_at_vertex:
+
+Create normal to a face at vertex
+=================================
+
+.. literalinclude:: examples/createNormalToFaceAtVertex.py 
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/createNormalToFaceAtVertex.py>`
\ No newline at end of file
index b4f9b16b2470acc0d6e2adc0dff61fb887c548e4..cf498b72d000faa8a3b1777b3f6973897af0ce5c 100644 (file)
@@ -46,7 +46,7 @@ Result of **Normal to a face**.
 
    Normal to a face
 
-**See Also** a sample TUI Script of :ref:`tui_create_Normal_To_Face` operation.
+**See Also** a sample TUI Script of :ref:`tui_create_normal_to_face` operation.
 
 
 **TUI Command**:
@@ -68,4 +68,4 @@ Result of **Normal to aface** where **Vertex** is selecteted.
 
    Normal to a face at vertex
 
-**See Also** a sample TUI Script of :ref:`tui_create_Normal_To_Face_At_Vertex` operation.
\ No newline at end of file
+**See Also** a sample TUI Script of :ref:`tui_create_normal_to_face_at_vertex` operation.
\ No newline at end of file
diff --git a/src/FeaturesPlugin/normal_to_face_widget.xml b/src/FeaturesPlugin/normal_to_face_widget.xml
new file mode 100644 (file)
index 0000000..71cde51
--- /dev/null
@@ -0,0 +1,21 @@
+<source>
+  <shape_selector id="face"
+                  label="Face"
+                  tooltip="Select a face"
+                  shape_types="face"
+                  default=""
+                  geometrical_selection="true">
+    <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
+  </shape_selector>
+  <optionalbox id="vertex_option" title="Option">
+    <shape_selector id="vertex"
+                    label="Vertex"
+                    tooltip="Select a vertex"
+                    shape_types="vertex"
+                    default=""
+                    geometrical_selection="true">
+      <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+    </shape_selector>
+  </optionalbox>
+  <boolvalue id="createnormal" label="Create normal" default="false"/>
+</source>
index 4a480d18fbbc5dd8fa5684103b8723d3893f87cc..9885f4df28554466de4986007d4e099c63945868 100644 (file)
     <group id="Face">
       <feature id="NormalMacro" title="Normal to a face" tooltip="Calculate the normal to a face" auto_preview="true"
                icon="icons/Features/normale.png" helpfile="normalToFaceFeature.html"> 
-        <source path="NormalToFace_widget.xml"/>
+        <source path="normal_to_face_widget.xml"/>
       </feature>
       <feature id="Normal" title="Normal to a face" tooltip="Calculate the normal to a face" auto_preview="true"
                icon="icons/Features/axis.png" helpfile="normalToFaceFeature.html" internal="1"> 
-        <source path="CreateNormalToFace_widget.xml"/>
+        <source path="create_normal_to_face_widget.xml"/>
       </feature>
     </group>
   </workbench>
index b39bbc8c3a5c1fb1fa2015282b984d94ef73298b..a4e81513d10f12fadba699b66852d7bf9032fc37 100644 (file)
@@ -40,7 +40,7 @@
    * \param theShape The shape to get type of.
    * \retval TopAbs_ShapeEnum Return type of shape for explode.
    */
-TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape)
+TopAbs_ShapeEnum GetTypeOfSimplePart(const TopoDS_Shape& theShape)
 {
   TopAbs_ShapeEnum aType = theShape.ShapeType();
   if      (aType == TopAbs_VERTEX)                             return TopAbs_VERTEX;
@@ -64,7 +64,7 @@ TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape)
    * Axes of the LCS are obtained from shape's location or,
    * if the shape is a planar face, from position of its plane.
    */
-gp_Ax3 GetPosition (const TopoDS_Shape& theShape)
+gp_Ax3 GetPosition(const TopoDS_Shape& theShape)
 {
   gp_Ax3 aResult;
 
@@ -81,8 +81,7 @@ gp_Ax3 GetPosition (const TopoDS_Shape& theShape)
       aResult = aPln.Position();
       // In case of reverse orinetation of the face invert the plane normal
       // (the face's normal does not mathc the plane's normal in this case)
-      if(theShape.Orientation() == TopAbs_REVERSED)
-      {
+      if (theShape.Orientation() == TopAbs_REVERSED) {
         gp_Dir Vx =  aResult.XDirection();
         gp_Dir N  =  aResult.Direction().Mirrored(Vx);
         gp_Pnt P  =  aResult.Location();
@@ -98,8 +97,7 @@ gp_Ax3 GetPosition (const TopoDS_Shape& theShape)
 
   if (aShType == TopAbs_VERTEX) {
     aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape));
-  }
-  else {
+  } else {
     if (aShType == TopAbs_COMPOUND) {
       aShType = GetTypeOfSimplePart(theShape);
     }
@@ -138,8 +136,8 @@ static bool GeomAlgoAPI_NormalToFace::normal(GeomShapePtr theFace,
   TopoDS_Shape aShape = theFace->impl<TopoDS_Shape>();
 
   if (aShape.ShapeType() != TopAbs_FACE) {
-      theError = "Shape for normale calculation is not a face";
-      return false;
+    theError = "Shape for normale calculation is not a face";
+    return false;
   }
 
   TopoDS_Face aFace = TopoDS::Face(aShape);
@@ -149,93 +147,89 @@ static bool GeomAlgoAPI_NormalToFace::normal(GeomShapePtr theFace,
 
   if (theOptionnelPoint.get()) {
     TopoDS_Shape anOptPnt = theOptionnelPoint->impl<TopoDS_Shape>();
-    if (anOptPnt.IsNull()){
+    if (anOptPnt.IsNull()) {
       theError = "Invalid shape given for point argument";
       return false;
     }
     p1 = BRep_Tool::Pnt(TopoDS::Vertex(anOptPnt));
-  }
-  else
-  {
-      gp_Ax3 aPos = GetPosition(aFace);
-      p1 = aPos.Location();
+  } else {
+    gp_Ax3 aPos = GetPosition(aFace);
+    p1 = aPos.Location();
   }
 
-    // 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);
-    SF.D1(pUV.X(), pUV.Y(), p1, Vec1, Vec2);
-    if (Vec1.Magnitude() < Precision::Confusion()) {
-      gp_Vec tmpV;
-      gp_Pnt tmpP;
-      SF.D1(pUV.X(), pUV.Y()-0.1, tmpP, Vec1, tmpV);
-    }
-    else if (Vec2.Magnitude() < Precision::Confusion()) {
-      gp_Vec tmpV;
-      gp_Pnt tmpP;
-      SF.D1(pUV.X()-0.1, pUV.Y(), tmpP, tmpV, Vec2);
-    }
+  // 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);
+  SF.D1(pUV.X(), pUV.Y(), p1, Vec1, Vec2);
+  if (Vec1.Magnitude() < Precision::Confusion()) {
+    gp_Vec tmpV;
+    gp_Pnt tmpP;
+    SF.D1(pUV.X(), pUV.Y()-0.1, tmpP, Vec1, tmpV);
+  }
+  else if (Vec2.Magnitude() < Precision::Confusion()) {
+    gp_Vec tmpV;
+    gp_Pnt tmpP;
+    SF.D1(pUV.X()-0.1, pUV.Y(), tmpP, tmpV, Vec2);
+  }
 
-    gp_Vec V = Vec1.Crossed(Vec2);
-    Standard_Real mod = V.Magnitude();
-    if (mod < Precision::Confusion())
-      Standard_NullObject::Raise("Normal vector of a face has null magnitude");
-
-    // Set length of normal vector to average radius of curvature
-    Standard_Real radius = 0.0;
-    GeomLProp_SLProps aProperties (aSurf, pUV.X(), pUV.Y(), 2, Precision::Confusion());
-    if (aProperties.IsCurvatureDefined()) {
-      Standard_Real radius1 = Abs(aProperties.MinCurvature());
-      Standard_Real radius2 = Abs(aProperties.MaxCurvature());
-      if (Abs(radius1) > Precision::Confusion()) {
-        radius = 1.0 / radius1;
-        if (Abs(radius2) > Precision::Confusion()) {
-          radius = (radius + 1.0 / radius2) / 2.0;
-        }
+  gp_Vec V = Vec1.Crossed(Vec2);
+  Standard_Real mod = V.Magnitude();
+  if (mod < Precision::Confusion())
+    Standard_NullObject::Raise("Normal vector of a face has null magnitude");
+
+  // Set length of normal vector to average radius of curvature
+  Standard_Real radius = 0.0;
+  GeomLProp_SLProps aProperties (aSurf, pUV.X(), pUV.Y(), 2, Precision::Confusion());
+  if (aProperties.IsCurvatureDefined()) {
+    Standard_Real radius1 = Abs(aProperties.MinCurvature());
+    Standard_Real radius2 = Abs(aProperties.MaxCurvature());
+    if (Abs(radius1) > Precision::Confusion()) {
+      radius = 1.0 / radius1;
+      if (Abs(radius2) > Precision::Confusion()) {
+        radius = (radius + 1.0 / radius2) / 2.0;
       }
-      else {
-        if (Abs(radius2) > Precision::Confusion()) {
-          radius = 1.0 / radius2;
-        }
+    } else {
+      if (Abs(radius2) > Precision::Confusion()) {
+        radius = 1.0 / radius2;
       }
     }
+  }
 
-    // Set length of normal vector to average dimension of the face
-    // (only if average radius of curvature is not appropriate)
-    if (radius < Precision::Confusion()) {
-        Bnd_Box B;
-        Standard_Real Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
-        BRepBndLib::Add(aFace, B);
-        B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
-        radius = ((Xmax - Xmin) + (Ymax - Ymin) + (Zmax - Zmin)) / 3.0;
-    }
-
-    if (radius < Precision::Confusion())
-      radius = 1.0;
+  // Set length of normal vector to average dimension of the face
+  // (only if average radius of curvature is not appropriate)
+  if (radius < Precision::Confusion()) {
+    Bnd_Box B;
+    Standard_Real Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
+    BRepBndLib::Add(aFace, B);
+    B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+    radius = ((Xmax - Xmin) + (Ymax - Ymin) + (Zmax - Zmin)) / 3.0;
+  }
 
-    V *= radius / mod;
+  if (radius < Precision::Confusion())
+    radius = 1.0;
 
-    // consider the face orientation
-    if (aFace.Orientation() == TopAbs_REVERSED ||
-        aFace.Orientation() == TopAbs_INTERNAL) {
-      V = - V;
-    }
+  V *= radius / mod;
 
-    // Edge
-    gp_Pnt p2 = p1.Translated(V);
-    BRepBuilderAPI_MakeEdge aBuilder (p1, p2);
-    if (!aBuilder.IsDone())
-      Standard_NullObject::Raise("Vector construction failed");
-    aShape = aBuilder.Shape();
+  // consider the face orientation
+  if (aFace.Orientation() == TopAbs_REVERSED ||
+      aFace.Orientation() == TopAbs_INTERNAL) {
+    V = - V;
+  }
 
-    theNormal->setImpl(new TopoDS_Shape(aShape));
+  // Edge
+  gp_Pnt p2 = p1.Translated(V);
+  BRepBuilderAPI_MakeEdge aBuilder (p1, p2);
+  if (!aBuilder.IsDone())
+    Standard_NullObject::Raise("Vector construction failed");
+  aShape = aBuilder.Shape();
 
-    return true;
+  theNormal->setImpl(new TopoDS_Shape(aShape));
 
+  return true;
 }
 
index 5bf44a3d1ff035146f2451826dbceac89f63d0f3..e12b49f2472c44130dec98335fececf8c7d153df 100644 (file)
@@ -22,9 +22,7 @@
 
 #include <GeomAlgoAPI.h>
 #include <GeomAPI_Edge.h>
-#include <GeomAPI_Pnt.h>
 #include <GeomAPI_Face.h>
-#include <Standard_TypeDef.hxx>
 
 /**\class GeomAlgoAPI_NormalToFace
  * \ingroup DataAlgo
 class GEOMALGOAPI_EXPORT GeomAlgoAPI_NormalToFace
 {
  public:
-  /// get the boundin box of theshape.
+  /// get the normal to face-shapes
   /// \param theface   the face
   /// \param theOptionnelPoint the optionnel point
+  /// \param theNormal the normal
+  /// \param theError the error
   static bool GeomAlgoAPI_NormalToFace::normal(GeomShapePtr theFace,
                                                GeomShapePtr theOptionnelPoint,
                                                GeomEdgePtr  theNormal,