triSurfaceMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::triSurfaceMesh
26 
27 Description
28  IOoject and searching on triSurface
29 
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
35 
36 SourceFiles
37  triSurfaceMesh.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef triSurfaceMesh_H
42 #define triSurfaceMesh_H
43 
44 #include "treeBoundBox.H"
45 #include "searchableSurface.H"
46 #include "objectRegistry.H"
47 #include "indexedOctree.H"
48 #include "treeDataTriSurface.H"
49 #include "treeDataPrimitivePatch.H"
50 #include "treeDataEdge.H"
51 #include "EdgeMap.H"
52 #include "triSurface.H"
53 #include "triSurfaceRegionSearch.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class triSurfaceMesh Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class triSurfaceMesh
65 :
66  public searchableSurface,
67  public objectRegistry, // so we can store fields
68  public triSurface,
70 {
71 private:
72 
73  // Private member data
74 
75  //- Optional min triangle quality. Triangles below this get
76  // ignored for normal calculation
77  scalar minQuality_;
78 
79  //- Search tree for boundary edges.
81 
82  //- Names of regions
83  mutable wordList regions_;
84 
85  //- Is surface closed
86  mutable label surfaceClosed_;
87 
88  //- If surface is closed, what is type of outside points
90 
91 
92  // Private Member Functions
93 
95  //static word findRawInstance
96  //(
97  // const Time&,
98  // const fileName&,
99  // const word&
100  //);
101 
102  //- Check file existence
103  static const fileName& checkFile
104  (
105  const fileName& fName,
106  const fileName& objectName
107  );
108 
109  //- Helper function for isSurfaceClosed
110  static bool addFaceToEdge
111  (
112  const edge&,
114  );
115 
116  //- Check whether surface is closed without calculating any permanent
117  // addressing.
118  bool isSurfaceClosed() const;
119 
120  //- Steps to next intersection. Adds smallVec and starts tracking
121  // from there.
122  static void getNextIntersections
123  (
124  const indexedOctree<treeDataTriSurface>& octree,
125  const point& start,
126  const point& end,
127  const vector& smallVec,
129  );
130 
131  //- Disallow default bitwise copy construct
133 
134  //- Disallow default bitwise assignment
135  void operator=(const triSurfaceMesh&);
136 
137 
138 public:
139 
140  //- Runtime type information
141  TypeName("triSurfaceMesh");
142 
143  //- Return the mesh sub-directory name (usually "triSurface")
144  static word meshSubDir;
145 
146 
147  // Constructors
148 
149  //- Construct from triSurface
150  triSurfaceMesh(const IOobject&, const triSurface&);
151 
152  //- Construct read.
153  triSurfaceMesh(const IOobject& io);
154 
155  //- Construct from IO and dictionary (used by searchableSurface).
156  // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
158  (
159  const IOobject& io,
160  const dictionary& dict
161  );
162 
163 
164  //- Destructor
165  virtual ~triSurfaceMesh();
166 
167  //- Clear storage
168  void clearOut();
169 
170 
171  // Member Functions
172 
173  //- Move points
174  virtual void movePoints(const pointField&);
175 
176  //- Demand driven construction of octree for boundary edges
177  const indexedOctree<treeDataEdge>& edgeTree() const;
178 
179 
180  // searchableSurface implementation
181 
182  virtual const wordList& regions() const;
183 
184  //- Whether supports volume type below. I.e. whether is closed.
185  virtual bool hasVolumeType() const;
186 
187  //- Range of local indices that can be returned.
188  virtual label size() const
189  {
190  return triSurface::size();
191  }
192 
193  //- Get representative set of element coordinates
194  // Usually the element centres (should be of length size()).
195  virtual tmp<pointField> coordinates() const;
196 
197  //- Get bounding spheres (centre and radius squared). Any point
198  // on surface is guaranteed to be inside.
199  virtual void boundingSpheres
200  (
201  pointField& centres,
202  scalarField& radiusSqr
203  ) const;
204 
205  //- Get the points that define the surface.
206  virtual tmp<pointField> points() const;
207 
208  // Does any part of the surface overlap the supplied bound box?
209  virtual bool overlaps(const boundBox& bb) const;
210 
211  virtual void findNearest
212  (
213  const pointField& sample,
214  const scalarField& nearestDistSqr,
216  ) const;
217 
218  virtual void findNearest
219  (
220  const pointField& sample,
221  const scalarField& nearestDistSqr,
222  const labelList& regionIndices,
224  ) const;
225 
226  virtual void findLine
227  (
228  const pointField& start,
229  const pointField& end,
231  ) const;
232 
233  virtual void findLineAny
234  (
235  const pointField& start,
236  const pointField& end,
238  ) const;
239 
240  //- Get all intersections in order from start to end.
241  virtual void findLineAll
242  (
243  const pointField& start,
244  const pointField& end,
246  ) const;
247 
248  //- From a set of points and indices get the region
249  virtual void getRegion
250  (
251  const List<pointIndexHit>&,
252  labelList& region
253  ) const;
254 
255  //- From a set of points and indices get the normal
256  virtual void getNormal
257  (
258  const List<pointIndexHit>&,
260  ) const;
261 
262  //- Determine type (inside/outside/mixed) for point. unknown if
263  // cannot be determined (e.g. non-manifold surface)
264  virtual void getVolumeType
265  (
266  const pointField&,
268  ) const;
269 
270 
271  // Other
272 
273  //- WIP. Store element-wise field.
274  virtual void setField(const labelList& values);
275 
276  //- WIP. From a set of hits (points and
277  // indices) get the specified field. Misses do not get set.
278  virtual void getField(const List<pointIndexHit>&, labelList&) const;
279 
280 
281  // regIOobject implementation
282 
283  bool writeData(Ostream&) const
284  {
286  return false;
287  }
288 
289  //- Write using given format, version and compression
290  virtual bool writeObject
291  (
295  ) const;
296 };
297 
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #endif
306 
307 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::triSurfaceMesh::operator=
void operator=(const triSurfaceMesh &)
Disallow default bitwise assignment.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
searchableSurface.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::triSurfaceMesh::minQuality_
scalar minQuality_
Optional min triangle quality. Triangles below this get.
Definition: triSurfaceMesh.H:76
Foam::triSurfaceMesh::edgeTree_
autoPtr< indexedOctree< treeDataEdge > > edgeTree_
Search tree for boundary edges.
Definition: triSurfaceMesh.H:79
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::triSurfaceMesh::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: triSurfaceMesh.C:653
Foam::triSurfaceMesh::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: triSurfaceMesh.C:632
Foam::IOstream::compressionType
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
Foam::triSurfaceMesh::edgeTree
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
Definition: triSurfaceMesh.C:471
Foam::triSurfaceMesh::TypeName
TypeName("triSurfaceMesh")
Runtime type information.
indexedOctree.H
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
objectRegistry.H
Foam::triSurfaceMesh
IOoject and searching on triSurface.
Definition: triSurfaceMesh.H:63
Foam::triSurfaceRegionSearch
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
Definition: triSurfaceRegionSearch.H:55
Foam::triSurfaceMesh::size
virtual label size() const
Range of local indices that can be returned.
Definition: triSurfaceMesh.H:187
Foam::triSurfaceMesh::surfaceClosed_
label surfaceClosed_
Is surface closed.
Definition: triSurfaceMesh.H:85
Foam::triSurfaceMesh::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: triSurfaceMesh.C:610
Foam::triSurfaceMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "triSurface")
Definition: triSurfaceMesh.H:143
Foam::triSurfaceMesh::movePoints
virtual void movePoints(const pointField &)
Move points.
Definition: triSurfaceMesh.C:449
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::IOstream::versionNumber
Version number type.
Definition: IOstream.H:96
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::volumeType
Definition: volumeType.H:54
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:57
treeBoundBox.H
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
Foam::triSurfaceMesh::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Definition: triSurfaceMesh.C:599
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
treeDataPrimitivePatch.H
Foam::triSurfaceMesh::getField
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Definition: triSurfaceMesh.C:770
Foam::triSurfaceMesh::regions
virtual const wordList & regions() const
Names of regions.
Definition: triSurfaceMesh.C:536
Foam::triSurfaceMesh::regions_
wordList regions_
Names of regions.
Definition: triSurfaceMesh.H:82
Foam::triSurfaceMesh::triSurfaceMesh
triSurfaceMesh(const triSurfaceMesh &)
Disallow default bitwise copy construct.
Foam::triSurfaceMesh::writeData
bool writeData(Ostream &) const
writeData function required by regIOobject but not used
Definition: triSurfaceMesh.H:282
Foam::triSurfaceMesh::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
Definition: triSurfaceMesh.C:406
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::triSurfaceMesh::clearOut
void clearOut()
Clear storage.
Definition: triSurfaceMesh.C:378
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
treeDataEdge.H
Foam::triSurfaceMesh::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: triSurfaceMesh.C:433
Foam::triSurfaceMesh::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: triSurfaceMesh.C:389
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::triSurfaceMesh::setField
virtual void setField(const labelList &values)
WIP. Store element-wise field.
Definition: triSurfaceMesh.C:729
Foam::List< labelledTri >::size
label size() const
Return the number of elements in the UList.
Foam::triSurfaceMesh::checkFile
static const fileName & checkFile(const fileName &fName, const fileName &objectName)
Check file existence.
Definition: triSurfaceMesh.C:105
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::EdgeMap< label >
Foam::triSurfaceMesh::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
Definition: triSurfaceMesh.C:621
Foam::triSurfaceMesh::~triSurfaceMesh
virtual ~triSurfaceMesh()
Destructor.
Definition: triSurfaceMesh.C:372
Foam::triSurfaceMesh::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
Definition: triSurfaceMesh.C:570
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::triSurfaceMesh::addFaceToEdge
static bool addFaceToEdge(const edge &, EdgeMap< label > &)
Helper function for isSurfaceClosed.
Definition: triSurfaceMesh.C:121
Foam::triSurfaceMesh::writeObject
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
Definition: triSurfaceMesh.C:840
Foam::triSurfaceMesh::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: triSurfaceMesh.C:439
Foam::triSurfaceMesh::getNextIntersections
static void getNextIntersections(const indexedOctree< treeDataTriSurface > &octree, const point &start, const point &end, const vector &smallVec, DynamicList< pointIndexHit, 1, 1 > &hits)
Steps to next intersection. Adds smallVec and starts tracking.
EdgeMap.H
Foam::triSurfaceMesh::isSurfaceClosed
bool isSurfaceClosed() const
Check whether surface is closed without calculating any permanent.
Definition: triSurfaceMesh.C:143
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
triSurfaceRegionSearch.H
Foam::triSurfaceMesh::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: triSurfaceMesh.C:796
Foam::triSurfaceMesh::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
Definition: triSurfaceMesh.C:551
Foam::triSurfaceMesh::outsideVolType_
volumeType outsideVolType_
If surface is closed, what is type of outside points.
Definition: triSurfaceMesh.H:88
normal
A normal distribution model.
Foam::IOstream::streamFormat
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86