]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add documentation and test unit
authorJérôme <jerome.lucas@cesgenslab.fr>
Thu, 26 Nov 2020 15:00:52 +0000 (16:00 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Thu, 26 Nov 2020 15:00:52 +0000 (16:00 +0100)
20 files changed:
src/FeaturesAPI/FeaturesAPI_NormalToFace.cpp
src/FeaturesAPI/FeaturesAPI_NormalToFace.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/CreateNormalToFace_widget.xml
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
src/FeaturesPlugin/Test/TestNormalToFace.py [new file with mode: 0644]
src/FeaturesPlugin/doc/FeaturesPlugin.rst
src/FeaturesPlugin/doc/TUI_NormalToFaceFeature.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/createNormalToFace.py [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py [new file with mode: 0644]
src/FeaturesPlugin/doc/images/normal.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/normalToFacePropertyPanel.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/normalToFaceResult.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/normalToFaceResultwithVertex.png [new file with mode: 0644]
src/FeaturesPlugin/doc/normalToFaceFeature.rst [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml

index 2875a9f977de9773e00542e168ab203f9eb02839..fbc7bd65086e772b725f654e17b802902c790fe4 100644 (file)
@@ -25,7 +25,7 @@
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 
-
+//=================================================================================================
 FeaturesAPI_NormalToFace::
           FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature)
   : ModelHighAPI_Interface(theFeature)
@@ -33,6 +33,7 @@ FeaturesAPI_NormalToFace::
   initialize();
 }
 
+//=================================================================================================
 FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
                                     const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                     const ModelHighAPI_Selection& theBaseFace,
@@ -47,6 +48,7 @@ FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
   }
 }
 
+//=================================================================================================
 FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
                                     const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                     const ModelHighAPI_Selection& theBaseFace)
@@ -59,21 +61,23 @@ FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
   }
 }
 
+//=================================================================================================
 FeaturesAPI_NormalToFace::~FeaturesAPI_NormalToFace()
 {
 }
 
+//=================================================================================================
 void FeaturesAPI_NormalToFace::dump(ModelHighAPI_Dumper& theDumper) const
 {
   FeaturePtr aBase = feature();
   const std::string& aDocName = theDumper.name(aBase->document());
 
   AttributeSelectionPtr anAttrObject;
-    anAttrObject = aBase->selection(FeaturesPlugin_CreateNormalToFace::OBJECTS_LIST_ID());
+    anAttrObject = aBase->selection(FeaturesPlugin_CreateNormalToFace::FACE_SELECTED_ID());
 
   theDumper << aBase << " = model.getNormal(" << aDocName << ", " << anAttrObject;
 
-  if ( !aBase->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())->value().empty()){
+  if (!aBase->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())->value().empty()){
 
     AttributeSelectionPtr anAttrVertex =
             aBase->selection(FeaturesPlugin_CreateNormalToFace::VERTEX_SELECTED_ID());
@@ -85,10 +89,9 @@ void FeaturesAPI_NormalToFace::dump(ModelHighAPI_Dumper& theDumper) const
 }
 
 //==================================================================================================
-
 NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
-                          const ModelHighAPI_Selection& theBaseFace,
-                          const ModelHighAPI_Selection& theOptionnelPoint)
+                    const ModelHighAPI_Selection& theBaseFace,
+                    const ModelHighAPI_Selection& theOptionnelPoint)
 {
 
   FeaturePtr aFeature =
@@ -101,6 +104,7 @@ NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
   return aNormalToface;
 }
 
+//=================================================================================================
 NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
                     const ModelHighAPI_Selection& theBaseFace)
 {
index a1ad491591b2a1742bd425d989db4076ed342619..f7c1facc06f55b571c270349489b7203c3058b38 100644 (file)
@@ -52,8 +52,8 @@ public:
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_NormalToFace();
 
-    INTERFACE_3(FeaturesPlugin_CreateNormalToFace::ID(),
-              faceSelected, FeaturesPlugin_CreateNormalToFace::OBJECTS_LIST_ID(),
+  INTERFACE_3(FeaturesPlugin_CreateNormalToFace::ID(),
+              faceSelected, FeaturesPlugin_CreateNormalToFace::FACE_SELECTED_ID(),
                               ModelAPI_AttributeSelection,
                               /** base face */,
               vertexSelected, FeaturesPlugin_CreateNormalToFace::VERTEX_SELECTED_ID(),
index 4777f6aeacce96d7d3b05e550aa3fddf7210550b..0375dd1d0290b3bafb6c3bfbb86b1cda60b8390c 100644 (file)
@@ -704,4 +704,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestFillet1D_Wire_3.py
                TestFillet1D_Wire_4.py
                TestFillet1D_Wire_5.py
+               TestNormalToFace.py
 )
index c2b4bece0c267abb0d2801c7af615f97ef142c9d..f7fc96d17ff0975d1e719aa2e308de97f19e2500 100644 (file)
@@ -1,5 +1,5 @@
 <source>
-  <shape_selector id="main_objects"
+  <shape_selector id="face"
                   label="Face"
                   tooltip="Select a face"
                   shape_types="face"
@@ -9,14 +9,13 @@
     <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
   </shape_selector>
   <optionalbox id="vertex_option" title="Option">
-    <shape_selector id="tool_objects"
+    <shape_selector id="vertex"
                     label="Vertex"
                     tooltip="Select a vertex"
                     shape_types="vertex"
                     default=""
                     geometrical_selection="true">
       <validator id="PartSet_DifferentObjects"/>
-      <!--validator id="GeomValidators_ShapeType" parameters="vertex"/-->
     </shape_selector>
   </optionalbox>
 </source>
index 4e9f7df11ca13d54443f17e74d4317a7b87defd0..14c8848ca791b2f3cc0e60f4443d08280af1c476 100644 (file)
 #include "FeaturesPlugin_CreateNormalToFace.h"
 
 #include <ModelAPI_AttributeSelection.h>
-#include <ModelAPI_AttributeDoubleArray.h>
-#include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
-#include <PrimitivesPlugin_Box.h>
-#include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Edge.h>
 #include <Config_PropManager.h>
-#include <ModelAPI_ResultBody.h>
 #include <GeomAlgoAPI_NormalToFace.h>
-#include <GeomAPI_ShapeExplorer.h>
-#include <GeomAPI_Ax1.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Dir.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 
 #include <iomanip>
 #include <sstream>
-#include <iostream>
 
+//=================================================================================================
 FeaturesPlugin_CreateNormalToFace::FeaturesPlugin_CreateNormalToFace()
 {
 }
 
+//=================================================================================================
 void FeaturesPlugin_CreateNormalToFace::initAttributes()
 {
   // attribute for object selected
-  data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(FACE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(VERTEX_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
   // attributes for result message and values
   data()->addAttribute(VERTEX_OPTION_ID(), ModelAPI_AttributeString::typeId());
@@ -60,35 +54,37 @@ void FeaturesPlugin_CreateNormalToFace::initAttributes()
 
 }
 
+//=================================================================================================
 void FeaturesPlugin_CreateNormalToFace::execute()
 {
-AttributeSelectionPtr aSelectionFace = selection(OBJECTS_LIST_ID());
-AttributeSelectionPtr aSelectionPoint = selection(VERTEX_SELECTED_ID());
 
-GeomShapePtr aShape;
-GeomShapePtr aShapePoint;
+  AttributeSelectionPtr aSelectionFace = selection(FACE_SELECTED_ID());
+  AttributeSelectionPtr aSelectionPoint = selection(VERTEX_SELECTED_ID());
+
+  GeomShapePtr aShape;
+  GeomShapePtr aShapePoint;
   if(!string(VERTEX_OPTION_ID())->value().empty())
-{
-  if (aSelectionPoint && aSelectionPoint->isInitialized()) {
-    aShapePoint = aSelectionPoint->value();
-    if (!aShapePoint && aSelectionPoint->context())
-      aShapePoint = aSelectionPoint->context()->shape();
-    }
-}
+  {
+    if (aSelectionPoint && aSelectionPoint->isInitialized()) {
+      aShapePoint = aSelectionPoint->value();
+      if (!aShapePoint && aSelectionPoint->context())
+        aShapePoint = aSelectionPoint->context()->shape();
+      }
+  }
 
-if (aSelectionFace && aSelectionFace->isInitialized()) {
-  aShape = aSelectionFace->value();
-  if (!aShape && aSelectionFace->context())
-    aShape = aSelectionFace->context()->shape();
-}
+  if (aSelectionFace && aSelectionFace->isInitialized()) {
+    aShape = aSelectionFace->value();
+    if (!aShape && aSelectionFace->context())
+      aShape = aSelectionFace->context()->shape();
+  }
 
-if (aShape){
-  std::string aError;
-  std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
-  if( !GeomAlgoAPI_NormalToFace::normal(aShape,
-                                        aShapePoint,
-                                        theNormal,
-                                        aError))
+  if (aShape) {
+    std::string aError;
+    std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
+    if( !GeomAlgoAPI_NormalToFace::normal(aShape,
+                                          aShapePoint,
+                                          theNormal,
+                                          aError))
       setError("Error in bounding box calculation :" +  aError);
 
     GeomDirPtr theDir;
@@ -98,8 +94,8 @@ if (aShape){
         theDir = theNormal->line()->direction();
       }
     }
-    aPnt->translate(theDir, 100 );
-    
+    aPnt->translate(theDir, 100);
+
     std::shared_ptr<GeomAPI_Edge> anEdge =
                         GeomAlgoAPI_EdgeBuilder::line(theNormal->firstPoint(),
                                                       aPnt);
@@ -111,6 +107,7 @@ if (aShape){
   }
 }
 
+//=================================================================================================
 void FeaturesPlugin_CreateNormalToFace::attributeChanged(const std::string& theID)
 {
 }
index 77ad40c52d351109756d992c0d0786ee5f0d6771..83210022ba51edcd53bc139aef07ceefefca7ce6 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <GeomAPI_IPresentable.h>
 #include <GeomAPI_IScreenParams.h>
-#include <GeomAlgoAPI_Box.h>
 
 /// \class FeaturesPlugin_CreateNormalToFace
 /// \ingroup Plugins
@@ -47,16 +46,16 @@ public:
   }
 
   /// Attribute name for face selected.
-  inline static const std::string& OBJECTS_LIST_ID()
+  inline static const std::string& FACE_SELECTED_ID()
   {
-    static const std::string MY_OBJECTS_LIST_ID("main_objects");
-    return MY_OBJECTS_LIST_ID;
+    static const std::string MY_FACE_ID("face");
+    return MY_FACE_ID;
   }
 
   /// Attribute name for vertex selected.
   inline static const std::string& VERTEX_SELECTED_ID()
   {
-    static const std::string MY_VERTEX_SELECTED_ID("tool_objects");
+    static const std::string MY_VERTEX_SELECTED_ID("vertex");
     return MY_VERTEX_SELECTED_ID;
   }
 
index ab98fed58ddee2a52e53a1ea6b1a20cc41b0b3e6..a70e8fd7995ce974e1de536a0d15a10d292b3ee6 100644 (file)
@@ -20,7 +20,6 @@
 #include "FeaturesPlugin_NormalToFace.h"
 
 #include <ModelAPI_AttributeSelection.h>
-#include <ModelAPI_AttributeDoubleArray.h>
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Edge.h>
 #include <Config_PropManager.h>
-#include <ModelAPI_ResultBody.h>
 #include <GeomAlgoAPI_NormalToFace.h>
-#include <GeomAPI_ShapeExplorer.h>
-#include <GeomAPI_Ax1.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Dir.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 
 #include <iomanip>
 #include <sstream>
-#include <iostream>
 
+//=================================================================================================
 FeaturesPlugin_NormalToFace::FeaturesPlugin_NormalToFace()
 {
 }
 
+//=================================================================================================
 void FeaturesPlugin_NormalToFace::initAttributes()
 {
   // attribute for object selected
-  data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(FACE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(VERTEX_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
   // attributes for result message and values
   data()->addAttribute(CREATENORMAL_ID(), ModelAPI_AttributeBoolean::typeId());
@@ -63,35 +60,35 @@ void FeaturesPlugin_NormalToFace::initAttributes()
 
 }
 
+//=================================================================================================
 void FeaturesPlugin_NormalToFace::execute()
 {
-AttributeSelectionPtr aSelectionFace = selection(OBJECTS_LIST_ID());
-AttributeSelectionPtr aSelectionPoint = selection(VERTEX_SELECTED_ID());
-
-GeomShapePtr aShape;
-GeomShapePtr aShapePoint;
-  if(!string(VERTEX_OPTION_ID())->value().empty())
-{
-  if (aSelectionPoint && aSelectionPoint->isInitialized()) {
-    aShapePoint = aSelectionPoint->value();
-    if (!aShapePoint && aSelectionPoint->context())
-      aShapePoint = aSelectionPoint->context()->shape();
+  AttributeSelectionPtr aSelectionFace = selection(FACE_SELECTED_ID());
+  AttributeSelectionPtr aSelectionPoint = selection(VERTEX_SELECTED_ID());
+
+  GeomShapePtr aShape;
+  GeomShapePtr aShapePoint;
+  if (!string(VERTEX_OPTION_ID())->value().empty()) {
+    if (aSelectionPoint && aSelectionPoint->isInitialized()) {
+      aShapePoint = aSelectionPoint->value();
+      if (!aShapePoint && aSelectionPoint->context())
+        aShapePoint = aSelectionPoint->context()->shape();
     }
-}
+  }
 
-if (aSelectionFace && aSelectionFace->isInitialized()) {
-  aShape = aSelectionFace->value();
-  if (!aShape && aSelectionFace->context())
-    aShape = aSelectionFace->context()->shape();
-}
+  if (aSelectionFace && aSelectionFace->isInitialized()) {
+    aShape = aSelectionFace->value();
+      if (!aShape && aSelectionFace->context())
+        aShape = aSelectionFace->context()->shape();
+  }
 
-if (aShape){
-  std::string aError;
-  std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
-  if( !GeomAlgoAPI_NormalToFace::normal(aShape,
-                                        aShapePoint,
-                                        theNormal,
-                                        aError))
+  if (aShape) {
+    std::string aError;
+    std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
+    if( !GeomAlgoAPI_NormalToFace::normal(aShape,
+                                          aShapePoint,
+                                          theNormal,
+                                          aError))
       setError("Error in bounding box calculation :" +  aError);
 
     GeomDirPtr theDir;
@@ -101,26 +98,23 @@ if (aShape){
         theDir = theNormal->line()->direction();
       }
     }
-    aPnt->translate(theDir, 100 );
-    
+    aPnt->translate(theDir, 100);
+
     std::shared_ptr<GeomAPI_Edge> anEdge =
-                        GeomAlgoAPI_EdgeBuilder::line(theNormal->firstPoint(),
-                                                      aPnt);
+                      GeomAlgoAPI_EdgeBuilder::line(theNormal->firstPoint(), aPnt);
 
     ResultConstructionPtr aConstr = document()->createConstruction(data());
     aConstr->setInfinite(true);
     aConstr->setShape(anEdge);
     setResult(aConstr);
   }
-  
-  if(boolean(CREATENORMAL_ID())->value())
-  {
-    if( !myCreateFeature.get() )
+
+  if (boolean(CREATENORMAL_ID())->value()) {
+    if (!myCreateFeature.get())
       createNormal();
     updateNormal();
-  }else{
-    if( myCreateFeature.get() )
-    {
+  } else {
+    if (myCreateFeature.get()) {
       myCreateFeature->eraseResults();
       SessionPtr aSession = ModelAPI_Session::get();
       DocumentPtr aDoc =  aSession->activeDocument();
@@ -130,10 +124,11 @@ if (aShape){
   }
 }
 
+//=================================================================================================
 void FeaturesPlugin_NormalToFace::attributeChanged(const std::string& theID)
 {
-   if (theID == OBJECTS_LIST_ID()) {
-    if( myCreateFeature.get() )
+   if (theID == FACE_SELECTED_ID()) {
+    if (myCreateFeature.get())
       updateNormal();
   }
 }
@@ -142,7 +137,7 @@ void FeaturesPlugin_NormalToFace::attributeChanged(const std::string& theID)
 void FeaturesPlugin_NormalToFace::createNormal()
 {
   SessionPtr aSession = ModelAPI_Session::get();
-  
+
   DocumentPtr aDoc =  aSession->activeDocument();
 
   if (aDoc.get()) {
@@ -150,17 +145,17 @@ void FeaturesPlugin_NormalToFace::createNormal()
   }
 }
 
+//=================================================================================================
 void FeaturesPlugin_NormalToFace::updateNormal()
 {
-  myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::OBJECTS_LIST_ID())
-                        ->setValue( selection(OBJECTS_LIST_ID())->context() ,
-                                    selection(OBJECTS_LIST_ID())->value() );
+  myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::FACE_SELECTED_ID())
+                        ->setValue( selection(FACE_SELECTED_ID())->context() ,
+                                    selection(FACE_SELECTED_ID())->value() );
 
   myCreateFeature->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())
                         ->setValue( string(VERTEX_OPTION_ID())->value());
 
-  if(!string(VERTEX_OPTION_ID())->value().empty())
-  {
+  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() );
index 1b171ff9e6c68630a90087c0a98395643988a08b..261b297707f7650af9ddac9d5217fd20328944e8 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <GeomAPI_IPresentable.h>
 #include <GeomAPI_IScreenParams.h>
-#include <GeomAlgoAPI_Box.h>
 
 /// \class FeaturesPlugin_NormalToFace
 /// \ingroup Plugins
@@ -47,16 +46,16 @@ public:
   }
 
   /// Attribute name for face selected.
-  inline static const std::string& OBJECTS_LIST_ID()
+  inline static const std::string& FACE_SELECTED_ID()
   {
-    static const std::string MY_OBJECTS_LIST_ID("main_objects");
-    return MY_OBJECTS_LIST_ID;
+    static const std::string MY_FACE_SELECTED_ID("face");
+    return MY_FACE_SELECTED_ID;
   }
 
   /// Attribute name for vertex selected.
   inline static const std::string& VERTEX_SELECTED_ID()
   {
-    static const std::string MY_VERTEX_SELECTED_ID("tool_objects");
+    static const std::string MY_VERTEX_SELECTED_ID("vertex");
     return MY_VERTEX_SELECTED_ID;
   }
 
@@ -92,7 +91,7 @@ public:
 
   private:
 
-  void createNormal(); 
+  void createNormal();
   void updateNormal();
   FeaturePtr myCreateFeature;
 
index e130762e46b201bffc668f0924274762054cfa02..a0b818a56671cbfe9af46ec350576fba6b9df645 100644 (file)
@@ -1,5 +1,5 @@
 <source>
-  <shape_selector id="main_objects"
+  <shape_selector id="face"
                   label="Face"
                   tooltip="Select a face"
                   shape_types="face"
@@ -9,14 +9,13 @@
     <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
   </shape_selector>
   <optionalbox id="vertex_option" title="Option">
-    <shape_selector id="tool_objects"
+    <shape_selector id="vertex"
                     label="Vertex"
                     tooltip="Select a vertex"
                     shape_types="vertex"
                     default=""
                     geometrical_selection="true">
       <validator id="PartSet_DifferentObjects"/>
-      <!--validator id="GeomValidators_ShapeType" parameters="vertex"/-->
     </shape_selector>
   </optionalbox>
   <boolvalue id="createnormal" label="Create normal" default="false"/>
diff --git a/src/FeaturesPlugin/Test/TestNormalToFace.py b/src/FeaturesPlugin/Test/TestNormalToFace.py
new file mode 100644 (file)
index 0000000..179b224
--- /dev/null
@@ -0,0 +1,66 @@
+# Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+      Unit test of ...
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+
+import os
+import math
+
+from ModelAPI import *
+from salome.shaper import model
+
+
+__updated__ = "2020-11-12"
+
+
+#=========================================================================
+# test creating normal to face  
+#=========================================================================
+def test_Normal_to_face():
+
+    model.begin()
+    file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Brep","box1.brep")
+    partSet = model.moduleDocument()
+    Part_1 = model.addPart(partSet)
+    Part_1_doc = Part_1.document()
+    Import_1 = model.addImport(Part_1_doc,file_path)
+    model.do()
+    ### Create Normal
+    Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "box1_1/Shape_6"))
+    model.end()
+    
+    assert (len(Normal_1.results()) > 0)
+    assert(Normal_1.feature().error() == "")
+    anAxisResult = modelAPI_ResultConstruction(Normal_1.feature().firstResult())
+    assert (anAxisResult is not None)
+
+    
+if __name__ == '__main__':
+
+    test_Normal_to_face()
+        
+    #=========================================================================
+    # End of test
+    #=========================================================================
index fb8e2a344b707376d72df48edb52804796a2e7bf..11cddbe42199dbc60a3fa3b7e84e593ec8f1c9ab 100644 (file)
@@ -24,6 +24,7 @@ Features plug-in provides a set of common topological operations. It implements
    importResultFeature.rst
    linearCopyFeature.rst
    measurementFeature.rst
+   normalToFaceFeature.rst
    pipeFeature.rst
    placementFeature.rst
    recoverFeature.rst
diff --git a/src/FeaturesPlugin/doc/TUI_NormalToFaceFeature.rst b/src/FeaturesPlugin/doc/TUI_NormalToFaceFeature.rst
new file mode 100644 (file)
index 0000000..eb8b036
--- /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
diff --git a/src/FeaturesPlugin/doc/examples/createNormalToFace.py b/src/FeaturesPlugin/doc/examples/createNormalToFace.py
new file mode 100644 (file)
index 0000000..a1f9730
--- /dev/null
@@ -0,0 +1,15 @@
+from salome.shaper import model
+import os
+
+model.begin()
+file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Brep","box1.brep")
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Import_1 = model.addImport(Part_1_doc,file_path)
+model.do()
+    
+### Create BoundingBox
+Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "box1_1/Shape_6"))
+model.do()
+model.end()
diff --git a/src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py b/src/FeaturesPlugin/doc/examples/createNormalToFaceAtVertex.py
new file mode 100644 (file)
index 0000000..c59aa67
--- /dev/null
@@ -0,0 +1,17 @@
+
+from salome.shaper import model
+import os
+
+model.begin()
+file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Brep","box1.brep")
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Import_1 = model.addImport(Part_1_doc,file_path)
+model.do()
+    
+### Create BoundingBox
+Normal_1 = model.getNormal(Part_1_doc, model.selection("FACE", "box1_1/Shape_6"), 
+                                    model.selection("VERTEX", "[box1_1/Shape_2][box1_1/Shape_4][box1_1/Shape_6]"))
+model.do()
+model.end()
diff --git a/src/FeaturesPlugin/doc/images/normal.png b/src/FeaturesPlugin/doc/images/normal.png
new file mode 100644 (file)
index 0000000..1608076
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/normal.png differ
diff --git a/src/FeaturesPlugin/doc/images/normalToFacePropertyPanel.png b/src/FeaturesPlugin/doc/images/normalToFacePropertyPanel.png
new file mode 100644 (file)
index 0000000..6ed5e80
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/normalToFacePropertyPanel.png differ
diff --git a/src/FeaturesPlugin/doc/images/normalToFaceResult.png b/src/FeaturesPlugin/doc/images/normalToFaceResult.png
new file mode 100644 (file)
index 0000000..ecfb260
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/normalToFaceResult.png differ
diff --git a/src/FeaturesPlugin/doc/images/normalToFaceResultwithVertex.png b/src/FeaturesPlugin/doc/images/normalToFaceResultwithVertex.png
new file mode 100644 (file)
index 0000000..98f1aa8
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/normalToFaceResultwithVertex.png differ
diff --git a/src/FeaturesPlugin/doc/normalToFaceFeature.rst b/src/FeaturesPlugin/doc/normalToFaceFeature.rst
new file mode 100644 (file)
index 0000000..b4f9b16
--- /dev/null
@@ -0,0 +1,71 @@
+.. |normalToFace.icon|    image:: images/normal.png
+
+Normal to a face
+================
+
+The **Normal to a face** feature displays the normal to a face. A vertex can be specified to indicate the position of the normal else the center of face is used. 
+
+the resulting normal can be created via a dedicated check-box **Create normal**. If this last is checked corresponding result and feature would be created. 
+
+If the check-box **Create normal** isn't checked, **Apply** button does not generate any result and has the same effect as **Cancel** for this feature.  
+
+To display the normal to a face in the active part:
+
+#. select in the Main Menu *Inspection - > Normal to a face* item  or
+#. click |normalToFace.icon| **Normal to a face** button in the toolbar
+
+The property panel is shown below.
+
+.. figure:: images/normalToFacePropertyPanel.png
+   :align: center
+
+   Normal to a face
+
+
+Input fields:
+
+- **Face** contains face selected in 3D OCC viewer or object browser. 
+- **Vertex** contains optionnal vertex selected in 3D OCC viewer or object browser. 
+- **Create normal** check-box allow the creation of the normal (result and feature). 
+
+**TUI Command**:
+
+.. py:function:: model.getNormal(Part, face)
+    :param part: The current part object.
+    :param object: A face in format *model.selection("FACE", face)*.
+    :return: Created normal to a face at center.
+
+Result
+""""""
+
+Result of **Normal to a face**.
+
+.. figure:: images/normalToFaceResult.png
+   :align: center
+
+   Normal to a face
+
+**See Also** a sample TUI Script of :ref:`tui_create_Normal_To_Face` operation.
+
+
+**TUI Command**:
+
+.. py:function:: model.getNormal(Part, face, vertex)
+    :param part: The current part object.
+    :param object: A face in format *model.selection("FACE", face)*.
+    :param object: A vertex in format *model.selection("VERTEX", vertex)*.
+    :return: Created normal to a face at vertex.
+
+Result
+""""""
+
+Result of **Normal to aface** where **Vertex** is selecteted.
+
+.. figure:: images/normalToFaceResultwithVertex.png
+   :align: center
+
+   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
index 3e17f562a530b776a1d0fb85f2327133a51cdf2b..4a480d18fbbc5dd8fa5684103b8723d3893f87cc 100644 (file)
     </group>
     <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="measurementFeature.html"> 
+               icon="icons/Features/normale.png" helpfile="normalToFaceFeature.html"> 
         <source path="NormalToFace_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="measurementFeature.html" internal="1"> 
+               icon="icons/Features/axis.png" helpfile="normalToFaceFeature.html" internal="1"> 
         <source path="CreateNormalToFace_widget.xml"/>
       </feature>
     </group>