edgeSurface.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-2016 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:
77 
78  // Private data
79 
80  //- All points (0 .. nSurfacePoints_-1 are points from surface)
81  pointField points_;
82 
83  label nSurfacePoints_;
84 
85  //- All edges (0 .. nSurfaceEdges_-1 are (possibly split) surface edges)
86  edgeList edges_;
87 
88  label nSurfaceEdges_;
89 
90  //- Original surface edge. Valid only surfaceEdges.
91  labelList parentEdges_;
92 
93  //- From face to our edges_
94  labelListList faceEdges_;
95 
96 
97  //- Constructed from above: pointEdges
98  labelListList pointEdges_;
99 
100 
101  // Private Member Functions
102 
103  //- Dump edges in obj format
104  static void writeOBJ(const pointField&, const edgeList&, Ostream&);
105 
106  //- Dump selected edges in obj format
107  static void writeOBJ
108  (
109  const pointField&,
110  const edgeList&,
111  const labelList&,
112  Ostream&
113  );
114 
115  //- Calculate pointEdges
116  void calcPointEdges();
117 
118 
119 public:
120 
121  ClassName("edgeSurface");
122 
123  // Constructors
124 
125  //- Construct from surface and intersection description
127  (
128  const triSurface& surf,
129  const bool isFirstSurface,
130  const surfaceIntersection& inter
131  );
132 
133 
134  // Member Functions
135 
136  // Access
138  const pointField& points() const
139  {
140  return points_;
141  }
143  label nSurfacePoints() const
144  {
145  return nSurfacePoints_;
146  }
148  const edgeList& edges() const
149  {
150  return edges_;
151  }
153  label nSurfaceEdges() const
154  {
155  return nSurfaceEdges_;
156  }
158  bool isSurfaceEdge(const label edgeI) const
159  {
160  return edgeI < nSurfaceEdges_;
161  }
162 
163  //- Parent edge (original surface edge this edge came from).
164  // Valid only for edgeI < nSurfaceEdges_.
165  label parentEdge(const label edgeI) const
166  {
167  if (edgeI < nSurfaceEdges_)
168  {
169  return parentEdges_[edgeI];
170  }
171  else
172  {
174  << "Trying to get parent (i.e. surface) edge for"
175  << " intersection edge " << edgeI
176  << abort(FatalError);
177  return -1;
178  }
179  }
180 
181  //- From face to our edges_
182  const labelListList& faceEdges() const
183  {
184  return faceEdges_;
185  }
186 
187  //- Point to edge addressing
188  const labelListList& pointEdges() const
189  {
190  return pointEdges_;
191  }
192 
193 
194  // Edit
195 
196  //- Add intersection edges to a face. Used for connecting
197  // floating intersection on face to rest of face.
198  void addIntersectionEdges(const label facei, const edgeList&);
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
const labelListList & pointEdges() const
Point to edge addressing.
Definition: edgeSurface.H:187
bool isSurfaceEdge(const label edgeI) const
Definition: edgeSurface.H:157
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
const labelListList & faceEdges() const
From face to our edges_.
Definition: edgeSurface.H:181
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
Description of surface in form of &#39;cloud of edges&#39;.
Definition: edgeSurface.H:73
const pointField & points() const
Definition: edgeSurface.H:137
edgeSurface(const triSurface &surf, const bool isFirstSurface, const surfaceIntersection &inter)
Construct from surface and intersection description.
Definition: edgeSurface.C:128
label nSurfacePoints() const
Definition: edgeSurface.H:142
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:53
label nSurfaceEdges() const
Definition: edgeSurface.H:152
Triangulated surface description with patch information.
Definition: triSurface.H:65
const edgeList & edges() const
Definition: edgeSurface.H:147
label parentEdge(const label edgeI) const
Parent edge (original surface edge this edge came from).
Definition: edgeSurface.H:164
Namespace for OpenFOAM.