1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

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().
This commit is contained in:
abk
2017-04-25 15:27:33 +03:00
committed by bugmaster
parent 98ffe9dfdf
commit 654c48b2b9
9 changed files with 123 additions and 238 deletions

View File

@@ -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<SubSequenceOfEdges> 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();
if (!myHistory.IsNull())
{
myHistory->Merge(myContext->History());
for (TopTools_MapOfShape::Iterator aIt(myRemoved);
aIt.More(); aIt.Next())
{
myHistory->Remove(aIt.Value());
}
}
//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);
}
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);
}

View File

@@ -17,6 +17,7 @@
#ifndef _ShapeUpgrade_UnifySameDomain_HeaderFile
#define _ShapeUpgrade_UnifySameDomain_HeaderFile
#include <BRepTools_History.hxx>
#include <Standard.hxx>
#include <Standard_Type.hxx>
@@ -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: <br>
//! - set a place holder for the history of the changing of the sub-shapes of
//! the initial shape; <br>
//! - get the collected history. <br>
//! 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 <aShape> 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 <aShape> 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 <aShape> has been deleted. The
//! result shape of the operation does not contain even trace of <aShape>.
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;
};