mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0026219: ShapeUpgrade_UnifySameDomain fails with StdFail_NotDone exception
Avoid merging edges if the collapsed vertex has a third connected edge. Fix the problem when merged edges have different location. Test case for issue CR26219 Additional fix to improve robustness. Test cases for issue CR26219 Small correction of test cases for issue CR26219
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
#include <ShapeFix_Edge.hxx>
|
||||
#include <ShapeFix_Shell.hxx>
|
||||
#include <ShapeUpgrade_RemoveLocations.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
@@ -568,11 +569,11 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||
}
|
||||
// union edges in chain
|
||||
// first step: union lines and circles
|
||||
TopLoc_Location Loc;
|
||||
Standard_Real fp1,lp1,fp2,lp2;
|
||||
for(j=1; j<aChain.Length(); j++) {
|
||||
TopoDS_Edge edge1 = TopoDS::Edge(aChain.Value(j));
|
||||
Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,Loc,fp1,lp1);
|
||||
Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,fp1,lp1);
|
||||
|
||||
if(c3d1.IsNull()) break;
|
||||
while(c3d1->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
Handle(Geom_TrimmedCurve) tc =
|
||||
@@ -580,7 +581,7 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||
c3d1 = tc->BasisCurve();
|
||||
}
|
||||
TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1));
|
||||
Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2);
|
||||
Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,fp2,lp2);
|
||||
if(c3d2.IsNull()) break;
|
||||
while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
Handle(Geom_TrimmedCurve) tc =
|
||||
@@ -596,7 +597,7 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||
//if(!Dir1.IsEqual(Dir2,Precision::Angular())) {
|
||||
//if(!Dir1.IsParallel(Dir2,Precision::Angular())) {
|
||||
if(!Dir1.IsParallel(Dir2,Tol)) {
|
||||
continue;
|
||||
return Standard_False;
|
||||
}
|
||||
// can union lines => create new edge
|
||||
TopoDS_Vertex V1 = sae.FirstVertex(edge1);
|
||||
@@ -625,7 +626,8 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||
Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2);
|
||||
gp_Pnt P01 = C1->Location();
|
||||
gp_Pnt P02 = C2->Location();
|
||||
if (P01.Distance(P02) > Precision::Confusion()) continue;
|
||||
if (P01.Distance(P02) > Precision::Confusion())
|
||||
return Standard_False;
|
||||
// can union circles => create new edge
|
||||
TopoDS_Vertex V1 = sae.FirstVertex(edge1);
|
||||
gp_Pnt PV1 = BRep_Tool::Pnt(V1);
|
||||
@@ -634,18 +636,18 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||
TopoDS_Vertex VM = sae.LastVertex(edge1);
|
||||
gp_Pnt PVM = BRep_Tool::Pnt(VM);
|
||||
GC_MakeCircle MC (PV1,PVM,PV2);
|
||||
Handle(Geom_Circle) C = MC.Value();
|
||||
TopoDS_Edge E;
|
||||
if (!MC.IsDone() || C.IsNull()) {
|
||||
if (!MC.IsDone() || MC.Value().IsNull()) {
|
||||
// jfa for Mantis issue 0020228
|
||||
if (PV1.Distance(PV2) > Precision::Confusion()) continue;
|
||||
if (PV1.Distance(PV2) > Precision::Confusion())
|
||||
return Standard_False;
|
||||
// closed chain
|
||||
C = C1;
|
||||
B.MakeEdge (E,C,Precision::Confusion());
|
||||
B.MakeEdge (E,C1,Precision::Confusion());
|
||||
B.Add(E,V1);
|
||||
B.Add(E,V2);
|
||||
}
|
||||
else {
|
||||
Handle(Geom_Circle) C = MC.Value();
|
||||
gp_Pnt P0 = C->Location();
|
||||
gp_Dir D1(gp_Vec(P0,PV1));
|
||||
gp_Dir D2(gp_Vec(P0,PV2));
|
||||
@@ -691,6 +693,7 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges,
|
||||
bool NeedUnion = true;
|
||||
for(j=1; j<=aChain.Length(); j++) {
|
||||
TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j));
|
||||
TopLoc_Location Loc;
|
||||
Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1);
|
||||
if(c3d.IsNull()) continue;
|
||||
while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
@@ -1181,6 +1184,10 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
|
||||
// creating map of edge faces
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||
|
||||
// creating map of vertex edges
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgesVertex;
|
||||
TopExp::MapShapesAndAncestors(aSolid, TopAbs_VERTEX, TopAbs_EDGE, aMapEdgesVertex);
|
||||
|
||||
//Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
|
||||
TopoDS_Shape aRes = aSolid;
|
||||
@@ -1218,11 +1225,38 @@ void ShapeUpgrade_UnifySameDomain::UnifyEdges()
|
||||
for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) {
|
||||
const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
|
||||
TopTools_SequenceOfShape SeqEdges;
|
||||
ShapeAnalysis_Edge sae;
|
||||
TopTools_ListIteratorOfListOfShape anIter(ListEdges);
|
||||
for ( ; anIter.More(); anIter.Next()) {
|
||||
Standard_Boolean IsSharedVertexPresent = Standard_False;
|
||||
for ( ; anIter.More(); anIter.Next())
|
||||
SeqEdges.Append(anIter.Value());
|
||||
if (SeqEdges.Length()==1)
|
||||
continue;
|
||||
TopTools_SequenceOfShape SeqVertexes;
|
||||
TopTools_MapOfShape MapVertexes;
|
||||
for (int k = 1; k <= SeqEdges.Length(); k++ )
|
||||
{
|
||||
TopoDS_Vertex aV1 = sae.FirstVertex(TopoDS::Edge(SeqEdges(k)));
|
||||
TopoDS_Vertex aV2 = sae.LastVertex(TopoDS::Edge(SeqEdges(k)));
|
||||
if (!MapVertexes.Add(aV1))
|
||||
SeqVertexes.Append(aV1);
|
||||
if (!MapVertexes.Add(aV2))
|
||||
SeqVertexes.Append(aV2);
|
||||
}
|
||||
if (SeqEdges.Length()==1) continue;
|
||||
|
||||
for (Standard_Integer k = 1; k <= SeqVertexes.Length() && !IsSharedVertexPresent; k++ )
|
||||
{
|
||||
const TopTools_ListOfShape& ListEdgesV1 = aMapEdgesVertex.FindFromKey(SeqVertexes(k));
|
||||
TopTools_MapOfShape aMapOfEdges;
|
||||
TopTools_ListIteratorOfListOfShape iter(ListEdgesV1);
|
||||
for (; iter.More(); iter.Next())
|
||||
aMapOfEdges.Add(iter.Value());
|
||||
if (aMapOfEdges.Extent() > 2)
|
||||
IsSharedVertexPresent = Standard_True;
|
||||
}
|
||||
|
||||
if (IsSharedVertexPresent)
|
||||
continue;
|
||||
TopoDS_Edge E;
|
||||
if ( MergeEdges(SeqEdges,aFace,Tol,myConcatBSplines,E) ) {
|
||||
// now we have only one edge - aChain.Value(1)
|
||||
|
Reference in New Issue
Block a user