From: VRO <> Date: Fri, 10 Feb 2012 09:57:58 +0000 (+0000) Subject: 0022822: Skipping of the first and the last edges of a wire for opened wires X-Git-Tag: V6_5_3_beta1~106 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=ef57920a5d93e37682d74c0e88c45023eb57e34d 0022822: Skipping of the first and the last edges of a wire for opened wires --- diff --git a/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx b/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx index f22a1d58e8..8cc35defa8 100755 --- a/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx +++ b/src/SWDRAW/SWDRAW_ShapeAnalysis.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,7 @@ #include #include +#include static Standard_Integer tolerance (Draw_Interpretor& di, Standard_Integer argc, const char** argv) @@ -830,6 +832,61 @@ static Standard_Integer getareacontour (Draw_Interpretor& di, return 0; } + +static Standard_Integer checkselfintersection + (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc < 2) + { + di<<"Call please \"checkselfintersection wire [face]\""<<"\n"; + return 1; + } + + // Get wire. + const char* arg1 = argv[1]; + TopoDS_Shape wire = DBRep::Get(arg1); + if (wire.IsNull() || wire.ShapeType() != TopAbs_WIRE) + { + di<<"A null shape or not a wire is used."<<"\n"; + return 2; + } + + // Get face if the user provided us with a face. + TopoDS_Shape face; + if (argc > 2) + { + const char* arg2 = argv[2]; + face = DBRep::Get(arg2); + if (face.IsNull() || face.ShapeType() != TopAbs_FACE) + { + di<<"A null shape or not a face is used."<<"\n"; + return 3; + } + } + + // If the face is null, make a plane inside the wire. + if (face.IsNull()) + { + BRepBuilderAPI_MakeFace mkFace(TopoDS::Wire(wire), true); + if (mkFace.IsDone()) + face = mkFace.Face(); + else + { + di<<"Can't make a face for the wire. Provide please a face for analysis."<<"\n"; + return 4; + } + } + + ShapeAnalysis_Wire analyser(TopoDS::Wire(wire), TopoDS::Face(face), Precision::Confusion()); + Standard_Boolean result = analyser.CheckSelfIntersection(); + + if (result == Standard_True) + di<<"A self-intersecting wire."<<"\n"; + else + di<<"Not self-intersecting wire."<<"\n"; + return 0; +} + //======================================================================= //function : InitCommands //purpose : @@ -866,4 +923,5 @@ static Standard_Integer getareacontour (Draw_Interpretor& di, __FILE__, MyVISEDG, groupold); theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold); + theCommands.Add ("checkselfintersection","wire [face]", __FILE__,checkselfintersection,g); } diff --git a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx index c62b08d048..13a471ae84 100755 --- a/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Wire.cxx @@ -395,7 +395,9 @@ void ShapeAnalysis_Wire::SetSurface (const Handle(Geom_Surface)& surface, Standard_Boolean isFail = Standard_False, isDone = Standard_False; for(Standard_Integer num1 = 1; num1 < nb-1; num1++) { - Standard_Integer fin = (num1 == 1 ? nb-1 : nb); + Standard_Integer fin = nb; + if (CheckClosed(Precision::Confusion()) && 1 == num1) + fin = nb-1; for(Standard_Integer num2 = num1+2; num2 <= fin; num2++) if(!boxes(num1).IsOut(boxes(num2))){ CheckIntersectingEdges(num1, num2);