ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / searchableSurface / triSurfaceMesh.H
blob91a3e16c19790b355cdf26caa009173795ab5a1d
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::triSurfaceMesh
27 Description
28     IOoject and searching on triSurface
30     Note: when constructing from dictionary has optional parameters:
31         - scale     : scaling factor.
32         - tolerance : relative tolerance for doing intersections
33                       (see triangle::intersection)
34         - minQuality: discard triangles with low quality when getting normal
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 min triangle quality. Triangles below this get
75         //  ignored for normal calculation
76         scalar minQuality_;
78         //- Optional max tree depth of octree
79         label maxTreeDepth_;
81         //- Search tree (triangles)
82         mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
84         //- Search tree for boundary edges.
85         mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
87         //- Names of regions
88         mutable wordList regions_;
90         //- Is surface closed
91         mutable label surfaceClosed_;
93     // Private Member Functions
95         ////- Helper: find instance of files without header
96         //static word findRawInstance
97         //(
98         //    const Time&,
99         //    const fileName&,
100         //    const word&
101         //);
103         //- Check file existence
104         static const fileName& checkFile
105         (
106             const fileName& fName,
107             const fileName& objectName
108         );
110         //- Helper function for isSurfaceClosed
111         static bool addFaceToEdge
112         (
113             const edge&,
114             EdgeMap<label>&
115         );
117         //- Check whether surface is closed without calculating any permanent
118         //  addressing.
119         bool isSurfaceClosed() const;
121         //- Steps to next intersection. Adds smallVec and starts tracking
122         //  from there.
123         static void getNextIntersections
124         (
125             const indexedOctree<treeDataTriSurface>& octree,
126             const point& start,
127             const point& end,
128             const vector& smallVec,
129             DynamicList<pointIndexHit, 1, 1>& hits
130         );
132         //- Disallow default bitwise copy construct
133         triSurfaceMesh(const triSurfaceMesh&);
135         //- Disallow default bitwise assignment
136         void operator=(const triSurfaceMesh&);
139 protected:
141         //- Calculate (number of)used points and their bounding box
142         void calcBounds(boundBox& bb, label& nPoints) const;
144 public:
146     //- Runtime type information
147     TypeName("triSurfaceMesh");
150     // Constructors
152         //- Construct from triSurface
153         triSurfaceMesh(const IOobject&, const triSurface&);
155         //- Construct read.
156         triSurfaceMesh(const IOobject& io);
158         //- Construct from IO and dictionary (used by searchableSurface).
159         //  Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
160         triSurfaceMesh
161         (
162             const IOobject& io,
163             const dictionary& dict
164         );
167     //- Destructor
168     virtual ~triSurfaceMesh();
170         //- Clear storage
171         void clearOut();
174     // Member Functions
176         //- Move points
177         virtual void movePoints(const pointField&);
179         //- Demand driven contruction of octree
180         const indexedOctree<treeDataTriSurface>& tree() const;
182         //- Demand driven contruction of octree for boundary edges
183         const indexedOctree<treeDataEdge>& edgeTree() const;
186         // searchableSurface implementation
188             virtual const wordList& regions() const;
190             //- Whether supports volume type below. I.e. whether is closed.
191             virtual bool hasVolumeType() const;
193             //- Range of local indices that can be returned.
194             virtual label size() const
195             {
196                 return triSurface::size();
197             }
199             //- Get representative set of element coordinates
200             //  Usually the element centres (should be of length size()).
201             virtual pointField coordinates() const;
203             virtual void findNearest
204             (
205                 const pointField& sample,
206                 const scalarField& nearestDistSqr,
207                 List<pointIndexHit>&
208             ) const;
210             virtual void findLine
211             (
212                 const pointField& start,
213                 const pointField& end,
214                 List<pointIndexHit>&
215             ) const;
217             virtual void findLineAny
218             (
219                 const pointField& start,
220                 const pointField& end,
221                 List<pointIndexHit>&
222             ) const;
224             //- Get all intersections in order from start to end.
225             virtual void findLineAll
226             (
227                 const pointField& start,
228                 const pointField& end,
229                 List<List<pointIndexHit> >&
230             ) const;
232             //- From a set of points and indices get the region
233             virtual void getRegion
234             (
235                 const List<pointIndexHit>&,
236                 labelList& region
237             ) const;
239             //- From a set of points and indices get the normal
240             virtual void getNormal
241             (
242                 const List<pointIndexHit>&,
243                 vectorField& normal
244             ) const;
246             //- Determine type (inside/outside/mixed) for point. unknown if
247             //  cannot be determined (e.g. non-manifold surface)
248             virtual void getVolumeType
249             (
250                 const pointField&,
251                 List<volumeType>&
252             ) const;
254         // Other
256             //- Set bounds of surface. Bounds currently set as list of
257             //  bounding boxes. The bounds are hints to the surface as for
258             //  the range of queries it can expect. faceMap/pointMap can be
259             //  set if the surface has done any redistribution.
260             virtual void distribute
261             (
262                 const List<treeBoundBox>&,
263                 const bool keepNonLocal,
264                 autoPtr<mapDistribute>& faceMap,
265                 autoPtr<mapDistribute>& pointMap
266             )
267             {}
269             //- WIP. Store element-wise field.
270             virtual void setField(const labelList& values);
272             //- WIP. From a set of hits (points and
273             //  indices) get the specified field. Misses do not get set.
274             virtual void getField(const List<pointIndexHit>&, labelList&) const;
277         // regIOobject implementation
279             bool writeData(Ostream&) const
280             {
281                 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
282                 return false;
283             }
285             //- Write using given format, version and compression
286             virtual bool writeObject
287             (
288                 IOstream::streamFormat fmt,
289                 IOstream::versionNumber ver,
290                 IOstream::compressionType cmp
291             ) const;
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 } // End namespace Foam
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 #endif
304 // ************************************************************************* //