![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 surfaceIntersection 00027 00028 Description 00029 Basic surface-surface intersection description. Constructed from two 00030 surfaces it creates a description of the intersection. 00031 00032 The intersection information consists of the intersection line(s) 00033 with new points, new edges between points (note that these edges and 00034 points are on both surfaces) and various addressing from original 00035 surface faces/edges to intersection and vice versa. 00036 00037 Gets either precalculated intersection information or calculates it 00038 itself. 00039 Algorithm works by intersecting all edges of one surface with the other 00040 surface and storing a reference from both faces (one on surface1, one on 00041 surface 2) to the vertex. If the reference re-occurs we have the second 00042 hit of both faces and an edge is created between the retrieved vertex and 00043 the new one. 00044 00045 Note: when doing intersecting itself uses intersection::planarTol() as a 00046 fraction of 00047 current edge length to determine if intersection is a point-touching one 00048 instead of an edge-piercing action. 00049 00050 SourceFiles 00051 surfaceIntersection.C 00052 surfaceIntersectionFuncs.C 00053 surfaceIntersectionTemplates.C 00054 00055 \*---------------------------------------------------------------------------*/ 00056 00057 #ifndef surfaceIntersection_H 00058 #define surfaceIntersection_H 00059 00060 #include "DynamicList.H" 00061 #include "point.H" 00062 #include "edge.H" 00063 #include "labelPairLookup.H" 00064 #include "typeInfo.H" 00065 #include "edgeList.H" 00066 00067 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00068 00069 namespace Foam 00070 { 00071 00072 // Class forward declarations 00073 class triSurfaceSearch; 00074 class triSurface; 00075 class pointIndexHit; 00076 class edgeIntersections; 00077 00078 /*---------------------------------------------------------------------------*\ 00079 Class surfaceIntersection Declaration 00080 \*---------------------------------------------------------------------------*/ 00081 00082 class surfaceIntersection 00083 { 00084 // Private data 00085 00086 //- Newly introduced points. 00087 pointField cutPoints_; 00088 00089 //- Newly introduced edges (are on both surfaces). Reference into 00090 // cutPoints. 00091 edgeList cutEdges_; 00092 00093 //- From face on surf1 and face on surf2 to intersection point 00094 // (label in cutPoints) 00095 labelPairLookup facePairToVertex_; 00096 00097 //- From face on surf1 and face on surf2 to intersection edge 00098 // (label in cutEdges) 00099 labelPairLookup facePairToEdge_; 00100 00101 //- Edges on surf1 that are cut. From edge on surf1 to label in cutPoint 00102 // If multiple cuts:sorted from edge.start to edge.end 00103 labelListList surf1EdgeCuts_; 00104 00105 //- Edges on surf2 that are cut. From edge on surf2 to label in cutPoint 00106 // If multiple cuts:sorted from edge.start to edge.end 00107 labelListList surf2EdgeCuts_; 00108 00109 00110 // Private Member Functions 00111 00112 //- Write point in obj format. 00113 static void writeOBJ(const point& pt, Ostream& os); 00114 00115 //- Write points and edges in obj format 00116 static void writeOBJ 00117 ( 00118 const List<point>&, 00119 const List<edge>&, 00120 Ostream& 00121 ); 00122 00123 //- Transfer contents of DynamicList to straight List 00124 template<class T> 00125 static void transfer(DynamicList<T>&, List<T>&); 00126 00127 //- Transfer contents of List<DynamicList<..> > to List<List<..>> 00128 template<class T> 00129 static void transfer(List<DynamicList<T> >&, List<List<T> >&); 00130 00131 //- Get minimum length of all edges connected to point 00132 static scalar minEdgeLen(const triSurface& surf, const label pointI); 00133 00134 //- Get edge label of edge between face vertices fp and fp+1 00135 static label getEdge 00136 ( 00137 const triSurface& surf, 00138 const label faceI, 00139 const label fp 00140 ); 00141 00142 //- Remove duplicates from ordered dynamic list. Returns map from old 00143 // to new (-1 if element removed) 00144 static void removeDuplicates(const labelList& map, labelList& labels); 00145 00146 //- Apply map to elements of a labelList 00147 static void inlineRemap(const labelList& map, labelList& elems); 00148 00149 // Remove all duplicate and degenerate elements. Return unique elements 00150 // and map from old to new. 00151 static edgeList filterEdges(const edgeList&, labelList& map); 00152 00153 //- Remove all duplicate elements. 00154 static labelList filterLabels(const labelList& elems, labelList& map); 00155 00156 //- Do some checks if edge and face (resulting from hit) 00157 // should not be considered. Returns true if can be discarded. 00158 static bool excludeEdgeHit 00159 ( 00160 const triSurface& surf, 00161 const label edgeI, 00162 const label faceI, 00163 const scalar tol 00164 ); 00165 00169 //static pointIndexHit faceEdgeIntersection 00170 //( 00171 // const triSurface&, 00172 // const label hitFaceI, 00173 // 00174 // const vector& n, 00175 // const point& eStart, 00176 // const point& eEnd 00177 //); 00178 00179 00180 //- Debugging: Dump intersected edges to stream 00181 void writeIntersectedEdges 00182 ( 00183 const triSurface& surf, 00184 const labelListList& edgeCutVerts, 00185 Ostream& os 00186 ) const; 00187 00188 //- Detect if point close to edge of end. Returns -1: not close. 00189 // 0:close (within startTol) to start, 1:close (within endTol) to end 00190 static label classify 00191 ( 00192 const scalar startTol, 00193 const scalar endTol, 00194 const point& p, 00195 const edge& e, 00196 const pointField& points 00197 ); 00198 00199 //- Update reference between faceA and faceB. Updates facePairToVertex_ 00200 // (first occurrence of face pair) and facePairToEdge_ (second occ.) 00201 void storeIntersection 00202 ( 00203 const bool isFirstSurf, 00204 const labelList& facesA, 00205 const label faceB, 00206 DynamicList<edge>&, 00207 DynamicList<point>& 00208 ); 00209 00210 //- Investigate pHit to whether is case of point hits point, 00211 // point hits edge, point hits face or edge hits face. 00212 void classifyHit 00213 ( 00214 const triSurface& surf1, 00215 const scalarField& surf1PointTol, 00216 const triSurface& surf2, 00217 const bool isFirstSurf, 00218 const label edgeI, 00219 const scalar tolDim, 00220 const pointIndexHit& pHit, 00221 00222 DynamicList<edge>& allCutEdges, 00223 DynamicList<point>& allCutPoints, 00224 List<DynamicList<label> >& surfEdgeCuts 00225 ); 00226 00227 //- Cut edges of surf1 with surface 2. 00228 void doCutEdges 00229 ( 00230 const triSurface& surf1, 00231 const triSurfaceSearch& querySurf2, 00232 const bool isFirstSurf, 00233 const bool isSelfIntersection, 00234 00235 DynamicList<edge>& allCutEdges, 00236 DynamicList<point>& allCutPoints, 00237 List<DynamicList<label> >& surfEdgeCuts 00238 ); 00239 00240 public: 00241 00242 ClassName("surfaceIntersection"); 00243 00244 00245 // Constructors 00246 00247 //- Construct null 00248 surfaceIntersection(); 00249 00250 //- Construct from precalculated intersection information. 00251 // Advantage: intersection information is guaranteed to have no 00252 // degenerate cuts. 00253 surfaceIntersection 00254 ( 00255 const triSurface& surf1, 00256 const edgeIntersections& intersections1, 00257 const triSurface& surf2, 00258 const edgeIntersections& intersections2 00259 ); 00260 00261 //- Construct from two surfaces. Does all its own cutting. 00262 // Has problems with degenerate cuts 00263 surfaceIntersection 00264 ( 00265 const triSurfaceSearch& querySurf1, 00266 const triSurfaceSearch& querySurf2 00267 ); 00268 00269 //- Special: intersect surface with itself. Used to check for 00270 // self-intersection. 00271 surfaceIntersection(const triSurfaceSearch& querySurf1); 00272 00273 00274 // Member Functions 00275 00276 const pointField& cutPoints() const; 00277 00278 const edgeList& cutEdges() const; 00279 00280 //const labelPairLookup& facePairToVertex() const; 00281 00282 const labelPairLookup& facePairToEdge() const; 00283 00284 //- Access either surf1EdgeCuts (isFirstSurface = true) or 00285 // surf2EdgeCuts 00286 const labelListList& edgeCuts(const bool) const; 00287 00288 const labelListList& surf1EdgeCuts() const; 00289 00290 const labelListList& surf2EdgeCuts() const; 00291 00292 }; 00293 00294 00295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00296 00297 } // End namespace Foam 00298 00299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00300 00301 #ifdef NoRepository 00302 # include "surfaceIntersectionTemplates.C" 00303 #endif 00304 00305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00306 00307 #endif 00308 00309 // ************************************************************************* //