1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 //- Search tree (triangles)
75 mutable autoPtr<indexedOctree<treeDataTriSurface> > tree_;
77 //- Search tree for boundary edges.
78 mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
81 mutable wordList regions_;
84 mutable label surfaceClosed_;
86 // Private Member Functions
88 ////- Helper: find instance of files without header
89 //static word findRawInstance
96 //- Check file existence
97 static const fileName& checkFile
99 const fileName& fName,
100 const fileName& objectName
103 //- Helper function for isSurfaceClosed
104 static bool addFaceToEdge
110 //- Check whether surface is closed without calculating any permanent
112 bool isSurfaceClosed() const;
114 //- Disallow default bitwise copy construct
115 triSurfaceMesh(const triSurfaceMesh&);
117 //- Disallow default bitwise assignment
118 void operator=(const triSurfaceMesh&);
123 //- Runtime type information
124 TypeName("triSurfaceMesh");
129 //- Construct from triSurface
130 triSurfaceMesh(const IOobject&, const triSurface&);
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)
140 const dictionary& dict
146 virtual ~triSurfaceMesh();
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
174 return triSurface::size();
177 virtual void findNearest
179 const pointField& sample,
180 const scalarField& nearestDistSqr,
184 virtual void findLine
186 const pointField& start,
187 const pointField& end,
191 virtual void findLineAny
193 const pointField& start,
194 const pointField& end,
198 //- Get all intersections in order from start to end.
199 virtual void findLineAll
201 const pointField& start,
202 const pointField& end,
203 List<List<pointIndexHit> >&
206 //- From a set of points and indices get the region
207 virtual void getRegion
209 const List<pointIndexHit>&,
213 //- From a set of points and indices get the normal
214 virtual void getNormal
216 const List<pointIndexHit>&,
220 //- Determine type (inside/outside/mixed) for point. unknown if
221 // cannot be determined (e.g. non-manifold surface)
222 virtual void getVolumeType
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
234 const List<treeBoundBox>&,
235 const bool keepNonLocal,
236 autoPtr<mapDistribute>& faceMap,
237 autoPtr<mapDistribute>& pointMap
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
247 const word& fieldName,
248 const List<pointIndexHit>&,
253 // regIOobject implementation
255 bool writeData(Ostream&) const
257 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
261 //- Write using given format, version and compression
262 virtual bool writeObject
264 IOstream::streamFormat fmt,
265 IOstream::versionNumber ver,
266 IOstream::compressionType cmp
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 } // End namespace Foam
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 // ************************************************************************* //