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 \*---------------------------------------------------------------------------*/
28 #include "meshSubset.H"
29 #include "labelList.H"
30 #include "IOstreams.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 inline meshSubset::meshSubset()
46 inline meshSubset::meshSubset
49 const meshSubset::subsetType_& t
57 template<class ListType>
58 inline meshSubset::meshSubset
61 const meshSubset::subsetType_& type,
62 const ListType& elements
70 data_.insert(elements[i]);
73 inline meshSubset::meshSubset(const meshSubset& ms)
82 inline meshSubset::meshSubset(Istream& is)
91 inline meshSubset::~meshSubset()
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 inline const word& meshSubset::name() const
101 inline label meshSubset::type() const
106 template<class ListType>
107 inline void meshSubset::containedElements(ListType& l) const
109 l.setSize(data_.size());
112 forAllConstIter(std::set<label>, data_, it)
116 inline void meshSubset::addElement(const label elmt)
121 inline void meshSubset::removeElement(const label elmt)
126 template<class ListType>
127 inline void meshSubset::updateSubset(const ListType& newLabels)
129 std::set<label> newData;
131 forAllConstIter(std::set<label>, data_, it)
133 if( newLabels[*it] < 0 )
136 newData.insert(newLabels[*it]);
142 inline void meshSubset::updateSubset(const VRWGraph& newLabels)
144 std::set<label> newData;
146 forAllConstIter(std::set<label>, data_, it)
148 forAllRow(newLabels, *it, i)
149 newData.insert(newLabels(*it, i));
155 inline bool meshSubset::contains(const label elmt) const
157 return (data_.find(elmt) != data_.end());
160 inline void meshSubset::operator=(const meshSubset& ms)
169 inline bool meshSubset::operator==(const meshSubset& ms) const
171 if( ms.name_ != name_ )
173 if( ms.type_ != ms.type_ )
176 forAllConstIter(std::set<label>, data_, it)
177 if( ms.data_.find(*it) == ms.data_.end() )
183 inline bool meshSubset::operator!=(const meshSubset& ms) const
185 return !operator==(ms);
188 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
190 inline Ostream& operator<<(Ostream& os, const meshSubset& sel)
192 os.check("inline Ostream& operator<<(Ostream&, const meshSubset&)");
194 os << sel.name_ << nl << sel.type_;
196 labelList data(sel.data_.size());
198 forAllConstIter(std::set<label>, sel.data_, it)
199 data[counter++] = *it;
206 inline Istream& operator>>(Istream& is, meshSubset& sel)
208 is.check("friend Istream& operator>>(Istream&, meshSubset&)");
211 is >> sel.name_ >> sel.type_ >> data;
215 sel.data_.insert(data[i]);
217 is.check("friend Istream& operator>>(Istream&, meshSubset&)");
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 } // End namespace Foam
227 // ************************************************************************* //