X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_CompositeSketch.cpp;h=8ee137663d548bb7d3fe7ce080caa3e2abc63ac9;hb=380f01e1fce1a012267d604a1190d04bf4659447;hp=1a6767086da52f312287e1cf2fc74cab74fc31dc;hpb=fd49e1d69802ac4fa4f4c6bd54b9bc483db92105;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 1a6767086..8ee137663 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -50,6 +50,7 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the // Initialize selection list. if(theInitFlags & InitBaseObjectsList) { data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); + myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType(); } } @@ -67,7 +68,7 @@ std::shared_ptr FeaturesPlugin_CompositeSketch::addFeature(std } //================================================================================================= -int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const +int FeaturesPlugin_CompositeSketch::numberOfSubs(bool /*forTree*/) const { ObjectPtr aObj = data()->reference(SKETCH_ID())->value(); return aObj.get() ? 1 : 0; @@ -75,7 +76,7 @@ int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const //================================================================================================= std::shared_ptr FeaturesPlugin_CompositeSketch::subFeature(const int theIndex, - bool forTree) + bool /*forTree*/) { FeaturePtr aSubFeature; if(theIndex == 0) { @@ -177,13 +178,10 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes case GeomAPI_Shape::COMPOUND: { aShapeTypeToExplode = GeomAPI_Shape::COMPOUND; } + default: // [to avoid compilation warnings] + break; } - int aLateralIndex = 1; - int aBaseEdgeIndex = 1; - int aVertexIndex = 1; - int aBaseVertexIndex = 1; - if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX || aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) { theResultBody->loadGeneratedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX); @@ -252,6 +250,8 @@ void FeaturesPlugin_CompositeSketch::storeShapes( aShapeTypeToExplore = GeomAPI_Shape::COMPOUND; break; } + default: // [to avoid compilation warnings] + break; } // Store shapes. @@ -282,9 +282,42 @@ void storeSubShape( for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) { GeomShapePtr aSubShape = anExp.current(); if (!theResultBody->generated(aSubShape, theName)) { - // store from/to shapes as primitives and then store modification of them by the boolean - theResultBody->generated(aSubShape, theName, false); - theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType); + int aNbSubs = theResultBody->numberOfSubs(); + if (aNbSubs > 0) { + // check the modified shape is in the result body, don't store it if not + ListOfShape aNewShapes; + theMakeShape->modified(aSubShape, aNewShapes); + for (int i = 0; i < aNbSubs; ++i) { + ResultBodyPtr aSubRes = theResultBody->subResult(i); + GeomShapePtr aShape = aSubRes->shape(); + ListOfShape::iterator aNewIt = aNewShapes.begin(); + for (; aNewIt != aNewShapes.end(); ++aNewIt) + if (aShape->isSubShape(*aNewIt, false)) + break; + if (aNewIt != aNewShapes.end()) { + // store from/to shapes as primitives and then store modification of them by the boolean + aSubRes->generated(aSubShape, theName, false); + aSubRes->loadModifiedShapes(theMakeShape, aSubShape, theType); + } + } + } + else { + // store from/to shapes as primitives and then store modification of them by the boolean + theResultBody->generated(aSubShape, theName, false); + theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType); + } + } + } +} + +//================================================================================================= +void FeaturesPlugin_CompositeSketch::attributeChanged(const std::string& theID) +{ + if (theID == BASE_OBJECTS_ID()) { + AttributeSelectionListPtr anObjects = selectionList(BASE_OBJECTS_ID()); + if (anObjects->size() == 0 || anObjects->selectionType() != myCurrentSelectionType) { + myCurrentSelectionType = anObjects->selectionType(); + removeResults(0); // clear the results } } }