From: ageay Date: Mon, 14 Mar 2011 07:16:08 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: FistStepOK2^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=75ef4758a045f9369ec5d788d333c55eecbdd8ab;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 5ba8b8657..baabc6570 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -396,7 +396,7 @@ std::string MEDCouplingCMesh::advancedRepr() const return simpleRepr(); } -DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception) +const DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception) { switch(i) { @@ -411,7 +411,22 @@ DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL: } } -void MEDCouplingCMesh::setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception) +DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) throw(INTERP_KERNEL::Exception) +{ + switch(i) + { + case 0: + return _x_array; + case 1: + return _y_array; + case 2: + return _z_array; + default: + throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2."); + } +} + +void MEDCouplingCMesh::setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception) { DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array}; if(i<0 || i>2) @@ -420,28 +435,28 @@ void MEDCouplingCMesh::setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KER { if(*(thisArr[i])) (*(thisArr[i]))->decrRef(); - (*(thisArr[i]))=arr; + (*(thisArr[i]))=const_cast(arr); if(*(thisArr[i])) (*(thisArr[i]))->incrRef(); declareAsNew(); } } -void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ) +void MEDCouplingCMesh::setCoords(const DataArrayDouble *coordsX, const DataArrayDouble *coordsY, const DataArrayDouble *coordsZ) { if(_x_array) _x_array->decrRef(); - _x_array=coordsX; + _x_array=const_cast(coordsX); if(_x_array) _x_array->incrRef(); if(_y_array) _y_array->decrRef(); - _y_array=coordsY; + _y_array=const_cast(coordsY); if(_y_array) _y_array->incrRef(); if(_z_array) _z_array->decrRef(); - _z_array=coordsZ; + _z_array=const_cast(coordsZ); if(_z_array) _z_array->incrRef(); declareAsNew(); @@ -534,7 +549,7 @@ void MEDCouplingCMesh::getBoundingBox(double *bbox) const int j=0; for (int idim=0; idimgetConstPointer(); @@ -675,7 +690,7 @@ DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const double *pt=ret->getPointer(); int tmp[3]; getSplitNodeValues(tmp); - DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; + const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; const double *tabsPtr[3]; for(int j=0;jgetPointer(); int tmp[3]; getSplitCellValues(tmp); - DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; + const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; std::vector tabsPtr[3]; for(int j=0;j& coo) const; std::string simpleRepr() const; std::string advancedRepr() const; - DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); - void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0); + const DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception); + void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); + void setCoords(const DataArrayDouble *coordsX, + const DataArrayDouble *coordsY=0, + const DataArrayDouble *coordsZ=0); // tools DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx index e279727d3..902efb2a8 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx +++ b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx @@ -42,7 +42,7 @@ void MEDCouplingNormalizedUnstructuredMesh::getBoundingBox(dou boundingBox[i]=std::numeric_limits::max(); boundingBox[SPACEDIM+i]=-std::numeric_limits::max(); } - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); + const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); const double *ptr=array->getConstPointer(); int nbOfPts=array->getNbOfElems()/SPACEDIM; for(int j=0;j::getConnectiv template const double *MEDCouplingNormalizedUnstructuredMesh::getCoordinatesPtr() const { - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); + const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); return array->getConstPointer(); } diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 816023a9b..588013a2c 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -73,13 +73,13 @@ void MEDCouplingPointSet::updateTime() const } } -void MEDCouplingPointSet::setCoords(DataArrayDouble *coords) +void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords) { if( coords != _coords ) { if (_coords) _coords->decrRef(); - _coords=coords; + _coords=const_cast(coords); if(_coords) _coords->incrRef(); declareAsNew(); @@ -642,7 +642,7 @@ void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) con { if(_coords) { - a2=getCoords(); + a2=const_cast(getCoords()); a2->incrRef(); } else diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index f18a77b0f..7367d9ca8 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -45,8 +45,9 @@ namespace ParaMEDMEM void updateTime() const; int getNumberOfNodes() const; int getSpaceDimension() const; - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoords() const { return _coords; } + void setCoords(const DataArrayDouble *coords); + const DataArrayDouble *getCoords() const { return _coords; } + DataArrayDouble *getCoords() { return _coords; } DataArrayDouble *getCoordinatesAndOwner() const; void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingMesh *other, double prec) const; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index b7c59e5ba..ec4ae0272 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -980,7 +980,7 @@ DataArrayInt *MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerg */ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) { - DataArrayDouble *coords=other.getCoords(); + const DataArrayDouble *coords=other.getCoords(); if(!coords) throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in other !"); if(!_coords) @@ -3742,7 +3742,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vectorgetCoords(); + const DataArrayDouble *coords=meshes.front()->getCoords(); int meshDim=meshes.front()->getMeshDimension(); std::vector::const_iterator iter=meshes.begin(); int meshLgth=0; diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 5e33d1382..6e47ce83e 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -52,8 +52,10 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT const std::set& getAllTypes() const { return _types; } MEDCOUPLING_EXPORT std::set getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true); - MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } - MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; } + MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } + MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; } + MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() { return _nodal_connec; } + MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() { return _nodal_connec_index; } MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector& conn) const; diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 66170e99b..948becb31 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -246,7 +246,6 @@ using namespace INTERP_KERNEL; %rename(assign) *::operator=; %ignore ParaMEDMEM::MemArray::operator=; %ignore ParaMEDMEM::MemArray::operator[]; -%ignore ParaMEDMEM::MEDCouplingPointSet::getCoords(); %ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo; %ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo; %ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues; @@ -541,7 +540,7 @@ namespace ParaMEDMEM { public: void updateTime() const; - void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); + void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception); bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const throw(INTERP_KERNEL::Exception); void zipCoords() throw(INTERP_KERNEL::Exception); @@ -588,7 +587,7 @@ namespace ParaMEDMEM return res; } - PyObject *getCoords() const throw(INTERP_KERNEL::Exception) + PyObject *getCoords() throw(INTERP_KERNEL::Exception) { DataArrayDouble *ret1=self->getCoords(); ret1->incrRef(); @@ -832,14 +831,14 @@ namespace ParaMEDMEM INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&sz); self->insertNextCell(type,size,tmp); } - DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception) + DataArrayInt *getNodalConnectivity() throw(INTERP_KERNEL::Exception) { DataArrayInt *ret=self->getNodalConnectivity(); if(ret) ret->incrRef(); return ret; } - DataArrayInt *getNodalConnectivityIndex() const throw(INTERP_KERNEL::Exception) + DataArrayInt *getNodalConnectivityIndex() throw(INTERP_KERNEL::Exception) { DataArrayInt *ret=self->getNodalConnectivityIndex(); if(ret) @@ -1155,16 +1154,16 @@ namespace ParaMEDMEM { public: static MEDCouplingCMesh *New(); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception); - void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); + void setCoords(const DataArrayDouble *coordsX, + const DataArrayDouble *coordsY=0, + const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception); + void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const { return self->simpleRepr(); } - DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception) + DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception) { DataArrayDouble *ret=self->getCoordsAt(i); if(ret) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 49221aea0..6a026ac24 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -1280,7 +1280,7 @@ void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector& ms) const throw(INTERP_KERNEL::Exception) { - DataArrayDouble *ret=ms[0]->getCoords(); + const DataArrayDouble *ret=ms[0]->getCoords(); int mdim=ms[0]->getMeshDimension(); for(unsigned int i=1;igetMeshDimension()!=mdim) throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes have not same mesh dimension !"); } - return ret; + return const_cast(ret); } void MEDFileUMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception) @@ -1631,7 +1631,7 @@ void MEDFileCMesh::write(const char *fileName, int mode) const throw(INTERP_KERN MEDmeshGridTypeWr(fid,maa,MED_CARTESIAN_GRID); for(int i=0;igetCoordsAt(i); + const DataArrayDouble *da=_cmesh->getCoordsAt(i); MEDmeshGridIndexCoordinateWr(fid,maa,_iteration,_order,_time,i+1,da->getNumberOfTuples(),da->getConstPointer()); } if((const DataArrayInt *)_fam_cells) diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 1c92710b8..4fbfe38c9 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -2103,7 +2103,7 @@ void MEDLoaderNS::writeUMeshesDirectly(const char *fileName, const std::vectorgetDescription(),MED_COMMENT_SIZE,desc,MEDLoader::_TOO_LONG_STR); const int spaceDim=mesh[0]->getSpaceDimension(); const int meshDim=mesh[0]->getMeshDimension(); - DataArrayDouble *arr=mesh[0]->getCoords(); + const DataArrayDouble *arr=mesh[0]->getCoords(); INTERP_KERNEL::AutoPtr comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); for(int i=0;igetCoords(); + const DataArrayDouble *coords=meshes.front()->getCoords(); for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) if(coords!=(*iter)->getCoords()) throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !"); @@ -2671,7 +2671,7 @@ void MEDLoader::WriteUMeshesPartitionDep(const char *fileName, const char *meshN } if(meshes.empty()) throw INTERP_KERNEL::Exception("List of meshes must be not empty !"); - DataArrayDouble *coords=meshes.front()->getCoords(); + const DataArrayDouble *coords=meshes.front()->getCoords(); for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) if(coords!=(*iter)->getCoords()) throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !"); @@ -2713,7 +2713,7 @@ void MEDLoader::WriteUMeshes(const char *fileName, const std::vectorgetName()); if(meshName.empty()) throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change name of first element of 2nd parameter !"); - DataArrayDouble *coords=meshes.front()->getCoords(); + const DataArrayDouble *coords=meshes.front()->getCoords(); for(std::vector::const_iterator iter=meshes.begin();iter!=meshes.end();iter++) if(coords!=(*iter)->getCoords()) throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !");