1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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/>.
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
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"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 /*---------------------------------------------------------------------------*\
58 Class triSurfaceMesh Declaration
59 \*---------------------------------------------------------------------------*/
63 public searchableSurface,
64 public objectRegistry, // so we can store fields
69 // Private member data
71 //- Optional tolerance to use in searches
74 //- Optional min triangle quality. Triangles below this get
75 // ignored for normal calculation
78 //- Optional max tree depth of octree
81 //- Search tree (triangles)
82 mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
84 //- Search tree for boundary edges.
85 mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
88 mutable wordList regions_;
91 mutable label surfaceClosed_;
93 // Private Member Functions
95 ////- Helper: find instance of files without header
96 //static word findRawInstance
103 //- Check file existence
104 static const fileName& checkFile
106 const fileName& fName,
107 const fileName& objectName
110 //- Helper function for isSurfaceClosed
111 static bool addFaceToEdge
117 //- Check whether surface is closed without calculating any permanent
119 bool isSurfaceClosed() const;
121 //- Steps to next intersection. Adds smallVec and starts tracking
123 static void getNextIntersections
125 const indexedOctree<treeDataTriSurface>& octree,
128 const vector& smallVec,
129 DynamicList<pointIndexHit, 1, 1>& hits
132 //- Disallow default bitwise copy construct
133 triSurfaceMesh(const triSurfaceMesh&);
135 //- Disallow default bitwise assignment
136 void operator=(const triSurfaceMesh&);
141 //- Calculate (number of)used points and their bounding box
142 void calcBounds(boundBox& bb, label& nPoints) const;
146 //- Runtime type information
147 TypeName("triSurfaceMesh");
152 //- Construct from triSurface
153 triSurfaceMesh(const IOobject&, const triSurface&);
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)
163 const dictionary& dict
168 virtual ~triSurfaceMesh();
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
196 return triSurface::size();
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
205 const pointField& sample,
206 const scalarField& nearestDistSqr,
210 virtual void findLine
212 const pointField& start,
213 const pointField& end,
217 virtual void findLineAny
219 const pointField& start,
220 const pointField& end,
224 //- Get all intersections in order from start to end.
225 virtual void findLineAll
227 const pointField& start,
228 const pointField& end,
229 List<List<pointIndexHit> >&
232 //- From a set of points and indices get the region
233 virtual void getRegion
235 const List<pointIndexHit>&,
239 //- From a set of points and indices get the normal
240 virtual void getNormal
242 const List<pointIndexHit>&,
246 //- Determine type (inside/outside/mixed) for point. unknown if
247 // cannot be determined (e.g. non-manifold surface)
248 virtual void getVolumeType
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
262 const List<treeBoundBox>&,
263 const bool keepNonLocal,
264 autoPtr<mapDistribute>& faceMap,
265 autoPtr<mapDistribute>& pointMap
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
281 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
285 //- Write using given format, version and compression
286 virtual bool writeObject
288 IOstream::streamFormat fmt,
289 IOstream::versionNumber ver,
290 IOstream::compressionType cmp
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 } // End namespace Foam
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 // ************************************************************************* //