1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-16 10:54:53 +03:00

0024807: Exception in ShapeAnalysis_FreeBounds::ConnectEdgesToWires

The reason for the exception was that given compound contains only edges with INTERNAL orientation (there are not any wires or faces). Consequently, given shape is non-manifold a priory.
New fix handles some cases.
Added test case bugs/modalg_5/bug24807
This commit is contained in:
nbv 2014-05-29 15:36:23 +04:00 committed by apn
parent 1e143abba6
commit 69b43824ac
2 changed files with 85 additions and 42 deletions

View File

@ -220,20 +220,32 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
aBox.SetGap(tolerance); aBox.SetGap(tolerance);
aTreeFiller.Add(inbW, aBox); aTreeFiller.Add(inbW, aBox);
} }
aTreeFiller.Fill(); aTreeFiller.Fill();
Standard_Integer nsel; Standard_Integer nsel;
ShapeAnalysis_Edge sae; //szv#4:S4163:12Mar99 moved ShapeAnalysis_Edge sae; //szv#4:S4163:12Mar99 moved
Standard_Boolean done = Standard_False; Standard_Boolean done = Standard_False;
Standard_Boolean isUsedManifoldMode = Standard_True;
if((sewd->NbEdges() < 1) && (sewd->NbNonManifoldEdges() > 0))
{
isUsedManifoldMode = Standard_False;
}
while (!done) { while (!done)
{
Standard_Boolean found = Standard_False, tail = Standard_False, direct = Standard_False; Standard_Boolean found = Standard_False, tail = Standard_False, direct = Standard_False;
Standard_Integer lwire=0; Standard_Integer lwire=0;
aSel.SetStop(); aSel.SetStop();
Bnd_Box FVBox, LVBox; Bnd_Box FVBox, LVBox;
TopoDS_Vertex Vf, Vl; TopoDS_Vertex Vf, Vl;
Vf = sae.FirstVertex(sewd->Edge(1)); Vf = isUsedManifoldMode ? sae.FirstVertex(sewd->Edge(1)) :
Vl = sae.LastVertex(sewd->Edge(sewd->NbEdges())); sae.FirstVertex(sewd->NonmanifoldEdge(1));
Vl = isUsedManifoldMode ? sae.LastVertex(sewd->Edge(sewd->NbEdges())) :
sae.LastVertex(sewd->NonmanifoldEdge(sewd->NbNonManifoldEdges()));
gp_Pnt pf, pl; gp_Pnt pf, pl;
pf = BRep_Tool::Pnt(Vf); pf = BRep_Tool::Pnt(Vf);
pl = BRep_Tool::Pnt(Vl); pl = BRep_Tool::Pnt(Vl);
@ -246,14 +258,16 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
if (shared) if (shared)
aSel.DefineVertexes(Vf,Vl); aSel.DefineVertexes(Vf,Vl);
else{ else
{
aSel.DefinePnt(pf,pl); aSel.DefinePnt(pf,pl);
aSel.SetTolerance(tolerance); aSel.SetTolerance(tolerance);
} }
nsel = aBBTree.Select(aSel); nsel = aBBTree.Select(aSel);
if (nsel != 0 && !aSel.LastCheckStatus(ShapeExtend_FAIL)) { if (nsel != 0 && !aSel.LastCheckStatus(ShapeExtend_FAIL))
{
found = Standard_True; found = Standard_True;
lwire = aSel.GetNb(); lwire = aSel.GetNb();
tail = aSel.LastCheckStatus (ShapeExtend_DONE1) || tail = aSel.LastCheckStatus (ShapeExtend_DONE1) ||
@ -263,53 +277,60 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
aSel.LoadList(lwire); aSel.LoadList(lwire);
} }
if (found) { if (found)
if (!direct) arrwires->ChangeValue(lwire).Reverse(); {
if (!direct)
arrwires->ChangeValue(lwire).Reverse();
TopoDS_Wire aCurW = TopoDS::Wire (arrwires->Value (lwire)); TopoDS_Wire aCurW = TopoDS::Wire (arrwires->Value (lwire));
Handle(ShapeExtend_WireData) acurwd = Handle(ShapeExtend_WireData) acurwd = new
new ShapeExtend_WireData ( TopoDS::Wire (arrwires->Value (lwire))); ShapeExtend_WireData ( TopoDS::Wire (arrwires->Value (lwire)));
sewd->Add (acurwd, (tail ? 0 : 1)); sewd->Add (acurwd, (tail ? 0 : 1));
} }
else { else
{
//making wire //making wire
//1.providing connection (see ShapeFix_Wire::FixConnected()) //1.providing connection (see ShapeFix_Wire::FixConnected())
//Standard_Integer i; // svv #1 //Standard_Integer i; // svv #1
for (/*Standard_Integer*/ i = 1; i <= saw->NbEdges(); i++) { for (/*Standard_Integer*/ i = 1; i <= saw->NbEdges(); i++)
if (saw->CheckConnected (i)) { {
Standard_Integer n2 = i; if (saw->CheckConnected (i))
Standard_Integer n1 = (n2 > 1 ? n2 - 1 : saw->NbEdges()); {
TopoDS_Edge E1 = sewd->Edge(n1); Standard_Integer n2 = i;
TopoDS_Edge E2 = sewd->Edge(n2); Standard_Integer n1 = (n2 > 1 ? n2 - 1 : saw->NbEdges());
TopoDS_Edge E1 = sewd->Edge(n1);
TopoDS_Vertex Vprev, Vfol, V; //connection vertex TopoDS_Edge E2 = sewd->Edge(n2);
Vprev = sae.LastVertex (E1);
Vfol = sae.FirstVertex (E2);
if (saw->LastCheckStatus (ShapeExtend_DONE1)) //absolutely confused TopoDS_Vertex Vprev, Vfol, V; //connection vertex
V = Vprev; Vprev = sae.LastVertex (E1);
else { Vfol = sae.FirstVertex (E2);
ShapeBuild_Vertex sbv;
V = sbv.CombineVertex (Vprev, Vfol);
}
vertices.Bind (Vprev, V);
vertices.Bind (Vfol, V);
//replace vertices to a new one if (saw->LastCheckStatus (ShapeExtend_DONE1)) //absolutely confused
ShapeBuild_Edge sbe; V = Vprev;
if (saw->NbEdges() < 2) else {
sewd->Set (sbe.CopyReplaceVertices (E2, V, V), n2); ShapeBuild_Vertex sbv;
else { V = sbv.CombineVertex (Vprev, Vfol);
sewd->Set (sbe.CopyReplaceVertices (E2, V, TopoDS_Vertex()), n2); }
if (!saw->LastCheckStatus (ShapeExtend_DONE1)) vertices.Bind (Vprev, V);
sewd->Set (sbe.CopyReplaceVertices (E1, TopoDS_Vertex(), V), n1); vertices.Bind (Vfol, V);
}
} //replace vertices to a new one
ShapeBuild_Edge sbe;
if (saw->NbEdges() < 2)
sewd->Set (sbe.CopyReplaceVertices (E2, V, V), n2);
else {
sewd->Set (sbe.CopyReplaceVertices (E2, V, TopoDS_Vertex()), n2);
if (!saw->LastCheckStatus (ShapeExtend_DONE1))
sewd->Set (sbe.CopyReplaceVertices (E1, TopoDS_Vertex(), V), n1);
}
}
} }
//2.making wire //2.making wire
TopoDS_Wire wire = sewd->Wire(); TopoDS_Wire wire = sewd->Wire();
if (!saw->CheckConnected (1) && saw->LastCheckStatus (ShapeExtend_OK)) if (!saw->CheckConnected (1) && saw->LastCheckStatus (ShapeExtend_OK))
wire.Closed (Standard_True); wire.Closed (Standard_True);
owires->Append (wire); owires->Append (wire);
sewd->Clear(); sewd->Clear();
@ -317,17 +338,27 @@ ShapeAnalysis_FreeBounds::ShapeAnalysis_FreeBounds(const TopoDS_Shape& shape,
//Searching for first edge for next wire //Searching for first edge for next wire
lwire = -1; lwire = -1;
for (/*Standard_Integer*/ i = 1 ; i <= arrwires->Length() && lwire == -1; i++) for (/*Standard_Integer*/ i = 1 ; i <= arrwires->Length() && lwire == -1; i++)
if (!aSel.ContWire(i)) lwire = i; //szv#4:S4163:12Mar99 optimized {
if (!aSel.ContWire(i))
{
lwire = i; //szv#4:S4163:12Mar99 optimized
}
}
if (lwire == -1) done = 1; if (lwire == -1)
else { done = 1;
sewd->Add (TopoDS::Wire (arrwires->Value (lwire))); else
{
sewd->Add (TopoDS::Wire (arrwires->Value (lwire)));
aSel.LoadList(lwire); aSel.LoadList(lwire);
} }
} }
} }
for ( /*Standard_Integer*/ i = 1; i <= iwires->Length(); i++) for ( /*Standard_Integer*/ i = 1; i <= iwires->Length(); i++)
{
iwires->SetValue (i, arrwires->Value(i)); iwires->SetValue (i, arrwires->Value(i));
}
} }
static void SplitWire(const TopoDS_Wire& wire, static void SplitWire(const TopoDS_Wire& wire,

View File

@ -0,0 +1,12 @@
puts "=========="
puts "OCC24807"
puts "=========="
puts ""
#######################################################################
# Exception in ShapeAnalysis_FreeBounds::ConnectEdgesToWires
#######################################################################
restore [locate_data_file bug24807_Compound.brep] a
connectedges result a
set 2dviewer 1