FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/edgeList.H>
57 #include <OpenFOAM/labelList.H>
58 #include <OpenFOAM/pointField.H>
59 #include <OpenFOAM/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 
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 
120 public:
121 
122  ClassName("edgeSurface");
123 
124  // Constructors
125 
126  //- Construct from surface and intersection description
128  (
129  const triSurface& surf,
130  const bool isFirstSurface,
131  const surfaceIntersection& inter
132  );
133 
134 
135  // Member Functions
136 
137  // Access
138 
139  const pointField& points() const
140  {
141  return points_;
142  }
143 
144  label nSurfacePoints() const
145  {
146  return nSurfacePoints_;
147  }
148 
149  const edgeList& edges() const
150  {
151  return edges_;
152  }
153 
154  label nSurfaceEdges() const
155  {
156  return nSurfaceEdges_;
157  }
158 
159  bool isSurfaceEdge(const label edgeI) const
160  {
161  return edgeI < nSurfaceEdges_;
162  }
163 
164  //- Parent edge (original surface edge this edge came from).
165  // Valid only for edgeI < nSurfaceEdges_.
166  label parentEdge(const label edgeI) const
167  {
168  if (edgeI < nSurfaceEdges_)
169  {
170  return parentEdges_[edgeI];
171  }
172  else
173  {
175  (
176  "edgeSurface::parentEdge(const label edgeI) const"
177  ) << "Trying to get parent (i.e. surface) edge for"
178  << " intersection edge " << edgeI
179  << abort(FatalError);
180  return -1;
181  }
182  }
183 
184  //- From face to our edges_
185  const labelListList& faceEdges() const
186  {
187  return faceEdges_;
188  }
189 
190  //- point to edge addressing
191  const labelListList& pointEdges() const
192  {
193  return pointEdges_;
194  }
195 
196 
197  // Edit
198 
199  //- Add intersection edges to a face. Used for connecting
200  // floating intersection on face to rest of face.
201  void addIntersectionEdges(const label faceI, const edgeList&);
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #endif
212 
213 // ************************ vim: set sw=4 sts=4 et: ************************ //