BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / meshTools / indexedOctree / treeDataEdge.H
blobc6af44e9edb8bd5f0bc48953c0dddd296e5f67de
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::treeDataEdge
27 Description
28     Holds data for octree to work on an edges subset.
30 SourceFiles
31     treeDataEdge.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef treeDataEdge_H
36 #define treeDataEdge_H
38 #include "treeBoundBoxList.H"
39 #include "linePointRef.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
47 template<class Type> class indexedOctree;
49 /*---------------------------------------------------------------------------*\
50                            Class treeDataEdge Declaration
51 \*---------------------------------------------------------------------------*/
53 class treeDataEdge
55     // Static data
57         //- tolerance on linear dimensions
58         static scalar tol;
61     // Private data
63         //- Reference to edgeList
64         const edgeList& edges_;
66         //- Reference to points
67         const pointField& points_;
69         //- labels of edges
70         const labelList edgeLabels_;
72         //- Whether to precalculate and store face bounding box
73         const bool cacheBb_;
75         //- bbs for all above edges (valid only if cacheBb_)
76         treeBoundBoxList bbs_;
79     // Private Member Functions
81         //- Calculate edge bounding box
82         treeBoundBox calcBb(const label edgeI) const;
84         //- Initialise all member data
85         void update();
87 public:
89     // Declare name of the class and its debug switch
90     ClassName("treeDataEdge");
93     // Constructors
95         //- Construct from selected edges. !Holds references to edges and points
96         treeDataEdge
97         (
98             const bool cacheBb,
99             const edgeList& edges,
100             const pointField& points,
101             const labelUList& edgeLabels
102         );
104         //- Construct from selected edges, transferring contents.
105         // !Holds references to edges and points
106         treeDataEdge
107         (
108             const bool cacheBb,
109             const edgeList& edges,
110             const pointField& points,
111             const Xfer<labelList>& edgeLabels
112         );
115     // Member Functions
117         // Access
119             const labelList& edgeLabels() const
120             {
121                 return edgeLabels_;
122             }
124             label size() const
125             {
126                 return edgeLabels_.size();
127             }
129             //- Get representative point cloud for all shapes inside
130             //  (one point per shape)
131             pointField shapePoints() const;
134         // Search
136             //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
137             //  Only makes sense for closed surfaces.
138             label getVolumeType
139             (
140                 const indexedOctree<treeDataEdge>&,
141                 const point&
142             ) const;
144             //- Does (bb of) shape at index overlap bb
145             bool overlaps
146             (
147                 const label index,
148                 const treeBoundBox& sampleBb
149             ) const;
151             //- Calculates nearest (to sample) point in shape.
152             //  Returns actual point and distance (squared)
153             void findNearest
154             (
155                 const labelUList& indices,
156                 const point& sample,
158                 scalar& nearestDistSqr,
159                 label& nearestIndex,
160                 point& nearestPoint
161             ) const;
163             //- Calculates nearest (to line) point in shape.
164             //  Returns point and distance (squared)
165             void findNearest
166             (
167                 const labelUList& indices,
168                 const linePointRef& ln,
170                 treeBoundBox& tightest,
171                 label& minIndex,
172                 point& linePoint,
173                 point& nearestPoint
174             ) const;
176             //- Calculate intersection of shape with ray. Sets result
177             //  accordingly
178             bool intersects
179             (
180                 const label index,
181                 const point& start,
182                 const point& end,
183                 point& result
184             ) const
185             {
186                 notImplemented
187                 (
188                     "treeDataEdge::intersects(const label, const point&,"
189                     "const point&, point&)"
190                 );
191                 return false;
192             }
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 #endif
206 // ************************************************************************* //