1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0028642: BRepOffsetAPI_ThruSections/BRepFill_Generator are modifying the input shape sections

1) BRepFill_Generator and BRepOffsetAPI_ThruSections now support 'non-destructive' mode for the input shapes (sections wires). The shape history of this algorithms also has been modified.
2) New test grids (based on the previous ones) have been added. These new cases use locked shapes as input arguments
3) The option '-safe' has been added to 'thrusections' command
This commit is contained in:
isn
2017-04-05 15:16:40 +03:00
committed by smoskvin
parent 71943b31f8
commit 7073768338
88 changed files with 3700 additions and 131 deletions

View File

@@ -503,13 +503,37 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
Surf = surface;
}
//=======================================================================
//function : CreateNewEdge
//purpose :
//=======================================================================
static TopoDS_Edge CreateNewEdge(const TopoDS_Edge& theEdge, TopTools_DataMapOfShapeShape& theCopiedEdges,
const TopoDS_Wire& theWire, TopTools_IndexedMapOfShape& theModifWires)
{
BRep_Builder aBuilder;
TopoDS_Edge aNewEdge;
aNewEdge = TopoDS::Edge(theEdge.EmptyCopied());
TopoDS_Iterator anIterator(theEdge);
for (; anIterator.More(); anIterator.Next())
{
aBuilder.Add(aNewEdge, anIterator.Value());
}
theCopiedEdges.Bind(theEdge, aNewEdge);
if (!theModifWires.Contains(theWire))
{
theModifWires.Add(theWire);
}
return aNewEdge;
}
//=======================================================================
//function : BRepFill_Generator
//purpose :
//=======================================================================
BRepFill_Generator::BRepFill_Generator()
BRepFill_Generator::BRepFill_Generator():
myMutableInput (Standard_True)
{
}
@@ -541,9 +565,11 @@ void BRepFill_Generator::Perform()
B.MakeShell(myShell);
Standard_Integer Nb = myWires.Length();
TopTools_IndexedMapOfShape aModifWires; //indexed map for debugging
BRepTools_WireExplorer ex1,ex2;
Standard_Boolean aFirstWire = Standard_True;
Standard_Boolean wPoint1, wPoint2, uClosed = Standard_False, DegenFirst = Standard_False, DegenLast = Standard_False;
for ( Standard_Integer i = 1; i <= Nb-1; i++) {
@@ -580,47 +606,51 @@ void BRepFill_Generator::Perform()
Standard_Boolean tantque = ex1.More() && ex2.More();
while ( tantque ) {
while (tantque)
{
TopoDS_Vertex V1f, V1l, V2f, V2l, Vf_toMap, Vl_toMap;
const TopoDS_Edge& anOrEdge1 = TopoDS::Edge(ex1.Current());
const TopoDS_Edge& anOrEdge2 = TopoDS::Edge(ex2.Current());
TopoDS_Vertex V1f,V1l,V2f,V2l, Vf_toMap, Vl_toMap;
Standard_Boolean degen1 = BRep_Tool::Degenerated(anOrEdge1);
Standard_Boolean degen2 = BRep_Tool::Degenerated(anOrEdge2);
Standard_Boolean degen1
= BRep_Tool::Degenerated(TopoDS::Edge(ex1.Current()));
Standard_Boolean degen2
= BRep_Tool::Degenerated(TopoDS::Edge(ex2.Current()));
if ( degen1 ) {
TopoDS_Shape aLocalShape = ex1.Current().EmptyCopied();
Edge1 = TopoDS::Edge(aLocalShape);
// Edge1 = TopoDS::Edge(ex1.Current().EmptyCopied());
// aLocalShape = ex1.Current();
// TopExp::Vertices(TopoDS::Edge(aLocalShape),V1f,V1l);
TopExp::Vertices(TopoDS::Edge(ex1.Current()),V1f,V1l);
V1f.Orientation(TopAbs_FORWARD);
B.Add(Edge1,V1f);
V1l.Orientation(TopAbs_REVERSED);
B.Add(Edge1,V1l);
B.Range(Edge1,0,1);
if (degen1)
{
TopoDS_Shape aLocalShape = anOrEdge1.EmptyCopied();
Edge1 = TopoDS::Edge(aLocalShape);
// Edge1 = TopoDS::Edge(ex1.Current().EmptyCopied());
// aLocalShape = ex1.Current();
// TopExp::Vertices(TopoDS::Edge(aLocalShape),V1f,V1l);
TopExp::Vertices(anOrEdge1, V1f, V1l);
V1f.Orientation(TopAbs_FORWARD);
B.Add(Edge1,V1f);
V1l.Orientation(TopAbs_REVERSED);
B.Add(Edge1,V1l);
B.Range(Edge1,0,1);
myOldNewShapes.Bind(anOrEdge1, Edge1);
}
else {
TopoDS_Shape aLocalShape = ex1.Current();
Edge1 = TopoDS::Edge(aLocalShape);
// Edge1 = TopoDS::Edge(ex1.Current());
else
{
Edge1 = anOrEdge1;
}
if ( degen2 ) {
TopoDS_Shape aLocalShape = ex2.Current().EmptyCopied();
Edge2 = TopoDS::Edge(aLocalShape);
// Edge2 = TopoDS::Edge(ex2.Current().EmptyCopied());
TopExp::Vertices(TopoDS::Edge(ex2.Current()),V2f,V2l);
V2f.Orientation(TopAbs_FORWARD);
B.Add(Edge2,V2f);
V2l.Orientation(TopAbs_REVERSED);
B.Add(Edge2,V2l);
B.Range(Edge2,0,1);
if (degen2)
{
TopoDS_Shape aLocalShape = anOrEdge2.EmptyCopied();
Edge2 = TopoDS::Edge(aLocalShape);
// Edge2 = TopoDS::Edge(ex2.Current().EmptyCopied());
TopExp::Vertices(anOrEdge2, V2f, V2l);
V2f.Orientation(TopAbs_FORWARD);
B.Add(Edge2,V2f);
V2l.Orientation(TopAbs_REVERSED);
B.Add(Edge2,V2l);
B.Range(Edge2,0,1);
myOldNewShapes.Bind(anOrEdge2, Edge2);
}
else {
Edge2 = TopoDS::Edge(ex2.Current());
else
{
Edge2 = anOrEdge2;
}
Standard_Boolean Periodic = (BRep_Tool::IsClosed(Edge1) || degen1) &&
@@ -821,32 +851,36 @@ void BRepFill_Generator::Perform()
Map.Bind(Vl_toMap, Edge4);
}
// make the wire
TopoDS_Wire W;
B.MakeWire(W);
if (! (degen1 && IType == 4))
B.Add(W,Edge1);
B.Add(W,Edge4);
if (! (degen2 && IType == 4))
B.Add(W,Edge2.Reversed());
B.Add(W,Edge3);
B.Add(Face,W);
B.Add(myShell,Face);
if (!myMutableInput)
{
if (!degen1) //if true=>already empty-copied
{
const TopoDS_Shape* aNewEd1 = myOldNewShapes.Seek(Edge1);
if (aNewEd1)
{
Edge1 = TopoDS::Edge(*aNewEd1);
}
else if (aFirstWire && (IType != 4 || BRep_Tool::SameParameter(Edge1) || BRep_Tool::SameRange(Edge1)))
{
//if such expression is true and mutableInput is false => pre-copy the edge to prevent a following modifying (see code below)
Edge1 = CreateNewEdge(Edge1, myOldNewShapes, Wire1, aModifWires);
}
}
if (!degen2)
{
const TopoDS_Shape* aNewEd2 = myOldNewShapes.Seek(Edge2);
if (aNewEd2)
{
Edge2 = TopoDS::Edge(*aNewEd2);
}
else if (IType != 4 || BRep_Tool::SameParameter(Edge2) || BRep_Tool::SameRange(Edge2))
{
Edge2 = CreateNewEdge(Edge2, myOldNewShapes, Wire2, aModifWires);
}
}
}
// complete myMap for edge1
if (! (degen1 && IType == 4))
{
TopTools_ListOfShape Empty;
if (!myMap.IsBound(Edge1)) myMap.Bind(Edge1,Empty);
myMap(Edge1).Append(Face);
}
// set the pcurves
Standard_Real T = Precision::Confusion();
if (IType != 4) //not plane
@@ -933,17 +967,98 @@ void BRepFill_Generator::Perform()
B.SameRange(Edge3,Standard_False);
B.SameRange(Edge4,Standard_False);
// make the wire
TopoDS_Wire aWire;
B.MakeWire(aWire);
if (!(degen1 && IType == 4))
{
B.Add(aWire,Edge1);
}
B.Add(aWire,Edge4);
if (!(degen2 && IType == 4))
{
B.Add(aWire,Edge2.Reversed());
}
B.Add(aWire,Edge3);
B.Add(Face,aWire);
B.Add(myShell,Face);
// complete myMap for edge1
if (! (degen1 && IType == 4))
{
TopoDS_Edge aREd = anOrEdge1;
if (degen1)
{
aREd = Edge1;
}
if (!myMap.IsBound(aREd))
{
TopTools_ListOfShape Empty;
myMap.Bind(aREd,Empty);
}
myMap(aREd).Append(Face);
}
tantque = ex1.More() && ex2.More();
if (wPoint1) tantque = ex2.More();
if (wPoint2) tantque = ex1.More();
}
aFirstWire = Standard_False;
}
//all vertices from myShell are the part of orig. section wires
if (myMutableInput)
{
BRepLib::SameParameter(myShell);
}
else
{
TopTools_DataMapIteratorOfDataMapOfShapeShape aMapIt(myOldNewShapes);
for (;aMapIt.More();aMapIt.Next())
{
const TopoDS_Shape& aK = aMapIt.Key();
const TopoDS_Shape& aVal = aMapIt.Value();
myReshaper.Replace(aK, aVal);
}
BRepLib::SameParameter(myShell, myReshaper);
myShell = TopoDS::Shell(myReshaper.Apply(myShell));
}
BRepLib::SameParameter(myShell);
if (uClosed && DegenFirst && DegenLast)
{
myShell.Closed(Standard_True);
}
}
//update wire's history
TopoDS_Iterator anItEdge;
for (int i = 1; i <= aModifWires.Extent(); i++)
{
const TopoDS_Shape& aCurWire = aModifWires(i);
TopoDS_Wire aNewWire;
B.MakeWire(aNewWire);
anItEdge.Initialize(aCurWire);
for (;anItEdge.More();anItEdge.Next())
{
const TopoDS_Shape& aCurEdge = anItEdge.Value(); //edges only
const TopoDS_Shape& aNewEdge = ResultShape(aCurEdge);
B.Add(aNewWire, aNewEdge);
}
aNewWire.Free(aCurWire.Free());
aNewWire.Modified(aCurWire.Modified());
aNewWire.Checked(aCurWire.Checked());
aNewWire.Orientable(aCurWire.Orientable());
aNewWire.Closed(aCurWire.Closed());
aNewWire.Infinite(aCurWire.Infinite());
aNewWire.Convex(aCurWire.Convex());
myOldNewShapes.Bind(aCurWire, aNewWire);
}
}
//=======================================================================
//function : GeneratedShapes
@@ -972,4 +1087,38 @@ const TopTools_DataMapOfShapeListOfShape& BRepFill_Generator::Generated() const
return myMap;
}
//=======================================================================
//function : ResultShape
//purpose :
//=======================================================================
TopoDS_Shape BRepFill_Generator::ResultShape (const TopoDS_Shape& theShape) const
{
const TopoDS_Shape* aShape = myOldNewShapes.Seek(theShape);
TopoDS_Shape aNewShape = aShape ? *aShape : theShape;
TopoDS_Shape aPrevShape;
do
{
aPrevShape = aNewShape;
aNewShape = myReshaper.Value(aNewShape);
}
while (aNewShape != aPrevShape);
return aNewShape;
}
//=======================================================================
//function : SetMutableInput
//purpose :
//=======================================================================
void BRepFill_Generator::SetMutableInput(const Standard_Boolean theIsMutableInput)
{
myMutableInput = theIsMutableInput;
}
//=======================================================================
//function : IsMutableInput
//purpose :
//=======================================================================
Standard_Boolean BRepFill_Generator::IsMutableInput() const
{
return myMutableInput;
}