summaryrefslogtreecommitdiff
path: root/src/BRepAlgo/BRepAlgo_EdgeConnector.cxx
blob: 68eeaaa5981b1471987a2b0a8d3fe2d97ae589fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// File:	BRepAlgo_EdgeConnector.cxx
// Created:	Fri Aug 22 11:47:30 1997
// Author:	Prestataire Mary FABIEN
//		<fbi@langdox.paris1.matra-dtv.fr>


#include <BRepAlgo_EdgeConnector.ixx>

#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS_Wire.hxx>
#include <BRep_Builder.hxx>
#include <TopOpeBRepBuild_ShapeSet.hxx>
#include <TopOpeBRepBuild_BlockIterator.hxx>
#include <TopOpeBRepBuild_BlockBuilder.hxx>
#include <BRepAlgo_DataMapOfShapeBoolean.hxx>

//=======================================================================
//function : Create
//purpose  : 
//=======================================================================

BRepAlgo_EdgeConnector::BRepAlgo_EdgeConnector()
:myIsDone(Standard_False)
{
  myListeOfEdge.Clear();
}

//=======================================================================
//function : Add
//purpose  : 
//=======================================================================

void BRepAlgo_EdgeConnector::Add(const TopoDS_Edge& e)
{
  if(e.IsNull()) return;
  myListeOfEdge.Append(e);
}

//=======================================================================
//function : Add
//purpose  : 
//=======================================================================

void BRepAlgo_EdgeConnector::Add(TopTools_ListOfShape& LOEdge)
{
  if(LOEdge.IsEmpty()) return;
  myListeOfEdge.Append(LOEdge);
}

//=======================================================================
//function : AddStart
//purpose  : 
//=======================================================================

void BRepAlgo_EdgeConnector::AddStart(const TopoDS_Shape& e)
{
  if(e.IsNull()) return;
  myListeOfStartEdge.Append(e);
}

//=======================================================================
//function : AddStart
//purpose  : 
//=======================================================================

void BRepAlgo_EdgeConnector::AddStart(TopTools_ListOfShape& LOEdge)
{
  if(LOEdge.IsEmpty()) return;
  myListeOfStartEdge.Append(LOEdge);
}

//=======================================================================
//function : ClearStartElement
//purpose  : 
//=======================================================================

void BRepAlgo_EdgeConnector::ClearStartElement()
{
  myListeOfStartEdge.Clear();
}

//=======================================================================
//function : MakeBlock
//purpose  : 
//=======================================================================

TopTools_ListOfShape& BRepAlgo_EdgeConnector::MakeBlock()
{
  Standard_Boolean b;
  if(myListeOfStartEdge.IsEmpty()) return myListeOfStartEdge;
  TopOpeBRepBuild_ShapeSet SS(TopAbs_VERTEX);
  myResultMap.Clear();
  myResultList.Clear();
  TopTools_ListIteratorOfListOfShape it(myListeOfEdge);
  for(;it.More();it.Next()) {
    const TopoDS_Shape& edge = it.Value();
    SS.AddElement(edge);
  }
  it.Initialize(myListeOfStartEdge);
  for(;it.More();it.Next()) {
    const TopoDS_Shape& edge = it.Value();
    SS.AddStartElement(edge);
  }
  myBlockB.MakeBlock(SS);
  BRep_Builder WireB;
  for(myBlockB.InitBlock();myBlockB.MoreBlock();myBlockB.NextBlock()) {
//#ifndef DEB
    TopOpeBRepBuild_BlockIterator BI = myBlockB.BlockIterator();
//#else
//    TopOpeBRepBuild_BlockIterator& BI = myBlockB.BlockIterator();
//#endif
    TopoDS_Wire W;
    WireB.MakeWire(W);
    for(BI.Initialize();BI.More();BI.Next()) {
      const TopoDS_Shape& CurrentE = myBlockB.Element(BI);
      WireB.Add(W, CurrentE);
    }
    b = myBlockB.CurrentBlockIsRegular();
    myResultMap.Bind(W, b);
    myResultList.Append(W);
  }
  Done();
  return myResultList;
}

//=======================================================================
//function : IsWire
//purpose  : 
//=======================================================================

Standard_Boolean BRepAlgo_EdgeConnector::IsWire(const TopoDS_Shape& S)
{
  if(!myResultMap.IsBound(S)) {
    return Standard_False;
  }
  Standard_Boolean b = Standard_False;
  myBlockB.InitBlock();
  TopTools_ListIteratorOfListOfShape LI(myResultList);
  for(;myBlockB.MoreBlock();myBlockB.NextBlock(),LI.Next()) {
    if(S == LI.Value()) {
      b = myBlockB.CurrentBlockIsRegular();
      break;
    }
  }
  return b;
}

//=======================================================================
//function : IsDone
//purpose  : 
//=======================================================================


Standard_Boolean BRepAlgo_EdgeConnector::IsDone() const
{
  return myIsDone;
}

//=======================================================================
//function : Done
//purpose  : 
//=======================================================================


void BRepAlgo_EdgeConnector::Done()
{
  myIsDone = Standard_True;
}