From: dbv Date: Mon, 23 May 2016 08:27:04 +0000 (+0300) Subject: Fix for test cases. X-Git-Tag: V_2.3.1~75 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=398e18a0544447b5f2937245a4a7de6395c4783c;p=modules%2Fshaper.git Fix for test cases. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 4f9d860c7..b451667ac 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -444,16 +444,31 @@ bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& the const std::list& theArguments, std::string& theError) const { - GeomValidators_BodyShapes aBodyValidator; - if(aBodyValidator.isValid(theAttribute, theArguments, theError)) { - return true; - } + std::string anAttributeType = theAttribute->attributeType(); + if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) { + AttributeSelectionListPtr aSelectionListAttr = + std::dynamic_pointer_cast(theAttribute); - GeomValidators_FeatureKind aFeatureKindValidator; - if(aFeatureKindValidator.isValid(theAttribute, theArguments, theError)) { - return true; + for(int anIndex = 0; anIndex < aSelectionListAttr->size(); ++anIndex) { + AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(anIndex); + + GeomValidators_BodyShapes aBodyValidator; + if(aBodyValidator.isValid(aSelectAttr, theArguments, theError)) { + continue; + } + + GeomValidators_FeatureKind aFeatureKindValidator; + if(aFeatureKindValidator.isValid(aSelectAttr, theArguments, theError)) { + continue; + } + + theError = "Only body shapes and construction planes are allowed for selection."; + return false; + } + } else { + theError = "This validator supports only " + ModelAPI_AttributeSelectionList::typeId() + " attribute type."; + return false; } - theError = "Only body shapes and construction planes are allowed for selection."; - return false; + return true; } diff --git a/src/FeaturesPlugin/Test/TestPartition.py b/src/FeaturesPlugin/Test/TestPartition.py index e12641257..c90a29082 100644 --- a/src/FeaturesPlugin/Test/TestPartition.py +++ b/src/FeaturesPlugin/Test/TestPartition.py @@ -94,9 +94,8 @@ aPlaneResult = aPlaneFeature.firstResult() aSession.startOperation() aPartitionFt = aPart.addFeature("Partition") assert (aPartitionFt.getKind() == "Partition") -aPartitionFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape()) -aPartitionFt.selectionList("tool_objects").append(aPlaneResult, None) -aPartitionFt.boolean("partition_combine").setValue(True) +aPartitionFt.selectionList("base_objects").append(anExtrusionResult, anExtrusionResult.shape()) +aPartitionFt.selectionList("base_objects").append(aPlaneResult, None) aPartitionFt.execute() aSession.finishOperation() @@ -116,9 +115,8 @@ aSession.undo() aSession.startOperation() aPartitionFt = aPart.addFeature("Partition") assert (aPartitionFt.getKind() == "Partition") -aPartitionFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape()) -aPartitionFt.selectionList("tool_objects").append(aPlaneResult, None) -aPartitionFt.boolean("partition_combine").setValue(False) +aPartitionFt.selectionList("base_objects").append(anExtrusionResult, anExtrusionResult.shape()) +aPartitionFt.selectionList("base_objects").append(aPlaneResult, None) aPartitionFt.execute() aSession.finishOperation() diff --git a/src/FeaturesPlugin/partition_widget.xml b/src/FeaturesPlugin/partition_widget.xml index ec2ea7105..593b19864 100755 --- a/src/FeaturesPlugin/partition_widget.xml +++ b/src/FeaturesPlugin/partition_widget.xml @@ -6,7 +6,6 @@ tooltip="Select objects for partitioning." type_choice="objects" concealment="true"> - + - diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index e6a89baa1..7f407d677 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -49,9 +49,8 @@ #include #include -namespace GeomAlgoAPI_ShapeTools { //================================================================================================== -double volume(const std::shared_ptr theShape) +double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr theShape) { GProp_GProps aGProps; if(!theShape.get()) { @@ -67,7 +66,7 @@ double volume(const std::shared_ptr theShape) } //================================================================================================== -std::shared_ptr centreOfMass(const std::shared_ptr theShape) +std::shared_ptr GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr theShape) { GProp_GProps aGProps; if(!theShape) { @@ -91,10 +90,10 @@ std::shared_ptr centreOfMass(const std::shared_ptr t } //================================================================================================== -std::shared_ptr combineShapes(const std::shared_ptr theCompound, - const GeomAPI_Shape::ShapeType theType, - ListOfShape& theCombinedShapes, - ListOfShape& theFreeShapes) +std::shared_ptr GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr theCompound, + const GeomAPI_Shape::ShapeType theType, + ListOfShape& theCombinedShapes, + ListOfShape& theFreeShapes) { GeomShapePtr aResult = theCompound; @@ -270,7 +269,7 @@ static TopoDS_Compound makeCompound(const NCollection_List theShap } //================================================================================================== -std::shared_ptr groupSharedTopology(const std::shared_ptr theCompound) +std::shared_ptr GeomAlgoAPI_ShapeTools::groupSharedTopology(const std::shared_ptr theCompound) { GeomShapePtr aResult = theCompound; @@ -338,7 +337,7 @@ std::shared_ptr groupSharedTopology(const std::shared_ptr > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge) +std::list > GeomAlgoAPI_ShapeTools::getBoundingBox(const ListOfShape& theShapes, const double theEnlarge) { // Bounding box of all objects. Bnd_Box aBndBox; @@ -372,7 +371,7 @@ std::list > getBoundingBox(const ListOfShape& theSh } //================================================================================================== -std::shared_ptr faceToInfinitePlane(const std::shared_ptr theFace) +std::shared_ptr GeomAlgoAPI_ShapeTools::faceToInfinitePlane(const std::shared_ptr theFace) { if (!theFace.get()) return std::shared_ptr(); @@ -394,8 +393,8 @@ std::shared_ptr faceToInfinitePlane(const std::shared_ptr fitPlaneToBox(const std::shared_ptr thePlane, - const std::list >& thePoints) +std::shared_ptr GeomAlgoAPI_ShapeTools::fitPlaneToBox(const std::shared_ptr thePlane, + const std::list >& thePoints) { std::shared_ptr aResultShape; @@ -447,9 +446,9 @@ std::shared_ptr fitPlaneToBox(const std::shared_ptr theShape, - std::shared_ptr& theV1, - std::shared_ptr& theV2) +void GeomAlgoAPI_ShapeTools::findBounds(const std::shared_ptr theShape, + std::shared_ptr& theV1, + std::shared_ptr& theV2) { if(!theShape.get()) { std::shared_ptr aVertex(new GeomAPI_Vertex); @@ -471,10 +470,10 @@ void findBounds(const std::shared_ptr theShape, } //================================================================================================== -void makeFacesWithHoles(const std::shared_ptr theOrigin, - const std::shared_ptr theDirection, - const ListOfShape& theWires, - ListOfShape& theFaces) +void GeomAlgoAPI_ShapeTools::makeFacesWithHoles(const std::shared_ptr theOrigin, + const std::shared_ptr theDirection, + const ListOfShape& theWires, + ListOfShape& theFaces) { BRepBuilderAPI_MakeFace aMKFace(gp_Pln(theOrigin->impl(), theDirection->impl())); @@ -503,7 +502,7 @@ void makeFacesWithHoles(const std::shared_ptr theOrigin, } //================================================================================================== -std::shared_ptr findPlane(const ListOfShape& theShapes) +std::shared_ptr GeomAlgoAPI_ShapeTools::findPlane(const ListOfShape& theShapes) { TopoDS_Compound aCompound; BRep_Builder aBuilder; @@ -531,8 +530,8 @@ std::shared_ptr findPlane(const ListOfShape& theShapes) } //================================================================================================== -bool isSubShapeInsideShape(const std::shared_ptr theSubShape, - const std::shared_ptr theBaseShape) +bool GeomAlgoAPI_ShapeTools::isSubShapeInsideShape(const std::shared_ptr theSubShape, + const std::shared_ptr theBaseShape) { if(!theSubShape.get() || !theBaseShape.get()) { return false; @@ -600,4 +599,3 @@ bool isSubShapeInsideShape(const std::shared_ptr theSubShape, return true; } -} //namespace GeomAlgoAPI_ShapeTools diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h index 41cc56983..3d62588f7 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h @@ -17,48 +17,49 @@ class GeomAPI_PlanarEdges; class GeomAPI_Pln; class GeomAPI_Pnt; -/// \namespace GeomAlgoAPI_ShapeTools +/// \class GeomAlgoAPI_ShapeTools /// \ingroup DataAlgo /// \brief Useful tools for working with shapes. -namespace GeomAlgoAPI_ShapeTools +class GeomAlgoAPI_ShapeTools { +public: /// \return the total volume of the solids of the current shape or 0.0 if it can be computed. - GEOMALGOAPI_EXPORT double volume(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr theShape); /// \return the centre of mass of the current face. The coordinates returned for the center of mass /// are expressed in the absolute Cartesian coordinate system. (This function works only for surfaces). - GEOMALGOAPI_EXPORT std::shared_ptr centreOfMass(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT static std::shared_ptr centreOfMass(const std::shared_ptr theShape); /// \brief Combines faces with common edges to shells, or solids to compsolids. /// \param[in] theCompound compound of shapes. /// \param[in] theType type of combine. /// \param[out] theCombinedShapes resulting shapes. /// \param[out] theFreeShapes shapes that does not have common subshapes. - GEOMALGOAPI_EXPORT std::shared_ptr combineShapes(const std::shared_ptr theCompound, - const GeomAPI_Shape::ShapeType theType, - ListOfShape& theCombinedShapes, - ListOfShape& theFreeShapes); + GEOMALGOAPI_EXPORT static std::shared_ptr combineShapes(const std::shared_ptr theCompound, + const GeomAPI_Shape::ShapeType theType, + ListOfShape& theCombinedShapes, + ListOfShape& theFreeShapes); /// \brief Groups shapes with shared topology to compounds. /// \param[in] theCompound compound of shapes. /// \return compound of compounds with shared topology. - GEOMALGOAPI_EXPORT std::shared_ptr groupSharedTopology(const std::shared_ptr theCompound); + GEOMALGOAPI_EXPORT static std::shared_ptr groupSharedTopology(const std::shared_ptr theCompound); /// \brief Calculates bounding box for theShapes /// \return list of eight points. /// \param[in] theShapes list of shapes. /// \param[in] theEnlarge enlarges bounding box size. - GEOMALGOAPI_EXPORT std::list > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0); + GEOMALGOAPI_EXPORT static std::list > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0); /// \return infinite plane received from theFace plane. - GEOMALGOAPI_EXPORT std::shared_ptr faceToInfinitePlane(const std::shared_ptr theFace); + GEOMALGOAPI_EXPORT static std::shared_ptr faceToInfinitePlane(const std::shared_ptr theFace); /// \brief Enlarges or reduces plane to fit bounding box. /// \return plane that fits to bounding box. /// \param[in] thePlane base plane. /// \param[in] thePoints bounding box points (shoud be eight). - GEOMALGOAPI_EXPORT std::shared_ptr fitPlaneToBox(const std::shared_ptr thePlane, - const std::list >& thePoints); + GEOMALGOAPI_EXPORT static std::shared_ptr fitPlaneToBox(const std::shared_ptr thePlane, + const std::list >& thePoints); /// \brief Finds the start and end vertices of theShape. theShape can be of the following type:\n /// Vertex: theV1 and theV2 are the same and equal to theShape;\n @@ -66,29 +67,29 @@ namespace GeomAlgoAPI_ShapeTools /// Wire : theV1 is start vertex of the first edge, theV2 is end vertex of the last edge. If wire /// contains no edges theV1 and theV2 are nullified.\n /// If none of the above theV1 and theV2 are nullified. - GEOMALGOAPI_EXPORT void findBounds(const std::shared_ptr theShape, - std::shared_ptr& theV1, - std::shared_ptr& theV2); + GEOMALGOAPI_EXPORT static void findBounds(const std::shared_ptr theShape, + std::shared_ptr& theV1, + std::shared_ptr& theV2); /// \brief Creates faces with holes from wires. /// \param[in] theWires base wires. /// \param[out] theFaces resulting faces. - GEOMALGOAPI_EXPORT void makeFacesWithHoles(const std::shared_ptr theOrigin, - const std::shared_ptr theDirection, - const ListOfShape& theWires, - ListOfShape& theFaces); + GEOMALGOAPI_EXPORT static void makeFacesWithHoles(const std::shared_ptr theOrigin, + const std::shared_ptr theDirection, + const ListOfShape& theWires, + ListOfShape& theFaces); /// \brief Return a plane for list of shapes if they are all planar. /// \param[in] theShapes shapes to find plane. /// \return plane where all shapes lie or empty ptr if they not planar. - GEOMALGOAPI_EXPORT std::shared_ptr findPlane(const ListOfShape& theShapes); + GEOMALGOAPI_EXPORT static std::shared_ptr findPlane(const ListOfShape& theShapes); /// \brief Checks that vertex/edge is inside face or vertext inside wire. /// \param[in] theSubShape shape that should be inside. /// \param[in] theBaseShape base shape. /// \return true if edge inside the face. - GEOMALGOAPI_EXPORT bool isSubShapeInsideShape(const std::shared_ptr theSubShape, - const std::shared_ptr theBaseShape); + GEOMALGOAPI_EXPORT static bool isSubShapeInsideShape(const std::shared_ptr theSubShape, + const std::shared_ptr theBaseShape); }; #endif