X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileJoint.cxx;h=af5ea9d17360c4f6a0ab69dd5d2bfd4cc927fe0d;hb=b219559763498c4bd10c730cd3d2c62b1eed45db;hp=94660c7f33845bb3091d4f0430b1b02c645d00ae;hpb=5da72d398d0eb1820c3ce6dd90b8579b6b14edf5;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileJoint.cxx b/src/MEDLoader/MEDFileJoint.cxx index 94660c7f3..af5ea9d17 100644 --- a/src/MEDLoader/MEDFileJoint.cxx +++ b/src/MEDLoader/MEDFileJoint.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -18,7 +18,7 @@ // #include "MEDFileJoint.hxx" -#include "MEDFileUtilities.hxx" +#include "MEDFileBasis.hxx" #include "MEDLoader.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileSafeCaller.txx" @@ -34,7 +34,7 @@ using namespace MEDCoupling; std::size_t MEDFileJointCorrespondence::getHeapMemorySizeWithoutChildren() const { - return sizeof(MCAuto); + return sizeof(MCAuto); } std::vector MEDFileJointCorrespondence::getDirectChildrenWithNull() const @@ -56,7 +56,7 @@ MEDFileJointCorrespondence::MEDFileJointCorrespondence(): * \param [in] loc_geo_type - the local geometry type of correspondence. * \param [in] rem_geo_type - the remote geometry type of correspondence. */ -MEDFileJointCorrespondence::MEDFileJointCorrespondence(DataArrayInt* correspondence, +MEDFileJointCorrespondence::MEDFileJointCorrespondence(DataArrayIdType* correspondence, bool isNodal, INTERP_KERNEL::NormalizedCellType loc_geo_type, INTERP_KERNEL::NormalizedCellType rem_geo_type): @@ -67,7 +67,7 @@ MEDFileJointCorrespondence::MEDFileJointCorrespondence(DataArrayInt* corresponde MEDFileJointCorrespondence::setCorrespondence( correspondence ); } -MEDFileJointCorrespondence* MEDFileJointCorrespondence::New(DataArrayInt* correspondence, +MEDFileJointCorrespondence* MEDFileJointCorrespondence::New(DataArrayIdType* correspondence, INTERP_KERNEL::NormalizedCellType loc_geo_type, INTERP_KERNEL::NormalizedCellType rem_geo_type) { @@ -77,7 +77,7 @@ MEDFileJointCorrespondence* MEDFileJointCorrespondence::New(DataArrayInt* corres /*! * Returns a new MEDFileJointCorrespondence of nodes */ -MEDFileJointCorrespondence *MEDFileJointCorrespondence::New(DataArrayInt* correspondence) +MEDFileJointCorrespondence *MEDFileJointCorrespondence::New(DataArrayIdType* correspondence) { return new MEDFileJointCorrespondence(correspondence); } @@ -109,7 +109,7 @@ void MEDFileJointCorrespondence::write(const std::string& fileName, int mode, co MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); std::ostringstream oss; oss << "MEDFileJointCorrespondence : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); + MEDFileUtilities::CheckMEDCode((int)fid,fid,oss.str()); if (( !_is_nodal ) && ( _loc_geo_type == INTERP_KERNEL::NORM_ERROR || @@ -118,7 +118,7 @@ void MEDFileJointCorrespondence::write(const std::string& fileName, int mode, co throw INTERP_KERNEL::Exception( "Geometric type not specified for a cell Joint" ); } - if ( (const DataArrayInt *)_correspondence ) + if ( (const DataArrayIdType *)_correspondence ) { writeLL(fid, localMeshName, jointName, order, iteration); } @@ -136,8 +136,8 @@ void MEDFileJointCorrespondence::writeLL(med_idt fid, const std::string& localMe order, iteration, MED_NODE, MED_NONE, MED_NODE, MED_NONE, - _correspondence->getNbOfElems()/2, - _correspondence->getConstPointer())); + ToMedInt(_correspondence->getNbOfElems()/2), + ToMedIntArray(_correspondence)->getConstPointer())); } else { @@ -145,12 +145,12 @@ void MEDFileJointCorrespondence::writeLL(med_idt fid, const std::string& localMe order, iteration, MED_CELL, typmai3[ _loc_geo_type ], MED_CELL, typmai3[ _rem_geo_type ], - _correspondence->getNbOfElems()/2, - _correspondence->getConstPointer())); + ToMedInt(_correspondence->getNbOfElems()/2), + ToMedIntArray(_correspondence)->getConstPointer())); } } -void MEDFileJointCorrespondence::setCorrespondence(DataArrayInt *corr) +void MEDFileJointCorrespondence::setCorrespondence(DataArrayIdType *corr) { _correspondence=corr; if ( corr ) @@ -199,13 +199,13 @@ std::string MEDFileJointCorrespondence::simpleRepr() const oss << "- entity type of the correspondence : " << ( getIsNodal() ? "NODE" : "CELL" ) << "\n"; oss << "- Local geometry type of the correspondence : " << INTERP_KERNEL::CellModel::GetCellModel( _loc_geo_type ).getRepr() << "\n"; oss << "- Remote geometry type of the correspondence : " << INTERP_KERNEL::CellModel::GetCellModel( _rem_geo_type ).getRepr() << "\n"; - if ( (const DataArrayInt *)_correspondence ) + if ( (const DataArrayIdType *)_correspondence ) { oss << "- Number entity of the correspondence : " << getCorrespondence()->getNumberOfTuples() << "\n"; - const DataArrayInt* tmp=getCorrespondence(); + const DataArrayIdType* tmp=getCorrespondence(); oss << "- Correspondence : <<"; - for(const int *it=tmp->begin();it!=tmp->end();it++) + for(const mcIdType *it=tmp->begin();it!=tmp->end();it++) oss<< *it << " "; } else @@ -223,7 +223,7 @@ MEDFileJointOneStep::MEDFileJointOneStep():_order(-1),_iteration(-1) std::size_t MEDFileJointOneStep::getHeapMemorySizeWithoutChildren() const { - return _correspondences.capacity()*sizeof(MCAuto); + return _correspondences.capacity()*sizeof(MCAuto); } std::vector MEDFileJointOneStep::getDirectChildrenWithNull() const @@ -263,20 +263,20 @@ MEDFileJointOneStep* MEDFileJointOneStep::New(med_idt fid, const std::string& mN MEDFileJointOneStep::MEDFileJointOneStep(med_idt fid, const std::string& mName, const std::string& jointName, int num) { - int order, iteration, ncorrespondence; + med_int order, iteration, ncorrespondence; MEDFILESAFECALLERRD0(MEDsubdomainComputingStepInfo,(fid, mName.c_str(), jointName.c_str(), num, &order, &iteration, &ncorrespondence)); - MEDFileJointOneStep::setOrder(order); - MEDFileJointOneStep::setIteration(iteration); + MEDFileJointOneStep::setOrder(FromMedInt(order)); + MEDFileJointOneStep::setIteration(FromMedInt(iteration)); for ( int cur_it = 1; cur_it <= ncorrespondence; ++cur_it ) { - int num_entity; + med_int num_entity; med_entity_type loc_ent_type, rem_ent_type; med_geometry_type loc_geo_type, rem_geo_type; MEDFILESAFECALLERRD0(MEDsubdomainCorrespondenceSizeInfo,(fid, mName.c_str(), jointName.c_str(), order, iteration, cur_it, &loc_ent_type, &loc_geo_type, &rem_ent_type, &rem_geo_type, &num_entity)); if ( num_entity > 0 ) { - MCAuto correspondence=DataArrayInt::New(); + MCAuto correspondence=DataArrayMedInt::New(); correspondence->alloc(num_entity*2, 1); MEDFILESAFECALLERRD0(MEDsubdomainCorrespondenceRd,(fid, mName.c_str(), jointName.c_str(), order, iteration, loc_ent_type, loc_geo_type, rem_ent_type, rem_geo_type, correspondence->getPointer())); @@ -284,7 +284,7 @@ MEDFileJointOneStep::MEDFileJointOneStep(med_idt fid, const std::string& mName, cor->setIsNodal( loc_ent_type == MED_NODE ); cor->setLocalGeometryType ( convertGeometryType( loc_geo_type )); cor->setRemoteGeometryType( convertGeometryType( rem_geo_type )); - cor->setCorrespondence( correspondence ); + cor->setCorrespondence( FromMedIntArray(correspondence )); _correspondences.push_back(cor); } } @@ -305,7 +305,7 @@ void MEDFileJointOneStep::write(const std::string& fileName, int mode, const std med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); std::ostringstream oss; oss << "MEDFileJointOneStep : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); + MEDFileUtilities::CheckMEDCode((int)fid,fid,oss.str()); if ( _correspondences.empty() ) throw INTERP_KERNEL::Exception("MEDFileJointOneStep::write : no correspondences defined !"); writeLL(fid, localMeshName, jointName); @@ -329,7 +329,7 @@ void MEDFileJointOneStep::pushCorrespondence(MEDFileJointCorrespondence* corresp int MEDFileJointOneStep::getNumberOfCorrespondences() const { - return _correspondences.size(); + return (int)_correspondences.size(); } /** Return a borrowed reference (caller is not responsible) */ @@ -358,7 +358,7 @@ bool MEDFileJointOneStep::isEqual(const MEDFileJointOneStep *other) const if ( getNumberOfCorrespondences() != other->getNumberOfCorrespondences() ) return false; - std::vector found( getNumberOfCorrespondences(), false ); + std::vector found( getNumberOfCorrespondences(), false ); for(int i=0; i); @@ -480,14 +482,14 @@ MEDFileJoint::MEDFileJoint(med_idt fid, const std::string& mName, int curJoint) INTERP_KERNEL::AutoPtr joint_name=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr desc_name=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); INTERP_KERNEL::AutoPtr rem_mesh_name=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - int domain_number=0, nstep=0, nocstpncorrespondence=0; + med_int domain_number=0, nstep=0, nocstpncorrespondence=0; MEDFILESAFECALLERRD0(MEDsubdomainJointInfo,(fid,mName.c_str(), curJoint, joint_name, desc_name, &domain_number,rem_mesh_name, &nstep, &nocstpncorrespondence)); setLocalMeshName(mName); setRemoteMeshName(MEDLoaderBase::buildStringFromFortran(rem_mesh_name,MED_NAME_SIZE)); setDescription(MEDLoaderBase::buildStringFromFortran(desc_name,MED_COMMENT_SIZE)); setJointName(MEDLoaderBase::buildStringFromFortran(joint_name,MED_NAME_SIZE)); - setDomainNumber(domain_number); + setDomainNumber(FromMedInt(domain_number)); for(int cur_step=1; cur_step <= nstep; ++cur_step) { MEDFileJointOneStep *cor=MEDFileJointOneStep::New(fid, mName.c_str(), getJointName(), cur_step); @@ -495,33 +497,13 @@ MEDFileJoint::MEDFileJoint(med_idt fid, const std::string& mName, int curJoint) } } -/*! - * Writes \a this joint into a MED file specified by its name. - * \param [in] fileName - the MED file name. - * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics. - * - 2 - erase; an existing file is removed. - * - 1 - append; same data should not be present in an existing file. - * - 0 - overwrite; same data present in an existing file is overwritten. - * \throw If the mesh name is not set. - * \throw If \a mode == 1 and the same data is present in an existing file. - */ -void MEDFileJoint::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileJoint : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - write(fid); -} - -void MEDFileJoint::write(med_idt fid) const +void MEDFileJoint::writeLL(med_idt fid) const { // if ( _loc_mesh_name.empty() ) // throw INTERP_KERNEL::Exception("MEDFileJoint::write : name of a local mesh not defined!"); MEDFILESAFECALLERWR0(MEDsubdomainJointCr,(fid,getLocalMeshName().c_str(),getJointName().c_str(),getDescription().c_str(),getDomainNumber(),getRemoteMeshName().c_str())); - for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++) { + for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++) (*it)->writeLL(fid, getLocalMeshName(),getJointName()); - } } void MEDFileJoint::pushStep(MEDFileJointOneStep* step) @@ -534,7 +516,7 @@ void MEDFileJoint::pushStep(MEDFileJointOneStep* step) int MEDFileJoint::getNumberOfSteps() const { - return _joint.size(); + return (int)_joint.size(); } /** Return a borrowed reference (caller is not responsible) */ @@ -566,20 +548,22 @@ bool MEDFileJoint::isEqual(const MEDFileJoint *other) const return false; if(_domain_number!=other->_domain_number) return false; - std::vector found( getNumberOfSteps(), false ); - for(int i=0; igetNumberOfSteps()) + return false; + std::vector found(nbTS,false); + for(int i=0;iisEqual(other->getStepAtPos(j))) + if(!found[j] && getStepAtPos(i)->isEqual(other->getStepAtPos(j))) { - found[ j ] = true; + found[j]=true; break; } } - if ( j == getNumberOfSteps() ) + if(j==nbTS) return false; } return true; @@ -654,21 +638,10 @@ MEDFileJoints *MEDFileJoints::New(med_idt fid, const std::string& meshName) return new MEDFileJoints( fid, meshName ); } -void MEDFileJoints::write(med_idt fid) const +void MEDFileJoints::writeLL(med_idt fid) const { for(std::vector< MCAuto >::const_iterator it=_joints.begin();it!=_joints.end();it++) - { - (*it)->write(fid); - } -} - -void MEDFileJoints::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileJoints : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - write(fid); + (*it)->writeLL(fid); } std::string MEDFileJoints::getMeshName() const @@ -682,7 +655,7 @@ std::string MEDFileJoints::getMeshName() const int MEDFileJoints::getNumberOfJoints() const { - return _joints.size(); + return (int)_joints.size(); } /** Return a borrowed reference (caller is not responsible) */ @@ -787,7 +760,7 @@ MEDFileJoints::MEDFileJoints() MEDFileJoints::MEDFileJoints(med_idt fid, const std::string& meshName) { - int num_joint=MEDnSubdomainJoint(fid, meshName.c_str() ); + med_int num_joint=MEDnSubdomainJoint(fid, meshName.c_str() ); for(int i = 1; i <= num_joint; i++) _joints.push_back(MEDFileJoint::New(fid,meshName,i)); }