1 // Created on: 1998-09-16
2 // Created by: Roman LYGIN
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // 25.12.98 pdn: renaming methods GetWires and GetEdges to GetClosedWires
18 // and GetOpenWires respectively
20 #include <BRep_Builder.hxx>
21 #include <ShapeAnalysis_FreeBounds.hxx>
22 #include <ShapeExtend_Explorer.hxx>
23 #include <ShapeFix_FreeBounds.hxx>
24 #include <TopExp_Explorer.hxx>
26 #include <TopoDS_Compound.hxx>
27 #include <TopoDS_Edge.hxx>
28 #include <TopoDS_Iterator.hxx>
29 #include <TopoDS_Shape.hxx>
30 #include <TopoDS_Vertex.hxx>
31 #include <TopTools_DataMapOfShapeShape.hxx>
33 //=======================================================================
34 //function : ShapeFix_FreeBounds
36 //=======================================================================
37 ShapeFix_FreeBounds::ShapeFix_FreeBounds()
38 : myShared(Standard_False),
41 mySplitClosed(Standard_False),
42 mySplitOpen(Standard_False)
46 //=======================================================================
47 //function : ShapeFix_FreeBounds
49 //=======================================================================
51 ShapeFix_FreeBounds::ShapeFix_FreeBounds(const TopoDS_Shape& shape,
52 const Standard_Real sewtoler,
53 const Standard_Real closetoler,
54 const Standard_Boolean splitclosed,
55 const Standard_Boolean splitopen) :
56 myShared (Standard_False), mySewToler (sewtoler), myCloseToler (closetoler),
57 mySplitClosed (splitclosed), mySplitOpen (splitopen)
63 //=======================================================================
64 //function : ShapeFix_FreeBounds
66 //=======================================================================
68 ShapeFix_FreeBounds::ShapeFix_FreeBounds(const TopoDS_Shape& shape,
69 const Standard_Real closetoler,
70 const Standard_Boolean splitclosed,
71 const Standard_Boolean splitopen):
72 myShared (Standard_True), mySewToler (0.), myCloseToler (closetoler),
73 mySplitClosed (splitclosed), mySplitOpen (splitopen)
79 //=======================================================================
82 //=======================================================================
84 Standard_Boolean ShapeFix_FreeBounds::Perform()
86 ShapeAnalysis_FreeBounds safb;
88 safb = ShapeAnalysis_FreeBounds (myShape, mySplitClosed, mySplitOpen);
90 safb = ShapeAnalysis_FreeBounds (myShape, mySewToler, mySplitClosed, mySplitOpen);
92 myWires = safb.GetClosedWires();
93 myEdges = safb.GetOpenWires();
95 if (myCloseToler > mySewToler) {
96 ShapeExtend_Explorer see;
97 Handle(TopTools_HSequenceOfShape) newwires,
98 open = see.SeqFromCompound (myEdges,
100 TopTools_DataMapOfShapeShape vertices;
101 ShapeAnalysis_FreeBounds::ConnectWiresToWires (open, myCloseToler, myShared,
104 ShapeAnalysis_FreeBounds::DispatchWires (newwires, myWires, myEdges);
106 for( TopExp_Explorer exp (myShape, TopAbs_EDGE); exp.More(); exp.Next()) {
107 TopoDS_Edge Edge = TopoDS::Edge(exp.Current());
108 for( TopoDS_Iterator iter (Edge); iter.More(); iter.Next()) {
109 TopoDS_Vertex V = TopoDS::Vertex (iter.Value());
112 if( vertices.IsBound(V)) {
113 newV = TopoDS::Vertex (vertices.Find(V));
114 newV.Orientation(V.Orientation());
121 return Standard_True;