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 "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 max tree depth of octree
77 //- Search tree (triangles)
78 mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
80 //- Search tree for boundary edges.
81 mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
84 mutable wordList regions_;
87 mutable label surfaceClosed_;
89 // Private Member Functions
91 ////- Helper: find instance of files without header
92 //static word findRawInstance
99 //- Check file existence
100 static const fileName& checkFile
102 const fileName& fName,
103 const fileName& objectName
106 //- Helper function for isSurfaceClosed
107 static bool addFaceToEdge
113 //- Check whether surface is closed without calculating any permanent
115 bool isSurfaceClosed() const;
117 //- Steps to next intersection. Adds smallVec and starts tracking
119 static void getNextIntersections
121 const indexedOctree<treeDataTriSurface>& octree,
124 const vector& smallVec,
125 DynamicList<pointIndexHit, 1, 1>& hits
128 //- Disallow default bitwise copy construct
129 triSurfaceMesh(const triSurfaceMesh&);
131 //- Disallow default bitwise assignment
132 void operator=(const triSurfaceMesh&);
137 //- Calculate (number of)used points and their bounding box
138 void calcBounds(boundBox& bb, label& nPoints) const;
142 //- Runtime type information
143 TypeName("triSurfaceMesh");
148 //- Construct from triSurface
149 triSurfaceMesh(const IOobject&, const triSurface&);
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)
159 const dictionary& dict
165 virtual ~triSurfaceMesh();
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
193 return triSurface::size();
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
202 const pointField& sample,
203 const scalarField& nearestDistSqr,
207 virtual void findLine
209 const pointField& start,
210 const pointField& end,
214 virtual void findLineAny
216 const pointField& start,
217 const pointField& end,
221 //- Get all intersections in order from start to end.
222 virtual void findLineAll
224 const pointField& start,
225 const pointField& end,
226 List<List<pointIndexHit> >&
229 //- From a set of points and indices get the region
230 virtual void getRegion
232 const List<pointIndexHit>&,
236 //- From a set of points and indices get the normal
237 virtual void getNormal
239 const List<pointIndexHit>&,
243 //- Determine type (inside/outside/mixed) for point. unknown if
244 // cannot be determined (e.g. non-manifold surface)
245 virtual void getVolumeType
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
259 const List<treeBoundBox>&,
260 const bool keepNonLocal,
261 autoPtr<mapDistribute>& faceMap,
262 autoPtr<mapDistribute>& pointMap
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
278 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
282 //- Write using given format, version and compression
283 virtual bool writeObject
285 IOstream::streamFormat fmt,
286 IOstream::versionNumber ver,
287 IOstream::compressionType cmp
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 } // End namespace Foam
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 // ************************************************************************* //