1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_Profil.cxx
7 * \brief see MULTIPR_Profil.hxx
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
14 //*****************************************************************************
16 //*****************************************************************************
18 #include "MULTIPR_Profil.hxx"
19 #include "MULTIPR_Exceptions.hxx"
30 //*****************************************************************************
31 // Class Profil implementation
32 //*****************************************************************************
53 void Profil::create(const char* pName)
55 if (pName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
63 const char* Profil::getName() const
69 med_int Profil::get(med_int pIndex) const
71 if ((pIndex < 0) || (pIndex >= med_int(mTable.size()))) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
73 return mTable[pIndex];
77 void Profil::add(med_int pElt)
79 mTable.push_back(pElt);
83 void Profil::readMED(med_idt pMEDfile, med_int pIndexProfil)
85 if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
86 if (pIndexProfil < 1) throw IllegalArgumentException("", __FILE__, __LINE__);
91 med_err ret = MEDprofilInfo(
97 if (ret != 0) throw IOException("", __FILE__, __LINE__);
99 med_int* dataTmp = new med_int[numData];
106 if (ret != 0) throw IOException("", __FILE__, __LINE__);
108 for (int itData = 0 ; itData < numData ; itData++)
110 mTable.push_back(dataTmp[itData]);
117 void Profil::writeMED(med_idt pMEDfile)
119 if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
120 if (strlen(mName) > MED_TAILLE_NOM) throw IllegalStateException("", __FILE__, __LINE__);
121 if (mTable.size() == 0) throw IllegalStateException("", __FILE__, __LINE__);
123 med_int* dataTmp = new med_int[mTable.size()];
124 for (unsigned itData = 0 ; itData < mTable.size() ; itData++)
126 dataTmp[itData] = mTable[itData];
129 med_err ret = MEDprofilEcr(
135 if (ret != 0) throw IOException("", __FILE__, __LINE__);
141 ostream& operator<<(ostream& pOs, Profil& pP)
143 pOs << "Profil:" << endl;
144 pOs << " Name=|" << pP.mName << "|" << endl;
145 pOs << " Size=" << pP.mTable.size() << endl;
147 pOs << " Entities=[";
148 for (unsigned itElt = 0; itElt < pP.mTable.size() ; itElt++)
150 pOs << pP.mTable[itElt] << " ";
158 } // namespace multipr