1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Partitioning/decimation module for the SALOME v3.2 platform
22 * \file MULTIPR_Profil.hxx
24 * \brief Class Profil used to managed MED profil.
25 * Profil is just a list of indices related to elements (NODES, CELLS).
26 * !!! currently not used !!!
28 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
33 #ifndef MULTIPR_PROFIL_HXX
34 #define MULTIPR_PROFIL_HXX
36 //*****************************************************************************
38 //*****************************************************************************
59 //*****************************************************************************
61 //*****************************************************************************
68 * Builds an empty profil (default constructor).
74 * \param pProfil The profil to copy.
76 Profil(const Profil& pProfil);
79 * Destructor. Removes everything.
84 * Resets this object in its state by default (empty). Cleans memory.
89 * Creates a profil from its name (reset before).
90 * \param pName name of the profil to be created.
91 * \throw NullArgumentException if pName is NULL.
93 void create(const char* pName);
95 //---------------------------------------------------------------------
96 // Basic accessors/mutators
97 //---------------------------------------------------------------------
100 * Returns the name of this profil.
101 * \return the name of this profil.
103 const char* getName() const;
106 * Get the complete set of elements of this profile.
107 * \return The set of elements.
109 std::set< med_int>& getSet() { return mTable; }
112 * Adds a new element to this profil.
113 * \param pElt element to be added; must be >= 1.
115 void add(med_int pElt);
118 * Find the given element in the profile.
119 * \param pElt The index of the element.
120 * \return true if the element was found.
122 bool find(med_int pElt);
125 * Assign a set of element to this profile.
126 * \param pElt The set of element to assign.
128 void set(std::set< med_int>& pElt) { this->mTable = pElt; }
131 * Select the elements of pIn contained in this profile. The two parameters pIn
132 * and pOut MUST be different.
133 * \param pIn Set of elements to filter.
134 * \param pOut The result.
135 * \throw IllegalStateException if pIn and pOut are not different.
137 void filterSetOfElement(std::set<med_int>& pIn, std::set<med_int>& pOut);
140 * Extract a profil. The two parameters pIn
141 * and pOut MUST be different.
142 * \param pIn Set of elements to extract.
143 * \param pOut The result.
144 * \throw IllegalStateException if pIn and pOut are not different.
146 void extractSetOfElement(const std::set<med_int>& pIn, std::set<med_int>& pOut);
149 * Returns the association of the profile.
150 * \return OnNodes or OnElements or Undef.
152 eProfilBinding getBinding() { return mBinding; }
155 * Return the index of the geometry (if any) associated with this profile.
156 * If this profile is on nodes it will return 0. Since the geometry index starts at
157 * 0 use getBinding to know if its on elements.
158 * \return the index of the geometry.
160 unsigned getGeomIdx() { return mGeomIdx; }
162 //---------------------------------------------------------------------
164 //---------------------------------------------------------------------
167 * Reads a Profil from a MED file.
168 * \param pMEDfile any valid MED file opened for reading.
169 * \param pIndexProfil index of the profil to be read; must be >= 1.
170 * \throw IOException if any i/o error occurs.
172 void readMED(med_idt pMEDfile, med_int pIndexProfil);
175 * Try to find in the MED file if this profile is associated to the nodes
176 * or the elements. If the profile is associated with elements it will get the
177 * index of the geometry.
178 * \param pMEDfile any valid MED file opened for reading.
179 * \param pMeshName The name of the mesh.
180 * \throw IllegalStateException if the profile is empty.
182 void readProfilBinding(med_idt pMEDfile, char* pMeshName);
185 * Writes this profil to a MED file.
186 * \param pMEDfile any valid MED file opened for writing.
187 * \throw IOException if any i/o error occurs.
189 void writeMED(med_idt pMEDfile);
192 * Dumps any Profil to the given output stream.
193 * \param pOs any output stream.
194 * \param pP any Profil.
195 * \return the output stream pOs.
197 friend std::ostream& operator<<(std::ostream& pOs, Profil& pP);
201 char mName[MED_TAILLE_NOM + 1]; /**< Name of the profil. */
202 std::set<med_int> mTable; /**< Table of elements. */
203 eProfilBinding mBinding; /**< Profil of nodes or elements. */
204 unsigned mGeomIdx; /**< If this profile is on elements, the index of the geometry. */
209 Profil& operator=(const Profil&);
211 // do not allow operator ==
212 bool operator==(const Profil&);
217 } // namespace MULTIPR
220 #endif // MULTIPR_PROFIL_HXX