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-2018 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  //- Construct as copy
251  explicit extendedEdgeMesh(const extendedEdgeMesh&);
252 
253  //- Construct from file name (uses extension to determine type)
254  extendedEdgeMesh(const fileName&);
255 
256  //- Construct from file name (uses extension to determine type)
257  extendedEdgeMesh(const fileName&, const word& ext);
258 
259  //- Construct from Istream
261 
262  //- Construct by transferring components (points, edges)
264  (
265  const Xfer<pointField>&,
266  const Xfer<edgeList>&
267  );
268 
269  //- Construct given a surface with selected edges,points
270  // (surfaceFeatures)
271  // Extracts, classifies and reorders the data from surfaceFeatures.
273  (
274  const surfaceFeatures& sFeat,
275  const boolList& surfBaffleRegions
276  );
277 
278  //- Construct from PrimitivePatch
280  (
282  const labelList& featureEdges,
283  const labelList& regionFeatureEdges,
284  const labelList& featurePoints
285  );
286 
287  //- Construct from all components
289  (
290  const pointField& pts,
291  const edgeList& eds,
299  const vectorField& normals,
303  const labelListList& edgeNormals,
306  const labelList& regionEdges
307  );
308 
309 
310  // Declare run-time constructor selection table
311 
313  (
314  autoPtr,
316  fileExtension,
317  (
318  const fileName& name
319  ),
320  (name)
321  );
322 
323 
324  // Selectors
325 
326  //- Select constructed from filename (explicit extension)
328  (
329  const fileName&,
330  const word& ext
331  );
332 
333  //- Select constructed from filename (implicit extension)
334  static autoPtr<extendedEdgeMesh> New(const fileName&);
335 
336 
337  //- Destructor
339 
340 
341  // Member Functions
342 
343  // Find
344 
345  //- Find nearest surface edge for the sample point.
347  (
348  const point& sample,
349  scalar searchDistSqr,
350  pointIndexHit& info
351  ) const;
352 
353  //- Find nearest surface edge for the sample point.
354  void nearestFeatureEdge
355  (
356  const point& sample,
357  scalar searchDistSqr,
358  pointIndexHit& info
359  ) const;
360 
361  //- Find nearest surface edge for each sample point.
362  void nearestFeatureEdge
363  (
364  const pointField& samples,
365  const scalarField& searchDistSqr,
366  pointIndexHitList& info
367  ) const;
368 
369  //- Find the nearest point on each type of feature edge
371  (
372  const point& sample,
373  const scalarField& searchDistSqr,
374  pointIndexHitList& info
375  ) const;
376 
377  //- Find all the feature points within searchDistSqr of sample
379  (
380  const point& sample,
381  scalar searchRadiusSqr,
382  pointIndexHitList& info
383  ) const;
384 
385  //- Find all the feature edges within searchDistSqr of sample
387  (
388  const point& sample,
389  const scalar searchRadiusSqr,
390  pointIndexHitList& info
391  ) const;
392 
393  //- Return the minimum distance between disconnected edges
394  scalar minDisconnectedDist(const pointIndexHitList& hitList) const;
395 
396 
397  // Access
398 
399  //- Return the index of the start of the convex feature points
400  inline label convexStart() const;
401 
402  //- Return the index of the start of the concave feature points
403  inline label concaveStart() const;
404 
405  //- Return the index of the start of the mixed type feature points
406  inline label mixedStart() const;
407 
408  //- Return the index of the start of the non-feature points
409  inline label nonFeatureStart() const;
410 
411  //- Return the index of the start of the external feature edges
412  inline label externalStart() const;
413 
414  //- Return the index of the start of the internal feature edges
415  inline label internalStart() const;
416 
417  //- Return the index of the start of the flat feature edges
418  inline label flatStart() const;
419 
420  //- Return the index of the start of the open feature edges
421  inline label openStart() const;
422 
423  //- Return the index of the start of the multiply-connected feature
424  // edges
425  inline label multipleStart() const;
426 
427  //- Return whether or not the point index is a feature point
428  inline bool featurePoint(label ptI) const;
429 
430  //- Return the normals of the surfaces adjacent to the feature edges
431  // and points
432  inline const vectorField& normals() const;
433 
434  //- Return
435  inline const List<sideVolumeType>& normalVolumeTypes() const;
436 
437  //- Return the edgeDirection vectors
438  inline const vectorField& edgeDirections() const;
439 
440  //-
441  inline const labelListList& normalDirections() const;
442 
443  //- Return the direction of edgeI, pointing away from ptI
444  inline vector edgeDirection(label edgeI, label ptI) const;
445 
446  //- Return the indices of the normals that are adjacent to the
447  // feature edges
448  inline const labelListList& edgeNormals() const;
449 
450  //- Return the normal vectors for a given set of normal indices
451  inline vectorField edgeNormals(const labelList& edgeNormIs) const;
452 
453  //- Return the normal vectors for a given edge
454  inline vectorField edgeNormals(label edgeI) const;
455 
456  //- Return the indices of the normals that are adjacent to the
457  // feature points
458  inline const labelListList& featurePointNormals() const;
459 
460  //- Return the normal vectors for a given feature point
461  inline vectorField featurePointNormals(label ptI) const;
462 
463  //- Return the edge labels for a given feature point. Edges are
464  // ordered by the faces that they share. The edge labels
465  // correspond to the entry in edges().
466  inline const labelListList& featurePointEdges() const;
467 
468  //- Return the feature edges which are on the boundary between
469  // regions
470  inline const labelList& regionEdges() const;
471 
472  //- Return the pointStatus of a specified point
473  inline pointStatus getPointStatus(label ptI) const;
474 
475  //- Return the edgeStatus of a specified edge
476  inline edgeStatus getEdgeStatus(label edgeI) const;
477 
478  //- Return the baffle faces of a specified edge
479  inline PackedList<2> edgeBaffles(label edgeI) const;
480 
481  //- Demand driven construction of octree for feature points
483 
484  //- Demand driven construction of octree for boundary edges
485  const indexedOctree<treeDataEdge>& edgeTree() const;
486 
487  //- Demand driven construction of octree for boundary edges by type
489  edgeTreesByType() const;
490 
491 
492  // Edit
493 
494  //- Transfer the contents of the argument and annul the argument
495  void transfer(extendedEdgeMesh&);
496 
497  //- Transfer contents to the Xfer container
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  // Ostream Operator
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.
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.
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.
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.
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.