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-2013 OpenFOAM Foundation
6  \\/ M anipulation |
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.
80  mutable autoPtr<indexedOctree<treeDataEdge> > edgeTree_;
81 
82  //- Names of regions
83  mutable wordList regions_;
84 
85  //- Is surface closed
86  mutable label surfaceClosed_;
87 
88 
89  // Private Member Functions
90 
92  //static word findRawInstance
93  //(
94  // const Time&,
95  // const fileName&,
96  // const word&
97  //);
98 
99  //- Check file existence
100  static const fileName& checkFile
101  (
102  const fileName& fName,
103  const fileName& objectName
104  );
105 
106  //- Helper function for isSurfaceClosed
107  static bool addFaceToEdge
108  (
109  const edge&,
111  );
112 
113  //- Check whether surface is closed without calculating any permanent
114  // addressing.
115  bool isSurfaceClosed() const;
116 
117  //- Steps to next intersection. Adds smallVec and starts tracking
118  // from there.
119  static void getNextIntersections
120  (
121  const indexedOctree<treeDataTriSurface>& octree,
122  const point& start,
123  const point& end,
124  const vector& smallVec,
126  );
127 
128  //- Disallow default bitwise copy construct
130 
131  //- Disallow default bitwise assignment
132  void operator=(const triSurfaceMesh&);
133 
134 
135 public:
136 
137  //- Runtime type information
138  TypeName("triSurfaceMesh");
139 
140 
141  // Constructors
142 
143  //- Construct from triSurface
144  triSurfaceMesh(const IOobject&, const triSurface&);
145 
146  //- Construct read.
147  triSurfaceMesh(const IOobject& io);
148 
149  //- Construct from IO and dictionary (used by searchableSurface).
150  // Dictionary may contain a 'scale' entry (eg, 0.001: mm -> m)
152  (
153  const IOobject& io,
154  const dictionary& dict
155  );
156 
157 
158  //- Destructor
159  virtual ~triSurfaceMesh();
160 
161  //- Clear storage
162  void clearOut();
163 
164 
165  // Member Functions
166 
167  //- Move points
168  virtual void movePoints(const pointField&);
169 
170  //- Demand driven construction of octree for boundary edges
171  const indexedOctree<treeDataEdge>& edgeTree() const;
172 
173 
174  // searchableSurface implementation
175 
176  virtual const wordList& regions() const;
177 
178  //- Whether supports volume type below. I.e. whether is closed.
179  virtual bool hasVolumeType() const;
180 
181  //- Range of local indices that can be returned.
182  virtual label size() const
183  {
184  return triSurface::size();
185  }
186 
187  //- Get representative set of element coordinates
188  // Usually the element centres (should be of length size()).
189  virtual tmp<pointField> coordinates() const;
190 
191  //- Get bounding spheres (centre and radius squared). Any point
192  // on surface is guaranteed to be inside.
193  virtual void boundingSpheres
194  (
195  pointField& centres,
196  scalarField& radiusSqr
197  ) const;
198 
199  //- Get the points that define the surface.
200  virtual tmp<pointField> points() const;
201 
202  // Does any part of the surface overlap the supplied bound box?
203  virtual bool overlaps(const boundBox& bb) const;
204 
205  virtual void findNearest
206  (
207  const pointField& sample,
208  const scalarField& nearestDistSqr,
210  ) const;
211 
212  virtual void findNearest
213  (
214  const pointField& sample,
215  const scalarField& nearestDistSqr,
216  const labelList& regionIndices,
218  ) const;
219 
220  virtual void findLine
221  (
222  const pointField& start,
223  const pointField& end,
225  ) const;
226 
227  virtual void findLineAny
228  (
229  const pointField& start,
230  const pointField& end,
232  ) const;
233 
234  //- Get all intersections in order from start to end.
235  virtual void findLineAll
236  (
237  const pointField& start,
238  const pointField& end,
240  ) const;
241 
242  //- From a set of points and indices get the region
243  virtual void getRegion
244  (
245  const List<pointIndexHit>&,
246  labelList& region
247  ) const;
248 
249  //- From a set of points and indices get the normal
250  virtual void getNormal
251  (
252  const List<pointIndexHit>&,
254  ) const;
255 
256  //- Determine type (inside/outside/mixed) for point. unknown if
257  // cannot be determined (e.g. non-manifold surface)
258  virtual void getVolumeType
259  (
260  const pointField&,
262  ) const;
263 
264 
265  // Other
266 
267  //- WIP. Store element-wise field.
268  virtual void setField(const labelList& values);
269 
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;
273 
274 
275  // regIOobject implementation
277  bool writeData(Ostream&) const
278  {
279  notImplemented("triSurfaceMesh::writeData(Ostream&) const");
280  return false;
281  }
282 
283  //- Write using given format, version and compression
284  virtual bool writeObject
285  (
289  ) const;
290 };
291 
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 } // End namespace Foam
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual label size() const
Range of local indices that can be returned.
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
Triangulated surface description with patch information.
Definition: triSurface.H:57
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
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
void clearOut()
Clear storage.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
virtual void movePoints(const pointField &)
Move points.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
virtual ~triSurfaceMesh()
Destructor.
Namespace for OpenFOAM.
TypeName("triSurfaceMesh")
Runtime type information.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
dictionary dict
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
virtual tmp< pointField > points() const
Get the points that define the surface.
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
Registry of regIOobjects.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
A class for handling file names.
Definition: fileName.H:69
A normal distribution model.
label size() const
Return the number of elements in the UList.
bool writeData(Ostream &) const
writeData function required by regIOobject but not used
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition: HashTable.H:106
Version number type.
Definition: IOstream.H:96
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
IOoject and searching on triSurface.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
A class for managing temporary objects.
Definition: PtrList.H:118
virtual void setField(const labelList &values)
WIP. Store element-wise field.
virtual const wordList & regions() const
Names of regions.