0031836: Modeling Algorithms - Boolean cut failed between a Cone and a Torus
[occt.git] / src / BOPAlgo / BOPAlgo_WireSplitter.lxx
1 // Created by: Peter KURNEV
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <BRep_Builder.hxx>
16 #include <BRep_Tool.hxx>
17
18 #include <TopoDS_Edge.hxx>
19
20 //=======================================================================
21 //function : BOPAlgo_EdgeInfo
22 //purpose  : 
23 //=======================================================================
24 class BOPAlgo_EdgeInfo {
25  public:
26   //
27   BOPAlgo_EdgeInfo() : 
28     myPassed(Standard_False),
29     myInFlag(Standard_False),
30     myIsInside (Standard_False),
31     myAngle (-1.)
32   {
33   };
34   //
35   void SetEdge(const TopoDS_Edge& theE) {
36     myEdge=theE;
37   };
38   //
39   const TopoDS_Edge& Edge() const{
40     return myEdge;
41   };
42   //
43   void SetPassed(const Standard_Boolean theFlag) {
44     myPassed=theFlag;
45   };
46   //
47   Standard_Boolean Passed()const {
48     return myPassed;
49   };
50   //
51   void SetInFlag(const Standard_Boolean theFlag) {
52     myInFlag=theFlag;
53   };
54   //
55   Standard_Boolean IsIn()const {
56     return myInFlag;
57   };
58   //
59   void SetAngle(const Standard_Real theAngle) {
60     myAngle=theAngle;
61   };
62   //
63   Standard_Real Angle()const {
64     return myAngle;
65   };
66   //
67   Standard_Boolean IsInside() const {
68     return myIsInside;
69   };
70   //
71   void SetIsInside (const Standard_Boolean theIsInside) {
72     myIsInside = theIsInside;
73   };
74   //
75  protected:
76   TopoDS_Edge myEdge;
77   Standard_Boolean myPassed;
78   Standard_Boolean myInFlag;
79   Standard_Boolean myIsInside;
80   Standard_Real myAngle;
81 };
82
83
84 #include <NCollection_List.hxx> 
85 typedef NCollection_List<BOPAlgo_EdgeInfo> BOPAlgo_ListOfEdgeInfo; 
86 typedef BOPAlgo_ListOfEdgeInfo::Iterator BOPAlgo_ListIteratorOfListOfEdgeInfo;  
87
88 #include <NCollection_IndexedDataMap.hxx>
89 #include <TopTools_ShapeMapHasher.hxx>
90
91 typedef NCollection_IndexedDataMap<TopoDS_Shape, \
92   BOPAlgo_ListOfEdgeInfo, \
93   TopTools_ShapeMapHasher> BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo; 
94
95 //=======================================================================
96 //function : MakeWire
97 //purpose  : 
98 //=======================================================================
99   inline void BOPAlgo_WireSplitter::MakeWire(TopTools_ListOfShape& aLE, 
100                                              TopoDS_Wire& aWire)
101 {
102   BRep_Builder aBB;
103   aBB.MakeWire(aWire);
104   //
105   TopTools_ListIteratorOfListOfShape aIt(aLE);
106   for (; aIt.More(); aIt.Next()){
107     aBB.Add(aWire, aIt.Value());
108   }
109   aWire.Closed(BRep_Tool::IsClosed(aWire));
110 }