1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Surface-surface intersection. Given two surfaces construct combined surface.
31 Called 'boolean' since the volume of resulting surface will encompass
32 the volumes of the original surface according to some boolean operation:
33 - all which is in surface1 AND in surface2 (intersection)
34 - all which is in surface1 AND NOT in surface2 ('chop' out surface2)
35 - all which is in surface1 OR in surface2 (union)
38 -# find edge-surface intersection. Class 'surfaceIntersection'.
39 -# combine intersection with both surfaces. Class 'intersectedSurface'.
40 -# subset surfaces upto intersection. The 'side' of the surface to
41 include is based on the faces that can be reached from a
42 user-supplied face index.
43 -# merge surfaces. Only the points on the intersection are shared.
48 \*---------------------------------------------------------------------------*/
50 #ifndef booleanSurface_H
51 #define booleanSurface_H
53 #include "triSurface.H"
54 #include "surfaceIntersection.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 // Forward declaration of classes
63 class triSurfaceSearch;
64 class intersectedSurface;
66 /*---------------------------------------------------------------------------*\
67 Class booleanSurface Declaration
68 \*---------------------------------------------------------------------------*/
76 //- Enumeration listing the status of a face (visible/invisible from
87 //- From new to old face + surface:
88 // >0 : to face on surface1
89 // <0 : to face on surface2. Negate and offset by one to get
90 // face2 (e.g. face2I = -faceMap[]-1)
93 // Private Member Functions
95 //- Check whether subset of faces (from markZones) reaches up to
97 static void checkIncluded
99 const intersectedSurface& surf,
100 const labelList& faceZone,
101 const label includedFace
104 //- Get label in elems of elem.
105 static label index(const labelList& elems, const label elem);
107 //- Find index of edge e in subset edgeLabels.
108 static label findEdge
110 const edgeList& edges,
111 const labelList& edgeLabels,
115 //- Get index of face in zoneI whose faceCentre is nearest farAwayPoint
116 static label findNearest
118 const triSurface& surf,
119 const labelList& faceZone,
123 //- Generate combined patchList (returned). Sets patchMap to map from
124 // surf region numbers into combined patchList
125 static geometricSurfacePatchList mergePatches
127 const triSurface& surf1,
128 const triSurface& surf2,
132 //- On edgeI, coming from face prevFace, determines visibility/side of
133 // all the other faces using the edge.
134 static void propagateEdgeSide
136 const triSurface& surf,
137 const label prevVert0,
138 const label prevFaceI,
139 const label prevState,
144 //- Given in/outside status of face determines status for all
145 // neighbouring faces.
146 static void propagateSide
148 const triSurface& surf,
149 const label prevState,
156 ClassName("booleanSurface");
161 //- Enumeration listing the possible volume operator types
164 OR, // Union of volumes
165 AND, // Intersection of volumes
166 XOR, // Difference of volumes
167 ALL // Special: does not subset combined surface. (Produces
168 // multiply connected surface)
177 //- Construct from surfaces and face labels to keep.
178 // Walks from provided seed faces without crossing intersection line
179 // to determine faces to keep.
182 const triSurface& surf1,
183 const triSurface& surf2,
184 const surfaceIntersection& inter,
185 const label includeFace1,
186 const label includeFace2
189 //- Construct from surfaces and operation. Surfaces need to be closed
190 // for this to make any sense since uses inside/outside to determine
191 // which part of combined surface to include.
194 const triSurface& surf1,
195 const triSurface& surf2,
196 const surfaceIntersection& inter,
197 const label booleanOp
203 //- new to old face map. >0: surface 1 face label. <0: surface 2. Negate
204 // and subtract 1 to get face label on surface 2.
205 const labelList& faceMap() const
210 bool from1(const label faceI) const
212 return faceMap_[faceI] >= 0;
215 bool surf1Face(const label faceI) const
219 FatalErrorIn("booleanSurface::surf1Face(const label)")
220 << "face " << faceI << " not from surface 1"
221 << abort(FatalError);
223 return faceMap_[faceI];
226 bool surf2Face(const label faceI) const
230 FatalErrorIn("booleanSurface::surf2Face(const label)")
231 << "face " << faceI << " not from surface 2"
232 << abort(FatalError);
234 return -faceMap_[faceI]-1;
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 } // End namespace Foam
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 // ************************************************************************* //