From: msv Date: Wed, 2 Sep 2015 15:40:41 +0000 (+0300) Subject: 0026635: UnifySameDomain loses internal edges X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=c7fa8f058ae23822521c182d34ddb7ff4c875106;p=occt-copy.git 0026635: UnifySameDomain loses internal edges -Treat internal edges in proper way to save them in the result -Adopt test case to the actual state --- diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index 9738f346cc..18c109ef8a 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -87,6 +87,7 @@ #include #include #include +#include struct SubSequenceOfEdges { @@ -988,6 +989,37 @@ void ShapeUpgrade_UnifySameDomain::Initialize(const TopoDS_Shape& aShape, //myGenerated.Clear(); } +//======================================================================= +//function : putIntWires +//purpose : Add internal wires that are classified inside the face as a subshape, +// and remove them from the sequence +//======================================================================= +static void putIntWires(TopoDS_Shape& theFace, TopTools_SequenceOfShape& theWires) +{ + TopoDS_Face& aFace = TopoDS::Face(theFace); + for (Standard_Integer i=1; i <= theWires.Length(); i++) + { + TopoDS_Shape aWire = theWires(i); + gp_Pnt2d aP2d; + Standard_Boolean isP2d = Standard_False; + for (TopoDS_Iterator it(aWire); it.More() && !isP2d; it.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(it.Value()); + Standard_Real aFirst, aLast; + Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(anEdge, aFace, aFirst, aLast); + aC2d->D0((aFirst + aLast) * 0.5, aP2d); + isP2d = Standard_True; + } + BRepClass_FaceClassifier aClass(aFace, aP2d, Precision::PConfusion()); + if (aClass.State() == TopAbs_IN) + { + BRep_Builder().Add(aFace, aWire); + theWires.Remove(i); + i--; + } + } +} + //======================================================================= //function : UnifyFaces //purpose : @@ -1106,6 +1138,8 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); edges.Remove(1); + // collect internal edges in separate wires + Standard_Boolean isInternal = (anEdge.Orientation() == TopAbs_INTERNAL); isEdge3d |= !BRep_Tool::Degenerated(anEdge); B.Add(aWire,anEdge); @@ -1119,6 +1153,10 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() isNewFound = Standard_False; for(Standard_Integer j = 1; j <= edges.Length(); j++) { anEdge = TopoDS::Edge(edges(j)); + // check if the current edge orientation corresponds to the first one + Standard_Boolean isCurrInternal = (anEdge.Orientation() == TopAbs_INTERNAL); + if (isCurrInternal != isInternal) + continue; TopExp::Vertices(anEdge,V1,V2); if(aVertices.Contains(V1) || aVertices.Contains(V2)) { isEdge3d |= !BRep_Tool::Degenerated(anEdge); @@ -1265,13 +1303,26 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() //CompShell.SetContext( aContext ); CompShell.SetContext( myContext ); - TopTools_SequenceOfShape parts; + TopTools_SequenceOfShape parts, anIntWires; ShapeFix_SequenceOfWireSegment wires; for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { - Handle(ShapeExtend_WireData) sbwd = - new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); - ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); - wires.Append(seg); + const TopoDS_Wire& aWire = TopoDS::Wire(W_Exp.Current()); + // check if the wire is ordinary (contains non-internal edges) + Standard_Boolean isInternal = Standard_True; + for (TopoDS_Iterator it(aWire); it.More() && isInternal; it.Next()) + isInternal = (it.Value().Orientation() == TopAbs_INTERNAL); + if (isInternal) + { + // place internal wire separately + anIntWires.Append(aWire); + } + else + { + Handle(ShapeExtend_WireData) sbwd = + new ShapeExtend_WireData (aWire); + ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); + wires.Append(seg); + } } CompShell.DispatchWires ( parts,wires ); @@ -1280,10 +1331,12 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() //aFixOrient.SetContext(aContext); aFixOrient.SetContext(myContext); aFixOrient.FixOrientation(); + // put internal wires to faces + putIntWires(parts(j), anIntWires); } TopoDS_Shape CompRes; - if ( faces.Length() !=1 ) { + if ( parts.Length() !=1 ) { TopoDS_Shell S; B.MakeShell ( S ); for ( i=1; i <= parts.Length(); i++ ) diff --git a/tests/bugs/heal/bug26219_gehause_rohteil b/tests/bugs/heal/bug26219_gehause_rohteil index 5cba82048f..296afe82c2 100644 --- a/tests/bugs/heal/bug26219_gehause_rohteil +++ b/tests/bugs/heal/bug26219_gehause_rohteil @@ -281,15 +281,15 @@ unifysamedom p p set nbshapes_after_simplify " Number of shapes in shape - VERTEX : 85 - EDGE : 128 + VERTEX : 82 + EDGE : 125 WIRE : 51 FACE : 44 SHELL : 1 SOLID : 1 COMPSOLID : 0 COMPOUND : 0 - SHAPE : 310 + SHAPE : 304 " checknbshapes p -ref ${nbshapes_after_simplify} -t -m "result after attempt to simplify the model"