extendedEdgeMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 #include "pointIndexHitList.H"
65 
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 
68 namespace Foam
69 {
70 
71 class surfaceFeatures;
72 class objectRegistry;
73 
74 // Forward declaration of friend functions and operators
75 
76 class extendedEdgeMesh;
77 
78 Istream& operator>>(Istream&, extendedEdgeMesh&);
79 Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
80 
81 
82 /*---------------------------------------------------------------------------*\
83  Class extendedEdgeMesh Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class extendedEdgeMesh
87 :
88  public edgeMesh
89 {
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("extendedEdgeMesh");
95 
96  enum pointStatus
97  {
98  CONVEX, // Fully convex point (w.r.t normals)
99  CONCAVE, // Fully concave point
100  MIXED, // A point surrounded by both convex and concave edges
101  NONFEATURE // Not a feature point
102  };
106  enum edgeStatus
107  {
108  EXTERNAL, // "Convex" edge
109  INTERNAL, // "Concave" edge
110  FLAT, // Neither concave or convex, on a flat surface
111  OPEN, // i.e. only connected to one face
112  MULTIPLE, // Multiply connected (connected to more than two faces)
113  NONE // Not a classified feature edge (consistency with
114  // surfaceFeatures)
115  };
118 
119  //- Normals point to the outside
120  enum sideVolumeType
121  {
122  INSIDE = 0, // mesh inside
123  OUTSIDE = 1, // mesh outside
124  BOTH = 2, // e.g. a baffle
125  NEITHER = 3 // not sure when this may be used
126  };
129 
130  //- Angular closeness tolerance for treating normals as the same
131  static scalar cosNormalAngleTol_;
132 
133 
134 protected:
135 
136  // Static data
137 
138  //- Index of the start of the convex feature points - static as 0
139  static label convexStart_;
140 
141  //- Index of the start of the external feature edges - static as 0
142  static label externalStart_;
143 
144 
145  // Protected data
146 
147  //- Index of the start of the concave feature points
149 
150  //- Index of the start of the mixed type feature points
152 
153  //- Index of the start of the non-feature points
155 
156  //- Index of the start of the internal feature edges
158 
159  //- Index of the start of the flat feature edges
161 
162  //- Index of the start of the open feature edges
164 
165  //- Index of the start of the multiply-connected feature edges
167 
168  //- Normals of the features, to be referred to by index by both feature
169  // points and edges, unsorted
171 
172  //- Type per normal: which side of normal to mesh
174 
175  //- Flat and open edges require the direction of the edge
177 
178  //- Starting directions for the edges.
179  // This vector points to the half of the plane defined by the first
180  // edge normal.
182 
183  //- Indices of the normals that are adjacent to the feature edges
185 
186  //- Indices of the normals that are adjacent to the feature points
187  // (only valid for 0..nonFeatureStart_-1)
189 
190  //- Indices of feature edges attached to feature points. The edges are
191  // ordered so that they can be circulated.
193 
194  //- Feature edges which are on the boundary between regions
196 
197  //- Search tree for all feature points
199 
200  //- Search tree for all edges
202 
203  //- Individual search trees for each type of edge
205 
206 
207  // Protected Member Functions
208 
209  //- Classify the type of feature point. Requires valid stored member
210  // data for edges and normals.
212 
213  template<class Patch>
214  void sortPointsAndEdges
215  (
216  const Patch&,
217  const labelList& featureEdges,
218  const labelList& regionFeatureEdges,
219  const labelList& feaurePoints
220  );
221 
222 public:
223 
224  // Static data
225 
226  //- Number of possible point types (i.e. number of slices)
227  static label nPointTypes;
228 
229  //- Number of possible feature edge types (i.e. number of slices)
230  static label nEdgeTypes;
231 
232  //- Can we read this file format?
233  static bool canRead(const fileName&, const bool verbose=false);
234 
235  //- Can we read this file format?
236  static bool canReadType(const word& ext, const bool verbose=false);
237 
238  //- Can we write this file format type?
239  static bool canWriteType(const word& ext, const bool verbose=false);
240 
241  static wordHashSet readTypes();
242  static wordHashSet writeTypes();
243 
244 
245  // Constructors
246 
247  //- Construct null
249 
250  //- Copy constructor
251  explicit extendedEdgeMesh(const extendedEdgeMesh&);
252 
253  //- Move constructor
255 
256  //- Construct from file name (uses extension to determine type)
257  extendedEdgeMesh(const fileName&);
258 
259  //- Construct from file name (uses extension to determine type)
260  extendedEdgeMesh(const fileName&, const word& ext);
261 
262  //- Construct from Istream
264 
265  //- Construct by transferring components (points, edges)
267  (
268  pointField&&,
269  edgeList&&
270  );
271 
272  //- Construct given a surface with selected edges,points
273  // (surfaceFeatures)
274  // Extracts, classifies and reorders the data from surfaceFeatures.
276  (
277  const surfaceFeatures& sFeat,
278  const boolList& surfBaffleRegions
279  );
280 
281  //- Construct from PrimitivePatch
283  (
285  const labelList& featureEdges,
286  const labelList& regionFeatureEdges,
287  const labelList& featurePoints
288  );
289 
290  //- Construct from all components
292  (
293  const pointField& pts,
294  const edgeList& eds,
302  const vectorField& normals,
306  const labelListList& edgeNormals,
309  const labelList& regionEdges
310  );
311 
312 
313  // Declare run-time constructor selection table
314 
316  (
317  autoPtr,
319  fileExtension,
320  (
321  const fileName& name
322  ),
323  (name)
324  );
325 
326 
327  // Selectors
328 
329  //- Select constructed from filename (explicit extension)
331  (
332  const fileName&,
333  const word& ext
334  );
335 
336  //- Select constructed from filename (implicit extension)
337  static autoPtr<extendedEdgeMesh> New(const fileName&);
338 
339 
340  //- Destructor
342 
343 
344  // Member Functions
345 
346  // Find
347 
348  //- Find nearest surface edge for the sample point.
350  (
351  const point& sample,
352  scalar searchDistSqr,
353  pointIndexHit& info
354  ) const;
355 
356  //- Find nearest surface edge for the sample point.
357  void nearestFeatureEdge
358  (
359  const point& sample,
360  scalar searchDistSqr,
361  pointIndexHit& info
362  ) const;
363 
364  //- Find nearest surface edge for each sample point.
365  void nearestFeatureEdge
366  (
367  const pointField& samples,
368  const scalarField& searchDistSqr,
369  pointIndexHitList& info
370  ) const;
371 
372  //- Find the nearest point on each type of feature edge
374  (
375  const point& sample,
376  const scalarField& searchDistSqr,
377  pointIndexHitList& info
378  ) const;
379 
380  //- Find all the feature points within searchDistSqr of sample
382  (
383  const point& sample,
384  scalar searchRadiusSqr,
385  pointIndexHitList& info
386  ) const;
387 
388  //- Find all the feature edges within searchDistSqr of sample
390  (
391  const point& sample,
392  const scalar searchRadiusSqr,
393  pointIndexHitList& info
394  ) const;
395 
396  //- Return the minimum distance between disconnected edges
397  scalar minDisconnectedDist(const pointIndexHitList& hitList) const;
398 
399 
400  // Access
401 
402  //- Return the index of the start of the convex feature points
403  inline label convexStart() const;
404 
405  //- Return the index of the start of the concave feature points
406  inline label concaveStart() const;
407 
408  //- Return the index of the start of the mixed type feature points
409  inline label mixedStart() const;
410 
411  //- Return the index of the start of the non-feature points
412  inline label nonFeatureStart() const;
413 
414  //- Return the index of the start of the external feature edges
415  inline label externalStart() const;
416 
417  //- Return the index of the start of the internal feature edges
418  inline label internalStart() const;
419 
420  //- Return the index of the start of the flat feature edges
421  inline label flatStart() const;
422 
423  //- Return the index of the start of the open feature edges
424  inline label openStart() const;
425 
426  //- Return the index of the start of the multiply-connected feature
427  // edges
428  inline label multipleStart() const;
429 
430  //- Return whether or not the point index is a feature point
431  inline bool featurePoint(label ptI) const;
432 
433  //- Return the normals of the surfaces adjacent to the feature edges
434  // and points
435  inline const vectorField& normals() const;
436 
437  //- Return
438  inline const List<sideVolumeType>& normalVolumeTypes() const;
439 
440  //- Return the edgeDirection vectors
441  inline const vectorField& edgeDirections() const;
442 
443  //-
444  inline const labelListList& normalDirections() const;
445 
446  //- Return the direction of edgeI, pointing away from ptI
447  inline vector edgeDirection(label edgeI, label ptI) const;
448 
449  //- Return the indices of the normals that are adjacent to the
450  // feature edges
451  inline const labelListList& edgeNormals() const;
452 
453  //- Return the normal vectors for a given set of normal indices
454  inline vectorField edgeNormals(const labelList& edgeNormIs) const;
455 
456  //- Return the normal vectors for a given edge
457  inline vectorField edgeNormals(label edgeI) const;
458 
459  //- Return the indices of the normals that are adjacent to the
460  // feature points
461  inline const labelListList& featurePointNormals() const;
462 
463  //- Return the normal vectors for a given feature point
464  inline vectorField featurePointNormals(label ptI) const;
465 
466  //- Return the edge labels for a given feature point. Edges are
467  // ordered by the faces that they share. The edge labels
468  // correspond to the entry in edges().
469  inline const labelListList& featurePointEdges() const;
470 
471  //- Return the feature edges which are on the boundary between
472  // regions
473  inline const labelList& regionEdges() const;
474 
475  //- Return the pointStatus of a specified point
476  inline pointStatus getPointStatus(label ptI) const;
477 
478  //- Return the edgeStatus of a specified edge
479  inline edgeStatus getEdgeStatus(label edgeI) const;
480 
481  //- Return the baffle faces of a specified edge
482  inline PackedList<2> edgeBaffles(label edgeI) const;
483 
484  //- Demand driven construction of octree for feature points
486 
487  //- Demand driven construction of octree for boundary edges
488  const indexedOctree<treeDataEdge>& edgeTree() const;
489 
490  //- Demand driven construction of octree for boundary edges by type
492  edgeTreesByType() const;
493 
494 
495  // Edit
496 
497  //- Transfer the contents of the argument and annul the argument
498  void transfer(extendedEdgeMesh&);
499 
500  //- Clear all storage
501  virtual void clear();
502 
503  //- Add extendedEdgeMesh. No filtering of duplicates.
504  void add(const extendedEdgeMesh&);
505 
506  //- Flip normals. All concave become convex, all internal external
507  // etc.
508  void flipNormals();
509 
510 
511  // Read
512 
513  //- Read from file. Chooses reader based on explicit extension
514  bool read(const fileName&, const word& ext);
515 
516  //- Read from file. Chooses reader based on detected extension
517  virtual bool read(const fileName&);
518 
519 
520  // Write
521 
522  //- Write all components of the extendedEdgeMesh as obj files
523  void writeObj
524  (
525  const fileName& prefix,
526  const bool verbose = true
527  ) const;
528 
529  //- Dump some information
530  virtual void writeStats(Ostream& os) const;
531 
532  friend Istream& operator>>(Istream& is, sideVolumeType& vt);
533  friend Ostream& operator<<(Ostream& os, const sideVolumeType& vt);
534 
535 
536  //- Classify the type of feature edge. Requires face centre 0 to face
537  // centre 1 vector to distinguish internal from external
538  static edgeStatus classifyEdge
539  (
540  const List<vector>& norms,
541  const labelList& edNorms,
542  const vector& fC0tofC1
543  );
544 
545 
546  // IOstream Operators
547 
548  friend Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
550 };
551 
552 
555 
556 
557 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
558 
559 } // End namespace Foam
560 
561 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
562 
563 #include "extendedEdgeMeshI.H"
564 
565 #ifdef NoRepository
566  #include "extendedEdgeMeshTemplates.C"
567 #endif
568 
569 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
570 
571 #endif
572 
573 // ************************************************************************* //
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.
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:79
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.
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.
void nearestFeatureEdgeByType(const point &sample, const scalarField &searchDistSqr, pointIndexHitList &info) const
Find the nearest point on each type of feature edge.
labelListList normalDirections_
Starting directions for the edges.
scalarField samples(nIntervals, 0)
A list of faces which address into the list of points.
void allNearestFeatureEdges(const point &sample, const scalar searchRadiusSqr, pointIndexHitList &info) const
Find all the feature edges within searchDistSqr of sample.
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.
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:70
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.
void writeObj(const fileName &prefix, const bool verbose=true) const
Write all components of the extendedEdgeMesh as obj files.
static label nPointTypes
Number of possible point types (i.e. number of slices)
const indexedOctree< treeDataPoint > & pointTree() const
Demand driven construction of octree for feature points.
static wordHashSet writeTypes()
scalar minDisconnectedDist(const pointIndexHitList &hitList) const
Return the minimum distance between disconnected edges.
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.
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.
void allNearestFeaturePoints(const point &sample, scalar searchRadiusSqr, pointIndexHitList &info) const
Find all the feature points within searchDistSqr of sample.
Namespace for OpenFOAM.
label concaveStart() const
Return the index of the start of the concave feature points.
pointStatus classifyFeaturePoint(label ptI) const
Classify the type of feature point. Requires valid stored member.