FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

octreeDataEdges.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-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::octreeDataEdges
00026 
00027 Description
00028     Holds data for octree to work on an edges subset.
00029 
00030 SourceFiles
00031     octreeDataEdges.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef octreeDataEdges_H
00036 #define octreeDataEdges_H
00037 
00038 #include <OpenFOAM/line.H>
00039 #include <OpenFOAM/linePointRef.H>
00040 #include "treeBoundBoxList.H"
00041 #include <OpenFOAM/labelList.H>
00042 #include <OpenFOAM/className.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // Forward declaration of classes
00050 template<class Type> class octree;
00051 
00052 /*---------------------------------------------------------------------------*\
00053                        Class octreeDataEdges Declaration
00054 \*---------------------------------------------------------------------------*/
00055 
00056 class octreeDataEdges
00057 {
00058     // Static data
00059 
00060         //- tolerance on linear dimensions
00061         static scalar tol;
00062 
00063 
00064     // Private data
00065 
00066         //- Reference to edgeList
00067         const edgeList& edges_;
00068 
00069         //- Reference to points
00070         const pointField& points_;
00071 
00072         //- labels of edges
00073         labelList edgeLabels_;
00074 
00075         //- bbs for all above edges
00076         treeBoundBoxList allBb_;
00077 
00078 
00079 public:
00080 
00081     // Declare name of the class and its debug switch
00082     ClassName("octreeDataEdges");
00083 
00084     // Constructors
00085 
00086         //- Construct from selected edges. !Holds references to edges and points
00087         octreeDataEdges
00088         (
00089             const edgeList& edges,
00090             const pointField& points,
00091             const labelList& edgeLabels
00092         );
00093 
00094         //- Construct as copy
00095         octreeDataEdges(const octreeDataEdges&);
00096 
00097 
00098     // Destructor
00099 
00100         ~octreeDataEdges();
00101 
00102 
00103     // Member Functions
00104 
00105         // Access
00106 
00107             const edgeList& edges() const
00108             {
00109                 return edges_;
00110             }
00111 
00112             const pointField& points() const
00113             {
00114                 return points_;
00115             }
00116 
00117             const labelList& edgeLabels() const
00118             {
00119                 return edgeLabels_;
00120             }
00121 
00122             const treeBoundBoxList& allBb() const
00123             {
00124                 return allBb_;
00125             }
00126 
00127             label size() const
00128             {
00129                 return allBb_.size();
00130             }
00131 
00132 
00133         // Search
00134 
00135             //- Get type of sample
00136             label getSampleType
00137             (
00138                 const octree<octreeDataEdges>&,
00139                 const point&
00140             ) const;
00141 
00142             //- Does (bb of) shape at index overlap bb
00143             bool overlaps
00144             (
00145                 const label index,
00146                 const treeBoundBox& sampleBb
00147             ) const;
00148 
00149             //- Does shape at index contain sample
00150             bool contains
00151             (
00152                 const label index,
00153                 const point& sample
00154             ) const;
00155 
00156             //- Segment (from start to end) intersection with shape at index.
00157             //  If intersects returns true and sets intersectionPoint
00158             bool intersects
00159             (
00160                 const label index,
00161                 const point& start,
00162                 const point& end,
00163                 point& intersectionPoint
00164             ) const;
00165 
00166             //- Sets newTightest to bounding box (and returns true) if
00167             //  nearer to sample than tightest bounding box. Otherwise
00168             //  returns false.
00169             bool findTightest
00170             (
00171                 const label index,
00172                 const point& sample,
00173                 treeBoundBox& tightest
00174             ) const;
00175 
00176             //- Given index get unit normal and calculate (numerical) sign
00177             //  of sample.
00178             //  Used to determine accuracy of calcNearest or inside/outside.
00179             scalar calcSign
00180             (
00181                 const label index,
00182                 const point& sample,
00183                 vector& n
00184             ) const;
00185 
00186             //- Calculates nearest (to sample) point in shape.
00187             //  Returns point and mag(nearest - sample).
00188             scalar calcNearest
00189             (
00190                 const label index,
00191                 const point& sample,
00192                 point& nearest
00193             ) const;
00194 
00195             //- Calculates nearest (to line segment) point in shape.
00196             //  Returns distance and both point.
00197             scalar calcNearest
00198             (
00199                 const label index,
00200                 const linePointRef& ln,
00201                 point& linePt,          // nearest point on line
00202                 point& shapePt          // nearest point on shape
00203             ) const;
00204 
00205 
00206         // Write
00207 
00208             //- Write shape at index
00209             void write(Ostream& os, const label index) const;
00210 };
00211 
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 } // End namespace Foam
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 
00220 #endif
00221 
00222 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines