-#==============================================================================
-# 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@
+// 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;
-//=============================================================================
-// 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;
-
#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
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();
+
+ END_OF(LOC);
+}
+
//=============================================================================
/*!
* CORBA: Load Mesh objects (called when an existing study is opened)
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:
char* Med_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
const char* IORString,
- CORBA::Boolean isMultiFile)
-{
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII) {
const char * LOC = "Med_Gen_i::IORToLocalPersistentID" ;
BEGIN_OF(LOC) ;
SCRUTE(IORString);
char* Med_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
const char* aLocalPersistentID,
- CORBA::Boolean isMultiFile)
+ 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()));
string aSaveStudyName(strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL())));
if (strlen(aLocalPersistentID) <= aStudyNameLen) return strdup("");
if (strcmp(aLocalPersistentID, "Objet Med + /OBJ_MED/") == 0) return strdup(""); // MED
- if (strncmp(&(aLocalPersistentID[aStudyNameLen]), "_MEDMESH_",13) == 0) {// MESH
+ if (strncmp(&(aLocalPersistentID[aStudyNameLen]), "_MEDMESH_",9) == 0) {// MESH
MESH * myMesh= new MESH() ;
- int aMeshNameLen = strlen(aLocalPersistentID) - 16 - aStudyNameLen;
+ int aMeshNameLen = strlen(aLocalPersistentID) - 12 - aStudyNameLen;
char* aMeshName = new char[aMeshNameLen];
- strncpy(aMeshName, &(aLocalPersistentID[aStudyNameLen + 13]), aMeshNameLen-1);
+ strncpy(aMeshName, &(aLocalPersistentID[aStudyNameLen + 9]), aMeshNameLen-1);
aMeshName[aMeshNameLen-1] = 0;
myMesh->setName(aMeshName);
- MED_MESH_RDONLY_DRIVER myMeshDriver((aTmpDir + strdup(aLocalPersistentID)).ToCString(),myMesh);
+
+ 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);
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);
+ }
+ 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
-//=============================================================================
-// 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_
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(SALOMEDS::SObject_ptr theSObject,
const char* IORString,
- CORBA::Boolean isMultiFile);
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII);
char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
const char* aLocalPersistentID,
- CORBA::Boolean isMultiFile)
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
throw(SALOME::SALOME_Exception);
bool CanPublishInStudy(CORBA::Object_ptr theIOR);
+// 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 );
+// 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_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);
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_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__ ) */
+// 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
#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;
+// 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;
}
+// 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;
}