1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-09 18:50:54 +03:00

0028227: ShapeUpgrade_UnifySameDomain modifies the edges even if it is not requested

- The option SafeInputMode has been added in the class ShapeUpgrade_UnifySameDomain. If it is set then the input shape is protected against modifications of any aspects of its sub-shapes. Default value is true.
- The option "-nosafe" has been added in draw command "unifysamedom". If it is not set the algorithm is run with SafeInputMode switched off.
This commit is contained in:
imn 2017-03-28 16:00:13 +03:00 committed by bugmaster
parent dfde2a3315
commit 632175c3a8
4 changed files with 205 additions and 192 deletions

View File

@ -1289,11 +1289,12 @@ static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, c
{ {
if (n < 3) if (n < 3)
{ {
di << "Use unifysamedom result shape [s1 s2 ...] [-f] [-e] [+b] [+i] [-t val] [-a val]\n"; di << "Use unifysamedom result shape [s1 s2 ...] [-f] [-e] [-nosafe] [+b] [+i] [-t val] [-a val]\n";
di << "options:\n"; di << "options:\n";
di << "s1 s2 ... to keep the given edges during unification of faces\n"; di << "s1 s2 ... to keep the given edges during unification of faces\n";
di << "-f to switch off 'unify-faces' mode \n"; di << "-f to switch off 'unify-faces' mode \n";
di << "-e to switch off 'unify-edges' mode\n"; di << "-e to switch off 'unify-edges' mode\n";
di << "-nosafe to switch off 'safe input shape' mode\n";
di << "+b to switch on 'concat bspline' mode\n"; di << "+b to switch on 'concat bspline' mode\n";
di << "+i to switch on 'allow internal edges' mode\n"; di << "+i to switch on 'allow internal edges' mode\n";
di << "-t val to set linear tolerance\n"; di << "-t val to set linear tolerance\n";
@ -1311,6 +1312,7 @@ static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, c
Standard_Boolean anUEdges = Standard_True; Standard_Boolean anUEdges = Standard_True;
Standard_Boolean anConBS = Standard_False; Standard_Boolean anConBS = Standard_False;
Standard_Boolean isAllowInternal = Standard_False; Standard_Boolean isAllowInternal = Standard_False;
Standard_Boolean isSafeInputMode = Standard_True;
Standard_Real aLinTol = Precision::Confusion(); Standard_Real aLinTol = Precision::Confusion();
Standard_Real aAngTol = Precision::Angular(); Standard_Real aAngTol = Precision::Angular();
TopoDS_Shape aKeepShape; TopoDS_Shape aKeepShape;
@ -1328,6 +1330,8 @@ static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, c
anUFaces = Standard_False; anUFaces = Standard_False;
else if (!strcmp(a[i], "-e")) else if (!strcmp(a[i], "-e"))
anUEdges = Standard_False; anUEdges = Standard_False;
else if (!strcmp(a[i], "-nosafe"))
isSafeInputMode = Standard_False;
else if (!strcmp(a[i], "+b")) else if (!strcmp(a[i], "+b"))
anConBS = Standard_True; anConBS = Standard_True;
else if (!strcmp(a[i], "+i")) else if (!strcmp(a[i], "+i"))
@ -1349,6 +1353,7 @@ static Standard_Integer unifysamedom(Draw_Interpretor& di, Standard_Integer n, c
Unifier().Initialize(aShape, anUEdges, anUFaces, anConBS); Unifier().Initialize(aShape, anUEdges, anUFaces, anConBS);
Unifier().KeepShapes(aMapOfShapes); Unifier().KeepShapes(aMapOfShapes);
Unifier().SetSafeInputMode(isSafeInputMode);
Unifier().AllowInternalEdges(isAllowInternal); Unifier().AllowInternalEdges(isAllowInternal);
Unifier().SetLinearTolerance(aLinTol); Unifier().SetLinearTolerance(aLinTol);
Unifier().SetAngularTolerance(aAngTol); Unifier().SetAngularTolerance(aAngTol);
@ -1658,7 +1663,8 @@ Standard_Integer reshape(Draw_Interpretor& di,
theCommands.Add ("removeloc","result shape [remove_level(see ShapeEnum)]",__FILE__,removeloc,g); theCommands.Add ("removeloc","result shape [remove_level(see ShapeEnum)]",__FILE__,removeloc,g);
theCommands.Add ("unifysamedom", theCommands.Add ("unifysamedom",
"unifysamedom result shape [s1 s2 ...] [-f] [-e] [+b] [+i] [-t val] [-a val]", __FILE__,unifysamedom,g); "unifysamedom result shape [s1 s2 ...] [-f] [-e] [-nosafe] [+b] [+i] [-t val] [-a val]",
__FILE__,unifysamedom,g);
theCommands.Add("unifysamedomgen", theCommands.Add("unifysamedomgen",
"unifysamedomgen newshape oldshape : get new shape generated " "unifysamedomgen newshape oldshape : get new shape generated "

View File

@ -443,17 +443,58 @@ static Standard_Boolean IsSameDomain(const TopoDS_Face& aFace,
return Standard_False; return Standard_False;
} }
//=======================================================================
//function : UpdateMapEdgeFaces
//purpose :
//=======================================================================
static void UpdateMapEdgeFaces(const TopoDS_Face& theFace,
Handle(ShapeBuild_ReShape)& theContext,
TopTools_IndexedDataMapOfShapeListOfShape& theMapEdgeFaces)
{
for (TopExp_Explorer anExp(theFace, TopAbs_EDGE); anExp.More(); anExp.Next()) {
TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current());
TopoDS_Edge aContextEdge = TopoDS::Edge(theContext->Apply(anEdge));
if (aContextEdge == anEdge)
continue;
Standard_Integer anIndex = theMapEdgeFaces.FindIndex(aContextEdge);
if (anIndex == 0)
theMapEdgeFaces.Add(aContextEdge,
theMapEdgeFaces.FindFromKey(anEdge));
else
theMapEdgeFaces.ChangeFromIndex(anIndex).Append(theFace);
}
}
//=======================================================================
//function : UpdateMapOfShapes
//purpose :
//=======================================================================
static void UpdateMapOfShapes(TopTools_MapOfShape& theMapOfShapes,
Handle(ShapeBuild_ReShape)& theContext)
{
for (TopTools_MapIteratorOfMapOfShape it(theMapOfShapes); it.More(); it.Next()) {
const TopoDS_Shape& aShape = it.Value();
TopoDS_Shape aContextShape = theContext->Apply(aShape);
if (!aContextShape.IsSame(aShape))
theMapOfShapes.Add(aContextShape);
}
}
//======================================================================= //=======================================================================
//function : MovePCurves //function : MovePCurves
//purpose : //purpose :
//======================================================================= //=======================================================================
static void MovePCurves(TopoDS_Face& aTarget, static void MovePCurves(TopoDS_Face& aTarget,
const TopoDS_Face& aSource) const TopoDS_Face& aSource,
Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext)
{ {
BRep_Builder B; BRep_Builder B;
for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) {
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()),
aTarget, Precision::Confusion()); aTarget, Precision::Confusion());
if (isSafeInputMode)
sfw->SetContext(theContext);
sfw->FixReorder(); sfw->FixReorder();
Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL );
sfw->FixEdgeCurves(); sfw->FixEdgeCurves();
@ -648,7 +689,12 @@ static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain,
//purpose : Merges a sequence of edges into one edge if possible //purpose : Merges a sequence of edges into one edge if possible
//======================================================================= //=======================================================================
static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, TopoDS_Edge& OutEdge, double Tol, Standard_Boolean ConcatBSplines) static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain,
TopoDS_Edge& OutEdge,
double theAngTol,
Standard_Boolean ConcatBSplines,
Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext)
{ {
ShapeAnalysis_Edge sae; ShapeAnalysis_Edge sae;
BRep_Builder B; BRep_Builder B;
@ -684,7 +730,7 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2);
gp_Dir Dir1 = L1->Position().Direction(); gp_Dir Dir1 = L1->Position().Direction();
gp_Dir Dir2 = L2->Position().Direction(); gp_Dir Dir2 = L2->Position().Direction();
if(!Dir1.IsParallel(Dir2,Tol)) if(!Dir1.IsParallel(Dir2,theAngTol))
IsUnionOfLinesPossible = Standard_False; IsUnionOfLinesPossible = Standard_False;
} }
else else
@ -706,19 +752,31 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
//union of lines is possible //union of lines is possible
if (IsUnionOfLinesPossible) if (IsUnionOfLinesPossible)
{ {
TopoDS_Vertex V1 = sae.FirstVertex(TopoDS::Edge(aChain.First())); TopoDS_Vertex V[2];
gp_Pnt PV1 = BRep_Tool::Pnt(V1); V[0] = sae.FirstVertex(TopoDS::Edge(aChain.First()));
TopoDS_Vertex V2 = sae.LastVertex(TopoDS::Edge(aChain.Last())); gp_Pnt PV1 = BRep_Tool::Pnt(V[0]);
gp_Pnt PV2 = BRep_Tool::Pnt(V2); V[1] = sae.LastVertex(TopoDS::Edge(aChain.Last()));
gp_Pnt PV2 = BRep_Tool::Pnt(V[1]);
gp_Vec Vec(PV1, PV2); gp_Vec Vec(PV1, PV2);
if (isSafeInputMode) {
for (int k = 0; k < 2; k++) {
if (!theContext->IsRecorded(V[k])) {
TopoDS_Vertex Vcopy = TopoDS::Vertex(V[k].EmptyCopied());
theContext->Replace(V[k], Vcopy);
V[k] = Vcopy;
}
else
V[k] = TopoDS::Vertex(theContext->Apply(V[k]));
}
}
Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec));
Standard_Real dist = PV1.Distance(PV2); Standard_Real dist = PV1.Distance(PV2);
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist);
TopoDS_Edge E; TopoDS_Edge E;
B.MakeEdge (E, tc ,Precision::Confusion()); B.MakeEdge (E, tc ,Precision::Confusion());
B.Add (E,V1); B.Add (E,V2); B.Add (E,V[0]); B.Add (E,V[1]);
B.UpdateVertex(V1, 0., E, 0.); B.UpdateVertex(V[0], 0., E, 0.);
B.UpdateVertex(V2, dist, E, 0.); B.UpdateVertex(V[1], dist, E, 0.);
OutEdge = E; OutEdge = E;
return Standard_True; return Standard_True;
} }
@ -736,10 +794,11 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
} }
Handle(Geom_Circle) Cir = Handle(Geom_Circle)::DownCast(c3d); Handle(Geom_Circle) Cir = Handle(Geom_Circle)::DownCast(c3d);
TopoDS_Vertex V1 = sae.FirstVertex(FE); TopoDS_Vertex V[2];
TopoDS_Vertex V2 = sae.LastVertex(TopoDS::Edge(aChain.Last())); V[0] = sae.FirstVertex(FE);
V[1] = sae.LastVertex(TopoDS::Edge(aChain.Last()));
TopoDS_Edge E; TopoDS_Edge E;
if (V1.IsSame(V2)) { if (V[0].IsSame(V[1])) {
// closed chain // closed chain
BRepAdaptor_Curve adef(FE); BRepAdaptor_Curve adef(FE);
Handle(Geom_Circle) Cir1; Handle(Geom_Circle) Cir1;
@ -757,8 +816,8 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
if (Abs(FP) < Precision::PConfusion()) if (Abs(FP) < Precision::PConfusion())
{ {
B.MakeEdge (E,Cir, Precision::Confusion()); B.MakeEdge (E,Cir, Precision::Confusion());
B.Add(E,V1); B.Add(E,V[0]);
B.Add(E,V2); B.Add(E,V[1]);
E.Orientation(FE.Orientation()); E.Orientation(FE.Orientation());
} }
else else
@ -769,13 +828,24 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
else else
return Standard_False; return Standard_False;
B.MakeEdge (E, Cir1, Precision::Confusion()); B.MakeEdge (E, Cir1, Precision::Confusion());
B.Add(E,V1); B.Add(E,V[0]);
B.Add(E,V2); B.Add(E,V[1]);
} }
} }
else { else {
gp_Pnt PV1 = BRep_Tool::Pnt(V1); if (isSafeInputMode) {
gp_Pnt PV2 = BRep_Tool::Pnt(V2); for (int k = 0; k < 2; k++) {
if (!theContext->IsRecorded(V[k])) {
TopoDS_Vertex Vcopy = TopoDS::Vertex(V[k].EmptyCopied());
theContext->Replace(V[k], Vcopy);
V[k] = Vcopy;
}
else
V[k] = TopoDS::Vertex(theContext->Apply(V[k]));
}
}
gp_Pnt PV1 = BRep_Tool::Pnt(V[0]);
gp_Pnt PV2 = BRep_Tool::Pnt(V[1]);
TopoDS_Vertex VM = sae.LastVertex(FE); TopoDS_Vertex VM = sae.LastVertex(FE);
gp_Pnt PVM = BRep_Tool::Pnt(VM); gp_Pnt PVM = BRep_Tool::Pnt(VM);
GC_MakeCircle MC (PV1,PVM,PV2); GC_MakeCircle MC (PV1,PVM,PV2);
@ -802,10 +872,10 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
if (lpar < fpar) lpar += 2*M_PI; if (lpar < fpar) lpar += 2*M_PI;
Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar);
B.MakeEdge (E,tc,Precision::Confusion()); B.MakeEdge (E,tc,Precision::Confusion());
B.Add(E,V1); B.Add(E,V[0]);
B.Add(E,V2); B.Add(E,V[1]);
B.UpdateVertex(V1, fpar, E, 0.); B.UpdateVertex(V[0], fpar, E, 0.);
B.UpdateVertex(V2, lpar, E, 0.); B.UpdateVertex(V[1], lpar, E, 0.);
} }
OutEdge = E; OutEdge = E;
return Standard_True; return Standard_True;
@ -857,7 +927,7 @@ static Standard_Boolean MergeSubSeq(const TopTools_SequenceOfShape& aChain, Topo
//======================================================================= //=======================================================================
static Standard_Boolean IsMergingPossible(const TopoDS_Edge& edge1, const TopoDS_Edge& edge2, static Standard_Boolean IsMergingPossible(const TopoDS_Edge& edge1, const TopoDS_Edge& edge2,
double Tol, const TopTools_MapOfShape& AvoidEdgeVrt) double theAngTol, const TopTools_MapOfShape& AvoidEdgeVrt)
{ {
TopoDS_Vertex CV = TopExp::LastVertex(edge1, Standard_True); TopoDS_Vertex CV = TopExp::LastVertex(edge1, Standard_True);
if (CV.IsNull() || AvoidEdgeVrt.Contains(CV)) if (CV.IsNull() || AvoidEdgeVrt.Contains(CV))
@ -897,7 +967,7 @@ static Standard_Boolean IsMergingPossible(const TopoDS_Edge& edge1, const TopoDS
Diff2 = -Diff2; Diff2 = -Diff2;
} }
if (Diff1.Angle(Diff2) > Tol) if (Diff1.Angle(Diff2) > theAngTol)
return Standard_False; return Standard_False;
return Standard_True; return Standard_True;
@ -911,7 +981,7 @@ static Standard_Boolean IsMergingPossible(const TopoDS_Edge& edge1, const TopoDS
static void GenerateSubSeq (const TopTools_SequenceOfShape& anInpEdgeSeq, static void GenerateSubSeq (const TopTools_SequenceOfShape& anInpEdgeSeq,
NCollection_Sequence<SubSequenceOfEdges>& SeqOfSubSeqOfEdges, NCollection_Sequence<SubSequenceOfEdges>& SeqOfSubSeqOfEdges,
Standard_Boolean IsClosed, double Tol, const TopTools_MapOfShape& AvoidEdgeVrt) Standard_Boolean IsClosed, double theAngTol, const TopTools_MapOfShape& AvoidEdgeVrt)
{ {
Standard_Boolean isOk = Standard_False; Standard_Boolean isOk = Standard_False;
TopoDS_Edge edge1, edge2; TopoDS_Edge edge1, edge2;
@ -924,7 +994,7 @@ static void GenerateSubSeq (const TopTools_SequenceOfShape& anInpEdgeSeq,
{ {
edge1 = TopoDS::Edge(anInpEdgeSeq(i)); edge1 = TopoDS::Edge(anInpEdgeSeq(i));
edge2 = TopoDS::Edge(anInpEdgeSeq(i+1)); edge2 = TopoDS::Edge(anInpEdgeSeq(i+1));
isOk = IsMergingPossible(edge1, edge2, Tol, AvoidEdgeVrt); isOk = IsMergingPossible(edge1, edge2, theAngTol, AvoidEdgeVrt);
if (!isOk) if (!isOk)
{ {
SubSequenceOfEdges aSubSeq; SubSequenceOfEdges aSubSeq;
@ -939,7 +1009,7 @@ static void GenerateSubSeq (const TopTools_SequenceOfShape& anInpEdgeSeq,
{ {
edge1 = TopoDS::Edge(anInpEdgeSeq.Last()); edge1 = TopoDS::Edge(anInpEdgeSeq.Last());
edge2 = TopoDS::Edge(anInpEdgeSeq.First()); edge2 = TopoDS::Edge(anInpEdgeSeq.First());
if (IsMergingPossible(edge1, edge2, Tol, AvoidEdgeVrt)) if (IsMergingPossible(edge1, edge2, theAngTol, AvoidEdgeVrt))
{ {
SeqOfSubSeqOfEdges.ChangeLast().SeqsEdges.Append(SeqOfSubSeqOfEdges.ChangeFirst().SeqsEdges); SeqOfSubSeqOfEdges.ChangeLast().SeqsEdges.Append(SeqOfSubSeqOfEdges.ChangeFirst().SeqsEdges);
SeqOfSubSeqOfEdges.Remove(1); SeqOfSubSeqOfEdges.Remove(1);
@ -952,8 +1022,10 @@ static void GenerateSubSeq (const TopTools_SequenceOfShape& anInpEdgeSeq,
//purpose : auxilary //purpose : auxilary
//======================================================================= //=======================================================================
static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges, static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
const Standard_Real Tol, const Standard_Real theAngTol,
const Standard_Boolean ConcatBSplines, const Standard_Boolean ConcatBSplines,
const Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext,
NCollection_Sequence<SubSequenceOfEdges>& SeqOfSubSeqOfEdges, NCollection_Sequence<SubSequenceOfEdges>& SeqOfSubSeqOfEdges,
const TopTools_MapOfShape& NonMergVrt) const TopTools_MapOfShape& NonMergVrt)
{ {
@ -1053,7 +1125,7 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
// split chain by vertices at which merging is not possible // split chain by vertices at which merging is not possible
NCollection_Sequence<SubSequenceOfEdges> aOneSeq; NCollection_Sequence<SubSequenceOfEdges> aOneSeq;
GenerateSubSeq(aChain, aOneSeq, IsClosed, Tol, VerticesToAvoid); GenerateSubSeq(aChain, aOneSeq, IsClosed, theAngTol, VerticesToAvoid);
// put sub-chains in the result // put sub-chains in the result
SeqOfSubSeqOfEdges.Append(aOneSeq); SeqOfSubSeqOfEdges.Append(aOneSeq);
@ -1064,7 +1136,8 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
TopoDS_Edge UE; TopoDS_Edge UE;
if (SeqOfSubSeqOfEdges(i).SeqsEdges.Length() < 2) if (SeqOfSubSeqOfEdges(i).SeqsEdges.Length() < 2)
continue; continue;
if (MergeSubSeq(SeqOfSubSeqOfEdges(i).SeqsEdges, UE, Tol, ConcatBSplines)) if (MergeSubSeq(SeqOfSubSeqOfEdges(i).SeqsEdges, UE, theAngTol,
ConcatBSplines, isSafeInputMode, theContext))
SeqOfSubSeqOfEdges(i).UnionEdges = UE; SeqOfSubSeqOfEdges(i).UnionEdges = UE;
} }
return Standard_True; return Standard_True;
@ -1077,8 +1150,9 @@ static Standard_Boolean MergeEdges(TopTools_SequenceOfShape& SeqEdges,
//======================================================================= //=======================================================================
static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges, static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges,
const Standard_Real Tol, const Standard_Real theAngTol,
const Standard_Boolean ConcatBSplines, const Standard_Boolean ConcatBSplines,
const Standard_Boolean isSafeInputMode,
Handle(ShapeBuild_ReShape)& theContext, Handle(ShapeBuild_ReShape)& theContext,
TopTools_DataMapOfShapeShape& theOldToGeneratedShapes, TopTools_DataMapOfShapeShape& theOldToGeneratedShapes,
const TopTools_MapOfShape& nonMergVert, const TopTools_MapOfShape& nonMergVert,
@ -1086,7 +1160,8 @@ static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges,
const TopTools_DataMapOfShapeShape& NewEdges2OldEdges) const TopTools_DataMapOfShapeShape& NewEdges2OldEdges)
{ {
NCollection_Sequence<SubSequenceOfEdges> SeqOfSubsSeqOfEdges; NCollection_Sequence<SubSequenceOfEdges> SeqOfSubsSeqOfEdges;
if ( MergeEdges(SeqEdges, Tol, ConcatBSplines, SeqOfSubsSeqOfEdges, nonMergVert) ) if (MergeEdges(SeqEdges, theAngTol, ConcatBSplines, isSafeInputMode,
theContext, SeqOfSubsSeqOfEdges, nonMergVert))
{ {
for (Standard_Integer i = 1; i <= SeqOfSubsSeqOfEdges.Length(); i++ ) for (Standard_Integer i = 1; i <= SeqOfSubsSeqOfEdges.Length(); i++ )
{ {
@ -1110,6 +1185,8 @@ static Standard_Boolean MergeSeq (TopTools_SequenceOfShape& SeqEdges,
TopExp::Vertices(TopoDS::Edge(anOldEdge), V[0], V[1]); TopExp::Vertices(TopoDS::Edge(anOldEdge), V[0], V[1]);
for (int k = 0; k < 2; k++) for (int k = 0; k < 2; 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)) if (!V[k].IsEqual(VF) && !V[k].IsEqual(VL))
RemovedShapes.Add(V[k]); RemovedShapes.Add(V[k]);
} }
@ -1164,7 +1241,8 @@ ShapeUpgrade_UnifySameDomain::ShapeUpgrade_UnifySameDomain()
myUnifyFaces(Standard_True), myUnifyFaces(Standard_True),
myUnifyEdges (Standard_True), myUnifyEdges (Standard_True),
myConcatBSplines (Standard_False), myConcatBSplines (Standard_False),
myAllowInternal (Standard_False) myAllowInternal (Standard_False),
mySafeInputMode(Standard_True)
{ {
myContext = new ShapeBuild_ReShape; myContext = new ShapeBuild_ReShape;
} }
@ -1185,6 +1263,7 @@ ShapeUpgrade_UnifySameDomain::ShapeUpgrade_UnifySameDomain(const TopoDS_Shape& a
myUnifyEdges (UnifyEdges), myUnifyEdges (UnifyEdges),
myConcatBSplines (ConcatBSplines), myConcatBSplines (ConcatBSplines),
myAllowInternal (Standard_False), myAllowInternal (Standard_False),
mySafeInputMode (Standard_True),
myShape (aShape) myShape (aShape)
{ {
myContext = new ShapeBuild_ReShape; myContext = new ShapeBuild_ReShape;
@ -1222,6 +1301,16 @@ void ShapeUpgrade_UnifySameDomain::AllowInternalEdges (const Standard_Boolean th
myAllowInternal = theValue; myAllowInternal = theValue;
} }
//=======================================================================
//function : SetSafeInputMode
//purpose :
//=======================================================================
void ShapeUpgrade_UnifySameDomain::SetSafeInputMode(Standard_Boolean theValue)
{
mySafeInputMode = theValue;
}
//======================================================================= //=======================================================================
//function : KeepShape //function : KeepShape
//purpose : //purpose :
@ -1307,9 +1396,13 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
myShape = myContext->Apply(myShape); myShape = myContext->Apply(myShape);
} }
//=======================================================================
//function : IntUnifyFaces
//purpose :
//=======================================================================
void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape, void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape,
const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces, TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
Standard_Boolean IsCheckSharedEdgeOri) Standard_Boolean IsCheckSharedEdgeOri)
{ {
// creating map of edge faces for the shape // creating map of edge faces for the shape
@ -1414,7 +1507,13 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
TopoDS_Face aMockUpFace; TopoDS_Face aMockUpFace;
BRep_Builder B; BRep_Builder B;
B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.);
MovePCurves(aMockUpFace,anCheckedFace); MovePCurves(aMockUpFace, anCheckedFace, mySafeInputMode,
myContext);
if (mySafeInputMode) {
UpdateMapEdgeFaces(anCheckedFace, myContext, theGMapEdgeFaces);
UpdateMapEdgeFaces(anCheckedFace, myContext, aMapEdgeFaces);
}
if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
// sequence edges is modified // sequence edges is modified
@ -1434,7 +1533,8 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
for (i = 1; i <= faces.Length(); i++) { for (i = 1; i <= faces.Length(); i++) {
TopExp::MapShapesAndAncestors(faces(i), TopAbs_EDGE, TopAbs_FACE, aMapEF); TopExp::MapShapesAndAncestors(faces(i), TopAbs_EDGE, TopAbs_FACE, aMapEF);
} }
if (mySafeInputMode)
UpdateMapOfShapes(myKeepShapes, myContext);
// Collect keep edges and multiconnected edges, i.e. edges that are internal to // Collect keep edges and multiconnected edges, i.e. edges that are internal to
// the set of selected faces and have connections to other faces. // the set of selected faces and have connections to other faces.
TopTools_ListOfShape aKeepEdges; TopTools_ListOfShape aKeepEdges;
@ -1600,6 +1700,8 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
aWire = TopoDS::Wire(myContext->Apply(aWire)); aWire = TopoDS::Wire(myContext->Apply(aWire));
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
if (mySafeInputMode)
sfw->SetContext(myContext);
sfw->FixReorder(); sfw->FixReorder();
Standard_Boolean isDegRemoved = Standard_False; Standard_Boolean isDegRemoved = Standard_False;
if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { if(!sfw->StatusReorder ( ShapeExtend_FAIL )) {
@ -1621,19 +1723,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
sfw->FixDegenerated(); sfw->FixDegenerated();
} }
TopoDS_Wire aWireFixed = sfw->Wire(); TopoDS_Wire aWireFixed = sfw->Wire();
//aContext->Replace(aWire,aWireFixed);
myContext->Replace(aWire,aWireFixed); myContext->Replace(aWire,aWireFixed);
//for history
/*
if (!myOldNewMap.IsBound(aWire))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aWire, EmptyList);
}
myOldNewMap(aWire).Clear();
myOldNewMap(aWire).Append(aWireFixed);
*/
/////////////
// add resulting wire // add resulting wire
if(isEdge3d) { if(isEdge3d) {
@ -1688,19 +1778,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
} }
// perform substitution of face // perform substitution of face
//aContext->Replace(aContext->Apply(aFace),aResult);
myContext->Replace(myContext->Apply(aFace),aResult); myContext->Replace(myContext->Apply(aFace),aResult);
//for history
/*
if (!myOldNewMap.IsBound(aFace))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aFace, EmptyList);
}
myOldNewMap(aFace).Clear();
myOldNewMap(aFace).Append(aResult);
*/
/////////////
ShapeFix_Face sff (aResult); ShapeFix_Face sff (aResult);
//Intializing by tolerances //Intializing by tolerances
@ -1710,7 +1788,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
//Setting modes //Setting modes
sff.FixOrientationMode() = 0; sff.FixOrientationMode() = 0;
//sff.FixWireMode() = 0; //sff.FixWireMode() = 0;
//sff.SetContext(aContext);
sff.SetContext(myContext); sff.SetContext(myContext);
// Applying the fixes // Applying the fixes
sff.Perform(); sff.Perform();
@ -1718,7 +1795,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
hasFailed = Standard_True; hasFailed = Standard_True;
// breaking down to several faces // breaking down to several faces
//TopoDS_Shape theResult = aContext->Apply(aResult);
TopoDS_Shape theResult = myContext->Apply(aResult); TopoDS_Shape theResult = myContext->Apply(aResult);
for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) { for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) {
TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD));
@ -1727,7 +1803,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid );
ShapeFix_ComposeShell CompShell; ShapeFix_ComposeShell CompShell;
CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision
//CompShell.SetContext( aContext );
CompShell.SetContext( myContext ); CompShell.SetContext( myContext );
TopTools_SequenceOfShape parts, anIntWires; TopTools_SequenceOfShape parts, anIntWires;
@ -1752,10 +1827,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
} }
} }
CompShell.DispatchWires ( parts,wires ); CompShell.DispatchWires( parts, wires );
for (Standard_Integer j=1; j <= parts.Length(); j++ ) { for (Standard_Integer j=1; j <= parts.Length(); j++ ) {
ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); ShapeFix_Face aFixOrient(TopoDS::Face(parts(j)));
//aFixOrient.SetContext(aContext);
aFixOrient.SetContext(myContext); aFixOrient.SetContext(myContext);
aFixOrient.FixOrientation(); aFixOrient.FixOrientation();
// put internal wires to faces // put internal wires to faces
@ -1773,19 +1847,7 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
} }
else CompRes = parts(1); else CompRes = parts(1);
//aContext->Replace(aCurrent,CompRes);
myContext->Replace(aCurrent,CompRes); myContext->Replace(aCurrent,CompRes);
//for history
/*
if (!myOldNewMap.IsBound(aCurrent))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aCurrent, EmptyList);
}
myOldNewMap(aCurrent).Clear();
myOldNewMap(aCurrent).Append(CompRes);
*/
/////////////
} }
// remove the remaining faces // remove the remaining faces
@ -1800,7 +1862,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
//TopoDS_Shape aResult = Shape; //TopoDS_Shape aResult = Shape;
if (NbModif > 0 && !hasFailed) { if (NbModif > 0 && !hasFailed) {
//TopoDS_Shape aResult = aContext->Apply(aShell);
TopoDS_Shape aResult = myContext->Apply(theInpShape); TopoDS_Shape aResult = myContext->Apply(theInpShape);
ShapeFix_Edge sfe; ShapeFix_Edge sfe;
@ -1813,17 +1874,6 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
} }
myContext->Replace(theInpShape, aResult); myContext->Replace(theInpShape, aResult);
//for history
/*
if (!myOldNewMap.IsBound(aShell))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aShell, EmptyList);
}
myOldNewMap(aShell).Clear();
myOldNewMap(aShell).Append(aResult);
*/
/////////////
} }
//else //else
{ {
@ -1852,24 +1902,17 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape
//======================================================================= //=======================================================================
void ShapeUpgrade_UnifySameDomain::UnifyEdges() void ShapeUpgrade_UnifySameDomain::UnifyEdges()
{ {
//Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; TopoDS_Shape aRes = myContext->Apply(myShape);
Standard_Real myTolerance = Precision::Confusion();
TopoDS_Shape aResult = myContext->Apply(myShape);
TopTools_IndexedMapOfShape ChangedFaces; TopTools_IndexedMapOfShape ChangedFaces;
// creating map of edge faces // creating map of edge faces
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); TopExp::MapShapesAndAncestors(aRes, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
// creating map of vertex edges // creating map of vertex edges
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgesVertex; TopTools_IndexedDataMapOfShapeListOfShape aMapEdgesVertex;
TopExp::MapShapesAndUniqueAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMapEdgesVertex); TopExp::MapShapesAndUniqueAncestors(aRes, TopAbs_VERTEX, TopAbs_EDGE, aMapEdgesVertex);
//Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
TopoDS_Shape aRes = myShape;
//aRes = aContext->Apply(aSolid);
aRes = myContext->Apply(myShape);
TopTools_MapOfShape SharedVert; TopTools_MapOfShape SharedVert;
@ -1879,11 +1922,15 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
TopTools_DataMapOfShapeShape NewEdges2OldEdges; TopTools_DataMapOfShapeShape NewEdges2OldEdges;
for (int i = 1; i <= anOldEdges.Extent(); i++) for (int i = 1; i <= anOldEdges.Extent(); i++)
{ {
TopoDS_Shape NewEdge = myContext->Apply(anOldEdges(i)); const TopoDS_Shape& anOldEdge = anOldEdges(i);
if (!NewEdge.IsNull()) TopoDS_Shape aNewEdge = myContext->Apply(anOldEdge);
NewEdges2OldEdges.Bind(NewEdge, anOldEdges(i)); if (!aNewEdge.IsNull() && !aNewEdge.IsSame(anOldEdge))
NewEdges2OldEdges.Bind(aNewEdge, anOldEdge);
} }
if (mySafeInputMode)
UpdateMapOfShapes(myKeepShapes, myContext);
TopExp_Explorer exp; TopExp_Explorer exp;
// processing separate wires // processing separate wires
for (exp.Init(aRes, TopAbs_WIRE, TopAbs_FACE); exp.More(); exp.Next()) for (exp.Init(aRes, TopAbs_WIRE, TopAbs_FACE); exp.More(); exp.Next())
@ -1894,49 +1941,37 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
SeqEdges.Append(expE.Current()); SeqEdges.Append(expE.Current());
SharedVert.Clear(); SharedVert.Clear();
CheckSharedVertices(SeqEdges, aMapEdgesVertex, myKeepShapes, SharedVert); CheckSharedVertices(SeqEdges, aMapEdgesVertex, myKeepShapes, SharedVert);
MergeSeq(SeqEdges, myAngTol, myConcatBSplines, myContext, MergeSeq(SeqEdges, myAngTol, myConcatBSplines, mySafeInputMode,
myOldToGeneratedShapes, SharedVert, myContext, myOldToGeneratedShapes, SharedVert,
myRemovedShapes, NewEdges2OldEdges); myRemovedShapes, NewEdges2OldEdges);
} }
TopTools_DataMapOfShapeShape oldFaces2NewFaces;
for (exp.Init(myShape, TopAbs_FACE); exp.More(); exp.Next())
{
const TopoDS_Face& f = TopoDS::Face(exp.Current());
TopoDS_Face NewF = TopoDS::Face(myContext->Apply(f));
if (!NewF.IsNull())
oldFaces2NewFaces.Bind(f, NewF);
}
// processing each face // processing each face
for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) {
//TopoDS_Face aFace = TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); TopoDS_Shape aFace = exp.Current().Oriented(TopAbs_FORWARD);
TopoDS_Face aFace = TopoDS::Face(myContext->Apply(exp.Current().Oriented(TopAbs_FORWARD)));
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
TopTools_SequenceOfShape aNonSharedEdges; TopTools_SequenceOfShape aNonSharedEdges;
for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) {
TopoDS_Edge edge = TopoDS::Edge(expe.Current()); TopoDS_Edge edge = TopoDS::Edge(expe.Current());
if (!aMapEdgeFaces.Contains(edge)) continue;
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
TopTools_ListIteratorOfListOfShape anIter(aList); TopTools_ListIteratorOfListOfShape anIter(aList);
Standard_Integer NbFacesPerEdge = aList.Extent(); Standard_Integer NbFacesPerEdge = aList.Extent();
for ( ; anIter.More(); anIter.Next()) { for ( ; anIter.More(); anIter.Next()) {
TopoDS_Face face = TopoDS::Face(anIter.Value()); const TopoDS_Shape& aFace1 = anIter.Value();
TopoDS_Face face1 = TopoDS::Face(oldFaces2NewFaces(anIter.Value())); if (aFace1.IsSame(aFace) && NbFacesPerEdge != 1)
if (face1.IsSame(aFace) && NbFacesPerEdge != 1)
continue; continue;
if (NbFacesPerEdge == 1) if (NbFacesPerEdge == 1)
//store non-shared edges separately //store non-shared edges separately
aNonSharedEdges.Append(edge); aNonSharedEdges.Append(edge);
else else
{ {
if (aMapFacesEdges.Contains(face)) if (aMapFacesEdges.Contains(aFace1))
aMapFacesEdges.ChangeFromKey(face).Append(edge); aMapFacesEdges.ChangeFromKey(aFace1).Append(edge);
else else
{ {
TopTools_ListOfShape ListEdges; TopTools_ListOfShape ListEdges;
ListEdges.Append(edge); ListEdges.Append(edge);
aMapFacesEdges.Add(face,ListEdges); aMapFacesEdges.Add(aFace1, ListEdges);
} }
} }
} }
@ -1954,27 +1989,10 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
SharedVert.Clear(); SharedVert.Clear();
CheckSharedVertices(SeqEdges, aMapEdgesVertex, myKeepShapes, SharedVert); CheckSharedVertices(SeqEdges, aMapEdgesVertex, myKeepShapes, SharedVert);
//if (!SharedVert.IsEmpty()) if (MergeSeq(SeqEdges, myAngTol, myConcatBSplines, mySafeInputMode,
// continue; myContext, myOldToGeneratedShapes, SharedVert,
if ( MergeSeq(SeqEdges, myAngTol, myConcatBSplines, myContext,
myOldToGeneratedShapes, SharedVert,
myRemovedShapes, NewEdges2OldEdges)) myRemovedShapes, NewEdges2OldEdges))
{ {
//for history
/*
for (j = 1; j <= SeqEdges.Length(); j++)
{
if (!myOldNewMap.IsBound(SeqEdges(j)))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(SeqEdges(j), EmptyList);
}
myOldNewMap(SeqEdges(j)).Clear();
myOldNewMap(SeqEdges(j)).Append(E);
}
*/
/////////////
TopoDS_Face tmpF = TopoDS::Face(exp.Current()); TopoDS_Face tmpF = TopoDS::Face(exp.Current());
if ( !ChangedFaces.Contains(tmpF) ) if ( !ChangedFaces.Contains(tmpF) )
ChangedFaces.Add(tmpF); ChangedFaces.Add(tmpF);
@ -1988,9 +2006,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
{ {
SharedVert.Clear(); SharedVert.Clear();
CheckSharedVertices(aNonSharedEdges, aMapEdgesVertex, myKeepShapes, SharedVert); CheckSharedVertices(aNonSharedEdges, aMapEdgesVertex, myKeepShapes, SharedVert);
if ( MergeSeq(aNonSharedEdges, myAngTol, myConcatBSplines, myContext, if (MergeSeq(aNonSharedEdges, myAngTol, myConcatBSplines, mySafeInputMode,
myOldToGeneratedShapes, SharedVert, myContext, myOldToGeneratedShapes, SharedVert,
myRemovedShapes, NewEdges2OldEdges)) myRemovedShapes, NewEdges2OldEdges))
{ {
TopoDS_Face tmpF = TopoDS::Face(exp.Current()); TopoDS_Face tmpF = TopoDS::Face(exp.Current());
if ( !ChangedFaces.Contains(tmpF) ) if ( !ChangedFaces.Contains(tmpF) )
@ -2001,71 +2019,39 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
} // end processing each face } // end processing each face
// fix changed faces and replace them in the local context // fix changed faces and replace them in the local context
for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { Standard_Real aPrec = Precision::Confusion();
//TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); for (Standard_Integer i = 1; i <= ChangedFaces.Extent(); i++) {
TopoDS_Face aFace = TopoDS::Face(myContext->Apply(ChangedFaces.FindKey(i))); TopoDS_Face aFace = TopoDS::Face(myContext->Apply(ChangedFaces.FindKey(i)));
if (aFace.IsNull()) if (aFace.IsNull())
continue; continue;
Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace);
sff->SetContext(myContext); sff->SetContext(myContext);
sff->SetPrecision(myTolerance); sff->SetPrecision(aPrec);
sff->SetMinTolerance(myTolerance); sff->SetMinTolerance(aPrec);
sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); sff->SetMaxTolerance(Max(1., aPrec*1000.));
sff->Perform(); sff->Perform();
TopoDS_Shape aNewFace = sff->Face(); TopoDS_Shape aNewFace = sff->Face();
//aContext->Replace(aFace,aNewFace);
myContext->Replace(aFace,aNewFace); myContext->Replace(aFace,aNewFace);
//for history
/*
if (!myOldNewMap.IsBound(aFace))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aFace, EmptyList);
}
myOldNewMap(aFace).Clear();
myOldNewMap(aFace).Append(aNewFace);
*/
/////////////
} }
if (ChangedFaces.Extent() > 0) { if (ChangedFaces.Extent() > 0) {
// fix changed shell and replace it in the local context // fix changed shell and replace it in the local context
//TopoDS_Shape aRes1 = aContext->Apply(aRes);
TopoDS_Shape aRes1 = myContext->Apply(aRes); TopoDS_Shape aRes1 = myContext->Apply(aRes);
Standard_Boolean isChanged = Standard_False;
TopExp_Explorer expsh; TopExp_Explorer expsh;
for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) {
TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); TopoDS_Shell aShell = TopoDS::Shell(expsh.Current());
Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell;
sfsh->FixFaceOrientation(aShell); sfsh->FixFaceOrientation(aShell);
TopoDS_Shape aNewShell = sfsh->Shell(); TopoDS_Shape aNewShell = sfsh->Shell();
//aContext->Replace(aShell,aNewShell); if (!aNewShell.IsSame(aShell)) {
myContext->Replace(aShell,aNewShell); myContext->Replace(aShell, aNewShell);
//for history isChanged = Standard_True;
/*
if (!myOldNewMap.IsBound(aShell))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aShell, EmptyList);
} }
myOldNewMap(aShell).Clear();
myOldNewMap(aShell).Append(aNewShell);
*/
/////////////
} }
//TopoDS_Shape aRes2 = aContext->Apply(aRes1); if (isChanged)
TopoDS_Shape aRes2 = myContext->Apply(aRes1); aRes1 = myContext->Apply(aRes1);
myContext->Replace(myShape,aRes2); myContext->Replace(myShape, aRes1);
//for history
/*
if (!myOldNewMap.IsBound(aSolid))
{
TopTools_ListOfShape EmptyList;
myOldNewMap.Bind(aSolid, EmptyList);
}
myOldNewMap(aSolid).Clear();
myOldNewMap(aSolid).Append(aRes2);
*/
/////////////
} }
myShape = myContext->Apply(myShape); myShape = myContext->Apply(myShape);

View File

@ -76,6 +76,12 @@ public:
//! If shape is edge it forbids merging of connected faces. //! If shape is edge it forbids merging of connected faces.
Standard_EXPORT void KeepShapes(const TopTools_MapOfShape& theShapes); Standard_EXPORT void KeepShapes(const TopTools_MapOfShape& theShapes);
//! Sets the flag defining the behavior of the algorithm regarding
//! modification of input shape.
//! If this flag is equal to True then the input (original) shape can't be
//! modified during modification process. Default value is true.
Standard_EXPORT void SetSafeInputMode(Standard_Boolean theValue);
//! Sets the linear tolerance. Default value is Precision::Confusion(). //! Sets the linear tolerance. Default value is Precision::Confusion().
void SetLinearTolerance(const Standard_Real theValue) void SetLinearTolerance(const Standard_Real theValue)
{ {
@ -134,7 +140,7 @@ protected:
private: private:
void IntUnifyFaces(const TopoDS_Shape& theInpShape, void IntUnifyFaces(const TopoDS_Shape& theInpShape,
const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces, TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
Standard_Boolean IsCheckSharedEdgeOri); Standard_Boolean IsCheckSharedEdgeOri);
TopoDS_Shape myInitShape; TopoDS_Shape myInitShape;
@ -144,6 +150,7 @@ private:
Standard_Boolean myUnifyEdges; Standard_Boolean myUnifyEdges;
Standard_Boolean myConcatBSplines; Standard_Boolean myConcatBSplines;
Standard_Boolean myAllowInternal; Standard_Boolean myAllowInternal;
Standard_Boolean mySafeInputMode;
TopoDS_Shape myShape; TopoDS_Shape myShape;
Handle(ShapeBuild_ReShape) myContext; Handle(ShapeBuild_ReShape) myContext;
TopTools_DataMapOfShapeShape myOldToGeneratedShapes; TopTools_DataMapOfShapeShape myOldToGeneratedShapes;

View File

@ -0,0 +1,14 @@
puts "TODO OCC28602 ALL: \\*\\* Exception \\*\\*.*"
puts "TODO OCC28602 ALL: An exception was caught"
puts "TODO OCC28602 ALL: TEST INCOMPLETE"
puts "=========="
puts "OCC28227"
puts "=========="
puts ""
#############################################################################
# ShapeUpgrade_UnifySameDomain modifies the edges even if it is not requested
#############################################################################
restore [locate_data_file bug28228_face.brep] a
setflags a locked
unifysamedom result a