|
|
|
booleanSurface.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::booleanSurface 00027 00028 Description 00029 Surface-surface intersection. Given two surfaces construct combined surface. 00030 00031 Called 'boolean' since the volume of resulting surface will encompass 00032 the volumes of the original surface according to some boolean operation: 00033 - all which is in surface1 AND in surface2 (intersection) 00034 - all which is in surface1 AND NOT in surface2 ('chop' out surface2) 00035 - all which is in surface1 OR in surface2 (union) 00036 00037 Algorithm: 00038 -# find edge-surface intersection. Class 'surfaceIntersection'. 00039 -# combine intersection with both surfaces. Class 'intersectedSurface'. 00040 -# subset surfaces upto intersection. The 'side' of the surface to 00041 include is based on the faces that can be reached from a 00042 user-supplied face index. 00043 -# merge surfaces. Only the points on the intersection are shared. 00044 00045 SourceFiles 00046 booleanSurface.C 00047 00048 \*---------------------------------------------------------------------------*/ 00049 00050 #ifndef booleanSurface_H 00051 #define booleanSurface_H 00052 00053 #include "triSurface.H" 00054 #include "surfaceIntersection.H" 00055 #include "typeInfo.H" 00056 00057 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00058 00059 namespace Foam 00060 { 00061 00062 // Forward declaration of classes 00063 class triSurfaceSearch; 00064 class intersectedSurface; 00065 00066 /*---------------------------------------------------------------------------*\ 00067 Class booleanSurface Declaration 00068 \*---------------------------------------------------------------------------*/ 00069 00070 class booleanSurface 00071 : 00072 public triSurface 00073 { 00074 // Data types 00075 00076 //- Enumeration listing the status of a face (visible/invisible from 00077 // outside) 00078 enum sideStat 00079 { 00080 UNVISITED, 00081 OUTSIDE, 00082 INSIDE 00083 }; 00084 00085 // Private data 00086 00087 //- From new to old face + surface: 00088 // >0 : to face on surface1 00089 // <0 : to face on surface2. Negate and offset by one to get 00090 // face2 (e.g. face2I = -faceMap[]-1) 00091 labelList faceMap_; 00092 00093 // Private Member Functions 00094 00095 //- Check whether subset of faces (from markZones) reaches up to 00096 // the intersection. 00097 static void checkIncluded 00098 ( 00099 const intersectedSurface& surf, 00100 const labelList& faceZone, 00101 const label includedFace 00102 ); 00103 00104 //- Get label in elems of elem. 00105 static label index(const labelList& elems, const label elem); 00106 00107 //- Find index of edge e in subset edgeLabels. 00108 static label findEdge 00109 ( 00110 const edgeList& edges, 00111 const labelList& edgeLabels, 00112 const edge& e 00113 ); 00114 00115 //- Get index of face in zoneI whose faceCentre is nearest farAwayPoint 00116 static label findNearest 00117 ( 00118 const triSurface& surf, 00119 const labelList& faceZone, 00120 const label zoneI 00121 ); 00122 00123 //- Generate combined patchList (returned). Sets patchMap to map from 00124 // surf region numbers into combined patchList 00125 static geometricSurfacePatchList mergePatches 00126 ( 00127 const triSurface& surf1, 00128 const triSurface& surf2, 00129 labelList& patchMap2 00130 ); 00131 00132 //- On edgeI, coming from face prevFace, determines visibility/side of 00133 // all the other faces using the edge. 00134 static void propagateEdgeSide 00135 ( 00136 const triSurface& surf, 00137 const label prevVert0, 00138 const label prevFaceI, 00139 const label prevState, 00140 const label edgeI, 00141 labelList& side 00142 ); 00143 00144 //- Given in/outside status of face determines status for all 00145 // neighbouring faces. 00146 static void propagateSide 00147 ( 00148 const triSurface& surf, 00149 const label prevState, 00150 const label faceI, 00151 labelList& side 00152 ); 00153 00154 public: 00155 00156 ClassName("booleanSurface"); 00157 00158 00159 // Data types 00160 00161 //- Enumeration listing the possible volume operator types 00162 enum booleanOpType 00163 { 00164 OR, // Union of volumes 00165 AND, // Intersection of volumes 00166 XOR, // Difference of volumes 00167 ALL // Special: does not subset combined surface. (Produces 00168 // multiply connected surface) 00169 }; 00170 00171 00172 // Constructors 00173 00174 //- Construct null 00175 booleanSurface(); 00176 00177 //- Construct from surfaces and face labels to keep. 00178 // Walks from provided seed faces without crossing intersection line 00179 // to determine faces to keep. 00180 booleanSurface 00181 ( 00182 const triSurface& surf1, 00183 const triSurface& surf2, 00184 const surfaceIntersection& inter, 00185 const label includeFace1, 00186 const label includeFace2 00187 ); 00188 00189 //- Construct from surfaces and operation. Surfaces need to be closed 00190 // for this to make any sense since uses inside/outside to determine 00191 // which part of combined surface to include. 00192 booleanSurface 00193 ( 00194 const triSurface& surf1, 00195 const triSurface& surf2, 00196 const surfaceIntersection& inter, 00197 const label booleanOp 00198 ); 00199 00200 00201 // Member Functions 00202 00203 //- new to old face map. >0: surface 1 face label. <0: surface 2. Negate 00204 // and subtract 1 to get face label on surface 2. 00205 const labelList& faceMap() const 00206 { 00207 return faceMap_; 00208 } 00209 00210 bool from1(const label faceI) const 00211 { 00212 return faceMap_[faceI] >= 0; 00213 } 00214 00215 bool surf1Face(const label faceI) const 00216 { 00217 if (!from1(faceI)) 00218 { 00219 FatalErrorIn("booleanSurface::surf1Face(const label)") 00220 << "face " << faceI << " not from surface 1" 00221 << abort(FatalError); 00222 } 00223 return faceMap_[faceI]; 00224 } 00225 00226 bool surf2Face(const label faceI) const 00227 { 00228 if (from1(faceI)) 00229 { 00230 FatalErrorIn("booleanSurface::surf2Face(const label)") 00231 << "face " << faceI << " not from surface 2" 00232 << abort(FatalError); 00233 } 00234 return -faceMap_[faceI]-1; 00235 } 00236 00237 00238 }; 00239 00240 00241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00242 00243 } // End namespace Foam 00244 00245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00246 00247 #endif 00248 00249 // ************************************************************************* // |