X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingCMesh.cxx;h=066d39ac41ddd8af03adf5dd60c363b0b3753450;hb=fc22b4cd63404700f73e09be7507a11b838e55bc;hp=c8949e32d02fb3bfef326966c941d816ebc68c92;hpb=fb6ad3f990cf8c26e23ff4f6ed571d85dc738aac;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index c8949e32d..066d39ac4 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 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 @@ -36,20 +36,20 @@ MEDCouplingCMesh::MEDCouplingCMesh():_x_array(0),_y_array(0),_z_array(0) { } -MEDCouplingCMesh::MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCopy):MEDCouplingStructuredMesh(other,deepCopy) +MEDCouplingCMesh::MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy):MEDCouplingStructuredMesh(other,deepCpy) { - if(deepCopy) + if(deepCpy) { if(other._x_array) - _x_array=other._x_array->deepCpy(); + _x_array=other._x_array->deepCopy(); else _x_array=0; if(other._y_array) - _y_array=other._y_array->deepCpy(); + _y_array=other._y_array->deepCopy(); else _y_array=0; if(other._z_array) - _z_array=other._z_array->deepCpy(); + _z_array=other._z_array->deepCopy(); else _z_array=0; } @@ -89,7 +89,7 @@ MEDCouplingCMesh *MEDCouplingCMesh::New(const std::string& meshName) return ret; } -MEDCouplingCMesh *MEDCouplingCMesh::deepCpy() const +MEDCouplingCMesh *MEDCouplingCMesh::deepCopy() const { return clone(true); } @@ -99,16 +99,21 @@ MEDCouplingCMesh *MEDCouplingCMesh::clone(bool recDeepCpy) const return new MEDCouplingCMesh(*this,recDeepCpy); } +const DataArrayDouble *MEDCouplingCMesh::getDirectAccessOfCoordsArrIfInStructure() const +{ + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getDirectAccessOfCoordsArrIfInStructure : MEDCouplingCMesh does not aggregate array of coordinates !"); +} + MEDCouplingCurveLinearMesh *MEDCouplingCMesh::buildCurveLinear() const { - checkCoherency(); + checkConsistencyLight(); int dim(getSpaceDimension()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingCurveLinearMesh::New()); + MCAuto ret(MEDCouplingCurveLinearMesh::New()); ret->MEDCouplingStructuredMesh::operator=(*this); INTERP_KERNEL::AutoPtr ngs(new int[dim]); getNodeGridStructure(ngs); ret->setNodeGridStructure(ngs,ngs+dim); - MEDCouplingAutoRefCountObjectPtr coo(getCoordinatesAndOwner()); + MCAuto coo(getCoordinatesAndOwner()); ret->setCoords(coo); return ret.retn(); } @@ -225,7 +230,7 @@ void MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *ot throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !"); } -void MEDCouplingCMesh::checkCoherency() const +void MEDCouplingCMesh::checkConsistencyLight() const { const char msg0[]="Invalid "; const char msg1[]=" array ! Must contain more than 1 element."; @@ -272,9 +277,9 @@ void MEDCouplingCMesh::checkCoherency() const } } -void MEDCouplingCMesh::checkCoherency1(double eps) const +void MEDCouplingCMesh::checkConsistency(double eps) const { - checkCoherency(); + checkConsistencyLight(); if(_x_array) _x_array->checkMonotonic(true, eps); if(_y_array) @@ -325,17 +330,17 @@ std::vector MEDCouplingCMesh::getNodeGridStructure() const MEDCouplingStructuredMesh *MEDCouplingCMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const { - checkCoherency(); + checkConsistencyLight(); int dim(getSpaceDimension()); if(dim!=(int)cellPart.size()) { std::ostringstream oss; oss << "MEDCouplingCMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDCouplingAutoRefCountObjectPtr ret(dynamic_cast(deepCpy())); + MCAuto ret(dynamic_cast(deepCopy())); for(int i=0;i tmp(ret->getCoordsAt(i)->selectByTupleId2(cellPart[i].first,cellPart[i].second+1,1)); + MCAuto tmp(ret->getCoordsAt(i)->selectByTupleIdSafeSlice(cellPart[i].first,cellPart[i].second+1,1)); ret->setCoordsAt(i,tmp); } return ret.retn(); @@ -628,6 +633,12 @@ int MEDCouplingCMesh::getCellContainingPoint(const double *pos, double eps) cons return ret; } +void MEDCouplingCMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const +{ + int ret(getCellContainingPoint(pos,eps)); + elts.push_back(ret); +} + void MEDCouplingCMesh::rotate(const double *center, const double *vector, double angle) { throw INTERP_KERNEL::Exception("No rotation available on CMesh : Traduce it to untructured mesh to apply it !"); @@ -691,7 +702,7 @@ MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh *other) */ DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const { - MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); + MCAuto ret(DataArrayDouble::New()); int spaceDim(getSpaceDimension()),nbNodes(getNumberOfNodes()); ret->alloc(nbNodes,spaceDim); double *pt(ret->getPointer()); @@ -722,7 +733,7 @@ DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const * components. The caller is to delete this array using decrRef() as it is * no more needed. */ -DataArrayDouble *MEDCouplingCMesh::getBarycenterAndOwner() const +DataArrayDouble *MEDCouplingCMesh::computeCellCenterOfMass() const { DataArrayDouble *ret=DataArrayDouble::New(); int spaceDim=getSpaceDimension(); @@ -754,7 +765,7 @@ DataArrayDouble *MEDCouplingCMesh::getBarycenterAndOwner() const DataArrayDouble *MEDCouplingCMesh::computeIsoBarycenterOfNodesPerCell() const { - return MEDCouplingCMesh::getBarycenterAndOwner(); + return MEDCouplingCMesh::computeCellCenterOfMass(); } void MEDCouplingCMesh::renumberCells(const int *old2NewBg, bool check) @@ -865,7 +876,7 @@ void MEDCouplingCMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData thisArr[i]->writeVTK(ofs,8,"Array",byteData); else { - MEDCouplingAutoRefCountObjectPtr coo=DataArrayDouble::New(); coo->alloc(1,1); + MCAuto coo=DataArrayDouble::New(); coo->alloc(1,1); coo->setIJ(0,0,0.); coo->writeVTK(ofs,8,"Array",byteData); }