From 654c48b2b99bc127661ad6842a77f5a45b2143f3 Mon Sep 17 00:00:00 2001 From: abk Date: Tue, 25 Apr 2017 15:27:33 +0300 Subject: [PATCH] 0028710: Implement 'BRepTools_History' history for algorithm 'ShapeUpgrade_UnifySameDomain' 'BRepTools_History' history was implemented for algorithm 'ShapeUpgrade_UnifySameDomain'. The history of the changing of the initial shape was corrected to consider all shapes created by the algorithm as modified shapes instead of generated ones. The old history interface was replaced by the new one: - to get the modified shapes use: History()->Modified(); - to check if the shapes has been deleted use: History()->IsRemoved(). --- dox/dev_guides/upgrade/upgrade.md | 6 + src/BOPAlgo/BOPAlgo_CellsBuilder.cxx | 58 ++++---- src/BOPAlgo/BOPAlgo_CellsBuilder.hxx | 4 +- .../BRepOffsetAPI_MiddlePath.cxx | 16 +-- src/SWDRAW/SWDRAW_ShapeUpgrade.cxx | 46 +----- .../ShapeUpgrade_UnifySameDomain.cxx | 136 ++++++------------ .../ShapeUpgrade_UnifySameDomain.hxx | 49 ++++--- tests/bugs/heal/bug26489_4 | 6 +- tests/heal/unify_same_domain/A4 | 38 ++--- 9 files changed, 122 insertions(+), 237 deletions(-) diff --git a/dox/dev_guides/upgrade/upgrade.md b/dox/dev_guides/upgrade/upgrade.md index ed2f82c401..3ba4a0efd1 100644 --- a/dox/dev_guides/upgrade/upgrade.md +++ b/dox/dev_guides/upgrade/upgrade.md @@ -1396,3 +1396,9 @@ if (anError != Storage_VSOk) Since 7.2.0 version, method *IsPeriodic()* returns the corresponding status of periodicity of the basis curve regardless of closure status of the adaptor curve (see method *IsClosed()*). Method *IsClosed()* for adaptor can return false even on periodic curve, in the case if its parametric range is not full period, e.g. for adaptor on circle in range [0, @f$ \pi @f$]. In previous versions, *IsPeriodic()* always returned false if *IsClosed()* returned false. + +@subsection upgrade_720_persistence Change in algorithm ShapeUpgrade_UnifySameDomain + +The history of the changing of the initial shape was corrected: +* all shapes created by the algorithm are considered as modified shapes instead of generated ones; +* method Generated was removed and its calls should be replaced by calls of method History()->Modified. diff --git a/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx b/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx index 0b89357ebf..f725224027 100644 --- a/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx +++ b/src/BOPAlgo/BOPAlgo_CellsBuilder.cxx @@ -48,7 +48,7 @@ BOPAlgo_CellsBuilder::BOPAlgo_CellsBuilder() myIndex(100, myAllocator), myMaterials(100, myAllocator), myShapeMaterial(100, myAllocator), - myMapGenerated(100, myAllocator) + myMapModified(100, myAllocator) { } @@ -63,7 +63,7 @@ BOPAlgo_CellsBuilder::BOPAlgo_CellsBuilder myIndex(100, myAllocator), myMaterials(100, myAllocator), myShapeMaterial(100, myAllocator), - myMapGenerated(100, myAllocator) + myMapModified(100, myAllocator) { } @@ -86,7 +86,7 @@ void BOPAlgo_CellsBuilder::Clear() myIndex.Clear(); myMaterials.Clear(); myShapeMaterial.Clear(); - myMapGenerated.Clear(); + myMapModified.Clear(); } //======================================================================= @@ -312,7 +312,7 @@ void BOPAlgo_CellsBuilder::AddAllToResult(const Standard_Integer theMaterial, { myShapeMaterial.Clear(); myMaterials.Clear(); - myMapGenerated.Clear(); + myMapModified.Clear(); // myShape = myAllParts; // @@ -435,7 +435,7 @@ void BOPAlgo_CellsBuilder::RemoveAllFromResult() // myMaterials.Clear(); myShapeMaterial.Clear(); - myMapGenerated.Clear(); + myMapModified.Clear(); // PrepareHistory(); } @@ -760,7 +760,7 @@ Standard_Boolean BOPAlgo_CellsBuilder::RemoveInternals(const BOPCol_ListOfShape& return bRemoved; } // - // fill map of generated shapes + // fill map of modified shapes BOPCol_IndexedMapOfShape aMG; Standard_Integer i, aNb; // @@ -771,20 +771,12 @@ Standard_Boolean BOPAlgo_CellsBuilder::RemoveInternals(const BOPCol_ListOfShape& aNb = aMG.Extent(); for (i = 1; i <= aNb; ++i) { const TopoDS_Shape& aSS = aMG(i); - const TopTools_ListOfShape& aLSGen = anUnify.Generated(aSS); - TopTools_ListIteratorOfListOfShape aIt(aLSGen); + const TopTools_ListOfShape& aLSMod = anUnify.History()->Modified(aSS); + TopTools_ListIteratorOfListOfShape aIt(aLSMod); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aSU = aIt.Value(); if (!aSU.IsNull() && !aSS.IsSame(aSU)) { - myMapGenerated.Bind(aSS, aSU); - bRemoved = Standard_True; - } - } - const TopTools_ListOfShape& aLSMod = anUnify.Modified(aSS); - for (aIt.Init(aLSMod); aIt.More(); aIt.Next()) { - const TopoDS_Shape& aSU = aIt.Value(); - if (!aSU.IsNull() && !aSS.IsSame(aSU)) { - myMapGenerated.Bind(aSS, aSU); + myMapModified.Bind(aSS, aSU); bRemoved = Standard_True; } } @@ -907,17 +899,17 @@ Standard_Boolean BOPAlgo_CellsBuilder::IsDeleted(const TopoDS_Shape& theS) return bRet; } // - Standard_Boolean bHasImage, bHasGenerated; + Standard_Boolean bHasImage, bHasModified; // bHasImage = myImages.IsBound(theS); - bHasGenerated = myMapGenerated.IsBound(theS); - if (!bHasImage && !bHasGenerated) { + bHasModified = myMapModified.IsBound(theS); + if (!bHasImage && !bHasModified) { bRet = !myMapShape.Contains(theS); return bRet; } // - if (bHasGenerated) { - const TopoDS_Shape& aSG = myMapGenerated.Find(theS); + if (bHasModified) { + const TopoDS_Shape& aSG = myMapModified.Find(theS); if (myMapShape.Contains(aSG)) { bRet = Standard_False; return bRet; @@ -932,8 +924,8 @@ Standard_Boolean BOPAlgo_CellsBuilder::IsDeleted(const TopoDS_Shape& theS) const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ? myShapesSD.Find(aSp) : aSp; // - const TopoDS_Shape& aSpRG = myMapGenerated.IsBound(aSpR) ? - myMapGenerated.Find(aSpR) : aSpR; + const TopoDS_Shape& aSpRG = myMapModified.IsBound(aSpR) ? + myMapModified.Find(aSpR) : aSpR; if (myMapShape.Contains(aSpRG)) { bRet = Standard_False; break; @@ -945,10 +937,10 @@ Standard_Boolean BOPAlgo_CellsBuilder::IsDeleted(const TopoDS_Shape& theS) } //======================================================================= -//function : Generated +//function : Modified //purpose : //======================================================================= -const TopTools_ListOfShape& BOPAlgo_CellsBuilder::Generated(const TopoDS_Shape& theS) +const TopTools_ListOfShape& BOPAlgo_CellsBuilder::Modified(const TopoDS_Shape& theS) { myHistShapes.Clear(); if (theS.IsNull()) { @@ -960,9 +952,9 @@ const TopTools_ListOfShape& BOPAlgo_CellsBuilder::Generated(const TopoDS_Shape& return myHistShapes; } // - Standard_Boolean bHasGenerated = myMapGenerated.IsBound(theS); - if (bHasGenerated) { - const TopoDS_Shape& aSG = myMapGenerated.Find(theS); + Standard_Boolean bHasModified = myMapModified.IsBound(theS); + if (bHasModified) { + const TopoDS_Shape& aSG = myMapModified.Find(theS); if (myMapShape.Contains(aSG)) { myHistShapes.Append(aSG); } @@ -982,14 +974,18 @@ const TopTools_ListOfShape& BOPAlgo_CellsBuilder::Generated(const TopoDS_Shape& const TopoDS_Shape& aSpR = myShapesSD.IsBound(aSp) ? myShapesSD.Find(aSp) : aSp; // - if (myMapGenerated.IsBound(aSpR)) { - const TopoDS_Shape& aSG = myMapGenerated.Find(aSpR); + if (myMapModified.IsBound(aSpR)) { + const TopoDS_Shape& aSG = myMapModified.Find(aSpR); if (myMapShape.Contains(aSG)) { if (aMFence.Add(aSG)) { myHistShapes.Append(aSG); } } } + else if (aMFence.Add(aSpR)) + { + myHistShapes.Append(aSpR); + } } // return myHistShapes; diff --git a/src/BOPAlgo/BOPAlgo_CellsBuilder.hxx b/src/BOPAlgo/BOPAlgo_CellsBuilder.hxx index ec0bee9614..6339a9970e 100644 --- a/src/BOPAlgo/BOPAlgo_CellsBuilder.hxx +++ b/src/BOPAlgo/BOPAlgo_CellsBuilder.hxx @@ -237,7 +237,7 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder Standard_EXPORT void MakeContainers(); //! Returns the list of shapes generated from the shape theS. - Standard_EXPORT virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) Standard_OVERRIDE; + Standard_EXPORT virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) Standard_OVERRIDE; //! Returns true if the shape theS has been deleted. Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& theS) Standard_OVERRIDE; @@ -287,7 +287,7 @@ class BOPAlgo_CellsBuilder : public BOPAlgo_Builder BOPCol_IndexedDataMapOfShapeListOfShape myIndex; BOPCol_DataMapOfIntegerListOfShape myMaterials; BOPCol_DataMapOfShapeInteger myShapeMaterial; - BOPCol_DataMapOfShapeShape myMapGenerated; + BOPCol_DataMapOfShapeShape myMapModified; private: diff --git a/src/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx b/src/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx index 112713abd4..9bb864cad0 100644 --- a/src/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx +++ b/src/BRepOffsetAPI/BRepOffsetAPI_MiddlePath.cxx @@ -270,11 +270,10 @@ static TopoDS_Wire GetUnifiedWire(const TopoDS_Wire& theWire, for (; wexp.More(); wexp.Next()) { TopoDS_Shape anEdge = wexp.Current(); - const TopTools_ListOfShape& aLSG = theUnifier.Generated(anEdge); - // take care of processing the result of Generated() before getting Modified() - Standard_Boolean isEmpty = aLSG.IsEmpty(); - if (!isEmpty) { - TopTools_ListIteratorOfListOfShape anIt(aLSG); + const TopTools_ListOfShape& aLS = theUnifier.History()->Modified(anEdge); + if (!aLS.IsEmpty()) + { + TopTools_ListIteratorOfListOfShape anIt(aLS); for (; anIt.More(); anIt.Next()) { const TopoDS_Shape& aShape = anIt.Value(); //wire shouldn't contain duplicated generated edges @@ -282,12 +281,11 @@ static TopoDS_Wire GetUnifiedWire(const TopoDS_Wire& theWire, aWMaker.Add(TopoDS::Edge(aShape)); } } - const TopTools_ListOfShape& aLSM = theUnifier.Modified(anEdge); - if (!aLSM.IsEmpty()) - aWMaker.Add(aLSM); - else if (isEmpty) + else + { // no change, put original edge aWMaker.Add(TopoDS::Edge(anEdge)); + } } return aWMaker.Wire(); } diff --git a/src/SWDRAW/SWDRAW_ShapeUpgrade.cxx b/src/SWDRAW/SWDRAW_ShapeUpgrade.cxx index c39067b258..82ad8b20fd 100644 --- a/src/SWDRAW/SWDRAW_ShapeUpgrade.cxx +++ b/src/SWDRAW/SWDRAW_ShapeUpgrade.cxx @@ -1364,43 +1364,6 @@ static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, c return 0; } -Standard_Integer unifysamedomgen(Draw_Interpretor& di, - Standard_Integer n, - const char** a) -{ - if (n != 3) { - di << "use unifysamedomgen newshape oldshape\n"; - return 0; - } - TopoDS_Shape aShape; - aShape = DBRep::Get(a[2]); - if (aShape.IsNull()) { - di << "Null shape is not allowed here\n"; - return 1; - } - - const TopTools_ListOfShape& aLS = Unifier().Generated(aShape); - - if (aLS.Extent() > 1) { - BRep_Builder aBB; - TopoDS_Compound aRes; - aBB.MakeCompound(aRes); - TopTools_ListIteratorOfListOfShape aIt(aLS); - for (; aIt.More(); aIt.Next()) { - const TopoDS_Shape& aCurrentShape = aIt.Value(); - aBB.Add(aRes, aCurrentShape); - } - DBRep::Set(a[1], aRes); - } - else if (aLS.Extent() == 1) { - DBRep::Set(a[1], aLS.First()); - } - else { - di << "No shapes were generated from the shape\n"; - } - return 0; -} - Standard_Integer unifysamedommod(Draw_Interpretor& di, Standard_Integer n, const char** a) @@ -1416,7 +1379,7 @@ Standard_Integer unifysamedommod(Draw_Interpretor& di, return 1; } - const TopTools_ListOfShape& aLS = Unifier().Modified(aShape); + const TopTools_ListOfShape& aLS = Unifier().History()->Modified(aShape); if (aLS.Extent() > 1) { BRep_Builder aBB; @@ -1451,7 +1414,7 @@ Standard_Integer unifysamedomisdel(Draw_Interpretor& di, di << "Null shape is not allowed here\n"; return 1; } - Standard_Boolean IsDeleted = Unifier().IsDeleted(aShape); + Standard_Boolean IsDeleted = Unifier().History()->IsRemoved(aShape); di << "The shape has" << (IsDeleted ? " " : " not ") << "been deleted" << "\n"; return 0; } @@ -1665,11 +1628,6 @@ Standard_Integer reshape(Draw_Interpretor& di, theCommands.Add ("unifysamedom", "unifysamedom result shape [s1 s2 ...] [-f] [-e] [-nosafe] [+b] [+i] [-t val] [-a val]", __FILE__,unifysamedom,g); - - theCommands.Add("unifysamedomgen", - "unifysamedomgen newshape oldshape : get new shape generated " - "by unifysamedom command from the old one", - __FILE__, unifysamedomgen, g); theCommands.Add("unifysamedommod", "unifysamedommod newshape oldshape : get new shape modified " diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index f3b740572f..0c154fa96b 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -1142,10 +1142,8 @@ static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges, const Standard_Boolean ConcatBSplines, const Standard_Boolean isSafeInputMode, Handle(ShapeBuild_ReShape)& theContext, - TopTools_DataMapOfShapeShape& theOldToGeneratedShapes, const TopTools_MapOfShape& nonMergVert, - TopTools_MapOfShape& RemovedShapes, - const TopTools_DataMapOfShapeShape& NewEdges2OldEdges) + TopTools_MapOfShape& theRemovedVertices) { NCollection_Sequence SeqOfSubsSeqOfEdges; if (MergeEdges(SeqEdges, theAngTol, ConcatBSplines, isSafeInputMode, @@ -1155,28 +1153,25 @@ static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges, { if (SeqOfSubsSeqOfEdges(i).UnionEdges.IsNull()) continue; + + theContext->Merge(SeqOfSubsSeqOfEdges(i).SeqsEdges, + SeqOfSubsSeqOfEdges(i).UnionEdges); + ShapeAnalysis_Edge sae; TopoDS_Vertex VF = sae.FirstVertex(SeqOfSubsSeqOfEdges(i).UnionEdges); TopoDS_Vertex VL = sae.LastVertex(SeqOfSubsSeqOfEdges(i).UnionEdges); for (Standard_Integer j = 1; j <= SeqOfSubsSeqOfEdges(i).SeqsEdges.Length(); j++) { const TopoDS_Shape& anOldEdge = SeqOfSubsSeqOfEdges(i).SeqsEdges(j); - const TopoDS_Shape* pOrigEdge = NewEdges2OldEdges.Seek(anOldEdge); - if (!pOrigEdge) - pOrigEdge = &anOldEdge; - theOldToGeneratedShapes.Bind(*pOrigEdge, SeqOfSubsSeqOfEdges(i).UnionEdges); - if (j == 1) - theContext->Replace(anOldEdge, SeqOfSubsSeqOfEdges(i).UnionEdges); - else - theContext->Remove(anOldEdge); TopoDS_Vertex V[2]; TopExp::Vertices(TopoDS::Edge(anOldEdge), V[0], V[1]); - for (int k = 0; k < 2; k++) + for (int k = 0; k < 2; k++) { + TopoDS_Vertex aV = V[k]; if (isSafeInputMode) // vertex might be changed and replaced - V[k] = TopoDS::Vertex(theContext->Apply(V[k])); - if (!V[k].IsEqual(VF) && !V[k].IsEqual(VL)) - RemovedShapes.Add(V[k]); + aV = TopoDS::Vertex(theContext->Apply(aV)); + if (!aV.IsEqual(VF) && !aV.IsEqual(VL)) + theRemovedVertices.Add(V[k]); } } } @@ -1230,7 +1225,8 @@ ShapeUpgrade_UnifySameDomain::ShapeUpgrade_UnifySameDomain() myUnifyEdges (Standard_True), myConcatBSplines (Standard_False), myAllowInternal (Standard_False), - mySafeInputMode(Standard_True) + mySafeInputMode(Standard_True), + myHistory(new BRepTools_History) { myContext = new ShapeBuild_ReShape; } @@ -1252,7 +1248,8 @@ ShapeUpgrade_UnifySameDomain::ShapeUpgrade_UnifySameDomain(const TopoDS_Shape& a myConcatBSplines (ConcatBSplines), myAllowInternal (Standard_False), mySafeInputMode (Standard_True), - myShape (aShape) + myShape (aShape), + myHistory(new BRepTools_History) { myContext = new ShapeBuild_ReShape; } @@ -1274,9 +1271,8 @@ void ShapeUpgrade_UnifySameDomain::Initialize(const TopoDS_Shape& aShape, myConcatBSplines = ConcatBSplines; myContext->Clear(); - myOldToGeneratedShapes.Clear(); + myRemoved.Clear(); myKeepShapes.Clear(); - myRemovedShapes.Clear(); } //======================================================================= @@ -1627,15 +1623,22 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape for (int j = 1; j <= edges.Length(); j++) { TopExp::MapShapes(edges(j), aMapEdgesAndVertexes); } - for (int j = 1; j <= anOldEdges.Extent(); j++) { + + for (int j = 1; j <= anOldEdges.Extent(); j++) + { const TopoDS_Edge& anEdge = TopoDS::Edge(anOldEdges(j)); - if (!aMapEdgesAndVertexes.Contains(anEdge)) { - myRemovedShapes.Add(anEdge); + if (!aMapEdgesAndVertexes.Contains(anEdge)) + { + myRemoved.Add(anEdge); + TopoDS_Vertex V[2]; TopExp::Vertices(anEdge, V[0], V[1]); - for (int k = 0; k < 2; k++) { + for (int k = 0; k < 2; k++) + { if (!aMapEdgesAndVertexes.Contains(V[k])) - myRemovedShapes.Add(V[k]); + { + myRemoved.Add(V[k]); + } } } } @@ -1701,7 +1704,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape if(BRep_Tool::Degenerated(E)) { sewd->Remove(j); isDegRemoved = Standard_True; - myRemovedShapes.Add(E); + myRemoved.Add(E); j--; } } @@ -1838,13 +1841,8 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape myContext->Replace(aCurrent,CompRes); } - // remove the remaining faces - for(i = 1; i <= faces.Length(); i++) - { - myOldToGeneratedShapes.Bind(faces(i), theResult); - if (i > 1) - myContext->Remove(faces(i)); - } + const TopoDS_Shape aResult3 = myContext->Apply(theResult); + myContext->Merge(faces, aResult3); } } // end processing each face @@ -1929,9 +1927,8 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() SeqEdges.Append(expE.Current()); SharedVert.Clear(); CheckSharedVertices(SeqEdges, aMapEdgesVertex, myKeepShapes, SharedVert); - MergeSeq(SeqEdges, myAngTol, myConcatBSplines, mySafeInputMode, - myContext, myOldToGeneratedShapes, SharedVert, - myRemovedShapes, NewEdges2OldEdges); + MergeSeq(SeqEdges, myAngTol, myConcatBSplines, mySafeInputMode, myContext, + SharedVert, myRemoved); } // processing each face @@ -1978,8 +1975,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() SharedVert.Clear(); CheckSharedVertices(SeqEdges, aMapEdgesVertex, myKeepShapes, SharedVert); if (MergeSeq(SeqEdges, myAngTol, myConcatBSplines, mySafeInputMode, - myContext, myOldToGeneratedShapes, SharedVert, - myRemovedShapes, NewEdges2OldEdges)) + myContext, SharedVert, myRemoved)) { TopoDS_Face tmpF = TopoDS::Face(exp.Current()); if ( !ChangedFaces.Contains(tmpF) ) @@ -1995,8 +1991,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges() SharedVert.Clear(); CheckSharedVertices(aNonSharedEdges, aMapEdgesVertex, myKeepShapes, SharedVert); if (MergeSeq(aNonSharedEdges, myAngTol, myConcatBSplines, mySafeInputMode, - myContext, myOldToGeneratedShapes, SharedVert, - myRemovedShapes, NewEdges2OldEdges)) + myContext, SharedVert, myRemoved)) { TopoDS_Face tmpF = TopoDS::Face(exp.Current()); if ( !ChangedFaces.Contains(tmpF) ) @@ -2077,60 +2072,15 @@ void ShapeUpgrade_UnifySameDomain::Build() else if (myUnifyFaces) UnifyFaces(); - //Done(); -} - -//======================================================================= -//function : Shape -//purpose : give the resulting shape -//======================================================================= -const TopoDS_Shape& ShapeUpgrade_UnifySameDomain::Shape() const -{ - return myShape; -} - -//======================================================================= -//function : Generated -//purpose : returns the new shape from the old one -//======================================================================= -const TopTools_ListOfShape& ShapeUpgrade_UnifySameDomain::Generated(const TopoDS_Shape& aShape) -{ - const TopoDS_Shape* aNewShape; - myHistShapes.Clear(); - aNewShape = myOldToGeneratedShapes.Seek(aShape); - if (aNewShape) { - if (myContext->IsRecorded(*aNewShape)) - myHistShapes.Append(myContext->Apply(*aNewShape)); - else - myHistShapes.Append(*aNewShape); - } - return myHistShapes; -} - -//======================================================================= -//function : Modified -//purpose : returns the new modified shape from the old one shape -//======================================================================= -const TopTools_ListOfShape& ShapeUpgrade_UnifySameDomain::Modified(const TopoDS_Shape& aShape) -{ - TopoDS_Shape aNewShape; - Standard_Integer aModifiedStatus; - myHistShapes.Clear(); - if (!myOldToGeneratedShapes.Seek(aShape) && - !myRemovedShapes.Contains(aShape) && - myContext->IsRecorded(aShape)){ - aModifiedStatus = myContext->Status(aShape, aNewShape, Standard_True); - if (aModifiedStatus > 0) - myHistShapes.Append(aNewShape); + if (!myHistory.IsNull()) + { + myHistory->Merge(myContext->History()); + for (TopTools_MapOfShape::Iterator aIt(myRemoved); + aIt.More(); aIt.Next()) + { + myHistory->Remove(aIt.Value()); + } } - return myHistShapes; -} -//======================================================================= -//function : IsDeleted -//purpose : returns true if the shape has been deleted. -//======================================================================= -Standard_Boolean ShapeUpgrade_UnifySameDomain::IsDeleted(const TopoDS_Shape& aShape) -{ - return myRemovedShapes.Contains(aShape); + //Done(); } diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx index e004b0366b..311784affe 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx @@ -17,6 +17,7 @@ #ifndef _ShapeUpgrade_UnifySameDomain_HeaderFile #define _ShapeUpgrade_UnifySameDomain_HeaderFile +#include #include #include @@ -43,13 +44,17 @@ DEFINE_STANDARD_HANDLE(ShapeUpgrade_UnifySameDomain, MMgt_TShared) //! on the BSpline or Bezier curves with C1 continuity on their common vertices will be merged into one common edge //! The output result of tool is an unified shape //! All the modifications of initial shape are recorded during unifying. -//! Method Generated() can be used to obtain the new (unified) shape from the old one +//! Methods History are intended to:
+//! - set a place holder for the history of the changing of the sub-shapes of +//! the initial shape;
+//! - get the collected history.
+//! The algorithm provides a place holder for the history and collects the +//! history by default. +//! To avoid collecting of the history the place holder should be set to the null handle. class ShapeUpgrade_UnifySameDomain : public MMgt_TShared { public: - - //! empty constructor Standard_EXPORT ShapeUpgrade_UnifySameDomain(); @@ -98,23 +103,10 @@ public: Standard_EXPORT void Build(); //! Gives the resulting shape - Standard_EXPORT const TopoDS_Shape& Shape() const; - - //! Returns list of new common shapes from the old one shape. - //! After successful common operation based on list - //! will contain new generated shape. - //! In other cases it will return an empty list - Standard_EXPORT const TopTools_ListOfShape& Generated(const TopoDS_Shape& aShape); - - //! Returns list of new modified shapes. - //! After successful modifying without geometry changes list - //! will contain new modified shape. - //! In other cases it will return an empty list - Standard_EXPORT const TopTools_ListOfShape& Modified(const TopoDS_Shape& aShape); - - //! Returns true if the has been deleted. The - //! result shape of the operation does not contain even trace of . - Standard_EXPORT Standard_Boolean IsDeleted(const TopoDS_Shape& aShape); + const TopoDS_Shape& Shape() const + { + return myShape; + } //! this method makes if possible a common face from each //! group of faces lying on coincident surfaces @@ -127,8 +119,17 @@ public: //! this method unifies same domain faces and edges Standard_EXPORT void UnifyFacesAndEdges(); + //! Returns the history of the processed shapes. + const Handle(BRepTools_History)& History() const + { + return myHistory; + } - + //! Returns the history of the processed shapes. + Handle(BRepTools_History)& History() + { + return myHistory; + } DEFINE_STANDARD_RTTIEXT(ShapeUpgrade_UnifySameDomain,MMgt_TShared) @@ -153,12 +154,10 @@ private: Standard_Boolean mySafeInputMode; TopoDS_Shape myShape; Handle(ShapeBuild_ReShape) myContext; - TopTools_DataMapOfShapeShape myOldToGeneratedShapes; - TopTools_ListOfShape myHistShapes; - TopTools_MapOfShape myRemovedShapes; TopTools_MapOfShape myKeepShapes; - + Handle(BRepTools_History) myHistory; //!< The history. + TopTools_MapOfShape myRemoved; }; diff --git a/tests/bugs/heal/bug26489_4 b/tests/bugs/heal/bug26489_4 index 5d3af85c02..874b9ec2fb 100755 --- a/tests/bugs/heal/bug26489_4 +++ b/tests/bugs/heal/bug26489_4 @@ -15,19 +15,19 @@ explode b1 f vinit vsetdispmode 1 -unifysamedomgen x1 b1_1 +unifysamedommod x1 b1_1 vclear vdisplay x1 vfit vdump ${imagedir}/${casename}_1.png -unifysamedomgen x2 b1_2 +unifysamedommod x2 b1_2 vclear vdisplay x2 vfit vdump ${imagedir}/${casename}_2.png -unifysamedomgen x3 b1_3 +unifysamedommod x3 b1_3 vclear vdisplay x3 vfit diff --git a/tests/heal/unify_same_domain/A4 b/tests/heal/unify_same_domain/A4 index 82b024edf8..fb2965230a 100644 --- a/tests/heal/unify_same_domain/A4 +++ b/tests/heal/unify_same_domain/A4 @@ -14,47 +14,25 @@ explode a e unifysamedom result a a_3 a_1_3 a_1_4 -set bug_info [unifysamedomgen res a_9] +set bug_info [unifysamedommod res a_9] set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] -if {$bug_info != "No shapes were generated from the shape"} { - puts "ERROR: OCC28226 is reproduced. Command unifysamedomgen does not work correctly." -} - -set bug_info [unifysamedomgen res a_10] -if {$bug_info != ""} { - puts "ERROR: OCC28226 is reproduced. Command unifysamedomgen does not work correctly." -} - -set bug_info [unifysamedomgen res a_11] -if {$bug_info != ""} { - puts "ERROR: OCC28226 is reproduced. Command unifysamedomgen does not work correctly." -} - -set bug_info [unifysamedomgen res a_3] -set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] -if {$bug_info != "No shapes were generated from the shape"} { - puts "ERROR: OCC28226 is reproduced. Command unifysamedomgen does not work correctly." -} - -set bug_info [unifysamedommod res a_1] -if {$bug_info != ""} { +if {$bug_info != "The shape has not been modified"} { puts "ERROR: OCC28226 is reproduced. Command unifysamedommod does not work correctly." } -set bug_info [unifysamedommod res a_3] +set bug_info [unifysamedommod res a_10] if {$bug_info != ""} { puts "ERROR: OCC28226 is reproduced. Command unifysamedommod does not work correctly." } -set bug_info [unifysamedommod res a_10] -set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] -if {$bug_info != "The shape has not been modified"} { +set bug_info [unifysamedommod res a_11] +if {$bug_info != ""} { puts "ERROR: OCC28226 is reproduced. Command unifysamedommod does not work correctly." } -set bug_info [unifysamedommod res a_11] +set bug_info [unifysamedommod res a_3] set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] -if {$bug_info != "The shape has not been modified"} { +if {$bug_info != ""} { puts "ERROR: OCC28226 is reproduced. Command unifysamedommod does not work correctly." } @@ -98,7 +76,7 @@ unifysamedom result2 a a_3 a_1_3 a_1_4 -e set bug_info [unifysamedomisdel a_1_8] set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] -if {$bug_info != "The shape has not been deleted"} { +if {$bug_info != "The shape has been deleted"} { puts "ERROR: OCC28226 is reproduced. Command unifysamedomisdel does not work correctly." } -- 2.20.1