From 8a8b9b4ba20d4758dc2ae5ade0359b8bb2772986 Mon Sep 17 00:00:00 2001 From: dbv Date: Mon, 24 Sep 2018 15:54:38 +0300 Subject: [PATCH] Revert "Issue #2593: CEA 2018-2 Geometrical Naming" This reverts commit 26dbe08c26b99ac1e02e1ab254069ccb620f0181. --- src/Config/Config_AttributeMessage.cpp | 11 -- src/Config/Config_AttributeMessage.h | 5 - src/Config/Config_FeatureReader.cpp | 3 - src/Config/Config_Keywords.h | 2 - .../ConstructionPlugin_Axis.cpp | 67 ++------- .../ConstructionPlugin_Plane.cpp | 64 +------- .../ConstructionPlugin_Point.cpp | 19 +-- .../ConstructionPlugin_Validators.cpp | 69 +++------ src/ConstructionPlugin/axis_widget.xml | 15 +- src/ConstructionPlugin/plane_widget.xml | 15 +- src/ConstructionPlugin/point_widget.xml | 6 +- .../FeaturesPlugin_Extrusion.cpp | 38 +---- .../FeaturesPlugin_MultiRotation.cpp | 48 ++---- .../FeaturesPlugin_MultiTranslation.cpp | 140 +++++------------- .../FeaturesPlugin_Placement.cpp | 60 ++------ src/FeaturesPlugin/FeaturesPlugin_Placement.h | 3 - .../FeaturesPlugin_Revolution.cpp | 47 ++---- .../FeaturesPlugin_Rotation.cpp | 48 ++---- .../FeaturesPlugin_Symmetry.cpp | 99 ++++--------- .../FeaturesPlugin_Translation.cpp | 49 ++---- .../FeaturesPlugin_Validators.cpp | 5 - src/FeaturesPlugin/extrusion_widget.xml | 3 - src/FeaturesPlugin/extrusioncut_widget.xml | 3 - src/FeaturesPlugin/extrusionfuse_widget.xml | 3 - src/FeaturesPlugin/multirotation_widget.xml | 3 +- .../multitranslation_widget.xml | 6 +- src/FeaturesPlugin/placement_widget.xml | 6 +- src/FeaturesPlugin/revolution_widget.xml | 3 - src/FeaturesPlugin/revolutioncut_widget.xml | 3 - src/FeaturesPlugin/revolutionfuse_widget.xml | 3 - src/FeaturesPlugin/rotation_widget.xml | 3 +- src/FeaturesPlugin/symmetry_widget.xml | 3 +- src/FeaturesPlugin/translation_widget.xml | 3 +- src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp | 47 ++---- src/GeomValidators/GeomValidators_Face.cpp | 71 ++++----- .../GeomValidators_ShapeType.cpp | 40 +---- src/GeomValidators/GeomValidators_ShapeType.h | 2 - .../GeomValidators_ZeroOffset.cpp | 9 -- src/Model/Model_AttributeSelection.cpp | 15 +- src/Model/Model_AttributeSelection.h | 8 - src/Model/Model_AttributeSelectionList.cpp | 2 +- src/Model/Model_Session.cpp | 4 - src/Model/Model_Validator.cpp | 24 --- src/Model/Model_Validator.h | 7 - src/ModelAPI/ModelAPI_AttributeSelection.h | 3 - src/ModelAPI/ModelAPI_Validator.h | 6 - src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 6 - .../PrimitivesPlugin_Cone.cpp | 45 ++---- .../PrimitivesPlugin_Cylinder.cpp | 48 ++---- .../PrimitivesPlugin_Torus.cpp | 45 ++---- src/PrimitivesPlugin/cone_widget.xml | 1 - src/PrimitivesPlugin/cylinder_widget.xml | 2 - src/PrimitivesPlugin/torus_widget.xml | 1 - src/SketchPlugin/SketchPlugin_Sketch.cpp | 10 +- 54 files changed, 271 insertions(+), 980 deletions(-) diff --git a/src/Config/Config_AttributeMessage.cpp b/src/Config/Config_AttributeMessage.cpp index d8f2f23e8..32051337c 100644 --- a/src/Config/Config_AttributeMessage.cpp +++ b/src/Config/Config_AttributeMessage.cpp @@ -27,7 +27,6 @@ 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() @@ -95,13 +94,3 @@ void Config_AttributeMessage::setMainArgument(bool isMainArg) { myIsMainArgument = isMainArg; } - -bool Config_AttributeMessage::isGeometricalSelection() const -{ - return myIsGeometricalSelection; -} - -void Config_AttributeMessage::setGeometricalSelection(bool isGeometricalSelection) -{ - myIsGeometricalSelection = isGeometricalSelection; -} diff --git a/src/Config/Config_AttributeMessage.h b/src/Config/Config_AttributeMessage.h index 4df9cd8b4..cb4ef232c 100644 --- a/src/Config/Config_AttributeMessage.h +++ b/src/Config/Config_AttributeMessage.h @@ -42,7 +42,6 @@ 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 > myCases; @@ -70,8 +69,6 @@ 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 >& getCases() const; /// Sets ids of pair of a case and switches @@ -87,8 +84,6 @@ 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 diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 85638935c..c76aee821 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -89,9 +89,6 @@ 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 > aCases; xmlNodePtr aCaseNode = hasParentRecursive(theNode, diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index eb3085ce6..beb599b20 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -100,8 +100,6 @@ 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; diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 44dbc0875..5f4b2f8d6 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -163,26 +162,16 @@ void ConstructionPlugin_Axis::createAxisByPointAndDirection() void ConstructionPlugin_Axis::createAxisByCylindricalFace() { - std::shared_ptr 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 anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection); - - ResultConstructionPtr aConstr = document()->createConstruction(data()); - aConstr->setInfinite(true); - aConstr->setShape(anEdge); - setResult(aConstr); - } + std::shared_ptr aSelection = data()->selection(CYLINDRICAL_FACE())->value(); + // update arguments due to the selection value + if (aSelection && !aSelection->isNull() && aSelection->isFace()) { + std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection); + + ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setInfinite(true); + aConstr->setShape(anEdge); + setResult(aConstr); + } } void ConstructionPlugin_Axis::createAxisByDimensions() @@ -214,14 +203,7 @@ void ConstructionPlugin_Axis::createAxisByLine() if(!aLineShape.get()) { aLineShape = anEdgeSelection->context()->shape(); } - GeomEdgePtr anEdge; - if (aLineShape->isEdge()) { - anEdge = aLineShape->edge(); - } - else if (aLineShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aLineShape); - anEdge = anIt.current()->edge(); - } + std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); ResultConstructionPtr aConstr = document()->createConstruction(data()); aConstr->setInfinite(true); @@ -237,14 +219,7 @@ void ConstructionPlugin_Axis::createAxisByPlaneAndPoint() if(!aFaceShape.get()) { aFaceShape = aFaceSelection->context()->shape(); } - GeomFacePtr aFace; - if (aFaceShape->isFace()) { - aFace = aFaceShape->face(); - } - else if (aFaceShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape); - aFace = anIt.current()->face(); - } + std::shared_ptr aFace(new GeomAPI_Face(aFaceShape)); std::shared_ptr aPln = aFace->getPlane(); // Get point. @@ -278,14 +253,7 @@ void ConstructionPlugin_Axis::createAxisByTwoPlanes() if(!aFaceShape1.get()) { aFaceShape1 = aFaceSelection1->context()->shape(); } - std::shared_ptr aFace1; - if (aFaceShape1->isFace()) { - aFace1 = aFaceShape1->face(); - } - else if (aFaceShape1->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape1); - aFace1 = anIt.current()->face(); - } + std::shared_ptr aFace1(new GeomAPI_Face(aFaceShape1)); std::shared_ptr aPln1 = aFace1->getPlane(); std::string useOffset1 = string(USE_OFFSET1())->value(); @@ -304,14 +272,7 @@ void ConstructionPlugin_Axis::createAxisByTwoPlanes() if(!aFaceShape2.get()) { aFaceShape2 = aFaceSelection2->context()->shape(); } - std::shared_ptr aFace2; - if (aFaceShape2->isFace()) { - aFace2 = aFaceShape2->face(); - } - else if (aFaceShape2->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape2); - aFace2 = anIt.current()->face(); - } + std::shared_ptr aFace2(new GeomAPI_Face(aFaceShape2)); std::shared_ptr aPln2 = aFace2->getPlane(); std::string useOffset2 = string(USE_OFFSET2())->value(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index 52e292035..3680ab503 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -229,14 +228,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByLineAndPoint() if(!aLineShape.get()) { aLineShape = anEdgeSelection->context()->shape(); } - std::shared_ptr anEdge; - if (aLineShape->isEdge()) { - anEdge = aLineShape->edge(); - } - else if (aLineShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aLineShape); - anEdge = anIt.current()->edge(); - } + std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); // Get point. AttributeSelectionPtr aPointSelection = selection(POINT()); @@ -290,14 +282,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByDistanceFromOth return aPlane; } - std::shared_ptr aFace; - if (aShape->isFace()) { - aFace = aShape->face(); - } - else if (aShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aShape); - aFace = anIt.current()->face(); - } + std::shared_ptr aFace(new GeomAPI_Face(aShape)); std::shared_ptr aPln = aFace->getPlane(); std::shared_ptr aOrig = aPln->location(); @@ -320,14 +305,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByCoincidentPoint if(!aFaceShape.get()) { aFaceShape = aFaceSelection->context()->shape(); } - std::shared_ptr aFace; - if (aFaceShape->isFace()) { - aFace = aFaceShape->face(); - } - else if (aFaceShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape); - aFace = anIt.current()->face(); - } + std::shared_ptr aFace(new GeomAPI_Face(aFaceShape)); // Get point. AttributeSelectionPtr aPointSelection = selection(COINCIDENT_POINT()); @@ -355,14 +333,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByRotation() if(!aFaceShape.get()) { aFaceShape = aFaceSelection->context()->shape(); } - std::shared_ptr aFace; - if (aFaceShape->isFace()) { - aFace = aFaceShape->face(); - } - else if (aFaceShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape); - aFace = anIt.current()->face(); - } + std::shared_ptr aFace(new GeomAPI_Face(aFaceShape)); aFace = makeRectangularFace(aFace, aFace->getPlane()); // Get axis. @@ -371,14 +342,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByRotation() if(!anAxisShape.get()) { anAxisShape = anAxisSelection->context()->shape(); } - std::shared_ptr anEdge; - if (anAxisShape->isEdge()) { - anEdge = anAxisShape->edge(); - } - else if (anAxisShape->isCompound()) { - GeomAPI_ShapeIterator anIt(anAxisShape); - anEdge = anIt.current()->edge(); - } + std::shared_ptr anEdge(new GeomAPI_Edge(anAxisShape)); std::shared_ptr anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), @@ -411,14 +375,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByTwoParallelPlan if(!aFaceShape1.get()) { aFaceShape1 = aFaceSelection1->context()->shape(); } - std::shared_ptr aFace1; - if (aFaceShape1->isFace()) { - aFace1 = aFaceShape1->face(); - } - else if (aFaceShape1->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape1); - aFace1 = anIt.current()->face(); - } + std::shared_ptr aFace1(new GeomAPI_Face(aFaceShape1)); std::shared_ptr aPln1 = aFace1->getPlane(); // Get plane 2. @@ -427,14 +384,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByTwoParallelPlan if(!aFaceShape2.get()) { aFaceShape2 = aFaceSelection2->context()->shape(); } - std::shared_ptr aFace2; - if (aFaceShape2->isFace()) { - aFace2 = aFaceShape2->face(); - } - else if (aFaceShape2->isCompound()) { - GeomAPI_ShapeIterator anIt(aFaceShape2); - aFace2 = anIt.current()->face(); - } + std::shared_ptr aFace2(new GeomAPI_Face(aFaceShape2)); std::shared_ptr aPln2 = aFace2->getPlane(); std::shared_ptr anOrig1 = aPln1->location(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 688f25333..bb59c3d55 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -36,7 +36,6 @@ #include #include #include -#include //================================================================================================== ConstructionPlugin_Point::ConstructionPlugin_Point() @@ -271,14 +270,7 @@ std::list > if(!aLineShape.get()) { aLineShape = aLineSelection->context()->shape(); } - GeomEdgePtr anEdge; - if (aLineShape->isEdge()) { - anEdge = aLineShape->edge(); - } - else if (aLineShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aLineShape); - anEdge = anIt.current()->edge(); - } + std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); // Get plane. AttributeSelectionPtr aPlaneSelection= selection(INTERSECTION_PLANE()); @@ -286,14 +278,7 @@ std::list > if(!aPlaneShape.get()) { aPlaneShape = aPlaneSelection->context()->shape(); } - GeomFacePtr aFace; - if (aPlaneShape->isFace()) { - aFace = aPlaneShape->face(); - } - else if (aPlaneShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aPlaneShape); - aFace = anIt.current()->face(); - } + std::shared_ptr aFace(new GeomAPI_Face(aPlaneShape)); if (!string(USE_OFFSET())->value().empty()) { double anOffset = real(OFFSET())->value(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp b/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp index 50047dd69..2390b83a4 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -36,7 +35,6 @@ #include static std::shared_ptr getEdge(const GeomShapePtr theShape); -static std::shared_ptr getFace(const GeomShapePtr theShape); static std::shared_ptr getLin(const GeomShapePtr theShape); static std::shared_ptr getPln(const GeomShapePtr theShape); static std::shared_ptr getPnt(const GeomShapePtr theShape); @@ -116,7 +114,7 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid( AttributeSelectionPtr anAttribute2 = aFeature->selection(theArguments.front()); std::shared_ptr anEdge; - std::shared_ptr aFace; + std::shared_ptr aPln; GeomShapePtr aShape1 = anAttribute1->value(); ResultPtr aContext1 = anAttribute1->context(); @@ -139,20 +137,20 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid( bool isPlaneFirst = false; anEdge = getEdge(aShape1); - - aFace = getFace(aShape2); - if(!anEdge.get() || !aFace.get()) { + aPln = getPln(aShape2); + if(!anEdge.get() || !aPln.get()) { anEdge = getEdge(aShape2); - aFace = getFace(aShape1); + aPln = getPln(aShape1); isPlaneFirst = true; } - if(!anEdge.get() || !aFace.get()) { + if(!anEdge.get() || !aPln.get()) { theError = "Wrong shape types selected."; return false; } - if(GeomAlgoAPI_ShapeTools::isParallel(anEdge, aFace)) { + std::shared_ptr aPlaneFace(new GeomAPI_Face(isPlaneFirst ? aShape1 : aShape2)); + if(GeomAlgoAPI_ShapeTools::isParallel(anEdge, aPlaneFace)) { theError = "Plane and edge are parallel."; return false; } @@ -476,51 +474,25 @@ bool ConstructionPlugin_ValidatorPointThreeNonParallelPlanes::isValid( std::shared_ptr getEdge(const GeomShapePtr theShape) { - GeomEdgePtr anEdge; - - if(theShape->isEdge()) { - anEdge = theShape->edge(); + if(!theShape->isEdge()) { + return std::shared_ptr(); } - 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(); - } + std::shared_ptr anEdge(new GeomAPI_Edge(theShape)); - return aFace; + return anEdge; } std::shared_ptr getLin(const GeomShapePtr theShape) { std::shared_ptr aLin; - GeomEdgePtr anEdge; - - if (theShape->isEdge()) { - anEdge = theShape->edge(); - } - else if (theShape->isCompound()) { - GeomAPI_ShapeIterator anIt(theShape); - anEdge = anIt.current()->edge(); - } - else { + if(!theShape->isEdge()) { return aLin; } + std::shared_ptr anEdge(new GeomAPI_Edge(theShape)); + if(!anEdge->isLine()) { return aLin; } @@ -534,19 +506,12 @@ std::shared_ptr getPln(const GeomShapePtr theShape) { std::shared_ptr aPln; - GeomFacePtr aFace; - - if(theShape->isFace()) { - aFace = theShape->face(); - } - else if (theShape->isCompound()) { - GeomAPI_ShapeIterator anIt(theShape); - aFace = anIt.current()->face(); - } - else { + if(!theShape->isFace()) { return aPln; } + std::shared_ptr aFace(new GeomAPI_Face(theShape)); + if(!aFace->isPlanar()) { return aPln; } diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index 4ccefe011..928d03022 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -50,8 +50,7 @@ email : webmaster.salome@opencascade.com + shape_types="edge"> @@ -60,8 +59,7 @@ email : webmaster.salome@opencascade.com + shape_types="face"> @@ -70,8 +68,7 @@ email : webmaster.salome@opencascade.com + shape_types="face"> + shape_types="face"> @@ -99,8 +95,7 @@ email : webmaster.salome@opencascade.com + shape_types="face"> diff --git a/src/ConstructionPlugin/plane_widget.xml b/src/ConstructionPlugin/plane_widget.xml index dfe2007b3..f23a4f406 100644 --- a/src/ConstructionPlugin/plane_widget.xml +++ b/src/ConstructionPlugin/plane_widget.xml @@ -55,8 +55,7 @@ email : webmaster.salome@opencascade.com + shape_types="edge"> @@ -80,8 +79,7 @@ email : webmaster.salome@opencascade.com + shape_types="face"> @@ -120,8 +118,7 @@ email : webmaster.salome@opencascade.com + shape_types="edge"> + shape_types="face"> @@ -152,8 +148,7 @@ email : webmaster.salome@opencascade.com + shape_types="face"> diff --git a/src/ConstructionPlugin/point_widget.xml b/src/ConstructionPlugin/point_widget.xml index 3ccf77550..bd7439f8a 100644 --- a/src/ConstructionPlugin/point_widget.xml +++ b/src/ConstructionPlugin/point_widget.xml @@ -141,8 +141,7 @@ email : webmaster.salome@opencascade.com + shape_types="edge"> @@ -150,8 +149,7 @@ email : webmaster.salome@opencascade.com + shape_types="face"> diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index ceb01e793..baf8f6397 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -31,7 +31,6 @@ #include #include #include -#include //================================================================================================= FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() @@ -96,29 +95,16 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, getBaseShapes(theBaseShapes); //Getting direction. - static const std::string aSelectionError = "Error: The direction shape selection is bad."; + std::shared_ptr aDir; + std::shared_ptr anEdge; AttributeSelectionPtr aSelection = selection(DIRECTION_OBJECT_ID()); - 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(); - } + if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->value())); + } else if(aSelection->context().get() && + aSelection->context()->shape().get() && + aSelection->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->context()->shape())); } - - std::shared_ptr aDir; if(anEdge.get()) { if(anEdge->isLine()) { aDir = anEdge->line()->direction(); @@ -148,10 +134,6 @@ 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()) { @@ -159,10 +141,6 @@ 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(); - } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp index ea1cf57d7..5f8870f59 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -94,44 +93,21 @@ void FeaturesPlugin_MultiRotation::performRotation1D() } //Getting axis. - 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 (!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; + std::shared_ptr anAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - - if (!anEdge.get()) - { - setError(aSelectionError); - return; + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - std::shared_ptr anAxis(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); - // Getting number of copies. int nbCopies = integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp index 76a644c2a..d23742c6d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -102,44 +101,21 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() } //Getting axis. - 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 (!aShape.get()) { - setError(aSelectionError); - return; - } - - GeomEdgePtr anEdge; - if (aShape->isEdge()) - { - anEdge = aShape->edge(); + std::shared_ptr anAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - else if (aShape->isCompound()) - { - GeomAPI_ShapeIterator anIt(aShape); - anEdge = anIt.current()->edge(); - } - else - { - setError(aSelectionError); - return; - } - - if (!anEdge.get()) - { - setError(aSelectionError); - return; + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - std::shared_ptr anAxis (new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); - // Getting step. double aStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value(); @@ -246,80 +222,32 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() } //Getting axis. - 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(); - } + std::shared_ptr aFirstAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - if (!aShape.get()) { - setError(aSelectionError); - return; + if(anEdge) { + aFirstAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - - GeomEdgePtr anEdge; - if (aShape->isEdge()) - { - anEdge = aShape->edge(); + std::shared_ptr aSecondAxis; + anObjRef = selection(FeaturesPlugin_MultiTranslation::AXIS_SECOND_DIR_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - else if (aShape->isCompound()) - { - GeomAPI_ShapeIterator anIt(aShape); - anEdge = anIt.current()->edge(); + if(anEdge) { + aSecondAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - else - { - setError(aSelectionError); - return; - } - - if (!anEdge.get()) - { - setError(aSelectionError); - return; - } - - std::shared_ptr 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 aSecondAxis(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); // Getting step. double aFirstStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index 187ee252f..ab932f01d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -122,8 +121,21 @@ void FeaturesPlugin_Placement::execute() // Verify planarity of faces and linearity of edges std::shared_ptr aShapes[2] = {aStartShape, anEndShape}; for (int i = 0; i < 2; i++) { - if (!isShapeValid(aShapes[i])) { - return; + if (aShapes[i]->isFace()) { + std::shared_ptr 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 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; + } } } @@ -187,48 +199,6 @@ void FeaturesPlugin_Placement::execute() 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 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 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; -} - //============================================================================ void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo, std::shared_ptr theResultBody, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.h b/src/FeaturesPlugin/FeaturesPlugin_Placement.h index e40392c14..1b8a7b6bd 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.h @@ -96,9 +96,6 @@ class FeaturesPlugin_Placement : public ModelAPI_Feature /// Use plugin manager for features creation FeaturesPlugin_Placement(); private: - /// Checks validity of passed shape. - bool isShapeValid(GeomShapePtr theShape); - /// Load Naming data structure of the feature to the document void loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo, std::shared_ptr theResultBody, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 4ac87606e..4a6433180 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -30,7 +30,6 @@ #include #include -#include //================================================================================================= FeaturesPlugin_Revolution::FeaturesPlugin_Revolution() @@ -93,37 +92,17 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes, // Getting base shapes. getBaseShapes(theBaseShapes); - // Getting axis. - static const std::string aSelectionError = "Error: The axis shape selection is bad."; + //Getting axis. + std::shared_ptr anAxis; + std::shared_ptr anEdge; AttributeSelectionPtr aSelection = selection(AXIS_OBJECT_ID()); - 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(); + if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->value())); + } else if(aSelection->context().get() && + aSelection->context()->shape().get() && + aSelection->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->context()->shape())); } - else - { - setError(aSelectionError); - return false; - } - - std::shared_ptr anAxis; if(anEdge.get()) { if(anEdge->isLine()) { anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), @@ -158,10 +137,6 @@ 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()) { @@ -169,10 +144,6 @@ 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(); - } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 81e244802..07d2d575c 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -100,43 +99,20 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle() } //Getting axis. - 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; + std::shared_ptr anAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - - 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(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - else - { - setError(aSelectionError); - return; - } - - if (!anEdge.get()) - { - setError(aSelectionError); - return; - } - - std::shared_ptr anAxis (new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); // Getting angle. double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp index ff8988e80..d50b74aa2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -196,45 +195,21 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis() return; //Getting axis. - 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(); - } - else - { - setError(aSelectionError); - return; + std::shared_ptr anAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - - if (!anEdge.get()) - { - setError(aSelectionError); - return; + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - std::shared_ptr anAxis (new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); - - // Moving each object. int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); @@ -296,46 +271,24 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane() if (!collectSourceObjects(anObjects, aContextes)) return; - //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(); - } - } - if (!aShape.get()) { - setError(aSelectionError); - return; - } - - GeomFacePtr aFace; - if (aShape->isFace()) - { - aFace = aShape->face(); - } - else if (aShape->isCompound()) - { - GeomAPI_ShapeIterator anIt(aShape); - aFace = anIt.current()->face(); + //Getting axis. + std::shared_ptr aPlane; + std::shared_ptr aPln; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID()); + if (anObjRef && anObjRef->value() && anObjRef->value()->isFace()) { + aPln = std::shared_ptr(new GeomAPI_Face(anObjRef->value()))->getPlane(); } - else - { - setError(aSelectionError); - return; + else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isFace()) { + aPln = + std::shared_ptr(new GeomAPI_Face(anObjRef->context()->shape()))->getPlane(); } - - if (!aFace.get()) - { - setError(aSelectionError); - return; + if (aPln) { + aPlane = std::shared_ptr(new GeomAPI_Ax2(aPln->location(), + aPln->direction())); } - std::shared_ptr aPlane(new GeomAPI_Ax2(aFace->getPlane()->location(), - aFace->getPlane()->direction())); - - // Moving each object. int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index f4469d2e9..0da4b6acc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -113,45 +112,21 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance() } //Getting axis. - 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(); + std::shared_ptr anAxis; + std::shared_ptr anEdge; + std::shared_ptr anObjRef = + selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID()); + if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); + } else if (anObjRef && !anObjRef->value() && anObjRef->context() && + anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); } - else - { - setError(aSelectionError); - return; - } - - if (!anEdge.get()) - { - setError(aSelectionError); - return; + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); } - std::shared_ptr anAxis(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); - - // Getting distance. double aDistance = real(FeaturesPlugin_Translation::DISTANCE_ID())->value(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 0470dd73e..b991e38f0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -474,11 +474,6 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid( if(aContext.get()) { aDirShape = aContext->shape(); } - - if (aDirShape.get() && aDirShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aDirShape); - aDirShape = anIt.current(); - } } } diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 6e14b846e..910a623e3 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -41,7 +41,6 @@ email : webmaster.salome@opencascade.com @@ -75,7 +74,6 @@ email : webmaster.salome@opencascade.com @@ -92,7 +90,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index c8bc95a8e..b176ddc18 100755 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -43,7 +43,6 @@ email : webmaster.salome@opencascade.com @@ -77,7 +76,6 @@ email : webmaster.salome@opencascade.com @@ -93,7 +91,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index 0891b5589..e65b6b4af 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -43,7 +43,6 @@ email : webmaster.salome@opencascade.com @@ -77,7 +76,6 @@ email : webmaster.salome@opencascade.com @@ -93,7 +91,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/multirotation_widget.xml b/src/FeaturesPlugin/multirotation_widget.xml index 747af9377..8396f4869 100644 --- a/src/FeaturesPlugin/multirotation_widget.xml +++ b/src/FeaturesPlugin/multirotation_widget.xml @@ -15,8 +15,7 @@ label="Axis" tooltip="Select an edge for the angular direction" shape_types="edge" - default="" - geometrical_selection="true"> + default=""> diff --git a/src/FeaturesPlugin/multitranslation_widget.xml b/src/FeaturesPlugin/multitranslation_widget.xml index 4eed46173..b6137c34e 100644 --- a/src/FeaturesPlugin/multitranslation_widget.xml +++ b/src/FeaturesPlugin/multitranslation_widget.xml @@ -34,8 +34,7 @@ email : webmaster.salome@opencascade.com + default=""> + default=""> + shape_types="face edge vertex"> + shape_types="face edge vertex"> diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index 3bc2c6683..3d71c3d84 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -41,7 +41,6 @@ email : webmaster.salome@opencascade.com @@ -75,7 +74,6 @@ email : webmaster.salome@opencascade.com @@ -92,7 +90,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/revolutioncut_widget.xml b/src/FeaturesPlugin/revolutioncut_widget.xml index 297fc706f..12f2f247f 100644 --- a/src/FeaturesPlugin/revolutioncut_widget.xml +++ b/src/FeaturesPlugin/revolutioncut_widget.xml @@ -43,7 +43,6 @@ email : webmaster.salome@opencascade.com @@ -77,7 +76,6 @@ email : webmaster.salome@opencascade.com @@ -93,7 +91,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/revolutionfuse_widget.xml b/src/FeaturesPlugin/revolutionfuse_widget.xml index 5e358ee66..6d1bb8394 100644 --- a/src/FeaturesPlugin/revolutionfuse_widget.xml +++ b/src/FeaturesPlugin/revolutionfuse_widget.xml @@ -43,7 +43,6 @@ email : webmaster.salome@opencascade.com @@ -77,7 +76,6 @@ email : webmaster.salome@opencascade.com @@ -93,7 +91,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/rotation_widget.xml b/src/FeaturesPlugin/rotation_widget.xml index 418998210..c07bd8ba8 100755 --- a/src/FeaturesPlugin/rotation_widget.xml +++ b/src/FeaturesPlugin/rotation_widget.xml @@ -37,8 +37,7 @@ email : webmaster.salome@opencascade.com + default=""> + default=""> diff --git a/src/FeaturesPlugin/translation_widget.xml b/src/FeaturesPlugin/translation_widget.xml index 3e5ef8260..28bb25115 100644 --- a/src/FeaturesPlugin/translation_widget.xml +++ b/src/FeaturesPlugin/translation_widget.xml @@ -37,8 +37,7 @@ email : webmaster.salome@opencascade.com + default=""> -#include #include #include @@ -29,7 +28,6 @@ #include #include #include -#include #include #include @@ -72,48 +70,29 @@ void GeomAlgoAPI_Placement::build(const std::shared_ptr& theSourc GProp_GProps aProps; static const double aPropEps = 1.e-4; - GeomShapePtr aShape; - bool isCompound = false; for (int i = 0; i < aNbObjects; 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 aFace(new GeomAPI_Face(aShape)); + if (aShapes[i]->isFace()) { + std::shared_ptr aFace(new GeomAPI_Face(aShapes[i])); std::shared_ptr aPlane = aFace->getPlane(); std::shared_ptr aDir = aPlane->direction(); aSrcDstNormals[i].SetCoord(aDir->x(), aDir->y(), aDir->z()); - if (!isCompound) { - BRepGProp::SurfaceProperties(aFace->impl(), aProps, aPropEps); - gp_Pnt aLoc = aProps.CentreOfMass(); - aSrcDstPoints[i].SetCoord(aLoc.X(), aLoc.Y(), aLoc.Z()); - } + BRepGProp::SurfaceProperties(aFace->impl(), aProps, aPropEps); + gp_Pnt aLoc = aProps.CentreOfMass(); + aSrcDstPoints[i].SetCoord(aLoc.X(), aLoc.Y(), aLoc.Z()); } - else if (aShape->isEdge()) { - std::shared_ptr anEdge(new GeomAPI_Edge(aShape)); + else if (aShapes[i]->isEdge()) { + std::shared_ptr anEdge(new GeomAPI_Edge(aShapes[i])); std::shared_ptr aLine = anEdge->line(); std::shared_ptr aDir = aLine->direction(); + std::shared_ptr aFirstPnt = anEdge->firstPoint(); + std::shared_ptr aLastPnt = anEdge->lastPoint(); + std::shared_ptr 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 aFirstPnt = anEdge->firstPoint(); - std::shared_ptr aLastPnt = anEdge->lastPoint(); - std::shared_ptr aLoc = aFirstPnt->xyz()->added(aLastPnt->xyz()) - ->multiplied(0.5); - aSrcDstPoints[i].SetCoord(aLoc->x(), aLoc->y(), aLoc->z()); - } } - else if (aShape->isVertex()) { - std::shared_ptr aVertex(new GeomAPI_Vertex(aShape)); + else if (aShapes[i]->isVertex()) { + std::shared_ptr aVertex(new GeomAPI_Vertex(aShapes[i])); std::shared_ptr aPnt = aVertex->point(); aSrcDstPoints[i].SetCoord(aPnt->x(), aPnt->y(), aPnt->z()); } else // something goes wrong diff --git a/src/GeomValidators/GeomValidators_Face.cpp b/src/GeomValidators/GeomValidators_Face.cpp index a5f9d588c..945f9bc34 100644 --- a/src/GeomValidators/GeomValidators_Face.cpp +++ b/src/GeomValidators/GeomValidators_Face.cpp @@ -24,7 +24,6 @@ #include "ModelAPI_AttributeSelection.h" #include -#include #include @@ -47,40 +46,6 @@ 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& theArguments, Events_InfoMessage& theError) const @@ -113,22 +78,36 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, theError = "The shape is not a face."; } else { - GeomAbs_SurfaceType aFaceType = GeomAbs_Plane; - if (theArguments.size() == 1) aFaceType = faceType(theArguments.front()); - if (aGeomShape->isFace()) { - isValidFace(aGeomShape, aFaceType, theError); + std::shared_ptr aGeomFace(new GeomAPI_Face(aGeomShape)); + if (!aGeomFace.get()) { + aValid = false; + theError = "The shape is not a face."; } - else if (aSelectionAttr->isGeometricalSelection() && aGeomShape->isCompound()) { - for (GeomAPI_ShapeIterator anIt(aGeomShape); anIt.more(); anIt.next()) { - if (!isValidFace(anIt.current(), 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."; break; } } } - else { - aValid = false; - theError = "The shape is not a face."; - } } } return aValid; diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp index a7638e7be..afb7dd0c9 100755 --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -22,7 +22,6 @@ #include "GeomValidators_Tools.h" #include -#include #include #include @@ -131,27 +130,18 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute std::dynamic_pointer_cast(theAttribute); GeomShapePtr aShape = anAttr->value(); if (aShape.get()) - aValid = isValidShape(aShape, theShapeType, anAttr->isGeometricalSelection(), theError); + aValid = isValidShape(aShape, theShapeType, theError); else { if (anAttr->context().get()) - aValid = isValidObject(anAttr->context(), - theShapeType, - anAttr->isGeometricalSelection(), - theError); + aValid = isValidObject(anAttr->context(), theShapeType, theError); else - aValid = isValidObject(anAttr->contextFeature(), - theShapeType, - anAttr->isGeometricalSelection(), - theError); + aValid = isValidObject(anAttr->contextFeature(), theShapeType, theError); } } else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttribute); if (anAttr->isObject()) { - aValid = isValidObject(anAttr->object(), - theShapeType, - false, - theError); + aValid = isValidObject(anAttr->object(), theShapeType, theError); } else if (theShapeType == Vertex) { AttributePtr aRefAttr = anAttr->attr(); @@ -172,7 +162,7 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute else if (anAttributeType == ModelAPI_AttributeReference::typeId()) { AttributeReferencePtr anAttr = std::dynamic_pointer_cast(theAttribute); - aValid = isValidObject(anAttr->value(), theShapeType, false, theError); + aValid = isValidObject(anAttr->value(), theShapeType, theError); } else if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aListAttr = @@ -200,7 +190,6 @@ 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; @@ -225,7 +214,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, aValid = false; theError = "The result is empty"; } else { - aValid = isValidShape(aResult->shape(), theShapeType, theIsGeometricalSelection, theError); + aValid = isValidShape(aResult->shape(), theShapeType, theError); } } else { FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); @@ -242,7 +231,6 @@ 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; @@ -259,21 +247,9 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape, case Edge: aValid = theShape->isEdge(); break; - 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(); - } + case Line: + aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isLine(); break; - } case Circle: aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle(); break; diff --git a/src/GeomValidators/GeomValidators_ShapeType.h b/src/GeomValidators/GeomValidators_ShapeType.h index 0606cd411..daf9fda38 100644 --- a/src/GeomValidators/GeomValidators_ShapeType.h +++ b/src/GeomValidators/GeomValidators_ShapeType.h @@ -83,7 +83,6 @@ 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 @@ -92,7 +91,6 @@ protected: /// \param[out] theError error message. bool isValidShape(const GeomShapePtr theShape, const TypeOfShape theShapeType, - const bool theIsGeometricalSelection, Events_InfoMessage& theError) const; }; diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index d6181783f..4a919d0c4 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -132,10 +131,6 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { aToShape = anAttrSel->context()->shape(); } - if (aToShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aToShape); - aToShape = anIt.current(); - } } anIt++; @@ -151,10 +146,6 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { aFromShape = anAttrSel->context()->shape(); } - if (aFromShape->isCompound()) { - GeomAPI_ShapeIterator anIt(aFromShape); - aFromShape = anIt.current(); - } } anIt++; diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 90cbe4322..af1020ab5 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -452,10 +451,6 @@ void Model_AttributeSelection::setID(const std::string theID) { myRef.setID(theID); ModelAPI_AttributeSelection::setID(theID); - FeaturePtr aFeature = std::dynamic_pointer_cast(owner()); - // TODO: check if parent list have geometrical selection flag. - myIsGeometricalSelection = - ModelAPI_Session::get()->validators()->isGeometricalSelection(aFeature->getKind(), id()); } ResultPtr Model_AttributeSelection::context() @@ -779,7 +774,7 @@ void Model_AttributeSelection::selectBody( if (aEraseResults) // erase results without flash deleted and redisplay: do it after Select aFeatureOwner->removeResults(0, false, false); } - aSel.Select(aNewSub, aNewContext, myIsGeometricalSelection); + aSel.Select(aNewSub, aNewContext); // face may become divided after the model update, so, new labels may be added to the scope myScope.Clear(); @@ -869,14 +864,6 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa return ""; } - if (myIsGeometricalSelection - && aSubSh.get() - && aSubSh->isCompound()) - { - GeomAPI_ShapeIterator anIt(aSubSh); - aSubSh = anIt.current(); - } - Model_SelectionNaming aSelNaming(selectionLabel()); std::string aResult = aSelNaming.namingName( aCont, aSubSh, theDefaultName, owner()->document() != aCont->document()); diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 380b998de..cafa6ea37 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -47,9 +47,6 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection CenterType myTmpCenterType; /// Reference to the partent attribute, if any (to split selection compounds in issue 1799) Model_AttributeSelectionList* myParent; - /// 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 @@ -183,11 +180,6 @@ 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; }; diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index c231bfd0e..9fb412407 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -332,11 +332,11 @@ std::shared_ptr // (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid) std::shared_ptr aNewAttr = std::shared_ptr(new Model_AttributeSelection(aLabel)); + aNewAttr->setID(id()); if (owner()) { aNewAttr->setObject(owner()); aNewAttr->setParent(this); } - aNewAttr->setID(id()); return aNewAttr; } diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index a7a032eea..2a830e788 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -471,10 +471,6 @@ void Model_Session::processEvent(const std::shared_ptr& 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 diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index 5bf41b289..41fa0f701 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -377,27 +377,3 @@ bool Model_ValidatorsFactory::isMainArgument(std::string theFeature, std::string std::map::iterator aFound = myMainArgument.find(theFeature); return aFound != myMainArgument.end() && aFound->second == theAttribute; } - -void Model_ValidatorsFactory::registerGeometricalSelection(std::string theFeature, - std::string theAttribute) -{ - std::map >::iterator aFind = - myGeometricalSelection.find(theFeature); - if (aFind == myGeometricalSelection.end()) { - std::set aNewSet; - aNewSet.insert(theAttribute); - myGeometricalSelection[theFeature] = aNewSet; - } - else { - aFind->second.insert(theAttribute); - } -} - -bool Model_ValidatorsFactory::isGeometricalSelection(std::string theFeature, - std::string theAttribute) -{ - std::map >::iterator aFind = - myGeometricalSelection.find(theFeature); - return aFind != myGeometricalSelection.end() - && aFind->second.find(theAttribute) != aFind->second.end(); -} diff --git a/src/Model/Model_Validator.h b/src/Model/Model_Validator.h index 7dcf2ff98..939cdf213 100644 --- a/src/Model/Model_Validator.h +++ b/src/Model/Model_Validator.h @@ -58,7 +58,6 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory std::map > > > myCases; /// Stores main attribute for each feature std::map myMainArgument; - std::map > myGeometricalSelection; public: /// Registers the instance of the validator by the ID @@ -124,12 +123,6 @@ 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. diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index ea37d4173..53e0151b8 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -115,9 +115,6 @@ 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(); diff --git a/src/ModelAPI/ModelAPI_Validator.h b/src/ModelAPI/ModelAPI_Validator.h index e40e05536..a2c8af67a 100644 --- a/src/ModelAPI/ModelAPI_Validator.h +++ b/src/ModelAPI/ModelAPI_Validator.h @@ -128,12 +128,6 @@ 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() diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 7e33d61fe..92eaa64f2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -1068,11 +1067,6 @@ 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) { diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp index 2da170fd6..2c2916586 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include @@ -83,43 +82,21 @@ void PrimitivesPlugin_Cone::execute() } // Getting axis. - static const std::string aSelectionError = "Error: The axis shape selection is bad."; - std::shared_ptr 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 anAxis; std::shared_ptr anEdge; - if (aShape->isEdge()) - { - anEdge = aShape->edge(); - } - else if (aShape->isCompound()) - { - GeomAPI_ShapeIterator anIt(aShape); - anEdge = anIt.current()->edge(); + std::shared_ptr anEdgeRef = + selection(PrimitivesPlugin_Cone::AXIS_ID()); + if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->value())); + } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() && + anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->context()->shape())); } - else - { - setError(aSelectionError); - return; + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, + anEdge->line()->direction())); } - if (!anEdge.get()) - { - setError(aSelectionError); - return; - } - - std::shared_ptr 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(); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp index 9a80ed0ae..c3d5b8223 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include @@ -113,44 +112,21 @@ void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle) } // Getting axis. - static const std::string aSelectionError = "Error: The axis shape selection is bad."; - std::shared_ptr 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 anAxis; std::shared_ptr 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 anEdgeRef = + selection(PrimitivesPlugin_Cylinder::AXIS_ID()); + if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->value())); + } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() && + anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->context()->shape())); + } + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, + anEdge->line()->direction())); } - std::shared_ptr 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(); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp index cddab69e4..a086def17 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include @@ -81,43 +80,21 @@ void PrimitivesPlugin_Torus::execute() } // Getting axis. - static const std::string aSelectionError = "Error: The axis shape selection is bad."; - std::shared_ptr 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 anAxis; std::shared_ptr anEdge; - if (aShape->isEdge()) - { - anEdge = aShape->edge(); - } - else if (aShape->isCompound()) - { - GeomAPI_ShapeIterator anIt(aShape); - anEdge = anIt.current()->edge(); + std::shared_ptr anEdgeRef = + selection(PrimitivesPlugin_Torus::AXIS_ID()); + if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->value())); + } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() && + anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->context()->shape())); } - else - { - setError(aSelectionError); - return; + if(anEdge) { + anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, + anEdge->line()->direction())); } - if (!anEdge.get()) - { - setError(aSelectionError); - return; - } - - std::shared_ptr 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(); diff --git a/src/PrimitivesPlugin/cone_widget.xml b/src/PrimitivesPlugin/cone_widget.xml index 710134ca0..4f1acd5e4 100644 --- a/src/PrimitivesPlugin/cone_widget.xml +++ b/src/PrimitivesPlugin/cone_widget.xml @@ -16,7 +16,6 @@ label="axis" default="" shape_types="edge" - geometrical_selection="true" icon="icons/Primitives/axis.png" tooltip="Select the axis of the cone"> diff --git a/src/PrimitivesPlugin/cylinder_widget.xml b/src/PrimitivesPlugin/cylinder_widget.xml index 2474f8bad..373bafb5f 100644 --- a/src/PrimitivesPlugin/cylinder_widget.xml +++ b/src/PrimitivesPlugin/cylinder_widget.xml @@ -37,7 +37,6 @@ email : webmaster.salome@opencascade.com @@ -76,7 +75,6 @@ email : webmaster.salome@opencascade.com diff --git a/src/PrimitivesPlugin/torus_widget.xml b/src/PrimitivesPlugin/torus_widget.xml index 30f6489e4..44d0ce688 100644 --- a/src/PrimitivesPlugin/torus_widget.xml +++ b/src/PrimitivesPlugin/torus_widget.xml @@ -16,7 +16,6 @@ label="axis" default="" shape_types="edge" - geometrical_selection="true" icon="icons/Primitives/axis.png" tooltip="Select the axis of the torus"> diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 1b7753423..d23ad07d0 100755 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -256,14 +255,7 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) { std::shared_ptr aSelection = aSelAttr->value(); if (!aSelection.get()) aSelection = aSelAttr->context()->shape(); // update the sketch plane - std::shared_ptr aFace; - if (aSelection->isFace()) { - aFace = aSelection->face(); - } else if (aSelection->isCompound()) { - GeomAPI_ShapeIterator anIt(aSelection); - aFace = anIt.current()->face(); - } - + std::shared_ptr aFace(new GeomAPI_Face(aSelection)); std::shared_ptr aPlane = aFace->getPlane(); if (aPlane) { double anA, aB, aC, aD; -- 2.39.2