|
|
|
surfaceIntersection.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::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 #include "pointIndexHit.H" 00067 00068 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00069 00070 namespace Foam 00071 { 00072 00073 // Forward declaration of classes 00074 class triSurfaceSearch; 00075 class triSurface; 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 List<DynamicList<..> > to List<List<..>> 00124 template<class T> 00125 static void transfer(List<DynamicList<T> >&, List<List<T> >&); 00126 00127 //- Get minimum length of all edges connected to point 00128 static scalar minEdgeLen(const triSurface& surf, const label pointI); 00129 00130 //- Get edge label of edge between face vertices fp and fp+1 00131 static label getEdge 00132 ( 00133 const triSurface& surf, 00134 const label faceI, 00135 const label fp 00136 ); 00137 00138 //- Remove duplicates from ordered dynamic list. Returns map from old 00139 // to new (-1 if element removed) 00140 static void removeDuplicates(const labelList& map, labelList& labels); 00141 00142 //- Apply map to elements of a labelList 00143 static void inlineRemap(const labelList& map, labelList& elems); 00144 00145 // Remove all duplicate and degenerate elements. Return unique elements 00146 // and map from old to new. 00147 static edgeList filterEdges(const edgeList&, labelList& map); 00148 00149 //- Remove all duplicate elements. 00150 static labelList filterLabels(const labelList& elems, labelList& map); 00151 00152 //- Do some checks if edge and face (resulting from hit) 00153 // should not be considered. Returns true if can be discarded. 00154 static bool excludeEdgeHit 00155 ( 00156 const triSurface& surf, 00157 const label edgeI, 00158 const label faceI, 00159 const scalar tol 00160 ); 00161 00165 //static pointIndexHit faceEdgeIntersection 00166 //( 00167 // const triSurface&, 00168 // const label hitFaceI, 00169 // 00170 // const vector& n, 00171 // const point& eStart, 00172 // const point& eEnd 00173 //); 00174 00175 00176 //- Debugging: Dump intersected edges to stream 00177 void writeIntersectedEdges 00178 ( 00179 const triSurface& surf, 00180 const labelListList& edgeCutVerts, 00181 Ostream& os 00182 ) const; 00183 00184 //- Detect if point close to edge of end. Returns -1: not close. 00185 // 0:close (within startTol) to start, 1:close (within endTol) to end 00186 static label classify 00187 ( 00188 const scalar startTol, 00189 const scalar endTol, 00190 const point& p, 00191 const edge& e, 00192 const pointField& points 00193 ); 00194 00195 //- Update reference between faceA and faceB. Updates facePairToVertex_ 00196 // (first occurrence of face pair) and facePairToEdge_ (second occ.) 00197 void storeIntersection 00198 ( 00199 const bool isFirstSurf, 00200 const labelList& facesA, 00201 const label faceB, 00202 DynamicList<edge>&, 00203 DynamicList<point>& 00204 ); 00205 00206 //- Investigate pHit to whether is case of point hits point, 00207 // point hits edge, point hits face or edge hits face. 00208 void classifyHit 00209 ( 00210 const triSurface& surf1, 00211 const scalarField& surf1PointTol, 00212 const triSurface& surf2, 00213 const bool isFirstSurf, 00214 const label edgeI, 00215 const scalar tolDim, 00216 const pointIndexHit& pHit, 00217 00218 DynamicList<edge>& allCutEdges, 00219 DynamicList<point>& allCutPoints, 00220 List<DynamicList<label> >& surfEdgeCuts 00221 ); 00222 00223 //- Cut edges of surf1 with surface 2. 00224 void doCutEdges 00225 ( 00226 const triSurface& surf1, 00227 const triSurfaceSearch& querySurf2, 00228 const bool isFirstSurf, 00229 const bool isSelfIntersection, 00230 00231 DynamicList<edge>& allCutEdges, 00232 DynamicList<point>& allCutPoints, 00233 List<DynamicList<label> >& surfEdgeCuts 00234 ); 00235 00236 public: 00237 00238 ClassName("surfaceIntersection"); 00239 00240 00241 // Constructors 00242 00243 //- Construct null 00244 surfaceIntersection(); 00245 00246 //- Construct from precalculated intersection information. 00247 // Advantage: intersection information is guaranteed to have no 00248 // degenerate cuts. 00249 surfaceIntersection 00250 ( 00251 const triSurface& surf1, 00252 const edgeIntersections& intersections1, 00253 const triSurface& surf2, 00254 const edgeIntersections& intersections2 00255 ); 00256 00257 //- Construct from two surfaces. Does all its own cutting. 00258 // Has problems with degenerate cuts 00259 surfaceIntersection 00260 ( 00261 const triSurfaceSearch& querySurf1, 00262 const triSurfaceSearch& querySurf2 00263 ); 00264 00265 //- Special: intersect surface with itself. Used to check for 00266 // self-intersection. 00267 surfaceIntersection(const triSurfaceSearch& querySurf1); 00268 00269 00270 // Member Functions 00271 00272 const pointField& cutPoints() const; 00273 00274 const edgeList& cutEdges() const; 00275 00276 //const labelPairLookup& facePairToVertex() const; 00277 00278 const labelPairLookup& facePairToEdge() const; 00279 00280 //- Access either surf1EdgeCuts (isFirstSurface = true) or 00281 // surf2EdgeCuts 00282 const labelListList& edgeCuts(const bool) const; 00283 00284 const labelListList& surf1EdgeCuts() const; 00285 00286 const labelListList& surf2EdgeCuts() const; 00287 00288 }; 00289 00290 00291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00292 00293 } // End namespace Foam 00294 00295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00296 00297 #ifdef NoRepository 00298 # include "surfaceIntersectionTemplates.C" 00299 #endif 00300 00301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00302 00303 #endif 00304 00305 // ************************************************************************* // |