-#==============================================================================
-# File : MED_test1.py
-# Created :
-# Author :
-# Project : SALOME
-# Copyright : EDF 2002
+# MED MED : implemetation of MED idl descriptions
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : MED_test1.py
+# Author :
+# Module : MED
# $Header$
-#==============================================================================
import salome
-#==============================================================================
-# File : MED_test2.py
-# Created :
-# Author :
-# Project : SALOME
-# Copyright : EDF 2002
+# MED MED : implemetation of MED idl descriptions
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : MED_test2.py
+# Author :
+# Module : MED
# $Header$
-#==============================================================================
import salome
import SALOME
-#==============================================================================
-# File : Makefile.in
-# Created : ven déc 7 13:33:08 CET 2001
-# Author : Paul RASCLE, EDF
-# Project : SALOME
-# Copyright : EDF 2001
+# MED MED : implemetation of MED idl descriptions
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Paul RASCLE, EDF
+# Module : MED
# $Header$
-#==============================================================================
-# source path
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
CPPFLAGS += $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
-LDFLAGS+= $(OCC_LIBS) $(HDF5_LIBS) -lSalomeContainer -lSalomeHDFPersist -lSalomeDS -lSalomeNS -lRegistry -lOpUtil -lmedmem -lMEDImpl
+LDFLAGS+= $(HDF5_LIBS) -lSalomeContainer -lTOOLSDS -lSalomeNS -lRegistry -lOpUtil -lmedmem -lMEDImpl -lSalomeHDFPersist
MED.hh MEDSK.cc: MED.idl
-//=============================================================================
-// File : Med_Gen_i.cxx
-// Created : mer fév 20 15:47:57 CET 2002
-// Author : Paul RASCLE, EDF
-// Project : SALOME
-// Copyright : EDF 2001
-// $Header$
-//=============================================================================
-using namespace std;
+// MED MED : implemetation of MED idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Med_Gen_i.cxx
+// Author : Paul RASCLE, EDF
+// Module : MED
+// $Header$
+using namespace std;
+using namespace std;
#include "Med_Gen_i.hxx"
#include "Mesh_i.hxx"
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
+#include <HDFascii.hxx>
#include "SALOMEDS_Tool.hxx"
// Initialisation des variables statiques
try
{
myMeshDriver.read();
-("apres read");
+ MESSAGE("apres read");
myMeshDriver.close();
}
catch (const exception & ex)
* CORBA: Save Mesh objects (called when a study is saved)
*/
//=============================================================================
-SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent) {
+SALOMEDS::TMPFile* Med_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile) {
const char* LOC = "Med_Gen_i::Save";
BEGIN_OF(LOC);
SALOMEDS::TMPFile_var aStreamFile;
// Get a temporary directory to store a file
- TCollection_AsciiString aTmpDir = SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
// Create a list to store names of created files
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
TColStd_SequenceOfAsciiString aFileNames;
+ CORBA::String_var aSaveStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+
SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH");
if (!CORBA::is_nil(aMedMeshFather)) {
SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather);
CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR);
if (! CORBA::is_nil(myMesh)) {
- TCollection_AsciiString aName;
- aName = "MED_tmp_";
+ TCollection_AsciiString aName(strdup(aSaveStudyName));
+ aName += "_MEDMESH_";
aName += myMesh->getName();
aName += ".med";
-// MESSAGE("Save mesh with name "<<aName.ToCString());
+ MESSAGE("Save mesh with name "<<aName.ToCString());
long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName());
myMesh->write(driverId,"");
aFileNames.Append(aName);
CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR);
if (! CORBA::is_nil(myField)) {
- TCollection_AsciiString aName;
- aName = "MED_tmp_";
+ ostringstream a,b;
+ a<< myField->getOrderNumber();
+ b<< myField->getIterationNumber();
+
+ TCollection_AsciiString aName(strdup(aSaveStudyName));
+ aName += "_MEDFIELD_";
aName += myField->getName();
+ aName += "_ORDRE_";
+ aName += strdup(a.str().c_str());
+ aName += "_ITER_";
+ aName += strdup(b.str().c_str());
aName += ".med";
-// MESSAGE("Save mesh with name "<<aName.ToCString());
+ MESSAGE("Save mesh with name "<<aName.ToCString());
long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName());
myField->write(driverId,"");
aFileNames.Append(aName);
aSeq->length(aFileNames.Length());
for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
// Conver a file to the byte stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq);
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
// Remove the created file and tmp directory
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq, true);
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ // Return the created byte stream
+ return aStreamFile._retn();
+
+ END_OF(LOC);
+}
+
+SALOMEDS::TMPFile* Med_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile) {
+ const char* LOC = "Med_Gen_i::SaveASCII";
+ BEGIN_OF(LOC);
+
+ SALOMEDS::TMPFile_var aStreamFile;
+ // Get a temporary directory to store a file
+ TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ TColStd_SequenceOfAsciiString aFileNames;
+
+ CORBA::String_var aSaveStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+
+ SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH");
+ if (!CORBA::is_nil(aMedMeshFather)) {
+ SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather);
+ for(; anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var aSO = anIter->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSO->FindAttribute(anAttr,"AttributeIOR")) {
+ CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR);
+ if (! CORBA::is_nil(myMesh)) {
+ TCollection_AsciiString aName(strdup(aSaveStudyName));
+ aName += "_MEDMESH_";
+ aName += myMesh->getName();
+ aName += ".med";
+ MESSAGE("Save mesh with name "<<aName.ToCString());
+ long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myMesh->getName());
+ myMesh->write(driverId,"");
+ HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir+aName).ToCString()), true);
+ aFileNames.Append(aName);
+ }
+ }
+ }
+ }
+
+ SALOMEDS::SObject_var aMedFieldFather = theComponent->GetStudy()->FindObject("MEDFIELD");
+ if (!CORBA::is_nil(aMedFieldFather)) {
+ SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedFieldFather);
+ for(; anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var aSO = anIter->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSO->FindAttribute(anAttr,"AttributeIOR")) {
+ CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR);
+ if (! CORBA::is_nil(myField)) {
+ ostringstream a,b;
+ a<< myField->getOrderNumber();
+ b<< myField->getIterationNumber();
+
+ TCollection_AsciiString aName(strdup(aSaveStudyName));
+ aName += "_MEDFIELD_";
+ aName += myField->getName();
+ aName += "_ORDRE_";
+ aName += strdup(a.str().c_str());
+ aName += "_ITER_";
+ aName += strdup(b.str().c_str());
+ aName += ".med";
+ MESSAGE("Save mesh with name "<<aName.ToCString());
+ long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,(aTmpDir+aName).ToCString(),myField->getName());
+ myField->write(driverId,"");
+ HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir+aName).ToCString()), true);
+ aFileNames.Append(aName);
+ }
+ }
+ }
+ }
+
+ int i;
+ aSeq->length(aFileNames.Length());
+ for(i = aFileNames.Length(); i > 0; i--) aSeq[i-1] = CORBA::string_dup(aFileNames.Value(i).ToCString());
+ // Conver a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
+ // Remove the created file and tmp directory
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
// Return the created byte stream
return aStreamFile._retn();
*/
//=============================================================================
-CORBA::Boolean Med_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream) {
+CORBA::Boolean Med_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile) {
const char* LOC = "Med_Gen_i::Load";
BEGIN_OF(LOC);
// Get a temporary directory for a file
- TCollection_AsciiString aTmpDir = SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir =
+ (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
_saveFileName = CORBA::string_dup(aTmpDir.ToCString());
- SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString());
+ SALOMEDS::ListOfFileNames_var aSeq =
+ SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(), isMultiFile);
return true;
END_OF(LOC);
}
+CORBA::Boolean Med_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile) {
+ return Load(theComponent, theStream, theURL, isMultiFile);
+}
+
//=============================================================================
/*!
* CORBA:
*/
//=============================================================================
-void Med_Gen_i::Close(const char *IORSComponent)
+void Med_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
{
MESSAGE("Med_Gen_i::Close");
+ SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH");
+ if (!CORBA::is_nil(aMedMeshFather)) {
+ SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather);
+ for(; anIter->More(); anIter->Next()) {
+ SALOMEDS::SObject_var aSO = anIter->Value();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (aSO->FindAttribute(anAttr,"AttributeIOR")) {
+ CORBA::Object_var myIOR = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR);
+ // here must call method destroy of myMesh, but it not implented yet
+ }
+ }
+ }
}
//=============================================================================
*/
//=============================================================================
-char* Med_Gen_i::IORToLocalPersistentID(const char* IORString,
- CORBA::Boolean& IsAFile)
-{
+char* Med_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
+ const char* IORString,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII) {
const char * LOC = "Med_Gen_i::IORToLocalPersistentID" ;
BEGIN_OF(LOC) ;
-
SCRUTE(IORString);
- if (string(IORString).size()==0) return strdup("");
+
+ string aSaveStudyName(strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL())));
+
+
+ if (string(IORString).size()==0) return strdup((aSaveStudyName+"_MED").c_str());
// Well, we know where put object (_saveFilename) and we know object (IORString)
// cast object :
CORBA::Object_var myIOR = _orb->string_to_object(IORString);
if (! CORBA::is_nil(myMed))
{
// nothing to save : Support will be saved inside the mesh
- string str_MedName="Objet Med + /OBJ_MED/";
+ string str_MedName=aSaveStudyName + "_MED Objet Med + /OBJ_MED/";
return strdup(str_MedName.c_str()) ;
}
SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR);
if (! CORBA::is_nil(myMesh))
{
- string str_MeshName;
- try
- {
- long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER,_saveFileName.c_str(),myMesh->getName()) ;
- myMesh->write(driverId,"");
- str_MeshName=string("/ENS_MAA/")+string(myMesh->getName());
- }
- catch(...)
- {
- MESSAGE("Unable to save the mesh");
- THROW_SALOME_CORBA_EXCEPTION("Unable to save Mesh in Med"\
- ,SALOME::INTERNAL_ERROR);
- }
- return strdup(str_MeshName.c_str()) ;
+ CORBA::String_var aName((aSaveStudyName+"_MEDMESH_"+ myMesh->getName() + ".med").c_str());
+ return strdup(aName._retn()) ;
}
// SUPPORT
THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\
,SALOME::INTERNAL_ERROR);
}
- return strdup(str_SupportName.c_str());
+ return strdup((aSaveStudyName+"_MED"+str_SupportName).c_str());
}
SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR);
if (! CORBA::is_nil(myField))
{
- string str_FieldName;
- try
- {
- long driverId = myField->addDriver(SALOME_MED::MED_DRIVER,_saveFileName.c_str(),myField->getName()) ;
- myField->write(driverId,"");
- str_FieldName=string("/CHA/")+string(myField->getName());
- ostringstream a,b;
- a<< myField->getOrderNumber();
- b<< myField->getIterationNumber();
- str_FieldName+=string("/ORDRE/")+a.str()+string("/ITER/")+b.str();
- }
- catch(...)
- {
- MESSAGE("Unable to save the mesh");
- THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\
- ,SALOME::INTERNAL_ERROR);
- }
- return strdup(str_FieldName.c_str());
+ string str_FieldName;
+ ostringstream a,b;
+ a<< myField->getOrderNumber();
+ b<< myField->getIterationNumber();
+ CORBA::String_var aName((aSaveStudyName+"_MEDFIELD_"+ myField->getName() +
+ string("_ORDRE_")+a.str()+
+ string("_ITER_")+b.str() +
+ ".med").c_str());
+ return strdup(aName._retn());
}
//THROW_SALOME_CORBA_EXCEPTION("Unable to save IOR",SALOME::BAD_PARAM);
- return strdup("");
+ return strdup((aSaveStudyName+"_MED").c_str());
END_OF(LOC) ;
}
*/
//=============================================================================
-char* Med_Gen_i::LocalPersistentIDToIOR(const char* aLocalPersistentID)
+char* Med_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
+ const char* aLocalPersistentID,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
+ throw(SALOME::SALOME_Exception)
{
const char * LOC = "Med_Gen_i::LocalPersistentIDToIOR" ;
BEGIN_OF(LOC) ;
-
TCollection_AsciiString aTmpDir(CORBA::string_dup(_saveFileName.c_str()));
- TCollection_AsciiString aFileName("MED_tmp_");
- aFileName += CORBA::string_dup(aLocalPersistentID);
- aFileName += ".med";
- MESH * myMesh= new MESH() ;
- myMesh->setName(aLocalPersistentID);
- MED_MESH_RDONLY_DRIVER myMeshDriver((aTmpDir+aFileName).ToCString(),myMesh);
- try
- {
- myMeshDriver.setMeshName(aLocalPersistentID);
- myMeshDriver.open();
- }
- catch (const exception & ex)
- {
- MESSAGE("Exception Interceptee : ");
- SCRUTE(ex.what());
- THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM);
- };
- try
- {
- myMeshDriver.read();
- MESSAGE("apres read");
- myMeshDriver.close();
+ string aSaveStudyName(strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL())));
+ int aStudyNameLen = strlen(aSaveStudyName.c_str());
+
+ if (strlen(aLocalPersistentID) <= aStudyNameLen) return strdup("");
+ if (strcmp(aLocalPersistentID, "Objet Med + /OBJ_MED/") == 0) return strdup(""); // MED
+
+ if (strncmp(&(aLocalPersistentID[aStudyNameLen]), "_MEDMESH_",9) == 0) {// MESH
+ MESH * myMesh= new MESH() ;
+ int aMeshNameLen = strlen(aLocalPersistentID) - 12 - aStudyNameLen;
+ char* aMeshName = new char[aMeshNameLen];
+ strncpy(aMeshName, &(aLocalPersistentID[aStudyNameLen + 9]), aMeshNameLen-1);
+ aMeshName[aMeshNameLen-1] = 0;
+ myMesh->setName(aMeshName);
+
+ char* aFileName;
+ if (isASCII) {
+ char* aResultPath = HDFascii::ConvertFromASCIIToHDF((aTmpDir + strdup(aLocalPersistentID)).ToCString());
+ aFileName = new char[strlen(aResultPath) + 19];
+ sprintf(aFileName, "%shdf_from_ascii.hdf", aResultPath);
+ delete(aResultPath);
+ } else aFileName = strdup((aTmpDir + strdup(aLocalPersistentID)).ToCString());
+ MED_MESH_RDONLY_DRIVER myMeshDriver(aFileName,myMesh);
+ try
+ {
+ myMeshDriver.setMeshName(aMeshName);
+ myMeshDriver.open();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM);
+ };
+ try
+ {
+ myMeshDriver.read();
+ MESSAGE("apres read");
+ myMeshDriver.close();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM);
+ }
+ MESH_i * meshi = new MESH_i(myMesh);
+ //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this());
+ SALOME_MED::MESH_ptr mesh = meshi->_this();
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(1);
+ aSeq[0]=CORBA::string_dup(aLocalPersistentID);
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ if (isASCII) {
+ SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
+ aFilesToRemove->length(1);
+ aFilesToRemove[0] = strdup(&(aFileName[strlen(SALOMEDS_Tool::GetDirFromPath(aFileName))]));
+ SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aFileName), aFilesToRemove, true);
}
- catch (const exception & ex)
- {
- MESSAGE("Exception Interceptee : ");
- SCRUTE(ex.what());
- THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM);
- };
-
- MESH_i * meshi = new MESH_i(myMesh);
- //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this());
- SALOME_MED::MESH_ptr mesh = meshi->_this();
-
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(1);
- aSeq[0]=CORBA::string_dup(aFileName.ToCString());
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq, true);
+ delete(aFileName);
+ return(CORBA::string_dup(_orb->object_to_string(mesh)));
+ } else if (strncmp(&(aLocalPersistentID[aStudyNameLen]), "_MEDFIELD_",14) == 0) { // FIELD
+ return(strdup("")); // not implemented yet
+ }
- return(CORBA::string_dup(_orb->object_to_string(mesh)));
+ return strdup("");
END_OF(LOC) ;
}
return aResultSO._retn();
}
+//=============================================================================
+/*!
+ * returns true, if can copy the object
+ */
+//=============================================================================
+CORBA::Boolean Med_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
+ // Try to retrieve known by MED component mesh by given IOR
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
+ CORBA::Object_var anObj = _orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
+ // If the object is null one it can't be copied: return false
+ if (aMesh->_is_nil()) return false;
+ return true;
+}
+
+//=============================================================================
+/*!
+ * create copy of the object and put it to the stream
+ */
+//=============================================================================
+SALOMEDS::TMPFile* Med_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
+ // Declare a sequence of the byte to store the copied object
+ SALOMEDS::TMPFile_var aStreamFile;
+
+ // Try to get GEOM_Shape object by given SObject
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return new SALOMEDS::TMPFile(0);
+ CORBA::String_var anIOR = strdup(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ CORBA::Object_var anObj = _orb->string_to_object(anIOR);
+ SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj);
+ if (aMesh->_is_nil()) return new SALOMEDS::TMPFile(0);
+
+ // Get a temporary directory to store a temporary file
+ CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir();
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(1);
+ aSeq[0] = strdup(aMesh->getName());
+ char* aFullName = new char[strlen(aTmpDir)+strlen(aSeq[0])+1];
+ strcpy(aFullName, aTmpDir);
+ strcpy(aFullName+strlen(aTmpDir), aSeq[0]);
+ long driverId = aMesh->addDriver(SALOME_MED::MED_DRIVER,strdup(aFullName) , aMesh->getName());
+ aMesh->write(driverId,"");
+ delete(aFullName);
+
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false);
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true);
+
+ // Assign an ID = 1 the the type SALOME_MED::MESH
+ theObjectID = 1;
+
+ return aStreamFile._retn();
+}
+
+//=============================================================================
+/*!
+ * returns true, if can copy the object
+ */
+//=============================================================================
+CORBA::Boolean Med_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
+ // The MED component can paste only objects copied by MED component
+ // and with the object type = 1 (mesh)
+ if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false;
+ return true;
+}
+
+//=============================================================================
+/*!
+ * returns true, if can copy the object
+ */
+//=============================================================================
+SALOMEDS::SObject_ptr Med_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
+ CORBA::Long theObjectID,
+ SALOMEDS::SObject_ptr theObject) {
+ SALOMEDS::SObject_var aResultSO = SALOMEDS::SObject::_duplicate(theObject);
+ if (theStream.length() == 0) return aResultSO._retn();
+
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+
+ CORBA::String_var aTmpDir = strdup(SALOMEDS_Tool::GetTmpDir());
+ SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
+ CORBA::String_var aMeshName = strdup(aSeq[0]);
+ char* aFullName = new char[strlen(aTmpDir)+strlen(aMeshName)+1];
+ strcpy(aFullName, aTmpDir);
+ strcpy(aFullName+strlen(aTmpDir), aMeshName);
+
+ MESH * myMesh= new MESH() ;
+ myMesh->setName((char*)aMeshName);
+ MED_MESH_RDONLY_DRIVER myMeshDriver(aFullName, myMesh);
+ try {
+ myMeshDriver.setMeshName((char*)aMeshName);
+ myMeshDriver.open();
+ } catch (const exception & ex) {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ delete(aFullName);
+ return aResultSO._retn();
+ };
+ try {
+ myMeshDriver.read();
+ ("apres read");
+ myMeshDriver.close();
+ } catch (const exception & ex) {
+ MESSAGE("Exception Interceptee : ");
+ SCRUTE(ex.what());
+ delete(aFullName);
+ return aResultSO._retn();
+ };
+ // set new mesh name, becouse now there are no possibility to operate meshes with the same names
+// srand((unsigned int)time(NULL));
+ int aRND = rand(); //Get a random number to present a name of a copied mesh
+ char aCopiedMeshName[20];
+ sprintf(aCopiedMeshName,"MESH_COPY_%d",aRND);
+ myMesh->setName(aCopiedMeshName);
+ MESH_i * meshi = new MESH_i(myMesh);
+ SALOME_MED::MESH_ptr mesh = meshi->_this();
+ // add the mesh object in study
+ meshi->addInStudy(aStudy,mesh);
+ // get the IOR attribute of just added mesh
+ CORBA::String_var anIORString = _orb->object_to_string(mesh);
+ aResultSO = aStudy->FindObjectIOR(anIORString);
+
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true);
+ delete(aFullName);
+ return aResultSO._retn();
+}
+
+
+
+
+
+
//=============================================================================
/*!
* C factory, accessible with dlsym, after dlopen
-//=============================================================================
-// File : Med_Gen_i.hxx
-// Created : mer fév 20 15:47:52 CET 2002
-// Author : Paul RASCLE, EDF
-// Project : SALOME
-// Copyright : EDF 2001
-// $Header$
-//=============================================================================
+// MED MED : implemetation of MED idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Med_Gen_i.hxx
+// Author : Paul RASCLE, EDF
+// Module : MED
+// $Header$
#ifndef _MED_GEN_I_HXX_
#define _MED_GEN_I_HXX_
// void Save(const char *IORSComponent, const char *aUrlOfFile);
// void Load(const char *IORSComponent, const char *aUrlOfFile);
- SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent);
- CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream);
- void Close(const char *IORSComponent);
+ SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile);
+ SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile);
+
+ CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile);
+ CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile);
+
+ void Close(SALOMEDS::SComponent_ptr theComponent);
char* ComponentDataType();
- char* IORToLocalPersistentID(const char* IORString, CORBA::Boolean& IsAFile);
- char* LocalPersistentIDToIOR(const char* aLocalPersistentID);
+ char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
+ const char* IORString,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII);
+ char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
+ const char* aLocalPersistentID,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
+ throw(SALOME::SALOME_Exception);
bool CanPublishInStudy(CORBA::Object_ptr theIOR);
SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject,
const char* theName) throw (SALOME::SALOME_Exception) ;
+
+ CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
+ SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
+ CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
+ SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
+ CORBA::Long theObjectID,
+ SALOMEDS::SObject_ptr theObject);
+
private :
static map <string, string>_MedCorbaObj;
static string _myFileName;
-#==============================================================================
-# File : Makefile.in
-# Created : dim déc 9 18:35:11 CET 2001
-# Author : Paul RASCLE, EDF
-# Project : SALOME
-# Copyright : EDF 2001
+# MED MEDGUI : MED component GUI implemetation
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Paul RASCLE, EDF
+# Module : MED
# $Header$
-#==============================================================================
-# source path
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
-//=============================================================================
-// File : MedGUI.cxx
-// Project : SALOME
-// Copyright : EDF 2001
-//=============================================================================
-
+// MED MEDGUI : MED component GUI implemetation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MedGUI.cxx
+// Module : MED
+
+using namespace std;
#include "MedGUI.h"
// SALOME Includes
SCRUTE(file);
try
{
- medgen->readStructFile(file.latin1(),myStudyName);
+// medgen->readStructFile(file.latin1(),myStudyName);
+ medgen->readStructFileWithFieldType(file.latin1(),myStudyName);
if (myActiveStudy->getStudyDocument()->GetProperties()->IsLocked()) {
QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
QObject::tr("WRN_WARNING"),
-//=============================================================================
-// File : MEDGUI.h
-// Project : SALOME
-// Copyright : EDF 2001
-//=============================================================================
+// MED MEDGUI : MED component GUI implemetation
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDGUI.h
+// Module : MED
#ifndef _MEDGUI_H_
#define _MEDGUI_H_
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. translating
-# from French to English, "Foo::Bar" would be translated to "Pub",
-# not "Foo::Pub".
+# MED MEDGUI : MED component GUI implemetation
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : MedGUI_icons.po
+# Module : MED
+
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. translating
-# from French to English, "Foo::Bar" would be translated to "Pub",
-# not "Foo::Pub".
+# MED MEDGUI : MED component GUI implemetation
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : MedGUI_msg_en.po
+# Module : MED
+
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
-# This is a Qt message file in .po format. Each msgid starts with
-# a scope. This scope should *NOT* be translated - eg. translating
-# from French to English, "Foo::Bar" would be translated to "Pub",
-# not "Foo::Pub".
+# MED MEDGUI : MED component GUI implemetation
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : MedGUI_msg_fr.po
+# Module : MED
+
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
--- /dev/null
+maill.0.med:MAILTRQU:
+pointe.med:maa1:
+mesh.med:Mesh 1:
+zzzz121b.med:MUN:
+zzzz121b.med:MZERO:2
--- /dev/null
+
+mesh.med maillage du cube par SMESH
+pointe.med fichier de test cree par Med Memoire
+zzzz121b.med maillages Aster + champ : sert a Aster de fichier de test
+maill.0.med petit fichier Aster (2D)
+
+Seuls les 2 premiers fichiers peuvent etre entierement lus par Med Memoire en version V08.2 :
+Les 2 autres fichiers contiennent des points de Gauss qui ne seront pas gérés avant
+la version V08.4 de Med Memoire.
+
+ Utilisation des tests
+ ---------------------
+
+1) Tests Unitaires
+__________________
+
+Il faut récuperer les fichiers de reference
+puis lancer tous.sh (apres avoir modifier les variables selon votre
+environnement (SALOME,SALOME_LIB et SALOME_PATH) )
+
+
+Les resultats "grossiers" (OK ou NOK) sont dans le fichier cpterendu.
+La "log" des résultats est dans le fichier result_test
+
+
+2) Les deux tests readCoordinate et ReadEntete
+______________________________________________
+
+Ces deux tests, à terme devront permettre d'avoir un équivalent à mdump
+
+
+A Constitution des fichiers de référence mdump
+----------------------------------------------
+
+Une liste des fichiers avec les noms de maillages associés se trouve
+dans le fichier Maillages.txt sous la forme:
+
+ nom de fichier:nom de maillage:numero du maillage
+
+creer la directory Ref
+lancer constituedump.sh (apres avoir modifier les variables selon votre
+environnement (SALOME,SALOME_LIB et SALOME_PATH) )
+
+B Comparaison avec ces fichiers
+-------------------------------
+
+Lancer testReadCoordinate.sh (apres avoir modifier les variables selon votre
+environnement (SALOME,SALOME_LIB et SALOME_PATH) )
+Lancer testReadEntete.sh (apres avoir modifier les variables selon votre
+environnement (SALOME,SALOME_LIB et SALOME_PATH) )
+
+Les resultats sont dans le fichier PourMail
+
+
--- /dev/null
+CELLMODEL Test
+--------------
+
+MED_POINT1
+__________________
+CellModel de Nom : MED_POINT1
+Nb de Vertexes : 1
+Nb de Noeuds : 1
+Dimension : 0
+
+
+MED_SEG2
+__________________
+CellModel de Nom : MED_SEG2
+Nb de Vertexes : 2
+Nb de Noeuds : 2
+Dimension : 1
+
+
+MED_SEG3
+__________________
+CellModel de Nom : MED_SEG3
+Nb de Vertexes : 2
+Nb de Noeuds : 3
+Dimension : 1
+
+
+MED_TRIA3
+__________________
+CellModel de Nom : MED_TRIA3
+Nb de Vertexes : 3
+Nb de Noeuds : 3
+Dimension : 2
+Nb d elements de dimension 1 : 3
+Types de ces elements
+MED_SEG2
+Impression des coordonnées du 1er Element de ce type
+1 2
+
+Informations particulieres - dimension 1
+MED_SEG2
+
+MED_QUAD4
+__________________
+CellModel de Nom : MED_QUAD4
+Nb de Vertexes : 4
+Nb de Noeuds : 4
+Dimension : 2
+Nb d elements de dimension 1 : 4
+Types de ces elements
+MED_SEG2
+Impression des coordonnées du 1er Element de ce type
+1 2
+
+Informations particulieres - dimension 1
+MED_SEG2
+
+MED_TRIA6
+__________________
+CellModel de Nom : MED_TRIA6
+Nb de Vertexes : 3
+Nb de Noeuds : 6
+Dimension : 2
+Nb d elements de dimension 1 : 3
+Types de ces elements
+MED_SEG3
+Impression des coordonnées du 1er Element de ce type
+1 2 4
+
+Informations particulieres - dimension 1
+MED_SEG3
+
+MED_QUAD8
+__________________
+CellModel de Nom : MED_QUAD8
+Nb de Vertexes : 4
+Nb de Noeuds : 8
+Dimension : 2
+Nb d elements de dimension 1 : 4
+Types de ces elements
+MED_SEG3
+Impression des coordonnées du 1er Element de ce type
+1 2 5
+
+Informations particulieres - dimension 1
+MED_SEG3
+
+MED_TETRA4
+__________________
+CellModel de Nom : MED_TETRA4
+Nb de Vertexes : 4
+Nb de Noeuds : 4
+Dimension : 3
+Nb d elements de dimension 1 : 6
+Types de ces elements
+MED_SEG2
+Impression des coordonnées du 1er Element de ce type
+1 2
+Nb d elements de dimension 2 : 4
+Types de ces elements
+MED_TRIA3
+Impression des coordonnées du 1er Element de ce type
+1 2 3
+
+Informations particulieres - dimension 2
+MED_TRIA3
+
+MED_PYRA5
+__________________
+CellModel de Nom : MED_PYRA5
+Nb de Vertexes : 5
+Nb de Noeuds : 5
+Dimension : 3
+Nb d elements de dimension 1 : 8
+Types de ces elements
+MED_SEG2
+Impression des coordonnées du 1er Element de ce type
+1 2
+Nb d elements de dimension 2 : 5
+Types de ces elements
+MED_TRIA3
+MED_QUAD4
+Impression des coordonnées du 1er Element de ce type
+1 2 3 4
+
+Informations particulieres - dimension 2
+
+MED_PENTA6
+__________________
+CellModel de Nom : MED_PENTA6
+Nb de Vertexes : 6
+Nb de Noeuds : 6
+Dimension : 3
+Nb d elements de dimension 1 : 9
+Types de ces elements
+MED_SEG2
+Impression des coordonnées du 1er Element de ce type
+1 2
+Nb d elements de dimension 2 : 5
+Types de ces elements
+MED_TRIA3
+MED_QUAD4
+Impression des coordonnées du 1er Element de ce type
+1 2 3
+
+Informations particulieres - dimension 2
+
+MED_HEXA8
+__________________
+CellModel de Nom : MED_HEXA8
+Nb de Vertexes : 8
+Nb de Noeuds : 8
+Dimension : 3
+Nb d elements de dimension 1 : 12
+Types de ces elements
+MED_SEG2
+Impression des coordonnées du 1er Element de ce type
+1 2
+Nb d elements de dimension 2 : 6
+Types de ces elements
+MED_QUAD4
+Impression des coordonnées du 1er Element de ce type
+1 2 3 4
+
+Informations particulieres - dimension 2
+
+MED_TETRA10
+__________________
+CellModel de Nom : MED_TETRA10
+Nb de Vertexes : 4
+Nb de Noeuds : 10
+Dimension : 3
+Nb d elements de dimension 1 : 6
+Types de ces elements
+MED_SEG3
+Impression des coordonnées du 1er Element de ce type
+1 2 5
+Nb d elements de dimension 2 : 4
+Types de ces elements
+MED_TRIA6
+Impression des coordonnées du 1er Element de ce type
+1 2 3 5 6 7
+
+Informations particulieres - dimension 2
+MED_TRIA6
+
+MED_PYRA13
+__________________
+CellModel de Nom : MED_PYRA13
+Nb de Vertexes : 5
+Nb de Noeuds : 13
+Dimension : 3
+Nb d elements de dimension 1 : 8
+Types de ces elements
+MED_SEG3
+Impression des coordonnées du 1er Element de ce type
+1 2 6
+Nb d elements de dimension 2 : 5
+Types de ces elements
+MED_TRIA6
+MED_QUAD8
+Impression des coordonnées du 1er Element de ce type
+1 2 3 4 6 7 8 9
+
+Informations particulieres - dimension 2
+
+MED_PENTA15
+__________________
+CellModel de Nom : MED_PENTA15
+Nb de Vertexes : 6
+Nb de Noeuds : 15
+Dimension : 3
+Nb d elements de dimension 1 : 9
+Types de ces elements
+MED_SEG3
+Impression des coordonnées du 1er Element de ce type
+1 2 7
+Nb d elements de dimension 2 : 5
+Types de ces elements
+MED_TRIA6
+MED_QUAD8
+Impression des coordonnées du 1er Element de ce type
+1 2 3 7 8 9
+
+Informations particulieres - dimension 2
+
+MED_HEXA20
+__________________
+CellModel de Nom : MED_HEXA20
+Nb de Vertexes : 8
+Nb de Noeuds : 20
+Dimension : 3
+Nb d elements de dimension 1 : 12
+Types de ces elements
+MED_SEG3
+Impression des coordonnées du 1er Element de ce type
+1 2 9
+Nb d elements de dimension 2 : 6
+Types de ces elements
+MED_QUAD8
+Impression des coordonnées du 1er Element de ce type
+1 2 3 4 9 10 11 12
+
+Informations particulieres - dimension 2
--- /dev/null
+GEO_NAME Test
+-------------
+
+MED_NONE
+MED_POINT1
+MED_SEG2
+MED_SEG3
+MED_TRIA3
+MED_QUAD4
+MED_TRIA6
+MED_QUAD8
+MED_TETRA4
+MED_PYRA5
+MED_PENTA6
+MED_HEXA8
+MED_TETRA10
+MED_PYRA13
+MED_PENTA15
+MED_HEXA20
+
+MESH_ENTITIES Test
+------------------
+
+MED_MAILLE
+MED_POINT1
+MED_SEG2
+MED_SEG3
+MED_TRIA3
+MED_TRIA6
+MED_QUAD4
+MED_QUAD8
+MED_TETRA4
+MED_TETRA10
+MED_HEXA8
+MED_HEXA20
+MED_PENTA6
+MED_PENTA15
+MED_PYRA5
+MED_PYRA13
+
+MED_FACE
+MED_TRIA3
+MED_TRIA6
+MED_QUAD4
+MED_QUAD8
+
+MED_ARETE
+MED_SEG2
+MED_SEG3
+
+MED_NOEUD
+MED_NONE
+
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : constituedump.sh
+# Module : MED
+
+cd Data
+for i in `ls *.med`
+do
+ echo "constitution de $i : 1er maillage"
+ mdump $i > ${i}.coor.dump << EOF
+1
+1
+1
+EOF
+cp ${i}.coor.dump ${i}.ent.dump
+done
+
+for i in `echo zzzz121b.med`
+do
+ echo "constitution de $i : 2nd maillage"
+ mdump $i > ${i}.2.coor.dump << EOF
+1
+1
+2
+EOF
+cp ${i}.2.coor.dump ${i}.2.ent.dump
+done
+
+mv *.dump ../Ref
+cd ../Ref
+
+for j in `ls *.ent.dump`
+do
+echo "Traitement de $j : "
+vi ${j} << EOF
+:/INFORMATIONS GENERALES
+:-2
+:1,.d
+:/Nombre de familles
+:.,\$d
+:wq
+EOF
+done
+
+for j in `ls *.coor.dump`
+do
+echo "Traitement de $j : "
+vi ${j} << EOF
+:/NOEUDS DU MAILLAGE
+:-2
+:1,.d
+:/Coordonnees des noeuds
+: +2
+:.,\$d
+:wq
+EOF
+done
+
+
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : testreadCoordinate.sh
+# Module : MED
+
+SALOME=${HOME}/V08
+SALOME_LIB=${SALOME}/Build/lib
+SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB}
+RESULT=PourMail
+
+rm -rf ${RESULT}
+echo " - Comparaison des Coordonnees : " >> ${RESULT}
+echo -e " -------------------------------\n">> ${RESULT}
+
+npb=0;
+num=1
+while [ true ]
+do
+ ligne=`sed -n -e"$num,$num p" Maillages.txt`
+ num=`expr $num + 1 `
+ if [ "$ligne" = "" ]
+ then
+ break
+ fi
+ if [ `echo $ligne | cut -c1 ` = "#" ]
+ then
+ echo "COMMENTAIRE"
+ continue
+ fi
+ fich=`echo $ligne | cut -f1 -d":"`
+ maill=`echo $ligne | cut -f2 -d":"`
+ nb=`echo $ligne | cut -f3 -d":"`
+ if [ "$nb" = "" ]
+ then
+ Result=Rmem/Rmem.${fich}.coor.dump
+ Compare=Ref/${fich}.coor.dump
+ else
+ Result=Rmem/Rmem.${fich}.${nb}.coor.dump
+ Compare=Ref/${fich}.${nb}.coor.dump
+ fi
+ ${SALOME_PATH}/readCoordinate Data/${fich} "${maill}" > $Result
+
+ echo " Maillage " $maill "lu dans " $fich >> ${RESULT}
+ diff $Result $Compare >> /dev/null
+ rc=$?
+ if [ "$rc" != "0" ]
+ then
+ nb=`diff $Result $Compare| grep -v "Type de repere des coordonnees" | wc -l`
+ nb=`expr $nb + 0 `
+ if [ "$nb" != "2" ]
+ then
+ echo " Difference entre les resultats des deux methodes de dumps : " >> ${RESULT}
+ echo " Fichiers compares : $Result et $Compare " >> ${RESULT}
+ diff $Result $Compare >> ${RESULT}
+ echo -e "\n">> ${RESULT}
+ npb=`expr $npb + 1 `
+ else
+ echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT}
+ fi
+ else
+ echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT}
+ fi
+ echo -e "\n" >> ${RESULT}
+done
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : testreadEntete.sh
+# Module : MED
+
+SALOME=${HOME}/V08
+SALOME_LIB=${SALOME}/Build/lib
+SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB}
+RESULT=PourMail
+
+echo " - Comparaison des Entetes : " >> ${RESULT}
+echo -e " ------------------------\n">> ${RESULT}
+
+npb=0;
+num=1
+while [ true ]
+do
+ ligne=`sed -n -e"$num,$num p" Maillages.txt`
+ num=`expr $num + 1 `
+ if [ "$ligne" = "" ]
+ then
+ break
+ fi
+ if [ `echo $ligne | cut -c1 ` = "#" ]
+ then
+ echo "COMMENTAIRE"
+ continue
+ fi
+ fich=`echo $ligne | cut -f1 -d":"`
+ maill=`echo $ligne | cut -f2 -d":"`
+ nb=`echo $ligne | cut -f3 -d":"`
+ if [ "$nb" = "" ]
+ then
+ Result=Rmem/Rmem.${fich}.ent.dump
+ Compare=Ref/${fich}.ent.dump
+ else
+ Result=Rmem/Rmem.${fich}.${nb}.ent.dump
+ Compare=Ref/${fich}.${nb}.ent.dump
+ fi
+ ${SALOME_PATH}/readEntete Data/${fich} "${maill}" > $Result
+
+ echo " Maillage " $maill "lu dans " $fich >> ${RESULT}
+ diff $Result $Compare >> /dev/null
+ rc=$?
+ if [ "$rc" != "0" ]
+ then
+ nb=`diff $Result $Compare| grep -v "Type de repere des coordonnees" | wc -l`
+ nb=`expr $nb + 0 `
+ # if [ "$nb" != "2" ]
+ # then
+ echo " Difference entre les resultats des deux methodes de dumps : " >> ${RESULT}
+ echo " Fichiers compares : $Result et $Compare " >> ${RESULT}
+ diff $Result $Compare >> ${RESULT}
+ echo -e "\n">> ${RESULT}
+ npb=`expr $npb + 1 `
+ # else
+ # echo " Pas de différence sur les coordonnees == test OK == " >> ${RESULT}
+ # fi
+ else
+ echo " Pas de différence sur les informations generales == test OK == " >> ${RESULT}
+ fi
+ echo -e "\n" >> ${RESULT}
+done
--- /dev/null
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : tous.sh
+# Module : MED
+
+SALOME=${HOME}/V08
+SALOME_LIB=${SALOME}/Build/lib
+SALOME_PATH=${SALOME}/Build/MED/src/MEDMEM
+LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SALOME_LIB}
+RESULT=cptrendu
+rm -rf ${RESULT}
+
+echo " Tests Unitaires " >> $RESULT
+echo " --------------- " >> $RESULT
+echo " " >> $RESULT
+
+for prog in testUGeoNameMeshEntities testUCellModel testUUnit testUCoordinate
+#for prog in testUCoordinate
+do
+
+ echo "Passage du test : " ${prog}
+ echo "" >> result_test
+ echo "Passage du test : " ${prog} >> result_test
+ echo "Passage du test : " ${prog}
+ ${SALOME_PATH}/${prog} >> result_test
+ rc=$?
+ if [ "$rc" = "0" ]
+ then
+ echo "Test de " $prog " == Test OK" >> $RESULT
+ echo " " >> $RESULT
+ else
+ echo "Test de " $prog " NOK !!!!!!" >> $RESULT
+ fi
+done
+cat $RESULT
--- /dev/null
+# Doxyfile 0.1
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = medmemoire
+PROJECT_NUMBER = 1.0
+OUTPUT_DIRECTORY = doc_ref
+OUTPUT_LANGUAGE = English
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ALWAYS_DETAILED_SEC = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = NO
+STRIP_CODE_COMMENTS = YES
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+VERBATIM_HEADERS = YES
+SHOW_INCLUDE_FILES = YES
+JAVADOC_AUTOBRIEF = NO
+INHERIT_DOCS = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+ALIASES =
+ENABLED_SECTIONS = developper
+MAX_INITIALIZER_LINES = 30
+OPTIMIZE_OUTPUT_FOR_C = NO
+SHOW_USED_FILES = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_FORMAT =
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = @srcdir@
+FILE_PATTERNS = MEDMEM*.hxx \
+ MEDMEM*.cxx
+RECURSIVE = NO
+EXCLUDE = CVS
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT =
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = YES
+GENERATE_CHI = YES
+BINARY_TOC = NO
+TOC_EXPAND = YES
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = YES
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT =
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT =
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT =
+MAN_EXTENSION =
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+PERL_PATH =
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HAVE_DOT = YES
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+TEMPLATE_RELATIONS = YES
+HIDE_UNDOC_RELATIONS = YES
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+GRAPHICAL_HIERARCHY = YES
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
+CGI_NAME =
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH =
+EXT_DOC_PATHS =
--- /dev/null
+# Doxyfile 0.1
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = MED
+PROJECT_NUMBER = 1.0
+OUTPUT_DIRECTORY = doc_ref_user
+OUTPUT_LANGUAGE = English
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+BRIEF_MEMBER_DESC = NO
+REPEAT_BRIEF = YES
+ALWAYS_DETAILED_SEC = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = NO
+STRIP_CODE_COMMENTS = YES
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+VERBATIM_HEADERS = NO
+SHOW_INCLUDE_FILES = NO
+JAVADOC_AUTOBRIEF = NO
+INHERIT_DOCS = YES
+INLINE_INFO = NO
+SORT_MEMBER_DOCS = NO
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+ALIASES =
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+OPTIMIZE_OUTPUT_FOR_C = NO
+SHOW_USED_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = @srcdir@
+FILE_PATTERNS = MEDMEM*.hxx \
+ MEDMEM*.cxx
+RECURSIVE = NO
+EXCLUDE = /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_STRING.hxx \
+ /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_MedMeshDriver.cxx \
+ /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_Array.hxx \
+ /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_PointerOf.hxx \
+ /export/home/pgoldb/SALOME_ROOT/MED/src/MEDMEM/MEDMEM_ModulusArray.hxx
+EXCLUDE_PATTERNS = MEDMEM_DriversDef.* \
+ MEDMEM_SkyLineArray.* \
+ MEDMEM_Connectivity.* \
+ MEDMEM_Coordinate.*
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = YES
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HAVE_DOT = YES
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+TEMPLATE_RELATIONS = YES
+HIDE_UNDOC_RELATIONS = YES
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+GRAPHICAL_HIERARCHY = YES
+DOT_PATH = /export/home/LGLS/bin/
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
+CGI_NAME = search.cgi
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH = /usr/local/bin/
+EXT_DOC_PATHS =
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Array.hxx
+// Module : MED
+
#ifndef __MEDARRAY_H__
#define __MEDARRAY_H__
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
+#include "MEDMEM_PointerOf.hxx"
#include "utilities.h"
using namespace MED_EN;
/*!
A template class to generate an array of any particular type (int, long,
- float, double) for our purpose in the MED++ library.
+ float, double) for our purpose in the MED++ library./n/n
+
+ Arrays can be stored in MED_FULL_INTERLACE mode (ie : x1,y1,z1,x2,y2,z2...) or
+ in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn)./n The alternate
+ representation mode is calculate ONLY when it is usefull. We assure coherency
+ for minor data modifications (element, line or column) if you use set methods.
+ But, if you get a pointer and modify the array, no automatical coherency is possible.
+ You can use calculateOther to force a recalculation and insure the coherency./n
+ No recalculation is done, when the entire array is modified./n
+ Theses arrays are "Med like" arrays; lower bound equals 1. (first element is element 1,
+ first coordinate is coordinate 1). /n
+
+ Available constructors are :/n
+
+ - default constructor (not very usefull)/n
+ - constructor asking for array dimensions and mode (does memory allocation for you)/n
+ - constructor asking for array dimensions, mode and values (doesn't do memory allocation
+ but copies pointers only.)/n
+ - a copy constructor which copies only pointers./n
+ (be aware of coherency)
+ - a copy constructor which copies data (deepcopy)./n
+ - assignement operator is also available and only copies pointers (and not data)./n/n
+
+ Attribute "pointers" aren't standard pointers but class PointerOf objects in order to simplify
+ memory management./n
+
+ A simple test program (testUArray) allows to test this class.
*/
-template <class T> class MEDARRAY
-// Class Template MEDARRAY
-// template to generate an array of any
-// particular type (int, long, float, double)
-// for our purpose in the MED++ library
+template <class T> class MEDARRAY
{
private :
- med_int _ld_values ; // leading dimension of value (example : space dimension with coordinates)
- med_int _length_values ; // length of values (example : number of nodes with coordinates)
- medModeSwitch _mode; // data access mode:
- // MED_FULL_INTERLACE (default mode)
- // or MED_NO_INTERLACE
- T * _valuesDefault ; // in _mode representation
- T * _valuesOther ; // in other _mode
+
+ /*! leading dimension of value (example : space dimension for coordinates) */
+ med_int _ldValues;
+ /*! length of values (example : number of nodes for coordinates) */
+ med_int _lengthValues;
+ /*! data access mode. possible values are :\n
+ - MED_FULL_INTERLACE (default mode) \n
+ - MED_NO_INTERLACE */
+ medModeSwitch _mode;
+ /*! Pointer to representation in mode MED_FULL_INTERLACE */
+ PointerOf <T> _valuesFull;
+ /*! Pointer to representation in mode MED_NO_INTERLACE */
+ PointerOf <T> _valuesNo;
+ /*! Pointer to representation in mode _mode */
+ PointerOf <T> _valuesDefault;
+ /*! Pointer to representation in the other mode (!=_mode) */
+ PointerOf <T> _valuesOther;
public :
- MEDARRAY():_ld_values(0),_length_values(0),_mode(MED_FULL_INTERLACE),_valuesDefault((T*)NULL),_valuesOther((T*)NULL)
- {
- };
- ~MEDARRAY()
- {
- if (_valuesDefault)
- delete [] _valuesDefault ;
- if (_valuesOther)
- delete [] _valuesOther ;
- };
-
+ inline MEDARRAY();
+ inline ~MEDARRAY();
+
+ MEDARRAY (const med_int ld_values, const med_int length_values,
+ const medModeSwitch mode=MED_FULL_INTERLACE);
+ MEDARRAY (T* values, const med_int ld_values,
+ const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE);
+ MEDARRAY (MEDARRAY const &m);
+ MEDARRAY (MEDARRAY const &m, bool copyOther);
+ MEDARRAY & operator = (const MEDARRAY & m);
+
+ inline med_int getLeadingValue() const;
+ inline med_int getLengthValue() const;
+
+ const T * get (const medModeSwitch mode) ;
+ const T * getRow (const med_int i) ;
+ const T * getColumn (const med_int j) ;
+ const T getIJ (const med_int i, const med_int j) const;
+// T * const get (const medModeSwitch mode) const;
+// T * const getRow (const med_int i) const;
+// T * const getColumn (const med_int j) const;
+// T const getIJ (const med_int i, const med_int j) const;
+
+ inline medModeSwitch getMode() const;
+
+ void set (const medModeSwitch mode,const T* value);
+ void setI (const med_int i, const T* value);
+ void setJ (const med_int j, const T* value);
+ void setIJ (const med_int i, const med_int j, const T value);
+
+ void calculateOther();
+};
- // the following constructor are for the generation
- // with the default or not _mode
+//-------------------------------------------------//
+// //
+// IMPLEMENTED CODE //
+// //
+//-------------------------------------------------//
- MEDARRAY(const med_int ld_values, const med_int length_values,
- const medModeSwitch mode=MED_FULL_INTERLACE) ;
- MEDARRAY( T*values, const med_int ld_values,
- const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE) ;
+template <class T> inline MEDARRAY<T>::MEDARRAY():
+ _ldValues(0), _lengthValues(0), _mode(MED_FULL_INTERLACE),
+ _valuesFull(), _valuesNo(),
+ _valuesDefault(), _valuesOther()
+{
+};
- inline med_int getLeadingValue() ; // as Space Dimension with coordinates
- inline med_int getLengthValue() ; // as Number of Nodes with coordinates
-
- T * const get(medModeSwitch mode) ;
- T* const getI(medModeSwitch mode,med_int i) ;
- T getIJ(med_int i, med_int j) const ;
+// ------------------
- // need by write, to get default mode !
- inline medModeSwitch getMode() const ;
-
- void set(medModeSwitch mode, T* value);
- void setI(medModeSwitch mode, med_int i, T* value);
- void setIJ(med_int i, med_int j, T value);
-
-private:
- void calculateOther() ;
- void allocateOther();
- void updateDefault();
+template <class T> inline MEDARRAY<T>::~MEDARRAY()
+{
};
+// ------------------
-// implemented code
+ /*! This constructor does allocation and does not set values : \n.
+ It allocates a "T" array of length_values*ld_values length.\n
+ You don't have to know the T values when calling this construtor
+ but you have to call "set" method to initialize them later.
+ You also can get the pointer to the memory zone (with "get" method),
+ and work with it./n
+ The desallocation of T array is not your responsability. \n\n
+ Throws MEDEXCEPTION if T array length is < 1*/
template <class T> MEDARRAY<T>::MEDARRAY(const med_int ld_values,
const med_int length_values,
- const medModeSwitch mode = MED_FULL_INTERLACE): _ld_values(ld_values),_length_values(length_values),_mode(mode),_valuesOther((T*)NULL)
-{
- BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int , const med_int, const medModeSwitch (= MED_FULL_INTERLACE))");
-
- // if could not allocate ?
- if ((ld_values<1)|(length_values<1))
- throw MEDEXCEPTION( LOCALIZED("MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !"));
- _valuesDefault = new T[ld_values*length_values] ;
+ const medModeSwitch mode):
- SCRUTE(_valuesDefault);
+ _ldValues(ld_values),
+ _lengthValues(length_values),
+ _mode(mode),
+ _valuesFull(), _valuesNo(),
+ _valuesDefault(),_valuesOther()
+{
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch)");
- SCRUTE(_valuesOther);
+ // if ld_values < 1 or length_values < 1
+ // throws an exception
+ // Pointers are setted to NULL
- SCRUTE(_ld_values);
+ if ((ld_values<1)|(length_values<1))
+ {
+ throw MEDEXCEPTION(LOCALIZED("MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch) : dimension < 1 !"));
+ }
- SCRUTE(_length_values);
+ if ( _mode == MED_FULL_INTERLACE)
+ {
+ _valuesFull.set(length_values*ld_values);
+ _valuesDefault.set((T*) _valuesFull);
+ }
+ else
+ {
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(length_values*ld_values);
+ _valuesDefault.set((T*)_valuesNo);
+ }
- SCRUTE(_mode);
+ ASSERT( (T*)_valuesDefault != NULL);
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
- END_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int , const med_int, const medModeSwitch (= MED_FULL_INTERLACE))");
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(const med_int, const med_int, const medModeSwitch ()");
}
+// ------------------
+
+ /*! This constructor duplicate T*values.\n
+
+ Throws MEDEXCEPTION if the lenght of T is < 1*/
template <class T> MEDARRAY<T>::MEDARRAY( T*values,
const med_int ld_values,
const med_int length_values,
- const medModeSwitch mode=MED_FULL_INTERLACE): _ld_values(ld_values),_length_values(length_values),_mode(mode),_valuesOther((T*)NULL)
+ const medModeSwitch mode):
+ _ldValues(ld_values),
+ _lengthValues(length_values),
+ _mode(mode),
+ _valuesFull(),_valuesNo(),
+ _valuesDefault(),_valuesOther()
{
- _valuesDefault = values;
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)");
+
+ // if ld_values < 1 or length_values < 1, we could not allocate
+ // throws an exception
+
+ if ( (ld_values<1) | (length_values<1) )
+ {
+ throw MEDEXCEPTION(LOCALIZED("MEDARRAY<T>::MEDARRAY(T* values, const med_int, const medModeSwitch) : dimension < 1 !"));
+ }
+ if ( _mode == MED_FULL_INTERLACE)
+ {
+ _valuesFull.set(_ldValues*length_values,values);
+ _valuesDefault.set((T*)_valuesFull);
+ }
+ else
+ {
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(_ldValues*length_values,values);
+ _valuesDefault.set((T*)_valuesNo);
+ }
+
+ ASSERT( (T*)_valuesDefault != NULL);
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
+
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(T* values, const med_int, const med_int, const medModeSwitch)");
}
-template <class T> inline med_int MEDARRAY<T>::getLeadingValue() {
- return _ld_values ;
-};
-template <class T> inline med_int MEDARRAY<T>::getLengthValue() {
- return _length_values ;
-};
+// ------------------
+
+ /*! This constructor allocates a new medarray and does a copy of pointers/n
+ It DOES NOT copy the memory . The two objects will share the same data./n
+ (for copying data, use constructor MEDARRAY(MEDARRAY<T> const & m,bool copyOther). */
+template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m ):
+ _ldValues(m._ldValues),
+ _lengthValues(m._lengthValues),
+ _mode(m._mode),
+ _valuesFull((const T*)m._valuesFull),
+ _valuesNo((const T*)m._valuesNo),
+ _valuesDefault((const T*)m._valuesDefault),
+ _valuesOther((const T*)m._valuesOther)
+{
+ BEGIN_OF("constructor MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m)");
+ ASSERT( (T*)_valuesDefault != NULL);
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
+ END_OF("constructor MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m)");
+}
-template <class T> T* const MEDARRAY<T>::get(medModeSwitch mode)
+ /*! This constructor allocates a new array and does a copy of values
+ included in the m arrays./n
+ If the boolean is setted to true, both representations (in full mode
+ and no interlace mode) will be copied./n
+ Otherwise, only _valuesDefault will be copied./n
+ Desallocation of the arrays is not your reponsability./n/n
+ Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true*/
+template <class T> MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & p,bool copyOther ):
+ _ldValues(p._ldValues),
+ _lengthValues(p._lengthValues),
+ _mode(p._mode),
+ _valuesDefault(),
+ _valuesNo(),
+ _valuesFull(),
+ _valuesOther()
{
- if (_valuesDefault != NULL)
- if (mode == _mode) {
- return _valuesDefault;
+ BEGIN_OF("Constructeur deepCopy MEDARRAY<T>::MEDARRAY(MEDARRAY<T> const & m,bool copyOther");
+
+ // PG : Non, s'il n'y a rien, on test et on ne copie rien, c'est tout !
+
+// if ( copyOther==true && ((const T*)p._valuesOther==NULL))
+// {
+// throw MEDEXCEPTION("MEDARRAY MEDARRAY const &m,bool copyOther : No Other values defined and bool = true !");
+// }
+
+ if ( _mode == MED_FULL_INTERLACE)
+ {
+ _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull);
+ _valuesDefault.set((T*)_valuesFull);
+ if (copyOther)
+ if ((const T*)p._valuesNo != NULL)
+ {
+ _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo);
+ _valuesOther.set((T*)_valuesNo);
+ }
}
- else {
- calculateOther() ;
- return _valuesOther ;
+ else
+ {
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(p._ldValues*p._lengthValues,(const T*)p._valuesNo);
+ _valuesDefault.set((T*)_valuesNo);
+ if (copyOther)
+ if ((const T*)p._valuesFull != NULL)
+ {
+ _valuesFull.set(p._ldValues*p._lengthValues,(const T*)p._valuesFull);
+ _valuesOther.set((T*)_valuesFull);
+ }
}
- throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !");
}
-template <class T> T* const MEDARRAY<T>::getI(medModeSwitch mode,med_int i)
+// ------------------
+
+// /*! This operator does a copy of pointers/n
+// It DOES NOT copy of the memory.
+// The two objects will share data./n */
+
+template <class T> MEDARRAY<T> & MEDARRAY<T>::MEDARRAY::operator = (const MEDARRAY & m)
{
- // 1<=i<=_length_values and return an array of _ld_values length
- // if MED_FULL_INTERLACE
- // 1<=i<=_ld_values and return an array of _length_values length
- // if MED_NO_INTERLACE
-
- if (_valuesDefault != NULL) {
- // if mode = MED_FULL_INTERLACE :
- int first = _ld_values ;
- int second = _length_values;
- // else :
- if (mode == MED_NO_INTERLACE) {
- first = _length_values ;
- second = _ld_values ;
- }
- if (i<=0)
- throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be > 0");
- if (i>second)
- throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : argument i must be <= second");
- if (mode == _mode)
- return _valuesDefault + (i-1)*first ;
- else {
- calculateOther() ;
- return _valuesOther + (i-1)*first ;
- // return _valuesOther + (i-1)*second ;
- }
+
+ BEGIN_OF("Operator = MEDARRAY<T>");
+
+ _ldValues=m._ldValues;
+ _lengthValues=m._lengthValues;
+ _mode=m._mode;
+
+ SCRUTE(_mode);
+
+ if ((const T*) m._valuesFull !=NULL)
+ _valuesFull.set(_ldValues*_lengthValues,(const T*) m._valuesFull);
+
+ if ((const T*) m._valuesNo !=NULL)
+ _valuesNo.set(_ldValues*_lengthValues,(const T*) m._valuesNo);
+
+ if (_mode == MED_FULL_INTERLACE) {
+ //PN : pour enlever les warning compilateur
+ //_valuesDefault.set((const T*) _valuesFull);
+ //_valuesOther.set((const T*) _valuesNo);
+ _valuesDefault.set((T*) _valuesFull);
+ _valuesOther.set((T*) _valuesNo);
+ } else {
+ ASSERT (_mode == MED_NO_INTERLACE);
+ //PN : pour enlever les warning compilateur
+ //_valuesDefault.set((const T*) _valuesNo);
+ //_valuesOther.set((const T*) _valuesFull);
+ _valuesDefault.set((T*) _valuesNo);
+ _valuesOther.set((T*) _valuesFull);
}
- throw MEDEXCEPTION("MEDARRAY::getI(mode,i) : No values defined !");
+
+ SCRUTE((T*)_valuesDefault);
+ SCRUTE((T*)_valuesOther);
+ SCRUTE((T*)_valuesNo);
+ SCRUTE((T*)_valuesFull);
+
+ END_OF("Operator = MEDARRAY<T>");
+ return *this;
}
+// ------------------
-template <class T> T MEDARRAY<T>::getIJ(med_int i, med_int j) const
+ /*! returns _ldValues. (for example, space dimension for coordinates array)*/
+template <class T> inline med_int MEDARRAY<T>::getLeadingValue() const
{
- // 1<=i<=_length_values and 1<j<_ld_values
-
- if (i<1)
- throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1");
- if (i>_length_values)
- throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _length_values");
-
- if (j<1)
- throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1");
- if (j>_ld_values)
- throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ld_values");
-
- if (_valuesDefault != NULL) {
- switch (_mode)
- {
- case MED_FULL_INTERLACE :
- {
- return _valuesDefault[(i-1)*_ld_values+j-1];
- }
- case MED_NO_INTERLACE :
+ return _ldValues;
+};
+
+// ------------------
+
+ /*! returns _ldValues. (for example, number of nodes for coordinates array)*/
+template <class T> inline med_int MEDARRAY<T>::getLengthValue() const
+{
+ return _lengthValues;
+};
+
+// ------------------
+
+ /*! returns a pointer to _valuesDefault or _valuesOther, depending on
+ mode value : if mode is the same as _mode, _valuesDefault is returned.
+ else, if _valuesOther is calculated (if necessary) and then returned.
+ The pointer can be used to set values */
+template <class T> const T* MEDARRAY<T>::get(const medModeSwitch mode)
+{
+ BEGIN_OF("MEDARRAY<T>::get(const medModeSwitch mode)");
+ if ((T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::get(mode) : No values defined !");
+ }
+ if (mode == _mode)
+ {
+ //PN : pour enlever les warning compilateurs
+ //return (const T*)_valuesDefault;
+ return (T*) _valuesDefault;
+ }
+ else
+ {
+ if ((T*)_valuesOther == NULL)
{
- return _valuesDefault[(j-1)*_length_values+i-1];
+ calculateOther();
}
- }
- } else
- throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !");
+ //PN : pour enlever les warning compilateurs
+ //return (const T*)_valuesDefault;
+ return (T*) _valuesOther;
+ }
+ END_OF("MEDARRAY<T>::get(const medModeSwitch mode)");
}
-template <class T> inline medModeSwitch MEDARRAY<T>::getMode() const
+// ------------------
+
+ /*! returns a pointer to ith element of the array.
+ (ith line in a MED_FULL_INTERLACE representation )/n
+ Be aware : if _mode is MED_NO_INTERLACE, the entire
+ array will be recalculate in MED_FULL_INTERLACE representation./n*/
+
+template <class T> const T* MEDARRAY<T>::getRow(const med_int i)
{
- return _mode ;
+
+ BEGIN_OF("MEDARRAY<T>::getRow(const med_int i)");
+
+ if ((T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getRow(i) : No values defined !");
+ }
+ if (i<1)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be >= 1");
+ }
+ if (i>_lengthValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getRow(i) : argument i must be <= _lengthValues");
+ }
+
+ if ((T*)_valuesFull == NULL)
+ {
+ ASSERT(((T*) _valuesDefault)==((T*) _valuesNo));
+ calculateOther();
+ }
+ ASSERT((T*)_valuesFull != NULL);
+
+ // PN pour enlever les warning compilateurs
+ //const T* ptr = (const T*)_valuesFull + (i-1)*_ldValues;
+ const T* ptr = (T*) _valuesFull + (i-1)*_ldValues;
+
+ END_OF("MEDARRAY<T>::getRow(const med_int i )");
+ return ptr;
+}
+// ------------------
+
+ /*! this method is similar to getRow method./n
+ It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation
+ (for example, 2nd coordinates)./n
+ Be aware : if _mode is MED_FULL_INTERLACE, the entire
+ array will be recalculate in MED_NO_INTERLACE representation./n*/
+
+template <class T> const T* MEDARRAY<T>::getColumn(const med_int j)
+{
+ BEGIN_OF("MEDARRAY<T>::getColumn(const med_int j)");
+ if ((T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getColumn(j) : No values defined !");
+ }
+ if (j<1)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be >= 1");
+ }
+ if (j>_ldValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getColumn(j) : argument j must be <= _ldValues");
+ }
+
+ if ((T*)_valuesNo == NULL)
+ {
+ ASSERT(((T*) _valuesDefault)==((T*) _valuesFull));
+ calculateOther();
+ }
+ //PN pour enlever les warning compilateur
+ //const T* ptr = (const T*)_valuesNo + (j-1)*_lengthValues;
+ const T* ptr = ( T*)_valuesNo + (j-1)*_lengthValues;
+
+ return ptr;
}
-template <class T> void MEDARRAY<T>::set(medModeSwitch mode, T* value)
+// ------------------
+
+ /*! returns Jth value of Ith element .\n
+ don't forget first element is element 1 (and not element 0). */
+template <class T> const T MEDARRAY<T>::getIJ(const med_int i,const med_int j) const
{
+ BEGIN_OF("MEDARRAY<T>::getIJ(const med_int i, const med_int j)");
+ if (i<1)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be >= 1");
+ }
+ if (i>_lengthValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument i must be <= _lengthValues");
+ }
+ if (j<1)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be >= 1");
+ }
+ if (j>_ldValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : argument j must be <= _ldValues");
+ }
- BEGIN_OF("MEDARRAY<T>::set(mode,i,value)");
+ if ( (const T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::getIJ(i,j) : No value in array !");
+ }
- _mode = mode ;
+ if (_mode == MED_FULL_INTERLACE)
+ {
+ return _valuesDefault[(i-1)*_ldValues+j-1];
+ }
+ else
+ {
+ return _valuesDefault[(j-1)*_lengthValues+i-1];
+ }
+ END_OF("MEDARRAY<T>::getIJ(const med_int i, const med_int j)");
+}
- SCRUTE(_ld_values);
- SCRUTE(_length_values);
- SCRUTE(_valuesDefault);
- SCRUTE(_valuesOther);
- SCRUTE(_mode);
- SCRUTE(mode);
- SCRUTE(value);
-
- if (_valuesDefault != NULL)
- if (mode == _mode) {
- _valuesDefault = value ;
- if (_valuesOther != NULL) calculateOther() ;
- // if (_valuesOther != NULL) _valuesOther = value;
+// ------------------
+
+ /*! returns the default mode (_mode)/n
+ (internal use : needed by write method) */
+template <class T> inline medModeSwitch MEDARRAY<T>::getMode() const
+{
+ BEGIN_OF("MEDARRAY<T>::getMode()");
+ END_OF("MEDARRAY<T>::getMode()");
+ return _mode;
+}
+
+// ------------------
+
+ /*! sets T pointer of _valuesDefault (cf class PointerOf) on value.\n
+ no copy of value is done. \n
+ the other representation mode is not recalculate.
+ the corresponding pointers are setted to null */
+// template <class T> void MEDARRAY<T>::set(const medModeSwitch mode, const T* value)
+// {
+
+// BEGIN_OF("MEDARRAY<T>::set(mode,value)");
+
+// _mode = mode;
+// if ( _mode == MED_FULL_INTERLACE)
+// {
+// _valuesFull.set(value);
+// _valuesDefault.set((T*)_valuesFull);
+// _valuesNo.set(0);
+// }
+// else
+// {
+// ASSERT (_mode == MED_NO_INTERLACE);
+// _valuesNo.set(value);
+// _valuesDefault.set((T*)_valuesNo);
+// _valuesFull.set(0);
+// }
+// _valuesOther.set(0);
+// END_OF("MEDARRAY<T>::set(mode,i,value)");
+// }
+
+// set with duplication because we don't know were value come and
+// MEDARRAY must have properties on it !!!!
+template <class T> void MEDARRAY<T>::set(const medModeSwitch mode, const T* value)
+{
+ BEGIN_OF("MEDARRAY<T>::set(mode,value)");
+
+ _mode = mode;
+ if ( _mode == MED_FULL_INTERLACE)
+ {
+ _valuesFull.set(_ldValues*_lengthValues,value);
+ _valuesDefault.set((T*)_valuesFull);
+ _valuesNo.set(0);
}
- else {
- allocateOther() ;
- _valuesOther = value ;
- updateDefault() ;
+ else
+ {
+ ASSERT (_mode == MED_NO_INTERLACE);
+ _valuesNo.set(_ldValues*_lengthValues,value);
+ _valuesDefault.set((T*)_valuesNo);
+ _valuesFull.set(0);
}
- else throw MEDEXCEPTION("MEDARRAY::set(mode,value) : No values defined !");
+ _valuesOther.set(0);
END_OF("MEDARRAY<T>::set(mode,i,value)");
}
-template <class T> void MEDARRAY<T>::setI(medModeSwitch mode, med_int i, T* value)
+
+
+// ------------------
+
+ /*! Sets ith element to T* values\n
+ if they both exist, both _valuesFull and _valuesNo arrays will be updated./n
+ Throws exception if i < 1 or i > _lengthValues */
+template <class T> void MEDARRAY<T>::setI(const med_int i, const T* value)
{
- BEGIN_OF("MEDARRAY<T>::setI(mode,i,value)");
+ BEGIN_OF("MEDARRAY<T>::setI(i,value)");
- _mode = mode ;
+ if ((T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setI(i,value) : No values defined !");
+ }
+ if (i<=0)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be > 0");
+ }
+ if ( i > _lengthValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setI(i,value) : argument i must be <= _lenghtValues");
+ }
- SCRUTE(i);
- SCRUTE(_ld_values);
- SCRUTE(_length_values);
- SCRUTE(_valuesDefault);
- SCRUTE(_valuesOther);
- SCRUTE(_mode);
- SCRUTE(mode);
-
- // 1<=i<=_length_values and return an array of _ld_values length
- // if MED_FULL_INTERLACE
- // 1<=i<=_ld_values and return an array of _length_values length
- // if MED_NO_INTERLACE
-
- if (_valuesDefault != NULL) {
- // if mode = MED_FULL_INTERLACE :
- int first = _ld_values ;
- int second = _length_values;
- // else :
- if (mode == MED_NO_INTERLACE) {
- first = _length_values ;
- second = _ld_values ;
- }
- SCRUTE(second);
- if (i<=0)
- throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be > 0");
- if (i>second) {
- SCRUTE(i);
- SCRUTE(second);
- throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : argument i must be <= second");}
- if (mode == _mode)
- {
- // _valuesDefault + (i-1)*first = value ;
- for (int k =0;k<first;k++)
- // _valuesDefault[(i-1)*second+k] = value[k];
- (_valuesDefault + (i-1)*first)[k] = value[k];
- if (_valuesOther != NULL)
- for (int k =0;k<first;k++) {
- _valuesOther[k*second+i-1] = value[k];
- }
- }
- else
- {
- allocateOther() ;
- // return _valuesOther + (i-1)*first = &value ;
- for (int k =0;k<second;k++) {
- _valuesOther[(i-1)*first+k-1] = value[k];
- _valuesDefault[k*second+i-1] = value[k];
- }
- }
+ if ((T*)_valuesFull != NULL)
+ {
+ for (int k = 0;k<_ldValues;k++)
+ {
+ _valuesFull[k+_ldValues*(i-1)] = value[k];
+ }
+ }
+
+ if ((T*)_valuesNo != NULL)
+ {
+ for (int k = 0;k<_ldValues;k++)
+ {
+ _valuesNo[k*_lengthValues +(i-1)] = value[k];
+ }
}
- else throw MEDEXCEPTION("MEDARRAY::setI(mode,i,value) : No values defined !");
- SCRUTE(_valuesDefault);
- SCRUTE( _valuesOther);
+ END_OF("MEDARRAY::setI(i,value)");
+}
+// ------------------
+
+ /*! Sets ith element to T* values\n
+ if they both exist, both _valuesFull and _valuesNo arrays will be updated./n
+ Throws exception if i < 1 or i > _lengthValues */
+template <class T> void MEDARRAY<T>::setJ(const med_int j, const T* value)
+{
+ BEGIN_OF("MEDARRAY::setJ(j,value)");
+ if (( T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setJ(j) : No values defined !");
+ }
+ if (j<1)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be >= 1");
+ }
+ if (j>_ldValues)
+ {
+ throw MEDEXCEPTION("MEDARRAY::setJ(j) : argument j must be <= _ldValues");
+ }
+ if ((T*)_valuesFull != NULL)
+ {
+ for (int k = 0;k<_lengthValues;k++)
+ {
+ _valuesFull[k*_ldValues+(j-1)] = value[k];
+ }
+ }
- END_OF("MEDARRAY::setI(mode,i,value)");
+ if ((T*)_valuesNo != NULL)
+ {
+ for (int k = 0;k<_lengthValues;k++)
+ {
+ _valuesNo[k+_lengthValues*(j-1)] = value[k];
+ }
+ }
+ END_OF("MEDARRAY::setJ(j,value)");
}
-template <class T> void MEDARRAY<T>::setIJ(med_int i, med_int j, T value)
+// ------------------
+
+ /*! Sets value of Jth coordinate of Ith element to T value./n
+ Maintains coherency./n
+ Throws exception if we don't have
+ 1<=i<=_lengthValues and 1<=j<=_ldValues */
+template <class T> void MEDARRAY<T>::setIJ(const med_int i, const med_int j, const T value)
{
- // 1<=i<=_length_values and 1<j<_ld_values
+ // 1<=i<=_lengthValues and 1<=j<=_ldValues
- if (i<1)
+ if (i<1)
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be >= 1");
- if (i>_length_values)
- throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _length_values");
+ if (i>_lengthValues)
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument i must be <= _lengthValues");
- if (j<1)
+ if (j<1)
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be >= 1");
- if (j>_ld_values)
- throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ld_values");
+ if (j>_ldValues)
+ throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : argument j must be <= _ldValues");
- if (_valuesDefault != NULL) {
- switch (_mode)
- {
- case MED_FULL_INTERLACE :
- {
- _valuesDefault[(i-1)*_ld_values+j-1] = value;
- break;
- }
- case MED_NO_INTERLACE :
- {
- _valuesDefault[(j-1)*_length_values+i-1] = value;
- break;
- }
- }
- } else
+ if ((T*)_valuesDefault == NULL)
+ {
throw MEDEXCEPTION("MEDARRAY::setIJ(i,j,value) : No value in array !");
-}
-
-template <class T> void MEDARRAY<T>::calculateOther()
-{
- if (_valuesDefault != NULL) {
- //we allocate _valuesOther if needed
- if (_valuesOther == NULL) _valuesOther = new T[_ld_values*_length_values] ;
- // we set _valuesOther
- // if mode = MED_FULL_INTERLACE :
- int first = _ld_values ;
- int second = _length_values;
- // else :
- if (_mode == MED_NO_INTERLACE) {
- first = _length_values ;
- second = _ld_values;
- }
+ }
- for (int i=0; i<first;i++)
- for (int j=0; j<second; j++)
- _valuesOther[i*second+j] = _valuesDefault[j*first+i];
+ if ((T*)_valuesFull != NULL)
+ {
+ _valuesFull[j-1+_ldValues*(i-1)] = value;
+ }
+ if ((T*)_valuesNo != NULL)
+ {
+ _valuesNo[(j-1)*_lengthValues+i-1] = value;
}
- else
- throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !");
}
-template <class T> void MEDARRAY<T>::allocateOther()
+ /*! Calculates the other mode of representation : MED_FULL_INTERLACE
+ if __mode = MED_NO_INTERLACE and vice versa./n
+ Throws exception if no value are setted */
+template <class T> void MEDARRAY<T>::calculateOther()
{
- if (_valuesDefault != NULL) {
- if (_valuesOther == NULL) {
- // we set _valuesOther
- _valuesOther = new T[_ld_values*_length_values] ;
- }
+ BEGIN_OF("MEDARRAY<T>::calculateOther()");
+ if ((T*)_valuesDefault == NULL)
+ {
+ throw MEDEXCEPTION("MEDARRAY::calculateOther() : No values defined !");
}
- else
- throw MEDEXCEPTION("MEDARRAY::allocateOther() : No values defined !");
-}
-template <class T> void MEDARRAY<T>::updateDefault()
-{
- BEGIN_OF("MEDARRAY<T>::updateDefault()");
-
- if (_valuesDefault != NULL) {
- if (_valuesOther != NULL) {
- // we update _valuesDefault with _valuesOther
- // if mode = MED_FULL_INTERLACE :
- int first = _ld_values ;
- int second = _length_values;
- // else :
- if (_mode == MED_NO_INTERLACE) {
- first = _length_values ;
- second = _ld_values;
- }
- for (int i=0; i<first;i++)
- for (int j=0; j<second; j++)
- _valuesDefault[j*first+i] = _valuesOther[i*second+j];
- }
- else
- throw MEDEXCEPTION("MEDARRAY<T>::updateDefault() : No valuesOther defined !");
+ if ((T*)_valuesOther == NULL)
+ {
+ _valuesOther.set(_ldValues*_lengthValues);
+ }
+ if (_mode == MED_NO_INTERLACE)
+ {
+ _valuesFull.set((T*)_valuesOther);
}
else
- throw MEDEXCEPTION("MEDARRAY<T>::updateDefault() : No values defined !");
+ {
+ ASSERT( _mode==MED_FULL_INTERLACE);
+ _valuesNo.set((T*)_valuesOther);
+ }
- END_OF("MEDARRAY<T>::updateDefault()");
+ for (int i=0; i<_lengthValues;i++)
+ {
+ for (int j=0; j<_ldValues; j++)
+ {
+ if (_mode == MED_NO_INTERLACE)
+ {
+ _valuesFull[i*_ldValues+j] = _valuesNo[j*_lengthValues+i];
+ }
+ else
+ {
+ _valuesNo[j*_lengthValues+i]=_valuesFull[i*_ldValues+j];
+ }
+ }
+ }
+ END_OF("MEDARRAY<T>::calculateOther()");
}
# endif /* # ifndef __MEDARRAY_H__ */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_CellModel.cxx
+// Module : MED
+
+using namespace std;
/*
File MEDMEM_CellModel.cxx
$Header$
CELLMODEL::CELLMODEL(medGeometryElement t)
{
+ // init first all to nothing
+ _dimension=0 ;
+ _numberOfNodes=0 ;
+ _numberOfVertexes=0 ;
+ _numberOfConstituentsDimension=0 ;
+ _numberOfConstituents=(int*)NULL ;
+ _numberOfNodeOfEachConstituent=(int**)NULL ;
+ _constituents=(int***)NULL ;
+ //_numberOfonstituentsType=(int*)NULL ;
+ _constituentsType=(medGeometryElement**)NULL ;
+
MESSAGE("CELLMODEL : constructeur pour le type " << t);
switch (t)
{
_numberOfVertexes=2;
_numberOfNodes=2;
// constituent are POINT1 and we have no need to define _constituents vector
- vector<medGeometryElement> vector_type(2,MED_POINT1) ;
- vector<medGeometryElement> __constituents_type[]={vector_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+1) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=1 ;
+ _numberOfConstituents=new int[1] ;
+ _numberOfConstituents[0]=2 ;
+ _numberOfNodeOfEachConstituent=new (int*)[1] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[2] ;
+ _numberOfNodeOfEachConstituent[0][0]=1 ;
+ _numberOfNodeOfEachConstituent[0][1]=1 ;
+
+ _constituents = new (int**)[1] ;
+ _constituents[0] = new (int*)[2] ;
+ _constituents[0][0] = new int[1] ;
+ _constituents[0][0][0] = 1 ;
+ _constituents[0][1] = new int[1] ;
+ _constituents[0][1][0] = 2 ;
+
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[2] ;
+ tmpConstituentsType1[0] = MED_POINT1 ;
+ tmpConstituentsType1[1] = MED_POINT1 ;
+ _constituentsType = new medGeometryElement*[1] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
break;
}
case MED_SEG3 : {
_numberOfVertexes=2;
_numberOfNodes=3;
// constituent are POINT1 and we have no need to define _constituents vector
- vector<medGeometryElement> vector_type(3,MED_POINT1) ;
- vector<medGeometryElement> __constituents_type[]={vector_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+1) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=1 ;
+ _numberOfConstituents=new int[1] ;
+ _numberOfConstituents[0]=3 ;
+ _numberOfNodeOfEachConstituent=new (int*)[1] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[3] ;
+ _numberOfNodeOfEachConstituent[0][0]=1 ;
+ _numberOfNodeOfEachConstituent[0][1]=1 ;
+ _numberOfNodeOfEachConstituent[0][2]=1 ;
+
+ _constituents = new (int**)[1] ;
+ _constituents[0] = new (int*)[3] ;
+ _constituents[0][0] = new int[1] ;
+ _constituents[0][0][0] = 1 ;
+ _constituents[0][1] = new int[1] ;
+ _constituents[0][1][0] = 2 ;
+ _constituents[0][2] = new int[1] ;
+ _constituents[0][2][0] = 3 ;
+
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ;
+ tmpConstituentsType1[0] = MED_POINT1 ;
+ tmpConstituentsType1[1] = MED_POINT1 ;
+ tmpConstituentsType1[2] = MED_POINT1 ;
+ _constituentsType = new medGeometryElement*[1] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
break;
}
case MED_TRIA3 : {
_dimension=2;
_numberOfVertexes=3;
_numberOfNodes=3;
- int _edge1[]={1,2} ;
- int _edge2[]={2,3} ;
- int _edge3[]={3,1} ;
- vector<int> edge1(_edge1,_edge1+2) ;
- vector<int> edge2(_edge2,_edge2+2) ;
- vector<int> edge3(_edge3,_edge3+2) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+3) ;
- vector< vector<int> > __constituents__[]={vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(3,MED_SEG2) ;
- vector<medGeometryElement> vector_type(3,MED_POINT1) ;
- vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+
+ _numberOfConstituentsDimension=1 ;
+ _numberOfConstituents=new int[1] ;
+ _numberOfConstituents[0]=3 ;
+ _numberOfNodeOfEachConstituent=new (int*)[1] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[3] ;
+ _numberOfNodeOfEachConstituent[0][0]=2 ;
+ _numberOfNodeOfEachConstituent[0][1]=2 ;
+ _numberOfNodeOfEachConstituent[0][2]=2 ;
+
+ int* _edge1=new int[2];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ int* _edge2=new int[2];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ int* _edge3=new int[2];
+ _edge3[0]=3;
+ _edge3[1]=1;
+ int ** tmpConstituents1 = new (int*)[3];
+ tmpConstituents1[0]=_edge1 ;
+ tmpConstituents1[1]=_edge2 ;
+ tmpConstituents1[2]=_edge3 ;
+ _constituents = new int**[1] ;
+ _constituents[0]=tmpConstituents1 ;
+
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ;
+ tmpConstituentsType1[0] = MED_SEG2 ;
+ tmpConstituentsType1[1] = MED_SEG2 ;
+ tmpConstituentsType1[2] = MED_SEG2 ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[3] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
+ // Well, point are defined, but could not be acces because we have
+ // only 1 numberOfConstituentsDimension !
+
break;
}
case MED_TRIA6 : {
_dimension=2;
_numberOfVertexes=3;
_numberOfNodes=6;
- int _edge1[]={1,2,4} ;
- int _edge2[]={2,3,5} ;
- int _edge3[]={3,1,6} ;
- vector<int> edge1(_edge1,_edge1+3) ;
- vector<int> edge2(_edge2,_edge2+3) ;
- vector<int> edge3(_edge3,_edge3+3) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+3) ;
- vector< vector<int> > __constituents__[]={vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(3,MED_SEG3) ;
- vector<medGeometryElement> vector_type(6,MED_POINT1) ;
- vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=1 ;
+ _numberOfConstituents=new int[1] ;
+ _numberOfConstituents[0]=3 ;
+ _numberOfNodeOfEachConstituent=new (int*)[1] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[3] ;
+ _numberOfNodeOfEachConstituent[0][0]=3 ;
+ _numberOfNodeOfEachConstituent[0][1]=3 ;
+ _numberOfNodeOfEachConstituent[0][2]=3 ;
+
+ int* _edge1=new int[3];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ _edge1[2]=4;
+ int* _edge2=new int[3];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ _edge2[2]=5;
+ int* _edge3=new int[3];
+ _edge3[0]=3;
+ _edge3[1]=1;
+ _edge3[2]=6;
+ int ** tmpConstituents1 = new (int*)[3];
+ tmpConstituents1[0]=_edge1 ;
+ tmpConstituents1[1]=_edge2 ;
+ tmpConstituents1[2]=_edge3 ;
+ _constituents = new int**[1] ;
+ _constituents[0]=tmpConstituents1 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[3] ;
+ tmpConstituentsType1[0] = MED_SEG3 ;
+ tmpConstituentsType1[1] = MED_SEG3 ;
+ tmpConstituentsType1[2] = MED_SEG3 ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// tmpConstituentsType2[3] = MED_POINT1 ;
+// tmpConstituentsType2[4] = MED_POINT1 ;
+// tmpConstituentsType2[5] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
+ // Well, point are defined, but could not be acces because we have
+ // only 1 numberOfConstituentsDimension !
+
break;
}
case MED_QUAD4 : {
_dimension=2;
_numberOfVertexes=4;
_numberOfNodes=4;
- int _edge1[]={1,2} ;
- int _edge2[]={2,3} ;
- int _edge3[]={3,4} ;
- int _edge4[]={4,1} ;
- vector<int> edge1(_edge1,_edge1+2) ;
- vector<int> edge2(_edge2,_edge2+2) ;
- vector<int> edge3(_edge3,_edge3+2) ;
- vector<int> edge4(_edge4,_edge4+2) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+4) ;
- vector< vector<int> > __constituents__[]={vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(4,MED_SEG2) ;
- vector<medGeometryElement> vector_type(4,MED_POINT1) ;
- vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=1 ;
+ _numberOfConstituents=new int[1] ;
+ _numberOfConstituents[0]=4 ;
+ _numberOfNodeOfEachConstituent=new (int*)[1] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent[0][0]=2 ;
+ _numberOfNodeOfEachConstituent[0][1]=2 ;
+ _numberOfNodeOfEachConstituent[0][2]=2 ;
+ _numberOfNodeOfEachConstituent[0][3]=2 ;
+
+ int* _edge1=new int[2];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ int* _edge2=new int[2];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ int* _edge3=new int[2];
+ _edge3[0]=3;
+ _edge3[1]=4;
+ int* _edge4=new int[2];
+ _edge4[0]=4;
+ _edge4[1]=1;
+ int ** tmpConstituents1 = new (int*)[4];
+ tmpConstituents1[0]=_edge1 ;
+ tmpConstituents1[1]=_edge2 ;
+ tmpConstituents1[2]=_edge3 ;
+ tmpConstituents1[3]=_edge4 ;
+ _constituents = new int**[1] ;
+ _constituents[0]=tmpConstituents1 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
+ tmpConstituentsType1[0] = MED_SEG2 ;
+ tmpConstituentsType1[1] = MED_SEG2 ;
+ tmpConstituentsType1[2] = MED_SEG2 ;
+ tmpConstituentsType1[3] = MED_SEG2 ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[4] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// tmpConstituentsType2[3] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
+ // Well, point are defined, but could not be acces because we have
+ // only 1 numberOfConstituentsDimension !
+
break;
}
case MED_QUAD8 : {
_dimension=2;
_numberOfVertexes=4;
_numberOfNodes=8;
- int _edge1[]={1,2,5} ;
- int _edge2[]={2,3,6} ;
- int _edge3[]={3,4,7} ;
- int _edge4[]={4,1,8} ;
- vector<int> edge1(_edge1,_edge1+3) ;
- vector<int> edge2(_edge2,_edge2+3) ;
- vector<int> edge3(_edge3,_edge3+3) ;
- vector<int> edge4(_edge4,_edge4+3) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+4) ;
- vector< vector<int> > __constituents__[]={vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+1) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(4,MED_SEG3) ;
- vector<medGeometryElement> vector_type(8,MED_POINT1) ;
- vector<medGeometryElement> __constituents_type[]={vector_edge_type,vector_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=1 ;
+ _numberOfConstituents=new int[1] ;
+ _numberOfConstituents[0]=4 ;
+ _numberOfNodeOfEachConstituent=new (int*)[1] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent[0][0]=3 ;
+ _numberOfNodeOfEachConstituent[0][1]=3 ;
+ _numberOfNodeOfEachConstituent[0][2]=3 ;
+ _numberOfNodeOfEachConstituent[0][3]=3 ;
+
+ int* _edge1=new int[3];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ _edge1[2]=5;
+ int* _edge2=new int[3];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ _edge2[2]=6;
+ int* _edge3=new int[3];
+ _edge3[0]=3;
+ _edge3[1]=4;
+ _edge3[2]=7;
+ int* _edge4=new int[3];
+ _edge4[0]=4;
+ _edge4[1]=1;
+ _edge4[2]=8;
+ int ** tmpConstituents1 = new (int*)[4];
+ tmpConstituents1[0]=_edge1 ;
+ tmpConstituents1[1]=_edge2 ;
+ tmpConstituents1[2]=_edge3 ;
+ tmpConstituents1[3]=_edge4 ;
+ _constituents = new int**[1] ;
+ _constituents[0]=tmpConstituents1 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
+ tmpConstituentsType1[0] = MED_SEG3 ;
+ tmpConstituentsType1[1] = MED_SEG3 ;
+ tmpConstituentsType1[2] = MED_SEG3 ;
+ tmpConstituentsType1[3] = MED_SEG3 ;
+// medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ;
+// tmpConstituentsType2[0] = MED_POINT1 ;
+// tmpConstituentsType2[1] = MED_POINT1 ;
+// tmpConstituentsType2[2] = MED_POINT1 ;
+// tmpConstituentsType2[3] = MED_POINT1 ;
+// tmpConstituentsType2[4] = MED_POINT1 ;
+// tmpConstituentsType2[5] = MED_POINT1 ;
+// tmpConstituentsType2[6] = MED_POINT1 ;
+// tmpConstituentsType2[7] = MED_POINT1 ;
+// _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType = new medGeometryElement*[1] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+// _constituentsType[1]=tmpConstituentsType2 ;
+ // Well, point are defined, but could not be acces because we have
+ // only 1 numberOfConstituentsDimension !
+
break;
}
case MED_TETRA4 : {
_dimension=3;
_numberOfVertexes=4;
_numberOfNodes=4;
- int _edge1[]={1,2} ;
- int _edge2[]={2,3} ;
- int _edge3[]={3,1} ;
- int _edge4[]={1,4} ;
- int _edge5[]={2,4} ;
- int _edge6[]={3,4} ;
- vector<int> edge1(_edge1,_edge1+2) ;
- vector<int> edge2(_edge2,_edge2+2) ;
- vector<int> edge3(_edge3,_edge3+2) ;
- vector<int> edge4(_edge4,_edge4+2) ;
- vector<int> edge5(_edge5,_edge5+2) ;
- vector<int> edge6(_edge6,_edge6+2) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+6) ;
- int _face1[]={1,2,3} ;
- int _face2[]={1,4,2} ;
- int _face3[]={2,4,3} ;
- int _face4[]={3,4,1} ;
- vector<int> face1(_face1,_face1+3) ;
- vector<int> face2(_face2,_face2+3) ;
- vector<int> face3(_face3,_face3+3) ;
- vector<int> face4(_face4,_face4+3) ;
- vector<int> _vector_face[] = {face1,face2,face3,face4} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+4) ;
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(6,MED_SEG2) ;
- vector<medGeometryElement> vector_face_type(4,MED_TRIA3) ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=4 ;
+ _numberOfConstituents[1]=6 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent[0][0]=3 ;
+ _numberOfNodeOfEachConstituent[0][1]=3 ;
+ _numberOfNodeOfEachConstituent[0][2]=3 ;
+ _numberOfNodeOfEachConstituent[0][3]=3 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent[1][0]=2 ;
+ _numberOfNodeOfEachConstituent[1][1]=2 ;
+ _numberOfNodeOfEachConstituent[1][2]=2 ;
+ _numberOfNodeOfEachConstituent[1][3]=2 ;
+ _numberOfNodeOfEachConstituent[1][4]=2 ;
+ _numberOfNodeOfEachConstituent[1][5]=2 ;
+
+ int* _face1=new int[3];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ int* _face2=new int[3];
+ _face2[0]=1;
+ _face2[1]=4;
+ _face2[2]=2;
+ int* _face3=new int[3];
+ _face3[0]=2;
+ _face3[1]=4;
+ _face3[2]=3;
+ int* _face4=new int[3];
+ _face4[0]=3;
+ _face4[1]=4;
+ _face4[2]=1;
+ int* _edge1=new int[2];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ int* _edge2=new int[2];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ int* _edge3=new int[2];
+ _edge3[0]=3;
+ _edge3[1]=1;
+ int* _edge4=new int[2];
+ _edge4[0]=1;
+ _edge4[1]=4;
+ int* _edge5=new int[2];
+ _edge5[0]=2;
+ _edge5[1]=4;
+ int* _edge6=new int[2];
+ _edge6[0]=3;
+ _edge6[1]=4;
+ int ** tmpConstituents1 = new (int*)[4];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ int ** tmpConstituents2 = new (int*)[6];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
+ tmpConstituentsType1[0] = MED_TRIA3 ;
+ tmpConstituentsType1[1] = MED_TRIA3 ;
+ tmpConstituentsType1[2] = MED_TRIA3 ;
+ tmpConstituentsType1[3] = MED_TRIA3 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ;
+ tmpConstituentsType2[0] = MED_SEG2 ;
+ tmpConstituentsType2[1] = MED_SEG2 ;
+ tmpConstituentsType2[2] = MED_SEG2 ;
+ tmpConstituentsType2[3] = MED_SEG2 ;
+ tmpConstituentsType2[4] = MED_SEG2 ;
+ tmpConstituentsType2[5] = MED_SEG2 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
case MED_TETRA10 : {
_dimension=3;
_numberOfVertexes=4;
_numberOfNodes=10;
- int _edge1[]={1,2,5} ;
- int _edge2[]={2,3,6} ;
- int _edge3[]={3,1,7} ;
- int _edge4[]={1,4,8} ;
- int _edge5[]={2,4,9} ;
- int _edge6[]={3,4,10} ;
- vector<int> edge1(_edge1,_edge1+3) ;
- vector<int> edge2(_edge2,_edge2+3) ;
- vector<int> edge3(_edge3,_edge3+3) ;
- vector<int> edge4(_edge4,_edge4+3) ;
- vector<int> edge5(_edge5,_edge5+3) ;
- vector<int> edge6(_edge6,_edge6+3) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+6) ;
- int _face1[]={1,2,3,5,6,7} ;
- int _face2[]={1,4,2,8,9,5} ;
- int _face3[]={2,4,3,9,10,6} ;
- int _face4[]={3,4,1,10,8,7} ;
- vector<int> face1(_face1,_face1+6) ;
- vector<int> face2(_face2,_face2+6) ;
- vector<int> face3(_face3,_face3+6) ;
- vector<int> face4(_face4,_face4+6) ;
- vector<int> _vector_face[] = {face1,face2,face3,face4} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+4) ;
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(6,MED_SEG3) ;
- vector<medGeometryElement> vector_face_type(4,MED_TRIA6) ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=4 ;
+ _numberOfConstituents[1]=6 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[4] ;
+ _numberOfNodeOfEachConstituent[0][0]=6 ;
+ _numberOfNodeOfEachConstituent[0][1]=6 ;
+ _numberOfNodeOfEachConstituent[0][2]=6 ;
+ _numberOfNodeOfEachConstituent[0][3]=6 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent[1][0]=3 ;
+ _numberOfNodeOfEachConstituent[1][1]=3 ;
+ _numberOfNodeOfEachConstituent[1][2]=3 ;
+ _numberOfNodeOfEachConstituent[1][3]=3 ;
+ _numberOfNodeOfEachConstituent[1][4]=3 ;
+ _numberOfNodeOfEachConstituent[1][5]=3 ;
+
+ int* _face1=new int[6];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ _face1[3]=5;
+ _face1[4]=6;
+ _face1[5]=7;
+ int* _face2=new int[6];
+ _face2[0]=1;
+ _face2[1]=4;
+ _face2[2]=2;
+ _face2[3]=8;
+ _face2[4]=9;
+ _face2[5]=5;
+ int* _face3=new int[6];
+ _face3[0]=2;
+ _face3[1]=4;
+ _face3[2]=3;
+ _face3[3]=9;
+ _face3[4]=10;
+ _face3[5]=6;
+ int* _face4=new int[6];
+ _face4[0]=3;
+ _face4[1]=4;
+ _face4[2]=1;
+ _face4[3]=10;
+ _face4[4]=8;
+ _face4[5]=7;
+ int* _edge1=new int[3];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ _edge1[2]=5;
+ int* _edge2=new int[3];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ _edge2[2]=6;
+ int* _edge3=new int[3];
+ _edge3[0]=3;
+ _edge3[1]=1;
+ _edge3[2]=7;
+ int* _edge4=new int[3];
+ _edge4[0]=1;
+ _edge4[1]=4;
+ _edge4[2]=8;
+ int* _edge5=new int[3];
+ _edge5[0]=2;
+ _edge5[1]=4;
+ _edge5[2]=9;
+ int* _edge6=new int[3];
+ _edge6[0]=3;
+ _edge6[1]=4;
+ _edge6[2]=10;
+ int ** tmpConstituents1 = new (int*)[4];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ int ** tmpConstituents2 = new (int*)[6];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[4] ;
+ tmpConstituentsType1[0] = MED_TRIA6 ;
+ tmpConstituentsType1[1] = MED_TRIA6 ;
+ tmpConstituentsType1[2] = MED_TRIA6 ;
+ tmpConstituentsType1[3] = MED_TRIA6 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[6] ;
+ tmpConstituentsType2[0] = MED_SEG3 ;
+ tmpConstituentsType2[1] = MED_SEG3 ;
+ tmpConstituentsType2[2] = MED_SEG3 ;
+ tmpConstituentsType2[3] = MED_SEG3 ;
+ tmpConstituentsType2[4] = MED_SEG3 ;
+ tmpConstituentsType2[5] = MED_SEG3 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
case MED_HEXA8 : {
_dimension=3;
_numberOfVertexes=8;
_numberOfNodes=8;
- int _edge1[]={1,2} ;
- int _edge2[]={2,3} ;
- int _edge3[]={3,4} ;
- int _edge4[]={4,1} ;
- int _edge5[]={5,6} ;
- int _edge6[]={6,7} ;
- int _edge7[]={7,8} ;
- int _edge8[]={8,5} ;
- int _edge9[]={1,5} ;
- int _edge10[]={2,6} ;
- int _edge11[]={3,7} ;
- int _edge12[]={4,8} ;
- vector<int> edge1(_edge1,_edge1+2) ;
- vector<int> edge2(_edge2,_edge2+2) ;
- vector<int> edge3(_edge3,_edge3+2) ;
- vector<int> edge4(_edge4,_edge4+2) ;
- vector<int> edge5(_edge5,_edge5+2) ;
- vector<int> edge6(_edge6,_edge6+2) ;
- vector<int> edge7(_edge7,_edge7+2) ;
- vector<int> edge8(_edge8,_edge8+2) ;
- vector<int> edge9(_edge9,_edge9+2) ;
- vector<int> edge10(_edge10,_edge10+2) ;
- vector<int> edge11(_edge11,_edge11+2) ;
- vector<int> edge12(_edge12,_edge12+2) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10,edge11,edge12};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+12) ;
- int _face1[]={1,2,3,4} ;
- int _face2[]={5,8,7,6} ;
- int _face3[]={1,5,6,2} ;
- int _face4[]={2,6,7,3} ;
- int _face5[]={3,7,8,4} ;
- int _face6[]={4,8,5,1} ;
- vector<int> face1(_face1,_face1+4) ;
- vector<int> face2(_face2,_face2+4) ;
- vector<int> face3(_face3,_face3+4) ;
- vector<int> face4(_face4,_face4+4) ;
- vector<int> face5(_face5,_face5+4) ;
- vector<int> face6(_face6,_face6+4) ;
- vector<int> _vector_face[] = {face1,face2,face3,face4,face5,face6} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+6) ;
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(12,MED_SEG2) ;
- vector<medGeometryElement> vector_face_type(6,MED_QUAD4) ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2);
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=6 ;
+ _numberOfConstituents[1]=12 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent[0][0]=4 ;
+ _numberOfNodeOfEachConstituent[0][1]=4 ;
+ _numberOfNodeOfEachConstituent[0][2]=4 ;
+ _numberOfNodeOfEachConstituent[0][3]=4 ;
+ _numberOfNodeOfEachConstituent[0][4]=4 ;
+ _numberOfNodeOfEachConstituent[0][5]=4 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[12] ;
+ _numberOfNodeOfEachConstituent[1][0]=2 ;
+ _numberOfNodeOfEachConstituent[1][1]=2 ;
+ _numberOfNodeOfEachConstituent[1][2]=2 ;
+ _numberOfNodeOfEachConstituent[1][3]=2 ;
+ _numberOfNodeOfEachConstituent[1][4]=2 ;
+ _numberOfNodeOfEachConstituent[1][5]=2 ;
+ _numberOfNodeOfEachConstituent[1][6]=2 ;
+ _numberOfNodeOfEachConstituent[1][7]=2 ;
+ _numberOfNodeOfEachConstituent[1][8]=2 ;
+ _numberOfNodeOfEachConstituent[1][9]=2 ;
+ _numberOfNodeOfEachConstituent[1][10]=2 ;
+ _numberOfNodeOfEachConstituent[1][11]=2 ;
+
+ int* _edge1=new int[2];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ int* _edge2=new int[2];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ int* _edge3=new int[2];
+ _edge3[0]=3;
+ _edge3[1]=4;
+ int* _edge4=new int[2];
+ _edge4[0]=4;
+ _edge4[1]=1;
+ int* _edge5=new int[2];
+ _edge5[0]=5;
+ _edge5[1]=6;
+ int* _edge6=new int[2];
+ _edge6[0]=6;
+ _edge6[1]=7;
+ int* _edge7=new int[2];
+ _edge7[0]=7;
+ _edge7[1]=8;
+ int* _edge8=new int[2];
+ _edge8[0]=8;
+ _edge8[1]=5;
+ int* _edge9=new int[2];
+ _edge9[0]=1;
+ _edge9[1]=5;
+ int* _edge10=new int[2];
+ _edge10[0]=2;
+ _edge10[1]=6;
+ int* _edge11=new int[2];
+ _edge11[0]=3;
+ _edge11[1]=7;
+ int* _edge12=new int[2];
+ _edge12[0]=4;
+ _edge12[1]=8;
+ int* _face1=new int[4];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ _face1[3]=4;
+ int* _face2=new int[4];
+ _face2[0]=5;
+ _face2[1]=8;
+ _face2[2]=7;
+ _face2[3]=6;
+ int* _face3=new int[4];
+ _face3[0]=1;
+ _face3[1]=5;
+ _face3[2]=6;
+ _face3[3]=2;
+ int* _face4=new int[4];
+ _face4[0]=2;
+ _face4[1]=6;
+ _face4[2]=7;
+ _face4[3]=3;
+ int* _face5=new int[4];
+ _face5[0]=3;
+ _face5[1]=7;
+ _face5[2]=8;
+ _face5[3]=4;
+ int* _face6=new int[4];
+ _face6[0]=4;
+ _face6[1]=8;
+ _face6[2]=5;
+ _face6[3]=1;
+ int ** tmpConstituents1 = new (int*)[6];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ tmpConstituents1[4]=_face5 ;
+ tmpConstituents1[5]=_face6 ;
+ int ** tmpConstituents2 = new (int*)[12];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ tmpConstituents2[6]=_edge7 ;
+ tmpConstituents2[7]=_edge8 ;
+ tmpConstituents2[8]=_edge9 ;
+ tmpConstituents2[9]=_edge10;
+ tmpConstituents2[10]=_edge11;
+ tmpConstituents2[11]=_edge12;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ;
+ tmpConstituentsType1[0] = MED_QUAD4 ;
+ tmpConstituentsType1[1] = MED_QUAD4 ;
+ tmpConstituentsType1[2] = MED_QUAD4 ;
+ tmpConstituentsType1[3] = MED_QUAD4 ;
+ tmpConstituentsType1[4] = MED_QUAD4 ;
+ tmpConstituentsType1[5] = MED_QUAD4 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[12] ;
+ tmpConstituentsType2[0] = MED_SEG2 ;
+ tmpConstituentsType2[1] = MED_SEG2 ;
+ tmpConstituentsType2[2] = MED_SEG2 ;
+ tmpConstituentsType2[3] = MED_SEG2 ;
+ tmpConstituentsType2[4] = MED_SEG2 ;
+ tmpConstituentsType2[5] = MED_SEG2 ;
+ tmpConstituentsType2[6] = MED_SEG2 ;
+ tmpConstituentsType2[7] = MED_SEG2 ;
+ tmpConstituentsType2[8] = MED_SEG2 ;
+ tmpConstituentsType2[9] = MED_SEG2 ;
+ tmpConstituentsType2[10] = MED_SEG2 ;
+ tmpConstituentsType2[11] = MED_SEG2 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
case MED_HEXA20 : {
_dimension=3;
_numberOfVertexes=8;
_numberOfNodes=20;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=6 ;
+ _numberOfConstituents[1]=12 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[6] ;
+ _numberOfNodeOfEachConstituent[0][0]=8 ;
+ _numberOfNodeOfEachConstituent[0][1]=8 ;
+ _numberOfNodeOfEachConstituent[0][2]=8 ;
+ _numberOfNodeOfEachConstituent[0][3]=8 ;
+ _numberOfNodeOfEachConstituent[0][4]=8 ;
+ _numberOfNodeOfEachConstituent[0][5]=8 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[12] ;
+ _numberOfNodeOfEachConstituent[1][0]=3 ;
+ _numberOfNodeOfEachConstituent[1][1]=3 ;
+ _numberOfNodeOfEachConstituent[1][2]=3 ;
+ _numberOfNodeOfEachConstituent[1][3]=3 ;
+ _numberOfNodeOfEachConstituent[1][4]=3 ;
+ _numberOfNodeOfEachConstituent[1][5]=3 ;
+ _numberOfNodeOfEachConstituent[1][6]=3 ;
+ _numberOfNodeOfEachConstituent[1][7]=3 ;
+ _numberOfNodeOfEachConstituent[1][8]=3 ;
+ _numberOfNodeOfEachConstituent[1][9]=3 ;
+ _numberOfNodeOfEachConstituent[1][10]=3 ;
+ _numberOfNodeOfEachConstituent[1][11]=3 ;
- int _edge1[]={1,2,9} ;
- int _edge2[]={2,3,10} ;
- int _edge3[]={3,4,11} ;
- int _edge4[]={4,1,12} ;
- int _edge5[]={5,6,13} ;
- int _edge6[]={6,7,14};
- int _edge7[]={7,8,15} ;
- int _edge8[]={8,5,16} ;
- int _edge9[]={1,5,17} ;
- int _edge10[]={2,6,18} ;
- int _edge11[]={3,7,19} ;
- int _edge12[]={4,8,20} ;
-
- vector<int> edge1(_edge1,_edge1+3) ;
- vector<int> edge2(_edge2,_edge2+3) ;
- vector<int> edge3(_edge3,_edge3+3) ;
- vector<int> edge4(_edge4,_edge4+3) ;
- vector<int> edge5(_edge5,_edge5+3) ;
- vector<int> edge6(_edge6,_edge6+3) ;
- vector<int> edge7(_edge7,_edge7+3) ;
- vector<int> edge8(_edge8,_edge8+3) ;
- vector<int> edge9(_edge9,_edge9+3) ;
- vector<int> edge10(_edge10,_edge10+3) ;
- vector<int> edge11(_edge11,_edge11+3) ;
- vector<int> edge12(_edge12,_edge12+3) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9,edge10, edge11,edge12};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+12) ;
-
- int _face1[]={1,2,3,4,9,10,11,12} ;
- int _face2[]={5,8,7,6,16,15,14,13} ;
- int _face3[]={1,5,6,2,17,13,18,9} ;
- int _face4[]={2,6,7,3,18,14,19,10} ;
- int _face5[]={3,7,8,4,19,15,20,11} ;
- int _face6[]={4,8,5,1,20,16,17,12} ;
- vector<int> face1(_face1,_face1+8);
- vector<int> face2(_face2,_face2+8);
- vector<int> face3(_face3,_face3+8);
- vector<int> face4(_face4,_face4+8);
- vector<int> face5(_face5,_face5+8);
- vector<int> face6(_face6,_face6+8);
- vector<int> _vector_face[]= {face1,face2,face3,face4,face5,face6} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+6);
-
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(12,MED_SEG3) ;
- vector<medGeometryElement> vector_face_type(6,MED_QUAD8) ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ int* _edge1=new int[3];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ _edge1[2]=9;
+ int* _edge2=new int[3];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ _edge2[2]=10;
+ int* _edge3=new int[3];
+ _edge3[0]=3;
+ _edge3[1]=4;
+ _edge3[2]=11;
+ int* _edge4=new int[3];
+ _edge4[0]=4;
+ _edge4[1]=1;
+ _edge4[2]=12;
+ int* _edge5=new int[3];
+ _edge5[0]=5;
+ _edge5[1]=6;
+ _edge5[2]=13;
+ int* _edge6=new int[3];
+ _edge6[0]=6;
+ _edge6[1]=7;
+ _edge6[2]=14;
+ int* _edge7=new int[3];
+ _edge7[0]=7;
+ _edge7[1]=8;
+ _edge7[2]=15;
+ int* _edge8=new int[3];
+ _edge8[0]=8;
+ _edge8[1]=5;
+ _edge8[2]=16;
+ int* _edge9=new int[3];
+ _edge9[0]=1;
+ _edge9[1]=5;
+ _edge9[2]=17;
+ int* _edge10=new int[3];
+ _edge10[0]=2;
+ _edge10[1]=6;
+ _edge10[2]=18;
+ int* _edge11=new int[3];
+ _edge11[0]=3;
+ _edge11[1]=7;
+ _edge11[2]=19;
+ int* _edge12=new int[3];
+ _edge12[0]=4;
+ _edge12[1]=8;
+ _edge12[2]=20;
+ int* _face1=new int[8];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ _face1[3]=4;
+ _face1[4]=9;
+ _face1[5]=10;
+ _face1[6]=11;
+ _face1[7]=12;
+ int* _face2=new int[8];
+ _face2[0]=5;
+ _face2[1]=8;
+ _face2[2]=7;
+ _face2[3]=6;
+ _face2[4]=16;
+ _face2[5]=15;
+ _face2[6]=14;
+ _face2[7]=13;
+ int* _face3=new int[8];
+ _face3[0]=1;
+ _face3[1]=5;
+ _face3[2]=6;
+ _face3[3]=2;
+ _face3[4]=17;
+ _face3[5]=13;
+ _face3[6]=18;
+ _face3[7]=9;
+ int* _face4=new int[8];
+ _face4[0]=2;
+ _face4[1]=6;
+ _face4[2]=7;
+ _face4[3]=3;
+ _face4[4]=18;
+ _face4[5]=14;
+ _face4[6]=19;
+ _face4[7]=10;
+ int* _face5=new int[8];
+ _face5[0]=3;
+ _face5[1]=7;
+ _face5[2]=8;
+ _face5[3]=4;
+ _face5[4]=19;
+ _face5[5]=15;
+ _face5[6]=20;
+ _face5[7]=11;
+ int* _face6=new int[8];
+ _face6[0]=4;
+ _face6[1]=8;
+ _face6[2]=5;
+ _face6[3]=1;
+ _face6[4]=20;
+ _face6[5]=16;
+ _face6[6]=17;
+ _face6[7]=12;
+ int ** tmpConstituents1 = new (int*)[6];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ tmpConstituents1[4]=_face5 ;
+ tmpConstituents1[5]=_face6 ;
+ int ** tmpConstituents2 = new (int*)[12];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ tmpConstituents2[6]=_edge7 ;
+ tmpConstituents2[7]=_edge8 ;
+ tmpConstituents2[8]=_edge9 ;
+ tmpConstituents2[9]=_edge10;
+ tmpConstituents2[10]=_edge11;
+ tmpConstituents2[11]=_edge12;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[6] ;
+ tmpConstituentsType1[0] = MED_QUAD8 ;
+ tmpConstituentsType1[1] = MED_QUAD8 ;
+ tmpConstituentsType1[2] = MED_QUAD8 ;
+ tmpConstituentsType1[3] = MED_QUAD8 ;
+ tmpConstituentsType1[4] = MED_QUAD8 ;
+ tmpConstituentsType1[5] = MED_QUAD8 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[12] ;
+ tmpConstituentsType2[0] = MED_SEG3 ;
+ tmpConstituentsType2[1] = MED_SEG3 ;
+ tmpConstituentsType2[2] = MED_SEG3 ;
+ tmpConstituentsType2[3] = MED_SEG3 ;
+ tmpConstituentsType2[4] = MED_SEG3 ;
+ tmpConstituentsType2[5] = MED_SEG3 ;
+ tmpConstituentsType2[6] = MED_SEG3 ;
+ tmpConstituentsType2[7] = MED_SEG3 ;
+ tmpConstituentsType2[8] = MED_SEG3 ;
+ tmpConstituentsType2[9] = MED_SEG3 ;
+ tmpConstituentsType2[10] = MED_SEG3 ;
+ tmpConstituentsType2[11] = MED_SEG3 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
case MED_PENTA6 : {
_numberOfVertexes=6;
_numberOfNodes=6;
- int _edge1[]= {1,2} ;
- int _edge2[]= {2,3} ;
- int _edge3[]= {3,1} ;
- int _edge4[]= {4,5} ;
- int _edge5[]= {5,6} ;
- int _edge6[]= {6,4} ;
- int _edge7[]= {1,4} ;
- int _edge8[]= {2,5} ;
- int _edge9[]= {3,6} ;
-
- vector<int> edge1(_edge1,_edge1+2) ;
- vector<int> edge2(_edge2,_edge2+2) ;
- vector<int> edge3(_edge3,_edge3+2) ;
- vector<int> edge4(_edge4,_edge4+2) ;
- vector<int> edge5(_edge5,_edge5+2) ;
- vector<int> edge6(_edge6,_edge6+2) ;
- vector<int> edge7(_edge7,_edge7+2) ;
- vector<int> edge8(_edge8,_edge8+2) ;
- vector<int> edge9(_edge9,_edge9+2) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+9) ;
-
- int _face1[]={1,2,3};
- int _face2[]={4,6,5};
- int _face3[]={1,4,5,2};
- int _face4[]={2,5,6,3};
- int _face5[]={3,6,4,1};
- vector<int> face1(_face1,_face1+3);
- vector<int> face2(_face2,_face2+3);
- vector<int> face3(_face3,_face3+4);
- vector<int> face4(_face4,_face4+4);
- vector<int> face5(_face5,_face5+4);
- vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(9,MED_SEG2) ;
- vector<medGeometryElement> vector_face_type(5,MED_QUAD4) ;
- vector_face_type[0]=MED_TRIA3 ;
- vector_face_type[1]=MED_TRIA3 ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=5 ;
+ _numberOfConstituents[1]=9 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent[0][0]=3 ;
+ _numberOfNodeOfEachConstituent[0][1]=3 ;
+ _numberOfNodeOfEachConstituent[0][2]=4 ;
+ _numberOfNodeOfEachConstituent[0][3]=4 ;
+ _numberOfNodeOfEachConstituent[0][4]=4 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[9] ;
+ _numberOfNodeOfEachConstituent[1][0]=2 ;
+ _numberOfNodeOfEachConstituent[1][1]=2 ;
+ _numberOfNodeOfEachConstituent[1][2]=2 ;
+ _numberOfNodeOfEachConstituent[1][3]=2 ;
+ _numberOfNodeOfEachConstituent[1][4]=2 ;
+ _numberOfNodeOfEachConstituent[1][5]=2 ;
+ _numberOfNodeOfEachConstituent[1][6]=2 ;
+ _numberOfNodeOfEachConstituent[1][7]=2 ;
+ _numberOfNodeOfEachConstituent[1][8]=2 ;
+
+ int* _edge1=new int[2];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ int* _edge2=new int[2];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ int* _edge3=new int[2];
+ _edge3[0]=3;
+ _edge3[1]=1;
+ int* _edge4=new int[2];
+ _edge4[0]=4;
+ _edge4[1]=5;
+ int* _edge5=new int[2];
+ _edge5[0]=5;
+ _edge5[1]=6;
+ int* _edge6=new int[2];
+ _edge6[0]=6;
+ _edge6[1]=4;
+ int* _edge7=new int[2];
+ _edge7[0]=1;
+ _edge7[1]=4;
+ int* _edge8=new int[2];
+ _edge8[0]=2;
+ _edge8[1]=5;
+ int* _edge9=new int[2];
+ _edge9[0]=3;
+ _edge9[1]=6;
+ int* _face1=new int[3];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ int* _face2=new int[3];
+ _face2[0]=4;
+ _face2[1]=6;
+ _face2[2]=5;
+ int* _face3=new int[4];
+ _face3[0]=1;
+ _face3[1]=4;
+ _face3[2]=5;
+ _face3[3]=2;
+ int* _face4=new int[4];
+ _face4[0]=2;
+ _face4[1]=5;
+ _face4[2]=6;
+ _face4[3]=3;
+ int* _face5=new int[4];
+ _face5[0]=3;
+ _face5[1]=6;
+ _face5[2]=4;
+ _face5[3]=1;
+ int ** tmpConstituents1 = new (int*)[5];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ tmpConstituents1[4]=_face5 ;
+ int ** tmpConstituents2 = new (int*)[9];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ tmpConstituents2[6]=_edge7 ;
+ tmpConstituents2[7]=_edge8 ;
+ tmpConstituents2[8]=_edge9 ;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
+ tmpConstituentsType1[0] = MED_TRIA3 ;
+ tmpConstituentsType1[1] = MED_TRIA3 ;
+ tmpConstituentsType1[2] = MED_QUAD4 ;
+ tmpConstituentsType1[3] = MED_QUAD4 ;
+ tmpConstituentsType1[4] = MED_QUAD4 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[9] ;
+ tmpConstituentsType2[0] = MED_SEG2 ;
+ tmpConstituentsType2[1] = MED_SEG2 ;
+ tmpConstituentsType2[2] = MED_SEG2 ;
+ tmpConstituentsType2[3] = MED_SEG2 ;
+ tmpConstituentsType2[4] = MED_SEG2 ;
+ tmpConstituentsType2[5] = MED_SEG2 ;
+ tmpConstituentsType2[6] = MED_SEG2 ;
+ tmpConstituentsType2[7] = MED_SEG2 ;
+ tmpConstituentsType2[8] = MED_SEG2 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
case MED_PENTA15 : {
_dimension=3;
_numberOfVertexes=6;
_numberOfNodes=15;
- int _edge1[]={1,2,7} ;
- int _edge2[]={2,3,8} ;
- int _edge3[]={3,1,9} ;
- int _edge4[]={4,5,10} ;
- int _edge5[]={5,6,11} ;
- int _edge6[]={6,4,12} ;
- int _edge7[]={1,4,13} ;
- int _edge8[]={2,5,14} ;
- int _edge9[]={3,6,15} ;
-
- vector<int> edge1(_edge1,_edge1+3) ;
- vector<int> edge2(_edge2,_edge2+3) ;
- vector<int> edge3(_edge3,_edge3+3) ;
- vector<int> edge4(_edge4,_edge4+3) ;
- vector<int> edge5(_edge5,_edge5+3) ;
- vector<int> edge6(_edge6,_edge6+3) ;
- vector<int> edge7(_edge7,_edge7+3) ;
- vector<int> edge8(_edge8,_edge8+3) ;
- vector<int> edge9(_edge9,_edge9+3) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8,edge9};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+9) ;
-
- int _face1[]={1,2,3,7,8,9};
- int _face2[]={4,6,5,12,11,10};
- int _face3[]={1,4,5,2,13,10,14,7};
- int _face4[]={2,5,6,3,14,11,15,8};
- int _face5[]={3,6,4,1,15,12,13,9};
- vector<int> face1(_face1,_face1+6);
- vector<int> face2(_face2,_face2+6);
- vector<int> face3(_face3,_face3+8);
- vector<int> face4(_face4,_face4+8);
- vector<int> face5(_face5,_face5+8);
- vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(9,MED_SEG3) ;
- vector<medGeometryElement> vector_face_type(5,MED_QUAD8) ;
- vector_face_type[0]=MED_TRIA6 ;
- vector_face_type[1]=MED_TRIA6 ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
- break;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=5 ;
+ _numberOfConstituents[1]=9 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent[0][0]=6 ;
+ _numberOfNodeOfEachConstituent[0][1]=6 ;
+ _numberOfNodeOfEachConstituent[0][2]=8 ;
+ _numberOfNodeOfEachConstituent[0][3]=8 ;
+ _numberOfNodeOfEachConstituent[0][4]=8 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[9] ;
+ _numberOfNodeOfEachConstituent[1][0]=3 ;
+ _numberOfNodeOfEachConstituent[1][1]=3 ;
+ _numberOfNodeOfEachConstituent[1][2]=3 ;
+ _numberOfNodeOfEachConstituent[1][3]=3 ;
+ _numberOfNodeOfEachConstituent[1][4]=3 ;
+ _numberOfNodeOfEachConstituent[1][5]=3 ;
+ _numberOfNodeOfEachConstituent[1][6]=3 ;
+ _numberOfNodeOfEachConstituent[1][7]=3 ;
+ _numberOfNodeOfEachConstituent[1][8]=3 ;
+
+ int* _edge1=new int[3];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ _edge1[2]=7;
+ int* _edge2=new int[3];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ _edge2[2]=8;
+ int* _edge3=new int[3];
+ _edge3[0]=3;
+ _edge3[1]=1;
+ _edge3[2]=9;
+ int* _edge4=new int[3];
+ _edge4[0]=4;
+ _edge4[1]=5;
+ _edge4[2]=10;
+ int* _edge5=new int[3];
+ _edge5[0]=5;
+ _edge5[1]=6;
+ _edge5[2]=11;
+ int* _edge6=new int[3];
+ _edge6[0]=6;
+ _edge6[1]=4;
+ _edge6[2]=12;
+ int* _edge7=new int[3];
+ _edge7[0]=1;
+ _edge7[1]=4;
+ _edge7[2]=13;
+ int* _edge8=new int[3];
+ _edge8[0]=2;
+ _edge8[1]=5;
+ _edge8[2]=14;
+ int* _edge9=new int[3];
+ _edge9[0]=3;
+ _edge9[1]=6;
+ _edge9[2]=15;
+ int* _face1=new int[6];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ _face1[3]=7;
+ _face1[4]=8;
+ _face1[5]=9;
+ int* _face2=new int[6];
+ _face2[0]=4;
+ _face2[1]=5;
+ _face2[2]=6;
+ _face2[3]=12;
+ _face2[4]=11;
+ _face2[5]=10;
+ int* _face3=new int[8];
+ _face3[0]=1;
+ _face3[1]=4;
+ _face3[2]=5;
+ _face3[3]=2;
+ _face3[4]=13;
+ _face3[5]=10;
+ _face3[6]=14;
+ _face3[7]=7;
+ int* _face4=new int[8];
+ _face4[0]=2;
+ _face4[1]=5;
+ _face4[2]=6;
+ _face4[3]=3;
+ _face4[4]=14;
+ _face4[5]=11;
+ _face4[6]=15;
+ _face4[7]=8;
+ int* _face5=new int[8];
+ _face5[0]=3;
+ _face5[1]=6;
+ _face5[2]=4;
+ _face5[3]=1;
+ _face5[4]=15;
+ _face5[5]=12;
+ _face5[6]=13;
+ _face5[7]=9;
+ int ** tmpConstituents1 = new (int*)[5];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ tmpConstituents1[4]=_face5 ;
+ int ** tmpConstituents2 = new (int*)[9];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ tmpConstituents2[6]=_edge7 ;
+ tmpConstituents2[7]=_edge8 ;
+ tmpConstituents2[8]=_edge9 ;
+ _constituents = new (int**)[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
+ tmpConstituentsType1[0] = MED_TRIA6 ;
+ tmpConstituentsType1[1] = MED_TRIA6 ;
+ tmpConstituentsType1[2] = MED_QUAD8 ;
+ tmpConstituentsType1[3] = MED_QUAD8 ;
+ tmpConstituentsType1[4] = MED_QUAD8 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[9] ;
+ tmpConstituentsType2[0] = MED_SEG3 ;
+ tmpConstituentsType2[1] = MED_SEG3 ;
+ tmpConstituentsType2[2] = MED_SEG3 ;
+ tmpConstituentsType2[3] = MED_SEG3 ;
+ tmpConstituentsType2[4] = MED_SEG3 ;
+ tmpConstituentsType2[5] = MED_SEG3 ;
+ tmpConstituentsType2[6] = MED_SEG3 ;
+ tmpConstituentsType2[7] = MED_SEG3 ;
+ tmpConstituentsType2[8] = MED_SEG3 ;
+ _constituentsType = new (medGeometryElement*)[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
+ break ;
}
case MED_PYRA5 : {
_name="MED_PYRA5" ;
_dimension=3;
_numberOfVertexes=5;
_numberOfNodes=5;
- int _edge1[]={1,2} ;
- int _edge2[]={2,3} ;
- int _edge3[]={3,4} ;
- int _edge4[]={4,1} ;
- int _edge5[]={1,5} ;
- int _edge6[]={2,5} ;
- int _edge7[]={3,5} ;
- int _edge8[]={4,5} ;
-
- vector<int> edge1(_edge1,_edge1+2) ;
- vector<int> edge2(_edge2,_edge2+2) ;
- vector<int> edge3(_edge3,_edge3+2) ;
- vector<int> edge4(_edge4,_edge4+2) ;
- vector<int> edge5(_edge5,_edge5+2) ;
- vector<int> edge6(_edge6,_edge6+2) ;
- vector<int> edge7(_edge7,_edge7+2) ;
- vector<int> edge8(_edge8,_edge8+2) ;
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+8) ;
-
- int _face1[]={1,2,3,4} ;
- int _face2[]={1,5,2} ;
- int _face3[]={2,5,3} ;
- int _face4[]={3,5,4} ;
- int _face5[]={4,5,1} ;
- vector<int> face1(_face1,_face1+4);
- vector<int> face2(_face2,_face2+3);
- vector<int> face3(_face3,_face3+3);
- vector<int> face4(_face4,_face4+3);
- vector<int> face5(_face5,_face5+3);
- vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(8,MED_SEG2) ;
- vector<medGeometryElement> vector_face_type(5,MED_TRIA3) ;
- vector_face_type[0]=MED_QUAD4 ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=5 ;
+ _numberOfConstituents[1]=8 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent[0][0]=4 ;
+ _numberOfNodeOfEachConstituent[0][1]=3 ;
+ _numberOfNodeOfEachConstituent[0][2]=3 ;
+ _numberOfNodeOfEachConstituent[0][3]=3 ;
+ _numberOfNodeOfEachConstituent[0][4]=3 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[8] ;
+ _numberOfNodeOfEachConstituent[1][0]=2 ;
+ _numberOfNodeOfEachConstituent[1][1]=2 ;
+ _numberOfNodeOfEachConstituent[1][2]=2 ;
+ _numberOfNodeOfEachConstituent[1][3]=2 ;
+ _numberOfNodeOfEachConstituent[1][4]=2 ;
+ _numberOfNodeOfEachConstituent[1][5]=2 ;
+ _numberOfNodeOfEachConstituent[1][6]=2 ;
+ _numberOfNodeOfEachConstituent[1][7]=2 ;
+
+ int* _edge1=new int[2];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ int* _edge2=new int[2];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ int* _edge3=new int[2];
+ _edge3[0]=3;
+ _edge3[1]=4;
+ int* _edge4=new int[2];
+ _edge4[0]=4;
+ _edge4[1]=1;
+ int* _edge5=new int[2];
+ _edge5[0]=1;
+ _edge5[1]=5;
+ int* _edge6=new int[2];
+ _edge6[0]=2;
+ _edge6[1]=5;
+ int* _edge7=new int[2];
+ _edge7[0]=3;
+ _edge7[1]=5;
+ int* _edge8=new int[2];
+ _edge8[0]=4;
+ _edge8[1]=5;
+ int* _face1=new int[4];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ _face1[3]=4;
+ int* _face2=new int[3];
+ _face2[0]=1;
+ _face2[1]=5;
+ _face2[2]=2;
+ int* _face3=new int[3];
+ _face3[0]=2;
+ _face3[1]=5;
+ _face3[2]=3;
+ int* _face4=new int[3];
+ _face4[0]=3;
+ _face4[1]=5;
+ _face4[2]=4;
+ int* _face5=new int[3];
+ _face5[0]=4;
+ _face5[1]=5;
+ _face5[2]=1;
+ int ** tmpConstituents1 = new (int*)[5];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ tmpConstituents1[4]=_face5 ;
+ int ** tmpConstituents2 = new (int*)[8];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ tmpConstituents2[6]=_edge7 ;
+ tmpConstituents2[7]=_edge8 ;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
+ tmpConstituentsType1[0] = MED_QUAD4 ;
+ tmpConstituentsType1[1] = MED_TRIA3 ;
+ tmpConstituentsType1[2] = MED_TRIA3 ;
+ tmpConstituentsType1[3] = MED_TRIA3 ;
+ tmpConstituentsType1[4] = MED_TRIA3 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ;
+ tmpConstituentsType2[0] = MED_SEG2 ;
+ tmpConstituentsType2[1] = MED_SEG2 ;
+ tmpConstituentsType2[2] = MED_SEG2 ;
+ tmpConstituentsType2[3] = MED_SEG2 ;
+ tmpConstituentsType2[4] = MED_SEG2 ;
+ tmpConstituentsType2[5] = MED_SEG2 ;
+ tmpConstituentsType2[6] = MED_SEG2 ;
+ tmpConstituentsType2[7] = MED_SEG2 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
case MED_PYRA13 : {
_dimension=3;
_numberOfVertexes=5;
_numberOfNodes=13;
- int _edge1[]={1,2,6} ;
- int _edge2[]={2,3,7} ;
- int _edge3[]={3,4,8} ;
- int _edge4[]={4,1,9} ;
- int _edge5[]={1,5,10} ;
- int _edge6[]={2,5,11} ;
- int _edge7[]={3,5,12} ;
- int _edge8[]={4,5,13} ;
-
- vector<int> edge1(_edge1,_edge1+3) ;
- vector<int> edge2(_edge2,_edge2+3) ;
- vector<int> edge3(_edge3,_edge3+3) ;
- vector<int> edge4(_edge4,_edge4+3) ;
- vector<int> edge5(_edge5,_edge5+3) ;
- vector<int> edge6(_edge6,_edge6+3) ;
- vector<int> edge7(_edge7,_edge7+3) ;
- vector<int> edge8(_edge8,_edge8+3) ;
-
-
- vector<int> _vector_edge[]={edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8};
- vector< vector<int> > vector_edge(_vector_edge,_vector_edge+8) ;
-
- int _face1[]={1,2,3,4,6,7,8,9} ;
- int _face2[]={1,5,2,10,11,6} ;
- int _face3[]={2,5,3,11,12,7} ;
- int _face4[]={3,5,4,12,13,8} ;
- int _face5[]={4,5,1,13,10,9} ;
- vector<int> face1(_face1,_face1+8);
- vector<int> face2(_face2,_face2+6);
- vector<int> face3(_face3,_face3+6);
- vector<int> face4(_face4,_face4+6);
- vector<int> face5(_face5,_face5+6);
- vector<int> _vector_face[]= {face1,face2,face3,face4,face5} ;
- vector< vector<int> > vector_face(_vector_face,_vector_face+5);
-
-
- vector< vector<int> > __constituents__[]={vector_face,vector_edge};
- vector< vector< vector<int> > > _constituents_(__constituents__,__constituents__+2) ;
- _constituents = _constituents_ ;
- vector<medGeometryElement> vector_edge_type(8,MED_SEG3) ;
- vector<medGeometryElement> vector_face_type(5,MED_TRIA6) ;
- vector_face_type[0]=MED_QUAD8 ;
- vector<medGeometryElement> __constituents_type[]={vector_face_type,vector_edge_type};
- vector< vector<medGeometryElement> > _constituents_type(__constituents_type,__constituents_type+2) ;
-
- _constituentsType = _constituents_type ;
+ _numberOfConstituentsDimension=2 ;
+ _numberOfConstituents=new int[2] ;
+ _numberOfConstituents[0]=5 ;
+ _numberOfConstituents[1]=8 ;
+ _numberOfNodeOfEachConstituent=new (int*)[2] ;
+ _numberOfNodeOfEachConstituent[0]=new (int)[5] ;
+ _numberOfNodeOfEachConstituent[0][0]=8 ;
+ _numberOfNodeOfEachConstituent[0][1]=6 ;
+ _numberOfNodeOfEachConstituent[0][2]=6 ;
+ _numberOfNodeOfEachConstituent[0][3]=6 ;
+ _numberOfNodeOfEachConstituent[0][4]=6 ;
+ _numberOfNodeOfEachConstituent[1]=new (int)[8] ;
+ _numberOfNodeOfEachConstituent[1][0]=3 ;
+ _numberOfNodeOfEachConstituent[1][1]=3 ;
+ _numberOfNodeOfEachConstituent[1][2]=3 ;
+ _numberOfNodeOfEachConstituent[1][3]=3 ;
+ _numberOfNodeOfEachConstituent[1][4]=3 ;
+ _numberOfNodeOfEachConstituent[1][5]=3 ;
+ _numberOfNodeOfEachConstituent[1][6]=3 ;
+ _numberOfNodeOfEachConstituent[1][7]=3 ;
+
+ int* _edge1=new int[3];
+ _edge1[0]=1;
+ _edge1[1]=2;
+ _edge1[2]=6;
+ int* _edge2=new int[3];
+ _edge2[0]=2;
+ _edge2[1]=3;
+ _edge2[2]=7;
+ int* _edge3=new int[3];
+ _edge3[0]=3;
+ _edge3[1]=4;
+ _edge3[2]=8;
+ int* _edge4=new int[3];
+ _edge4[0]=4;
+ _edge4[1]=1;
+ _edge4[2]=9;
+ int* _edge5=new int[3];
+ _edge5[0]=1;
+ _edge5[1]=5;
+ _edge5[2]=10;
+ int* _edge6=new int[3];
+ _edge6[0]=2;
+ _edge6[1]=5;
+ _edge6[2]=11;
+ int* _edge7=new int[3];
+ _edge7[0]=3;
+ _edge7[1]=5;
+ _edge7[2]=12;
+ int* _edge8=new int[3];
+ _edge8[0]=4;
+ _edge8[1]=5;
+ _edge8[2]=13;
+ int* _face1=new int[8];
+ _face1[0]=1;
+ _face1[1]=2;
+ _face1[2]=3;
+ _face1[3]=4;
+ _face1[4]=6;
+ _face1[5]=7;
+ _face1[6]=8;
+ _face1[7]=9;
+ int* _face2=new int[6];
+ _face2[0]=1;
+ _face2[1]=5;
+ _face2[2]=2;
+ _face2[3]=10;
+ _face2[4]=11;
+ _face2[5]=6;
+ int* _face3=new int[6];
+ _face3[0]=2;
+ _face3[1]=5;
+ _face3[2]=3;
+ _face3[3]=11;
+ _face3[4]=12;
+ _face3[5]=7;
+ int* _face4=new int[6];
+ _face4[0]=3;
+ _face4[1]=5;
+ _face4[2]=4;
+ _face4[3]=12;
+ _face4[4]=13;
+ _face4[5]=8;
+ int* _face5=new int[6];
+ _face5[0]=4;
+ _face5[1]=5;
+ _face5[2]=1;
+ _face5[3]=13;
+ _face5[4]=10;
+ _face5[5]=9;
+ int ** tmpConstituents1 = new (int*)[5];
+ tmpConstituents1[0]=_face1 ;
+ tmpConstituents1[1]=_face2 ;
+ tmpConstituents1[2]=_face3 ;
+ tmpConstituents1[3]=_face4 ;
+ tmpConstituents1[4]=_face5 ;
+ int ** tmpConstituents2 = new (int*)[8];
+ tmpConstituents2[0]=_edge1 ;
+ tmpConstituents2[1]=_edge2 ;
+ tmpConstituents2[2]=_edge3 ;
+ tmpConstituents2[3]=_edge4 ;
+ tmpConstituents2[4]=_edge5 ;
+ tmpConstituents2[5]=_edge6 ;
+ tmpConstituents2[6]=_edge7 ;
+ tmpConstituents2[7]=_edge8 ;
+ _constituents = new int**[2] ;
+ _constituents[0]=tmpConstituents1 ;
+ _constituents[1]=tmpConstituents2 ;
+ medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ;
+ tmpConstituentsType1[0] = MED_QUAD8 ;
+ tmpConstituentsType1[1] = MED_TRIA6 ;
+ tmpConstituentsType1[2] = MED_TRIA6 ;
+ tmpConstituentsType1[3] = MED_TRIA6 ;
+ tmpConstituentsType1[4] = MED_TRIA6 ;
+ medGeometryElement * tmpConstituentsType2 = new medGeometryElement[8] ;
+ tmpConstituentsType2[0] = MED_SEG3 ;
+ tmpConstituentsType2[1] = MED_SEG3 ;
+ tmpConstituentsType2[2] = MED_SEG3 ;
+ tmpConstituentsType2[3] = MED_SEG3 ;
+ tmpConstituentsType2[4] = MED_SEG3 ;
+ tmpConstituentsType2[5] = MED_SEG3 ;
+ tmpConstituentsType2[6] = MED_SEG3 ;
+ tmpConstituentsType2[7] = MED_SEG3 ;
+ _constituentsType = new medGeometryElement*[2] ;
+ _constituentsType[0]=tmpConstituentsType1 ;
+ _constituentsType[1]=tmpConstituentsType2 ;
break;
}
// default :
os << " - dimension : " << my._dimension << endl;
os << " - number of nodes : " << my._numberOfNodes << endl ;
os << " - number of vertexes : " << my._numberOfVertexes << endl ;
- for(int i=0;i<my._constituents.size();i++)
+
+ os << " - number of Constituents Dimension : " << my._numberOfConstituentsDimension << endl ;
+
+ for(int i=0;i<my._numberOfConstituentsDimension;i++)
{
+
os << " - for dimension (-" << i+1 << ") : " << endl ;
- for(int j=0;j<my._constituents[i].size();j++)
+ os << " - number of Constituents for this Dimension : " << my._numberOfConstituents[i] << endl ;
+
+ for(int j=0;j<my._numberOfConstituents[i];j++)
{
- os << " - constituents " << j+1 << " of type "<< my._constituentsType[i][j] <<" : " ;
- for(int k=0;k<my._constituents[i][j].size();k++)
+ os << " - number of node for this constituent : " << my._numberOfNodeOfEachConstituent[i][j] << endl ;
+ os << " - constituents " << j+1 << " of type "<< my._constituentsType[i][j] <<" : " ;
+ for(int k=0;k<my._numberOfNodeOfEachConstituent[i][j];k++)
os << my._constituents[i][j][k] << " " ;
os << endl ;
}
return os;
}
-
-
- // Return number of constituents type (which dimension is _dimension-1).
+// Return number of constituents type (which dimension is _dimension-1).
int CELLMODEL::getNumberOfConstituentsType() const
{
set<medGeometryElement> constituentsTypes ;
- if (_constituentsType.size() > 0 ) {
- vector<medGeometryElement> constituentsType = _constituentsType[0] ;
- vector<medGeometryElement>::iterator itvec ;
- for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++)
- constituentsTypes.insert(*itvec);
- }
+// if (_constituentsType.size() > 0 ) {
+// vector<medGeometryElement> constituentsType = _constituentsType[0] ;
+// vector<medGeometryElement>::iterator itvec ;
+// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++)
+// constituentsTypes.insert(*itvec);
+// }
return constituentsTypes.size() ;
}
// Return all types of constituents which dimension is (_dimension-1).
-set <medGeometryElement> CELLMODEL::getAllConstituentsType() const
+set<medGeometryElement> CELLMODEL::getAllConstituentsType() const
{
set<medGeometryElement> constituentsTypes ;
- if (_constituentsType.size() > 0 ) {
- vector<medGeometryElement> constituentsType = _constituentsType[0] ;
- vector<medGeometryElement>::iterator itvec ;
- for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++)
- constituentsTypes.insert(*itvec);
- }
+// if (_constituentsType.size() > 0 ) {
+// vector<medGeometryElement> constituentsType = _constituentsType[0] ;
+// vector<medGeometryElement>::iterator itvec ;
+// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++)
+// constituentsTypes.insert(*itvec);
+// }
return constituentsTypes ;
}
// Return number of constituents foreach type (which dimension is _dimension-1).
-map <medGeometryElement,int> CELLMODEL::getNumberOfConstituentsForeachType() const
+map<medGeometryElement,int> CELLMODEL::getNumberOfConstituentsForeachType() const
{
map<medGeometryElement,int> numberOfConstituentsForeachType ;
- map<medGeometryElement,int>::iterator itmap ;
- if (_constituentsType.size() > 0 ) {
- vector<medGeometryElement> constituentsType = _constituentsType[0] ;
- vector<medGeometryElement>::iterator itvec ;
- for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) {
- itmap = numberOfConstituentsForeachType.find(*itvec);
- if (itmap==numberOfConstituentsForeachType.end()) // new element
- numberOfConstituentsForeachType[*itvec]=1 ;
- else
- numberOfConstituentsForeachType[*itvec]++ ;
+// map<medGeometryElement,int>::iterator itmap ;
+// if (_constituentsType.size() > 0 ) {
+// vector<medGeometryElement> constituentsType = _constituentsType[0] ;
+// vector<medGeometryElement>::iterator itvec ;
+// for(itvec=constituentsType.begin();itvec!=constituentsType.end();itvec++) {
+// itmap = numberOfConstituentsForeachType.find(*itvec);
+// if (itmap==numberOfConstituentsForeachType.end()) // new element
+// numberOfConstituentsForeachType[*itvec]=1 ;
+// else
+// numberOfConstituentsForeachType[*itvec]++ ;
+// }
+// }
+ return numberOfConstituentsForeachType ;
+}
+
+void CELLMODEL::init(const CELLMODEL &m)
+{
+ _name=m._name ;
+ _type= m._type ;
+ _dimension = m._dimension ;
+ _numberOfNodes = m._numberOfNodes ;
+ _numberOfVertexes = m._numberOfVertexes ;
+
+ _numberOfConstituentsDimension = m._numberOfConstituentsDimension ;
+
+ _numberOfConstituents = new int[_numberOfConstituentsDimension] ;
+ for(int i=0; i<_numberOfConstituentsDimension; i++)
+ _numberOfConstituents[i]=m._numberOfConstituents[i] ;
+
+ _numberOfNodeOfEachConstituent = new (int*)[_numberOfConstituentsDimension] ;
+ for(int i=0; i<_numberOfConstituentsDimension; i++) {
+ int numberOf = _numberOfConstituents[i] ;
+ int * newArray = new int[numberOf] ;
+ int * oldArray = m._numberOfNodeOfEachConstituent[i] ;
+ for(int j=0; j<numberOf; j++)
+ newArray[j] = oldArray[j] ;
+ _numberOfNodeOfEachConstituent[i] = newArray ;
+ }
+ _constituents = new (int**)[_numberOfConstituentsDimension] ;
+ _constituentsType = new (medGeometryElement*)[_numberOfConstituentsDimension] ;
+ for(int i=0; i<_numberOfConstituentsDimension; i++) {
+ int numberOf = _numberOfConstituents[i] ;
+ int ** tmpArray = new (int*)[numberOf] ;
+ medGeometryElement * newArrayType = new medGeometryElement[numberOf] ;
+ medGeometryElement * oldArrayType = m._constituentsType[i] ;
+
+ for(int j=0; j<numberOf; j++) {
+ int numberOf2 = _numberOfNodeOfEachConstituent[i][j] ;
+ int * newArray = new int[numberOf2] ;
+ int * oldArray = m._constituents[i][j] ;
+ for(int k=0; k<numberOf2; k++)
+ newArray[k] = oldArray[k] ;
+ tmpArray[j] = newArray ;
+ newArrayType[j] = oldArrayType[j] ;
}
+ _constituents[i] = tmpArray ;
+ _constituentsType[i] = newArrayType ;
}
- return numberOfConstituentsForeachType ;
+
+}
+void CELLMODEL::clean()
+{
+ for(int i=0; i<_numberOfConstituentsDimension; i++) {
+ int numberOf = _numberOfConstituents[i] ;
+ for(int j=0; j<numberOf; j++) {
+ if (NULL!=_constituents[i][j])
+ delete[] _constituents[i][j] ;
+ }
+ if (NULL!=_constituentsType[i])
+ delete[] _constituentsType[i] ;
+ if (NULL!=_constituents[i])
+ delete[] _constituents[i] ;
+ if (NULL!=_numberOfNodeOfEachConstituent[i])
+ delete[] _numberOfNodeOfEachConstituent[i] ;
+ }
+ if (NULL!=_numberOfConstituents)
+ delete[]_numberOfConstituents ;
+ if (NULL!=_constituentsType)
+ delete[] _constituentsType ;
+ if (NULL!=_constituents)
+ delete[] _constituents ;
+ if (NULL!=_numberOfNodeOfEachConstituent)
+ delete[] _numberOfNodeOfEachConstituent ;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_CellModel.hxx
+// Module : MED
+
/*
- File CellModel.hxx
+ File MEDMEM_CellModel.hxx
$Header$
*/
#ifndef CELLMODEL_HXX
#define CELLMODEL_HXX
-#include <vector>
#include <set>
#include <map>
#include <string>
+#include "utilities.h"
#include "MEDMEM_define.hxx"
+using namespace std ;
using namespace MED_EN;
-class CELLMODEL
-{
+/*!
+ This class is an internal class and should not be used by the end-user.
+ This class describes all possible cell models and is used in order
+ to acces informations about geometric type of the cell :
+ Each object (if instancied), contains generic informations about
+ the cell model it describes as cell dimensions, number of nodes...
+*/
-protected :
+class CELLMODEL
+{
- string _name ;
- medGeometryElement _type ;
- int _dimension ; // Cell _dimension (!= space _dimension)
- int _numberOfNodes ;
- int _numberOfVertexes ;
- vector< vector< vector<int> > > _constituents ;
- // define local connectivity for each constituents
- // composing it (
- // first vector : for each cell _dimension
- // (first : dim-1, second if any : dim-2)
- // second vector : for each constituents of this _dimension,
- // third vector : list of local nodes
- vector< vector<medGeometryElement> > _constituentsType ;
+private:
+ /*! private method : /n
+ used by constructor and operator= */
+ void init(const CELLMODEL &m);
+
+ /*! private method : /n */
+ void clean();
+
+
+ //protected:
+ /*! explicit name (as MED_POINT1) */
+ string _name;
+ /*! type of cell (cf define.h) */
+ medGeometryElement _type;
+ /*! Cell dimension (not space dimension) */
+ int _dimension;
+ /*! number of nodes forming this type of a cell */
+ int _numberOfNodes;
+ /*! number of vertexes forming this type of a cell */
+ int _numberOfVertexes;
+ /*! 2 for a 3D Cell and 1 for a 2DCell */
+ int _numberOfConstituentsDimension;
+ /*! Array of size numberOfConstituentsDimension */
+ int* _numberOfConstituents ;
+ /*! Array of size _numberOfConstituentsDimension
+ x_numberOfConstituents[i] */
+ int** _numberOfNodeOfEachConstituent ;
+ /*! defines nodal local connectivity for each
+ constituents of each dimension:
+ should be seen as a vector<vector<vector>> \n
+ - first vector : for each cell dimension
+ (first : dim-1, second if any : dim-2)\n
+ - second vector : for each constituent of
+ this dimension\n
+ - third vector : list of local nodes */
+ int*** _constituents ;
+ medGeometryElement** _constituentsType ;
public :
- CELLMODEL(){
- _type=MED_NONE ;
- _dimension = 0 ;
- _numberOfNodes = 0 ;
- _numberOfVertexes = 0 ;
- }
- CELLMODEL(medGeometryElement t) ;
- CELLMODEL(const CELLMODEL &m){
- _name= m._name ;
- _type= m._type ;
- _dimension = m._dimension ;
- _numberOfNodes = m._numberOfNodes ;
- _numberOfVertexes = m._numberOfVertexes ;
- _constituents = m._constituents ;
- _constituentsType = m._constituentsType ;
- }
- ~CELLMODEL() {
- };
-
- CELLMODEL & operator=(const CELLMODEL &m) {
- _name=m._name ;
- _type= m._type ;
- _dimension = m._dimension ;
- _numberOfNodes = m._numberOfNodes ;
- _numberOfVertexes = m._numberOfVertexes ;
- _constituents = m._constituents ;
- _constituentsType = m._constituentsType ;
- return *this ;
- }
+ /*! Constructor. */
+ inline CELLMODEL();
+ /*! Constructor. */
+ CELLMODEL(medGeometryElement t);
+ /*! Copy constructor. */
+ inline CELLMODEL(const CELLMODEL &m);
+ /*! Destructor. */
+ inline ~CELLMODEL();
+
+ /*! Operator = : duplicate CELLMODEL. */
+ inline CELLMODEL & operator=(const CELLMODEL &m);
+
+ /*! Operator << : print CELLMODEL to the given stream. */
friend ostream & operator<<(ostream &os,const CELLMODEL &my);
- inline string getName() const ;
+ /*! returns _name attribute (ie: MED_PENTA15).\n
+ see med.h (in med/include) */
+ inline string getName() const;
+
+ /*! returns number of vertexes forming this type of cell */
inline int getNumberOfVertexes() const;
- inline int getNumberOfNodes() const;
- inline int getDimension() const;
- inline medGeometryElement getType() const;
- // Return all constituents which dimension is _dimension-dim.
- vector< vector<int> > getConstituents(int dim) const;
+ /*! returns number of nodes forming this type of cell */
+ inline int getNumberOfNodes() const;
- // Return number of constituents which dimension is _dimension-dim.
- int getNumberOfConstituents(int dim) const;
+ /*! returns the dimension of this type of cell./n
+ it can be different from mesh dimension */
+ inline int getDimension() const;
- // Return local nodes numbers vector for num-th constituent which dimension is _dimension-dim.
- vector<int> getNodesConstituent(int dim,int num) const;
+ /*! returns the geometric type of the cell. \n
+ see med.h (in med/include) */
+ inline medGeometryElement getType() const;
- // Return local node number of nodes_index-th node for num-th constituent which dimension is _dimension-dim.
- int getNodeConstituent(int dim,int num,int nodes_index);
+ /*! returns all constituents which dimension is _dimension-dim.*/
+ int** getConstituents(int dim) const;
- // Return types of each constituents which dimension is _dimension-dim.
- vector <medGeometryElement> getConstituentsType(int dim) const;
+ /*! returns number of constituents which dimension is _dimension-dim.*/
+ int getNumberOfConstituents(int dim) const;
- // Return type of num-th constituent which dimension is _dimension-dim.
- medGeometryElement getConstituentType(int dim,int num) const;
+ /*! returns local nodes numbers vector for num-th constituent
+ which dimension is _dimension-dim.*/
+ int* getNodesConstituent(int dim,int num) const;
+ /*! returns local node number of nodes_index-th node for
+ num-th constituent which dimension is _dimension-dim.*/
+ int getNodeConstituent(int dim,int num,int nodes_index) const;
- // Return number of constituents type (which dimension is _dimension-1).
+ /*! returns types of each constituents which dimension
+ is _dimension-dim.*/
+ medGeometryElement* getConstituentsType(int dim) const;
+
+ /*! returns type of num-th constituent which dimension
+ is _dimension-dim.*/
+ medGeometryElement getConstituentType(int dim,int num) const;
+
+ /*! returns number of constituents type
+ (which dimension is _dimension-1).*/
int getNumberOfConstituentsType() const;
- // Return all types of constituents which dimension is (_dimension-1).
- set <medGeometryElement> getAllConstituentsType() const;
+ /*! returns all types of constituents which dimension
+ is (_dimension-1).*/
+ set<medGeometryElement> getAllConstituentsType() const;
- // Return number of constituents foreach type (which dimension is _dimension-1).
- map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;
+ /*! returns number of constituents foreach type (which dimension
+ is _dimension-1).*/
+ map<medGeometryElement,int> getNumberOfConstituentsForeachType() const;
};
// Methodes Inline
// ------------------------------------------
+inline CELLMODEL::CELLMODEL():
+ _type(MED_NONE),
+ _dimension(0),
+ _numberOfNodes(0),
+ _numberOfVertexes(0),
+ _numberOfConstituentsDimension(0),
+ _numberOfConstituents((int*)NULL),
+ _numberOfNodeOfEachConstituent((int**)NULL),
+ _constituents((int***)NULL),
+ _constituentsType((medGeometryElement**)NULL)
+{
+}
+inline CELLMODEL::CELLMODEL(const CELLMODEL &m)
+{
+ init(m) ;
+}
+inline CELLMODEL::~CELLMODEL()
+{
+ MESSAGE("CELLMODEL::~CELLMODEL() destroying the cell");
+ clean() ;
+};
+inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m)
+{
+ clean() ;
+ init(m) ;
+ return *this ;
+}
inline string CELLMODEL::getName() const
{
- return _name ;
+ return _name ;
}
inline int CELLMODEL::getNumberOfVertexes() const
{
- return _numberOfVertexes;
+ return _numberOfVertexes;
}
inline int CELLMODEL::getNumberOfNodes() const
{
- return _numberOfNodes;
+ return _numberOfNodes;
}
inline int CELLMODEL::getDimension() const
{
- return _dimension;
+ return _dimension;
}
inline medGeometryElement CELLMODEL::getType() const
{
- return _type;
+ return _type;
}
-inline vector< vector<int> > CELLMODEL::getConstituents(int dim) const
+inline int** CELLMODEL::getConstituents(int dim) const
{
return _constituents[dim-1] ;
}
inline int CELLMODEL::getNumberOfConstituents(int dim) const
{
- return _constituents[dim-1].size() ;
+ return _numberOfConstituents[dim-1] ;
}
-inline vector<int> CELLMODEL::getNodesConstituent(int dim,int num) const
+inline int* CELLMODEL::getNodesConstituent(int dim,int num) const
{
return _constituents[dim-1][num-1];
}
-inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber)
+inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) const
{
return _constituents[dim-1][num-1][nodesNumber-1] ;
}
-inline vector<medGeometryElement> CELLMODEL::getConstituentsType(int dim) const
+inline medGeometryElement* CELLMODEL::getConstituentsType(int dim) const
{
return _constituentsType[dim-1];
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Connectivity.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_Family.hxx"
#include "MEDMEM_CellModel.hxx"
#include "MEDMEM_STRING.hxx"
-//------------------------------------------------------//
-CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity=MED_CELL):
-//------------------------------------------------------//
- _entity(Entity),
- _typeConnectivity(MED_NODAL),
- _numberOfTypes(0),
- _geometricTypes((medGeometryElement*)NULL),
- _type((CELLMODEL*)NULL),
- _entityDimension(0),
- _count((int*)NULL),
- _nodal((MEDSKYLINEARRAY*)NULL),
- _descending((MEDSKYLINEARRAY*)NULL),
- _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
- _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
- _neighbourhood((MEDSKYLINEARRAY*)NULL),
- _constituent((CONNECTIVITY*)NULL)
+/*!
+ Default Constructor. /n
+ Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */
+//--------------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) :
+//--------------------------------------------------------------//
+ _entity(Entity),
+ _typeConnectivity(MED_NODAL),
+ _numberOfTypes(0),
+ _geometricTypes((medGeometryElement*)NULL),
+ _type((CELLMODEL*)NULL),
+ _entityDimension(0),
+ _count((int*)NULL),
+ _nodal((MEDSKYLINEARRAY*)NULL),
+ _descending((MEDSKYLINEARRAY*)NULL),
+ _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
+ _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
+ _neighbourhood((MEDSKYLINEARRAY*)NULL),
+ _constituent((CONNECTIVITY*)NULL)
{
- MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)") ;
+ MESSAGE("CONNECTIVITY(medEntityMesh Entity=MED_CELL)");
}
-//-------------------------------------------------------------------------//
-CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL):
-//-------------------------------------------------------------------------//
- _entity(Entity),
- _typeConnectivity(MED_NODAL),
- _numberOfTypes(numberOfTypes),
- _entityDimension(0),
- _nodal((MEDSKYLINEARRAY*)NULL),
- _descending((MEDSKYLINEARRAY*)NULL),
- _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
- _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
- _neighbourhood((MEDSKYLINEARRAY*)NULL),
- _constituent((CONNECTIVITY*)NULL)
+/*!
+ Constructor. /n
+ Default for Entity is MED_CELL */
+//------------------------------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */):
+//------------------------------------------------------------------------------//
+ _entity(Entity),
+ _typeConnectivity(MED_NODAL),
+ _numberOfTypes(numberOfTypes),
+ _entityDimension(0),
+ _nodal((MEDSKYLINEARRAY*)NULL),
+ _descending((MEDSKYLINEARRAY*)NULL),
+ _reverseNodalConnectivity((MEDSKYLINEARRAY*)NULL),
+ _reverseDescendingConnectivity((MEDSKYLINEARRAY*)NULL),
+ _neighbourhood((MEDSKYLINEARRAY*)NULL),
+ _constituent((CONNECTIVITY*)NULL)
{
- MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)") ;
+ MESSAGE("CONNECTIVITY(int numberOfTypes,medEntityMesh Entity=MED_CELL)");
_geometricTypes = new medGeometryElement[numberOfTypes];
_type = new CELLMODEL[numberOfTypes];
- _count = new int[numberOfTypes];
+ _count = new int[numberOfTypes+1];
+}
+
+/*!
+ Copy Constructor.
+*/
+//------------------------------------------------------//
+CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m):
+//----------------------------------------------------//
+ _entity (m._entity),
+ _typeConnectivity (m._typeConnectivity),
+ _numberOfTypes (m._numberOfTypes),
+ _entityDimension (m._entityDimension),
+ _numberOfNodes (m._numberOfNodes)
+{
+ if (m._geometricTypes != NULL)
+ {
+ _geometricTypes = new medGeometryElement[_numberOfTypes];
+ memcpy(_geometricTypes,m._geometricTypes,_numberOfTypes*sizeof(medGeometryElement));
+ }
+ else
+ _geometricTypes = (medGeometryElement *) NULL;
+
+ if (m._type != NULL)
+ {
+ _type = new CELLMODEL[_numberOfTypes];
+ for (int i=0;i<_numberOfTypes;i++)
+ _type[i] = CELLMODEL(m._type[i]);
+ }
+ else
+ _type = (CELLMODEL *) NULL;
+
+ if (m._count != NULL)
+ {
+ _count = new med_int[_numberOfTypes+1];
+ memcpy(_count,m._count,(_numberOfTypes+1)*sizeof(med_int));
+ }
+ else
+ _count = (med_int *) NULL;
+
+ if (m._nodal != NULL)
+ _nodal = new MEDSKYLINEARRAY(* m._nodal);
+ else
+ _nodal = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._descending != NULL)
+ _descending = new MEDSKYLINEARRAY(* m._descending);
+ else
+ _descending = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._reverseNodalConnectivity != NULL)
+ _reverseNodalConnectivity = new MEDSKYLINEARRAY(* m._reverseNodalConnectivity);
+ else
+ _reverseNodalConnectivity = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._reverseDescendingConnectivity != NULL)
+ _reverseDescendingConnectivity = new MEDSKYLINEARRAY(* m._reverseDescendingConnectivity);
+ else
+ _reverseDescendingConnectivity = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._neighbourhood != NULL)
+ _neighbourhood = new MEDSKYLINEARRAY(* m._neighbourhood);
+ else
+ _neighbourhood = (MEDSKYLINEARRAY *) NULL;
+
+ if (m._constituent != NULL)
+ _constituent = new CONNECTIVITY(* m._constituent);
+ else
+ _constituent = (CONNECTIVITY *) NULL;
}
+/*!
+ Destructor./n
+ desallocates existing pointers */
//----------------------------//
CONNECTIVITY::~CONNECTIVITY()
//----------------------------//
{
- MESSAGE("Destructeur de CONNECTIVITY()") ;
- if ( _geometricTypes != NULL )
- delete [] _geometricTypes ;
- if ( _count != NULL )
- delete[] _count ;
- if ( _nodal != NULL )
- delete _nodal ;
- if ( _descending != NULL )
- delete _descending ;
- if ( _reverseNodalConnectivity != NULL )
- delete _reverseNodalConnectivity ;
- if ( _reverseDescendingConnectivity != NULL )
- delete _reverseDescendingConnectivity ;
- if ( _constituent != NULL )
- delete _constituent ;
+ MESSAGE("Destructeur de CONNECTIVITY()");
+
+ if (_geometricTypes != NULL)
+ delete [] _geometricTypes;
+ if (_type != NULL)
+ delete [] _type;
+ if (_count != NULL)
+ delete[] _count;
+ if (_nodal != NULL)
+ delete _nodal;
+ if (_descending != NULL)
+ delete _descending;
+ if (_reverseNodalConnectivity != NULL)
+ delete _reverseNodalConnectivity;
+ if (_reverseDescendingConnectivity != NULL)
+ delete _reverseDescendingConnectivity;
+ if (_constituent != NULL)
+ delete _constituent;
+}
+
+/*!
+ set _constituent to Constituent
+ be aware desallocation of _constituent is done by CONNECTIVITY:~CONNECTIVITY
+ throws an exception if Constituent = MED_CELL
+ A DOCUMENTER
+ */
+//----------------------------------------------------------//
+void CONNECTIVITY::setConstituent(CONNECTIVITY * Constituent)
+ throw (MEDEXCEPTION)
+//----------------------------------------------------------//
+{
+ medEntityMesh Entity = Constituent->getEntity();
+ if (Entity == MED_CELL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : could not set constituent on MED_CELL !"));
+
+ if ((Entity == MED_EDGE)&(_entityDimension == 3))
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setConstituent : Entity not found !"));
+ _constituent->setConstituent(Constituent);
+ }
+ else
+ _constituent = Constituent;
+}
+
+/*! Duplicated Types array in CONNECTIVITY object. */
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setGeometricTypes(const medGeometryElement * Types,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//--------------------------------------------------------------------//
+{
+ if (Entity == _entity)
+ for (int i=0; i<_numberOfTypes; i++)
+ {
+ _geometricTypes[i] = Types[i];
+ _type[i] = CELLMODEL(_geometricTypes[i]);
+ }
+ else
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setGeometricTypes : Entity not found !"));
+ _constituent->setGeometricTypes(Types,Entity);
+ }
+}
+
+/*! A DOCUMENTER */
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setCount(const int * Count, const medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//--------------------------------------------------------------------//
+{
+ if (Entity == _entity)
+ {
+ int * index = new int[Count[_numberOfTypes]];
+ index[0]=1;
+ _count[0]=1;
+ for (int i=0; i<_numberOfTypes; i++) {
+ _count[i+1] = Count[i+1];
+ int NumberOfNodesPerElement = _type[i].getNumberOfNodes() ;
+ for (int j=_count[i]; j<_count[i+1]; j++)
+ index[j] = index[j-1]+NumberOfNodesPerElement;
+ }
+ // allocate _nodal
+ if (_nodal != NULL) delete _nodal;
+ _nodal = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,index[_count[_numberOfTypes]-1]-1);
+ _nodal->setIndex(index);
+ delete[] index;
+ }
+ else
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setCount : Entity not found !"));
+ _constituent->setCount(Count,Entity);
+ }
+}
+
+//--------------------------------------------------------------------//
+void CONNECTIVITY::setNodal(const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type)
+ throw (MEDEXCEPTION)
+//--------------------------------------------------------------------//
+{
+ if (_entity == Entity)
+ {
+ // find geometric type
+ bool find = false;
+ for (int i=0; i<_numberOfTypes; i++)
+ if (_geometricTypes[i] == Type) {
+ find = true;
+ int NumberOfNodePerElements = _type[i].getNumberOfNodes() ;
+ //_nodal->setI(i+1,Connectivity);
+ for( int j=_count[i];j<_count[i+1]; j++)
+ _nodal->setI(j,Connectivity+(j-_count[i])*NumberOfNodePerElements);
+ }
+ if (!find)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : geometric type not found"));
+ } else
+ {
+ if (_constituent == NULL)
+ throw MEDEXCEPTION(LOCALIZED("CONNECTIVITY::setNodal : Entity not found !"));
+ _constituent->setNodal(Connectivity,Entity,Type);
+ }
}
/*! A DOCUMENTER */
if (Entity==_entity)
if (ConnectivityType==MED_NODAL)
- calculateNodalConnectivity() ;
+ calculateNodalConnectivity();
else
if (Entity==MED_CELL)
- calculateDescendingConnectivity() ;
+ calculateDescendingConnectivity();
else
throw MEDEXCEPTION("CONNECTIVITY::calculateConnectivity : Could not build DESCENDING !");
if (Entity!=_entity) {
- calculateDescendingConnectivity() ;
- _constituent->calculateConnectivity(ConnectivityType,Entity) ;
+ calculateDescendingConnectivity();
+ _constituent->calculateConnectivity(ConnectivityType,Entity);
}
}
int numberOfFamilies = myFamilies.size();
if (numberOfFamilies == 0 ) {
- MESSAGE(LOC<<"No family") ;
- return ;
+ MESSAGE(LOC<<"No family");
+ return;
}
// does we do an update ?
if ((_constituent != NULL)&(_descending != NULL)) {
- MESSAGE(LOC<<"Constituent is already defined") ;
- return ;
+ MESSAGE(LOC<<"Constituent is already defined");
+ return;
}
if ((_constituent != NULL)&(_descending == NULL)) {
if (myFamilies[0]->getEntity() != _constituent->getEntity()) {
- MESSAGE(LOC<<"Family and constituent entity are different. We do nothing") ;
- return ;
+ MESSAGE(LOC<<"Family and constituent entity are different. We do nothing");
+ return;
}
// well we could go !
- CONNECTIVITY * oldConstituent = _constituent ;
- _constituent = (CONNECTIVITY *)NULL ;
+ CONNECTIVITY * oldConstituent = _constituent;
+
+// for(int i=0; i<numberOfFamilies; i++) {
+// FAMILY * myFamily = myFamilies[i];
+// MESSAGE(LOC<<"updating the family (BEGIN) : " << *myFamily);
+// }
+
+ _constituent = (CONNECTIVITY *)NULL;
// for instance we must have nodal connectivity in constituent :
if (oldConstituent->_nodal == NULL)
{
MESSAGE(LOC<<"We have no nodal connectivity of sub cell");
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell")) ;
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have no nodal connectivity of sub cell"));
}
- int oldNumberOfFace = oldConstituent->_nodal->getNumberOf() ;
- int * oldConstituentValue = oldConstituent->_nodal->getValue() ;
- int * oldConstituentIndex = oldConstituent->_nodal->getIndex() ;
+ int oldNumberOfFace = oldConstituent->_nodal->getNumberOf();
+ const int * oldConstituentValue = oldConstituent->_nodal->getValue();
+ const int * oldConstituentIndex = oldConstituent->_nodal->getIndex();
- calculateDescendingConnectivity() ;
+ calculateDescendingConnectivity();
- // if (oldConstituent->_nodal != NULL) {
- int newNumberOfFace = _constituent->_nodal->getNumberOf() ;
- int * newConstituentValue = _constituent->_nodal->getValue() ;
- int * newConstituentIndex = _constituent->_nodal->getIndex() ;
+ int newNumberOfFace = _constituent->_nodal->getNumberOf();
+ const int * newConstituentValue = _constituent->_nodal->getValue();
+ const int * newConstituentIndex = _constituent->_nodal->getIndex();
- int * newReverseDescendingIndex =
+ const int * newReverseDescendingIndex =
_reverseDescendingConnectivity->getIndex();
- int * newReverseDescendingValue =
- _reverseDescendingConnectivity->getValue();
- int * newDescendingIndex = _descending->getIndex();
- int * newDescendingValue = _descending->getValue();
+ const int * newDescendingIndex = _descending->getIndex();
+ const int * newDescendingValue = _descending->getValue();
// loop on all family,
// for all constituent in family, we get it's old connectivity
int index1 = 0;
int indexm1 = 0;
+ _constituent->calculateReverseNodalConnectivity();
+
for (int iOldFace=0;iOldFace<oldNumberOfFace;iOldFace++)
{
int index = 0;
-
-// renumberingFromOldToNew[iOldFace] = 999999;
+ renumberingFromOldToNew[iOldFace] = iOldFace+1;
+ // renumberingFromOldToNew[iOldFace] = 999999;
+
int face_it_beginOld = oldConstituentIndex[iOldFace];
int face_it_endOld = oldConstituentIndex[iOldFace+1];
int face_size_itOld = face_it_endOld - face_it_beginOld;
+
+ const int* NodesLists = oldConstituentValue + (face_it_beginOld-1);
int face_size_itNew;
- MEDMODULUSARRAY modulusArrayOld(face_size_itOld,oldConstituentValue+face_it_beginOld-1);
-
- for (int iNewFace=0;iNewFace<newNumberOfFace && index == 0;
- iNewFace++)
+ const int * reverseFaceNodal = _constituent->getReverseNodalConnectivity();
+ const int * reverseFaceNodalIndex = _constituent->getReverseNodalConnectivityIndex();
+
+ // set an array wich contains faces numbers arround first node
+ int BeginIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]-1];
+ int EndIndexFaceArrayFirstNode=reverseFaceNodalIndex[NodesLists[0]];
+ int NumberOfFacesInList=EndIndexFaceArrayFirstNode-BeginIndexFaceArrayFirstNode;
+
+ int * FacesList = new int[NumberOfFacesInList];
+
+ for (int l=BeginIndexFaceArrayFirstNode; l<EndIndexFaceArrayFirstNode; l++){
+ FacesList[l-BeginIndexFaceArrayFirstNode]=reverseFaceNodal[l-1];
+ }
+ // foreach node in sub cell, we search elements which are in common
+ // at the end, we must have only one !
+
+ for (int nodeFaceOld=1; nodeFaceOld<face_size_itOld; nodeFaceOld++)
{
- int face_it_beginNew = newConstituentIndex[iNewFace];
- int face_it_endNew = newConstituentIndex[iNewFace+1];
+ int NewNumberOfFacesInList = 0;
+ int * NewFacesList = new int[NumberOfFacesInList];
+
+ for (int l1=0; l1<NumberOfFacesInList; l1++) {
+ for (int l2=reverseFaceNodalIndex[NodesLists[nodeFaceOld]-1]; l2<reverseFaceNodalIndex[NodesLists[nodeFaceOld]]; l2++) {
+ if (FacesList[l1]<reverseFaceNodal[l2-1])
+ // increasing order : FacesList[l1] are not in elements list of node l
+ break;
+ if (FacesList[l1]==reverseFaceNodal[l2-1]) {
+ // we have found one
+ NewFacesList[NewNumberOfFacesInList]=FacesList[l1];
+ NewNumberOfFacesInList++;
+ break;
+ }
+ }
+ }
+ NumberOfFacesInList = NewNumberOfFacesInList;
+ delete [] FacesList;
+ FacesList = NewFacesList;
+ }
+
+ if (!NumberOfFacesInList==0)
+ {
+ if (NumberOfFacesInList>1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one face found ("<<NumberOfFacesInList<<") ! " <<FacesList[0]<<" "<<FacesList[1] ));
+
+ MEDMODULUSARRAY modulusArrayOld(face_size_itOld,NodesLists);
+
+ int face_it_beginNew = newConstituentIndex[FacesList[0]-1];
+ int face_it_endNew = newConstituentIndex[FacesList[0]];
face_size_itNew = face_it_endNew - face_it_beginNew;
-
- if (face_size_itNew == face_size_itOld)
+
+ const int * newNodesLists = newConstituentValue+newConstituentIndex[FacesList[0]-1]-1;
+ MEDMODULUSARRAY modulusArrayNew(face_size_itNew,newNodesLists);
+
+ int retCompareNewOld = modulusArrayNew.compare(modulusArrayOld);
+
+ //SCRUTE(retCompareNewOld);
+
+ // Real new face found
+
+ if(retCompareNewOld == 1)
{
- MEDMODULUSARRAY modulusArrayNew(face_size_itNew,newConstituentValue+face_it_beginNew-1);
-
- int retCompareNewOld = modulusArrayNew.compare(modulusArrayOld);
-
- // Real new face found
-
- if(retCompareNewOld == 1)
- {
- renumberingFromOldToNew[iOldFace] = iNewFace+1;
- index = 1;
- index1++;
- }
-
- // Reverse new face found
-
- if(retCompareNewOld == -1)
- {
- renumberingFromOldToNew[iOldFace] = iNewFace+1;
- index = 1;
- indexm1++;
-
- int face_it_begin = newReverseDescendingIndex[iNewFace];
- int face_it_end = newReverseDescendingIndex[iNewFace+1];
- int face_size_it = face_it_end - face_it_begin;
-
- if (face_size_it == 1)
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
-
- if (face_size_it > 2)
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<<face_size_it<<" neighbouring"));
-
- // we have always 2 neighbourings
- int cell1 = newReverseDescendingValue[face_it_begin-1];
- int cell2 = newReverseDescendingValue[face_it_begin];
-
- // PROVISOIRE : en attendant que le SKYLINEARRAY de ReverseDescending soit correct (sans le zero)
-// if (cell2 == 0)
-// throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
-
- if (cell2 != 0) { // we are not on border !!!!
-
- newReverseDescendingValue[face_it_begin-1] = cell2;
- // Updating _constituent->_nodal because of reversity
- int * oldArray = oldConstituentValue+face_it_beginOld-1;
- int * newArray = newConstituentValue+face_it_beginNew-1;
- for(int iarray=0;iarray<face_size_itNew;iarray++)
- newArray[iarray] = oldArray[iarray] ;
-
-
- // Updating _reverseDescendingConnectivity
-
-
- newReverseDescendingValue[face_it_begin] = cell1;
-
- // Updating _descending for cell1 and cell2
- for(int iface=newDescendingIndex[cell1-1];iface<newDescendingIndex[cell1];iface++)
- if (newDescendingValue[iface-1]==iNewFace+1)
- newDescendingValue[iface-1]=-iNewFace-1 ;
- else if (newDescendingValue[iface-1]==-iNewFace-1)
- newDescendingValue[iface-1]=iNewFace+1 ;
-
- for(int iface=newDescendingIndex[cell2-1];iface<newDescendingIndex[cell2];iface++)
- if (newDescendingValue[iface-1]==iNewFace+1)
- newDescendingValue[iface-1]=-iNewFace-1 ;
- else if (newDescendingValue[iface-1]==-iNewFace-1)
- newDescendingValue[iface-1]=iNewFace+1 ;
- } else {// else we are on border and we do nothing !!!!!!!!
- INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- INFOS(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !") ;
- INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
- }
+ renumberingFromOldToNew[iOldFace] = FacesList[0];
+ index = 1;
+ index1++;
+ }
+
+ // Reverse new face found
+
+ if(retCompareNewOld == -1)
+ {
+ renumberingFromOldToNew[iOldFace] = FacesList[0];
+ index = 1;
+ indexm1++;
+
+ int face_it_begin = newReverseDescendingIndex[FacesList[0]-1];
+ int face_it_end = newReverseDescendingIndex[FacesList[0]];
+ int face_size_it = face_it_end - face_it_begin;
+
+ if (face_size_it == 1)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
+
+ if (face_size_it > 2)
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This face/edge should not be a (d-1) cell because it has "<<face_size_it<<" neighbouring"));
+
+ // we have always 2 neighbourings
+ int cell1 = _reverseDescendingConnectivity->getIJ(FacesList[0],1);
+ int cell2 = _reverseDescendingConnectivity->getIJ(FacesList[0],2);
+ // PROVISOIRE : en attendant que le SKYLINEARRAY de ReverseDescending soit correct (sans le zero)
+ // if (cell2 == 0)
+ // throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"This is a boundary face/edge, it should not be renumbered and it is wrongly oriented."));
+
+ if (cell2 != 0) { // we are not on border !!!!
+
+ _reverseDescendingConnectivity->setIJ(FacesList[0],1,cell2);
+ // Updating _constituent->_nodal because of reversity
+ const int * oldArray = oldConstituentValue+face_it_beginOld-1;
+ for(int iarray=1;iarray<=face_size_itNew;iarray++){
+ _constituent->_nodal->setIJ(FacesList[0],iarray,oldArray[iarray-1]);
}
+
+ // Updating _reverseDescendingConnectivity
+
+
+ _reverseDescendingConnectivity->setIJ(FacesList[0],2,cell1);
+
+ // Updating _descending for cell1 and cell2
+ for(int iface=newDescendingIndex[cell1-1];iface<=newDescendingIndex[cell1];iface++)
+ if (_descending->getIndexValue(iface)==FacesList[0])
+ _descending->setIndexValue(iface,-FacesList[0]);
+ else if (_descending->getIndexValue(iface)==-FacesList[0])
+ _descending->setIndexValue(iface,FacesList[0]);
+ // else nothing to do
+
+ for(int iface=newDescendingIndex[cell2-1];iface<newDescendingIndex[cell2];iface++)
+ if (_descending->getIndexValue(iface)==FacesList[0])
+ _descending->setIndexValue(iface,-FacesList[0]);
+ else if (_descending->getIndexValue(iface)==-FacesList[0])
+ _descending->setIndexValue(iface,FacesList[0]);
+ // else nothing to do
+
+ } else {// else we are on border and we do nothing !!!!!!!!
+ INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+ INFOS(LOC<<" Boudary FACE "<<iOldFace+1<<" are wrong oriented !");
+ INFOS("WARNING,WARNING,WARNING,WARNING,WARNING,WARNING");
+ }
}
- }
- if(index == 0)
- {
- INFOS(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
- throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
+ if(index == 0)
+ {
+ INFOS(LOC<<"Renumbering problem with the Face connectivity given by the User and the new Connectivity computed");
+ throw MED_EXCEPTION(LOCALIZED(STRING(LOC)<<"We have a Face connectivity problem"));
+ }
}
+ delete[] FacesList;
}
MESSAGE(LOC<<"The Renumbering is finished and the status is");
- SCRUTE(index1);
- SCRUTE(indexm1);
// Updating the Family
for(int i=0; i<numberOfFamilies; i++) {
- FAMILY * myFamily = myFamilies[i] ;
+ FAMILY * myFamily = myFamilies[i];
- int length_skyline = myFamily->getnumber()->getLength();
- int * value_skyline = myFamily->getnumber()->getValue();
+ MEDSKYLINEARRAY * number = myFamily->getnumber();
+ int numberOfLines_skyline = number->getNumberOf();
+ const int * index_skyline = number->getIndex();
- for (int i=0;i<length_skyline;i++)
- value_skyline[i] = renumberingFromOldToNew[value_skyline[i]-1];
+ for (int i=0;i<numberOfLines_skyline;i++) {
+ for (int j=index_skyline[i]; j<index_skyline[i+1];j++) {
+ number->setIndexValue(j,renumberingFromOldToNew[number->getIndexValue(j)-1]);
+ }
+ }
+ MESSAGE(LOC<<"updating the family (END) : " << *myFamily);
}
+
+ delete oldConstituent ;
+ delete [] renumberingFromOldToNew;
}
+
END_OF(LOC);
- return ;
+ return;
}
//------------------------------------------------------------------------------------------------------------------//
-med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
+const med_int * CONNECTIVITY::getConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type)
//------------------------------------------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getConnectivity" ;
+ const char * LOC = "CONNECTIVITY::getConnectivity";
BEGIN_OF(LOC);
- MEDSKYLINEARRAY * Connectivity ;
+ MEDSKYLINEARRAY * Connectivity;
if (Entity==_entity) {
if (ConnectivityType==MED_NODAL)
- Connectivity=_nodal;
+ {
+ calculateNodalConnectivity();
+ Connectivity=_nodal;
+ }
else
- Connectivity=_descending;
+ {
+ calculateDescendingConnectivity();
+ Connectivity=_descending;
+ }
if (Connectivity!=NULL)
if (Type==MED_ALL_ELEMENTS)
- return Connectivity->getValue() ;
+ return Connectivity->getValue();
else {
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return Connectivity->getI(_count[i]) ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !")) ;
+ //return Connectivity->getI(i+1);
+ return Connectivity->getI(_count[i]);
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Type not found !"));
}
else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !"));
} else
if (_constituent != NULL)
return _constituent->getConnectivity(ConnectivityType,Entity,Type);
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
/*! Give morse index array to use with
- In C mode : Connectivity[ConnectivityIndex[i]-1+j-1]
- In fortran mode : Connectivity[ConnectivityIndex[i]+j] */
//-----------------------------------------------------------------------------------------------//
-med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
+const med_int * CONNECTIVITY::getConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
//------------------------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getConnectivityIndex" ;
+ const char * LOC = "CONNECTIVITY::getConnectivityIndex";
BEGIN_OF(LOC);
- MEDSKYLINEARRAY * Connectivity ;
+ MEDSKYLINEARRAY * Connectivity;
if (Entity==_entity) {
if (ConnectivityType==MED_NODAL)
Connectivity=_descending;
if (Connectivity!=NULL)
- return Connectivity->getIndex() ;
+ return Connectivity->getIndex();
else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Connectivity not defined !"));
} else
if (_constituent != NULL)
return _constituent->getConnectivityIndex(ConnectivityType,Entity);
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
/*! A DOCUMENTER */
//--------------------------------------------------------------//
-CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
+const CELLMODEL & CONNECTIVITY::getType(medGeometryElement Type) const
//--------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getType" ;
+ const char * LOC = "CONNECTIVITY::getType";
BEGIN_OF(LOC);
if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE !"));
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return _type[i] ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ;
+ return _type[i];
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !"));
}
/*! Returns the number of elements of type <med geometrie element>.
med_int CONNECTIVITY::getNumberOfNodesInType(medGeometryElement Type) const
//------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getNumberOfNodesInType" ;
+ const char * LOC = "CONNECTIVITY::getNumberOfNodesInType";
BEGIN_OF(LOC);
if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!")) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!"));
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return _type[i].getNumberOfNodes() ;
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !")) ;
+ return _type[i].getNumberOfNodes();
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement not found !"));
}
/*! Returns the number of geometric sub cells of <med geometrie element> type.
//------------------------------------------------------------------------//
{
if ((Type==MED_ALL_ELEMENTS) || (Type==MED_NONE))
- throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!") ;
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement must be different of MED_ALL_ELEMENTS and MED_NONE!");
for (med_int i=0; i<_numberOfTypes; i++)
if (_geometricTypes[i]==Type)
- return _type[i].getNumberOfConstituents(1) ;
- throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !") ;
+ return _type[i].getNumberOfConstituents(1);
+ throw MEDEXCEPTION("CONNECTIVITY::getNumberOfSubCell : medGeometryElement not found !");
}
/*! Returns the number of elements of type <med geometrie element>.
med_int CONNECTIVITY::getNumberOf(medEntityMesh Entity, medGeometryElement Type) const
//-----------------------------------------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::getNumberOf" ;
+ const char * LOC = "CONNECTIVITY::getNumberOf";
BEGIN_OF(LOC);
MESSAGE(LOC<<" Entity = "<< Entity << ", _entity = "<<_entity);
if (Entity==_entity) {
if (Type==MED_NONE)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE"));
+ return 0; // not defined !
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : medGeometryElement must be different of MED_NONE"));
if (Type==MED_ALL_ELEMENTS)
return _count[_numberOfTypes]-1;
for (med_int i=0; i<_numberOfTypes; i++)
if (_constituent != NULL)
return _constituent->getNumberOf(Entity,Type);
- return 0 ; // valid if they are nothing !
- //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !")) ;
+ return 0; // valid if they are nothing else !
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" : Entity not defined !"));
}
/*! A DOCUMENTER */
//--------------------------------------------------------------//
-med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity,
+const med_int* CONNECTIVITY::getValue(medConnectivity TypeConnectivity,
medGeometryElement Type)
//--------------------------------------------------------------//
{
/*! A DOCUMENTER */
//---------------------------------------------------------------------//
-med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity)
+const med_int* CONNECTIVITY:: getValueIndex(medConnectivity TypeConnectivity)
//---------------------------------------------------------------------//
{
if (TypeConnectivity == MED_NODAL)
/*! Not yet implemented */
//----------------------------------------------//
-med_int* CONNECTIVITY:: getNeighbourhood() const
+const med_int* CONNECTIVITY:: getNeighbourhood() const
//----------------------------------------------//
{
throw MEDEXCEPTION("CONNECTIVITY::getNeighbourhood : Not implemented");
/*! Returns an array which contains, for each node, all cells
arround it. */
//-------------------------------------------------//
-med_int* CONNECTIVITY::getReverseNodalConnectivity()
+const med_int* CONNECTIVITY::getReverseNodalConnectivity()
//-------------------------------------------------//
{
calculateReverseNodalConnectivity();
/*! Give index array to use with getReverseConnectivity(MED_NODAL).
It is unusefull with MED_DESCENDING mode, because we have allways two cells. */
//-------------------------------------------------------//
-med_int* CONNECTIVITY::getReverseNodalConnectivityIndex()
+const med_int* CONNECTIVITY::getReverseNodalConnectivityIndex()
//-------------------------------------------------------//
{
calculateReverseNodalConnectivity();
the 2 cells of each side. First is cell which face normal is outgoing.
arround it. */
//------------------------------------------------------//
-med_int* CONNECTIVITY::getReverseDescendingConnectivity()
+const med_int* CONNECTIVITY::getReverseDescendingConnectivity()
//------------------------------------------------------//
{
- // it is in _constituent connectivity only if we are in MED_CELL
- if (_entity==MED_CELL) {
- // we want descending connectivity
- calculateDescendingConnectivity();
- return _reverseDescendingConnectivity->getValue();
- }
- throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivity : Error Only in MED_CELL connectivity");
+ // it is in _constituent connectivity only if we are in MED_CELL
+ // (we could not for instance calculate face-edge connectivity !)
+ if (_entity!=MED_CELL)
+ throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivity : Error Only in MED_CELL connectivity");
+
+ // we need descending connectivity
+ calculateDescendingConnectivity();
+ return _reverseDescendingConnectivity->getValue();
}
/*! calculate the reverse descending Connectivity
and returns the index ( A DOCUMENTER MIEUX)*/
//-----------------------------------------------------------//
-med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex()
+const med_int* CONNECTIVITY::getReverseDescendingConnectivityIndex()
//-----------------------------------------------------------//
{
// it is in _constituent connectivity only if we are in MED_CELL
- if (_entity==MED_CELL) {
- // we want descending connectivity
- calculateDescendingConnectivity();
- return _reverseDescendingConnectivity->getIndex();
- }
- throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity");
+ if (_entity!=MED_CELL)
+ throw MEDEXCEPTION("CONNECTIVITY::getReverseDescendingConnectivityIndex : Error Only in MED_CELL connectivity");
+
+ // we need descending connectivity
+ calculateDescendingConnectivity();
+ return _reverseDescendingConnectivity->getIndex();
}
/*! A DOCUMENTER (et a finir ???) */
void CONNECTIVITY::calculateReverseNodalConnectivity()
//---------------------------------------------------//
{
- const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : " ;
- BEGIN_OF(LOC) ;
+ const char * LOC = "CONNECTIVITY::calculateReverseNodalConnectivity : ";
+ BEGIN_OF(LOC);
if (_nodal==NULL)
- calculateNodalConnectivity() ;
+ calculateNodalConnectivity();
- MESSAGE(LOC<<"Number of nodes = "<<_numberOfNodes);
-
if(_reverseNodalConnectivity==NULL) {
med_int node_number = 0;
// treat all cells of a particular type
for (med_int k = _count[j]; k < _count[j+1]; k++)
// treat all nodes of the cell type
- for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++)
+ for (med_int local_node_number = 1; local_node_number < node_number+1; local_node_number++)
{
- med_int global_node = _nodal->getIJ(k,local_node_number) ;
+ med_int global_node = _nodal->getIJ(k,local_node_number);
reverse_connectivity[global_node].push_back(k);
}
}
for (med_int i = 1; i < _numberOfNodes+1; i++)
size_reverse_nodal_connectivity += reverse_connectivity[i].size();
- MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity) ;
- // reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1];
- // reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity];
- med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue() ;
- med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex() ;
+ //MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity);
+ med_int * reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1];
+ med_int * reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity];
+ //const med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue();
+ //const med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex();
reverse_nodal_connectivity_index[0] = 1;
for (med_int i = 1; i < _numberOfNodes+1; i++)
{
med_int size = reverse_connectivity[i].size();
- reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size ;
+ reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size;
for (med_int j = 0; j < size; j++)
reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j];
}
- _reverseNodalConnectivity = ReverseConnectivity ;
-
- }
+ //_reverseNodalConnectivity = ReverseConnectivity;
+ _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity,
+ reverse_nodal_connectivity_index,
+ reverse_nodal_connectivity);
+ delete[] reverse_nodal_connectivity_index;
+ delete[] reverse_nodal_connectivity;
+ }
}
/*! If not yet done, calculate the Descending Connectivity */
MESSAGE(LOC<<": No descending connectivity defined, but constituent exist !");
if (_entityDimension == 3)
- _constituent = new CONNECTIVITY(MED_FACE) ;
+ _constituent = new CONNECTIVITY(MED_FACE);
else if (_entityDimension == 2)
- _constituent = new CONNECTIVITY(MED_EDGE) ;
+ _constituent = new CONNECTIVITY(MED_EDGE);
else {
MESSAGE(LOC<<"We are in 1D");
return;
}
- _constituent->_typeConnectivity = MED_DESCENDING ;
- _constituent->_numberOfNodes = _numberOfNodes ;
+ _constituent->_typeConnectivity = MED_NODAL;
+ _constituent->_numberOfNodes = _numberOfNodes;
// foreach cells, we built array of constituent
- int DescendingSize = 0 ;
+ int DescendingSize = 0;
for(int i=0; i<_numberOfTypes; i++)
- DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1) ;
- _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize) ;
- int * descend_connectivity = _descending->getValue() ;
+ DescendingSize+=(_count[i+1]-_count[i])*_type[i].getNumberOfConstituents(1);
+ //_descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,DescendingSize);
+ //const int * descend_connectivity = _descending->getValue();
+ int * descend_connectivity = new int[DescendingSize];
for (int i=0; i<DescendingSize; i++)
descend_connectivity[i]=0;
- int * descend_connectivity_index = _descending->getIndex() ;
+ //const int * descend_connectivity_index = _descending->getIndex();
+ int * descend_connectivity_index = new int[_count[_numberOfTypes]];
descend_connectivity_index[0]=1;
medGeometryElement* ConstituentsTypes = new medGeometryElement[2];
- ConstituentsTypes[0]=MED_NONE ;
- ConstituentsTypes[1]=MED_NONE ;
+ ConstituentsTypes[0]=MED_NONE;
+ ConstituentsTypes[1]=MED_NONE;
int * NumberOfConstituentsForeachType = new int[2];
NumberOfConstituentsForeachType[0]=0;
NumberOfConstituentsForeachType[1]=0;
for(int i=0; i<_numberOfTypes; i++) {
// initialize descend_connectivity_index array :
- int NumberOfConstituents = _type[i].getNumberOfConstituents(1) ;
+ int NumberOfConstituents = _type[i].getNumberOfConstituents(1);
for (int j=_count[i];j<_count[i+1];j++){
- descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents ;
+ descend_connectivity_index[j]=descend_connectivity_index[j-1]+NumberOfConstituents;
// compute number of constituent of all cell for each type
for(int k=1;k<NumberOfConstituents+1;k++) {
- medGeometryElement MEDType = _type[i].getConstituentType(1,k) ;
+ medGeometryElement MEDType = _type[i].getConstituentType(1,k);
if (ConstituentsTypes[0]==MED_NONE) {
ConstituentsTypes[0]=MEDType;
- NumberOfConstituentsForeachType[0]++ ;
+ NumberOfConstituentsForeachType[0]++;
} else if (ConstituentsTypes[0]==MEDType)
- NumberOfConstituentsForeachType[0]++ ;
+ NumberOfConstituentsForeachType[0]++;
else if (ConstituentsTypes[1]==MED_NONE) {
ConstituentsTypes[1]=MEDType;
- NumberOfConstituentsForeachType[1]++ ;
+ NumberOfConstituentsForeachType[1]++;
} else if (ConstituentsTypes[1]==MEDType)
- NumberOfConstituentsForeachType[1]++ ;
+ NumberOfConstituentsForeachType[1]++;
else
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<MEDType<<" is different of "<<ConstituentsTypes[0]<<" and "<<ConstituentsTypes[1]));
}
}
// we could built _constituent !
- int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1] ;
- int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100) ;
- _constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes) ;
+ int TotalNumberOfConstituents = NumberOfConstituentsForeachType[0]+NumberOfConstituentsForeachType[1];
+ int TotalNumberOfNodes = NumberOfConstituentsForeachType[0]*(ConstituentsTypes[0]%100)+NumberOfConstituentsForeachType[1]*(ConstituentsTypes[1]%100);
+
+ //_constituent->_nodal = new MEDSKYLINEARRAY(TotalNumberOfConstituents,TotalNumberOfNodes);
// we use _constituent->_nodal
- int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
- int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
+ //const int * ConstituentNodalConnectivity = _constituent->_nodal->getValue();
+ //const int * ConstituentNodalConnectivityIndex = _constituent->_nodal->getIndex();
+ int * ConstituentNodalConnectivity = new int[TotalNumberOfNodes];
+ int * ConstituentNodalConnectivityIndex = new int[TotalNumberOfConstituents+1];
ConstituentNodalConnectivityIndex[0]=1;
_constituent->_entityDimension=ConstituentsTypes[0]/100;
if (ConstituentsTypes[1]==MED_NONE)
- _constituent->_numberOfTypes = 1 ;
+ _constituent->_numberOfTypes = 1;
else
- _constituent->_numberOfTypes = 2 ;
- _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes] ;
- _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes] ;
- _constituent->_count = new med_int[_constituent->_numberOfTypes+1] ;
+ _constituent->_numberOfTypes = 2;
+ _constituent->_geometricTypes = new medGeometryElement[_constituent->_numberOfTypes];
+ _constituent->_type = new CELLMODEL[_constituent->_numberOfTypes];
+ _constituent->_count = new med_int[_constituent->_numberOfTypes+1];
_constituent->_count[0]=1;
- int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1] ;
+ int* tmp_NumberOfConstituentsForeachType = new med_int[_constituent->_numberOfTypes+1];
tmp_NumberOfConstituentsForeachType[0]=0; // to count constituent of each type
for (int i=0; i<_constituent->_numberOfTypes;i++) {
- _constituent->_geometricTypes[i]=ConstituentsTypes[i] ;
- _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i] ;
+ _constituent->_geometricTypes[i]=ConstituentsTypes[i];
+ _constituent->_count[i+1]=_constituent->_count[i]+NumberOfConstituentsForeachType[i];
CELLMODEL Type(ConstituentsTypes[i]);
_constituent->_type[i]=Type;
- tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i] ;
+ tmp_NumberOfConstituentsForeachType[i+1]=NumberOfConstituentsForeachType[i];
for (int j=tmp_NumberOfConstituentsForeachType[i]; j<tmp_NumberOfConstituentsForeachType[i+1]+tmp_NumberOfConstituentsForeachType[i]; j++)
- ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100) ;
+ ConstituentNodalConnectivityIndex[j+1]=ConstituentNodalConnectivityIndex[j]+(ConstituentsTypes[i]%100);
}
delete[] ConstituentsTypes;
- delete[] NumberOfConstituentsForeachType ;
+ delete[] NumberOfConstituentsForeachType;
// we need reverse nodal connectivity
if (! _reverseNodalConnectivity)
- calculateReverseNodalConnectivity() ;
- int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
- int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
+ calculateReverseNodalConnectivity();
+ const int * ReverseNodalConnectivityIndex = _reverseNodalConnectivity->getIndex();
+ const int * ReverseNodalConnectivityValue = _reverseNodalConnectivity->getValue();
// array to keep reverse descending connectivity
int * ReverseDescendingConnectivityValue = new int[TotalNumberOfConstituents*2];
- int TotalNumberOfSubCell = 0 ;
+ int TotalNumberOfSubCell = 0;
for (int i=0; i<_numberOfTypes; i++) { // loop on all cell type
- CELLMODEL Type = _type[i] ;
- int NumberOfNodesPerCell = Type.getNumberOfNodes() ;
+ CELLMODEL Type = _type[i];
+ int NumberOfNodesPerCell = Type.getNumberOfNodes();
int NumberOfConstituentPerCell = Type.getNumberOfConstituents(1);
for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type
- for (int k=1 ; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it
+ for (int k=1; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it
if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) {
// it is a new sub cell !
// TotalNumberOfSubCell++;
//we have maximum two types
descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell;
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j ;
- int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100 ;
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j;
+ int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100;
- int * NodesLists = new int[NumberOfNodesPerConstituent] ;
+ int * NodesLists = new int[NumberOfNodesPerConstituent];
for (int l=0; l<NumberOfNodesPerConstituent; l++) {
NodesLists[l]=_nodal->getIJ(j,Type.getNodeConstituent(1,k,l+1));
ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l];
// we use reverse_nodal_connectivity to find the other element which contain this sub cell
// all elements which contains first node of sub cell :
- int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1] ;
- int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]] ;
- int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0 ;
- int * CellsList = new int[NumberOfCellsInList] ;
- for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
- CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1] ;
+ int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1];
+ int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]];
+ int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0;
+
+ if (NumberOfCellsInList > 0) { // we could have no element !
+ int * CellsList = new int[NumberOfCellsInList];
+ for (int l=ReverseNodalConnectivityIndex_0; l<ReverseNodalConnectivityIndex_1; l++)
+ CellsList[l-ReverseNodalConnectivityIndex_0]=ReverseNodalConnectivityValue[l-1];
- // foreach node in sub cell, we search elements which are in common
- // at the end, we must have only one !
-
- for (int l=1; l<NumberOfNodesPerConstituent; l++) {
- int NewNumberOfCellsInList = 0 ;
- int * NewCellsList = new int[NumberOfCellsInList] ;
- for (int l1=0; l1<NumberOfCellsInList; l1++)
- for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++) {
- if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
- // increasing order : CellsList[l1] are not in elements list of node l
- break ;
- if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
- // we have found one
- NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
- NewNumberOfCellsInList++;
- break;
+ // foreach node in sub cell, we search elements which are in common
+ // at the end, we must have only one !
+
+ for (int l=1; l<NumberOfNodesPerConstituent; l++) {
+ int NewNumberOfCellsInList = 0;
+ int * NewCellsList = new int[NumberOfCellsInList];
+ for (int l1=0; l1<NumberOfCellsInList; l1++)
+ for (int l2=ReverseNodalConnectivityIndex[NodesLists[l]-1]; l2<ReverseNodalConnectivityIndex[NodesLists[l]]; l2++) {
+ if (CellsList[l1]<ReverseNodalConnectivityValue[l2-1])
+ // increasing order : CellsList[l1] are not in elements list of node l
+ break;
+ if ((CellsList[l1]==ReverseNodalConnectivityValue[l2-1])&(CellsList[l1]!=j)) {
+ // we have found one
+ NewCellsList[NewNumberOfCellsInList]=CellsList[l1];
+ NewNumberOfCellsInList++;
+ break;
+ }
}
- }
- NumberOfCellsInList = NewNumberOfCellsInList;
- delete [] CellsList ;
- CellsList = NewCellsList;
- }
-
- int CellNumber = CellsList[0] ;
- delete [] CellsList ;
- if (NumberOfCellsInList>1)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
-
+ NumberOfCellsInList = NewNumberOfCellsInList;
-// int cell_number_1=-1 ;
-// int cell_number_2=-1 ;
-// int cell_number_3=-1 ;
-// bool find = false ;
-// for (int l=ReverseNodalConnectivityIndex[NodesLists[0]-1]; l<ReverseNodalConnectivityIndex[NodesLists[0]]; l++) { // first node
-// cell_number_1 = ReverseNodalConnectivityValue[l-1] ;
-// if (cell_number_1 != j)
-// for (int m=ReverseNodalConnectivityIndex[NodesLists[1]-1]; m<ReverseNodalConnectivityIndex[NodesLists[1]]; m++) { //second node
-// cell_number_2 = ReverseNodalConnectivityValue[m-1] ;
-// if ((cell_number_2 != j) && (cell_number_2 == cell_number_1))
-// for (int n=ReverseNodalConnectivityIndex[NodesLists[2]-1]; n<ReverseNodalConnectivityIndex[NodesLists[2]]; n++) { //third node
-// cell_number_3 = ReverseNodalConnectivityValue[n-1] ;
-// if ((cell_number_3 != j) && (cell_number_3 == cell_number_1)) { // we found element which have three node in it
-// find = true ;
-// break ;
-// }
-// if (find)
-// break ;
-// }
-// if (find)
-// break ;
-// }
-// if (find)
-// break ;
-// }
-
-
-// if (find) {
- if (NumberOfCellsInList==1) {
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber ;
- // we search sub cell number in this cell to not calculate it another time
- // which type ?
- CELLMODEL Type2 ;
- for (int l=0; l<_numberOfTypes; l++)
- if (CellNumber < _count[l+1]) {
- Type2=_type[l] ;
- break ;
- }
- //int sub_cell_count2 = Type2.get_entities_count(1) ;
- //int nodes_cell_count2 = Type2.get_nodes_count() ;
- bool find2 = false ;
- for (int l=1; l<=Type2.getNumberOfConstituents(1) ;l++) { // on all sub cell
- int counter = 0 ;
- for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++)
- for (int n=1; n<=Type.getConstituentType(1,k)%100; n++) {
- if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1])
- counter++ ;
+ delete [] CellsList;
+ CellsList = NewCellsList;
+ }
+
+ if (NumberOfCellsInList > 0) { // We have found some elements !
+ int CellNumber = CellsList[0];
+ //delete [] CellsList;
+ if (NumberOfCellsInList>1)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<<NumberOfCellsInList<<") !"));
+
+ if (NumberOfCellsInList==1) {
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=CellNumber;
+
+ // we search sub cell number in this cell to not calculate it another time
+ // which type ?
+ CELLMODEL Type2;
+ for (int l=0; l<_numberOfTypes; l++)
+ if (CellNumber < _count[l+1]) {
+ Type2=_type[l];
+ break;
+ }
+ //int sub_cell_count2 = Type2.get_entities_count(1);
+ //int nodes_cell_count2 = Type2.get_nodes_count();
+ bool find2 = false;
+ for (int l=1; l<=Type2.getNumberOfConstituents(1);l++) { // on all sub cell
+ int counter = 0;
+ for (int m=1; m<=Type2.getConstituentType(1,l)%100; m++)
+ for (int n=1; n<=Type.getConstituentType(1,k)%100; n++) {
+ if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1])
+ counter++;
+ }
+ if (counter==Type.getConstituentType(1,k)%100) {
+ descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
+ find2 = true;
+ }
+ if (find2)
+ break;
}
- if (counter==Type.getConstituentType(1,k)%100) {
- descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side !
- find2 = true ;
- }
- if (find2)
- break ;
+ if (!find2)
+ INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ?
+ }
+ } else {
+ ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0;
}
- if (!find2)
- INFOS(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!") ; // exception ?
- } else
- ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0 ;
+ delete[] CellsList;
+ }
- delete[] NodesLists ;
+ delete[] NodesLists;
}
}
}
// we adjust _constituent
- int NumberOfConstituent=0 ;
- int SizeOfConstituentNodal=0 ;
+ int NumberOfConstituent=0;
+ int SizeOfConstituentNodal=0;
for (int i=0;i<_constituent->_numberOfTypes; i++) {
NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1;
SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes();
}
// we built new _nodal attribute in _constituent
- MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
- int *ConstituentNodalValue = ConstituentNodal->getValue();
- int *ConstituentNodalIndex = ConstituentNodal->getIndex();
+ //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal);
+ //const int *ConstituentNodalValue = ConstituentNodal->getValue();
+ //const int *ConstituentNodalIndex = ConstituentNodal->getIndex();
+ int *ConstituentNodalValue = new int[SizeOfConstituentNodal];
+ int *ConstituentNodalIndex = new int[NumberOfConstituent+1];
ConstituentNodalIndex[0]=1;
// we build _reverseDescendingConnectivity
- _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent) ;
- int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
- int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
+ //_reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,2*NumberOfConstituent);
+ //const int *reverseDescendingConnectivityValue = _reverseDescendingConnectivity->getValue();
+ //const int *reverseDescendingConnectivityIndex = _reverseDescendingConnectivity->getIndex();
+ int *reverseDescendingConnectivityValue = new int[2*NumberOfConstituent];
+ int *reverseDescendingConnectivityIndex = new int[NumberOfConstituent+1];
reverseDescendingConnectivityIndex[0]=1;
// first constituent type
}
// second type if any
if (_constituent->_numberOfTypes==2) {
- int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1 ;
+ int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1;
int offset1=offset*_constituent->_type[0].getNumberOfNodes();
- int offset2=offset*2 ;
+ int offset2=offset*2;
int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes();
for(int j=tmp_NumberOfConstituentsForeachType[0]; j<NumberOfConstituent; j++) {
ConstituentNodalIndex[j+1]=ConstituentNodalIndex[j]+NumberOfNodesPerConstituent;
reverseDescendingConnectivityValue[k-1]=ReverseDescendingConnectivityValue[offset2+k-1];
}
}
- _constituent->_count[2]=NumberOfConstituent+1 ;
+ _constituent->_count[2]=NumberOfConstituent+1;
// we correct _descending to adjust face number
for(int j=0;j<DescendingSize;j++)
if (descend_connectivity[j]>tmp_NumberOfConstituentsForeachType[0])
descend_connectivity[j]-=offset;
}
+
+ delete[] ConstituentNodalConnectivityIndex;
+ delete[] ConstituentNodalConnectivity;
+
+ _descending = new MEDSKYLINEARRAY(_count[_numberOfTypes]-1,
+ DescendingSize,
+ descend_connectivity_index,
+ descend_connectivity);
+ delete[] descend_connectivity_index;
+ delete[] descend_connectivity;
+ _reverseDescendingConnectivity = new MEDSKYLINEARRAY(NumberOfConstituent,
+ 2*NumberOfConstituent,
+ reverseDescendingConnectivityIndex,
+ reverseDescendingConnectivityValue);
+ delete[] reverseDescendingConnectivityIndex;
+ delete[] reverseDescendingConnectivityValue;
+
_constituent->_count[1]=tmp_NumberOfConstituentsForeachType[0]+1;
- delete _constituent->_nodal ;
- _constituent->_nodal = ConstituentNodal ;
+ delete[] tmp_NumberOfConstituentsForeachType;
+
+ //delete _constituent->_nodal;
+ _constituent->_nodal = new MEDSKYLINEARRAY(NumberOfConstituent,
+ SizeOfConstituentNodal,
+ ConstituentNodalIndex,
+ ConstituentNodalValue);
- delete[] ReverseDescendingConnectivityValue ;
+ delete[] ConstituentNodalIndex;
+ delete[] ConstituentNodalValue;
+
+ delete[] ReverseDescendingConnectivityValue;
}
END_OF(LOC);
}
// if (myConnectivity->getEntity()!=MED_CELL)
// throw MEDEXCEPTION("CONNECTIVITY::calculateReverseDescending
// Connectivity : we need MED_CELL connectivity !");
-// return ;
+// return;
// }
/*! Not implemented yet */
//--------------------------------------------------------------------//
{
// Mesh dimension !
- return ;
+ return;
}
Give, for one element number of a specified entity the geometric type
Of this element.
- Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35) ;
+ Example : medGeometryElement myType = myConnectivity.getElementType(MED_CELL,35);
*/
//--------------------------------------------------------------------//
medGeometryElement CONNECTIVITY::getElementType(medEntityMesh Entity,int Number) const
if (_entity==Entity) {
for(int i=1; i<=_numberOfTypes;i++)
if (Number<_count[i])
- return _geometricTypes[i-1] ;
+ return _geometricTypes[i-1];
}
else if (_constituent!=NULL)
- return _constituent->getElementType(Entity,Number) ;
+ return _constituent->getElementType(Entity,Number);
else
- throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !")) ;
- throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !")) ;
+ throw MEDEXCEPTION(LOCALIZED("getElementType : Entity not defined !"));
+ throw MEDEXCEPTION(LOCALIZED("getElementType : Wrong Number !"));
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Connectivity.hxx
+// Module : MED
+
#ifndef CONNECTIVITY_HXX
#define CONNECTIVITY_HXX
class FAMILY;
/*!
- this class deals with all type of connectivity
- this a recursive class in order to store
-
+ This class deals with all type of connectivity ./n
+ it a recursive class.
*/
-class CONNECTIVITY // recursive class
+/* ------------------------------------------- */
+class CONNECTIVITY
+/* ------------------------------------------- */
{
- /*
- Class Attributs
- */
+ /* ---------------------- */
+ /* Class Attributs */
+ /* ---------------------- */
protected:
/*! contains MED_CELL MED_FACE or MED_EDGE */
- medEntityMesh _entity ;
+ medEntityMesh _entity;
/*! contains MED_NODAL or MED_DESCEND */
- medConnectivity _typeConnectivity ;
+ medConnectivity _typeConnectivity;
/*! count of differents cells types
used by the mesh */
- med_int _numberOfTypes ;
+ med_int _numberOfTypes;
/*! array of all med_geometric_type used by MESH. */
- medGeometryElement* _geometricTypes ;
+ medGeometryElement* _geometricTypes;
/*! map indexed by med_geometric_type
which contains the different
'CellModel' used by MESH. */
- CELLMODEL * _type ;
+ CELLMODEL * _type;
/*! contains the dimension of the entity */
- med_int _entityDimension ;
+ med_int _entityDimension;
/*! needed by calculateReverseNodalConnectivity */
- med_int _numberOfNodes ;
+ med_int _numberOfNodes;
/*! array of size _numberOfTypes+1 which
gives for each cell type the first
( 0 <= i < _numberOfTypes ).
Note that _count[_numberOfTypes] returns
total cells count + 1 */
- med_int * _count ;
-
- /*! pointer on an array which stores the nodal connectivity */
- MEDSKYLINEARRAY* _nodal ;
- /*! pointer on an array which stores the descending connectivity */
- MEDSKYLINEARRAY* _descending ;
- /*! pointer on an array which stores the resverse nodal connectivity */
- MEDSKYLINEARRAY* _reverseNodalConnectivity ;
- /*! pointer on an array which stores the reverse descending connectivity */
- MEDSKYLINEARRAY* _reverseDescendingConnectivity ;
+ med_int * _count;
+
+ /*! pointer to an array which stores the nodal connectivity */
+ MEDSKYLINEARRAY* _nodal;
+ /*! pointer to an array which stores
+ the descending connectivity */
+ MEDSKYLINEARRAY* _descending;
+ /*! pointer to an array which stores
+ the reverse nodal connectivity */
+ MEDSKYLINEARRAY* _reverseNodalConnectivity;
+ /*! pointer to an array which stores
+ the reverse descending connectivity */
+ MEDSKYLINEARRAY* _reverseDescendingConnectivity;
/*! if face or edge, list of 2 cells or
2 faces it belongs to.
If 2nd number equals 0, we have a
boundary entity. We could use
MEDSKYLINEARRAY, but we suppose we have
always only 2 (or 1) entities. */
- MEDSKYLINEARRAY* _neighbourhood ;
+ MEDSKYLINEARRAY* _neighbourhood;
/*! connectivity of sub cell if
descendant connectivity is calculated */
- CONNECTIVITY * _constituent ;
+ CONNECTIVITY * _constituent;
- /*
- Class Methods
- */
+ /* -------------------- */
+ /* Class Methods */
+ /* -------------------- */
private:
- /*! does nothing if already exists, else
+ /*! private method :/n
+ does nothing if already exists, else
evaluates _nodal from _descending */
- void calculateNodalConnectivity() ;
- /*! does nothing if already exists, else
+ void calculateNodalConnectivity();
+ /*! private method :/n
+ does nothing if already exists, else
evaluates from _nodal */
- void calculateReverseNodalConnectivity() ;
- /*! does nothing if already exists, else
+ void calculateReverseNodalConnectivity();
+ /*! private method :/n
+ does nothing if already exists, else
evaluates _descending from _nodal */
- void calculateDescendingConnectivity() ;
- /*! does nothing if already exists, else
+ void calculateDescendingConnectivity();
+ /*! private method :/n
+ does nothing if already exists, else
evaluates from _descending */
- // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity) ;
- /*! does nothing if already exists, else
+ // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity);
+
+ const med_int* getReverseNodalConnectivity ();
+ const med_int* getReverseNodalConnectivityIndex ();
+ const med_int* getReverseDescendingConnectivity ();
+ const med_int* getReverseDescendingConnectivityIndex ();
+
+ /*! private method :/n
+ does nothing if already exists, else
evaluates _neighbourhood from _descending */
- void calculateNeighbourhood(CONNECTIVITY &myConnectivity) ;
+ void calculateNeighbourhood(CONNECTIVITY &myConnectivity);
public:
friend class MED_MESH_RDONLY_DRIVER;
friend class MED_MESH_WRONLY_DRIVER;
- CONNECTIVITY(medEntityMesh Entity=MED_CELL);
- CONNECTIVITY(int numberOfTypes, medEntityMesh Entity=MED_CELL);
- ~CONNECTIVITY();
+ // in order to fill CONNECTIVITY of MESH
+ friend class GRID;
+
+ CONNECTIVITY (medEntityMesh Entity=MED_CELL);
+ CONNECTIVITY (int numberOfTypes, medEntityMesh Entity=MED_CELL);
+ CONNECTIVITY (const CONNECTIVITY & m);
+ ~CONNECTIVITY ();
+
+ void setConstituent (CONNECTIVITY * Constituent)
+ throw (MEDEXCEPTION);
+
+ void setGeometricTypes (const medGeometryElement * Types,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION);
- inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const ;
- void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity) ;
- void updateFamily(vector<FAMILY*> myFamilies) ;
+ void setCount (const int * Count, const medEntityMesh Entity)
+ throw (MEDEXCEPTION);
- inline medEntityMesh getEntity () const;
- inline med_int getNumberOfTypes (medEntityMesh Entity) const;
- inline medGeometryElement * getGeometricTypes (medEntityMesh Entity) const;
- medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
- inline int * getGlobalNumberingIndex (medEntityMesh Entity) const ;
+ void setNodal (const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type)
+ throw (MEDEXCEPTION);
- med_int * getConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity,
- medGeometryElement Type) ;
- med_int * getConnectivityIndex (medConnectivity ConnectivityType,medEntityMesh Entity) ;
+ inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const;
+
+ void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity);
+
+ void updateFamily (vector<FAMILY*> myFamilies);
+
+ inline medEntityMesh getEntity () const;
+ inline med_int getNumberOfTypes (medEntityMesh Entity) const;
+ inline const medGeometryElement * getGeometricTypes (medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
+ medGeometryElement getElementType (medEntityMesh Entity,
+ int Number) const;
+ inline const int * getGlobalNumberingIndex (medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
+
+ const med_int * getConnectivity (medConnectivity ConnectivityType,
+ medEntityMesh Entity,
+ medGeometryElement Type);
+ const med_int * getConnectivityIndex (medConnectivity ConnectivityType,
+ medEntityMesh Entity);
- CELLMODEL & getType (medGeometryElement Type) const;
- CELLMODEL * getCellsTypes (medEntityMesh Entity) const;
+ const CELLMODEL & getType (medGeometryElement Type) const;
+ const CELLMODEL * getCellsTypes (medEntityMesh Entity) const
+ throw (MEDEXCEPTION);
- med_int getNumberOfNodesInType (medGeometryElement Type) const;
- med_int getNumberOfSubCellInType (medGeometryElement Type) const;
- med_int getNumberOf (medEntityMesh Entity, medGeometryElement Type) const;
- med_int* getValue (medConnectivity TypeConnectivity, medGeometryElement Type) ;
- med_int* getValueIndex (medConnectivity TypeConnectivity) ;
- med_int* getReverseNodalConnectivity () ;
- med_int* getReverseNodalConnectivityIndex () ;
- med_int* getReverseDescendingConnectivity () ;
- med_int* getReverseDescendingConnectivityIndex () ;
- med_int* getNeighbourhood() const;
-
-} ;
+ med_int getNumberOfNodesInType (medGeometryElement Type) const;
+ med_int getNumberOfSubCellInType (medGeometryElement Type) const;
+ med_int getNumberOf (medEntityMesh Entity,
+ medGeometryElement Type) const;
+ const med_int* getValue (medConnectivity TypeConnectivity,
+ medGeometryElement Type);
+ const med_int* getValueIndex (medConnectivity TypeConnectivity);
+
+ inline const med_int* getReverseConnectivity (medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL)
+ throw (MEDEXCEPTION);
+ inline const med_int* getReverseConnectivityIndex (medConnectivity ConnectivityType,
+ medEntityMesh Entity=MED_CELL)
+ throw (MEDEXCEPTION);
+
+ const med_int* getNeighbourhood() const;
+
+};
/*----------------------*/
/* Methodes Inline */
/*----------------------*/
/*! Returns the medEntityMesh */
+//--------------------------------------------------//
inline medEntityMesh CONNECTIVITY::getEntity() const
+//--------------------------------------------------//
{
- return _entity;
+ return _entity;
}
-/*! Returns the number of different <medGeometryElement> types existing in the specified entity.
-
+/*! Returns the number of different <medGeometryElement> types
+ existing in the specified entity. /n
Note : Not implemented for MED_ALL_ENTITIES. */
+//-----------------------------------------------------------------------//
inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
+//-----------------------------------------------------------------------//
{
MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "<<Entity<<", _entity = "<<_entity);
if (_entity==Entity)
- return _numberOfTypes;
+ return _numberOfTypes;
else if (_constituent!=NULL)
- return _constituent->getNumberOfTypes(Entity) ;
+ return _constituent->getNumberOfTypes(Entity);
else
- return 0 ; // because it is the right information (no need exception !
- //throw MEDEXCEPTION("Entity not defined !") ;
+ return 0; // because it is the right information (no exception needed)!
}
-/*! Returns an array of all <med geometry elements> types existing in the mesh for the given medEntityMesh.
-
- Note : Not implemented for MED_ALL_ENTITIES. */
-inline medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
+/*! Returns an array of all <med geometry elements> types existing in the mesh
+ for the given medEntityMesh./n
+ Note : Not implemented for MED_ALL_ENTITIES. /n
+ Throws an exception if Entity is unknown */
+//------------------------------------------------------------------------------------------//
+inline const medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
+ throw (MEDEXCEPTION)
+//------------------------------------------------------------------------------------------//
{
if (_entity==Entity)
- return _geometricTypes;
+ return _geometricTypes;
else if (_constituent!=NULL)
- return _constituent->getGeometricTypes(Entity) ;
+ return _constituent->getGeometricTypes(Entity);
else
- throw MEDEXCEPTION("Entity not defined !") ;
+ throw MEDEXCEPTION("Entity not defined !");
}
/*! A DOCUMENTER */
-inline int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
+//----------------------------------------------------------------------------------//
+inline const int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
+ throw (MEDEXCEPTION)
+//----------------------------------------------------------------------------------//
{
if (_entity==Entity)
- return _count;
+ return _count;
else if (_constituent!=NULL)
- return _constituent->getGlobalNumberingIndex(Entity) ;
+ return _constituent->getGlobalNumberingIndex(Entity);
else
- throw MEDEXCEPTION("Entity not defined !") ;
+ throw MEDEXCEPTION("Entity not defined !");
}
/*! Returns true if a connectivity exists on elements of type "Entity" */
-inline bool CONNECTIVITY::existConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
+inline bool CONNECTIVITY::existConnectivity( medConnectivity ConnectivityType,
+ medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
{
if (_entity==Entity) {
MESSAGE("existConnectivity : _entity==Entity="<<Entity);
if ((ConnectivityType==MED_NODAL)&(_nodal!=(MEDSKYLINEARRAY*)NULL))
- return true ;
+ return true;
if ((ConnectivityType==MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL))
- return true ;
+ return true;
} else if (_constituent!=NULL)
- return _constituent->existConnectivity(ConnectivityType,Entity) ;
- return false ;
+ return _constituent->existConnectivity(ConnectivityType,Entity);
+ return false;
}
/*!
-Return an array which contain CELLMODEL foreach element type present in connectivity for given medEntityMesh (similar as getGeometricTypes)
-
+Returns an array containing CELLMODEL foreach element type present
+in connectivity for given medEntityMesh (similar as getGeometricTypes)./n
Throw an execption if the given entity is not defined or if the array is not defined.
*/
-inline CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
+//-----------------------------------------------------------------------------//
+inline const CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
+ throw (MEDEXCEPTION)
+//-----------------------------------------------------------------------------//
{
if (Entity == _entity)
if (_type!=NULL)
- return _type ;
+ return _type;
else
- throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : CELLMODEL array is not defined !");
+ throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) :
+ CELLMODEL array is not defined !");
else
if (_constituent != NULL)
- return _constituent->getCellsTypes(Entity) ;
+ return _constituent->getCellsTypes(Entity);
else
throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !");
}
+/*! A DOCUMENTER */
+//------------------------------------------------------------------------------------------//
+inline const med_int* CONNECTIVITY::getReverseConnectivity( medConnectivity ConnectivityType,
+ medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//------------------------------------------------------------------------------------------//
+{
+ if(_entity==Entity)
+ if (ConnectivityType==MED_NODAL)
+ return getReverseNodalConnectivity();
+ else if (ConnectivityType==MED_DESCENDING)
+ return getReverseDescendingConnectivity();
+ else
+ throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !");
+
+ // other entity :
+ if (NULL==_constituent)
+ calculateDescendingConnectivity();
+ return _constituent->getReverseConnectivity(ConnectivityType,Entity);
+}
+
+/*! A DOCUMENTER */
+//-----------------------------------------------------------------------------------------------//
+inline const med_int* CONNECTIVITY::getReverseConnectivityIndex(medConnectivity ConnectivityType,
+ medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+//-----------------------------------------------------------------------------------------------//
+{
+ if(_entity==Entity)
+ if (ConnectivityType==MED_NODAL)
+ return getReverseNodalConnectivityIndex();
+ else if (ConnectivityType==MED_DESCENDING)
+ return getReverseDescendingConnectivityIndex();
+ else
+ throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !");
+
+ // other entity :
+ if (NULL==_constituent)
+ calculateDescendingConnectivity();
+ return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity);
+}
+
#endif /* CONNECTIVITY_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Coordinate.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_STRING.hxx"
+
#include "utilities.h"
-/*! This class contains coordinates of the nodes */
+/*! Default Constructor : should not be used */
//----------------------------------------------------------//
-COORDINATE::COORDINATE():_coordinate((MEDARRAY<double>*)NULL),
- _coordinateName((string*)NULL),
- _coordinateUnit((string*)NULL),
- _nodeNumber((int*)NULL)
+COORDINATE::COORDINATE():_coordinate(MEDARRAY<double>()),
+ _coordinateName(),
+ _coordinateUnit(),
+ _coordinateSystem(""),
+ _nodeNumber()
//----------------------------------------------------------//
{
BEGIN_OF("Default Constructor COORDINATE");
}
+/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes./n
+ It will create empty array for optional data (nodeNumber..) */
//------------------------------------------------------------------------------//
-COORDINATE::COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes):
- _nodeNumber((int*)NULL)
+COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode):
+ _nodeNumber(),
+ _coordinateUnit(SpaceDimension),
+ _coordinateSystem(""),
+ _coordinateName(SpaceDimension),
+ _coordinate(SpaceDimension,NumberOfNodes,Mode)
+
//------------------------------------------------------------------------------//
{
BEGIN_OF("Constructor COORDINATE");
- _coordinateName = new string[SpaceDimension] ;
- _coordinateUnit = new string[SpaceDimension] ;
- _coordinate = new MEDARRAY<double>(SpaceDimension,NumberOfNodes,Mode);
}
+
+/*! This constructor will COPY all data (it is a deep copy) included in m./n
+ But only the default storage mode of coordinates array
+ will be copied (not both storage representation modes even if they both
+ exist in original object) : for example only full_interlace mode */
+//------------------------------------------------------------------------------//
+COORDINATE::COORDINATE(const COORDINATE & m):
+ _coordinateSystem(m._coordinateSystem),
+ _coordinate(m._coordinate,false)
+//------------------------------------------------------------------------------//
+{
+ BEGIN_OF("Copy Constructor COORDINATE");
+
+ int spaceDimension = _coordinate.getLeadingValue();
+ int numberOfNodes = _coordinate.getLengthValue();
+
+ SCRUTE(spaceDimension);
+ setCoordinatesNames((const string*)m._coordinateName) ;
+ setCoordinatesUnits((const string*)m._coordinateUnit) ;
+
+ if ( (const int * const) m._nodeNumber != NULL)
+ _nodeNumber.set(numberOfNodes,(const med_int*)m._nodeNumber);
+ // PG : it's default no ?
+// else
+// {
+// _nodeNumber.set(0);
+// }
+}
+
+
+/* does nothing : all attributs are object (not pointers) */
//----------------------//
COORDINATE::~COORDINATE()
//----------------------//
{
- MESSAGE("Debut Destructeur COORDINATE");
- if (_coordinate!=NULL)
- delete _coordinate ;
- if (_coordinateName!=NULL)
- delete[] _coordinateName ;
- if (_coordinateUnit!=NULL)
- delete[] _coordinateUnit ;
- if (_nodeNumber!=NULL)
- delete[] _nodeNumber ;
- }
+ MESSAGE("~COORDINATE()");
+}
-/*! set the attribute _coordinate with Coordinate */
+/*! sets the attribute _coordinate with Coordinate */
//----------------------------------------------------------//
void COORDINATE::setCoordinates(MEDARRAY<double> *Coordinate)
//----------------------------------------------------------//
{
- _coordinate=Coordinate ;
+
+ const medModeSwitch mode = Coordinate->getMode();
+ const int spaceDimension = (int) Coordinate->getLeadingValue();
+ const int numberOfNodes = (int) Coordinate->getLengthValue();
+ if ( Coordinate->get(mode) != NULL)
+ {
+ MEDARRAY<double> pourAttribut(*Coordinate,false);
+ _coordinate = pourAttribut;
+ //_coordinate.set(mode,Coordinate->get(mode));
+ }
+ else
+ {
+ throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY<double>
+ *Coordinate)") << "No Coordinate"));
+ }
}
-/*! set the attribute _coordinateName with CoordinateName */
+/*!
+ Sets the value in attribute _coordinate with Coordinate.
+ _coordinate must be allocated (with
+ COORDINATE::COORDINATE(int,int,medModeSwitch).
+*/
//----------------------------------------------------------//
-void COORDINATE::setCoordinatesNames(string * CoordinateName)
+void COORDINATE::setCoordinates(const medModeSwitch Mode,
+ const double *Coordinate)
//----------------------------------------------------------//
-{
- _coordinateName=CoordinateName ;
+{
+// if (_coordinate == NULL)
+// throw MEDEXCEPTION("COORDINATE::setCoordinates(double*) : coordinate array not allocated !");
+
+ _coordinate.set(Mode,Coordinate);
+}
+
+/*! sets the attribute _coordinateName with CoordinateName */
+//----------------------------------------------------------//
+void COORDINATE::setCoordinatesNames(const string * CoordinateName)
+//----------------------------------------------------------//
+{
+ int SpaceDimension = getSpaceDimension() ;
+ _coordinateName.set(SpaceDimension) ;
+ for (int i=0; i<SpaceDimension; i++)
+ _coordinateName[i]=CoordinateName[i];
+}
+
+/*!
+ sets the (i+1)^th component of the attribute _coordinateName with
+ CoordinateName
+*/
+//----------------------------------------------------------//
+void COORDINATE::setCoordinateName(const string CoordinateName, const int i)
+//----------------------------------------------------------//
+{
+ _coordinateName[i]=CoordinateName;
+}
+
+/*! sets the attribute _coordinateUnit with CoordinateUnit */
+//----------------------------------------------------------//
+void COORDINATE::setCoordinatesUnits(const string * CoordinateUnit)
+//----------------------------------------------------------//
+{
+ int SpaceDimension = getSpaceDimension() ;
+ _coordinateUnit.set(SpaceDimension) ;
+ for (int i=0; i<SpaceDimension; i++)
+ _coordinateUnit[i]=CoordinateUnit[i];
}
-/*! set the attribute _coordinateUnit with CoordinateUnit */
+/*!
+ sets the (i+1)^th component of the attribute _coordinateUnit with
+ CoordinateUnit
+*/
//----------------------------------------------------------//
-void COORDINATE::setCoordinatesUnits(string * CoordinateUnit)
+void COORDINATE::setCoordinateUnit(const string CoordinateUnit, const int i)
//----------------------------------------------------------//
{
- _coordinateUnit=CoordinateUnit ;
+ _coordinateUnit[i]=CoordinateUnit;
}
-/*! set the attribute _nodeNumber with NodeNumber */
+/*! sets the attribute _coordinateSystem with CoordinateSystem */
+//----------------------------------------------------------//
+void COORDINATE::setCoordinatesSystem(const string CoordinateSystem)
+//----------------------------------------------------------//
+{
+ _coordinateSystem=CoordinateSystem;
+}
+
+/*! sets the attribute _nodeNumber with NodeNumber */
//------------------------------------------------//
-void COORDINATE::setNodesNumbers(int * NodeNumber)
+void COORDINATE::setNodesNumbers(const int * NodeNumber)
//------------------------------------------------//
{
- _nodeNumber=NodeNumber ;
+ int NumberOfNodes = getNumberOfNodes() ;
+ _nodeNumber.set(NumberOfNodes,NodeNumber) ;
+}
+
+int COORDINATE::getSpaceDimension() const
+{
+ _coordinate.getLeadingValue() ;
+}
+
+int COORDINATE::getNumberOfNodes() const
+{
+ _coordinate.getLengthValue() ;
}
-/*! returns the number of nodes defined in the mesh*/
+
+/*! returns a pointer to the optional array storing
+ eventual nodes numbers */
//-------------------------------------------------//
-int * COORDINATE::getNodesNumbers() const
+const int * COORDINATE::getNodesNumbers() const
//-------------------------------------------------//
{
- return _nodeNumber;
+ return (const int *)_nodeNumber;
}
-/*! returns the mode of coordinates (FULL_INTERLACE or NO_INTERLACE) */
-//-------------------------------------------------------------------//
-const double * COORDINATE::getCoordinates (medModeSwitch Mode)
-//-------------------------------------------------------------------//
+/*! returns a Pointer to Coordinates Array in specified mode representation */
+//--------------------------------------------------------------------------//
+const double * COORDINATE::getCoordinates (medModeSwitch Mode)
+//--------------------------------------------------------------------------//
{
- return _coordinate->get(Mode) ;
+ return _coordinate.get(Mode) ;
}
/* returns the coordinate of node Number on axis Axis */
double COORDINATE::getCoordinate(int Number,int Axis)
//----------------------------------------------------//
{
- return _coordinate->getIJ(Number,Axis) ;
+ return _coordinate.getIJ(Number,Axis) ;
}
/* returns all nodes coordinates from axis Axis */
//----------------------------------------------------//
-const double * COORDINATE::getCoordinateAxis(int Axis)
+const double * COORDINATE::getCoordinateAxis(int Axis)
//----------------------------------------------------//
{ //< return all nodes coordinates from axis Axis
- return _coordinate->getI(MED_NO_INTERLACE,Axis) ;
+ return _coordinate.getColumn(Axis) ;
}
-/*! Returns an array with names of coordinates.
- Example :
- - x,y,z
- - r,teta,phi
+/*! returns an array with names of coordinates. /n
+ Example : /n
+ - x,y,z /n
+ - r,teta,phi /n
- ... */
//--------------------------------------//
-string * COORDINATE::getCoordinatesNames()
+const string * COORDINATE::getCoordinatesNames() const
{
return _coordinateName ;
}
/* returns the name of axis Axis */
//-------------------------------------------//
-string COORDINATE::getCoordinateName(int Axis)
+string COORDINATE::getCoordinateName(int Axis) const
//-------------------------------------------//
{
return _coordinateName[Axis-1];
}
-/*! Returns an array with units of coordinates (cm, m, mm, ...)
+/*! returns an array with units of coordinates (cm, m, mm, ...)
It could be empty. We suppose we are IS (meter). */
//-----------------------------------------------------//
-string * COORDINATE::getCoordinatesUnits()
+const string * COORDINATE::getCoordinatesUnits() const
//-----------------------------------------------------//
{
return _coordinateUnit ;
}
-/*! Returns the unit of axis Axis */
+/*! returns the unit of axis Axis */
//------------------------------------------//
-string COORDINATE::getCoordinateUnit(int Axis)
+string COORDINATE::getCoordinateUnit(int Axis) const
//------------------------------------------//
{
return _coordinateUnit[Axis-1] ;
}
-/*! Returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
+/*! returns "CARTESIAN", "CYLINDRICAL" or "SPHERICAL"*/
//---------------------------------------------------//
string COORDINATE::getCoordinatesSystem() const
//---------------------------------------------------//
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Coordinate.hxx
+// Module : MED
+
/*
File Coordinate.hxx
$Header$
#include <string>
+#include "MEDMEM_PointerOf.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
-//using namespace MED_EN;
#include "MEDMEM_Array.hxx"
-class COORDINATE {
+/*!
+ This class contains coordinates of the nodes ./n
+ It could also store useful optional information about nodes
+ as node numbers and about axes as names or units. /n
+ spaceDimension and numberOfNodes can be found in _coordinate object.
+*/
+
+class COORDINATE
+{
protected:
/*! contains "CARTESIAN",
"CYLINDRICAL" or "SPHERICAL"*/
- string _coordinateSystem;
+ string _coordinateSystem;
+
+
+ /*! _coordinate is a MEDARRAY<double> object : \n
+ - spaceDimension /n
+ - numberOfNodes /n
+ - default storage mode /n
+ - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes/n
+
+ Storing the object (not a pointer to this object) is more convenient for memory
+ management.
+ */
+ MEDARRAY<double> _coordinate;
- // all in _coordinate object !!!
- // int _spaceDimension;
- // int _numberOfNodes;
+ /*! PointerOf to an array of size spaceDimension storing axes names*/
+ PointerOf<string> _coordinateName;
+
+ /*! PointerOf to an array of size spaceDimension storing units */
+ PointerOf<string> _coordinateUnit;
+
+ /*! PointerOf to an array of size NumberOfNodes : optional nodes numbers */
+ PointerOf<int> _nodeNumber;
- /*! array of size spaceDimension*NumberOfNodes */
- MEDARRAY<double>* _coordinate;
- /*! array of size spaceDimension */
- string * _coordinateName;
- /*! array of size spaceDimension */
- string * _coordinateUnit;
- /*! array of size NumberOfNodes : optionnal nodes numbers */
- int * _nodeNumber;
public :
COORDINATE();
- COORDINATE(medModeSwitch Mode,int SpaceDimension, int NumberOfNodes);
+ COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode);
+ COORDINATE(const COORDINATE & m);
~COORDINATE();
void setCoordinates(MEDARRAY<double> *Coordinate);
- void setCoordinatesNames(string * CoordinateName);
- void setCoordinatesUnits(string * CoordinateUnit);
- void setNodesNumbers(int * NodeNumber);
-
- int* getNodesNumbers() const;
+ void setCoordinates(const medModeSwitch Mode, const double *Coordinate);
+ void setCoordinatesNames(const string * CoordinateName);
+ void setCoordinateName(const string CoordinateName, const int i);
+ void setCoordinatesUnits(const string * CoordinateUnit);
+ void setCoordinateUnit(const string CoordinateUnit, const int i);
+ void setCoordinatesSystem(const string CoordinateSystem);
+ void setNodesNumbers(const int * NodeNumber);
+
+ int getSpaceDimension() const;
+ int getNumberOfNodes() const;
+
+ const int* getNodesNumbers() const;
+ //const int* getNodesNumbers() ;
string getCoordinatesSystem() const;
+
const double * getCoordinates(medModeSwitch Mode);
- double getCoordinate(int Number,int Axis);
- // return coordinate of node number Number, on axis Axis (1: X, 2: Y, 3: Z)
- const double * getCoordinateAxis(int Axis);
- // return all nodes coordinates from axis Axis
- string * getCoordinatesNames();
- string getCoordinateName(int Axis);
- string * getCoordinatesUnits();
- string getCoordinateUnit(int Axis);
+ double getCoordinate(int Number,int Axis);
+ const double * getCoordinateAxis(int Axis);
+
+ const string * getCoordinatesNames() const;
+ string getCoordinateName(int Axis) const;
+ const string * getCoordinatesUnits() const;
+ string getCoordinateUnit(int Axis) const;
};
#endif /* COORDINATE_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_DriversDef.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_DriversDef.hxx"
-namespace MED_FR {
+namespace MED_FR
+{
// Returns the (string) name of the geometry of
// an element given by a med_geometrie_element value
-GEO_NAME::GEO_NAME () : map<int,string>()
+GEO_NAME::GEO_NAME() : map<int,string>()
{
map<int,string> &table = (map<int,string>&)*this ;
table[(int)0 ] = "MED_NONE" ;
// Returns the (string) name of the type of
// an entity given by a med_entite_maillage value
-ENT_NAME:: ENT_NAME () : map<int,string>()
+ENT_NAME::ENT_NAME() : map<int,string>()
{
map<int,string> &table = (map<int,string>&)*this ;
table[(int)MED_MAILLE ] = "MED_MAILLE";
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_DriversDef.hxx
+// Module : MED
+
# ifndef DRIVERS_DEF_HXX
# define DRIVERS_DEF_HXX
using namespace std ;
#include "MEDMEM_define.hxx"
-namespace MED_FR {
+namespace MED_FR
+{
-// Returns the (string) name of the geometry of
-// an element given by a med_geometrie_element value
+/*! This Class inherits from map. /n
+ It is a constant map association int (which is a med_geometrie_element) and string. /n
+ Operator [] returns the (string) name of the geometry of an element
+ given by a med_geometrie_element value. /n
+ Such a static map is instancied and can be used in any code to have
+ the name of the geometry of an element : MED_FR:GEO_NAME
+ A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */
+//----------------------------------------
class GEO_NAME : public map<int,string>
+//----------------------------------------
{
public :
- GEO_NAME ();
-
+ GEO_NAME();
string & operator[]( const MED_FR::med_geometrie_element &c ) const;
} ;
-
static const GEO_NAME geoNames ;
+
+// ____________________________
-// Returns the (string) name of the type of
-// an entity given by a med_entite_maillage value
+/*! This Class inherits from map. /n
+ It is a constant map association int (which is a med_entite_maillage) and string. /n
+ Operator[] returns the (string) name of the type of an entity given by
+ a med_entite_maillage value. /n
+ Such a static map is instancied and can be used in any code to have
+ the name of the geometry of an element : MED_FR:ENT_NAME
+ A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */
+
+//----------------------------------------
class ENT_NAME : public map<int,string>
+//----------------------------------------
{
public :
+
ENT_NAME ();
string & operator[]( const MED_FR::med_entite_maillage &c ) const;
} ;
static const ENT_NAME entNames ;
+// ____________________________
+
+/*! This Class inherits from map. /n
+ It is a constant map association int (which is a med_entite_maillage) and a list. /n
+ Operator[] returns the list of all exisiting med_geometrie_element for
+ a med_entite_maillage value. /n
+ Such a static map is instancied and can be used in any code to have
+ the name of the geometry of an element : MED_FR:MESH_ENTITIES
+ A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */
+
+
+//--------------------------------------------------------------------------------
class MESH_ENTITIES : public map<int, const list<MED_FR::med_geometrie_element> >
+//--------------------------------------------------------------------------------
{
public :
const list<MED_FR::med_geometrie_element> & operator[]( const MED_FR::med_entite_maillage &c ) const;
private:
- // This operator is used to initialize class objects of type const list<med_geometrie_element>
+ /*! This operator is used to initialize class objects of
+ type const list<med_geometrie_element> */
list<MED_FR::med_geometrie_element> & operator[]( const MED_FR::med_entite_maillage &c );
} ;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Exception.cxx
+// Module : MED
+
+using namespace std;
/*
File MedException.cxx
$Header$
}
+/*!
+ \internal
+ Function used to duplicate char *
+*/
const char* duplicate( const char *const str ) ;
-
const char* duplicate( const char *const str )
{
ASSERT(str!=NULL) ;
return new_str ;
}
+/*!
+ \internal Default Constructor (Should not be used)
+*/
+// ------------------------------------------------------ //
MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0)
+// ------------------------------------------------------ //
{
MESSAGE( "You must user the standard builder : MEDEXCEPTION::MEDEXCEPTION( const char *text )" ) ;
INTERRUPTION(1) ;
}
+/*!
+ \internal
+ Function used to elaborate the text of the MEDEXCEPTION
+*/
+// --------------------------------------------------------------------------------------- //
const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
+// --------------------------------------------------------------------------------------- //
{
char *newText = 0 ;
ASSERT(text) ;
- const size_t l1 = 1+strlen(text) ;
- ASSERT(l1>1) ;
+ const size_t l1 = strlen(text) ;
const char* prefix = "MED Exception" ;
- const size_t l0 = 2+strlen(prefix) ;
+ const size_t l0 = strlen(prefix) ;
if ( fileName )
- {
- const size_t l2 = 4+strlen(fileName) ;
- ASSERT(l2>4) ;
+ {
+ const size_t l2 = strlen(fileName) ;
ASSERT(lineNumber>=1) ;
- const size_t l3 = 4+int(log10(float(lineNumber))) ;
-
- newText = new char [ 1+l0+l1+l2+l3 ] ;
+ const size_t l3 = 1+int(log10(float(lineNumber))) ;
+
+ const size_t l4 = l0+l1+l2+l3+10+1 ;
+ newText = new char [ l4 ] ;
sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ;
- }
+ ASSERT(newText[l4-1] == '\0' );
+
+ }
else
- {
- newText = new char [ 1+l0+l1 ] ;
+ {
+ newText = new char [ l0+l1+3+1 ] ;
sprintf( newText , "%s : %s" , prefix, text ) ;
- }
+ }
ASSERT(newText) ;
return newText ;
}
-
-MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) )
+/*!
+ Constructor : \n
+ It will create the text of the MEDEXCEPTION from the different parameters.
+ It will take the form : \n
+ MEDEXCEPTION, fileName, lineNumber and text of the exception
+*/
+// ------------------------------------------------------------------------------------------------ //
+MEDEXCEPTION::MEDEXCEPTION( const char *text, const char *fileName, const unsigned int lineNumber ) :
+ exception(), _text( makeText( text , fileName , lineNumber ) )
+// ------------------------------------------------------------------------------------------------ //
{
MESSAGE(_text);
}
+/*!
+ Destructor : \n
+ If necessary desallocates Memory
+*/
+// ------------------------------------//
MEDEXCEPTION::~MEDEXCEPTION() throw ()
+// ------------------------------------//
{
if ( _text )
{
}
-
+/*!
+ Copy Constructor : \n
+ Should not be used very often
+*/
+// ----------------------------------------------------------------------- //
MEDEXCEPTION::MEDEXCEPTION( const MEDEXCEPTION &ex ): _text(duplicate(ex._text))
+// ----------------------------------------------------------------------- //
{
;
}
-
-
+/*!
+ Operator << : put the message to the given stream.
+*/
+// ------------------------------------------------------- //
ostream & operator<<( ostream &os , const MEDEXCEPTION &ex )
+// ------------------------------------------------------- //
{
os << ex._text ;
return os ;
}
-
-
+/*!
+ Return a char * which contain the message.
+*/
+// ------------------------------------------------- //
const char* MEDEXCEPTION::what( void ) const throw ()
+// ------------------------------------------------- //
{
return _text ;
}
MED_DRIVER_NOT_FOUND_EXCEPTION::MED_DRIVER_NOT_FOUND_EXCEPTION
(
- const char *text, const char *fileName=0,
- const unsigned int lineNumber=0
+ const char *text, const char *fileName/*=0*/,
+ const unsigned int lineNumber/*=0*/
) : MEDEXCEPTION(text, fileName, lineNumber) {};
MED_DRIVER_NOT_FOUND_EXCEPTION::~MED_DRIVER_NOT_FOUND_EXCEPTION() throw (){};
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Exception.hxx
+// Module : MED
+
/*
File MedException.hxx
$Header$
#endif
#define MED_EXCEPTION MEDEXCEPTION
-class MEDEXCEPTION : public exception
+
+/*!
+ Class used to throws exception.\n
+ Inherits from public exception.
+*/
+//--------------------------------------//
+ class MEDEXCEPTION : public exception
+//--------------------------------------//
{
private :
MEDEXCEPTION(void);
} ;
+//---------------------------------------------------------//
class MED_DRIVER_NOT_FOUND_EXCEPTION : public MEDEXCEPTION
+//---------------------------------------------------------//
{
private :
MED_DRIVER_NOT_FOUND_EXCEPTION(void);
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Family.cxx
+// Module : MED
+
+using namespace std;
/*
File MEDMEM_Family.cxx
$Header$
FAMILY::FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,
int *AttributeIdentifier, int *AttributeValue, string AttributeDescription,
- int NumberOfGroup, string GroupName
+ int NumberOfGroup, string GroupName,
+ int * MEDArrayNodeFamily,
+ int ** MEDArrayCellFamily,
+ int ** MEDArrayFaceFamily,
+ int ** MEDArrayEdgeFamily
): SUPPORT(Mesh,Name),
_identifier(Identifier),
_numberOfAttribute(NumberOfAttribute),
- _attributeIdentifier(AttributeIdentifier),
- _attributeValue(AttributeValue),
_numberOfGroup(NumberOfGroup)
{
MESSAGE("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "<<Identifier);
+ _isOnAllElts = false ;
+ // replace them by pointerOf ?
+ _attributeIdentifier = new int[_numberOfAttribute] ;
+ memcpy(_attributeIdentifier,AttributeIdentifier,_numberOfAttribute*sizeof(int));
+ _attributeValue = new int[_numberOfAttribute] ;
+ memcpy(_attributeValue,AttributeValue,_numberOfAttribute*sizeof(int));
+
_attributeDescription=new string[_numberOfAttribute];
for (int i=0;i<NumberOfAttribute;i++) {
_attributeDescription[i].assign(AttributeDescription,i*MED_TAILLE_DESC,MED_TAILLE_DESC);
// the list <tmp_NodesList> of node numbers <i+1> belonging to the family <_identifier>
int NumberOfNodes = _mesh->getNumberOfNodes();
int NumberOfNodesInFamily = 0 ;
- int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !!
+ //int * NodeFamilyNumber = _mesh->getMEDArrayNodeFamily() ; // EF : TEMPORAIRE !!
int * tmp_NodesList = new int[NumberOfNodes] ; // Un peu brutal...., oui mais ce n'est qu'un tableau de travail !
for (int i=0; i<NumberOfNodes; i++)
- if ( _identifier == NodeFamilyNumber[i] ) {
+ if ( _identifier == MEDArrayNodeFamily[i] ) {
tmp_NodesList[NumberOfNodesInFamily]=i+1 ;
NumberOfNodesInFamily++;
}
-
+ //SCRUTE(NumberOfNodesInFamily);
+
// If we found nodes set the family attributes adequatly
if (NumberOfNodesInFamily>0) {
Find = true ;
_entity = MED_NODE ;
- _numberOfGeometricType = 1 ;
- _geometricType = new medGeometryElement[1] ;
- _geometricType[0]=MED_NONE ;
+// _numberOfGeometricType = 1 ;
+// _geometricType = new medGeometryElement[1] ;
+// _geometricType[0]=MED_NONE ;
// family on all NODE
- if (NumberOfNodesInFamily==NumberOfNodes)
+ if (NumberOfNodesInFamily==NumberOfNodes) {
_isOnAllElts = true ;
- else {
+ update();
+ } else {
+ _numberOfGeometricType = 1 ;
+ if (_geometricType!=NULL) delete[] _geometricType ;
+ _geometricType = new medGeometryElement[1] ;
+ _geometricType[0]=MED_NONE ;
_isOnAllElts= false ;
- _numberOfEntities = new int[1] ;
- _numberOfEntities[0]=NumberOfNodesInFamily ;
- _totalNumberOfEntities=NumberOfNodesInFamily;
+ if (_numberOfElements!=NULL) delete[] _numberOfElements ;
+ _numberOfElements = new int[1] ;
+ _numberOfElements[0]=NumberOfNodesInFamily ;
+ _totalNumberOfElements=NumberOfNodesInFamily;
- _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ;
- int * NumberIndex = _number->getIndex();
- int * NumberValue = _number->getValue();
+// _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily) ;
+// int * NumberIndex = _number->getIndex();
+// int * NumberValue = _number->getValue();
+ int * NumberIndex = new int[2];
+ int * NumberValue = new int[NumberOfNodesInFamily];
+
NumberIndex[0]=1; //set the MEDSKYLINEARRAY Index table
NumberIndex[1]=1+NumberOfNodesInFamily; //set the MEDSKYLINEARRAY Index table
for(int i=0; i<NumberOfNodesInFamily; i++) // OH LA LA...
NumberValue[i]=tmp_NodesList[i] ; // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
// PG : pas de problème, si ca marche. Il faudra déplacer le delete !
+ if(_number!=NULL) delete _number ;
+ _number=new MEDSKYLINEARRAY(1,NumberOfNodesInFamily,NumberIndex,NumberValue) ;
+ delete[] NumberIndex ;
+ delete[] NumberValue ;
}
}
delete[] tmp_NodesList ;
// ?? Scan every cell family number <NodeFamilyNumber[i]> in order to create
// ?? the list <tmp_NodesList> of node numbers <i+1> belonging to the family <_identifier>
if (!Find) {
-
- // Get cell types information from <_mesh>
- int numberOfCellTypes = _mesh->getNumberOfTypes(MED_CELL) ;
- medGeometryElement * cellTypes = _mesh->getTypes(MED_CELL) ;
-
- int * numberOfCellsInFamily = new int[numberOfCellTypes] ;
- int numberOfCellTypesInFamily = 0 ;
-
- medGeometryElement * tmp_CellsTypes = new medGeometryElement[numberOfCellTypes];
- int ** tmp_CellsLists = new int*[numberOfCellTypes] ;
- int * GeometricTypeNumber = new int[numberOfCellTypes] ;
- int ** CellFamilyNumber = _mesh->getMEDArrayCellFamily(); // EF: TEMPORAIRE
- int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_CELL);
-
- // we search for all cell in this family
- for (int cellTypeNumber=0; cellTypeNumber < numberOfCellTypes; cellTypeNumber++) {
-
- int NumberOfCells = _mesh->getNumberOfElements(MED_CELL,cellTypes[cellTypeNumber]) ;
- int NumberOfCellsInThisFamily = 0 ;
- int * CellsOfThisFamilyNumber = CellFamilyNumber[cellTypeNumber];
- int * tmp_CellsList = new int[NumberOfCells];
-
- for (int i=0; i<NumberOfCells; i++)
- if (_identifier == CellsOfThisFamilyNumber[i]) {
- tmp_CellsList[NumberOfCellsInThisFamily]=i+GlobalNumberingIndex[cellTypeNumber] ;
- NumberOfCellsInThisFamily++;
- }
-
- if (NumberOfCellsInThisFamily>0) {// we have found some cells
- numberOfCellsInFamily[numberOfCellTypesInFamily]=NumberOfCellsInThisFamily;
- int * CellsList=new int[NumberOfCellsInThisFamily] ;
-
- for (int i=0;i<NumberOfCellsInThisFamily;i++)
- CellsList[i]=tmp_CellsList[i] ; // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
-
- tmp_CellsLists[numberOfCellTypesInFamily]=CellsList ;
- tmp_CellsTypes[numberOfCellTypesInFamily]=cellTypes[cellTypeNumber];
- GeometricTypeNumber[numberOfCellTypesInFamily]=cellTypeNumber+1;
- numberOfCellTypesInFamily++;
- }
-
- delete[] tmp_CellsList ;
- }
-
- // we define all attribut in SUPPORT :
- if (numberOfCellTypesInFamily>0) { // we have found cells
- Find = true ;
- _entity = MED_CELL ;
- _numberOfGeometricType = numberOfCellTypesInFamily ;
- _geometricType = new medGeometryElement[numberOfCellTypesInFamily] ;
- _geometricTypeNumber = new int[numberOfCellTypesInFamily] ;
- _isOnAllElts = false ;
- _numberOfEntities = new int[numberOfCellTypesInFamily] ;
- _totalNumberOfEntities=0;
- for (int i=0; i<numberOfCellTypesInFamily; i++) {
- _geometricType[i]=tmp_CellsTypes[i] ;
- _geometricTypeNumber[i]=GeometricTypeNumber[i];
- _numberOfEntities[i]=numberOfCellsInFamily[i] ;
- _totalNumberOfEntities+=numberOfCellsInFamily[i] ;
- }
- delete[] numberOfCellsInFamily;
- delete[] tmp_CellsTypes;
- delete[] GeometricTypeNumber;
-
- // family on all CELL ?
- if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)) {
- _isOnAllElts = true ;
- delete[] _numberOfEntities ;
- _numberOfEntities=(int*)NULL;
- } else {
- _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
- int *NumberValue=_number->getValue();
- int *NumberIndex=_number->getIndex();
- NumberIndex[0]=1;
- for (int i=0; i<_numberOfGeometricType; i++) {
- NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
- for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
- NumberValue[j-1]=tmp_CellsLists[i][j-NumberIndex[i]];
- delete[] tmp_CellsLists[i];
- }
- delete[] tmp_CellsLists;
- }
- }
+ Find = build(MED_CELL,MEDArrayCellFamily) ;
}
// on face ?
- if (!Find)
+ if (!Find) {
if ((_mesh->existConnectivity(MED_NODAL,MED_FACE))|(_mesh->existConnectivity(MED_DESCENDING,MED_FACE))) {
- int NumberOfFacesType = _mesh->getNumberOfTypes(MED_FACE) ;
- medGeometryElement * FacesType = _mesh->getTypes(MED_FACE) ;
- int * NumberOfFacesInFamily = new int[NumberOfFacesType] ;
- int NumberOfFacesTypeInFamily = 0 ;
- medGeometryElement * tmp_FacesTypes = new medGeometryElement[NumberOfFacesType];
- int ** tmp_FacesLists = new int*[NumberOfFacesType] ;
- int * GeometricTypeNumber = new int[NumberOfFacesType] ;
- int ** FaceFamilyNumber = _mesh->getMEDArrayFaceFamily();
- int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_FACE);
- // we search all face in this family
- for (int FaceTypeNumber=0; FaceTypeNumber<NumberOfFacesType; FaceTypeNumber++) {
- int NumberOfThisFaces = _mesh->getNumberOfElements(MED_FACE,FacesType[FaceTypeNumber]) ;
- int NumberOfFacesInThisFamily = 0 ;
- int * FaceOfThisFamilyNumber = FaceFamilyNumber[FaceTypeNumber];
- int * tmp_FacesList = new int[NumberOfThisFaces];
- for (int i=0; i<NumberOfThisFaces; i++)
- if (_identifier == FaceOfThisFamilyNumber[i]) {
- tmp_FacesList[NumberOfFacesInThisFamily]=i+GlobalNumberingIndex[FaceTypeNumber] ;
- NumberOfFacesInThisFamily++;
-
- SCRUTE(i);
- SCRUTE(NumberOfFacesInThisFamily);
-
- }
- if (NumberOfFacesInThisFamily>0) {// we have found some faces
- NumberOfFacesInFamily[NumberOfFacesTypeInFamily]=NumberOfFacesInThisFamily;
- int * FacesList=new int[NumberOfFacesInThisFamily] ;
- for (int i=0;i<NumberOfFacesInThisFamily;i++)
- FacesList[i]=tmp_FacesList[i] ;
- tmp_FacesLists[NumberOfFacesTypeInFamily]=FacesList ;
- tmp_FacesTypes[NumberOfFacesTypeInFamily]=FacesType[FaceTypeNumber];
- GeometricTypeNumber[NumberOfFacesTypeInFamily]=FaceTypeNumber+1;
- NumberOfFacesTypeInFamily++;
- }
- delete[] tmp_FacesList ;
- }
- // we define all attribut in SUPPORT :
- if (NumberOfFacesTypeInFamily>0) { // we have found faces
- Find = true ;
- _entity = MED_FACE ;
- _numberOfGeometricType = NumberOfFacesTypeInFamily ;
- _geometricType = new medGeometryElement[NumberOfFacesTypeInFamily] ;
- _geometricTypeNumber = new int[NumberOfFacesTypeInFamily] ;
- _isOnAllElts = false ;
- _numberOfEntities = new int[NumberOfFacesTypeInFamily] ;
- _totalNumberOfEntities=0;
- for (int i=0; i<NumberOfFacesTypeInFamily; i++) {
- _geometricType[i]=tmp_FacesTypes[i] ;
- _geometricTypeNumber[i]=GeometricTypeNumber[i];
- _numberOfEntities[i]=NumberOfFacesInFamily[i] ;
- _totalNumberOfEntities+=NumberOfFacesInFamily[i] ;
- }
- delete[] NumberOfFacesInFamily;
- delete[] tmp_FacesTypes;
- delete[] GeometricTypeNumber;
-
- // family on all FACE ?
-
- // we suppose family is never on all face !!!!!!!!!
- // in all case, family is only on boundary and connectivity is partial
-
-// if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)) {
-// _isOnAllElts = true ;
-// delete[] _numberOfEntities ;
-// _numberOfEntities=(int*)NULL;
-// } else {
- _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
- int *NumberValue=_number->getValue();
- int *NumberIndex=_number->getIndex();
- NumberIndex[0]=1;
- for (int i=0; i<_numberOfGeometricType; i++) {
- NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
- for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
- NumberValue[j-1]=tmp_FacesLists[i][j-NumberIndex[i]];
- delete[] tmp_FacesLists[i];
- }
- delete[] tmp_FacesLists;
-// }
- }
+ Find = build(MED_FACE,MEDArrayFaceFamily) ;
}
+ }
// on edge ?
- if (!Find)
+ if (!Find) {
if ((_mesh->existConnectivity(MED_NODAL,MED_EDGE))|(_mesh->existConnectivity(MED_DESCENDING,MED_EDGE))) {
- int NumberOfEdgesType = _mesh->getNumberOfTypes(MED_EDGE) ;
- medGeometryElement * EdgesType = _mesh->getTypes(MED_EDGE) ;
- int * NumberOfEdgesInFamily = new int[NumberOfEdgesType] ;
- int NumberOfEdgesTypeInFamily = 0 ;
- medGeometryElement * tmp_EdgesTypes = new medGeometryElement[NumberOfEdgesType];
- int ** tmp_EdgesLists = new int*[NumberOfEdgesType] ;
- int * GeometricTypeNumber = new int[NumberOfEdgesType] ;
- int ** EdgeFamilyNumber = _mesh->getMEDArrayEdgeFamily();
- int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(MED_EDGE);
- // we search all edge in this family
- for (int EdgeTypeNumber=0; EdgeTypeNumber<NumberOfEdgesType; EdgeTypeNumber++) {
- int NumberOfThisEdges = _mesh->getNumberOfElements(MED_EDGE,EdgesType[EdgeTypeNumber]) ;
- int NumberOfEdgesInThisFamily = 0 ;
- int * EdgeOfThisFamilyNumber = EdgeFamilyNumber[EdgeTypeNumber];
- int * tmp_EdgesList = new int[NumberOfThisEdges];
- for (int i=0; i<NumberOfThisEdges; i++)
- if (_identifier == EdgeOfThisFamilyNumber[i]) {
- tmp_EdgesList[NumberOfEdgesInThisFamily]=i+GlobalNumberingIndex[EdgeTypeNumber] ;
- NumberOfEdgesInThisFamily++;
- }
- if (NumberOfEdgesInThisFamily>0) {// we have found some edges
- NumberOfEdgesInFamily[NumberOfEdgesTypeInFamily]=NumberOfEdgesInThisFamily;
- int * EdgesList=new int[NumberOfEdgesInThisFamily] ;
- for (int i=0;i<NumberOfEdgesInThisFamily;i++)
- EdgesList[i]=tmp_EdgesList[i] ;
- tmp_EdgesLists[NumberOfEdgesTypeInFamily]=EdgesList ;
- tmp_EdgesTypes[NumberOfEdgesTypeInFamily]=EdgesType[EdgeTypeNumber];
- GeometricTypeNumber[NumberOfEdgesTypeInFamily]=EdgeTypeNumber+1;
- NumberOfEdgesTypeInFamily++;
- }
- delete[] tmp_EdgesList ;
- }
- // we define all attribut in SUPPORT :
- if (NumberOfEdgesTypeInFamily>0) { // we have found edges
- Find = true ;
- _entity = MED_EDGE ;
- _numberOfGeometricType = NumberOfEdgesTypeInFamily ;
- _geometricType = new medGeometryElement[NumberOfEdgesTypeInFamily] ;
- _geometricTypeNumber = new int[NumberOfEdgesTypeInFamily] ;
- _isOnAllElts = false ;
- _numberOfEntities = new int[NumberOfEdgesTypeInFamily] ;
- _totalNumberOfEntities=0;
- for (int i=0; i<NumberOfEdgesTypeInFamily; i++) {
- _geometricType[i]=tmp_EdgesTypes[i] ;
- _geometricTypeNumber[i]=GeometricTypeNumber[i];
- _numberOfEntities[i]=NumberOfEdgesInFamily[i] ;
- _totalNumberOfEntities+=NumberOfEdgesInFamily[i] ;
- }
- delete[] NumberOfEdgesInFamily;
- delete[] tmp_EdgesTypes;
- delete[] GeometricTypeNumber;
-
- // family on all EDGE ?
-
- // we suppose family is never on all edge !!!!!!!!!
- // in all case, family is only on boundary and connectivity is partial
-
-// if (_totalNumberOfEntities==Mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)) {
-// _isOnAllElts = true ;
-// delete[] _numberOfEntities ;
-// _numberOfEntities=(int*)NULL;
-// } else {
- _number=new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities);
- int *NumberValue=_number->getValue();
- int *NumberIndex=_number->getIndex();
- NumberIndex[0]=1;
- for (int i=0; i<_numberOfGeometricType; i++) {
- NumberIndex[i+1]=NumberIndex[i]+_numberOfEntities[i];
- for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
- NumberValue[j-1]=tmp_EdgesLists[i][j-NumberIndex[i]];
- delete[] tmp_EdgesLists[i];
- }
- delete[] tmp_EdgesLists;
-// }
- }
+ Find = build(MED_EDGE,MEDArrayEdgeFamily) ;
}
+ }
// That's all !
// if not find : no entity in familly !!!
_numberOfGeometricType = 0 ;
_isOnAllElts = false ;
MESSAGE ("FAMILY() : No entity found !") ;
- } else { // set gauss point number to be equal one !
- _numberOfGaussPoint = new int[_numberOfGeometricType] ;
- for (int i=0; i<_numberOfGeometricType; i++)
- _numberOfGaussPoint[i]=1 ;
- }
+ }
+ // already done by support !!!!
+// else { // set gauss point number to be equal one !
+// _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+// for (int i=0; i<_numberOfGeometricType; i++)
+// _numberOfGaussPoint[i]=1 ;
+// }
+};
+
+FAMILY::FAMILY(const FAMILY & m):SUPPORT(m)
+{
+ MESSAGE("FAMILY::FAMILY(FAMILY & m)");
+ _identifier = m._identifier;
+ _numberOfAttribute = m._numberOfAttribute;
+ if (m._attributeIdentifier != NULL)
+ {
+ _attributeIdentifier = new int[m._numberOfAttribute];
+ memcpy(_attributeIdentifier,m._attributeIdentifier,m._numberOfAttribute*sizeof(int));
+ }
+ else
+ _attributeIdentifier = (int *) NULL;
+ if (m._attributeValue != NULL)
+ {
+ _attributeValue = new int[m._numberOfAttribute];
+ memcpy(_attributeValue,m._attributeValue,m._numberOfAttribute*sizeof(int));
+ }
+ else
+ _attributeValue = (int *) NULL;
+ if (m._attributeDescription != NULL)
+ {
+ _attributeDescription = new string[m._numberOfAttribute];
+ for (int i=0;i<m._numberOfAttribute;i++)
+ _attributeDescription[i] = m._attributeDescription[i];
+ }
+ else
+ _attributeDescription = (string *) NULL;
+ _numberOfGroup = m._numberOfGroup;
+ if (m._groupName != NULL)
+ {
+ _groupName = new string[m._numberOfGroup];
+ for (int i=0;i<m._numberOfGroup;i++)
+ _groupName[i]=m._groupName[i];
+ }
+ else
+ _groupName = (string *) NULL;
+};
+
+FAMILY::FAMILY(const SUPPORT & s):SUPPORT(s)
+{
+ MESSAGE("FAMILY::FAMILY(const SUPPORT & s)");
+
+ _identifier = 0;
+ _numberOfAttribute = 0;
+ _attributeIdentifier = (int*) NULL;
+ _attributeValue = (int*) NULL;
+ _attributeDescription = (string*) NULL;
+ _numberOfGroup = 0;
+ _groupName= (string*) NULL;
};
FAMILY::~FAMILY()
_groupName = fam._groupName;
return *this;
};
+
+ostream & operator<<(ostream &os, FAMILY &myFamily)
+{
+ // how do cast without duplicate ?
+ os << (SUPPORT) myFamily;
+
+ os << " - Identifier : "<<myFamily.getIdentifier()<<endl;
+ int numberofattributes = myFamily.getNumberOfAttributes();
+ os << " - Attributes ("<<numberofattributes<<") :"<<endl;
+ for (int j=1;j<numberofattributes+1;j++)
+ os << " * "<<myFamily.getAttributeIdentifier(j)<<" : "<<myFamily.getAttributeValue(j)<<", "<<myFamily.getAttributeDescription(j).c_str()<<endl;
+ int numberofgroups = myFamily.getNumberOfGroups();
+ os << " - Groups ("<<numberofgroups<<") :"<<endl;
+ for (int j=1;j<numberofgroups+1;j++)
+ os << " * "<<myFamily.getGroupName(j).c_str()<<endl ;
+
+ return os;
+};
+
+bool FAMILY::build(medEntityMesh Entity,int **FamilyNumber /* from MED file */)
+{
+ MESSAGE("FAMILY::build(medEntityMesh Entity,int **FamilyNumber /* from MED file */)");
+ bool Find = false ;
+ // Get types information from <_mesh>
+ int numberOfTypes = _mesh->getNumberOfTypes(Entity) ;
+ const medGeometryElement * types = _mesh->getTypes(Entity) ;
+
+ int * numberOfElementsInFamily = new int[numberOfTypes] ;
+ int numberOfElementTypesInFamily = 0 ;
+
+ medGeometryElement * tmp_Types = new medGeometryElement[numberOfTypes];
+ int ** tmp_ElementsLists = new int*[numberOfTypes] ;
+ // int * GeometricTypeNumber = new int[numberOfTypes] ;
+ const int * GlobalNumberingIndex = _mesh->getGlobalNumberingIndex(Entity);
+
+ // we search for all elements in this family
+ for (int TypeNumber=0; TypeNumber < numberOfTypes; TypeNumber++) {
+
+ int NumberOfElements = _mesh->getNumberOfElements(Entity,types[TypeNumber]) ;
+ int NumberOfElementsInThisFamily = 0 ;
+ int * ElementsOfThisFamilyNumber = FamilyNumber[TypeNumber];
+ int * tmp_ElementsList = new int[NumberOfElements];
+
+ for (int i=0; i<NumberOfElements; i++)
+ if (_identifier == ElementsOfThisFamilyNumber[i]) {
+ tmp_ElementsList[NumberOfElementsInThisFamily]=i+GlobalNumberingIndex[TypeNumber] ;
+ NumberOfElementsInThisFamily++;
+ }
+
+ if (NumberOfElementsInThisFamily>0) {// we have found some elements
+ numberOfElementsInFamily[numberOfElementTypesInFamily]=NumberOfElementsInThisFamily;
+
+ //int * ElementsList = tmp_ElementsList.resize(NumberOfElementsInThisFamily);
+ int * ElementsList = new int[NumberOfElementsInThisFamily] ;
+ memcpy(ElementsList,tmp_ElementsList,sizeof(int)*NumberOfElementsInThisFamily); // RESIZE de tmp_NodesList serait plus efficace !!!!!!!!
+
+ tmp_ElementsLists[numberOfElementTypesInFamily]=ElementsList ;
+ tmp_Types[numberOfElementTypesInFamily]=types[TypeNumber];
+ // GeometricTypeNumber[numberOfElementTypesInFamily]=TypeNumber+1;
+ numberOfElementTypesInFamily++;
+ // delete [] ElementsList;
+ }
+ delete[] tmp_ElementsList;
+ }
+
+ // we define all attribut in SUPPORT :
+ if (numberOfElementTypesInFamily>0) { // we have found elements
+ Find = true ;
+ _entity = Entity ;
+ _numberOfGeometricType = numberOfElementTypesInFamily ;
+ if (_geometricType!=NULL) delete[] _geometricType ;
+ _geometricType = new medGeometryElement[numberOfElementTypesInFamily] ;
+ _isOnAllElts = false ;
+ if (_numberOfElements!=NULL) delete[] _numberOfElements ;
+ _numberOfElements = new int[numberOfElementTypesInFamily] ;
+ _totalNumberOfElements=0;
+
+ //_numberOfGaussPoint = new int[numberOfElementTypesInFamily] ;
+
+ //int * numberIndex = new int[numberOfElementTypesInFamily+1];
+ //numberIndex[0]=1;
+ for (int i=0; i<numberOfElementTypesInFamily; i++) {
+ _geometricType[i]=tmp_Types[i] ;
+ //numberIndex[i+1]=numberIndex[i]+numberOfElementsInFamily[i];
+ _numberOfElements[i]=numberOfElementsInFamily[i]; // plutot un resize !!
+ _totalNumberOfElements+=_numberOfElements[i];
+ //_numberOfGaussPoint[i]=1;
+ }
+ // delete[] numberOfElementsInFamily;
+ // delete[] tmp_Types;
+ // delete[] GeometricTypeNumber;
+
+ // family on all ELEMENT ?
+ if (_totalNumberOfElements == _mesh->getNumberOfElements(Entity,MED_ALL_ELEMENTS)) {
+ _isOnAllElts = true ;
+ // all others attributs are rights !
+ for (int i=0; i<_numberOfGeometricType; i++)
+ delete[] tmp_ElementsLists[i];
+ } else {
+ int *NumberValue = new int[_totalNumberOfElements];
+ int *NumberIndex = new int[_numberOfGeometricType+1];
+ NumberIndex[0]=1;
+ for (int i=0; i<_numberOfGeometricType; i++) {
+ NumberIndex[i+1]=NumberIndex[i]+_numberOfElements[i];
+ for (int j=NumberIndex[i]; j<NumberIndex[i+1]; j++)
+ NumberValue[j-1]=tmp_ElementsLists[i][j-NumberIndex[i]];
+ delete[] tmp_ElementsLists[i];
+ }
+ if(_number!=NULL) delete _number ;
+ _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,NumberIndex,NumberValue);
+ delete[] NumberIndex ;
+ delete[] NumberValue ;
+ }
+ }
+ delete[] tmp_Types;
+ delete[] numberOfElementsInFamily;
+
+ delete[] tmp_ElementsLists;
+
+ return Find ;
+}
+
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Family.hxx
+// Module : MED
+
#ifndef FAMILY_HXX
#define FAMILY_HXX
#include <string>
#include "MEDMEM_Support.hxx"
+/*!
+
+ This class describe a family of elements on an entity./n
+ It inherits from support. /n
+ It contains a list of elements (by SUPPORT class inheritance)
+ and a description of some attributs./n
+
+ All families on one entity represent a mesh partition for this entity.
+
+*/
+
class FAMILY : public SUPPORT
{
protected :
- /*! Identifier of the family in the mesh
- Note : There is precisely one for each family. */
+ /*!
+ \if developper
+ Identifier of the family in the mesh
+ Note : There is precisely one for each family.
+ \endif
+ */
int _identifier ;
- /*! Number of attribute of the family */
+ /*!
+ \if developper
+ Number of attribute of the family ./n
+ Note that attributes are numbered from 1 to N.
+ \endif
+ */
int _numberOfAttribute ;
- /*! Array of all attributes' identifiers.
- There is one for each attribute. */
+ /*!
+ \if developper
+ Array of all attributes' identifiers.
+ There is one for each attribute.
+ \endif
+ */
int * _attributeIdentifier ;
- /*! Array of all attributes' values.
- There is one for each attribute. */
+ /*!
+ \if developper
+ Array of all attributes' values.
+ There is one for each attribute.
+ \endif
+ */
int * _attributeValue ;
- /*! Array of all attributes' descriptions.
- There is one for each attribute. */
+ /*!
+ \if developper
+ Array of all attributes' descriptions.
+ There is one for each attribute.
+ \endif
+ */
string * _attributeDescription ;
-
- /*! Number of the group the family belongs to */
+ /*!
+ \if developper
+ Number of the group the family belongs to.
+ \endif
+ */
int _numberOfGroup ;
- /*! Name of the group the family belongs to */
+ /*!
+ \if developper
+ Name of the group the family belongs to.
+ \endif
+ */
string * _groupName ;
public:
+ /*! Constructor. */
FAMILY();
+ /*!
+ \if developper
+ Constructor to use with med driver.
+ */
+ FAMILY( MESH* Mesh, int Identifier, string Name,
+ int NumberOfAttribute, int *AttributeIdentifier,
+ int *AttributeValue, string AttributeDescription,
+ int NumberOfGroup, string GroupName,
+ int * MEDArrayNodeFamily,
+ int ** MEDArrayCellFamily,
+ int ** MEDArrayFaceFamily,
+ int ** MEDArrayEdgeFamily
+ ) ;
+
+ /*! Copy Constructor. */
+ FAMILY(const FAMILY & m);
- // constructor to use with med driver
- FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName) ;
+ /*! Constructor with SUPPORT entry. */
+ FAMILY(const SUPPORT & s);
+ /*! Destructor. */
~FAMILY();
FAMILY & operator=(const FAMILY &fam);
+ friend ostream & operator<<(ostream &os, FAMILY &my) ;
+
+ bool build(medEntityMesh Entity,int **FamilyNumber);
inline void setIdentifier (int Identifier);
inline void setNumberOfAttributes (int NumberOfAttribute);
// inline methods :
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _identifier to Identifier. */
//----------------------------------------------
inline void FAMILY::setIdentifier(int Identifier)
//----------------------------------------------
_identifier = Identifier;
}
-/* Set the attribute _numberOfAttribute to NumberOfAttribute. */
+/*! Sets the attribute _numberOfAttribute to NumberOfAttribute. */
//--------------------------------------------------------------
inline void FAMILY::setNumberOfAttributes(int NumberOfAttribute)
//--------------------------------------------------------------
_numberOfAttribute = NumberOfAttribute;
}
-/* Set the attribute _attributeIdentifier to AttributeIdentifier. */
+/*! Sets the attribute _attributeIdentifier to AttributeIdentifier. */
//---------------------------------------------------------------------
inline void FAMILY::setAttributesIdentifiers(int * AttributeIdentifier)
//---------------------------------------------------------------------
_attributeIdentifier = AttributeIdentifier ;
}
-/* Set the attribute _attributeValue to AttributeValue. */
+/*! Sets the attribute _attributeValue to AttributeValue. */
//-----------------------------------------------------------
inline void FAMILY::setAttributesValues(int * AttributeValue)
//-----------------------------------------------------------
_attributeValue = AttributeValue ;
}
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _attributeDescription to AttributeDescription. */
//--------------------------------------------------------------------------
inline void FAMILY::setAttributesDescriptions(string * AttributeDescription)
//--------------------------------------------------------------------------
_attributeDescription = AttributeDescription ;
}
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _numberOfGroup to NumberOfGroups. */
//-------------------------------------------------------
inline void FAMILY::setNumberOfGroups(int NumberOfGroups)
//-------------------------------------------------------
_numberOfGroup = NumberOfGroups ;
}
-/* Set the attribute _identifier to Identifier. */
+/*! Sets the attribute _groupName to GroupName. */
//----------------------------------------------------
inline void FAMILY::setGroupsNames(string * GroupName)
//----------------------------------------------------
{
_groupName = GroupName ;
}
+/*! Returns the attribute _identifier./n
+ Note that there is one identifier precisely for each family. */
//--------------------------------------
inline int FAMILY::getIdentifier() const
//--------------------------------------
{
return _identifier ;
}
+
+/*! Returns the number of attributes of the family. */
//----------------------------------------------
inline int FAMILY::getNumberOfAttributes() const
//----------------------------------------------
{
return _numberOfAttribute ;
}
+/*! Returns a pointer to attributes identifiers .
+ (There are _numberOfAttribute attributes) */
//---------------------------------------------------
inline int * FAMILY::getAttributesIdentifiers() const
//---------------------------------------------------
{
return _attributeIdentifier ;
}
+/*! Returns identifer of the Ith attribute of the family./n
+ Note that they are numbered from 1 to N */
//----------------------------------------------------
inline int FAMILY::getAttributeIdentifier(int i) const
//----------------------------------------------------
{
return _attributeIdentifier[i-1] ;
}
+/*! Returns a pointer to attributes values.
+ (There are _numberOfAttribute attributes)*/
//----------------------------------------------
inline int * FAMILY::getAttributesValues() const
//----------------------------------------------
{
return _attributeValue ;
}
+/*! Returns value of the Ith attribute of the family./n
+ Note that they are numbered from 1 to N */
//-----------------------------------------------
inline int FAMILY::getAttributeValue(int i) const
//-----------------------------------------------
{
return _attributeDescription ;
}
+/*! Returns description of the Ith attribute of the family/n
+ Note that they are numbered from 1 to N */
//--------------------------------------------------------
inline string FAMILY::getAttributeDescription(int i) const
//--------------------------------------------------------
{
return _attributeDescription[i-1] ;
}
+/*! Returns the number of groups the family belongs to.*/
//------------------------------------------
inline int FAMILY::getNumberOfGroups() const
//------------------------------------------
{
return _numberOfGroup;
}
+/*! Returns a pointer to the names of the groups the family belongs to */
//--------------------------------------------
inline string * FAMILY::getGroupsNames() const
//--------------------------------------------
{
return _groupName ;
}
+/*! Returns the name of the Ith group the family belongs to./n
+ Note that they are numbered from 1 to N*/
//---------------------------------------------
inline string FAMILY::getGroupName(int i) const
//---------------------------------------------
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Field.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_Field.hxx"
// ---------------------------------
// FIELD_ : Constructors
// ---------------------------------
FIELD_::FIELD_():
+ _isRead(false),
_name(""), _description(""), _support((SUPPORT *)NULL),
- _numberOfComponents(0), _componentsTypes((int *)NULL),
+ _numberOfComponents(0), _numberOfValues(0),_componentsTypes((int *)NULL),
_componentsNames((string *)NULL),
_componentsDescriptions((string *)NULL),
_componentsUnits((UNIT*)NULL),
}
FIELD_::FIELD_(const SUPPORT * Support, const int NumberOfComponents):
+ _isRead(false),
_name(""), _description(""), _support(Support),
_numberOfComponents(NumberOfComponents),
_iterationNumber(-1),_time(0.0),_orderNumber(-1)
{
MESSAGE("FIELD_(const SUPPORT * Support, const int NumberOfComponents)");
+ _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
_componentsTypes = new int[NumberOfComponents] ;
_componentsNames = new string[NumberOfComponents];
_componentsDescriptions = new string[NumberOfComponents];
FIELD_::FIELD_(const FIELD_ &m)
{
+ _isRead = m._isRead ;
_name = m._name;
_description = m._description;
_support = m._support;
_numberOfComponents = m._numberOfComponents;
- _componentsTypes = m._componentsTypes;
- _componentsNames = m._componentsNames;
- _componentsDescriptions = m._componentsDescriptions;
- _componentsUnits = m._componentsUnits;
- _MEDComponentsUnits = m._MEDComponentsUnits;
+ _numberOfValues = m._numberOfValues;
+
+ if (m._componentsTypes != NULL)
+ {
+ _componentsTypes = new int[m._numberOfComponents] ;
+ memcpy(_componentsTypes,m._componentsTypes,sizeof(int)*m._numberOfComponents);
+ /*
+ _componentsTypes = new int[m._numberOfComponents] ;
+ for(int i=0;i<m._numberOfComponents;i++) {
+ _componentsTypes[i] = m._componentsTypes[i] ;
+ }
+ */
+ }
+ else _componentsTypes = (int *) NULL;
+
+ _componentsNames = new string[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ {_componentsNames[i]=m._componentsNames[i];}
+ _componentsDescriptions = new string[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ {_componentsDescriptions[i]=m._componentsDescriptions[i];}
+ _componentsUnits = new UNIT[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ {_componentsUnits[i] = m._componentsUnits[i];}
+ // L'operateur '=' est defini dans la classe UNIT
+ _MEDComponentsUnits = new string[m._numberOfComponents];
+ for (int i=0; i<m._numberOfComponents; i++)
+ {_MEDComponentsUnits[i] = m._MEDComponentsUnits[i];}
_iterationNumber = m._iterationNumber;
_time = m._time;
_orderNumber = m._orderNumber;
_valueType = m._valueType;
+ //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor !
+
}
FIELD_::~FIELD_()
delete[] _componentsUnits ;
if ( _MEDComponentsUnits !=NULL)
delete[] _MEDComponentsUnits ;
+
+ // delete driver
+// vector<GENDRIVER *>::const_iterator it ;
+// SCRUTE(_drivers.size());
+// int i=0;
+// for (it=_drivers.begin();it!=_drivers.end();it++) {
+// i++;
+// SCRUTE(i);
+// delete (*it) ;
+
+
+ MESSAGE("In this object FIELD_ there is(are) " << _drivers.size() << " driver(s)");
+
+ for (int index=0; index < _drivers.size(); index++ )
+ {
+ SCRUTE(_drivers[index]);
+ if ( _drivers[index] != NULL) delete _drivers[index];
+ }
}
// void FIELD_::setIterationNumber (int IterationNumber) {};
// void FIELD_::setOrderNumber (int OrderNumber) {};
// void FIELD_::setFieldName (string& fieldName) {};
-void FIELD_::rmDriver (int index) {};
-int FIELD_::addDriver (driverTypes driverType,
- const string & fileName,
- const string & driverFieldName) {} ;
-int FIELD_::addDriver (GENDRIVER & driver) {};
-void FIELD_::write (const GENDRIVER &) {};
+void FIELD_::rmDriver (int index) {};
+int FIELD_::addDriver (driverTypes driverType,
+ const string & fileName,
+ const string & driverFieldName) {};
+int FIELD_::addDriver (GENDRIVER & driver) {};
+void FIELD_::write (const GENDRIVER &) {};
+void FIELD_::read (const GENDRIVER &) {};
+void FIELD_::write (int index, const string & driverName) {};
+void FIELD_::read (int index) {};
// void FIELD_::setValueType(med_type_champ ValueType) {};
// med_type_champ FIELD_::getValueType() {};
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Field.hxx
+// Module : MED
+
/*
File Field.hxx
$Header$
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_MedFieldDriver.hxx"
-
-// template <class T> class MED_FIELD_RDONLY_DRIVER;
-// template <class T> class MED_FIELD_WRONLY_DRIVER;
-// template <class T> class MED_FIELD_RDWR_DRIVER;
+#include "MEDMEM_MedMedDriver.hxx"
using namespace MED_EN;
-//class GENDRIVER;
+/*!
+
+ This class contains all the informations related with a template class FIELD :
+ - Components descriptions
+ - Time step description
+ - Location of the values (a SUPPORT class)
+
+*/
+
class FIELD_ // GENERIC POINTER TO a template <class T> class FIELD
{
-
protected:
- string _name ;
- string _description ;
+ bool _isRead ;
+
+ /*!
+ \if developper
+ Field name.
+ \endif
+ */
+ string _name ;
+ /*!
+ \if developper
+ Field description.
+ \endif
+ */
+ string _description ;
+ /*!
+ \if developper
+ Pointer to the support the field deals with.
+ \endif
+ */
const SUPPORT * _support ;
- int _numberOfComponents ;
- int * _componentsTypes ; // array of size _numberOfComponents
- // (constant, scalar, vector, tensor)
- // we could use an array of integer to store
- // numbers of values
- // 1 for scalar,
- // space dimension for vector,
- // space dimension square for tensor.
- // so numbers of values per entities are
- // sum of _componentsTypes array
- // Do not use yet! All type are scalar !
- string * _componentsNames; // array of size _numberOfComponents
- string * _componentsDescriptions; // array of size _numberOfComponents
- UNIT * _componentsUnits; // array of size _numberOfComponents
- string * _MEDComponentsUnits; // array of size _numberOfComponents :
- // get unit from med file
-
- int _iterationNumber ;
- double _time;
- int _orderNumber ;
-
- /*MED_EN::*/med_type_champ _valueType ;
+
+ /*!
+ \if developper
+ Number of field's components.
+ \endif
+ */
+ int _numberOfComponents ;
+ /*!
+ \if developper
+ Number of field's values.
+ \endif
+ */
+ int _numberOfValues ;
+
+ /*!
+ \if developper
+ Array of size _numberOfComponents. /n
+ (constant, scalar, vector, tensor)/n
+ We could use an array of integer to store
+ numbers of values: /n
+ - 1 for scalar,/n
+ - space dimension for vector,/n
+ - space dimension square for tensor./n
+ So numbers of values per entities would be
+ sum of _componentsTypes array.
+
+ Not implemented yet! All type are scalar !
+ \endif
+ */
+ int * _componentsTypes ;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components names if any.
+ \endif
+ */
+ string * _componentsNames;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components descriptions if any.
+ \endif
+ */
+ string * _componentsDescriptions;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components units if any.
+ \endif
+ */
+ UNIT * _componentsUnits;
+ /*!
+ \if developper
+ Array of size _numberOfComponents
+ storing components units if any.
+ \endif
+ */
+ string * _MEDComponentsUnits;
+ int _iterationNumber ;
+ double _time;
+ int _orderNumber ;
+
+ med_type_champ _valueType ;
+
+ vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
public:
-
+
+ friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
+
+ /*!
+ Constructor.
+ */
FIELD_ ();
+ /*!
+ Constructor.
+ */
FIELD_(const SUPPORT * Support, const int NumberOfComponents);
+ /*!
+ Copy constructor.
+ */
FIELD_(const FIELD_ &m);
+ /*!
+ Destructor.
+ */
~FIELD_();
// virtual void setIterationNumber (int IterationNumber);
-// virtual void setOrderNumber (int OrderNumber);
-// virtual void setFieldName (string& fieldName);
+// virtual void setOrderNumber (int OrderNumber);
+// virtual void setFieldName (string& fieldName);
virtual void rmDriver(int index);
- virtual int addDriver(driverTypes driverType,
- const string & fileName,
- const string & driverFieldName) ;
- virtual int addDriver(GENDRIVER & driver);
+ virtual int addDriver(driverTypes driverType,
+ const string & fileName="Default File Name.med",
+ const string & driverFieldName="Default Field Nam") ;
+ virtual int addDriver( GENDRIVER & driver);
+ virtual void read (const GENDRIVER &);
+ virtual void read(int index=0);
virtual void write(const GENDRIVER &);
-
- // virtual void getValueType (MED_FR::med_type_champ ValueType) ;
- // virtual void setValueType (/*MED_EN::*/med_type_champ ValueType) ;
- // virtual med_type_champ getValueType () ;
+ virtual void write(int index=0, const string & driverName="");
inline void setName(string Name);
inline string getName() const;
inline void setDescription(string Description);
- inline string getDescription()const;
+ inline string getDescription() const;
inline const SUPPORT * getSupport() const;
- inline void setSupport(SUPPORT * support);
+ inline void setSupport(SUPPORT * support);
inline void setNumberOfComponents(int NumberOfComponents);
inline int getNumberOfComponents() const;
+ inline void setNumberOfValues(int NumberOfValues);
+ inline int getNumberOfValues() const;
// inline void setComponentType(int *ComponentType);
// inline int * getComponentType() const;
// inline int getComponentTypeI(int i) const;
inline void setComponentsNames(string * ComponentsNames);
- inline void setComponentName(int i, string ComponentName);
- inline string * getComponentsNames() const;
+ inline void setComponentName(int i, string ComponentName);
+ inline const string * getComponentsNames() const;
inline string getComponentName(int i) const;
inline void setComponentsDescriptions(string *ComponentsDescriptions);
inline void setComponentDescription(int i, string ComponentDescription);
- inline string * getComponentsDescriptions() const;
+ inline const string * getComponentsDescriptions() const;
inline string getComponentDescription(int i) const;
// provisoire : en attendant de regler le probleme des unites !
inline void setComponentsUnits(UNIT * ComponentsUnits);
- inline UNIT * getComponentsUnits() const;
- inline UNIT * getComponentUnit(int i) const;
+ inline const UNIT * getComponentsUnits() const;
+ inline const UNIT * getComponentUnit(int i) const;
inline void setMEDComponentsUnits(string * MEDComponentsUnits);
inline void setMEDComponentUnit(int i, string MEDComponentUnit);
- inline string * getMEDComponentsUnits() const;
+ inline const string * getMEDComponentsUnits() const;
inline string getMEDComponentUnit(int i) const;
inline void setIterationNumber(int IterationNumber);
inline int getIterationNumber() const;
inline void setTime(double Time);
inline double getTime() const;
- inline void setOrderNumber(int OrderNumber);
+ inline void setOrderNumber(int OrderNumber);
inline int getOrderNumber() const;
- inline void setValueType (/*MED_EN::*/med_type_champ ValueType) ;
- inline /*MED_EN::*/med_type_champ getValueType () ;
+ inline void setValueType (med_type_champ ValueType) ;
+ inline med_type_champ getValueType () const;
};
// -----------------
// Methodes Inline
// -----------------
-
+/*!
+ Set FIELD name.
+*/
inline void FIELD_::setName(string Name)
{
_name=Name;
}
-inline string FIELD_::getName() const
+/*!
+ Get FIELD name.
+*/
+inline string FIELD_::getName() const
{
return _name;
}
+/*!
+ Set FIELD description.
+*/
inline void FIELD_::setDescription(string Description)
{
_description=Description;
}
-inline string FIELD_::getDescription() const
+/*!
+ Get FIELD description.
+*/
+inline string FIELD_::getDescription() const
{
return _description;
}
+/*!
+ Set FIELD number of components.
+*/
inline void FIELD_::setNumberOfComponents(int NumberOfComponents)
{
_numberOfComponents=NumberOfComponents;
-}
-inline int FIELD_::getNumberOfComponents() const
-{
- return _numberOfComponents ;
-}
-// inline void FIELD_::setComponentType(int *ComponentType)
-// {
-// _componentsTypes=ComponentType ;
+}
+/*!
+ Get FIELD number of components.
+*/
+inline int FIELD_::getNumberOfComponents() const
+{
+ return _numberOfComponents ;
+}
+/*!
+ Set FIELD number of values.
+
+ It must be the same than in the associated SUPPORT object.
+*/
+inline void FIELD_::setNumberOfValues(int NumberOfValues)
+{
+ _numberOfValues=NumberOfValues;
+}
+/*!
+ Get FIELD number of value.
+*/
+inline int FIELD_::getNumberOfValues() const
+{
+ return _numberOfValues ;
+}
+
+// inline void FIELD_::setComponentType(int *ComponentType)
+// {
+// _componentsTypes=ComponentType ;
// }
-// inline int * FIELD_::getComponentType() const
-// {
-// return _componentsTypes ;
+// inline int * FIELD_::getComponentType() const
+// {
+// return _componentsTypes ;
// }
-// inline int FIELD_::getComponentTypeI(int i) const
-// {
-// return _componentsTypes[i-1] ;
+// inline int FIELD_::getComponentTypeI(int i) const
+// {
+// return _componentsTypes[i-1] ;
// }
-inline void FIELD_::setComponentsNames(string * ComponentsNames)
-{
- _componentsNames=ComponentsNames ;
+
+/*!
+ Set FIELD components names.
+
+ Duplicate the ComponentsNames string array to put components names in
+ FIELD. ComponentsNames size must be equal to number of components.
+*/
+inline void FIELD_::setComponentsNames(string * ComponentsNames)
+{
+ if (NULL == _componentsNames)
+ _componentsNames = new string[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _componentsNames[i]=ComponentsNames[i] ;
}
-inline void FIELD_::setComponentName(int i, string ComponentName)
-{
- _componentsNames[i-1]=ComponentName ;
+/*!
+ Set FIELD i^th component name.
+
+ i must be >=1 and <= number of components.
+*/
+inline void FIELD_::setComponentName(int i, string ComponentName)
+{
+ _componentsNames[i-1]=ComponentName ;
}
-inline string * FIELD_::getComponentsNames() const
-{
- return _componentsNames ;
+/*!
+ Get a reference to the string array which contain the components names.
+
+ This Array size is equal to number of components
+*/
+inline const string * FIELD_::getComponentsNames() const
+{
+ return _componentsNames ;
}
-inline string FIELD_::getComponentName(int i) const
-{
- return _componentsNames[i-1] ;
+/*!
+ Get the name of the i^th component.
+*/
+inline string FIELD_::getComponentName(int i) const
+{
+ return _componentsNames[i-1] ;
}
-inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
-{
- _componentsDescriptions=ComponentsDescriptions ;
+/*!
+ Set FIELD components descriptions.
+
+ Duplicate the ComponentsDescriptions string array to put components
+ descriptions in FIELD.
+ ComponentsDescriptions size must be equal to number of components.
+*/
+inline void FIELD_::setComponentsDescriptions(string *ComponentsDescriptions)
+{
+ if (NULL == _componentsDescriptions)
+ _componentsDescriptions = new string[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _componentsDescriptions[i]=ComponentsDescriptions[i] ;
}
+/*!
+ Set FIELD i^th component description.
+
+ i must be >=1 and <= number of components.
+*/
inline void FIELD_::setComponentDescription(int i,string ComponentDescription)
-{
- _componentsDescriptions[i-1]=ComponentDescription ;
+{
+ _componentsDescriptions[i-1]=ComponentDescription ;
}
-inline string * FIELD_::getComponentsDescriptions() const
-{
- return _componentsDescriptions ;
+/*!
+ Get a reference to the string array which contain the components descriptions.
+
+ This Array size is equal to number of components
+*/
+inline const string * FIELD_::getComponentsDescriptions() const
+{
+ return _componentsDescriptions ;
}
+/*!
+ Get the description of the i^th component.
+*/
inline string FIELD_::getComponentDescription(int i) const
-{
- return _componentsDescriptions[i-1];
-}
-inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits)
-{
- _componentsUnits=ComponentsUnits ;
-}
-inline UNIT * FIELD_::getComponentsUnits() const
-{
- return _componentsUnits ;
-}
-inline UNIT * FIELD_::getComponentUnit(int i) const
-{
- return &_componentsUnits[i-1] ;
-}
-inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
-{
- _MEDComponentsUnits=MEDComponentsUnits ;
-}
-inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit)
-{
- _MEDComponentsUnits[i-1]=MEDComponentUnit ;
-}
-inline string * FIELD_::getMEDComponentsUnits() const
-{
- return _MEDComponentsUnits ;
-}
-inline string FIELD_::getMEDComponentUnit(int i) const
-{
- return _MEDComponentsUnits[i-1] ;
-}
-inline void FIELD_::setIterationNumber(int IterationNumber)
-{
- _iterationNumber=IterationNumber;
-}
-inline int FIELD_::getIterationNumber() const
-{
- return _iterationNumber ;
-}
-inline void FIELD_::setTime(double Time)
-{
- _time=Time ;
-}
-inline double FIELD_::getTime() const
-{
- return _time ;
-}
-inline void FIELD_::setOrderNumber(int OrderNumber)
-{
- _orderNumber=OrderNumber ;
-}
-inline int FIELD_::getOrderNumber() const
-{
+{
+ return _componentsDescriptions[i-1];
+}
+
+/*!
+ \todo
+ Set FIELD components UNIT.
+
+ Duplicate the ComponentsUnits UNIT array to put components
+ units in FIELD.
+ ComponentsUnits size must be equal to number of components.
+*/
+inline void FIELD_::setComponentsUnits(UNIT * ComponentsUnits)
+{
+ if (NULL == _componentsUnits)
+ _componentsUnits = new UNIT[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _componentsUnits[i]=ComponentsUnits[i] ;
+}
+/*!
+ Get a reference to the UNIT array which contain the components units.
+
+ This Array size is equal to number of components
+*/
+inline const UNIT * FIELD_::getComponentsUnits() const
+{
+ return _componentsUnits ;
+}
+/*!
+ Get the UNIT of the i^th component.
+*/
+inline const UNIT * FIELD_::getComponentUnit(int i) const
+{
+ return &_componentsUnits[i-1] ;
+}
+/*!
+ Set FIELD components unit.
+
+ Duplicate the MEDComponentsUnits string array to put components
+ units in FIELD.
+ MEDComponentsUnits size must be equal to number of components.
+
+*/
+inline void FIELD_::setMEDComponentsUnits(string * MEDComponentsUnits)
+{
+ if (NULL == _MEDComponentsUnits)
+ _MEDComponentsUnits = new string[_numberOfComponents] ;
+ for (int i=0; i<_numberOfComponents; i++)
+ _MEDComponentsUnits[i]=MEDComponentsUnits[i] ;
+}
+/*!
+ Set FIELD i^th component unit.
+
+ i must be >=1 and <= number of components.
+*/
+inline void FIELD_::setMEDComponentUnit(int i, string MEDComponentUnit)
+{
+ _MEDComponentsUnits[i-1]=MEDComponentUnit ;
+}
+/*!
+ Get a reference to the string array which contain the components units.
+
+ This Array size is equal to number of components
+*/
+inline const string * FIELD_::getMEDComponentsUnits() const
+{
+ return _MEDComponentsUnits ;
+}
+/*!
+ Get the string for unit of the i^th component.
+*/
+inline string FIELD_::getMEDComponentUnit(int i) const
+{
+ return _MEDComponentsUnits[i-1] ;
+}
+/*!
+ Set the iteration number where FIELD has been calculated.
+*/
+inline void FIELD_::setIterationNumber(int IterationNumber)
+{
+ _iterationNumber=IterationNumber;
+}
+/*!
+ Get the iteration number where FIELD has been calculated.
+*/
+inline int FIELD_::getIterationNumber() const
+{
+ return _iterationNumber ;
+}
+/*!
+ Set the time (in second) where FIELD has been calculated.
+*/
+inline void FIELD_::setTime(double Time)
+{
+ _time=Time ;
+}
+/*!
+ Get the time (in second) where FIELD has been calculated.
+*/
+inline double FIELD_::getTime() const
+{
+ return _time ;
+}
+/*!
+ Set the order number where FIELD has been calculated.
+
+ It corresponds to internal iteration during one time step.
+*/
+inline void FIELD_::setOrderNumber(int OrderNumber)
+{
+ _orderNumber=OrderNumber ;
+}
+/*!
+ Get the order number where FIELD has been calculated.
+*/
+inline int FIELD_::getOrderNumber() const
+{
return _orderNumber ;
}
+/*!
+ Get a reference to the SUPPORT object associated to FIELD.
+*/
inline const SUPPORT * FIELD_::getSupport() const
{
return _support ;
}
+/*!
+ Set the reference to the SUPPORT object associated to FIELD.
+ Reference is not duplicate, so it must not be deleted.
+*/
inline void FIELD_::setSupport(SUPPORT * support)
{
_support = support ;
}
-
-inline /*MED_EN::*/med_type_champ FIELD_::getValueType ()
+/*!
+ Get the FIELD med value type (MED_INT32 or MED_REEL64).
+*/
+inline med_type_champ FIELD_::getValueType () const
{
return _valueType ;
}
-
-inline void FIELD_::setValueType (/*MED_EN::*/med_type_champ ValueType)
+/*!
+ Set the FIELD med value type (MED_INT32 or MED_REEL64).
+*/
+inline void FIELD_::setValueType (med_type_champ ValueType)
{
_valueType = ValueType ;
}
// END OF CLASS FIELD_ //
/////////////////////////
+/*!
+
+ This template class contains informations related with a FIELD :
+ - Values of the field
+
+*/
+
template <class T> class FIELD : public FIELD_
{
protected:
//-----------------------//
- class INSTANCE
+ class INSTANCE
//-----------------------//
{
public:
virtual GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const = 0 ;
} ;
-
+
//-------------------------------------------------------//
- template <class T2> class INSTANCE_DE : public INSTANCE
+ template <class T2> class INSTANCE_DE : public INSTANCE
//-------------------------------------------------------//
{
public :
- GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const
- {
- return new T2(fileName,ptrFIELD);
+ GENDRIVER * run(const string & fileName, FIELD<T> * ptrFIELD) const
+ {
+ return new T2(fileName,ptrFIELD);
}
} ;
-
+
// static INSTANCE_DE<MED_FIELD_RDONLY_DRIVER> inst_med_rdonly ;
static INSTANCE_DE<MED_FIELD_RDWR_DRIVER<T> > inst_med ;
static const INSTANCE * const instances[] ;
// ------ End of Drivers Management Part
-
- vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
// array of value of type T
MEDARRAY<T> *_value ;
public:
FIELD();
- FIELD(const FIELD &m); // A FAIRE
+ FIELD(const FIELD &m);
FIELD & operator=(const FIELD &m); // A FAIRE
FIELD(const SUPPORT * Support, const int NumberOfComponents); // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut
- FIELD(driverTypes driverType, const string & fileName="",
- const string & fieldName="");
- ~FIELD();
+ FIELD(const SUPPORT * Support, driverTypes driverType,
+ const string & fileName="", const string & fieldName="");
+ ~FIELD();
friend class MED_FIELD_RDONLY_DRIVER<T>;
friend class MED_FIELD_WRONLY_DRIVER<T>;
- friend class MED_FIELD_RDWR_DRIVER <T>;
+ //friend class MED_FIELD_RDWR_DRIVER <T>;
void init ();
void rmDriver(int index=0);
- int addDriver(driverTypes driverType,
+ int addDriver(driverTypes driverType,
const string & fileName="Default File Name.med",
const string & driverFieldName="Default Field Name") ;
int addDriver(GENDRIVER & driver);
void allocValue(const int NumberOfComponents, const int LengthValue);
void deallocValue();
-
- inline void read(int index=0);
+
+ inline void read(int index=0);
+ inline void read(const GENDRIVER & genDriver);
inline void write(int index=0, const string & driverName = "");
inline void write(const GENDRIVER &);
inline void setValue(MEDARRAY<T> *Value);
- inline T* getValue(medModeSwitch Mode) const;
- inline T* getValueI(medModeSwitch Mode,int i) const;
+ inline MEDARRAY<T>* getvalue() const;
+ inline const T* getValue(medModeSwitch Mode) const;
+ inline const T* getValueI(medModeSwitch Mode,int i) const;
inline T getValueIJ(int i,int j) const;
inline void setValue(medModeSwitch mode, T* value);
inline void setValueI(medModeSwitch mode, int i, T* value);
inline void setValueIJ(int i, int j, T value);
+
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ volume of each cells belonging to the argument Support. The field has to be
+ initialised via the constructor FIELD<double>(const SUPPORT * , const int )
+ with Support as SUPPORT argument, 1 has the number of components, and Support
+ has be a SUPPORT on 3D cells. This initialisation could be done by the empty
+ constructor followed by a setSupport and setNumberOfComponents call but it has
+ be followed by a setValueType(MED_REEL64) call.
+ */
+ void getVolume() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ area of each cells (or faces) belonging to the attribut _support. The field
+ has to be initialised via the constructor FIELD<double>(const SUPPORT * ,
+ const int ) with 1 has the number of components, and _support has be a
+ SUPPORT on 2D cells or 3D faces. This initialisation could be done by the
+ empty constructor followed by a setSupport and setNumberOfComponents call but
+ it has be followed by a setValueType(MED_REEL64) call.
+ */
+ void getArea() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ length of each segments belonging to the attribut _support. The field has
+ to be initialised via the constructor FIELD<double>(const SUPPORT * ,
+ const int ) with 1 has the number of components, and _support has be a
+ SUPPORT on 3D edges or 2D faces. This initialisation could be done by the
+ empty constructor followed by a setSupport and setNumberOfComponents call but
+ it has be followed by a setValueType(MED_REEL64) call.
+ */
+ void getLength() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ normal vector of each faces belonging to the attribut _support. The field
+ has to be initialised via the constructor FIELD<double>(const SUPPORT * ,
+ const int ) with the space dimension has the number of components, and
+ _support has be a SUPPORT on 3D or 2D faces. This initialisation could be done
+ by the empty constructor followed by a setSupport and setNumberOfComponents
+ call but it has be followed by a setValueType(MED_REEL64) call.
+ */
+ void getNormal() const throw (MEDEXCEPTION) ;
+ /*!
+ This fonction feeds the FIELD<double> private attributs _value with the
+ barycenter of each faces or cells or edges belonging to the attribut _support.
+ The field has to be initialised via the constructor
+ FIELD<double>(const SUPPORT * ,const int ) with the space dimension has the
+ number of components, and _support has be a SUPPORT on 3D cells or 2D faces.
+ This initialisation could be done by the empty constructor followed by a
+ setSupport and setNumberOfComponents call but it has be followed by a
+ setValueType(MED_REEL64) call.
+ */
+ void getBarycenter() const throw (MEDEXCEPTION) ;
};
// --------------------
-// Implemented Methods
+// Implemented Methods
// --------------------
-template <class T> FIELD<T>::FIELD():
+/*!
+ Constructor.
+*/
+template <class T> FIELD<T>::FIELD():
_value((MEDARRAY<T>*)NULL)
{
MESSAGE("Constructeur FIELD sans parametre");
}
+/*!
+ Constructor.
+*/
template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
const int NumberOfComponents):
FIELD_(Support, NumberOfComponents)
{
BEGIN_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
-
- int length = 0 ;
+
try {
- length = Support->getNumberOfElements(MED_ALL_ELEMENTS);
+ _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined ! ("<<ex.what()<<")");
_value = (MEDARRAY<T>*)NULL ;
}
- MESSAGE("FIELD : constructeur : "<<length <<" et "<< NumberOfComponents);
- if (0<length)
- _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,length);
- else
+ MESSAGE("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents);
+ if (0<_numberOfValues) {
+ _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+ _isRead = true ;
+ } else
_value = (MEDARRAY<T>*)NULL ;
END_OF("FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)");
}
+/*!
+ \if developper
+ \endif
+*/
template <class T> void FIELD<T>::init ()
{
}
-template <class T> FIELD<T>::FIELD(const FIELD &m):
+/*!
+ Copy constructor.
+*/
+template <class T> FIELD<T>::FIELD(const FIELD & m):
FIELD_((FIELD_) m)
{
- _value = m._value;
- _drivers = m._drivers;
+ if (m._value != NULL)
+ {
+ // copie only default !
+ _value = new MEDARRAY<T>::MEDARRAY(* m._value,false);
+ }
+ else
+ _value = (MEDARRAY<T> *) NULL;
+ //_drivers = m._drivers;
}
-template <class T> FIELD<T> & FIELD<T>::FIELD::operator=(const FIELD &m)
+/*!
+
+*/
+template <class T> FIELD<T> & FIELD<T>::operator=(const FIELD &m)
{
}
-template <class T> FIELD<T>::FIELD(driverTypes driverType,
- const string & fileName="",
- const string & fieldName="")
+/*!
+ Constructor.
+*/
+template <class T> FIELD<T>::FIELD(const SUPPORT * Support,
+ driverTypes driverType,
+ const string & fileName/*=""*/,
+ const string & fieldDriverName/*=""*/)
{
+ const char * LOC = "template <class T> FIELD<T>::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\") : ";
+
+ int current;
+
+ BEGIN_OF(LOC);
+
+ init();
+
+ _support = Support;
+ _value = (MEDARRAY<T>*)NULL;
+
+ MED_FIELD_RDONLY_DRIVER<T> myDriver(fileName,this);
+ myDriver.setFieldName(fieldDriverName);
+ current = addDriver(myDriver);
+// current = addDriver(driverType,fileName,fieldDriverName);
+// switch(_drivers[current]->getAccessMode() ) {
+// case MED_WRONLY : {
+// MESSAGE("FIELD<T>::FIELD(driverTypes driverType, .....) : driverType must have a MED_RDONLY or MED_RDWR accessMode");
+// rmDriver(current);
+// break;}
+// default : {
+// }
+// }
+ _drivers[current]->open();
+ _drivers[current]->read();
+ _drivers[current]->close();
+
+ END_OF(LOC);
}
-template <class T> FIELD<T>::~FIELD()
-{
+/*!
+ Destructor.
+*/
+template <class T> FIELD<T>::~FIELD()
+{
BEGIN_OF(" Destructeur FIELD<T>::~FIELD()");
if (_value) delete _value;
END_OF(" Destructeur FIELD<T>::~FIELD()");
}
+/*!
+
+*/
template <class T> void FIELD<T>::allocValue(const int NumberOfComponents)
{
- BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
+ const char* LOC = "FIELD<T>::allocValue(const int NumberOfComponents)" ;
+ BEGIN_OF(LOC);
_numberOfComponents = NumberOfComponents ;
if (_componentsTypes == NULL)
}
try {
- int length = _support->getNumberOfElements(MED_ALL_ELEMENTS);
- MESSAGE("FIELD : constructeur : "<<length <<" et "<< NumberOfComponents);
-
- _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,length);
+ _numberOfValues = _support->getNumberOfElements(MED_ALL_ELEMENTS);
+ MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents);
+
+ _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+
+ _isRead = true ;
}
catch (MEDEXCEPTION &ex) {
MESSAGE("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY<T>::_value !");
END_OF("void FIELD<T>::allocValue(const int NumberOfComponents)");
}
+/*!
+
+*/
template <class T> void FIELD<T>::allocValue(const int NumberOfComponents, const int LengthValue)
{
BEGIN_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
}
MESSAGE("FIELD : constructeur : "<<LengthValue <<" et "<< NumberOfComponents);
-
- _value = new MEDARRAY<T>::MEDARRAY(NumberOfComponents,LengthValue);
+ _numberOfValues = LengthValue ;
+ _value = new MEDARRAY<T>::MEDARRAY(_numberOfComponents,_numberOfValues);
+ _isRead = true ;
SCRUTE(_value);
END_OF("void FIELD<T>::allocValue(const int NumberOfComponents,const int LengthValue)");
}
+/*!
+
+*/
template <class T> void FIELD<T>::deallocValue()
{
BEGIN_OF("void FIELD<T>::deallocValue()");
-
- delete _value;
+ _numberOfValues = 0 ;
+ _numberOfComponents = 0 ;
+ if (_value != NULL)
+ delete _value;
END_OF("void FIELD<T>::deallocValue()");
}
template <class T> const FIELD<T>::INSTANCE * const FIELD<T>::instances[] = { &FIELD<T>::inst_med } ;
-template <class T> int FIELD<T>::addDriver(driverTypes driverType,
- const string & fileName="Default File Name.med",
- const string & driverName="Default Field Name")
+/*!
+ Create the specified driver and return its index reference to path to
+ read or write methods.
+*/
+template <class T> int FIELD<T>::addDriver(driverTypes driverType,
+ const string & fileName/*="Default File Name.med"*/,
+ const string & driverName/*="Default Field Name"*/)
{
const char * LOC = "FIELD<T>::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\") : ";
-
+
GENDRIVER * driver;
int current;
BEGIN_OF(LOC);
-
+
driver = instances[driverType]->run(fileName, this) ;
_drivers.push_back(driver);
current = _drivers.size()-1;
-
+
_drivers[current]->setFieldName(driverName);
return current;
}
+
+/*!
+ Duplicate the given driver and return its index reference to path to
+ read or write methods.
+*/
template <class T> inline int FIELD<T>::addDriver (GENDRIVER & driver )
{
const char * LOC = "FIELD<T>::addDriver(GENDRIVER &) : ";
BEGIN_OF(LOC);
- _drivers.push_back(&driver);
+ // duplicate driver to delete it with destructor !
+ GENDRIVER * newDriver = driver.copy() ;
+
+ _drivers.push_back(newDriver);
return _drivers.size() -1 ;
END_OF(LOC);
};
-template <class T> void FIELD<T>::rmDriver (int index=0)
+/*!
+ Remove the driver referenced by its index.
+*/
+template <class T> void FIELD<T>::rmDriver (int index/*=0*/)
{
const char * LOC = "FIELD<T>::rmDriver (int index=0): ";
BEGIN_OF(LOC);
-
+
if ( _drivers[index] ) {
- //_drivers.erase(&_drivers[index]);
+ //_drivers.erase(&_drivers[index]);
// why not ????
MESSAGE ("detruire");
}
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
-
+ );
+
END_OF(LOC);
}
-
-template <class T> inline void FIELD<T>::read(int index=0)
-{
+
+/*!
+ Read FIELD in the file specified in the driver given by its index.
+*/
+template <class T> inline void FIELD<T>::read(int index/*=0*/)
+{
const char * LOC = "FIELD<T>::read(int index=0) : ";
BEGIN_OF(LOC);
if ( _drivers[index] ) {
- _drivers[index]->open();
+ _drivers[index]->open();
_drivers[index]->read();
_drivers[index]->close();
}
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
+ );
END_OF(LOC);
}
-template <class T> inline void FIELD<T>::write(int index=0, const string & driverName = "")
-{
+/*!
+ Write FIELD in the file specified in the driver given by its index.
+*/
+template <class T> inline void FIELD<T>::write(int index/*=0*/, const string & driverName /*= ""*/)
+{
const char * LOC = "FIELD<T>::write(int index=0, const string & driverName = \"\") : ";
BEGIN_OF(LOC);
if( _drivers[index] ) {
- _drivers[index]->open();
- if (driverName != "") _drivers[index]->setFieldName(driverName);
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setFieldName(driverName);
_drivers[index]->write();
_drivers[index]->close();
- }
+ }
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
+ );
END_OF(LOC);
}
-template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
-{
+/*!
+ \internal
+ Write FIELD with the driver which is equal to the given driver.
+
+ Use by MED object.
+*/
+template <class T> inline void FIELD<T>::write(const GENDRIVER & genDriver)
+{
const char * LOC = " FIELD<T>::write(const GENDRIVER &) : ";
BEGIN_OF(LOC);
for (int index=0; index < _drivers.size(); index++ )
- if ( *_drivers[index] == genDriver ) {
- _drivers[index]->open();
- _drivers[index]->write();
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->write();
_drivers[index]->close();
}
-
+
END_OF(LOC);
-
-}
-template <class T> inline void FIELD<T>::setValue(MEDARRAY<T> *Value)
-{
- _value=Value ;
}
-template <class T> inline T* FIELD<T>::getValue(medModeSwitch Mode) const
-{
- return _value->get(Mode) ;
+
+/*!
+ \internal
+ Read FIELD with the driver which is equal to the given driver.
+
+ Use by MED object.
+*/
+template <class T> inline void FIELD<T>::read(const GENDRIVER & genDriver)
+{
+ const char * LOC = " FIELD<T>::read(const GENDRIVER &) : ";
+ BEGIN_OF(LOC);
+
+ for (int index=0; index < _drivers.size(); index++ )
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->read();
+ _drivers[index]->close();
+ }
+
+ END_OF(LOC);
+
}
-template <class T> inline T* FIELD<T>::getValueI(medModeSwitch Mode,int i) const
+
+/*!
+ \if developper
+ Destroy the MEDARRAY<T> in FIELD and put the new one without copy.
+ \endif
+*/
+template <class T> inline void FIELD<T>::setValue(MEDARRAY<T> *Value)
+{
+ if (NULL != _value) delete _value ;
+ _value=Value ;
+}
+
+/*!
+ \if developper
+ Return a reference to the MEDARRAY<T> in FIELD.
+ \endif
+*/
+template <class T> inline MEDARRAY<T>* FIELD<T>::getvalue() const
{
- return _value->getI(Mode,i) ;
+ return _value ;
}
-template <class T> inline T FIELD<T>::getValueIJ(int i,int j) const
+
+/*!
+ Return a reference to values array to read them.
+*/
+template <class T> inline const T* FIELD<T>::getValue(medModeSwitch Mode) const
{
- return _value->getIJ(i,j) ;
+ return _value->get(Mode) ;
}
+/*!
+ Return a reference to i^{th} row or column - component - (depend on Mode value)
+ of FIELD values array.
+*/
+template <class T> inline const T* FIELD<T>::getValueI(medModeSwitch Mode,int i) const
+{
+ if ( Mode == MED_FULL_INTERLACE )
+ {
+ return _value->getRow(i) ;
+ }
+ ASSERT ( Mode == MED_NO_INTERLACE);
+ return _value->getColumn(i);
+}
+
+/*!
+ Return the value of i^{th} element and j^{th} component.
+*/
+template <class T> inline T FIELD<T>::getValueIJ(int i,int j) const
+{
+ return _value->getIJ(i,j) ;
+}
+
+/*!
+ Copy new values array in FIELD according to the given mode.
+
+ Array must have right size. If not results are unpredicable.
+*/
template <class T> inline void FIELD<T>::setValue(medModeSwitch mode, T* value)
{
_value->set(mode,value);
}
+/*!
+ Update values array in FIELD with the given ones according to specified mode.
+*/
template <class T> inline void FIELD<T>::setValueI(medModeSwitch mode, int i, T* value)
{
- _value->setI(mode,i,value);
+ // PROVISOIRE :
+ if (MED_FULL_INTERLACE == mode)
+ _value->setI(i,value);
+ else if (MED_NO_INTERLACE == mode)
+ _value->setJ(i,value);
+ else
+ throw MEDEXCEPTION(LOCALIZED("FIELD<T>::setValueI : bad medModeSwitch")) ;
}
+/*!
+ Set the value of i^{th} element and j^{th} component with the given one.
+*/
template <class T> inline void FIELD<T>::setValueIJ(int i, int j, T value)
{
_value->setIJ(i,j,value);
}
+/*
+ METHODS
+*/
+
+/*!
+ Fill values array with volume values.
+*/
+template <class T> void FIELD<T>::getVolume() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getVolume() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with area values.
+*/
+template <class T> void FIELD<T>::getArea() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getArea() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with length values.
+*/
+template <class T> void FIELD<T>::getLength() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getLength() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if ((_support == (SUPPORT *) NULL) || (_numberOfComponents != 1) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to 1 and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with normal values.
+*/
+template <class T> void FIELD<T>::getNormal() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getNormal() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a
+ // number of components = 1 and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if (_support == (SUPPORT *) NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ int dim_space = _support->getMesh()->getSpaceDimension();
+
+ if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
+/*!
+ Fill values array with barycenter values.
+*/
+template <class T> void FIELD<T>::getBarycenter() const throw (MEDEXCEPTION)
+{
+ const char * LOC = "FIELD<double>::getBarycenter() const : ";
+ BEGIN_OF(LOC);
+
+ // The field has to be initilised by a non empty support and a number of
+ //components = space dimension and its value type has to be set to MED_REEL64
+ // (ie a FIELD<double>)
+
+ if (_support == (SUPPORT *) NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ int dim_space = _support->getMesh()->getSpaceDimension();
+
+ if ((_numberOfComponents != dim_space) || (_valueType != MED_REEL64))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The field has to be initialised with a non empty support, a number of components set to the space dimension and a value type set to MED_REEL64"));
+
+ END_OF(LOC);
+}
+
#endif /* FIELD_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_GenDriver.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_GenDriver.hxx"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
-GENDRIVER::GENDRIVER(): _fileName(""),_accessMode((med_mode_acces)MED_INVALID),_status(MED_INVALID),_driverType(NO_DRIVER) {}
+GENDRIVER::GENDRIVER(): _id(MED_INVALID),
+ _fileName(""),
+ _accessMode( (med_mode_acces) MED_INVALID ),
+ _status(MED_INVALID),
+ _driverType(NO_DRIVER) {}
GENDRIVER::GENDRIVER(const string & fileName,
- med_mode_acces accessMode=(med_mode_acces) MED_INVALID): _fileName(fileName),
+ med_mode_acces accessMode=(med_mode_acces) MED_INVALID): _id(MED_INVALID),
+ _fileName(fileName),
_accessMode(accessMode),
_status(MED_CLOSED),
_driverType(NO_DRIVER) {}
-GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):_fileName(genDriver._fileName),
- _accessMode(genDriver._accessMode),
- _status(genDriver._status),_driverType(NO_DRIVER) {}
+GENDRIVER::GENDRIVER(const GENDRIVER & genDriver):
+ //_id(MED_INVALID),
+ _id(genDriver._id),
+ _fileName(genDriver._fileName),
+ _accessMode(genDriver._accessMode),
+ _status(genDriver._status),
+ _driverType(genDriver._driverType)
+{}
+
GENDRIVER::~GENDRIVER() {}
GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) {
+ const char * LOC = " GENDRIVER & GENDRIVER::operator=(const GENDRIVER & genDriver) : ";
+
+ BEGIN_OF(LOC);
+
_fileName = genDriver._fileName;
_accessMode = genDriver._accessMode;
_status = genDriver._status;
-
+ _id = genDriver._id;
return *this;
+
+ END_OF(LOC);
}
void GENDRIVER::writeFrom ( void ) {};
void GENDRIVER::setMeshName (const string & meshName) {};
void GENDRIVER::setFieldName (const string & fieldName) {};
+void GENDRIVER::setId ( int id ) {
+ const char * LOC = "void GENDRIVER::setId ( int id ) : ";
+
+ BEGIN_OF(LOC);
+
+ if ( id >= 0 ) _id=id; else _id = MED_INVALID ;
+
+ END_OF(LOC);
+};
+
+int GENDRIVER::getId ( void) const {
+ const char * LOC = "int GENDRIVER::getId ( void) const ";
+
+ BEGIN_OF(LOC);
+
+ return _id ;
+
+ END_OF(LOC);
+};
+
string GENDRIVER::getFileName() const {
+
+ const char * LOC = "string GENDRIVER::getFileName() const : ";
+ BEGIN_OF(LOC);
+
return _fileName;
+
+ END_OF(LOC);
}
-
+
+
void GENDRIVER::setFileName(const string & fileName) {
- _fileName = fileName;
+
+ const char * LOC = "void GENDRIVER::setFileName(const string & fileName) : ";
+ BEGIN_OF(LOC);
+
+ if ( _status == MED_OPENED )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" File |" << _fileName
+ << "| is still openned, close it before openning : | " << fileName << "|"));
+ else
+ _fileName = fileName;
+
+ END_OF(LOC);
}
+
+
med_mode_acces GENDRIVER::getAccessMode() const {
+
+ const char * LOC = "med_mode_acces GENDRIVER::getAccessMode() const : ";
+
+ BEGIN_OF(LOC);
+
return _accessMode;
+
+ END_OF(LOC);
}
ostream & operator<<(ostream &os,const GENDRIVER & drv)
return os;
}
+// Test if this driver has been created from MED driver
bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const {
+ const char * LOC = "bool GENDRIVER::operator ==(const GENDRIVER &genDriver) const : ";
+
+ MESSAGE(LOC);
+
return ( _id == genDriver._id ) &&
- ( _fileName == genDriver._fileName ) &&
( _driverType == genDriver._driverType );
};
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_GenDriver.hxx
+// Module : MED
+
#ifndef GENDRIVER_HXX
#define GENDRIVER_HXX
/* Generic Read/Write Driver Class for Meshes & Fields */
-typedef enum { MED_DRIVER = 0, VTK_DRIVER = 1, NO_DRIVER = 255 } driverTypes;
+/* Modify the following line to add a new driver type (step 1) */
+typedef enum { MED_DRIVER = 0, GIBI_DRIVER = 1, VTK_DRIVER = 254, NO_DRIVER = 255 } driverTypes;
using namespace MED_EN;
using namespace std;
+/*!
+
+ Virtual class GENDRIVER use by all driver.
+
+*/
+
class GENDRIVER {
protected :
int _id; // MED_INVALID : if the driver hasn't been created by a MedMedDriver
// the MedMedDriver index of the driver vector in the MED object where it has been created
/*File related part*/
- string _fileName;
- med_mode_acces _accessMode;
- int _status;
+ string _fileName; // The name of the file currently in use.
+ med_mode_acces _accessMode; // The file access mode set by the adequate construtor.
+ int _status; // The file status {MED_INVALID, MED_OPENED, MED_CLOSED }
driverTypes _driverType; // A FAIRE LE POSITIONNER DS TOUTES LES SS CLASSES !!
public:
+ /*!
+ Constructor.
+ */
GENDRIVER();
-
+ /*!
+ Constructor.
+ */
GENDRIVER(const string & fileName,med_mode_acces accessMode);
+ /*!
+ Copy constructor.
+ */
GENDRIVER(const GENDRIVER & genDriver);
- ~GENDRIVER();
+ /*!
+ Destructor.
+ */
+ virtual ~GENDRIVER();
+
+ /*!
+ Operator = : duplicate the given genDriver.
+ */
GENDRIVER & operator=(const GENDRIVER & genDriver);
+ /*!
+ Operator << : put GENDRIVER object information to the given stream
+ */
friend ostream & operator<<(ostream &os,const GENDRIVER &genDriver);
bool operator ==(const GENDRIVER &genDriver) const;
-
+ /*!
+ Open file.
+ */
virtual void open ( void ) = 0;
+ /*!
+ Close file.
+ */
virtual void close( void ) = 0;
+ /*!
+ Write object in opened file.
+ */
virtual void write( void ) const = 0;
+ /*!
+ Read object in opened file.
+ */
virtual void read ( void ) = 0;
+ // needed to duplicate arrays
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+
// MED related part
virtual void writeFrom ( void );
virtual void readFileStruct ( void );
// FIELD related Part
virtual void setFieldName ( const string & fieldName);
+ void setId ( int id = MED_INVALID );
+ int getId ( void ) const ;
string getFileName () const;
- void setFileName (const string & fileName);
+ void setFileName ( const string & fileName);
med_mode_acces getAccessMode() const;
};
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_GibiMeshDriver.cxx
+// Module : MED
+
+using namespace std;
+#include "MEDMEM_GibiMeshDriver.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+
+GIBI_MESH_DRIVER::GIBI_MESH_DRIVER():
+ GENDRIVER(),
+ _ptrMesh(( MESH *)MED_NULL),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName("")
+{
+}
+
+GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode):
+ GENDRIVER(fileName,accessMode),
+ _ptrMesh(ptrMesh),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName("")
+{
+}
+
+GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMesh(driver._ptrMesh),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName(driver._meshName)
+{
+}
+
+GIBI_MESH_DRIVER::~GIBI_MESH_DRIVER()
+{
+}
+
+void GIBI_MESH_DRIVER::open()
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MESH_DRIVER::open()" ;
+ BEGIN_OF(LOC);
+
+// if (_medIdt > 0)
+// _status = MED_OPENED;
+// else {
+// _medIdt = MED_INVALID;
+// _status = MED_CLOSED;
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
+// }
+
+ END_OF(LOC);
+}
+
+void GIBI_MESH_DRIVER::close()
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MESH_DRIVER::close() " ;
+ BEGIN_OF(LOC);
+
+// int err = 0;
+// if ( _status == MED_OPENED) {
+// err=MED_FR::MEDfermer(_medIdt);
+// H5close(); // If we call H5close() all the files are closed.
+// if (err != 0)
+// throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
+// <<" Error when closing file !"
+// )
+// );
+// _status = MED_CLOSED;
+// _medIdt = MED_INVALID;
+// }
+
+ END_OF(LOC);
+}
+
+void GIBI_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
+string GIBI_MESH_DRIVER::getMeshName() const { return _meshName; };
+
+
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+
+GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(): GIBI_MESH_DRIVER()
+{
+}
+
+GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+{
+ MESSAGE("GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver):
+ GIBI_MESH_DRIVER(driver)
+{
+}
+
+GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER()
+{
+ //MESSAGE("GIBI_MESH_RDONLY_DRIVER::~GIBI_MESH_RDONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * GIBI_MESH_RDONLY_DRIVER::copy(void) const
+{
+ return new GIBI_MESH_RDONLY_DRIVER(*this);
+}
+
+void GIBI_MESH_RDONLY_DRIVER::read(void)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GIBI_MESH_RDONLY_DRIVER::read() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ;
+
+ _ptrMesh->_name = _meshName;
+
+
+ END_OF(LOC);
+}
+
+void GIBI_MESH_RDONLY_DRIVER::write( void ) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("GIBI_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
+}
+
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER():GIBI_MESH_DRIVER()
+{
+}
+
+GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ GIBI_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
+{
+ MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver):
+ GIBI_MESH_DRIVER(driver)
+{
+}
+
+GIBI_MESH_WRONLY_DRIVER::~GIBI_MESH_WRONLY_DRIVER()
+{
+ //MESSAGE("GIBI_MESH_WRONLY_DRIVER::GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * GIBI_MESH_WRONLY_DRIVER::copy(void) const
+{
+ return new GIBI_MESH_WRONLY_DRIVER(*this);
+}
+
+void GIBI_MESH_WRONLY_DRIVER::read (void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("GIBI_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
+void GIBI_MESH_WRONLY_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "void GIBI_MESH_WRONLY_DRIVER::write(void) const : ";
+ BEGIN_OF(LOC);
+
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
+
+ END_OF(LOC);
+}
+
+
+
+/*--------------------- RDWR PART -------------------------------*/
+
+GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER():GIBI_MESH_DRIVER()
+{
+}
+
+GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ GIBI_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
+{
+ MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver):
+ GIBI_MESH_RDONLY_DRIVER::GIBI_MESH_DRIVER(driver)
+{
+}
+
+GIBI_MESH_RDWR_DRIVER::~GIBI_MESH_RDWR_DRIVER() {
+ //MESSAGE("GIBI_MESH_RDWR_DRIVER::GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * GIBI_MESH_RDWR_DRIVER::copy(void) const
+{
+ return new GIBI_MESH_RDWR_DRIVER(*this);
+}
+
+void GIBI_MESH_RDWR_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ GIBI_MESH_WRONLY_DRIVER::write();
+}
+void GIBI_MESH_RDWR_DRIVER::read (void)
+ throw (MEDEXCEPTION)
+{
+ GIBI_MESH_RDONLY_DRIVER::read();
+}
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_GibiMeshDriver.hxx
+// Module : MED
+
+#ifndef GIBI_MESH_DRIVER_HXX
+#define GIBI_MESH_DRIVER_HXX
+
+#include <string>
+#include <vector>
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_GenDriver.hxx"
+
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "utilities.h"
+
+class MESH;
+class FAMILY;
+class GROUP;
+class CONNECTIVITY;
+
+/*!
+
+ Driver GIBI for MESH.
+
+ Generic part : implement the readopen and close methods.
+
+*/
+
+
+class GIBI_MESH_DRIVER : public GENDRIVER
+{
+protected:
+
+ MESH * _ptrMesh;
+ // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
+ string _meshName;
+
+public :
+
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ med_mode_acces accessMode) ;
+ /*!
+ Copy constructor.
+ */
+ GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~GIBI_MESH_DRIVER() ;
+
+ void open() throw (MEDEXCEPTION);
+ void close() throw (MEDEXCEPTION);
+
+ virtual void write( void ) const = 0 ;
+ virtual void read ( void ) = 0 ;
+
+ /*!
+ Set the name of the MESH asked in file.
+
+ It could be different than the name of the MESH object.
+ */
+ void setMeshName(const string & meshName) ;
+ /*!
+ Get the name of the MESH asked in file.
+ */
+ string getMeshName() const ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+
+};
+
+
+class GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER
+{
+
+public :
+
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_RDONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~GIBI_MESH_RDONLY_DRIVER() ;
+
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+
+ GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
+class GIBI_MESH_WRONLY_DRIVER : public virtual GIBI_MESH_DRIVER {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_WRONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~GIBI_MESH_WRONLY_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+
+ GENDRIVER * copy ( void ) const ;
+};
+
+
+/*!
+
+ Driver GIBI for MESH : Read write.
+ - Use read method from GIBI_MESH_RDONLY_DRIVER
+ - Use write method from GIBI_MESH_WRONLY_DRIVER
+
+*/
+
+class GIBI_MESH_RDWR_DRIVER : public GIBI_MESH_RDONLY_DRIVER, public GIBI_MESH_WRONLY_DRIVER {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_RDWR_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ ~GIBI_MESH_RDWR_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION);
+
+private:
+ GENDRIVER * copy(void) const ;
+
+};
+
+
+#endif /* GIBI_MESH_DRIVER_HXX */
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_Grid.hxx
+// Author : Edward AGAPOV (eap)
+// Module : MED
+// $Header$
+
+using namespace std;
+#include "MEDMEM_Grid.hxx"
+#include <MEDMEM_CellModel.hxx>
+#include <MEDMEM_SkyLineArray.hxx>
+
+//=======================================================================
+//function : GRID
+//purpose : empty constructor
+//=======================================================================
+
+GRID::GRID() {
+ init();
+ MESSAGE("A GRID CREATED");
+}
+
+//=======================================================================
+//function : GRID
+//purpose : empty constructor
+//=======================================================================
+
+GRID::GRID(const med_grid_type type)
+{
+ init();
+ _gridType = type;
+ MESSAGE("A TYPED GRID CREATED");
+}
+
+//=======================================================================
+//function : GRID
+//purpose : copying constructor
+//=======================================================================
+
+GRID::GRID(const GRID& otherGrid) {
+ *this = otherGrid;
+}
+
+//=======================================================================
+//function : ~GRID
+//purpose : destructor
+//=======================================================================
+
+GRID::~GRID() {
+ MESSAGE("GRID::~GRID() : Destroying the Grid");
+ if ( _iArray != (double* ) NULL) delete [] _iArray;
+ if ( _jArray != (double* ) NULL) delete [] _jArray;
+ if ( _kArray != (double* ) NULL) delete [] _kArray;
+}
+
+//=======================================================================
+//function : init
+//purpose :
+//=======================================================================
+
+void GRID::init()
+{
+ _gridType = MED_CARTESIAN;
+
+ _iArray = _jArray = _kArray = (double* ) NULL;
+ _iArrayLength = _jArrayLength = _kArrayLength = 0;
+
+ _is_coordinates_filled = false;
+ _is_connectivity_filled = false;
+
+ MESH::init();
+
+ _isAGrid = true;
+}
+
+//=======================================================================
+//function: operator=
+//purpose : operator=
+//=======================================================================
+
+GRID & GRID::operator=(const GRID & otherGrid)
+{
+ // NOT IMPLEMENTED
+
+ MESH::operator=(otherGrid);
+ return *this;
+}
+
+//=======================================================================
+//function : GRID
+//purpose : Create a GRID object using a MESH driver of type
+// (MED_DRIVER, ....) associated with file <fileName>.
+//=======================================================================
+
+GRID::GRID(driverTypes driverType,
+ const string & fileName,
+ const string & driverName) {
+ const char * LOC ="GRID::GRID(driverTypes , const string & , const string &) : ";
+
+ BEGIN_OF(LOC);
+
+// int current;
+
+ init();
+ MESH(driverType,fileName,driverName);
+
+// current = addDriver(driverType,fileName,driverName);
+
+// switch(_drivers[current]->getAccessMode() ) {
+// case MED_RDONLY :
+// MESSAGE(LOC << "driverType must have a MED_RDWR accessMode");
+// rmDriver(current);
+// break;
+// default: {}
+// }
+// _drivers[current]->open();
+// _drivers[current]->read();
+// _drivers[current]->close();
+
+// // fill some fields of MESH
+// fillMeshAfterRead();
+
+ END_OF(LOC);
+};
+
+//=======================================================================
+//function : fillMeshAfterRead
+//purpose :
+//=======================================================================
+
+void GRID::fillMeshAfterRead()
+{
+ // fill not only MESH (:-)
+ _is_coordinates_filled = false;
+ _is_connectivity_filled = false;
+
+ if (_gridType == MED_BODY_FITTED)
+ {
+ _is_coordinates_filled = true;
+
+ // nb of nodes in each direction is not known, set anything
+ // in order to be able to work anyhow
+// INFOS("GRID::fillMeshAfterRead(): This stub must be removed");
+// switch (_spaceDimension) {
+// case 1:
+// _iArrayLength = _numberOfNodes;
+// _jArrayLength = 0;
+// _kArrayLength = 0;
+// break;
+// case 2:
+// _iArrayLength = 2;
+// _jArrayLength = _numberOfNodes / _iArrayLength;
+// _kArrayLength = 0;
+// break;
+// default:
+// _iArrayLength = 2;
+// _jArrayLength = _numberOfNodes / _iArrayLength / 2;
+// _kArrayLength = _numberOfNodes / _iArrayLength / _jArrayLength;
+// }
+ //cout << "ARRAY LENGTHS: " << _iArrayLength << " " << _jArrayLength
+// << " " << _kArrayLength << endl;
+ }
+// else {
+// int NbNodes = _iArrayLength;
+// if (_jArrayLength)
+// NbNodes *= _jArrayLength;
+// if (_kArrayLength)
+// NbNodes *= _kArrayLength;
+// MESH::_numberOfNodes = NbNodes;
+// }
+
+ MESH::_meshDimension = MESH::_spaceDimension;
+}
+
+//=======================================================================
+//function : fillCoordinates
+//purpose :
+//=======================================================================
+
+void GRID::fillCoordinates()
+{
+ if (_is_coordinates_filled)
+ {
+ MESSAGE("GRID::fillCoordinates(): Already filled");
+ return;
+ }
+
+ const char * LOC ="GRID::fillCoordinates()";
+ BEGIN_OF(LOC);
+
+ double* myCoord =
+ const_cast <double *> ( _coordinate->getCoordinates(MED_FULL_INTERLACE) );
+
+ bool hasJ = _jArrayLength, hasK = _kArrayLength;
+ int J = hasJ ? _jArrayLength : 1;
+ int K = hasK ? _kArrayLength : 1;
+ int nb, i, j, k;
+ for (k=0; k < K; ++k) {
+ for (j=0; j < J; ++j) {
+ for (i=0; i < _iArrayLength; ++i) {
+
+ * myCoord = _iArray[ i ];
+ ++ myCoord;
+
+ if (hasJ)
+ {
+ * myCoord = _jArray[ j ];
+ ++ myCoord;
+
+ if (hasK)
+ {
+ * myCoord = _jArray[ k ];
+ ++ myCoord;
+ }
+ }
+ }
+ }
+ }
+
+ _is_coordinates_filled = true;
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : makeConnectivity
+//purpose :
+//=======================================================================
+
+CONNECTIVITY * GRID::makeConnectivity (const medEntityMesh Entity,
+ const medGeometryElement Geometry,
+ const int NbEntities,
+ const int NbNodes,
+ int * NodeNumbers)
+{
+ CONNECTIVITY * Connectivity = new CONNECTIVITY(Entity) ;
+ Connectivity->_numberOfNodes = NbNodes ;
+ Connectivity->_entityDimension = Geometry/100 ;
+
+ int numberOfGeometricType = 1;
+ Connectivity->_numberOfTypes = numberOfGeometricType;
+
+ Connectivity->_count = new int [numberOfGeometricType + 1] ;
+ Connectivity->_count[0] = 1;
+ Connectivity->_count[1] = 1 + NbEntities;
+
+ Connectivity->_type = new CELLMODEL [numberOfGeometricType];
+ Connectivity->_type[0] = CELLMODEL( Geometry ) ;
+
+ Connectivity->_geometricTypes = new medGeometryElement [ numberOfGeometricType ];
+ Connectivity->_geometricTypes[0] = Geometry;
+
+ // Connectivity->_nodal = new MEDSKYLINEARRAY() ;
+ int * skyLineArrayIndex = new int [NbEntities + 1];
+ int i, j, nbEntityNodes = Connectivity->_type[0].getNumberOfNodes();
+ for (i=0, j=1; i <= NbEntities; ++i, j += nbEntityNodes)
+ skyLineArrayIndex [ i ] = j;
+
+ // Connectivity->_nodal->setMEDSKYLINEARRAY (NbEntities, NbNodes,
+ //skyLineArrayIndex, NodeNumbers);
+
+ Connectivity->_nodal = new MEDSKYLINEARRAY (NbEntities, NbNodes,
+ skyLineArrayIndex, NodeNumbers);
+
+ delete [] skyLineArrayIndex;
+
+ // test connectivity right away
+// for (med_int j = 0; j < numberOfGeometricType; j++)
+// {
+// int node_number = Connectivity->_type[j].getNumberOfNodes();
+// for (med_int k = Connectivity->_count[j]; k < Connectivity->_count[j+1]; k++)
+// for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++)
+// {
+// cout << "MEDSKYLINEARRAY::getIJ(" << k << ", " << local_node_number << endl;
+// med_int global_node = Connectivity->_nodal->getIJ(k,local_node_number) ;
+// cout << "...= " << global_node << endl;
+// }
+// }
+
+ return Connectivity;
+}
+
+//=======================================================================
+//function : fillConnectivity
+//purpose : fill _coordinates and _connectivity of MESH if not yet done
+//=======================================================================
+
+void GRID::fillConnectivity()
+{
+ if (_is_connectivity_filled)
+ {
+ MESSAGE("GRID::fillConnectivity(): Already filled");
+ return;
+ }
+
+ const char * LOC = "GRID::fillConnectivity() ";
+ BEGIN_OF(LOC);
+
+ int nbCells, nbFaces, nbEdges;
+ int nbCNodes, nbFNodes, nbENodes;
+ int indexC, indexF, indexE;
+ int * nodeCNumbers, * nodeFNumbers, * nodeENumbers;
+ // about descending connectivity
+ int nbSub, nbRevSub, indexSub, indexRevSub, * subNumbers, * subRevNumbers;
+
+ bool hasFaces = _kArrayLength, hasEdges = _jArrayLength;
+
+ int iLenMin1 = _iArrayLength-1, jLenMin1 = _jArrayLength-1;
+ int kLenMin1 = _kArrayLength-1, ijLenMin1 = iLenMin1 * jLenMin1;
+ if (!hasEdges) jLenMin1 = 1;
+ if (!hasFaces) kLenMin1 = 1;
+
+ // nb of cells and of their connectivity nodes
+
+ nbCells = iLenMin1 * jLenMin1 * kLenMin1;
+ nbCNodes = nbCells * 2 * (hasEdges ? 2 : 1) * (hasFaces ? 2 : 1);
+ nodeCNumbers = new int [ nbCNodes ];
+
+ // nb of faces and of their connectivity nodes
+
+ if (hasFaces) {
+ nbFaces = _iArrayLength * jLenMin1 * kLenMin1;
+ nbFaces += _jArrayLength * kLenMin1 * iLenMin1;
+ nbFaces += _kArrayLength * iLenMin1 * jLenMin1;
+ nbFNodes = nbFaces * 4;
+ nodeFNumbers = new int [ nbFNodes ];
+ } else
+ nbFaces = nbFNodes = 0;
+
+ // nb of edges and of their connectivity nodes
+
+ if (hasEdges) {
+ if (_kArrayLength) { // 3d grid
+ nbEdges = iLenMin1 * _jArrayLength * _kArrayLength;
+ nbEdges += jLenMin1 * _kArrayLength * _iArrayLength;
+ nbEdges += kLenMin1 * _iArrayLength * _jArrayLength;
+ }
+ else if (_jArrayLength) { // 2d
+ nbEdges = iLenMin1 * _jArrayLength;
+ nbEdges += jLenMin1 * _iArrayLength;
+ }
+ nbENodes = nbEdges * 2;
+ nodeENumbers = new int [ nbENodes ];
+ } else
+ nbEdges = nbENodes = 0;
+
+ // nb of descending connectivity Elements
+
+ if (hasFaces)
+ {
+ nbSub = nbCells * 6;
+ nbRevSub = nbFaces * 2;
+ }
+ else
+ {
+ nbSub = nbCells * 4;
+ nbRevSub = nbEdges * 2;
+ }
+ subNumbers = new int [ nbSub ];
+ subRevNumbers = new int [ nbRevSub ];
+ for (int r=0; r<nbRevSub; ++r)
+ subRevNumbers[ r ] = 0;
+
+ int nSubI = 1, nSubJ, nSubK; // subelement numbers
+ if (hasFaces)
+ {
+ nSubJ = getFaceNumber(2, 0, 0, 0);
+ nSubK = getFaceNumber(3, 0, 0, 0);
+ }
+ else
+ nSubJ = getEdgeNumber(2, 0, 0, 0);
+
+
+ // fill cell node numbers and descending element numbers
+
+
+ indexC = indexF = indexE = indexSub = indexRevSub = -1;
+ int iNode = 0, iCell = 0;
+ int ijLen = _iArrayLength * _jArrayLength;
+ int i, j, k, n1, n2, n3 ,n4;
+
+ int I = _iArrayLength;
+ int J = _jArrayLength ? _jArrayLength : 2; // pass at least once
+ int K = _kArrayLength ? _kArrayLength : 2;
+ // pass by all but last nodes in all directions
+ for (k = 1; k < K; ++k ) {
+ for (j = 1; j < J; ++j ) {
+ for (i = 1; i < I; ++i ) {
+
+ ++iCell;
+
+ n1 = ++iNode; // iNode
+ n2 = n1 + 1;
+ nodeCNumbers [ ++indexC ] = n1;
+ nodeCNumbers [ ++indexC ] = n2;
+
+ if (hasEdges) { // at least 2d
+ n3 = n2 + I;
+ n4 = n3 - 1;
+ nodeCNumbers [ ++indexC ] = n3;
+ nodeCNumbers [ ++indexC ] = n4;
+ }
+ if (hasFaces) { // 3d
+ nodeCNumbers [ ++indexC ] = n1 + ijLen;
+ nodeCNumbers [ ++indexC ] = n2 + ijLen;
+ nodeCNumbers [ ++indexC ] = n3 + ijLen;
+ nodeCNumbers [ ++indexC ] = n4 + ijLen;
+
+ // descending faces
+ n1 = nSubI;
+ n2 = n1 + 1;
+ n3 = (n1-1) * 2;
+ n4 = (n2-1) * 2 + 1;
+ subNumbers [ ++indexSub ] = n1;
+ subRevNumbers[ n3 ] = iCell;
+ subNumbers [ ++indexSub ] = n2;
+ subRevNumbers[ n4 ] = -iCell;
+ n1 = nSubJ;
+ n2 = n1 + iLenMin1;
+ n3 = (n1-1) * 2;
+ n4 = (n2-1) * 2 + 1;
+ subNumbers [ ++indexSub ] = n1;
+ subRevNumbers[ n3 ] = iCell;
+ subNumbers [ ++indexSub ] = n2;
+ subRevNumbers[ n4 ] = -iCell;
+ n1 = nSubK;
+ n2 = n1 + ijLenMin1;
+ n3 = (n1-1) * 2;
+ n4 = (n2-1) * 2 + 1;
+ subNumbers [ ++indexSub ] = n1;
+ subRevNumbers[ n3 ] = iCell;
+ subNumbers [ ++indexSub ] = n2;
+ subRevNumbers[ n4 ] = -iCell;
+ }
+ else
+ {
+ // descending edges
+ n1 = nSubI;
+ n2 = n1 + iLenMin1;
+ n3 = (n1-1) * 2;
+ n4 = (n2-1) * 2 + 1;
+ subNumbers [ ++indexSub ] = n1;
+ subRevNumbers[ n3 ] = iCell;
+ subNumbers [ ++indexSub ] = n2;
+ subRevNumbers[ n4 ] = -iCell;
+ n1 = nSubJ;
+ n2 = n1 + 1;
+ n3 = (n1-1) * 2;
+ n4 = (n2-1) * 2 + 1;
+ subNumbers [ ++indexSub ] = n1;
+ subRevNumbers[ n3 ] = iCell;
+ subNumbers [ ++indexSub ] = n2;
+ subRevNumbers[ n4 ] = -iCell;
+ }
+ ++nSubI; ++nSubJ; ++nSubK;
+ }
+ ++iNode; // skip the last node in a row
+ if (hasFaces)
+ ++nSubI;
+ else
+ ++nSubJ;
+ }
+ iNode += I; // skip the whole last row
+ }
+
+ // fill face node numbers
+
+ int ax, AX = hasFaces ? 3 : 0;
+ for (ax = 1; ax <= AX; ++ax) {
+
+ iNode = 0;
+
+ I = _iArrayLength;
+ J = _jArrayLength;
+ K = _kArrayLength;
+ switch (ax) {
+ case 1: --J; --K; break;
+ case 2: --K; --I; break;
+ default: --I; --J;
+ }
+ for (k = 1; k <= K; ++k ) {
+ for (j = 1; j <= J; ++j ) {
+ for (i = 1; i <= I; ++i ) {
+
+ n1 = ++iNode;
+
+ switch (ax) {
+ case 1: // nodes for faces normal to i direction
+ n2 = n1 + ijLen;
+ n3 = n2 + I;
+ n4 = n1 + I;
+ break;
+ case 2: // nodes for faces normal to j direction
+ n2 = n1 + 1;
+ n3 = n2 + ijLen;
+ n4 = n3 - 1;
+ break;
+ default: // nodes for faces normal to k direction
+ n2 = n1 + I;
+ n3 = n2 + 1;
+ n4 = n1 + 1;
+ }
+ nodeFNumbers [ ++indexF ] = n1;
+ nodeFNumbers [ ++indexF ] = n2;
+ nodeFNumbers [ ++indexF ] = n3;
+ nodeFNumbers [ ++indexF ] = n4;
+ }
+ if (ax != 1) ++iNode;
+ }
+ if (ax != 2) iNode += _iArrayLength;
+ }
+ }
+ if (nbFNodes != indexF+1) {
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Wrong nbFNodes : " \
+ << nbFNodes << " indexF : " << indexF ));
+ }
+
+ // fill edge node numbers
+
+ AX = hasEdges ? _spaceDimension : 0;
+ for (ax = 1; ax <= AX; ++ax) {
+
+ iNode = 0;
+
+ I = _iArrayLength;
+ J = _jArrayLength;
+ K = _kArrayLength;
+ if (K == 0) K = 1;
+
+ switch (ax) {
+ case 1: --I; break;
+ case 2: --J; break;
+ default: --K;
+ }
+ for (k = 1; k <= K; ++k ) {
+ for (j = 1; j <= J; ++j ) {
+ for (i = 1; i <= I; ++i ) {
+
+ n1 = ++iNode;
+
+ switch (ax) {
+ case 1: // nodes for edges going along i direction
+ n2 = n1 + 1;
+ break;
+ case 2: // nodes for edges going along j direction
+ n2 = n1 + _iArrayLength;
+ break;
+ default: // nodes for edges going along k direction
+ n2 = n1 + ijLen;
+ }
+ nodeENumbers [ ++indexE ] = n1;
+ nodeENumbers [ ++indexE ] = n2;
+ }
+ if (ax == 1) ++iNode;
+ }
+ if (ax == 2) iNode += _iArrayLength;
+ }
+ }
+ if (nbENodes != indexE+1) {
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Wrong nbFNodes : " \
+ << nbENodes << " indexE : " << indexE ));
+ }
+
+
+ CONNECTIVITY * CellCNCT, * FaceCNCT, * EdgeCNCT;
+
+ // make connectivity for CELL
+
+ medGeometryElement aCellGeometry;
+ if (_kArrayLength) aCellGeometry = MED_HEXA8;
+ else if (_jArrayLength) aCellGeometry = MED_QUAD4;
+ else aCellGeometry = MED_SEG2;
+
+ // nodal
+ CellCNCT = makeConnectivity (MED_CELL, aCellGeometry, nbCells, nbCNodes, nodeCNumbers);
+
+ delete [] nodeCNumbers;
+
+ // descending
+ {
+ // CellCNCT->_descending = new MEDSKYLINEARRAY() ;
+ int * skyLineArrayIndex = new int [nbCells + 1];
+ int nbEntitySub = CellCNCT->_type[0].getNumberOfConstituents(1);
+ for (i=0, j=1; i <= nbCells; ++i, j += nbEntitySub)
+ skyLineArrayIndex [ i ] = j;
+ // CellCNCT->_descending->setMEDSKYLINEARRAY (nbCells, nbSub,
+ // skyLineArrayIndex, subNumbers);
+ CellCNCT->_descending = new MEDSKYLINEARRAY (nbCells, nbSub,
+ skyLineArrayIndex,
+ subNumbers);
+ delete [] skyLineArrayIndex;
+ }
+ delete [] subNumbers;
+
+ // reverse descending
+ {
+ // CellCNCT->_reverseDescendingConnectivity = new MEDSKYLINEARRAY() ;
+ nbSub = nbRevSub/2;
+ int * skyLineArrayIndex = new int [nbSub + 1];
+ for (i=0, j=1; i <= nbSub; ++i, j += 2)
+ skyLineArrayIndex [ i ] = j;
+ // CellCNCT->_reverseDescendingConnectivity->setMEDSKYLINEARRAY
+ // (nbSub, nbRevSub, skyLineArrayIndex, subRevNumbers);
+
+ CellCNCT->_reverseDescendingConnectivity =
+ new MEDSKYLINEARRAY(nbSub, nbRevSub, skyLineArrayIndex, subRevNumbers);
+
+ delete [] skyLineArrayIndex;
+ }
+ delete [] subRevNumbers;
+
+ // make connectivity for FACE and/or EDGE
+
+ if (hasFaces) {
+ FaceCNCT = makeConnectivity (MED_FACE, MED_QUAD4, nbFaces, nbFNodes, nodeFNumbers);
+
+ delete [] nodeFNumbers;
+
+ CellCNCT->_constituent = FaceCNCT;
+ }
+ if (hasEdges) {
+ EdgeCNCT = makeConnectivity (MED_EDGE, MED_SEG2, nbEdges, nbENodes, nodeENumbers);
+
+ delete [] nodeENumbers;
+
+ if (hasFaces)
+ FaceCNCT->_constituent = EdgeCNCT;
+ else
+ CellCNCT->_constituent = EdgeCNCT;
+ }
+
+ MESH::_connectivity = CellCNCT;
+
+ _is_connectivity_filled = true;
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : getArrayLength
+//purpose : return array length. Axis = [1,2,3] meaning [i,j,k],
+//=======================================================================
+
+int GRID::getArrayLength( const int Axis ) throw (MEDEXCEPTION)
+{
+ switch (Axis) {
+ case 1: return _iArrayLength;
+ case 2: return _jArrayLength;
+ case 3: return _kArrayLength;
+ default:
+ throw MED_EXCEPTION ( LOCALIZED( STRING("GRID::getArrayLength ( ") << Axis << ")"));
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : getArrayValue
+//purpose : return i-th array component. Axis = [1,2,3] meaning [i,j,k],
+// exception if Axis out of [1-3] range
+// exception if i is out of range 0 <= i < getArrayLength(Axis);
+//=======================================================================
+
+const double GRID::getArrayValue (const int Axis, const int i)
+ throw (MEDEXCEPTION)
+{
+ if (i < 0 || i >= getArrayLength(Axis))
+ throw MED_EXCEPTION
+ ( LOCALIZED(STRING("GRID::getArrayValue ( ") << Axis << ", " << i << ")"));
+
+ switch (Axis) {
+ case 1: return _iArray[ i ];
+ case 2: return _jArray[ i ];
+ default: return _kArray[ i ];
+ }
+ return 0.0;
+}
+
+//=======================================================================
+//function : getEdgeNumber
+//purpose :
+//=======================================================================
+
+int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GRID::getEdgeNumber(Axis, i,j,k) :";
+
+ int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3;
+ int maxAxis = Len[ K ] ? 3 : 2;
+
+ if (Axis <= 0 || Axis > maxAxis)
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis out of range: " << Axis));
+
+ Len[Axis]--;
+ int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ];
+ Len[Axis]++ ;
+
+ if (!Len[ K ])
+ Len[ K ] = 1;
+
+ if (Axis > 1) { // add all edges in i direction
+ Len[I]-- ;
+ Nb += Len[ I ]*Len[ J ]*Len[ K ];
+ Len[I]++ ;
+ }
+ if (Axis > 2) { // add all edges in j direction
+ Len[J]-- ;
+ Nb += Len[ I ]*Len[ J ]*Len[ K ];
+ }
+
+ return Nb;
+}
+
+//=======================================================================
+//function : getFaceNumber
+//purpose : return a NODE, EDGE, FACE, CELL number by its position in the grid.
+// Axis [1,2,3] means one of directions: along i, j or k
+// For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k):
+// * a FACE which is normal to direction along given Axis;
+// * an EDGE going along given Axis.
+// Exception for Axis out of range
+//=======================================================================
+
+int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GRID::getFaceNumber(Axis, i,j,k) :";
+
+// if (Axis <= 0 || Axis > 3)
+ if (Axis < 0 || Axis > 3)
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis = " << Axis));
+
+ int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
+
+ Len[Axis]++;
+ int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ];
+ Len[Axis]--;
+
+ if (Axis > 1) { // add all faces in i direction
+ Len[I]++ ;
+ Nb += Len[ I ]*Len[ J ]*Len[ K ];
+ Len[I]-- ;
+ }
+ if (Axis > 2) { // add all faces in j direction
+ Len[J]++ ;
+ Nb += Len[ I ]*Len[ J ]*Len[ K ];
+ }
+
+ return Nb;
+}
+
+//=======================================================================
+//function : getNodePosition
+//purpose :
+//=======================================================================
+
+void GRID::getNodePosition(const int Number, int& i, int& j, int& k)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GRID::getNodePosition(Number, i,j,k) :";
+
+ if (Number <= 0 || Number > _numberOfNodes)
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
+
+ int Len[] = {_iArrayLength, _jArrayLength, _kArrayLength }, I=0, J=1, K=2;
+
+ int ijLen = Len[I] * Len[J]; // nb in a full k layer
+ int kLen = (Number - 1) % ijLen; // nb in the non full k layer
+
+ i = kLen % Len[J];
+ j = kLen / Len[J];
+ k = (Number - 1) / ijLen;
+
+ ////cout <<" NODE POS: " << Number << " - " << i << ", " << j << ", " << k << endl;
+}
+
+//=======================================================================
+//function : getCellPosition
+//purpose :
+//=======================================================================
+
+void GRID::getCellPosition(const int Number, int& i, int& j, int& k)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GRID::getCellPosition(Number, i,j,k) :";
+
+ int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
+
+// if (Number <= 0 || Number > getCellNumber(Len[I]-1, Len[J]-1, Len[K]-1))
+// throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
+
+ int ijLen = Len[I] * Len[J]; // nb in a full k layer
+ int kLen = (Number - 1) % ijLen; // nb in the non full k layer
+
+ i = kLen % Len[J];
+ j = kLen / Len[J];
+ k = (Number - 1) / ijLen;
+}
+
+//=======================================================================
+//function : getEdgePosition
+//purpose :
+//=======================================================================
+
+void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GRID::getEdgePosition(Number, i,j,k) :";
+
+ if (!_jArrayLength)
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no edges in the grid: "));
+
+ if (Number <= 0)
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
+
+ int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3;
+
+ int theNb = Number;
+ int maxAxis = _kArrayLength ? 3 : 2;
+
+ for (Axis = 1; Axis <= maxAxis; ++Axis)
+ {
+ Len[Axis]--; // one less edge in Axis direction
+
+ // max edge number in Axis direction
+ int maxNb = getEdgeNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1);
+
+ if (theNb > maxNb)
+ {
+ Len[Axis]++;
+ theNb -= maxNb;
+ continue;
+ }
+
+ if (theNb == maxNb)
+ {
+ i = Len[I]-1;
+ j = Len[J]-1;
+ k = Len[K]-1;
+ }
+ else
+ {
+ int ijLen = Len[I] * Len[J]; // nb in a full k layer
+ int kLen = (theNb - 1) % ijLen; // nb in the non full k layer
+ i = kLen % Len[J];
+ j = kLen / Len[J];
+ k = (theNb - 1) / ijLen;
+ }
+ return;
+ }
+
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
+}
+
+//=======================================================================
+//function : getFacePosition
+//purpose : return position (i,j,k) of an entity #Number
+// Axis [1,2,3] means one of directions: along i, j or k
+// For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k):
+// * a FACE which is normal to direction along given Axis;
+// * an EDGE going along given Axis.
+// Exception for Number out of range
+//=======================================================================
+
+void GRID::getFacePosition(const int Number, int& Axis, int& i, int& j, int& k)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "GRID::getFacePosition(Number, i,j,k) :";
+
+ if (_kArrayLength == 0) {
+ getCellPosition(Number, i, j, k);
+ Axis = 1;
+ return;
+ };
+
+ if (!_kArrayLength)
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no faces in the grid: "));
+
+ if ( Number <= 0 )
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
+
+ int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
+ int theNb = Number;
+
+ for (Axis = 1; Axis <= 3; ++Axis)
+ {
+ Len[Axis]++;
+
+ // max face number in Axis direction
+ int maxNb = getFaceNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1);
+
+ if (theNb > maxNb)
+ {
+ Len[Axis]--;
+ theNb -= maxNb;
+ continue;
+ }
+
+ if (theNb == maxNb)
+ {
+ i = Len[I]-1;
+ j = Len[J]-1;
+ k = Len[K]-1;
+ }
+ else
+ {
+ int ijLen = Len[I] * Len[J]; // nb in a full k layer
+ int kLen = (theNb - 1) % ijLen; // nb in the non full k layer
+ i = kLen % Len[J];
+ j = kLen / Len[J];
+ k = (theNb - 1) / ijLen;
+ }
+ return;
+ }
+
+ throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
+}
+
+//=======================================================================
+//function : writeUnstructured
+//purpose : write a Grid as an Unstructured mesh
+//=======================================================================
+
+void GRID::writeUnstructured(int index, const string & driverName)
+{
+ const char * LOC = "GRID::writeUnstructured(int index=0, const string & driverName) : ";
+ BEGIN_OF(LOC);
+
+ if ( _drivers[index] ) {
+
+ makeUnstructured();
+ _isAGrid = false;
+
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setMeshName(driverName);
+ _drivers[index]->write();
+ _drivers[index]->close();
+
+ _isAGrid = true;
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ END_OF(LOC);
+}
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_Grid.hxx
+// Author : Edward AGAPOV (eap)
+// Module : MED
+// $Header$
+
+#ifndef MEDMEM_Grid_HeaderFile
+#define MEDMEM_Grid_HeaderFile
+
+#include "MEDMEM_Mesh.hxx"
+
+// class containing structured mesh data
+
+class GRID: public MESH
+{
+ protected:
+ //-----------------------//
+ // Fields
+ //-----------------------//
+
+ // 1. grid type: MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED
+ med_grid_type _gridType;
+
+ // 2. node coordinates
+ // For MED_BODY_FITTED MESH::_coordinate is used
+
+ // 2.1. i component array: X for MED_CARTESIAN, R for MED_POLAR
+ int _iArrayLength;
+ double* _iArray;
+ // 2.2. j component array: Y for MED_CARTESIAN, Theta for MED_POLAR
+ int _jArrayLength;
+ double* _jArray;
+ // 2.3. k component array: Z for both MED_CARTESIAN and MED_POLAR
+ int _kArrayLength;
+ double* _kArray;
+
+ // 3. flags to know that _coordinates and _connectivity of MESH are filled
+ bool _is_coordinates_filled;
+ bool _is_connectivity_filled;
+
+ //-----------------------//
+ // Protected Methods
+ //-----------------------//
+
+ CONNECTIVITY * makeConnectivity (const medEntityMesh Entity,
+ const medGeometryElement Geometry,
+ const int NbEntities,
+ const int NbNodes,
+ int * NodeNumbers);
+ // creates nodal connectivity
+
+
+ // Suppose a READ Driver to do the following except filling _[ijk]Array's
+ // 1) fill MESH fields:
+ // * _name
+ // * _spaceDimension
+ // * _meshDimension
+ // * _numberOfNodesFamilies, _numberOfCellsFamilies, ect
+ // * _familyNode, _familyCell, etc
+ // * _numberOfNodesGroups, _numberOfCellsGroups, etc
+ // * _groupNode, _groupCell, etc
+ // * _
+ // 2) create MESH::_coordinate without setting _coordinate->_coordinate and set:
+ // * _coordinate->_coordinateSystem
+ // * _coordinate->_coordinateName
+ // * _coordinate->_coordinateUnit
+
+
+ public:
+ //-----------------------//
+ // Methods
+ //-----------------------//
+
+ GRID();
+ GRID(const med_grid_type type);
+ GRID(const GRID &m);
+ GRID( driverTypes driverType, const string & fileName="",const string & meshName="");
+ GRID & operator=(const GRID &m);
+ virtual ~GRID();
+ virtual void init();
+
+ void fillCoordinates();
+ void fillConnectivity();
+ // fill _coordinates and _connectivity of MESH if not yet done
+
+ inline void makeUnstructured();
+ // fill both coordinates and connectivity of MESH
+
+ void fillMeshAfterRead();
+ // fill some fields (_numberOfNodes, etc.) after reading
+
+ void writeUnstructured(int index=0, const string & driverName = "");
+ // write a Grid as an Unstructured mesh
+
+ // API Methods returning fields of MESH that are filled while reading.
+ // So they need not to be redefined
+
+// string getName() const;
+// int getSpaceDimension();
+// int getMeshDimension();
+// string getCoordinatesSystem();
+// int getNumberOfNodes();
+// string * getCoordinatesNames();
+// string * getCoordinatesUnits();
+// int getNumberOfFamilies(medEntityMesh Entity);
+// vector<FAMILY*> getFamilies(medEntityMesh Entity);
+// FAMILY* getFamily(medEntityMesh Entity,int i);
+// int getNumberOfGroups(medEntityMesh Entity);
+// vector<GROUP*> getGroups(medEntityMesh Entity);
+// GROUP* getGroup(medEntityMesh Entity,int i);
+
+
+// Since a MESH itself knows if it is a GRID, it calls fillConnectivity()
+// or fillCoordinates() whenever needed. So no redifinition of the following methods
+
+// const double * getCoordinates(medModeSwitch Mode);
+// COORDINATE * getCoordinateptr();
+// const double getCoordinate(int Number,int Axis);
+// int getNumberOfTypes(medEntityMesh Entity);
+// medGeometryElement * getTypes(medEntityMesh Entity);
+// CELLMODEL * getCellsTypes(medEntityMesh Entity);
+// medGeometryElement getElementType(medEntityMesh Entity,int Number) ;
+// int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
+// int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ;
+// int * getGlobalNumberingIndex(medEntityMesh Entity);
+// int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type);
+// int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity);
+// int * getReverseConnectivity(medConnectivity ConnectivityType);
+// int * getReverseConnectivityIndex(medConnectivity ConnectivityType);
+// bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity);
+// void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity);
+// FIELD<double>* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ;
+// FIELD<double>* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ;
+// FIELD<double>* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ;
+// FIELD<double>* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ;
+// FIELD<double>* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ;
+
+
+ // Specific GRID methods
+
+ inline int getNodeNumber(const int i, const int j=0, const int k=0);
+ // return a NODE number by its position in the grid.
+ // WARNING: be carefull, there is no check that i,j,k are within a good range
+ // A good range is: 0 <= X < getArrayLength( X_Axis )
+ inline int getCellNumber(const int i, const int j=0, const int k=0) ;
+ // return a CELL number by its position in the grid.
+ // WARNING: be carefull, there is no check that i,j,k are within a good range
+ // A good range is: 0 <= X < (getArrayLength( X_Axis )-1)
+
+ int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) throw (MEDEXCEPTION) ;
+ // return an EDGE number by its position in the grid.
+ // Axis [1,2,3] means one of directions: along i, j or k.
+ // It selects an edge of ones having same (i,j,k):
+ // * an EDGE going along given Axis.
+ // Exception for Axis out of range or when there is no edges in the grid (1D)
+ // WARNING: be carefull, there is no check that i,j,k are within a good range
+ // A good range is:
+ // 0 <= X < (getArrayLength( X_Axis )-1)
+ // 0 <= X < getArrayLength( NOT_X_Axis )
+
+ int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) throw (MEDEXCEPTION) ;
+ // return a FACE number by its position in the grid.
+ // Axis [1,2,3] means one of directions: along i, j or k.
+ // It selects a face of ones having same (i,j,k):
+ // * a FACE which is normal to given Axis
+ // Exception for Axis out of range or when there is no faces in the grid (1,2D)
+ // WARNING: be carefull, there is no check that i,j,k are within a good range
+ // A good range is:
+ // 0 <= X < (getArrayLength( NOT_X_Axis )-1)
+ // 0 <= X < getArrayLength( X_Axis )
+
+
+ void getNodePosition(const int Number, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
+ void getCellPosition(const int Number, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
+ void getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
+ void getFacePosition(const int Number, int& Axis, int& i, int& j, int& k) throw (MEDEXCEPTION) ;
+ // return position (i,j,k) of an entity #Number
+ // Axis: [1,2,3], see get*Number for details
+ // Exception for Number out of range
+
+
+ // Access to fields
+
+ inline med_grid_type getGridType() const;
+ // return MED_CARTESIAN, MED_POLAR or MED_BODY_FITTED
+
+ int getArrayLength( const int Axis ) throw (MEDEXCEPTION);
+ // return array length. Axis = [1,2,3] meaning [i,j,k],
+ // exception if Axis out of [1-3] range
+
+ const double getArrayValue (const int Axis, const int i) throw (MEDEXCEPTION) ;
+ // return i-th array component. Axis = [1,2,3] meaning [i,j,k],
+ // exception if Axis out of [1 - 3] range
+ // exception if i is out of range [0 - (getArrayLength(Axis)-1)];
+
+ // Setting fields
+
+ inline void setGridType(med_grid_type gridType);
+
+ friend class MED_MESH_RDONLY_DRIVER;
+ friend class MED_MESH_WRONLY_DRIVER;
+
+};
+
+
+ //----------------------------------//
+ // Inline Methods Implementation
+ //----------------------------------//
+
+inline med_grid_type GRID::getGridType() const
+{
+ return _gridType;
+}
+//=======================================================================
+//function : getNodeNumber
+//purpose :
+//=======================================================================
+
+inline int GRID::getNodeNumber(const int i, const int j, const int k)
+{
+ return 1 + i + _iArrayLength * j + _iArrayLength * _jArrayLength * k;
+}
+
+//=======================================================================
+//function : getCellNumber
+//purpose :
+//=======================================================================
+
+inline int GRID::getCellNumber(const int i, const int j, const int k)
+{
+ return 1 + i + (_iArrayLength-1) * j + (_iArrayLength-1) * (_jArrayLength-1) * k;
+}
+
+//=======================================================================
+//function : makeUnstructured
+//purpose : fill coordinates and connectivity of MESH
+//=======================================================================
+
+inline void GRID::makeUnstructured()
+{
+ fillCoordinates();
+ fillConnectivity();
+}
+
+//=======================================================================
+//function : setGridType
+//purpose : set the _gridType field od the class GRID
+//=======================================================================
+
+inline void GRID::setGridType(med_grid_type gridType)
+{
+ _gridType = gridType;
+}
+
+#endif
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Group.cxx
+// Module : MED
+
+using namespace std;
/*
File Group.cxx
$Header$
return *this;
};
-GROUP::GROUP(const string & name, const list<FAMILY*> & families)
+ostream & operator<<(ostream &os, GROUP &myGroup)
+{
+ os << (SUPPORT) myGroup;
+
+ int numberoffamilies = myGroup.getNumberOfFamilies();
+ os << " - Families ("<<numberoffamilies<<") :"<<endl;
+ for (int j=1;j<numberoffamilies+1;j++)
+ os << " * "<<myGroup.getFamily(j)->getName().c_str()<<endl ;
+
+ return os;
+};
+
+GROUP::GROUP(const string & name, const list<FAMILY*> & families) throw (MEDEXCEPTION)
{
const char * LOC = "GROUP( const string & , const list<FAMILY*> & ) : " ;
BEGIN_OF(LOC);
MESSAGE(LOC<<name);
+
+ int numberOfFamilies = families.size();
_name = name ;
// description : none !
// first FAMILY to set all !
FAMILY * myFamily = families.front() ;
_mesh = myFamily->getMesh() ;
_entity = myFamily->getEntity() ;
+ bool isOnAllElts = myFamily->isOnAllElements() ;
+ if ((numberOfFamilies==1)&(isOnAllElts))
+ {
+ _numberOfFamilies = numberOfFamilies;
+ _isOnAllElts = false ;
+ _family.resize(_numberOfFamilies) ;
+ _family[0] = myFamily;
+ return;
+ }
+ else if ((!(numberOfFamilies==1))&(isOnAllElts))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "building of a GROUP object from several FAMILY, and one of them is on all entities" )) ;
+
_numberOfGeometricType = myFamily->getNumberOfTypes() ;
_geometricType = new medGeometryElement[_numberOfGeometricType];
//_geometricTypeNumber = new int[_numberOfGeometricType] ;
_numberOfGaussPoint = new int[_numberOfGeometricType] ;
- _numberOfEntities = new int[_numberOfGeometricType] ;
- medGeometryElement * geometricType = myFamily->getTypes() ;
+ _numberOfElements = new int[_numberOfGeometricType] ;
+ const medGeometryElement * geometricType = myFamily->getTypes() ;
//int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
- int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
+ const int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
for (int i=0 ; i<_numberOfGeometricType; i++) {
_geometricType[i]= geometricType[i] ;
// _geometricTypeNumber[i] = geometricTypeNumber[i] ;
_numberOfGaussPoint[i] = numberOfGaussPoint[i] ;
- _numberOfEntities[i]=myFamily->getNumberOfElements(geometricType[i]);
+ _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]);
}
_isOnAllElts = false ;
- _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ //_totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
_number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ;
_numberOfFamilies = families.size();
END_OF(LOC);
};
-void GROUP::init(const list<FAMILY*> & families)
+GROUP::GROUP(const GROUP & m):SUPPORT(m)
{
- const char * LOC = "GROUP::init( const list<FAMILY*> & ) : " ;
+ _numberOfFamilies = m._numberOfFamilies;
+ _family = m._family;
+};
+
+// void GROUP::init(const list<FAMILY*> & families)
+// {
+// const char * LOC = "GROUP::init( const list<FAMILY*> & ) : " ;
- BEGIN_OF(LOC);
+// BEGIN_OF(LOC);
- FAMILY * myFamily = families.front() ;
- _mesh = myFamily->getMesh() ;
- _entity = myFamily->getEntity() ;
- _numberOfGeometricType = myFamily->getNumberOfTypes() ;
- _geometricType = new medGeometryElement[_numberOfGeometricType];
- //_geometricTypeNumber = new int[_numberOfGeometricType] ;
- _numberOfGaussPoint = new int[_numberOfGeometricType] ;
- _numberOfEntities = new int[_numberOfGeometricType] ;
- medGeometryElement * geometricType = myFamily->getTypes() ;
- //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
- int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
- for (int i=0 ; i<_numberOfGeometricType; i++) {
- _geometricType[i]= geometricType[i] ;
- // _geometricTypeNumber[i] = geometricTypeNumber[i] ;
- _numberOfGaussPoint[i] = numberOfGaussPoint[i] ;
- _numberOfEntities[i]=myFamily->getNumberOfElements(geometricType[i]);
- }
- _isOnAllElts = false ;
- _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
- _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ;
+// FAMILY * myFamily = families.front() ;
+// _mesh = myFamily->getMesh() ;
+
+// _isOnAllElts = myFamily->isOnAllElements() ;
+
+// SCRUTE(_mesh);
+
+// SCRUTE(_isOnAllElts);
+
+// _entity = myFamily->getEntity() ;
+
+// SCRUTE(_mesh->getNumberOfTypes(_entity));
+
+// _numberOfGeometricType = myFamily->getNumberOfTypes() ;
+// _geometricType = new medGeometryElement[_numberOfGeometricType];
+// //_geometricTypeNumber = new int[_numberOfGeometricType] ;
+// _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+// _numberOfElements = new int[_numberOfGeometricType] ;
+// medGeometryElement * geometricType = myFamily->getTypes() ;
+// //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ;
+// int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ;
+// for (int i=0 ; i<_numberOfGeometricType; i++) {
+// _geometricType[i]= geometricType[i] ;
+// // _geometricTypeNumber[i] = geometricTypeNumber[i] ;
+// _numberOfGaussPoint[i] = numberOfGaussPoint[i] ;
+// _numberOfElements[i]=myFamily->getNumberOfElements(geometricType[i]);
+// }
+// _isOnAllElts = false ;
+// _totalNumberOfEntities = myFamily->getNumberOfElements(MED_ALL_ELEMENTS) ;
+// _number = new MEDSKYLINEARRAY(*myFamily->getnumber()) ;
- _numberOfFamilies = families.size();
- _family.resize(_numberOfFamilies) ;
- list<FAMILY*>::const_iterator liIni = families.begin() ;
- _family[0]=(*liIni);
- liIni++;
- list<FAMILY*>::const_iterator li ;
- int it = 1 ;
- for (li=liIni;li!=families.end();li++) {
- blending(*li);
- _family[it] = (*li) ;
- it++ ;
- }
+// _numberOfFamilies = families.size();
+// _family.resize(_numberOfFamilies) ;
+// list<FAMILY*>::const_iterator liIni = families.begin() ;
+// _family[0]=(*liIni);
+// liIni++;
+// list<FAMILY*>::const_iterator li ;
+// int it = 1 ;
+// for (li=liIni;li!=families.end();li++) {
+// blending(*li);
+// _family[it] = (*li) ;
+// it++ ;
+// }
- END_OF(LOC);
-};
+// END_OF(LOC);
+// };
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Group.hxx
+// Module : MED
+
/*
File Group.hxx
$Header$
class FAMILY;
+/*!
+
+ This class describe a group of elements on an entity./n
+ It inherits from SUPPORT./n
+ It is a blending of some FAMILY class./n/n
+
+*/
+
class GROUP : public SUPPORT
{
protected :
- /*! Number of families in the group */
+ /*!
+ \if developper
+ Number of families in the group.
+ */
int _numberOfFamilies ;
- /*! Vector of families in the group */
+ /*!
+ \if developper
+ Vector of families in the group.
+ Note that Families are numbered from 1 to N.
+ */
vector<FAMILY*> _family ;
public:
+ /*! Constructor. */
GROUP();
- GROUP(const string & name, const list<FAMILY*> & family);
+ /*! Constructor. */
+ GROUP(const string & name, const list<FAMILY*> & family) throw (MEDEXCEPTION) ;
+ /*! Copy Constructor. */
+ GROUP(const GROUP & m);
+ /*! Destructor. */
~GROUP();
+
+ /*! Copy operator. */
+ // PN ATTention il n y a pas de copie du vecteur Family ????
GROUP & operator=(const GROUP &group);
-
+
+ /*! Operator << */
+ friend ostream & operator<<(ostream &os, GROUP &my) ;
+
inline void setNumberOfFamilies(int numberOfFamilies);
inline void setFamilies(vector<FAMILY*> Family);
inline vector<FAMILY*> getFamilies() const ;
inline FAMILY * getFamily(int i) const ;
- void init(const list<FAMILY*> & family);
};
// inline method :
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Med.cxx
+// Module : MED
+
+using namespace std;
+# include <string>
+
# include "MEDMEM_Med.hxx"
# include "MEDMEM_STRING.hxx"
# include "MEDMEM_Mesh.hxx"
+# include "MEDMEM_Grid.hxx"
# include "MEDMEM_Field.hxx"
# include "MEDMEM_Exception.hxx"
# include "utilities.h"
-// MED constructors
+/*!
+ Constructor.
+*/
MED::MED() {
- const char * LOC = "MED::MED() : ";
-
- MESSAGE(LOC << "Construction...");
-
+ MESSAGE("MED::MED()");
};
-MED::MED(driverTypes driverType, const string & fileName) {
+/*!
+ Constructor.
+*/
+MED::MED(driverTypes driverType, const string & fileName)
+{
const char * LOC = "MED::MED(driverTypes driverType, const string & fileName) : ";
- int current;
+ BEGIN_OF(LOC);
+
+ MED_MED_RDONLY_DRIVER * myDriver = new MED_MED_RDONLY_DRIVER(fileName,this) ;
+ int current = addDriver(*myDriver);
+ //int current= addDriver(driverType,fileName);
- BEGIN_OF(STRING(LOC));
- current = addDriver(driverType,fileName);
_drivers[current]->open();
_drivers[current]->readFileStruct();
_drivers[current]->close();
- END_OF(STRING(LOC));
+
+ END_OF(LOC);
};
+/*!
+ Destructor.
+*/
MED::~MED()
{
+ const char * LOC = "MED::~MED() : ";
+ BEGIN_OF(LOC);
+
+ // Analysis of the object MED
+
+ int index;
+
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+ index = 0;
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ if ( (*currentField).first != NULL) index++;
+ }
+
+ MESSAGE(LOC << " there is(are) " << index << " field(s):");
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ if ( (*currentField).first != NULL) MESSAGE(" " << ((*currentField).first)->getName().c_str());
+ }
+
+ map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::iterator itSupportOnMesh ;
+ index = 0;
+ for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
+ map<MED_FR::med_entite_maillage,SUPPORT *>::iterator itSupport ;
+ for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++)
+ index++;
+ }
+
+ MESSAGE(LOC << " there is(are) " << index << " support(s):");
+
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+ index =0;
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ if ( (*currentMesh).second != NULL)
+ index++;
+ }
+
+ MESSAGE(LOC << " there is(are) " << index << " meshe(s):");
+// for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+// if ( (*currentMesh).second != NULL)
+// {
+// SCRUTE((*currentMesh).second);
+
+// string meshName = ((*currentMesh).second)->getName();
+
+// MESSAGE(" " << meshName);
+// }
+// }
+
+ // delete all ? : PG : YES !
+ // map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ if ( (*currentField).first != NULL) {
+ // cast in right type to delete it !
+ switch ((*currentField).first->getValueType()) {
+ case MED_INT32 :
+ // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms
+ //delete (FIELD<int>*) (*currentField).first ;
+ break ;
+ case MED_REEL64 :
+ // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms
+ //delete (FIELD<double>*) (*currentField).first ;
+ break ;
+ default :
+ INFOS("Field has type different of int or double, could not destroy its values array !") ;
+ // mpv: such recursive destructors call is problematic for current ALLIANCES algorithms
+ //delete (*currentField).first;
+ }
+ }
+ }
+ // map<MESH_NAME_, map<MED_FR::med_entite_maillage,SUPPORT *> >::iterator itSupportOnMesh ;
+ for ( itSupportOnMesh=_support.begin();itSupportOnMesh != _support.end(); itSupportOnMesh++ ) {
+ map<MED_FR::med_entite_maillage,SUPPORT *>::iterator itSupport ;
+ for ( itSupport=(*itSupportOnMesh).second.begin();itSupport!=(*itSupportOnMesh).second.end();itSupport++)
+ ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms
+ //delete (*itSupport).second ;
+ }
+
+ // map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ if ( (*currentMesh).second != NULL)
+ {
+ if (!((*currentMesh).second)->getIsAGrid())
+ ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms
+ //delete (*currentMesh).second;
+ else
+ ;// mpv: such recursive destructors call is problematic for current ALLIANCES algorithms
+ //delete (GRID *) (*currentMesh).second;
+ }
+ }
+
+ index =_drivers.size();
+
+ MESSAGE(LOC << "In this object MED there is(are) " << index << " driver(s):");
+
+ for (int ind=0; ind < _drivers.size(); ind++ )
+ {
+ SCRUTE(_drivers[ind]);
+ if ( _drivers[ind] != NULL) delete _drivers[ind];
+ }
+
+
+
+ END_OF(LOC);
} ;
// ------- Drivers Management Part
-MED::INSTANCE_DE<MED_MED_DRIVER> MED::inst_med ;
-//MED::INSTANCE_DE<VTK_DRIVER> MED::inst_vtk ;
+// Add your new driver instance declaration here (step 3-1)
+MED::INSTANCE_DE<MED_MED_RDWR_DRIVER> MED::inst_med ;
+MED::INSTANCE_DE<VTK_MED_DRIVER> MED::inst_vtk ;
-const MED::INSTANCE * const MED::instances[] = { &MED::inst_med }; //, &MED::inst_vtk } ;
+// Add your new driver instance in the MED instance list (step 3-2)
+const MED::INSTANCE * const MED::instances[] = { &MED::inst_med, &MED::inst_vtk };
+/*!
+ Create the specified driver and return its index reference to path to
+ read or write methods.
+*/
int MED::addDriver(driverTypes driverType, const string & fileName="Default File Name.med") {
const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : ";
BEGIN_OF(LOC);
+ MESSAGE(LOC << " the file name is " << fileName);
driver = instances[driverType]->run(fileName, this) ;
- _drivers.push_back(driver);
current = _drivers.size()-1;
- // _drivers[current]->set...
+ driver->setId(current);
END_OF(LOC);
return current;
}
+/*!
+ Duplicate the given driver and return its index reference to path to
+ read or write methods.
+*/
+int MED::addDriver(GENDRIVER & driver) {
+ const char * LOC = "MED::addDriver(GENDRIVER &) : ";
+ int current;
+
+ BEGIN_OF(LOC);
+
+ SCRUTE(_drivers.size());
+
+ _drivers.push_back(&driver);
-void MED::rmDriver (int index=0) {
+ SCRUTE(_drivers.size());
+
+ SCRUTE(_drivers[0]);
+ SCRUTE(driver);
+
+ current = _drivers.size()-1;
+ driver.setId(current);
+
+ END_OF(LOC);
+ return current;
+
+}
+
+/*!
+ Remove the driver referenced by its index.
+*/
+void MED::rmDriver (int index/*=0*/)
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::rmDriver (int index=0): ";
BEGIN_OF(LOC);
END_OF(LOC);
}
-
-void MED::writeFrom (int index=0)
+/*!
+ ??? to do comment ???
+*/
+void MED::writeFrom (int index/*=0*/)
+ throw (MED_EXCEPTION)
{
const char * LOC = "MED::write (int index=0): ";
BEGIN_OF(LOC);
if (_drivers[index]) {
- _drivers[index]->open();
- _drivers[index]->writeFrom();
- _drivers[index]->close();
+ // open and close are made by all objects !
+ _drivers[index]->writeFrom();
}
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
<< "The index given is invalid, index must be between 0 and |"
END_OF(LOC);
};
-
-void MED::write (int index=0)
+/*!
+ Write all objects with the driver given by its index.
+*/
+void MED::write (int index/*=0*/)
+ throw (MED_EXCEPTION)
{
- const char * LOC = "MED::writeAll (int index=0): ";
+ const char * LOC = "MED::write (int index=0): ";
BEGIN_OF(LOC);
if (_drivers[index]) {
- _drivers[index]->open();
+ // open and close are made by the subsequent objects !
_drivers[index]->write();
- _drivers[index]->close();
}
else
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
END_OF(LOC);
};
+/*!
+ Parse all the file and generate empty object.
-void MED::readFileStruct (int index=0) {
+ All object must be read explicitly later with their own method read
+ or use MED::read to read all.
+
+ This method is automaticaly call by constructor with driver information.
+*/
+void MED::readFileStruct (int index/*=0*/)
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::readFileStruct (int index=0): ";
BEGIN_OF(LOC);
END_OF(LOC);
}
-// void MED::read (int index=0)
-// {
-// const char * LOC = "MED::read (int index=0): ";
-// BEGIN_OF(LOC);
+/*!
+ Read all objects in the file specified in the driver given by its index.
+*/
+void MED::read (int index/*=0*/)
+ throw (MED_EXCEPTION)
+{
+ const char * LOC = "MED::read (int index=0): ";
+ BEGIN_OF(LOC);
-// if (_drivers[index])
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-// << "The index given is invalid, index must be between >0 and < |"
-// << _drivers.size()-1
-// )
-// );
-// // GERER LE 0
-// _drivers[index]->open();
-// _drivers[index]->read();
-// _drivers[index]->close();
-
-// END_OF(LOC);
-
-// };
+ if (_drivers[index]) {
+ // open and close are made by all objects !
+ SCRUTE(index);
+ SCRUTE(_drivers[index]);
+ SCRUTE(&_drivers[index]);
+ // _drivers[index]->open();
+ _drivers[index]->read();
+ // _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between >0 and < |"
+ << _drivers.size()-1
+ )
+ );
+ END_OF(LOC);
+
+};
// ------- End Of Drivers Management Part
+/*!
+ Get the number of MESH objects.
+*/
int MED::getNumberOfMeshes ( void ) const {
const char * LOC = "MED::getNumberOfMeshes ( void ) const : ";
END_OF(LOC);
};
+/*!
+ Get the number of FIELD objects.
+*/
int MED::getNumberOfFields ( void ) const {
const char * LOC = "MED::getNumberOfFields ( void ) const : ";
BEGIN_OF(LOC);
- // return _meshName.size();
return _fields.size(); // we get number of field with different name
END_OF(LOC);
};
-void MED::getMeshNames ( string * meshNames ) const {
+/*!
+ Get the names of all MESH objects.
+ meshNames is an in/out argument.
+
+ It is a string array of size the
+ number of MESH objects. It must be allocated before calling
+ this method. All names are put in it.
+*/
+void MED::getMeshNames ( string * meshNames ) const
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::getMeshNames ( string * ) const : ";
BEGIN_OF(LOC);
int meshNamesSize;
END_OF(LOC);
};
+/*!
+ Get the names of all MESH objects.
+
+ Return a deque<string> object which contain the name of all MESH objects.
+*/
deque<string> MED::getMeshNames () const {
const char * LOC = "MED::getMeshNames () const : ";
return meshNames ;
};
-MESH * MED::getMesh ( const string & meshName ) const {
+
+/*!
+ Return a reference to the MESH object named meshName.
+*/
+MESH * MED::getMesh ( const string & meshName ) const
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::getMesh ( const string & meshName ) const : ";
BEGIN_OF(LOC);
map<MESH_NAME_,MESH*>::const_iterator itMeshes = _meshes.find(meshName);
- // if ( itMeshes == _meshName.end() )
if ( itMeshes == _meshes.end() )
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
<< "There is no known mesh named |"
END_OF(LOC);
}
-MESH * MED::getMesh (const FIELD_ * const field ) const {
+/*!
+ \internal Return a reference to the MESH object associated with
+ field argument.
+*/
+MESH * MED::getMesh (const FIELD_ * const field ) const
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::getMesh ( const FIELD * field ) const : ";
BEGIN_OF(LOC);
if ( itMeshName == _meshName.end() )
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "There is no known field associated with |"
+ << "There is no known mesh associated with |"
<< field << "| pointer"
)
);
};
-void MED::getFieldNames ( string * fieldNames ) const {
+/*!
+ Get the names of all FIELD objects.
+
+ fieldNames is an in/out argument.
+ It is an array of string of size the
+ number of FIELD objects. It must be allocated before calling
+ this method. All names are put in it.
+*/
+void MED::getFieldNames ( string * fieldNames ) const
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::getFieldNames ( string * ) const : ";
BEGIN_OF(LOC);
};
+/*!
+ Get the names of all FIELD objects.
+
+ Return a deque<string> object which contain the name of all FIELD objects.
+*/
deque<string> MED::getFieldNames () const {
const char * LOC = "MED::getFieldNames ( ) const : ";
return fieldNames ;
};
-deque<DT_IT_> MED::getFieldIteration (const string & fieldName) const {
+/*!
+ Return a deque<DT_IT_> which contain all iteration step for the FIELD
+ identified by its name.
+*/
+deque<DT_IT_> MED::getFieldIteration (const string & fieldName) const
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::getFieldIteration ( const string & ) const : ";
BEGIN_OF(LOC);
return Iteration ;
};
-FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NOPDT, const int it=MED_NOPDT ) const {
+/*!
+ Return a reference to the FIELD object named fieldName with
+ time step number dt and order number it.
+*/
+FIELD_ * MED::getField ( const string & fieldName, const int dt=MED_NOPDT, const int it=MED_NOPDT ) const
+ throw (MED_EXCEPTION)
+{
const char * LOC = "MED::getField ( const string &, const int, const int ) const : ";
BEGIN_OF(LOC);
// return os;
// };
-
+/*!
+ Return a map<MED_FR::med_entite_maillage,SUPPORT*> which contain
+ foreach entity, a reference to the SUPPORT on all elements.
+*/
const map<MED_FR::med_entite_maillage,SUPPORT*> & MED::getSupports(const string & meshName) const
+ throw (MED_EXCEPTION)
{
const char * LOC = "MED::getSupports ( const string ) const : ";
BEGIN_OF(LOC);
return (*itSupportOnMesh).second ;
}
+/*!
+ Return a reference to the SUPPORT object on all elements of entity
+ for the MESH named meshName.
+*/
SUPPORT * MED::getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const
+ throw (MED_EXCEPTION)
{
const char * LOC = "MED::getSupport ( const string, MED_FR::med_entite_maillage ) const : ";
BEGIN_OF(LOC);
return (*itSupport).second ;
};
+/*!
+ Temporary method : when all MESH objects are read, this methods
+ update all SUPPORT objects with the rigth dimension.
+*/
void MED::updateSupport ()
{
}
catch (MEDEXCEPTION & ex) {
// entity not defined in mesh -> we remove support on it !
+ MESSAGE(LOC<<ex.what());
delete (*itSupport).second ;
(*itSupportOnMesh).second.erase(itSupport) ; // that's rigth ????
+ itSupport-- ;
}
}
END_OF(LOC);
}
-void MED::addMesh(const MESH * ptrMesh) throw (MEDEXCEPTION)
+/*!
+ Add the given MESH object. MED object control it,
+ and destroy it, so you must not destroy it after.
+
+ The meshName is given by the MESH object.
+*/
+void MED::addMesh( MESH * const ptrMesh)
+ throw (MED_EXCEPTION)
{
const char * LOC = "MED::addMesh(const MESH * ptrMesh): ";
+ BEGIN_OF(LOC);
+
+ if ( ! ptrMesh )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrMesh must not be NULL !"));
+
+ string meshName;
+ if ( ! ( meshName = ptrMesh->getName()).size() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrMesh->_name must not be NULL !"));
+
+ _meshes[meshName] = ptrMesh; // if ptrMesh->meshName already exists it is modified
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "WARNING method not yet implemented"));
+ END_OF(LOC);
}
-void MED::addField(const FIELD_ * const ptrField) throw (MEDEXCEPTION)
+/*!
+ Add the given FIELD object. MED object control it,
+ and destroy it, so you must not destroy it after.
+
+ The fieldName is given by the FIELD object.
+*/
+void MED::addField( FIELD_ * const ptrField)
+ throw (MED_EXCEPTION)
{
const char * LOC = "MED::addField(const FIELD_ * const ptrField): ";
+ BEGIN_OF(LOC);
+
+ if ( ! ptrField )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField must not be NULL !"));
+
+ string fieldName;
+ if ( ! (fieldName = ptrField->getName()).size() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_name must not be NULL !"));
+
+ SUPPORT * ptrSupport;
+ if ( ! ( ptrSupport = (SUPPORT * ) ptrField->getSupport()) )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support must not be NULL !"));
+
+ MESH * ptrMesh;
+ if ( ! ( ptrMesh = ptrSupport->getMesh()) )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support->_mesh must not be NULL !"));
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "WARNING method not yet implemented"));
+ string meshName;
+ if ( ! ( meshName = ptrMesh->getName()).size() )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "ptrField->_support->_mesh->_name must not be NULL !"));
+
+ DT_IT_ dtIt;
+ dtIt.dt = ptrField->getIterationNumber();
+ dtIt.it = ptrField->getOrderNumber();
+
+ _fields [fieldName][dtIt] = ptrField; // if it already exists it is replaced
+ _meshName [ptrField] = meshName; // if it already exists it is replaced
+ _meshes [meshName] = ptrMesh; // if it already exists it is replaced
+
+ int numberOfTypes = ptrSupport->getNumberOfTypes();
+ _support [meshName][ (MED_FR::med_entite_maillage) ptrSupport->getEntity()] = ptrSupport;// if it already exists it is replaced
+
+
+ END_OF(LOC);
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Med.hxx
+// Module : MED
+
# ifndef MED_HXX
# define MED_HXX
// LOCAL
# include "MEDMEM_define.hxx"
+
+// Add your own driver header (step 2)
# include "MEDMEM_MedMedDriver.hxx"
+# include "MEDMEM_VtkMedDriver.hxx"
+
# include "MEDMEM_Exception.hxx"
//using namespace MED_EN;
// CONTAINNED WITHIN A FILE <fileName> OF TYPE GIVEN BY THE <driverType> PARAMETER
// - IN THE SECOND CASE THE USER BEGINS HIS WORK WITH A MESH OR A FIELD,
// ?? GET A MED POINTER THEN CAN ADD MESHes OR FIELDs ??
+//
+
+/*!
+
+ This class is use to group together some MESH, SUPPORT and FIELD
+ objects.
+
+*/
class MED
{
- friend class MED_MED_DRIVER;
+ // Add your personnal driver line (step 2)
friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
private:
map<MESH_NAME_,MESH*> _meshes; // We can't have two MESHes with the same meshName.
- // The string key is a meshName.
+ // The string key is a meshName.
- map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELDs with the same fieldName.
+ map<FIELD_NAME_,MAP_DT_IT_> _fields; // We can't have two FIELD_s with the same fieldName.
- map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD *
- // in order to get the MESH* from _meshes
+ map<FIELD_ *, MESH_NAME_> _meshName; // Get the meshName associated with a FIELD_ *
+ // in order to get the MESH* from _meshes
+ // POURQUOI MED_FR::med_entite_maillage ? devrait être MED_EN !
map < MESH_NAME_, map <MED_FR::med_entite_maillage,SUPPORT * > > _support ;
// For each MESH, we list support for each entity on all elements.
// INUTILE : void addMesh (const string & meshName ); // Read the mesh <meshName> found in the file <_fileName>. <_fileName> must be set.
// INUTILE : void addField (const string & fieldName ); // Pensez au cas ou on ajoute un Field/Mesh avec un driver déjà existant.
- void addField (const FIELD_ * const ptrField ) throw (MEDEXCEPTION) ; // Add an existing FIELD object to the FIELD list, the meshName is given by the FIELD object.
- void addMesh (const MESH * ptrMesh ) throw (MEDEXCEPTION) ; // Add an existing MESH object to the MESH list, the meshName is given by the MESH object.
-
+ void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ;
+ void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ;
+
// ------ Drivers Management Part
protected:
template <class T> class INSTANCE_DE : public INSTANCE {
public :
- GENDRIVER * run(const string & fileName, MED * const ptrMed) const { return new T(fileName,ptrMed) ; }
+ GENDRIVER * run(const string & fileName, MED * const ptrMed) const
+ {
+ MESSAGE("GENDRIVER * run") ;
+ return new T(fileName,ptrMed) ;
+ }
} ;
- static INSTANCE_DE<MED_MED_DRIVER> inst_med ;
- //static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
+ // Add your new driver instance here (step 3)
+ static INSTANCE_DE<MED_MED_RDWR_DRIVER> inst_med ;
+ static INSTANCE_DE<VTK_MED_DRIVER> inst_vtk ;
static const INSTANCE * const instances[] ;
public:
int addDriver (driverTypes driverType, const string & fileName);
- void rmDriver (int index=0);
- void readFileStruct(int index=0);
- // void read (int index=0);
- void writeFrom (int index=0);
- void write (int index=0);
+ int addDriver (GENDRIVER & driver);
+ void rmDriver (int index=0) throw (MEDEXCEPTION) ;
+
+ void readFileStruct(int index=0) throw (MEDEXCEPTION) ;
+ void read (int index=0) throw (MEDEXCEPTION) ;
+ void writeFrom (int index=0) throw (MEDEXCEPTION) ;
+ void write (int index=0) throw (MEDEXCEPTION) ;
// ------ End Of Drivers Management Part
int getNumberOfMeshes ( void ) const;
int getNumberOfFields ( void ) const;
- void getMeshNames ( string * meshNames ) const;
- deque<string> getMeshNames () const;
- MESH * getMesh ( const string & meshName ) const;
- MESH * getMesh ( const FIELD_ * field ) const;
- void getFieldNames ( string * fieldNames ) const;
- deque<string> getFieldNames () const;
+ void getMeshNames ( string * meshNames ) const throw (MEDEXCEPTION) ;
+ deque<string> getMeshNames () const;
+ MESH * getMesh ( const string & meshName ) const throw (MEDEXCEPTION) ;
+ MESH * getMesh ( const FIELD_ * const field ) const throw (MEDEXCEPTION) ;
+ void getFieldNames ( string * fieldNames ) const throw (MEDEXCEPTION) ;
+ deque<string> getFieldNames () const;
// A FAIRE DES ROUTINES QUI DONNENT LES PDT ET ITE
- deque<DT_IT_> getFieldIteration (const string & fieldName) const ;
+ deque<DT_IT_> getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION) ;
FIELD_ * getField ( const string & fieldName,
- const int dt, const int it) const;
+ const int dt, const int it) const throw (MEDEXCEPTION) ;
+
+ const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const throw (MEDEXCEPTION) ;
- const map<MED_FR::med_entite_maillage,SUPPORT *> & getSupports(const string & meshName) const;
- SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const ;
+ SUPPORT * getSupport (const string & meshName,MED_FR::med_entite_maillage entity) const throw (MEDEXCEPTION) ;
void updateSupport () ;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedFieldDriver.hxx
+// Module : MED
+
#ifndef MED_FIELD_DRIVER_HXX
#define MED_FIELD_DRIVER_HXX
#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Unit.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_Support.hxx"
//#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Mesh.hxx"
//using namespace MED_FR ;
template <class T> class FIELD;
// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt...
+
+/*!
+
+ Driver Med for FIELD.
+
+ Generic part : implement open and close methods.
+
+*/
+
template <class T> class MED_FIELD_DRIVER : public GENDRIVER
{
protected:
// static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
+ /*!
+ Constructor.
+ */
MED_FIELD_DRIVER():GENDRIVER(),
_ptrField((FIELD<T> *)MED_NULL),_medIdt(MED_INVALID),
_fieldName(""),_fieldNum(MED_INVALID) {}
+ /*!
+ Constructor.
+ */
MED_FIELD_DRIVER(const string & fileName, FIELD<T> * ptrField,
med_mode_acces accessMode)
: GENDRIVER(fileName,accessMode),
_ptrField((FIELD<T> *) ptrField),_medIdt(MED_INVALID),
- _fieldName(""),_fieldNum(MED_INVALID)
+ _fieldName(fileName),_fieldNum(MED_INVALID)
{
}
-
- void open() {
+
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_DRIVER(const MED_FIELD_DRIVER & fieldDriver):
+ GENDRIVER(fieldDriver),
+ _ptrField(fieldDriver._ptrField),
+ _medIdt(MED_INVALID),
+ _fieldName(fieldDriver._fieldName),
+ _fieldNum(fieldDriver._fieldNum)
+ {
+ }
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_DRIVER() {
+ }
+
+ void open() throw (MEDEXCEPTION)
+ {
const char * LOC = "MED_FIELD_DRIVER::open() ";
BEGIN_OF(LOC);
// we must set fieldname before open, because we must find field number in file (if it exist !!!)
+ if ( _fileName == "" )
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "_fileName is |\"\"|, please set a correct fileName before calling open()"
+ )
+ );
MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
_medIdt = MED_FR::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode);
MESSAGE(LOC<<"_medIdt : "<< _medIdt );
- if (_medIdt > 0) _status=MED_OPENED; else {
+ if (_medIdt > 0)
+ _status=MED_OPENED;
+ else {
_status = MED_INVALID;
+ _medIdt = MED_INVALID;
+ throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
+ << "Can't open |" << _fileName
+ << "|, _medIdt : " << _medIdt
+ )
+ );
}
END_OF(LOC);
MED_FR::med_int err = 0;
if (_status == MED_OPENED) {
err=MED_FR::MEDfermer(_medIdt);
- H5close();
+ H5close(); // If we call H5close() all the files are closed.
_status = MED_CLOSED;
_medIdt = MED_INVALID;
MESSAGE(" MED_FIELD_DRIVER::close() : MEDfermer : _medIdt= " << _medIdt );
virtual void write( void ) const = 0 ;
virtual void read ( void ) = 0 ;
+
+ /*!
+ Set the name of the FIELD asked in file.
+
+ It could be different than the name of the FIELD object.
+ */
void setFieldName(const string & fieldName) ;
+ /*!
+ Get the name of the FIELD asked in file.
+ */
string getFieldName() const ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+
};
+/*!
+
+ Driver Med for FIELD : Read only.
+
+ Implement read method.
+
+*/
+
template <class T> class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER<T>
{
public :
+ /*!
+ Constructor.
+ */
MED_FIELD_RDONLY_DRIVER():MED_FIELD_DRIVER<T>() {};
+ /*!
+ Constructor.
+ */
MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
MED_FIELD_DRIVER<T>(fileName,ptrField,MED_RDONLY) {
BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
}
- ~MED_FIELD_RDONLY_DRIVER() {
- BEGIN_OF("MED_FIELD_RDONLY_DRIVER::~MED_FIELD_RDONLY_DRIVER()");
- END_OF("MED_FIELD_RDONLY_DRIVER::~MED_FIELD_RDONLY_DRIVER()");
- }
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver) {};
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_RDONLY_DRIVER() {};
// CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
- void write( void ) const ;
- void read ( void ) ;
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write( void ) const throw (MEDEXCEPTION) ;
+ /*!
+ Read FIELD in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
+
};
+/*!
+
+ Driver Med for FIELD : Write only.
+
+ Implement write method.
+
+*/
+
template <class T> class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER<T> {
public :
+ /*!
+ Constructor.
+ */
MED_FIELD_WRONLY_DRIVER():MED_FIELD_DRIVER<T>() {}
+ /*!
+ Constructor.
+ */
MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD<T> * ptrField):
MED_FIELD_DRIVER<T>(fileName,ptrField,MED_WRONLY)
{
END_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
};
- ~MED_FIELD_WRONLY_DRIVER() { }
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver) {};
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_FIELD_WRONLY_DRIVER() {};
+
+ /*!
+ Write FIELD in the specified file.
+ */
+ void write( void ) const throw (MEDEXCEPTION) ;
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
- void write( void ) const ;
- void read ( void ) ;
};
+/*!
+
+ Driver Med for FIELD : Read write.
+ - Use read method from MED_FIELD_RDONLY_DRIVER
+ - Use write method from MED_FIELD_WDONLY_DRIVER
+
+*/
+
template <class T> class MED_FIELD_RDWR_DRIVER : public MED_FIELD_RDONLY_DRIVER<T>, public MED_FIELD_WRONLY_DRIVER<T> {
public :
+ /*!
+ Constructor.
+ */
MED_FIELD_RDWR_DRIVER():MED_FIELD_DRIVER<T>() {}
+ /*!
+ Constructor.
+ */
MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD<T> * ptrField):
MED_FIELD_DRIVER<T>(fileName,ptrField,MED_RDWR)
{
BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
+ //_accessMode = MED_RDWR ;
END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD<T> * ptrField)");
};
- ~MED_FIELD_RDWR_DRIVER() { }
+ /*!
+ Copy constructor.
+ */
+ MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver):
+ MED_FIELD_DRIVER<T>(fieldDriver) {};
+
+ /*!
+ Destructor.
+ */
+ ~MED_FIELD_RDWR_DRIVER() {};
+
+ /*!
+ Write FIELD in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION) ;
+ /*!
+ Read FIELD in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION) ;
+
+private:
+ GENDRIVER * copy( void ) const ;
- void write(void) const ;
- void read (void) ;
};
/*--------------------- RDONLY PART -------------------------------*/
+template <class T> GENDRIVER * MED_FIELD_RDONLY_DRIVER<T>::copy(void) const
+{
+ MED_FIELD_RDONLY_DRIVER<T> * myDriver =
+ new MED_FIELD_RDONLY_DRIVER<T>(*this);
+ return myDriver ;
+}
+
template <class T> void MED_FIELD_RDONLY_DRIVER<T>::read(void)
+ throw (MEDEXCEPTION)
{
const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ;
BEGIN_OF(LOC);
_fieldNum = i ;
break ;
}
+ // not found : release memory and search next field !
+ delete[] componentName ;
+ delete[] unitName ;
}
}
// read values for each geometric type in _support
int NumberOfTypes = _ptrField->_support->getNumberOfTypes() ;
- medGeometryElement *Types = _ptrField->_support->getTypes() ;
+ const medGeometryElement *Types = _ptrField->_support->getTypes() ;
T ** myValues = new (T*)[NumberOfTypes] ;
int * NumberOfValues = new int[NumberOfTypes] ;
int TotalNumberOfValues = 0 ;
_ptrField->getOrderNumber()
) < 0) {
// we must do some delete !!!
+ for(int j=0; j<=i;j++)
+ delete[] myValues[j];
+ delete[] myValues;
+ delete[] NumberOfValues ;
+ delete[] ProfilName;
+ delete[] _ptrField->_componentsTypes ;
+ delete[] _ptrField->_componentsNames ;
+ delete[] _ptrField->_componentsUnits ;
+ delete[] _ptrField->_componentsDescriptions ;
+ delete[] _ptrField->_MEDComponentsUnits ;
+ _ptrField->_componentsTypes = NULL ;
+ _ptrField->_componentsNames = NULL ;
+ _ptrField->_componentsUnits = NULL ;
+ _ptrField->_componentsDescriptions = NULL ;
+ _ptrField->_MEDComponentsUnits = NULL ;
_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number
throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
}
_ptrField->_value=new MEDARRAY<T>(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE);
MEDARRAY<T> * Values = _ptrField->_value ; // create by constructor ???
- // check if dimensions are right
- if (Values->getLeadingValue() != numberOfComponents)
- throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
- if (Values->getLengthValue() != TotalNumberOfValues)
- throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<<Values->getLengthValue()<<" and "<<TotalNumberOfValues) ) ;
+ // check if dimensions are right : inutile : c'est dans le constructeur !!!
+ //if (Values->getLeadingValue() != numberOfComponents)
+ // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<<Values->getLeadingValue()<<" and "<<numberOfComponents) ) ;
+ //if (Values->getLengthValue() != TotalNumberOfValues)
+ // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<<Values->getLengthValue()<<" and "<<TotalNumberOfValues) ) ;
for (int i=0; i<numberOfComponents; i++) {
- T * ValuesT = Values->getI(MED_NO_INTERLACE,i+1) ;
- int Count = 0 ;
+ //T * ValuesT = Values->getRow(i+1) ;
+ int Count = 1 ;
for (int j=0; j<NumberOfTypes; j++) {
T * myValue = myValues[j] ;
int NumberOf = NumberOfValues[j] ;
+ _ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
int offset = NumberOf*i ;
for (int k=0 ; k<NumberOf; k++) {
- ValuesT[Count]=myValue[k+offset] ;
+ //ValuesT[Count]=myValue[k+offset] ;
+ Values->setIJ(Count,i+1,myValue[k+offset]);
+ SCRUTE(Count);
+ SCRUTE(Values->getIJ(Count,i+1));
Count++;
}
}
delete[] myValues[j] ;
delete[] myValues ;
delete[] NumberOfValues ;
+
+ _ptrField->_isRead = true ;
}
+
END_OF(LOC);
}
template <class T> void MED_FIELD_RDONLY_DRIVER<T>::write( void ) const
+ throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MED_FIELD_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
}
/*--------------------- WRONLY PART -------------------------------*/
+template <class T> GENDRIVER * MED_FIELD_WRONLY_DRIVER<T>::copy(void) const
+{
+ MED_FIELD_WRONLY_DRIVER<T> * myDriver =
+ new MED_FIELD_WRONLY_DRIVER<T>(*this);
+ return myDriver ;
+}
+
template <class T> void MED_FIELD_WRONLY_DRIVER<T>::read (void)
+ throw (MEDEXCEPTION)
{
- throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::write : Can't read with a WRONLY driver !");
+ throw MEDEXCEPTION("MED_FIELD_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
}
template <class T> void MED_FIELD_WRONLY_DRIVER<T>::write(void) const
+ throw (MEDEXCEPTION)
{
const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ;
BEGIN_OF(LOC);
string component_name(component_count*MED_TAILLE_PNOM,' ') ;
string component_unit(component_count*MED_TAILLE_PNOM,' ') ;
- string * listcomponent_name=_ptrField->getComponentsNames() ;
- string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ;
+ const string * listcomponent_name=_ptrField->getComponentsNames() ;
+ const string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ;
int length ;
for (int i=0; i < component_count ; i++) {
length = min(MED_TAILLE_PNOM,(int)listcomponent_name[i].size());
// on boucle sur tout les types pour ecrire les tableaux de valeur
int NumberOfType = mySupport->getNumberOfTypes() ;
int Index = 1 ;
- medGeometryElement * Types = mySupport->getTypes() ;
- int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
+ const medGeometryElement * Types = mySupport->getTypes() ;
+ const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ;
for (int i=0;i<NumberOfType;i++) {
int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
MESSAGE(" "<<_ptrField->getOrderNumber());
MESSAGE("MEDchampEcr :"<<MeshName.c_str());
- T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
+ const T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
err=MED_FR::MEDchampEcr(_medIdt, const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
const_cast <char*> ( (_ptrField->getName()).c_str()),
/*--------------------- RDWR PART -------------------------------*/
+template <class T> GENDRIVER * MED_FIELD_RDWR_DRIVER<T>::copy(void) const
+{
+ MED_FIELD_RDWR_DRIVER<T> * myDriver =
+ new MED_FIELD_RDWR_DRIVER<T>(*this);
+ return myDriver ;
+}
+
template <class T> void MED_FIELD_RDWR_DRIVER<T>::write(void) const
+ throw (MEDEXCEPTION)
{
BEGIN_OF("MED_FIELD_RDWR_DRIVER::write(void)");
MED_FIELD_WRONLY_DRIVER<T>::write();
}
template <class T> void MED_FIELD_RDWR_DRIVER<T>::read (void)
+ throw (MEDEXCEPTION)
{
BEGIN_OF("MED_FIELD_RDWR_DRIVER::read(void)");
MED_FIELD_RDONLY_DRIVER<T>::read();
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedMedDriver.cxx
+// Module : MED
+
+using namespace std;
# include <string>
# include "MEDMEM_MedMedDriver.hxx"
# include "MEDMEM_DriversDef.hxx"
# include "MEDMEM_Mesh.hxx"
+# include "MEDMEM_Grid.hxx"
# include "MEDMEM_Field.hxx"
// EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
# include "MEDMEM_MedFieldDriver.hxx"
using namespace MED_FR;
MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(),
- _ptrMed((MED * const)MED_NULL),
- _medIdt(MED_INVALID)
+ _ptrMed((MED * const)MED_NULL),_medIdt(MED_INVALID)
{}
MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed):
GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _medIdt(MED_INVALID)
-{}
+{
+ _ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
+}
MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,
MED * const ptrMed,
MED_EN::med_mode_acces accessMode):
GENDRIVER(fileName,accessMode), _ptrMed(ptrMed), _medIdt(MED_INVALID)
-{}
-
+{
+}
//REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
+MED_MED_DRIVER::MED_MED_DRIVER(const MED_MED_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMed(driver._ptrMed),
+ _medIdt(MED_INVALID)
+{
+}
+
+MED_MED_DRIVER::~MED_MED_DRIVER()
+{
+ MESSAGE("MED_MED_DRIVER::~MED_MED_DRIVER() has been destroyed");
+}
+
+// GENDRIVER * MED_MED_DRIVER::copy(void) const
+// {
+// return new MED_MED_DRIVER(*this) ;
+// }
+void MED_MED_DRIVER::read()
+{
+}
+void MED_MED_DRIVER::readFileStruct()
+{
+}
+void MED_MED_DRIVER::write() const
+{
+}
+GENDRIVER * MED_MED_DRIVER::copy(void) const
+{
+}
+void MED_MED_DRIVER::writeFrom() const
+{
+}
+
+
-void MED_MED_DRIVER::open() {
+void MED_MED_DRIVER::open()
+ throw (MEDEXCEPTION)
+{
const char * LOC ="MED_MED_DRIVER::open() : ";
BEGIN_OF(LOC);
// REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
- if ( _medIdt != MED_INVALID )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_medIdt is already in use, please close the file |"
- << _fileName << "| before calling open()"
- )
- );
+// if ( _medIdt != MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_medIdt is already in use, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
- if ( _status != MED_CLOSED )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_status is closed, please close the file |"
- << _fileName << "| before calling open()"
- )
- );
+// if ( _status != MED_CLOSED )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "_status is closed, please close the file |"
+// << _fileName << "| before calling open()"
+// )
+// );
if ( _fileName == "" )
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
)
);
+ MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
_medIdt = MEDouvrir( (const_cast <char *> (_fileName.c_str())), (MED_FR::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt = "<<_medIdt);
- if (_medIdt > 0) _status=MED_OPENED;
+ if (_medIdt > 0)
+ _status=MED_OPENED;
else {
_status = MED_CLOSED;
_medIdt = MED_INVALID;
)
);
}
-
+
END_OF(LOC);
}
-void MED_MED_DRIVER::close() {
+void MED_MED_DRIVER::close()
+{
MED_FR::med_int err = 0;
const char * LOC = "MED_MED_DRIVER::close() : ";
- if ( _status == MED_CLOSED)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
- << _fileName << "| is already closed"
- )
- );
+// if ( _status == MED_CLOSED)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
+// << _fileName << "| is already closed"
+// )
+// );
- if ( _medIdt == MED_INVALID )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
- << _fileName << "| seems to be openned !"
- )
- );
+// if ( _medIdt == MED_INVALID )
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
+// << _fileName << "| seems to be openned !"
+// )
+// );
+
+ if ( _medIdt != MED_INVALID )
+ err=MEDfermer(_medIdt);
- err=MEDfermer(_medIdt);
+// if (err != MED_VALID)
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
+// << _fileName << "| couldn't be closed"
+// )
+// );
_status = MED_CLOSED;
_medIdt = MED_INVALID;
-
- if (err != MED_VALID)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
- << _fileName << "| couldn't be closed"
- )
- );
-
+
END_OF(LOC);
}
+// ------------- Read Only Part --------------
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER():MED_MED_DRIVER()
+{
+}
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
+}
+
+MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver):
+ MED_MED_DRIVER(driver)
+{
+}
+
+MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER()
+{
+ MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * MED_MED_RDONLY_DRIVER::copy(void) const
+{
+ return new MED_MED_RDONLY_DRIVER(*this) ;
+}
-void MED_MED_DRIVER::readFileStruct( void )
+void MED_MED_RDONLY_DRIVER::readFileStruct( void )
+ throw (MEDEXCEPTION)
{
const char * LOC = "MED_MED_DRIVER::readFileStruct() : ";
int err,i,j;
MESH_ENTITIES::const_iterator currentEntity;
for (i=1;i<=numberOfMeshes;i++) {
+
+ // find out if the mesh is a Grid
+
+ int isAGrid = false;
+ MED_FR::med_grid_type type;
+
+ err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
+ if (err != MED_VALID)
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
+
err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
if (err != MED_VALID)
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
);
MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
- ptrMesh = new MESH();
- // NO : create a MED_MESH_RDWR_DRIVER with the currently used
- // _medIdt which remains VALID as long as _fileName is openned
- // NO: then as long as the MED driver remains open
- MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
- _ptrDriver->setMeshName(meshName);
- ptrMesh->addDriver(*_ptrDriver);
- _ptrMed->_meshes[meshName] = ptrMesh;
+ if (isAGrid)
+ ptrMesh = new GRID((MED_EN::med_grid_type) type);
+ else
+ ptrMesh = new MESH();
+
+ //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+ MED_EN::med_mode_acces myMode = getAccessMode();
+ MED_MESH_DRIVER * ptrDriver ;
+ switch (myMode) {
+ case MED_EN::MED_LECT:
+ ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+ break ;
+ case MED_EN::MED_REMP:
+ ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
+ break ;
+ case MED_EN::MED_ECRI: // should never append !!
+ ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+ }
+ ptrDriver->setId ( getId() );
+ ptrDriver->setMeshName ( meshName );
+ ptrMesh->addDriver(*ptrDriver);
+ delete ptrDriver ;
+
+ if (isAGrid)
+ _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
+ else
+ _ptrMed->_meshes[meshName] = ptrMesh;
+
+ ptrMesh->setName(meshName);
+
+ SCRUTE(ptrMesh);
+
+ MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
+
// we create all global support (for each entity type :
for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
string supportName="SupportOnAll_" ;
supportName+=entNames[(MED_FR::med_entite_maillage)(*currentEntity).first] ;
- (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
+ //(_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
+ SUPPORT* mySupport = new SUPPORT() ;
+ mySupport->setName(supportName);
+ mySupport->setMesh(ptrMesh);
+ mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
+ mySupport->setAll(true);
+ (_ptrMed->_support)[meshName][(MED_FR::med_entite_maillage)(*currentEntity).first] = mySupport ;
}
}
}
((FIELD<MED_FR::med_int>*) ptrField)->setNumberOfComponents(numberOfComponents);
((FIELD<MED_FR::med_int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
MESSAGE("#### SET NAME in FIELD : "<<fieldName);
- ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_int> (_fileName, (FIELD<MED_FR::med_int> *) ptrField);
+
+ MED_EN::med_mode_acces myMode = getAccessMode();
+ switch (myMode) {
+ case MED_EN::MED_LECT:
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_int>(_fileName, (FIELD<MED_FR::med_int> *)ptrField);
+ break ;
+ case MED_EN::MED_REMP:
+ ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_int>(_fileName, (FIELD<MED_FR::med_int> *)ptrField);
+ break ;
+ case MED_EN::MED_ECRI: // should never append !!
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_int>(_fileName, (FIELD<MED_FR::med_int> *)ptrField);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+ }
break;
}
case MED_FR::MED_REEL64 : {
((FIELD<MED_FR::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
MESSAGE("#### SET NAME in FIELD : "<<fieldName);
- ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *) ptrField);
+ MED_EN::med_mode_acces myMode = getAccessMode();
+ switch (myMode) {
+ case MED_EN::MED_LECT:
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *)ptrField);
+ break ;
+ case MED_EN::MED_REMP:
+ ptrDriver = new MED_FIELD_RDWR_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *)ptrField);
+ break ;
+ case MED_EN::MED_ECRI: // should never append !!
+ ptrDriver = new MED_FIELD_RDONLY_DRIVER<MED_FR::med_float>(_fileName, (FIELD<MED_FR::med_float> *)ptrField);
+ break;
+ default:
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
+ }
break;
}
default : {
MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
ptrField->setOrderNumber ( orderNumber);
- ptrField->setTime ( timeStep);
+ ptrField->setTime ( timeStep);
// Create a driver for this (field n°dt,n°it)
-
+ ptrDriver->setId ( getId() );
MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
ptrDriver->setFieldName(fieldName);
-
ptrField->addDriver(*ptrDriver);
-
+ // driver is duplicated : remove it
+ delete ptrDriver;
+
DT_IT_ dtIt;
dtIt.dt = timeStepNumber;
dtIt.it = orderNumber;
}
-void MED_MED_DRIVER::read( void ) {
-
+// This method ask the drivers of all MESH/FIELD objects created from this MED driver
+// to read themselves
+void MED_MED_RDONLY_DRIVER::read( void )
+ throw (MEDEXCEPTION) // from objects method read !
+{
const char * LOC = "MED_MED_DRIVER::read() : ";
BEGIN_OF(LOC);
- MESSAGE("METHODE PAS ENCORE IMPLEMENTEE !!! ");
+
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
+
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
+ (*currentMesh).second->read(*this);
+ //(*currentMesh).second->read(); // default reader, from readFileStruct
+
+ // PROVISOIRE
+ _ptrMed->updateSupport() ;
+
+ for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
+ (*currentField).first->read(*this);
+ //(*currentField).first->read(); // default reader, from readFileStruct
+
END_OF(LOC);
}
-void MED_MED_DRIVER::writeFrom( void) const {
-
+void MED_MED_RDONLY_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
+}
+
+void MED_MED_RDONLY_DRIVER::writeFrom(void) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::writeFrom : Can't write with a RDONLY driver !");
+}
+
+// ------------- Write Only Part --------------
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER():MED_MED_DRIVER()
+{
+}
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
+ MED_MED_DRIVER(fileName,ptrMed)
+{}
+
+MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver):
+ MED_MED_DRIVER(driver)
+{}
+
+MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER()
+{
+ MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * MED_MED_WRONLY_DRIVER::copy(void) const
+{
+ return new MED_MED_WRONLY_DRIVER(*this) ;
+}
+
+void MED_MED_WRONLY_DRIVER::read(void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
+void MED_MED_WRONLY_DRIVER::readFileStruct(void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
+// This method ask the drivers of all MESH/FIELD objects created from this MED driver
+// to write themselves
+void MED_MED_WRONLY_DRIVER::writeFrom( void) const
+ throw (MEDEXCEPTION) //from object method write !
+{
const char * LOC = "MED_MED_DRIVER::writeFrom() : ";
BEGIN_OF(LOC);
for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
try {
(*currentMesh).second->write(*this);
- // A CREER pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
+ // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
}
catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
continue;
}
- // catch (const MED_EXCEPTION & ex) {
- // throw ex; // DOIT-ON CREER UNE NOUVELLE EXCEPTION AVEC UN MESSAGE INDIQUANT LA PILE
- // }
}
for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
}
-void MED_MED_DRIVER::write(void ) const {
-
+void MED_MED_WRONLY_DRIVER::write(void ) const
+ throw (MEDEXCEPTION) // from object method write !
+{
const char * LOC = "MED_MED_DRIVER::write() : ";
+ int current;
BEGIN_OF(LOC);
- // BCLE SUR LES DRIVERS AVEC APPELS WriteFrom
- END_OF(LOC);
+ // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
-}
+ const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
+ map<MESH_NAME_,MESH*>::const_iterator currentMesh;
-MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
- MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
-{
- MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
-}
+ const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
+ map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
+
+ for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
+ //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
+ current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
+ // put right _id in Mesh driver (same as this._id)
+ (*currentMesh).second->_drivers[current]->setId( getId() );
+ //(*currentMesh).second->write(current) ;
+ }
-void MED_MED_RDONLY_DRIVER::open() {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::open()");
- MED_MED_DRIVER::open();
- END_OF("MED_MED_RDONLY_DRIVER::open()");
-}
+ for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
+ //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
+ current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
+ // put right _id in Field driver (same as this._id)
+ (*currentField).first->_drivers[current]->setId( getId() );
+ //(*currentField).first->write(current) ;
+ }
-void MED_MED_RDONLY_DRIVER::close() {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::close()");
- MED_MED_DRIVER::close();
- END_OF("MED_MED_RDONLY_DRIVER::clode()");
-}
+ // that's work, but it is more efficenty to write directly when we had driver, no ?
+ writeFrom();
+
+ END_OF(LOC);
-void MED_MED_RDONLY_DRIVER::read(void) {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::read(void)");
- MED_MED_DRIVER::read();
- END_OF("MED_MED_RDONLY_DRIVER::read(void)");
}
-void MED_MED_RDONLY_DRIVER::readFileStruct(void) {
- BEGIN_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)");
- MED_MED_DRIVER::readFileStruct();
- END_OF("MED_MED_RDONLY_DRIVER::readFileStruct(void)");
-}
+// ------------- Read Write Part --------------
-MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
- MED_MED_DRIVER(fileName,ptrMed)
+MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER()
{}
-void MED_MED_WRONLY_DRIVER::open() {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::open()");
- MED_MED_DRIVER::open();
- END_OF("MED_MED_WRONLY_DRIVER::open()");
-}
-
-void MED_MED_WRONLY_DRIVER::close() {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::close()");
- MED_MED_DRIVER::close();
- END_OF("MED_MED_WRONLY_DRIVER::clode()");
-}
-
-void MED_MED_WRONLY_DRIVER::write(void) const {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::write(void) const");
- MED_MED_DRIVER::write();
- END_OF("MED_MED_WRONLY_DRIVER::write(void) const");
-}
-
-void MED_MED_WRONLY_DRIVER::writeFrom(void) const {
- BEGIN_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const");
- MED_MED_DRIVER::writeFrom();
- END_OF("MED_MED_WRONLY_DRIVER::writeFrom(void) const");
-}
-
MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed):
MED_MED_DRIVER(fileName,ptrMed)
{}
-void MED_MED_RDWR_DRIVER::open() {
- BEGIN_OF("MED_MED_RDWR_DRIVER::open()");
- MED_MED_DRIVER::open();
- END_OF("MED_MED_RDWR_DRIVER::open()");
+MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver):
+ MED_MED_DRIVER(driver)
+{}
+
+MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() {
+ MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
}
-void MED_MED_RDWR_DRIVER::close() {
- BEGIN_OF("MED_MED_RDWR_DRIVER::close()");
- MED_MED_DRIVER::close();
- END_OF("MED_MED_RDWR_DRIVER::clode()");
+GENDRIVER * MED_MED_RDWR_DRIVER::copy(void) const
+{
+ return new MED_MED_RDWR_DRIVER(*this) ;
}
-void MED_MED_RDWR_DRIVER::read(void) {
+void MED_MED_RDWR_DRIVER::read(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::read(void)");
MED_MED_RDONLY_DRIVER::read();
END_OF("MED_MED_RDWR_DRIVER::read(void)");
}
-void MED_MED_RDWR_DRIVER::readFileStruct(void) {
+void MED_MED_RDWR_DRIVER::readFileStruct(void)
+ throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
MED_MED_RDONLY_DRIVER::readFileStruct();
END_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
}
-void MED_MED_RDWR_DRIVER::write(void) const {
+void MED_MED_RDWR_DRIVER::write(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::write(void) const");
MED_MED_WRONLY_DRIVER::write();
END_OF("MED_MED_RDWR_DRIVER::write(void) const");
}
-void MED_MED_RDWR_DRIVER::writeFrom(void) const {
+void MED_MED_RDWR_DRIVER::writeFrom(void) const
+ throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
+{
BEGIN_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
MED_MED_WRONLY_DRIVER::writeFrom();
END_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedMedDriver.hxx
+// Module : MED
+
#ifndef MED_MED_DRIVER_HXX
#define MED_MED_DRIVER_HXX
class FIELD_;
class MED;
+/*!
+
+ Driver Med for MED.
+
+ Generic part : implement open and close methods.
+
+*/
+
// This driver pilots within a MED class read/write accesses of fields/meshes
class MED_MED_DRIVER : public GENDRIVER
{
// MED_MED_DRIVER();
public :
+ /*!
+ Constructor.
+ */
MED_MED_DRIVER();
-
+ /*!
+ Constructor.
+ */
MED_MED_DRIVER(const string & fileName, MED * const ptrMed);
-
+ /*!
+ Constructor.
+ */
MED_MED_DRIVER(const string & fileName, MED * const ptrMed,
MED_EN::med_mode_acces accessMode);
+
// OPERATEUR DE RECOPIE AVEC _medIdt ??
+ /*!
+ Copy constructor.
+ */
+ MED_MED_DRIVER(const MED_MED_DRIVER & driver);
- void open();
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MED_DRIVER() ;
+
+ void open() throw (MEDEXCEPTION) ;
void close();
+ //virtual void write ( void ) const = 0 ;
virtual void write ( void ) const ;
- virtual void writeFrom ( void ) const ;
- virtual void read ( void ) ;
+ //virtual void writeFrom ( void ) const = 0 ;
+ virtual void writeFrom ( void ) const ;
+ //virtual void read ( void ) = 0 ;
+ virtual void read ( void ) ;
+ //virtual void readFileStruct ( void ) = 0 ;
virtual void readFileStruct ( void ) ;
+private:
+ //virtual GENDRIVER * copy ( void ) const = 0 ;
+ virtual GENDRIVER * copy ( void ) const ;
+
};
+/*!
+
+ Driver Med for MED : Read only.
+
+ Implement read method.
+
+*/
+
class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
{
public :
- MED_MED_RDONLY_DRIVER():MED_MED_DRIVER(){};
-
+ /*!
+ Constructor.
+ */
+ MED_MED_RDONLY_DRIVER();
+ /*!
+ Constructor.
+ */
MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed);
+ /*!
+ Copy constructor.
+ */
+ MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver);
- ~MED_MED_RDONLY_DRIVER() {
- MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
- }
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MED_RDONLY_DRIVER();
- void open();
- void close();
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write ( void ) const throw (MEDEXCEPTION) ;
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void writeFrom ( void ) const throw (MEDEXCEPTION) ;
+ /*!
+ Read all from the file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+ /*!
+ Read only table of contents of the file.
+
+ All objects are created but there values are not read.
+ */
+ void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const ;
- void read ( void ) ;
- void readFileStruct ( void ) ;
};
+/*!
+
+ Driver Med for MED : Write only.
+
+ Implement write method.
+
+*/
+
class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
{
public :
- MED_MED_WRONLY_DRIVER():MED_MED_DRIVER(){};
-
+ /*!
+ Constructor.
+ */
+ MED_MED_WRONLY_DRIVER();
+ /*!
+ Constructor.
+ */
MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed);
+ /*!
+ Copy constructor.
+ */
+ MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver);
- ~MED_MED_WRONLY_DRIVER() {
- MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
- }
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MED_WRONLY_DRIVER();
- void open();
- void close();
+ /*!
+ Write all in file.
+ */
+ void write ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Write only objects created from this MED driver in file.
+ */
+ void writeFrom ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION) ;
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void readFileStruct ( void ) throw (MEDEXCEPTION) ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const ;
- void write ( void ) const ;
- void writeFrom ( void ) const ;
};
+/*!
+
+ Driver Med for MED : Read write.
+ - Use read method from MED_MED_RDONLY_DRIVER
+ - Use write method from MED_MED_WDONLY_DRIVER
+
+*/
+
class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
- public virtual MED_MED_WRONLY_DRIVER,
- public virtual MED_MED_DRIVER
+ public virtual MED_MED_WRONLY_DRIVER
{
public :
- MED_MED_RDWR_DRIVER():MED_MED_DRIVER(){};
-
+ /*!
+ Constructor.
+ */
+ MED_MED_RDWR_DRIVER();
+ /*!
+ Constructor.
+ */
MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed);
+ /*!
+ Copy constructor.
+ */
+ MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver);
- ~MED_MED_RDWR_DRIVER() {
- MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
- }
+ /*!
+ Destructor.
+ */
+ ~MED_MED_RDWR_DRIVER();
- void open();
- void close();
+ /*!
+ Write all in file.
+ */
+ void write ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Write only objects created from this MED driver in file.
+ */
+ void writeFrom ( void ) const throw (MEDEXCEPTION);
+ /*!
+ Read all from the file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+ /*!
+ Read only table of contents of the file.
+
+ All objects are created but there values are not read.
+ */
+ void readFileStruct ( void ) throw (MEDEXCEPTION);
+
+private:
+ virtual GENDRIVER * copy ( void ) const ;
- void write ( void ) const ;
- void writeFrom ( void ) const ;
- void read ( void ) ;
- void readFileStruct ( void ) ;
};
#endif /* MED_MED_DRIVER_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedMeshDriver.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_MedMeshDriver.hxx"
#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_Grid.hxx"
extern "C" {
extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
extern med_err _MEDdatagroupFermer(med_idt id);
}
-using namespace MED_FR;
// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+MED_MESH_DRIVER::MED_MESH_DRIVER():
+ GENDRIVER(),
+ _ptrMesh(( MESH *)MED_NULL),
+ _medIdt(MED_INVALID),
+ _meshName(""),
+ _meshNum(MED_INVALID)
+{
+}
+
+MED_MESH_DRIVER::MED_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode):
+ GENDRIVER(fileName,accessMode),
+ _ptrMesh(ptrMesh),
+ _medIdt(MED_INVALID),
+ _meshName(""),
+ _meshNum(MED_INVALID)
+{
+}
+
+MED_MESH_DRIVER::MED_MESH_DRIVER(const MED_MESH_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMesh(driver._ptrMesh),
+ _medIdt(MED_INVALID),
+ _meshName(driver._meshName),
+ _meshNum(driver._meshNum)
+{
+}
+
+MED_MESH_DRIVER::~MED_MESH_DRIVER()
+{
+}
+
+void MED_MESH_DRIVER::open()
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED_MESH_DRIVER::open()" ;
+ BEGIN_OF(LOC);
+ MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
+ _medIdt = MED_FR::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode);
+ MESSAGE(LOC<<" _medIdt : "<< _medIdt );
+ if (_medIdt > 0)
+ _status = MED_OPENED;
+ else {
+ _medIdt = MED_INVALID;
+ _status = MED_CLOSED;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
+ }
+
+ END_OF(LOC);
+}
+
+void MED_MESH_DRIVER::close()
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MED_MESH_DRIVER::close() " ;
+ BEGIN_OF(LOC);
+ int err = 0;
+ if ( _status == MED_OPENED) {
+ err=MED_FR::MEDfermer(_medIdt);
+ H5close(); // If we call H5close() all the files are closed.
+ if (err != 0)
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
+ <<" Error when closing file !"
+ )
+ );
+ MESSAGE(LOC <<": _medIdt= " << _medIdt );
+ MESSAGE(LOC<<": MEDfermer : err = " << err );
+ _status = MED_CLOSED;
+ _medIdt = MED_INVALID;
+ }
+ END_OF(LOC);
+}
+
void MED_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
string MED_MESH_DRIVER::getMeshName() const { return _meshName; };
-//---------------------------------- RDONLY PART -------------------------------------------------------------
-
//A FAIRE UTILISER LES MAPS...
const MED_FR::med_geometrie_element MED_MESH_DRIVER::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
{ MED_FR::MED_POINT1,MED_FR::MED_SEG2,MED_FR::MED_SEG3,MED_FR::MED_TRIA3,MED_FR::MED_QUAD4,MED_FR::MED_TRIA6,MED_FR::MED_QUAD8,
"MED_PENTA15","MED_HEXA20"};
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(): MED_MESH_DRIVER()
+{
+}
+
+MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+{
+ MESSAGE("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver):
+ MED_MESH_DRIVER(driver)
+{
+}
+
+MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER()
+{
+ //MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * MED_MESH_RDONLY_DRIVER::copy(void) const
+{
+ return new MED_MESH_RDONLY_DRIVER(*this);
+}
void MED_MESH_RDONLY_DRIVER::read(void)
+ throw (MEDEXCEPTION)
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::read() : " ;
BEGIN_OF(LOC);
if (_status!=MED_OPENED)
- throw MEDEXCEPTION(" ");
- //throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
_ptrMesh->_name = _meshName;
-
+
+ SCRUTE(_ptrMesh->getIsAGrid());
+
+ if (_ptrMesh->getIsAGrid())
+ {
+ getGRID( );
+
+ // always call getFAMILY : families are requiered !!!!
+
+// int nbFam = MEDnFam(_medIdt,
+// const_cast <char *> (_meshName.c_str()),
+// 0,
+// MED_FR::MED_FAMILLE);
+// if (nbFam > 0)
+ {
+// getFAMILY();
+
+ if (getFAMILY()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
+
+ buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
+ _ptrMesh->_numberOfNodesGroups = _ptrMesh->_groupNode.size() ;
+ }
+
+ END_OF(LOC);
+ return;
+ }
+
if (getCOORDINATE()!=MED_VALID)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
_ptrMesh->_numberOfEdgesGroups = _ptrMesh->_groupEdge.size() ;
+ MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
+
+ int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
+// for(int i=0;i<nbOfTypes;i++)
+// {
+// MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
+// }
+
END_OF(LOC);
}
+//=======================================================================
+//function : getGRID
+//purpose :
+//=======================================================================
+void MED_MESH_RDONLY_DRIVER::getGRID()
+{
+ const char * LOC = "MED_MESH_RDONLY_DRIVER::getGRID() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
+
+ GRID * ptrGrid = (GRID *) _ptrMesh;
+
+ int err, i;
+
+ // Read the dimension of the space for the mesh <_meshName>
+ int SpaceDimension = MED_FR::MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
+ if ( SpaceDimension <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension <<
+ "| seems to be incorrect " << "for the mesh : |" <<
+ _meshName << "|")) ;
+ _ptrMesh->_spaceDimension = SpaceDimension;
+
+ // Read Array length
+ int * ArrayLen[] = { & ptrGrid->_iArrayLength,
+ & ptrGrid->_jArrayLength,
+ & ptrGrid->_kArrayLength };
+ int idim;
+ for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
+ {
+ int lenght = MED_FR::MEDnGrid(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ (MED_FR::med_grid)
+ idim
+ );
+ if ( lenght <= MED_VALID )
+ throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << lenght <<
+ "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" ) ;
+
+ ArrayLen [idim][0] = lenght;
+ }
+
+ MED_FR::med_repere rep ;
+ string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,' ');
+ string tmp_unit_coord(MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,' ');
+ char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
+ char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
+
+ // Read node coordinates for MED_BODY_FITTED grid
+ if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED)
+ {
+ // Read nb of nodes
+ int NumberOfNodes = MED_FR::MEDnGrid(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ MED_FR::MED_GRID_NOEUD);
+ if ( NumberOfNodes <= MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes <<
+ "| seems to be incorrect "
+ << "for the mesh : |" << _meshName << "|" )) ;
+ _ptrMesh->_numberOfNodes = NumberOfNodes ;
+
+ // this array is useless because families numbers are read in getFAMILY
+ int * MEDArrayNodeFamily = new int[ NumberOfNodes ];
+ // create coordinates
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
+ MED_EN::MED_FULL_INTERLACE);
+
+ // Read coordinates and families
+ double * coo = const_cast <double *>
+ (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
+
+ err = MED_FR::MEDbodyFittedLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ coo,
+ MED_FR::MED_FULL_INTERLACE,
+ & rep,
+ tmp_nom,
+ tmp_unit,
+ MEDArrayNodeFamily,
+ NumberOfNodes);
+ delete[] MEDArrayNodeFamily;
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedLire()"));
+
+ // _ptrMesh->_MEDArrayNodeFamily = fam ;
+
+ }
+ else
+ {
+ // Read Arrays and Node families in Cartesian or Polar Grid
+
+ int nbNodes = 1;
+ double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
+ for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
+ {
+ int nbNodesDim = * ArrayLen [idim];
+ nbNodes *= nbNodesDim;
+ Array [idim] = new double [ nbNodesDim ];
+ err = MED_FR::MEDgridLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ Array [idim],
+ idim,
+ MED_FR::MED_FULL_INTERLACE,
+ & rep,
+ tmp_nom,
+ tmp_unit);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in MEDgridLire for dimention" << idim ));
+
+ }
+ ptrGrid->_iArray = Array[0];
+ ptrGrid->_jArray = Array[1];
+ ptrGrid->_kArray = Array[2];
+
+ _ptrMesh->_numberOfNodes = nbNodes ;
+
+ // create coordinates
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,nbNodes,
+ MED_EN::MED_FULL_INTERLACE);
+ // Read node families
+// int nbFamNodes = MED_FR::MEDnGrid(_medIdt,
+// const_cast <char *> (_ptrMesh->_name.c_str()),
+// MED_FR::MED_FAM_NOEUD);
+// if (nbFamNodes > 0)
+// {
+// // int * fam = new int[ nbFamNodes ];
+
+// //_ptrMesh->_MEDArrayNodeFamily = new int[ nbFamNodes ];
+// // this array is useless because families numbers are read in getFAMILY
+// int * MEDArrayNodeFamily = new int[ nbFamNodes ];
+
+// err = MED_FR::MEDfamGridLire (_medIdt,
+// const_cast <char *> (_ptrMesh->_name.c_str()),
+// MEDArrayNodeFamily,
+// nbFamNodes,
+// MED_FR::MED_NOEUD);
+
+// if (err != MED_VALID)
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid nodes families for "
+// << idim << "-th dimention"));
+// else
+// _ptrMesh->_MEDArrayNodeFamily = fam;
+// }
+
+ } // end read Cartesian or Polar Grid
+
+ // set coordinate names
+
+ for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
+ string myStringName(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ string myStringUnit(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ // suppress space at the end
+ int j ;
+ for(j=MED_TAILLE_PNOM-1;j>=0;j--)
+ if (myStringName[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
+ for(j=MED_TAILLE_PNOM-1;j>=0;j--)
+ if (myStringUnit[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
+ }
+
+ string coordinateSystem = "UNDEFINED";
+
+ if( rep == MED_FR::MED_CART) coordinateSystem = "CARTESIAN";
+ else if ( rep == MED_FR::MED_CYL) coordinateSystem = "CYLINDRICAL";
+ else if ( rep == MED_FR::MED_SPHER) coordinateSystem = "SPHERICAL";
+
+ _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
+
+
+ END_OF(LOC);
+}
+
+//=======================================================================
+//function : getCOORDINATE
// A FAIRE : RENVOYER DU VOID
+//=======================================================================
int MED_MESH_RDONLY_DRIVER::getCOORDINATE()
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::getCOORDINATE() : " ;
// Read the dimension of the space for the mesh <_meshName>
// to be able to create a COORDINATE object
- int SpaceDimension = MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
+ int SpaceDimension = MED_FR::MEDdimLire(_medIdt,const_cast <char *> (_meshName.c_str())) ;
if ( SpaceDimension <= MED_VALID )
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The space dimension |" << SpaceDimension << "| seems to be incorrect "
<< "for the mesh : |" << _meshName << "|")) ;
// create a COORDINATE object
- _ptrMesh->_coordinate = new COORDINATE(MED_EN::MED_FULL_INTERLACE, SpaceDimension, NumberOfNodes);
+ _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
MED_FR::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
string tmp_nom_coord (MED_TAILLE_PNOM*(_ptrMesh->_spaceDimension)+1,'\0');
err=MEDcoordLire(_medIdt,
const_cast <char *> (_ptrMesh->_name.c_str()),
_ptrMesh->_spaceDimension,
- const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
MED_FR::MED_FULL_INTERLACE,
MED_ALL, // we read all the coordinates
NULL, // we don't use a profile
<< "| and units |" << tmp_unit
<< " |")) ;
+
for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
- // PG : What about blank !!!!!
- _ptrMesh->_coordinate->_coordinateName[i]=string(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
- _ptrMesh->_coordinate->_coordinateUnit[i]=string(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+ string myStringName(tmp_nom,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ string myStringUnit(tmp_unit,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ;
+ // suppress space at the end
+ int j ;
+ for(j=MED_TAILLE_PNOM-1;j>=0;j--)
+ if (myStringName[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
+ for(j=MED_TAILLE_PNOM-1;j>=0;j--)
+ if (myStringUnit[j] != ' ') break ;
+ _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
}
// Pourquoi le stocker sous forme de chaîne ?
}
}
- // Read the unused optionnal node Names
+ // Read the unused optional node Names
char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM+1];
tmp_node_name[NumberOfNodes]='\0' ;
err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
delete[] tmp_node_name ;
- // ??? Read the unused optionnal node Numbers ???
+ // ??? Read the unused optional node Numbers ???
int * tmp_node_number = new int[NumberOfNodes] ;
err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
- tmp_node_number,NumberOfNodes,MED_NOEUD,(MED_FR::med_geometrie_element)0);
+ tmp_node_number,NumberOfNodes,MED_FR::MED_NOEUD,(MED_FR::med_geometrie_element)0);
if (err == MED_VALID) {
INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
- _ptrMesh->_coordinate->_nodeNumber = tmp_node_number ;
- } else
- delete[] tmp_node_number ;
+ _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
+ memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
+ }
+
+ delete[] tmp_node_number ;
END_OF(LOC);
return MED_VALID;
int numberOfEdgesTypes = 0;
int * tmp_faces_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
int numberOfFacesTypes = 0;
- if ((version_med != "2.2")&(Entity==MED_MAILLE)) {
+ if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE)) {
Connectivity->_numberOfTypes=0;
for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) {
tmp_faces_count[i]=0;
int TypeNumber=1 ;
for (int i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++) { // no point1 cell type (?)
if (tmp_cells_count[i]>0) {
-
Connectivity->_count[TypeNumber]=Connectivity->_count[TypeNumber-1]+tmp_cells_count[i];
-
+
CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ;
Connectivity->_type[TypeNumber-1]=t ;
}
// Creation of the MEDSKYLINEARRAY
- Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
- int * NodalIndex = Connectivity->_nodal->getIndex() ;
+ //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = Connectivity->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
NodalIndex[0]=1 ;
// Fill the MEDSKYLINEARRAY by reading the MED file.
MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
return MED_ERROR ;
}
- int * ConnectivityArray = Connectivity->_nodal->getI(Connectivity->_count[i]) ;
+ int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
for (int j=0; j<tmp_numberOfCells; j++)
for (int k=0; k<NumberOfNodeByCell; k++)
ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
-
delete[] tmp_ConnectivityArray;
}
+
+ Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+ delete[] NodalIndex;
+ delete[] NodalValue;
+
} // end of bloc to read CELL
delete[] tmp_cells_count;
}
// Creation of the MEDSKYLINEARRAY
- constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
- int * NodalIndex = constituent->_nodal->getIndex() ;
+ //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = constituent->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
NodalIndex[0]=1 ;
// Fill the MEDSKYLINEARRAY by reading the MED file.
return MED_ERROR ;
}
- int * constituentArray = constituent->_nodal->getI(constituent->_count[i]) ;
+ int * constituentArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
for (int j=0; j<tmp_numberOfFaces; j++)
for (int k=0; k<NumberOfNodeByFace; k++)
constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
delete[] tmp_constituentArray;
}
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+ delete[] NodalIndex ;
+ delete[] NodalValue ;
+
Connectivity->_constituent = constituent ;
}
// ===============
if (numberOfEdgesTypes!=0) {
CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
- constituent->_entityDimension = 2 ;
+ constituent->_entityDimension = 1 ;
constituent->_count[0]=1 ;
int size = 0 ;
}
// Creation of the MEDSKYLINEARRAY
- constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
- int * NodalIndex = constituent->_nodal->getIndex() ;
+ //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
+ //int * NodalIndex = constituent->_nodal->getIndex() ;
+ int * NodalValue = new int[size] ;
+ int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
NodalIndex[0]=1 ;
// Fill the MEDSKYLINEARRAY by reading the MED file.
int * tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- Connectivity->_entityDimension,tmp_constituentArray,
+ _ptrMesh->_spaceDimension,tmp_constituentArray,
MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD);
if ( err != MED_VALID) {
MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
return MED_ERROR ;
}
- int * constituentArray = constituent->_nodal->getI(constituent->_count[i]) ;
+ int * constituentArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
for (int j=0; j<tmp_numberOfEdges; j++)
for (int k=0; k<NumberOfNodeByEdge; k++)
constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
-
+
delete[] tmp_constituentArray;
}
+ constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
+ size,
+ NodalIndex,
+ NodalValue) ;
+
+ delete[] NodalIndex ;
+ delete[] NodalValue ;
+
if (Connectivity->_entityDimension == 3) {
if (Connectivity->_constituent==NULL)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
if (_status==MED_OPENED) {
int err = 0 ;
- // read number :
- // NODE :
- err = getNodesFamiliesNumber() ; // error only if (_status!=MED_OPENED), other case exeception !
- // CELL
- _ptrMesh->_MEDArrayCellFamily = new (int*)[_ptrMesh->_connectivity->_numberOfTypes] ; // ET SI IL N'Y A PAS DE CELLS ?
- getCellsFamiliesNumber(_ptrMesh->_MEDArrayCellFamily,_ptrMesh->_connectivity) ;
- if (_ptrMesh->_connectivity->_constituent != NULL) {
- if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
- // FACE
- _ptrMesh->_MEDArrayFaceFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_numberOfTypes] ;
- getCellsFamiliesNumber(_ptrMesh->_MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ;
- } else {
- // EDGE in 2D
- _ptrMesh->_MEDArrayEdgeFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_numberOfTypes] ;
- getCellsFamiliesNumber(_ptrMesh->_MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ;
+
+ int * MEDArrayNodeFamily = NULL ;
+ int ** MEDArrayCellFamily = NULL ;
+ int ** MEDArrayFaceFamily = NULL ;
+ int ** MEDArrayEdgeFamily = NULL ;
+
+ if ( !_ptrMesh->getIsAGrid() )
+ {
+ // read number :
+ // NODE :
+ MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
+ err = getNodesFamiliesNumber(MEDArrayNodeFamily) ; // error only if (_status!=MED_OPENED), other case exeception !
+ // CELL
+ MEDArrayCellFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ?
+ const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
+ MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ;
+
+ getCellsFamiliesNumber(MEDArrayCellFamily,_ptrMesh->_connectivity) ;
+ if (_ptrMesh->_connectivity->_constituent != NULL) {
+ if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) {
+ // FACE
+ MEDArrayFaceFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_FACE)] ;
+ myTypes = _ptrMesh->getTypes(MED_FACE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
+ MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ;
+
+ getCellsFamiliesNumber(MEDArrayFaceFamily,_ptrMesh->_connectivity->_constituent) ;
+ } else {
+ // EDGE in 2D
+ MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+ myTypes = _ptrMesh->getTypes(MED_EDGE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
+ getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ;
+ }
+ // EDGE in 3D
+ if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
+ MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
+ myTypes = _ptrMesh->getTypes(MED_EDGE);
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ;
+ getCellsFamiliesNumber(MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent->_constituent) ; // we are in 3D !
+ }
+ }
}
- // EDGE in 3D
- if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) {
- _ptrMesh->_MEDArrayEdgeFamily = new (int*)[_ptrMesh->_connectivity->_constituent->_constituent->_numberOfTypes] ;
- getCellsFamiliesNumber(_ptrMesh->_MEDArrayEdgeFamily,_ptrMesh->_connectivity->_constituent) ; // we are in 3D !
+ else
+ {
+ // node
+ int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
+ MEDArrayNodeFamily = new int[ NumberOfNodes ];
+ err = MED_FR::MEDfamGridLire (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayNodeFamily,
+ NumberOfNodes,
+ MED_FR::MED_NOEUD);
+
+ // what about cell face and edge ?
}
- }
// Creation of the families
int NumberOfFamilies = MEDnFam(_medIdt,const_cast <char *> (_meshName.c_str()),0,MED_FR::MED_FAMILLE) ;
int * AttributesIdentifier = new int[NumberOfAttributes] ;
int * AttributesValues = new int[NumberOfAttributes] ;
string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
- string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups,' ') ;
- err = MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
- i+1,const_cast <char *> (FamilyName.c_str()),
- &FamilyIdentifier,AttributesIdentifier,AttributesValues,
- const_cast <char *> (AttributesDescription.c_str()),
- &NumberOfAttributes,
- const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
+ string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,' ') ;
+ err = MED_FR::MEDfamInfo(_medIdt,const_cast <char *> (_meshName.c_str()),
+ i+1,const_cast <char *> (FamilyName.c_str()),
+ &FamilyIdentifier,AttributesIdentifier,AttributesValues,
+ const_cast <char *> (AttributesDescription.c_str()),
+ &NumberOfAttributes,
+ const_cast <char *> (GroupsNames.c_str()),&NumberOfGroups
);
//SCRUTE(GroupsNames);
if (err != MED_VALID)
FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
NumberOfAttributes,AttributesIdentifier,
AttributesValues,AttributesDescription,
- NumberOfGroups,GroupsNames) ;
- switch (Family->getEntity()) {
- case MED_EN::MED_NODE :
- NodeFamilyVector.push_back(Family) ;
- numberOfNodesFamilies++ ;
- break ;
- case MED_EN::MED_CELL :
- CellFamilyVector.push_back(Family) ;
- numberOfCellsFamilies++ ;
- break ;
- case MED_EN::MED_FACE :
- FaceFamilyVector.push_back(Family) ;
- numberOfFacesFamilies++ ;
- break ;
- case MED_EN::MED_EDGE :
- EdgeFamilyVector.push_back(Family) ;
- numberOfEdgesFamilies++ ;
- break ;
- }
+ NumberOfGroups,GroupsNames,
+ MEDArrayNodeFamily,
+ MEDArrayCellFamily,
+ MEDArrayFaceFamily,
+ MEDArrayEdgeFamily
+ ) ;
+ // All good ?
+ // if nothing found, delete Family
+ if (Family->getNumberOfTypes() == 0) {
+ INFOS(LOC<<"Nothing found for family "<<FamilyName<< " : skip");
+ delete Family;
+ } else
+ switch (Family->getEntity()) {
+ case MED_EN::MED_NODE :
+ NodeFamilyVector.push_back(Family) ;
+ numberOfNodesFamilies++ ;
+ break ;
+ case MED_EN::MED_CELL :
+ CellFamilyVector.push_back(Family) ;
+ numberOfCellsFamilies++ ;
+ break ;
+ case MED_EN::MED_FACE :
+ FaceFamilyVector.push_back(Family) ;
+ numberOfFacesFamilies++ ;
+ break ;
+ case MED_EN::MED_EDGE :
+ EdgeFamilyVector.push_back(Family) ;
+ numberOfEdgesFamilies++ ;
+ break ;
+ }
}
+
+ delete [] AttributesIdentifier ;
+ delete [] AttributesValues ;
}
+
+ if (MEDArrayNodeFamily != NULL)
+ delete[] MEDArrayNodeFamily ;
+ if (MEDArrayCellFamily != NULL) {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
+ delete[] MEDArrayCellFamily[i] ;
+ delete[] MEDArrayCellFamily ;
+ }
+ if (MEDArrayFaceFamily != NULL) {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
+ delete[] MEDArrayFaceFamily[i] ;
+ delete[] MEDArrayFaceFamily ;
+ }
+ if (MEDArrayEdgeFamily != NULL) {
+ for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
+ delete[] MEDArrayEdgeFamily[i] ;
+ delete[] MEDArrayEdgeFamily ;
+ }
+
_ptrMesh->_numberOfNodesFamilies = numberOfNodesFamilies ;
_ptrMesh->_numberOfCellsFamilies = numberOfCellsFamilies ;
_ptrMesh->_numberOfFacesFamilies = numberOfFacesFamilies ;
return MED_ERROR;
}
-int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber()
+int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
{
const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber() : " ;
BEGIN_OF(LOC);
if (_status==MED_OPENED) {
int err = 0 ;
- int * tmp_NodesFamilies = new int[_ptrMesh->getNumberOfNodes()] ;
err = MEDfamLire(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
- tmp_NodesFamilies, _ptrMesh->getNumberOfNodes(),
- MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE);
+ MEDArrayNodeFamily,
+ _ptrMesh->getNumberOfNodes(),
+ MED_FR::MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE);
if ( err != MED_VALID) {
- delete[] tmp_NodesFamilies ;
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes()
<< "| nodes in mesh |"
<< _ptrMesh->_name.c_str() << "|" ));
}
- _ptrMesh->_MEDArrayNodeFamily = tmp_NodesFamilies ;
END_OF(LOC);
return MED_VALID;
}
int i, err = 0 ;
for (i=0;i<Connectivity->_numberOfTypes;i++) {
int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
- int * fam = new int[NumberOfCell] ;
-
err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- fam,NumberOfCell,
+ MEDArrayFamily[i],NumberOfCell,
(MED_FR::med_entite_maillage) Connectivity->_entity,
(MED_FR::med_geometrie_element) Connectivity->_geometricTypes[i]);
if (err != MED_VALID) {
MESSAGE(LOC<<"search face/edge family on cell !!!");
err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
- fam,NumberOfCell,
+ MEDArrayFamily[i],NumberOfCell,
MED_FR::MED_MAILLE,
(MED_FR::med_geometrie_element) Connectivity->_geometricTypes[i]);
}
- MEDArrayFamily[i]=fam ;
if (err != MED_VALID)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
map< string,list<FAMILY*> >::const_iterator currentGroup ;
int it = 0 ;
for(currentGroup=groupsNames.begin();currentGroup!=groupsNames.end();currentGroup++) {
- // GROUP * myGroup = new GROUP((*currentGroup).first,(*currentGroup).second) ;
- GROUP * myGroup = new GROUP() ;
- myGroup->setName((*currentGroup).first);
- SCRUTE(myGroup->getName());
- //myGroup->setMesh(_ptrMesh);
- myGroup->init((*currentGroup).second);
+ GROUP * myGroup = new GROUP((*currentGroup).first,(*currentGroup).second) ;
+// GROUP * myGroup = new GROUP() ;
+// myGroup->setName((*currentGroup).first);
+// SCRUTE(myGroup->getName());
+// //myGroup->setMesh(_ptrMesh);
+// myGroup->init((*currentGroup).second);
Groups[it]=myGroup;
//SCRUTE(it);
it++;
}
-void MED_MESH_RDONLY_DRIVER::write( void ) const { INFOS("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");}
+void MED_MESH_RDONLY_DRIVER::write( void ) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
+}
-/*--------------------- RDWR PART -------------------------------*/
+/*--------------------- WRONLY PART -------------------------------*/
-void MED_MESH_RDWR_DRIVER::write(void) const { MED_MESH_WRONLY_DRIVER::write(); }
-void MED_MESH_RDWR_DRIVER::read (void) { MED_MESH_RDONLY_DRIVER::read(); }
+MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER()
+{
+}
+
+MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
+{
+ MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver):
+ MED_MESH_DRIVER(driver)
+{
+}
-/*--------------------- WRONLY PART -------------------------------*/
-void MED_MESH_WRONLY_DRIVER::read (void) { INFOS("MED_MESH_WRONLY_DRIVER::write : Can't read with a WRONLY driver !");}
+MED_MESH_WRONLY_DRIVER::~MED_MESH_WRONLY_DRIVER()
+{
+ //MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
-void MED_MESH_WRONLY_DRIVER::write(void) const {
+GENDRIVER * MED_MESH_WRONLY_DRIVER::copy(void) const
+{
+ return new MED_MESH_WRONLY_DRIVER(*this);
+}
+
+void MED_MESH_WRONLY_DRIVER::read (void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("MED_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
+void MED_MESH_WRONLY_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
const char * LOC = "void MED_MESH_WRONLY_DRIVER::write(void) const : ";
BEGIN_OF(LOC);
// we must first create mesh !!
- MESSAGE(LOC<< "MeshName : "<< _meshName <<"FileName : "<<_fileName<<" MedIdt : "<< _medIdt);
+ MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
- if (writeCoordinates()!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
- if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
- if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
- if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
+ if (_ptrMesh->getIsAGrid())
+ {
+ if ( writeGRID() != MED_VALID )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
+ }
+ else
+ {
+ if (writeCoordinates()!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
+
+ if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
+ if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
+ if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
+ }
if (writeFamilyNumbers() !=MED_VALID)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
-
+
+
// well we must first write zero family :
if (_status==MED_OPENED) {
int err ;
// test if the family already exists (HDF trick waiting a MED evolution to be replaced)
string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_0/";
- SCRUTE("|"<<dataGroupFam<<"|");
+ MESSAGE("|"<<dataGroupFam<<"|");
if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
SCRUTE(err);
- err = MEDfamCr( _medIdt, const_cast <char *> ( _meshName.c_str() ),
- "FAMILLE_0", 0,
- (int*)NULL, (int*)NULL, (char*)NULL, 0,
- (char*)NULL, 0);
+ err = MED_FR::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ "FAMILLE_0", 0,
+ (int*)NULL, (int*)NULL, (char*)NULL, 0,
+ (char*)NULL, 0);
if ( err != MED_VALID)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_0| with identifier |0| groups names || and attributes descriptions ||")) ;
END_OF(LOC);
}
+//=======================================================================
+//function : writeGRID
+//purpose :
+//=======================================================================
+
+int MED_MESH_WRONLY_DRIVER::writeGRID() const
+{
+ const char * LOC = "MED_MESH_WRONLY_DRIVER::writeGRID() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ {
+ MESSAGE (LOC<<" Not open !!!");
+ return MED_ERROR;
+ }
+ GRID * ptrGrid = (GRID*) _ptrMesh;
+
+ MED_FR::med_err err = MED_ERROR;
+ MED_FR::med_repere rep;
+ string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
+ string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
+
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+ int dim = MED_FR::MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
+ if (dim < MED_VALID)
+ {
+ err = MEDgridCr(_medIdt,
+ const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ (MED_FR::med_grid_type) ptrGrid->getGridType());
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
+ else
+ MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if (dim != _ptrMesh->_spaceDimension)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
+ "| already exists in file |" << _fileName <<
+ "| with dimension |" << dim <<
+ "| but the dimension of the mesh we want to write is |"
+ << _ptrMesh->_spaceDimension <<"|" )) ;
+
+ // Recompose the <_spaceDimension> strings in 1 string
+ int lengthString ;
+ string valueString ;
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ SCRUTE(i);
+ valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
+ lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
+ tmp_name.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
+ valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
+ lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
+ tmp_unit.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
+ }
+
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = MED_FR::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = MED_FR::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = MED_FR::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
+ "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
+
+ int ArrayLen[] = { ptrGrid->_iArrayLength,
+ ptrGrid->_jArrayLength,
+ ptrGrid->_kArrayLength };
+
+ // Write node coordinates for MED_BODY_FITTED grid
+ if (ptrGrid->getGridType() == MED_EN::MED_BODY_FITTED)
+ {
+
+ // Write Coordinates and families
+ double * coo = const_cast <double *>
+ (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
+
+ // Write unused families
+ int * MEDArrayNodeFamily = new int[_ptrMesh->_numberOfNodes] ;
+
+ err = MEDbodyFittedEcr (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ coo,
+ ArrayLen,
+ MED_FR::MED_FULL_INTERLACE,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str()),
+ MEDArrayNodeFamily,
+ _ptrMesh->_numberOfNodes,
+ MED_FR::MED_REMP);
+ delete[] MEDArrayNodeFamily;
+
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDbodyFittedEcr()"));
+
+ }
+ else
+ {
+ // Write Arrays of Cartesian or Polar Grid
+
+ double * Array[] = { ptrGrid->_iArray,
+ ptrGrid->_jArray,
+ ptrGrid->_kArray };
+ int idim;
+ for (idim = 0; idim < _ptrMesh->_spaceDimension; ++idim)
+ {
+ err = MEDgridEcr (_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ _ptrMesh->_spaceDimension,
+ Array [idim],
+ ArrayLen [idim],
+ idim,
+ MED_FR::MED_FULL_INTERLACE,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str()),
+ MED_FR::MED_REMP);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read grid coordinates for "
+ << idim << "-th dimention"));
+ }
+
+// err = MEDfamGridEcr(_medIdt,
+// const_cast <char *> (_ptrMesh->_name.c_str()),
+// _ptrMesh->_MEDArrayNodeFamily,
+// _ptrMesh->_numberOfNodes,
+// MED_FR::MED_REMP,
+// MED_FR::MED_NOEUD);
+ if (err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in MEDfamGridEcr()"));
+
+ } // end Write Cartesian or Polar Grid
+
+ END_OF(LOC);
+ return MED_VALID;
+}
+
+//=======================================================================
+//function : writeCoordinates
+//purpose :
+//=======================================================================
int MED_MESH_WRONLY_DRIVER::writeCoordinates() const {
const char * LOC = "int MED_MESH_WRONLY_DRIVER::writeCoordinates() const : ";
BEGIN_OF(LOC);
- if (_status==MED_OPENED) {
- MED_FR::med_err err = MED_ERROR;
- MED_FR::med_repere rep;
- string tmp_name,tmp_unit;
+ MED_FR::med_err err = MED_ERROR;
+ MED_FR::med_repere rep;
+ string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
+ string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM,' ');
- // Recompose the <_spaceDimension> strings in 1 string
- for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
- tmp_name += _ptrMesh->_coordinate->_coordinateName[i];
- tmp_unit += _ptrMesh->_coordinate->_coordinateUnit[i];
-
- }
+ // Recompose the <_spaceDimension> strings in 1 string
+ int lengthString ;
+ string valueString ;
+ for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
+ valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
+ lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
+ tmp_name.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
+ valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
+ lengthString = (MED_TAILLE_PNOM<valueString.size())?MED_TAILLE_PNOM:valueString.size() ;
+ tmp_unit.replace(i*MED_TAILLE_PNOM,i*MED_TAILLE_PNOM+lengthString,valueString,0,lengthString);
+ }
- // Test if the mesh <_meshName> already exists
- // If it doesn't exists create it
- // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
- // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
- int dim = MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
- if (dim < MED_VALID)
- if (MEDmaaCr(_medIdt,const_cast <char *> (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh"));
- else
- {
- MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
- }
- else if (dim != _ptrMesh->_spaceDimension)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName
- << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |"
- << _ptrMesh->_spaceDimension <<"|" )) ;
+ // Test if the mesh <_meshName> already exists
+ // If it doesn't exists create it
+ // If it already exists verify if its dimension is the same as <_ptrMesh->_spaceDimension>
+ // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
+ int dim = MED_FR::MEDdimLire(_medIdt, const_cast <char *> (_meshName.c_str()) );
+ if (dim < MED_VALID)
+ if (MED_FR::MEDmaaCr(_medIdt,const_cast <char *> (_meshName.c_str()),_ptrMesh->_spaceDimension) != 0 )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
+ else
+ {
+ MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
+ }
+ else if (dim != _ptrMesh->_spaceDimension)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| already exists in file |" << _fileName
+ << "| with dimension |" << dim << "| but the dimension of the mesh we want to write is |"
+ << _ptrMesh->_spaceDimension <<"|" )) ;
- // Pourquoi le stocker sous forme de chaîne ?
- const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
- if (coordinateSystem == "CARTESIAN")
- rep = MED_FR::MED_CART;
- else if ( coordinateSystem == "CYLINDRICAL")
- rep = MED_FR::MED_CYL;
- else if ( coordinateSystem == "SPHERICAL" )
- rep = MED_FR::MED_SPHER;
- else
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
- << _ptrMesh->_coordinate->_coordinateSystem
- << "|" )) ;
+ // Pourquoi le stocker sous forme de chaîne ?
+ const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
+ if (coordinateSystem == "CARTESIAN")
+ rep = MED_FR::MED_CART;
+ else if ( coordinateSystem == "CYLINDRICAL")
+ rep = MED_FR::MED_CYL;
+ else if ( coordinateSystem == "SPHERICAL" )
+ rep = MED_FR::MED_SPHER;
+ else
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
+ << _ptrMesh->_coordinate->_coordinateSystem
+ << "|" )) ;
- err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
- _ptrMesh->_spaceDimension,
- const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
- MED_FR::MED_FULL_INTERLACE,
- _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
- MED_FR::MED_REMP,
- rep,
- const_cast <char *> (tmp_name.c_str()),
- const_cast <char *> (tmp_unit.c_str())
- );
-
- if (err<0)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- << " with units names |" << tmp_name
- << "| and units |" << tmp_unit
- << " |")) ;
+ err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
+ const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
+ MED_FR::MED_FULL_INTERLACE,
+ _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
+ MED_FR::MED_REMP,
+ rep,
+ const_cast <char *> (tmp_name.c_str()),
+ const_cast <char *> (tmp_unit.c_str())
+ );
+
+ if (err<0)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ << " with units names |" << tmp_name
+ << "| and units |" << tmp_unit
+ << " |")) ;
- END_OF(LOC);
+ END_OF(LOC);
- return MED_VALID;
- }
-
- MESSAGE (LOC<<" Not open !!!");
- return MED_ERROR;
+ return MED_VALID;
}
MED_FR::med_err err;
- if (_status==MED_OPENED) {
-
- // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
+ // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
+ // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
// A FAIRE : A tester surtout dans les methodes de MESH.
// if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
- if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
+ if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
- if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) {
+ if ( _ptrMesh->existConnectivity(MED_NODAL,entity) ) {
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
- for (int i=0; i<numberOfTypes; i++) {
+ for (int i=0; i<numberOfTypes; i++) {
- int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
- int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
- MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
+ MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
- // Pour l'instant la class utilise le multi.....
- int multi = 0 ;
- if (entity==MED_EN::MED_CELL)
- if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
- multi=1 ;
- int numberOfNodes = types[i]%100 ;
- int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
- for (int j=0 ; j<numberOfElements; j++) {
- for (int k=0; k<numberOfNodes; k++)
- connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+ // Pour l'instant la class utilise le multi.....
+ int multi = 0 ;
+ if (entity==MED_EN::MED_CELL)
+ if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
+ multi=1 ;
+ int numberOfNodes = types[i]%100 ;
+ int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
+ for (int j=0 ; j<numberOfElements; j++) {
+ for (int k=0; k<numberOfNodes; k++)
+ connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
+ if (multi>0)
connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
- }
- err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
- connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
- MED_FR::MED_REMP,
- (MED_FR::med_entite_maillage ) entity,
- (MED_FR::med_geometrie_element) types[i], MED_NOD );
- delete[] connectivityArray ;
-
- if (err<0) // ETENDRE LES EXPLICATIONS
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- )) ;
- }
- }
- // Connctivity descending :
- if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
-
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- medGeometryElement * types = _ptrMesh->getTypes (entity) ;
-
- for (int i=0; i<numberOfTypes; i++) {
-
- int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
- int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
-
- // Pour l'instant la class utilise le multi.....
- err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
- connectivity, MED_FR::MED_FULL_INTERLACE , numberOfElements,
- MED_FR::MED_REMP,
- (MED_FR::med_entite_maillage ) entity,
- (MED_FR::med_geometrie_element) types[i], MED_DESC );
-
- if (err<0) // ETENDRE LES EXPLICATIONS
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- )) ;
}
+ err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
+ connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
+ MED_FR::MED_REMP,
+ (MED_FR::med_entite_maillage ) entity,
+ (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
+ delete[] connectivityArray ;
+
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
}
- // Connctivity descending :
- if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
+ }
+ // Connctivity descending :
+ if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) {
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
- for (int i=0; i<numberOfTypes; i++) {
+ for (int i=0; i<numberOfTypes; i++) {
- int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
- int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
+ int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
+ const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
- // Pour l'instant la class utilise le multi.....
- err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
- connectivity, MED_FR::MED_FULL_INTERLACE , numberOfElements,
- MED_FR::MED_REMP,
- (MED_FR::med_entite_maillage ) entity,
- (MED_FR::med_geometrie_element) types[i], MED_DESC );
+ // Pour l'instant la class utilise le multi.....
+ err = MED_FR::MEDconnEcr( _medIdt,
+ const_cast <char *> ( _meshName.c_str()),
+ _ptrMesh->_spaceDimension,
+ const_cast <int *> (connectivity),
+ MED_FR::MED_FULL_INTERLACE,
+ numberOfElements,
+ MED_FR::MED_REMP,
+ (MED_FR::med_entite_maillage ) entity,
+ (MED_FR::med_geometrie_element) types[i],
+ MED_FR::MED_DESC );
- if (err<0) // ETENDRE LES EXPLICATIONS
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
- << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
- )) ;
+ if (err<0) // ETENDRE LES EXPLICATIONS
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
+ << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
+ )) ;
- }
}
- END_OF(LOC);
- return MED_VALID;
}
- return MED_ERROR;
+ END_OF(LOC);
+ return MED_VALID;
}
int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const {
MED_FR::med_err err;
- if (_status==MED_OPENED) {
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
+
+ { // Node related block
+
+ // We build the array from the families list objects :
+ int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
+ int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
+ // family 0 by default
+ for (int i=0; i<NumberOfNodes; i++)
+ MEDArrayNodeFamily[i]=0;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
+ int NumberOfNodesFamilies = myFamilies->size() ;
+ //bool ToDestroy = false;
+ if (0 == NumberOfNodesFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(i+1);
+ myFamilies->push_back(myFamily);
+ }
+ NumberOfNodesFamilies=myFamilies->size() ;
+ }
+ for (int i=0 ; i<NumberOfNodesFamilies; i++) {
+ //SCRUTE(i);
+ //SCRUTE(myFamilies[i]->getName());
+ int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
+ int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int j=0; j<TotalNumber; j++)
+ MEDArrayNodeFamily[j]=FamilyIdentifier;
+ else {
+ const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int j=0; j<TotalNumber; j++)
+ MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
+ }
+ }
+ for(int j=0; j<NumberOfNodes; j++) {
+ SCRUTE(MEDArrayNodeFamily[j]);
+ }
+ if ( !_ptrMesh->getIsAGrid() )
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ MEDArrayNodeFamily, NumberOfNodes,MED_FR::MED_REMP ,
+ MED_FR::MED_NOEUD,
+ (enum MED_FR::med_geometrie_element) MED_NONE);
+ else
+ err = MEDfamGridEcr(_medIdt,
+ const_cast <char *> (_ptrMesh->_name.c_str()),
+ MEDArrayNodeFamily,
+ NumberOfNodes,
+ MED_FR::MED_REMP,
+ MED_FR::MED_NOEUD);
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- _ptrMesh->_MEDArrayNodeFamily, _ptrMesh->getNumberOfNodes(),MED_FR::MED_REMP ,
- MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE);
if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< _ptrMesh->getNumberOfNodes()
- << "| nodes in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
+ << "| nodes in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
+ delete[] MEDArrayNodeFamily;
+ //if (true == ToDestroy)
+ // for (int i=0; i<NumberOfNodesFamilies; i++)
+ // delete myFamilies[i];
+ }
+
+ { // CELLS RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_CELL;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+
+ // We build the array from the families list objects :
+ int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
+ int * MEDArrayFamily = new int[NumberOfElements] ;
+ // family 0 by default
+ for (int i=0; i<NumberOfElements; i++)
+ MEDArrayFamily[i]=0;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
+ int NumberOfFamilies = myFamilies->size() ;
+ //bool ToDestroy = false;
+ if (0 == NumberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-1);
+ myFamilies->push_back(myFamily);
+ }
+ NumberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0 ; i<NumberOfFamilies; i++) {
+ int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
+ int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<TotalNumber; ii++)
+ MEDArrayFamily[ii]=FamilyIdentifier;
+ else {
+ const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
+ for (int ii=0; ii<TotalNumber; ii++)
+ MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
+ }
+ }
- { // CELLS RELATED BLOCK
- medEntityMesh entity=MED_EN::MED_CELL;
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
- if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- medGeometryElement * types = _ptrMesh->getTypes (entity) ;
-
- for (int i=0; i<numberOfTypes; i++) {
+ for (int i=0; i<numberOfTypes; i++) {
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- _ptrMesh->_MEDArrayCellFamily[i], _ptrMesh->getNumberOfElements(entity, types[i]),
- MED_FR::MED_REMP ,
- (MED_FR::med_entite_maillage) entity,
- (MED_FR::med_geometrie_element) types[i]);
-
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
- << "| cells of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ MEDArrayFamily+typeCount[i]-1,typeCount[i+1]-typeCount[i],
+ MED_FR::MED_REMP ,
+ (MED_FR::med_entite_maillage) entity,
+ (MED_FR::med_geometrie_element) types[i]
+);
+ MESSAGE("OK "<<i);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| cells of geometric type |" << MED_FR::geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
}
+ delete[] MEDArrayFamily ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
}
+ }
- { // FACE RELATED BLOCK
- medEntityMesh entity=MED_EN::MED_FACE;
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
- if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+ { // FACE RELATED BLOCK
+ medEntityMesh entity=MED_EN::MED_FACE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ SCRUTE(numberOfTypes);
- int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
- int * familyArray = new int[numberOfElements] ;
- for (int i=0;i<numberOfElements;i++)
- familyArray[i]=0;
-
- int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
- vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
- for (int i=0;i<numberOfFamilies;i++) {
- int familyNumber = myFamilies[i]->getIdentifier() ;
- int numberOfFamilyElements = myFamilies[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
- int * myFamilyElements = myFamilies[i]->getNumber(MED_ALL_ELEMENTS) ;
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
+ //bool ToDestroy = false;
+ if (0 == numberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-1000);
+ myFamilies->push_back(myFamily);
+ }
+ numberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = (*myFamilies)[i]->getIdentifier() ;
+ int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<numberOfFamilyElements; ii++)
+ familyArray[ii]=familyNumber;
+ else {
+ const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
for (int ii=0;ii<numberOfFamilyElements;ii++)
- familyArray[myFamilyElements[ii]-1]=familyNumber;
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
}
+ }
- int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
-
- for (int i=0; i<numberOfTypes; i++) {
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
- int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- familyArray+typeCount[i]-1, typeNumberOfElements,
- MED_FR::MED_REMP ,
- (MED_FR::med_entite_maillage) entity,
- (MED_FR::med_geometrie_element) types[i]);
+ for (int i=0; i<numberOfTypes; i++) {
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
- << "| faces of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
- delete[] familyArray ;
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ MED_FR::MED_REMP ,
+ (MED_FR::med_entite_maillage) entity,
+ (MED_FR::med_geometrie_element) types[i]);
+
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| faces of geometric type |" << MED_FR::geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
}
+ delete[] familyArray ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
}
+ }
- { // EDGE RELATED BLOCK
- //medEntityMesh entity=MED_EN::MED_FACE;
- medEntityMesh entity=MED_EN::MED_EDGE;
- // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
- if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
+ { // EDGE RELATED BLOCK
+ //medEntityMesh entity=MED_EN::MED_FACE;
+ medEntityMesh entity=MED_EN::MED_EDGE;
+ // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
+ if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
- int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
- medGeometryElement * types = _ptrMesh->getTypes (entity) ;
+ int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
+ const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
- int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
- int * familyArray = new int[numberOfElements] ;
- for (int i=0;i<numberOfElements;i++)
- familyArray[i]=0;
-
- int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
- vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
- for (int i=0;i<numberOfFamilies;i++) {
- int familyNumber = myFamilies[i]->getIdentifier() ;
- int numberOfFamilyElements = myFamilies[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
- int * myFamilyElements = myFamilies[i]->getNumber(MED_ALL_ELEMENTS) ;
+ int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
+ int * familyArray = new int[numberOfElements] ;
+ for (int i=0;i<numberOfElements;i++)
+ familyArray[i]=0;
+
+ int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
+ //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
+ vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
+ //bool ToDestroy = false;
+ if (0 == numberOfFamilies) {
+ //ToDestroy = true ;
+ vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
+ int NumberOfGroups = myGroups.size() ;
+ // build families from groups
+ for (int i=0; i<NumberOfGroups; i++) {
+ SCRUTE( myGroups[i]->getName() );
+ SUPPORT * mySupport = myGroups[i] ;
+ FAMILY* myFamily = new FAMILY(*mySupport);
+ myFamily->setIdentifier(-i-2000);
+ myFamilies->push_back(myFamily);
+ }
+ numberOfFamilies=myFamilies->size() ;
+ }
+ for (int i=0;i<numberOfFamilies;i++) {
+ int familyNumber = (*myFamilies)[i]->getIdentifier() ;
+ int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ if ((*myFamilies)[i]->isOnAllElements())
+ for (int ii=0; ii<numberOfFamilyElements; ii++)
+ familyArray[ii]=familyNumber;
+ else {
+ const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
for (int ii=0;ii<numberOfFamilyElements;ii++)
- familyArray[myFamilyElements[ii]-1]=familyNumber;
+ familyArray[myFamilyElements[ii]-1]=familyNumber;
}
+ }
- int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
+ const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
- for (int i=0; i<numberOfTypes; i++) {
+ for (int i=0; i<numberOfTypes; i++) {
- int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
- err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
- familyArray+typeCount[i]-1, typeNumberOfElements,
- MED_FR::MED_REMP ,
- (MED_FR::med_entite_maillage) entity,
- (MED_FR::med_geometrie_element) types[i]);
+ int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
+ err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
+ familyArray+typeCount[i]-1, typeNumberOfElements,
+ MED_FR::MED_REMP ,
+ (MED_FR::med_entite_maillage) entity,
+ (MED_FR::med_geometrie_element) types[i]);
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
- << "| edges of geometric type |" << geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
- << _ptrMesh->_name.c_str() << "|" ));
- }
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
+ << "| edges of geometric type |" << MED_FR::geoNames[ (MED_FR::med_geometrie_element) types[i]] <<"|in mesh |"
+ << _ptrMesh->_name.c_str() << "|" ));
}
+ delete[] familyArray ;
+ //if (true == ToDestroy) {
+ // int NumberOfFamilies = myFamilies->size();
+ // for (int i=0; i<NumberOfFamilies; i++)
+ // delete myFamilies[i];
+ //}
}
-
- END_OF(LOC);
- return MED_VALID;
}
- return MED_ERROR;
+
+ END_OF(LOC);
+ return MED_VALID;
}
-
int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> & families ) const {
const char * LOC="int MED_MESH_WRONLY_DRIVER::writeFamilies(vector<FAMILY*> families) const : ";
MED_FR::med_err err;
- if (_status==MED_OPENED) {
+ MESSAGE(LOC<<" families.size() :"<<families.size());
- MESSAGE(LOC<<" families.size() :"<<families.size());
+ for (int i=0; i< families.size(); i++) {
- for (int i=0; i< families.size(); i++) {
+ int numberOfAttributes = families[i]->getNumberOfAttributes ();
+ string attributesDescriptions = "";
- int numberOfAttributes = families[i]->getNumberOfAttributes ();
- string attributesDescriptions = "";
-
- // Recompose the attributes descriptions arg for MED
- for (int j=0; j < numberOfAttributes; j++) {
+ // Recompose the attributes descriptions arg for MED
+ for (int j=0; j < numberOfAttributes; j++) {
- string attributeDescription = families[i]->getAttributeDescription(j+1);
+ string attributeDescription = families[i]->getAttributeDescription(j+1);
- if ( attributeDescription.size() > MED_TAILLE_DESC )
- throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
- << "| with identifier |" << families[i]->getIdentifier() << "| is |"
- << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
+ if ( attributeDescription.size() > MED_TAILLE_DESC )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
- attributesDescriptions += attributeDescription;
- }
+ attributesDescriptions += attributeDescription;
+ }
- int numberOfGroups = families[i]->getNumberOfGroups();
- string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
- // Recompose the groups names arg for MED
- for (int j=0; j < numberOfGroups; j++) {
+ int numberOfGroups = families[i]->getNumberOfGroups();
+ string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
+ // Recompose the groups names arg for MED
+ for (int j=0; j < numberOfGroups; j++) {
- string groupName = families[i]->getGroupName(j+1);
+ string groupName = families[i]->getGroupName(j+1);
- if ( groupName.size() > MED_TAILLE_LNOM )
- throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
- << "| with identifier |" << families[i]->getIdentifier() << "| is |"
- << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
+ if ( groupName.size() > MED_TAILLE_LNOM )
+ throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| is |"
+ << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
- int length = min(MED_TAILLE_LNOM,(int)groupName.size());
- groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
+ int length = min(MED_TAILLE_LNOM,(int)groupName.size());
+ groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
- }
-
- // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
- string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/";
- SCRUTE("|"<<dataGroupFam<<"|");
- if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
- SCRUTE(err);
-
- MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
- MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
- MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
- MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
- MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
- MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
- MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
- MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
- MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
-
- err = MEDfamCr( _medIdt,
- const_cast <char *> ( _meshName.c_str() ),
- const_cast <char *> ( families[i]->getName().c_str() ),
- families[i]->getIdentifier(),
- families[i]->getAttributesIdentifiers(),
- families[i]->getAttributesValues(),
- const_cast <char *> (attributesDescriptions.c_str()),
- numberOfAttributes,
- const_cast <char *> (groupsNames.c_str()),
- numberOfGroups);
- SCRUTE(err);
- if ( err != MED_VALID)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
- << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
- << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
- }
- else
- _MEDdatagroupFermer(_medIdt);
+ }
+ // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
+ string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/"+families[i]->getName()+"/";
+ SCRUTE("|"<<dataGroupFam<<"|");
+ if ( err =_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) < MED_VALID ) {
+ SCRUTE(err);
+ MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
+ MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
+ MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
+ MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
+
+ //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
+ //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
+ MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
+ MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
+ MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
+
+ err = MED_FR::MEDfamCr( _medIdt,
+ const_cast <char *> ( _meshName.c_str() ),
+ const_cast <char *> ( families[i]->getName().c_str() ),
+ families[i]->getIdentifier(),
+ families[i]->getAttributesIdentifiers(),
+ families[i]->getAttributesValues(),
+ const_cast <char *> (attributesDescriptions.c_str()),
+ numberOfAttributes,
+ const_cast <char *> (groupsNames.c_str()),
+ numberOfGroups);
+ SCRUTE(err);
+ if ( err != MED_VALID)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
+ << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
+ << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
}
+ else
+ _MEDdatagroupFermer(_medIdt);
+
- END_OF(LOC);
-
- return MED_VALID;
}
- return MED_ERROR;
+
+ END_OF(LOC);
+
+ return MED_VALID;
}
// A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
+
+
+
+/*--------------------- RDWR PART -------------------------------*/
+
+MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER()
+{
+}
+
+MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
+{
+ MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver):
+ MED_MESH_RDONLY_DRIVER::MED_MESH_DRIVER(driver)
+{
+}
+
+MED_MESH_RDWR_DRIVER::~MED_MESH_RDWR_DRIVER() {
+ //MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * MED_MESH_RDWR_DRIVER::copy(void) const
+{
+ return new MED_MESH_RDWR_DRIVER(*this);
+}
+
+void MED_MESH_RDWR_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ MED_MESH_WRONLY_DRIVER::write();
+}
+void MED_MESH_RDWR_DRIVER::read (void)
+ throw (MEDEXCEPTION)
+{
+ MED_MESH_RDONLY_DRIVER::read();
+}
+
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_MedMeshDriver.hxx
+// Module : MED
+
#ifndef MED_MESH_DRIVER_HXX
#define MED_MESH_DRIVER_HXX
class GROUP;
class CONNECTIVITY;
+/*!
+
+ Driver Med for MESH.
+
+ Generic part : implement open and close methods.
+
+*/
+
class MED_MESH_DRIVER : public GENDRIVER
{
protected:
static const MED_FR::med_geometrie_element all_cell_type[MED_NBR_GEOMETRIE_MAILLE];
static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE];
-
- MED_MESH_DRIVER():GENDRIVER(),
- _ptrMesh(( MESH *)MED_NULL),_medIdt(MED_INVALID),
- _meshName(""),_meshNum(MED_INVALID)
- {
- }
- MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode):
- GENDRIVER(fileName,accessMode),
- _ptrMesh(ptrMesh),_medIdt(MED_INVALID),
- _meshName(""),_meshNum(MED_INVALID)
- {
- }
-
- void open() {
- BEGIN_OF("MED_MESH_DRIVER::open()");
- _medIdt = MED_FR::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(MED_FR::med_mode_acces) _accessMode);
- MESSAGE("MED_MESH_DRIVER::open() _medIdt : "<< _medIdt );
- if (_medIdt > 0) _status=MED_OPENED; else {
- MESSAGE(" MED_MESH__DRIVER::open() : MEDouvrir : _medIdt= " << _medIdt );
- _status = MED_INVALID;
- }
- END_OF("MED_MESH_DRIVER::open()");
- }
-
- void close() {
- const char * LOC = "MED_MESH_DRIVER::close() " ;
- BEGIN_OF(LOC);
- med_int err = 0;
- if ( _status == MED_OPENED) {
- err=MED_FR::MEDfermer(_medIdt);
- H5close();
- if (err != 0)
- throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
- <<" Error when closing file !"
- )
- );
- MESSAGE(LOC <<": _medIdt= " << _medIdt );
- MESSAGE(LOC<<": MEDfermer : err = " << err );
- _status = MED_CLOSED;
- _medIdt = MED_INVALID;
- }
- END_OF(LOC);
- }
+
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ med_mode_acces accessMode) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_DRIVER(const MED_MESH_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_DRIVER() ;
+
+ void open() throw (MEDEXCEPTION);
+ void close() throw (MEDEXCEPTION);
virtual void write( void ) const = 0 ;
virtual void read ( void ) = 0 ;
-
+
+ /*!
+ Set the name of the MESH asked in file.
+
+ It could be different than the name of the MESH object.
+ */
void setMeshName(const string & meshName) ;
+ /*!
+ Get the name of the MESH asked in file.
+ */
string getMeshName() const ;
+private:
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+
};
+/*!
+
+ Driver Med for MESH : Read only.
+
+ Implement read method.
+
+*/
+
class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER
{
public :
- MED_MESH_RDONLY_DRIVER():MED_MESH_DRIVER() {};
-
- MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY) {
- MESSAGE("MED_MESH_RDONLY_DRIVER::MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
- }
-
- ~MED_MESH_RDONLY_DRIVER() {
- MESSAGE("MED_MESH_RDONLY_DRIVER::~MED_MESH_RDONLY_DRIVER() has been destroyed");
- }
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_RDONLY_DRIVER() ;
// CREER UNE METHODE POUR LIRE LA LISTE DES MAILLAGES .....
+
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
int getCOORDINATE();
int getCONNECTIVITY();
int getFAMILY();
- void write( void ) const ;
- void read ( void ) ;
-
-private:
int getNodalConnectivity(CONNECTIVITY * Connectivity) ;
int getDescendingConnectivity(CONNECTIVITY * Connectivity) ;
- int getNodesFamiliesNumber() ;
+ int getNodesFamiliesNumber(int * MEDArrayNodeFamily) ;
int getCellsFamiliesNumber(int** Arrays, CONNECTIVITY* Connectivity) ;
void updateFamily() ;
void buildAllGroups(vector<GROUP*> & Groups, vector<FAMILY*> & Families) ;
-
+ void getGRID ();
+
+ GENDRIVER * copy ( void ) const ;
+
};
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER {
public :
- MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {}
-
- MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
- {
- MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
- };
-
- ~MED_MESH_WRONLY_DRIVER() {
- MESSAGE("MED_MESH_WRONLY_DRIVER::MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
- }
-
- void write( void ) const ;
- void read ( void ) ;
-
- int writeCoordinates () const;
- int writeConnectivities (medEntityMesh entity) const;
- int writeFamilyNumbers () const;
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~MED_MESH_WRONLY_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+ int writeCoordinates () const;
+ int writeConnectivities (medEntityMesh entity) const;
+ int writeFamilyNumbers () const;
int writeFamilies (vector<FAMILY*> & families) const;
+ int writeGRID() const;
+
+ GENDRIVER * copy ( void ) const ;
};
+/*!
+
+ Driver Med for MESH : Read write.
+ - Use read method from MED_MESH_RDONLY_DRIVER
+ - Use write method from MED_MESH_WRONLY_DRIVER
+
+*/
+
class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER {
public :
- MED_MESH_RDWR_DRIVER():MED_MESH_DRIVER() {}
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver) ;
- MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh):
- MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
- {
- MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
- };
+ /*!
+ Destructor.
+ */
+ ~MED_MESH_RDWR_DRIVER() ;
- ~MED_MESH_RDWR_DRIVER() {
- MESSAGE("MED_MESH_RDWR_DRIVER::MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
- }
-
- void write(void) const ;
- void read (void) ;
-};
+ /*!
+ Write MESH in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION);
+private:
+ GENDRIVER * copy(void) const ;
+
+};
#endif /* MED_MESH_DRIVER_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Mesh.cxx
+// Module : MED
+
+using namespace std;
/*
File Mesh.cxx
$Header$
#include <list>
#include <map>
+#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Support.hxx"
#include "MEDMEM_Family.hxx"
#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_Grid.hxx"
//update Families with content list
//int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
// MESH::INSTANCE_DE<MED_MESH_RDONLY_DRIVER> MESH::inst_med_rdonly ;
//const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
+// Add a similar line for your personnal driver (step 3)
MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER> MESH::inst_med ;
-const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med } ;
+MESH::INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> MESH::inst_gibi ;
+// Add your own driver in the driver list (step 4)
+// Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx.
+const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med, &MESH::inst_gibi } ;
/*! Add a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. The meshname used in the file
is <driverName>. addDriver returns an int handler. */
int MESH::addDriver(driverTypes driverType,
- const string & fileName="Default File Name.med",const string & driverName="Default Mesh Name") {
+ const string & fileName/*="Default File Name.med"*/,const string & driverName/*="Default Mesh Name"*/) {
const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : ";
const char * LOC = "MESH::addDriver(GENDRIVER &) : ";
BEGIN_OF(LOC);
- // A FAIRE VERIFIER QUE LE DRIVER EST DE TYPE MESH !!
- _drivers.push_back(&driver);
+ // A faire : Vérifier que le driver est de type MESH.
+ GENDRIVER * newDriver = driver.copy() ;
+
+ _drivers.push_back(newDriver);
return _drivers.size()-1;
-
+
END_OF(LOC);
}
/*! Remove an existing MESH driver. */
-void MESH::rmDriver (int index=0) {
+void MESH::rmDriver (int index/*=0*/) {
const char * LOC = "MESH::rmDriver (int index=0): ";
BEGIN_OF(LOC);
void MESH::init() {
+ const char * LOC = "MESH::init(): ";
+
+ BEGIN_OF(LOC);
+
string _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ?
- _numberOfMEDNodeFamily = MED_INVALID;
- _MEDArrayNodeFamily = (int * ) NULL; // SOLUTION TEMPORAIRE
- _numberOfMEDCellFamily = (int * ) NULL;
- _numberOfMEDFaceFamily = (int * ) NULL;
- _numberOfMEDEdgeFamily = (int * ) NULL;
- _MEDArrayCellFamily = (int **) NULL; // SOLUTION TEMPORAIRE
- _MEDArrayFaceFamily = (int **) NULL; // SOLUTION TEMPORAIRE
- _MEDArrayEdgeFamily = (int **) NULL; // SOLUTION TEMPORAIRE
-
COORDINATE * _coordinate = (COORDINATE *) NULL;
CONNECTIVITY * _connectivity = (CONNECTIVITY *) NULL;
_numberOfFacesGroups = 0;
_numberOfEdgesGroups = 0;
+ _isAGrid = false;
};
/*! Create an empty MESH. */
-MESH::MESH() {
+MESH::MESH():_coordinate(NULL),_connectivity(NULL) {
init();
};
-MESH::MESH(const MESH &m)
+MESH::MESH(MESH &m)
{
- // VERIFIER QUE TS LES OPERATEURS DE RECOPIE DES ATTRIBUTS
- // SONT CORRECTS.
- *this = m;
+ _name=m._name;
+ _isAGrid = m._isAGrid;
+
+ if (m._coordinate != NULL)
+ _coordinate = new COORDINATE(* m._coordinate);
+ else
+ _coordinate = (COORDINATE *) NULL;
+
+ if (m._connectivity != NULL)
+ _connectivity = new CONNECTIVITY(* m._connectivity);
+ else
+ _connectivity = (CONNECTIVITY *) NULL;
+
+ _spaceDimension = m._spaceDimension;
+ _meshDimension = m._meshDimension;
+ _numberOfNodes = m._numberOfNodes;
+
+ _numberOfNodesFamilies = m._numberOfNodesFamilies;
+ _familyNode = m._familyNode;
+ for (int i=0; i<m._numberOfNodesFamilies; i++)
+ {
+ _familyNode[i] = new FAMILY(* m._familyNode[i]);
+ _familyNode[i]->setMesh(this);
+ }
+
+ _numberOfCellsFamilies = m._numberOfCellsFamilies;
+ _familyCell = m._familyCell;
+ for (int i=0; i<m._numberOfCellsFamilies; i++)
+ {
+ _familyCell[i] = new FAMILY(* m._familyCell[i]);
+ _familyCell[i]->setMesh(this);
+ }
+
+ _numberOfFacesFamilies = m._numberOfFacesFamilies;
+ _familyFace = m._familyFace;
+ for (int i=0; i<m._numberOfFacesFamilies; i++)
+ {
+ _familyFace[i] = new FAMILY(* m._familyFace[i]);
+ _familyFace[i]->setMesh(this);
+ }
+
+ _numberOfEdgesFamilies = m._numberOfEdgesFamilies;
+ _familyEdge = m._familyEdge;
+ for (int i=0; i<m._numberOfEdgesFamilies; i++)
+ {
+ _familyEdge[i] = new FAMILY(* m._familyEdge[i]);
+ _familyEdge[i]->setMesh(this);
+ }
+
+ _numberOfNodesGroups = m._numberOfNodesGroups;
+ _groupNode = m._groupNode;
+ for (int i=0; i<m._numberOfNodesGroups; i++)
+ {
+ _groupNode[i] = new GROUP(* m._groupNode[i]);
+ _groupNode[i]->setMesh(this);
+ }
+
+ _numberOfCellsGroups = m._numberOfCellsGroups;
+ _groupCell = m._groupCell;
+ for (int i=0; i<m._numberOfCellsGroups; i++)
+ {
+ _groupCell[i] = new GROUP(* m._groupCell[i]);
+ _groupCell[i]->setMesh(this);
+ }
+
+ _numberOfFacesGroups = m._numberOfFacesGroups;
+ _groupFace = m._groupFace;
+ for (int i=0; i<m._numberOfFacesGroups; i++)
+ {
+ _groupFace[i] = new GROUP(* m._groupFace[i]);
+ _groupFace[i]->setMesh(this);
+ }
+
+ _numberOfEdgesGroups = m._numberOfEdgesGroups;
+ _groupEdge = m._groupEdge;
+ for (int i=0; i<m._numberOfEdgesGroups; i++)
+ {
+ _groupEdge[i] = new GROUP(* m._groupEdge[i]);
+ _groupEdge[i]->setMesh(this);
+ }
+
+ //_drivers = m._drivers; //Recopie des drivers?
}
MESH::~MESH() {
- if ( _MEDArrayNodeFamily != (int * ) NULL) delete [] _MEDArrayNodeFamily; // SOLUTION TEMPORAIRE
- if ( _numberOfMEDCellFamily != (int * ) NULL) delete [] _numberOfMEDCellFamily;
- if ( _numberOfMEDFaceFamily != (int * ) NULL) delete [] _numberOfMEDFaceFamily;
- if ( _numberOfMEDEdgeFamily != (int * ) NULL) delete [] _numberOfMEDEdgeFamily;
- // IL FAUT FAIRE UNE BOUCLE DE DESALLOCATION
- if ( _MEDArrayCellFamily != (int **) NULL) delete [] _MEDArrayCellFamily; // SOLUTION TEMPORAIRE
- if ( _MEDArrayFaceFamily != (int **) NULL) delete [] _MEDArrayFaceFamily; // SOLUTION TEMPORAIRE
- if ( _MEDArrayEdgeFamily != (int **) NULL) delete [] _MEDArrayEdgeFamily; // SOLUTION TEMPORAIRE
-
- if (_coordinate != NULL) delete _coordinate ;
- if (_connectivity != NULL) delete _connectivity ;
+ MESSAGE("MESH::~MESH() : Destroying the Mesh");
+ if (_coordinate != ((COORDINATE *) NULL)) delete _coordinate ;
+ if (_connectivity != ((CONNECTIVITY *) NULL)) delete _connectivity ;
int size ;
size = _familyNode.size() ;
for (int i=0;i<size;i++)
- delete _familyNode[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyNode[i] ;
size = _familyCell.size() ;
for (int i=0;i<size;i++)
- delete _familyCell[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyCell[i] ;
size = _familyFace.size() ;
for (int i=0;i<size;i++)
- delete _familyFace[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyFace[i] ;
size = _familyEdge.size() ;
for (int i=0;i<size;i++)
- delete _familyEdge[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _familyEdge[i] ;
size = _groupNode.size() ;
for (int i=0;i<size;i++)
- delete _groupNode[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupNode[i] ;
size = _groupCell.size() ;
for (int i=0;i<size;i++)
- delete _groupCell[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupCell[i] ;
size = _groupFace.size() ;
for (int i=0;i<size;i++)
- delete _groupFace[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupFace[i] ;
size = _groupEdge.size() ;
for (int i=0;i<size;i++)
- delete _groupEdge[i] ;
+ ;// mpv such destructors call is problemmatic for ALLIANCES algorithms
+ //delete _groupEdge[i] ;
+
+ MESSAGE("In this object MESH there is(are) " << _drivers.size() << " driver(s)");
+
+ for (int index=0; index < _drivers.size(); index++ )
+ {
+ SCRUTE(_drivers[index]);
+ if ( _drivers[index] != NULL) delete _drivers[index];
+ }
}
/*! Create a MESH object using a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>.
The meshname <driverName> must already exists in the file.*/
-MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") {
+MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) {
const char * LOC ="MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") : ";
int current;
init();
- current = addDriver(driverType,fileName,driverName);
- switch(_drivers[current]->getAccessMode() ) {
- case MED_RDONLY : {
- MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must have a MED_RDWR accessMode");
- rmDriver(current);
- break;}
- default : {
- }
- }
+ MED_MESH_RDONLY_DRIVER myDriver(fileName,this) ;
+ myDriver.setMeshName(driverName);
+ current = addDriver(myDriver);
+// current = addDriver(driverType,fileName,driverName);
+// switch(_drivers[current]->getAccessMode() ) {
+// case MED_WRONLY : {
+// MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must not be a MED_WRONLY accessMode");
+// rmDriver(current);
+// break;}
+// default : {
+// }
+// }
_drivers[current]->open();
_drivers[current]->read();
_drivers[current]->close();
+
+ if (_isAGrid)
+ ((GRID *) this)->fillMeshAfterRead();
+
END_OF(LOC);
};
ostream & operator<<(ostream &os, MESH &myMesh)
{
-// int space_dimension = myMesh.get_space_dimension();
-// os << "Space dimension "<< space_dimension << endl ;
-// int nodes_count = myMesh.get_nodes_count() ;
-// os << "Nodes count : "<< nodes_count << endl ;
-// double * coord = myMesh.get_coordinates();
-// os << "Coordinates :" << endl ;
-// string * coordinate_name = myMesh.get_coordinates_name() ;
-// string * coordinate_unit = myMesh.get_coordinates_unit() ;
-
-// for(int i=0;i<space_dimension;i++) {
-// os << " - name "<< i << " : "<< coordinate_name[i] << endl;
-// os << " - unit "<< i << " : "<< coordinate_unit[i] << endl ;
-// }
-
-// for(int j=0;j<nodes_count;j++) {
-// for(int i=0;i<space_dimension;i++)
-// os << " coord["<< i <<","<< j << "] : "<< coord[j+i*nodes_count] <<" ," ;
-// os << endl;
-// }
-
-// int cells_types_count = myMesh.get_cells_types_count() ;
-// os << "cells_types_count : " << cells_types_count << endl ;
-// for(int i=1;i<cells_types_count;i++) {
-// os << "cell type : " << myMesh.get_cells_type(i) << endl ;
-// os << " - cells count : " << myMesh.get_cells_count(i) << endl ;
-// int *conectivity = myMesh.get_nodal_connectivity(i) ;
-// int nodes_cells_count = myMesh.get_cells_type(i).get_nodes_count() ;
-// for(int j=0;j<myMesh.get_cells_count(i);j++) {
-// os << " " ;
-// for(int k=0;k<nodes_cells_count;k++)
-// os <<conectivity[j*nodes_cells_count+k] << " " ;
-// os << endl ;
-// }
-// }
-
-// int nodes_families_count = myMesh.get_nodes_families_count() ;
-// os << "nodes_families_count : " << nodes_families_count << endl ;
-// vector<FamilyNode*> nodes_Families = myMesh.get_nodes_Families() ;
-// for(int i=0;i<nodes_families_count;i++)
-// os << " - Famile "<<i<<" : "<< (FamilyNode &) (*nodes_Families[i]) << endl ;
-// os << endl ;
-
-// int cells_families_count = myMesh.get_cells_families_count() ;
-// os << "cells_families_count : " << cells_families_count << endl ;
-// vector<FamilyCell*> cells_Families = myMesh.get_cells_Families() ;
-// for(int i=0;i<cells_families_count;i++)
-// os << " - Famile "<<i<<" : "<< (*cells_Families[i]) << endl ;
-// os << endl ;
-
- return os ;
+ int spacedimension = myMesh.getSpaceDimension();
+ int meshdimension = myMesh.getMeshDimension();
+ int numberofnodes = myMesh.getNumberOfNodes();
+
+ os << "Space Dimension : " << spacedimension << endl << endl;
+
+ os << "Mesh Dimension : " << meshdimension << endl << endl;
+
+ const double * coordinates = myMesh.getCoordinates(MED_FULL_INTERLACE);
+ os << "SHOW NODES COORDINATES : " << endl;
+
+ os << "Name :" << endl;
+ const string * coordinatesnames = myMesh.getCoordinatesNames();
+ for(int i=0; i<spacedimension ; i++)
+ {
+ os << " - " << coordinatesnames[i] << endl;
+ }
+ os << "Unit :" << endl;
+ const string * coordinatesunits = myMesh.getCoordinatesUnits();
+ for(int i=0; i<spacedimension ; i++)
+ {
+ os << " - " << coordinatesunits[i] << endl;
+ }
+ for(int i=0; i<numberofnodes ; i++)
+ {
+ os << "Nodes " << i+1 << " : ";
+ for (int j=0; j<spacedimension ; j++)
+ os << coordinates[i*spacedimension+j] << " ";
+ os << endl;
+ }
+
+ const CONNECTIVITY * myConnectivity = myMesh.getConnectivityptr();
+ if (!myConnectivity->existConnectivity(MED_NODAL,MED_CELL) && myConnectivity->existConnectivity(MED_DESCENDING,MED_CELL))
+ {
+ os << endl << "SHOW CONNECTIVITY (DESCENDING) :" << endl;
+ int numberofelements;
+ const int * connectivity;
+ const int * connectivity_index;
+ myMesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
+ try {
+ numberofelements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
+ connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS);
+ connectivity_index = myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL);
+ }
+ catch (MEDEXCEPTION m) {
+ os << m.what() << endl;
+ exit (-1);
+ }
+ for (int j=0;j<numberofelements;j++) {
+ os << "Element "<<j+1<<" : ";
+ for (int k=connectivity_index[j];k<connectivity_index[j+1];k++)
+ os << connectivity[k-1]<<" ";
+ os << endl;
+ }
+ }
+ else
+ {
+ int numberoftypes = myMesh.getNumberOfTypes(MED_CELL);
+ const medGeometryElement * types = myMesh.getTypes(MED_CELL);
+ os << endl << "SHOW CONNECTIVITY (NODAL) :" << endl;
+ for (int i=0; i<numberoftypes; i++) {
+ os << "For type " << types[i] << " : " << endl;
+ int numberofelements = myMesh.getNumberOfElements(MED_CELL,types[i]);
+ const int * connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[i]);
+ int numberofnodespercell = types[i]%100;
+ for (int j=0;j<numberofelements;j++){
+ os << "Element "<< j+1 <<" : ";
+ for (int k=0;k<numberofnodespercell;k++)
+ os << connectivity[j*numberofnodespercell+k]<<" ";
+ os << endl;
+ }
+ }
+ }
+
+
+ medEntityMesh entity;
+ os << endl << "SHOW FAMILIES :" << endl << endl;
+ for (int k=1; k<=4; k++)
+ {
+ if (k==1) entity = MED_NODE;
+ if (k==2) entity = MED_CELL;
+ if (k==3) entity = MED_FACE;
+ if (k==4) entity = MED_EDGE;
+ int numberoffamilies = myMesh.getNumberOfFamilies(entity);
+ using namespace MED_FR;
+ os << "NumberOfFamilies on "<< entNames[(MED_FR::med_entite_maillage) entity] <<" : "<<numberoffamilies<<endl;
+ using namespace MED_EN;
+ for (int i=1; i<numberoffamilies+1;i++)
+ {
+ os << * myMesh.getFamily(entity,i) << endl;
+ }
+ }
+
+ os << endl << "SHOW GROUPS :" << endl << endl;
+ for (int k=1; k<=4; k++)
+ {
+ if (k==1) entity = MED_NODE;
+ if (k==2) entity = MED_CELL;
+ if (k==3) entity = MED_FACE;
+ if (k==4) entity = MED_EDGE;
+ int numberofgroups = myMesh.getNumberOfGroups(entity);
+ using namespace MED_FR;
+ os << "NumberOfGroups on "<< entNames[(MED_FR::med_entite_maillage) entity] <<" : "<<numberofgroups<<endl;
+ using namespace MED_EN;
+ for (int i=1; i<numberofgroups+1;i++)
+ {
+ os << * myMesh.getGroup(entity,i) << endl;
+ }
+ }
+
+ return os;
}
/*!
- Get global number of element which have same connectivity than connectivity argument
+ Get global number of element which have same connectivity than connectivity argument.
+
+ It do not take care of connectivity order (3,4,7,10 is same as 7,3,10,4).
+
+ Return -1 if not found.
*/
-int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity)
+int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const
{
const char* LOC="MESH::getElementNumber " ;
BEGIN_OF(LOC) ;
else
numberOfValue = myType.getNumberOfNodes() ; // nodes
- int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType) ;
- int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType) ;
+ const int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType,Entity) ;
+ const int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType,Entity) ;
// First node or face/edge
int indexBegin = myReverseConnectivityIndex[connectivity[0]-1] ;
For instance, we could get only face in 3D and edge in 2D.
*/
-SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION)
+SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity)
+ throw (MEDEXCEPTION)
{
const char * LOC = "MESH::getBoundaryElements : " ;
BEGIN_OF(LOC) ;
mySupport->setAll(false);
- int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
- int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
+ const int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
+ const int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ;
list<int> myElementsList ;
int size = 0 ;
- SCRUTE(numberOf) ;
for (int i=0 ; i<numberOf; i++)
if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
- SCRUTE(i+1) ;
myElementsList.push_back(i+1) ;
size++ ;
}
- SCRUTE(size) ;
// Well, we must know how many geometric type we have found
int * myListArray = new int[size] ;
int id = 0 ;
list<int>::iterator myElementsListIt ;
for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
myListArray[id]=(*myElementsListIt) ;
- SCRUTE(id);
- SCRUTE(myListArray[id]);
id ++ ;
}
medGeometryElement* geometricType ;
int * numberOfGaussPoint ;
int * geometricTypeNumber ;
- int * numberOfEntities ;
- MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * numberOfElements ;
+ //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
int * mySkyLineArrayIndex ;
int numberOfType = getNumberOfTypes(Entity) ;
if (numberOfType == 1) { // wonderfull : it's easy !
numberOfGeometricType = 1 ;
geometricType = new medGeometryElement[1] ;
- medGeometryElement * allType = getTypes(Entity);
+ const medGeometryElement * allType = getTypes(Entity);
geometricType[0] = allType[0] ;
numberOfGaussPoint = new int[1] ;
numberOfGaussPoint[0] = 1 ;
geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
geometricTypeNumber[0] = 0 ;
- numberOfEntities = new int[1] ;
- numberOfEntities[0] = size ;
+ numberOfElements = new int[1] ;
+ numberOfElements[0] = size ;
mySkyLineArrayIndex = new int[2] ;
mySkyLineArrayIndex[0]=1 ;
mySkyLineArrayIndex[1]=1+size ;
}
numberOfGeometricType = theType.size() ;
geometricType = new medGeometryElement[numberOfGeometricType] ;
- medGeometryElement * allType = getTypes(Entity);
+ const medGeometryElement * allType = getTypes(Entity);
numberOfGaussPoint = new int[numberOfGeometricType] ;
geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
- numberOfEntities = new int[numberOfGeometricType] ;
+ numberOfElements = new int[numberOfGeometricType] ;
mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
int index = 0 ;
mySkyLineArrayIndex[0]=1 ;
geometricType[index] = (*theTypeIt).first ;
numberOfGaussPoint[index] = 1 ;
geometricTypeNumber[index] = 0 ;
- numberOfEntities[index] = (*theTypeIt).second ;
- mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
+ numberOfElements[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ;
index++ ;
}
}
- mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
mySupport->setGeometricType(geometricType) ;
mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
- mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
- mySupport->setNumberOfEntities(numberOfEntities) ;
- mySupport->setTotalNumberOfEntities(size) ;
+ mySupport->setNumberOfElements(numberOfElements) ;
+ mySupport->setTotalNumberOfElements(size) ;
+ // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
mySupport->setNumber(mySkyLineArray) ;
+ delete[] numberOfElements;
+ delete[] geometricTypeNumber;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+ delete[] mySkyLineArrayIndex;
+ delete[] myListArray;
+// delete mySkyLineArray;
+
END_OF(LOC) ;
return mySupport ;
}
-FIELD<double>* MESH::getVolume(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getVolume(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 3D elements
- MESSAGE("MESH::getVolume(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
int index;
- FIELD<double>* Volume;
-
- Volume = new FIELD<double>::FIELD(Support,1);
+ FIELD<double>* Volume = new FIELD<double>::FIELD(Support,1);
// double *volume = new double [length_values];
Volume->setName("VOLUME");
Volume->setDescription("cells volume");
Volume->setOrderNumber(0);
Volume->setTime(0.0);
- double *volume = Volume->getValue(MED_FULL_INTERLACE);
+ //const double *volume = Volume->getValue(MED_FULL_INTERLACE);
+ MEDARRAY<double> *volume = Volume->getvalue();
- index = 0;
+ index = 1;
const double * coord = getCoordinates(MED_FULL_INTERLACE);
for (int i=0;i<nb_type;i++)
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
-
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all"));
+
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp ;
}
switch (type)
(x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) +
(x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index++;
}
break;
(x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1)))
)/6.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index = index++;
}
break;
xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index++;
}
break;
V + W) + 2.0*(I + R + U + X + Y + Z) +
AA)/27.0;
- volume[index] = xvolume ;
+ //volume[index] = xvolume ;
+ volume->setIJ(index,1,xvolume) ;
index++;
}
break;
}
default :
- throw MEDEXCEPTION("MESH::getVolume(SUPPORT*) Bad Support to get Volumes on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !"));
break;
}
}
return Volume;
}
-FIELD<double>* MESH::getArea(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getArea(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 2D elements
- MESSAGE("MESH::getArea(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getArea(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
+
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+
+ global_connectivity = global_connectivity_tmp ;
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
}
switch (type)
break;
}
default :
- throw MEDEXCEPTION("MESH::getArea(SUPPORT*) Bad Support to get Areas on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Areas on it !"));
break;
}
}
Area->setValue(MED_FULL_INTERLACE,area);
-
+ delete[] area;
return Area;
}
-FIELD<double>* MESH::getLength(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getLength(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 1D elements
- MESSAGE("MESH::getLength(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getLength(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
// double *length = new double [length_values];
Length->setValueType(MED_REEL64);
- double *length = Length->getValue(MED_FULL_INTERLACE);
+ //const double *length = Length->getValue(MED_FULL_INTERLACE);
+ MEDARRAY<double> * length = Length->getvalue();
const double * coord = getCoordinates(MED_FULL_INTERLACE);
- index = 0;
+ index = 1;
for (int i=0;i<nb_type;i++)
{
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
+ nb_entity_type = Support->getNumberOfElements(type);
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int* global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp ;
}
switch (type)
xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) +
(z1 - z2)*(z1 - z2));
- length[index] = xlength ;
+ length->setIJ(index,1,xlength) ;
index++;
}
break;
}
default :
- throw MEDEXCEPTION("MESH::getLength(SUPPORT*) Bad Support to get Lengths on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Lengths on it !"));
break;
}
}
return Length;
}
-FIELD<double>* MESH::getNormal(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
+ const char * LOC = "MESH::getNormal(SUPPORT*) : ";
+ BEGIN_OF(LOC);
+
// Support must be on 2D or 1D elements
- MESSAGE("MESH::getNormal(SUPPORT*)");
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : pointeur problem !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : pointeur problem !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
FIELD<double>* Normal = new FIELD<double>::FIELD(Support,dim_space);
Normal->setName("NORMAL");
Normal->setDescription("cells or faces normal");
- for (int k=0;k<dim_space;k++) {
- int kp1 = k + 1;
- Normal->setComponentName(kp1,"normal");
- Normal->setComponentDescription(kp1,"desc-comp");
- Normal->setMEDComponentUnit(kp1,"unit");
+ for (int k=1;k<=dim_space;k++) {
+ Normal->setComponentName(k,"normal");
+ Normal->setComponentDescription(k,"desc-comp");
+ Normal->setMEDComponentUnit(k,"unit");
}
Normal->setValueType(MED_REEL64);
- Normal->setIterationNumber(0);
- Normal->setOrderNumber(0);
+ Normal->setIterationNumber(MED_NOPDT);
+ Normal->setOrderNumber(MED_NONOR);
Normal->setTime(0.0);
double * normal = new double [dim_space*length_values];
(type==MED_QUAD4) || (type==MED_QUAD8)) &&
(dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) &&
(dim_space != 2)) )
- throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) no compatibility between *this and SUPPORT::_mesh : dimension problem !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : dimension problem !"));
double xnormal1, xnormal2, xnormal3 ;
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
-
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all for instance !"));
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+
+ global_connectivity = global_connectivity_tmp ;
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
}
switch (type)
break;
}
default :
- throw MEDEXCEPTION("MESH::getNormal(SUPPORT*) Bad Support to get Normals on it !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !"));
break;
}
}
Normal->setValue(MED_FULL_INTERLACE,normal);
+ delete[] normal ;
+
+ END_OF(LOC);
return Normal;
}
-FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION)
+FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION)
{
- MESSAGE("MESH::getBarycenter(SUPPORT*)");
+ const char * LOC = "MESH::getBarycenter(SUPPORT*) : ";
+ BEGIN_OF(LOC);
// Make sure that the MESH class is the same as the MESH class attribut
// in the class Support
MESH* myMesh = Support->getMesh();
if (this != myMesh)
- throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) no compatibility between *this and SUPPORT::_mesh !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
int dim_space = getSpaceDimension();
medEntityMesh support_entity = Support->getEntity();
bool onAll = Support->isOnAllElements();
int nb_type, length_values;
- medGeometryElement* types;
+ const medGeometryElement* types;
int nb_entity_type;
// !!!! WARNING : use of nodal global numbering in the mesh !!!!
- int* global_connectivity;
+ const int* global_connectivity;
- if (onAll)
- {
- nb_type = myMesh->getNumberOfTypes(support_entity);
- length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
- types = getTypes(support_entity);
- }
- else
+// if (onAll)
+// {
+// nb_type = myMesh->getNumberOfTypes(support_entity);
+// length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
+// types = getTypes(support_entity);
+// }
+// else
{
nb_type = Support->getNumberOfTypes();
length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
}
else
{
- nb_entity_type = Support->getNumberOfElements(type);
-
- int * supp_number = Support->getNumber(type);
- int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
- int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
- global_connectivity = new int[(type%100)*nb_entity_type];
-
- for (int k_type = 0; k_type<nb_entity_type; k_type++) {
- for (int j_ent = 0; j_ent<(type%100); j_ent++) {
- global_connectivity[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
- }
- }
+ // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
+ nb_entity_type = Support->getNumberOfElements(type);
+
+ const int * supp_number = Support->getNumber(type);
+ const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
+ const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
+ int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
+
+ for (int k_type = 0; k_type<nb_entity_type; k_type++) {
+ for (int j_ent = 0; j_ent<(type%100); j_ent++) {
+ global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
+ }
+ }
+ global_connectivity = global_connectivity_tmp;
}
switch (type)
break;
}
default :
- throw MEDEXCEPTION("MESH::getBarycenter(SUPPORT*) Bad Support to get a barycenter on it (in fact unknown type) !");
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get a barycenter on it (in fact unknown type) !"));
break;
}
}
Barycenter->setValue(MED_FULL_INTERLACE,barycenter);
+ delete[] barycenter ;
+
+ END_OF(LOC);
+
return Barycenter;
}
+
+//=======================================================================
+//function : checkGridFillCoords
+//purpose : if this->_isAGrid, assure that _coordinate is filled
+//=======================================================================
+
+inline void MESH::checkGridFillCoords() const
+{
+ if (_isAGrid)
+ ((GRID *) this)->fillCoordinates();
+}
+
+//=======================================================================
+//function : checkGridFillConnectivity
+//purpose : if this->_isAGrid, assure that _connectivity is filled
+//=======================================================================
+
+inline void MESH::checkGridFillConnectivity() const
+{
+ if (_isAGrid)
+ ((GRID *) this)->fillConnectivity();
+}
+
+
+void MESH::read(int index)
+{
+ const char * LOC = "MESH::read(int index=0) : ";
+ BEGIN_OF(LOC);
+
+ if (_drivers[index]) {
+ _drivers[index]->open();
+ _drivers[index]->read();
+ _drivers[index]->close();
+ }
+ else
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
+ )
+ );
+ if (_isAGrid)
+ ((GRID *) this)->fillMeshAfterRead();
+
+ END_OF(LOC);
+}
+//=======================================================================
+//function : getSkin
+//purpose :
+//=======================================================================
+
+SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESH::getSkin : " ;
+ BEGIN_OF(LOC) ;
+ // some test :
+ if (this != Support3D->getMesh())
+ throw MEDEXCEPTION(STRING(LOC) << "no compatibility between *this and SUPPORT::_mesh !");
+ if (_meshDimension != 3 || Support3D->getEntity() != MED_CELL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Defined on 3D cells only"));
+
+ // well, all rigth !
+ SUPPORT * mySupport = new SUPPORT(this,"Skin",MED_FACE);
+ mySupport->setAll(false);
+
+ list<int> myElementsList ;
+ int i,j, size = 0 ;
+
+ calculateConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, MED_CELL);
+ if (Support3D->isOnAllElements())
+ {
+ int * myConnectivityValue = const_cast <int*> (getReverseConnectivity(MED_DESCENDING)) ;
+ int nbFaces = getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
+ for (i=0, j=1 ; j<=nbFaces; ++j, i += 2)
+ {
+ int cellNb1 = myConnectivityValue [i];
+ int cellNb2 = myConnectivityValue [i+1];
+ //MESSAGE( " FACE # " << j << " -- Cells: " << cellNb1 << ", " << cellNb2 );
+ if ((cellNb1 == 0 || cellNb2 == 0) && (cellNb1 + cellNb2 > 0))
+ {
+ myElementsList.push_back( j ) ;
+ size++ ;
+ }
+ }
+ }
+ else
+ {
+ map<int,int> FaceNbEncounterNb;
+
+ int * myConnectivityValue = const_cast <int *>
+ (getConnectivity(MED_FULL_INTERLACE, MED_DESCENDING,
+ MED_CELL, MED_ALL_ELEMENTS));
+ int * myConnectivityIndex = const_cast <int *> (getConnectivityIndex(MED_DESCENDING, MED_CELL));
+ int * myCellNbs = const_cast <int *> (Support3D->getnumber()->getValue());
+ int nbCells = Support3D->getnumber()->getLength();
+ for (i=0; i<nbCells; ++i)
+ {
+ int cellNb = myCellNbs [ i ];
+ int faceFirst = myConnectivityIndex[ cellNb-1 ];
+ int faceLast = myConnectivityIndex[ cellNb ];
+ for (j = faceFirst; j < faceLast; ++j)
+ {
+ int faceNb = abs( myConnectivityValue [ j-1 ] );
+ //MESSAGE( "Cell # " << i << " -- Face: " << faceNb);
+ if (FaceNbEncounterNb.find( faceNb ) == FaceNbEncounterNb.end())
+ FaceNbEncounterNb[ faceNb ] = 1;
+ else
+ FaceNbEncounterNb[ faceNb ] ++;
+ }
+ }
+ map<int,int>::iterator FaceNbEncounterNbItr;
+ for (FaceNbEncounterNbItr = FaceNbEncounterNb.begin();
+ FaceNbEncounterNbItr != FaceNbEncounterNb.end();
+ FaceNbEncounterNbItr ++)
+ if ((*FaceNbEncounterNbItr).second == 1)
+ {
+ myElementsList.push_back( (*FaceNbEncounterNbItr).first) ;
+ size++ ;
+ }
+ }
+ // Well, we must know how many geometric type we have found
+ int * myListArray = new int[size] ;
+ int id = 0 ;
+ list<int>::iterator myElementsListIt ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ myListArray[id]=(*myElementsListIt) ;
+ id ++ ;
+ }
+
+ int numberOfGeometricType ;
+ medGeometryElement* geometricType ;
+ int * numberOfGaussPoint ;
+ int * geometricTypeNumber ;
+ int * numberOfEntities ;
+ // MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * mySkyLineArrayIndex ;
+
+ int numberOfType = getNumberOfTypes(MED_FACE) ;
+ if (numberOfType == 1) { // wonderfull : it's easy !
+ numberOfGeometricType = 1 ;
+ geometricType = new medGeometryElement[1] ;
+ const medGeometryElement * allType = getTypes(MED_FACE);
+ geometricType[0] = allType[0] ;
+ numberOfGaussPoint = new int[1] ;
+ numberOfGaussPoint[0] = 1 ;
+ geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
+ geometricTypeNumber[0] = 0 ;
+ numberOfEntities = new int[1] ;
+ numberOfEntities[0] = size ;
+ mySkyLineArrayIndex = new int[2] ;
+ mySkyLineArrayIndex[0]=1 ;
+ mySkyLineArrayIndex[1]=1+size ;
+ }
+ else {// hemmm
+ map<medGeometryElement,int> theType ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ medGeometryElement myType = getElementType(MED_FACE,*myElementsListIt) ;
+ if (theType.find(myType) != theType.end() )
+ theType[myType]+=1 ;
+ else
+ theType[myType]=1 ;
+ }
+ numberOfGeometricType = theType.size() ;
+ geometricType = new medGeometryElement[numberOfGeometricType] ;
+ const medGeometryElement * allType = getTypes(MED_FACE);
+ numberOfGaussPoint = new int[numberOfGeometricType] ;
+ geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
+ numberOfEntities = new int[numberOfGeometricType] ;
+ mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
+ int index = 0 ;
+ mySkyLineArrayIndex[0]=1 ;
+ map<medGeometryElement,int>::iterator theTypeIt ;
+ for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
+ geometricType[index] = (*theTypeIt).first ;
+ numberOfGaussPoint[index] = 1 ;
+ geometricTypeNumber[index] = 0 ;
+ numberOfEntities[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
+ index++ ;
+ }
+ }
+ // mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+
+ mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
+ mySupport->setGeometricType(geometricType) ;
+ mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
+ // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
+ mySupport->setNumberOfElements(numberOfEntities) ;
+ mySupport->setTotalNumberOfElements(size) ;
+ mySupport->setNumber(mySkyLineArray) ;
+
+ delete[] numberOfEntities;
+ delete[] geometricTypeNumber;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+ delete[] mySkyLineArrayIndex;
+ delete[] myListArray;
+// delete mySkyLineArray;
+
+ END_OF(LOC) ;
+ return mySupport ;
+
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Mesh.hxx
+// Module : MED
+
#ifndef MESH_HXX
#define MESH_HXX
#include "MEDMEM_Coordinate.hxx"
#include "MEDMEM_Connectivity.hxx"
+// Add your own driver header (step 2)
#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_GibiMeshDriver.hxx"
class CELLMODEL;
-class FAMILY;
-class GROUP;
-class SUPPORT;
+class FAMILY;
+class GROUP;
+class SUPPORT;
template <class T> class FIELD;
using namespace MED_EN;
-/*! This class contains all the informations related with a MESH :
+/*! This class contains all the informations related with a MESH :
- COORDINATES
- CONNECTIVITIES
- FAMILIES OF NODES
- FAMILIES OF CELLS
- FAMILIES OF FACES
- FAMILIES OF EDGES
-
+
NOTE: A Family is only on one type of entity (MED_CELL, MED_FACE, MED_EDGE, MED_NODE).
You can't have a family on MED_CELL and MED_FACE
-
+
*/
class MESH
// ------- Drivers Management Part
protected:
-
+
//-----------------------//
- class INSTANCE
+ class INSTANCE
//-----------------------//
{
public:
virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0 ;
} ;
-
+
//-------------------------------------------------------//
- template <class T> class INSTANCE_DE : public INSTANCE
+ template <class T> class INSTANCE_DE : public INSTANCE
//-------------------------------------------------------//
{
public :
- GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
+ GENDRIVER * run(const string & fileName, MESH * ptrMesh) const
{ return new T(fileName,ptrMesh) ; }
} ;
-
- static INSTANCE_DE<MED_MESH_RDWR_DRIVER> inst_med ;
+
+ // Add a similar line for your personnal driver (step 3)
+ static INSTANCE_DE<MED_MESH_RDWR_DRIVER> inst_med ;
+ static INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> inst_gibi ;
//static INSTANCE_DE<VTK_DRIVER> inst_vtk ;
static const INSTANCE * const instances[] ;
string _name; // A POSITIONNER EN FCT DES IOS ?
- int _numberOfMEDNodeFamily ; // INUTILE
- int * _MEDArrayNodeFamily ; // SOLUTION TEMPORAIRE
- int * _numberOfMEDCellFamily ; // INUTILE
- int * _numberOfMEDFaceFamily ; // INUTILE
- int * _numberOfMEDEdgeFamily ; // INUTILE
- int ** _MEDArrayCellFamily ; // SOLUTION TEMPORAIRE
- int ** _MEDArrayFaceFamily ; // SOLUTION TEMPORAIRE
- int ** _MEDArrayEdgeFamily ; // SOLUTION TEMPORAIRE
-
COORDINATE * _coordinate;
CONNECTIVITY * _connectivity;
int _numberOfNodes ;
int _numberOfNodesFamilies; //INUTILE ? -> _familyNode.size()
- vector<FAMILY*> _familyNode ; // array of size _numberOfNodesFamilies;
+ vector<FAMILY*> _familyNode ; // array of size _numberOfNodesFamilies;
int _numberOfCellsFamilies;
- vector<FAMILY*> _familyCell ; // array of size _numberOfCellsFamilies;
+ vector<FAMILY*> _familyCell ; // array of size _numberOfCellsFamilies;
int _numberOfFacesFamilies;
- vector<FAMILY*> _familyFace ; // array of size _numberOfFacesFamilies;
+ vector<FAMILY*> _familyFace ; // array of size _numberOfFacesFamilies;
int _numberOfEdgesFamilies;
vector<FAMILY*> _familyEdge ; // array of size _numberOfEdgesFamilies;
int _numberOfNodesGroups; //INUTILE ?
- vector<GROUP*> _groupNode; // array of size _numberOfNodesGroups;
+ vector<GROUP*> _groupNode; // array of size _numberOfNodesGroups;
int _numberOfCellsGroups; //INUTILE ?
- vector<GROUP*> _groupCell; // array of size _numberOfCellsGroups;
+ vector<GROUP*> _groupCell; // array of size _numberOfCellsGroups;
int _numberOfFacesGroups; //INUTILE ?
- vector<GROUP*> _groupFace; // array of size _numberOfFacesGroups;
+ vector<GROUP*> _groupFace; // array of size _numberOfFacesGroups;
int _numberOfEdgesGroups; //INUTILE ?
- vector<GROUP*> _groupEdge; // array of size _numberOfEdgesGroups;
+ vector<GROUP*> _groupEdge; // array of size _numberOfEdgesGroups;
// list of all Group
vector<GENDRIVER *> _drivers; // Storage of the drivers currently in use
-
+
+ bool _isAGrid; // am I a GRID or not
+
//-----------------------//
// Methods
//-----------------------//
+ inline void checkGridFillCoords() const;
+ inline void checkGridFillConnectivity() const;
+ // if this->_isAGrid, assure that _coordinate and _connectivity are filled
+
public :
+ // Add your personnal driver line (step 2)
friend class MED_MESH_RDONLY_DRIVER;
friend class MED_MESH_WRONLY_DRIVER;
+ friend class MED_MED_RDONLY_DRIVER;
+ friend class MED_MED_WRONLY_DRIVER;
+ friend class MED_MED_RDWR_DRIVER;
+
+ friend class GIBI_MESH_RDONLY_DRIVER;
+ friend class GIBI_MESH_WRONLY_DRIVER;
+ friend class GIBI_MESH_RDWR_DRIVER;
+
void init();
MESH();
- MESH(const MESH &m);
+ MESH(MESH &m);
MESH & operator=(const MESH &m);
- MESH( driverTypes driverType, const string & fileName="",
- const string & meshName="");
+ MESH( driverTypes driverType, const string & fileName="",
+ const string & meshName="");
~MESH();
friend ostream & operator<<(ostream &os, MESH &my) ;
- int addDriver(driverTypes driverType,
- const string & fileName ="Default File Name.med",
- const string & driverName="Default Mesh Name");
+ int addDriver(driverTypes driverType,
+ const string & fileName ="Default File Name.med",
+ const string & driverName="Default Mesh Name");
int addDriver(GENDRIVER & driver);
void rmDriver(int index=0);
- inline void read(int index=0);
+ void read(int index=0);
+ inline void read(const MED_MED_DRIVER & genDriver);
inline void write(int index=0, const string & driverName = "");
- inline void write(const GENDRIVER &);
-
- inline int * getMEDArrayNodeFamily() ;
- inline int ** getMEDArrayCellFamily() ;
- inline int ** getMEDArrayFaceFamily() ;
- inline int ** getMEDArrayEdgeFamily() ;
+ inline void write(const MED_MED_DRIVER & genDriver);
// void calculateReverseConnectivity();
// void createFaces(); //Faces creation => full constituent informations
inline void setName(string name);
inline string getName() const;
- inline int getSpaceDimension();
- inline int getMeshDimension();
-
- inline int getNumberOfNodes();
- inline COORDINATE * getCoordinateptr();
- inline string getCoordinatesSystem();
- inline const double * getCoordinates(medModeSwitch Mode);
- inline const double getCoordinate(int Number,int Axis);
- inline string * getCoordinatesNames();
- inline string * getCoordinatesUnits();
+ inline int getSpaceDimension() const ;
+ inline int getMeshDimension() const ;
+ inline bool getIsAGrid();
+
+ inline int getNumberOfNodes() const ;
+ inline const COORDINATE * getCoordinateptr() const ;
+ inline string getCoordinatesSystem() const ;
+ inline const double * getCoordinates(medModeSwitch Mode) const ;
+ inline const double getCoordinate(int Number,int Axis) const ;
+ inline const string * getCoordinatesNames() const ;
+ inline const string * getCoordinatesUnits() const ;
// inline int * getNodesNumbers();
- inline int getNumberOfTypes(medEntityMesh Entity);
- inline medGeometryElement * getTypes(medEntityMesh Entity);
- inline CELLMODEL * getCellsTypes(medEntityMesh Entity);
- inline int * getGlobalNumberingIndex(medEntityMesh Entity);
- inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type);
- inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity);
- inline medGeometryElement getElementType(medEntityMesh Entity,int Number) ;
- inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity);
- inline int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type);
- inline int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity);
- int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) ;
- inline int * getReverseConnectivity(medConnectivity ConnectivityType);
- inline int * getReverseConnectivityIndex(medConnectivity ConnectivityType);
-
- inline int getNumberOfFamilies(medEntityMesh Entity);
- inline vector<FAMILY*> getFamilies(medEntityMesh Entity);
- inline FAMILY* getFamily(medEntityMesh Entity,int i);
- inline int getNumberOfGroups(medEntityMesh Entity);
- inline vector<GROUP*> getGroups(medEntityMesh Entity);
- inline GROUP* getGroup(medEntityMesh Entity,int i);
-
-
+ inline int getNumberOfTypes(medEntityMesh Entity) const ;
+ inline const medGeometryElement * getTypes(medEntityMesh Entity) const ;
+ inline const CELLMODEL * getCellsTypes(medEntityMesh Entity) const ;
+ inline const int * getGlobalNumberingIndex(medEntityMesh Entity) const ;
+ inline int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type) const ;
+ inline bool existConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
+ inline medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
+ inline void calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity) ;
+ inline const int * getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh Entity, medGeometryElement Type) const ;
+ inline const int * getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity) const ;
+ int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const ;
+ inline const int * getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
+ inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity=MED_CELL) const ;
+
+ inline int getNumberOfFamilies(medEntityMesh Entity) const ;
+ inline const vector<FAMILY*> getFamilies(medEntityMesh Entity) const ;
+ inline const FAMILY* getFamily(medEntityMesh Entity,int i) const ;
+ inline int getNumberOfGroups(medEntityMesh Entity) const ;
+ inline const vector<GROUP*> getGroups(medEntityMesh Entity) const ;
+ inline const GROUP* getGroup(medEntityMesh Entity,int i) const ;
+ inline const CONNECTIVITY* getConnectivityptr() const ;
SUPPORT * getBoundaryElements(medEntityMesh Entity) throw (MEDEXCEPTION) ;
+ //SUPPORT * getBoundaryElements(medEntityMesh Entity) const throw (MEDEXCEPTION) ; // problème avec le maillage dans le support : le pointeur n'est pas const, mais sa valeur oui. A voir !!! PG
+
+ SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION) ;
// Node DonneBarycentre(const Cell &m) const;
- FIELD<double>* getVolume(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 3D elements
- FIELD<double>* getArea(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements
- FIELD<double>* getLength(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 1D elements
- FIELD<double>* getNormal(const SUPPORT * Support) throw (MEDEXCEPTION) ; // Support must be on 2D elements
- FIELD<double>* getBarycenter(const SUPPORT * Support) throw (MEDEXCEPTION) ;
- // FIELD<int>* getNeighbourhood(SUPPORT * Support) throw (MEDEXCEPTION) ; // Il faut preciser !
+ FIELD<double>* getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 3D elements
+ FIELD<double>* getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
+ FIELD<double>* getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 1D elements
+ FIELD<double>* getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) ; // Support must be on 2D elements
+ FIELD<double>* getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) ;
+ // FIELD<int>* getNeighbourhood(SUPPORT * Support) const throw (MEDEXCEPTION) ; // Il faut preciser !
};
// ---------------------------------------
// Methodes Inline
// ---------------------------------------
-inline void MESH::read(int index=0)
-{
- const char * LOC = "MESH::read(int index=0) : ";
- BEGIN_OF(LOC);
-
- if (_drivers[index]) {
- _drivers[index]->open();
- _drivers[index]->read();
- _drivers[index]->close();
- }
- else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
- )
- );
- END_OF(LOC);
-}
+inline const CONNECTIVITY* MESH::getConnectivityptr() const
+{
+ return _connectivity;
+}
+
+// inline void MESH::read(int index/*=0*/)
+// {
+// const char * LOC = "MESH::read(int index=0) : ";
+// BEGIN_OF(LOC);
+
+// if (_drivers[index]) {
+// _drivers[index]->open();
+// _drivers[index]->read();
+// _drivers[index]->close();
+// }
+// else
+// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+// << "The index given is invalid, index must be between 0 and |"
+// << _drivers.size()
+// )
+// );
+// END_OF(LOC);
+// }
/*! Write all the content of the MESH using driver referenced by the handler <index>*/
-inline void MESH::write(int index=0, const string & driverName = "")
-{
+inline void MESH::write(int index/*=0*/, const string & driverName/* = ""*/)
+{
const char * LOC = "MESH::write(int index=0, const string & driverName = \"\") : ";
BEGIN_OF(LOC);
if ( _drivers[index] ) {
- _drivers[index]->open();
- if (driverName != "") _drivers[index]->setMeshName(driverName);
- _drivers[index]->write();
- _drivers[index]->close();
+ _drivers[index]->open();
+ if (driverName != "") _drivers[index]->setMeshName(driverName);
+ _drivers[index]->write();
+ _drivers[index]->close();
}
else
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "The index given is invalid, index must be between 0 and |"
- << _drivers.size()
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
+ << "The index given is invalid, index must be between 0 and |"
+ << _drivers.size()
)
- );
+ );
+ END_OF(LOC);
+}
+
+// This method is MED specific : don't use it
+// must be private.
+inline void MESH::write(const MED_MED_DRIVER & genDriver)
+{
+ const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): ";
+ BEGIN_OF(LOC);
+
+ for (int index=0; index < _drivers.size(); index++ )
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->write();
+ _drivers[index]->close();
+ // ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
+ }
+
END_OF(LOC);
-}
-// This method is MED specific : don't use it
-// must be private.
-inline void MESH::write(const GENDRIVER & genDriver)
-{
- const char * LOC = "MESH::write(const GENDRIVER & genDriver): ";
+}
+
+// This method is MED specific : don't use it
+// must be private.
+inline void MESH::read(const MED_MED_DRIVER & genDriver)
+{
+ const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): ";
BEGIN_OF(LOC);
for (int index=0; index < _drivers.size(); index++ )
- if ( *_drivers[index] == genDriver ) {
- _drivers[index]->open();
- _drivers[index]->write();
+ if ( *_drivers[index] == genDriver ) {
+ _drivers[index]->open();
+ _drivers[index]->read();
_drivers[index]->close();
// ? FINALEMENT PAS BESOIN DE L'EXCEPTION ?
}
-
+
END_OF(LOC);
-
-}
+
+}
/*! Set the MESH name */
-inline void MESH::setName(string name)
+inline void MESH::setName(string name)
{
_name=name ; //NOM interne à la classe
}
/*! Get the MESH name */
-inline string MESH::getName() const
+inline string MESH::getName() const
{
return _name ;
}
/*! Get the dimension of the space */
-inline int MESH::getSpaceDimension()
+inline int MESH::getSpaceDimension() const
{
return _spaceDimension;
}
/*! Get the dimension of the MESH */
-inline int MESH::getMeshDimension()
+inline int MESH::getMeshDimension() const
{
return _meshDimension;
}
/*! Get the number of nodes used in the MESH */
-inline int MESH::getNumberOfNodes()
+inline int MESH::getNumberOfNodes() const
{
return _numberOfNodes;
}
/*! Get the COORDINATES object. Use it only if you need COORDINATES informations not provided by the MESH class.*/
-inline COORDINATE * MESH::getCoordinateptr()
+inline const COORDINATE * MESH::getCoordinateptr() const
{
+ checkGridFillCoords();
return _coordinate;
}
/*! Get the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */
-inline string MESH::getCoordinatesSystem()
+inline string MESH::getCoordinatesSystem() const
{
return _coordinate->getCoordinatesSystem();
}
/*! Get the whole coordinates array in a given interlacing mode. The interlacing mode are :
- MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2
- - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2
+ - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2
*/
-inline const double * MESH::getCoordinates(medModeSwitch Mode)
+inline const double * MESH::getCoordinates(medModeSwitch Mode) const
{
+ checkGridFillCoords();
return _coordinate->getCoordinates(Mode);
}
/*! Get the coordinate n° number on axis n°axis*/
-inline const double MESH::getCoordinate(int number, int axis)
+inline const double MESH::getCoordinate(int number, int axis) const
{
+ checkGridFillCoords();
return _coordinate->getCoordinate(number,axis);
}
/*! Get the coordinate names array ("x ","y ","z ")
of size n*MED_TAILLE_PNOM
*/
-inline string * MESH::getCoordinatesNames()
+inline const string * MESH::getCoordinatesNames() const
{
return _coordinate->getCoordinatesNames();
}
/*! Get the coordinate unit names array ("cm ","cm ","cm ")
of size n*MED_TAILLE_PNOM
*/
-inline string * MESH::getCoordinatesUnits()
+inline const string * MESH::getCoordinatesUnits() const
{
return _coordinate->getCoordinatesUnits();
}
-// int * MESH::getNodesNumbers() {
+// int * MESH::getNodesNumbers() const
+// {
// return nodesNumbers;
// }
/*! Get the number of different geometric types for a given entity type.
- For exemple getNumberOfTypes(MED_CELL) would return 2 is the MESH have some MED_TETRA4 and MED_HEXA6 in it.
- medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES
+
+ For exemple getNumberOfTypes(MED_CELL) would return 3 is the MESH
+ have some MED_TETRA4, MED_PYRA5 and MED_HEXA6 in it.
+
+ medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_NODE, MED_ALL_ENTITIES
+
+ If entity is not defined, return 0.
+
+ If there is no connectivity, return an exception.
*/
-inline int MESH::getNumberOfTypes(medEntityMesh entity)
+inline int MESH::getNumberOfTypes(medEntityMesh entity) const
{
MESSAGE("MESH::getNumberOfTypes(medEntityMesh entity) : "<<entity);
if (entity == MED_NODE)
return 1 ;
+ checkGridFillConnectivity();
if (_connectivity != NULL)
return _connectivity->getNumberOfTypes(entity) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*!
+/*!
Get the list of geometric types used by a given entity.
medEntityMesh entity : MED_CELL, MED_FACE, MED_EDGE, MED_ALL_ENTITIES
- REM : Don't use MED_NODE
+
+ REM : Don't use MED_NODE
+
+ If entity is not defined, return an exception.
*/
-inline medGeometryElement * MESH::getTypes(medEntityMesh entity)
+inline const medGeometryElement * MESH::getTypes(medEntityMesh entity) const
{
if (entity == MED_NODE)
throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : No medGeometryElement with MED_NODE entity !"));
-
+ // return un tableau de taille 1 contenant MED_NONE, comme les supports pour etre coherent avec getNumberOfTypes ???? PG
+
+ checkGridFillConnectivity();
if (_connectivity != NULL)
return _connectivity->getGeometricTypes(entity) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*!
+/*!
Get the whole list of CELLMODEL used by cells of given type (medEntityMesh).
+
REMARK : Don't use MED_NODE as medEntityMesh
*/
-inline CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity)
+inline const CELLMODEL * MESH::getCellsTypes(medEntityMesh Entity) const
{
+ checkGridFillConnectivity();
if (_connectivity != NULL)
- return _connectivity->getCellsTypes(Entity) ;
+ return _connectivity->getCellsTypes(Entity) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getCellsTypes( medEntityMesh ) : Connectivity not defined !"));
}
-/*! Since informations related with an entity type are stored in independent arrays, the only way to
- get a uniq index is to call this method.
- For exemple if you want the global numbers of your ... ????? size ?????
+/*! Return an array of size NumbreOfTypes+1 which contains, for each
+ geometric type of the given entity, the first global element number
+ of this type.
+
+ For exemple, if we have a mesh with 5 triangles and 4 quadrangle :
+ - size of GlobalNumberingIndex is 3
+ - GlobalNumberingIndex[0]=1 (the first type)
+ - GlobalNumberingIndex[1]=6 (the second type)
+ - GlobalNumberingIndex[2]=10
*/
-inline int * MESH::getGlobalNumberingIndex(medEntityMesh entity)
+inline const int * MESH::getGlobalNumberingIndex(medEntityMesh entity) const
{
+ checkGridFillConnectivity();
if (_connectivity != NULL)
- return _connectivity->getGlobalNumberingIndex(entity);
+ return _connectivity->getGlobalNumberingIndex(entity);
throw MEDEXCEPTION(LOCALIZED("MESH::getNumberOfTypes( medEntityMesh ) : Connectivity not defined !"));
}
-inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type)
+/*!
+ Return the number of element of given geometric type of given entity. Return 0 if query is not defined.
+
+ Example :
+ - getNumberOfElements(MED_NODE,MED_NONE) : number of node
+ - getNumberOfElements(MED_NODE,MED_TRIA3) : return 0 (not defined)
+ - getNumberOfElements(MED_FACE,MED_TRIA3) : return number of triangles
+ elements defined in face entity (0 if not defined)
+ - getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) : return total number
+ of elements defined in cell entity
+ */
+inline int MESH::getNumberOfElements(medEntityMesh entity, medGeometryElement Type) const
{
const char * LOC = "MESH::getNumberOfElements(medEntityMesh,medGeometryElement) : " ;
if (entity==MED_NODE)
return _numberOfNodes ;
else
return 0 ;
- //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
- else
- if (_connectivity != (CONNECTIVITY*)NULL)
- return _connectivity->getNumberOf(entity,Type) ;
- else
- return 0 ;
+ //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"wrong medGeometryElement with MED_NODE"));
+ else
+ {
+ checkGridFillConnectivity();
+ if (_connectivity != (CONNECTIVITY*)NULL)
+ return _connectivity->getNumberOf(entity,Type) ;
+ else
+ return 0 ;
//throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"connectivity not defined !"));
+ }
}
-inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity)
+/*!
+ Return true if the wanted connectivity exist, else return false
+ (to use before a getSomething method).
+ */
+inline bool MESH::existConnectivity(medConnectivity connectivityType, medEntityMesh entity) const
{
+ checkGridFillConnectivity();
if (_connectivity==(CONNECTIVITY*)NULL)
throw MEDEXCEPTION("MESH::existConnectivity(medConnectivity,medEntityMesh) : no connectivity defined !");
return _connectivity->existConnectivity(connectivityType,entity) ;
}
/*!
- Return the geometric type of element Number of entity Entity.
+ Return the geometric type of global element Number of entity Entity.
Throw an exception if Entity is not defined or Number are wrong (too big).
*/
-inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number)
+inline medGeometryElement MESH::getElementType(medEntityMesh Entity,int Number) const
{
+ checkGridFillConnectivity();
if (_connectivity==(CONNECTIVITY*)NULL)
throw MEDEXCEPTION("MESH::getElementType(medEntityMesh,int) : no connectivity defined !");
return _connectivity->getElementType(Entity,Number) ;
}
+/*!
+ Calculate the ask connectivity. Return an exception if this could not be
+ done. Do nothing if connectivity already exist.
+ */
+
inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity)
{
+ checkGridFillConnectivity();
if (Mode==MED_FULL_INTERLACE)
_connectivity->calculateConnectivity(ConnectivityType,entity) ;
else
throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode"));
}
-inline int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type)
+/*!
+ Return the required connectivity in the right mode for the given
+ geometric type of the given entity.
+
+ To get connectivity for all geometric type, use Mode=MED_FULL_INTERLACE
+ and Type=MED_ALL_ELEMENTS.
+ You must also get the corresponding index array.
+ */
+inline const int * MESH::getConnectivity(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const
{
+ checkGridFillConnectivity();
if (Mode==MED_FULL_INTERLACE)
return _connectivity->getConnectivity(ConnectivityType,entity,Type) ;
throw MEDEXCEPTION(LOCALIZED("MESH::getConnectivity : only for MED_FULL_INTERLACE mode"));
}
-inline int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity)
+/*!
+ Return the required index array for a connectivity received in
+ MED_FULL_ENTERLACE mode and MED_ALL_ELEMENTS type.
+
+ This array allow to find connectivity of each elements.
+
+ Example : Connectivity of i^{th} elements (1<=i<=NumberOfElement) begin
+ at index ConnectivityIndex[i-1] and end at index ConnectivityIndex[i]-1
+ in Connectivity array (Connectivity[ConnectivityIndex[i-1]-1] is the
+ first value)
+ */
+inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh entity) const
{
+ checkGridFillConnectivity();
return _connectivity->getConnectivityIndex(ConnectivityType, entity) ;
}
-inline int * MESH::getReverseConnectivity(medConnectivity ConnectivityType)
+/*!
+ Return the reverse connectivity required by ConnectivityType :
+ - If ConnectivityType=MED_NODAL : return connectivity node-cell
+ - If ConnectivityType=MED_DESCENDING : return connectivity face-cell
+
+ You must get ReverseConnectivityIndex array to use it.
+ */
+inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
{
- if (ConnectivityType==MED_NODAL)
- return _connectivity->getReverseNodalConnectivity() ;
- else if (ConnectivityType==MED_DESCENDING)
- return _connectivity->getReverseDescendingConnectivity() ;
- throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !");
+ checkGridFillConnectivity();
+ if (NULL==_connectivity)
+ throw MEDEXCEPTION("MESH::getReverseConnectivity : no connectivity defined in MESH !");
+
+ return _connectivity->getReverseConnectivity(ConnectivityType,Entity) ;
}
-inline int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType)
+/*!
+ Return the index array required by ConnectivityType.
+
+ This array allow to find reverse connectivity of each elements.
+
+ Example : Reverse connectivity of i^{th} elements (1<=i<=NumberOfElement)
+ begin at index ReverseConnectivityIndex[i-1] and end at index
+ ReverseConnectivityIndex[i]-1
+ in ReverseConnectivity array (
+ ReverseConnectivity[ReverseConnectivityIndex[i-1]-1]
+ is the first value)
+ */
+inline const int * MESH::getReverseConnectivityIndex(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const
{
- if (ConnectivityType==MED_NODAL)
- return _connectivity->getReverseNodalConnectivityIndex() ;
- else if (ConnectivityType==MED_DESCENDING)
- return _connectivity->getReverseDescendingConnectivityIndex() ;
- throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !");
+ checkGridFillConnectivity();
+ if (NULL==_connectivity)
+ throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : no connectivity defined in MESH !");
+
+ return _connectivity->getReverseConnectivityIndex(ConnectivityType,Entity) ;
}
-inline int MESH::getNumberOfFamilies (medEntityMesh entity)
+inline int MESH::getNumberOfFamilies (medEntityMesh entity) const
{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _numberOfNodesFamilies ;
- case MED_CELL :
+ case MED_CELL :
return _numberOfCellsFamilies ;
case MED_FACE :
return _numberOfFacesFamilies ;
throw MEDEXCEPTION("MESH::getNumberOfFamilies : Unknown entity");
}
}
-inline int MESH::getNumberOfGroups (medEntityMesh entity)
+inline int MESH::getNumberOfGroups (medEntityMesh entity) const
{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _numberOfNodesGroups ;
- case MED_CELL :
+ case MED_CELL :
return _numberOfCellsGroups ;
case MED_FACE :
return _numberOfFacesGroups ;
throw MEDEXCEPTION("MESH::getNumberOfGroups : Unknown entity");
}
}
-vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) {
+const vector<FAMILY*> MESH::getFamilies(medEntityMesh entity) const
+{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _familyNode ;
- case MED_CELL :
+ case MED_CELL :
return _familyCell ;
case MED_FACE :
return _familyFace ;
}
}
-vector<GROUP*> MESH::getGroups(medEntityMesh entity) {
+const vector<GROUP*> MESH::getGroups(medEntityMesh entity) const
+{
switch (entity) {
- case MED_NODE :
+ case MED_NODE :
return _groupNode ;
- case MED_CELL :
+ case MED_CELL :
return _groupCell ;
case MED_FACE :
return _groupFace ;
}
}
-FAMILY* MESH::getFamily(medEntityMesh entity, int i) {
- if (i<=0)
+const FAMILY* MESH::getFamily(medEntityMesh entity, int i) const
+{
+ if (i<=0)
throw MEDEXCEPTION("MESH::getFamily(i) : argument i must be > 0");
int NumberOfFamilies = 0 ;
vector<FAMILY*> Family ;
default :
throw MEDEXCEPTION("MESH::getFamilies : Unknown entity");
}
- if (i>NumberOfFamilies)
+ if (i>NumberOfFamilies)
throw MEDEXCEPTION("MESH::getFamily(entity,i) : argument i must be <= _numberOfFamilies");
- return Family[i-1];
+ return Family[i-1];
}
-GROUP* MESH::getGroup(medEntityMesh entity, int i) {
+const GROUP* MESH::getGroup(medEntityMesh entity, int i) const
+{
const char * LOC = "MESH::getGroup(medEntityMesh entity, int i) : " ;
- if (i<=0)
+ if (i<=0)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i must be > 0"));
int NumberOfGroups = 0 ;
vector<GROUP*> Group ;
default :
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Unknown entity"));
}
- if (i>NumberOfGroups)
+ if (i>NumberOfGroups)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"argument i="<<i<<" must be <= _numberOfGroups="<<NumberOfGroups));
- return Group[i-1];
+ return Group[i-1];
}
// return ;
// }
-//inline void MESH::write(const string & driverName) {
+//inline void MESH::write(const string & driverName) {
// write(0,driverName);
//}
-
-// this method are temporary, perhaps we remove it if we put information in an other place
-inline int * MESH::getMEDArrayNodeFamily() {
- return _MEDArrayNodeFamily ;
-}
-inline int ** MESH::getMEDArrayCellFamily() {
- return _MEDArrayCellFamily ;
-}
-inline int ** MESH::getMEDArrayFaceFamily() {
- return _MEDArrayFaceFamily ;
-}
-inline int ** MESH::getMEDArrayEdgeFamily() {
- return _MEDArrayEdgeFamily ;
+inline bool MESH::getIsAGrid()
+{
+ return _isAGrid;
}
#endif /* MESH_HXX */
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_Meshing.cxx
+// Module : MED
+
+using namespace std;
+/*
+ File MEDMEM_Meshing.cxx
+ $Header$
+*/
+
+#include <string>
+
+#include "utilities.h"
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Meshing.hxx"
+#include "MEDMEM_Group.hxx"
+
+/*! Create an empty MESH. */
+MESHING::MESHING(): MESH()
+{
+ MESSAGE("MESHING::MESHING()");
+ SCRUTE(_coordinate);
+ SCRUTE(_connectivity);
+}
+
+MESHING::~MESHING()
+{
+ MESSAGE("Deletinh MESHING !!");
+}
+
+/*! Set the dimension of the space */
+void MESHING::setSpaceDimension(const int SpaceDimension)
+{
+ _spaceDimension = SpaceDimension ;
+}
+
+/* Set the dimension of the MESHING */
+// void MESHING::setMeshDimension(const int MeshDimension)
+// {
+// _meshDimension = MeshDimension ;
+// }
+
+/*! Set the number of nodes used in the MESH */
+void MESHING::setNumberOfNodes(const int NumberOfNodes)
+{
+ _numberOfNodes = NumberOfNodes ;
+}
+
+/*!
+ Set the whole coordinates array in a given system and interlacing mode.
+ The system coordinates are :
+ - "CARTESIAN"
+ - "CYLINDRICAL"
+ - "SPHERICAL"
+ The interlacing mode are :
+ - MED_NO_INTERLACE : X1 X2 Y1 Y2 Z1 Z2
+ - MED_FULL_INTERLACE : X1 Y1 Z1 X2 Y2 Z2
+*/
+void MESHING::setCoordinates(const int SpaceDimension,
+ const int NumberOfNodes,
+ const double * Coordinates,
+ const string System,
+ const medModeSwitch Mode)
+{
+ setSpaceDimension(SpaceDimension);
+ setNumberOfNodes(NumberOfNodes);
+
+ SCRUTE(_coordinate);
+ SCRUTE(_connectivity);
+ //if (NULL != _coordinate) delete _coordinate;
+
+ _coordinate = new COORDINATE(SpaceDimension,
+ NumberOfNodes,
+ Mode);
+ _coordinate->setCoordinates(Mode,Coordinates);
+ _coordinate->setCoordinatesSystem(System);
+}
+
+/*! Set the system in which coordinates are given (CARTESIAN,CYLINDRICAL,SPHERICAL) __??MED_CART??__. */
+void MESHING::setCoordinatesSystem(const string System)
+ throw (MEDEXCEPTION)
+{
+ if (NULL == _coordinate)
+ throw MEDEXCEPTION(LOCALIZED("MESHING::setCoordinatesSystem : no coordinates defined"));
+ _coordinate->setCoordinatesSystem(System);
+}
+
+/*! Set the coordinate names array ("x ","y ","z ")
+ of size n*MED_TAILLE_PNOM
+*/
+void MESHING::setCoordinatesNames(const string * name)
+{
+// int SpaceDimension = getSpaceDimension() ;
+// _coordinate->setCoordinatesNames(SpaceDimension,name);
+ _coordinate->setCoordinatesNames(name);
+}
+
+/*!
+ Set the (i+1)^th component of coordinate names array
+ ("x ","y ","z ") of size n*MED_TAILLE_PNOM
+*/
+void MESHING::setCoordinateName(const string name, const int i)
+{
+ _coordinate->setCoordinateName(name,i);
+}
+
+/*! Set the coordinate unit names array ("cm ","cm ","cm ")
+ of size n*MED_TAILLE_PNOM
+*/
+void MESHING::setCoordinatesUnits(const string * units)
+{
+// int SpaceDimension = getSpaceDimension() ;
+// _coordinate->setCoordinatesUnits(SpaceDimension,units);
+ _coordinate->setCoordinatesUnits(units);
+}
+
+/*!
+ Set the (i+1)^th component of the coordinate unit names array
+ ("cm ","cm ","cm ") of size n*MED_TAILLE_PNOM
+*/
+void MESHING::setCoordinateUnit(const string unit, const int i)
+{
+ _coordinate->setCoordinateUnit(unit,i);
+}
+
+/*!
+ Create a new connectivity object with the given number of type and
+ entity. If a connectivity already exist, delete it !
+
+ For exemple setNumberOfTypes(3,MED_CELL) create a connectivity with 3
+ medGeometryElement in MESH for MED_CELL entity (like MED_TETRA4,
+ MED_PYRA5 and MED_HEXA6 for example).
+
+ Return an exception if could not create the connectivity (as if we set
+ MED_FACE connectivity before MED_CELL).
+*/
+void MESHING::setNumberOfTypes(const int NumberOfTypes,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESHING::setNumberOfTypes( medEntityMesh ) : ";
+
+ // No defined for MED_NODE !
+ if (Entity == MED_NODE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not required with MED_NODE !"));
+
+ if (MED_CELL == Entity) {
+ SCRUTE(_connectivity);
+// if (_connectivity != (CONNECTIVITY *) NULL)
+// delete _connectivity ;
+ _connectivity = new CONNECTIVITY(NumberOfTypes,Entity) ;
+
+ } else {
+
+ if (_connectivity == NULL) // we must have defined MED_CELL connectivity
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_CELL defined !"));
+
+ if (MED_FACE == Entity)
+ if (3 != getSpaceDimension())
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_FACE could be defined in non 3D space !"));
+
+ if (MED_EDGE == Entity)
+ if (3 == getSpaceDimension()) {
+ if (!_connectivity->existConnectivity(MED_NODAL,MED_FACE))
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity on MED_FACE defined !"));
+ } else {
+ if (2 != getSpaceDimension())
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Could not set connectivity on MED_EDGE !"));
+ }
+ // all rigth, we could create connectivity !
+ CONNECTIVITY * myConnectivity = new CONNECTIVITY(NumberOfTypes,Entity) ;
+ _connectivity->setConstituent(myConnectivity);
+ }
+}
+
+/*!
+ Set the list of geometric types used by a given entity.
+ medEntityMesh entity could be : MED_CELL, MED_FACE, MED_EDGE
+
+ REM : Don't use MED_NODE and MED_ALL_ENTITIES
+
+ If entity is not defined, throw an exception.
+*/
+void MESHING::setTypes(const medGeometryElement * Types,
+ const medEntityMesh entity)
+ throw (MEDEXCEPTION)
+{
+ if (entity == MED_NODE)
+ throw MEDEXCEPTION(LOCALIZED("MESHING::setTypes : Not defined with MED_NODE entity !"));
+
+ if (_connectivity == NULL)
+ throw MEDEXCEPTION(LOCALIZED("MESHING::setTypes : No connectivity defined !"));
+
+ _connectivity->setGeometricTypes(Types,entity) ;
+}
+
+/*!
+ Set the number of elements for each geometric type of given entity.
+
+ Example : setNumberOfElements({12,23},MED_FACE)
+ if we have two type of face (MED_TRIA3 and MED_QUAD4),
+ we set 12 triangles and 23 quadrangles.
+*/
+void MESHING::setNumberOfElements(const int * NumberOfElements,
+ medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESHING::setNumberOfElements(const int *, medEntityMesh) : " ;
+
+ if (Entity==MED_NODE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined with MED_NODE entity !"));
+
+ if (_connectivity == (CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity defined !"));
+
+ int NumberOfTypes = getNumberOfTypes(Entity) ;
+ int * Count = new int[NumberOfTypes+1] ;
+ Count[0]=1 ;
+ for (int i=0; i<NumberOfTypes; i++)
+ Count[i+1]=Count[i]+NumberOfElements[i] ;
+ _connectivity->setCount(Count,Entity) ;
+ delete[] Count ;
+}
+
+/*!
+ Set the nodal connectivity for one geometric type of the given entity.
+
+ Example : setConnectivity({1,2,3,1,4,2},MED_FACE,MED_TRIA3)
+ Define 2 triangles face defined with nodes 1,2,3 and 1,4,2.
+*/
+void MESHING::setConnectivity(const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESHING::setConnectivity : " ;
+
+ if (Entity==MED_NODE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined with MED_NODE entity !"));
+
+ if (_connectivity == (CONNECTIVITY*)NULL)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No connectivity defined !"));
+
+ _connectivity->setNodal(Connectivity,Entity,Type) ;
+}
+
+/*!
+ NOT YET IMPLEMENTED !! WARNING
+*/
+void MESHING::setConnectivities (const int * ConnectivityIndex,
+ const int * ConnectivityValue,
+ const medConnectivity ConnectivityType,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESHING::setConnectivities : " ;
+
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not Yet Implemented :: Warning !"));
+}
+
+/*!
+*/
+
+// void MESHING::setGroup(const string name,
+// const string description,
+// const int NumberOfElements,
+// const int * ElementsNumbers,
+// const medEntityMesh Entity)
+// {
+// GROUP * myGroup = new GROUP() ;
+// myGroup->setMesh(*this) ;
+// myGroup->setName(name) ;
+// myGroup->setDescription(description) ;
+// myGroup->setEntity(Entity) ;
+// // medEntityMesh and medGeometryElement ???
+// myGroup->setNumberOfGeometricType(NumberOfType) ;
+// myGroup->setGeometricType(Type) ;
+// myGroup->setNumberOfGaussPoint(NumberOfGaussPoint) ;
+// myGroup->setNumberOfElements(NumberOfElements) ;
+// myGroup->setNumber(Number) ;
+// }
+
+void MESHING::addGroup(const GROUP & Group)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "MESHING::addGroup : " ;
+
+ GROUP * myGroup = new GROUP(Group) ;
+ switch(Group.getEntity()){
+ case MED_CELL : {
+ _groupCell.push_back(myGroup);
+ _numberOfCellsGroups++;
+ break;
+ }
+ case MED_FACE : {
+ _groupFace.push_back(myGroup);
+ _numberOfFacesGroups++;
+ break;
+ }
+ case MED_EDGE : {
+ _groupEdge.push_back(myGroup);
+ _numberOfEdgesGroups++;
+ break;
+ }
+ case MED_NODE : {
+ _groupNode.push_back(myGroup);
+ _numberOfNodesGroups++;
+ break;
+ }
+ default :
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Entity !"));
+ }
+}
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_Meshing.hxx
+// Module : MED
+
+/*
+ File MEDMEM_Meshing.hxx
+ $Header$
+*/
+
+#ifndef MESHING_HXX
+#define MESHING_HXX
+
+#include "MEDMEM_Mesh.hxx"
+
+using namespace MED_EN;
+
+/*!
+ This class MESHING is a special class to set a MESH object.
+*/
+
+class MESHING: public MESH
+{
+public :
+ MESHING();
+ ~MESHING();
+
+ void setSpaceDimension (const int SpaceDimension) ;
+ //void setMeshDimension (const int MeshDimension) ;
+ void setNumberOfNodes (const int NumberOfNodes) ;
+ void setCoordinates (const int SpaceDimension,
+ const int NumberOfNodes,
+ const double * Coordinates,
+ const string System,
+ const medModeSwitch Mode) ;
+ void setCoordinatesSystem(const string System)
+ throw (MEDEXCEPTION) ;
+ void setCoordinatesNames (const string * names) ;
+ void setCoordinateName (const string name, const int i) ;
+ void setCoordinatesUnits (const string * units) ;
+ void setCoordinateUnit (const string unit, const int i) ;
+
+ void setNumberOfTypes (const int NumberOfTypes,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION) ;
+ void setTypes (const medGeometryElement * Types,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION) ;
+ void setNumberOfElements (const int * NumberOfElements,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION) ;
+ void setConnectivity (const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type)
+ throw (MEDEXCEPTION) ;
+
+ void setConnectivities (const int * ConnectivityIndex,
+ const int * ConnectivityValue,
+ const medConnectivity ConnectivityType,
+ const medEntityMesh Entity)
+ throw (MEDEXCEPTION) ;
+
+// void setGroup (const string name,
+// const string description,
+// const int NumberOfElements,
+// const int * ElementsNumbers,
+// const medEntityMesh Entity) ;
+ void addGroup (const GROUP & Group)
+ throw (MEDEXCEPTION) ;
+};
+
+#endif /* MESHING_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_ModulusArray.hxx
+// Module : MED
+
#ifndef __MEDMODULUSARRAY_H__
#define __MEDMODULUSARRAY_H__
class MEDMODULUSARRAY {
private:
int _length ;
- int * _array ;
+ const int * _array ;
public:
- MEDMODULUSARRAY(int length, int * array) ;
+ MEDMODULUSARRAY(int length, const int * array) ;
~MEDMODULUSARRAY() ;
- int & operator[](const int &i) const ;
+ const int & operator[](const int &i) const ;
int compare(const MEDMODULUSARRAY &modulusArray) const;
};
-MEDMODULUSARRAY::MEDMODULUSARRAY(int length, int * array) :
+MEDMODULUSARRAY::MEDMODULUSARRAY(int length, const int * array) :
_length(length), _array(array)
{
- // MESSAGE("MEDMODULUSARRAY::MEDMODULUSARRAY("<<length<<", "<<array<<")") ;
+// SCRUTE(_length);
+// for (int i=0;i<_length;i++){
+// MESSAGE("MEDMODULUSARRAY["<<i<<"]="<<_array[i]);
+// }
};
MEDMODULUSARRAY::~MEDMODULUSARRAY()
};
-int & MEDMODULUSARRAY::operator[](const int &i) const
+const int & MEDMODULUSARRAY::operator[](const int &i) const
{
int position = i%_length ;
if (position<0)
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_PointerOf.hxx
+// Module : MED
+
# if ! defined( __PointerOf_HXX__ )
# define __PointerOf_HXX__
#include <cstdlib>
#include "utilities.h"
+#include "MEDMEM_Exception.hxx"
/*!
The template class PointerOf embedding a standard pointer (_pointer) is in charge of
- managing a the pointed memory.
+ managing the pointed memory.\n
+
+ the object PointerOf is the memory owner if a size is given at object construction.
+ In these cases, memory will be desallocated at object destruction. In all other cases,
+ the desallocator will only nullify pointers.
*/
template <typename T> class PointerOf
{
protected :
+ /*! pointer to the pointed memory */
T* _pointer ;
+ /*! boolean setted to true if memory has to be desallocated */
bool _done ;
+
public :
- PointerOf() ; //
+ PointerOf() ;
+ ~PointerOf() ;
PointerOf( const int &size ) ;
PointerOf( const T *pointer ) ;
- ~PointerOf() ;
- operator T*() ;
+ PointerOf( const int &size, const T *pointer ) ;
+ PointerOf( const PointerOf<T> & pointerOf ) ;
+ PointerOf( const int &size, const PointerOf<T> & pointerOf ) ;
+ operator T*() ;
operator const T*() const ;
-
- //operator T*() const ;
-
void set( const int &size ) ;
void set( const T *pointer ) ;
+ void set( const int &size, const T *pointer ) ;
PointerOf<T>& operator=( const PointerOf<T> &pointer ) ;
} ;
-template <typename T> PointerOf<T>& PointerOf<T>::operator=( const PointerOf<T> &pointer )
+// ------------------------------------------------------------ //
+// //
+// Implementation //
+// //
+// ------------------------------------------------------------ //
+
+
+/*! Creates a null T* pointer and sets the boolean (for desallocation) to false. */
+template <typename T> PointerOf<T>::PointerOf() : _pointer(0), _done(false)
{
- BEGIN_OF("PointerOf<T>::operator=( const PointerOf<T> &pointer )") ;
- if ( &pointer != this )
- {
- this->set( pointer._pointer ) ;
- }
- END_OF("PointerOf<T>::operator=( const PointerOf<T> &pointer )") ;
- return *this ;
}
-template <typename T> PointerOf<T>::PointerOf() : _pointer(0), _done(false)
+/*! Creates a standard T* pointer to the pointed memory. \n
+ The boolean for desallocation is setted to false. \n
+ Be aware : \n
+ - The "old" PointerOf always has propriety of the pointed memory. \n
+ - If the "old" PointerOf is detroyed, the "new" PointerOf points
+ a desallocated memory zone. */
+template <typename T> PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf) : _done(false),
+ _pointer((T*)(const T* const)pointerOf)
{
+ BEGIN_OF("PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf)");
+ MESSAGE("Warning ! No Propriety Transfer");
+ END_OF ("PointerOf<T>::PointerOf(const PointerOf<T> & pointerOf)");
}
-template <typename T> PointerOf<T>::PointerOf( const int &size ) : _pointer( new T[ size ]), _done(true)
+/*!
+ Duplicate array of size size pointed in pointerOf.
+*/
+template <typename T> PointerOf<T>::PointerOf( const int &size, const PointerOf<T> & pointerOf) :
+ _pointer((size,(T*)pointerOf))
+{
+}
+
+/*! If size <= 0, creates a null "T*" pointer\n
+ Else allocates memory and sets desallocation boolean to true./n
+ Memory will be desallocated when erasing this PointerOf*/
+template <typename T> PointerOf<T>::PointerOf( const int &size )
{
+ if (size <= 0)
+ {
+ _pointer=(T*)NULL;
+ _done=false;
+ }
+ else
+ {
+ _pointer = new T[ size ] ;
+ _done=true;
+ }
}
+/*! Creates a standard pointer to the memory zone pointed by T*. /n
+ T* owner is in charged of memory desallocation. /n
+ Memory will not be released when erasing this PointerOf*/
template <typename T> PointerOf<T>::PointerOf( const T* pointer ) : _pointer( (T*)pointer ), _done(false)
{
}
+/*! If size <= 0, return an exception\n
+ Else duplicate array and sets desallocation boolean to true./n
+ Memory will be desallocated when erasing this PointerOf*/
+template <typename T> PointerOf<T>::PointerOf( const int &size, const T* pointer)
+{
+ if (size <= 0)
+ throw MEDEXCEPTION("PointerOf( const int,const T*) : array size <= 0");
+
+ _pointer = new T[ size ] ;
+ memcpy(_pointer,pointer,size*sizeof(T));
+ _done=true;
+}
+
+/*! The destuctor desallocates memory if necessary (that is if the attribute _done equals true).\n
+ The attribute _pointer is nullified */
template <typename T> PointerOf<T>::~PointerOf()
{
if ( _pointer )
}
}
+/*! Creates a standard pointer (T*) to the pointed memory. \n
+ The boolean for desallocation is setted to false. \n
+ Be aware : \n
+ - The "right" PointerOf always has propriety of the pointed memory. \n
+ - If the "right" PointerOf is detroyed, the "left" PointerOf points
+ a desallocated memory zone.
+ - it works the same way as PointerOf(const PointerOf<T> & pointerOf) */
+template <typename T> PointerOf<T>& PointerOf<T>::operator=( const PointerOf<T> &pointer )
+{
+ BEGIN_OF("PointerOf<T>::operator=( const PointerOf<T> &pointer )") ;
+ if ( &pointer != this )
+ {
+ this->set( pointer._pointer ) ;
+ }
+ END_OF("PointerOf<T>::operator=( const PointerOf<T> &pointer )") ;
+ return *this ;
+}
+
+/*! Returns _pointer.*/
template <typename T> PointerOf<T>::operator T*()
{
return _pointer ;
}
+
+/*! Returns _pointer.*/
template <typename T> PointerOf<T>::operator const T*() const
{
return _pointer ;
}
-// template <typename T> PointerOf<T>::operator T*() const
-// {
-// return _pointer ;
-// }
+/*! If necessary, released memory holded by PointerOf/n.
+ Else allocates memory and sets desallocation boolean to true./n
+ Can be used in order to "nullify" an existing PointerOf/n
+ Memory will be desallocated when erasing this PointerOf*/
template <typename T> void PointerOf<T>::set( const int &size )
{
- ASSERT(size>0) ;
if ( _pointer && _done )
{
- delete [] _pointer ;
+ delete [] _pointer ;
_pointer=0 ;
}
- _pointer = new T[ size ] ;
+ if (size <= 0)
+ {
+ _pointer=(T*)NULL;
+ }
+ else
+ {
+ _pointer = new T[ size ] ;
+ }
_done = true ;
return ;
}
+
+/*! If necessary, released memory holded by PointerOf/n.
+ Then, sets _pointer to the memory zone pointed by T*. /n
+ T* owner is in charged of memory desallocation. /n
+ memory will not be released when erasing this PointerOf*/
template <typename T> void PointerOf<T>::set( const T *pointer )
{
- MESSAGE( "PointerOf<T>::set( const T *pointer )" ) ;
+ MESSAGE( "BEGIN PointerOf<T>::set( const T *pointer )" ) ;
SCRUTE(pointer) ;
SCRUTE(_done) ;
if ( _pointer && _done )
{
MESSAGE("PointerOf<T>::set --> deleting _pointer") ;
- delete [] _pointer ;
+ delete [] _pointer ;
_pointer=0 ;
_done=false ;
}
_pointer=(T*)pointer ;
_done=false ;
- MESSAGE( "PointerOf<T>::set( const T *pointer )" ) ;
+ MESSAGE( "END PointerOf<T>::set( const T *pointer )" ) ;
return ;
}
+/*! If necessary, released memory holded by PointerOf/n.
+ If size <= 0, return an exception\n.
+ Else allocates memory and sets desallocation boolean to true./n
+ Can be used in order to "nullify" an existing PointerOf/n
+ Memory will be desallocated when erasing this PointerOf*/
+template <typename T> void PointerOf<T>::set( const int &size, const T *pointer)
+{
+ if ( _pointer && _done )
+ {
+ delete [] _pointer ;
+ _pointer = NULL ;
+ }
+ if (size <= 0)
+ throw MEDEXCEPTION("PointerOf( const int,const T*) : array size <= 0");
+
+ _pointer = new T[ size ] ;
+ memcpy(_pointer,pointer,size*sizeof(T));
+ _done=true;
+
+ return ;
+}
+
# endif /* # if ! defined( __PointerOf_HXX__ ) */
-# ifndef STRING_HXX
-# define STRING_HXX
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_STRING.hxx
+// Module : MED
-# include <string>
-# include <sstream>
+# ifndef MEDMEM_STRING_HXX
+# define MEDMEM_STRING_HXX
using namespace std;
+# include <string>
+# include <strstream>
+
+/*!
+ A class to generate string from any type:
+
+ here is a simple use case
+ STRING msgErr;
+ msgErr << "This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens ";
+ throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
+ */
class STRING : public string
{
+
private :
- ostringstream _s ;
+ ostrstream _s ;
+
public :
- operator const char*() const
- {
- return _s.str().c_str() ;
- }
- STRING() : _s()
- {
- }
- template <class T> STRING( const T &valeur ) : _s()
- {
- _s << valeur ;
- }
- template <class T> STRING &operator<<( const T &valeur )
- {
- _s << valeur ;
- return *this ;
- }
-} ;
+
+ STRING::STRING() :string(), _s()
+ {
+ }
+
+ STRING::~STRING()
+ {
+ _s.freeze(false);
+ }
+
+ STRING::operator const char * () const
+ {
+ return const_cast <const char *> (this->c_str()) ;
+ }
-// Exemple d'utilisation avec les exceptions SALOME
-// STRING msgErr;
-// msgErr << "ESSAI::ESSAI() : This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens ";
-// throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ;
+ template <class T> STRING::STRING( const T &valeur ) : string(), _s()
+ {
+ _s.freeze(false);
+
+ _s << valeur ;
+ _s << ends;
+
+ this->string::operator =( _s.str()); // freeze is true by now
+ }
+
+ template <class T> STRING & STRING::operator<<( const T &valeur )
+ {
+
+ if ( _s.pcount() )
+ {
+ _s.seekp(-1, ios::cur); // Back up before NULL
+ _s.rdbuf()->freeze(0); // Unfreeze it
+ }
+
+ _s << valeur ;
+ _s << ends;
+
+ this->string::operator = ( _s.str() ) ; // freeze is true by now
+ _s.freeze( false ) ;
+ return *this ;
+
+
+ }
+} ;
# endif
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SkyLineArray.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_SkyLineArray.hxx"
#include "utilities.h"
MESSAGE("Constructeur MEDSKYLINEARRAY sans parametre");
}
-MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray)
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray):
+ _count(myArray._count),_length(myArray._length),
+ _index(_count+1),_value(_length)
{
- MESSAGE("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)");
- _count = myArray._count ;
- _length = myArray._length ;
- _index = new med_int[_count+1] ;
- _value = new med_int[_length] ;
- memcpy(_index,myArray._index,sizeof(med_int)*(_count+1));
- memcpy(_value,myArray._value,sizeof(med_int)*_length);
+ BEGIN_OF("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)");
+ memcpy(_index,myArray._index,sizeof(med_int)*(_count+1));
+ memcpy(_value,myArray._value,sizeof(med_int)*_length);
+ END_OF("MEDSKYLINEARRAY(const MEDSKYLINEARRAY &)");
}
MEDSKYLINEARRAY::~MEDSKYLINEARRAY()
{
MESSAGE("Destructeur ~MEDSKYLINEARRAY");
- if (_index != NULL) delete [] _index;
- if (_value != NULL) delete [] _value;
+ //if (_index != NULL) delete [] _index;
+ //if (_value != NULL) delete [] _value;
}
-MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count , const med_int length ) :
- _count(count), _length(length)
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length):
+ _count(count), _length(length),
+ _index(_count+1),_value(_length)
{
- MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
-
- _index = new med_int[count+1] ;
- _value = new med_int[length] ;
+ MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
}
-void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const med_int count , const med_int length, med_int* index , med_int* value )
+MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length,
+ const med_int* index, const med_int* value):
+ _count(count), _length(length),
+ _index(_count+1),_value(_length)
{
- MESSAGE("void MEDSKYLINEARRAY::setMEDSKYLINEARRAY(count, length, index, value)");
- _count = count ;
- _length = length ;
+ MESSAGE("Constructeur MEDSKYLINEARRAY(count="<<count<<", length="<<length<<") avec parametres");
+ memcpy((med_int*)_index,index,sizeof(med_int)*(_count+1));
+ memcpy((med_int*)_value,value,sizeof(med_int)*_length);
+}
- if (_index != NULL) delete [] _index;
- if (_value != NULL) delete [] _value;
+// void MEDSKYLINEARRAY::setMEDSKYLINEARRAY( const med_int count , const med_int length, med_int* index , med_int* value )
+// {
+// MESSAGE("void MEDSKYLINEARRAY::setMEDSKYLINEARRAY(count, length, index, value)");
+// _count = count ;
+// _length = length ;
- _index = index;
- _value = value;
-}
+// //if (_index != NULL) delete [] _index;
+// //if (_value != NULL) delete [] _value;
+
+// _index.set(index);
+// _value.set(value);
+// }
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SkyLineArray.hxx
+// Module : MED
+
# ifndef __MEDSKYLINEARRAY_H__
# define __MEDSKYLINEARRAY_H__
#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_PointerOf.hxx"
#include "MEDMEM_define.hxx"
using MED_EN::med_int ;
private :
med_int _count ;
med_int _length ;
- med_int * _index ; // array of size _count+1 : _index[0]=1 and
- // _index[_count]=length+1
- med_int * _value ; // array of size _length
+ PointerOf <med_int> _index ; // array of size _count+1 : _index[0]=1 and
+ // _index[_count]=length+1
+ PointerOf <med_int> _value ; // array of size _length
public :
MEDSKYLINEARRAY();
~MEDSKYLINEARRAY();
MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
- MEDSKYLINEARRAY( const med_int count , const med_int length );
-
- void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
+ MEDSKYLINEARRAY( const med_int count, const med_int length );
+ MEDSKYLINEARRAY( const med_int count, const med_int length,
+ const med_int* index, const med_int* value );
+
+ //void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
inline med_int getNumberOf() const;
inline med_int getLength() const;
- inline med_int* getIndex() const;
- inline med_int* getValue() const;
+ inline const med_int* getIndex() const;
+ inline const med_int* getValue() const;
inline med_int getNumberOfI(int i) const throw (MEDEXCEPTION) ;
- inline med_int* getI(int i) const throw (MEDEXCEPTION) ;
+ inline const med_int* getI(int i) const throw (MEDEXCEPTION) ;
inline med_int getIJ(int i, int j) const throw (MEDEXCEPTION) ;
-
+ inline med_int getIndexValue(int i) const throw (MEDEXCEPTION) ;
+
+ inline void setIndex(const med_int* index) ;
+ inline void setI(const med_int i, const med_int* values) throw (MEDEXCEPTION) ;
+ inline void setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION) ;
+ inline void setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION) ;
+
} ;
// ---------------------------------------
{
return _length ;
};
-inline med_int* MEDSKYLINEARRAY::getIndex() const
-{
- return _index ;
+inline const med_int* MEDSKYLINEARRAY::getIndex() const
+{
+ return (const med_int*)_index ;
} ;
-inline med_int* MEDSKYLINEARRAY::getValue() const
-{
- return _value ;
+inline const med_int* MEDSKYLINEARRAY::getValue() const
+{
+ return (const med_int*)_value ;
} ;
inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
{
throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
return _index[i]-_index[i-1] ;
} ;
-inline med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
-{
+inline const med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
+{
if (i<1)
throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
if (i>_count)
throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
- return _value+_index[i-1]-1 ;
+ return _value+_index[i-1]-1 ;
}
inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
-{
+{
if (i<1)
throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
if (j<1)
return _value[_index[i-1]+j-2] ;
}
+inline med_int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1");
+ if (i>_index[_count])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ;
+ return _value[i-1] ;
+}
+
+inline void MEDSKYLINEARRAY::setIndex(const med_int* index)
+{
+ memcpy((med_int*)_index,index,(_count+1)*sizeof(med_int));
+}
+
+
+inline void MEDSKYLINEARRAY::setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1");
+ if (j<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1");
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ;
+ if (j>_index[i])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ;
+
+ _value[_index[i-1]+j-2]=value ;
+
+}
+
+inline void MEDSKYLINEARRAY::setI(const med_int i, const med_int * values) throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1");
+;
+ if (i>_count)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ;
+
+ memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(med_int)) ;
+}
+
+inline void MEDSKYLINEARRAY::setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION)
+{
+ if (i<1)
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1");
+ if (i>_index[_count])
+ throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ;
+ _value[i-1]=value ;
+}
# endif
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Support.cxx
+// Module : MED
+
+using namespace std;
/*
File Support.cxx
$Header$
#include <set>
#include <list>
-#include "utilities.h"
-#include "MEDMEM_define.hxx"
+//#include "utilities.h"
+//#include "MEDMEM_define.hxx"
#include "MEDMEM_DriversDef.hxx"
#include "MEDMEM_Support.hxx"
-#include "MEDMEM_Family.hxx"
-#include "MEDMEM_Group.hxx"
+//#include "MEDMEM_Family.hxx"
+//#include "MEDMEM_Group.hxx"
#include "MEDMEM_Mesh.hxx"
using namespace MED_EN;
/* This class is a generic class for family and group */
+
+/*!
+ Constructor.
+*/
//--------------------------------------------------------------------------
SUPPORT::SUPPORT(): _name(""), _description(""), _mesh((MESH*)NULL),
_entity(MED_CELL), _numberOfGeometricType(0),
_geometricType((medGeometryElement*)NULL),
_numberOfGaussPoint((int*)NULL),
- _geometricTypeNumber((int*)NULL), _isOnAllElts(false),
- _numberOfEntities((int*)NULL), _totalNumberOfEntities(0),
+ //_geometricTypeNumber((int*)NULL),
+ _isOnAllElts(false),
+ _numberOfElements((int*)NULL),
+ _totalNumberOfElements(0),
_number((MEDSKYLINEARRAY*)NULL)
//--------------------------------------------------------------------------
{
- MESSAGE("Constructeur SUPPORT sans parametre");
+ MESSAGE("SUPPORT::SUPPORT()");
};
+/*!
+ Constructor.
+*/
//--------------------------------------------------------------------------
-SUPPORT::SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL):
+SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL*/):
_name(Name), _description(""), _mesh(Mesh), _entity(Entity),
_numberOfGeometricType(0),
_geometricType((medGeometryElement*)NULL),
_numberOfGaussPoint((int*)NULL),
- _geometricTypeNumber((int*)NULL),
- _isOnAllElts(true), _numberOfEntities((int*)NULL),
- _totalNumberOfEntities(0),
+ //_geometricTypeNumber((int*)NULL),
+ _isOnAllElts(true),
+ _numberOfElements((int*)NULL),
+ _totalNumberOfElements(0),
_number((MEDSKYLINEARRAY*)NULL)
//--------------------------------------------------------------------------
{
- MESSAGE("Constructeur SUPPORT avec parametres MESH* Mesh,string name,medEntityMesh Entity");
- if ( Entity == MED_NODE) {
- _numberOfGeometricType=1 ;
- _geometricType=new medGeometryElement[1] ;
- _geometricType[0]=MED_NONE ;
- }
+ MESSAGE("SUPPORT::SUPPORT(MESH*Mesh,string Name,medEntityMesh Entity)");
+ update() ;
};
+/*!
+ Copy constructor.
+*/
+//--------------------------------------------------------------------------
+SUPPORT::SUPPORT(const SUPPORT & m)
+//--------------------------------------------------------------------------
+{
+ const char * LOC = "SUPPORT::SUPPORT(SUPPORT & m) : " ;
+ BEGIN_OF(LOC) ;
+
+ _name = m._name;
+ _description = m._description;
+ _mesh = m._mesh; // on recopie uniquement l'adresse
+ _entity = m._entity;
+ _numberOfGeometricType = m._numberOfGeometricType;
+ if (m._geometricType != NULL)
+ {
+ _geometricType = new medGeometryElement[m._numberOfGeometricType];
+ memcpy(_geometricType,m._geometricType,m._numberOfGeometricType*sizeof(medGeometryElement));
+ }
+ else
+ _geometricType = (medGeometryElement *) NULL;
+ if (m._numberOfGaussPoint != NULL)
+ {
+ _numberOfGaussPoint = new int[m._numberOfGeometricType];
+ memcpy(_numberOfGaussPoint,m._numberOfGaussPoint,m._numberOfGeometricType*sizeof(int));
+ }
+ else
+ _numberOfGaussPoint = (int *) NULL;
+// if (m._geometricTypeNumber != NULL)
+// {
+// _geometricTypeNumber = new int[m._numberOfGeometricType];
+// memcpy(_geometricTypeNumber,m._geometricTypeNumber,m._numberOfGeometricType*sizeof(int));
+// }
+// else
+// _geometricTypeNumber = (int *) NULL;
+ _isOnAllElts = m._isOnAllElts;
+ if (m._numberOfElements != NULL)
+ {
+ _numberOfElements = new int[_numberOfGeometricType];
+ memcpy(_numberOfElements,m._numberOfElements,_numberOfGeometricType*sizeof(int));
+ }
+ else
+ _numberOfElements = (int *) NULL;
+ _totalNumberOfElements = m._totalNumberOfElements;
+ if (m._isOnAllElts == false)
+ _number = new MEDSKYLINEARRAY(* m._number);
+ else
+ _number = (MEDSKYLINEARRAY *) NULL;
+
+ END_OF(LOC) ;
+};
+
+
+/*!
+ Destructor.
+*/
//-----------------
SUPPORT::~SUPPORT()
//-----------------
{
- MESSAGE("Destructeur ~SUPPORT()");
- if (_geometricType!=NULL)
- delete[] _geometricType ;
- if (_numberOfGaussPoint!=NULL)
- delete[] _numberOfGaussPoint ;
- if (_geometricTypeNumber!=NULL)
- delete[] _geometricTypeNumber ;
- if (_numberOfEntities!=NULL)
- delete[] _numberOfEntities ;
- if (_number!=NULL)
- delete _number ;
+ MESSAGE("Destructeur ~SUPPORT()");
+ if (_geometricType != (medGeometryElement *) NULL)
+ delete [] _geometricType ;
+ if (_numberOfGaussPoint != (int *) NULL)
+ delete [] _numberOfGaussPoint ;
+ // if (_geometricTypeNumber!=NULL)
+ // delete[] _geometricTypeNumber ;
+ if (_numberOfElements != (int *) NULL)
+ delete[] _numberOfElements ;
+ if (_number != (MEDSKYLINEARRAY *) NULL)
+ delete _number ;
}
+/*!
+ operator <<.
+*/
//--------------------------------------------------
ostream & operator<<(ostream &os, const SUPPORT &my)
//--------------------------------------------------
{
- os << "Name : "<<my._name<< endl ;
+ os << "Name : "<< my._name << endl ;
os << "Description : "<< my._description << endl ;
os << "Mesh name : ";
if (my._mesh==NULL)
os << "ERROR : Mesh not defined !" << endl ;
else
os << my._mesh->getName() << endl ;
+ os << "Entity : "<< my._entity << endl;
+ os << "Entity list : "<< endl;
+ if (!(my._isOnAllElts)) {
+ int numberoftypes = my._numberOfGeometricType ;
+ os << "NumberOfTypes : "<<numberoftypes<<endl;
+ medGeometryElement * types = my._geometricType;
+ for (int j=0;j<numberoftypes;j++) {
+ os << " * Type "<<types[j]<<" : ";
+ int numberOfElements = my._numberOfElements[j];
+ const int * number = my._number->getI(j+1);
+ for (int k=0; k<numberOfElements;k++)
+ os << number[k] << " ";
+ os << endl ;
+ }
+ } else
+ os << "Is on all entities !"<< endl;
+
return os ;
}
-/*! A DOCUMENTER */
+/*!
+ Updade the SUPPORT attributs with rigth MESH information.
+
+ It has an effect only if SUPPORT is on all elements.
+
+ No more need in future release.
+*/
//-------------------
void SUPPORT::update()
//-------------------
const char * LOC = "SUPPORT::update() : " ;
BEGIN_OF(LOC) ;
- if (_isOnAllElts)
- if (_numberOfGaussPoint==NULL) {
- MESSAGE( "ENTITY : "<< _entity );
- int NumberOfTypes = _mesh->getNumberOfTypes(_entity) ;
- MESSAGE( "NumberOfTypes : "<< NumberOfTypes );
- _numberOfGaussPoint = new int[NumberOfTypes] ;
- for (int i=0;i<NumberOfTypes;i++)
+ if (_isOnAllElts) {
+ if (_entity == MED_NODE) {
+ _numberOfGeometricType=1 ;
+ _geometricType=new medGeometryElement[1] ;
+ _geometricType[0]=MED_NONE ;
+ _numberOfElements = new int[1] ;
+ _numberOfElements[0]=_mesh->getNumberOfNodes();
+ _totalNumberOfElements=_numberOfElements[0];
+ _numberOfGaussPoint = new int[1] ;
+ _numberOfGaussPoint[0]=1;
+ } else { // we duplicate information from _mesh
+ _numberOfGeometricType=_mesh->getNumberOfTypes(_entity);
+ if (_geometricType == (medGeometryElement *) NULL)
+ _geometricType = new medGeometryElement[_numberOfGeometricType] ;
+ memcpy(_geometricType,_mesh->getTypes(_entity),_numberOfGeometricType*sizeof(medGeometryElement));
+ if (_numberOfElements == (int *) NULL)
+ _numberOfElements = new int[_numberOfGeometricType] ;
+ if (_numberOfGaussPoint == (int *) NULL)
+ _numberOfGaussPoint = new int[_numberOfGeometricType] ;
+ _totalNumberOfElements=0;
+ for (int i=0;i<_numberOfGeometricType;i++) {
+ _numberOfElements[i]=_mesh->getNumberOfElements(_entity,_geometricType[i]) ;
+ _totalNumberOfElements+=_numberOfElements[i];
_numberOfGaussPoint[i]=1 ;
+ }
}
- if (_entity == MED_NODE)
- _totalNumberOfEntities = _mesh->getNumberOfNodes();
-
+ }
END_OF(LOC);
};
-/*! A DOCUMENTER */
+/*!
+ Blend the given SUPPORT into it.
+*/
//-------------------
void SUPPORT::blending(SUPPORT * mySupport)
//-------------------
const char * LOC = "SUPPORT::blending() : " ;
BEGIN_OF(LOC) ;
+ MESSAGE(LOC<< "SUPPORT entry : " << *mySupport) ;
+
// on same entity :
if ( _entity != mySupport->getEntity() )
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Entities are different !"));
}
}
// set new value :
- int * numberOfEntities=_numberOfEntities ;
- _numberOfEntities = new int[it] ;
- _totalNumberOfEntities = 0 ;
- // int totalSize = 0 ;
+ int * numberOfElements=_numberOfElements ;
+ _numberOfElements = new int[it] ;
+ _totalNumberOfElements = 0 ;
+ //int totalSize = 0 ;
int ** tmp_array = new (int*)[it];
for (int i=0;i<it;i++) {
int numberOfElementsInType = tmp_NumberOfElementsInType[i] ;
- _numberOfEntities[i] = numberOfElementsInType ;
+ _numberOfElements[i] = numberOfElementsInType ;
tmp_array[i] = new int[numberOfElementsInType] ;
//totalSize+=numberOfElementsInType*(myType[i]%100) ;
- _totalNumberOfEntities+=numberOfElementsInType ;
+ _totalNumberOfElements+=numberOfElementsInType ;
if (whereIsType[i] == 1) { // only first Support
memcpy(tmp_array[i],getNumber(myType[i]),sizeof(int)*numberOfElementsInType);
} else if (whereIsType[i] == 2) { // only second Support
int i1 = 0 ;
int i2 = 0 ;
int ii = 0 ;
- int * number1 = getNumber(myType[i]) ;
- int * number2 = mySupport->getNumber(myType[i]) ;
+ const int * number1 = getNumber(myType[i]) ;
+ const int * number2 = mySupport->getNumber(myType[i]) ;
+
+ SCRUTE(number1);
+ SCRUTE(number2);
- int numberOfElements1 = numberOfEntities[i] ;
+ int numberOfElements1 = numberOfElements[i] ;
int numberOfElements2 = mySupport->getNumberOfElements(myType[i]) ;
+ SCRUTE(numberOfElements1);
+ SCRUTE(numberOfElements2);
+
for(int j=0;j<numberOfElements1;j++){
elementList.insert(number1[j]) ;
}
for(int j=0;j<numberOfElements2;j++){
+ SCRUTE(number2[j]);
elementList.insert(number2[j]) ;
}
//create the array !
- int newNumberOfEntities = elementList.size() ;
- _numberOfEntities[i] = newNumberOfEntities ;
- int * tmp_arrayNew = new int[newNumberOfEntities];
+ int newNumberOfElements = elementList.size() ;
+ _numberOfElements[i] = newNumberOfElements ;
+ int * tmp_arrayNew = new int[newNumberOfElements];
set<int>::iterator its ;
for(its=elementList.begin();its!=elementList.end(); its++) {
delete[] tmp_array[i] ;
tmp_array[i] = tmp_arrayNew ;
- _totalNumberOfEntities-=(numberOfElementsInType-newNumberOfEntities) ;
+ _totalNumberOfElements-=(numberOfElementsInType-newNumberOfElements) ;
} else
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"ERROR")) ;
_geometricType = new medGeometryElement[it] ;
int * numberOfGaussPoint=_numberOfGaussPoint ;
_numberOfGaussPoint= new int[it] ;
- int * geometricTypeNumber=_geometricTypeNumber ;
- _geometricTypeNumber = new int[it] ;
+// int * geometricTypeNumber=_geometricTypeNumber ;
+// _geometricTypeNumber = new int[it] ;
- MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfEntities);
- int * numberIndex = numberNew->getIndex() ;
+// MEDSKYLINEARRAY* numberNew = new MEDSKYLINEARRAY(it,_totalNumberOfElements);
+// int * numberIndex = numberNew->getIndex() ;
+ int size = _mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS);
+ if (_totalNumberOfElements == size) _isOnAllElts = true;
+
+ int * numberValue = new int[_totalNumberOfElements] ;
+ int * numberIndex = new int[it+1] ;
numberIndex[0]=1;
for (int i=0;i<it;i++) {
- memcpy(numberNew->getI(i+1),tmp_array[i],sizeof(int)*_numberOfEntities[i]) ;
+ memcpy(numberValue+numberIndex[i]-1,tmp_array[i],sizeof(int)*_numberOfElements[i]) ;
delete[] tmp_array[i] ;
- numberIndex[i+1]=numberIndex[i]+_numberOfEntities[i] ;
+ numberIndex[i+1]=numberIndex[i]+_numberOfElements[i] ;
_geometricType[i]=myType[i] ;
_numberOfGaussPoint[i]=1 ;
- _geometricTypeNumber[i]=0 ;
-
}
- delete _number ;
- _number = numberNew ;
+ if ( _number != (MEDSKYLINEARRAY *) NULL) delete _number ;
+ //_number = numberNew ;
+ _number = new MEDSKYLINEARRAY(it,_totalNumberOfElements,numberIndex,numberValue);
+ delete[] numberIndex;
+
+ delete[] numberValue;
delete[] myType ;
delete[] tmp_array ;
delete[] geometricType ;
delete[] numberOfGaussPoint ;
- delete[] geometricTypeNumber ;
- delete[] numberOfEntities ;
+// delete[] geometricTypeNumber ;
+ delete[] numberOfElements ;
END_OF(LOC);
};
it should be used after an initialisation with the constructor
SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
after the call to the function setAll(false).
- It allocates and initialises all the attributs of the class SUPPORT.;
- useful for the Python API.
+ It allocates and initialises all the attributs of the class SUPPORT.
*/
//-------------------
void SUPPORT::setpartial(string Description, int NumberOfGeometricType,
- int TotalNumberOfEntity,
+ int TotalNumberOfElements,
medGeometryElement *GeometricType,
- int *NumberOfEntity, int *NumberValue)
+ int *NumberOfElements, int *NumberValue)
//-------------------
{
const char * LOC = "SUPPORT::setpartial(string , int , int , medGeometryElement * , int * , int *) : " ;
BEGIN_OF(LOC) ;
+ _isOnAllElts = false ;
+
_description=Description;
_numberOfGeometricType=NumberOfGeometricType;
- _totalNumberOfEntities=TotalNumberOfEntity;
-
+ if (_geometricType!=NULL) delete[] _geometricType ;
_geometricType = new medGeometryElement[NumberOfGeometricType];
- _geometricType = GeometricType;
+ if (_numberOfElements!=NULL) delete[] _numberOfElements ;
+ _numberOfElements = new int[NumberOfGeometricType];
+ _totalNumberOfElements = TotalNumberOfElements;
+ if (_numberOfGaussPoint!=NULL) delete[] _numberOfGaussPoint ;
+ _numberOfGaussPoint = new int[NumberOfGeometricType];
+ int * index = new int[_numberOfGeometricType+1];
+ index[0]=1;
+ for (int i=0;i<_numberOfGeometricType;i++) {
+ _geometricType[i] = GeometricType[i] ;
+ _numberOfElements[i] = NumberOfElements[i] ;
+ _numberOfGaussPoint[i] = 1 ;
+ index[i+1] = index[i]+NumberOfElements[i] ;
+ }
+
+ if (_number!=NULL) delete _number ;
+ _number = new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,NumberValue);
- // attributes initialised at 0 because not really useful but it has to be
- // allocated !! WARNING !!
+ delete[] index ;
- _geometricTypeNumber = new int[NumberOfGeometricType] ;
- for (int i=0;i<NumberOfGeometricType;i++) _geometricTypeNumber[i] = 0;
+ END_OF(LOC);
+};
+
+
+/*!
+ This method gets the boundary elements of the mesh. The support has to be
+ build using the constructor SUPPORT(MESH *,string, medEntityMesh) or
+ SUPPORT() followed by setMesh(MESH*) setName(string) and
+ setEntity(medEntityMesh) before using this method.
+*/
+//-------------------
+void SUPPORT::getBoundaryElements() throw (MEDEXCEPTION)
+//-------------------
+{
+ const char * LOC = "SUPPORT::getBoundaryElements() : " ;
+ BEGIN_OF(LOC) ;
- //_numberOfEntities = new int[NumberOfGeometricType] ;
- _numberOfEntities = NumberOfEntity;
+ if (_mesh == (MESH*)NULL) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"You shlould use the appropriate SUPPORT Constructor before calling this method"));
+
+ int spaceDimension = _mesh->getSpaceDimension();
+
+ if (spaceDimension == 3)
+ if (_entity != MED_FACE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<_entity<<" !"));
+ if (spaceDimension == 2)
+ if (_entity != MED_EDGE)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<_entity<<" !"));
+
+ setAll(false);
+
+ const int * myConnectivityValue = _mesh->getReverseConnectivity(MED_DESCENDING) ;
+ const int * myConnectivityIndex = _mesh->getReverseConnectivityIndex(MED_DESCENDING) ;
+ int numberOf = _mesh->getNumberOfElements(_entity,MED_ALL_ELEMENTS) ;
+ list<int> myElementsList ;
+ int size = 0 ;
+ SCRUTE(numberOf) ;
+ for (int i=0 ; i<numberOf; i++)
+ if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
+ SCRUTE(i+1) ;
+ myElementsList.push_back(i+1) ;
+ size++ ;
+ }
+ SCRUTE(size) ;
+ // Well, we must know how many geometric type we have found
+ int * myListArray = new int[size] ;
+ int id = 0 ;
+ list<int>::iterator myElementsListIt ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ myListArray[id]=(*myElementsListIt) ;
+ SCRUTE(id);
+ SCRUTE(myListArray[id]);
+ id ++ ;
+ }
- MEDSKYLINEARRAY * number = new MEDSKYLINEARRAY();
+ int numberOfGeometricType ;
+ medGeometryElement* geometricType ;
+ int * numberOfGaussPoint ;
+ int * geometricTypeNumber ;
+ int * numberOfElements ;
+ //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
+ int * mySkyLineArrayIndex ;
+
+ int numberOfType = _mesh->getNumberOfTypes(_entity) ;
+ if (numberOfType == 1) { // wonderfull : it's easy !
+ numberOfGeometricType = 1 ;
+ geometricType = new medGeometryElement[1] ;
+ const medGeometryElement * allType = _mesh->getTypes(_entity);
+ geometricType[0] = allType[0] ;
+ numberOfGaussPoint = new int[1] ;
+ numberOfGaussPoint[0] = 1 ;
+ geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
+ geometricTypeNumber[0] = 0 ;
+ numberOfElements = new int[1] ;
+ numberOfElements[0] = size ;
+ mySkyLineArrayIndex = new int[2] ;
+ mySkyLineArrayIndex[0]=1 ;
+ mySkyLineArrayIndex[1]=1+size ;
+ }
+ else {// hemmm
+ map<medGeometryElement,int> theType ;
+ for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
+ medGeometryElement myType = _mesh->getElementType(_entity,*myElementsListIt) ;
+ if (theType.find(myType) != theType.end() )
+ theType[myType]+=1 ;
+ else
+ theType[myType]=1 ;
+ }
+ numberOfGeometricType = theType.size() ;
+ geometricType = new medGeometryElement[numberOfGeometricType] ;
+ const medGeometryElement * allType = _mesh->getTypes(_entity);
+ numberOfGaussPoint = new int[numberOfGeometricType] ;
+ geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
+ numberOfElements = new int[numberOfGeometricType] ;
+ mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
+ int index = 0 ;
+ mySkyLineArrayIndex[0]=1 ;
+ map<medGeometryElement,int>::iterator theTypeIt ;
+ for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
+ geometricType[index] = (*theTypeIt).first ;
+ numberOfGaussPoint[index] = 1 ;
+ geometricTypeNumber[index] = 0 ;
+ numberOfElements[index] = (*theTypeIt).second ;
+ mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ;
+ index++ ;
+ }
+ }
+ //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+ MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
+
+ setNumberOfGeometricType(numberOfGeometricType) ;
+ // setGeometricType(geometricType) ;
+ // setNumberOfGaussPoint(numberOfGaussPoint) ;
+ for (int i=0;i<numberOfGeometricType;i++)
+ {
+ _numberOfGaussPoint[i] = numberOfGaussPoint[i];
+ _geometricType[i] = geometricType[i];
+ }
- int * index = new int[_numberOfGeometricType+1];
- index[0]=1;
+ setNumberOfElements(numberOfElements) ;
+ setTotalNumberOfElements(size) ;
+ // setNumber(mySkyLineArray) ;
- for (int i=0;i<_numberOfGeometricType;i++)
- index[i+1] = index[i]+_numberOfEntities[i] ;
+ _number = new MEDSKYLINEARRAY(numberOfGeometricType,size);
- number->setMEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfEntities,index,NumberValue);
+ _number->setIndex(mySkyLineArrayIndex);
- if (_number!=NULL) delete _number ;
- _number = number;
+ for (int i=0;i<size;i++)
+ {
+ _number->setIndexValue(i+1,myListArray[i]);
+ }
- update();
+ delete[] numberOfElements;
+ delete[] geometricTypeNumber;
+ delete[] numberOfGaussPoint;
+ delete[] geometricType;
+ delete[] mySkyLineArrayIndex;
+ delete[] myListArray;
+ delete mySkyLineArray;
- END_OF(LOC);
-};
+ END_OF(LOC) ;
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Support.hxx
+// Module : MED
+
/*
- File Support.hxx
- $Header$
+ File Support.hxx
+ $Header$
*/
#ifndef SUPPORT_HXX
#include <string>
#include "utilities.h"
+#include "MEDMEM_STRING.hxx"
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_define.hxx"
#include "MEDMEM_SkyLineArray.hxx"
-#include "MEDMEM_Mesh.hxx"
+//#include "MEDMEM_Mesh.hxx"
using namespace MED_EN;
class MESH ;
-class SUPPORT
+/*!
+
+ This class describe a support of elements on an entity of the mesh.
+
+ It contains the list of meshes elements for an entity (MED_NODE,
+ MED_CELL, MED_FACE or MED_EDGE).
+
+*/
+
+class SUPPORT
{
protected:
- /*! name of the support */
+ /*!
+ \if developper
+ Support name.
+ \endif
+ */
string _name;
- /*! description of the support (optionnal) */
+
+ /*!
+ \if developper
+ Description of the support (optional).
+ \endif
+ */
string _description;
- /*! reference to the mesh on which the support is defined */
+
+ /*!
+ \if developper
+ Reference to the mesh on which the support is defined.
+ \endif
+ */
MESH * _mesh;
- /*! type of entity on which the support is defined
- (only one for each support) */
+
+ /*!
+ \if developper
+ Type of entity on which the support is defined
+ (only one for each support).
+ \endif
+ */
medEntityMesh _entity ;
- /*! number of geometric type defined in the support */
+
+ /*!
+ \if developper
+ Number of geometric type defined in the support.
+ \endif
+ */
int _numberOfGeometricType;
- /*! array of all geometric type defined in the support */
+
+ /*!
+ \if developper
+ Array of all geometric type defined in the support.
+ \endif
+ */
medGeometryElement * _geometricType;
- /*! array of size _numberOfGeometricType which contains
- for each type the number of gauss point
- (not yet implemented) */
- int * _numberOfGaussPoint ;
- /*! array of size _numberOfGeometricType
- which contains number of geometric
- entity type in Mesh
- (to get corresponding CellModel)*/
- int * _geometricTypeNumber;
- /*! If true, we consider all entities of type _entity */
- bool _isOnAllElts;
- /*! array of size _numberOfGeometricType wich contains
- for each geometric type, count of entities.
- (if _isOnAllElts is true, we could get same
- information from _mesh) */
- int * _numberOfEntities;
- /*! sum of each _numberOfEntities component (if
- _isOnAllElts is true, we could get same
- information from _mesh) */
- int _totalNumberOfEntities;
+
+ /*!
+ \if developper
+ Array of size _numberOfGeometricType which contains
+ for each type the number of gauss point
+ (not yet implemented).
+ \endif
+ */
+ int * _numberOfGaussPoint ;
+
+ /*
+ \if developper
+ Array of size _numberOfGeometricType
+ which contains number of geometric
+ entity type in Mesh
+ (to get corresponding CellModel).
+ \endif
+ */
+ //int * _geometricTypeNumber;
+
+ /*!
+ \if developper
+ If true, we consider all entities of type _entity.
+ \endif
+ */
+ bool _isOnAllElts;
+
+ /*!
+ \if developper
+ Index array of size _numberOfGeometricType wich contains
+ for each geometric type, the number of elements of this type.
+ \endif
+ */
+ int * _numberOfElements;
+
+ /*!
+ \if developper
+ Sum of each _numberOfElements component.
+ \endif
+ */
+ int _totalNumberOfElements;
// the two following arrays are defined only if _isOnAllElts is false :
- /* array of size _numberOfType+1 wich contains for
- each geometric type, index in _number._value
- (if _all is true, we must ask _mesh to get
- information). _typeIndex[i+1]-_typeIndex[i]
- represents count of entities of ith geometric
- type. _typeIndex[_numberOfType] contains total
- entities count. If _numberOf[i]=0,
- _typeIndex[i+1]=_typeIndex[i]
- defined only if _isOnAllElts is false*/
- // int * _typeIndex;
- /*! array of size _index[_numberOfType] wich contain number of
- entities of each geometric type. We use global numbering.
- defined only if _isOnAllElts is false*/
- MEDSKYLINEARRAY * _number;
+ /*
+ \if developper
+ array of size _numberOfType+1 wich contains for
+ each geometric type, index in _number._value
+ (if _all is true, we must ask _mesh to get
+ information). _typeIndex[i+1]-_typeIndex[i]
+ represents count of entities of ith geometric
+ type. _typeIndex[_numberOfType] contains total
+ entities count. If _numberOf[i]=0,
+ _typeIndex[i+1]=_typeIndex[i]
+ defined only if _isOnAllElts is false
+ \endif
+ */
+ // int * _typeIndex;
+
+ /*!
+ \if developper
+ Array of size _index[_numberOfType]-1 wich contain number of
+ entities of each geometric type. We use global numbering.\n
+ Defined only if _isOnAllElts is false.
+ \endif
+ */
+ MEDSKYLINEARRAY * _number;
public:
- SUPPORT();
- SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
+ SUPPORT();
+ SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
+ SUPPORT(const SUPPORT & m);
~SUPPORT();
friend ostream & operator<<(ostream &os,const SUPPORT &my);
-
+
// function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
void update();
-
+
inline void setName(string Name);
- inline void setDescription(string Description);
- inline void setMesh(MESH *Mesh);
- inline void setAll(bool All);
- inline void setEntity(medEntityMesh Entity);
- inline void setNumberOfGeometricType(int NumberOfGeometricType);
- inline void setGeometricType(medGeometryElement *GeometricType);
- inline void setNumberOfGaussPoint(int *NumberOfGaussPoint);
- inline void setGeometricTypeNumber(int *GeometricTypeNumber);
- inline void setNumberOfEntities(int *NumberOfEntities);
- inline void setTotalNumberOfEntities(int TotalNumberOfEntities);
- inline void setNumber(MEDSKYLINEARRAY * Number);
-
- inline string getName() const;
- inline string getDescription() const;
- inline MESH * getMesh() const;
+ inline void setDescription(string Description);
+ inline void setMesh(MESH *Mesh);
+ inline void setAll(bool All);
+ inline void setEntity(medEntityMesh Entity);
+ inline void setNumberOfGeometricType(int NumberOfGeometricType);
+ inline void setGeometricType(const medGeometryElement *GeometricType);
+ inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
+ // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
+ inline void setNumberOfElements(const int *NumberOfElements);
+ inline void setTotalNumberOfElements(int TotalNumberOfElements);
+ inline void setNumber(MEDSKYLINEARRAY * Number);
+ inline void setNumber(const int * index, const int* value);
+
+ inline string getName() const;
+ inline string getDescription() const;
+ inline MESH * getMesh() const;
inline medEntityMesh getEntity() const;
- inline bool isOnAllElements() const;
+ inline bool isOnAllElements() const;
inline int getNumberOfTypes() const;
- inline medGeometryElement* getTypes() const ;
- inline int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
- inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
- inline int * getGeometricTypeNumber() const;
- // inline int getNumberOfTotalEntity() const;
+ inline const medGeometryElement* getTypes() const ;
+ inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
+ inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
+ //inline int * getGeometricTypeNumber() const;
+ //inline int getTotalNumberOfElement() const;
inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
- inline int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
- inline int * getNumberIndex() const throw (MEDEXCEPTION);
+ inline const int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
+ inline const int * getNumberIndex() const throw (MEDEXCEPTION);
void blending(SUPPORT * mySupport);
- /*
- This function allows the user to set a support not on all entities Entity,
- it should be used after an initialisation with the constructor
- SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
- after the call to the function setAll(false).
- It allocates and initialises all the attributs of the class SUPPORT.
- */
-
void setpartial(string Description, int NumberOfGeometricType,
int TotalNumberOfEntity, medGeometryElement *GeometricType,
int *NumberOfEntity, int *NumberValue);
+
+ void getBoundaryElements() throw (MEDEXCEPTION);
};
// _____________________
// Methodes Inline
// _____________________
-/*! If isOnAllElements is false, returns number of elements in the
- support else returns number of nodes.
+/*!
+ If isOnAllElements is false, returns number of elements in the
+ support else returns number of nodes.
- Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
- in entity of support.
+ Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
+ in entity of support.
- Note : If SUPPORT is defined on MED_NODE, use MED_NONE
- medGeometryElement type. */
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type.
+*/
//-----------------------------------------------------------------------------
inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
-throw (MEDEXCEPTION)
+ throw (MEDEXCEPTION)
//-----------------------------------------------------------------------------
{
- if (_isOnAllElts){
- return _mesh->getNumberOfElements(_entity,GeometricType);
- } else {
- if (GeometricType==MED_ALL_ELEMENTS)
- return _totalNumberOfEntities;
- for (int i=0;i<_numberOfGeometricType;i++)
- if (_geometricType[i]==GeometricType)
- return _numberOfEntities[i] ;
- throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ;
- }
+ if (GeometricType==MED_ALL_ELEMENTS)
+ return _totalNumberOfElements;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ if (_geometricType[i]==GeometricType)
+ return _numberOfElements[i];
+ throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
}
-// inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const
-// throw (MEDEXCEPTION)
-// {
-// if (GeometricType==MED_ALL_ELEMENTS)
-// return _totalNumberOfEntities ;
-// for (int i=0;i<_numberOfGeometricType;i++)
-// if (_geometricType[i]==GeometricType)
-// return _numberOfEntities[i] ;
-// throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !");
-// }
-
-// inline int SUPPORT::getNumberOfTotalEntity() const
-// {
-// return _totalNumberOfEntities ;
-// }
//---------------------------------------------------------------------
-inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
- throw (MEDEXCEPTION)
+inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
+ throw (MEDEXCEPTION)
//---------------------------------------------------------------------
{
- if (_number==NULL)
+ if (_number==NULL)
throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
return _number ;
}
-/*! If isOnAllElements is false, returns an array which contains
- all number of given medGeometryElement.
+/*!
+ If isOnAllElements is false, returns an array which contains
+ all number of given medGeometryElement.
- Numbering is global, ie numbers are bounded by 1 and
- MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
- MESH::getNumberOfElement(entity,geomElement).
+ Numbering is global, ie numbers are bounded by 1 and
+ MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
+ MESH::getNumberOfElement(entity,geomElement).
- Note : If SUPPORT is defined on MED_NODE, use MED_NONE
- medGeometryElement type. */
+ Note : If SUPPORT is defined on MED_NODE, use MED_NONE
+ medGeometryElement type.
+*/
//---------------------------------------------------------------------
-inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const
- throw (MEDEXCEPTION)
+inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const
+ throw (MEDEXCEPTION)
//---------------------------------------------------------------------
{
const char * LOC = "Support::getNumber : " ;
- if (_isOnAllElts)
+ if (_isOnAllElts)
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
if (GeometricType==MED_ALL_ELEMENTS)
- return _number->getValue() ;
+ return _number->getValue() ;
for (int i=0;i<_numberOfGeometricType;i++)
if (_geometricType[i]==GeometricType)
return _number->getI(i+1) ;
throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
}
-/*! If isOnAllElements is false, returns index of element number.
- Use it with getNumber(MED_ALL_ELEMENTS).
+/*!
+ If isOnAllElements is false, returns index of element number.
+ Use it with getNumber(MED_ALL_ELEMENTS).
- Note : See getConnectivityIndex for details. */
+ Note : See getConnectivityIndex for details.
+*/
//-------------------------------------------
-inline int * SUPPORT::getNumberIndex() const
+inline const int * SUPPORT::getNumberIndex() const
//-------------------------------------------
-throw (MEDEXCEPTION)
+ throw (MEDEXCEPTION)
{
- if (_isOnAllElts)
- throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
- return _number->getIndex() ;
+ if (_isOnAllElts)
+ throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
+ return _number->getIndex() ;
}
/*! A DOCUMENTER */
//-------------------------------------------------
-inline int * SUPPORT::getNumberOfGaussPoint() const
-throw (MEDEXCEPTION)
+inline const int * SUPPORT::getNumberOfGaussPoint() const
+ throw (MEDEXCEPTION)
//-------------------------------------------------
{
if (_numberOfGaussPoint!=NULL)
throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
}
-/*! Returns number of Gauss points for this medGeometryElement.
+/*!
+ Returns number of Gauss points for this medGeometryElement.
- Note :
- - Not defined if SUPPORT is on MED_NODE.
- - Not defined for MED_ALL_ELEMENTS medGeometryElement type. */
+ Note :
+ - Not defined if SUPPORT is on MED_NODE.
+ - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
+*/
//-----------------------------------------------------------------------------
-inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
-throw (MEDEXCEPTION)
+inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
+ throw (MEDEXCEPTION)
//-----------------------------------------------------------------------------
{
if (_numberOfGaussPoint!=NULL) {
} else
throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
}
-// inline int SUPPORT::getNumberLength() const
-// throw (MEDEXCEPTION)
+// inline int SUPPORT::getNumberLength() const
+// throw (MEDEXCEPTION)
// {
-// if (_isOnAllElts)
+// if (_isOnAllElts)
// throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
// return _number->getLength() ;
// }
-/*! set the attribute _name to Name */
+/*! set the attribute _name to Name */
//--------------------------------------
inline void SUPPORT::setName(string Name)
//--------------------------------------
-{
- _name=Name;
+{
+ _name=Name;
}
/*! set the attribute _description to Description */
//--------------------------------------------------
inline void SUPPORT::setDescription(string Description)
//--------------------------------------------------
-{
- _description=Description;
+{
+ _description=Description;
}
-/*! set the reference _mesh to Mesh */
+/*! set the reference _mesh to Mesh */
//--------------------------------------
inline void SUPPORT::setMesh(MESH *Mesh)
//--------------------------------------
-{
- _mesh=Mesh;
+{
+ _mesh=Mesh;
}
/*! set the attribute _isOnAllElts to All */
//------------------------------------------
inline void SUPPORT::setAll(bool All)
//------------------------------------------
-{
- _isOnAllElts=All;
+{
+ _isOnAllElts=All;
}
/*! set the attribute _entity to Entity */
//------------------------------------------
inline void SUPPORT::setEntity(medEntityMesh Entity)
-{
- _entity=Entity;
- if ( Entity == MED_NODE) {
- _numberOfGeometricType=1 ;
- _geometricType=new medGeometryElement[1] ; // delete previous ???
- _geometricType[0]=MED_NONE ;
- }
+{
+ _entity=Entity;
+// if ( Entity == MED_NODE) {
+// _numberOfGeometricType=1 ;
+// if (_geometricType == (medGeometryElement *) NULL)
+// _geometricType=new medGeometryElement[1] ;
+// else
+// {
+// // delete previous ???
+// delete [] _geometricType;
+// _geometricType=new medGeometryElement[1] ;
+// }
+// _geometricType[0]=MED_NONE ;
+// }
}
/*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
//---------------------------------------------------------------------
inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
//---------------------------------------------------------------------
-{
- _numberOfGeometricType=NumberOfGeometricType;
+{
+ _numberOfGeometricType=NumberOfGeometricType;
+ if (_geometricType!=NULL) {
+ delete[] _geometricType ;
+ _geometricType = NULL ;
+ }
+ if (_numberOfElements!=NULL) {
+ delete[] _numberOfElements ;
+ _numberOfElements = NULL ;
+ }
+ if (_numberOfGaussPoint!=NULL) {
+ delete[] _numberOfGaussPoint ;
+ _numberOfGaussPoint = NULL ;
+ }
}
-/*! set the attribute _geometricType to geometricType */
+/*! set the attribute _geometricType to geometricType */
//---------------------------------------------------------------------
-inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType)
+inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType)
//---------------------------------------------------------------------
-{
- _geometricType=GeometricType;
+{
+ if (NULL == _geometricType)
+ _geometricType=new medGeometryElement[_numberOfGeometricType];
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _geometricType[i] = GeometricType[i];
+ // _geometricType=GeometricType;
}
-/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
+/*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
//-----------------------------------------------------------------
-inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint)
+inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
//-----------------------------------------------------------------
{
- _numberOfGaussPoint = NumberOfGaussPoint ;
+ if (NULL == _numberOfGaussPoint)
+ _numberOfGaussPoint=new int[_numberOfGeometricType];
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
+ // _numberOfGaussPoint = NumberOfGaussPoint ;
}
-/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
+/*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
//-------------------------------------------------------------------
-inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
+//inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
//-------------------------------------------------------------------
-{
- _geometricTypeNumber=GeometricTypeNumber;
-}
+//{
+// _geometricTypeNumber=GeometricTypeNumber;
+//}
-/*! set the attribute _numberOfEntities to NumberOfEntities */
+/*!
+ Set the attribute _numberOfElements to NumberOfElements and
+ calculate the total number of elements.
+*/
//----------------------------------------------------------
-inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities)
+inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
//----------------------------------------------------------
-{
- _numberOfEntities=NumberOfEntities;
+{
+ if (NULL == _numberOfElements)
+ _numberOfElements=new int[_numberOfGeometricType];
+ memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
+ _totalNumberOfElements = 0 ;
+ for (int i=0;i<_numberOfGeometricType;i++)
+ _totalNumberOfElements+=_numberOfElements[i];
}
-/*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */
+/*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
//--------------------------------------------------------------------
-inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities)
+inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
//--------------------------------------------------------------------
-{
- _totalNumberOfEntities=TotalNumberOfEntities;
+{
+ _totalNumberOfElements=TotalNumberOfElements;
}
-/*! set the attribute _number to Number */
+/*! set the attribute _number to Number */
//---------------------------------------------------
inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
//---------------------------------------------------
-{
- _number=Number;
+{
+ if (_number != NULL) delete _number ;
+ _number=Number;
+}
+
+/*! set the attribute _number with index and value arrays */
+//---------------------------------------------------
+inline void SUPPORT::setNumber(const int * index, const int* value)
+//---------------------------------------------------
+{
+ if (_number != NULL) delete _number ;
+ _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
}
/*! returns the name of the support. */
//------------------------------------
-inline string SUPPORT::getName() const
+inline string SUPPORT::getName() const
//------------------------------------
-{
- return _name;
+{
+ return _name;
}
/*! returns the description of the support. */
//--------------------------------------------
-inline string SUPPORT::getDescription() const
+inline string SUPPORT::getDescription() const
//--------------------------------------------
-{
- return _description;
+{
+ return _description;
}
-/*! returns a refernce to the mesh */
+/*! returns a reference to the mesh */
//------------------------------------
-inline MESH * SUPPORT::getMesh() const
+inline MESH * SUPPORT::getMesh() const
//------------------------------------
-{
- return _mesh;
+{
+ return _mesh;
}
-/*! Returns true if all elements of this entity are
- concerned, false otherwise.
- If true, you must use mesh reference (getMesh) to get more information.*/
+/*!
+ Returns true if all elements of this entity are
+ concerned, false otherwise.
+ If true, you must use mesh reference (getMesh) to get more information.
+*/
//------------------------------------------
-inline bool SUPPORT::isOnAllElements() const
+inline bool SUPPORT::isOnAllElements() const
//------------------------------------------
-{
- return _isOnAllElts;
+{
+ return _isOnAllElts;
}
-/*! Returns number of geometric Types
- defines in the support */
+/*!
+ Returns number of geometric Types
+ defines in the support
+*/
//------------------------------------------
-inline int SUPPORT::getNumberOfTypes() const
+inline int SUPPORT::getNumberOfTypes() const
//------------------------------------------
-{
- if ((_isOnAllElts)&(_entity != MED_NODE))
- return _mesh->getNumberOfTypes(_entity) ;
- else
- return _numberOfGeometricType ;
+{
+ // if ((_isOnAllElts)&(_entity != MED_NODE))
+ // return _mesh->getNumberOfTypes(_entity) ;
+ // else
+ return _numberOfGeometricType ;
}
-/*! Returns the medEntityMesh's type used by the support.
- Note : A support deals only with one entity's type
- (for example : MED_FACE or MED_NODE)*/
+/*!
+ Returns the medEntityMesh's type used by the support.
+ Note : A support deals only with one entity's type
+ (for example : MED_FACE or MED_NODE)
+*/
//---------------------------------------------
-inline medEntityMesh SUPPORT::getEntity() const
+inline medEntityMesh SUPPORT::getEntity() const
//---------------------------------------------
-{
- return _entity;
+{
+ return _entity;
}
-/*! If isOnAllElements is false, returns an array of <medGeometryElement>
- types used by the support.
+/*!
+ If isOnAllElements is false, returns an array of <medGeometryElement>
+ types used by the support.
- <medEntityMesh> is given by getEntity. */
+ <medEntityMesh> is given by getEntity.
+*/
//---------------------------------------------------
-inline medGeometryElement * SUPPORT::getTypes() const
+inline const medGeometryElement * SUPPORT::getTypes() const
//---------------------------------------------------
{
- if ((_isOnAllElts)&(_entity != MED_NODE))
- return _mesh->getTypes(_entity) ;
- else
- return _geometricType;
+ // if ((_isOnAllElts)&(_entity != MED_NODE))
+ // return _mesh->getTypes(_entity) ;
+ // else
+ return _geometricType;
}
//---------------------------------------------------
-inline int * SUPPORT::getGeometricTypeNumber() const
+//inline int * SUPPORT::getGeometricTypeNumber() const
//---------------------------------------------------
-{
- const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
- if (_isOnAllElts)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
- if (_geometricTypeNumber==NULL)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
- return _geometricTypeNumber;
-}
+// {
+// const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
+// if (_isOnAllElts)
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
+// if (_geometricTypeNumber==NULL)
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
+// return _geometricTypeNumber;
+// }
+
-
#endif /* SUPPORT_HXX */
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_TypeMeshDriver.cxx
+// Module : MED
+
+#include "MEDMEM_TypeMeshDriver.hxx"
+
+#include "MEDMEM_DriversDef.hxx"
+
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include "MEDMEM_Connectivity.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
+
+// Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
+
+TYPE_MESH_DRIVER::TYPE_MESH_DRIVER():
+ GENDRIVER(),
+ _ptrMesh(( MESH *)MED_NULL),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName("")
+{
+}
+
+TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ MED_EN::med_mode_acces accessMode):
+ GENDRIVER(fileName,accessMode),
+ _ptrMesh(ptrMesh),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName("")
+{
+}
+
+TYPE_MESH_DRIVER::TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMesh(driver._ptrMesh),
+ // A VOIR _medIdt(MED_INVALID),
+ _meshName(driver._meshName)
+{
+}
+
+TYPE_MESH_DRIVER::~TYPE_MESH_DRIVER()
+{
+}
+
+void TYPE_MESH_DRIVER::open()
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "TYPE_MESH_DRIVER::open()" ;
+ BEGIN_OF(LOC);
+
+// if (_medIdt > 0)
+// _status = MED_OPENED;
+// else {
+// _medIdt = MED_INVALID;
+// _status = MED_CLOSED;
+// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
+// }
+
+ END_OF(LOC);
+}
+
+void TYPE_MESH_DRIVER::close()
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "TYPE_MESH_DRIVER::close() " ;
+ BEGIN_OF(LOC);
+
+// int err = 0;
+// if ( _status == MED_OPENED) {
+// err=MED_FR::MEDfermer(_medIdt);
+// H5close(); // If we call H5close() all the files are closed.
+// if (err != 0)
+// throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
+// <<" Error when closing file !"
+// )
+// );
+// _status = MED_CLOSED;
+// _medIdt = MED_INVALID;
+// }
+
+ END_OF(LOC);
+}
+
+void TYPE_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; };
+string TYPE_MESH_DRIVER::getMeshName() const { return _meshName; };
+
+
+//---------------------------------- RDONLY PART -------------------------------------------------------------
+
+TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(): TYPE_MESH_DRIVER()
+{
+}
+
+TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
+{
+ MESSAGE("TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver):
+ TYPE_MESH_DRIVER(driver)
+{
+}
+
+TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER()
+{
+ //MESSAGE("TYPE_MESH_RDONLY_DRIVER::~TYPE_MESH_RDONLY_DRIVER() has been destroyed");
+}
+
+GENDRIVER * TYPE_MESH_RDONLY_DRIVER::copy(void) const
+{
+ return new TYPE_MESH_RDONLY_DRIVER(*this);
+}
+
+void TYPE_MESH_RDONLY_DRIVER::read(void)
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "TYPE_MESH_RDONLY_DRIVER::read() : " ;
+ BEGIN_OF(LOC);
+
+ if (_status!=MED_OPENED)
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << " (the file is not opened)." )) ;
+
+ _ptrMesh->_name = _meshName;
+
+
+ END_OF(LOC);
+}
+
+void TYPE_MESH_RDONLY_DRIVER::write( void ) const
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("TYPE_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
+}
+
+
+/*--------------------- WRONLY PART -------------------------------*/
+
+TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER():TYPE_MESH_DRIVER()
+{
+}
+
+TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ TYPE_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
+{
+ MESSAGE("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver):
+ TYPE_MESH_DRIVER(driver)
+{
+}
+
+TYPE_MESH_WRONLY_DRIVER::~TYPE_MESH_WRONLY_DRIVER()
+{
+ //MESSAGE("TYPE_MESH_WRONLY_DRIVER::TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * TYPE_MESH_WRONLY_DRIVER::copy(void) const
+{
+ return new TYPE_MESH_WRONLY_DRIVER(*this);
+}
+
+void TYPE_MESH_WRONLY_DRIVER::read (void)
+ throw (MEDEXCEPTION)
+{
+ throw MEDEXCEPTION("TYPE_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
+}
+
+void TYPE_MESH_WRONLY_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ const char * LOC = "void TYPE_MESH_WRONLY_DRIVER::write(void) const : ";
+ BEGIN_OF(LOC);
+
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
+
+ END_OF(LOC);
+}
+
+
+
+/*--------------------- RDWR PART -------------------------------*/
+
+TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER():TYPE_MESH_DRIVER()
+{
+}
+
+TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName,
+ MESH * ptrMesh):
+ TYPE_MESH_DRIVER(fileName,ptrMesh,MED_RDWR)
+{
+ MESSAGE("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
+}
+
+TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver):
+ TYPE_MESH_RDONLY_DRIVER::TYPE_MESH_DRIVER(driver)
+{
+}
+
+TYPE_MESH_RDWR_DRIVER::~TYPE_MESH_RDWR_DRIVER() {
+ //MESSAGE("TYPE_MESH_RDWR_DRIVER::TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
+}
+
+GENDRIVER * TYPE_MESH_RDWR_DRIVER::copy(void) const
+{
+ return new TYPE_MESH_RDWR_DRIVER(*this);
+}
+
+void TYPE_MESH_RDWR_DRIVER::write(void) const
+ throw (MEDEXCEPTION)
+{
+ TYPE_MESH_WRONLY_DRIVER::write();
+}
+void TYPE_MESH_RDWR_DRIVER::read (void)
+ throw (MEDEXCEPTION)
+{
+ TYPE_MESH_RDONLY_DRIVER::read();
+}
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : MEDMEM_TypeMeshDriver.hxx
+// Module : MED
+
+#ifndef TYPE_MESH_DRIVER_HXX
+#define TYPE_MESH_DRIVER_HXX
+
+#include <string>
+#include <vector>
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_GenDriver.hxx"
+
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+#include "utilities.h"
+
+class MESH;
+class FAMILY;
+class GROUP;
+class CONNECTIVITY;
+
+/*!
+
+ Driver TYPE for MESH.
+
+ Generic part : implement the readopen and close methods.
+
+*/
+
+
+class TYPE_MESH_DRIVER : public GENDRIVER
+{
+protected:
+
+ MESH * _ptrMesh;
+ // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
+ string _meshName;
+
+public :
+
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_DRIVER(const string & fileName,
+ MESH * ptrMesh,
+ med_mode_acces accessMode) ;
+ /*!
+ Copy constructor.
+ */
+ TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~TYPE_MESH_DRIVER() ;
+
+ void open() throw (MEDEXCEPTION);
+ void close() throw (MEDEXCEPTION);
+
+ virtual void write( void ) const = 0 ;
+ virtual void read ( void ) = 0 ;
+
+ /*!
+ Set the name of the MESH asked in file.
+
+ It could be different than the name of the MESH object.
+ */
+ void setMeshName(const string & meshName) ;
+ /*!
+ Get the name of the MESH asked in file.
+ */
+ string getMeshName() const ;
+
+private:
+ virtual GENDRIVER * copy ( void ) const = 0 ;
+
+};
+
+
+class TYPE_MESH_RDONLY_DRIVER : public virtual TYPE_MESH_DRIVER
+{
+
+public :
+
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_RDONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~TYPE_MESH_RDONLY_DRIVER() ;
+
+ /*!
+ Return a MEDEXCEPTION : it is the read-only driver.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+
+ GENDRIVER * copy ( void ) const ;
+
+};
+
+/*!
+
+ Driver Med for MESH : Write only.
+
+ Implement write method.
+
+*/
+
+class TYPE_MESH_WRONLY_DRIVER : public virtual TYPE_MESH_DRIVER {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_WRONLY_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ virtual ~TYPE_MESH_WRONLY_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write( void ) const throw (MEDEXCEPTION);
+ /*!
+ Return a MEDEXCEPTION : it is the write-only driver.
+ */
+ void read ( void ) throw (MEDEXCEPTION);
+
+private:
+
+ GENDRIVER * copy ( void ) const ;
+};
+
+
+/*!
+
+ Driver TYPE for MESH : Read write.
+ - Use read method from TYPE_MESH_RDONLY_DRIVER
+ - Use write method from TYPE_MESH_WRONLY_DRIVER
+
+*/
+
+class TYPE_MESH_RDWR_DRIVER : public TYPE_MESH_RDONLY_DRIVER, public TYPE_MESH_WRONLY_DRIVER {
+
+public :
+
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_RDWR_DRIVER() ;
+ /*!
+ Constructor.
+ */
+ TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
+ /*!
+ Copy constructor.
+ */
+ TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver) ;
+
+ /*!
+ Destructor.
+ */
+ ~TYPE_MESH_RDWR_DRIVER() ;
+
+ /*!
+ Write MESH in the specified file.
+ */
+ void write(void) const throw (MEDEXCEPTION);
+ /*!
+ Read MESH in the specified file.
+ */
+ void read (void) throw (MEDEXCEPTION);
+
+private:
+ GENDRIVER * copy(void) const ;
+
+};
+
+
+#endif /* TYPE_MESH_DRIVER_HXX */
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Unit.cxx
+// Module : MED
+
+using namespace std;
/*
File MEDMEM_Unit.cxx
$Header$
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_Unit.hxx
+// Module : MED
+
/*
File Unit.hxx
$Header$
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_VtkMedDriver.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_VtkMedDriver.hxx"
+#include <sstream>
+
+#include "MEDMEM_define.hxx"
#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_CellModel.hxx"
VTK_MED_DRIVER::VTK_MED_DRIVER(): GENDRIVER(),
- _ptrMed((MED * const)MED_NULL),
- _vtkFile(MED_INVALID)
+ _ptrMed((MED * const)MED_NULL)
{
+ _vtkFile = new ofstream();
// What about _id in Gendriver ?
// _driverType ???
}
VTK_MED_DRIVER::VTK_MED_DRIVER(const string & fileName, MED * const ptrMed):
- GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _vtkFile(MED_INVALID)
+ GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed)
{
+ _ptrMed->addDriver(*this); // OU RECUPERER L'ID.
+ _vtkFile = new ofstream();
// What about _id in Gendriver ?
// _driverType ???
}
-//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui
+VTK_MED_DRIVER::VTK_MED_DRIVER(const VTK_MED_DRIVER & driver):
+ GENDRIVER(driver),
+ _ptrMed(driver._ptrMed)
+{
+ _ptrMed->addDriver(*this); // OU RECUPERER L'ID.
+ _vtkFile = new ofstream();
+ // What about _id in Gendriver ?
+ // _driverType ???
+}
+VTK_MED_DRIVER::~VTK_MED_DRIVER()
+{
+ close();
+ delete _vtkFile ;
+}
-void VTK_MED_DRIVER::open() {
+GENDRIVER * VTK_MED_DRIVER::copy() const
+{
+ return new VTK_MED_DRIVER(*this) ;
+}
+
+//REM : As t'on besoin du champ _status : _vtkFile <-> _status ? Oui
+
+void VTK_MED_DRIVER::openConst() const {
const char * LOC ="VTK_MED_DRIVER::open() : ";
BEGIN_OF(LOC);
- // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
-// if ( _vtkFile != MED_INVALID )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
-// << "_vtkFile is already in use, please close the file |"
-// << _fileName << "| before calling open()"
-// )
-// );
-
- if ( _status != MED_CLOSED )
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
- << "_status is not closed, please close the file |"
- << _fileName << "| before calling open()"
- )
- );
-
if ( _fileName == "" )
throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
<< "_fileName is |\"\"|, please set a correct fileName before calling open()"
)
);
- _vtkFile.open(filename.c_str()) ; // ? if error ????
- _status = MED_OPENED ;
-
-// if (_vtkFile > 0) _status=MED_OPENED;
-// else {
-// _status = MED_CLOSED;
-// _vtkFile = MED_INVALID;
-// throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
-// << "Can't open |" << _fileName
-// << "|, _vtkFile : " << _vtkFile
-// )
-// );
-// }
-
+
+ if (!(*_vtkFile).is_open())
+ (*_vtkFile).open(_fileName.c_str()) ;
+// if (*_vtkFile)
+// _status = MED_OPENED ;
+// else
+ if (!(*_vtkFile))
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not open file "
+ << _fileName)
+ );
END_OF(LOC);
}
+void VTK_MED_DRIVER::open() {
+ openConst() ;
+}
-void VTK_MED_DRIVER::close() {
+void VTK_MED_DRIVER::closeConst() const {
- const char * LOC = "MED_MED_DRIVER::close() : ";
+ const char * LOC = "VTK_MED_DRIVER::close() : ";
BEGIN_OF(LOC);
- if ( _status == MED_CLOSED)
- throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
- << _fileName << "| is already closed"
- )
- );
-
- // if ( _vtkFile == MED_INVALID )
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_vtkFile invalid, but the file |"
-// << _fileName << "| seems to be openned !"
-// )
-// );
- vtkFile_.close();
-
- _status = MED_CLOSED;
- // _vtkFile = MED_INVALID;
-
-// if (err != MED_VALID)
-// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
-// << _fileName << "| couldn't be closed"
-// )
-// );
+ (*_vtkFile).close();
+// if (*_vtkFile)
+// _status = MED_CLOSED ;
+// else
+ if (!(*_vtkFile))
+ throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Could not close file "
+ << _fileName)
+ );
END_OF(LOC);
}
+void VTK_MED_DRIVER::close() {
+ closeConst() ;
+}
+
-void VTK_MED_DRIVER::write() {
+void VTK_MED_DRIVER::write() const {
- const char * LOC = "MED_MED_DRIVER::write() : ";
+ const char * LOC = "VTK_MED_DRIVER::write() : ";
BEGIN_OF(LOC);
+ // Well we must open vtk file first, because there are
+ // no other driver than MED for VTK that do it !
+ openConst() ;
+
// could we put more than one Mesh ?????
- _vtkFile << "# vtk DataFile Version 2.0" << endl
- << "maillage SALOLME" << endl ;
- // only ASCII for the moment (binary came latest :-)
- _vtkFile << "ASCII" << endl ;
-
- int NumberOfMeshes = _ptrMED->getNumberOfMeshes() ;
- string * MeshName = new string[NumberOfMeshes] ;
- _ptrMED->getMeshNames(MeshName) ;
+ (*_vtkFile) << "# vtk DataFile Version 2.0" << endl
+ << "maillage from MedMemory" << endl ;
+ // only ASCII for the moment (binary came later :-)
+ (*_vtkFile) << "ASCII" << endl ;
+
+ int NumberOfMeshes = _ptrMed->getNumberOfMeshes() ;
+ deque<string> MeshNames = _ptrMed->getMeshNames() ;
+ deque<string>::const_iterator currentMesh ;
// In fact, we must take care of all supports
// We restrict Field on all nodes or cells
+
+ int NumberOfFields = _ptrMed->getNumberOfFields() ;
+ deque<string> FieldNames = _ptrMed->getFieldNames() ;
+ deque<string>::const_iterator currentField ;
+
+ // for ( currentMesh=MeshName.begin();currentMesh != MeshName.end(); currentMesh++) {
for (int i=0; i<NumberOfMeshes; i++) {
- MESH * myMesh = _ptrMED->getMesh(MeshName[i]) ;
+ MESH * myMesh = _ptrMed->getMesh(MeshNames[i]) ;
writeMesh(myMesh) ;
// get all field which values are on this mesh => revoir api de Med !!!
- _vtkFile << "NODE" << endl ;
// first : field on node
+ // fields is on all node !
+ (*_vtkFile) << "POINT_DATA " << myMesh->getNumberOfNodes() << endl ;
for (int j=0; j<NumberOfFields; j++) {
- FIELD_ * myField = _ptrMED->getField() ;
- if (myField->getSupport()->getEntity()!=MED_NODE)
- if (myField->getSupport()->isOnAllElements())
- writeField(myField) ;
-
+ deque<DT_IT_> timeStep = _ptrMed->getFieldIteration(FieldNames[j]) ;
+ deque<DT_IT_>::const_iterator currentTimeStep ;
+ for ( currentTimeStep=timeStep.begin(); currentTimeStep!=timeStep.end(); currentTimeStep++) {
+ int dt = (*currentTimeStep).dt ;
+ int it = (*currentTimeStep).it ;
+ FIELD_ * myField = _ptrMed->getField(FieldNames[j],dt,it) ;
+ if( MeshNames[i] == myField->getSupport()->getMesh()->getName() ) {
+ // rigth in all case : better compare pointeur ?
+ if (MED_NODE == myField->getSupport()->getEntity())
+ if (myField->getSupport()->isOnAllElements()) {
+ ostringstream name ;
+ name << myField->getName() << "_" << dt << "_" << it ;
+ writeField(myField,name.str()) ;
+ } else
+ INFOS("Could not write field "<<myField->getName()<<" which is not on all nodes !");
+ }
+ }
}
- _vtkFile << "CELL" << endl ;
+
+ (*_vtkFile) << "CELL_DATA " << myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl ;
// second : field on cell
for (int j=0; j<NumberOfFields; j++) {
- FIELD_ * myField = _ptrMED->getField() ;
- if (myField->getSupport()->getEntity()!=MED_CELL)
- if (myField->getSupport()->isOnAllElements())
- writeField(myField) ;
-
+ deque<DT_IT_> timeStep = _ptrMed->getFieldIteration(FieldNames[j]) ;
+ deque<DT_IT_>::const_iterator currentTimeStep ;
+ for ( currentTimeStep=timeStep.begin(); currentTimeStep!=timeStep.end(); currentTimeStep++) {
+ int dt ;
+ int it ;
+ FIELD_ * myField = _ptrMed->getField(FieldNames[j],dt,it) ;
+ if( MeshNames[i] == myField->getSupport()->getMesh()->getName() ) {
+ // rigth in all case : better compare pointeur ?
+ if (MED_CELL == myField->getSupport()->getEntity())
+ if (myField->getSupport()->isOnAllElements()) {
+ ostringstream name ;
+ name << myField->getName() << "_" << dt << "_" << it ;
+ writeField(myField,name.str()) ;
+ } else
+ INFOS("Could not write field "<<myField->getName()<<" which is not on all cells !");
+ }
+ }
}
}
+ // Well we must close vtk file first, because there are
+ // no other driver than MED for VTK that do it !
+ closeConst() ;
+
END_OF(LOC);
}
-void VTK_MED_DRIVER::writeMesh(MESH * myMesh) {
+void VTK_MED_DRIVER::writeMesh(MESH * myMesh) const {
- const char * LOC = "MED_MED_DRIVER::writeMesh() : ";
+ const char * LOC = "VTK_MED_DRIVER::writeMesh() : ";
BEGIN_OF(LOC);
- _vtkFile << "DATASET UNSTRUCTURED_GRID" << endl ;
+ (*_vtkFile) << "DATASET UNSTRUCTURED_GRID" << endl ;
// put points (all point are in 3D, so if we are in 1D or 2D, we complete by zero !
int SpaceDimension = myMesh->getSpaceDimension() ;
int NumberOfNodes = myMesh->getNumberOfNodes() ;
- _vtkFile << "POINTS " << NumberOfNodes << " float" << endl ;
- double *coordinate = myMesh->getCoordinates(MED_FULL_ENTERLACE) ;
- if (SpaceDimension<3) { // 1D or 2D
- coordinate_z = new double[NumberOfNodes] ;
- // we put zero :
- for (int i=0;i<NumberOfNodes;i++)
- coordinate_z[i] = 0.0 ;
+ (*_vtkFile) << "POINTS " << NumberOfNodes << " float" << endl ;
+ const double *coordinate = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
+ for (int i=0;i<NumberOfNodes;i++) {
+ for (int j=0;j<SpaceDimension;j++)
+ (*_vtkFile) << coordinate[i*SpaceDimension+j] << " " ;
if (SpaceDimension==1)
- coordinate_y = coordinate_z ; // only one array of zero !
- else
- coordinate_y = coordinate_x + NumberOfNodes ;
- } else {
- coordinate_y = coordinate_x + NumberOfNodes ;
- coordinate_z = coordinate_y + NumberOfNodes ;
+ (*_vtkFile) << "0 0" ;
+ if (SpaceDimension==2)
+ (*_vtkFile) << "0" ;
+ (*_vtkFile) << endl ;
}
- for (int i=0;i<NumberOfNodes;i++)
- for (int j=0;j<SpaceDimension;j++)
- _vtkFile << coordinate[i*SpaceDimension+j] << " " ;
- if (SpaceDimension==1)
- _vtkFile << "0 0" ;
- if (SpaceDimension==2)
- _vtkFile << "0" ;
- _vtkFile << endl ;
// we put connectivity
// how many cells and how many value in connectivity :
int cells_types_count = myMesh->getNumberOfTypes(MED_CELL) ;
- int * cells_count = myMesh->get_cells_count() ;
- int cells_sum = cells_count[cells_types_count] ;
- CellModel * cells_type = myMesh->get_cells_type() ;
- int connectivity_sum = 0 ;
+ // int * cells_count = myMesh->get_cells_count() ;
+ // int cells_sum = cells_count[cells_types_count] ;
+ int cells_sum = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ;
+ const CELLMODEL * cells_type = myMesh->getCellsTypes(MED_CELL) ;
+ // int connectivity_sum = 0 ;
- int * connectivity = myMesh->getConnectivity(MED_FULL_ENTERLACE,MED_CELL,MED_ALL_ELEMENTS) ;
- int * connectivityIndex = myMesh->getConnectivityIndex(MED_CELL) ;
+ const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) ;
+ const int * connectivityIndex = myMesh->getConnectivityIndex(MED_NODAL,MED_CELL) ;
- for (int i=0;i<cells_types_count;i++) {
- int nodes_cell = cells_type[i].getNumberOfNodes();
- connectivity_sum+= (cells_count[i+1]-cells_count[i])*(nodes_cell + 1);
- // we add 1 because we put nodes count in vtk file !
- }
- _vtkFile << "CELLS " << cells_sum << " " << connectivity_sum << endl ;
+ int connectivity_sum = connectivityIndex[cells_sum]-1 ;
+
+ (*_vtkFile) << "CELLS " << cells_sum << " " << connectivity_sum+cells_sum << endl ;
// we put connectivity
for (int i=0;i<cells_types_count;i++) {
int *filter = (int*) NULL ; // index in vtk connectivity
- switch (cells_type[i].get_type())
+ switch (cells_type[i].getType())
{
case MED_POINT1 : {
filter = new int[1] ;
}
}
if (filter==NULL)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].get_type() ) ) ;
- int nodes_cell = cells_type[i].get_NumberOfNodes();
- for (int j=0;j<cells_count[i+1]-cells_count[i];j++) {
- _vtkFile << nodes_cell << " " ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getName() ) ) ;
+ int nodes_cell = cells_type[i].getNumberOfNodes();
+ int numberOfCell = myMesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+ const int * connectivityArray = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,cells_type[i].getType());
+ for (int j=0;j<numberOfCell;j++) {
+ (*_vtkFile) << nodes_cell << " " ;
for (int k=0;k<nodes_cell;k++)
- _vtkFile << (myMesh->get_nodal_connectivity(i+1))[j*nodes_cell+filter[k]] - 1 << " " ;
- _vtkFile << endl ;
+ (*_vtkFile) << connectivityArray[j*nodes_cell+filter[k]] - 1 << " " ;
+ (*_vtkFile) << endl ;
}
+ if (filter != NULL)
+ delete[] filter ;
}
- _vtkFile << endl ;
+ (*_vtkFile) << endl ;
// we put cells type
- _vtkFile << "CELL_TYPES " << cells_sum << endl ;
+ (*_vtkFile) << "CELL_TYPES " << cells_sum << endl ;
for (int i=0;i<cells_types_count;i++) {
int vtkType = 0 ;
- switch (cells_type[i].get_type())
+ switch (cells_type[i].getType())
{
case MED_POINT1 : {
vtkType = 1 ;
}
}
if (vtkType == 0)
- throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].get_type() ) ) ;
- for (int j=0;j<cells_count[i+1]-cells_count[i];j++)
- _vtkFile << vtkType << endl ;
- if (filter != NULL)
- delete[] filter ;
+ throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": MED element type not supported yet : " << cells_type[i].getType() ) ) ;
+ int numberOfCell = myMesh->getNumberOfElements(MED_CELL,cells_type[i].getType()) ;
+ for (int j=0;j<numberOfCell;j++)
+ (*_vtkFile) << vtkType << endl ;
}
// add a constant field on all node to test !
// for (int i=0;i<NumberOfNodes;i++)
// _vtkFile << i << endl ;
- return 1 ;
+ return ;
END_OF(LOC);
}
-void VTK_MED_DRIVER::writeField(FIELD * myField) {
+void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const {
- const char * LOC = "MED_MED_DRIVER::writeField() : ";
+ const char * LOC = "VTK_MED_DRIVER::writeField() : ";
BEGIN_OF(LOC);
-
-
+ int NomberOfValue = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ;
+ int NomberOfComponents = myField->getNumberOfComponents() ;
+
+ med_type_champ type = myField->getValueType() ;
+ SCRUTE(name);
+ SCRUTE(type);
+ switch (type)
+ {
+ case MED_INT32 : {
+ MESSAGE("MED_INT32");
+ if (NomberOfComponents==3) {
+ (*_vtkFile) << "VECTORS " << name << " int" << endl ;
+ } else if (NomberOfComponents<=4) {
+ (*_vtkFile) << "SCALARS " << name << " int " << NomberOfComponents << endl ;
+ (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+ } else {
+ INFOS("Could not write field "<<myField->getName()<<" there are more than 4 components !");
+ return ;
+ }
+
+ //const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
+ const int * value = ((FIELD<int>*)myField)->getValue(MED_NO_INTERLACE) ;
+ for (int i=0; i<NomberOfValue; i++) {
+ for(int j=0; j<NomberOfComponents; j++)
+ (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+ (*_vtkFile) << endl ;
+ }
+ break ;
+ }
+ case MED_REEL64 : {
+ MESSAGE("MED_REEL64");
+ if (NomberOfComponents==3) {
+ (*_vtkFile) << "VECTORS " << name << " float" << endl ;
+ } else if (NomberOfComponents<=4) {
+ (*_vtkFile) << "SCALARS " << name << " float " << NomberOfComponents << endl ;
+ (*_vtkFile) << "LOOKUP_TABLE default" << endl ;
+ } else {
+ INFOS("Could not write field "<<myField->getName()<<" there are more than 4 components !");
+ return ;
+ }
+ const double * value = ((FIELD<double>*)myField)->getValue(MED_NO_INTERLACE) ;
+ for (int i=0; i<NomberOfValue; i++) {
+ for(int j=0; j<NomberOfComponents; j++)
+ (*_vtkFile) << value[j*NomberOfValue+i] << " " ;
+ (*_vtkFile) << endl ;
+ }
+ break ;
+ }
+ default : {
+ INFOS("Could not write field "<<name<<" the type is not int or double !");
+ }
+ }
+
END_OF(LOC);
}
+
+void VTK_MED_DRIVER::writeSupport(SUPPORT * mySupport) const {
+ const char * LOC = "VTK_MED_DRIVER::writeSupport(SUPPORT *)" ;
+ BEGIN_OF(LOC) ;
+ END_OF(LOC) ;
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_VtkMedDriver.hxx
+// Module : MED
+
#ifndef VTK_MED_DRIVER_HXX
#define VTK_MED_DRIVER_HXX
#include "MEDMEM_GenDriver.hxx"
+#include <fstream>
+
+using namespace std ;
class MESH;
+class SUPPORT;
class FIELD_;
class MED;
// This driver pilots within a VTK class read/write accesses of fields/meshes
-class VTK_VTK_DRIVER : public GENDRIVER
+class VTK_MED_DRIVER : public GENDRIVER
{
protected:
- MED * const _ptrMED ; // Store 'VTK_DRIVER (0..n)----(1) VTK' associations
- ofstream _vtkFile ; // The _vtkFile used to write Meshes and Fields to _filename
+ MED * const _ptrMed ; // Store 'VTK_DRIVER (0..n)----(1) VTK' associations
+ ofstream * _vtkFile ; // The _vtkFile used to write Meshes and Fields to _filename
private:
VTK_MED_DRIVER();
+ //writeField(FIELD * myField) ;
+ //writeMesh(MESH * myMesh) ;
+
+ void open() ;
+ void close() ;
+ void openConst() const ;
+ void closeConst() const ;
+
public :
VTK_MED_DRIVER(const string & fileName, MED * const ptrMed);
+ VTK_MED_DRIVER(const VTK_MED_DRIVER & driver);
+ ~VTK_MED_DRIVER();
// OPERATEUR DE RECOPIE AVEC _vtkFile ??
- void open();
- void close();
-
- virtual void write ( void ) const ;
+ //virtual void write ( void ) ;
+ void write ( void ) const ;
+ virtual void read ( void ) {} ;
// virtual void writeFrom ( void ) const ;
// virtual void read ( void ) ;
+ GENDRIVER * copy (void ) const ;
-protected :
- void writeMesh(MESH * myMesh) ;
- void writeField(FIELD_ * myField) ;
+private :
+ void writeMesh(MESH * myMesh) const ;
+ void writeSupport(SUPPORT * mySupport) const ;
+ void writeField(FIELD_ * myField,string name) const ;
};
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_define.hxx
+// Module : MED
+
#ifndef DEFINE_HXX
#define DEFINE_HXX
#include <stdio.h>
-#include <iostream.h>
-#include <string.h>
+#include <iostream>
+#include <string>
#include <assert.h>
// UTILE AUX DEUX NAMESPACES
#define MED_TAILLE_LNOM 80
#define MED_TAILLE_PNOM 8
+typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type;
+
typedef enum {MED_FULL_INTERLACE,
MED_NO_INTERLACE} medModeSwitch;
-#==============================================================================
-# File : Makefile.in
-# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS)
-# CVS : $Header$
-#==============================================================================
+# MED MEDMEM : MED files in memory
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Patrick GOLDBRONN (CEA/DEN/DM2S/SFME/LGLS)
+# Module : MED
-# source path
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
-VPATH=.:$(srcdir)
+VPATH=.:$(srcdir):$(srcdir)/tests
MACHINE=PCLINUX
EXPORT_HEADERS = \
+MEDMEM_PointerOf.hxx \
MEDMEM_CellModel.hxx \
MEDMEM_Connectivity.hxx \
MEDMEM_Coordinate.hxx \
MEDMEM_Med.hxx \
MEDMEM_MedMedDriver.hxx \
MEDMEM_MedMeshDriver.hxx \
+MEDMEM_GibiMeshDriver.hxx \
MEDMEM_ModulusArray.hxx \
MEDMEM_SkyLineArray.hxx \
MEDMEM_VtkMedDriver.hxx \
MEDMEM_Mesh.hxx \
+MEDMEM_Meshing.hxx \
MEDMEM_STRING.hxx \
MEDMEM_Support.hxx \
-MEDMEM_Unit.hxx
+MEDMEM_Unit.hxx \
+MEDMEM_Grid.hxx
# Libraries targets
MEDMEM_Exception.cxx \
MEDMEM_MedMedDriver.cxx \
MEDMEM_MedMeshDriver.cxx \
+MEDMEM_GibiMeshDriver.cxx \
MEDMEM_SkyLineArray.cxx \
MEDMEM_Mesh.cxx \
+MEDMEM_Meshing.cxx \
MEDMEM_Support.cxx \
MEDMEM_Unit.cxx \
-
-#VtkMedDriver.cxx \
+MEDMEM_VtkMedDriver.cxx \
+MEDMEM_Grid.cxx
# Executables targets
-BIN = duplicateMED med_test duplicateMEDMESH
+BIN = med2vtk duplicateMED med_test duplicateMEDMESH
BIN_SRC =
BIN_SERVER_IDL =
BIN_CLIENT_IDL =
-TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel
+TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing
+
+# testUCellModel -> a revoir car l'API a changee (plus de vector)
-CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES)
-CXXFLAGS+=-ftemplate-depth-42
-LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer
+CPPFLAGS+=$(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(inc_builddir) -I$(srcdir) -I.
+LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -L$(top_builddir)/lib -lstdc++ -lSalomeLoggerServer
# build create_mesh :
-bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong
+bin: create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong create_mesh_c2q4s2_wrong create_grid
-create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4: %: %.c
+create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_grid: %: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $(LDFLAGS) $<
@CONCLUDE@
--- /dev/null
+/*----------------------------------------------------------------------------
+MED MEDMEM : MED files in memory
+
+ Copyright (C) 2003 CEA/DEN, EDF R&D
+
+
+
+ File : create_grid.c
+Module : MED
+----------------------------------------------------------------------------*/
+
+/******************************************************************************
+ * - Nom du fichier : test19.c
+ *
+ * - Description : ecriture des objets MED relatifs aux grilles
+ * MED V2.0
+ *
+ *****************************************************************************/
+
+#include <med.h>
+#include <string.h>
+
+/******************************************************************************
+ * - creation d'un fichier MED
+ * - ecriture des noeuds : coordonnees en mode MED_FULL_INTERLACE,
+ * noms,numeros,numeros de familles
+ * - ecriture des familles d'un maillage MED
+ * 2.0 via les routines de bas niveau
+ * - fermeture du fichier
+ *****************************************************************************/
+
+int main (int argc, char **argv)
+{
+
+/* Ecriture d'un premier maillage non structure (test14 + test8)
+ ************************************************************* */
+
+ med_err ret;
+ med_idt fid;
+ /* la dimension du maillage */
+ med_int mdim = 2;
+ /* nom du maillage de longueur maxi MED_TAILLE_NOM */
+ char maa[MED_TAILLE_NOM+1] = "maa1";
+ /* le nombre de noeuds */
+ med_int nnoe = 4;
+ /* table des coordonnees
+ profil : (dimension * nombre de noeuds) */
+ med_float coo[8] = {0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0};
+ med_int nbr[2] = {2, 2};
+ /* tables des noms et des unites des coordonnees
+ profil : (dimension*MED_TAILLE_PNOM+1) */
+ char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
+ char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
+ /* tables des noms, numeros, numeros de familles des noeuds
+ autant d'elements que de noeuds - les noms ont pout longueur
+ MED_TAILLE_PNOM */
+ char nomnoe[4*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4 ";
+ med_int numnoe[4] = {1,2,3,4};
+ med_int nufano[4] = {0,1,2,2};
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ char attdes[MED_TAILLE_DESC+1];
+ med_int natt;
+ med_int attide;
+ med_int attval;
+ med_int ngro;
+ char gro[MED_TAILLE_LNOM+1];
+ int i;
+ int nfame = 1;
+ int nfamn = 2;
+ med_int fam[16];
+ /*
+ les elements:
+ */
+ med_int nquad4 = 1;
+ med_int quad4[4] = {
+ 1, 2, 4, 3
+ };
+ char nomquad4[MED_TAILLE_PNOM*1+1] = "quad1 ";
+ med_int numquad4[1] = {1};
+ med_int nufaquad4[1] = {-1};
+
+ fid = MEDouvrir("test19.med",MED_REMP);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ /* creation du maillage maa de dimension 2 */
+ if (ret == 0)
+ ret = MEDmaaCr(fid,maa,mdim);
+ printf("%d\n",ret);
+
+ /* ecriture des noeuds d'un maillage MED :
+ - des coo en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...)
+ dans un repere cartesien
+ - des noms (optionnel dans un fichier MED)
+ - des numeros (optionnel dans un fichier MED)
+ - des numeros de familles des noeuds */
+ if (ret == 0)
+ ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nomnoe,MED_VRAI,numnoe,MED_VRAI,
+ nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /* ecriture des mailles MED_QUAD4 :
+ - connectivite
+ - noms (optionnel)
+ - numeros (optionnel)
+ - numeros des familles */
+ if (ret == 0)
+ ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
+ nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
+ MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
+ printf("%d \n",ret);
+
+ /* ecriture des familles */
+ /* Conventions :
+ - toujours creer une famille de numero 0 ne comportant aucun attribut
+ ni groupe (famille de reference pour les noeuds ou les elements
+ qui ne sont rattaches a aucun groupe ni attribut)
+ - les numeros de familles de noeuds sont > 0
+ - les numeros de familles des elements sont < 0
+ - rien d'imposer sur les noms de familles
+ */
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+ /* on cree pour correspondre aux cas tests precedents, 3 familles
+ d'elements (-1,-2,-3) et deux familles de noeuds (1,2) */
+ if (ret == 0)
+ {
+ nfame = 1;
+ for (i=0;i<nfame;i++)
+ {
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_ELEMENT_");
+ numfam = -(i+1);
+ sprintf(nomfam,"%s%d",nomfam,-numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+ printf("%s - %d - %d - %d - %d \n",nomfam,numfam,attide,attval,
+ ngro);
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr (elements) : %d\n",ret);
+ }
+ }
+ }
+
+ if (ret == 0)
+ {
+ nfamn = 2;
+ for (i=0;i<nfamn;i++)
+ {
+ if(ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_");
+ numfam = i+1;
+ sprintf(nomfam,"%s%d",nomfam,numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+ printf("%s - %d - %d - %d - %d \n",nomfam,numfam,attide,attval,
+ ngro);
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr (nodes) : %d\n",ret);
+ }
+ }
+ }
+
+
+ /* fermeture du fichier */
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+/* Ecriture d'un deuxieme maillage structure : body fitted
+ ******************************************************* */
+
+ fid = MEDouvrir("test19.med",MED_ECRI);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ strcpy(maa, "bodyfitted");
+ /* creation du maillage body fitted maa de dimension 2 */
+ if (ret == 0)
+ ret = MEDgridCr(fid, maa, mdim, MED_BODY_FITTED);
+ printf("%d\n",ret);
+
+ /* ecriture des noeuds d'un maillage MED :
+ - des coo en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...)
+ dans un repere cartesien
+ - des noms (optionnel dans un fichier MED)
+ - des numeros (optionnel dans un fichier MED)
+ - des numeros de familles des noeuds */
+ if (ret == 0)
+ ret = MEDbodyFittedEcr(fid,maa,mdim,coo,nbr,MED_FULL_INTERLACE,MED_CART,
+ nomcoo,unicoo,nufano,nnoe,MED_ECRI);
+ printf("%d\n",ret);
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+
+
+ if (ret == 0)
+ {
+ nfamn = 2;
+ for (i=0;i<nfamn;i++)
+ {
+ if(ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_");
+ numfam = i+1;
+ sprintf(nomfam,"%s%d",nomfam,numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+ printf("%s - %d - %d - %d - %d \n",nomfam,numfam,attide,attval,
+ ngro);
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr (nodes) : %d\n",ret);
+ }
+ }
+ }
+
+
+
+
+ /* fermeture du fichier */
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+/* Ecriture d'un troisieme maillage structure : grille cartesienne
+ *************************************************************** */
+
+ fid = MEDouvrir("test19.med", MED_ECRI);
+ if (fid < 0)
+ ret = -1;
+ else
+ ret = 0;
+ printf("%d\n",ret);
+
+ strcpy(maa, "CartGrid");
+ /* creation d'une grille cartesienne maa de dimension 2 */
+ if (ret == 0)
+ ret = MEDgridCr(fid, maa, mdim, MED_CARTESIAN);
+ printf("%d\n",ret);
+
+ /* Ecriture des indices de la grille cartesienne :
+ - des coo en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...) */
+ for (i=0; i<mdim; i++) {
+ coo[0] = 1.1+i;
+ coo[1] = 1.2+i;
+ coo[2] = 1.3+i;
+ coo[3] = 1.4+i;
+ if (ret == 0) {
+ ret = MEDgridEcr(fid, maa, mdim, coo, nnoe, i, MED_FULL_INTERLACE, MED_CART, nomcoo, unicoo, MED_ECRI);
+ };
+ };
+ printf("%d\n",ret);
+
+ /* Ecriture des familles de la grille cartesienne */
+ if (ret == 0) {
+ fam[ 0]=3; fam[ 1]=3; fam[ 2]=2; fam[ 3]=1;
+ fam[ 4]=7; fam[ 5]=8; fam[ 6]=2; fam[ 7]=4;
+ fam[ 8]=2; fam[ 9]=9; fam[10]=0; fam[11]=2;
+ fam[12]=5; fam[13]=5; fam[14]=6; fam[15]=7;
+ ret = MEDfamGridEcr(fid, maa, fam, 16, MED_ECRI,MED_NOEUD);
+ };
+
+
+ /* la famille 0 */
+ if (ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_0");
+ numfam = 0;
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
+ gro,0);
+ }
+ printf("%d \n",ret);
+
+
+ if (ret == 0)
+ {
+ nfamn = 9;
+ for (i=0;i<nfamn;i++)
+ {
+ if(ret == 0)
+ {
+ strcpy(nomfam,"FAMILLE_NOEUD_");
+ numfam = i+1;
+ sprintf(nomfam,"%s%d",nomfam,numfam);
+ attide = 1;
+ attval = numfam*100;
+ natt = 1;
+ strcpy(attdes,"description attribut");
+ strcpy(gro,"groupe1");
+ ngro = 1;
+ printf("%s - %d - %d - %d - %d \n",nomfam,numfam,attide,attval,
+ ngro);
+ ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
+ natt,gro,ngro);
+ printf("MEDfamCr (nodes) : %d\n",ret);
+ }
+ }
+ }
+
+
+ /* fermeture du fichier */
+ ret = MEDfermer(fid);
+ printf("%d\n",ret);
+
+ return 0;
+}
+/*----------------------------------------------------------------------------
+MED MEDMEM : MED files in memory
+
+ Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+ CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+
+
+ File : create_mesh.c
+Module : MED
+----------------------------------------------------------------------------*/
+
#include <med.h>
#include <string.h>
med_float fieldnodedouble1[19] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.};
med_float fieldnodedouble2[19] = {1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.};
- char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
+ char champ3[MED_TAILLE_NOM+1]="fieldcelldoublevector" ;
char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
- char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S M/s m/s " ;
- med_float fieldcelldouble1[12*3] = {1,1,1,2,2,2,3,3,3,4,4,4,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0};
- med_float fieldcelldouble2[2*3] = {5,5,0,1,0,1};
- med_float fieldcelldouble3[2*3] = {6,6,1,0,1,0};
+ char champ3_unit[MED_TAILLE_PNOM*3+1]="m/s m/s m/s " ;
+ med_float fieldcelldouble1[12*3] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,0.,0.,0.,1.,1.,1.,0.,0.,0.,1.,1.,1.,1.,1.,1.,0.,0.,0.,1.,1.,1.,0.,0.,0.};
+ med_float fieldcelldouble2[2*3] = {5.,5.,0.,1.,0.,1.};
+ med_float fieldcelldouble3[2*3] = {6.,6.,1.,0.,1.,0.};
+
+ char champ4[MED_TAILLE_NOM+1]="fieldcelldoublescalar" ;
+ char champ4_comp[MED_TAILLE_PNOM+1]="comp1 " ;
+ char champ4_unit[MED_TAILLE_PNOM+1]="m/s " ;
+ med_float fieldcelldouble4[12] = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};
+ med_float fieldcelldouble5[2] = {2.,2.};
+ med_float fieldcelldouble6[2] = {3.,3.};
/***************************************************************************/
fid = MEDouvrir("pointe.med",MED_REMP);
MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR);
printf("MEDchampEcr : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble3,
+ MED_NO_INTERLACE, nhexa8,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble2,
MED_NO_INTERLACE, npyra5,
MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
MED_PYRA5, MED_NOPDT," ", 0., MED_NONOR);
printf("MEDchampEcr : %d \n",ret);
- ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble3,
+ }
+ }
+
+ if (ret == 0)
+ {
+ ret = MEDchampCr(fid,champ4,MED_REEL64,champ4_comp,champ4_unit,1);
+ printf("MEDchampCr : %d \n",ret);
+ if (ret == 0) {
+ ret = MEDchampEcr(fid, maa, champ4, (unsigned char *)fieldcelldouble4,
+ MED_NO_INTERLACE, ntet4,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ4, (unsigned char *)fieldcelldouble6,
MED_NO_INTERLACE, nhexa8,
MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
printf("MEDchampEcr : %d \n",ret);
+ ret = MEDchampEcr(fid, maa, champ4, (unsigned char *)fieldcelldouble5,
+ MED_NO_INTERLACE, npyra5,
+ MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
+ MED_PYRA5, MED_NOPDT," ", 0., MED_NONOR);
+ printf("MEDchampEcr : %d \n",ret);
}
}
+/*----------------------------------------------------------------------------
+MED MEDMEM : MED files in memory
+
+ Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+ CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+
+
+ File : create_mesh_c2q4s2.c
+Module : MED
+----------------------------------------------------------------------------*/
+
/*
creation d'une geometrie 2d : un cube [0,1]^2
maillé uniformement en quadrangle reguliers;
+/*----------------------------------------------------------------------------
+MED MEDMEM : MED files in memory
+
+ Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+ CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+
+
+ File : create_mesh_c2q4s2_wrong.c
+Module : MED
+----------------------------------------------------------------------------*/
+
/*
creation d'une geometrie 2d : un cube [0,1]^2
maillé uniformement en quadrangle reguliers;
+/*----------------------------------------------------------------------------
+MED MEDMEM : MED files in memory
+
+ Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+ CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+
+
+ File : create_mesh_c3h8q4.c
+Module : MED
+----------------------------------------------------------------------------*/
+
/*
creation d'une geometrie 3d : un cube [0,1]^3
maillé uniformement en hexahedres reguliers;
+/*----------------------------------------------------------------------------
+MED MEDMEM : MED files in memory
+
+ Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+ CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+
+
+
+ File : create_mesh_c3h8q4_wrong.c
+Module : MED
+----------------------------------------------------------------------------*/
+
/*
creation d'une geometrie 3d : un cube [0,1]^3
maillé uniformement en hexahedres reguliers;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : duplicateMED.cxx
+// Module : MED
+
+using namespace std;
#include<string>
-#include<deque>
#include "MEDMEM_Exception.hxx"
-#include "MEDMEM_define.hxx"
-
#include "MEDMEM_Med.hxx"
-#include "MEDMEM_Mesh.hxx"
-#include "MEDMEM_Family.hxx"
-#include "MEDMEM_Support.hxx"
-#include "MEDMEM_Field.hxx"
-
-#include "MEDMEM_GenDriver.hxx"
-#include "MEDMEM_MedMedDriver.hxx"
-#include "MEDMEM_MedMeshDriver.hxx"
-#include "MEDMEM_MedFieldDriver.hxx"
-
void usage(char * name)
{
int main (int argc, char ** argv) {
if (argc != 3) usage(argv[0]);
-
+
string filenameIN = argv[1] ;
string filenameOUT = argv[2] ;
- MED * myMed = new MED() ;
- MED_MED_DRIVER myMedDriver(filenameIN,myMed) ;
-
- // we read all meshes and fields in filenameIN
try {
- int read ;
- myMedDriver.open();
- myMedDriver.readFileStruct();
- myMedDriver.close();
-
- // read all mesh
- MESSAGE("Read all meshes :") ;
- int NumberOfMeshes = myMed->getNumberOfMeshes() ;
- MESSAGE("Number of meshes : "<<NumberOfMeshes) ;
- deque<string> MeshName = myMed->getMeshNames() ;
- map<string,MESH*> _meshes ;
- for (int i=0; i<NumberOfMeshes; i++) {
- _meshes[MeshName[i]]=myMed->getMesh(MeshName[i]) ;
- _meshes[MeshName[i]]->read();
- MESSAGE(" - Mesh "<<i+1<<", named "<<MeshName[i]<<" read !");
- MED_MESH_WRONLY_DRIVER myMeshDriver(filenameOUT,_meshes[MeshName[i]]);
- myMeshDriver.setMeshName(MeshName[i]);
- myMeshDriver.open() ;
- myMeshDriver.write() ;
- myMeshDriver.close() ;
- }
+ MED myMed(MED_DRIVER,filenameIN) ; // do readFilestruct !
- // set support : support must be calculated with mesh information !!!
- myMed->updateSupport() ;
-
- // read all field
- MESSAGE("Read all fields :") ;
- int NumberOfFields = myMed->getNumberOfFields() ;
- MESSAGE("Number of fields : "<<NumberOfFields);
- deque<string> FieldName = myMed->getFieldNames() ;
- map<string,FIELD_*> _fields ;
- for (int i=0; i<NumberOfFields; i++) {
- deque<DT_IT_> FieldIteration = myMed->getFieldIteration(FieldName[i]) ;
- MESSAGE(" - Field "<<i+1<<", named "<<FieldName[i]<<" :");
- int NumberOfIteration = FieldIteration.size() ;
- MESSAGE(" Number of iteration pair : "<<NumberOfIteration);
- for (int j=0; j<NumberOfIteration; j++) {
- MESSAGE(" FieldName[i] "<<FieldName[i]<<",Iteration "<< FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" j="<<j<<",i="<<i<<" :");
- FIELD_ * myField = myMed->getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
-
- med_type_champ type = myField->getValueType() ;
- switch (type) {
- case MED_FR::MED_INT32: {
- // if (type == MED_FR::MED_INT32) {
- MESSAGE(" * Field named "<<((FIELD<int>*)myField)->getName());
- ((FIELD<int>*)myField)->read() ;
- MESSAGE(" * Iteration "<<FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" read !");
- MED_FIELD_WRONLY_DRIVER<int> myFieldDriver(filenameOUT,(FIELD<int>*)myField);
- myFieldDriver.setFieldName(FieldName[i]);
- myFieldDriver.open() ;
- myFieldDriver.write() ;
- myFieldDriver.close() ;
- break ;
- }
- // else
- case MED_FR::MED_REEL64: {
- // if (type == MED_FR::MED_REEL64) {
- FIELD<double>* myField2 = (FIELD<double>*)myField ;
- MESSAGE(" * Field named "<<myField2->getName());
- myField2->read() ;
- MESSAGE(" * Iteration "<<FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" read !");
- MED_FIELD_WRONLY_DRIVER<double> myFieldDriver(filenameOUT,myField2);
- myFieldDriver.setFieldName(FieldName[i]);
- myFieldDriver.open() ;
- myFieldDriver.write() ;
- myFieldDriver.close() ;
- break ;
- }
- // else {
- default: {
- MESSAGE(" * Iteration "<<FieldIteration[j].dt<<", order number "<<FieldIteration[j].it<<" not read : wrond type "<<type);
- break ;
- }
- }
- }
- }
- } catch (MEDEXCEPTION& ex){
- MESSAGE(ex.what()) ;
- }
+ // we read all meshes and fields in filenameIN
+ myMed.read() ;
- // we write all in file filenameOUT :
-// try {
-
-// MED_MED_DRIVER myMedDriverOUT("/tmp/test.med",myMed) ;
-// myMedDriverOUT.open() ;
-// myMedDriverOUT.write() ;
-// myMedDriverOUT.close() ;
-// } catch (MEDEXCEPTION& ex){
-// MESSAGE(ex.what()) ;
-// }
+ // we write all in file filenameOUT :
+ int id = myMed.addDriver(MED_DRIVER,filenameOUT) ;
+ myMed.write(id);
- delete myMed ;
+ } catch (MEDEXCEPTION& ex) {
+ MESSAGE(ex.what()) ;
+ }
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : duplicateMEDMESH.cxx
+// Module : MED
+
+using namespace std;
#include<string>
#include<deque>
string filenameOUT = argv[2] ;
MED * myMed = new MED() ;
- MED_MED_DRIVER myMedDriver(filenameIN,myMed) ;
+ MED_MED_RDONLY_DRIVER myMedDriver(filenameIN,myMed) ;
// we read all meshes in filenameIN
try {
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : med2vtk.cxx
+// Module : MED
+
+using namespace std;
+#include<string>
+#include<deque>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+
+#include "MEDMEM_Med.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_VtkMedDriver.hxx"
+
+void usage(char * name)
+{
+ cout << " " << name << " <input med file> <output vtk file> " <<endl ;
+ cout << " " << "(the two file name are mandatory)" << endl ;
+ exit(-1);
+}
+
+int main (int argc, char ** argv) {
+
+ if (argc != 3) usage(argv[0]);
+
+ string filenameIN = argv[1] ;
+ string filenameOUT = argv[2] ;
+
+ try {
+ /////////////////////////////////////////////////
+ // we read all meshes and fields in filenameIN //
+ /////////////////////////////////////////////////
+ MED myMed(MED_DRIVER,filenameIN) ;
+
+ // read all meshes
+ ////////////////////
+
+ cout << "Read all meshes " ;
+ int NumberOfMeshes = myMed.getNumberOfMeshes() ;
+ cout << "( "<<NumberOfMeshes << " ) :" << endl ;
+ deque<string> MeshName = myMed.getMeshNames() ;
+ for (int i=0; i<NumberOfMeshes; i++) {
+ myMed.getMesh(MeshName[i])->read() ;
+ cout << " - Mesh "<<i+1<<", named "<<MeshName[i]<<" is read !" << endl;
+ }
+
+ // PROVISOIRE
+ ///////////////
+
+ // set support : support must be calculated with mesh information !!!
+ myMed.updateSupport() ;
+
+ // read all fields
+ ////////////////////
+
+ cout << "Read all fields " ;
+ int NumberOfFields = myMed.getNumberOfFields() ;
+ cout << "( "<<NumberOfFields << " ) :" << endl;
+ deque<string> FieldName = myMed.getFieldNames() ;
+ for (int i=0; i<NumberOfFields; i++) {
+ deque<DT_IT_> FieldIteration = myMed.getFieldIteration(FieldName[i]) ;
+ cout << " - Field "<<i+1<<", named "<<FieldName[i] << " :" << endl ;
+ int NumberOfIteration = FieldIteration.size() ;
+ cout << " Number of iteration pair : "<< NumberOfIteration << endl;
+ for (int j=0; j<NumberOfIteration; j++) {
+ FIELD_ * myField = myMed.getField(FieldName[i],FieldIteration[j].dt,FieldIteration[j].it) ;
+
+ myField->read() ;
+ cout << " * Iteration "<<FieldIteration[j].dt<<" and order number "<<FieldIteration[j].it<<" ) is read !" << endl;
+ }
+ }
+
+ //////////////////////////////////////////
+ // we write all in VTK file filenameOUT //
+ /////////////////////////////////////////
+ int id = myMed.addDriver(VTK_DRIVER,filenameOUT) ;
+ myMed.write(id) ;
+
+ }
+ catch (MEDEXCEPTION& ex){
+ cout << ex.what() << endl ;
+ }
+
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : med_test.cxx
+// Module : MED
+
+using namespace std;
#include<string>
#include <math.h>
double infty = 1.e20;
-void affiche_support(SUPPORT * mySupport)
+void affiche_support(const SUPPORT * mySupport)
{
- MESSAGE( " - Name : "<<mySupport->getName().c_str());
- MESSAGE( " - Description : "<<mySupport->getDescription().c_str());
- MESSAGE( " - Entity : "<<mySupport->getEntity());
- MESSAGE( " - Entities list : ");
+ cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
+ cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
+ cout << " - Entity : "<<mySupport->getEntity()<<endl ;
+ cout << " - Entities list : "<<endl ;
if (!(mySupport->isOnAllElements())) {
int NumberOfTypes = mySupport->getNumberOfTypes() ;
- MESSAGE(" - NumberOfTypes : "<<NumberOfTypes);
- medGeometryElement * Types = mySupport->getTypes() ;
+ cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
+ const medGeometryElement * Types = mySupport->getTypes() ;
for (int j=0;j<NumberOfTypes;j++) {
- MESSAGE( " * Type "<<Types[j]<<" : " );
+ cout << " * Type "<<Types[j]<<" : " ;
int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
- int * Number = mySupport->getNumber(Types[j]) ;
+ const int * Number = mySupport->getNumber(Types[j]) ;
for (int k=0; k<NumberOfElements;k++)
- MESSAGE( Number[k] << " ");
- MESSAGE("");
+ cout << Number[k] << " ";
+ cout << endl ;
}
} else
- MESSAGE( " Is on all entities !");
+ cout << " Is on all entities !"<< endl;
}
void affiche_famille(MESH *myMesh,medEntityMesh Entity)
{
int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
- MESSAGE( "NumberOfFamilies : "<<NumberOfFamilies);
+ cout << "NumberOfFamilies : "<<NumberOfFamilies<<endl;
for (int i=1; i<NumberOfFamilies+1;i++) {
- FAMILY* myFamily = myMesh->getFamily(Entity,i);
+ const FAMILY* myFamily = myMesh->getFamily(Entity,i);
affiche_support(myFamily);
- MESSAGE( " - Identifier : "<<myFamily->getIdentifier());
+ cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
- MESSAGE( " - Attributes ("<<NumberOfAttributes<<") :");
+ cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
for (int j=1;j<NumberOfAttributes+1;j++)
- MESSAGE( " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str());
+ cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
int NumberOfGroups = myFamily->getNumberOfGroups() ;
- MESSAGE( " - Groups ("<<NumberOfGroups<<") :");
+ cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
for (int j=1;j<NumberOfGroups+1;j++)
- MESSAGE( " * "<<myFamily->getGroupName(j).c_str());
+ cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
}
}
void affiche_groupe(MESH *myMesh,medEntityMesh Entity)
{
int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
- MESSAGE( "NumberOfGroups : "<<NumberOfGroups);
+ cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
for (int i=1; i<NumberOfGroups+1;i++) {
- GROUP* myGroup = myMesh->getGroup(Entity,i);
+ const GROUP* myGroup = myMesh->getGroup(Entity,i);
affiche_support(myGroup);
int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
- MESSAGE( " - Families ("<<NumberOfFamillies<<") :");
+ cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
for (int j=1;j<NumberOfFamillies+1;j++)
- MESSAGE( " * "<<myGroup->getFamily(j)->getName().c_str());
+ cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
}
}
int MeshDimension = myMesh->getMeshDimension() ;
int NumberOfNodes = myMesh->getNumberOfNodes() ;
- MESSAGE( "Space Dimension : " << SpaceDimension << endl );
+ cout << "Space Dimension : " << SpaceDimension << endl << endl ;
- MESSAGE( "Mesh Dimension : " << MeshDimension << endl );
+ cout << "Mesh Dimension : " << MeshDimension << endl << endl ;
const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
- MESSAGE( "Show Nodes Coordinates : " );
+ cout << "Show Nodes Coordinates : " << endl ;
- MESSAGE( "Name :" );
- string * CoordinatesNames = myMesh->getCoordinatesNames() ;
+ cout << "Name :" << endl ;
+ const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
for(int i=0; i<SpaceDimension ; i++) {
- MESSAGE( " - " << CoordinatesNames[i] );
+ cout << " - " << CoordinatesNames[i] << endl ;
}
- MESSAGE( "Unit :" );
- string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
+ cout << "Unit :" << endl ;
+ const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
for(int i=0; i<SpaceDimension ; i++) {
- MESSAGE( " - " << CoordinatesUnits[i] );
+ cout << " - " << CoordinatesUnits[i] << endl ;
}
for(int i=0; i<NumberOfNodes ; i++) {
- MESSAGE( "Nodes " << i+1 << " : " );
+ cout << "Nodes " << i+1 << " : " ;
for (int j=0; j<SpaceDimension ; j++)
- MESSAGE( Coordinates[i*SpaceDimension+j] << " " );
- MESSAGE("");
+ cout << Coordinates[i*SpaceDimension+j] << " " ;
+ cout << endl ;
}
int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ;
- medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
+ const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
- MESSAGE( "Show Connectivity (Nodal) :" );
+ cout << "Show Connectivity (Nodal) :" << endl ;
for (int i=0; i<NumberOfTypes; i++) {
- MESSAGE( "For type " << Types[i] << " : " );
+ cout << "For type " << Types[i] << " : " << endl ;
int NumberOfElements = myMesh->getNumberOfElements(MED_CELL,Types[i]);
- int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
+ const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
int NomberOfNodesPerCell = Types[i]%100 ;
for (int j=0;j<NumberOfElements;j++){
- MESSAGE( "Element "<< j+1 <<" : " );
+ cout << "Element "<< j+1 <<" : " ;
for (int k=0;k<NomberOfNodesPerCell;k++)
- MESSAGE( connectivity[j*NomberOfNodesPerCell+k]<<" ");
- MESSAGE("");
+ cout << connectivity[j*NomberOfNodesPerCell+k]<<" ";
+ cout << endl ;
}
}
- MESSAGE( "Show Family :");
+ cout << "Show Family :"<<endl ;
affiche_famille(myMesh,MED_NODE);
affiche_famille(myMesh,MED_CELL);
affiche_famille(myMesh,MED_FACE);
affiche_famille(myMesh,MED_EDGE);
- MESSAGE( "Show Group :");
+ cout << "Show Group :"<<endl ;
affiche_groupe(myMesh,MED_NODE);
affiche_groupe(myMesh,MED_CELL);
affiche_groupe(myMesh,MED_FACE);
affiche_groupe(myMesh,MED_EDGE);
- MESSAGE( "Show Reverse Nodal Connectivity :" );
- int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
- int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
+ cout << "Show Reverse Nodal Connectivity :" << endl ;
+ const int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
+ const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
for (int i=0; i<NumberOfNodes; i++) {
- MESSAGE( "Node "<<i+1<<" : " );
+ cout << "Node "<<i+1<<" : " ;
for (int j=ReverseNodalConnectivityIndex[i];j<ReverseNodalConnectivityIndex[i+1];j++)
- MESSAGE( ReverseNodalConnectivity[j-1] << " " );
- MESSAGE("");
+ cout << ReverseNodalConnectivity[j-1] << " " ;
+ cout << endl ;
}
- MESSAGE( "Show Connectivity (Descending) :" );
+ cout << "Show Connectivity (Descending) :" << endl ;
int NumberOfElements ;
- int * connectivity ;
- int * connectivity_index ;
+ const int * connectivity ;
+ const int * connectivity_index ;
myMesh->calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
try {
NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
connectivity_index = myMesh->getConnectivityIndex(MED_DESCENDING,MED_CELL);
}
catch (MEDEXCEPTION m) {
- MESSAGE( m.what() );
+ cout << m.what() << endl ;
exit (-1) ;
}
for (int j=0;j<NumberOfElements;j++) {
- MESSAGE( "Element "<<j+1<<" : " );
+ cout << "Element "<<j+1<<" : " ;
for (int k=connectivity_index[j];k<connectivity_index[j+1];k++)
- MESSAGE( connectivity[k-1]<<" ");
- MESSAGE("");
+ cout << connectivity[k-1]<<" ";
+ cout << endl ;
}
- MESSAGE( "Show Reverse Descending Connectivity :" );
- int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
- int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
+ cout << "Show Reverse Descending Connectivity :" << endl ;
+ const int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
+ const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
int NumberOfConstituents = 0;
string constituent ;
}
if (MeshDimension==1) {
- MESSAGE("ERROR : MeshDimension = 1 !");
- MESSAGE("We could not see Reverse Descending Connectivity.") ;
+ INFOS("ERROR : MeshDimension = 1 !");
+ INFOS("We could not see Reverse Descending Connectivity.") ;
} else {
NumberOfConstituents = myMesh->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS);
for (int i=0; i<NumberOfConstituents; i++) {
- MESSAGE( constituent <<i+1<<" : " );
+ cout << constituent <<i+1<<" : " ;
for (int j=ReverseDescendingConnectivityIndex[i];j<ReverseDescendingConnectivityIndex[i+1];j++)
- MESSAGE( ReverseDescendingConnectivity[j-1] << " " );
- MESSAGE("");
+ cout << ReverseDescendingConnectivity[j-1] << " " ;
+ cout << endl ;
}
}
- MESSAGE( "Show "<<constituent<<" Connectivity (Nodal) :" );
- int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
- int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
+ cout << "Show "<<constituent<<" Connectivity (Nodal) :" << endl ;
+ const int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
+ const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
for (int i=0; i<NumberOfConstituents; i++) {
- MESSAGE( constituent <<i+1<<" : " );
+ cout << constituent <<i+1<<" : " ;
for (int j=face_connectivity_index[i];j<face_connectivity_index[i+1];j++)
- MESSAGE( face_connectivity[j-1]<<" ");
- MESSAGE("");
+ cout << face_connectivity[j-1]<<" ";
+ cout << endl ;
}
/* test of normal, area, volume, barycenter */
SUPPORT * support1 = (SUPPORT*) NULL;
- FIELD<double>* normal = new FIELD<double>::FIELD();
- FIELD<double>* length = new FIELD<double>::FIELD();
- normal = NULL;
- length = NULL;
+ //FIELD<double>* normal = new FIELD<double>::FIELD();
+ //FIELD<double>* length = new FIELD<double>::FIELD();
+ //normal = NULL;
+ //length = NULL;
string support_name = "Support on all " ;
support_name+=constituent;
support1 = new SUPPORT(myMesh,support_name,constituentEntity);
- MESSAGE( "Building of the Support on all cells dimensionned (Meshdim-1) of the mesh :");
- MESSAGE( "Face in 3D or Edge in 2D" );
+ cout << "Building of the Support on all cells dimensionned (Meshdim-1) of the mesh :"<< endl ;
+ cout << "Face in 3D or Edge in 2D" << endl;
- MESSAGE( "Getting the normal of each face of this support !" );
+ cout << "Getting the normal of each face of this support !" << endl ;
- normal = myMesh->getNormal(support1);
+ FIELD<double>* normal = myMesh->getNormal(support1);
double normal_square, norm ;
double maxnorm=-infty;
double tmp_value ;
for (int i = 1; i<=NumberOfConstituents;i++) {
normal_square = 0. ;
- MESSAGE( "Normal " << i << " " );
+ cout << "Normal " << i << " " ;
for (int j=1; j<=SpaceDimension; j++) {
tmp_value = normal->getValueIJ(i,j) ;
normal_square += tmp_value*tmp_value ;
- MESSAGE( tmp_value << " " );
+ cout << tmp_value << " " ;
}
norm = sqrt(normal_square);
maxnorm = dmax(maxnorm,norm);
minnorm = dmin(minnorm,norm);
- MESSAGE( ", Norm = " << norm );
+ cout << ", Norm = " << norm << endl;
}
- MESSAGE( "Max Norm " << maxnorm << " Min Norm " << minnorm );
+ cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl;
+ delete normal ;
if (SpaceDimension == 2)
{
- MESSAGE( "Getting the length of each edge !" );
+ cout << "Getting the length of each edge !" << endl ;
- length = myMesh->getLength(support1);
+ FIELD<double>* length = myMesh->getLength(support1);
double length_value,maxlength,minlength;
maxlength = -infty;
for (int i = 1; i<=NumberOfConstituents;i++)
{
length_value = length->getValueIJ(i,1) ;
- MESSAGE( "Length " << i << " " << length_value );
+ cout << "Length " << i << " " << length_value << endl;
maxlength = dmax(maxlength,length_value);
minlength = dmin(minlength,length_value);
}
- MESSAGE( "Max Length " << maxlength << " Min Length " << minlength );
+ cout << "Max Length " << maxlength << " Min Length " << minlength << endl;
+
+ delete length ;
}
- MESSAGE( "Building of the Support on all space-dimensionned cells of the mesh :");
+ delete support1 ;
+
+ cout << "Building of the Support on all space-dimensionned cells of the mesh :"<< endl ;
SUPPORT * support = new SUPPORT(myMesh);
- MESSAGE( "Getting the barycenter of each element of this support !" );
+ cout << "Getting the barycenter of each element of this support !" << endl ;
- FIELD<double>* barycenter = new FIELD<double>::FIELD();
+ //FIELD<double>* barycenter = new FIELD<double>::FIELD();
- barycenter = myMesh->getBarycenter(support);
+ FIELD<double>* barycenter = myMesh->getBarycenter(support);
NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
for (int i = 1; i<=NumberOfElements;i++)
{
if (SpaceDimension == 3)
- MESSAGE( "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) );
+ cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) << endl;
if (SpaceDimension == 2)
- MESSAGE( "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) );
+ cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << endl;
}
- FIELD<double>* volume = new FIELD<double>::FIELD();
- FIELD<double>* area = new FIELD<double>::FIELD();
- volume = NULL;
- area = NULL;
+ delete barycenter ;
+
+ //FIELD<double>* volume = new FIELD<double>::FIELD();
+ //FIELD<double>* area = new FIELD<double>::FIELD();
+ //volume = NULL;
+ //area = NULL;
if (SpaceDimension == 3)
{
- MESSAGE( "Getting the Volume of each element of this support which is a 3D one !" );
+ cout << "Getting the Volume of each element of this support which is a 3D one !" << endl;
- volume = myMesh->getVolume(support);
+ FIELD<double>* volume = myMesh->getVolume(support);
double maxvol,minvol,voltot;
maxvol = -infty;
voltot = 0.0;
for (int i = 1; i<=NumberOfElements;i++)
{
- MESSAGE( "Volume " << i << " " << volume->getValueIJ(i,1) );
+ cout << "Volume " << i << " " << volume->getValueIJ(i,1) << endl;
maxvol = dmax(maxvol,volume->getValueIJ(i,1));
minvol = dmin(minvol,volume->getValueIJ(i,1));
voltot = voltot + volume->getValueIJ(i,1);
}
- MESSAGE( "Max Volume " << maxvol << " Min Volume " << minvol );
- MESSAGE( "Support Volume " << voltot );
+ cout << "Max Volume " << maxvol << " Min Volume " << minvol << endl;
+ cout << "Support Volume " << voltot << endl;
+
+ delete volume ;
}
else if (SpaceDimension == 2)
{
- MESSAGE( "Getting the Area of each element of this support which is a 2D one !" );
+ cout << "Getting the Area of each element of this support which is a 2D one !" << endl;
- area = myMesh->getArea(support);
+ FIELD<double>* area = myMesh->getArea(support);
- // MESSAGE( "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) );
+ // cout << "nb of comp "<< area->getNumberOfComponents() << " length " << area->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) << endl;
double maxarea,minarea,areatot;
maxarea = -infty;
areatot = 0.0;
for (int i = 1; i<=NumberOfElements;i++)
{
- MESSAGE( "Area " << i << " " << area->getValueIJ(i,1) );
+ cout << "Area " << i << " " << area->getValueIJ(i,1) << endl;
maxarea = dmax(maxarea,area->getValueIJ(i,1));
minarea = dmin(minarea,area->getValueIJ(i,1));
areatot = areatot + area->getValueIJ(i,1);
}
- MESSAGE( "Max Area " << maxarea << " Min Area " << minarea );
- MESSAGE( "Support Area " << areatot );
+ cout << "Max Area " << maxarea << " Min Area " << minarea << endl;
+ cout << "Support Area " << areatot << endl;
+
+ delete area ;
}
- if (barycenter != NULL) delete barycenter;
- if (volume != NULL ) delete volume;
- if (area != NULL ) delete area;
+ delete support ;
+
+ //if (barycenter != NULL) delete barycenter;
+ //if (volume != NULL ) delete volume;
+ //if (area != NULL ) delete area;
if (argc < 4) return 0;
myFieldDriver.close() ;
- MESSAGE( "Field "<< myField->getName() << " : " <<myField->getDescription() );
+ cout << "Field "<< myField->getName() << " : " <<myField->getDescription() << endl ;
int NumberOfComponents = myField->getNumberOfComponents() ;
- MESSAGE( "- Nombre de composantes : "<< NumberOfComponents );
+ cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
for (int i=1; i<NumberOfComponents+1; i++) {
- MESSAGE( " - composante "<<i<<" :");
- MESSAGE( " - nom : "<<myField->getComponentName(i));
- MESSAGE( " - description : "<<myField->getComponentDescription(i) );
- MESSAGE( " - units : "<<myField->getMEDComponentUnit(i) );
+ cout << " - composante "<<i<<" :"<<endl ;
+ cout << " - nom : "<<myField->getComponentName(i)<< endl;
+ cout << " - description : "<<myField->getComponentDescription(i) << endl;
+ cout << " - units : "<<myField->getMEDComponentUnit(i) << endl;
}
- MESSAGE( "- iteration :" );
- MESSAGE( " - numero : " << myField->getIterationNumber());
- MESSAGE( " - ordre : " << myField->getOrderNumber());
- MESSAGE( " - temps : " << myField->getTime());
+ cout << "- iteration :" << endl ;
+ cout << " - numero : " << myField->getIterationNumber()<< endl ;
+ cout << " - ordre : " << myField->getOrderNumber()<< endl ;
+ cout << " - temps : " << myField->getTime()<< endl ;
- MESSAGE( "- Valeurs :");
+ cout << "- Valeurs :"<<endl;
int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
// for (int i=1; i<NumberOfComponents+1; i++) {
// double * value = myField->getValueI(MED_NO_INTERLACE,i) ;
// for (int j=0; j<NumberOf; j++)
- // MESSAGE( value[j]<< " ");
- // MESSAGE();
+ // cout << value[j]<< " ";
+ // cout<<endl;
// }
+ MEDARRAY<double> * myvalue = myField->getvalue();
+ const double * value ;
for (int i=1; i<NumberOf+1; i++) {
- double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+ value = myvalue->getRow(i) ;
for (int j=0; j<NumberOfComponents; j++)
- MESSAGE( value[j]<< " ");
- MESSAGE("");
+ cout << value[j]<< " ";
+ cout<<endl;
}
+ cout<<endl;
+
+ delete myField;
+ delete mySupport;
+ delete myMesh ;
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_Array.cxx
+// Module : MED
+
+using namespace std;
#include "utilities.h"
#include "MEDMEM_Array.hxx"
int NumberOfNodes = 4 ;
MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ;
- int * value = myArray->get(MED_FULL_INTERLACE) ;
- for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
- value[i]=i ;
+ //const int * value = myArray->get(MED_FULL_INTERLACE) ;
+ for (int i=1; i<=NumberOfNodes; i++)
+ for (int j=1; j<=SpaceDimension; j++)
+ myArray->setIJ(i,j,i) ;
int numberof ;
MESSAGE("Show all 1 :");
numberof = myArray->getLeadingValue() ;
for (int i=1; i<=myArray->getLengthValue() ; i++) {
- int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
- MESSAGE( " - " );
+ //int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
+ const int * node = myArray->getRow(i) ;
+ cout << " - " ;
for (int j=0;j<numberof;j++)
- MESSAGE( node[j] << " " );
- MESSAGE("");
+ cout << node[j] << " " ;
+ cout << endl ;
}
MESSAGE("Show all 2 :");
numberof = myArray->getLengthValue() ;
for (int i=1; i<=myArray->getLeadingValue() ; i++) {
- int * node = myArray->getI(MED_NO_INTERLACE,i) ;
- MESSAGE( " - " );
+ //int * node = myArray->getJ(MED_NO_INTERLACE,i) ;
+ const int * node = myArray->getColumn(i) ;
+ cout << " - " ;
for (int j=0;j<numberof;j++)
- MESSAGE( node[j] << " " );
- MESSAGE("");
+ cout << node[j] << " " ;
+ cout << endl ;
}
MESSAGE("Show all 3 :");
numberof = myArray->getLeadingValue() ;
for (int i=1; i<=myArray->getLengthValue() ; i++) {
- MESSAGE( " - " );
+ cout << " - " ;
for (int j=1;j<numberof+1;j++)
- MESSAGE( myArray->getIJ(i,j) << " " );
- MESSAGE("");
+ cout << myArray->getIJ(i,j) << " " ;
+ cout << endl ;
}
MESSAGE("Show all 0 :");
numberof = myArray->getLeadingValue() ;
int length = myArray->getLengthValue() ;
- int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
+ const int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
for (int i=0; i<length ; i++) {
- MESSAGE( " - " );
+ cout << " - " ;
for (int j=0;j<numberof;j++)
- MESSAGE( NoInterlaceArray[j*length+i] << " " );
- MESSAGE("");
+ cout << NoInterlaceArray[j*length+i] << " " ;
+ cout << endl ;
}
+
+ delete myArray ;
+
return 0 ;
}
-
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_CellModel.cxx
+// Module : MED
+
+using namespace std;
#include "utilities.h"
#include "MEDMEM_CellModel.hxx"
#include "MEDMEM_DriversDef.hxx"
for(itGeomList=geomList.begin();itGeomList!=geomList.end();itGeomList++) {
CELLMODEL myCellModel((MED_EN::medGeometryElement)(*itGeomList)) ;
+ cout << "First CellModel :" << endl << endl ;
+
cout << myCellModel << endl ;
cout << "Number of constituents type : "<<myCellModel.getNumberOfConstituentsType() << endl ;
cout << " - " << (*myMapIt).second << " constituent(s) of type " << (*myMapIt).first << endl ;
cout << endl;
+ cout << "Second CellModel :" << endl << endl ;
+ CELLMODEL myCellModel2=myCellModel ;
+ cout << myCellModel2 << endl ;
+
+ cout << "Third CellModel :" << endl << endl ;
+ CELLMODEL myCellModel3 ;
+ myCellModel3=myCellModel ;
+ cout << myCellModel3 << endl ;
}
}
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : test_MEDMEM_Meshing.cxx
+// Module : MED
+
+#include "MEDMEM_Meshing.hxx"
+#include "MEDMEM_Group.hxx"
+
+using namespace std;
+
+int main (int argc, char ** argv) {
+
+ if (argc <2) {
+ cerr << "Usage : " << argv[0]
+ << " filename" << endl << endl;
+ exit(-1);
+ }
+
+ // filename to save the generated MESH
+ string filename = argv[1] ;
+
+ MESHING myMeshing ;
+ myMeshing.setName("meshing") ;
+
+ // define coordinates
+
+ int SpaceDimension = 3 ;
+ int NumberOfNodes = 19 ;
+ double Coordinates[57] = {
+ 0.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0,
+ 2.0, 0.0, 1.0,
+ 0.0, 2.0, 1.0,
+ -2.0, 0.0, 1.0,
+ 0.0, -2.0, 1.0,
+ 1.0, 1.0, 2.0,
+ -1.0, 1.0, 2.0,
+ -1.0, -1.0, 2.0,
+ 1.0, -1.0, 2.0,
+ 1.0, 1.0, 3.0,
+ -1.0, 1.0, 3.0,
+ -1.0, -1.0, 3.0,
+ 1.0, -1.0, 3.0,
+ 1.0, 1.0, 4.0,
+ -1.0, 1.0, 4.0,
+ -1.0, -1.0, 4.0,
+ 1.0, -1.0, 4.0,
+ 0.0, 0.0, 5.0
+ };
+
+ myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
+
+ string Names[3] = { "X","Y","Z" } ;
+ myMeshing.setCoordinatesNames(Names);
+
+ string Units[3] = { "cm","cm","cm" } ;
+ myMeshing.setCoordinatesUnits(Units) ;
+
+ // define conectivities
+
+ // cell part
+
+ const int NumberOfTypes = 3 ;
+ medGeometryElement Types[NumberOfTypes] = {MED_TETRA4,MED_PYRA5,MED_HEXA8} ;
+ const int NumberOfElements[NumberOfTypes] = {12,2,2} ;
+
+ myMeshing.setNumberOfTypes(NumberOfTypes,MED_CELL);
+ myMeshing.setTypes(Types,MED_CELL);
+ myMeshing.setNumberOfElements(NumberOfElements,MED_CELL);
+
+ const int sizeTetra = 12*4 ;
+ int ConnectivityTetra[sizeTetra]=
+ {
+ 1,2,3,6,
+ 1,2,4,3,
+ 1,2,5,4,
+ 1,2,6,5,
+ 2,7,4,3,
+ 2,8,5,4,
+ 2,9,6,5,
+ 2,10,3,6,
+ 2,7,3,10,
+ 2,8,4,7,
+ 2,9,5,8,
+ 2,10,6,9
+ };
+
+ myMeshing.setConnectivity(ConnectivityTetra,MED_CELL,MED_TETRA4);
+
+ int ConnectivityPyra[2*5]=
+ {
+ 7,8,9,10,2,
+ 15,18,17,16,19
+ };
+
+ myMeshing.setConnectivity(ConnectivityPyra,MED_CELL,MED_PYRA5);
+
+ int ConnectivityHexa[2*8]=
+ {
+ 11,12,13,14,7,8,9,10,
+ 15,16,17,18,11,12,13,14
+ };
+
+ myMeshing.setConnectivity(ConnectivityHexa,MED_CELL,MED_HEXA8);
+
+ // face part
+
+ const int NumberOfFacesTypes = 2 ;
+ medGeometryElement FacesTypes[NumberOfFacesTypes] = {MED_TRIA3,MED_QUAD4} ;
+ const int NumberOfFacesElements[NumberOfFacesTypes] = {4,4} ;
+
+ myMeshing.setNumberOfTypes(NumberOfFacesTypes,MED_FACE);
+ myMeshing.setTypes(FacesTypes,MED_FACE);
+ myMeshing.setNumberOfElements(NumberOfFacesElements,MED_FACE);
+
+ const int sizeTria = 3*4 ;
+ int ConnectivityTria[sizeTria]=
+ {
+ 1,4,3,
+ 1,5,4,
+ 1,6,5,
+ 1,3,6
+ };
+
+ myMeshing.setConnectivity(ConnectivityTria,MED_FACE,MED_TRIA3);
+
+ int ConnectivityQua[4*4]=
+ {
+ 7,8,9,10,
+ 11,12,13,14,
+ 11,7,8,12,
+ 12,8,9,13
+ };
+
+ myMeshing.setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4);
+
+ // edge part
+
+ // not yet implemented : if set, results are unpredictable.
+
+ // Some groups :
+
+ // Node :
+ {
+ GROUP myGroup ;
+ myGroup.setName("SomeNodes");
+ myGroup.setMesh(&myMeshing);
+ myGroup.setEntity(MED_NODE);
+ myGroup.setNumberOfGeometricType(1);
+ medGeometryElement myTypes[1] = {MED_NONE};
+ myGroup.setGeometricType(myTypes);
+ const int myNumberOfElements[1] = {4} ;
+ myGroup.setNumberOfElements(myNumberOfElements);
+ const int index[1+1] = {1,5} ;
+ const int value[4]= { 1,4,5,7} ;
+ myGroup.setNumber(index,value);
+
+ myMeshing.addGroup(myGroup);
+ }
+ {
+ GROUP myGroup ;
+ myGroup.setName("OtherNodes");
+ myGroup.setMesh(&myMeshing);
+ myGroup.setEntity(MED_NODE);
+ myGroup.setNumberOfGeometricType(1);
+ medGeometryElement myTypes[1] = {MED_NONE};
+ myGroup.setGeometricType(myTypes);
+ const int myNumberOfElements[1] = {3} ;
+ myGroup.setNumberOfElements(myNumberOfElements);
+ const int index[1+1] = {1,4} ;
+ const int value[3]= { 2,3,6} ;
+ myGroup.setNumber(index,value);
+
+ myMeshing.addGroup(myGroup);
+ }
+
+ // Cell :
+ {
+ GROUP myGroup ;
+ myGroup.setName("SomeCells");
+ myGroup.setMesh(&myMeshing);
+ myGroup.setEntity(MED_CELL);
+ myGroup.setNumberOfGeometricType(3);
+ medGeometryElement myTypes[3] = {MED_TETRA4,MED_PYRA5,MED_HEXA8};
+ myGroup.setGeometricType(myTypes);
+ const int myNumberOfElements[3] = {4,1,2} ;
+ myGroup.setNumberOfElements(myNumberOfElements);
+ const int index[3+1] = {1,5,6,8} ;
+ const int value[4+1+2]=
+ {
+ 2,7,8,12,
+ 13,
+ 15,16
+ };
+ myGroup.setNumber(index,value);
+
+ myMeshing.addGroup(myGroup);
+ }
+ {
+ GROUP myGroup ;
+ myGroup.setName("OtherCells");
+ myGroup.setMesh(&myMeshing);
+ myGroup.setEntity(MED_CELL);
+ myGroup.setNumberOfGeometricType(2);
+ medGeometryElement myTypes[] = {MED_TETRA4,MED_PYRA5};
+ myGroup.setGeometricType(myTypes);
+ const int myNumberOfElements[] = {4,1} ;
+ myGroup.setNumberOfElements(myNumberOfElements);
+ const int index[3+1] = {1,5,6} ;
+ const int value[4+1]=
+ {
+ 3,4,5,9,
+ 14
+ };
+ myGroup.setNumber(index,value);
+
+ myMeshing.addGroup(myGroup);
+ }
+
+ // Face :
+ {
+ GROUP myGroup ;
+ myGroup.setName("SomeFaces");
+ myGroup.setMesh(&myMeshing);
+ myGroup.setEntity(MED_FACE);
+ myGroup.setNumberOfGeometricType(2);
+ medGeometryElement myTypes[2] = {MED_TRIA3,MED_QUAD4};
+ myGroup.setGeometricType(myTypes);
+ const int myNumberOfElements[2] = {2,3} ;
+ myGroup.setNumberOfElements(myNumberOfElements);
+ const int index[2+1] = {1,3,6} ;
+ const int value[2+3]=
+ {
+ 2,4,
+ 5,6,8
+ } ;
+ myGroup.setNumber(index,value);
+
+ myMeshing.addGroup(myGroup);
+ }
+ {
+ GROUP myGroup ;
+ myGroup.setName("OtherFaces");
+ myGroup.setMesh(&myMeshing);
+ myGroup.setEntity(MED_FACE);
+ myGroup.setNumberOfGeometricType(1);
+ medGeometryElement myTypes[1] = {MED_TRIA3};
+ myGroup.setGeometricType(myTypes);
+ const int myNumberOfElements[1] = {2} ;
+ myGroup.setNumberOfElements(myNumberOfElements);
+ const int index[1+1] = {1,3} ;
+ const int value[2]=
+ {
+ 1,3
+ } ;
+ myGroup.setNumber(index,value);
+
+ myMeshing.addGroup(myGroup);
+ }
+
+ // all rigtht, we save it !
+
+ int id = myMeshing.addDriver(MED_DRIVER,filename,myMeshing.getName());
+ myMeshing.write(id) ;
+
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_ModulusArray.cxx
+// Module : MED
+
+using namespace std;
#include "utilities.h"
+
#include "MEDMEM_ModulusArray.hxx"
int main (int argc, char ** argv) {
+ using namespace std ;
+
int array[5]={0,1,2,1,4} ;
MEDMODULUSARRAY modulusArray(5,array);
- MESSAGE("ModuloArray :");
+ cout<<"ModuloArray :"<<endl;
for(int i=-10;i<15;i++)
- MESSAGE(" - A["<<i<<"]="<<modulusArray[i]);
- MESSAGE("");
+ cout <<" - A["<<i<<"]="<<modulusArray[i]<<endl;
+ cout <<endl;
// test compare
int ret ;
int array2[5]={1,4,0,1,2} ;
MEDMODULUSARRAY modulusArray2(5,array2) ;
- MESSAGE("Same arrays, same order ... ");
+ cout<<"Same arrays, same order ... ";
if ((ret=modulusArray2.compare(modulusArray))!=1)
- MESSAGE( "Error : two arrays must be identical !"<<ret)
+ cout << "Error : two arrays must be identical !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
int array3[5]={1,2,1,0,4} ;
MEDMODULUSARRAY modulusArray3(5,array3) ;
- MESSAGE("Same arrays, reverse order ... ");
+ cout<<"Same arrays, reverse order ... ";
if ((ret=modulusArray3.compare(modulusArray))!=-1)
- MESSAGE( "Error : two arrays are in reverse order !"<<ret)
+ cout << "Error : two arrays are in reverse order !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
int array4[6]={1,2,1,0} ;
MEDMODULUSARRAY modulusArray4(4,array4) ;
- MESSAGE("Different arrays size ... ");
+ cout<<"Different arrays size ... ";
if ((ret=modulusArray4.compare(modulusArray))!=0)
- MESSAGE( "Error : two arrays have different size !"<<ret)
+ cout << "Error : two arrays have different size !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
int array5[5]={1,2,1,0,1} ;
MEDMODULUSARRAY modulusArray5(5,array5) ;
- MESSAGE("Different array, same size ... ");
+ cout<<"Different array, same size ... ";
if ((ret=modulusArray5.compare(modulusArray))!=0)
- MESSAGE( "Error : two arrays are not be identical !"<<ret)
+ cout << "Error : two arrays are not be identical !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
// test small array :
int array6[1]={1} ;
MEDMODULUSARRAY modulusArray6(1,array6);
- MESSAGE("ModuloArray 1 :");
+ cout<<"ModuloArray 1 :"<<endl;
for(int i=-10;i<15;i++)
- MESSAGE(" - A["<<i<<"]="<<modulusArray6[i]);
- MESSAGE("");
+ cout <<" - A["<<i<<"]="<<modulusArray6[i]<<endl;
+ cout <<endl;
int array7[1]={1} ;
MEDMODULUSARRAY modulusArray7(1,array7);
- MESSAGE("Same arrays, same order ... ");
+ cout<<"Same arrays, same order ... ";
if ((ret=modulusArray6.compare(modulusArray7))!=1)
- MESSAGE( "Error : two arrays are identical !"<<ret)
+ cout << "Error : two arrays are identical !"<<ret<<endl;
else
- MESSAGE( "OK" )
-
+ cout << "OK" <<endl;
int array8[1]={2} ;
MEDMODULUSARRAY modulusArray8(1,array8);
- MESSAGE("Different arrays ... ");
+ cout<<"Different arrays ... ";
if ((ret=modulusArray6.compare(modulusArray8))!=0)
- MESSAGE( "Error : two arrays are different !"<<ret)
+ cout << "Error : two arrays are different !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
// 2
int array60[2]={1,2} ;
MEDMODULUSARRAY modulusArray60(2,array60);
- MESSAGE("ModuloArray 2 :");
+ cout<<"ModuloArray 2 :"<<endl;
for(int i=-10;i<15;i++)
- MESSAGE(" - A["<<i<<"]="<<modulusArray60[i]);
- MESSAGE("");
+ cout <<" - A["<<i<<"]="<<modulusArray60[i]<<endl;
+ cout <<endl;
int array70[2]={1,2} ;
MEDMODULUSARRAY modulusArray70(2,array70);
- MESSAGE("Same arrays, same order ... ");
+ cout<<"Same arrays, same order ... ";
if ((ret=modulusArray60.compare(modulusArray70))!=1)
- MESSAGE( "Error : two arrays are identical !"<<ret)
+ cout << "Error : two arrays are identical !"<<ret<<endl;
else
- MESSAGE( "OK" );
+ cout << "OK" <<endl;
int array80[2]={2,2} ;
MEDMODULUSARRAY modulusArray80(2,array80);
- MESSAGE("Different arrays ... ");
+ cout<<"Different arrays ... ";
if ((ret=modulusArray60.compare(modulusArray80))!=0)
- MESSAGE( "Error : two arrays are different !"<<ret)
+ cout << "Error : two arrays are different !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
int array90[2]={2,1} ;
MEDMODULUSARRAY modulusArray90(2,array90);
- MESSAGE("Same arrays, reverse order ... ");
+ cout<<"Same arrays, reverse order ... ";
if ((ret=modulusArray60.compare(modulusArray90))!=-1)
- MESSAGE( "Error : two arrays are in reverse order !"<<ret)
+ cout << "Error : two arrays are in reverse order !"<<ret<<endl;
else
- MESSAGE( "OK" )
+ cout << "OK" <<endl;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_MEDMEM_SkyLineArray.cxx
+// Module : MED
+
+using namespace std;
#include "utilities.h"
#include "MEDMEM_SkyLineArray.hxx"
int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
int Size = 10 ; // 10 nodes
- MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size) ;
- int * index = myArray->getIndex() ;
+ int * index = new int[NumberOfCell+1] ;
index[0]=1;
index[1]=4;
index[2]=8;
index[3]=11;
- int * value = myArray->getValue() ;
+ int * value = new int[Size] ;
value[0]=1; // first
value[1]=2;
value[2]=5;
value[9]=6;
// value[]=; // forth
- MESSAGE( "Show all 1 :" );
+ MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
+
+ cout << "Show all 1 :" << endl ;
for (int i=1; i<NumberOfCell+1 ; i++) {
- int * cell = myArray->getI(i) ;
+ const int * cell = myArray->getI(i) ;
int numberof = myArray->getNumberOfI(i) ;
- MESSAGE( " - " );
+ cout << " - " ;
for (int j=0;j<numberof;j++)
- MESSAGE( cell[j] << " " );
- MESSAGE("");
+ cout << cell[j] << " " ;
+ cout << endl ;
}
- MESSAGE( "Show all 2 :" );
+ cout << "Show all 2 :" << endl ;
for (int i=1; i<NumberOfCell+1 ; i++) {
- MESSAGE( " - " );
+ cout << " - " ;
int numberof = myArray->getNumberOfI(i) ;
for (int j=1;j<numberof+1;j++)
- MESSAGE( myArray->getIJ(i,j) << " " );
- MESSAGE("");
+ cout << myArray->getIJ(i,j) << " " ;
+ cout << endl ;
}
MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ;
delete myArray ;
- MESSAGE( "Show all 3 :" );
- for (int i=1; i<NumberOfCell+1 ; i++) {
- int * cell = myArray2->getI(i) ;
- int numberof = myArray2->getNumberOfI(i) ;
- MESSAGE( " - " );
- for (int j=0;j<numberof;j++)
- MESSAGE( cell[j] << " " );
- MESSAGE("");
+ cout << "Show all 3 :" << endl ;
+ const int * index2 = myArray2->getIndex() ;
+ for (int i=1; i<=NumberOfCell ; i++) {
+ cout << " - " ;
+ for (int j=index2[i-1];j<index2[i];j++)
+ cout << myArray2->getIndexValue(j) << " " ;
+ cout << endl ;
}
+ delete myArray2 ;
+ delete[] index ;
+ delete[] value ;
+
return 0 ;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_affect_medarray.cxx
+// Module : MED
+
using namespace std;
/* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
jroy - 16/12/2002 */
MESSAGE("Show all 1 :");
numberof = myMedArray.getLeadingValue() ;
for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
- double * node = myMedArray.getI(MED_FULL_INTERLACE,i) ;
+ const double * node = myMedArray.getRow(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << node[j] << " " ;
MESSAGE("Show all 2 :");
numberof = myMedArray.getLengthValue() ;
for (int i=1; i<=myMedArray.getLeadingValue() ; i++) {
- double * node = myMedArray.getI(MED_NO_INTERLACE,i) ;
+ const double * node = myMedArray.getColumn(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << node[j] << " " ;
MESSAGE("Show all 0 :");
numberof = myMedArray.getLeadingValue() ;
int length = myMedArray.getLengthValue() ;
- double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
+ const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
for (int i=0; i<length ; i++) {
cout << " - " ;
for (int j=0;j<numberof;j++)
affiche_medarray(* myMedArray);
MEDARRAY<double> * myMedArray2 = new MEDARRAY<double>();
* myMedArray2 = * myMedArray;
- delete myMedArray;
+ // delete myMedArray; // si on recopie les tableaux
affiche_medarray(* myMedArray2);
+ delete myMedArray; // si on ne recopie pas les tableaux
delete myMedArray2;
return 0;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_connectivity.cxx
+// Module : MED
+
using namespace std;
/* Programme de test du constructeur de copies de la classe CONNECTIVITY de MEDMEM
jroy - 19/12/2002 */
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
-void affiche_connectivity(CONNECTIVITY * myConnectivity, MESH * myMesh)
+void affiche_connectivity(const CONNECTIVITY * myConnectivity, MESH * myMesh)
{
int SpaceDimension = myMesh->getSpaceDimension() ;
int MeshDimension = myMesh->getMeshDimension() ;
int NumberOfNodes = myMesh->getNumberOfNodes() ;
- int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ;
- medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
+ int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ;
+ const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ;
cout << "Show Connectivity (Nodal) :" << endl ;
for (int i=0; i<NumberOfTypes; i++) {
cout << "For type " << Types[i] << " : " << endl ;
int NumberOfElements = myMesh->getNumberOfElements(MED_CELL,Types[i]);
- int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
+ const int * connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,Types[i]);
int NomberOfNodesPerCell = Types[i]%100 ;
for (int j=0;j<NumberOfElements;j++){
cout << "Element "<< j+1 <<" : " ;
}
cout << "Show Reverse Nodal Connectivity :" << endl ;
- int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
- int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
+ const int * ReverseNodalConnectivity = myMesh->getReverseConnectivity(MED_NODAL) ;
+ const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ;
for (int i=0; i<NumberOfNodes; i++) {
cout << "Node "<<i+1<<" : " ;
for (int j=ReverseNodalConnectivityIndex[i];j<ReverseNodalConnectivityIndex[i+1];j++)
cout << "Show Connectivity (Descending) :" << endl ;
int NumberOfElements ;
- int * connectivity ;
- int * connectivity_index ;
+ const int * connectivity ;
+ const int * connectivity_index ;
myMesh->calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL);
try {
NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
}
cout << "Show Reverse Descending Connectivity :" << endl ;
- int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
- int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
+ const int * ReverseDescendingConnectivity = myMesh->getReverseConnectivity(MED_DESCENDING) ;
+ const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ;
int NumberOfConstituents = 0;
string constituent ;
}
}
cout << "Show "<<constituent<<" Connectivity (Nodal) :" << endl ;
- int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
- int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
+ const int * face_connectivity = myMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,constituentEntity,MED_ALL_ELEMENTS);
+ const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity);
for (int i=0; i<NumberOfConstituents; i++) {
cout << constituent <<i+1<<" : " ;
for (int j=face_connectivity_index[i];j<face_connectivity_index[i+1];j++)
int main (int argc, char ** argv) {
- if (argc !=3) {
+ if (argc <3) { // after 3, ignored !
cerr << "Usage : " << argv[0]
<< " filename meshname" << endl << endl;
exit(-1);
myMeshDriver.read() ; //A partir d'ici la connectivité est construite
myMeshDriver.close() ;
- CONNECTIVITY * myConnectivity = myMesh->getConnectivityptr();
+ const CONNECTIVITY * myConnectivity = myMesh->getConnectivityptr();
affiche_connectivity(myConnectivity, myMesh);
+
CONNECTIVITY * myConnectivity2 = new CONNECTIVITY(* myConnectivity);
affiche_connectivity(myConnectivity2, myMesh);
- delete myConnectivity;//myConnectivity utile pour afficher myConnectivity2 via myMesh!
+
+ CONNECTIVITY * myConnectivity3 = new CONNECTIVITY(* myConnectivity2);
+ delete myConnectivity2;
+ affiche_connectivity(myConnectivity3, myMesh);
+ delete myConnectivity3;
+
+ delete myMesh ;
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_coordinate.cxx
+// Module : MED
+
using namespace std;
/* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM
jroy - 17/12/2002 */
// myCoordinate->setCoordinatesNames((string *)NULL);
// myCoordinate->setNodesNumbers((int *) NULL);
+ delete myMedArray ;
+ delete[] myCoordinatesNames ;
+ delete[] myCoordinatesUnits ;
+ delete[] myNodeNumber ;
+
affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension);
COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate);
- delete myCoordinate;
+ delete myCoordinate ;
+
affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension);
+ delete myCoordinate2 ;
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_family.cxx
+// Module : MED
+
using namespace std;
#include<string>
#include "MEDMEM_define.hxx"
-void affiche_support(SUPPORT * mySupport)
+void affiche_support(const SUPPORT * mySupport)
{
cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
if (!(mySupport->isOnAllElements())) {
int NumberOfTypes = mySupport->getNumberOfTypes() ;
cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
- medGeometryElement * Types = mySupport->getTypes() ;
+ const medGeometryElement * Types = mySupport->getTypes() ;
for (int j=0;j<NumberOfTypes;j++) {
cout<<" * Type "<<Types[j]<<" : ";
int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
- int * Number = mySupport->getNumber(Types[j]) ;
+ const int * Number = mySupport->getNumber(Types[j]) ;
for (int k=0; k<NumberOfElements;k++)
cout << Number[k] << " ";
cout << endl ;
}
-void affiche_famille(FAMILY * myFamily)
+void affiche_famille(const FAMILY * myFamily)
{
affiche_support(myFamily);
cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
for (int i=1; i<NumberOfGroups+1;i++) {
- GROUP* myGroup = myMesh->getGroup(Entity,i);
+ const GROUP* myGroup = myMesh->getGroup(Entity,i);
affiche_support(myGroup);
int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
int read;
- if (argc !=3) {
+ if (argc <3) { // after 3, ignored !
cerr << "Usage : " << argv[0]
<< " filename meshname" << endl << endl;
exit(-1);
myMeshDriver.read() ;
myMeshDriver.close() ;
- FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
+ const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
//On renseigne les attributs spécifiques à FAMILY (p/r à SUPPORT) et non renseignés lors de la lecture du maillage
- int NumberOfAttribute = 3;
- int *AttributeIdentifier = new int[NumberOfAttribute];
- int *AttributeValue = new int[NumberOfAttribute];
- string *AttributeDescription = new string[NumberOfAttribute];
- char *tmp;
- for (int i=0;i<NumberOfAttribute;i++)
- {
- AttributeIdentifier[i]=i+1;
- AttributeValue[i]=(i+1)*10;
- sprintf(tmp,"Attribut N° %d",i+1);
- AttributeDescription[i]=tmp;
- }
-
- myFamily->setNumberOfAttributes(NumberOfAttribute);
- myFamily->setAttributesIdentifiers (AttributeIdentifier);
- myFamily->setAttributesValues (AttributeValue);
- myFamily->setAttributesDescriptions (AttributeDescription);
+// int NumberOfAttribute = 3;
+// int *AttributeIdentifier = new int[NumberOfAttribute];
+// int *AttributeValue = new int[NumberOfAttribute];
+// string *AttributeDescription = new string[NumberOfAttribute];
+// char *tmp;
+// for (int i=0;i<NumberOfAttribute;i++)
+// {
+// AttributeIdentifier[i]=i+1;
+// AttributeValue[i]=(i+1)*10;
+// sprintf(tmp,"Attribut N° %d",i+1);
+// AttributeDescription[i]=tmp;
+// }
+
+// myFamily->setNumberOfAttributes(NumberOfAttribute);
+// myFamily->setAttributesIdentifiers (AttributeIdentifier);
+// myFamily->setAttributesValues (AttributeValue);
+// myFamily->setAttributesDescriptions (AttributeDescription);
cout << "Show Family :"<<endl ;
affiche_famille(myFamily);
FAMILY * myFamily2 = new FAMILY(* myFamily);
- delete myFamily;
+ //delete myFamily;
+ cout << "Show Family2 :"<<endl ;
affiche_famille(myFamily2);
+ FAMILY * myFamily3 = new FAMILY(* myFamily2);
delete myFamily2;
+ cout << "Show Family3 :"<<endl ;
+ affiche_famille(myFamily3);
+ delete myFamily3;
+
+ cout << "That's all"<<endl ;
/*
cout << "Show Group :"<<endl ;
affiche_groupe(myMesh,MED_FACE);
affiche_groupe(myMesh,MED_EDGE);
*/
+
+ delete myMesh;
+
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_fieldT.cxx
+// Module : MED
+
using namespace std;
/* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM
jroy - 12/12/2002 */
int NumberOfComponents = myField->getNumberOfComponents() ;
for (int i=1; i<NumberOf+1; i++) {
- double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
+ const double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
for (int j=0; j<NumberOfComponents; j++)
cout << value[j]<< " ";
cout<<endl;
myMesh->setName(meshname);
MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
myMeshDriver.setMeshName(meshname);
- myMeshDriver.open() ;
- myMeshDriver.read() ;
- myMeshDriver.close() ;
+ int current = myMesh->addDriver(myMeshDriver);
+ myMesh->read(current);
// read field :
if (argc != 4) exit(0) ;
// else we have a field !
string fieldname = argv[3];
+ FIELD<double> * myField ;
// SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
- FIELD<double> * myField = new FIELD<double>() ;
-
- myField->setName(fieldname);
- myField->setSupport(mySupport);
- MED_FIELD_RDONLY_DRIVER<double> myFieldDriver(filename,myField) ;
- myFieldDriver.setFieldName(fieldname);
- myFieldDriver.open() ;
-
try {
- myFieldDriver.read() ;
+ myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
+ myField->setValueType(MED_REEL64);
} catch (...) {
delete mySupport ;
mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
- myField->setSupport(mySupport);
try {
- myFieldDriver.read() ;
+ myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
+ myField->setValueType(MED_REEL64);
} catch (...) {
- cout << "Field " << fieldname << " not found !!!" << endl ;
+ cout << "Field double " << fieldname << " not found !!!" << endl ;
exit (-1) ;
}
}
- myFieldDriver.close() ;
-
affiche_fieldT(myField, mySupport);
FIELD<double> * myField2 = new FIELD<double>(* myField);
delete myField;
affiche_fieldT(myField2, myField2->getSupport());
delete myField2;
+ delete mySupport ;
+ delete myMesh ;
+
return 0;
}
-using namespace std;
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_field_.cxx
+// Module : MED
+
/* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM
jroy - 12/12/2002 */
// SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
FIELD<double> * myField = new FIELD<double>() ;
+ myField->setValueType(MED_REEL64);
myField->setName(fieldname);
myField->setSupport(mySupport);
FIELD_ * pt_field_2 = new FIELD_(* pt_field_);
delete myField;
affiche_field(pt_field_2, pt_field_2->getSupport());
+
+ delete pt_field_2 ;
+
+ delete mySupport ;
+ delete myMesh ;
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_group.cxx
+// Module : MED
+
using namespace std;
#include<string>
#include "MEDMEM_define.hxx"
-void affiche_support(SUPPORT * mySupport)
+void affiche_support(const SUPPORT * mySupport)
{
cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
if (!(mySupport->isOnAllElements())) {
int NumberOfTypes = mySupport->getNumberOfTypes() ;
cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
- medGeometryElement * Types = mySupport->getTypes() ;
+ const medGeometryElement * Types = mySupport->getTypes() ;
for (int j=0;j<NumberOfTypes;j++) {
cout<<" * Type "<<Types[j]<<" : ";
int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
- int * Number = mySupport->getNumber(Types[j]) ;
+ const int * Number = mySupport->getNumber(Types[j]) ;
for (int k=0; k<NumberOfElements;k++)
cout << Number[k] << " ";
cout << endl ;
}
-void affiche_famille(FAMILY * myFamily)
+void affiche_famille(const FAMILY * myFamily)
{
affiche_support(myFamily);
cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
}
-void affiche_groupe(GROUP * myGroup)
+void affiche_groupe(const GROUP * myGroup)
{
affiche_support(myGroup);
int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
int read;
- if (argc !=3) {
+ if (argc <3) { // after 3, ignored !
cerr << "Usage : " << argv[0]
<< " filename meshname" << endl << endl;
exit(-1);
myMeshDriver.read() ;
myMeshDriver.close() ;
- GROUP * myGroup = myMesh->getGroup(MED_NODE,1);
+ const GROUP * myGroup = myMesh->getGroup(MED_NODE,1);
cout << "Show Group :"<<endl ;
affiche_groupe(myGroup);
GROUP * myGroup2 = new GROUP(* myGroup);
- delete myGroup;
+ //delete myGroup; // no because in mesh !!
affiche_groupe(myGroup2);
+ GROUP * myGroup3 = new GROUP(* myGroup2);
delete myGroup2;
+ affiche_groupe(myGroup3);
+ delete myGroup3;
+
+ delete myMesh ;
return 0;
}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_medarray.cxx
+// Module : MED
+
using namespace std;
/* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
jroy - 16/12/2002 */
MESSAGE("Show all 1 :");
numberof = myMedArray.getLeadingValue() ;
for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
- double * node = myMedArray.getI(MED_FULL_INTERLACE,i) ;
+ const double * node = myMedArray.getRow(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << node[j] << " " ;
MESSAGE("Show all 2 :");
numberof = myMedArray.getLengthValue() ;
for (int i=1; i<=myMedArray.getLeadingValue() ; i++) {
- double * node = myMedArray.getI(MED_NO_INTERLACE,i) ;
+ const double * node = myMedArray.getColumn(i) ;
cout << " - " ;
for (int j=0;j<numberof;j++)
cout << node[j] << " " ;
MESSAGE("Show all 0 :");
numberof = myMedArray.getLeadingValue() ;
int length = myMedArray.getLengthValue() ;
- double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
+ const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
for (int i=0; i<length ; i++) {
cout << " - " ;
for (int j=0;j<numberof;j++)
};
affiche_medarray(* myMedArray);
- MEDARRAY<double> * myMedArray2 = new MEDARRAY<double>(* myMedArray);
+ MEDARRAY<double> * myMedArray2 = new MEDARRAY<double>(* myMedArray,false);
delete myMedArray;
affiche_medarray(* myMedArray2);
+ MEDARRAY<double> * myMedArray3 = new MEDARRAY<double>(10,20);
+ (* myMedArray3) = (* myMedArray2) ;
delete myMedArray2;
+ affiche_medarray(* myMedArray3);
+ delete myMedArray3;
return 0;
}
--- /dev/null
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : test_copie_mesh.cxx
+// Module : MED
+
+using namespace std;
+#include<string>
+
+#include <math.h>
+#include <stdlib.h>
+
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDMEM_Group.hxx"
+
+#include "MEDMEM_MedMeshDriver.hxx"
+#include "MEDMEM_MedFieldDriver.hxx"
+#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Field.hxx"
+#include "MEDMEM_define.hxx"
+
+
+int main (int argc, char ** argv) {
+
+ int read;
+
+ if (argc <3) { // after 3, ignored !
+ cerr << "Usage : " << argv[0]
+ << " filename meshname" << endl << endl;
+ exit(-1);
+ }
+
+ string filename = argv[1] ;
+ string meshname = argv[2] ;
+
+ MESH * myMesh= new MESH() ;
+ myMesh->setName(meshname);
+ MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
+ myMeshDriver.setMeshName(meshname);
+ myMeshDriver.open() ;
+ myMeshDriver.read() ;
+ myMeshDriver.close() ;
+
+ cout << * myMesh << endl;
+ MESH * myMesh2 = new MESH(* myMesh);
+ delete myMesh;
+ cout << * myMesh2 << endl;
+ delete myMesh2;
+
+ return 0;
+}
+// MED MEDMEM : MED files in memory
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : test_copie_support.cxx
+// Module : MED
+
using namespace std;
#include<string>
#include "MEDMEM_define.hxx"
-void affiche_support(SUPPORT * mySupport)
+void affiche_support(const SUPPORT * mySupport)
{
cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
if (!(mySupport->isOnAllElements())) {
int NumberOfTypes = mySupport->getNumberOfTypes() ;
cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
- medGeometryElement * Types = mySupport->getTypes() ;
+ const medGeometryElement * Types = mySupport->getTypes() ;
for (int j=0;j<NumberOfTypes;j++) {
cout<<" * Type "<<Types[j]<<" : ";
int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
- int * Number = mySupport->getNumber(Types[j]) ;
+ const int * Number = mySupport->getNumber(Types[j]) ;
for (int k=0; k<NumberOfElements;k++)
cout << Number[k] << " ";
cout << endl ;
int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
cout << "NumberOfFamilies : "<<NumberOfFamilies<<endl;
for (int i=1; i<NumberOfFamilies+1;i++) {
- FAMILY* myFamily = myMesh->getFamily(Entity,i);
+ const FAMILY* myFamily = myMesh->getFamily(Entity,i);
affiche_support(myFamily);
cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
for (int i=1; i<NumberOfGroups+1;i++) {
- GROUP* myGroup = myMesh->getGroup(Entity,i);
+ const GROUP* myGroup = myMesh->getGroup(Entity,i);
affiche_support(myGroup);
int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
int read;
- if (argc !=3) {
+ if (argc <3) { // after 3, ignored !
cerr << "Usage : " << argv[0]
<< " filename meshname" << endl << endl;
exit(-1);
// int TotalNumberOfEntity = 2;
// medGeometryElement * GeometricTypePartial = new medGeometryElement[NumberOfGeometricType];
// GeometricTypePartial[0] = MED_HEXA8;
- medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL);
- int TotalNumberOfEntity = 0;
- int * NumberOfEntity = new int[myMesh->getNumberOfTypes(MED_CELL)];
+ int TotalNumberOfElements = 0;
+ int * NumberOfElements = new int[myMesh->getNumberOfTypes(MED_CELL)];
// NumberOfEntity[0] = 2;
// int * NumberValue = new int[TotalNumberOfEntity];
int * NumberValue = new int[myMesh->getGlobalNumberingIndex(MED_CELL)[myMesh->getNumberOfTypes(MED_CELL)]-1];
// NumberValue[1] = 15;
int cmp = 0;
medGeometryElement * GeometricTypePartial = new medGeometryElement[myMesh->getNumberOfTypes(MED_CELL)];
+ const medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL);
for (int i=0;i<myMesh->getNumberOfTypes(MED_CELL);i=i+2)
{
NumberOfGeometricType=NumberOfGeometricType+1;
- TotalNumberOfEntity=TotalNumberOfEntity+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
- NumberOfEntity[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
+ TotalNumberOfElements=TotalNumberOfElements+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
+ NumberOfElements[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
for (int j=0;j<myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);j++)
{
NumberValue[cmp]=myMesh->getGlobalNumberingIndex(MED_CELL)[i]+j;
GeometricTypePartial[i/2]=GeometricType[i];
}
- mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfEntity,GeometricTypePartial,NumberOfEntity,NumberValue);
+ mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfElements,GeometricTypePartial,NumberOfElements,NumberValue);
+
+ delete[] NumberOfElements ;
+ delete[] NumberValue ;
+ delete[] GeometricTypePartial ;
cout << "Show Partial Support :"<<endl ;
affiche_support(mySupport);
affiche_groupe(myMesh,MED_FACE);
affiche_groupe(myMesh,MED_EDGE);
*/
+
+ delete myMesh ;
+
return 0;
}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : readCoordinate.cxx
+// Module : MED
+
+using namespace std;
+#include<string>
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Mesh.hxx"
+
+void usage(char * name)
+{
+ cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
+ cout << " " << "displays all Nodes Coordinates in mdump mode" << endl;
+ cout << endl;
+ cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl;
+ cout << " " << "values for interlace mode are : " << endl;
+ cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
+ exit(-1);
+}
+
+int main (int argc, char ** argv) {
+
+ if (argc < 3) usage(argv[0]);
+ if (argc > 4) usage(argv[0]);
+
+ string fileName = argv[1];
+ string meshName = argv[2];
+
+ medModeSwitch Mode = MED_FULL_INTERLACE;
+ if (argc==4)
+ {
+ string comp=argv[3];
+ if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE;
+ else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
+ }
+
+
+ MESH * myMesh= new MESH() ;
+ myMesh->setName(meshName);
+ MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
+ try
+ {
+ myMeshDriver.setMeshName(meshName);
+ myMeshDriver.open();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Catch Exception : ");
+ SCRUTE(ex.what());
+ };
+ MESSAGE("Open done");
+
+ try
+ {
+ myMeshDriver.read();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Catch Exception : ");
+ SCRUTE(ex.what());
+ };
+ MESSAGE("Read done");
+
+ int SpaceDimension = myMesh->getSpaceDimension() ;
+ int MeshDimension = myMesh->getMeshDimension() ;
+ int NumberOfNodes = myMesh->getNumberOfNodes() ;
+
+ cout << "(************************)"<<endl;
+ cout << "(* NOEUDS DU MAILLAGE : *)"<<endl;
+ cout << "(************************)"<<endl;
+
+ string typeRepere = myMesh->getCoordinatesSystem();
+ if ( typeRepere.size() == 0 ) typeRepere ="0";
+ cout << "- Type de repere des coordonnees : " << typeRepere << endl;
+
+ string chainevide(MED_TAILLE_PNOM+2,' ');
+ cout << "- Nom des coordonnees : " << endl ;
+ const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
+ for (int i=0; i < SpaceDimension ; i++)
+ {
+ string bonnelongueur=chainevide;
+ bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]);
+ cout << bonnelongueur;
+ }
+ cout <<endl;
+
+ cout << "- Unites des coordonnees : " << endl ;
+ const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
+ for ( int i=0; i < SpaceDimension ; i++)
+ {
+ string bonnelongueur=chainevide;
+ bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]);
+ cout << bonnelongueur;
+ }
+ cout <<endl;
+
+ const double * Coordinates = myMesh->getCoordinates(Mode) ;
+ cout << "- Coordonnees des noeuds : " << endl;
+ for (int i=0; i < SpaceDimension*NumberOfNodes; i++)
+ {
+ fprintf(stdout," %f ",Coordinates[i]);
+ }
+ cout <<endl;
+
+ delete myMesh;
+
+}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : readEntete.cxx
+// Module : MED
+
+using namespace std;
+#include<string>
+#include "MEDMEM_Exception.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_DriversDef.hxx"
+
+void usage(char * name)
+{
+ cout << " " << name <<" <file name>"<< " <mesh name> " << " <interlace mode>" << endl;
+ cout << " " << "displays all Nodes Coordinates in mdump mode" << endl;
+ cout << endl;
+ cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl;
+ cout << " " << "values for interlace mode are : " << endl;
+ cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl;
+ exit(-1);
+}
+
+int main (int argc, char ** argv) {
+
+ if (argc < 3) usage(argv[0]);
+ if (argc > 4) usage(argv[0]);
+
+ string fileName = argv[1];
+ string meshName = argv[2];
+
+ medModeSwitch Mode = MED_FULL_INTERLACE;
+ if (argc==4)
+ {
+ string comp=argv[3];
+ if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE;
+ else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]);
+ }
+
+
+ MESH * myMesh= new MESH() ;
+ myMesh->setName(meshName);
+ MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh);
+ try
+ {
+ myMeshDriver.setMeshName(meshName);
+ myMeshDriver.open();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Catch Exception : ");
+ SCRUTE(ex.what());
+ };
+ MESSAGE("Open done");
+
+ try
+ {
+ myMeshDriver.read();
+ }
+ catch (const exception & ex)
+ {
+ MESSAGE("Catch Exception : ");
+ SCRUTE(ex.what());
+ };
+ MESSAGE("Read done");
+
+ int SpaceDimension = myMesh->getSpaceDimension();
+ int MeshDimension = myMesh->getMeshDimension();
+ int NumberOfNodes = myMesh->getNumberOfNodes();
+
+ cout << "(****************************)" << endl;
+ cout << "(* INFORMATIONS GENERALES : *)" << endl;
+ cout << "(****************************)" << endl;
+
+ string chainevide(MED_TAILLE_PNOM+2,' ');
+ cout << "- Nom du maillage : <<" << meshName << ">>" << endl;
+ cout << "- Dimension du maillage : "<< SpaceDimension << endl;
+ cout << "- Pas de nom universel " << endl ;
+ cout << "- Nombre de noeuds : " << NumberOfNodes << " " << endl;
+
+ int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL);
+ const medGeometryElement * Types = myMesh->getTypes(MED_CELL);
+
+
+ const list<MED_FR::med_geometrie_element> currentEntity = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_CELL];
+ list<MED_FR::med_geometrie_element>::const_iterator currentGeometry;
+ for (currentGeometry = currentEntity.begin();
+ currentGeometry != currentEntity.end();
+ currentGeometry++)
+ {
+ cout << "- Nombre de mailles de type ";
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << " : ";
+ cout << myMesh->getNumberOfElements(MED_CELL,(MED_EN::medGeometryElement)(*currentGeometry));
+ cout << " " << endl;
+ }
+
+ const list<MED_FR::med_geometrie_element> currentEntity2 = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_FACE];
+ for (currentGeometry = currentEntity2.begin();
+ currentGeometry != currentEntity2.end();
+ currentGeometry++)
+ {
+ cout << "- Nombre de faces de type ";
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << " : ";
+ cout << myMesh->getNumberOfElements(MED_FACE,(MED_EN::medGeometryElement)(*currentGeometry));
+ cout << " " << endl;
+ }
+
+ const list<MED_FR::med_geometrie_element> currentEntity3 = MED_FR::meshEntities[(MED_FR::med_entite_maillage)MED_EDGE];
+ for (currentGeometry = currentEntity3.begin();
+ currentGeometry != currentEntity3.end();
+ currentGeometry++)
+ {
+ cout << "- Nombre d'aretes de type ";
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << " : ";
+ cout << myMesh->getNumberOfElements(MED_EDGE,(MED_EN::medGeometryElement)(*currentGeometry));
+ cout << " " << endl;
+ }
+
+ delete myMesh;
+}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUArray.cxx
+// Module : MED
+
+using namespace std;
+#include <cstdlib> // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE
+#include "utilities.h"
+#include "MEDMEM_Array.hxx"
+
+void imprime(string titre,const int * myValues,const int * myOthers, int lignes, int colonnes)
+{
+ cout << " " <<titre << endl<< endl;
+ cout << "Full Interlace : " << endl;
+ if (myValues != NULL)
+ {
+ for (int i=0; i<lignes; i++)
+ {
+ cout << " - ";
+ for (int k=0; k< colonnes; k++)
+ {
+ cout << myValues[k + i * colonnes]<< " " ;
+ }
+ cout << endl;
+ }
+ }
+ else
+ {
+ cout << "Pointeur Null : pas de valeur" << endl << endl;
+ }
+ cout << endl;
+ cout << "No Interlace : " << endl;
+
+ if (myOthers != NULL)
+ {
+ for (int k=0; k< colonnes; k++)
+ {
+ cout << " - ";
+ for (int i=0; i<lignes; i++)
+ {
+ cout << myOthers[i + k*lignes]<< " " ;
+ }
+ cout << endl;
+ }
+ }
+ else
+ {
+ cout << "Pointeur Null : pas de valeur" << endl << endl;
+ }
+ cout << endl;
+}
+
+int main (int argc, char ** argv)
+{
+
+ /* ---------------------------------------------------------- */
+ /* */
+ /* INITIALISATION */
+ /* */
+ /* - constructeur new MEDARRAY<int>(int,int,mode) */
+ /* - get sur le pointeur MED_FULL_INTERLACE */
+ /* - initialisation des valeurs (coordonnées ieme elt = I+1) */
+ /* - get sur le pointeur MED_NO_INTERLACE */
+ /* ---------------------------------------------------------- */
+
+ int SpaceDimension = 3;
+ int NumberOfNodes = 4;
+
+
+
+ MEDARRAY<int> * myArrayfull= new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE);
+ ASSERT(myArrayfull != NULL);
+
+ const int * myValues = myArrayfull->get(MED_FULL_INTERLACE);
+ ASSERT(myValues!= NULL);
+
+ for (int i=0; i<NumberOfNodes; i++)
+ {
+ for (int k=0; k<SpaceDimension; k++)
+ {
+ //myValues[i* SpaceDimension +k]=i + 1;
+ myArrayfull->setIJ(i+1,k+1,i+1) ;
+ }
+ }
+
+ const int * myOthers = myArrayfull->get(MED_NO_INTERLACE) ;
+ ASSERT(myOthers != NULL);
+
+ imprime("Initialisation full interlace (xi=yi=zi=i+1)",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ MEDARRAY<int> * myArrayno= new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_NO_INTERLACE);
+ ASSERT(myArrayno != NULL);
+ const int * myValuesno = myArrayno->get(MED_NO_INTERLACE);
+ ASSERT(myValuesno!= NULL);
+
+ for (int k=0; k<SpaceDimension; k++)
+ {
+ for (int i=0; i<NumberOfNodes; i++)
+ {
+ //myValuesno[i +k*NumberOfNodes]=k + 1;
+ myArrayno->setIJ(i+1,k+1,k+1) ;
+ }
+ }
+
+ const int * myOthersno = myArrayno->get(MED_FULL_INTERLACE) ;
+ ASSERT(myOthersno != NULL);
+
+ imprime("Initialisation no interlace (xi=yi=zi=i+1)",myOthersno,myValuesno,NumberOfNodes,SpaceDimension);
+
+
+ /* ---------------------------------------------------------- */
+ /* */
+ /* Tests des Fonctions Set */
+ /* */
+ /* - setI sur l'element 1 avec des coordonnees a 100 */
+ /* - setJ sur l'element 1 avec des coordonnees a 100 */
+ /* - setIJ sur (1,2) avec une coordonnee = 1992 */
+ /* - set avec l ensemble des coordonnes remises à i */
+ /* ---------------------------------------------------------- */
+
+
+ int * myNewLine = new int[SpaceDimension];
+ for (int i = 0; i < SpaceDimension; i++)
+ myNewLine[i] = myValues[i] * 100;
+ try
+ {
+ myArrayfull->setI(1, myNewLine);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "--------------" << endl;
+ cout << " Pb au setI " << endl;
+ cout << "--------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au setI " << endl;
+ cout << "---------------" << endl;
+ }
+
+ delete [] myNewLine;
+ imprime("1er element : coordonnees à 100",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ int * myNewCol = new int[NumberOfNodes];
+ for (int i = 0; i < NumberOfNodes; i++)
+ myNewCol[i] = 100;
+ try
+ {
+ myArrayno->setJ(1, myNewCol);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "--------------" << endl;
+ cout << " Pb au setJ " << endl;
+ cout << "--------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au setJ " << endl;
+ cout << "---------------" << endl;
+ }
+
+ delete [] myNewCol;
+ imprime("1eres coordonnees à 100",myOthersno,myValuesno,NumberOfNodes,SpaceDimension);
+
+ try
+ {
+ myArrayfull->setIJ(1,2,1992);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " Pb au setIJ() de 1 , 2 " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------------------" << endl;
+ cout << " Pb au setIJ() de 1 , 2 " << endl;
+ cout << "-----------------------------" << endl;
+ }
+
+ imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+
+ try
+ {
+ myArrayno->setIJ(1,2,1992);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " Pb au setIJ() de 1 , 2 " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------------------" << endl;
+ cout << " Pb au setIJ() de 1 , 2 " << endl;
+ cout << "-----------------------------" << endl;
+ }
+
+ imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ int * mynewvalues= new int [ NumberOfNodes*SpaceDimension ];
+ for (int i=0; i<NumberOfNodes*SpaceDimension; i++)
+ {
+ mynewvalues[i]=i;
+ }
+ try
+ {
+ myArrayfull->set(MED_FULL_INTERLACE,mynewvalues);
+ myValues = myArrayfull->get(MED_FULL_INTERLACE);
+ myOthers = myArrayfull->get(MED_NO_INTERLACE);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------" << endl;
+ cout << " Pb au set " << endl;
+ cout << "-------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "--------------" << endl;
+ cout << " Pb au set " << endl;
+ cout << "--------------" << endl;
+ }
+ imprime("remise valeur a i sur myArrayfull med full interlace",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ try
+ {
+ myArrayno->set(MED_FULL_INTERLACE,mynewvalues);
+ myValuesno = myArrayfull->get(MED_FULL_INTERLACE);
+ myOthersno = NULL;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------" << endl;
+ cout << " Pb au set " << endl;
+ cout << "-------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "--------------" << endl;
+ cout << " Pb au setI " << endl;
+ cout << "--------------" << endl;
+ }
+ imprime("set full interlace de myArrayno",myValuesno,myOthersno,NumberOfNodes,SpaceDimension);
+
+ /* ---------------------------------------------------------- */
+ /* */
+ /* Tests des constructeurs */
+ /* Tests des Fonctions Get */
+ /* */
+ /* */
+ /* ---------------------------------------------------------- */
+
+ MEDARRAY<int> * myArrayShare = new MEDARRAY<int>( *myArrayfull);
+ const int * sharevalues = myArrayShare->get(MED_FULL_INTERLACE);
+ const int * shareno = myArrayShare->get(MED_NO_INTERLACE);
+ imprime("test contructeur par recopie non profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension);
+
+ myArrayfull->setIJ(1,2,1992);
+ ASSERT(myArrayShare->getIJ(1,2) == 1992);
+ imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension);
+
+ myArrayShare->setIJ(1,2,1995);
+ ASSERT(myArrayfull->getIJ(1,2) == 1995);
+ imprime("change valeur tableau cible, impression tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ delete myArrayShare;
+ imprime("tableau cible apres destruction tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ MEDARRAY<int> * myArrayShare2 = new MEDARRAY<int>( *myArrayfull,true);
+ sharevalues = myArrayShare2->get(MED_FULL_INTERLACE);
+ shareno = myArrayShare2->get(MED_NO_INTERLACE);
+ imprime("test contructeur par recopie profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension);
+
+ myArrayfull->setIJ(1,2,18);
+ imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension);
+
+ myArrayShare2->setIJ(1,2,19);
+ imprime("change valeur tableau cible, impression tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension);
+
+ myArrayno->set(MED_NO_INTERLACE,mynewvalues);
+ myArrayno->setIJ(2,1,1);
+ myValuesno = myArrayno->get(MED_NO_INTERLACE);
+ myOthersno = myArrayno->get(MED_FULL_INTERLACE);
+ imprime("Initialisation no interlace (0...11)",myOthersno,myValuesno,NumberOfNodes,SpaceDimension);
+
+ MEDARRAY<int> * myArrayShare3 = new MEDARRAY<int>( *myArrayno);
+ sharevalues = myArrayShare3->get(MED_FULL_INTERLACE);
+ shareno = myArrayShare3->get(MED_NO_INTERLACE);
+ imprime("test contructeur par recopie non profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension);
+
+ myArrayno->setIJ(1,2,1992);
+ ASSERT(myArrayShare3->getIJ(1,2) == 1992);
+ imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension);
+
+ myArrayShare3->setIJ(1,2,1995);
+ ASSERT(myArrayno->getIJ(1,2) == 1995);
+ imprime("change valeur tableau cible, impression tableau source",myValuesno,myOthersno,NumberOfNodes,SpaceDimension);
+
+ delete myArrayno;
+ delete [] mynewvalues;
+ delete myArrayfull;
+ delete myArrayShare2;
+ delete myArrayShare3;
+ MESSAGE("FIN NORMALE DU TRAITEMENT");
+ return EXIT_SUCCESS ;
+}
+/*
+ inline medModeSwitch getMode() const ;
+*/
--- /dev/null
+#include <cstdlib> // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE
+#include "utilities.h"
+#include "MEDMEM_Array.hxx"
+
+int main (int argc, char ** argv)
+{
+
+ int SpaceDimension = 3;
+ int NumberOfNodes = 4;
+ MEDARRAY<int> * myArray = new MEDARRAY<int>(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ;
+ ASSERT(myArray != NULL);
+
+ int * value = myArray->get(MED_FULL_INTERLACE) ;
+ ASSERT(value!= NULL);
+
+ for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
+ value[i]=i ;
+
+ int leadingValue;
+ try
+ {
+ leadingValue = myArray->getLeadingValue() ;
+ ASSERT (leadingValue == SpaceDimension);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getLeadingValue() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getLeadingValue() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ int lengthValue;
+ try
+ {
+ lengthValue = myArray->getLengthValue() ;
+ ASSERT(lengthValue == NumberOfNodes)
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getLengthValue() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getLengthValue() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ cout << "Show all using getI and full interlace :" << endl;
+ for (int i=1; i<=lengthValue; i++)
+ {
+ try
+ {
+ int * node = myArray->getI(MED_FULL_INTERLACE,i) ;
+ cout << " - " ;
+ for (int j=0;j<leadingValue;j++)
+ cout << node[j] << " " ;
+ cout << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getI() valeur de i " << i << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getI() valeur de i " << i << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+
+ cout << "Show all using getI and no interlace :" << endl;
+ for (int i=1; i<=leadingValue; i++)
+ {
+ try
+ {
+ int * node = myArray->getI(MED_NO_INTERLACE,i) ;
+ cout << " - " ;
+ for (int j=0;j<lengthValue;j++)
+ cout << node[j] << " " ;
+ cout << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getI() valeur de i " << i << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getI() valeur de i " << i << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+
+ cout << "Show all using getIJ :" << endl;
+ for (int i=1; i<=lengthValue ; i++)
+ {
+ int j;
+ try
+ {
+ cout << " - " ;
+ for (j=1;j<leadingValue+1;j++)
+ cout << myArray->getIJ(i,j) << " " ;
+ cout << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getIJ() i " << i << " j " << j << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getIJ() i " << i << " j " << j << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+
+ cout << "Show all using get and MED_NO_INTERLACE :" << endl;
+ try
+ {
+ int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ;
+ for (int i=0; i<lengthValue ; i++)
+ {
+ cout << " - " ;
+ for (int j=0;j<leadingValue;j++)
+ cout << NoInterlaceArray[j*lengthValue+i] << " " ;
+ cout << endl ;
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au get " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au get " << endl;
+ cout << "---------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+
+ cout << endl << endl << "Tests des fonctions Set " << endl;
+
+ int * myNewInt = new int[SpaceDimension*NumberOfNodes];
+ for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
+ {
+ myNewInt[i]=i*10 ;
+ }
+
+ try
+ {
+ myArray->set(MED_FULL_INTERLACE, myNewInt);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au set " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au set " << endl;
+ cout << "---------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ delete [] myNewInt;
+
+ cout << "Nouvelles valeurs (x10) : get avec Full interlace : " << endl;
+ int * myNewValue;
+ try
+ {
+ myNewValue = myArray->get(MED_FULL_INTERLACE) ;
+ ASSERT(myNewValue!= NULL);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " Pb au get " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au get " << endl;
+ cout << "---------------" << endl;
+ }
+
+ cout << " - ";
+ for (int i=0; i<SpaceDimension*NumberOfNodes; i++)
+ cout << myNewValue[i]<< " " ;
+ cout << endl;
+
+
+ int * myNewLine = new int[SpaceDimension];
+ for (int i = 0; i < SpaceDimension; i++)
+ myNewLine[i] = i * 100;
+
+ try
+ {
+ myArray->setI(MED_FULL_INTERLACE, 1, myNewLine);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getLengthValue() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au setI " << endl;
+ cout << "---------------" << endl;
+ }
+ delete [] myNewLine;
+
+ try
+ {
+ myNewValue = myArray->getI(MED_FULL_INTERLACE,1) ;
+ ASSERT(myNewValue!= NULL);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getLengthValue() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------" << endl;
+ cout << " Pb au getI " << endl;
+ cout << "---------------" << endl;
+ }
+
+ cout << endl << " Nouvelles valeurs (x100) sur la 1ere ligne: get avec Full interlace : ";
+ cout << endl << " - ";
+ for (int i=0; i<SpaceDimension; i++)
+ cout << myNewValue[i]<< " " ;
+ cout << endl;
+
+ try
+ {
+ myArray->setIJ(1,1,1992);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " Pb au setIJ() de 1 , 1 " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------------------" << endl;
+ cout << " Pb au setIJ() de 1 , 1 " << endl;
+ cout << "-----------------------------" << endl;
+ }
+
+ cout << "Nouvelle valeur avec setIJ et getIJ" << endl;
+ cout << " - " << myArray->getIJ(1,1) << endl;
+
+ delete myArray;
+ return EXIT_SUCCESS ;
+}
+
+/*
+ inline medModeSwitch getMode() const ;
+
+*/
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUCellModel.cxx
+// Module : MED
+
+using namespace std;
+#include <set>
+#include <cstdlib>
+#include "utilities.h"
+
+#include "MEDMEM_CellModel.hxx"
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_DriversDef.hxx"
+
+void usage(char * name)
+{
+ cout << " " << name << endl;
+}
+
+int main (int argc, char ** argv)
+{
+
+ if (argc < 1) usage(argv[0]);
+
+
+ cout << "CELLMODEL Test" << endl ;
+ cout << "--------------" << endl;
+
+/* -----------------------------------------------------
+ Construction de tous les types de cellmodel possibles
+ -----------------------------------------------------
+*/
+
+ CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ];
+ const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]=
+ {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3,
+ MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4,
+ MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10,
+ MED_PYRA13, MED_PENTA15, MED_HEXA20 };
+
+ for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
+ {
+ tous[i]=CELLMODEL(allCellType[i]);
+ }
+
+/* -----------------------------------------------------
+ Boucle sur tous les types de cellmodel possibles
+ - Chaque Méthode de cellmodel est appelee
+ -----------------------------------------------------
+*/
+ for (int i=0; i<MED_NBR_GEOMETRIE_MAILLE ; i++)
+ {
+ cout << endl;
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)tous[i].getType()] << endl;
+ cout << "__________________" << endl;
+
+ try
+ {
+ cout << "CellModel de Nom : " << tous[i].getName() << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getName() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getName() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ try
+ {
+ cout << "Nb de Vertexes : " << tous[i].getNumberOfVertexes() << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNumberOfVertexes() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------------------" << endl;
+ cout << " Pb au getNumberOfVertexes() " << endl;
+ cout << "---------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ try
+ {
+ cout << "Nb de Noeuds : " << tous[i].getNumberOfNodes() << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNumberOfNodes() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------------" << endl;
+ cout << " Pb au getNumberOfNodes() " << endl;
+ cout << "---------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ int dimension;
+ try
+ {
+ dimension=tous[i].getDimension();
+ cout << "Dimension : " << dimension << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getDimension() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getDimension() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ for (int dim=1; dim< dimension; dim++)
+ {
+ int dim2=dimension - dim;
+ cout << "Nb d elements de dimension " << dim << " : ";
+
+ try
+ {
+ cout << tous[i].getNumberOfConstituents(dim)<< endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------------------------" << endl;
+ cout << " Pb au getNumberOfConstituents() " << endl;
+ cout << "------------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------------------" << endl;
+ cout << " Pb au getNumberOfConstituents() " << endl;
+ cout << "------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+ }
+/*
+
+ try
+ {
+ int** v1=tous[i].getConstituents(dim2);
+ if ( v1.size() != tous[i].getNumberOfConstituents(dim2) )
+ {
+ cout << "----------------------------" << endl;
+ cout << " Pb au getConstituents() " << endl;
+ cout << "----------------------------" << endl;
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getConstituents() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------------------" << endl;
+ cout << " Pb au getConstituents() " << endl;
+ cout << "----------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ cout << "Types de ces elements " << endl;
+
+ set <medGeometryElement> setGeomElt;
+ medGeometryElement * vt;
+ int taille;
+ try
+ {
+ vt=tous[i].getConstituentsType(dim2);
+ taille=tous[i].getNumberOfConstituents(dim2);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getConstituentsType() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "--------------------------------" << endl;
+ cout << " Pb au getConstituentsType() " << endl;
+ cout << "--------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+ for (int k=0; k<taille;k++)
+ {
+ try
+ {
+ medGeometryElement me=tous[i].getConstituentType(dim2,k+1);
+ if ( vt[k] != me )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getConstituentType() " << endl;
+ cout << "-------------------------------" << endl;
+ }
+ setGeomElt.insert(me);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getConstituentType() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "--------------------------------" << endl;
+ cout << " Pb au getConstituentsType() " << endl;
+ cout << "--------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+
+/*
+ set <medGeometryElement>::iterator iter_s;
+ for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++)
+ {
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;
+ }
+
+ cout << "Impression des coordonnées du 1er Element de ce type" << endl;
+ try
+ {
+ vector<int> v2=tous[i].getNodesConstituent(dim2,1);
+ for (int k=0; k<v2.size();k++)
+ {
+ cout << v2[k] << " ";
+ try
+ {
+ int verif=tous[i].getNodeConstituent(dim2,1,k+1);
+ if ( v2[k] != verif)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNodeConstituent() " << endl;
+ cout << "-------------------------------" << endl;
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNodeConstituent() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNodeConstituent() " << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+ cout << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getNodeConstituent() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "--------------------------------" << endl;
+ cout << " Pb au getNodeConstituent() " << endl;
+ cout << "--------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+*/
+
+ cout << endl;
+/*
+ if ( dimension > 1 )
+ {
+ try
+ {
+ cout << "Informations particulieres - dimension " << dimension - 1 << endl;
+ set <medGeometryElement>::iterator iter_s;
+ for (iter_s=tous[i].getAllConstituentsType().begin() ;
+ iter_s!=tous[i].getAllConstituentsType().end();iter_s++)
+ {
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*iter_s)] << endl;
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << " Pb au getAllConstituentsType() " << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------------------" << endl;
+ cout << " Pb au getAllConstituentsType() " << endl;
+ cout << "------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+*/
+
+ }
+
+ delete[] tous ;
+
+ return EXIT_SUCCESS ;
+/*
+Reste a Tester
+ // Return number of constituents foreach type (which dimension is _dimension-1).
+ map <medGeometryElement,int> getNumberOfConstituentsForeachType() const;
+*/
+}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUCoordinate.cxx
+// Module : MED
+
+using namespace std;
+#include <cstdlib>
+#include <cmath>
+#include "utilities.h"
+
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Array.hxx"
+#include "MEDMEM_Coordinate.hxx"
+#include <string>
+
+void usage(char * name)
+{
+ cout << " " << name << endl;
+}
+
+int main (int argc, char ** argv)
+{
+
+
+ if (argc < 1) usage(argv[0]);
+
+ const double pouieme = 0.009;
+
+ cout << "COORDINATE Test" << endl;
+ cout << "---------------" << endl;
+
+ int SpaceDim = 3;
+ int NbOfNodes = 5;
+
+ string * noms = new string[3];
+ noms[0]=" X ";
+ noms[1]=" Y ";
+ noms[2]=" Z ";
+
+ string units[3];
+ units[0]=" m ";
+ units[1]=" m ";
+ units[2]=" m ";
+
+ int * numbers=new int[5];
+ for (int i=0; i< 5; i++) numbers[i] =10+i;
+
+ MED_EN::medModeSwitch ModeFull=MED_EN::MED_FULL_INTERLACE;
+ MED_EN::medModeSwitch ModeNo=MED_EN::MED_NO_INTERLACE;
+ double coor[15] = {0,0,0,0,0,1,0,1,0,1,0,0,0.5,0.5,0.5} ;
+ ASSERT(SpaceDim*NbOfNodes == 15);
+
+
+ cout << " - mode : MED_FULL_INTERLACE" << endl;
+ cout << " - dimension de l espace : " << SpaceDim << endl;
+ cout << " - nombre de noeuds : " << NbOfNodes << endl;
+
+ double * coor1 = new double[SpaceDim*NbOfNodes];
+ for( int k=0 ; k<SpaceDim*NbOfNodes ; k++ )
+ coor1[k] = coor[k] ;
+
+ MEDARRAY<double>* CoordinateArray = new MEDARRAY<double>(coor1,SpaceDim,NbOfNodes,ModeFull);
+ COORDINATE mycoo;
+ try
+ {
+ mycoo.setCoordinates(CoordinateArray);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinates" << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinates" << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ //--------------------------------------------------------------------//
+ // Tests des methodes //
+ // //
+ // - setCoordinatesNames //
+ // - setCoordinatesUnits //
+ // - setCoordinatesSystem //
+ // - setNodesNumbers //
+ // //
+ //--------------------------------------------------------------------//
+ try
+ {
+ mycoo.setCoordinatesNames(noms);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinatesNames" << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinatesNames" << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ try
+ {
+ mycoo.setCoordinatesUnits(units);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinatesUnits" << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinatesUnits" << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ try
+ {
+ mycoo.setCoordinatesSystem("cartesien");
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinatesSystem" << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setCoordinatesSystem" << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ try
+ {
+ mycoo.setNodesNumbers(numbers);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setNodesNumbers" << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec setNodesNumbers" << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ //--------------------------------------------------------------------//
+ // Tests des methodes //
+ // //
+ // - getCoordinatesNames //
+ // - getCoordinatesUnits //
+ // - getCoordinatesUnit //
+ // - getCoordinatesSystem //
+ // - getNodesNumbers //
+ // //
+ //--------------------------------------------------------------------//
+
+ cout << endl << " Relecture des Coordonnees" << endl << endl;
+
+ try
+ {
+ cout << " Le systeme est : " << mycoo.getCoordinatesSystem() << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec getCoordinatesSystem" << endl;
+ cout << "-------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------------" << endl;
+ cout << "pb avec getCoordinatesSystem" << endl;
+ cout << "-------------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ const string * units2;
+ try
+ {
+ units2=mycoo.getCoordinatesUnits();
+ for (int axe = 0; axe < SpaceDim; axe++)
+ {
+ try
+ {
+ string verif = mycoo.getCoordinateUnit(axe+1);
+ if (verif != units2[axe])
+ cout << "Pb avec les noms des axes" << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------" << endl;
+ cout << "pb avec getCoordinateUnit" << endl;
+ cout << "-------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------" << endl;
+ cout << "pb avec getCoordinateUnit" << endl;
+ cout << "-------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << "pb avec getCoordinatesUnits" << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << "pb avec getCoordinatesUnits" << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+ const string * noms2;
+ try
+ {
+ noms2=mycoo.getCoordinatesNames();
+ for (int axe = 0; axe < SpaceDim; axe++)
+ {
+ try
+ {
+ string verif = mycoo.getCoordinateName(axe+1);
+ if (verif != noms2[axe])
+ cout << "Pb avec les noms des axes" << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------" << endl;
+ cout << "pb avec getCoordinateName" << endl;
+ cout << "-------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------" << endl;
+ cout << "pb avec getCoordinateName" << endl;
+ cout << "-------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << "pb avec getCoordinatesNames" << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << "pb avec getCoordinatesNames" << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+
+ try
+ {
+ const double * coor2=mycoo.getCoordinates(ModeFull);
+
+ for (int axe = 0; axe < SpaceDim; axe++)
+ {
+
+ cout << "Coordonnees sur l'Axe : " << noms2[axe] ;
+ cout << " dont l unite est " << units2[axe] << endl;
+
+ try
+ {
+ const double * coor3=mycoo.getCoordinateAxis(axe+1);
+ for (int num=0; num < NbOfNodes; num++)
+ {
+ try
+ {
+ double d = mycoo.getCoordinate(num + 1,axe+1);
+ cout << d <<" , ";
+ ASSERT(fabs(d - coor3[num]) < pouieme);
+ ASSERT(fabs(d - coor2[(num * SpaceDim)+axe]) < pouieme);
+ ASSERT(fabs(d - coor [(num * SpaceDim)+axe]) < pouieme);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------------" << endl;
+ cout << "pb avec getCoordinates" << endl;
+ cout << "----------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------------" << endl;
+ cout << "pb avec getCoordinates" << endl;
+ cout << "----------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+ }
+ cout << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------" << endl;
+ cout << "pb avec getCoordinateAxis" << endl;
+ cout << "-------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------------" << endl;
+ cout << "pb avec getCoordinateAxis" << endl;
+ cout << "-------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------------" << endl;
+ cout << "pb avec getCoordinates" << endl;
+ cout << "----------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------------" << endl;
+ cout << "pb avec getCoordinates" << endl;
+ cout << "----------------------" << endl;
+ return EXIT_FAILURE ;
+ };
+
+
+ delete [] noms ;
+ delete [] numbers;
+ delete [] coor1;
+
+ delete CoordinateArray ;
+
+ MESSAGE("FIN normale du traitement");
+ return EXIT_SUCCESS ;
+}
+
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUGeoNameMeshEntities.cxx
+// Module : MED
+
+using namespace std;
+#include "MEDMEM_DriversDef.hxx"
+
+void usage(char * name)
+{
+ cout << " " << name << endl;
+ cout << " " << "displays all avalaible geometry elements" << endl;
+ cout << " " << "display then all avalaible entities, and for each" << endl;
+ cout << " " << "all possible geomety element" << endl;
+ cout << endl;
+ exit(-1);
+}
+
+int main (int argc, char ** argv)
+{
+
+ if (argc < 1) usage(argv[0]);
+
+
+ cout << "GEO_NAME Test" << endl ;
+ cout << "-------------" << endl << endl;
+ MED_FR::GEO_NAME::const_iterator currentGeom;
+ for (currentGeom = MED_FR::geoNames.begin();
+ currentGeom != MED_FR::geoNames.end();
+ currentGeom++)
+ {
+ cout << (*currentGeom).second << endl;
+ };
+
+ MED_FR::MESH_ENTITIES::const_iterator currentEntity;
+ list<MED_FR::med_geometrie_element>::const_iterator currentGeometry;
+
+ cout << endl;
+ cout << "MESH_ENTITIES Test" << endl ;
+ cout << "------------------" << endl << endl;
+ for (currentEntity = MED_FR::meshEntities.begin();
+ currentEntity != MED_FR::meshEntities.end();
+ currentEntity++)
+ {
+ cout << (*((MED_FR::entNames).find((*currentEntity).first))).second <<endl;
+ for (currentGeometry = (*currentEntity).second.begin();
+ currentGeometry != (*currentEntity).second.end();
+ currentGeometry++)
+ {
+ cout << MED_FR::geoNames[(MED_FR::med_geometrie_element)(*currentGeometry)] << endl;
+ }
+ cout << endl;
+ }
+
+}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUMedException.cxx
+// Module : MED
+
+using namespace std;
+#include <cstdlib>
+#include "MEDMEM_STRING.hxx"
+#include "MEDMEM_Exception.hxx"
+
+int main (int argc, char ** argv)
+{
+ MEDEXCEPTION a = MEDEXCEPTION("test med exception");
+ cout << a << endl;;
+ cout << a.what() << endl;;
+
+ MEDEXCEPTION b(a);
+ cout << b << endl;
+ cout << b.what() << endl;;
+
+ MEDEXCEPTION c("test med exception",argv[0],14);
+ cout << c << endl;
+ cout << c.what() << endl;;
+
+ STRING msgErr;
+ msgErr << "ESSAI::ESSAI()! "<< 4 << "ieme essai ";
+ cout << MEDEXCEPTION (LOCALIZED(msgErr)).what() << endl ;
+
+ const char * LOC = "toto" ;
+ cout << MEDEXCEPTION (LOCALIZED(STRING(LOC)<<" et titi")).what() << endl ;
+
+ return EXIT_SUCCESS;
+
+};
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUModulusArray.cxx
+// Module : MED
+
+using namespace std;
+#include <cstdlib>
+#include <exception>
+#include "utilities.h"
+#include "MEDMEM_ModulusArray.hxx"
+
+int main (int argc, char ** argv)
+{
+
+ using namespace std ;
+
+ int array[5]={0,1,2,1,4} ;
+ MEDMODULUSARRAY modulusArray(5,array);
+
+ cout << " ModulusArray : " << endl;
+ cout << " _______________" << endl;
+ for(int i=-10;i<15;i++)
+ {
+ cout <<" - A[" << i <<"]="<<modulusArray[i]<<endl;
+ }
+ cout << endl;
+
+ // ------------
+ // test compare
+ // ------------
+
+ int ret ;
+ int array2[5]={1,4,0,1,2} ;
+ MEDMODULUSARRAY modulusArray2(5,array2) ;
+
+ cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
+
+ try
+ {
+ ret=modulusArray2.compare(modulusArray);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=1)
+ {
+ cout << "-----------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray et modulusArray2 " << endl;
+ cout << " Les deux tableaux sont identiques " << endl;
+ cout << "-----------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray et modulusArray2 : OK" << endl;
+ cout << endl;
+ }
+
+ int array3[5]={1,2,1,0,4} ;
+ MEDMODULUSARRAY modulusArray3(5,array3) ;
+
+ cout << " Test compare : mêmes tableaux ordres inverses ..." << endl;
+
+ try
+ {
+ ret=modulusArray3.compare(modulusArray);
+ }
+ catch (const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=-1)
+ {
+ cout << "-----------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray et modulusArray3 " << endl;
+ cout << " Les deux tableaux sont inverses " << endl;
+ cout << "-----------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray et modulusArray3 : OK" << endl;
+ cout << endl;
+ }
+
+ int array4[6]={1,2,1,0} ;
+ MEDMODULUSARRAY modulusArray4(4,array4) ;
+
+ cout << " Test compare : Tableaux de differentes tailles ... " << endl;
+ try
+ {
+ ret=modulusArray4.compare(modulusArray);
+ }
+ catch (const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=0)
+ {
+ cout << "-----------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray et modulusArray4 " << endl;
+ cout << " Les deux n ont pas la meme taille " << endl;
+ cout << "-----------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray et modulusArray4 : OK" << endl;
+ cout << endl;
+ }
+
+ int array5[5]={1,2,1,0,1} ;
+ MEDMODULUSARRAY modulusArray5(5,array5) ;
+ cout << " Test compare : tableaux differents de même taille ..." << endl;
+ try
+ {
+ ret=modulusArray5.compare(modulusArray);
+ }
+ catch (const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=0)
+ {
+ cout << "-----------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray et modulusArray5 " << endl;
+ cout << " Les deux tableaux sont differents " << endl;
+ cout << "-----------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray et modulusArray5 : OK" << endl;
+ cout << endl;
+ }
+
+ // test small array :
+ // taille 1
+ int array6[1]={1} ;
+ MEDMODULUSARRAY modulusArray6(1,array6);
+
+ cout << " ModulusArray 1 : " << endl;
+ cout << " __________________" << endl;
+
+ for(int i=-10;i<15;i++)
+ {
+ cout <<" - A[" << i <<"]="<<modulusArray6[i]<<endl;
+ }
+ cout << endl;
+
+ int array7[1]={1} ;
+ MEDMODULUSARRAY modulusArray7(1,array7);
+
+ cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
+ try
+ {
+ ret=modulusArray6.compare(modulusArray7);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=1)
+ {
+ cout << "-----------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray6 et modulusArray7" << endl;
+ cout << " Les deux tableaux sont identiques " << endl;
+ cout << "-----------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray6 et modulusArray7 : OK" << endl ;
+ cout << endl;
+ }
+
+ int array8[1]={2} ;
+ MEDMODULUSARRAY modulusArray8(1,array8);
+
+ cout << " Test compare : tableaux differents "<< endl;
+ try
+ {
+ ret=modulusArray6.compare(modulusArray8);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=0)
+ {
+ cout << "-----------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray6 et modulusArray8" << endl;
+ cout << " Les deux tableaux sont differents" << endl;
+ cout << "-----------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray6 et modulusArray8 : OK" << endl;
+ cout << endl;
+ }
+
+
+ // 2
+ int array60[2]={1,2} ;
+ MEDMODULUSARRAY modulusArray60(2,array60);
+
+
+ cout << " ModulusArray 2 : " << endl;
+ cout << " __________________" << endl;
+
+ for(int i=-10;i<15;i++)
+ {
+ cout <<" - A[" << i <<"]="<<modulusArray60[i]<<endl;
+ }
+ cout << endl;
+
+ int array70[2]={1,2} ;
+ MEDMODULUSARRAY modulusArray70(2,array70);
+ cout << " Test compare : mêmes tableaux mêmes ordres ..." << endl;
+
+ try
+ {
+ ret=modulusArray60.compare(modulusArray70);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=1)
+ {
+ cout << "--------------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray60 et modulusArray70 " << endl;
+ cout << " Les deux tableaux sont identiques " << endl;
+ cout << "--------------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray60 et modulusArray70 : OK" << endl;
+ cout << endl;
+ }
+
+ int array80[2]={2,2} ;
+ MEDMODULUSARRAY modulusArray80(2,array80);
+
+ cout << " Test compare : tableaux differents ..." << endl;
+
+ try
+ {
+ ret=modulusArray60.compare(modulusArray80);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=0)
+ {
+ cout << "--------------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray60 et modulusArray80 " << endl;
+ cout << " Les deux tableaux sont differents " << endl;
+ cout << "--------------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray60 et modulusArray80 : OK" << endl;
+ cout << endl;
+ }
+
+ int array90[2]={2,1} ;
+ MEDMODULUSARRAY modulusArray90(2,array90);
+ cout << " Test compare : tableaux differents ordres inverses ..." << endl;
+ try
+ {
+ ret=modulusArray60.compare(modulusArray90);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec compare " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ if (ret!=-1)
+ {
+ cout << "--------------------------------------------------------" << endl;
+ cout << " pb avec compare entre modulusArray60 et modulusArray90 " << endl;
+ cout << " Les deux tableaux sont differents " << endl;
+ cout << "--------------------------------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ else
+ {
+ cout << " compare entre modulusArray60 et modulusArray90 : OK" << endl;
+ cout << endl;
+ }
+
+ return EXIT_SUCCESS ;
+}
--- /dev/null
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : testUPointerOf.cxx
+// Module : MED
+
+using namespace std;
+#include "utilities.h"
+#include "MEDMEM_PointerOf.hxx"
+#include "MEDMEM_Exception.hxx"
+
+
+int main (int argc, char ** argv)
+{
+ cout << "PointerOf Test" << endl ;
+ cout << "--------------" << endl;
+
+ const int size=10;
+ PointerOf<int> P;
+
+ // Creation d'un PointerOf de int
+ // et vérification de la methode set en essayant avec
+ // une taille nulle, négative puis positive
+ try
+ {
+ P.set(0);
+ ASSERT((int *)P == NULL);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------------" << endl;
+ cout << " pb avec set(taille = 0) " << endl;
+ cout << "-------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ P.set(-1 * size);
+ ASSERT((int *)P == NULL);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------" << endl;
+ cout << " pb avec set(taille) " << endl;
+ cout << "---------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ P.set(size);
+ ASSERT((int *)P != NULL);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------" << endl;
+ cout << " pb avec set(taille) " << endl;
+ cout << "---------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ for (int i=0; i < size; i++)
+ {
+ P[i]=i;
+ }
+
+ PointerOf<int> P2(10);
+
+ P2=P;
+ for (int i=0; i < size; i++)
+ {
+ SCRUTE(P2[i]);
+ }
+
+ int * p=new int [size];
+ for (int i=0; i < size; i++)
+ {
+ p[i]=i*10;
+ }
+
+ P2.set(p);
+ PointerOf<int> P3(p);
+
+ for (int i=0; i < size; i++)
+ {
+ SCRUTE(P2[i]);
+ SCRUTE(P3[i]);
+ }
+
+ const PointerOf<int> P4(p);
+ const PointerOf<int> P5(P4);
+ delete [] p;
+
+}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUSkyLineArray.cxx
+// Module : MED
+
+using namespace std;
+#include <cstdlib>
+#include "utilities.h"
+#include "MEDMEM_SkyLineArray.hxx"
+
+int main (int argc, char ** argv)
+{
+
+ int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle
+ int Size = 10 ; // 10 nodes
+
+ int * index = new int[NumberOfCell+1];
+ index[0]=1;
+ index[1]=4;
+ index[2]=8;
+ index[3]=11;
+
+ int * value = new int[Size];
+ value[0]=1; // first
+ value[1]=2;
+ value[2]=5;
+ value[3]=2; // second
+ value[4]=3;
+ value[5]=5;
+ value[6]=6;
+ value[7]=3; // thirst
+ value[8]=4;
+ value[9]=6;
+
+ MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ;
+
+ const int * ArrayIndex ;
+ try
+ {
+ ArrayIndex = myArray->getIndex() ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------" << endl;
+ cout << "pb avec getIndex" << endl;
+ cout << "----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------" << endl;
+ cout << "pb avec getIndex" << endl;
+ cout << "----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ const int * ArrayValue ;
+ try
+ {
+ ArrayValue = myArray->getValue() ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------" << endl;
+ cout << "pb avec getValue" << endl;
+ cout << "----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------" << endl;
+ cout << "pb avec getValue" << endl;
+ cout << "----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+
+ try
+ {
+ ASSERT(myArray->getNumberOf()==NumberOfCell);
+ cout << myArray->getNumberOf() << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------" << endl;
+ cout << "pb avec getNumberOf" << endl;
+ cout << "-------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------" << endl;
+ cout << "pb avec getNumberOf" << endl;
+ cout << "-------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ ASSERT(myArray->getLength()==Size);
+ cout << myArray->getLength() << endl;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------" << endl;
+ cout << "pb avec getLength" << endl;
+ cout << "-------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------" << endl;
+ cout << "pb avec getLength" << endl;
+ cout << "-------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ cout << "Show all :" << endl ;
+ for (int i=1; i< NumberOfCell+1 ; i++)
+ {
+ const int * cell;
+ try
+ {
+ cell = myArray->getI(i) ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------------------" << endl;
+ cout << "pb avec getI, valeur de i : " << i << endl;
+ cout << "-----------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------" << endl;
+ cout << "pb avec getI, valeur de i : " << i << endl;
+ cout << "-------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ int numberof;
+ try
+ {
+ numberof= myArray->getNumberOfI(i) ;
+ ASSERT(numberof==index[i]-index[i-1]);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------------------------" << endl;
+ cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
+ cout << "----------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------------------------" << endl;
+ cout << "pb avec getNumberOfI, valeur de i : " << i << endl;
+ cout << "----------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ cout << " - " ;
+ for (int j=0;j<numberof;j++)
+ {
+ cout << cell[j] << " " ;
+ try
+ {
+ int verif=myArray->getIJ(i,j+1);
+ if (verif != cell[j])
+ {
+ cout << "----------------------------------" << endl;
+ cout << " incoherence dans les valeurs : " << endl;
+ cout << " cell[" << j << "] : " << cell[j] << endl;
+ cout << " getIJ(" << i <<"," << j << ") : " << verif << endl;
+ cout << "----------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------------------------" << endl;
+ cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
+ cout << "----------------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------------------------" << endl;
+ cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl;
+ cout << "----------------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+ }
+ cout << endl ;
+ }
+
+ delete[] index ;
+ delete[] value ;
+
+ delete myArray;
+ MESSAGE("FIN normale du traitement");
+ return EXIT_SUCCESS ;
+
+
+/*
+ MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
+ void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
+
+
+*/
+}
--- /dev/null
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : testUUnit.cxx
+// Module : MED
+
+using namespace std;
+#include <cstdlib>
+#include <exception>
+
+#include "MEDMEM_Unit.hxx"
+
+int main (int argc, char ** argv)
+{
+
+ cout << "UNIT Test" << endl ;
+ cout << "---------" << endl;
+
+ UNIT testu;
+ try
+ {
+ testu.setName("ForTesting") ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec setName " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec setName " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setDescription("all values are setted 10") ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec setDescription " << endl;
+ cout << "------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec setDescription " << endl;
+ cout << "------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setMasse(10);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------" << endl;
+ cout << " pb avec setMasse " << endl;
+ cout << "------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------" << endl;
+ cout << " pb avec setMasse " << endl;
+ cout << "------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setLength(10);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------" << endl;
+ cout << " pb avec setLength " << endl;
+ cout << "-------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------" << endl;
+ cout << " pb avec setLength " << endl;
+ cout << "-------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setTime(10);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec setTime " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec setTime " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setTemperature(10);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec setTemperature " << endl;
+ cout << "------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec setTemperature " << endl;
+ cout << "------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setMatterQuantity(10);
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec setMatterQuantity " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec setMatterQuantity " << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setCurrentStrength(10) ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec setCurrentStrengt " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec setCurrentStrengt " << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ testu.setLightIntensity(10) ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec setLightIntensity " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec setLightIntensity " << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+
+ try
+ {
+ cout << testu.getName() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec getName " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec getName " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getDescription() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec getDescription " << endl;
+ cout << "------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec getDescription " << endl;
+ cout << "------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getMasse() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------" << endl;
+ cout << " pb avec getMasse " << endl;
+ cout << "------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------" << endl;
+ cout << " pb avec getMasse " << endl;
+ cout << "------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getLength() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-------------------" << endl;
+ cout << " pb avec getLength " << endl;
+ cout << "-------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-------------------" << endl;
+ cout << " pb avec getLength " << endl;
+ cout << "-------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getTime() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec getTime " << endl;
+ cout << "-----------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "-----------------" << endl;
+ cout << " pb avec getTime " << endl;
+ cout << "-----------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getTemperature() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec getTemperature " << endl;
+ cout << "------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "------------------------" << endl;
+ cout << " pb avec getTemperature " << endl;
+ cout << "------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getMatterQuantity() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec getMatterQuantity " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec getMatterQuantity " << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getCurrentStrength() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "----------------------------" << endl;
+ cout << " pb avec getCurrentStrength " << endl;
+ cout << "----------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "----------------------------" << endl;
+ cout << " pb avec getCurrentStrength " << endl;
+ cout << "----------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ try
+ {
+ cout << testu.getLightIntensity() << endl ;
+ }
+ catch ( const std::exception &e )
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec getLightIntensity " << endl;
+ cout << "---------------------------" << endl;
+ MESSAGE( "catched exception : " << e.what() ) ;
+ return EXIT_FAILURE ;
+ }
+ catch (...)
+ {
+ cout << "---------------------------" << endl;
+ cout << " pb avec getLightIntensity " << endl;
+ cout << "---------------------------" << endl;
+ return EXIT_FAILURE ;
+ }
+
+ return EXIT_SUCCESS ;
+
+} ;
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_FieldDouble.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_SWIG_FieldDouble.hxx"
//=============================================================================
END_OF("Constructor with arguments (for Python API) FIELDDOUBLE");
}
-/*
-FIELDDOUBLE::FIELDDOUBLE(FIELD_ *field)
- : FIELD<double> ( * (FIELD<double> *)(field))
+//=============================================================================
+/*!
+ * Another constructor with arguments
+ */
+//=============================================================================
+FIELDDOUBLE::FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType,
+ const string & fileName,
+ const string & fieldName) :
+ FIELD<double>(Support, driverType, fileName, fieldName)
{
- BEGIN_OF("Constructor (for Python API) FIELDDOUBLE avec parametre");
-
- SCRUTE(_value);
+ BEGIN_OF("Another constructor with arguments (for Python API) FIELDDOUBLE");
- END_OF("Constructor(for Python API) FIELDDOUBLE avec parametre");
+ END_OF("Another constructor with arguments (for Python API) FIELDDOUBLE");
}
-*/
//=============================================================================
/*!
* Destructor
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_FieldDouble.hxx
+// Module : MED
+
#ifndef MEDMEM_SWIG_FIELDDOUBLE_HXX_
#define MEDMEM_SWIG_FIELDDOUBLE_HXX_
public:
FIELDDOUBLE();
FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents);
+ FIELDDOUBLE(const SUPPORT * Support, driverTypes driverType,
+ const string & fileName="", const string & fieldName="");
~FIELDDOUBLE();
};
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_FieldInt.cxx
+// Module : MED
+
+using namespace std;
#include "MEDMEM_SWIG_FieldInt.hxx"
//=============================================================================
END_OF("Constructor with arguments (for Python API) FIELDINT");
}
-/*
-FIELDINT::FIELDINT(FIELD_ * field)
- : FIELD<int> ( * (FIELD<int> *) (field))
+//=============================================================================
+/*!
+ * Another constructor with arguments
+ */
+//=============================================================================
+FIELDINT::FIELDINT(const SUPPORT * Support, driverTypes driverType,
+ const string & fileName,
+ const string & fieldName) :
+ FIELD<int>(Support, driverType, fileName, fieldName)
{
- BEGIN_OF("Constructor (for Python API) FIELDINT avec parametre");
+ BEGIN_OF("Another constructor with arguments (for Python API) FIELDINT");
- END_OF("Constructor (for Python API) FIELDINT avec parametre");
+ END_OF("Another constructor with arguments (for Python API) FIELDINT");
}
-*/
//=============================================================================
/*!
* Destructor
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_FieldInt.hxx
+// Module : MED
+
#ifndef MEDMEM_SWIG_FIELDINT_HXX_
#define MEDMEM_SWIG_FIELDINT_HXX_
public:
FIELDINT();
FIELDINT(const SUPPORT * Support, const int NumberOfComponents);
+ FIELDINT(const SUPPORT * Support, driverTypes driverType,
+ const string & fileName="", const string & fieldName="");
~FIELDINT();
};
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_MedFieldDoubleDriver.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx"
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_MedFieldDoubleDriver.hxx
+// Module : MED
+
#ifndef MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_
#define MEDMEM_SWIG_MEDFIELDDOUBLEDRIVER_HXX_
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_MedFieldIntDriver.cxx
+// Module : MED
+
using namespace std;
#include "MEDMEM_SWIG_MedFieldIntDriver.hxx"
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : MEDMEM_SWIG_MedFieldIntDriver.hxx
+// Module : MED
+
#ifndef MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_
#define MEDMEM_SWIG_MEDFIELDINTDRIVER_HXX_
-#==============================================================================
-# File : Makefile.in
-# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS)
-# CVS : $Header$
-#==============================================================================
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS)
+# Module : MED
-# source path
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
libMEDMEM_Swig.i \
my_typemap.i \
MEDMEM_SWIG_FieldDouble.hxx \
- MEDMEM_SWIG_FieldInt.hxx
+ MEDMEM_SWIG_FieldInt.hxx \
+ MEDMEM_SWIG_MedFieldDoubleDriver.hxx \
+ MEDMEM_SWIG_MedFieldIntDriver.hxx
# Libraries targets
LIB = libMEDMEM_Swigcmodule.la
LIB_SRC = MEDMEM_SWIG_FieldDouble.cxx \
- MEDMEM_SWIG_FieldInt.cxx
+ MEDMEM_SWIG_FieldInt.cxx \
+ MEDMEM_SWIG_MedFieldDoubleDriver.cxx \
+ MEDMEM_SWIG_MedFieldIntDriver.cxx
SWIG_DEF = libMEDMEM_Swig.i
-EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py
+EXPORT_PYSCRIPTS = libMEDMEM_Swig.py med_test1.py med_test2.py med_test3.py med_test_grid.py med_test_skin.py medMeshing_test.py
#############################################################################
-CPPFLAGS+= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES)
+CPPFLAGS= $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(inc_builddir) -I$(srcdir) -I. $(CORBA_INCLUDES)
CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__
CXXFLAGS+=-ftemplate-depth-42
LIBS= $(PYTHON_LIBS)
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : libMEDMEM_Swig.i
+// Module : MED
+
%module libMEDMEM_Swig
-%include "typemaps.i"
-%include "my_typemap.i"
-
%{
#include "MEDMEM_CellModel.hxx"
#include "MEDMEM_GenDriver.hxx"
#include "MEDMEM_Unit.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_MedMedDriver.hxx"
+#include "MEDMEM_Grid.hxx"
#include "MEDMEM_SWIG_FieldDouble.hxx"
#include "MEDMEM_SWIG_FieldInt.hxx"
+#include "MEDMEM_SWIG_MedFieldDoubleDriver.hxx"
+#include "MEDMEM_SWIG_MedFieldIntDriver.hxx"
+#include "MEDMEM_Meshing.hxx"
%}
+%include "typemaps.i"
+%include "my_typemap.i"
+
+/*
+ managing C++ exception in the Python API
+*/
+
+%exception
+{
+ try
+ {
+ $action ;
+ }
+ catch(MEDEXCEPTION& exception)
+ {
+ PyErr_SetString(PyExc_RuntimeError,exception.what());
+ return NULL;
+ }
+}
+
+/*
+ managing the use of operator= of any class by renaming it assign()
+ because assignment can't be overloaded in python.
+
+ In python, you would then use
+
+ a.assign(b) # a = b
+*/
+
+%rename(assign) *::operator=;
+
/*
- enum du MED++ que l'on utilise dans l'API Python
+ enum of the C++ MED used in the Python API
*/
+typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type;
+
typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch;
-typedef enum {MED_LECT,MED_ECRI,MED_REMP} med_mode_acces;
+typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces;
typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE,
MED_ALL_ENTITIES} medEntityMesh;
Class et methodes du MED++ que l'on utilise dans l'API Python
*/
-class CELLMODEL;
+class CELLMODEL
+{
+ public:
+ CELLMODEL();
+
+ CELLMODEL(medGeometryElement t);
+
+ CELLMODEL(const CELLMODEL &m);
+
+ int getNumberOfVertexes();
+
+ int getNumberOfNodes();
+
+ int getDimension();
+
+ medGeometryElement getType();
+
+ int getNumberOfConstituents(int dim);
+
+ int getNodeConstituent(int dim,int num,int nodes_index);
+
+ medGeometryElement getConstituentType(int dim,int num);
+
+ int getNumberOfConstituentsType();
+
+
+
+/* int* getNodesConstituent(int dim,int num) const; */
+
+
+
+
+
+
+
+
+
+/* medGeometryElement* getConstituentsType(int dim) const; */
+
+
+
+
+
+
+
+
+
+
+
+/* set<medGeometryElement> getAllConstituentsType() const; */
+
+
+/* map<medGeometryElement,int> getNumberOfConstituentsForeachType() const; */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ~CELLMODEL();
+
+ %extend {
+ %newobject getName();
+ char * getName()
+ {
+ string tmp_str = self->getName();
+ char * tmp = new char[strlen(tmp_str.c_str())+1];
+ strcpy(tmp,tmp_str.c_str());
+ return tmp;
+ }
+
+ %newobject __str__();
+ const char* __str__()
+ {
+ ostrstream line;
+ line << "Python Printing CELLMODEL : " << *self << endl;
+ char * tmp = new char[strlen(line.str())+1];
+ strcpy(tmp,line.str());
+ return tmp;
+ }
+ }
+};
class SUPPORT
{
public:
- // SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
- // ~SUPPORT();
+ SUPPORT();
+
+ SUPPORT(const SUPPORT & m);
+
+ ~SUPPORT();
void update ( void );
void setGeometricType(medGeometryElement *GeometricType);
- void setGeometricTypeNumber(int *GeometricTypeNumber);
+ void setNumberOfElements(int *NumberOfElements);
- void setNumberOfEntities(int *NumberOfEntities);
+ void setTotalNumberOfElements(int TotalNumberOfElements);
- void setTotalNumberOfEntities(int TotalNumberOfEntities);
+ void getBoundaryElements();
%extend {
SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL)
return new SUPPORT(Mesh,string(Name),Entity);
}
+ %newobject __str__();
+ const char* __str__()
+ {
+ ostrstream line;
+ line << "Python Printing SUPPORT : " << *self << endl;
+ char * tmp = new char[strlen(line.str())+1];
+ strcpy(tmp,line.str());
+ return tmp;
+ }
+
void setpartial(char * Description, int NumberOfGeometricType,
- int TotalNumberOfEntity, medGeometryElement *GeometricType,
- int *NumberOfEntity, int *NumberValue)
+ int TotalNumberOfElements, medGeometryElement *GeometricType,
+ int *NumberOfElements, int *NumberValue)
{
self->setpartial(string(Description), NumberOfGeometricType,
- TotalNumberOfEntity, GeometricType,
- NumberOfEntity, NumberValue);
+ TotalNumberOfElements, GeometricType,
+ NumberOfElements, NumberValue);
}
void setName(char * Name)
self->setName(string(Name));
}
+ %newobject getName();
const char * getName()
{
string tmp_str = self->getName();
self->setDescription(string(Description));
}
+ %newobject getDescription();
const char * getDescription()
{
string tmp_str = self->getDescription();
{
PyObject *py_list;
- medGeometryElement * types = self->getTypes();
+ const medGeometryElement * types = self->getTypes();
int size = self->getNumberOfTypes();
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
- }
-
- PyObject * getGeometricTypeNumber()
- {
- PyObject *py_list;
-
- int * GeometricTypeNumber = self->getGeometricTypeNumber();
- int size = self->getNumberOfTypes();
- py_list = PyList_New(size);
- for (int i=0; i < size; i++)
- {
- int err = PyList_SetItem(py_list, i,
- Py_BuildValue("i",
- GeometricTypeNumber[i]));
- if(err)
- {
- char * message = "Error in SUPPORT::getGeometricTypeNumber";
- PyErr_SetString(PyExc_RuntimeError, message);
- return NULL;
- }
- }
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getNumber(medGeometryElement GeometricType)
{
PyObject *py_list;
- int * number = self->getNumber(GeometricType);
+ const int * number = self->getNumber(GeometricType);
int size = self->getNumberOfElements(GeometricType);
py_list = PyList_New(size);
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getNumberIndex()
{
PyObject *py_list;
- int * numberindex = self->getNumberIndex();
+ const int * numberindex = self->getNumberIndex();
int size = (self->getNumberOfElements(MED_ALL_ELEMENTS))+1;
py_list = PyList_New(size);
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
}
};
class FAMILY : public SUPPORT
{
public:
- // ~FAMILY();
+ FAMILY();
+
+ FAMILY(const FAMILY & m);
+
+ ~FAMILY();
+
+ FAMILY & operator=(const FAMILY &fam);
void setIdentifier(int Identifier);
+
void setNumberOfAttributes(int NumberOfAttribute);
+
void setAttributesIdentifiers(int * AttributeIdentifier);
+
void setAttributesValues(int * AttributeValue);
+
void setAttributesDescriptions(string * AttributeDescription);
+
void setNumberOfGroups(int NumberOfGroups);
+
void setGroupsNames(string * GroupName);
int getIdentifier() const;
+
int getNumberOfAttributes() const;
- /* int * getAttributesIdentifiers() const;*/
- /* int * getAttributesValues() const;*/
- /* string * getAttributesDescriptions() const;*/
+
int getNumberOfGroups() const;
- /* string * getGroupsNames() const;*/
%extend {
FAMILY(MESH* Mesh, int Identifier, char * Name, int NumberOfAttribute,
int *AttributeIdentifier, int *AttributeValue,
char * AttributeDescription, int NumberOfGroup,
- char * GroupName)
+ char * GroupName, int * MEDArrayNodeFamily,
+ int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily,
+ int ** MEDArrayEdgeFamily)
{
return new FAMILY(Mesh,Identifier,string(Name),NumberOfAttribute,
AttributeIdentifier,AttributeValue,
string(AttributeDescription),NumberOfGroup,
- string(GroupName));
+ string(GroupName), MEDArrayNodeFamily,
+ MEDArrayCellFamily, MEDArrayFaceFamily,
+ MEDArrayEdgeFamily);
+ }
+
+ %newobject __str__();
+ const char* __str__()
+ {
+ ostrstream line;
+ line << "Python Printing Family : " << *self << endl;
+ char * tmp = new char[strlen(line.str())+1];
+ strcpy(tmp,line.str());
}
+ %newobject getAttributeDescription(int );
const char * getAttributeDescription(int i)
{
string tmp_str = self->getAttributeDescription(i);
return tmp;
}
+ %newobject getGroupName(int );
const char * getGroupName(int i)
{
string tmp_str = self->getGroupName(i);
{
PyObject *py_list;
- int * attributesids = self->getAttributesIdentifiers();
+ const int * attributesids = self->getAttributesIdentifiers();
int size = self->getNumberOfAttributes();
py_list = PyList_New(size);
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getAttributesValues()
{
PyObject *py_list;
- int * attributesvals = self->getAttributesValues();
+ const int * attributesvals = self->getAttributesValues();
int size = self->getNumberOfAttributes();
py_list = PyList_New(size);
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
}
};
{
public:
FIELD_(const SUPPORT * Support, const int NumberOfComponents);
- // ~FIELD_();
+
+ ~FIELD_();
void rmDriver(int index=0);
void setNumberOfComponents(int NumberOfComponents);
int getNumberOfComponents() const;
+ void setNumberOfValues(int NumberOfValues);
+ int getNumberOfValues() const;
+
%extend {
int addDriver(driverTypes driverType,
char * fileName="Default File Name.med",
self->setName(string(name));
}
+ %newobject getName();
const char * getName()
{
string tmp_str = self->getName();
self->setDescription(string(Description));
}
- const char * getDescription()
+ %newobject getDescription();
+ const char * getDescription() const
{
string tmp_str = self->getDescription();
char * tmp = new char[strlen(tmp_str.c_str())+1];
strcpy(tmp,tmp_str.c_str());
- return tmp;
+ return tmp;
}
+ %newobject getComponentName(int );
const char * getComponentName(int i)
{
string tmp_str = self->getComponentName(i);
self->setComponentName(i,string(ComponentName));
}
+ %newobject getComponentDescription(int );
const char * getComponentDescription(int i)
{
string tmp_str = self->getComponentDescription(i);
self->setComponentDescription(i,string(ComponentDescription));
}
+ %newobject getMEDComponentUnit(int );
const char * getMEDComponentUnit(int i)
{
string tmp_str = self->getMEDComponentUnit(i);
char * tmp = new char[strlen(tmp_str.c_str())+1];
strcpy(tmp,tmp_str.c_str());
- return tmp;
+ return tmp;
}
void setMEDComponentUnit(int i, char * MEDComponentUnit)
class FIELDDOUBLE : public FIELD_
{
public:
- // ~FIELDDOUBLE();
+ ~FIELDDOUBLE();
FIELDDOUBLE(const SUPPORT * Support, const int NumberOfComponents);
+ /*
+ WARNING:
+ other constructor of FIELDDOUBLE (C++ FIELD<double>) object.
+ Only one constructor could be wrapped and
+ the others commented out when using
+ SWIG with a version lesser than 1.3
+ */
+
+ FIELDDOUBLE();
+
void read(int index=0);
double getValueIJ(int i,int j) const;
void deallocValue();
%extend {
- /*
- FIELDDOUBLE(FIELD_ * field)
+ FIELDDOUBLE (const SUPPORT * Support, driverTypes driverType,
+ char * fileName, char * fieldName)
{
- MESSAGE("Constructor (pour API Python) FIELDDOUBLE avec parameters");
- return (FIELDDOUBLE *) field;
+ return new FIELDDOUBLE(Support, driverType, string(fileName),
+ string(fieldName));
}
- */
void write(int index=0, char * driverName="")
{
int size = (self->getNumberOfComponents())*
((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS));
- double * value = self->getValue(Mode);
+ const double * value = self->getValue(Mode);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
+ %newobject getValueI(medModeSwitch , int );
PyObject * getValueI(medModeSwitch Mode, int index)
{
PyObject *py_list;
if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
- double * value = self->getValueI(Mode,index);
+ const double * value = self->getValueI(Mode,index);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
void allocValue2(int NumberOfComponents, int LengthValue)
class FIELDINT : public FIELD_
{
public:
- // ~FIELDINT();
+ ~FIELDINT();
FIELDINT(const SUPPORT * Support, const int NumberOfComponents);
+ /*
+ WARNING:
+ other constructor of FIELDINT (C++ FIELD<int>) object.
+ other constructor of MED object.
+ Only one constructor could be wrapped and
+ the others commented out when using
+ SWIG with a version lesser than 1.3
+ */
+
+ FIELDINT();
+
void read(int index=0);
int getValueIJ(int i,int j) const;
void deallocValue();
%extend {
- /*
- FIELDINT(FIELD_ * field)
+ FIELDINT(const SUPPORT * Support, driverTypes driverType,
+ char * fileName, char * fieldName)
{
- MESSAGE("Constructor (pour API Python) FIELDINT avec parameters");
- return (FIELDINT *) field;
+ return new FIELDINT(Support, driverType, string(fileName),
+ string(fieldName));
}
- */
void write(int index=0, char * driverName="")
{
int size = (self->getNumberOfComponents())*
((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS));
- int * value = self->getValue(Mode);
+ const int * value = self->getValue(Mode);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getValueI(medModeSwitch Mode, int index)
if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS);
- int * value = self->getValueI(Mode,index);
+ const int * value = self->getValueI(Mode,index);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
void allocValue2(int NumberOfComponents, int LengthValue)
{
public:
GROUP();
- // ~GROUP();
+
+ ~GROUP();
void setNumberOfFamilies(int numberOfFamilies);
void setFamilies(vector<FAMILY*> Family);
class MESH
{
- public :
+public :
+ /*
+ WARNING:
+ other constructor of MESH object.
+ Only one constructor could be wrapped and
+ the others commented out when using
+ SWIG with a version lesser than 1.3
+ */
+
+ MESH();
+
+ ~MESH();
+
void rmDriver(int index=0);
void read(int index=0);
int getNumberOfNodes();
+ bool getIsAGrid();
+
const double getCoordinate(int Number, int Axis);
int getNumberOfTypes(medEntityMesh Entity);
int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity);
+ CELLMODEL * getCellsTypes(medEntityMesh Entity);
+
FAMILY* getFamily(medEntityMesh Entity,int i);
int getNumberOfGroups(medEntityMesh Entity);
medGeometryElement getElementType(medEntityMesh Entity,int Number);
- SUPPORT * getBoundaryElements(medEntityMesh Entity) ;
-
%extend {
+ %newobject getBoundaryElements(medEntityMesh );
+ SUPPORT * getBoundaryElements(medEntityMesh Entity)
+ {
+ return self->getBoundaryElements(Entity);
+ }
+
+ %newobject getSkin(const SUPPORT * );
+ SUPPORT * getSkin(const SUPPORT * Support3D)
+ {
+ return self->getSkin(Support3D);
+ }
+
+ CELLMODEL getCellType(medEntityMesh Entity,int i)
+ {
+ return self->getCellsTypes(Entity)[i];
+ }
+
+ MESH (driverTypes driverType, char * fileName, char * meshName)
+ {
+ return new MESH(driverType, string(fileName), string(meshName));
+ }
+
int addDriver(driverTypes driverType,
char * fileName="Default File Name.med",
char * driverName="Default Mesh Name")
self->setName(string(name));
}
+ %newobject getName();
const char * getName()
{
string tmp_str = self->getName();
return tmp;
}
+ %newobject getCoordinatesSystem();
const char * getCoordinatesSystem()
{
string tmp_str = self->getCoordinatesSystem();
return tmp;
}
+ %newobject getCoordinateName(int );
const char * getCoordinateName(int i)
{
string tmp_str = self->getCoordinatesNames()[i];
return tmp;
}
+ %newobject getCoordinateUnit(int );
const char * getCoordinateUnit(int i)
{
string tmp_str = self->getCoordinatesUnits()[i];
strcpy(tmp,tmp_str.c_str());
return tmp;
}
+
+ PyObject * getCoordinatesNames()
+ {
+ PyObject *py_list;
+ const string * array = self->getCoordinatesNames();
+ int size = self->getSpaceDimension();
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("s", array[i].c_str()));
+ if(err)
+ {
+ char * message = "Error in MESH::getCoordinatesNames";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
+ }
+
+ PyObject * getCoordinatesUnits()
+ {
+ PyObject *py_list;
+ const string * array = self->getCoordinatesUnits();
+ int size = self->getSpaceDimension();
+ py_list = PyList_New(size);
+ for (int i=0; i < size; i++)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("s", array[i].c_str()));
+ if(err)
+ {
+ char * message = "Error in MESH::getCoordinatesUnits";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
+ }
+
PyObject * getCoordinates(medModeSwitch Mode)
{
PyObject *py_list;
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getTypes(medEntityMesh Entity)
{
PyObject *py_list;
- medGeometryElement * types = self->getTypes(Entity);
+ const medGeometryElement * types = self->getTypes(Entity);
int size = self->getNumberOfTypes(Entity);
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getConnectivity(medModeSwitch Mode,
medGeometryElement Type)
{
PyObject *py_list;
- int * connectivity = self->getConnectivity(Mode,ConnectivityType,
+ const int * connectivity = self->getConnectivity(Mode,ConnectivityType,
Entity,Type);
int nbOfElm = self->getNumberOfElements(Entity,Type);
int size;
if (Type == MED_ALL_ELEMENTS)
{
- size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm];
+ size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]-1;
}
else
{
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getConnectivityIndex(medConnectivity ConnectivityType,
medEntityMesh Entity)
{
PyObject *py_list;
- int * connectivity_index =
+ const int * connectivity_index =
self->getConnectivityIndex(ConnectivityType,Entity);
int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1;
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getReverseConnectivity(medConnectivity ConnectivityType)
{
PyObject *py_list;
- int * reverseconnectivity =
+ const int * reverseconnectivity =
self->getReverseConnectivity(ConnectivityType);
int spaceDim = self->getSpaceDimension();
int nb;
MED_ALL_ELEMENTS));
}
- int size = self->getReverseConnectivityIndex(ConnectivityType)[nb];
+ int size = self->getReverseConnectivityIndex(ConnectivityType)[nb]-1;
py_list = PyList_New(size);
for (int i=0; i < size; i++)
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
PyObject * getReverseConnectivityIndex(medConnectivity
ConnectivityType)
{
PyObject *py_list;
- int * reverseconnectivity_index =
+ const int * reverseconnectivity_index =
self->getReverseConnectivityIndex(ConnectivityType);
int size;
return NULL;
}
}
- return Py_BuildValue("O", py_list);
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
}
- FIELDDOUBLE * getVolume(const SUPPORT * Support)
- {
- return (FIELDDOUBLE *) self->getVolume(Support);
- }
+ %newobject getVolume(const SUPPORT * );
+ FIELDDOUBLE * getVolume(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getVolume(Support);
+ }
- FIELDDOUBLE * getArea(const SUPPORT * Support)
- {
- return (FIELDDOUBLE *) self->getArea(Support);
- }
+ %newobject getArea(const SUPPORT * );
+ FIELDDOUBLE * getArea(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getArea(Support);
+ }
- FIELDDOUBLE * getLength(const SUPPORT * Support)
- {
- return (FIELDDOUBLE *) self->getLength(Support);
- }
+ %newobject getLength(const SUPPORT * );
+ FIELDDOUBLE * getLength(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getLength(Support);
+ }
- FIELDDOUBLE * getNormal(const SUPPORT * Support)
- {
- return (FIELDDOUBLE *) self->getNormal(Support);
- }
+ %newobject getNormal(const SUPPORT * );
+ FIELDDOUBLE * getNormal(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getNormal(Support);
+ }
- FIELDDOUBLE * getBarycenter(const SUPPORT * Support)
- {
- return (FIELDDOUBLE *) self->getBarycenter(Support);
- }
+ %newobject getBarycenter(const SUPPORT * );
+ FIELDDOUBLE * getBarycenter(const SUPPORT * Support)
+ {
+ return (FIELDDOUBLE *) self->getBarycenter(Support);
+ }
}
} ;
-class MED
+class MESHING: public MESH
{
- public:
- MED();
+public :
+ MESHING();
+ ~MESHING();
- ~MED();
+ void setSpaceDimension (const int SpaceDimension) ;
- int getNumberOfMeshes ( void ) const;
+ void setNumberOfNodes (const int NumberOfNodes) ;
- int getNumberOfFields ( void ) const;
+ void setNumberOfTypes (const int NumberOfTypes,
+ const medEntityMesh Entity) ;
+
+ void setTypes (const medGeometryElement * Types,
+ const medEntityMesh Entity) ;
- void updateSupport ( void ) ;
+ void setNumberOfElements (const int * NumberOfElements,
+ const medEntityMesh Entity) ;
+
+ void setConnectivity (const int * Connectivity,
+ const medEntityMesh Entity,
+ const medGeometryElement Type) ;
+
+ void setConnectivities (const int * ConnectivityIndex,
+ const int * ConnectivityValue,
+ const medConnectivity ConnectivityType,
+ const medEntityMesh Entity) ;
+
+ void addGroup (const GROUP & Group) ;
%extend {
- const char * getMeshName(int i)
+ void setCoordinates(const int SpaceDimension, const int NumberOfNodes,
+ const double * Coordinates, const char * System,
+ const medModeSwitch Mode)
{
- deque<string> list_string = self->getMeshNames();
- char * tmp = new char[strlen(list_string[i].c_str())+1];
- strcpy(tmp,list_string[i].c_str());
- return tmp;
+ self->setCoordinates(SpaceDimension, NumberOfNodes, Coordinates,
+ string(System), Mode);
}
- const char * getFieldName(int i)
+ void setCoordinatesSystem(const char * System)
{
- deque<string> list_string = self->getFieldNames();
- char * tmp = new char[strlen(list_string[i].c_str())+1];
- strcpy(tmp,list_string[i].c_str());
- return tmp;
+ self->setCoordinatesSystem(string(System));
}
- MESH * getMesh(char * meshName)
+ void setCoordinateName (const char * name, const int i)
{
- MESH * myMesh = self->getMesh(string(meshName));
- return myMesh;
+ self->setCoordinateName(string(name), i);
+ }
+
+ void setCoordinateUnit (const char* unit, const int i)
+ {
+ self->setCoordinateUnit (string(unit), i) ;
+ }
+ }
+};
+
+class GRID : public MESH
+{
+ public:
+ GRID();
+
+ GRID(const GRID &m);
+
+ ~GRID();
+
+ int getNodeNumber(const int i, const int j=0, const int k=0);
+
+ int getCellNumber(const int i, const int j=0, const int k=0) ;
+
+ int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0);
+
+ int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0);
+
+ med_grid_type getGridType();
+
+ int getArrayLength( const int Axis );
+
+ const double getArrayValue (const int Axis, const int i);
+
+ void setGridType(med_grid_type gridType);
+
+ %extend {
+ GRID(driverTypes driverType, const char * fileName="", const char * meshName="")
+ {
+ return new GRID(driverType, string(fileName), string(meshName));
+ }
+
+ PyObject * getEntityPosition(const medEntityMesh Entity, const int Number)
+ {
+ int ijk[3], Axis;
+ int i=0, size = self->getSpaceDimension();
+ int j=0;
+ switch (Entity) {
+ case MED_CELL:
+ self->getCellPosition(Number, ijk[0], ijk[1], ijk[2]);
+ break;
+ case MED_NODE:
+ self->getNodePosition(Number, ijk[0], ijk[1], ijk[2]);
+ break;
+ case MED_FACE:
+ self->getFacePosition(Number, Axis, ijk[0], ijk[1], ijk[2]);
+ size++;
+ i++;
+ break;
+ case MED_EDGE:
+ self->getEdgePosition(Number, Axis, ijk[0], ijk[1], ijk[2]);
+ size++;
+ i++;
+ break;
+ default:
+ char * message = "Error in GRID::getEntityPosition: wrong Entity";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ PyObject *py_list = PyList_New( size );
+ for (; i < size; ++i)
+ {
+ int err = PyList_SetItem(py_list, i,
+ Py_BuildValue("i", ijk[j++]));
+ if(err)
+ {
+ char * message = "Error in GRID::getNodePosition";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
+ }
+ if (Entity == MED_FACE || Entity == MED_EDGE)
+ PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis));
+
+ PyObject * result = Py_BuildValue("O", py_list);
+ return result;
+ }
+ }
+};
+
+class MED
+{
+ public:
+ MED();
+
+ ~MED();
+
+ void rmDriver (int index=0);
+
+ int getNumberOfMeshes ( void ) const;
+
+ int getNumberOfFields ( void ) const;
+
+ void updateSupport () ;
+
+ void write (int index=0);
+
+ %extend {
+ /*
+ WARNING:
+ other constructor of MED object.
+ Only one constructor could be wrapped and
+ the others commented out when using
+ SWIG with a version lesser than 1.3
+ */
+
+ MED(driverTypes driverType, char * fileName)
+ {
+ return new MED(driverType,string(fileName));
+ }
+
+ int addDriver(driverTypes driverType,
+ char * fileName="Default File Name.med")
+ {
+ return self->addDriver(driverType,string(fileName));
+ }
+
+ %newobject getMeshName(int );
+ const char * getMeshName(int i)
+ {
+ deque<string> list_string = self->getMeshNames();
+ char * tmp = new char[strlen(list_string[i].c_str())+1];
+ strcpy(tmp,list_string[i].c_str());
+ return tmp;
+ }
+
+ %newobject getFieldName(int );
+ const char * getFieldName(int i)
+ {
+ deque<string> list_string = self->getFieldNames();
+ char * tmp = new char[strlen(list_string[i].c_str())+1];
+ strcpy(tmp,list_string[i].c_str());
+ return tmp;
+ }
+
+ MESH * getMesh(char * meshName)
+ {
+ MESH * myMesh = self->getMesh(string(meshName));
+ return myMesh;
}
int getFieldNumberOfIteration(char * fieldName)
};
/*
- APPI du driver MED_MED
+ API de MED_MED_[RDONLY,WRONLY,RDWR]_DRIVER
*/
-class MED_MED_DRIVER
-{
- public :
- void open();
- void close();
-
- virtual void write ( void ) const ;
- virtual void writeFrom ( void ) const ;
- virtual void read ( void ) ;
- virtual void readFileStruct ( void ) ;
-
- %extend {
- MED_MED_DRIVER(char * fileName, MED * ptrMed)
- {
- return new MED_MED_DRIVER(string(fileName), ptrMed);
- }
- }
-};
-
-class MED_MED_RDONLY_DRIVER : public virtual MED_MED_DRIVER
+class MED_MED_RDONLY_DRIVER
{
public :
void open();
void read ( void ) ;
void readFileStruct ( void ) ;
+ virtual ~MED_MED_RDONLY_DRIVER();
+
%extend {
MED_MED_RDONLY_DRIVER(char * fileName, MED * ptrMed)
{
}
};
-class MED_MED_WRONLY_DRIVER : public virtual MED_MED_DRIVER
+class MED_MED_WRONLY_DRIVER
{
public :
void open();
void write ( void ) const ;
void writeFrom ( void ) const ;
+ virtual ~MED_MED_WRONLY_DRIVER();
+
%extend {
MED_MED_WRONLY_DRIVER(char * fileName, MED * ptrMed)
{
};
class MED_MED_RDWR_DRIVER : public virtual MED_MED_RDONLY_DRIVER,
- public virtual MED_MED_WRONLY_DRIVER,
- public virtual MED_MED_DRIVER
+ public virtual MED_MED_WRONLY_DRIVER
{
public :
void open();
void read ( void ) ;
void readFileStruct ( void ) ;
+ ~MED_MED_RDWR_DRIVER();
+
%extend {
MED_MED_RDWR_DRIVER(char * fileName, MED * ptrMed)
{
};
/*
- API du driver MED_MESH
+ API de MED_MESH_[RDONLY,WRONLY,RDWR]_DRIVER
*/
-/*
-class MED_MESH_DRIVER
+class MED_MESH_RDONLY_DRIVER
{
public :
- // MED_MESH_DRIVER();
-
- // MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode);
+
+ ~MED_MESH_RDONLY_DRIVER();
void open();
+
void close();
- // virtual void write( void ) const = 0;
- // virtual void read ( void ) = 0;
-
- // void setMeshName(const string & meshName) ;
- // string getMeshName() const ;
+ void write( void ) ;
+
+ void read ( void ) ;
%extend {
- MED_MESH_DRIVER(char * fileName, MESH * ptrMesh,
- med_mode_acces accessMode)
+ MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh)
{
- return new MED_MESH_DRIVER(string(fileName), ptrMesh, accessMode);
+ return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh);
}
void setMeshName(char * meshName)
self->setMeshName(string(meshName));
}
+ %newobject getMeshName();
char * getMeshName()
{
string tmp_str = self->getMeshName();
}
}
};
-*/
-class MED_MESH_RDONLY_DRIVER
-// : public virtual MED_MESH_DRIVER
+class MED_MESH_WRONLY_DRIVER
{
public :
-
- // MED_MESH_RDONLY_DRIVER();
+ ~MED_MESH_WRONLY_DRIVER();
+
+ void write( void ) const ;
+
+ void read ( void ) ;
+
+ void open();
- // MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh);
+ void close();
+
+ %extend {
+ MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh)
+ {
+ return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh);
+ }
+
+ void setMeshName(char * meshName)
+ {
+ self->setMeshName(string(meshName));
+ }
+
+ %newobject getMeshName();
+ char * getMeshName()
+ {
+ string tmp_str = self->getMeshName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ }
+};
+
+class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER,
+ public virtual MED_MESH_WRONLY_DRIVER
+{
+ public :
+
+ ~MED_MESH_RDWR_DRIVER();
- ~MED_MESH_RDONLY_DRIVER();
+ void write(void) const ;
+
+ void read (void) ;
- int getCOORDINATE();
+ void open();
- int getCONNECTIVITY();
+ void close();
- int getFAMILY();
+ %extend {
+ MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh)
+ {
+ return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh);
+ }
- void write( void ) ;
+ void setMeshName(char * meshName)
+ {
+ self->setMeshName(string(meshName));
+ }
+
+ %newobject getMeshName();
+ char * getMeshName()
+ {
+ string tmp_str = self->getMeshName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ }
+};
+
+/*
+ API de MED_FIELDDOUBLE_[RDONLY,WRONLY,RDWR]_DRIVER
+*/
+
+class MED_FIELDDOUBLE_RDONLY_DRIVER
+{
+public:
+
+ ~MED_FIELDDOUBLE_RDONLY_DRIVER();
+
+ void open();
+
+ void close();
+
+ void write( void ) const ;
void read ( void ) ;
%extend {
- MED_MESH_RDONLY_DRIVER(char * fileName, MESH * ptrMesh)
+ MED_FIELDDOUBLE_RDONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField)
{
- return new MED_MESH_RDONLY_DRIVER(string(fileName), ptrMesh);
+ return new MED_FIELDDOUBLE_RDONLY_DRIVER(string(fileName), ptrField);
+ }
+
+ void setFieldName(char * fieldName)
+ {
+ self->setFieldName(string(fieldName));
+ }
+
+ %newobject getFieldName();
+ char * getFieldName()
+ {
+ string tmp_str = self->getFieldName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
}
}
};
-class MED_MESH_WRONLY_DRIVER
-// : public virtual MED_MESH_DRIVER
+class MED_FIELDDOUBLE_WRONLY_DRIVER
{
- public :
-
- // MED_MESH_WRONLY_DRIVER():MED_MESH_DRIVER() {}
-
- // MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh);
+public:
- ~MED_MESH_WRONLY_DRIVER();
+ ~MED_FIELDDOUBLE_WRONLY_DRIVER();
+
+ void open();
+
+ void close();
void write( void ) const ;
+
void read ( void ) ;
- int writeCoordinates () const;
- int writeConnectivities (medEntityMesh entity) const;
- int writeFamilyNumbers () const;
- int writeFamilies (vector<FAMILY*> & families) const;
+ %extend {
+ MED_FIELDDOUBLE_WRONLY_DRIVER(char * fileName, FIELDDOUBLE * ptrField)
+ {
+ return new MED_FIELDDOUBLE_WRONLY_DRIVER(string(fileName), ptrField);
+ }
+
+ void setFieldName(char * fieldName)
+ {
+ self->setFieldName(string(fieldName));
+ }
+
+ %newobject getFieldName();
+ char * getFieldName()
+ {
+ string tmp_str = self->getFieldName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ }
+};
+
+class MED_FIELDDOUBLE_RDWR_DRIVER : public virtual MED_FIELDDOUBLE_RDONLY_DRIVER, public virtual MED_FIELDDOUBLE_WRONLY_DRIVER
+{
+public:
+
+ ~MED_FIELDDOUBLE_RDWR_DRIVER();
+
+ void open();
+
+ void close();
+
+ void write( void ) const ;
+
+ void read ( void ) ;
%extend {
- MED_MESH_WRONLY_DRIVER(char * fileName, MESH * ptrMesh)
+ MED_FIELDDOUBLE_RDWR_DRIVER(char * fileName, FIELDDOUBLE * ptrField)
{
- return new MED_MESH_WRONLY_DRIVER(string(fileName), ptrMesh);
+ return new MED_FIELDDOUBLE_RDWR_DRIVER(string(fileName), ptrField);
+ }
+
+ void setFieldName(char * fieldName)
+ {
+ self->setFieldName(string(fieldName));
+ }
+
+ %newobject getFieldName();
+ char * getFieldName()
+ {
+ string tmp_str = self->getFieldName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
}
}
};
-class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER
+/*
+ API de MED_FIELDINT_[RDONLY,WRONLY,RDWR]_DRIVER
+*/
+
+class MED_FIELDINT_RDONLY_DRIVER
{
- public :
+public:
- // MED_MESH_RDWR_DRIVER();
+ ~MED_FIELDINT_RDONLY_DRIVER();
- // MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh);
+ void open();
- ~MED_MESH_RDWR_DRIVER();
-
- void write(void) const ;
- void read (void) ;
+ void close();
+
+ void write( void ) const ;
+
+ void read ( void ) ;
%extend {
- MED_MESH_RDWR_DRIVER(char * fileName, MESH * ptrMesh)
+ MED_FIELDINT_RDONLY_DRIVER(char * fileName, FIELDINT * ptrField)
{
- return new MED_MESH_RDWR_DRIVER(string(fileName), ptrMesh);
+ return new MED_FIELDINT_RDONLY_DRIVER(string(fileName), ptrField);
+ }
+
+ void setFieldName(char * fieldName)
+ {
+ self->setFieldName(string(fieldName));
+ }
+
+ %newobject getFieldName();
+ char * getFieldName()
+ {
+ string tmp_str = self->getFieldName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ }
+};
+
+class MED_FIELDINT_WRONLY_DRIVER
+{
+public:
+
+ ~MED_FIELDINT_WRONLY_DRIVER();
+
+ void open();
+
+ void close();
+
+ void write( void ) const ;
+
+ void read ( void ) ;
+
+ %extend {
+ MED_FIELDINT_WRONLY_DRIVER(char * fileName, FIELDINT * ptrField)
+ {
+ return new MED_FIELDINT_WRONLY_DRIVER(string(fileName), ptrField);
+ }
+
+ void setFieldName(char * fieldName)
+ {
+ self->setFieldName(string(fieldName));
+ }
+
+ %newobject getFieldName();
+ char * getFieldName()
+ {
+ string tmp_str = self->getFieldName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
+ }
+ }
+};
+
+class MED_FIELDINT_RDWR_DRIVER : public virtual MED_FIELDINT_RDONLY_DRIVER, public virtual MED_FIELDINT_WRONLY_DRIVER
+{
+public:
+
+ ~MED_FIELDINT_RDWR_DRIVER();
+
+ void open();
+
+ void close();
+
+ void write( void ) const ;
+
+ void read ( void ) ;
+
+ %extend {
+ MED_FIELDINT_RDWR_DRIVER(char * fileName, FIELDINT * ptrField)
+ {
+ return new MED_FIELDINT_RDWR_DRIVER(string(fileName), ptrField);
+ }
+
+ void setFieldName(char * fieldName)
+ {
+ self->setFieldName(string(fieldName));
+ }
+
+ %newobject getFieldName();
+ char * getFieldName()
+ {
+ string tmp_str = self->getFieldName();
+ char * tmp = new char[strlen(tmp_str.c_str())];
+ strcat(tmp,tmp_str.c_str());
+ return tmp;
}
}
};
FIELDINT * createFieldIntFromField(FIELD_ * field) ;
+GRID * createGridFromMesh( MESH * aMesh );
+
%{
FIELDDOUBLE * createFieldDoubleFromField(FIELD_ * field)
{
MESSAGE("creatFieldDoubleFromField : Constructor (for Python API) FIELDDOUBLE with parameter FIELD_");
+ MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDDOUBLE");
return (FIELDDOUBLE *) field;
}
FIELDINT * createFieldIntFromField(FIELD_ * field)
{
MESSAGE("creatFieldIntFromField : Constructor (for Python API) FIELDINT with parameter FIELD_");
+ MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELDINT");
return (FIELDINT *) field;
}
+
+ GRID * createGridFromMesh( MESH * aMesh )
+ {
+ MESSAGE("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *");
+ MESSAGE("Its returns a proper cast of the input pointer :: MESH --> GRID");
+
+ if (aMesh->getIsAGrid())
+ return (GRID *) aMesh;
+
+ char * message = "Error in GRID(mesh): mesh is not a grid";
+ PyErr_SetString(PyExc_RuntimeError, message);
+ return NULL;
+ }
%}
--- /dev/null
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : medMeshing_test.py
+# Module : MED
+
+from libMEDMEM_Swig import *
+
+# file name to save the generated MESH(ING)
+
+medFileName = "toto.med"
+
+vtkFileName = "toto.vtk"
+
+myMeshing = MESHING()
+
+myMeshing.setName("meshing")
+
+# definition of the coordinates
+
+spaceDimension = 3
+
+numberOfNodes = 19
+
+coordinates = []
+
+coordinate = [0.0, 0.0, 0.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [0.0, 0.0, 1.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [2.0, 0.0, 1.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [0.0, 2.0, 1.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-2.0, 0.0, 1.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [0.0, -2.0, 1.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [1.0, 1.0, 2.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-1.0, 1.0, 2.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-1.0, -1.0, 2.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [1.0, -1.0, 2.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [1.0, 1.0, 3.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-1.0, 1.0, 3.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-1.0, -1.0, 3.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [1.0, -1.0, 3.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [1.0, 1.0, 4.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-1.0, 1.0, 4.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [-1.0, -1.0, 4.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [1.0, -1.0, 4.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+coordinate = [0.0, 0.0, 5.0]
+coordinates.append(coordinate[0])
+coordinates.append(coordinate[1])
+coordinates.append(coordinate[2])
+
+myMeshing.setCoordinates(spaceDimension,numberOfNodes,coordinates,"CARTESIAN",MED_FULL_INTERLACE)
+
+for i in range(spaceDimension):
+ unit = "cm "
+ if (i == 0):
+ name = "X "
+ elif (i == 1):
+ name = "Y "
+ elif (i == 2):
+ name = "Z "
+
+ myMeshing.setCoordinateName(name,i)
+ myMeshing.setCoordinateUnit(unit,i)
+
+# definition of connectivities
+# cell part
+
+numberOfTypes = 3
+entity = MED_CELL
+
+types = []
+numberOfElements = []
+
+types.append(MED_TETRA4)
+numberOfElements.append(12)
+
+types.append(MED_PYRA5)
+numberOfElements.append(2)
+
+types.append(MED_HEXA8)
+numberOfElements.append(2)
+
+myMeshing.setNumberOfTypes(numberOfTypes,entity)
+myMeshing.setTypes(types,entity)
+myMeshing.setNumberOfElements(numberOfElements,entity)
+
+connectivityTetra = []
+
+connectivity = [1,2,3,6]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [1,2,4,3]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [1,2,5,4]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [1,2,6,5]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,7,4,3]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,8,5,4]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,9,6,5]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,10,3,6]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,7,3,10]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,8,4,7]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,9,5,8]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+connectivity = [2,10,6,9]
+connectivityTetra.append(connectivity[0])
+connectivityTetra.append(connectivity[1])
+connectivityTetra.append(connectivity[2])
+connectivityTetra.append(connectivity[3])
+
+myMeshing.setConnectivity(connectivityTetra,entity,types[0])
+
+connectivityPyra = []
+connectivity = [7,8,9,10,2]
+connectivityPyra.append(connectivity[0])
+connectivityPyra.append(connectivity[1])
+connectivityPyra.append(connectivity[2])
+connectivityPyra.append(connectivity[3])
+connectivityPyra.append(connectivity[4])
+connectivity = [15,18,17,16,19]
+connectivityPyra.append(connectivity[0])
+connectivityPyra.append(connectivity[1])
+connectivityPyra.append(connectivity[2])
+connectivityPyra.append(connectivity[3])
+connectivityPyra.append(connectivity[4])
+
+myMeshing.setConnectivity(connectivityPyra,entity,types[1])
+
+connectivityHexa = []
+connectivity = [11,12,13,14,7,8,9,10]
+connectivityHexa.append(connectivity[0])
+connectivityHexa.append(connectivity[1])
+connectivityHexa.append(connectivity[2])
+connectivityHexa.append(connectivity[3])
+connectivityHexa.append(connectivity[4])
+connectivityHexa.append(connectivity[5])
+connectivityHexa.append(connectivity[6])
+connectivityHexa.append(connectivity[7])
+connectivity = [15,16,17,18,11,12,13,14]
+connectivityHexa.append(connectivity[0])
+connectivityHexa.append(connectivity[1])
+connectivityHexa.append(connectivity[2])
+connectivityHexa.append(connectivity[3])
+connectivityHexa.append(connectivity[4])
+connectivityHexa.append(connectivity[5])
+connectivityHexa.append(connectivity[6])
+connectivityHexa.append(connectivity[7])
+
+myMeshing.setConnectivity(connectivityHexa,entity,types[2])
+
+# face part
+
+# edge part
+
+# saving of the generated mesh in MED and VTK format
+
+idMed = myMeshing.addDriver(MED_DRIVER,medFileName,myMeshing.getName())
+myMeshing.write(idMed)
+
+idVtk = myMeshing.addDriver(MED_DRIVER,vtkFileName,myMeshing.getName())
+myMeshing.write(idVtk)
-###################################################################################
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
#
-# This Python script is parsing a MED file using MED Memory from SALOME platform:
-# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
-# well as (d-1)-cells, families). It analyses fields stored in the MED file (d is
-# the space dimension). You can assume that it is a kind of MED file parser.
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
-###################################################################################
+#
+#
+# File : med_test1.py
+# Module : MED
from libMEDMEM_Swig import *
from random import *
suppBound = mesh.getBoundaryElements(MED_FACE)
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
- normalBound = mesh.getNormal(suppBound)
- for j in range(nbElmBound):
- normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
- value1 = normalBoundJ[0]
- value2 = normalBoundJ[1]
- value3 = normalBoundJ[2]
- norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
- print " * ",normalBoundJ[:spaceDim],"norm:",norm
+## normalBound = mesh.getNormal(suppBound)
+## for j in range(nbElmBound):
+## normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+## value1 = normalBoundJ[0]
+## value2 = normalBoundJ[1]
+## value3 = normalBoundJ[2]
+## norm = (value1*value1 + value2*value2 + value3*value3)**(0.5)
+## print " * ",normalBoundJ[:spaceDim],"norm:",norm
elif spaceDim == 2:
suppBound = mesh.getBoundaryElements(MED_EDGE)
nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS)
print "Getting normal field on the boundary",nbElmBound
- normalBound = mesh.getNormal(suppBound)
- for j in range(nbElmBound):
- normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
- value1 = normalBoundJ[0]
- value2 = normalBoundJ[1]
- norm = (value1*value1 + value2*value2)**(0.5)
- print " * ",normalBoundJ[:spaceDim],"norm:",norm
+## normalBound = mesh.getNormal(suppBound)
+## for j in range(nbElmBound):
+## normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1)
+## value1 = normalBoundJ[0]
+## value2 = normalBoundJ[1]
+## norm = (value1*value1 + value2*value2)**(0.5)
+## print " * ",normalBoundJ[:spaceDim],"norm:",norm
print ""
if (nbFields>0):
+ print "Updating supports in the Med Object"
+ md.updateSupport()
print "Field(s) Analysis "
for i in range(nbFields):
field_name = md.getFieldName(i)
-###################################################################################
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
#
-# This Python script is parsing a MED file using MED Memory from SALOME platform:
-# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as
-# well as (d-1)-cells, families), it tests all fields generated ine the MESH class
-# and write them in a new file , it gives only the number of fields stored in the
-# MED file (d is the space dimension).
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
-###################################################################################
+#
+#
+# File : med_test2.py
+# Module : MED
from libMEDMEM_Swig import *
from random import *
-###################################################################################
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
#
-# This Python script is parsing a MED file using MED Memory from SALOME platform:
-# It tests the setValue(I) function on MED fields
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
-###################################################################################
+#
+#
+# File : med_test3.py
+# Module : MED
from libMEDMEM_Swig import *
from random import *
--- /dev/null
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : med_test_grid.py
+# Module : MED
+
+#% Test structured mesh (GRID) reading from file test19.med
+#% test19.med can be obtained by running test19_c.out executable
+
+from libMEDMEM_Swig import *
+
+medFile = "test19.med"
+print "Read file", medFile
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+nbMeshes = md.getNumberOfMeshes()
+print "Nb meshes:", nbMeshes
+if nbMeshes == 0:
+ raise RuntimeError, "Can't read med file"
+
+##############################
+# test "CartGrid"
+##############################
+
+mesh_name = md.getMeshName(0)
+mesh = md.getMesh(mesh_name)
+print "Read", mesh_name
+mesh.read()
+
+if mesh.getIsAGrid() == 0:
+ raise RuntimeError, "Mesh 0 is not a grid"
+
+grid = createGridFromMesh(mesh)
+
+I = grid.getArrayLength(1)
+print "_iArrayLength", I
+if I != 4:
+ raise RuntimeError, "Error in grid.getArrayLength(1)"
+
+J = grid.getArrayLength(2)
+print "_jArrayLength", J
+if J != 4:
+ raise RuntimeError, "Error in grid.getArrayLength(2)"
+
+K = grid.getArrayLength(3)
+print "_kArrayLength", K
+if K != 0:
+ raise RuntimeError, "Error in grid.getArrayLength(3)"
+
+grid_type = grid.getGridType()
+print "grid_type =", grid_type
+if grid_type != MED_CARTESIAN:
+ raise RuntimeError, "Wrong grid type"
+
+spaceDim = grid.getSpaceDimension()
+print "spaceDim =", spaceDim
+if spaceDim != 2:
+ raise RuntimeError, "Wrong space dimention"
+
+meshDim = grid.getMeshDimension()
+print "meshDim =", meshDim
+if spaceDim != meshDim:
+ raise RuntimeError, "Wrong mesh dimention"
+
+nbNodes = grid.getNumberOfNodes()
+print "nbNodes =", nbNodes
+if nbNodes != 16:
+ raise RuntimeError, "Wrong nb of nodes"
+
+coordSyst = grid.getCoordinatesSystem()
+print "coordSyst =", coordSyst
+if coordSyst != "CARTESIAN":
+ raise RuntimeError, "Wrong coordinates system"
+
+coordinates = grid.getCoordinates(MED_FULL_INTERLACE)
+print "coordinates =", coordinates
+xy = [ grid.getArrayValue(1, I-1 ) , grid.getArrayValue(2, J-1 ) ]
+xy2 = coordinates[(nbNodes-1)*spaceDim:(nbNodes*spaceDim)]
+if xy != xy2:
+ raise RuntimeError, "Error in grid.getCoordinates(MED_FULL_INTERLACE)"
+
+nbTypesCell = grid.getNumberOfTypes(MED_CELL)
+print "nbTypesCell =", nbTypesCell
+if nbTypesCell != 1:
+ raise RuntimeError, "Wrong nbTypesCell"
+
+types = grid.getTypes(MED_CELL)
+print "Cell types =", types
+if types != [204]:
+ raise RuntimeError, "Wrong Cell types"
+
+nbElemType = grid.getNumberOfElements(MED_CELL,types[0])
+print "Nb cells =", nbElemType
+if nbElemType != 9:
+ raise RuntimeError, "Wrong Nb cells"
+
+print "getEntityPosition : convert node number to i,j,k"
+
+n1 = grid.getEntityPosition(MED_NODE,10)
+n2 = grid.getEntityPosition(MED_NODE,16)
+
+if n1 == [1,2]: o1 = "Ok"
+else: o1 = "KO"
+if n2 == [3,3]: o2 = "Ok"
+else: o2 = "KO"
+
+print "Node 10 -> i,j = ", n1, " : ", o1
+print "Node 16 -> i,j = ", n2, " : ", o2
+
+print "getEntityPosition : convert cell number to i,j,k"
+
+n1 = grid.getEntityPosition(MED_CELL,3)
+n2 = grid.getEntityPosition(MED_CELL,4)
+
+if n1 == [2,0]: o1 = "Ok"
+else: o1 = "KO"
+if n2 == [0,1]: o2 = "Ok"
+else: o2 = "KO"
+
+print "Cell 3 -> i,j = ", n1, " : ", o1
+print "Cell 4 -> i,j = ", n2, " : ", o2
+
+print "getEntityPosition : convert face number to i,j,k"
+
+n1 = grid.getEntityPosition(MED_FACE,6)
+n2 = grid.getEntityPosition(MED_FACE,8)
+
+if n1 == [1,2,1]: o1 = "Ok"
+else: o1 = "KO"
+if n2 == [1,1,2]: o2 = "Ok"
+else: o2 = "KO"
+
+print "Face 6 -> i,j = ", n1, " : ", o1
+print "Face 8 -> i,j = ", n2, " : ", o2
+
+print "getNodeNumber : convert i,j,k to node number"
+
+n1 = grid.getNodeNumber(2,1,0)
+n2 = grid.getNodeNumber(1,2,0)
+
+if n1 == 7: o1 = "Ok"
+else: o1 = "KO"
+if n2 == 10: o2 = "Ok"
+else: o2 = "KO"
+
+print "getNodeNumber 2,1,0 = ", n1, " : ", o1
+print "getNodeNumber 1,2,0 = ", n2, " : ", o2
+
+print "getCellNumber : convert i,j,k to cell number"
+
+n1 = grid.getCellNumber(1,0,0)
+n2 = grid.getCellNumber(2,1,0)
+
+if n1 == 2: o1 = "Ok"
+else: o1 = "KO"
+if n2 == 6: o2 = "Ok"
+else: o2 = "KO"
+
+print "getCellNumber 1,0,0 = ", n1, " : ", o1
+print "getCellNumber 2,1,0 = ", n2, " : ", o2
+
+print "getFaceNumber : convert i,j,k to face number"
+
+n1 = grid.getFaceNumber(0,0,2,0)
+n2 = grid.getFaceNumber(0,1,1,0)
+
+if n1 == 7: o1 = "Ok"
+else: o1 = "KO"
+if n2 == 5: o2 = "Ok"
+else: o2 = "KO"
+
+print "getFaceNumber 1,0,2,0 = ", n1, " : ", o1
+print "getFaceNumber 1,1,1,0 = ", n2, " : ", o2
+
+print "Connectivity"
+n1 = grid.getNodeNumber(0,0,0)
+n2 = grid.getNodeNumber(1,0,0)
+n3 = grid.getNodeNumber(1,1,0)
+n4 = grid.getNodeNumber(0,1,0)
+
+conn1 = [n1,n2,n3,n4]
+
+Connectivity = grid.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[0])
+print "connectivity =", Connectivity
+
+print "Cell 1 nodes:", conn1, Connectivity[0:4]
+if conn1 != Connectivity[0:4]:
+ raise RuntimeError, "Wrong nodal connectivity"
+
+
+ReverseConnectivity = grid.getReverseConnectivity(MED_NODAL)
+ReverseConnectivityIndex = grid.getReverseConnectivityIndex(MED_NODAL)
+n = 6
+beg = ReverseConnectivityIndex[n-1]-1
+end = ReverseConnectivityIndex[n]-1
+print "Node",n,"rev connectivity =",ReverseConnectivity[beg:end]
+if end-beg != 4:
+ raise RuntimeError, "Wrong reverse connectivity"
+if ReverseConnectivity[beg] != 1:
+ raise RuntimeError, "Wrong reverse connectivity"
+
+
+grid.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL)
+Connectivity = grid.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS)
+ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL)
+n = 1
+beg = ConnectivityIndex[n-1]-1
+end = ConnectivityIndex[n]-1
+print "Element",n,"descending connectivity -->",Connectivity[beg:end]
+if Connectivity[beg:end] != [1, 4, 13, 14]:
+ raise RuntimeError, "Wrong descending connectivity"
+
+print "getReverseConnectivity(MED_DESCENDING)", grid.getReverseConnectivity(MED_DESCENDING)
+print "grid.getReverseConnectivityIndex(MED_DESCENDING)",grid.getReverseConnectivityIndex(MED_DESCENDING)
+
+##############################
+# test "bodyfitted"
+##############################
+
+mesh_name = md.getMeshName(1)
+mesh = md.getMesh(mesh_name)
+print "Read", mesh_name
+mesh.read()
+
+if mesh.getIsAGrid() == 0:
+ raise RuntimeError, "Mesh 1 is not a grid"
+
+grid = createGridFromMesh(mesh)
+
+I = grid.getArrayLength(1)
+print "_iArrayLength", I
+if I != 2:
+ raise RuntimeError, "Error in grid.getArrayLength(1)"
+
+J = grid.getArrayLength(2)
+print "_jArrayLength", J
+if J != 2:
+ raise RuntimeError, "Error in grid.getArrayLength(2)"
+
+K = grid.getArrayLength(3)
+print "_kArrayLength", K
+if K != 0:
+ raise RuntimeError, "Error in grid.getArrayLength(3)"
+
+grid_type = grid.getGridType()
+print "grid_type =", grid_type
+if grid_type != MED_BODY_FITTED:
+ raise RuntimeError, "Wrong grid type"
+
+spaceDim = grid.getSpaceDimension()
+print "spaceDim =", spaceDim
+if spaceDim != 2:
+ raise RuntimeError, "Wrong space dimention"
+
+meshDim = grid.getMeshDimension()
+print "meshDim =", meshDim
+if spaceDim != meshDim:
+ raise RuntimeError, "Wrong mesh dimention"
+
+nbNodes = grid.getNumberOfNodes()
+print "nbNodes =", nbNodes
+if nbNodes != 4:
+ raise RuntimeError, "Wrong nb of nodes"
+
+coordSyst = grid.getCoordinatesSystem()
+print "coordSyst =", coordSyst
+if coordSyst != "CARTESIAN":
+ raise RuntimeError, "Wrong coordinates system"
+
+nbTypesCell = grid.getNumberOfTypes(MED_CELL)
+print "nbTypesCell =", nbTypesCell
+if nbTypesCell != 1:
+ raise RuntimeError, "Wrong nbTypesCell"
+
+types = grid.getTypes(MED_CELL)
+print "Cell types =", types
+if types != [204]:
+ raise RuntimeError, "Wrong Cell types"
+
+nbElemType = grid.getNumberOfElements(MED_CELL,types[0])
+print "Nb cells =", nbElemType
+if nbElemType != 1:
+ raise RuntimeError, "Wrong Nb cells"
+
+Connectivity = grid.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,types[0])
+print "connectivity =", Connectivity
+n1 = grid.getNodeNumber(0,0,0)
+n2 = grid.getNodeNumber(1,0,0)
+n3 = grid.getNodeNumber(1,1,0)
+n4 = grid.getNodeNumber(0,1,0)
+conn1 = [n1,n2,n3,n4]
+print "Cell 1 nodes:", conn1, Connectivity[0:4]
+if conn1 != Connectivity[0:4]:
+ raise RuntimeError, "Wrong nodal connectivity"
+
+##############################################
+# test "maa1" which in fact is not a pure GRID
+##############################################
+
+mesh_name = md.getMeshName(2)
+mesh = md.getMesh(mesh_name)
+print "Read", mesh_name
+mesh.read()
+
+if mesh.getIsAGrid() == 0:
+ print "Mesh ",mesh_name," is not a grid"
+
+print "END of the Pyhton script ..... Ctrl D to exit"
--- /dev/null
+# MED MEDMEM_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : med_test_skin.py
+# Module : MED
+
+#% Test function MESH::getSkin() on mesh from file cube_hexa8_quad4.med
+#% The med file can be obtained by running create_mesh_c3h8q4 executable
+
+from libMEDMEM_Swig import *
+
+medFile = "cube_hexa8_quad4.med"
+
+md = MED()
+
+mdDriver = MED_MED_RDONLY_DRIVER(medFile,md)
+
+print ""
+print "Read file", medFile
+print ""
+
+mdDriver.open()
+mdDriver.readFileStruct()
+mdDriver.close()
+
+mesh_name = md.getMeshName(0)
+mesh = md.getMesh(mesh_name)
+mesh.read()
+
+print "Building the support on all (8) Cells of the mesh."
+supportCell = SUPPORT(mesh)
+supportCell.update()
+
+print "Getting skin of an all cell support"
+
+supportSkin = mesh.getSkin(supportCell)
+faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] )
+print "--------", faceNumbers
+if faceNumbers != [2, 3, 6, 8, 10, 11, 12, 13, 16, 17, 19, 20, 22, 23, 24, 27, 28, 29, 30, 31, 32, 34, 35, 36]:
+ raise RuntimeError, "Wrong skin of an all cell support"
+
+print "Build the support on 1 Cell (#8) of the mesh."
+supportCell.setAll( 0 )
+nbGeomTypes = 1
+nbTotalEntity = 1
+GeometricType = mesh.getTypes(MED_CELL)
+nbEntityList = [1, 2]
+EntityNbs = [8]
+supportCell.setpartial("1 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs)
+
+print "Getting skin of 1 cell support"
+supportSkin = mesh.getSkin(supportCell)
+faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] )
+print "Skin Support FACE numbers:"
+print "--------", faceNumbers
+if faceNumbers != [18, 26, 33, 34, 35, 36]:
+ raise RuntimeError, "Wrong skin of 1 cell support"
+
+
+
+print "Building the support on 2 Cells (#1 #2) of the mesh."
+nbTotalEntity = 2
+nbEntityList = [1, 3]
+EntityNbs = [1, 2]
+supportCell.setpartial("2 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs)
+
+print "Getting skin of 2 cell support"
+supportSkin = mesh.getSkin(supportCell)
+faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] )
+print "Skin Support FACE numbers:", faceNumbers
+if faceNumbers != [1, 2, 3, 4, 6, 7, 8, 9, 10, 11]:
+ raise RuntimeError, "Wrong skin of 2 cells support"
+// MED MEDMEM_SWIG : binding of C++ implementation and Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : my_typemap.i
+// Module : MED
+
%{
#include <stdio.h>
%}
+%typemap(python,in) string * {
+ /* Check if is a list */
+ if (PyList_Check($source)) {
+ int size = PyList_Size($source);
+ int i = 0;
+ $target = new string[size];
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem($source,i);
+ if (PyString_Check(o))
+ $target[i] = string(PyString_AsString(PyList_GetItem($source,i)));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings");
+ free($target);
+ return NULL;
+ }
+ }
+ // $target[i] = 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
%typemap(python,in) double *
{
+ /* typemap in for double * */
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
%typemap(python,in) int *
{
+ /* typemap in for int * */
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
%typemap(python,in) medGeometryElement *
{
+ /* typemap in for medGeometryElement * */
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
}
}
-
%typemap(python,out) list<string> {
int i;
list<string>::iterator iL;
for (i=0, iL=$1->begin(); iL!=$1->end(); i++, iL++)
PyList_SetItem($result,i,PyString_FromString((*iL).c_str()));
}
+
+%typemap(freearg) int * {
+ /* free the memory allocated in the typemap in for int * */
+ free($1);
+}
+
+%typemap(freearg) double * {
+ /* free the memory allocated in the typemap in for double * */
+ free($1);
+}
+
+%typemap(freearg) medGeometryElement * {
+ /* free the memory allocated in the typemap in for medGeometryElement * */
+ free($1);
+}
-#==============================================================================
-# File : Makefile.in
-# Created : ven déc 7 13:32:20 CET 2001
-# Author : Paul RASCLE, EDF
-# Project : SALOME
-# Copyright : EDF 2001
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Paul RASCLE, EDF
+# Module : MED
# $Header$
-#==============================================================================
-# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
-#==============================================================================
-# File : Makefile.in
-# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS)
-# CVS : $Header$
-#==============================================================================
+# MED MedCorba_Swig : binding of MED CORBA objects woth Python
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Nadir BOUHAMOU (CEA/DEN/DM2S/SFME/LGLS)
+# Module : MED
-# source path
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
+# MED MedCorba_Swig : binding of MED CORBA objects woth Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : batchmode_medcorba_test.py
+# Module : MED
+
import batchmode_salome
import SALOME_MED
+// MED MedCorba_Swig : binding of MED CORBA objects woth Python
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : libMedCorba_Swig.i
+// Module : MED
+
%module libMedCorba_Swig
%include "libMEDMEM_Swig.i"
+# MED MedCorba_Swig : binding of MED CORBA objects woth Python
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : medcorba_test.py
+# Module : MED
+
import salome
import SALOME_MED
-//=============================================================================
-// File : Family_i.cxx
-// Project : SALOME
-// Copyright : EDF 2002
-// Author : EDF
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Family_i.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.cxx
+using namespace std;
#include "Family_i.hxx"
#include "utilities.h"
-//=============================================================================
-// File : Family_i.hxx
-// Project : SALOME
-// Copyright : EDF 2002
-// Author : EDF
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Family_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Family_i.hxx
+
#ifndef MED_FAMILY_I_HXX_
#define MED_FAMILY_I_HXX_
-//=============================================================================
-// File : Fielddouble_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Fielddouble_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
+using namespace std;
#include "FieldDouble_i.hxx"
#include "utilities.h"
#include "convert.hxx"
}
medModeSwitch modemed=convertIdlModeToMedMode(mode);
- double * values =_fieldTptr->getValue(modemed);
+ const double * values =_fieldTptr->getValue(modemed);
myseq->length(nbval);
for (int i=0; i<nbval; i++)
-//=============================================================================
-// File : Fielddouble_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Fielddouble_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fielddouble_i.hxx
#ifndef MED_FIELDDOUBLE_I_HXX_
#define MED_FIELDDOUBLE_I_HXX_
-//=============================================================================
-// File : Fieldint_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fieldint_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Fieldint_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Fieldint_i.hxx
+using namespace std;
#include "FieldInt_i.hxx"
#include "utilities.h"
#include "convert.hxx"
}
medModeSwitch modemed=convertIdlModeToMedMode(mode);
- int * values =_fieldTptr->getValue(modemed);
+ const int * values =_fieldTptr->getValue(modemed);
myseq->length(nbval);
for (int i=0; i<nbval; i++)
-//=============================================================================
-// File : FieldInt_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldInt_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : FieldInt_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldInt_i.hxx
#ifndef MED_FIELDINT_I_HXX_
#define MED_FIELDINT_I_HXX_
-//=============================================================================
-// File : FieldOf_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldOf_i.hxx
-//=============================================================================
-
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : FieldOf_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/FieldOf_i.hxx
#ifndef MED_FIELDOF_I_HXX_
#define MED_FIELDOF_I_HXX_
{
int nbcom = _fieldTptr->getNumberOfComponents();
myseq->length(nbcom);
- string * namecom=_fieldTptr->getComponentsNames();
+ const string * namecom=_fieldTptr->getComponentsNames();
for (int i=0;i<nbcom;i++)
{
myseq[i]=CORBA::string_dup(namecom[i].c_str());
{
int nbcom = _fieldTptr->getNumberOfComponents();
myseq->length(nbcom);
- string * unitcom=_fieldTptr->getMEDComponentsUnits();
+ const string * unitcom=_fieldTptr->getMEDComponentsUnits();
for (int i=0;i<nbcom;i++)
{
myseq[i]=CORBA::string_dup(unitcom[i].c_str());
-//=============================================================================
-// File : Field_i.cxx
-// Created : mer fév 20 15:47:57 CET 2002
-// Author : EDF
-// Project : SALOME
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.cxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Field_i.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.cxx
+
+using namespace std;
# include "Field_i.hxx"
FIELD_i::FIELD_i()
-//=============================================================================
-// File : Field_i.hxx
-// Created : mer fév 20 15:47:57 CET 2002
-// Author : EDF
-// Project : SALOME
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Field_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Field_i.hxx
+
# ifndef __FIELD_I_H__
# define __FIELD_I_H__
-//=============================================================================
-// File : Group_i.cxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Group_i.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/
+using namespace std;
#include <vector>
#include "utilities.h"
-//=============================================================================
-// File : Group_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Group_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Group_i.hxx
+
#ifndef MED_GROUP_I_HXX_
#define MED_GROUP_I_HXX_
-#==============================================================================
-// File : Field_i.hxx
-// Author : Marc Tajchman
-// Project : SALOME
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Makefile.in
-//=============================================================================
-
-# source path
+# MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Field_i.hxx
+# Author : Marc Tajchman
+# Module : MED
+# $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Makefile.in
+
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES)
CXXFLAGS=-g -D_DEBUG_ -D__x86__ -D__linux__
-LDFLAGS+=-lmedmem -lOpUtil
+LDFLAGS+= $(MED2_LIBS) -lmedmem -lOpUtil
#LDFLAGS+=-lmedmem -L. -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification
# does we put only -lSalomeContainer and compiler retrieves -lSalomeNS -lRegistry -lOpUtil ????
-//=============================================================================
-// File : Med_i.cxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx
-//=============================================================================
-
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Med_i.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.cxx
+
+using namespace std;
#include <deque>
//#include "MEDMEM_Field.hxx"
// SUPPORT :
_med->updateSupport() ;
+
+ // we add all group and family in study :
+ // we add all families
+ vector<FAMILY*> familyVector ;
+ vector<FAMILY*>::iterator familyVectorIt ;
+ // we add all groups
+ vector<GROUP*> groupVector ;
+ vector<GROUP*>::iterator groupVectorIt ;
+
+ MED_FR::MESH_ENTITIES::const_iterator currentEntity;
+ for (int i=0; i<numberOfMeshes; i++) {
+ ::MESH * ptrMesh = _med->getMesh(meshesNames[i]) ;
+ for (currentEntity=MED_FR::meshEntities.begin();currentEntity != MED_FR::meshEntities.end(); currentEntity++) {
+ // family :
+ familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first) ;
+ for(familyVectorIt=familyVector.begin();familyVectorIt!=familyVector.end();familyVectorIt++) {
+ FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
+ SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this() ;
+ myFamilyI->addInStudy(myStudy,myFamilyIOR) ;
+ }
+ // group :
+ groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first) ;
+ for(groupVectorIt=groupVector.begin();groupVectorIt!=groupVector.end();groupVectorIt++) {
+ GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
+ SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this() ;
+ myGroupI->addInStudy(myStudy,myGroupIOR) ;
+ }
+ }
+ }
+
for (int i=0; i<numberOfMeshes; i++) {
map<MED_FR::med_entite_maillage,::SUPPORT*> mySupports = _med->getSupports(meshesNames[i]) ;
map<MED_FR::med_entite_maillage,::SUPPORT*>::const_iterator itSupport ;
-//=============================================================================
-// File : Med_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Med_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Med_i.hxx
#ifndef _MED_MED_I_HXX_
#define _MED_MED_I_HXX_
-//=============================================================================
-// File : Mesh_i.cxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Mesh_i.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.cxx
+using namespace std;
#include <vector>
#include "utilities.h"
try
{
int spaceDimension=_mesh->getSpaceDimension();
- string * coordinatesName =_mesh->getCoordinatesNames();
+ const string * coordinatesName =_mesh->getCoordinatesNames();
myseq->length(spaceDimension);
for (int i=0; i<spaceDimension; i++)
{
try
{
int spaceDimension=_mesh->getSpaceDimension();
- string * coordinatesUnits =_mesh->getCoordinatesUnits();
+ const string * coordinatesUnits =_mesh->getCoordinatesUnits();
myseq->length(spaceDimension);
for (int i=0; i<spaceDimension; i++)
{
try
{
int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
- medGeometryElement * elemts =_mesh->getTypes(
+ const medGeometryElement * elemts =_mesh->getTypes(
convertIdlEntToMedEnt(entity));
myseq->length(nbTypes);
for (int i=0; i<nbTypes; i++)
else
{
MESSAGE("MED_NODAL");
- int * tab=_mesh->getConnectivityIndex(
+ const int * tab=_mesh->getConnectivityIndex(
convertIdlConnToMedConn(mode),
convertIdlEntToMedEnt(entity));
- nbelements = tab[elt1 ] - 1 ;
+ nbelements = elt1*(convertIdlEltToMedElt(geomElement)%100);
+ //nbelements = tab[elt1 ] - 1 ;
}
SCRUTE(entity);
SCRUTE(geomElement);
SCRUTE(nbelements);
myseq->length(nbelements);
- int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
+ const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
convertIdlConnToMedConn(mode),
convertIdlEntToMedEnt(entity),
convertIdlEltToMedElt(geomElement));
convertIdlEntToMedEnt(entity),
MED_ALL_ELEMENTS);
myseq->length(nbelements);
- int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
+ const int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
convertIdlEntToMedEnt(entity));
for (int i=0;i<nbelements;i++)
{
}
SCRUTE(nbelements);
myseq->length(nbelements);
- int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
+ const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
for (int i=0;i<nbelements;i++)
{
myseq[i]=numbers[i];
}
myseq->length(nbelements);
- int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
+ const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
for (int i=0;i<nbelements;i++)
{
myseq[i]=numbers[i];
SALOME::INTERNAL_ERROR);
try
{
- FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
+ const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
FAMILY_i * f1=new FAMILY_i(fam);
SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
f1->_remove_ref();
SALOME::INTERNAL_ERROR);
try
{
- GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
+ const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
GROUP_i * f1=new GROUP_i(grou);
SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
f1->_remove_ref();
-//=============================================================================
-// File : Mesh_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Mesh_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Mesh_i.hxx
#ifndef _MED_MESH_I_HXX_
#define _MED_MESH_I_HXX_
-//=============================================================================
-// File : Support_i.cxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx
-//=============================================================================
-
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Support_i.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.cxx
+
+using namespace std;
#include "utilities.h"
#include "Utils_CorbaException.hxx"
#include "Utils_ORB_INIT.hxx"
{
int mySeqLength=_support->getNumberOfTypes();
myseq->length(mySeqLength);
- medGeometryElement * elemts = _support->getTypes();
+ const medGeometryElement * elemts = _support->getTypes();
for (int i=0;i<mySeqLength;i++)
{
myseq[i]=convertMedEltToIdlElt(elemts[i]);
SCRUTE(_support->getName());
SCRUTE(nbelements);
SCRUTE(convertIdlEltToMedElt(geomElement));
- int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
+ const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
for (int i=0;i<nbelements;i++)
{
myseq[i]=numbers[i];
MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS");
int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
myseq->length(nbelements);
- int * numbers=_support->getNumberIndex();
+ const int * numbers=_support->getNumberIndex();
for (int i=0;i<nbelements;i++)
{
myseq[i]=numbers[i];
-//=============================================================================
-// File : Support_i.hxx
-// Project : SALOME
-// Author : EDF
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Support_i.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/Support_i.hxx
#ifndef _MED_SUPPORT_I_HXX_
#define _MED_SUPPORT_I_HXX_
-//=============================================================================
-// File : convert.cxx
-// Created : mer fév 20 15:47:57 CET 2002
-// Author : EDF
-// Project : SALOME
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.cxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : convert.cxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.cxx
+using namespace std;
#include "utilities.h"
#include "Utils_CorbaException.hxx"
-//=============================================================================
-// File : convert.hxx
-// Created : mer fév 20 15:47:57 CET 2002
-// Author : EDF
-// Project : SALOME
-// Copyright : EDF 2002
-// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.hxx
-//=============================================================================
+// MED MedMem : MED idl descriptions implementation based on the classes of MEDMEM
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : convert.hxx
+// Author : EDF
+// Module : MED
+// $Header: /export/home/CVS/SALOME_ROOT/MED/src/MedMem/convert.hxx
+
# if ! defined ( __CONVERT_H__ )
# define __CONVERT_H__