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

treeDataPoint.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::treeDataPoint
00026 
00027 Description
00028     Holds (reference to) pointField. Encapsulation of data needed for
00029     octree searches.
00030     Used for searching for nearest point. No bounding boxes around points.
00031     Only overlaps and calcNearest are implemented, rest makes little sense.
00032 
00033 SourceFiles
00034     treeDataPoint.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef treeDataPoint_H
00039 #define treeDataPoint_H
00040 
00041 #include <OpenFOAM/pointField.H>
00042 #include <meshTools/treeBoundBox.H>
00043 #include <OpenFOAM/linePointRef.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Forward declaration of classes
00051 template<class Type> class indexedOctree;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                            Class treeDataPoint Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class treeDataPoint
00058 {
00059     // Private data
00060 
00061         const pointField& points_;
00062 
00063 public:
00064 
00065     // Declare name of the class and its debug switch
00066     ClassName("treeDataPoint");
00067 
00068 
00069     // Constructors
00070 
00071         //- Construct from components. Holds reference to points!
00072         treeDataPoint(const pointField& points);
00073 
00074 
00075     // Member Functions
00076 
00077         // Access
00078 
00079             label size() const
00080             {
00081                 return points_.size();
00082             }
00083 
00084             //- Get representative point cloud for all shapes inside
00085             //  (one point per shape)
00086             pointField points() const;
00087 
00088 
00089         // Search
00090 
00091             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
00092             //  Only makes sense for closed surfaces.
00093             label getVolumeType
00094             (
00095                 const indexedOctree<treeDataPoint>&,
00096                 const point&
00097             ) const;
00098 
00099             //- Does (bb of) shape at index overlap bb
00100             bool overlaps
00101             (
00102                 const label index,
00103                 const treeBoundBox& sampleBb
00104             ) const;
00105 
00106             //- Calculates nearest (to sample) point in shape.
00107             //  Returns actual point and distance (squared)
00108             void findNearest
00109             (
00110                 const labelList& indices,
00111                 const point& sample,
00112 
00113                 scalar& nearestDistSqr,
00114                 label& nearestIndex,
00115                 point& nearestPoint
00116             ) const;
00117 
00118             //- Calculates nearest (to line) point in shape.
00119             //  Returns point and distance (squared)
00120             void findNearest
00121             (
00122                 const labelList& indices,
00123                 const linePointRef& ln,
00124 
00125                 treeBoundBox& tightest,
00126                 label& minIndex,
00127                 point& linePoint,
00128                 point& nearestPoint
00129             ) const;
00130 
00131             //- Calculate intersection of shape with ray. Sets result
00132             //  accordingly
00133             bool intersects
00134             (
00135                 const label index,
00136                 const point& start,
00137                 const point& end,
00138                 point& result
00139             ) const
00140             {
00141                 notImplemented
00142                 (
00143                     "treeDataPoint::intersects(const label, const point&,"
00144                     "const point&, point&)"
00145                 );
00146                 return false;
00147             }
00148 
00149 };
00150 
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 } // End namespace Foam
00155 
00156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00157 
00158 
00159 #endif
00160 
00161 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines