summaryrefslogtreecommitdiff
path: root/src/BOP/BOP_SolidBuilder.cxx
blob: c4ec8a2e6ab96b4633cc973121d1e8b83ba03883 (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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include <BOP_SolidBuilder.ixx>

#include <TopoDS.hxx>

#include <BOP_ShellFaceClassifier.hxx>
#include <BOP_Loop.hxx>
#include <BOP_SFSCorrector.hxx>



// ==============================================================
// function: BOP_SolidBuilder
// purpose: 
// ==============================================================
  BOP_SolidBuilder::BOP_SolidBuilder()
{
}

// ==============================================================
// function: BOP_SolidBuilder
// purpose: 
// ==============================================================
  BOP_SolidBuilder::BOP_SolidBuilder(BOP_ShellFaceSet&      theSFS,
				     const Standard_Boolean theForceClassFlag)
{
  InitSolidBuilder(theSFS, theForceClassFlag);
}

// ==============================================================
// function: InitSolidBuilder
// purpose: 
// ==============================================================
  void BOP_SolidBuilder::InitSolidBuilder(BOP_ShellFaceSet&      theSFS,
					  const Standard_Boolean theForceClassFlag) 
{
  //
  BOP_SFSCorrector aSFSCor;
  aSFSCor.SetSFS(theSFS);
  aSFSCor.Do();
  BOP_ShellFaceSet& aNewSFS=aSFSCor.NewSFS();
  //
  //MakeLoops(theSFS);
  
  MakeLoops(aNewSFS);
  BOP_ShellFaceClassifier SFC(myBlockBuilder);
  //
  mySolidAreaBuilder.InitSolidAreaBuilder(myLoopSet, SFC, theForceClassFlag);
}

// ==============================================================
// function: InitSolid
// purpose: 
// ==============================================================
  Standard_Integer BOP_SolidBuilder::InitSolid() 
{
  return mySolidAreaBuilder.InitArea();
}

// ==============================================================
// function: MoreSolid
// purpose: 
// ==============================================================
  Standard_Boolean BOP_SolidBuilder::MoreSolid() const
{
  return mySolidAreaBuilder.MoreArea();
}

// ==============================================================
// function: NextSolid
// purpose: 
// ==============================================================
  void BOP_SolidBuilder::NextSolid() 
{
  mySolidAreaBuilder.NextArea();
}

// ==============================================================
// function: InitShell
// purpose: 
// ==============================================================
  Standard_Integer BOP_SolidBuilder::InitShell() 
{
  return mySolidAreaBuilder.InitLoop();
}

// ==============================================================
// function: MoreShell
// purpose: 
// ==============================================================
  Standard_Boolean BOP_SolidBuilder::MoreShell() const
{
  return mySolidAreaBuilder.MoreLoop();
}

// ==============================================================
// function: NextShell
// purpose: 
// ==============================================================
  void BOP_SolidBuilder::NextShell() 
{
  mySolidAreaBuilder.NextLoop();
}

// ==============================================================
// function: IsOldShell
// purpose: 
// ==============================================================
  Standard_Boolean BOP_SolidBuilder::IsOldShell() const
{
  return mySolidAreaBuilder.Loop()->IsShape();  
}

// ==============================================================
// function: OldShell
// purpose: 
// ==============================================================
  TopoDS_Shell BOP_SolidBuilder::OldShell() const
{
  if(!IsOldShell()) {
    Standard_DomainError::Raise("BOP_SolidBuilder::OldShell");
  }
  
  return TopoDS::Shell(mySolidAreaBuilder.Loop()->Shape());
}

// ==============================================================
// function: InitFace
// purpose: 
// ==============================================================
  Standard_Integer BOP_SolidBuilder::InitFace() 
{
  const Handle(BOP_Loop)& aLoop = mySolidAreaBuilder.Loop();
  
  if(aLoop->IsShape())
    Standard_DomainError::Raise("BOP_SolidBuilder::InitFace");
  else {
    myBlockIterator = aLoop->BlockIterator();
    myBlockIterator.Initialize();
  }
  return myBlockIterator.Extent();
}

// ==============================================================
// function: MoreFace
// purpose: 
// ==============================================================
  Standard_Boolean BOP_SolidBuilder::MoreFace() const
{
  return myBlockIterator.More();
}

// ==============================================================
// function: NextFace
// purpose: 
// ==============================================================
  void BOP_SolidBuilder::NextFace() 
{
  myBlockIterator.Next();
}

// ==============================================================
// function: Face
// purpose: 
// ==============================================================
  const TopoDS_Face& BOP_SolidBuilder::Face() const
{
  const TopoDS_Shape& aShape = myBlockBuilder.Element(myBlockIterator);
  return TopoDS::Face(aShape);
}

// ==============================================================
// function: MakeLoops
// purpose: 
// ==============================================================
  void BOP_SolidBuilder::MakeLoops(BOP_ShapeSet& theSFS) 
{
  myBlockBuilder.MakeBlock(theSFS);

  BOP_ListOfLoop& aList = myLoopSet.ChangeListOfLoop();
  aList.Clear();

  // Add shapes of theSFS as shape loops
  for(theSFS.InitShapes(); theSFS.MoreShapes(); theSFS.NextShape()) {
    Handle(BOP_Loop) aShapeLoop = new BOP_Loop(theSFS.Shape());
    aList.Append(aShapeLoop);
  }

  // Add blocks of myBlockBuilder as block loops
  for(myBlockBuilder.InitBlock(); myBlockBuilder.MoreBlock(); myBlockBuilder.NextBlock()) {
    BOP_BlockIterator aBlockIterator = myBlockBuilder.BlockIterator();
    Handle(BOP_Loop) aShapeLoop = new BOP_Loop(aBlockIterator);
    aList.Append(aShapeLoop);
  }
}