X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_ResultConstruction.cpp;h=103c5425904bf65d8e8bb299ee2a43c6f5bda36b;hb=b0196aeefbaa53754b1052fab904386707caad87;hp=87fe4c5ed6bbc73c6019ab58a98d69830e04d49e;hpb=e40b79a40fe27c188aa1c49643559be328bbcb06;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 87fe4c5ed..103c54259 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -65,8 +66,10 @@ void Model_ResultConstruction::setShape(std::shared_ptr theShape) if (myShape != theShape) { if (!isInfinite()) storeShape(theShape); - static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + if (!theShape.get() || !theShape->isEqual(myShape)) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + } myShape = theShape; } } @@ -100,7 +103,7 @@ bool Model_ResultConstruction::updateShape() { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData && aData->isValid()) { - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); Handle(TNaming_NamedShape) aNS; if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { TopoDS_Shape aShape = aNS->Get(); @@ -164,7 +167,7 @@ int Model_ResultConstruction::facesNum(const bool theUpdateNaming) int aResult = 0; std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData.get() && aData->isValid()) { - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); TDF_ChildIDIterator anOldIter(aShapeLab, TDataStd_IntPackedMap::GetID()); for (; anOldIter.More(); anOldIter.Next()) { aResult++; @@ -179,7 +182,7 @@ std::shared_ptr Model_ResultConstruction::face(const int theIndex) int anIndex = 0; std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData.get() && aData->isValid()) { - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); TDF_ChildIDIterator anOldIter(aShapeLab, TDataStd_IntPackedMap::GetID()); for (; anOldIter.More(); anOldIter.Next()) { if (anIndex == theIndex) { @@ -205,7 +208,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData && aData->isValid()) { std::string aMyName = data()->name(); - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); if (!theShape.get() || theShape->isNull()) { aShapeLab.ForgetAllAttributes(); TDataStd_Name::Set(aShapeLab, aMyName.c_str()); // restore name forgotten @@ -227,10 +230,10 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap TopExp_Explorer anExp(aShape, TopAbs_VERTEX); for(int anIndex = 1; anExp.More(); anExp.Next(), anIndex++) { - TDF_Label aSubLab = aShapeLab.FindChild(anIndex);; + TDF_Label aSubLab = aShapeLab.FindChild(anIndex); TNaming_Builder aBuilder(aSubLab); aBuilder.Generated(anExp.Current()); - std::string aVertexName = anIndex == 1 ? "StartVertex" : "EndVertex"; + std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex"); TDataStd_Name::Set(aSubLab, aVertexName.c_str()); aMyDoc->addNamingName(aSubLab, aVertexName); } @@ -273,14 +276,15 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap std::list > aFaces; GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), aWirePtr->norm(), aWirePtr, aFaces); - NCollection_DataMap aNewIndices; // edges indices + // order is important to store faces in the same order if sketch is created from scratch + NCollection_IndexedDataMap aNewIndices; // edges indices std::list >::iterator aFIter = aFaces.begin(); for (; aFIter != aFaces.end(); aFIter++) { std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); // put them to a label, trying to keep the same faces on the same labels if (aFace.get() && !aFace->isNull()) { TopoDS_Face aTopoFace = TopoDS::Face(aFace->impl()); - aNewIndices.Bind(aTopoFace, TColStd_ListOfInteger()); + aNewIndices.Add(aTopoFace, TColStd_ListOfInteger()); // keep new indices of sub-elements used in this face for (TopExp_Explorer anEdges(aTopoFace, TopAbs_EDGE); anEdges.More(); anEdges.Next()) { TopoDS_Edge anEdge = TopoDS::Edge(anEdges.Current()); @@ -290,7 +294,7 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap int anIndex = aCurvesIndices.Find(aCurve); if ((aFirst > aLast) != (anEdge.Orientation() == TopAbs_REVERSED)) anIndex = -anIndex; - aNewIndices.ChangeFind(aTopoFace).Append(anIndex); + aNewIndices.ChangeFromKey(aTopoFace).Append(anIndex); } } } @@ -298,7 +302,8 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap NCollection_DataMap aFacesOrder; // faces -> tag where they must be set NCollection_List anUnorderedFaces; // faces that may be located at any index // searching for the best new candidate to old location - NCollection_DataMap::Iterator aNewIter(aNewIndices); + NCollection_IndexedDataMap::Iterator + aNewIter(aNewIndices); for (; aNewIter.More(); aNewIter.Next()) { double aBestFound = 0, aBestNotFound = 1.e+100; int aBestTag = 0; @@ -367,33 +372,51 @@ void Model_ResultConstruction::storeShape(std::shared_ptr theShap aFaceBuilder.Generated(aFaceToPut); // store also indices of the new face edges Handle(TDataStd_IntPackedMap) aNewMap = TDataStd_IntPackedMap::Set(aLab); - const TColStd_ListOfInteger& aNewInd = aNewIndices.Find(aFaceToPut); + const TColStd_ListOfInteger& aNewInd = aNewIndices.FindFromKey(aFaceToPut); std::stringstream aName; aName<<"Face"; TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE); TNaming_Builder* anEdgesBuilder = 0; for(TColStd_ListOfInteger::Iterator anIter(aNewInd); anIter.More(); anIter.Next()) { int anIndex = anIter.Value(); + int aModIndex = anIndex > 0 ? anIndex : -anIndex; aNewMap->Add(anIndex); - aName<<"-"< 0 ? anIndex : -anIndex]; + aName<<"-"< 0) aName<<"f"; else aName<<"r"; // collect all edges of the face which are modified in sub-label of the face - if (anEdgeIndices.IsBound(anIndex) && - !aFaceEdges.Contains(anEdgeIndices.Find(anIndex))) { + if (anEdgeIndices.IsBound(aModIndex) && + !aFaceEdges.Contains(anEdgeIndices.Find(aModIndex))) { if (!anEdgesBuilder) { TDF_Label anEdgesLabel = aLab.FindChild(1); anEdgesBuilder = new TNaming_Builder(anEdgesLabel); - TDataStd_Name::Set(anEdgesLabel, "SubEdge"); + std::ostringstream aSubName; + // tag is needed for Test1922 to distinguish subedges of different faces + aSubName<<"SubEdge_"<Modify(anEdgeIndices.Find(anIndex), aPutEdges.Current()); + anEdgesBuilder->Modify(anEdgeIndices.Find(aModIndex), aPutEdges.Current()); } aPutEdges.Next(); } 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 + 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<<"_"<addNamingName(aWireLab, aWireName.str()); + aWireTag++; + } } } }