OpenFOAM logo
Open Source CFD Toolkit

edgeIntersections.H

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