All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edgeSurface.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::edgeSurface
26 
27 Description
28  Description of surface in form of 'cloud of edges'.
29 
30  The 'cloud of edges':
31  - points
32  - edges
33  - faceEdges
34  - parentEdge (edge on surface this edge originates from)
35  and nothing more.
36 
37  (pointEdges constructed from above data)
38 
39  Constructed from triSurface and surfaceIntersection. (uses localPoints
40  of surface of course)
41 
42  Used to easily insert cuts and split faces.
43 
44 Note
45  - points with surface (local)points first, intersection points last
46  - edges with (split) surface edges first, intersection edges last.
47 
48 SourceFiles
49  edgeSurface.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef edgeSurface_H
54 #define edgeSurface_H
55 
56 #include "edgeList.H"
57 #include "labelList.H"
58 #include "pointField.H"
59 #include "typeInfo.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 // Forward declaration of classes
67 class triSurface;
68 class surfaceIntersection;
69 
70 /*---------------------------------------------------------------------------*\
71  Class edgeSurface Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class edgeSurface
75 {
76  // Private Data
77 
78  //- All points (0 .. nSurfacePoints_-1 are points from surface)
79  pointField points_;
80 
81  label nSurfacePoints_;
82 
83  //- All edges (0 .. nSurfaceEdges_-1 are (possibly split) surface edges)
84  edgeList edges_;
85 
86  label nSurfaceEdges_;
87 
88  //- Original surface edge. Valid only surfaceEdges.
89  labelList parentEdges_;
90 
91  //- From face to our edges_
92  labelListList faceEdges_;
93 
94 
95  //- Constructed from above: pointEdges
96  labelListList pointEdges_;
97 
98 
99  // Private Member Functions
100 
101  //- Dump edges in obj format
102  static void writeOBJ(const pointField&, const edgeList&, Ostream&);
103 
104  //- Dump selected edges in obj format
105  static void writeOBJ
106  (
107  const pointField&,
108  const edgeList&,
109  const labelList&,
110  Ostream&
111  );
112 
113  //- Calculate pointEdges
114  void calcPointEdges();
115 
116 
117 public:
118 
119  ClassName("edgeSurface");
120 
121  // Constructors
122 
123  //- Construct from surface and intersection description
125  (
126  const triSurface& surf,
127  const bool isFirstSurface,
128  const surfaceIntersection& inter
129  );
130 
131 
132  // Member Functions
133 
134  // Access
136  const pointField& points() const
137  {
138  return points_;
139  }
141  label nSurfacePoints() const
142  {
143  return nSurfacePoints_;
144  }
146  const edgeList& edges() const
147  {
148  return edges_;
149  }
151  label nSurfaceEdges() const
152  {
153  return nSurfaceEdges_;
154  }
156  bool isSurfaceEdge(const label edgeI) const
157  {
158  return edgeI < nSurfaceEdges_;
159  }
160 
161  //- Parent edge (original surface edge this edge came from).
162  // Valid only for edgeI < nSurfaceEdges_.
163  label parentEdge(const label edgeI) const
164  {
165  if (edgeI < nSurfaceEdges_)
166  {
167  return parentEdges_[edgeI];
168  }
169  else
170  {
172  << "Trying to get parent (i.e. surface) edge for"
173  << " intersection edge " << edgeI
174  << abort(FatalError);
175  return -1;
176  }
177  }
178 
179  //- From face to our edges_
180  const labelListList& faceEdges() const
181  {
182  return faceEdges_;
183  }
184 
185  //- Point to edge addressing
186  const labelListList& pointEdges() const
187  {
188  return pointEdges_;
189  }
190 
191 
192  // Edit
193 
194  //- Add intersection edges to a face. Used for connecting
195  // floating intersection on face to rest of face.
196  void addIntersectionEdges(const label facei, const edgeList&);
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 #endif
207 
208 // ************************************************************************* //
label nSurfacePoints() const
Definition: edgeSurface.H:140
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
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
label nSurfaceEdges() const
Definition: edgeSurface.H:150
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
const pointField & points() const
Definition: edgeSurface.H:135
Description of surface in form of &#39;cloud of edges&#39;.
Definition: edgeSurface.H:73
bool isSurfaceEdge(const label edgeI) const
Definition: edgeSurface.H:155
edgeSurface(const triSurface &surf, const bool isFirstSurface, const surfaceIntersection &inter)
Construct from surface and intersection description.
Definition: edgeSurface.C:128
const edgeList & edges() const
Definition: edgeSurface.H:145
errorManip< error > abort(error &err)
Definition: errorManip.H:131
ClassName("edgeSurface")
void addIntersectionEdges(const label facei, const edgeList &)
Add intersection edges to a face. Used for connecting.
Definition: edgeSurface.C:343
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const labelListList & faceEdges() const
From face to our edges_.
Definition: edgeSurface.H:179
const labelListList & pointEdges() const
Point to edge addressing.
Definition: edgeSurface.H:185
Triangulated surface description with patch information.
Definition: triSurface.H:66
label parentEdge(const label edgeI) const
Parent edge (original surface edge this edge came from).
Definition: edgeSurface.H:162
Namespace for OpenFOAM.