1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Foam::UnsortedMeshedSurface
28 A surface geometry mesh, in which the surface zone information is
29 conveyed by the 'zoneId' associated with each face.
31 This form of surface description is particularly useful for reading in
32 surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
33 can also be particularly useful for situations in which the surface
34 many be adjusted in an arbitrary manner without worrying about needed
35 to adjust the zone information (eg, surface refinement).
38 The Foam::MeshedSurface - which is organized as a surface mesh, but
39 with independent zone information.
42 UnsortedMeshedSurface.C
44 \*---------------------------------------------------------------------------*/
46 #ifndef UnsortedMeshedSurface_H
47 #define UnsortedMeshedSurface_H
49 #include "MeshedSurface.H"
50 #include "surfZoneIdentifierList.H"
51 #include "surfZoneList.H"
52 #include "surfaceFormatsCore.H"
53 #include "runTimeSelectionTables.H"
54 #include "memberFunctionSelectionTables.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 // Forward declaration of friend functions and operators
67 template<class Face> class MeshedSurface;
68 template<class Face> class MeshedSurfaceProxy;
69 template<class Face> class UnsortedMeshedSurface;
71 /*---------------------------------------------------------------------------*\
72 Class UnsortedMeshedSurface Declaration
73 \*---------------------------------------------------------------------------*/
76 class UnsortedMeshedSurface
78 public MeshedSurface<Face>
80 // friends - despite different face representationsx
81 template<class Face2> friend class MeshedSurface;
82 template<class Face2> friend class UnsortedMeshedSurface;
83 friend class surfMesh;
87 //- Private typedefs for convenience
89 typedef MeshedSurface<Face> ParentType;
90 typedef MeshedSurface<Face> FriendType;
91 typedef MeshedSurfaceProxy<Face> ProxyType;
94 // Private Member Data
96 //- The zone Id associated with each face
99 //- Zone information (face ordering nFaces/startFace only used
100 // during reading and writing)
101 List<surfZoneIdentifier> zoneToc_;
104 // Private member functions
106 //- Disable resize with value
107 void resize(const label, const Face&);
109 //- Disable setSize with value
110 void setSize(const label, const Face&);
112 //- Read foam Surface format
118 // Protected Member functions
120 //- Return non-const access to the zone Ids
121 List<label>& storedZoneIds()
126 //- Return non-const access to the zone table-of-contents
127 List<surfZoneIdentifier>& storedZoneToc()
132 //- Set new zones from faceMap
133 virtual void remapFaces(const UList<label>& faceMap);
138 //- Runtime type information
139 TypeName("UnsortedMeshedSurface");
144 //- Can we read this file format?
145 static bool canReadType(const word& ext, const bool verbose=false);
147 //- Can we read this file format?
148 static bool canRead(const fileName&, const bool verbose=false);
150 //- Can we write this file format?
151 static bool canWriteType(const word& ext, const bool verbose=false);
153 static wordHashSet readTypes();
154 static wordHashSet writeTypes();
160 UnsortedMeshedSurface();
162 //- Construct by transferring components
163 // (points, faces, zone ids, zone info).
164 UnsortedMeshedSurface
166 const Xfer< pointField >&,
167 const Xfer< List<Face> >&,
168 const Xfer< List<label> >& zoneIds,
169 const Xfer< surfZoneIdentifierList >&
172 //- Construct by transferring points, faces.
173 // Use zone information, or set single default zone
174 UnsortedMeshedSurface
176 const Xfer<pointField>&,
177 const Xfer<List<Face> >&,
178 const UList<label>& zoneSizes = UList<label>(),
179 const UList<word>& zoneNames = UList<word>()
182 //- Construct as copy
183 UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
185 //- Construct from a meshedSurface
186 UnsortedMeshedSurface(const MeshedSurface<Face>&);
188 //- Construct by transferring the contents from a UnsortedMeshedSurface
189 UnsortedMeshedSurface(const Xfer<UnsortedMeshedSurface<Face> >&);
191 //- Construct by transferring the contents from a meshedSurface
192 UnsortedMeshedSurface(const Xfer<MeshedSurface<Face> >&);
194 //- Construct from file name (uses extension to determine type)
195 UnsortedMeshedSurface(const fileName&);
197 //- Construct from file name (uses extension to determine type)
198 UnsortedMeshedSurface(const fileName&, const word&);
200 //- Construct from Istream
201 UnsortedMeshedSurface(Istream&);
203 //- Construct from objectRegistry and a named surface
204 UnsortedMeshedSurface(const Time&, const word& surfName="");
207 // Declare run-time constructor selection table
209 declareRunTimeSelectionTable
212 UnsortedMeshedSurface,
223 //- Select constructed from filename (explicit extension)
224 static autoPtr<UnsortedMeshedSurface> New
230 //- Select constructed from filename (implicit extension)
231 static autoPtr<UnsortedMeshedSurface> New(const fileName&);
236 virtual ~UnsortedMeshedSurface();
239 // Member Function Selectors
241 declareMemberFunctionSelectionTable
244 UnsortedMeshedSurface,
248 const fileName& name,
249 const UnsortedMeshedSurface<Face>& surf
255 static void write(const fileName&, const UnsortedMeshedSurface<Face>&);
262 //- The surface size is the number of faces
265 return ParentType::size();
268 //- Reset size of face and zone list
269 void setSize(const label);
271 //- Return const access to the zone ids
272 const List<label>& zoneIds() const
277 //- Return const access to the zone table-of-contents
278 const List<surfZoneIdentifier>& zoneToc() const
283 //- Sort faces according to zoneIds
284 // Returns a surfZoneList and sets faceMap to index within faces()
285 surfZoneList sortedZones(labelList& faceMap) const;
287 //- Set zones to 0 and set a single zone
290 //- Set zone ids and zones
291 void setZones(const surfZoneList&);
293 //- Set zone ids and zones
294 void setZones(const UList<label>& sizes, const UList<word>& names);
296 //- Set zone ids and zones with default names
297 void setZones(const UList<label>& sizes);
302 //- Clear all storage
303 virtual void clear();
305 //- Return new surface.
306 // Returns return pointMap, faceMap from subsetMeshMap
307 UnsortedMeshedSurface subsetMesh
309 const labelHashSet& include,
314 //- Return new surface.
315 UnsortedMeshedSurface subsetMesh
317 const labelHashSet& include
320 //- Transfer components (points, faces, zone ids).
323 const Xfer< pointField >&,
324 const Xfer< List<Face> >&,
325 const Xfer< List<label> >& zoneIds
328 //- Transfer components (points, faces, zone ids).
331 const Xfer< List<point> >&,
332 const Xfer< List<Face> >&,
333 const Xfer< List<label> >& zoneIds
336 //- Transfer the contents of the argument and annull the argument
337 void transfer(UnsortedMeshedSurface<Face>&);
339 //- Transfer the contents of the argument and annull the argument
340 void transfer(MeshedSurface<Face>&);
342 //- Transfer contents to the Xfer container
343 Xfer< UnsortedMeshedSurface<Face> > xfer();
348 //- Read from file. Chooses reader based on explicit extension
349 bool read(const fileName&, const word& ext);
351 //- Read from file. Chooses reader based on detected extension
352 virtual bool read(const fileName&);
357 //- Generic write routine. Chooses writer based on extension.
358 virtual void write(const fileName& name) const
363 //- Write to database
364 void write(const Time&, const word& surfName="") const;
369 void operator=(const UnsortedMeshedSurface<Face>&);
371 //- Conversion operator to MeshedSurfaceProxy
372 operator MeshedSurfaceProxy<Face>() const;
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378 } // End namespace Foam
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 # include "UnsortedMeshedSurface.C"
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390 // ************************************************************************* //