1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh 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 cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
29 #include "demandDrivenData.H"
36 #include "triSurface.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 void triSurf::readFromFTR(const fileName& fName)
47 IFstream fStream(fName);
49 fStream >> triSurfFacets::patches_;
51 fStream >> triSurfPoints::points_;
53 fStream >> triSurfFacets::triangles_;
56 void triSurf::writeToFTR(const fileName& fName) const
58 OFstream fStream(fName);
60 fStream << triSurfFacets::patches_;
64 fStream << triSurfPoints::points_;
68 fStream << triSurfFacets::triangles_;
71 void triSurf::readFromFMS(const fileName& fName)
73 IFstream fStream(fName);
75 //- read the list of patches defined on the surface mesh
76 fStream >> triSurfFacets::patches_;
79 fStream >> triSurfPoints::points_;
81 //- read surface triangles
82 fStream >> triSurfFacets::triangles_;
84 //- read feature edges
85 fStream >> triSurfFeatureEdges::featureEdges_;
87 List<meshSubset> subsets;
89 //- read point subsets
91 forAll(subsets, subsetI)
92 triSurfPoints::pointSubsets_.insert(subsetI, subsets[subsetI]);
96 //- read facet subsets
98 forAll(subsets, subsetI)
99 triSurfFacets::facetSubsets_.insert(subsetI, subsets[subsetI]);
103 //- read subsets on feature edges
105 forAll(subsets, subsetI)
106 triSurfFeatureEdges::featureEdgeSubsets_.insert
113 void triSurf::writeToFMS(const fileName& fName) const
115 OFstream fStream(fName);
118 fStream << triSurfFacets::patches_;
123 fStream << triSurfPoints::points_;
128 fStream << triSurfFacets::triangles_;
132 //- write feature edges
133 fStream << triSurfFeatureEdges::featureEdges_;
137 //- write point subsets
138 List<meshSubset> subsets;
140 subsets.setSize(pointSubsets_.size());
141 forAllConstIter(Map<meshSubset>, pointSubsets_, it)
147 //- write subsets of facets
148 subsets.setSize(triSurfFacets::facetSubsets_.size());
150 forAllConstIter(Map<meshSubset>, triSurfFacets::facetSubsets_, it)
156 //- write subets of feature edges
157 subsets.setSize(triSurfFeatureEdges::featureEdgeSubsets_.size());
162 triSurfFeatureEdges::featureEdgeSubsets_,
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 triSurfFeatureEdges(),
176 triSurfAddressing(triSurfPoints::points_, triSurfFacets::triangles_)
179 //- Construct from parts
182 const LongList<labelledTri>& triangles,
183 const geometricSurfacePatchList& patches,
184 const edgeLongList& featureEdges,
185 const pointField& points
188 triSurfPoints(points),
189 triSurfFacets(triangles, patches),
190 triSurfFeatureEdges(featureEdges),
191 triSurfAddressing(triSurfPoints::points_, triSurfFacets::triangles_)
195 triSurf::triSurf(const fileName& fName)
199 triSurfFeatureEdges(),
200 triSurfAddressing(triSurfPoints::points_, triSurfFacets::triangles_)
205 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 void triSurf::readSurface(const fileName& fName)
214 if( fName.ext() == "fms" || fName.ext() == "FMS" )
218 else if( fName.ext() == "ftr" || fName.ext() == "FTR" )
224 triSurface copySurface(fName);
227 triSurfPoints::points_.setSize(copySurface.points().size());
228 forAll(copySurface.points(), pI)
229 triSurfPoints::points_[pI] = copySurface.points()[pI];
231 //- copy the triangles
232 triSurfFacets::triangles_.setSize(copySurface.size());
233 forAll(copySurface, tI)
234 triSurfFacets::triangles_[tI] = copySurface[tI];
237 triSurfFacets::patches_ = copySurface.patches();
241 void triSurf::writeSurface(const fileName& fName) const
243 if( fName.ext() == "fms" || fName.ext() == "FMS" )
247 else if( fName.ext() == "ftr" || fName.ext() == "FTR" )
253 const pointField& pts = this->points();
254 const LongList<labelledTri>& facets = this->facets();
255 const geometricSurfacePatchList& patches = this->patches();
257 List<labelledTri> newTrias(facets.size());
259 newTrias[tI] = facets[tI];
261 triSurface newSurf(newTrias, patches, pts);
262 newSurf.write(fName);
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 } // End namespace Foam
270 // ************************************************************************* //