1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 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
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
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)
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 "octreeDataTriSurfaceTreeLeaf.H"
50 #include "treeDataEdge.H"
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 /*---------------------------------------------------------------------------*\
59 Class triSurfaceMesh Declaration
60 \*---------------------------------------------------------------------------*/
64 public searchableSurface,
65 public objectRegistry, // so we can store fields
70 // Private member data
72 //- Optional tolerance to use in searches
75 //- Optional max tree depth of octree
78 //- Search tree (triangles)
79 mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
81 //- Search tree for boundary edges.
82 mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
85 mutable wordList regions_;
88 mutable label surfaceClosed_;
90 // Private Member Functions
92 ////- Helper: find instance of files without header
93 //static word findRawInstance
100 //- Check file existence
101 static const fileName& checkFile
103 const fileName& fName,
104 const fileName& objectName
107 //- Helper function for isSurfaceClosed
108 static bool addFaceToEdge
114 //- Check whether surface is closed without calculating any permanent
116 bool isSurfaceClosed() const;
118 //- Steps to next intersection. Adds smallVec and starts tracking
120 static void getNextIntersections
122 const indexedOctree<treeDataTriSurface>& octree,
125 const vector& smallVec,
126 DynamicList<pointIndexHit, 1, 1>& hits
129 //- Disallow default bitwise copy construct
130 triSurfaceMesh(const triSurfaceMesh&);
132 //- Disallow default bitwise assignment
133 void operator=(const triSurfaceMesh&);
138 //- Calculate (number of)used points and their bounding box
139 void calcBounds(boundBox& bb, label& nPoints) const;
143 //- Runtime type information
144 TypeName("triSurfaceMesh");
149 //- Construct from triSurface
150 triSurfaceMesh(const IOobject&, const triSurface&);
153 triSurfaceMesh(const IOobject& io);
155 //- Construct from IO and dictionary (used by searchableSurface).
156 // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
160 const dictionary& dict
166 virtual ~triSurfaceMesh();
175 virtual void movePoints(const pointField&);
177 //- Demand driven contruction of octree
178 const indexedOctree<treeDataTriSurface>& tree() const;
180 //- Demand driven contruction of octree for boundary edges
181 const indexedOctree<treeDataEdge>& edgeTree() const;
184 // searchableSurface implementation
186 virtual const wordList& regions() const;
188 //- Whether supports volume type below. I.e. whether is closed.
189 virtual bool hasVolumeType() const;
191 //- Range of local indices that can be returned.
192 virtual label size() const
194 return triSurface::size();
197 //- Get representative set of element coordinates
198 // Usually the element centres (should be of length size()).
199 virtual pointField coordinates() const;
201 virtual void findNearest
203 const pointField& sample,
204 const scalarField& nearestDistSqr,
208 virtual void findLine
210 const pointField& start,
211 const pointField& end,
215 virtual void findLineAny
217 const pointField& start,
218 const pointField& end,
222 //- Get all intersections in order from start to end.
223 virtual void findLineAll
225 const pointField& start,
226 const pointField& end,
227 List<List<pointIndexHit> >&
230 //- From a set of points and indices get the region
231 virtual void getRegion
233 const List<pointIndexHit>&,
237 //- From a set of points and indices get the normal
238 virtual void getNormal
240 const List<pointIndexHit>&,
244 //- Determine type (inside/outside/mixed) for point. unknown if
245 // cannot be determined (e.g. non-manifold surface)
246 virtual void getVolumeType
254 //- Set bounds of surface. Bounds currently set as list of
255 // bounding boxes. The bounds are hints to the surface as for
256 // the range of queries it can expect. faceMap/pointMap can be
257 // set if the surface has done any redistribution.
258 virtual void distribute
260 const List<treeBoundBox>&,
261 const bool keepNonLocal,
262 autoPtr<mapDistribute>& faceMap,
263 autoPtr<mapDistribute>& pointMap
267 //- WIP. Store element-wise field.
268 virtual void setField(const labelList& values);
270 //- WIP. From a set of hits (points and
271 // indices) get the specified field. Misses do not get set.
272 virtual void getField(const List<pointIndexHit>&, labelList&) const;
275 // regIOobject implementation
277 bool writeData(Ostream&) const
279 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
283 //- Write using given format, version and compression
284 virtual bool writeObject
286 IOstream::streamFormat fmt,
287 IOstream::versionNumber ver,
288 IOstream::compressionType cmp
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 } // End namespace Foam
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 // ************************************************************************* //