#include <BRepGProp.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <ShapeAnalysis_ShapeContents.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <ShapeFix_FreeBounds.hxx>
#include <ShapeExtend_WireData.hxx>
+#include <ShapeAnalysis_Wire.hxx>
static Standard_Integer tolerance
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
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 :
__FILE__, MyVISEDG, groupold);
theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold);
+ theCommands.Add ("checkselfintersection","wire [face]", __FILE__,checkselfintersection,g);
}
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);