]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Modification for "create normal" functionality
authorJérôme <jerome.lucas@cesgenslab.fr>
Mon, 16 Nov 2020 18:25:18 +0000 (19:25 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Mon, 16 Nov 2020 18:25:18 +0000 (19:25 +0100)
src/FeaturesAPI/FeaturesAPI_NormalToFace.cpp
src/FeaturesAPI/FeaturesAPI_NormalToFace.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/CreateNormalToFace_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_NormalToFace.cpp
src/FeaturesPlugin/FeaturesPlugin_NormalToFace.h
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/plugin-Features.xml

index d6453ad805e2d61657b55865d46065b23b21d0b1..2875a9f977de9773e00542e168ab203f9eb02839 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "FeaturesAPI_NormalToFace.h"
 
+#include <FeaturesPlugin_CreateNormalToFace.h>
 
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Selection.h>
@@ -39,9 +40,9 @@ FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
 :ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
-    fillAttribute(theBaseFace, myfaceselected);
-    fillAttribute(theOptionnelPoint, myvertexselected);
-    feature()->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->setValue("true");
+    fillAttribute(theBaseFace, myfaceSelected);
+    fillAttribute(theOptionnelPoint, myvertexSelected);
+    feature()->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())->setValue("true");
     execute();
   }
 }
@@ -52,8 +53,8 @@ FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
 :ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
-    fillAttribute(theBaseFace, myfaceselected);
-    feature()->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->setValue("");
+    fillAttribute(theBaseFace, myfaceSelected);
+    feature()->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())->setValue("");
     execute();
   }
 }
@@ -68,21 +69,18 @@ void FeaturesAPI_NormalToFace::dump(ModelHighAPI_Dumper& theDumper) const
   const std::string& aDocName = theDumper.name(aBase->document());
 
   AttributeSelectionPtr anAttrObject;
-    anAttrObject = aBase->selection(FeaturesPlugin_NormalToFace::OBJECTS_LIST_ID());
+    anAttrObject = aBase->selection(FeaturesPlugin_CreateNormalToFace::OBJECTS_LIST_ID());
 
   theDumper << aBase << " = model.getNormal(" << aDocName << ", " << anAttrObject;
 
-  if ( !aBase->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->value().empty()){
+  if ( !aBase->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())->value().empty()){
 
     AttributeSelectionPtr anAttrVertex =
-            aBase->selection(FeaturesPlugin_NormalToFace::VERTEX_SELECTED_ID());
+            aBase->selection(FeaturesPlugin_CreateNormalToFace::VERTEX_SELECTED_ID());
 
     theDumper << ", " << anAttrVertex;
   }
 
-  //if (!aBase->data()->version().empty())
-  //  theDumper << ", keepSubResults = True";
-
   theDumper << ")" << std::endl;
 }
 
@@ -94,7 +92,7 @@ NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
 {
 
   FeaturePtr aFeature =
-      thePart->addFeature(FeaturesAPI_NormalToFace::ID());
+      thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
 
   NormalPtr aNormalToface;
 
@@ -108,7 +106,7 @@ NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
 {
 
   FeaturePtr aFeature =
-      thePart->addFeature(FeaturesAPI_NormalToFace::ID());
+      thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
 
   NormalPtr aNormalToface;
 
index 10554383c89e1a6a9763f081bce341eb59ad110e..a1ad491591b2a1742bd425d989db4076ed342619 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "FeaturesAPI.h"
 
-#include <FeaturesPlugin_NormalToFace.h>
+#include <FeaturesPlugin_CreateNormalToFace.h>
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
@@ -52,14 +52,14 @@ public:
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_NormalToFace();
 
-    INTERFACE_3(FeaturesPlugin_NormalToFace::ID(),
-              faceselected, FeaturesPlugin_NormalToFace::OBJECTS_LIST_ID(),
+    INTERFACE_3(FeaturesPlugin_CreateNormalToFace::ID(),
+              faceSelected, FeaturesPlugin_CreateNormalToFace::OBJECTS_LIST_ID(),
                               ModelAPI_AttributeSelection,
                               /** base face */,
-              vertexselected, FeaturesPlugin_NormalToFace::VERTEX_SELECTED_ID(),
+              vertexSelected, FeaturesPlugin_CreateNormalToFace::VERTEX_SELECTED_ID(),
                               ModelAPI_AttributeSelection,
                               /** vetex option */,
-              vertexoption, FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID(),
+              vertexOption, FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID(),
                            ModelAPI_AttributeString,
                            /** option */)
 
index 3e8ae8999531fe17a6bc921e1934f6f55fb00498..4777f6aeacce96d7d3b05e550aa3fddf7210550b 100644 (file)
@@ -71,6 +71,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_Fillet1D.h
     FeaturesPlugin_Measurement.h
     FeaturesPlugin_NormalToFace.h
+    FeaturesPlugin_CreateNormalToFace.h
     FeaturesPlugin_FusionFaces.h
     FeaturesPlugin_RemoveResults.h
     FeaturesPlugin_Chamfer.h
@@ -119,6 +120,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_Fillet1D.cpp
     FeaturesPlugin_Measurement.cpp
     FeaturesPlugin_NormalToFace.cpp
+    FeaturesPlugin_CreateNormalToFace.cpp
     FeaturesPlugin_FusionFaces.cpp
     FeaturesPlugin_RemoveResults.cpp
     FeaturesPlugin_Chamfer.cpp
@@ -158,6 +160,7 @@ SET(XML_RESOURCES
   fillet1d_widget.xml
   measurement_widget.xml
   NormalToFace_widget.xml
+  CreateNormalToFace_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
new file mode 100644 (file)
index 0000000..c2b4bec
--- /dev/null
@@ -0,0 +1,22 @@
+<source>
+  <shape_selector id="main_objects"
+                  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="tool_objects"
+                    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>
diff --git a/src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.cpp b/src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.cpp
new file mode 100644 (file)
index 0000000..4e9f7df
--- /dev/null
@@ -0,0 +1,118 @@
+// Copyright (C) 2018-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
+//
+
+#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 <ModelAPI_ResultConstruction.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(VERTEX_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
+  // attributes for result message and values
+  data()->addAttribute(VERTEX_OPTION_ID(), ModelAPI_AttributeString::typeId());
+
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERTEX_SELECTED_ID());
+
+}
+
+void FeaturesPlugin_CreateNormalToFace::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();
+    }
+}
+
+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))
+      setError("Error in bounding box calculation :" +  aError);
+
+    GeomDirPtr theDir;
+    std::shared_ptr<GeomAPI_Pnt> aPnt = theNormal->lastPoint();
+    if (theNormal.get()) {
+      if (theNormal->isLine()) {
+        theDir = theNormal->line()->direction();
+      }
+    }
+    aPnt->translate(theDir, 100 );
+    
+    std::shared_ptr<GeomAPI_Edge> anEdge =
+                        GeomAlgoAPI_EdgeBuilder::line(theNormal->firstPoint(),
+                                                      aPnt);
+
+    ResultConstructionPtr aConstr = document()->createConstruction(data());
+    aConstr->setInfinite(true);
+    aConstr->setShape(anEdge);
+    setResult(aConstr);
+  }
+}
+
+void FeaturesPlugin_CreateNormalToFace::attributeChanged(const std::string& theID)
+{
+}
+
+
diff --git a/src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.h b/src/FeaturesPlugin/FeaturesPlugin_CreateNormalToFace.h
new file mode 100644 (file)
index 0000000..77ad40c
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2018-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
+//
+
+#ifndef FeaturesPlugin_CreateNormalToFace_H_
+#define FeaturesPlugin_CreateNormalToFace_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_IScreenParams.h>
+#include <GeomAlgoAPI_Box.h>
+
+/// \class FeaturesPlugin_CreateNormalToFace
+/// \ingroup Plugins
+/// \brief Feature for construct normal to face
+
+class FeaturesPlugin_CreateNormalToFace : public ModelAPI_Feature
+{
+public:
+   inline static const std::string& ID()
+  {
+    static const std::string MY_ID("Normal");
+    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& OBJECTS_LIST_ID()
+  {
+    static const std::string MY_OBJECTS_LIST_ID("main_objects");
+    return MY_OBJECTS_LIST_ID;
+  }
+
+  /// Attribute name for vertex selected.
+  inline static const std::string& VERTEX_SELECTED_ID()
+  {
+    static const std::string MY_VERTEX_SELECTED_ID("tool_objects");
+    return MY_VERTEX_SELECTED_ID;
+  }
+
+  /// Attribute name of vertex option.
+  inline static const std::string& VERTEX_OPTION_ID()
+  {
+    static const std::string MY_VERTEX_OPTION_ID("vertex_option");
+    return MY_VERTEX_OPTION_ID;
+  }
+
+  /// Performs the algorithm and stores results it in the data structure.
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_CreateNormalToFace();
+
+};
+
+#endif
index 87dc63683bae9d4f5f35438a809402c8f3f5f2bd..ab98fed58ddee2a52e53a1ea6b1a20cc41b0b3e6 100644 (file)
@@ -26,6 +26,8 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Edge.h>
 #include <Config_PropManager.h>
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_Dir.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <ModelAPI_ResultConstruction.h>
 
+#include <FeaturesPlugin_CreateNormalToFace.h>
+
 #include <iomanip>
 #include <sstream>
+#include <iostream>
 
 FeaturesPlugin_NormalToFace::FeaturesPlugin_NormalToFace()
 {
@@ -59,65 +65,106 @@ void FeaturesPlugin_NormalToFace::initAttributes()
 
 void FeaturesPlugin_NormalToFace::execute()
 {
-    AttributeSelectionPtr aSelectionFace = selection(OBJECTS_LIST_ID());
-    AttributeSelectionPtr aSelectionPoint = selection(VERTEX_SELECTED_ID());
+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();
-        }
+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))
-         setError("Error in bounding box calculation :" +  aError);
-
-      ResultBodyPtr aResultBody = document()->createBody(data());
-      if( boolean(CREATENORMAL_ID())->value() )
-      {
-        eraseResults();
-        std::shared_ptr<GeomAPI_Edge> anEdge =
-                            GeomAlgoAPI_EdgeBuilder::line(theNormal->firstPoint(),
-                                                          theNormal->lastPoint());
-
-        ResultConstructionPtr aConstr = document()->createConstruction(data());
-        aConstr->setInfinite(true);
-        aConstr->setShape(anEdge);
-        setResult(aConstr);
-      }else
-      {
-        eraseResults();
-        // Load the result
-        aResultBody->store(theNormal);
-        /*int aVertexIndex = 1;
-        for (GeomAPI_ShapeExplorer anExp(theNormal, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) {
-          std::string aVertexName = "VertexFromNormal_" + std::to_string((long long)aVertexIndex);
-          aResultBody->generated(anExp.current(), aVertexName);
-          aVertexIndex++;
-        }*/
-        setResult(aResultBody);
+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;
+    std::shared_ptr<GeomAPI_Pnt> aPnt = theNormal->lastPoint();
+    if (theNormal.get()) {
+      if (theNormal->isLine()) {
+        theDir = theNormal->line()->direction();
       }
     }
+    aPnt->translate(theDir, 100 );
+    
+    std::shared_ptr<GeomAPI_Edge> anEdge =
+                        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() )
+      createNormal();
+    updateNormal();
+  }else{
+    if( myCreateFeature.get() )
+    {
+      myCreateFeature->eraseResults();
+      SessionPtr aSession = ModelAPI_Session::get();
+      DocumentPtr aDoc =  aSession->activeDocument();
+      aDoc->removeFeature(myCreateFeature);
+      myCreateFeature.reset();
+    }
+  }
 }
 
 void FeaturesPlugin_NormalToFace::attributeChanged(const std::string& theID)
 {
+   if (theID == OBJECTS_LIST_ID()) {
+    if( myCreateFeature.get() )
+      updateNormal();
+  }
 }
 
+//=================================================================================================
+void FeaturesPlugin_NormalToFace::createNormal()
+{
+  SessionPtr aSession = ModelAPI_Session::get();
+  
+  DocumentPtr aDoc =  aSession->activeDocument();
+
+  if (aDoc.get()) {
+    myCreateFeature = aDoc->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
+  }
+}
 
+void FeaturesPlugin_NormalToFace::updateNormal()
+{
+  myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::OBJECTS_LIST_ID())
+                        ->setValue( selection(OBJECTS_LIST_ID())->context() ,
+                                    selection(OBJECTS_LIST_ID())->value() );
+
+  myCreateFeature->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())
+                        ->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() );
+  }
+
+  myCreateFeature->execute();
+}
\ No newline at end of file
index fa6e8b3dc7f261c664a91584e0a029436e0387ee..1b171ff9e6c68630a90087c0a98395643988a08b 100644 (file)
@@ -36,7 +36,7 @@ class FeaturesPlugin_NormalToFace : public ModelAPI_Feature
 public:
    inline static const std::string& ID()
   {
-    static const std::string MY_ID("Normal");
+    static const std::string MY_ID("NormalMacro");
     return MY_ID;
   }
 
@@ -84,9 +84,18 @@ public:
   /// \param theID identifier of changed attribute
   FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
+  FEATURESPLUGIN_EXPORT virtual bool isMacro() const { return true; }
+
   /// Use plugin manager for features creation
   FeaturesPlugin_NormalToFace();
 
+  private:
+
+  void createNormal(); 
+  void updateNormal();
+  FeaturePtr myCreateFeature;
+
 };
 
 #endif
index b4dabda191dfd3beb53f06cf8977e721ab9e9a0f..8c5e64ad65245ed80edcc0d44a88e6ad972aafa7 100644 (file)
@@ -34,6 +34,7 @@
 #include <FeaturesPlugin_Intersection.h>
 #include <FeaturesPlugin_Measurement.h>
 #include <FeaturesPlugin_NormalToFace.h>
+#include <FeaturesPlugin_CreateNormalToFace.h>
 #include <FeaturesPlugin_MultiRotation.h>
 #include <FeaturesPlugin_MultiTranslation.h>
 #include <FeaturesPlugin_Partition.h>
@@ -189,7 +190,9 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
   } else if (theFeatureID == FeaturesPlugin_Measurement::ID()) {
     return FeaturePtr(new FeaturesPlugin_Measurement);
   } else if (theFeatureID == FeaturesPlugin_NormalToFace::ID()) {
-    return FeaturePtr(new FeaturesPlugin_NormalToFace);  
+    return FeaturePtr(new FeaturesPlugin_NormalToFace);
+  } else if (theFeatureID == FeaturesPlugin_CreateNormalToFace::ID()) {
+    return FeaturePtr(new FeaturesPlugin_CreateNormalToFace);
   } else if (theFeatureID == FeaturesPlugin_RemoveResults::ID()) {
     return FeaturePtr(new FeaturesPlugin_RemoveResults);
   } else if (theFeatureID == FeaturesPlugin_Chamfer::ID()) {
index 50395cf4605c73369516a02e4b78b3727beda332..3e17f562a530b776a1d0fb85f2327133a51cdf2b 100644 (file)
       </feature>
     </group>
     <group id="Face">
-      <feature id="Normal" title="Normal to a face" tooltip="Calculate the normal to a face" auto_preview="true"
+      <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"> 
         <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"> 
+        <source path="CreateNormalToFace_widget.xml"/>
+      </feature>
     </group>
   </workbench>
 </plugin>