1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Points connected by edges.
35 \*---------------------------------------------------------------------------*/
40 #include "pointField.H"
42 #include "edgeFormatsCore.H"
43 #include "runTimeSelectionTables.H"
44 #include "memberFunctionSelectionTables.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of classes
56 // Forward declaration of friend functions and operators
58 Istream& operator>>(Istream&, edgeMesh&);
59 Ostream& operator<<(Ostream&, const edgeMesh&);
62 /*---------------------------------------------------------------------------*\
63 Class edgeMesh Declaration
64 \*---------------------------------------------------------------------------*/
68 public fileFormats::edgeFormatsCore
72 //- Vertices of the edges
75 //- The edges defining the boundary
78 //- From point to edges
79 mutable autoPtr<labelListList> pointEdgesPtr_;
81 // Private Member Functions
83 //- Calculate point-edge addressing (inverse of edges)
84 void calcPointEdges() const;
89 // Protected Member Functions
91 //- Non-const access to global points
92 inline pointField& storedPoints();
94 //- Non-const access to the edges
95 inline edgeList& storedEdges();
100 //- Runtime type information
101 TypeName("edgeMesh");
106 //- Can we read this file format?
107 static bool canRead(const fileName&, const bool verbose=false);
109 //- Can we read this file format?
110 static bool canReadType(const word& ext, const bool verbose=false);
112 //- Can we write this file format type?
113 static bool canWriteType(const word& ext, const bool verbose=false);
115 static wordHashSet readTypes();
116 static wordHashSet writeTypes();
124 //- Construct from components
125 edgeMesh(const pointField&, const edgeList&);
127 //- Construct by transferring components (points, edges).
130 const Xfer<pointField>&,
131 const Xfer<edgeList>&
134 //- Construct as copy
135 edgeMesh(const edgeMesh&);
137 //- Construct from file name (uses extension to determine type)
138 edgeMesh(const fileName&);
140 //- Construct from file name (uses extension to determine type)
141 edgeMesh(const fileName&, const word& ext);
143 //- Construct from Istream
147 // Declare run-time constructor selection table
149 declareRunTimeSelectionTable
163 //- Select constructed from filename (explicit extension)
164 static autoPtr<edgeMesh> New
170 //- Select constructed from filename (implicit extension)
171 static autoPtr<edgeMesh> New(const fileName&);
178 // Member Function Selectors
180 declareMemberFunctionSelectionTable
187 const fileName& name,
194 static void write(const fileName&, const edgeMesh&);
199 //- Transfer the contents of the argument and annul the argument
200 void transfer(edgeMesh&);
202 //- Transfer contents to the Xfer container
203 Xfer<edgeMesh > xfer();
207 //- Read from file. Chooses reader based on explicit extension
208 bool read(const fileName&, const word& ext);
210 //- Read from file. Chooses reader based on detected extension
211 virtual bool read(const fileName&);
217 inline const pointField& points() const;
220 inline const edgeList& edges() const;
223 inline const labelListList& pointEdges() const;
225 //- Find connected regions. Set region number per edge.
226 // Returns number of regions.
227 label regions(labelList& edgeRegion) const;
232 //- Clear all storage
233 virtual void clear();
235 //- Reset primitive data (points, edges)
236 // Note, optimized to avoid overwriting data (with Xfer::null)
239 const Xfer<pointField>& points,
240 const Xfer<edgeList>& edges
243 //- Scale points. A non-positive factor is ignored
244 virtual void scalePoints(const scalar);
246 //- Merge common points (points within mergeDist)
247 void mergePoints(const scalar mergeDist);
252 void writeStats(Ostream&) const;
254 //- Generic write routine. Chooses writer based on extension.
255 virtual void write(const fileName& name) const
263 inline void operator=(const edgeMesh&);
267 friend Ostream& operator<<(Ostream&, const edgeMesh&);
268 friend Istream& operator>>(Istream&, edgeMesh&);
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 } // End namespace Foam
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 #include "edgeMeshI.H"
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 // ************************************************************************* //