X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingCurveLinearMesh.cxx;h=6dc3063daacc8714a70bd019ef81515aea0ab395;hb=a23c622fadddf57290253debb129d9008226cdb9;hp=a7b953acf2664fa3d64b60fd16c782f25f4002a5;hpb=f1a947b32a36d8dc8e3079b25305bb50e8cb59a0;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index a7b953acf..6dc3063da 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -80,20 +80,26 @@ void MEDCouplingCurveLinearMesh::updateTime() const updateTimeWith(*_coords); } -std::size_t MEDCouplingCurveLinearMesh::getHeapMemorySize() const +std::size_t MEDCouplingCurveLinearMesh::getHeapMemorySizeWithoutChildren() const { - std::size_t ret=0; + std::size_t ret(MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren()); ret+=_structure.capacity()*sizeof(int); + return ret; +} + +std::vector MEDCouplingCurveLinearMesh::getDirectChildren() const +{ + std::vector ret; if((const DataArrayDouble *)_coords) - ret+=_coords->getHeapMemorySize(); - return MEDCouplingStructuredMesh::getHeapMemorySize()+ret; + ret.push_back((const DataArrayDouble *)_coords); + return ret; } /*! * This method copyies all tiny strings from other (name and components name). * @throw if other and this have not same mesh type. */ -void MEDCouplingCurveLinearMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) { const MEDCouplingCurveLinearMesh *otherC=dynamic_cast(other); if(!otherC) @@ -103,7 +109,7 @@ void MEDCouplingCurveLinearMesh::copyTinyStringsFrom(const MEDCouplingMesh *othe _coords->copyStringInfoFrom(*otherC->_coords); } -bool MEDCouplingCurveLinearMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception) +bool MEDCouplingCurveLinearMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::isEqualIfNotWhy : input other pointer is null !"); @@ -172,7 +178,7 @@ void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCoupli throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith : other is NOT a cartesian mesh ! Impossible to check equivalence !"); } -void MEDCouplingCurveLinearMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::checkCoherency() const { std::size_t sz=_structure.size(),i=0,nbOfNodes=1; if(sz<1) @@ -196,12 +202,12 @@ void MEDCouplingCurveLinearMesh::checkCoherency() const throw(INTERP_KERNEL::Exc } } -void MEDCouplingCurveLinearMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::checkCoherency1(double eps) const { checkCoherency(); } -void MEDCouplingCurveLinearMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::checkCoherency2(double eps) const { checkCoherency1(eps); } @@ -265,7 +271,7 @@ int MEDCouplingCurveLinearMesh::getMeshDimension() const return (int)_structure.size(); } -void MEDCouplingCurveLinearMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::getCoordinatesOfNode(int nodeId, std::vector& coo) const { if(!((const DataArrayDouble *)_coords)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCoordinatesOfNode : Coordinates not set !"); @@ -300,17 +306,17 @@ std::string MEDCouplingCurveLinearMesh::advancedRepr() const return simpleRepr(); } -DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() throw(INTERP_KERNEL::Exception) +DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() { return _coords; } -const DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() const throw(INTERP_KERNEL::Exception) +const DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() const { return _coords; } -void MEDCouplingCurveLinearMesh::setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::setCoords(const DataArrayDouble *coords) { if(coords!=(const DataArrayDouble *)_coords) { @@ -321,17 +327,57 @@ void MEDCouplingCurveLinearMesh::setCoords(const DataArrayDouble *coords) throw( } } -void MEDCouplingCurveLinearMesh::setNodeGridStructure(const int *gridStructBg, const int *gridStructEnd) throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::setNodeGridStructure(const int *gridStructBg, const int *gridStructEnd) { - _structure.resize(0); - _structure.insert(_structure.end(),gridStructBg,gridStructEnd); + std::size_t sz=std::distance(gridStructBg,gridStructEnd); + if(sz>=1 && sz<=3) + { + _structure.resize(0); + _structure.insert(_structure.end(),gridStructBg,gridStructEnd); + } + else + { + std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::setNodeGridStructure : size of input nodal grid structure (" << sz << ") should be in 1, 2 or 3 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } } -std::vector MEDCouplingCurveLinearMesh::getNodeGridStructure() const throw(INTERP_KERNEL::Exception) +std::vector MEDCouplingCurveLinearMesh::getNodeGridStructure() const { return _structure; } +MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const +{ + checkCoherency(); + int dim(getMeshDimension()); + std::vector dims(getMeshDimension()); + if(dim!=(int)cellPart.size()) + { + std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::buildStructuredSubPart : the mesh dimension is " << dim << " and cell part size is " << cellPart.size() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + std::vector< std::pair > nodePartFormat(cellPart); + for(std::vector< std::pair >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++) + (*it).second++; + MEDCouplingAutoRefCountObjectPtr tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); + MEDCouplingAutoRefCountObjectPtr ret(dynamic_cast(deepCpy())); + const DataArrayDouble *coo(ret->getCoords()); + if(coo) + { + MEDCouplingAutoRefCountObjectPtr coo2(coo->selectByTupleIdSafe(tmp1->begin(),tmp1->end())); + ret->setCoords(coo2); + } + for(int i=0;isetNodeGridStructure(&dims[0],&dims[0]+dims.size()); + return ret.retn(); +} + void MEDCouplingCurveLinearMesh::getBoundingBox(double *bbox) const { if(!((const DataArrayDouble *)_coords)) @@ -363,7 +409,7 @@ MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureField(bool isAbs) * \param [in,out] f field feeded with good values. * \sa MEDCouplingCurveLinearMesh::getMeasureField */ -void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const { int nbnodes=getNumberOfNodes(); int spaceDim=getSpaceDimension(); @@ -389,7 +435,7 @@ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCoupling * \param [in,out] f field feeded with good values. * \sa MEDCouplingCurveLinearMesh::getMeasureField */ -void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const { int nbcells=getNumberOfCells(); int spaceDim=getSpaceDimension(); @@ -415,7 +461,7 @@ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2(bool isAbs, MEDCoupling * \param [in,out] f field feeded with good values. * \sa MEDCouplingCurveLinearMesh::getMeasureField */ -void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3(bool isAbs, MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3(bool isAbs, MEDCouplingFieldDouble *field) const { int nbcells=getNumberOfCells(); int spaceDim=getSpaceDimension(); @@ -706,7 +752,7 @@ DataArrayDouble *MEDCouplingCurveLinearMesh::getBarycenterAndOwner() const } } -DataArrayDouble *MEDCouplingCurveLinearMesh::computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception) +DataArrayDouble *MEDCouplingCurveLinearMesh::computeIsoBarycenterOfNodesPerCell() const { return MEDCouplingCurveLinearMesh::getBarycenterAndOwner(); } @@ -771,7 +817,7 @@ void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim1(DataArrayDouble * std::transform(bary->begin(),bary->end(),bary->getPointer(),std::bind2nd(std::multiplies(),0.5)); } -void MEDCouplingCurveLinearMesh::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::renumberCells(const int *old2NewBg, bool check) { throw INTERP_KERNEL::Exception("Functionnality of renumbering cell not available for CurveLinear Mesh !"); } @@ -851,7 +897,7 @@ void MEDCouplingCurveLinearMesh::unserialization(const std::vector& tiny } } -void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const { std::ostringstream extent; int meshDim=(int)_structure.size(); @@ -867,23 +913,42 @@ void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string ofs << " \n"; ofs << " \n"; if(getSpaceDimension()==3) - _coords->writeVTK(ofs,8,"Points"); + _coords->writeVTK(ofs,8,"Points",byteData); else { MEDCouplingAutoRefCountObjectPtr coo=_coords->changeNbOfComponents(3,0.); - coo->writeVTK(ofs,8,"Points"); + coo->writeVTK(ofs,8,"Points",byteData); } ofs << " \n"; ofs << " \n"; ofs << " \n"; } -void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) +void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const { - stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << "."; -} - -std::string MEDCouplingCurveLinearMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exception) + stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << ". Name : \"" << getName() << "\"."; + stream << " Nodal structure : ["; + for(std::size_t i=0;i<_structure.size();i++) + { + char tmp='X'+i; + stream << " " << tmp << "=" << _structure[i]; + if(i!=_structure.size()-1) + stream << ", "; + } + stream << " ]."; + const DataArrayDouble *coo(_coords); + if(!coo) + { stream << std::endl << "No coordinates set !"; return ; } + if(!coo->isAllocated()) + { stream << std::endl << "Coordinates set but not allocated !"; return ; } + int nbOfCompo=coo->getNumberOfComponents(); + if(nbOfCompo!=(int)_structure.size()) + { stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; } + stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : "; + coo->reprQuickOverviewData(stream,200); +} + +std::string MEDCouplingCurveLinearMesh::getVTKDataSetType() const { return std::string("StructuredGrid"); }