OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

triSurfaceMeshes.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-2007 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     triSurfaceMeshes
00027 
00028 Description
00029     Container for triSurfaces read from files.
00030 
00031 SourceFiles
00032     triSurfaceMeshes.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef triSurfaceMeshes_H
00037 #define triSurfaceMeshes_H
00038 
00039 #include "triSurfaceMesh.H"
00040 #include "fileNameList.H"
00041 #include "treeDataTriSurface.H"
00042 #include "indexedOctree.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // Class forward declarations
00050 
00051 /*---------------------------------------------------------------------------*\
00052                            Class triSurfaceMeshes Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 class triSurfaceMeshes
00056 :
00057     public PtrList<triSurfaceMesh>
00058 {
00059     // Private data
00060 
00061         //- Names of surfaces
00062         fileNameList names_;
00063 
00064         //- Indices of all surfaces. Precalculated and stored.
00065         const labelList allSurfaces_;
00066 
00067         //- Trees
00068         mutable autoPtr<PtrList<indexedOctree<treeDataTriSurface> > > treesPtr_;
00069 
00070 
00071     // Private Member Functions
00072 
00073         void calcTrees() const;
00074 
00075         //- Disallow default bitwise copy construct
00076         triSurfaceMeshes(const triSurfaceMeshes&);
00077 
00078         //- Disallow default bitwise assignment
00079         void operator=(const triSurfaceMeshes&);
00080 
00081 
00082 public:
00083 
00084     // Constructors
00085 
00086         //- Construct from directory (io.instance()) and list of local filenames
00087         triSurfaceMeshes(const IOobject& io, const fileNameList&);
00088 
00089         //- Clear derived storage
00090         void clearOut();
00091 
00092 
00093     // Member Functions
00094 
00095         //- Get all surfaces in directory
00096         static fileNameList allNames(const IOobject&);
00097 
00098         //- Get current list of surfaces
00099         const fileNameList& names() const
00100         {
00101             return names_;
00102         }
00103 
00104         //- Get trees for searching
00105         const PtrList<indexedOctree<treeDataTriSurface> >& trees() const
00106         {
00107             if (!treesPtr_.valid())
00108             {
00109                 calcTrees();
00110             }
00111             return treesPtr_();
00112         }
00113 
00114 
00115         //- Find any intersection. Return hit point information and surface
00116         //  number
00117         label findAnyIntersection
00118         (
00119             const labelList& surfacesToTest,
00120             const point& start,
00121             const point& end,
00122             pointIndexHit&
00123         ) const;
00124 
00125         label findAnyIntersection
00126         (
00127             const point& start,
00128             const point& end,
00129             pointIndexHit&
00130         ) const;
00131 
00132 
00133         //- Find all intersections in order from start to end. Returns for
00134         //  every hit the surface and the hit info.
00135         void findAllIntersections
00136         (
00137             const labelList& surfacesToTest,
00138             const point& start,
00139             const point& end,
00140             labelList& surfaces,
00141             List<pointIndexHit>& surfaceHits
00142         ) const;
00143 
00144         void findAllIntersections
00145         (
00146             const point& start,
00147             const point& end,
00148             labelList& surfaces,
00149             List<pointIndexHit>& surfaceHits
00150         ) const;
00151 
00152 
00153         //- Find intersections of edge nearest to both endpoints.
00154         void findNearestIntersection
00155         (
00156             const labelList& surfacesToTest,
00157             const point& start,
00158             const point& end,
00159 
00160             label& surface1,        // surface index
00161             pointIndexHit& hit1,    // hit point information
00162             label& surface2,
00163             pointIndexHit& hit2
00164         ) const;
00165 
00166         void findNearestIntersection
00167         (
00168             const point& start,
00169             const point& end,
00170 
00171             label& surface1,        // surface index
00172             pointIndexHit& hit1,    // hit point information
00173             label& surface2,
00174             pointIndexHit& hit2
00175         ) const;
00176 
00177 
00178         //- Find nearest. Return -1 or surface and nearest point (in
00179         //  pointIndexHit)
00180         label findNearest
00181         (
00182             const labelList& surfacesToTest,
00183             const point&,
00184             const scalar nearestDistSqr,
00185             pointIndexHit&
00186         ) const;
00187 
00188         label findNearest
00189         (
00190             const point&,
00191             const scalar nearestDistSqr,
00192             pointIndexHit&
00193         ) const;
00194 
00195 };
00196 
00197 
00198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00199 
00200 } // End namespace Foam
00201 
00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00203 
00204 #endif
00205 
00206 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd