X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultConstruction.cpp;h=272cb7338a24527bc298cd3b8807e42d9544fce8;hb=8ca1067287eaaad921a6e08e7d10b875778f8457;hp=103c5425904bf65d8e8bb299ee2a43c6f5bda36b;hpb=464fd2e1a68d874f6affac424c8e5c0c3be012c1;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 103c54259..272cb7338 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -23,11 +23,14 @@ #include #include #include +#include #include #include #include #include #include +#include +#include #include #include @@ -52,7 +55,6 @@ Standard_GUID kIS_INFINITE("dea8cc5a-53f2-49c1-94e8-a947bed20a9f"); // identifier of the result not in history Standard_GUID kIS_IN_HISTORY("a9aec01c-805e-44d1-b5d2-a63f06522f8a"); - void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault) { @@ -64,8 +66,7 @@ void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::str void Model_ResultConstruction::setShape(std::shared_ptr theShape) { if (myShape != theShape) { - if (!isInfinite()) - storeShape(theShape); + storeShape(theShape); if (!theShape.get() || !theShape->isEqual(myShape)) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); @@ -88,7 +89,7 @@ static std::string shortName( aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end()); aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end()); // remove the last 's', 'e', 'f' and 'r' symbols: - // they are used as markers of start/end/forward/rewersed indicators + // they are used as markers of start/end/forward/reversed indicators static const std::string aSyms("sefr"); std::string::iterator aSuffix = aName.end() - 1; while(aSyms.find(*aSuffix) != std::string::npos) { @@ -98,7 +99,6 @@ static std::string shortName( return aName; } - bool Model_ResultConstruction::updateShape() { std::shared_ptr aData = std::dynamic_pointer_cast(data()); @@ -108,9 +108,28 @@ bool Model_ResultConstruction::updateShape() if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { TopoDS_Shape aShape = aNS->Get(); if (!aShape.IsNull()) { + if (aShape.ShapeType() == TopAbs_COMPOUND) { + // restore the sketch planar edges object + std::shared_ptr aBigWire(new GeomAPI_PlanarEdges); + aBigWire->setImpl(new TopoDS_Shape(aShape)); + FeaturePtr aSketch = + document()->feature(std::dynamic_pointer_cast(data()->owner())); + std::shared_ptr anOrigin = + std::dynamic_pointer_cast(aSketch->data()->attribute("Origin")); + std::shared_ptr aDirX = + std::dynamic_pointer_cast(aSketch->data()->attribute("DirX")); + std::shared_ptr aNorm = + std::dynamic_pointer_cast(aSketch->data()->attribute("Norm")); + if (anOrigin.get() && aDirX.get() && aNorm.get()) { + aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir()); + myShape = aBigWire; + return true; + } + } + // just restore shape GeomShapePtr aGShape(new GeomAPI_Shape); aGShape->setImpl(new TopoDS_Shape(aShape)); - myShape = aGShape; // restore the sketch sub-components + myShape = GeomAPI_Tools::getTypedShape(aGShape); // restore the sketch sub-components return true; } } @@ -217,7 +236,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap std::shared_ptr aMyDoc = std::dynamic_pointer_cast(document()); const TopoDS_Shape& aShape = theShape->impl(); - if (aShape.ShapeType() == TopAbs_VERTEX) { + if (isInfinite() || aShape.ShapeType() == TopAbs_VERTEX) { aShapeLab.ForgetAllAttributes(); // clear all previously stored TNaming_Builder aBuilder(aShapeLab); aBuilder.Generated(aShape); @@ -376,7 +395,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap std::stringstream aName; aName<<"Face"; TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE); - TNaming_Builder* anEdgesBuilder = 0; + TNaming_Builder *anEdgesBuilder = 0, *aVerticesBuilder = 0; for(TColStd_ListOfInteger::Iterator anIter(aNewInd); anIter.More(); anIter.Next()) { int anIndex = anIter.Value(); int aModIndex = anIndex > 0 ? anIndex : -anIndex; @@ -393,26 +412,49 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap TDF_Label anEdgesLabel = aLab.FindChild(1); anEdgesBuilder = new TNaming_Builder(anEdgesLabel); std::ostringstream aSubName; - // tag is needed for Test1922 to distinguish subedges of different faces + // tag is needed for Test1922 to distinguish sub-edges of different faces aSubName<<"SubEdge_"<Modify(anEdgeIndices.Find(aModIndex), aPutEdges.Current()); } + // put also modified vertices, otherwise vertex of original edge has no history + if (anEdgeIndices.IsBound(aModIndex)) { + TopExp_Explorer aVExpOld(anEdgeIndices.Find(aModIndex), TopAbs_VERTEX); + TopExp_Explorer aVExpNew(aPutEdges.Current(), TopAbs_VERTEX); + for(; aVExpNew.More() && aVExpOld.More(); aVExpNew.Next(), aVExpOld.Next()) { + if (!aVExpOld.Current().IsSame(aVExpNew.Current())) { + if (!aVerticesBuilder) { + TDF_Label aVertLabel = aLab.FindChild(2); + aVerticesBuilder = new TNaming_Builder(aVertLabel); + std::ostringstream aSubName; + // tag is needed for Test1922 to distinguish sub-edges of different faces + aSubName<<"SubVertex_"<Modify(aVExpOld.Current(), aVExpNew.Current()); + + } + } + } aPutEdges.Next(); } + if (anEdgesBuilder) + delete anEdgesBuilder; + if (aVerticesBuilder) + delete aVerticesBuilder; TDataStd_Name::Set(aLab, TCollection_ExtendedString(aName.str().c_str())); aMyDoc->addNamingName(aLab, aName.str()); // put also wires to sub-labels to correctly select them instead of collection by edges - int aWireTag = 2; // first tag is for SubEdge-s + int aWireTag = 3; // first tag is for SubEdge-s, second - for vertices for(TopExp_Explorer aWires(aFaceToPut, TopAbs_WIRE); aWires.More(); aWires.Next()) { TDF_Label aWireLab = aLab.FindChild(aWireTag); TNaming_Builder aWireBuilder(aWireLab); aWireBuilder.Generated(aWires.Current()); std::ostringstream aWireName; aWireName< 2) - aWireName<<"_"< 3) + aWireName<<"_"<addNamingName(aWireLab, aWireName.str()); aWireTag++;