Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
meshTools
triSurface
booleanOps
intersectedSurface
intersectedSurface.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
11
OpenFOAM is free software: you can redistribute it and/or modify it
12
under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::intersectedSurface
26
27
Description
28
Given triSurface and intersection creates the intersected
29
(properly triangulated) surface.
30
(note: intersection is the list of points and edges 'shared'
31
by two surfaces)
32
33
Algorithm:
34
- from the intersection get the points created on the edges of the surface
35
- split the edges of the surface
36
- construct a new edgeList with (in this order) the edges from the
37
intersection ('cuts', i.e. the edges shared with the other surface)
38
and the (split) edges from the original triangles (from 0 ..
39
nSurfaceEdges)
40
- construct face-edge addressing for above edges
41
- for each face do a right-handed walk to reconstruct faces (splitFace)
42
- retriangulate resulting faces (might be non-convex so use
43
faceTriangulation which does proper bisection)
44
45
The resulting surface will have the points from the surface first
46
in the point list (0 .. nSurfacePoints-1)
47
48
Note: problematic are the cut-edges which are completely inside a face.
49
These will not be visited by a edge-point-edge walk. These are handled by
50
resplitFace which first connects the 'floating' edges to triangle edges
51
with two extra edges and then tries the splitting again. Seems to work
52
(mostly). Will probably fail for boundary edge (edge with only face).
53
54
Note: points are compact, i.e. points().size() == localPoints().size()
55
(though points() probably not localPoints())
56
57
SourceFiles
58
intersectedSurface.C
59
60
\*---------------------------------------------------------------------------*/
61
62
#ifndef intersectedSurface_H
63
#define intersectedSurface_H
64
65
#include <
triSurface/triSurface.H
>
66
#include <
OpenFOAM/Map.H
>
67
#include <
OpenFOAM/typeInfo.H
>
68
69
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70
71
namespace
Foam
72
{
73
74
// Forward declaration of classes
75
class
surfaceIntersection;
76
class
edgeSurface;
77
78
/*---------------------------------------------------------------------------*\
79
Class intersectedSurface Declaration
80
\*---------------------------------------------------------------------------*/
81
82
class
intersectedSurface
83
:
84
public
triSurface
85
{
86
public
:
87
88
static
const
label
UNVISITED
;
89
static
const
label
STARTTOEND
;
90
static
const
label
ENDTOSTART
;
91
static
const
label
BOTH
;
92
93
private
:
94
95
// Private data
96
97
//- Edges which are part of intersection
98
labelList
intersectionEdges_;
99
100
//- From new to original faces
101
labelList
faceMap_;
102
103
//- What are surface points: 0 .. nSurfacePoints_-1
104
label nSurfacePoints_;
105
106
107
// Static Member Functions
108
109
//- Debug:Dump edges to stream. Mantains vertex numbering
110
static
void
writeOBJ
111
(
112
const
pointField
&
points
,
113
const
edgeList
&
edges
,
114
Ostream
& os
115
);
116
117
//- Debug:Dump selected edges to stream. Mantains vertex numbering
118
static
void
writeOBJ
119
(
120
const
pointField
&
points
,
121
const
edgeList
&
edges
,
122
const
labelList
&
faceEdges
,
123
Ostream
& os
124
);
125
126
//- Debug:Dump selected edges to stream. Renumbers vertices to local ordering.
127
static
void
writeLocalOBJ
128
(
129
const
pointField
&
points
,
130
const
edgeList
&
edges
,
131
const
labelList
&
faceEdges
,
132
const
fileName
&
133
);
134
135
//- Debug:Write whole pointField and face to stream
136
static
void
writeOBJ
137
(
138
const
pointField
&
points
,
139
const
face
&
f
,
140
Ostream
& os
141
);
142
143
//- Debug:Print visited status
144
static
void
printVisit
145
(
146
const
edgeList
&
edges
,
147
const
labelList
& edgeLabels,
148
const
Map<label>
& visited
149
);
150
151
152
//- Check if the two vertices that f0 and f1 share are in the same
153
// order on both faces.
154
static
bool
sameEdgeOrder
155
(
156
const
labelledTri
& fA,
157
const
labelledTri
& fB
158
);
159
160
//- Increment data for key. (start from 0 if not found)
161
static
void
incCount
162
(
163
Map<label>
& visited,
164
const
label key,
165
const
label offset
166
);
167
168
//- Calculate point-edge addressing for single face only.
169
static
Map<DynamicList<label>
> calcPointEdgeAddressing
170
(
171
const
edgeSurface
&,
172
const
label faceI
173
);
174
175
//- Choose edge out of candidates (facePointEdges) according to
176
// angle with previous edge.
177
static
label nextEdge
178
(
179
const
edgeSurface
& eSurf,
180
const
Map<label>
& visited,
181
const
label faceI,
182
const
vector
& n,
// original triangle normal
183
const
Map
<
DynamicList<label>
>& facePointEdges,
184
const
label prevEdgeI,
185
const
label prevVertI
186
);
187
188
//- Walk path along edges in face. Used by splitFace.
189
static
face
walkFace
190
(
191
const
edgeSurface
& eSurf,
192
const
label faceI,
193
const
vector
& n,
194
const
Map
<
DynamicList<label>
>& facePointEdges,
195
196
const
label startEdgeI,
197
const
label startVertI,
198
199
Map<label>
& visited
200
);
201
202
//- For resplitFace: find nearest (to pt) fully visited point. Return
203
// point and distance.
204
static
void
findNearestVisited
205
(
206
const
edgeSurface
& eSurf,
207
const
label faceI,
208
const
Map
<
DynamicList<label>
>& facePointEdges,
209
const
Map<label>
& pointVisited,
210
const
point
& pt,
211
const
label excludeFaceI,
212
213
label& minVertI,
214
scalar& minDist
215
);
216
217
218
//- Fallback for if splitFace fails to connect all.
219
static
faceList
resplitFace
220
(
221
const
triSurface
& surf,
222
const
label faceI,
223
const
Map
<
DynamicList<label>
>& facePointEdges,
224
const
Map<label>
& visited,
225
edgeSurface
& eSurf
226
);
227
228
//- Main face splitting routine. Gets overall points and edges and
229
// owners and face-local edgeLabels. Returns list of faces.
230
static
faceList
splitFace
231
(
232
const
triSurface
& surf,
233
const
label faceI,
234
edgeSurface
& eSurf
235
);
236
237
238
// Private Member Functions
239
240
241
public
:
242
243
ClassName
(
"intersectedSurface"
);
244
245
246
// Constructors
247
248
//- Construct null
249
intersectedSurface
();
250
251
//- Construct from surface
252
intersectedSurface
(
const
triSurface
& surf);
253
254
//- Construct from surface and intersection. isFirstSurface is needed
255
// to determine which side of face pairs stored in the intersection
256
// to address. Should be in the same order as how the intersection was
257
// constructed.
258
intersectedSurface
259
(
260
const
triSurface
& surf,
261
const
bool
isFirstSurface,
262
const
surfaceIntersection
& inter
263
);
264
265
// Member Functions
266
267
//- Labels of edges in *this which originate from 'cuts'
268
const
labelList
&
intersectionEdges
()
const
269
{
270
return
intersectionEdges_;
271
}
272
273
//- New to old
274
const
labelList
&
faceMap
()
const
275
{
276
return
faceMap_;
277
}
278
279
//- Number of points from original surface
280
label
nSurfacePoints
()
const
281
{
282
return
nSurfacePoints_;
283
}
284
285
//- Is point coming from original surface?
286
bool
isSurfacePoint
(
const
label pointI)
const
287
{
288
return
pointI < nSurfacePoints_;
289
}
290
};
291
292
293
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294
295
}
// End namespace Foam
296
297
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298
299
#endif
300
301
// ************************ vim: set sw=4 sts=4 et: ************************ //