From: dbv Date: Fri, 27 May 2016 15:09:44 +0000 (+0300) Subject: Fix for Partition feature. X-Git-Tag: V_2.3.1~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bf18521b03c3298a3e46591d41595db5a7980b8e;p=modules%2Fshaper.git Fix for Partition feature. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 7cf005d96..c2f90be01 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -131,25 +132,47 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA AttributeSelectionListPtr aListAttr = std::dynamic_pointer_cast(theAttribute); for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) { AttributeSelectionPtr aSelectionAttr = aListAttr->value(anIndex); - ResultConstructionPtr aContext = std::dynamic_pointer_cast(aSelectionAttr->context()); + ResultPtr aContext = aSelectionAttr->context(); if(!aContext.get()) { - // It is not a result construction, continue. + theError = "Error: Empty context."; + return false; + } + + ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast(aContext); + if(!aResultConstruction.get()) { + // It is not a result construction. If shape is compound check that it contains only faces and edges. + GeomShapePtr aShape = aSelectionAttr->value(); + if(!aShape.get()) { + aShape = aContext->shape(); + } + + if(aShape->shapeType() == GeomAPI_Shape::COMPOUND) { + for(GeomAPI_ShapeIterator anIt(aShape); anIt.more(); anIt.next()) { + GeomShapePtr aSubShape = anIt.current(); + if(aSubShape->shapeType() != GeomAPI_Shape::EDGE + && aSubShape->shapeType() != GeomAPI_Shape::FACE) { + theError = "Error: Compound should contain only faces and edges."; + return false; + } + } + } + continue; } GeomShapePtr aShape = aSelectionAttr->value(); - GeomShapePtr aContextShape = aContext->shape(); + GeomShapePtr aContextShape = aResultConstruction->shape(); if(!aShape.get()) { // Whole sketch selected. - if(aSelectedSketchesFromObjects.find(aContext) != aSelectedSketchesFromObjects.cend()) { + if(aSelectedSketchesFromObjects.find(aResultConstruction) != aSelectedSketchesFromObjects.cend()) { theError = "Error: Object from this sketch is already selected. Sketch is not allowed for selection."; return false; } - aSelectedSketches.insert(aContext); + aSelectedSketches.insert(aResultConstruction); } else { // Object from sketch selected. - if(aSelectedSketches.find(aContext) != aSelectedSketches.cend()) { + if(aSelectedSketches.find(aResultConstruction) != aSelectedSketches.cend()) { theError = "Error: Whole sketch with this object is already selected. Don't allow to select this object."; return false; } @@ -167,7 +190,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA } aSelectedWiresFromObjects.bind(aWire, aWire); - aSelectedSketchesFromObjects.insert(aContext); + aSelectedSketchesFromObjects.insert(aResultConstruction); } } } @@ -496,13 +519,20 @@ bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& the ResultPtr aContext = aSelectAttr->context(); ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast(aContext); if(aResultConstruction.get()) { + theError = "Error: Only body shapes and construction planes are allowed for selection."; + return false; + } + ResultCompSolidPtr aResultCompsolid = std::dynamic_pointer_cast(aContext); + if(aResultCompsolid.get()) { + continue; } theError = "Error: Only body shapes and construction planes are allowed for selection."; return false; } + theError = ""; return true; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index 69da42608..6d00e70eb 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -320,13 +320,17 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::groupSharedTopology(const aBuilder.MakeCompound(aCompound); ListOfShape aCompSolids, aFreeSolids; for(NCollection_Vector>::Iterator anIt(aGroups); anIt.More(); anIt.Next()) { - TopoDS_Compound aGroupCompound = makeCompound(anIt.Value()); + NCollection_List aGroup = anIt.Value(); GeomShapePtr aGeomShape(new GeomAPI_Shape()); - aGeomShape->setImpl(new TopoDS_Shape(aGroupCompound)); - aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape, - GeomAPI_Shape::COMPSOLID, - aCompSolids, - aFreeSolids); + if(aGroup.Size() == 1) { + aGeomShape->setImpl(new TopoDS_Shape(aGroup.First())); + } else { + aGeomShape->setImpl(new TopoDS_Shape(makeCompound(anIt.Value()))); + aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape, + GeomAPI_Shape::COMPSOLID, + aCompSolids, + aFreeSolids); + } aBuilder.Add(aCompound, aGeomShape->impl()); }