BUG: PointEdgeWave : n cyclics bool instead of label
[OpenFOAM-1.6.x.git] / src / meshTools / searchableSurface / triSurfaceMesh.H
blobdea7c642b896ab21f8670c2e6218b3a491e79c63
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::triSurfaceMesh
28 Description
29     IOoject and searching on triSurface
31     Note: when constructing from dictionary has optional parameters:
32         - scale     : scaling factor.
33         - tolerance : relative tolerance for doing intersections
34                       (see triangle::intersection)
36 SourceFiles
37     triSurfaceMesh.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef triSurfaceMesh_H
42 #define triSurfaceMesh_H
44 #include "treeBoundBox.H"
45 #include "searchableSurface.H"
46 #include "objectRegistry.H"
47 #include "indexedOctree.H"
48 #include "treeDataTriSurface.H"
49 #include "treeDataEdge.H"
50 #include "EdgeMap.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 namespace Foam
57 /*---------------------------------------------------------------------------*\
58                            Class triSurfaceMesh Declaration
59 \*---------------------------------------------------------------------------*/
61 class triSurfaceMesh
63     public searchableSurface,
64     public objectRegistry,      // so we can store fields
65     public triSurface
67 private:
69     // Private member data
71         //- Optional tolerance to use in searches
72         scalar tolerance_;
74         //- Optional max tree depth of octree
75         label maxTreeDepth_;
77         //- Search tree (triangles)
78         mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
80         //- Search tree for boundary edges.
81         mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
83         //- Names of regions
84         mutable wordList regions_;
86         //- Is surface closed
87         mutable label surfaceClosed_;
89     // Private Member Functions
91         ////- Helper: find instance of files without header
92         //static word findRawInstance
93         //(
94         //    const Time&,
95         //    const fileName&,
96         //    const word&
97         //);
99         //- Check file existence
100         static const fileName& checkFile
101         (
102             const fileName& fName,
103             const fileName& objectName
104         );
106         //- Helper function for isSurfaceClosed
107         static bool addFaceToEdge
108         (
109             const edge&,
110             EdgeMap<label>&
111         );
113         //- Check whether surface is closed without calculating any permanent
114         //  addressing.
115         bool isSurfaceClosed() const;
117         //- Steps to next intersection. Adds smallVec and starts tracking
118         //  from there.
119         static void getNextIntersections
120         (
121             const indexedOctree<treeDataTriSurface>& octree,
122             const point& start,
123             const point& end,
124             const vector& smallVec,
125             DynamicList<pointIndexHit, 1, 1>& hits
126         );
128         //- Disallow default bitwise copy construct
129         triSurfaceMesh(const triSurfaceMesh&);
131         //- Disallow default bitwise assignment
132         void operator=(const triSurfaceMesh&);
135 protected:
137         //- Calculate (number of)used points and their bounding box
138         void calcBounds(boundBox& bb, label& nPoints) const;
140 public:
142     //- Runtime type information
143     TypeName("triSurfaceMesh");
146     // Constructors
148         //- Construct from triSurface
149         triSurfaceMesh(const IOobject&, const triSurface&);
151         //- Construct read.
152         triSurfaceMesh(const IOobject& io);
154         //- Construct from IO and dictionary (used by searchableSurface).
155         //  Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
156         triSurfaceMesh
157         (
158             const IOobject& io,
159             const dictionary& dict
160         );
163     // Destructor
165         virtual ~triSurfaceMesh();
167         //- Clear storage
168         void clearOut();
171     // Member Functions
173         //- Move points
174         virtual void movePoints(const pointField&);
176         //- Demand driven contruction of octree
177         const indexedOctree<treeDataTriSurface>& tree() const;
179         //- Demand driven contruction of octree for boundary edges
180         const indexedOctree<treeDataEdge>& edgeTree() const;
183         // searchableSurface implementation
185             virtual const wordList& regions() const;
187             //- Whether supports volume type below. I.e. whether is closed.
188             virtual bool hasVolumeType() const;
190             //- Range of local indices that can be returned.
191             virtual label size() const
192             {
193                 return triSurface::size();
194             }
196             //- Get representative set of element coordinates
197             //  Usually the element centres (should be of length size()).
198             virtual pointField coordinates() const;
200             virtual void findNearest
201             (
202                 const pointField& sample,
203                 const scalarField& nearestDistSqr,
204                 List<pointIndexHit>&
205             ) const;
207             virtual void findLine
208             (
209                 const pointField& start,
210                 const pointField& end,
211                 List<pointIndexHit>&
212             ) const;
214             virtual void findLineAny
215             (
216                 const pointField& start,
217                 const pointField& end,
218                 List<pointIndexHit>&
219             ) const;
221             //- Get all intersections in order from start to end.
222             virtual void findLineAll
223             (
224                 const pointField& start,
225                 const pointField& end,
226                 List<List<pointIndexHit> >&
227             ) const;
229             //- From a set of points and indices get the region
230             virtual void getRegion
231             (
232                 const List<pointIndexHit>&,
233                 labelList& region
234             ) const;
236             //- From a set of points and indices get the normal
237             virtual void getNormal
238             (
239                 const List<pointIndexHit>&,
240                 vectorField& normal
241             ) const;
243             //- Determine type (inside/outside/mixed) for point. unknown if
244             //  cannot be determined (e.g. non-manifold surface)
245             virtual void getVolumeType
246             (
247                 const pointField&,
248                 List<volumeType>&
249             ) const;
251         // Other
253             //- Set bounds of surface. Bounds currently set as list of
254             //  bounding boxes. The bounds are hints to the surface as for
255             //  the range of queries it can expect. faceMap/pointMap can be
256             //  set if the surface has done any redistribution.
257             virtual void distribute
258             (
259                 const List<treeBoundBox>&,
260                 const bool keepNonLocal,
261                 autoPtr<mapDistribute>& faceMap,
262                 autoPtr<mapDistribute>& pointMap
263             )
264             {}
266             //- WIP. Store element-wise field.
267             virtual void setField(const labelList& values);
269             //- WIP. From a set of hits (points and
270             //  indices) get the specified field. Misses do not get set.
271             virtual void getField(const List<pointIndexHit>&, labelList&) const;
274         // regIOobject implementation
276             bool writeData(Ostream&) const
277             {
278                 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
279                 return false;
280             }
282             //- Write using given format, version and compression
283             virtual bool writeObject
284             (
285                 IOstream::streamFormat fmt,
286                 IOstream::versionNumber ver,
287                 IOstream::compressionType cmp
288             ) const;
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 } // End namespace Foam
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 #endif
301 // ************************************************************************* //