From 0399b9ae68a68c22b52dae9d04f3abcc48bbde6b Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 3 Apr 2013 16:04:26 +0000 Subject: [PATCH] Little possiblities for advanced users on Gauss spatial discretization --- src/MEDCoupling/MEDCouplingCMesh.cxx | 2 +- .../MEDCouplingCurveLinearMesh.cxx | 2 +- src/MEDCoupling/MEDCouplingExtrudedMesh.cxx | 2 +- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 1 + src/MEDCoupling/MEDCouplingFieldTemplate.cxx | 9 ++++++++- src/MEDCoupling/MEDCouplingUMesh.cxx | 7 +++++-- src/MEDCoupling/MEDCouplingUMeshDesc.cxx | 2 +- src/MEDCoupling_Swig/MEDCouplingCommon.i | 20 ++++++++++++++++--- src/MEDLoader/MEDFileMesh.cxx | 5 ++++- 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 9be92f3d9..742b7ad03 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -775,7 +775,7 @@ void MEDCouplingCMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData void MEDCouplingCMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) { - stream << "MEDCouplingCMesh C++ instance at " << this << "."; + stream << "MEDCouplingCMesh C++ instance at " << this << ". Name : \"" << getName() << "\"."; const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; std::ostringstream stream2[3]; bool isDef[3]; diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index 26403d670..6e93efb12 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -889,7 +889,7 @@ void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) { - stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << "." << std::endl; + stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << ". Name : \"" << getName() << "\"."; stream << "Nodal structure : ["; for(std::size_t i=0;i<_structure.size();i++) { diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index 42b654466..5677bbe7b 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -921,7 +921,7 @@ void MEDCouplingExtrudedMesh::writeVTKLL(std::ostream& ofs, const std::string& c void MEDCouplingExtrudedMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) { - stream << "MEDCouplingExtrudedMesh C++ instance at " << this << "."; + stream << "MEDCouplingExtrudedMesh C++ instance at " << this << ". Name : \"" << getName() << "\"."; } std::string MEDCouplingExtrudedMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 3c00355ab..d8b115566 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -1846,4 +1846,5 @@ void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vectorreprQuickOverview(oss); + std::string tmp(oss.str()); + stream << "Mesh info : " << tmp.substr(0,tmp.find('\n')); + } } diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 6f0795151..e7bcee9ed 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -2629,7 +2629,10 @@ std::string MEDCouplingUMesh::simpleRepr() const double tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; - ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : "; + if(_mesh_dim>=-1) + { ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : "; } + else + { ret << " Mesh dimension has not been set or is invalid !"; } if(_coords!=0) { const int spaceDim=getSpaceDimension(); @@ -7443,7 +7446,7 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData void MEDCouplingUMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) { - stream << "MEDCouplingUMesh C++ instance at " << this << "."; + stream << "MEDCouplingUMesh C++ instance at " << this << ". Name : \"" << getName() << "\"."; if(_mesh_dim==-2) { stream << " Not set !"; return ; } stream << " Mesh dimension : " << _mesh_dim << "."; diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index 8cc1e5dbb..4c6ef588f 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -536,5 +536,5 @@ DataArrayDouble *MEDCouplingUMeshDesc::computeIsoBarycenterOfNodesPerCell() cons void MEDCouplingUMeshDesc::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) { - stream << "MEDCouplingUMeshDesc C++ instance at " << this << "."; + stream << "MEDCouplingUMeshDesc C++ instance at " << this << ". Name : \"" << getName() << "\"."; } diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 9b600a3f6..276d13b83 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -7933,9 +7933,16 @@ namespace ParaMEDMEM } std::string __str__() const throw(INTERP_KERNEL::Exception) - { - return self->simpleRepr(); - } + { + return self->simpleRepr(); + } + + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; + self->reprQuickOverview(oss); + return oss.str(); + } } }; @@ -8053,6 +8060,13 @@ namespace ParaMEDMEM return self->simpleRepr(); } + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; + self->reprQuickOverview(oss); + return oss.str(); + } + DataArrayDouble *getArray() throw(INTERP_KERNEL::Exception) { DataArrayDouble *ret=self->getArray(); diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 8626120f3..6c583f5c4 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -2073,7 +2073,10 @@ DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::ve } /*! - * Returns a pointer to mesh at the specified level. + * Returns a pointer to mesh at the specified level. ** WARNING **, if the input \a meshDimRelToMaxExt is set to one (nodes), + * The returned mesh ** will be not valid **. It is a feature, because MEDLoader do not creates cells that do not exist ! + * To build a valid MEDCouplingUMesh instance from the returned value when \a meshDimRelToMaxExt is equal to one, simply + * call MEDCouplingUMesh::Build0DMeshFromCoords. * * \return a pointer to unstructured mesh that need to be managed by the caller. * \warning the returned pointer has to be managed by the caller. -- 2.39.2