initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / searchableSurface / triSurfaceMesh.H
blob4ae415fafa441090bc9589b1b582aec298281d2b
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         //- Search tree (triangles)
75         mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
77         //- Search tree for boundary edges.
78         mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
80         //- Names of regions
81         mutable wordList regions_;
83         //- Is surface closed
84         mutable label surfaceClosed_;
86     // Private Member Functions
88         ////- Helper: find instance of files without header
89         //static word findRawInstance
90         //(
91         //    const Time&,
92         //    const fileName&,
93         //    const word&
94         //);
96         //- Check file existence
97         static const fileName& checkFile
98         (
99             const fileName& fName,
100             const fileName& objectName
101         );
103         //- Helper function for isSurfaceClosed
104         static bool addFaceToEdge
105         (
106             const edge&,
107             EdgeMap<label>&
108         );
110         //- Check whether surface is closed without calculating any permanent
111         //  addressing.
112         bool isSurfaceClosed() const;
114         //- Disallow default bitwise copy construct
115         triSurfaceMesh(const triSurfaceMesh&);
117         //- Disallow default bitwise assignment
118         void operator=(const triSurfaceMesh&);
121 public:
123     //- Runtime type information
124     TypeName("triSurfaceMesh");
127     // Constructors
129         //- Construct from triSurface
130         triSurfaceMesh(const IOobject&, const triSurface&);
132         //- Construct read.
133         triSurfaceMesh(const IOobject& io);
135         //- Construct from IO and dictionary (used by searchableSurface).
136         //  Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
137         triSurfaceMesh
138         (
139             const IOobject& io,
140             const dictionary& dict
141         );
144     // Destructor
146         virtual ~triSurfaceMesh();
148         //- Clear storage
149         void clearOut();
152     // Member Functions
154         //- Move points
155         virtual void movePoints(const pointField&);
157         //- Demand driven contruction of octree
158         const indexedOctree<treeDataTriSurface>& tree() const;
160         //- Demand driven contruction of octree for boundary edges
161         const indexedOctree<treeDataEdge>& edgeTree() const;
164         // searchableSurface implementation
166             virtual const wordList& regions() const;
168             //- Whether supports volume type below. I.e. whether is closed.
169             virtual bool hasVolumeType() const;
171             //- Range of local indices that can be returned.
172             virtual label size() const
173             {
174                 return triSurface::size();
175             }
177             virtual void findNearest
178             (
179                 const pointField& sample,
180                 const scalarField& nearestDistSqr,
181                 List<pointIndexHit>&
182             ) const;
184             virtual void findLine
185             (
186                 const pointField& start,
187                 const pointField& end,
188                 List<pointIndexHit>&
189             ) const;
191             virtual void findLineAny
192             (
193                 const pointField& start,
194                 const pointField& end,
195                 List<pointIndexHit>&
196             ) const;
198             //- Get all intersections in order from start to end.
199             virtual void findLineAll
200             (
201                 const pointField& start,
202                 const pointField& end,
203                 List<List<pointIndexHit> >&
204             ) const;
206             //- From a set of points and indices get the region
207             virtual void getRegion
208             (
209                 const List<pointIndexHit>&,
210                 labelList& region
211             ) const;
213             //- From a set of points and indices get the normal
214             virtual void getNormal
215             (
216                 const List<pointIndexHit>&,
217                 vectorField& normal
218             ) const;
220             //- Determine type (inside/outside/mixed) for point. unknown if
221             //  cannot be determined (e.g. non-manifold surface)
222             virtual void getVolumeType
223             (
224                 const pointField&,
225                 List<volumeType>&
226             ) const;
228             //- Set bounds of surface. Bounds currently set as list of
229             //  bounding boxes. The bounds are hints to the surface as for
230             //  the range of queries it can expect. faceMap/pointMap can be
231             //  set if the surface has done any redistribution.
232             virtual void distribute
233             (
234                 const List<treeBoundBox>&,
235                 const bool keepNonLocal,
236                 autoPtr<mapDistribute>& faceMap,
237                 autoPtr<mapDistribute>& pointMap
238             )
239             {}
241         // Other
243             //- Specific to triSurfaceMesh: from a set of hits (points and
244             //  indices) get the specified field. Misses do not get set.
245             virtual void getField
246             (
247                 const word& fieldName,
248                 const List<pointIndexHit>&,
249                 labelList& values
250             ) const;
253         // regIOobject implementation
255             bool writeData(Ostream&) const
256             {
257                 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
258                 return false;
259             }
261             //- Write using given format, version and compression
262             virtual bool writeObject
263             (
264                 IOstream::streamFormat fmt,
265                 IOstream::versionNumber ver,
266                 IOstream::compressionType cmp
267             ) const;
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 } // End namespace Foam
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 #endif
280 // ************************************************************************* //