00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::edgeIntersections 00026 00027 Description 00028 Holder of intersections of edges of a surface with another surface. 00029 Optionally shuffles around points on surface to resolve any 'conflicts' 00030 (edge hitting triangle edge, edge hitting point etc.). 00031 00032 SourceFiles 00033 edgeIntersections.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef edgeIntersections_H 00038 #define edgeIntersections_H 00039 00040 #include <meshTools/pointIndexHit.H> 00041 #include <OpenFOAM/scalarField.H> 00042 #include <OpenFOAM/pointField.H> 00043 #include <OpenFOAM/typeInfo.H> 00044 #include <OpenFOAM/boolList.H> 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 namespace Foam 00049 { 00050 00051 // Forward declaration of classes 00052 class triSurface; 00053 class triSurfaceSearch; 00054 class Random; 00055 class edge; 00056 00057 /*---------------------------------------------------------------------------*\ 00058 Class edgeIntersections Declaration 00059 \*---------------------------------------------------------------------------*/ 00060 00061 class edgeIntersections 00062 : 00063 public List<List<pointIndexHit> > 00064 { 00065 // Private data 00066 00067 //- For every entry in *this gives the edge classification result. 00068 // -1 : intersection not close to edge 00069 // 0 : intersection close to e[0] 00070 // 1 : intersection close to e[1] 00071 // 2 : edge aligned with intersection face 00072 labelListList classification_; 00073 00074 00075 // Private Member Functions 00076 00077 //- Check for too small edges 00078 static void checkEdges(const triSurface& surf); 00079 00080 //- Intersect selected surface edges (edgeLabels) with surface2. 00081 // Updates *this with pointHits and classification_ with status 00082 // of hitPoint compared to edge end points. 00083 void intersectEdges 00084 ( 00085 const triSurface& surf1, 00086 const pointField& points1, // surf1 meshPoints 00087 const triSurfaceSearch& querySurf2, 00088 const scalarField& surf1PointTol, // surf1 tolerance per point 00089 const labelList& edgeLabels 00090 ); 00091 00092 //- Perturb endpoints of edge if they are close to the intersection. 00093 // Move point (in points1) by factor*surf1PointTol in direction of 00094 // edge. Mark pointEdges of moved point in affectedEdges. 00095 // Return true if anything changed. 00096 bool inlinePerturb 00097 ( 00098 const triSurface& surf1, 00099 const scalarField& surf1PointTol, 00100 const label edgeI, 00101 Random& rndGen, 00102 pointField& points1, 00103 boolList& affectedEdges 00104 ) const; 00105 00106 //- Perturb single endpoint of edge if edge is algigned with face. 00107 // See inlinePerturb. Return true if anything changed. 00108 bool rotatePerturb 00109 ( 00110 const triSurface& surf1, 00111 const scalarField& surf1PointTol, 00112 const label edgeI, 00113 Random& rndGen, 00114 pointField& points1, 00115 boolList& affectedEdges 00116 ) const; 00117 00118 00119 //- Perturb edge by shifting in direction trianglecentre - intersection 00120 // when hits close to face. Update points, mark affected edges and 00121 // return true if anything changed. 00122 bool offsetPerturb 00123 ( 00124 const triSurface& surf1, 00125 const triSurface& surf2, 00126 const label edgeI, 00127 00128 Random& rndGen, 00129 pointField& points1, 00130 boolList& affectedEdges 00131 ) const; 00132 00133 public: 00134 00135 ClassName("edgeIntersections"); 00136 00137 00138 // Static data members 00139 00140 //- cosine between edge and face normal when considered parallel 00141 // (note: should be private and make access- and set- function) 00142 static scalar alignedCos_; 00143 00144 00145 // Static Functions 00146 00147 //- Calculate min edge length for every surface point 00148 static scalarField minEdgeLength(const triSurface& surf); 00149 00150 00151 // Constructors 00152 00153 //- Construct null 00154 edgeIntersections(); 00155 00156 //- Construct from surface and tolerance 00157 edgeIntersections 00158 ( 00159 const triSurface& surf1, 00160 const triSurfaceSearch& query2, 00161 const scalarField& surf1PointTol 00162 ); 00163 00164 //- Construct from components 00165 edgeIntersections 00166 ( 00167 const List<List<pointIndexHit> >&, 00168 const labelListList& 00169 ); 00170 00171 00172 // Member Functions 00173 00174 00175 // Access 00176 00177 //- For every intersection the classification status. 00178 const labelListList& classification() const 00179 { 00180 return classification_; 00181 } 00182 00183 00184 // Edit 00185 00186 //- Resolve ties. Shuffles points so all edge - face intersections 00187 // will be on the face interior. 00188 // Points will be the new surface points. 00189 // Returns number of iterations needed. (= nIters if still 00190 // has degenerate cuts) 00191 label removeDegenerates 00192 ( 00193 const label nIters, 00194 const triSurface& surf1, 00195 const triSurfaceSearch& query2, 00196 const scalarField& surf1PointTol, 00197 pointField& points1 00198 ); 00199 }; 00200 00201 00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00203 00204 } // End namespace Foam 00205 00206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00207 00208 #endif 00209 00210 // ************************ vim: set sw=4 sts=4 et: ************************ //