]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1343 validators update
authordbv <dbv@opencascade.com>
Tue, 5 Apr 2016 05:44:30 +0000 (08:44 +0300)
committerdbv <dbv@opencascade.com>
Tue, 5 Apr 2016 05:44:44 +0000 (08:44 +0300)
30 files changed:
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp [deleted file]
src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.h [deleted file]
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/FeaturesPlugin_Validators.h
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/extrusioncut_widget.xml
src/FeaturesPlugin/extrusionfuse_widget.xml
src/FeaturesPlugin/pipe_widget.xml
src/FeaturesPlugin/revolution_widget.xml
src/FeaturesPlugin/revolutioncut_widget.xml
src/FeaturesPlugin/revolutionfuse_widget.xml
src/GeomAPI/GeomAPI_Face.cpp
src/GeomAPI/GeomAPI_Face.h
src/GeomAPI/GeomAPI_PlanarEdges.cpp
src/GeomAPI/GeomAPI_PlanarEdges.h
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.h
src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Prism.h
src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Revolution.h
src/GeomValidators/GeomValidators_ShapeType.cpp
src/GeomValidators/GeomValidators_ShapeType.h

index 0ae589cc71404b6762c77f5848840b23585bb63d..3f940c5c0f6684d2095fae1d11ad5e727d8d72a8 100644 (file)
@@ -24,7 +24,6 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_RevolutionBoolean.h
     FeaturesPlugin_RevolutionCut.h
     FeaturesPlugin_RevolutionFuse.h
-    FeaturesPlugin_ValidatorExtrusionBase.h
     FeaturesPlugin_ValidatorTransform.h
     FeaturesPlugin_Validators.h
 )
@@ -49,7 +48,6 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_RevolutionBoolean.cpp
     FeaturesPlugin_RevolutionCut.cpp
     FeaturesPlugin_RevolutionFuse.cpp
-    FeaturesPlugin_ValidatorExtrusionBase.cpp
     FeaturesPlugin_ValidatorTransform.cpp
     FeaturesPlugin_Validators.cpp
 )
index 0b5a103ceb74a3e604583f174019fa0a9243e37e..8c5f797caa9e1e3ab2b2533c965a02acd9bb2bae 100644 (file)
@@ -220,7 +220,7 @@ bool FeaturesPlugin_CompositeSketch::isMakeShapeValid(const std::shared_ptr<Geom
 {
   // Check that algo is done.
   if(!theMakeShape->isDone()) {
-    setError("Error:" + getKind() + "algorithm failed.");
+    setError("Error: " + getKind() + " algorithm failed.");
     return false;
   }
 
index 20b7c254ae2c0148e193db24eea484b9143253eb..16333c306bb5e8fe98aa113255f0dc5c7e80bd9d 100644 (file)
 
 #include <GeomAlgoAPI_Prism.h>
 
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+
 //=================================================================================================
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
 {
@@ -78,6 +82,23 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   // Getting base shapes.
   getBaseShapes(theBaseShapes);
 
+  //Getting direction.
+  std::shared_ptr<GeomAPI_Dir> aDir;
+  std::shared_ptr<GeomAPI_Edge> anEdge;
+  AttributeSelectionPtr aSelection = selection(DIRECTION_OBJECT_ID());
+  if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) {
+    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aSelection->value()));
+  } else if(aSelection->context().get() &&
+            aSelection->context()->shape().get() &&
+            aSelection->context()->shape()->isEdge()) {
+    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aSelection->context()->shape()));
+  }
+  if(anEdge.get()) {
+    if(anEdge->isLine()) {
+      aDir = anEdge->line()->direction();
+    }
+  }
+
   // Getting sizes.
   double aToSize = 0.0;
   double aFromSize = 0.0;
@@ -95,7 +116,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   GeomShapePtr aFromShape;
 
   if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
-    AttributeSelectionPtr aSelection = selection(TO_OBJECT_ID());
+    aSelection = selection(TO_OBJECT_ID());
     if(aSelection.get()) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
       if(!aToShape.get() && aSelection->context().get()) {
@@ -115,7 +136,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   for(ListOfShape::const_iterator anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) {
     std::shared_ptr<GeomAPI_Shape> aBaseShape = *anIter;
 
-    std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape,
+    std::shared_ptr<GeomAlgoAPI_Prism> aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape, aDir,
                                                                         aToShape, aToSize,
                                                                         aFromShape, aFromSize));
     if(!isMakeShapeValid(aPrismAlgo)) {
index baa8a115077f6132f7e708612244cb2a4c9a9e14..1de58f332c830f1e5e033d01e3f8cb11afdf55ae 100644 (file)
@@ -17,7 +17,6 @@
 #include <FeaturesPlugin_RevolutionFuse.h>
 #include <FeaturesPlugin_Rotation.h>
 #include <FeaturesPlugin_ValidatorTransform.h>
-#include <FeaturesPlugin_ValidatorExtrusionBase.h>
 #include <FeaturesPlugin_Validators.h>
 
 #include <ModelAPI_Session.h>
@@ -37,12 +36,14 @@ FeaturesPlugin_Plugin::FeaturesPlugin_Plugin()
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
   aFactory->registerValidator("FeaturesPlugin_ValidatorTransform",
                               new FeaturesPlugin_ValidatorTransform);
-  aFactory->registerValidator("FeaturesPlugin_ValidatorExtrusionBase",
-                              new FeaturesPlugin_ValidatorExtrusionBase);
+  aFactory->registerValidator("FeaturesPlugin_ValidatorCompositeLauncher",
+                              new FeaturesPlugin_ValidatorCompositeLauncher);
   aFactory->registerValidator("FeaturesPlugin_ValidatorBaseForGeneration",
                               new FeaturesPlugin_ValidatorBaseForGeneration);
-  aFactory->registerValidator("FeaturesPlugin_PipeLocationsValidator",
-                              new FeaturesPlugin_PipeLocationsValidator);
+  aFactory->registerValidator("FeaturesPlugin_ValidatorPipeLocations",
+                              new FeaturesPlugin_ValidatorPipeLocations);
+  aFactory->registerValidator("FeaturesPlugin_ValidatorCanBeEmpty",
+                              new FeaturesPlugin_ValidatorCanBeEmpty);
 
   // register this plugin
   ModelAPI_Session::get()->registerPlugin(this);
index fb3d594adecb7942017b1ad51f6a5680cfa47f1d..ae67aa67a8734a9d07408168418147bbfa7214ad 100644 (file)
@@ -92,8 +92,14 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
     anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aSelection->context()->shape()));
   }
   if(anEdge.get()) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
+    if(anEdge->isLine()) {
+      anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
+                                                            anEdge->line()->direction()));
+    }
+  }
+
+  if(!anAxis.get()) {
+    return false;
   }
 
   // Getting angles.
diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp b/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp
deleted file mode 100755 (executable)
index 00f2dc1..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-#include "FeaturesPlugin_ValidatorExtrusionBase.h"
-
-#include "GeomValidators_FeatureKind.h"
-#include "GeomValidators_ShapeType.h"
-
-#include "ModelAPI_AttributeSelectionList.h"
-#include "ModelAPI_ResultPart.h"
-#include "ModelAPI_ResultBody.h"
-#include "ModelAPI_ResultCompSolid.h"
-#include "ModelAPI_Session.h"
-
-bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttribute,
-                                                const std::list<std::string>& theArguments,
-                                                std::string& theError) const
-{
-  bool aValid = true;
-
-  /*GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind();
-  // check whether the selection is on the sketch
-  bool aFeatureKindValid = aValidator->isValid(theAttribute, theArguments, theError);
-  if (!aFeatureKindValid) {
-    // check if selection has Face selected
-    GeomValidators_ShapeType* aShapeType = new GeomValidators_ShapeType();
-    std::list<std::string> anArguments;
-    anArguments.push_back("face");
-    aValid = aShapeType->isValid(theAttribute, anArguments, theError);
-  }*/
-  return aValid;
-}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.h b/src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.h
deleted file mode 100755 (executable)
index 240718b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        FeaturesPlugin_ValidatorExtrusionBase.h
-// Created:     16 Sep 2015
-// Author:      Natalia ERMOLAEVA
-
-#ifndef FeaturesPlugin_ValidatorExtrusionBase_H
-#define FeaturesPlugin_ValidatorExtrusionBase_H
-
-#include "ModelAPI_AttributeValidator.h"
-
-/** \class FeaturesPlugin_ValidatorExtrusionBase
- *  \ingroup Validators
- *  \brief A validator of selection
- */
-class FeaturesPlugin_ValidatorExtrusionBase : public ModelAPI_AttributeValidator
-{
- public:
-  /** \return true if attribute is valid
-   *  \param theAttribute the checked attribute
-   *  \param theArguments arguments of the attribute
-   *  \param theError error message
-   */
-  virtual bool isValid(const AttributePtr& theAttribute,
-                       const std::list<std::string>& theArguments,
-                       std::string& theError) const;
-};
-
-#endif
index f23ef720b49d6e361ac891b9b6ee3f478dd6c7fc..0c0e893ba24e1eed4fa20274f3baf6e204a439b6 100644 (file)
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_ResultConstruction.h>
 
+#include <GeomValidators_ShapeType.h>
+
 //=================================================================================================
-bool FeaturesPlugin_PipeLocationsValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+bool FeaturesPlugin_ValidatorPipeLocations::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                                     const std::list<std::string>& theArguments,
                                                     std::string& theError) const
 {
@@ -56,7 +58,7 @@ bool FeaturesPlugin_PipeLocationsValidator::isValid(const std::shared_ptr<ModelA
 }
 
 //=================================================================================================
-bool FeaturesPlugin_PipeLocationsValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
+bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature, std::string theAttribute)
 {
   return false;
 }
@@ -66,10 +68,15 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
                                                         const std::list<std::string>& theArguments,
                                                         std::string& theError) const
 {
+  if(theArguments.empty()) {
+    theError = "Validator parameters is empty.";
+    return false;
+  }
+
   // Checking attribute.
-  if(!isValidAttribute(theAttribute, theError)) {
+  if(!isValidAttribute(theAttribute, theArguments, theError)) {
     if(theError.empty()) {
-      theError = "Attribute contains shape with unacceptable type.";
+      theError = "Attribute contains unacceptable shape.";
     }
     return false;
   }
@@ -79,6 +86,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
 
 //=================================================================================================
 bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute,
+                                                                 const std::list<std::string>& theArguments,
                                                                  std::string& theError) const
 {
   if(!theAttribute.get()) {
@@ -91,7 +99,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
     AttributeSelectionListPtr aListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
     for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
       // If at least one attribute is invalid, the result is false.
-      if(!isValidAttribute(aListAttr->value(anIndex), theError)) {
+      if(!isValidAttribute(aListAttr->value(anIndex), theArguments, theError)) {
         return false;
       }
     }
@@ -142,14 +150,15 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
     }
 
     // Check that object is a shape with allowed type.
-    aShape = aContext->shape();
-    GeomAPI_Shape::ShapeType aShapeType = aShape->shapeType();
-    if(aShapeType != GeomAPI_Shape::VERTEX &&
-       aShapeType != GeomAPI_Shape::EDGE &&
-       aShapeType != GeomAPI_Shape::WIRE &&
-       aShapeType != GeomAPI_Shape::FACE) {
+    GeomValidators_ShapeType aShapeTypeValidator;
+    if(!aShapeTypeValidator.isValid(anAttr, theArguments, theError)) {
       theError = "Selected shape has unacceptable type. Acceptable types are: faces or wires on sketch, \
-                  whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.";
+                  whole sketch(if it has at least one face), and whole objects with shape types: ";
+      std::list<std::string>::const_iterator anIt = theArguments.cbegin();
+      theError += *anIt;
+      for(++anIt; anIt != theArguments.cend(); ++anIt) {
+        theError += ", " + *anIt;
+      }
       return false;
     }
 
@@ -159,4 +168,139 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
   }
 
   return true;
-}
\ No newline at end of file
+}
+
+//=================================================================================================
+bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theAttribute,
+                                                        const std::list<std::string>& theArguments,
+                                                        std::string& theError) const
+{
+  FeaturesPlugin_ValidatorBaseForGeneration aBaseValidator;
+
+  if(aBaseValidator.isValid(theAttribute, theArguments, theError)) {
+    return true;
+  }
+
+  // Check that face selected.
+  GeomValidators_ShapeType aShapeType;
+  std::list<std::string> anArguments;
+  anArguments.push_back("face");
+  if(aShapeType.isValid(theAttribute, anArguments, theError)) {
+    return true;
+  }
+
+  theError = "Selected shape is not suitable for this operation";
+
+  return false;
+}
+
+//=================================================================================================
+bool FeaturesPlugin_ValidatorCanBeEmpty::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                                 const std::list<std::string>& theArguments,
+                                                 std::string& theError) const
+{
+  if(theArguments.size() != 5 && theArguments.size() != 6) {
+    theError = "Validator should be used with 6 parameters for extrusion and with 5 for revolution.";
+    return false;
+  }
+
+  std::list<std::string>::const_iterator anArgsIt = theArguments.begin(), aLast = theArguments.end();
+
+  std::string aSelectedMethod;
+  if(theFeature->string(*anArgsIt)) {
+    aSelectedMethod = theFeature->string(*anArgsIt)->value();
+  }
+  ++anArgsIt;
+  std::string aCreationMethod = *anArgsIt;
+  ++anArgsIt;
+
+  AttributePtr aCheckAttribute = theFeature->attribute(*anArgsIt);
+  ++anArgsIt;
+
+  if(isShapesCanBeEmpty(aCheckAttribute, theError)) {
+    return true;
+  }
+
+  if(aSelectedMethod == aCreationMethod) {
+    ++anArgsIt;
+    ++anArgsIt;
+  }
+
+  for(; anArgsIt != theArguments.cend(); ++anArgsIt) {
+    AttributeSelectionPtr aSelAttr = theFeature->selection(*anArgsIt);
+    if(!aSelAttr.get()) {
+      theError = "Could not get selection attribute \"" + *anArgsIt + "\".";
+      return false;
+    }
+
+    GeomShapePtr aShape = aSelAttr->value();
+    if(!aShape.get()) {
+      ResultPtr aContext = aSelAttr->context();
+      if(!aContext.get()) {
+        theError = "Selection attribute \"" + *anArgsIt + "\" can not be empty.";
+        return false;
+      }
+
+      aShape = aContext->shape();
+    }
+
+    if(!aShape.get()) {
+      theError = "Selection attribute \"" + *anArgsIt + "\" can not be empty.";
+      return false;
+    }
+  }
+
+  return true;
+}
+
+//=================================================================================================
+bool FeaturesPlugin_ValidatorCanBeEmpty::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+  return false;
+}
+
+//=================================================================================================
+bool FeaturesPlugin_ValidatorCanBeEmpty::isShapesCanBeEmpty(const AttributePtr& theAttribute,
+                                                            std::string& theError) const
+{
+  if(!theAttribute.get()) {
+    return true;
+  }
+
+  std::string anAttributeType = theAttribute->attributeType();
+  if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+    AttributeSelectionListPtr aListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+    for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
+      // If at least one attribute is invalid, the result is false.
+      if(!isShapesCanBeEmpty(aListAttr->value(anIndex), theError)) {
+        return false;
+      }
+    }
+  } else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
+    // Getting context.
+    AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+    ResultPtr aContext = anAttr->context();
+    if(!aContext.get()) {
+      return false;
+    }
+
+    GeomShapePtr aShape = anAttr->value();
+    GeomShapePtr aContextShape = aContext->shape();
+    if(!aShape.get()) {
+      aShape = aContextShape;
+    }
+    if(!aShape.get()) {
+      return false;
+    }
+
+    if(aShape->shapeType() == GeomAPI_Shape::VERTEX ||
+       aShape->shapeType() == GeomAPI_Shape::EDGE ||
+       !aShape->isPlanar()) {
+      return false;
+    }
+  } else {
+    return false;
+  }
+
+  return true;
+}
index 2e0978b910ac0baea874ac7f85335901626b8f4b..e02b2ee63c2c15055cfb440472066c34ea5cedc2 100644 (file)
 #include <ModelAPI_AttributeValidator.h>
 #include <ModelAPI_FeatureValidator.h>
 
-/// \class FeaturesPlugin_PipeLocationsValidator
+/// \class FeaturesPlugin_ValidatorPipeLocations
 /// \ingroup Validators
 /// \brief Validator for the pipe locations.
-class FeaturesPlugin_PipeLocationsValidator : public ModelAPI_FeatureValidator
+class FeaturesPlugin_ValidatorPipeLocations: public ModelAPI_FeatureValidator
 {
  public:
   //! \return true if number of selected locations the same as number of selected bases, or empty.
@@ -32,7 +32,7 @@ class FeaturesPlugin_PipeLocationsValidator : public ModelAPI_FeatureValidator
 /// \ingroup Validators
 /// \brief A validator for selection base for generation. Allows to select faces on sketch,
 /// whole sketch(if it has at least one face), and following objects: vertex, edge, wire, face.
-class FeaturesPlugin_ValidatorBaseForGeneration : public ModelAPI_AttributeValidator
+class FeaturesPlugin_ValidatorBaseForGeneration: public ModelAPI_AttributeValidator
 {
 public:
   //! Returns true if attribute has selection type listed in the parameter arguments.
@@ -45,7 +45,47 @@ public:
 
 private:
   bool isValidAttribute(const AttributePtr& theAttribute,
+                        const std::list<std::string>& theArguments,
+                        std::string& theError) const;
+};
+
+/// \class FeaturesPlugin_ValidatorCompositeLauncher
+/// \ingroup Validators
+/// \brief A validator for selection at composite feature start
+class FeaturesPlugin_ValidatorCompositeLauncher: public ModelAPI_AttributeValidator
+{
+public:
+  //! Returns true if attribute has selection type listed in the parameter arguments.
+  //! \param[in] theAttribute the checked attribute.
+  //! \param[in] theArguments arguments of the attribute.
+  //! \param[out] theError error message.
+   virtual bool isValid(const AttributePtr& theAttribute,
+                        const std::list<std::string>& theArguments,
                         std::string& theError) const;
 };
 
+/// \class FeaturesPlugin_ValidatorCanBeEmpty
+/// \ingroup Validators
+/// \brief A validator for extrusion direction attribute and bounding planes for extrusion and
+///        revolution. Allows them to be empty if base objects are planar and do not contain
+///        vertices and edges.
+class FeaturesPlugin_ValidatorCanBeEmpty: public ModelAPI_FeatureValidator
+{
+public:
+  //! Returns true if attribute listed in the parameter arguments are planar.
+  //! \param[in] theFeature the checked feature.
+  //! \param[in] theArguments arguments of the attribute.
+  //! \param[out] theError error message.
+  virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
+
+  /// Returns true if the attribute in feature is not obligatory for the feature execution
+  virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
+
+private:
+  bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
+                          std::string& theError) const;
+};
+
 #endif
index 7a9043658d1c4dde7e7f1e58c2a9157b3c6e412d..ccf8af3afc1e41eb50b6679996218b11b6734f07 100644 (file)
@@ -13,7 +13,7 @@
                             label="Base objects:"
                             tooltip="Select a base objects"
                             type_choice="faces objects">
-    <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+    <validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="vertex,edge,wire,face,shell"/>
   </composite_multi_selector>
   <shape_selector id="direction_object"
                   icon=":icons/axis.png"
@@ -82,4 +82,5 @@
     </box>
   </toolbox>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,base,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,BySizes,base,to_object,from_object,direction_object"/>
 </source>
index fe01e3a419ad02d9baa9ad806d32459c02923edd..1f894d22344227ac2f139042c2a8434e87bcd6ee 100755 (executable)
@@ -15,7 +15,7 @@
       icon=":icons/sketch.png"
       tooltip="Select a sketch face"
       type_choice="Faces Objects">
-      <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+      <validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="face,shell"/>
     </composite_multi_selector>
     <shape_selector id="direction_object"
                     icon=":icons/axis.png"
@@ -91,4 +91,5 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,sketch_selection,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,BySizes,base,to_object,from_object,direction_object"/>
 </source>
index 1d1d19fc6df245752eee9bf290684257fc829093..eacd36c65859dd21351f2189c578b0c2f0b61969 100644 (file)
@@ -15,7 +15,7 @@
       icon=":icons/sketch.png"
       tooltip="Select a sketch face"
       type_choice="Faces Objects">
-      <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+      <validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="vertex,edge,wire,face,shell"/>
     </composite_multi_selector>
     <shape_selector id="direction_object"
                     icon=":icons/axis.png"
@@ -91,4 +91,5 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,sketch_selection,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,BySizes,base,to_object,from_object,direction_object"/>
 </source>
index f964308ccc21e6109216747b28cca534f8b82031..7535ac1b65d0621ccd076a21ba916689eafc64bd 100644 (file)
@@ -31,5 +31,5 @@
       </multi_selector>
     </box>
   </toolbox>
-  <validator id="FeaturesPlugin_PipeLocationsValidator"/>
+  <validator id="FeaturesPlugin_ValidatorPipeLocations"/>
 </source>
index ac18d203bae803276f87c7215c5a635391d7ea7e..78df77f664df63feba665e15158973b3da4f0f9c 100644 (file)
@@ -13,7 +13,7 @@
                             label="Base objects:"
                             tooltip="Select a base objects"
                             type_choice="faces objects">
-    <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+    <validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="vertex,edge,wire,face,shell"/>
   </composite_multi_selector>
   <shape_selector id="axis_object"
                   icon=":icons/axis.png"
@@ -82,4 +82,5 @@
     </box>
   </toolbox>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,base,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,ByAngles,base,to_object,from_object"/>
 </source>
index a42e01027b7a87e65256265e60334504840a979c..d0ad1d37a590065c6223e62aead76617f0919511 100644 (file)
@@ -15,7 +15,7 @@
       icon=":icons/sketch.png"
       tooltip="Select a sketch face"
       type_choice="Faces Objects">
-      <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+      <validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="face,shell"/>
     </composite_multi_selector>
     <shape_selector id="axis_object"
                     icon=":icons/axis.png"
@@ -91,4 +91,5 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,sketch_selection,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,ByAngles,base,to_object,from_object"/>
 </source>
index 03fd77ed7a4a754d13e003d264919d284265d350..56a417a9ba34adb4bb6cb1f12b767c6761629260 100644 (file)
@@ -15,7 +15,7 @@
       icon=":icons/sketch.png"
       tooltip="Select a sketch face"
       type_choice="Faces Objects">
-      <validator id="FeaturesPlugin_ValidatorExtrusionBase" parameters="Sketch"/>
+      <validator id="FeaturesPlugin_ValidatorCompositeLauncher" parameters="vertex,edge,wire,face,shell"/>
     </composite_multi_selector>
     <shape_selector id="axis_object"
                     icon=":icons/axis.png"
@@ -91,4 +91,5 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,sketch_selection,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,ByAngles,base,to_object,from_object"/>
 </source>
index 826b8477ae7a5ebb95545ea5dc3040489a29ac0a..e47070176a383be1533f3eb7723aecac0099c71e 100644 (file)
@@ -4,21 +4,19 @@
 // Created:     2 Dec 2014
 // Author:      Artem ZHIDKOV
 
-#include <GeomAPI_Face.h>
-#include <GeomAPI_Dir.h>
-#include <GeomAPI_Pln.h>
-#include <GeomAPI_Pnt.h>
+#include "GeomAPI_Face.h"
+
+#include "GeomAPI_Dir.h"
+#include "GeomAPI_Pln.h"
+#include "GeomAPI_Pnt.h"
 
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS.hxx>
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <Geom_Surface.hxx>
-#include <Geom_Plane.hxx>
 #include <Geom_CylindricalSurface.hxx>
-#include <GeomLib_IsPlanarSurface.hxx>
 #include <Geom_RectangularTrimmedSurface.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
 
 GeomAPI_Face::GeomAPI_Face()
   : GeomAPI_Shape()
@@ -63,18 +61,6 @@ bool GeomAPI_Face::isEqual(std::shared_ptr<GeomAPI_Shape> theFace) const
   return true;
 }
 
-bool GeomAPI_Face::isPlanar() const
-{
-  const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
-  Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
-  Handle(Geom_RectangularTrimmedSurface) aTrimmed = 
-    Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf);
-  if (!aTrimmed.IsNull())
-    aSurf = aTrimmed->BasisSurface();
-  GeomLib_IsPlanarSurface isPlanar(aSurf);
-  return isPlanar.IsPlanar() == Standard_True;
-}
-
 bool GeomAPI_Face::isCylindrical() const
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
index 413c03b81eb6e3f5affb0b903a57bedbbf6c935a..c47bc036aff475045e083f65eacc0009ca71bab1 100644 (file)
@@ -30,10 +30,6 @@ public:
   GEOMAPI_EXPORT 
   virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theFace) const;
 
-  /// Returns true if the face is a planar face
-  GEOMAPI_EXPORT 
-  bool isPlanar() const;
-
   /// Returns true if the face is a cylindrical face
   GEOMAPI_EXPORT 
   bool isCylindrical() const;
index 9bb3fb994dfaa1d1cf05efc47b1763910334abdb..e87ce4d893facc4393d2d4e0badcebcab7d02d9b 100644 (file)
@@ -91,6 +91,11 @@ std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::norm() const
   return std::shared_ptr<GeomAPI_Dir>();
 }
 
+bool GeomAPI_PlanarEdges::isPlanar() const
+{
+  return true;
+}
+
 void GeomAPI_PlanarEdges::setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
                                    const std::shared_ptr<GeomAPI_Dir>& theDirX,
                                    const std::shared_ptr<GeomAPI_Dir>& theNorm)
index 9ba13cd1a0be499dfa5d8f9621ff9c61a0b37002..5628f40e89844516c1cc3d8fc19c338c5a8cd418 100644 (file)
@@ -54,6 +54,9 @@ class GeomAPI_PlanarEdges : public GeomAPI_Shape
   /// Returns Z direction vector
   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> norm() const;
 
+  /// Returns whether the shape is planar
+  GEOMAPI_EXPORT virtual bool isPlanar() const;
+
   /// Set working plane
   /// \param theOrigin origin of the plane axis
   /// \param theDirX X direction of the plane axis
index d00fe34db29f733d99db9d497539b46726c1a6fd..3ae40cab1238b28e440b0050f1e29bd7645e98d5 100644 (file)
@@ -4,13 +4,18 @@
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
 
-#include<GeomAPI_Shape.h>
+#include "GeomAPI_Shape.h"
 
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Iterator.hxx>
+#include <BRep_Tool.hxx>
 #include <BRepBndLib.hxx>
-#include <Bnd_Box.hxx>
+#include <BRepBuilderAPI_FindPlane.hxx>
 #include <BRepTools.hxx>
+#include <Bnd_Box.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
 
 #include <sstream>
 
@@ -88,10 +93,72 @@ bool GeomAPI_Shape::isCompSolid() const
   return !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPSOLID;
 }
 
+bool GeomAPI_Shape::isPlanar() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+
+  if(aShape.IsNull()) {
+    return false;
+  }
+
+  TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
+
+  if(aShapeType == TopAbs_VERTEX) {
+    return true;
+  } else if(aShapeType == TopAbs_EDGE || aShapeType ==  TopAbs_WIRE || aShapeType == TopAbs_SHELL) {
+    BRepBuilderAPI_FindPlane aFindPlane(aShape);
+    return aFindPlane.Found() == Standard_True;
+  } else if(aShapeType == TopAbs_FACE) {
+    const Handle(Geom_Surface)& aSurface = BRep_Tool::Surface(TopoDS::Face(aShape));
+    Handle(Standard_Type) aType = aSurface->DynamicType();
+
+    if(aType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
+      Handle(Geom_RectangularTrimmedSurface) aTrimSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
+      aType = aTrimSurface->BasisSurface()->DynamicType();
+    }
+    return (aType == STANDARD_TYPE(Geom_Plane));
+  } else {
+    return false;
+  }
+}
+
 GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeType() const
 {
   const TopoDS_Shape& aShape = impl<TopoDS_Shape>();
-  return (ShapeType)aShape.ShapeType();
+
+  ShapeType aST = GeomAPI_Shape::SHAPE;
+
+  switch(aShape.ShapeType()) {
+  case TopAbs_COMPOUND:
+    aST = GeomAPI_Shape::COMPOUND;
+    break;
+  case TopAbs_COMPSOLID:
+    aST = GeomAPI_Shape::COMPSOLID;
+    break;
+  case TopAbs_SOLID:
+    aST = GeomAPI_Shape::SOLID;
+    break;
+  case TopAbs_SHELL:
+    aST = GeomAPI_Shape::SHELL;
+    break;
+  case TopAbs_FACE:
+    aST = GeomAPI_Shape::FACE;
+    break;
+  case TopAbs_WIRE:
+    aST = GeomAPI_Shape::WIRE;
+    break;
+  case TopAbs_EDGE:
+    aST = GeomAPI_Shape::EDGE;
+    break;
+  case TopAbs_VERTEX:
+    aST = GeomAPI_Shape::VERTEX;
+    break;
+  case TopAbs_SHAPE:
+    aST = GeomAPI_Shape::SHAPE;
+    break;
+  }
+
+  return aST;
 }
 
 std::string GeomAPI_Shape::shapeTypeStr() const
index 37ba2b462ef86d890c4fb0571c0538f95ed8d008..7adf4da806700ea5f439f8963d727e2b44bfd770 100644 (file)
@@ -66,6 +66,10 @@ public:
   GEOMAPI_EXPORT
   virtual bool isCompSolid() const;
 
+  /// Returns whether the shape is planar
+  GEOMAPI_EXPORT
+  virtual bool isPlanar() const;
+
   /// Returns the shape type
   GEOMAPI_EXPORT
   virtual ShapeType shapeType() const;
index 7761a5b9d64085a01a5370002254edea84b4ab93..d8056eb153fd19204c2c6841bf12e668e3096b31 100644 (file)
 
 static bool getBase(TopoDS_Shape& theBaseOut,
                     TopAbs_ShapeEnum& theBaseTypeOut,
-                    const std::shared_ptr<GeomAPI_Shape> theBaseShape);
+                    const GeomShapePtr theBaseShape);
 static bool getPath(TopoDS_Wire& thePathOut,
-                    const std::shared_ptr<GeomAPI_Shape> thePathShape);
+                    const GeomShapePtr thePathShape);
 static bool buildPipe(BRepOffsetAPI_MakePipeShell* thePipeBuilder);
 
 //=================================================================================================
-GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                   const std::shared_ptr<GeomAPI_Shape> thePathShape)
+GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const GeomShapePtr theBaseShape,
+                                   const GeomShapePtr thePathShape)
 : /*myIsPipeShellUsed(false),*/
   myBaseShape(theBaseShape),
   myPathShape(thePathShape)
@@ -40,9 +40,9 @@ GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const std::shared_ptr<GeomAPI_Shape> theBaseS
 }
 
 //=================================================================================================
-GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                   const std::shared_ptr<GeomAPI_Shape> thePathShape,
-                                   const std::shared_ptr<GeomAPI_Shape> theBiNormal)
+GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const GeomShapePtr theBaseShape,
+                                   const GeomShapePtr thePathShape,
+                                   const GeomShapePtr theBiNormal)
 //: myIsPipeShellUsed(true)
 {
   build(theBaseShape, thePathShape, theBiNormal);
@@ -51,15 +51,15 @@ GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const std::shared_ptr<GeomAPI_Shape> theBaseS
 //=================================================================================================
 GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const ListOfShape& theBaseShapes,
                                    const ListOfShape& theLocations,
-                                   const std::shared_ptr<GeomAPI_Shape> thePathShape)
+                                   const GeomShapePtr thePathShape)
 //: myIsPipeShellUsed(true)
 {
   build(theBaseShapes, theLocations, thePathShape);
 }
 
 //=================================================================================================
-void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                             const std::shared_ptr<GeomAPI_Shape> thePathShape)
+void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape,
+                             const GeomShapePtr thePathShape)
 {
   // Getting base shape.
   if(!theBaseShape.get()) {
@@ -97,7 +97,7 @@ void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
   this->initialize(aPipeBuilder);
 
   // Setting naming.
-  std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
+  GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
   aFromShape->setImpl(new TopoDS_Shape(aPipeBuilder->FirstShape()));
   aToShape->setImpl(new TopoDS_Shape(aPipeBuilder->LastShape()));
   this->addFromShape(aFromShape);
@@ -105,16 +105,16 @@ void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
 
   // Setting result.
   TopoDS_Shape aResultShape = aPipeBuilder->Shape();
-  std::shared_ptr<GeomAPI_Shape> aResultGeomShape(new GeomAPI_Shape());
+  GeomShapePtr aResultGeomShape(new GeomAPI_Shape());
   aResultGeomShape->setImpl(new TopoDS_Shape(aResultShape));
   this->setShape(aResultGeomShape);
   this->setDone(true);
 }
 
 //=================================================================================================
-void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                             const std::shared_ptr<GeomAPI_Shape> thePathShape,
-                             const std::shared_ptr<GeomAPI_Shape> theBiNormal)
+void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape,
+                             const GeomShapePtr thePathShape,
+                             const GeomShapePtr theBiNormal)
 {
   // Getting base shape.
   TopoDS_Shape aBaseShape;
@@ -170,7 +170,7 @@ void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
   }
 
   // Setting naming.
-  std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
+  GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
   aFromShape->setImpl(new TopoDS_Shape(aPipeBuilder->FirstShape()));
   aToShape->setImpl(new TopoDS_Shape(aPipeBuilder->LastShape()));
   this->addFromShape(aFromShape);
@@ -178,7 +178,7 @@ void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
 
   // Setting result.
   TopoDS_Shape aResultShape = aPipeBuilder->Shape();
-  std::shared_ptr<GeomAPI_Shape> aResultGeomShape(new GeomAPI_Shape());
+  GeomShapePtr aResultGeomShape(new GeomAPI_Shape());
   aResultGeomShape->setImpl(new TopoDS_Shape(aResultShape));
   this->setShape(aResultGeomShape);
   this->setDone(true);
@@ -187,7 +187,7 @@ void GeomAlgoAPI_Pipe::build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
 //=================================================================================================
 void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
                              const ListOfShape& theLocations,
-                             const std::shared_ptr<GeomAPI_Shape> thePathShape)
+                             const GeomShapePtr thePathShape)
 {
   if(theBaseShapes.empty() || (!theLocations.empty() && theLocations.size() != theBaseShapes.size())) {
     return;
@@ -213,7 +213,7 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
   ListOfShape::const_iterator aBaseIt = theBaseShapes.cbegin();
   ListOfShape::const_iterator aLocIt = theLocations.cbegin();
   while(aBaseIt != theBaseShapes.cend()) {
-    std::shared_ptr<GeomAPI_Shape> aBase = *aBaseIt;
+    GeomShapePtr aBase = *aBaseIt;
     TopoDS_Shape aBaseShape;
     TopAbs_ShapeEnum aBaseShapeType;
     if(!getBase(aBaseShape, aBaseShapeType, aBase)) {
@@ -226,7 +226,7 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
     }
 
     if(aHasLocations) {
-      std::shared_ptr<GeomAPI_Shape> aLocation = *aLocIt;
+      GeomShapePtr aLocation = *aLocIt;
       if(!aLocation.get() || aLocation->shapeType() != GeomAPI_Shape::VERTEX) {
         delete aPipeBuilder;
         return;
@@ -261,7 +261,7 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
   }
 
   // Setting naming.
-  std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
+  GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
   aFromShape->setImpl(new TopoDS_Shape(aPipeBuilder->FirstShape()));
   aToShape->setImpl(new TopoDS_Shape(aPipeBuilder->LastShape()));
   this->addFromShape(aFromShape);
@@ -269,59 +269,24 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
 
   // Setting result.
   TopoDS_Shape aResultShape = aPipeBuilder->Shape();
-  std::shared_ptr<GeomAPI_Shape> aResultGeomShape(new GeomAPI_Shape());
+  GeomShapePtr aResultGeomShape(new GeomAPI_Shape());
   aResultGeomShape->setImpl(new TopoDS_Shape(aResultShape));
   this->setShape(aResultGeomShape);
   this->setDone(true);
 }
 
 //=================================================================================================
-void GeomAlgoAPI_Pipe::generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+void GeomAlgoAPI_Pipe::generated(const GeomShapePtr theShape,
                                  ListOfShape& theHistory)
 {
   GeomAlgoAPI_MakeShape::generated(theShape, theHistory);
-
-  //if(myIsPipeShellUsed) {
-  //  GeomAlgoAPI_MakeShape::generated(theShape, theHistory);
-  //  return;
-  //}
-
-  //BRepOffsetAPI_MakePipe* aMakePipe = implPtr<BRepOffsetAPI_MakePipe>();
-  //const TopoDS_Shape& aProfile = theShape->impl<TopoDS_Shape>();
-  //const TopAbs_ShapeEnum aProfileShapeType = aProfile.ShapeType();
-  //if(aProfileShapeType != TopAbs_VERTEX && aProfileShapeType != TopAbs_EDGE) {
-  //  return;
-  //}
-  //const TopoDS_Shape& aBaseShape = myBaseShape->impl<TopoDS_Shape>();
-  //TopExp_Explorer anExp(aBaseShape, aProfileShapeType);
-  //Standard_Boolean ahasShape = Standard_False;
-  //for(; anExp.More(); anExp.Next()) {
-  //  if(anExp.Current().IsSame(aProfile)) {
-  //    ahasShape = Standard_True;
-  //    break;
-  //  }
-  //}
-  //if(!ahasShape) {
-  //  return;
-  //}
-  //TopExp_Explorer aShapeExplorer(myPathShape->impl<TopoDS_Shape>(), TopAbs_EDGE);
-  //for(; aShapeExplorer.More(); aShapeExplorer.Next ()) {
-  //  const TopoDS_Shape& aSpine = aShapeExplorer.Current();
-  //  const TopoDS_Shape& aGeneratedShape = aMakePipe->Generated(aSpine, aProfile);
-  //  if(aGeneratedShape.IsNull()) {
-  //    continue;
-  //  }
-  //  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-  //  aShape->setImpl(new TopoDS_Shape(aGeneratedShape));
-  //  theHistory.push_back(aShape);
-  //}
 }
 
 // Auxilary functions:
 //=================================================================================================
 bool getBase(TopoDS_Shape& theBaseOut,
              TopAbs_ShapeEnum& theBaseTypeOut,
-             const std::shared_ptr<GeomAPI_Shape> theBaseShape)
+             const GeomShapePtr theBaseShape)
 {
   if(!theBaseShape.get()) {
     return false;
@@ -350,7 +315,7 @@ bool getBase(TopoDS_Shape& theBaseOut,
 
 //=================================================================================================
 bool getPath(TopoDS_Wire& thePathOut,
-             const std::shared_ptr<GeomAPI_Shape> thePathShape)
+             const GeomShapePtr thePathShape)
 {
   if(!thePathShape.get()) {
     return false;
index 197e1be8006534a18a0c057e87a06392059612a0..54f64c462f1be780dfc6389bcfbd01b0cb10a979 100644 (file)
@@ -26,17 +26,17 @@ public:
   /// \brief Creates extrusion for the given shape along a path.
   /// \param[in] theBaseShape base shape(vertex, edge, wire of face).
   /// \param[in] thePathShape path shape(edge or wire).
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Pipe(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                      const std::shared_ptr<GeomAPI_Shape> thePathShape);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Pipe(const GeomShapePtr theBaseShape,
+                                      const GeomShapePtr thePathShape);
 
   /// \brief Creates extrusion for the given shape along a path.
   /// \param[in] theBaseShape base shape(vertex, edge, wire of face).
   /// \param[in] thePathShape path shape(edge or wire).
   /// \param[in] theBiNormal edge or wire to preserve the constant angle between the normal vector
   /// to the base object and the BiNormal vector.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Pipe(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                      const std::shared_ptr<GeomAPI_Shape> thePathShape,
-                                      const std::shared_ptr<GeomAPI_Shape> theBiNormal);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Pipe(const GeomShapePtr theBaseShape,
+                                      const GeomShapePtr thePathShape,
+                                      const GeomShapePtr theBiNormal);
 
   /// \brief Creates extrusion for the given shape along a path.
   /// \param[in] theBaseShapes base shape(vertex, edge, wire of face).
@@ -45,30 +45,30 @@ public:
   /// to the base object and the BiNormal vector.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Pipe(const ListOfShape& theBaseShapes,
                                       const ListOfShape& theLocations,
-                                      const std::shared_ptr<GeomAPI_Shape> thePathShape);
+                                      const GeomShapePtr thePathShape);
 
   /// \return the list of shapes generated from theShape.
   /// \param[in] theShape base shape.
   /// \param[out] theHistory generated shapes.
-  GEOMALGOAPI_EXPORT void generated(const std::shared_ptr<GeomAPI_Shape> theShape,
+  GEOMALGOAPI_EXPORT void generated(const GeomShapePtr theShape,
                                     ListOfShape& theHistory);
 
 private:
-  void build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-             const std::shared_ptr<GeomAPI_Shape> thePathShape);
+  void build(const GeomShapePtr theBaseShape,
+             const GeomShapePtr thePathShape);
 
-  void build(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-             const std::shared_ptr<GeomAPI_Shape> thePathShape,
-             const std::shared_ptr<GeomAPI_Shape> theBiNormal);
+  void build(const GeomShapePtr theBaseShape,
+             const GeomShapePtr thePathShape,
+             const GeomShapePtr theBiNormal);
 
   void build(const ListOfShape& theBaseShapes,
              const ListOfShape& theLocations,
-             const std::shared_ptr<GeomAPI_Shape> thePathShape);
+             const GeomShapePtr thePathShape);
 
 private:
   //bool myIsPipeShellUsed;
-  std::shared_ptr<GeomAPI_Shape> myBaseShape;
-  std::shared_ptr<GeomAPI_Shape> myPathShape;
+  GeomShapePtr myBaseShape;
+  GeomShapePtr myPathShape;
 };
 
 #endif
index f0a6690e2127406b08c829b09d8dc06e82bcf68a..9ec5b27380291e12b2a689899d827cb55574c178 100644 (file)
 #include <BRep_Builder.hxx>
 #include <BRepAlgoAPI_Cut.hxx>
 #include <BRepBndLib.hxx>
+#include <BRepBuilderAPI_FindPlane.hxx>
 #include <BRepBuilderAPI_Transform.hxx>
 #include <BRepPrimAPI_MakePrism.hxx>
+#include <Geom_Plane.hxx>
 #include <gp_Pln.hxx>
 #include <IntAna_IntConicQuad.hxx>
 #include <IntAna_Quadric.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 
 //=================================================================================================
-GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                     double                         theToSize,
-                                     double                         theFromSize)
+GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
+                                     const double       theToSize,
+                                     const double       theFromSize)
 {
-  build(theBaseShape, std::shared_ptr<GeomAPI_Shape>(), theToSize, std::shared_ptr<GeomAPI_Shape>(), theFromSize);
+  build(theBaseShape, std::shared_ptr<GeomAPI_Dir>(), GeomShapePtr(), theToSize, GeomShapePtr(), theFromSize);
 }
 
 //=================================================================================================
-GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                     std::shared_ptr<GeomAPI_Shape> theToShape,
-                                     double                         theToSize,
-                                     std::shared_ptr<GeomAPI_Shape> theFromShape,
-                                     double                         theFromSize)
+GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr                 theBaseShape,
+                                     const std::shared_ptr<GeomAPI_Dir> theDirection,
+                                     const double                       theToSize,
+                                     const double                       theFromSize)
 {
-  build(theBaseShape, theToShape, theToSize, theFromShape, theFromSize);
+  build(theBaseShape, theDirection, GeomShapePtr(), theToSize, GeomShapePtr(), theFromSize);
 }
 
 //=================================================================================================
-void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
-                              const std::shared_ptr<GeomAPI_Shape>& theToShape,
-                              double                                theToSize,
-                              const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-                              double                                theFromSize)
+GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
+                                     const GeomShapePtr theToShape,
+                                     const double       theToSize,
+                                     const GeomShapePtr theFromShape,
+                                     const double       theFromSize)
 {
-  if(!theBaseShape ||
-    (((!theFromShape && !theToShape) || (theFromShape && theToShape && theFromShape->isEqual(theToShape)))
+  build(theBaseShape, std::shared_ptr<GeomAPI_Dir>(), theToShape, theToSize, theFromShape, theFromSize);
+}
+
+//=================================================================================================
+GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr                 theBaseShape,
+                                     const std::shared_ptr<GeomAPI_Dir> theDirection,
+                                     const GeomShapePtr                 theToShape,
+                                     const double                       theToSize,
+                                     const GeomShapePtr                 theFromShape,
+                                     const double                       theFromSize)
+{
+  build(theBaseShape, theDirection, theToShape, theToSize, theFromShape, theFromSize);
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Prism::build(const GeomShapePtr&                theBaseShape,
+                              const std::shared_ptr<GeomAPI_Dir> theDirection,
+                              const GeomShapePtr&                theToShape,
+                              const double                       theToSize,
+                              const GeomShapePtr&                theFromShape,
+                              const double                       theFromSize)
+{
+  if(!theBaseShape.get() ||
+    (((!theFromShape.get() && !theToShape.get()) || (theFromShape.get() && theToShape.get() && theFromShape->isEqual(theToShape)))
     && (theFromSize == -theToSize))) {
     return;
   }
 
-  // Getting base plane.
+  // Getting base shape.
   const TopoDS_Shape& aBaseShape = theBaseShape->impl<TopoDS_Shape>();
-  std::shared_ptr<GeomAPI_Face> aBaseFace;
-  if(theBaseShape->shapeType() == GeomAPI_Shape::FACE) {
-    aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(theBaseShape));
-  } else if(theBaseShape->shapeType() == GeomAPI_Shape::SHELL){
-    GeomAPI_ShapeExplorer anExp(theBaseShape, GeomAPI_Shape::FACE);
-    if(anExp.more()) {
-      std::shared_ptr<GeomAPI_Shape> aFaceOnShell = anExp.current();
-      aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(aFaceOnShell));
+
+  // Getting direction.
+  gp_Vec aDirVec;
+  std::shared_ptr<GeomAPI_Pnt> aBaseLoc;
+  std::shared_ptr<GeomAPI_Dir> aBaseDir;
+  GeomShapePtr aBasePlane;
+  if(theDirection.get()) {
+    aDirVec = theDirection->impl<gp_Dir>();
+  } else {
+    BRepBuilderAPI_FindPlane aFindPlane(aBaseShape);
+    if(aBaseShape.ShapeType() == TopAbs_VERTEX ||
+       aBaseShape.ShapeType() == TopAbs_EDGE ||
+       aFindPlane.Found() != Standard_True) {
+      return;
     }
-  }
-  if(!aBaseFace.get()) {
-    return;
-  }
 
-  std::shared_ptr<GeomAPI_Pln>   aBasePln = aBaseFace->getPlane();
-  std::shared_ptr<GeomAPI_Dir>   aBaseDir = aBasePln->direction();
-  std::shared_ptr<GeomAPI_Pnt>   aBaseLoc = aBasePln->location();
-  std::shared_ptr<GeomAPI_Shape> aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir);
+    Handle(Geom_Plane) aPlane = aFindPlane.Plane();
+    gp_Pnt aLoc = aPlane->Axis().Location();
+    aDirVec = aPlane->Axis().Direction();
+
+    aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+    aBaseDir.reset(new GeomAPI_Dir(aDirVec.X(), aDirVec.Y(), aDirVec.Z()));
+    aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir);
+  }
 
-  gp_Vec aBaseVec(aBaseDir->impl<gp_Dir>());
-  const gp_Pnt& aBasePnt = aBaseLoc->impl<gp_Pnt>();
+  //std::shared_ptr<GeomAPI_Face> aBaseFace;
+  //if(theBaseShape->shapeType() == GeomAPI_Shape::FACE) {
+  //  aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(theBaseShape));
+  //} else if(theBaseShape->shapeType() == GeomAPI_Shape::SHELL){
+  //  GeomAPI_ShapeExplorer anExp(theBaseShape, GeomAPI_Shape::FACE);
+  //  if(anExp.more()) {
+  //    GeomShapePtr aFaceOnShell = anExp.current();
+  //    aBaseFace = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(aFaceOnShell));
+  //  }
+  //}
 
   TopoDS_Shape aResult;
   bool isBoundingShapesSet = theFromShape || theToShape;
   if(!isBoundingShapesSet) {
     // Moving base shape.
     gp_Trsf aTrsf;
-    aTrsf.SetTranslation(aBaseVec * -theFromSize);
+    aTrsf.SetTranslation(aDirVec * -theFromSize);
     BRepBuilderAPI_Transform* aTransformBuilder = new BRepBuilderAPI_Transform(aBaseShape, aTrsf);
     if(!aTransformBuilder) {
       return;
@@ -101,7 +138,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     TopoDS_Shape aMovedBase = aTransformBuilder->Shape();
 
     // Making prism.
-    BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aBaseVec * (theFromSize + theToSize));
+    BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aDirVec * (theFromSize + theToSize));
     if(!aPrismBuilder) {
       return;
     }
@@ -114,15 +151,15 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     // Setting naming.
     for(TopExp_Explorer anExp(aMovedBase, TopAbs_FACE); anExp.More(); anExp.Next()) {
       const TopoDS_Shape& aFace = anExp.Current();
-      std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
+      GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
       aFromShape->setImpl(new TopoDS_Shape(aPrismBuilder->FirstShape(aFace)));
       aToShape->setImpl(new TopoDS_Shape(aPrismBuilder->LastShape(aFace)));
       this->addFromShape(aFromShape);
       this->addToShape(aToShape);
     }
   } else {
-    std::shared_ptr<GeomAPI_Shape> aBoundingFromShape = theFromShape ? theFromShape : aBasePlane;
-    std::shared_ptr<GeomAPI_Shape> aBoundingToShape   = theToShape   ? theToShape   : aBasePlane;
+    GeomShapePtr aBoundingFromShape = theFromShape ? theFromShape : aBasePlane;
+    GeomShapePtr aBoundingToShape   = theToShape   ? theToShape   : aBasePlane;
 
     // Moving prism bounding faces according to "from" and "to" sizes.
     std::shared_ptr<GeomAPI_Face> aFromFace(new GeomAPI_Face(aBoundingFromShape));
@@ -167,7 +204,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     IntAna_Quadric aBndFromQuadric(gp_Pln(aFromPnt->impl<gp_Pnt>(), aFromDir->impl<gp_Dir>()));
     Standard_Real aMaxToDist = 0, aMaxFromDist = 0;
     for(int i = 0; i < 8; i++) {
-      gp_Lin aLine(aPoints[i], aBaseVec);
+      gp_Lin aLine(aPoints[i], aDirVec);
       IntAna_IntConicQuad aToIntAna(aLine, aBndToQuadric);
       IntAna_IntConicQuad aFromIntAna(aLine, aBndFromQuadric);
       if(aToIntAna.NbPoints() == 0 || aFromIntAna.NbPoints() == 0) {
@@ -188,7 +225,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
 
     // Moving base shape.
     gp_Trsf aTrsf;
-    aTrsf.SetTranslation(aBaseVec * -aPrismLength);
+    aTrsf.SetTranslation(aDirVec * -aPrismLength);
     BRepBuilderAPI_Transform* aTransformBuilder = new BRepBuilderAPI_Transform(aBaseShape, aTrsf);
     if(!aTransformBuilder) {
       return;
@@ -200,7 +237,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     TopoDS_Shape aMovedBase = aTransformBuilder->Shape();
 
     // Making prism.
-    BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aBaseVec * 2 * aPrismLength);
+    BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aDirVec * 2 * aPrismLength);
     if(!aPrismBuilder) {
       return;
     }
@@ -213,30 +250,30 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     // Orienting bounding planes.
     std::shared_ptr<GeomAPI_Pnt> aCentreOfMass = GeomAlgoAPI_ShapeTools::centreOfMass(theBaseShape);
     const gp_Pnt& aCentrePnt = aCentreOfMass->impl<gp_Pnt>();
-    gp_Lin aLine(aCentrePnt, aBaseVec);
+    gp_Lin aLine(aCentrePnt, aDirVec);
     IntAna_IntConicQuad aToIntAna(aLine, aBndToQuadric);
     IntAna_IntConicQuad aFromIntAna(aLine, aBndFromQuadric);
     Standard_Real aToParameter = aToIntAna.ParamOnConic(1);
     Standard_Real aFromParameter = aFromIntAna.ParamOnConic(1);
     if(aToParameter > aFromParameter) {
       gp_Vec aVec = aToDir->impl<gp_Dir>();
-      if((aVec * aBaseVec) > 0) {
+      if((aVec * aDirVec) > 0) {
         aToDir->setImpl(new gp_Dir(aVec.Reversed()));
         aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
       }
       aVec = aFromDir->impl<gp_Dir>();
-      if((aVec * aBaseVec) < 0) {
+      if((aVec * aDirVec) < 0) {
         aFromDir->setImpl(new gp_Dir(aVec.Reversed()));
         aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
       }
     } else {
       gp_Vec aVec = aToDir->impl<gp_Dir>();
-      if((aVec * aBaseVec) < 0) {
+      if((aVec * aDirVec) < 0) {
         aToDir->setImpl(new gp_Dir(aVec.Reversed()));
         aBoundingToShape = GeomAlgoAPI_FaceBuilder::planarFace(aToPnt, aToDir);
       }
       aVec = aFromDir->impl<gp_Dir>();
-      if((aVec * aBaseVec) > 0) {
+      if((aVec * aDirVec) > 0) {
         aFromDir->setImpl(new gp_Dir(aVec.Reversed()));
         aBoundingFromShape = GeomAlgoAPI_FaceBuilder::planarFace(aFromPnt, aFromDir);
       }
@@ -249,12 +286,12 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     const TopoDS_Shape& aFromShape = aBoundingFromShape->impl<TopoDS_Shape>();
     BRep_Builder aBoundingBuilder;
     aBoundingBuilder.MakeShell(aToShell);
-    aBoundingBuilder.MakeShell(aFromShell);
     aBoundingBuilder.Add(aToShell, aToShape);
+    aBoundingBuilder.MakeShell(aFromShell);
     aBoundingBuilder.Add(aFromShell, aFromShape);
     aBoundingBuilder.MakeSolid(aToSolid);
-    aBoundingBuilder.MakeSolid(aFromSolid);
     aBoundingBuilder.Add(aToSolid, aToShell);
+    aBoundingBuilder.MakeSolid(aFromSolid);
     aBoundingBuilder.Add(aFromSolid, aFromShell);
 
     // Cutting with to plane.
@@ -266,7 +303,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
     const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape);
     for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      GeomShapePtr aShape(new GeomAPI_Shape());
       aShape->setImpl(new TopoDS_Shape(anIt.Value()));
       this->addToShape(aShape);
     }
@@ -281,7 +318,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
     this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
     const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape);
     for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      GeomShapePtr aShape(new GeomAPI_Shape());
       aShape->setImpl(new TopoDS_Shape(anIt.Value()));
       this->addFromShape(aShape);
     }
@@ -295,7 +332,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
       aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
     }
     if(aResult.ShapeType() == TopAbs_COMPOUND) {
-      std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
+      GeomShapePtr aCompound(new GeomAPI_Shape);
       aCompound->setImpl(new TopoDS_Shape(aResult));
       ListOfShape aCompSolids, aFreeSolids;
       GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
@@ -320,7 +357,7 @@ void GeomAlgoAPI_Prism::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape
   if(aResult.IsNull()) {
     return;
   }
-  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  GeomShapePtr aShape(new GeomAPI_Shape());
   aShape->setImpl(new TopoDS_Shape(aResult));
   this->setShape(aShape);
   this->setDone(true);
index f286e6970ebcedbfc9f66d9af11289748a1db3ea..be17e8b7ad7d843195b2b9bddce00f42fb6fe069 100644 (file)
@@ -7,9 +7,12 @@
 #ifndef GeomAlgoAPI_Prism_H_
 #define GeomAlgoAPI_Prism_H_
 
-#include <GeomAlgoAPI.h>
+#include "GeomAlgoAPI.h"
+
+#include "GeomAlgoAPI_MakeSweep.h"
+
+#include <GeomAPI_Dir.h>
 #include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_MakeSweep.h>
 
 #include <memory>
 
@@ -22,32 +25,57 @@ class GeomAlgoAPI_Prism : public GeomAlgoAPI_MakeSweep
 {
 public:
   /// \brief Creates extrusion for the given shape along the normal for this shape.
-  /// \param[in] theBaseShape face or wire to be extruded.
+  /// \param[in] theBaseShape planar face or wire to be extruded.
+  /// \param[in] theToSize offset for "to" plane.
+  /// \param[in] theFromSize offset for "from" plane.
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
+                                       const double       theToSize,
+                                       const double       theFromSize);
+
+  /// \brief Creates extrusion for the given shape along the normal for this shape.
+  /// \param[in] theBaseShape vertex, edge, wire, face or shell.
+  /// \param[in] theDirection direction of extrusion. Can be empty if theBaseShape is planar wire or face.
   /// \param[in] theToSize offset for "to" plane.
   /// \param[in] theFromSize offset for "from" plane.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                       double                         theToSize,
-                                       double                         theFromSize);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr                 theBaseShape,
+                                       const std::shared_ptr<GeomAPI_Dir> theDirection,
+                                       const double                       theToSize,
+                                       const double                       theFromSize);
+
+  /// \brief Creates extrusion for the given shape along the normal for this shape.
+  /// \param[in] theBaseShape planar face or wire to be extruded.
+  /// \param[in] theToShape top bounding shape. Can be empty. In this case offset will be applied to the basis.
+  /// \param[in] theToSize offset for "to" plane.
+  /// \param[in] theFromShape bottom bounding shape. Can be empty. In this case offset will be applied to the basis.
+  /// \param[in] theFromSize offset for "from" plane.
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
+                                       const GeomShapePtr theToShape,
+                                       const double       theToSize,
+                                       const GeomShapePtr theFromShape,
+                                       const double       theFromSize);
 
   /// \brief Creates extrusion for the given shape along the normal for this shape.
-  /// \param[in] theBaseShape face or wire to be extruded.
-  /// \param[in] theToShape top bounding shape.  Can be empty. In this case offset will be applied to the basis.
+  /// \param[in] theBaseShape planar face or wire to be extruded.
+  /// \param[in] theDirection direction of extrusion. Can be empty if theBaseShape is planar wire or face.
+  /// \param[in] theToShape top bounding shape. Can be empty. In this case offset will be applied to the basis.
   /// \param[in] theToSize offset for "to" plane.
   /// \param[in] theFromShape bottom bounding shape. Can be empty. In this case offset will be applied to the basis.
   /// \param[in] theFromSize offset for "from" plane.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                       std::shared_ptr<GeomAPI_Shape> theToShape,
-                                       double                         theToSize,
-                                       std::shared_ptr<GeomAPI_Shape> theFromShape,
-                                       double                         theFromSize);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr                 theBaseShape,
+                                       const std::shared_ptr<GeomAPI_Dir> theDirection,
+                                       const GeomShapePtr                 theToShape,
+                                       const double                       theToSize,
+                                       const GeomShapePtr                 theFromShape,
+                                       const double                       theFromSize);
 
 private:
   /// Builds resulting shape.
-  void build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
-             const std::shared_ptr<GeomAPI_Shape>& theToShape,
-             double                                theToSize,
-             const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-             double                                theFromSize);
+  void build(const GeomShapePtr&                theBaseShape,
+             const std::shared_ptr<GeomAPI_Dir> theDirection,
+             const GeomShapePtr&                theToShape,
+             const double                       theToSize,
+             const GeomShapePtr&                theFromShape,
+             const double                       theFromSize);
 };
 
 #endif
index cd3198a77c99fac5da8876d61563d7936facb621..9e234c0acb8c6bb109e4bcf293bd703a41fbb2c8 100644 (file)
@@ -45,32 +45,32 @@ static TopoDS_Solid makeSolidFromShape(const TopoDS_Shape& theShape);
 static TopoDS_Shape findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint);
 
 //=================================================================================================
-GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                               std::shared_ptr<GeomAPI_Ax1>   theAxis,
-                                               double                         theToAngle,
-                                               double                         theFromAngle)
+GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(const GeomShapePtr                 theBaseShape,
+                                               const std::shared_ptr<GeomAPI_Ax1> theAxis,
+                                               const double                       theToAngle,
+                                               const double                       theFromAngle)
 {
-  build(theBaseShape, theAxis, std::shared_ptr<GeomAPI_Shape>(), theToAngle, std::shared_ptr<GeomAPI_Shape>(), theFromAngle);
+  build(theBaseShape, theAxis, GeomShapePtr(), theToAngle, GeomShapePtr(), theFromAngle);
 }
 
 //=================================================================================================
-GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                               std::shared_ptr<GeomAPI_Ax1>   theAxis,
-                                               std::shared_ptr<GeomAPI_Shape> theToShape,
-                                               double                         theToAngle,
-                                               std::shared_ptr<GeomAPI_Shape> theFromShape,
-                                               double                         theFromAngle)
+GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(const GeomShapePtr                 theBaseShape,
+                                               const std::shared_ptr<GeomAPI_Ax1> theAxis,
+                                               const GeomShapePtr                 theToShape,
+                                               const double                       theToAngle,
+                                               const GeomShapePtr                 theFromShape,
+                                               const double                       theFromAngle)
 {
   build(theBaseShape, theAxis, theToShape, theToAngle, theFromShape, theFromAngle);
 }
 
 //=================================================================================================
-void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
-                                   const std::shared_ptr<GeomAPI_Ax1>&   theAxis,
-                                   const std::shared_ptr<GeomAPI_Shape>& theToShape,
-                                   double                                theToAngle,
-                                   const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-                                   double                                theFromAngle)
+void GeomAlgoAPI_Revolution::build(const GeomShapePtr&                 theBaseShape,
+                                   const std::shared_ptr<GeomAPI_Ax1>& theAxis,
+                                   const GeomShapePtr&                 theToShape,
+                                   const double                        theToAngle,
+                                   const GeomShapePtr&                 theFromShape,
+                                   const double                        theFromAngle)
 {
   if(!theBaseShape || !theAxis ||
     (((!theFromShape && !theToShape) || (theFromShape && theToShape && theFromShape->isEqual(theToShape)))
@@ -86,7 +86,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
   } else if(theBaseShape->shapeType() == GeomAPI_Shape::SHELL) {
     GeomAPI_ShapeExplorer anExp(theBaseShape, GeomAPI_Shape::FACE);
     if(anExp.more()) {
-      std::shared_ptr<GeomAPI_Shape> aFaceOnShell = anExp.current();
+      GeomShapePtr aFaceOnShell = anExp.current();
       aBaseFace = TopoDS::Face(aFaceOnShell->impl<TopoDS_Shape>());
     }
   }
@@ -137,7 +137,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
     // Setting naming.
     for(TopExp_Explorer anExp(aRotatedBase, TopAbs_FACE); anExp.More(); anExp.Next()) {
       const TopoDS_Shape& aFace = anExp.Current();
-      std::shared_ptr<GeomAPI_Shape> aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
+      GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape);
       aFromShape->setImpl(new TopoDS_Shape(aRevolBuilder->FirstShape(aFace)));
       aToShape->setImpl(new TopoDS_Shape(aRevolBuilder->LastShape(aFace)));
       this->addFromShape(aFromShape);
@@ -217,7 +217,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
       aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
     }
     if(aResult.ShapeType() == TopAbs_COMPOUND) {
-      std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
+      GeomShapePtr aCompound(new GeomAPI_Shape);
       aCompound->setImpl(new TopoDS_Shape(aResult));
       ListOfShape aCompSolids, aFreeSolids;
       GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
@@ -247,12 +247,12 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
       Handle(Geom_Surface) aFromSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedFromFace));
       Handle(Geom_Surface) aToSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedToFace));
       if(aFaceSurface == aFromSurface) {
-        std::shared_ptr<GeomAPI_Shape> aFSHape(new GeomAPI_Shape);
+        GeomShapePtr aFSHape(new GeomAPI_Shape);
         aFSHape->setImpl(new TopoDS_Shape(aFaceOnResult));
         this->addFromShape(aFSHape);
       }
       if(aFaceSurface == aToSurface) {
-        std::shared_ptr<GeomAPI_Shape> aTSHape(new GeomAPI_Shape);
+        GeomShapePtr aTSHape(new GeomAPI_Shape);
         aTSHape->setImpl(new TopoDS_Shape(aFaceOnResult));
         this->addToShape(aTSHape);
       }
@@ -322,7 +322,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
     // Setting naming.
     const TopTools_ListOfShape& aBndShapes = aBoundingCutBuilder->Modified(aBoundingFace);
     for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      GeomShapePtr aShape(new GeomAPI_Shape());
       aShape->setImpl(new TopoDS_Shape(anIt.Value()));
       isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape);
     }
@@ -364,7 +364,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
 
     const TopTools_ListOfShape& aBsShapes = aBaseCutBuilder->Modified(aBoundingFace);
     for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) {
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      GeomShapePtr aShape(new GeomAPI_Shape());
       aShape->setImpl(new TopoDS_Shape(anIt.Value()));
       isFromFaceSet ? this->addToShape(aShape) : this->addFromShape(aShape);
     }
@@ -377,7 +377,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
       aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
     }
     if(aResult.ShapeType() == TopAbs_COMPOUND) {
-      std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
+      GeomShapePtr aCompound(new GeomAPI_Shape);
       aCompound->setImpl(new TopoDS_Shape(aResult));
       ListOfShape aCompSolids, aFreeSolids;
       GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
@@ -406,7 +406,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
       Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aFaceOnResult));
       Handle(Geom_Surface) aBoundingSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedBoundingFace));
       if(aFaceSurface == aBoundingSurface) {
-        std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+        GeomShapePtr aShape(new GeomAPI_Shape());
         aShape->setImpl(new TopoDS_Shape(aFaceOnResult));
         isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape);
       }
@@ -417,7 +417,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBase
   if(aResult.IsNull()) {
     return;
   }
-  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+  GeomShapePtr aShape(new GeomAPI_Shape());
   aShape->setImpl(new TopoDS_Shape(aResult));
   this->setShape(aShape);
   this->setDone(true);
index 847435e0ca8ecb2548167d5bad678ea284c855eb..6a75f2e21beed0bac42c9790ecd76f905f16b71a 100644 (file)
@@ -7,8 +7,10 @@
 #ifndef GeomAlgoAPI_Revolution_H_
 #define GeomAlgoAPI_Revolution_H_
 
-#include <GeomAlgoAPI.h>
-#include <GeomAlgoAPI_MakeSweep.h>
+#include "GeomAlgoAPI.h"
+
+#include "GeomAlgoAPI_MakeSweep.h"
+
 #include <GeomAPI_Ax1.h>
 
 /// \class GeomAlgoAPI_Revolution
@@ -29,10 +31,10 @@ public:
   /// \param[in] theAxis axis for revolution.
   /// \param[in] theToAngle to angle.
   /// \param[in] theFromAngle from angle.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                            std::shared_ptr<GeomAPI_Ax1>   theAxis,
-                                            double                         theToAngle,
-                                            double                         theFromAngle);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(const GeomShapePtr                 theBaseShape,
+                                            const std::shared_ptr<GeomAPI_Ax1> theAxis,
+                                            const double                       theToAngle,
+                                            const double                       theFromAngle);
 
   /// \brief Creates revolution for the given shape.
   /// \param[in] theBaseShape face for revolution.
@@ -41,21 +43,21 @@ public:
   /// \param[in] theToAngle to angle.
   /// \param[in] theFromShape from bounding shape. Can be empty. In this case offset will be applied to the basis.
   /// \param[in] theFromAngle from angle.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(std::shared_ptr<GeomAPI_Shape> theBaseShape,
-                                            std::shared_ptr<GeomAPI_Ax1>   theAxis,
-                                            std::shared_ptr<GeomAPI_Shape> theToShape,
-                                            double                         theToAngle,
-                                            std::shared_ptr<GeomAPI_Shape> theFromShape,
-                                            double                         theFromAngle);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(const GeomShapePtr                 theBaseShape,
+                                            const std::shared_ptr<GeomAPI_Ax1> theAxis,
+                                            const GeomShapePtr                 theToShape,
+                                            const double                       theToAngle,
+                                            const GeomShapePtr                 theFromShape,
+                                            const double                       theFromAngle);
 
 private:
   /// Builds resulting shape.
-  void build(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
-             const std::shared_ptr<GeomAPI_Ax1>&   theAxis,
-             const std::shared_ptr<GeomAPI_Shape>& theToShape,
-             double                                theToAngle,
-             const std::shared_ptr<GeomAPI_Shape>& theFromShape,
-             double                                theFromAngle);
+  void build(const GeomShapePtr&                 theBaseShape,
+             const std::shared_ptr<GeomAPI_Ax1>& theAxis,
+             const GeomShapePtr&                 theToShape,
+             const double                        theToAngle,
+             const GeomShapePtr&                 theFromShape,
+             const double                        theFromAngle);
 };
 
 #endif
\ No newline at end of file
index 9b7df3693cbeea1eb9c433e39b30de751525c496..5ad27fc3824c0e5ef0615ba2be6817c0f2ed1b7a 100644 (file)
@@ -30,6 +30,7 @@ GeomValidators_ShapeType::TypeOfShape GeomValidators_ShapeType::shapeType(const
     MyShapeTypes["edge"]   = Edge;
     MyShapeTypes["line"]   = Line;
     MyShapeTypes["circle"] = Circle;
+    MyShapeTypes["wire"]   = Wire;
     MyShapeTypes["face"]   = Face;
     MyShapeTypes["solid"]  = Solid;
     MyShapeTypes["plane"]  = Plane;
@@ -197,31 +198,34 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
   }
   else {
     switch (theShapeType) {
+    case Vertex:
+      aValid = theShape->isVertex();
+      break;
     case Edge:
       aValid = theShape->isEdge();
       break;
-      case Line:
-        aValid = theShape->isEdge() && !GeomAPI_Curve(theShape).isCircle();
+    case Line:
+      aValid = theShape->isEdge() && !GeomAPI_Curve(theShape).isCircle();
       break;
-      case Circle:
-        aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle();
+    case Circle:
+      aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle();
       break;
-      case Vertex:
-        aValid = theShape->isVertex();
+    case Wire:
+      aValid = theShape->shapeType() == GeomAPI_Shape::WIRE;
+      break;
+    case Face:
+      aValid = theShape->isFace();
+      break;
+    case Solid:
+      aValid = theShape->isSolid() || theShape->isCompSolid() ||
+               theShape->isCompoundOfSolids();
+      break;
+    case Compound:
+      aValid = theShape->isCompound();
+      break;
+    default:
+      aValid = false;
       break;
-      case Solid:
-        aValid = theShape->isSolid() || theShape->isCompSolid() ||
-                 theShape->isCompoundOfSolids();
-        break;
-      case Face:
-        aValid = theShape->isFace();
-        break;
-      case Compound:
-        aValid = theShape->isCompound();
-        break;
-      default:
-        aValid = false;
-        break;
     }
   }
   return aValid;
index 57de1470897b06bba892e4ab5678fb3a42b3cc38..50be8a5ec16eca8a4d719278af55c6f3f2a21c85 100644 (file)
@@ -31,10 +31,11 @@ class GeomValidators_ShapeType : public ModelAPI_AttributeValidator
     Edge,
     Line,
     Circle,
+    Wire,
     Face,
+    Plane,
     Solid,
     Compound,
-    Plane,
     AnyShape
   };