extendedEdgeMesh.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-2017 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::extendedEdgeMesh
26 
27 Description
28 
29  Description of feature edges and points.
30 
31  Feature points are a sorted subset at the start of the overall points list:
32  0 .. concaveStart_-1 : convex points (w.r.t normals)
33  concaveStart_ .. mixedStart_-1 : concave points
34  mixedStart_ .. nonFeatureStart_-1 : mixed internal/external points
35  nonFeatureStart_ .. size-1 : non-feature points
36 
37  Feature edges are the edgeList of the edgeMesh and are sorted:
38  0 .. internalStart_-1 : external edges (convex w.r.t normals)
39  internalStart_ .. flatStart_-1 : internal edges (concave)
40  flatStart_ .. openStart_-1 : flat edges (neither concave or convex)
41  can arise from region interfaces on
42  flat surfaces
43  openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces)
44  multipleStart_ .. size-1 : multiply connected edges
45 
46  The edge direction and feature edge and feature point adjacent normals
47  are stored.
48 
49 SourceFiles
50  extendedEdgeMeshI.H
51  extendedEdgeMesh.C
52  extendedEdgeMeshNew.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef extendedEdgeMesh_H
57 #define extendedEdgeMesh_H
58 
59 #include "edgeMesh.H"
60 #include "indexedOctree.H"
61 #include "treeDataEdge.H"
62 #include "treeDataPoint.H"
63 #include "PrimitivePatch.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 class surfaceFeatures;
71 class objectRegistry;
72 
73 // Forward declaration of friend functions and operators
74 
75 class extendedEdgeMesh;
76 
77 Istream& operator>>(Istream&, extendedEdgeMesh&);
78 Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
79 
80 
81 /*---------------------------------------------------------------------------*\
82  Class extendedEdgeMesh Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 class extendedEdgeMesh
86 :
87  public edgeMesh
88 {
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("extendedEdgeMesh");
94 
95  enum pointStatus
96  {
97  CONVEX, // Fully convex point (w.r.t normals)
98  CONCAVE, // Fully concave point
99  MIXED, // A point surrounded by both convex and concave edges
100  NONFEATURE // Not a feature point
101  };
105  enum edgeStatus
106  {
107  EXTERNAL, // "Convex" edge
108  INTERNAL, // "Concave" edge
109  FLAT, // Neither concave or convex, on a flat surface
110  OPEN, // i.e. only connected to one face
111  MULTIPLE, // Multiply connected (connected to more than two faces)
112  NONE // Not a classified feature edge (consistency with
113  // surfaceFeatures)
114  };
117 
118  //- Normals point to the outside
119  enum sideVolumeType
120  {
121  INSIDE = 0, // mesh inside
122  OUTSIDE = 1, // mesh outside
123  BOTH = 2, // e.g. a baffle
124  NEITHER = 3 // not sure when this may be used
125  };
128 
129  //- Angular closeness tolerance for treating normals as the same
130  static scalar cosNormalAngleTol_;
131 
132 
133 protected:
134 
135  // Static data
136 
137  //- Index of the start of the convex feature points - static as 0
138  static label convexStart_;
139 
140  //- Index of the start of the external feature edges - static as 0
141  static label externalStart_;
142 
143 
144  // Protected data
145 
146  //- Index of the start of the concave feature points
148 
149  //- Index of the start of the mixed type feature points
151 
152  //- Index of the start of the non-feature points
154 
155  //- Index of the start of the internal feature edges
157 
158  //- Index of the start of the flat feature edges
160 
161  //- Index of the start of the open feature edges
163 
164  //- Index of the start of the multiply-connected feature edges
166 
167  //- Normals of the features, to be referred to by index by both feature
168  // points and edges, unsorted
170 
171  //- Type per normal: which side of normal to mesh
173 
174  //- Flat and open edges require the direction of the edge
176 
177  //- Starting directions for the edges.
178  // This vector points to the half of the plane defined by the first
179  // edge normal.
181 
182  //- Indices of the normals that are adjacent to the feature edges
184 
185  //- Indices of the normals that are adjacent to the feature points
186  // (only valid for 0..nonFeatureStart_-1)
188 
189  //- Indices of feature edges attached to feature points. The edges are
190  // ordered so that they can be circulated.
192 
193  //- Feature edges which are on the boundary between regions
195 
196  //- Search tree for all feature points
198 
199  //- Search tree for all edges
201 
202  //- Individual search trees for each type of edge
204 
205 
206  // Protected Member Functions
207 
208  //- Classify the type of feature point. Requires valid stored member
209  // data for edges and normals.
211 
212  template<class Patch>
213  void sortPointsAndEdges
214  (
215  const Patch&,
216  const labelList& featureEdges,
217  const labelList& regionFeatureEdges,
218  const labelList& feaurePoints
219  );
220 
221 public:
222 
223  // Static data
224 
225  //- Number of possible point types (i.e. number of slices)
226  static label nPointTypes;
227 
228  //- Number of possible feature edge types (i.e. number of slices)
229  static label nEdgeTypes;
230 
231  //- Can we read this file format?
232  static bool canRead(const fileName&, const bool verbose=false);
233 
234  //- Can we read this file format?
235  static bool canReadType(const word& ext, const bool verbose=false);
236 
237  //- Can we write this file format type?
238  static bool canWriteType(const word& ext, const bool verbose=false);
239 
240  static wordHashSet readTypes();
241  static wordHashSet writeTypes();
242 
243 
244  // Constructors
245 
246  //- Construct null
248 
249  //- Construct as copy
250  explicit extendedEdgeMesh(const extendedEdgeMesh&);
251 
252  //- Construct from file name (uses extension to determine type)
253  extendedEdgeMesh(const fileName&);
254 
255  //- Construct from file name (uses extension to determine type)
256  extendedEdgeMesh(const fileName&, const word& ext);
257 
258  //- Construct from Istream
260 
261  //- Construct by transferring components (points, edges)
263  (
264  const Xfer<pointField>&,
265  const Xfer<edgeList>&
266  );
267 
268  //- Construct given a surface with selected edges,points
269  // (surfaceFeatures)
270  // Extracts, classifies and reorders the data from surfaceFeatures.
272  (
273  const surfaceFeatures& sFeat,
274  const boolList& surfBaffleRegions
275  );
276 
277  //- Construct from PrimitivePatch
279  (
281  const labelList& featureEdges,
282  const labelList& regionFeatureEdges,
283  const labelList& featurePoints
284  );
285 
286  //- Construct from all components
288  (
289  const pointField& pts,
290  const edgeList& eds,
298  const vectorField& normals,
302  const labelListList& edgeNormals,
305  const labelList& regionEdges
306  );
307 
308 
309  // Declare run-time constructor selection table
310 
312  (
313  autoPtr,
315  fileExtension,
316  (
317  const fileName& name
318  ),
319  (name)
320  );
321 
322 
323  // Selectors
324 
325  //- Select constructed from filename (explicit extension)
327  (
328  const fileName&,
329  const word& ext
330  );
331 
332  //- Select constructed from filename (implicit extension)
333  static autoPtr<extendedEdgeMesh> New(const fileName&);
334 
335 
336  //- Destructor
338 
339 
340  // Member Functions
341 
342  // Find
343 
344  //- Find nearest surface edge for the sample point.
346  (
347  const point& sample,
348  scalar searchDistSqr,
349  pointIndexHit& info
350  ) const;
351 
352  //- Find nearest surface edge for the sample point.
353  void nearestFeatureEdge
354  (
355  const point& sample,
356  scalar searchDistSqr,
357  pointIndexHit& info
358  ) const;
359 
360  //- Find nearest surface edge for each sample point.
361  void nearestFeatureEdge
362  (
363  const pointField& samples,
364  const scalarField& searchDistSqr,
365  List<pointIndexHit>& info
366  ) const;
367 
368  //- Find the nearest point on each type of feature edge
370  (
371  const point& sample,
372  const scalarField& searchDistSqr,
373  List<pointIndexHit>& info
374  ) const;
375 
376  //- Find all the feature points within searchDistSqr of sample
378  (
379  const point& sample,
380  scalar searchRadiusSqr,
381  List<pointIndexHit>& info
382  ) const;
383 
384  //- Find all the feature edges within searchDistSqr of sample
386  (
387  const point& sample,
388  const scalar searchRadiusSqr,
389  List<pointIndexHit>& info
390  ) const;
391 
392 
393  // Access
394 
395  //- Return the index of the start of the convex feature points
396  inline label convexStart() const;
397 
398  //- Return the index of the start of the concave feature points
399  inline label concaveStart() const;
400 
401  //- Return the index of the start of the mixed type feature points
402  inline label mixedStart() const;
403 
404  //- Return the index of the start of the non-feature points
405  inline label nonFeatureStart() const;
406 
407  //- Return the index of the start of the external feature edges
408  inline label externalStart() const;
409 
410  //- Return the index of the start of the internal feature edges
411  inline label internalStart() const;
412 
413  //- Return the index of the start of the flat feature edges
414  inline label flatStart() const;
415 
416  //- Return the index of the start of the open feature edges
417  inline label openStart() const;
418 
419  //- Return the index of the start of the multiply-connected feature
420  // edges
421  inline label multipleStart() const;
422 
423  //- Return whether or not the point index is a feature point
424  inline bool featurePoint(label ptI) const;
425 
426  //- Return the normals of the surfaces adjacent to the feature edges
427  // and points
428  inline const vectorField& normals() const;
429 
430  //- Return
431  inline const List<sideVolumeType>& normalVolumeTypes() const;
432 
433  //- Return the edgeDirection vectors
434  inline const vectorField& edgeDirections() const;
435 
436  //-
437  inline const labelListList& normalDirections() const;
438 
439  //- Return the direction of edgeI, pointing away from ptI
440  inline vector edgeDirection(label edgeI, label ptI) const;
441 
442  //- Return the indices of the normals that are adjacent to the
443  // feature edges
444  inline const labelListList& edgeNormals() const;
445 
446  //- Return the normal vectors for a given set of normal indices
447  inline vectorField edgeNormals(const labelList& edgeNormIs) const;
448 
449  //- Return the normal vectors for a given edge
450  inline vectorField edgeNormals(label edgeI) const;
451 
452  //- Return the indices of the normals that are adjacent to the
453  // feature points
454  inline const labelListList& featurePointNormals() const;
455 
456  //- Return the normal vectors for a given feature point
457  inline vectorField featurePointNormals(label ptI) const;
458 
459  //- Return the edge labels for a given feature point. Edges are
460  // ordered by the faces that they share. The edge labels
461  // correspond to the entry in edges().
462  inline const labelListList& featurePointEdges() const;
463 
464  //- Return the feature edges which are on the boundary between
465  // regions
466  inline const labelList& regionEdges() const;
467 
468  //- Return the pointStatus of a specified point
469  inline pointStatus getPointStatus(label ptI) const;
470 
471  //- Return the edgeStatus of a specified edge
472  inline edgeStatus getEdgeStatus(label edgeI) const;
473 
474  //- Return the baffle faces of a specified edge
475  inline PackedList<2> edgeBaffles(label edgeI) const;
476 
477  //- Demand driven construction of octree for feature points
479 
480  //- Demand driven construction of octree for boundary edges
481  const indexedOctree<treeDataEdge>& edgeTree() const;
482 
483  //- Demand driven construction of octree for boundary edges by type
485  edgeTreesByType() const;
486 
487 
488  // Edit
489 
490  //- Transfer the contents of the argument and annul the argument
491  void transfer(extendedEdgeMesh&);
492 
493  //- Transfer contents to the Xfer container
495 
496  //- Clear all storage
497  virtual void clear();
498 
499  //- Add extendedEdgeMesh. No filtering of duplicates.
500  void add(const extendedEdgeMesh&);
501 
502  //- Flip normals. All concave become convex, all internal external
503  // etc.
504  void flipNormals();
505 
506 
507  // Read
508 
509  //- Read from file. Chooses reader based on explicit extension
510  bool read(const fileName&, const word& ext);
511 
512  //- Read from file. Chooses reader based on detected extension
513  virtual bool read(const fileName&);
514 
515 
516  // Write
517 
518  //- Write all components of the extendedEdgeMesh as obj files
519  void writeObj(const fileName& prefix) const;
520 
521  //- Dump some information
522  virtual void writeStats(Ostream& os) const;
523 
524  friend Istream& operator>>(Istream& is, sideVolumeType& vt);
525  friend Ostream& operator<<(Ostream& os, const sideVolumeType& vt);
526 
527 
528  //- Classify the type of feature edge. Requires face centre 0 to face
529  // centre 1 vector to distinguish internal from external
530  static edgeStatus classifyEdge
531  (
532  const List<vector>& norms,
533  const labelList& edNorms,
534  const vector& fC0tofC1
535  );
536 
537 
538  // Ostream Operator
539 
540  friend Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
542 };
543 
544 
547 
548 
549 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
550 
551 } // End namespace Foam
552 
553 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
554 
555 #include "extendedEdgeMeshI.H"
556 
557 #ifdef NoRepository
558  #include "extendedEdgeMeshTemplates.C"
559 #endif
560 
561 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
562 
563 #endif
564 
565 // ************************************************************************* //
extendedEdgeMesh()
Construct null.
label nonFeatureStart() const
Return the index of the start of the non-feature points.
pointStatus getPointStatus(label ptI) const
Return the pointStatus of a specified point.
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
static autoPtr< extendedEdgeMesh > New(const fileName &, const word &ext)
Select constructed from filename (explicit extension)
label convexStart() const
Return the index of the start of the convex feature points.
const labelListList & featurePointNormals() const
Return the indices of the normals that are adjacent to the.
A HashTable with keys but without contents.
Definition: HashSet.H:59
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
A class for handling file names.
Definition: fileName.H:69
static wordHashSet readTypes()
vectorField normals_
Normals of the features, to be referred to by index by both feature.
declareRunTimeSelectionTable(autoPtr, extendedEdgeMesh, fileExtension,(const fileName &name),(name))
const labelListList & edgeNormals() const
Return the indices of the normals that are adjacent to the.
const labelListList & normalDirections() const
void nearestFeaturePoint(const point &sample, scalar searchDistSqr, pointIndexHit &info) const
Find nearest surface edge for the sample point.
static bool canWriteType(const word &ext, const bool verbose=false)
Can we write this file format type?
TypeName("extendedEdgeMesh")
Runtime type information.
void sortPointsAndEdges(const Patch &, const labelList &featureEdges, const labelList &regionFeatureEdges, const labelList &feaurePoints)
PtrList< indexedOctree< treeDataEdge > > edgeTreesByType_
Individual search trees for each type of edge.
label mixedStart_
Index of the start of the mixed type feature points.
const List< sideVolumeType > & normalVolumeTypes() const
Return.
virtual void writeStats(Ostream &os) const
Dump some information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Description of feature edges and points.
label multipleStart() const
Return the index of the start of the multiply-connected feature.
label openStart_
Index of the start of the open feature edges.
static const Foam::NamedEnum< sideVolumeType, 4 > sideVolumeTypeNames_
virtual void clear()
Clear all storage.
bool featurePoint(label ptI) const
Return whether or not the point index is a feature point.
static const Foam::NamedEnum< edgeStatus, 6 > edgeStatusNames_
const vectorField & normals() const
Return the normals of the surfaces adjacent to the feature edges.
label concaveStart_
Index of the start of the concave feature points.
label openStart() const
Return the index of the start of the open feature edges.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:53
List< sideVolumeType > normalVolumeTypes_
Type per normal: which side of normal to mesh.
void add(const extendedEdgeMesh &)
Add extendedEdgeMesh. No filtering of duplicates.
const labelList & regionEdges() const
Return the feature edges which are on the boundary between.
void writeObj(const fileName &prefix) const
Write all components of the extendedEdgeMesh as obj files.
friend Ostream & operator<<(Ostream &os, const sideVolumeType &vt)
edgeStatus getEdgeStatus(label edgeI) const
Return the edgeStatus of a specified edge.
label internalStart_
Index of the start of the internal feature edges.
labelListList normalDirections_
Starting directions for the edges.
scalarField samples(nIntervals, 0)
A list of faces which address into the list of points.
void flipNormals()
Flip normals. All concave become convex, all internal external.
label flatStart() const
Return the index of the start of the flat feature edges.
labelList regionEdges_
Feature edges which are on the boundary between regions.
static label convexStart_
Index of the start of the convex feature points - static as 0.
label internalStart() const
Return the index of the start of the internal feature edges.
static label nEdgeTypes
Number of possible feature edge types (i.e. number of slices)
A class for handling words, derived from string.
Definition: word.H:59
label flatStart_
Index of the start of the flat feature edges.
Istream & operator>>(Istream &, directionInfo &)
bool read(const fileName &, const word &ext)
Read from file. Chooses reader based on explicit extension.
~extendedEdgeMesh()
Destructor.
sideVolumeType
Normals point to the outside.
static label externalStart_
Index of the start of the external feature edges - static as 0.
void transfer(extendedEdgeMesh &)
Transfer the contents of the argument and annul the argument.
autoPtr< indexedOctree< treeDataEdge > > edgeTree_
Search tree for all edges.
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
static scalar cosNormalAngleTol_
Angular closeness tolerance for treating normals as the same.
label mixedStart() const
Return the index of the start of the mixed type feature points.
label externalStart() const
Return the index of the start of the external feature edges.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
PackedList< 2 > edgeBaffles(label edgeI) const
Return the baffle faces of a specified edge.
const labelListList & featurePointEdges() const
Return the edge labels for a given feature point. Edges are.
Points connected by edges.
Definition: edgeMesh.H:69
const PtrList< indexedOctree< treeDataEdge > > & edgeTreesByType() const
Demand driven construction of octree for boundary edges by type.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static edgeStatus classifyEdge(const List< vector > &norms, const labelList &edNorms, const vector &fC0tofC1)
Classify the type of feature edge. Requires face centre 0 to face.
static bool canReadType(const word &ext, const bool verbose=false)
Can we read this file format?
const vectorField & edgeDirections() const
Return the edgeDirection vectors.
Xfer< extendedEdgeMesh > xfer()
Transfer contents to the Xfer container.
label multipleStart_
Index of the start of the multiply-connected feature edges.
static const Foam::NamedEnum< pointStatus, 4 > pointStatusNames_
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
Ostream & operator<<(Ostream &, const ensightPart &)
static bool canRead(const fileName &, const bool verbose=false)
Can we read this file format?
friend Istream & operator>>(Istream &is, sideVolumeType &vt)
labelListList featurePointEdges_
Indices of feature edges attached to feature points. The edges are.
static label nPointTypes
Number of possible point types (i.e. number of slices)
void allNearestFeatureEdges(const point &sample, const scalar searchRadiusSqr, List< pointIndexHit > &info) const
Find all the feature edges within searchDistSqr of sample.
const indexedOctree< treeDataPoint > & pointTree() const
Demand driven construction of octree for feature points.
static wordHashSet writeTypes()
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
labelListList featurePointNormals_
Indices of the normals that are adjacent to the feature points.
labelListList edgeNormals_
Indices of the normals that are adjacent to the feature edges.
label nonFeatureStart_
Index of the start of the non-feature points.
void nearestFeatureEdge(const point &sample, scalar searchDistSqr, pointIndexHit &info) const
Find nearest surface edge for the sample point.
void nearestFeatureEdgeByType(const point &sample, const scalarField &searchDistSqr, List< pointIndexHit > &info) const
Find the nearest point on each type of feature edge.
vector edgeDirection(label edgeI, label ptI) const
Return the direction of edgeI, pointing away from ptI.
vectorField edgeDirections_
Flat and open edges require the direction of the edge.
autoPtr< indexedOctree< treeDataPoint > > pointTree_
Search tree for all feature points.
Holds feature edges/points of surface.
Namespace for OpenFOAM.
label concaveStart() const
Return the index of the start of the concave feature points.
void allNearestFeaturePoints(const point &sample, scalar searchRadiusSqr, List< pointIndexHit > &info) const
Find all the feature points within searchDistSqr of sample.
pointStatus classifyFeaturePoint(label ptI) const
Classify the type of feature point. Requires valid stored member.