1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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)
38 \*---------------------------------------------------------------------------*/
40 #ifndef triSurfaceMesh_H
41 #define triSurfaceMesh_H
43 #include "treeBoundBox.H"
44 #include "searchableSurface.H"
45 #include "objectRegistry.H"
46 #include "indexedOctree.H"
47 #include "treeDataTriSurface.H"
48 #include "octreeDataTriSurfaceTreeLeaf.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_;
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 construction 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
255 //- Set bounds of surface. Bounds currently set as list of
256 // bounding boxes. The bounds are hints to the surface as for
257 // the range of queries it can expect. faceMap/pointMap can be
258 // set if the surface has done any redistribution.
259 virtual void distribute
261 const List<treeBoundBox>&,
262 const bool keepNonLocal,
263 autoPtr<mapDistribute>& faceMap,
264 autoPtr<mapDistribute>& pointMap
268 //- WIP. Store element-wise field.
269 virtual void setField(const labelList& values);
271 //- WIP. From a set of hits (points and
272 // indices) get the specified field. Misses do not get set.
273 virtual void getField
275 const List<pointIndexHit>&,
280 // regIOobject implementation
282 bool writeData(Ostream&) const
284 notImplemented("triSurfaceMesh::writeData(Ostream&) const");
289 //- Write using given format, version and compression
290 virtual bool writeObject
292 IOstream::streamFormat fmt,
293 IOstream::versionNumber ver,
294 IOstream::compressionType cmp
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 } // End namespace Foam
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 // ************************************************************************* //