- else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) {
- // load faces and all the free edges
- TopTools_IndexedMapOfShape Faces;
- TopExp::MapShapes(aShape, TopAbs_FACE, Faces);
- if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) {
- TopExp_Explorer expl(aShape, TopAbs_FACE);
- for (; expl.More(); expl.Next()) {
- builder(theTag)->Generated(expl.Current());
- TCollection_AsciiString aStr(theTag);
- aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- theTag++;
- }
- }
- TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces;
- TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, anEdgeAndNeighbourFaces);
- for (Standard_Integer i = 1; i <= anEdgeAndNeighbourFaces.Extent(); i++)
- {
- const TopTools_ListOfShape& aLL = anEdgeAndNeighbourFaces.FindFromIndex(i);
- if (aLL.Extent() < 2) {
- if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeAndNeighbourFaces.FindKey(i))))
- continue;
- builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
- TCollection_AsciiString aStr(theTag);
- aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- theTag++;
- } else {
- TopTools_ListIteratorOfListOfShape anIter(aLL);
- const TopoDS_Face& aFace = TopoDS::Face(anIter.Value());
- anIter.Next();
- if(aFace.IsEqual(anIter.Value())) {
- builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i));
- TCollection_AsciiString aStr(theTag);
- aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- theTag++;
- }
- }
- }
- } else if (aShape.ShapeType() == TopAbs_WIRE) {
- TopTools_IndexedMapOfShape Edges;
- BRepTools::Map3DEdges(aShape, Edges);
- if (Edges.Extent() == 1) {
- builder(++theTag)->Generated(Edges.FindKey(1));
- TopExp_Explorer expl(aShape, TopAbs_VERTEX);
- for (; expl.More(); expl.Next()) {
- builder(theTag)->Generated(expl.Current());
- TCollection_AsciiString aStr(theTag);
- aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- theTag++;
- }
- } else {
- TopExp_Explorer expl(aShape, TopAbs_EDGE);
- for (; expl.More(); expl.Next()) {
- builder(theTag)->Generated(expl.Current());
- TCollection_AsciiString aStr(theTag);
- aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- theTag++;
- }
- // and load generated vertices.
- TopTools_DataMapOfShapeShape generated;
- if (getDangleShapes(aShape, TopAbs_EDGE, generated))
- {
- TNaming_Builder* pBuilder = builder(theTag++);
- loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder);
- }
- }
- } else if (aShape.ShapeType() == TopAbs_EDGE) {
- TopExp_Explorer expl(aShape, TopAbs_VERTEX);
- for (; expl.More(); expl.Next()) {
- builder(theTag)->Generated(expl.Current());
- TCollection_AsciiString aStr(theTag);
- aName = theName + aStr.ToCString();
- buildName(theTag, aName);
- theTag++;
- }
+ // iterate all sub-solids of compsolid to make sub-results synchronized with them
+ TopoDS_Shape aThisShape;
+ if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
+ if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
+ aThisShape.ShapeType() == TopAbs_COMPOUND)) {
+ bool aWasEmpty = mySubs.empty();
+ Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
+ unsigned int aSubIndex = 0;
+ TopoDS_Iterator aShapesIter(aThisShape);
+ for(; aShapesIter.More(); aShapesIter.Next(), aSubIndex++) {
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(aShapesIter.Value()));
+ ResultBodyPtr aSub;
+ if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
+ std::wstring thenameshape = L"";
+ // find shape name read
+ for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
+ myNamesShape.begin();
+ it != myNamesShape.end();
+ ++it)
+ {
+ TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
+ if (!(aShapesIter.Value().IsSame(curSelectedShape))) continue;
+ thenameshape = (*it).first;
+ break;
+ }
+ aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape);
+ //finf color read
+ std::map< std::wstring, std::vector<int>>::iterator itColor =
+ myColorsShape.find(thenameshape);
+ if (itColor != myColorsShape.end()){
+ ModelAPI_Tools::setColor(aSub,(*itColor).second);
+ }
+ aSub->setShapeName(myNamesShape,myColorsShape);
+ mySubs.push_back(aSub);
+ mySubsMap[aSub] = int(mySubs.size() - 1);
+ if (isConcealed()) { // for issue #2579 note7
+ aSub->ModelAPI_ResultBody::setIsConcealed(true);
+ std::dynamic_pointer_cast<Model_ResultBody>(aSub)->updateConcealment();
+ }
+
+ } else { // just update shape of this result
+ aSub = mySubs[aSubIndex];
+ }
+ GeomShapePtr anOldSubShape = aSub->shape();
+ if (!aShape->isEqual(anOldSubShape)) {
+ if (myAlgo.get()) {
+ std::list<GeomShapePtr> anOldForSub;
+ computeOldForSub(aShape, myOlds, anOldForSub);
+ myIsGenerated ? aSub->storeGenerated(anOldForSub, aShape, myAlgo) :
+ aSub->storeModified(anOldForSub, aShape, myAlgo);
+ } else {
+ aSub->store(aShape, false);
+ }
+ aECreator->sendUpdated(aSub, EVENT_DISP);
+ aECreator->sendUpdated(aSub, EVENT_UPD);
+ }
+ aSub->setDisabled(aSub, isDisabled());
+ }
+ // erase left, unused results
+ while(mySubs.size() > aSubIndex) {
+ ResultBodyPtr anErased = *(mySubs.rbegin());
+ if (anErased->ModelAPI_ResultBody::isConcealed()) {
+ anErased->ModelAPI_ResultBody::setIsConcealed(false);
+ std::dynamic_pointer_cast<Model_ResultBody>(anErased)->updateConcealment();
+ }
+ anErased->setDisabled(anErased, true);
+ mySubsMap.erase(anErased);
+ mySubs.pop_back();
+ }
+ if (aWasEmpty) { // erase all subs
+ // redisplay this because result with and without subs are displayed differently
+ aECreator->sendUpdated(data()->owner(), EVENT_DISP);
+ }
+ cleanCash();
+ } else if (!mySubs.empty()) { // erase all subs
+ while(!mySubs.empty()) {
+ ResultBodyPtr anErased = *(mySubs.rbegin());
+ if (anErased->ModelAPI_ResultBody::isConcealed()) {
+ anErased->ModelAPI_ResultBody::setIsConcealed(false);
+ std::dynamic_pointer_cast<Model_ResultBody>(anErased)->updateConcealment();
+ }
+ anErased->setDisabled(anErased, true); // even if it is invalid (to erase subs on abort/undo)
+ mySubs.pop_back();
+ }
+ mySubsMap.clear();
+ // redisplay this because result with and without subs are displayed differently
+ aECreator->sendUpdated(data()->owner(), EVENT_DISP);