]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2593: CEA 2018-2 Geometrical Naming
authordbv <dbv@opencascade.com>
Wed, 29 Aug 2018 06:54:52 +0000 (09:54 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
# Conflicts:
# src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
# src/FeaturesPlugin/FeaturesPlugin_Placement.h
# src/Model/Model_AttributeSelection.cpp
# src/Model/Model_AttributeSelection.h

54 files changed:
src/Config/Config_AttributeMessage.cpp
src/Config/Config_AttributeMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Validators.cpp
src/ConstructionPlugin/axis_widget.xml
src/ConstructionPlugin/plane_widget.xml
src/ConstructionPlugin/point_widget.xml
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp
src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
src/FeaturesPlugin/FeaturesPlugin_Placement.h
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp
src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp
src/FeaturesPlugin/FeaturesPlugin_Translation.cpp
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/extrusioncut_widget.xml
src/FeaturesPlugin/extrusionfuse_widget.xml
src/FeaturesPlugin/multirotation_widget.xml
src/FeaturesPlugin/multitranslation_widget.xml
src/FeaturesPlugin/placement_widget.xml
src/FeaturesPlugin/revolution_widget.xml
src/FeaturesPlugin/revolutioncut_widget.xml
src/FeaturesPlugin/revolutionfuse_widget.xml
src/FeaturesPlugin/rotation_widget.xml
src/FeaturesPlugin/symmetry_widget.xml
src/FeaturesPlugin/translation_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp
src/GeomValidators/GeomValidators_Face.cpp
src/GeomValidators/GeomValidators_ShapeType.cpp
src/GeomValidators/GeomValidators_ShapeType.h
src/GeomValidators/GeomValidators_ZeroOffset.cpp
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_Session.cpp
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModelAPI/ModelAPI_Validator.h
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp
src/PrimitivesPlugin/cone_widget.xml
src/PrimitivesPlugin/cylinder_widget.xml
src/PrimitivesPlugin/torus_widget.xml
src/SketchPlugin/SketchPlugin_Sketch.cpp

index 32051337cd23c0e703978d8cd3146387bb639565..d8f2f23e8704f3817f51a22b5d4b3d5a47485131 100644 (file)
@@ -27,6 +27,7 @@ Config_AttributeMessage::Config_AttributeMessage(const Events_ID theId, const vo
   myFeatureId = std::string(); // Feature unique id
   myIsObligatory = true;
   myIsConcealment = false;
+  myIsGeometricalSelection = false;
 }
 
 Config_AttributeMessage::~Config_AttributeMessage()
@@ -94,3 +95,13 @@ void Config_AttributeMessage::setMainArgument(bool isMainArg)
 {
   myIsMainArgument = isMainArg;
 }
+
+bool Config_AttributeMessage::isGeometricalSelection() const
+{
+  return myIsGeometricalSelection;
+}
+
+void Config_AttributeMessage::setGeometricalSelection(bool isGeometricalSelection)
+{
+  myIsGeometricalSelection = isGeometricalSelection;
+}
index cb4ef232c79b2740c8768b8a49ccf716e3a57484..4df9cd8b474845d5b05003f199095464a0cb94c3 100644 (file)
@@ -42,6 +42,7 @@ class Config_AttributeMessage : public Events_Message
   bool myIsObligatory; ///< Required to be set by user, else it's feature is invalid.
   bool myIsConcealment; ///< If true, conceals features used as input
   bool myIsMainArgument; ///< Mark attribute as a main argument of the feature
+  bool myIsGeometricalSelection; ///< If true selects geometry instead of shape;
   ///< a list of pairs, if the attribute is placed inside paged containers: (case, switch)
   std::list<std::pair<std::string, std::string> > myCases;
 
@@ -69,6 +70,8 @@ public:
   CONFIG_EXPORT bool isConcealment() const;
   /// Returns true if attribute is a main argument of the feature
   CONFIG_EXPORT bool isMainArgument() const;
+  /// Returns true if attribute selects geometry instead of shape;
+  CONFIG_EXPORT bool isGeometricalSelection() const;
   /// Returns container of ids of pair of a case and switches
   CONFIG_EXPORT const std::list<std::pair<std::string, std::string> >& getCases() const;
   /// Sets ids of pair of a case and switches
@@ -84,6 +87,8 @@ public:
   CONFIG_EXPORT void setObligatory(bool isObligatory);
   /// Set a state that the attribute is a main argument of the feature
   CONFIG_EXPORT void setMainArgument(bool isMainArg);
+  /// Set attribute's geometrical selection state
+  CONFIG_EXPORT void setGeometricalSelection(bool isGeometricalSelection);
 };
 
 #endif // ATTRIBUTE_MESSAGE_H
index 377cb364e10d69e818bc5899874219317fbd9e42..ac7fdbe6caac5b10537d5caeb06531f93ee8750e 100644 (file)
@@ -89,6 +89,9 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
         aMessage->setConcealment(isConcealment);
         bool isMainArg = isConcealment && getBooleanAttribute(theNode, ATTR_MAIN_ARG, false);
         aMessage->setMainArgument(isMainArg);
+        aMessage->setGeometricalSelection(getBooleanAttribute(theNode,
+                                                              ATTR_GEOMETRICAL_SELECTION,
+                                                              false));
 
         std::list<std::pair<std::string, std::string> > aCases;
         xmlNodePtr aCaseNode = hasParentRecursive(theNode,
index beb599b206d87450a827f5692f1d08c75881dc10..eb3085ce6e5b6d46b6ef29a6dfa136929284793d 100644 (file)
@@ -100,6 +100,8 @@ const static char* ATTR_USE_RESET = "use_reset";
 const static char* ATTR_GREED = "greed";
 const static char* ATTR_MODIFIED_IN_EDIT = "modified_in_edit";
 const static char* ATTR_MAIN_ARG = "main_argument";
+const static char* ATTR_GEOMETRICAL_SELECTION = "geometrical_selection";
+
 
 // WDG_INFO properties
 const static char* INFO_WDG_TEXT = FEATURE_TEXT;
index 5f4b2f8d65fb45391d3dd4567dfc0fd923a970c3..44dbc087595f99b85c13bc0fbc0ffb3cd3367266 100644 (file)
@@ -33,6 +33,7 @@
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_PointBuilder.h>
@@ -162,16 +163,26 @@ void ConstructionPlugin_Axis::createAxisByPointAndDirection()
 
 void ConstructionPlugin_Axis::createAxisByCylindricalFace()
 {
-    std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(CYLINDRICAL_FACE())->value();
-     // update arguments due to the selection value
-    if (aSelection && !aSelection->isNull() && aSelection->isFace()) {
-      std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection);
-
-      ResultConstructionPtr aConstr = document()->createConstruction(data());
-      aConstr->setInfinite(true);
-      aConstr->setShape(anEdge);
-      setResult(aConstr);
-    }
+  std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(CYLINDRICAL_FACE())->value();
+    // update arguments due to the selection value
+
+  if (!aSelection.get() || aSelection->isNull()) {
+    return;
+  }
+
+  if (aSelection->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aSelection);
+    aSelection = anIt.current();
+  }
+
+  if (aSelection->isFace()) {
+    std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection);
+
+    ResultConstructionPtr aConstr = document()->createConstruction(data());
+    aConstr->setInfinite(true);
+    aConstr->setShape(anEdge);
+    setResult(aConstr);
+  }
 }
 
 void ConstructionPlugin_Axis::createAxisByDimensions()
@@ -203,7 +214,14 @@ void ConstructionPlugin_Axis::createAxisByLine()
   if(!aLineShape.get()) {
     aLineShape = anEdgeSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
+  GeomEdgePtr anEdge;
+  if (aLineShape->isEdge()) {
+    anEdge = aLineShape->edge();
+  }
+  else if (aLineShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aLineShape);
+    anEdge = anIt.current()->edge();
+  }
 
   ResultConstructionPtr aConstr = document()->createConstruction(data());
   aConstr->setInfinite(true);
@@ -219,7 +237,14 @@ void ConstructionPlugin_Axis::createAxisByPlaneAndPoint()
   if(!aFaceShape.get()) {
     aFaceShape = aFaceSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aFaceShape));
+  GeomFacePtr aFace;
+  if (aFaceShape->isFace()) {
+    aFace = aFaceShape->face();
+  }
+  else if (aFaceShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape);
+    aFace = anIt.current()->face();
+  }
   std::shared_ptr<GeomAPI_Pln> aPln = aFace->getPlane();
 
   // Get point.
@@ -253,7 +278,14 @@ void ConstructionPlugin_Axis::createAxisByTwoPlanes()
   if(!aFaceShape1.get()) {
     aFaceShape1 = aFaceSelection1->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace1(new GeomAPI_Face(aFaceShape1));
+  std::shared_ptr<GeomAPI_Face> aFace1;
+  if (aFaceShape1->isFace()) {
+    aFace1 = aFaceShape1->face();
+  }
+  else if (aFaceShape1->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape1);
+    aFace1 = anIt.current()->face();
+  }
   std::shared_ptr<GeomAPI_Pln> aPln1 = aFace1->getPlane();
 
   std::string useOffset1 = string(USE_OFFSET1())->value();
@@ -272,7 +304,14 @@ void ConstructionPlugin_Axis::createAxisByTwoPlanes()
   if(!aFaceShape2.get()) {
     aFaceShape2 = aFaceSelection2->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace2(new GeomAPI_Face(aFaceShape2));
+  std::shared_ptr<GeomAPI_Face> aFace2;
+  if (aFaceShape2->isFace()) {
+    aFace2 = aFaceShape2->face();
+  }
+  else if (aFaceShape2->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape2);
+    aFace2 = anIt.current()->face();
+  }
   std::shared_ptr<GeomAPI_Pln> aPln2 = aFace2->getPlane();
 
   std::string useOffset2 = string(USE_OFFSET2())->value();
index ad046394a37ac7a5685644dcb02678c1eb7528d8..1189cb761d6e390b590593171d25912eafb57a6c 100644 (file)
@@ -33,6 +33,7 @@
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_XYZ.h>
 
@@ -231,7 +232,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByLineAndPoint()
   if(!aLineShape.get()) {
     aLineShape = anEdgeSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
+  std::shared_ptr<GeomAPI_Edge> anEdge;
+  if (aLineShape->isEdge()) {
+    anEdge = aLineShape->edge();
+  }
+  else if (aLineShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aLineShape);
+    anEdge = anIt.current()->edge();
+  }
 
   // Get point.
   AttributeSelectionPtr aPointSelection = selection(POINT());
@@ -285,7 +293,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByDistanceFromOth
       return aPlane;
     }
 
-    std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aShape));
+    std::shared_ptr<GeomAPI_Face> aFace;
+    if (aShape->isFace()) {
+      aFace = aShape->face();
+    }
+    else if (aShape->isCompound()) {
+      GeomAPI_ShapeIterator anIt(aShape);
+      aFace = anIt.current()->face();
+    }
 
     std::shared_ptr<GeomAPI_Pln> aPln = aFace->getPlane();
     std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
@@ -308,7 +323,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByCoincidentPoint
   if(!aFaceShape.get()) {
     aFaceShape = aFaceSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aFaceShape));
+  std::shared_ptr<GeomAPI_Face> aFace;
+  if (aFaceShape->isFace()) {
+    aFace = aFaceShape->face();
+  }
+  else if (aFaceShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape);
+    aFace = anIt.current()->face();
+  }
 
   // Get point.
   AttributeSelectionPtr aPointSelection = selection(COINCIDENT_POINT());
@@ -336,7 +358,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByRotation()
   if(!aFaceShape.get()) {
     aFaceShape = aFaceSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aFaceShape));
+  std::shared_ptr<GeomAPI_Face> aFace;
+  if (aFaceShape->isFace()) {
+    aFace = aFaceShape->face();
+  }
+  else if (aFaceShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape);
+    aFace = anIt.current()->face();
+  }
   aFace = makeRectangularFace(aFace, aFace->getPlane());
 
   // Get axis.
@@ -345,7 +374,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByRotation()
   if(!anAxisShape.get()) {
     anAxisShape = anAxisSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(anAxisShape));
+  std::shared_ptr<GeomAPI_Edge> anEdge;
+  if (anAxisShape->isEdge()) {
+    anEdge = anAxisShape->edge();
+  }
+  else if (anAxisShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(anAxisShape);
+    anEdge = anIt.current()->edge();
+  }
 
   std::shared_ptr<GeomAPI_Ax1> anAxis =
     std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
@@ -378,7 +414,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByTwoParallelPlan
   if(!aFaceShape1.get()) {
     aFaceShape1 = aFaceSelection1->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace1(new GeomAPI_Face(aFaceShape1));
+  std::shared_ptr<GeomAPI_Face> aFace1;
+  if (aFaceShape1->isFace()) {
+    aFace1 = aFaceShape1->face();
+  }
+  else if (aFaceShape1->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape1);
+    aFace1 = anIt.current()->face();
+  }
   std::shared_ptr<GeomAPI_Pln> aPln1 = aFace1->getPlane();
 
   // Get plane 2.
@@ -387,7 +430,14 @@ std::shared_ptr<GeomAPI_Shape> ConstructionPlugin_Plane::createByTwoParallelPlan
   if(!aFaceShape2.get()) {
     aFaceShape2 = aFaceSelection2->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace2(new GeomAPI_Face(aFaceShape2));
+  std::shared_ptr<GeomAPI_Face> aFace2;
+  if (aFaceShape2->isFace()) {
+    aFace2 = aFaceShape2->face();
+  }
+  else if (aFaceShape2->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aFaceShape2);
+    aFace2 = anIt.current()->face();
+  }
   std::shared_ptr<GeomAPI_Pln> aPln2 = aFace2->getPlane();
 
   std::shared_ptr<GeomAPI_Pnt> anOrig1 = aPln1->location();
index 8f4f8fc62ed55fec8c2226081ff66f03ddedc6e4..51432b609b7f269b390759b8a7a0f934973793b3 100644 (file)
@@ -36,6 +36,7 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_ShapeIterator.h>
 
 //==================================================================================================
 ConstructionPlugin_Point::ConstructionPlugin_Point()
@@ -271,7 +272,14 @@ std::list<std::shared_ptr<GeomAPI_Vertex> >
   if(!aLineShape.get()) {
     aLineShape = aLineSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
+  GeomEdgePtr anEdge;
+  if (aLineShape->isEdge()) {
+    anEdge = aLineShape->edge();
+  }
+  else if (aLineShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aLineShape);
+    anEdge = anIt.current()->edge();
+  }
 
   // Get plane.
   AttributeSelectionPtr aPlaneSelection= selection(INTERSECTION_PLANE());
@@ -279,7 +287,14 @@ std::list<std::shared_ptr<GeomAPI_Vertex> >
   if(!aPlaneShape.get()) {
     aPlaneShape = aPlaneSelection->context()->shape();
   }
-  std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aPlaneShape));
+  GeomFacePtr aFace;
+  if (aPlaneShape->isFace()) {
+    aFace = aPlaneShape->face();
+  }
+  else if (aPlaneShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(aPlaneShape);
+    aFace = anIt.current()->face();
+  }
 
   if (!string(USE_OFFSET())->value().empty()) {
     double anOffset = real(OFFSET())->value();
index 2390b83a4eec2b9e9327890a0c3d83f748dc02c5..50047dd6951d0c3ca7bb767df066018e4d3abfce 100644 (file)
@@ -27,6 +27,7 @@
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Pnt.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
 #include <ModelAPI_AttributeSelection.h>
@@ -35,6 +36,7 @@
 #include <Events_InfoMessage.h>
 
 static std::shared_ptr<GeomAPI_Edge> getEdge(const GeomShapePtr theShape);
+static std::shared_ptr<GeomAPI_Face> getFace(const GeomShapePtr theShape);
 static std::shared_ptr<GeomAPI_Lin> getLin(const GeomShapePtr theShape);
 static std::shared_ptr<GeomAPI_Pln> getPln(const GeomShapePtr theShape);
 static std::shared_ptr<GeomAPI_Pnt> getPnt(const GeomShapePtr theShape);
@@ -114,7 +116,7 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid(
   AttributeSelectionPtr anAttribute2 = aFeature->selection(theArguments.front());
 
   std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<GeomAPI_Pln> aPln;
+  std::shared_ptr<GeomAPI_Face> aFace;
 
   GeomShapePtr aShape1 = anAttribute1->value();
   ResultPtr aContext1 = anAttribute1->context();
@@ -137,20 +139,20 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid(
 
   bool isPlaneFirst = false;
   anEdge = getEdge(aShape1);
-  aPln = getPln(aShape2);
-  if(!anEdge.get() || !aPln.get()) {
+
+  aFace = getFace(aShape2);
+  if(!anEdge.get() || !aFace.get()) {
     anEdge = getEdge(aShape2);
-    aPln = getPln(aShape1);
+    aFace = getFace(aShape1);
     isPlaneFirst = true;
   }
 
-  if(!anEdge.get() || !aPln.get()) {
+  if(!anEdge.get() || !aFace.get()) {
     theError = "Wrong shape types selected.";
     return false;
   }
 
-  std::shared_ptr<GeomAPI_Face> aPlaneFace(new GeomAPI_Face(isPlaneFirst ? aShape1 : aShape2));
-  if(GeomAlgoAPI_ShapeTools::isParallel(anEdge, aPlaneFace)) {
+  if(GeomAlgoAPI_ShapeTools::isParallel(anEdge, aFace)) {
     theError = "Plane and edge are parallel.";
     return false;
   }
@@ -474,25 +476,51 @@ bool ConstructionPlugin_ValidatorPointThreeNonParallelPlanes::isValid(
 
 std::shared_ptr<GeomAPI_Edge> getEdge(const GeomShapePtr theShape)
 {
-  if(!theShape->isEdge()) {
-    return std::shared_ptr<GeomAPI_Edge>();
-  }
+  GeomEdgePtr anEdge;
 
-  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
+  if(theShape->isEdge()) {
+    anEdge = theShape->edge();
+  }
+  else if (theShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(theShape);
+    anEdge = anIt.current()->edge();
+  }
 
   return anEdge;
 }
 
+GeomFacePtr getFace(const GeomShapePtr theShape)
+{
+  GeomFacePtr aFace;
+
+  if (theShape->isFace()) {
+    aFace = theShape->face();
+  }
+  else if (theShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(theShape);
+    aFace = anIt.current()->face();
+  }
+
+  return aFace;
+}
+
 std::shared_ptr<GeomAPI_Lin> getLin(const GeomShapePtr theShape)
 {
   std::shared_ptr<GeomAPI_Lin> aLin;
 
-  if(!theShape->isEdge()) {
+  GeomEdgePtr anEdge;
+
+  if (theShape->isEdge()) {
+    anEdge = theShape->edge();
+  }
+  else if (theShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(theShape);
+    anEdge = anIt.current()->edge();
+  }
+  else {
     return aLin;
   }
 
-  std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
-
   if(!anEdge->isLine()) {
     return aLin;
   }
@@ -506,12 +534,19 @@ std::shared_ptr<GeomAPI_Pln> getPln(const GeomShapePtr theShape)
 {
   std::shared_ptr<GeomAPI_Pln> aPln;
 
-  if(!theShape->isFace()) {
+  GeomFacePtr aFace;
+
+  if(theShape->isFace()) {
+    aFace = theShape->face();
+  }
+  else if (theShape->isCompound()) {
+    GeomAPI_ShapeIterator anIt(theShape);
+    aFace = anIt.current()->face();
+  }
+  else {
     return aPln;
   }
 
-  std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(theShape));
-
   if(!aFace->isPlanar()) {
     return aPln;
   }
index 928d0302256c95e84fcba78a2cbd44de8cdde5a5..4ccefe0118ee526c315b9769bfa49dd1d987395c 100644 (file)
@@ -50,7 +50,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="Line"
                       tooltip="Select line."
                       icon="icons/Construction/edge.png"
-                      shape_types="edge">
+                      shape_types="edge"
+                      geometrical_selection="true">
         <validator id="GeomValidators_ShapeType" parameters="line"/>
       </shape_selector>
     </box>
@@ -59,7 +60,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         label="Main object"
         icon="icons/Construction/circle.png"
         tooltip="Select a cylindrical object"
-        shape_types="face">
+        shape_types="face"
+        geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="cylinder"/>
       </shape_selector>
     </box>
@@ -68,7 +70,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="Plane"
                       tooltip="Select a planar face."
                       icon="icons/Construction/face.png"
-                      shape_types="face">
+                      shape_types="face"
+                      geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="plane"/>
       </shape_selector>
       <shape_selector id="point"
@@ -83,7 +86,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="1st plane"
                       tooltip="Select a planar face."
                       icon="icons/Construction/face.png"
-                      shape_types="face">
+                      shape_types="face"
+                      geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="plane"/>
         <validator id="ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes" parameters="plane2"/>
       </shape_selector>
@@ -95,7 +99,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="2nd plane"
                       tooltip="Select a planar face."
                       icon="icons/Construction/face.png"
-                      shape_types="face">
+                      shape_types="face"
+                      geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="plane"/>
         <validator id="ConstructionPlugin_ValidatorAxisTwoNotParallelPlanes" parameters="plane1"/>
       </shape_selector>
index f23a4f40604f8053683bf81bf5461866a8ddd343..dfe2007b3a45f38006ece69b7ca5a9ffc4d93a7a 100644 (file)
@@ -55,7 +55,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="Line"
                       tooltip="Select line."
                       icon="icons/Construction/edge.png"
-                      shape_types="edge">
+                      shape_types="edge"
+                      geometrical_selection="true">
         <validator id="GeomValidators_ShapeType" parameters="line"/>
         <validator id="ConstructionPlugin_ValidatorPlaneLinePoint" parameters="point,perpendicular"/>
       </shape_selector>
@@ -79,7 +80,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="Plane"
                       tooltip="Select a planar face."
                       icon="icons/Construction/face.png"
-                      shape_types="face">
+                      shape_types="face"
+                      geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="plane"/>
       </shape_selector>
       <toolbox id="by_other_plane_option">
@@ -118,7 +120,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Axis"
                           tooltip="Select line for axis."
                           icon="icons/Construction/axis.png"
-                          shape_types="edge">
+                          shape_types="edge"
+                          geometrical_selection="true">
             <validator id="GeomValidators_ShapeType" parameters="line"/>
           </shape_selector>
           <doublevalue id="angle"
@@ -140,7 +143,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="1st plane"
                       tooltip="Select a planar face."
                       icon="icons/Construction/face.png"
-                      shape_types="face">
+                      shape_types="face"
+                      geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="plane"/>
         <validator id="ConstructionPlugin_ValidatorPlaneTwoParallelPlanes" parameters="plane2"/>
       </shape_selector>
@@ -148,7 +152,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="2nd plane"
                       tooltip="Select a planar face."
                       icon="icons/Construction/face.png"
-                      shape_types="face">
+                      shape_types="face"
+                      geometrical_selection="true">
         <validator id="GeomValidators_Face" parameters="plane"/>
         <validator id="ConstructionPlugin_ValidatorPlaneTwoParallelPlanes" parameters="plane1"/>
       </shape_selector>
index bd7439f8acc791f8f7d68c814c8b3e17ac248792..3ccf7755052a34edf6309881123bcfc1481c65e2 100644 (file)
@@ -141,7 +141,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Line"
                           tooltip="Line for intersection."
                           icon="icons/Construction/edge.png"
-                          shape_types="edge">
+                          shape_types="edge"
+                          geometrical_selection="true">
             <validator id="ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel"
                        parameters="intersection_plane"/>
           </shape_selector>
@@ -149,7 +150,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane"
                           tooltip="Plane for intersection."
                           icon="icons/Construction/face.png"
-                          shape_types="face">
+                          shape_types="face"
+                          geometrical_selection="true">
             <validator id="GeomValidators_Face" parameters="plane"/>
             <validator id="ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel"
                        parameters="intersection_line"/>
index baf8f639769f49b80e20980a6b7761b807be346d..ceb01e79336a84f291aa644980e52435afb6d828 100644 (file)
@@ -31,6 +31,7 @@
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 
 //=================================================================================================
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
@@ -95,16 +96,29 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   getBaseShapes(theBaseShapes);
 
   //Getting direction.
-  std::shared_ptr<GeomAPI_Dir> aDir;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
+  static const std::string aSelectionError = "Error: The direction shape selection is bad.";
   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()));
+  GeomShapePtr aShape = aSelection->value();
+  if (!aShape.get()) {
+    if (aSelection->context().get()) {
+      aShape = aSelection->context()->shape();
+    }
+  }
+
+  GeomEdgePtr anEdge;
+  if (aShape.get()) {
+    if (aShape->isEdge())
+    {
+      anEdge = aShape->edge();
+    }
+    else if (aShape->isCompound())
+    {
+      GeomAPI_ShapeIterator anIt(aShape);
+      anEdge = anIt.current()->edge();
+    }
   }
+
+  std::shared_ptr<GeomAPI_Dir> aDir;
   if(anEdge.get()) {
     if(anEdge->isLine()) {
       aDir = anEdge->line()->direction();
@@ -134,6 +148,10 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
       if(!aToShape.get() && aSelection->context().get()) {
         aToShape = aSelection->context()->shape();
       }
+      if (aToShape->isCompound()) {
+        GeomAPI_ShapeIterator anIt(aToShape);
+        aToShape = anIt.current();
+      }
     }
     aSelection = selection(FROM_OBJECT_ID());
     if(aSelection.get()) {
@@ -141,6 +159,10 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
       if(!aFromShape.get() && aSelection->context().get()) {
         aFromShape = aSelection->context()->shape();
       }
+      if (aFromShape->isCompound()) {
+        GeomAPI_ShapeIterator anIt(aFromShape);
+        aFromShape = anIt.current();
+      }
     }
   }
 
index 2410ac080beb0f962d42042e5ea3e65ab9e282a5..85390b59e613968272201a812d7aadd8e3462567 100644 (file)
@@ -15,6 +15,7 @@
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Trsf.h>
 
 #include <ModelAPI_AttributeDouble.h>
@@ -93,20 +94,43 @@ void FeaturesPlugin_MultiRotation::performRotation1D()
   }
 
   //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(AXIS_ANGULAR_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
+
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> anAxis(new GeomAPI_Ax1(anEdge->line()->location(),
+                                                      anEdge->line()->direction()));
 
   // Getting number of copies.
   int nbCopies =
index 81d07b5a40d7b236637fef18463e029b8090b250..355a0fdfd2beb7c8679f3b748697baecf4835654 100644 (file)
@@ -25,6 +25,7 @@
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Trsf.h>
 
 #include <ModelAPI_AttributeDouble.h>
@@ -101,21 +102,44 @@ void FeaturesPlugin_MultiTranslation::performOneDirection()
   }
 
   //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(AXIS_FIRST_DIR_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
+
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
+  }
+  else
+  {
+    setError(aSelectionError);
+    return;
   }
 
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> anAxis (new GeomAPI_Ax1(anEdge->line()->location(),
+                                                       anEdge->line()->direction()));
+
   // Getting step.
   double aStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value();
 
@@ -222,32 +246,80 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection()
   }
 
   //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> aFirstAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(AXIS_FIRST_DIR_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
   }
-  if(anEdge) {
-    aFirstAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                              anEdge->line()->direction()));
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
   }
-  std::shared_ptr<GeomAPI_Ax1> aSecondAxis;
-  anObjRef = selection(FeaturesPlugin_MultiTranslation::AXIS_SECOND_DIR_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
   }
-  if(anEdge) {
-    aSecondAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                               anEdge->line()->direction()));
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> aFirstAxis(new GeomAPI_Ax1(anEdge->line()->location(),
+                                                          anEdge->line()->direction()));
+
+  //Getting axis.
+  anObjRef = selection(AXIS_SECOND_DIR_ID());
+  aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
+  }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> aSecondAxis(new GeomAPI_Ax1(anEdge->line()->location(),
+                                                           anEdge->line()->direction()));
 
   // Getting step.
   double aFirstStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value();
index bd1e96efc6ad30c2baa8aef8f6e833c837e72419..ad4975878166096d757179600cf59e98928e6321 100644 (file)
@@ -31,6 +31,7 @@
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Face.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAlgoAPI_Placement.h>
 #include <GeomAlgoAPI_Transform.h>
 
@@ -121,21 +122,8 @@ void FeaturesPlugin_Placement::execute()
   // Verify planarity of faces and linearity of edges
   std::shared_ptr<GeomAPI_Shape> aShapes[2] = {aStartShape, anEndShape};
   for (int i = 0; i < 2; i++) {
-    if (aShapes[i]->isFace()) {
-      std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aShapes[i]));
-      if (!aFace->isPlanar()) {
-        static const std::string aPlanarityError = "Error: One of selected faces is not planar.";
-        setError(aPlanarityError);
-        return;
-      }
-    }
-    else if (aShapes[i]->isEdge()) {
-      std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aShapes[i]));
-      if (!anEdge->isLine()) {
-        static const std::string aLinearityError = "Error: One of selected endges is not linear.";
-        setError(aLinearityError);
-        return;
-      }
+    if (!isShapeValid(aShapes[i])) {
+      return;
     }
   }
 
@@ -199,3 +187,45 @@ void FeaturesPlugin_Placement::execute()
   // Remove the rest results if there were produced in the previous pass.
   removeResults(aResultIndex);
 }
+
+//==================================================================================================
+bool FeaturesPlugin_Placement::isShapeValid(GeomShapePtr theShape)
+{
+  if (theShape->isCompound()) {
+    GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+    for (GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) {
+      GeomShapePtr aCurrentShape = anIt.current();
+      if (aShapeType == GeomAPI_Shape::SHAPE) {
+        aShapeType = aCurrentShape->shapeType();
+      }
+      else if (aShapeType != aCurrentShape->shapeType()) {
+        static const std::string aLinearityError =
+          "Error: Selected compound contains shapes with different types.";
+        setError(aLinearityError);
+        return false;
+      }
+
+      if (!isShapeValid(aCurrentShape)) {
+        return false;
+      }
+    }
+  }
+  else if (theShape->isFace()) {
+    std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(theShape));
+    if (!aFace->isPlanar()) {
+      static const std::string aPlanarityError = "Error: One of selected faces is not planar.";
+      setError(aPlanarityError);
+      return false;
+    }
+  }
+  else if (theShape->isEdge()) {
+    std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
+    if (!anEdge->isLine()) {
+      static const std::string aLinearityError = "Error: One of selected edges is not linear.";
+      setError(aLinearityError);
+      return false;
+    }
+  }
+
+  return true;
+}
index ccc9dba8bdfa76a01547fb52cba8baa228bfba6c..4b8e94c6459b98bc692765fd3daf8cca031c45fe 100644 (file)
@@ -95,6 +95,9 @@ class FeaturesPlugin_Placement : public ModelAPI_Feature
 
   /// Use plugin manager for features creation
   FeaturesPlugin_Placement();
+private:
+  /// Checks validity of passed shape.
+  bool isShapeValid(GeomShapePtr theShape);
 };
 
 #endif
index 4a643318083edd19d5ba970d0452f74c18c0c355..4ac87606e659d9c0769bd44e7c421f3ddab6f00e 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 
 //=================================================================================================
 FeaturesPlugin_Revolution::FeaturesPlugin_Revolution()
@@ -92,17 +93,37 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
   // Getting base shapes.
   getBaseShapes(theBaseShapes);
 
-  //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
+  // Getting axis.
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
   AttributeSelectionPtr aSelection = selection(AXIS_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()));
+  GeomShapePtr aShape = aSelection->value();
+  if (!aShape.get()) {
+    if (aSelection->context().get()) {
+      aShape = aSelection->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return false;
+  }
+
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
+  else
+  {
+    setError(aSelectionError);
+    return false;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> anAxis;
   if(anEdge.get()) {
     if(anEdge->isLine()) {
       anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
@@ -137,6 +158,10 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
       if(!aToShape.get() && aSelection->context().get()) {
         aToShape = aSelection->context()->shape();
       }
+      if (aToShape->isCompound()) {
+        GeomAPI_ShapeIterator anIt(aToShape);
+        aToShape = anIt.current();
+      }
     }
     aSelection = selection(FROM_OBJECT_ID());
     if(aSelection.get()) {
@@ -144,6 +169,10 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
       if(!aFromShape.get() && aSelection->context().get()) {
         aFromShape = aSelection->context()->shape();
       }
+      if (aFromShape->isCompound()) {
+        GeomAPI_ShapeIterator anIt(aFromShape);
+        aFromShape = anIt.current();
+      }
     }
   }
 
index f9a11c5c6ac156b1a8c39dbcb62485c48c0836a5..8d13db5bfb76550245b8dbf096417a54ace53dc2 100755 (executable)
@@ -30,6 +30,7 @@
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Trsf.h>
 
 #include <FeaturesPlugin_Tools.h>
@@ -99,20 +100,43 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle()
   }
 
   //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
+
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> anAxis (new GeomAPI_Ax1(anEdge->line()->location(),
+                                                       anEdge->line()->direction()));
 
   // Getting angle.
   double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value();
index 9fa897e5e31de3414252261aa3dca469556a44f1..6d2cb59d28ceb46eb556a98678861027b9b58eab 100644 (file)
@@ -30,6 +30,7 @@
 #include <GeomAPI_Face.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Trsf.h>
 
 #include <ModelAPI_AttributeBoolean.h>
@@ -195,21 +196,45 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis()
     return;
 
   //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
   }
 
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
+  }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax1> anAxis (new GeomAPI_Ax1(anEdge->line()->location(),
+                                                       anEdge->line()->direction()));
+
+
   // Moving each object.
   int aResultIndex = 0;
   std::list<ResultPtr>::iterator aContext = aContextes.begin();
@@ -271,23 +296,45 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane()
   if (!collectSourceObjects(anObjects, aContextes))
     return;
 
-  //Getting axis.
-  std::shared_ptr<GeomAPI_Ax2> aPlane;
-  std::shared_ptr<GeomAPI_Pln> aPln;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID());
-  if (anObjRef && anObjRef->value() && anObjRef->value()->isFace()) {
-    aPln = std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(anObjRef->value()))->getPlane();
+  //Getting plane.
+  static const std::string aSelectionError = "Error: The plane shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(PLANE_OBJECT_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
   }
-  else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isFace()) {
-    aPln =
-      std::shared_ptr<GeomAPI_Face>(new GeomAPI_Face(anObjRef->context()->shape()))->getPlane();
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
   }
-  if (aPln) {
-    aPlane = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aPln->location(),
-                                                          aPln->direction()));
+
+  GeomFacePtr aFace;
+  if (aShape->isFace())
+  {
+    aFace = aShape->face();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    aFace = anIt.current()->face();
   }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!aFace.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax2> aPlane(new GeomAPI_Ax2(aFace->getPlane()->location(),
+                                                      aFace->getPlane()->direction()));
+
 
   // Moving each object.
   int aResultIndex = 0;
index 19ec3564ae804999dd42963d2851767990d137e9..9c32428bb5f5bac669d305a510aae5b94ce95456 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Trsf.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
@@ -112,21 +113,45 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance()
   }
 
   //Getting axis.
-  std::shared_ptr<GeomAPI_Ax1> anAxis;
-  std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
-  if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->value()));
-  } else if (anObjRef && !anObjRef->value() && anObjRef->context() &&
-             anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anObjRef->context()->shape()));
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID());
+  GeomShapePtr aShape = anObjRef->value();
+  if (!aShape.get()) {
+    if (anObjRef->context().get()) {
+      aShape = anObjRef->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
+
+  GeomEdgePtr anEdge;
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(anEdge->line()->location(),
-                                                          anEdge->line()->direction()));
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
   }
 
+  std::shared_ptr<GeomAPI_Ax1> anAxis(new GeomAPI_Ax1(anEdge->line()->location(),
+                                                      anEdge->line()->direction()));
+
+
   // Getting distance.
   double aDistance = real(FeaturesPlugin_Translation::DISTANCE_ID())->value();
 
index aa78551d6b665e30f0dcf7a03d678694efa7bb1a..ccb43b40643951035c1df9b12e70711e5bcb9576 100644 (file)
@@ -547,6 +547,11 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
       if(aContext.get()) {
         aDirShape = aContext->shape();
       }
+
+      if (aDirShape.get() && aDirShape->isCompound()) {
+        GeomAPI_ShapeIterator anIt(aDirShape);
+        aDirShape = anIt.current();
+      }
     }
   }
 
index 910a623e3bd48907dbbc846d0641782fc820b6d6..6e14b846e106534fd604b8f35e67afde4f6f94bb 100644 (file)
@@ -41,6 +41,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                   label="Direction"
                   tooltip="Select an edge for direction"
                   shape_types="edge"
+                  geometrical_selection="true"
                   default="&lt;base normal&gt;">
     <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
   </shape_selector>
@@ -74,6 +75,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                         label="Plane face"
                         tooltip="Bounding plane (select a planar face)"
                         shape_types="face"
+                        geometrical_selection="true"
                         default="&lt;base sketch&gt;">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
@@ -90,6 +92,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                         label="Plane face"
                         tooltip="Bounding plane (select a planar face)"
                         shape_types="face"
+                        geometrical_selection="true"
                         default="&lt;base sketch&gt;">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
index b176ddc1812e8050c855c02a8569abd097c22aca..c8bc95a8e47c36bdfcff7de3c851da29b5a83a9e 100755 (executable)
@@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                     label="Direction"
                     tooltip="Select an edge for direction"
                     shape_types="edge"
+                    geometrical_selection="true"
                     default="&lt;base normal&gt;">
       <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
     </shape_selector>
@@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
@@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
index e65b6b4af990bcdcb52914206dae5522a2fd9ade..0891b558926a5566ae69f1c874a217e3fb110935 100644 (file)
@@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                     label="Direction"
                     tooltip="Select an edge for direction"
                     shape_types="edge"
+                    geometrical_selection="true"
                     default="&lt;base normal&gt;">
       <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
     </shape_selector>
@@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
@@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;base sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
index e0357b1f45e78746e70eac77c094442febf8bc73..78cba48ea502b8638979a1f436932ee502ea0bb5 100644 (file)
@@ -15,7 +15,8 @@
                     label="Axis"
                     tooltip="Select an edge for the axis of rotation"
                     shape_types="edge"
-                    default="">
+                    default=""
+                    geometrical_selection="true">
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
     <optionalbox id="use_step_angular" title="Angular step">
index b6137c34ec3a8c3522ea408efb45ddf957312259..4eed46173cf3984ddb6be053b99c82d0c661cddb 100644 (file)
@@ -34,7 +34,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                     label="Axis"
                     tooltip="Select an edge for the first direction"
                     shape_types="edge"
-                    default="">
+                    default=""
+                    geometrical_selection="true">
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
     <doublevalue id="step_first_dir"
@@ -58,7 +59,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                     label="Axis"
                     tooltip="Select an edge for the second direction"
                     shape_types="edge"
-                    default="">
+                    default=""
+                    geometrical_selection="true">
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
     <doublevalue id="step_second_dir"
index 42a493390a912e2c7ce45ee764252c21bfc0e315..684e8f394c41038ce08ef6b12f56c02f258399d6 100644 (file)
@@ -32,14 +32,16 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
     label="Select an object"
     icon="icons/Features/placement_from.png"
     tooltip="Select a start face, edge or vertex"
-    shape_types="face edge vertex">
+    shape_types="face edge vertex"
+    geometrical_selection="true">
     <validator id="GeomValidators_BodyShapes"/>
   </shape_selector>
   <shape_selector id="placement_end_shape"
     label="Select an object"
     icon="icons/Features/placement_to.png"
     tooltip="Select an end face, edge or vertex"
-    shape_types="face edge vertex">
+    shape_types="face edge vertex"
+    geometrical_selection="true">
     <validator id="PartSet_DifferentObjects"/>
     <validator id="GeomValidators_BodyShapes"/>
   </shape_selector>
index 3d71c3d844b90a41682dbd5bfe7227b35f8abf25..3bc2c6683a86de26e96ab4e084abf0ae7efe60af 100644 (file)
@@ -41,6 +41,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                   label="Axis"
                   tooltip="Select an edge for axis"
                   shape_types="edge"
+                  geometrical_selection="true"
                   default="">
     <validator id="GeomValidators_ShapeType" parameters="line"/>
   </shape_selector>
@@ -74,6 +75,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                         label="Plane face"
                         tooltip="Bounding plane (select a planar face)"
                         shape_types="face"
+                        geometrical_selection="true"
                         default="&lt;base sketch&gt;">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
@@ -90,6 +92,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                         label="Plane face"
                         tooltip="Bounding plane (select a planar face)"
                         shape_types="face"
+                        geometrical_selection="true"
                         default="&lt;base sketch&gt;">
           <validator id="GeomValidators_Face" parameters="plane"/>
         </shape_selector>
index 12f2f247f45e509048e9dd951573275a38668bfa..297fc706fd950f69ed4f2ebf63aeee680980fbf2 100644 (file)
@@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                     label="Axis"
                     tooltip="Select an edge for axis"
                     shape_types="edge"
+                    geometrical_selection="true"
                     default="">
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
@@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
@@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
index 6d1bb83945ef55b9e1a08688f8ea6173cb2ae147..5e358ee66b311e70648c61231b8b3b8fa1fa4a90 100644 (file)
@@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                     label="Axis"
                     tooltip="Select an edge for axis"
                     shape_types="edge"
+                    geometrical_selection="true"
                     default="">
       <validator id="GeomValidators_ShapeType" parameters="line"/>
     </shape_selector>
@@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
@@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                           label="Plane face"
                           tooltip="Bounding plane (select a planar face)"
                           shape_types="face"
+                          geometrical_selection="true"
                           default="&lt;sketch&gt;">
             <validator id="GeomValidators_Face" parameters="plane"/>
           </shape_selector>
index c07bd8ba850eb192b91dabb611b572295cc4b740..41899821036b83b4031a8b91628884d4b48f32f9 100755 (executable)
@@ -37,7 +37,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                   label="Axis"
                   tooltip="Select an edge for axis"
                   shape_types="edge"
-                  default="">
+                  default=""
+                  geometrical_selection="true">
         <validator id="GeomValidators_ShapeType" parameters="line"/>
       </shape_selector>
       <doublevalue id="angle"
index 9923217faaed1415bab958bc097afdd7ceed7a27..6d73285bbb99a2604e26300ac9a9f49c19a7c3b3 100644 (file)
@@ -53,7 +53,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="Axis"
                       tooltip="Select an axis"
                       shape_types="edge"
-                      default="">
+                      default=""
+                      geometrical_selection="true">
         <validator id="GeomValidators_ShapeType" parameters="line"/>
       </shape_selector>
     </box>
index 28bb25115ef0ba4363f26de0757ae7442001644f..3e5ef8260ce4c12cb05e8263d131e5476514fd42 100644 (file)
@@ -37,7 +37,8 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
                       label="Axis"
                       tooltip="Select an edge for axis"
                       shape_types="edge"
-                      default="">
+                      default=""
+                      geometrical_selection="true">
         <validator id="GeomValidators_ShapeType" parameters="line"/>
       </shape_selector>
       <doublevalue id="distance"
index 3e3ed5d4edfaa4fd84df68c8243bb6ddcc082986..c07cda2db43205b1c52ac3070ba255f2370e973e 100644 (file)
@@ -21,6 +21,7 @@
 #include "GeomAlgoAPI_Placement.h"
 
 #include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_ShapeTools.h>
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
@@ -28,6 +29,7 @@
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Pln.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_XYZ.h>
 
@@ -70,29 +72,48 @@ void GeomAlgoAPI_Placement::build(const std::shared_ptr<GeomAPI_Shape>& theSourc
 
   GProp_GProps aProps;
   static const double aPropEps = 1.e-4;
+  GeomShapePtr aShape;
+  bool isCompound = false;
   for (int i = 0; i < aNbObjects; i++) {
-    if (aShapes[i]->isFace()) {
-      std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aShapes[i]));
+    aShape = aShapes[i];
+    isCompound = false;
+    if (aShapes[i]->isCompound()) {
+      isCompound = true;
+      GeomAPI_ShapeIterator anIt(aShapes[i]);
+      aShape = anIt.current();
+
+      GeomPointPtr aPnt = GeomAlgoAPI_ShapeTools::centreOfMass(aShapes[i]);
+      aSrcDstPoints[i].SetCoord(aPnt->x(), aPnt->y(), aPnt->z());
+    }
+
+    if (aShape->isFace()) {
+      std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aShape));
       std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
       std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
       aSrcDstNormals[i].SetCoord(aDir->x(), aDir->y(), aDir->z());
 
-      BRepGProp::SurfaceProperties(aFace->impl<TopoDS_Face>(), aProps, aPropEps);
-      gp_Pnt aLoc = aProps.CentreOfMass();
-      aSrcDstPoints[i].SetCoord(aLoc.X(), aLoc.Y(), aLoc.Z());
+      if (!isCompound) {
+        BRepGProp::SurfaceProperties(aFace->impl<TopoDS_Face>(), aProps, aPropEps);
+        gp_Pnt aLoc = aProps.CentreOfMass();
+        aSrcDstPoints[i].SetCoord(aLoc.X(), aLoc.Y(), aLoc.Z());
+      }
     }
-    else if (aShapes[i]->isEdge()) {
-      std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aShapes[i]));
+    else if (aShape->isEdge()) {
+      std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aShape));
       std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
       std::shared_ptr<GeomAPI_Dir> aDir = aLine->direction();
-      std::shared_ptr<GeomAPI_Pnt> aFirstPnt = anEdge->firstPoint();
-      std::shared_ptr<GeomAPI_Pnt> aLastPnt = anEdge->lastPoint();
-      std::shared_ptr<GeomAPI_XYZ> aLoc = aFirstPnt->xyz()->added(aLastPnt->xyz())->multiplied(0.5);
-      aSrcDstPoints[i].SetCoord(aLoc->x(), aLoc->y(), aLoc->z());
       aSrcDstDirections[i].SetCoord(aDir->x(), aDir->y(), aDir->z());
+
+      if (!isCompound) {
+        std::shared_ptr<GeomAPI_Pnt> aFirstPnt = anEdge->firstPoint();
+        std::shared_ptr<GeomAPI_Pnt> aLastPnt = anEdge->lastPoint();
+        std::shared_ptr<GeomAPI_XYZ> aLoc = aFirstPnt->xyz()->added(aLastPnt->xyz())
+                                                            ->multiplied(0.5);
+        aSrcDstPoints[i].SetCoord(aLoc->x(), aLoc->y(), aLoc->z());
+      }
     }
-    else if (aShapes[i]->isVertex()) {
-      std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aShapes[i]));
+    else if (aShape->isVertex()) {
+      std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aShape));
       std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
       aSrcDstPoints[i].SetCoord(aPnt->x(), aPnt->y(), aPnt->z());
     } else // something goes wrong
index 945f9bc34d306c14beda27425213d5b0cadb4100..a5f9d588cb888bb78977b362846b54f0ad8b9a7c 100644 (file)
@@ -24,6 +24,7 @@
 #include "ModelAPI_AttributeSelection.h"
 
 #include <GeomAPI_Face.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <GeomAbs_SurfaceType.hxx>
 
@@ -46,6 +47,40 @@ GeomAbs_SurfaceType faceType(const std::string& theType)
   return GeomAbs_Plane;
 }
 
+bool isValidFace(const GeomShapePtr theShape,
+                 const GeomAbs_SurfaceType theFaceType,
+                 Events_InfoMessage& theError)
+{
+  GeomFacePtr aGeomFace = theShape->face();
+
+  if (!aGeomFace.get()) {
+    theError = "The shape is not a face.";
+      return false;
+  }
+
+  bool aValid = true;
+
+  switch (theFaceType) {
+    case GeomAbs_Plane: {
+      aValid = aGeomFace->isPlanar();
+      if (!aValid) theError = "The shape is not a plane.";
+      break;
+    }
+    case GeomAbs_Cylinder: {
+      aValid = aGeomFace->isCylindrical();
+      if (!aValid) theError = "The shape is not a cylinder.";
+      break;
+    }
+    default: {
+      aValid = false;
+      theError = "The shape is not an available face.";
+      break;
+    }
+  }
+
+  return aValid;
+}
+
 bool GeomValidators_Face::isValid(const AttributePtr& theAttribute,
                                   const std::list<std::string>& theArguments,
                                   Events_InfoMessage& theError) const
@@ -78,36 +113,22 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute,
       theError = "The shape is not a face.";
     }
     else {
-      std::shared_ptr<GeomAPI_Face> aGeomFace(new GeomAPI_Face(aGeomShape));
-      if (!aGeomFace.get()) {
-        aValid = false;
-        theError = "The shape is not a face.";
+      GeomAbs_SurfaceType aFaceType = GeomAbs_Plane;
+      if (theArguments.size() == 1) aFaceType = faceType(theArguments.front());
+      if (aGeomShape->isFace()) {
+        isValidFace(aGeomShape, aFaceType, theError);
       }
-      else {
-        GeomAbs_SurfaceType aFaceType = GeomAbs_Plane;
-        if (theArguments.size() == 1)
-          aFaceType = faceType(theArguments.front());
-
-        switch (aFaceType) {
-          case GeomAbs_Plane: {
-            aValid = aGeomFace->isPlanar();
-            if (!aValid)
-              theError = "The shape is not a plane.";
-          }
-          break;
-          case GeomAbs_Cylinder:{
-            aValid = aGeomFace->isCylindrical();
-            if (!aValid)
-              theError = "The shape is not a cylinder.";
-          }
-          break;
-          default: {
-            aValid = false;
-            theError = "The shape is not an available face.";
+      else if (aSelectionAttr->isGeometricalSelection() && aGeomShape->isCompound()) {
+        for (GeomAPI_ShapeIterator anIt(aGeomShape); anIt.more(); anIt.next()) {
+          if (!isValidFace(anIt.current(), aFaceType, theError)) {
             break;
           }
         }
       }
+      else {
+        aValid = false;
+        theError = "The shape is not a face.";
+      }
     }
   }
   return aValid;
index afb7dd0c93eb2c6a5bb6eefa2965bd750a5b698b..a7638e7be7ad0e30441d7577daaf2a8b0ab9109a 100755 (executable)
@@ -22,6 +22,7 @@
 #include "GeomValidators_Tools.h"
 
 #include <GeomAPI_Curve.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModelAPI_Result.h>
@@ -130,18 +131,27 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
     GeomShapePtr aShape = anAttr->value();
     if (aShape.get())
-      aValid = isValidShape(aShape, theShapeType, theError);
+      aValid = isValidShape(aShape, theShapeType, anAttr->isGeometricalSelection(), theError);
     else {
       if (anAttr->context().get())
-        aValid = isValidObject(anAttr->context(), theShapeType, theError);
+        aValid = isValidObject(anAttr->context(),
+                               theShapeType,
+                               anAttr->isGeometricalSelection(),
+                               theError);
       else
-        aValid = isValidObject(anAttr->contextFeature(), theShapeType, theError);
+        aValid = isValidObject(anAttr->contextFeature(),
+                               theShapeType,
+                               anAttr->isGeometricalSelection(),
+                               theError);
     }
   }
   else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
     AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
     if (anAttr->isObject()) {
-      aValid = isValidObject(anAttr->object(), theShapeType, theError);
+      aValid = isValidObject(anAttr->object(),
+                             theShapeType,
+                             false,
+                             theError);
     }
     else if (theShapeType == Vertex) {
       AttributePtr aRefAttr = anAttr->attr();
@@ -162,7 +172,7 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute
   else if (anAttributeType == ModelAPI_AttributeReference::typeId()) {
     AttributeReferencePtr anAttr =
                               std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
-    aValid = isValidObject(anAttr->value(), theShapeType, theError);
+    aValid = isValidObject(anAttr->value(), theShapeType, false, theError);
   }
   else if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
     AttributeSelectionListPtr aListAttr =
@@ -190,6 +200,7 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute
 
 bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject,
                                              const TypeOfShape theShapeType,
+                                             const bool theIsGeometricalSelection,
                                              Events_InfoMessage& theError) const
 {
   bool aValid = true;
@@ -214,7 +225,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject,
         aValid = false;
         theError = "The result is empty";
       } else {
-        aValid = isValidShape(aResult->shape(), theShapeType, theError);
+        aValid = isValidShape(aResult->shape(), theShapeType, theIsGeometricalSelection, theError);
       }
     } else {
       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
@@ -231,6 +242,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject,
 
 bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
                                             const TypeOfShape theShapeType,
+                                            const bool theIsGeometricalSelection,
                                             Events_InfoMessage& theError) const
 {
   bool aValid = true;
@@ -247,9 +259,21 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape,
     case Edge:
       aValid = theShape->isEdge();
       break;
-    case Line:
-      aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isLine();
+    case Line: {
+      if (theIsGeometricalSelection && theShape->isCompound()) {
+        aValid = true;
+        for (GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) {
+          if (!anIt.current()->isEdge() || !GeomAPI_Curve(anIt.current()).isLine()) {
+            aValid = false;
+            break;
+          }
+        }
+      }
+      else {
+        aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isLine();
+      }
       break;
+    }
     case Circle:
       aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle();
       break;
index daf9fda38d230c7d73c38e318c4a809baea31e59..0606cd411235d36e110dfb60a8b10399b0f42694 100644 (file)
@@ -83,6 +83,7 @@ protected:
   /// \param[out] theError error message.
   bool isValidObject(const ObjectPtr& theObject,
                      const TypeOfShape theShapeType,
+                     const bool theIsGeometricalSelection,
                      Events_InfoMessage& theError) const;
 
   /// Returns true if the attibute's object type satisfies the argument value
@@ -91,6 +92,7 @@ protected:
   /// \param[out] theError error message.
   bool isValidShape(const GeomShapePtr theShape,
                     const TypeOfShape theShapeType,
+                    const bool theIsGeometricalSelection,
                     Events_InfoMessage& theError) const;
 
 };
index 4a919d0c4b6afe96dc4c0fe774509a0478fb1863..d6181783f4931cb7a9e647070e3c60d28dd5abfc 100644 (file)
@@ -31,6 +31,7 @@
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Face.h>
 #include <GeomAPI_Shape.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_Pnt.h>
 
@@ -131,6 +132,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
     if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) {
       aToShape =  anAttrSel->context()->shape();
     }
+    if (aToShape->isCompound()) {
+      GeomAPI_ShapeIterator anIt(aToShape);
+      aToShape = anIt.current();
+    }
   }
   anIt++;
 
@@ -146,6 +151,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr<ModelAPI_Feature>&
     if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) {
       aFromShape = anAttrSel->context()->shape();
     }
+    if (aFromShape->isCompound()) {
+      GeomAPI_ShapeIterator anIt(aFromShape);
+      aFromShape = anIt.current();
+    }
   }
   anIt++;
 
index 15f95f6dfede586e326ca2f2582f784d36895cf5..7cf468c5bb7bd165788254ec06a5b9d51ceaa90b 100644 (file)
@@ -39,6 +39,7 @@
 #include <Events_InfoMessage.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Pnt.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_ShapeExplorer.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
@@ -456,6 +457,10 @@ void Model_AttributeSelection::setID(const std::string theID)
 {
   myRef.setID(theID);
   ModelAPI_AttributeSelection::setID(theID);
+  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+  // TODO: check if parent list have geometrical selection flag.
+  myIsGeometricalSelection =
+    ModelAPI_Session::get()->validators()->isGeometricalSelection(aFeature->getKind(), id());
 }
 
 ResultPtr Model_AttributeSelection::context()
index 98e35767e845f19293df3fdeed2feeb15578e360..0e98757fbbdfa12ffbafb389d91bf78d58b6cea4 100644 (file)
@@ -50,6 +50,9 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection,
   Model_AttributeSelectionList* myParent;
 
   std::shared_ptr<Model_Document> myRestoreDocument; // current document to restore by name
+  /// If true attribute selects geometry instead of shape.
+  bool myIsGeometricalSelection;
+
 public:
   /// Defines the result and its selected sub-shape
   /// \param theContext object where the sub-shape was selected
@@ -197,6 +200,11 @@ protected:
   void computeValues(ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape,
     TopTools_ListOfShape& theShapes);
 
+  /// Returns true if is geometrical selection.
+  virtual bool isGeometricalSelection() const {
+    return myIsGeometricalSelection;
+  };
+
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
 };
index 9fb4124075eac962de1a6d8b15a7770541194003..c231bfd0e2ef088a356ed57a4b5628b3223d8366 100644 (file)
@@ -332,11 +332,11 @@ std::shared_ptr<ModelAPI_AttributeSelection>
   // (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid)
   std::shared_ptr<Model_AttributeSelection> aNewAttr =
     std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLabel));
-  aNewAttr->setID(id());
   if (owner()) {
     aNewAttr->setObject(owner());
     aNewAttr->setParent(this);
   }
+  aNewAttr->setID(id());
   return aNewAttr;
 }
 
index a22db3780ba50741c258ef66f0e94007c4118420..ea2521010941de1cdca9d6fa74741592a551e04b 100644 (file)
@@ -475,6 +475,10 @@ void Model_Session::processEvent(const std::shared_ptr<Events_Message>& theMessa
         if (!aCases.empty()) {
           validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(), aCases);
         }
+        if (aMsgAttr->isGeometricalSelection()) {
+          validators()->registerGeometricalSelection(aMsgAttr->featureId(),
+                                                     aMsgAttr->attributeId());
+        }
       }
     }
     // plugins information was started to load, so, it will be loaded
index 41fa0f7014a03e24137734cbd4bc447925905271..5bf41b28976b71d3a371eafcf31ad30f6b75d576 100644 (file)
@@ -377,3 +377,27 @@ bool Model_ValidatorsFactory::isMainArgument(std::string theFeature, std::string
   std::map<std::string, std::string>::iterator aFound = myMainArgument.find(theFeature);
   return aFound != myMainArgument.end() && aFound->second == theAttribute;
 }
+
+void Model_ValidatorsFactory::registerGeometricalSelection(std::string theFeature,
+                                                           std::string theAttribute)
+{
+  std::map<std::string, std::set<std::string> >::iterator aFind =
+    myGeometricalSelection.find(theFeature);
+  if (aFind == myGeometricalSelection.end()) {
+    std::set<std::string> aNewSet;
+    aNewSet.insert(theAttribute);
+    myGeometricalSelection[theFeature] = aNewSet;
+  }
+  else {
+    aFind->second.insert(theAttribute);
+  }
+}
+
+bool Model_ValidatorsFactory::isGeometricalSelection(std::string theFeature,
+                                                     std::string theAttribute)
+{
+  std::map<std::string, std::set<std::string> >::iterator aFind =
+    myGeometricalSelection.find(theFeature);
+  return aFind != myGeometricalSelection.end()
+         && aFind->second.find(theAttribute) != aFind->second.end();
+}
index 939cdf21390017aebd1c22b3bc2de2de5e62e94e..7dcf2ff98c2470ec64311439b3ab4d3a0f9cf5df 100644 (file)
@@ -58,6 +58,7 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
           std::map<std::string, std::set<std::string> > > > myCases;
   /// Stores main attribute for each feature
   std::map<std::string, std::string> myMainArgument;
+  std::map<std::string, std::set<std::string> > myGeometricalSelection;
 
  public:
   /// Registers the instance of the validator by the ID
@@ -123,6 +124,12 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   /// Returns true is the attribute is a main argument of the feature
   virtual bool isMainArgument(std::string theFeature, std::string theAttribute);
 
+  /// Register the selection attribute as geometrical selection
+  virtual void registerGeometricalSelection(std::string theFeature, std::string theAttribute);
+
+  /// Returns true if the attribute is a geometrical selection
+  virtual bool isGeometricalSelection(std::string theFeature, std::string theAttribute);
+
 
 protected:
   /// Adds the defualt validators that are usefull for all features.
index 877cc06e5504958daf29436e0c85dd9f9a84a359..93ad948d584751b277e1e7daac3128061dfdf0f6 100644 (file)
@@ -115,6 +115,9 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute
   /// Returns true if recompute of selection become impossible
   virtual bool isInvalid() = 0;
 
+  /// Returns true if is geometrical selection.
+  virtual bool isGeometricalSelection() const = 0;
+
   /// To virtually destroy the fields of successors
   MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection();
 
index a2c8af67abe69d060c96f75bcb140f12376753e4..e40e05536bbb58755672bb7329e52c7b24efeeb7 100644 (file)
@@ -128,6 +128,12 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory
  /// Returns true if the attribute must be checked (the case is selected)
   virtual bool isCase(FeaturePtr theFeature, std::string theAttribute) = 0;
 
+  /// Register the selection attribute as geometrical selection
+  virtual void registerGeometricalSelection(std::string theFeature, std::string theAttribute) = 0;
+
+  /// Returns true if the attribute is a geometrical selection
+  virtual bool isGeometricalSelection(std::string theFeature, std::string theAttribute) = 0;
+
  protected:
   /// Get instance from Session
   ModelAPI_ValidatorsFactory()
index c904de30e93d90e594f4b65b196c0233ac1e4f7d..62e3327e2c60320c088041c198cf6e2278bc38c4 100644 (file)
@@ -25,6 +25,7 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAlgoAPI_NExplode.h>
 
 #include <GeomDataAPI_Dir.h>
@@ -1067,6 +1068,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
     isDumpByGeom = aSelectedFeature && aSelectedFeature->isInHistory();
   }
 
+  if (theAttrSelect->isGeometricalSelection() && aShape->shapeType() == GeomAPI_Shape::COMPOUND) {
+    GeomAPI_ShapeIterator anIt(aShape);
+    aShape = anIt.current();
+  }
+
   myDumpBuffer << "\"" << aShape->shapeTypeStr();
   bool aStandardDump = true;
   if (isDumpByGeom) {
index c4c68b3711d414c7ec19ad781879a9cac3069475..3f94a85d50dc54ac1f8bee2cec401c2562156514 100644 (file)
@@ -9,6 +9,7 @@
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
 
@@ -82,21 +83,43 @@ void PrimitivesPlugin_Cone::execute()
   }
 
   // Getting axis.
-  std::shared_ptr<GeomAPI_Ax2> anAxis;
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef = selection(AXIS_ID());
+  GeomShapePtr aShape = anEdgeRef->value();
+  if (!aShape.get()) {
+    if (anEdgeRef->context().get()) {
+      aShape = anEdgeRef->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
   std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef =
-    selection(PrimitivesPlugin_Cone::AXIS_ID());
-  if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->value()));
-  } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() &&
-             anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->context()->shape()));
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
-                                                          anEdge->line()->direction()));
+  else
+  {
+    setError(aSelectionError);
+    return;
   }
 
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax2> anAxis(new GeomAPI_Ax2(aBasePoint,
+                                                      anEdge->line()->direction()));
+
   // Getting base radius, top radius and height
   double aBaseRadius = real(PrimitivesPlugin_Cone::BASE_RADIUS_ID())->value();
   double aTopRadius = real(PrimitivesPlugin_Cone::TOP_RADIUS_ID())->value();
index ee68294df4e4debb6bb296ff47abcc3a81378072..268c983f17f52c0ee8099d61be3875e54c06bd55 100644 (file)
@@ -23,6 +23,7 @@
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
 
@@ -112,21 +113,44 @@ void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle)
   }
 
   // Getting axis.
-  std::shared_ptr<GeomAPI_Ax2> anAxis;
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef = selection(AXIS_ID());
+  GeomShapePtr aShape = anEdgeRef->value();
+  if (!aShape.get()) {
+    if (anEdgeRef->context().get()) {
+      aShape = anEdgeRef->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
   std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef =
-    selection(PrimitivesPlugin_Cylinder::AXIS_ID());
-  if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->value()));
-  } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() &&
-             anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->context()->shape()));
-  }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
-                                                          anEdge->line()->direction()));
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
+  }
+  else
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
   }
 
+  std::shared_ptr<GeomAPI_Ax2> anAxis(new GeomAPI_Ax2(aBasePoint,
+                                                      anEdge->line()->direction()));
+
+
   // Getting radius and height
   double aRadius = real(PrimitivesPlugin_Cylinder::RADIUS_ID())->value();
   double aHeight = real(PrimitivesPlugin_Cylinder::HEIGHT_ID())->value();
index 43405e23e9fe501a0a6ba089c50ab6a57d48440b..0c000a8fe7f3d2ff14d9cc642841a1801a3f8d9f 100644 (file)
@@ -9,6 +9,7 @@
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <GeomAlgoAPI_PointBuilder.h>
 
@@ -80,21 +81,43 @@ void PrimitivesPlugin_Torus::execute()
   }
 
   // Getting axis.
-  std::shared_ptr<GeomAPI_Ax2> anAxis;
+  static const std::string aSelectionError = "Error: The axis shape selection is bad.";
+  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef = selection(AXIS_ID());
+  GeomShapePtr aShape = anEdgeRef->value();
+  if (!aShape.get()) {
+    if (anEdgeRef->context().get()) {
+      aShape = anEdgeRef->context()->shape();
+    }
+  }
+  if (!aShape.get()) {
+    setError(aSelectionError);
+    return;
+  }
   std::shared_ptr<GeomAPI_Edge> anEdge;
-  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef =
-    selection(PrimitivesPlugin_Torus::AXIS_ID());
-  if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->value()));
-  } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() &&
-             anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) {
-    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->context()->shape()));
+  if (aShape->isEdge())
+  {
+    anEdge = aShape->edge();
+  }
+  else if (aShape->isCompound())
+  {
+    GeomAPI_ShapeIterator anIt(aShape);
+    anEdge = anIt.current()->edge();
   }
-  if(anEdge) {
-    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
-                                                          anEdge->line()->direction()));
+  else
+  {
+    setError(aSelectionError);
+    return;
   }
 
+  if (!anEdge.get())
+  {
+    setError(aSelectionError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Ax2> anAxis(new GeomAPI_Ax2(aBasePoint,
+                                                      anEdge->line()->direction()));
+
   // Getting radius and ring radius
   double aRadius = real(PrimitivesPlugin_Torus::RADIUS_ID())->value();
   double aRingRadius = real(PrimitivesPlugin_Torus::RING_RADIUS_ID())->value();
index 4f1acd5e45c350b7a1be4ff2c7abe9bb34097fb9..710134ca0badd3ed7b2062c3605ba7a31a2b8bc1 100644 (file)
@@ -16,6 +16,7 @@
       label="axis"
       default=""
       shape_types="edge"
+      geometrical_selection="true"
       icon="icons/Primitives/axis.png"
       tooltip="Select the axis of the cone">
     <validator id="GeomValidators_ConstructionComposite"/>
index 373bafb5f2a297d4a08a5e29fd19ef1cec793527..2474f8badd8912154304bc27e2616470fec13d42 100644 (file)
@@ -37,6 +37,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
           label="axis"
           default=""
           shape_types="edge"
+          geometrical_selection="true"
           icon="icons/Primitives/axis.png"
           tooltip="Select the axis of the cylinder">
         <validator id="GeomValidators_ConstructionComposite"/>
@@ -75,6 +76,7 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
           label="axis"
           default=""
           shape_types="edge"
+          geometrical_selection="true"
           icon="icons/Primitives/axis.png"
           tooltip="Select the axis of the cylinder">
         <validator id="GeomValidators_ConstructionComposite"/>
index 44d0ce6888dc7938dc2c514d867066e207108764..30f6489e429fbc8a002da4f0847511f15f9c6ce9 100644 (file)
@@ -16,6 +16,7 @@
       label="axis"
       default=""
       shape_types="edge"
+      geometrical_selection="true"
       icon="icons/Primitives/axis.png"
       tooltip="Select the axis of the torus">
     <validator id="GeomValidators_ConstructionComposite"/>
index d23ad07d0118e0c581692eef8bca4e006d6d9d26..1b7753423b460656dcadfe74cc20f17ac54bc8eb 100755 (executable)
@@ -25,6 +25,7 @@
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_PlanarEdges.h>
+#include <GeomAPI_ShapeIterator.h>
 #include <GeomAPI_Vertex.h>
 
 #include <GeomDataAPI_Point2D.h>
@@ -255,7 +256,14 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
       std::shared_ptr<GeomAPI_Shape> aSelection = aSelAttr->value();
       if (!aSelection.get()) aSelection = aSelAttr->context()->shape();
       // update the sketch plane
-      std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aSelection));
+      std::shared_ptr<GeomAPI_Face> aFace;
+      if (aSelection->isFace()) {
+        aFace = aSelection->face();
+      } else if (aSelection->isCompound()) {
+        GeomAPI_ShapeIterator anIt(aSelection);
+        aFace = anIt.current()->face();
+      }
+
       std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
       if (aPlane) {
         double anA, aB, aC, aD;