0023258: Missing parenthesis
[occt.git] / src / BRepAlgo / BRepAlgo_EdgeConnector.cxx
CommitLineData
b311480e 1// Created on: 1997-08-22
2// Created by: Prestataire Mary FABIEN
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <BRepAlgo_EdgeConnector.ixx>
24
25#include <TopoDS_Shape.hxx>
26#include <TopTools_ListOfShape.hxx>
27#include <TopTools_ListIteratorOfListOfShape.hxx>
28#include <TopoDS_Wire.hxx>
29#include <BRep_Builder.hxx>
30#include <TopOpeBRepBuild_ShapeSet.hxx>
31#include <TopOpeBRepBuild_BlockIterator.hxx>
32#include <TopOpeBRepBuild_BlockBuilder.hxx>
33#include <BRepAlgo_DataMapOfShapeBoolean.hxx>
34
35//=======================================================================
36//function : Create
37//purpose :
38//=======================================================================
39
40BRepAlgo_EdgeConnector::BRepAlgo_EdgeConnector()
41:myIsDone(Standard_False)
42{
43 myListeOfEdge.Clear();
44}
45
46//=======================================================================
47//function : Add
48//purpose :
49//=======================================================================
50
51void BRepAlgo_EdgeConnector::Add(const TopoDS_Edge& e)
52{
53 if(e.IsNull()) return;
54 myListeOfEdge.Append(e);
55}
56
57//=======================================================================
58//function : Add
59//purpose :
60//=======================================================================
61
62void BRepAlgo_EdgeConnector::Add(TopTools_ListOfShape& LOEdge)
63{
64 if(LOEdge.IsEmpty()) return;
65 myListeOfEdge.Append(LOEdge);
66}
67
68//=======================================================================
69//function : AddStart
70//purpose :
71//=======================================================================
72
73void BRepAlgo_EdgeConnector::AddStart(const TopoDS_Shape& e)
74{
75 if(e.IsNull()) return;
76 myListeOfStartEdge.Append(e);
77}
78
79//=======================================================================
80//function : AddStart
81//purpose :
82//=======================================================================
83
84void BRepAlgo_EdgeConnector::AddStart(TopTools_ListOfShape& LOEdge)
85{
86 if(LOEdge.IsEmpty()) return;
87 myListeOfStartEdge.Append(LOEdge);
88}
89
90//=======================================================================
91//function : ClearStartElement
92//purpose :
93//=======================================================================
94
95void BRepAlgo_EdgeConnector::ClearStartElement()
96{
97 myListeOfStartEdge.Clear();
98}
99
100//=======================================================================
101//function : MakeBlock
102//purpose :
103//=======================================================================
104
105TopTools_ListOfShape& BRepAlgo_EdgeConnector::MakeBlock()
106{
107 Standard_Boolean b;
108 if(myListeOfStartEdge.IsEmpty()) return myListeOfStartEdge;
109 TopOpeBRepBuild_ShapeSet SS(TopAbs_VERTEX);
110 myResultMap.Clear();
111 myResultList.Clear();
112 TopTools_ListIteratorOfListOfShape it(myListeOfEdge);
113 for(;it.More();it.Next()) {
114 const TopoDS_Shape& edge = it.Value();
115 SS.AddElement(edge);
116 }
117 it.Initialize(myListeOfStartEdge);
118 for(;it.More();it.Next()) {
119 const TopoDS_Shape& edge = it.Value();
120 SS.AddStartElement(edge);
121 }
122 myBlockB.MakeBlock(SS);
123 BRep_Builder WireB;
124 for(myBlockB.InitBlock();myBlockB.MoreBlock();myBlockB.NextBlock()) {
125//#ifndef DEB
126 TopOpeBRepBuild_BlockIterator BI = myBlockB.BlockIterator();
127//#else
128// TopOpeBRepBuild_BlockIterator& BI = myBlockB.BlockIterator();
129//#endif
130 TopoDS_Wire W;
131 WireB.MakeWire(W);
132 for(BI.Initialize();BI.More();BI.Next()) {
133 const TopoDS_Shape& CurrentE = myBlockB.Element(BI);
134 WireB.Add(W, CurrentE);
135 }
136 b = myBlockB.CurrentBlockIsRegular();
137 myResultMap.Bind(W, b);
138 myResultList.Append(W);
139 }
140 Done();
141 return myResultList;
142}
143
144//=======================================================================
145//function : IsWire
146//purpose :
147//=======================================================================
148
149Standard_Boolean BRepAlgo_EdgeConnector::IsWire(const TopoDS_Shape& S)
150{
151 if(!myResultMap.IsBound(S)) {
152 return Standard_False;
153 }
154 Standard_Boolean b = Standard_False;
155 myBlockB.InitBlock();
156 TopTools_ListIteratorOfListOfShape LI(myResultList);
157 for(;myBlockB.MoreBlock();myBlockB.NextBlock(),LI.Next()) {
158 if(S == LI.Value()) {
159 b = myBlockB.CurrentBlockIsRegular();
160 break;
161 }
162 }
163 return b;
164}
165
166//=======================================================================
167//function : IsDone
168//purpose :
169//=======================================================================
170
171
172Standard_Boolean BRepAlgo_EdgeConnector::IsDone() const
173{
174 return myIsDone;
175}
176
177//=======================================================================
178//function : Done
179//purpose :
180//=======================================================================
181
182
183void BRepAlgo_EdgeConnector::Done()
184{
185 myIsDone = Standard_True;
186}
187