From 6a3352e7d4b7cf9c3da846f12836fe36954606b5 Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 2 Apr 2013 08:35:11 +0000 Subject: [PATCH] __repr__ of MEDCouplingCMesh --- src/MEDCoupling/MEDCouplingCMesh.cxx | 44 ++++++ src/MEDCoupling/MEDCouplingMemArray.cxx | 132 ++++++++++-------- src/MEDCoupling/MEDCouplingMemArray.hxx | 5 + src/MEDCoupling/MEDCouplingMemArrayChar.cxx | 146 +++++++++++--------- 4 files changed, 202 insertions(+), 125 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 2e6cab4e9..9be92f3d9 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -776,6 +776,50 @@ 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 << "."; + const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; + std::ostringstream stream2[3]; + bool isDef[3]; + int nbOfCells=1,nbOfNodes=1; + for(int i=0;i<3;i++) + { + isDef[i]=thisArr[i]!=0; + if(isDef[i]) + { + char tmp='X'+i; + stream2[i] << tmp << " positions array "; + if(!thisArr[i]->isAllocated()) + stream2[i] << "set but not allocated."; + else + { + int nbCompo=thisArr[i]->getNumberOfComponents(); + if(nbCompo==1) + { + int nbTuples=thisArr[i]->getNumberOfTuples(); + if(nbTuples<1) + { stream2[i] << "set and allocated - WARNING number of elements < 1 !"; nbOfCells=-1; nbOfNodes=-1; } + else + { + stream2[i] << "(length=" << nbTuples << ")" << ": "; + thisArr[i]->reprQuickOverviewData(stream2[i],200); + if(nbOfCells!=-1) + { nbOfNodes*=nbTuples; nbOfCells*=nbTuples-1; } + } + } + else + { stream2[i] << "set and allocated - WARNING number of components != 1 !"; nbOfCells=-1; nbOfNodes=-1; } + } + } + } + if(!isDef[0] && !isDef[1] && !isDef[2]) + { stream << " No arrays set !"; return; } + if(nbOfCells>=0) + { stream << std::endl << "Number of cells : " << nbOfCells << ". Number of nodes : " << nbOfNodes << "."; } + for(int i=0;i<3;i++) + { + if(isDef[i]) + stream << std::endl << stream2[i].str(); + } + } std::string MEDCouplingCMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 7e146a3bd..9fc2b9866 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1077,36 +1077,7 @@ void DataArrayDouble::reprQuickOverview(std::ostream& stream) const throw(INTERP { int nbOfTuples=getNumberOfTuples(); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; - const double *data=begin(); - std::ostringstream oss2; oss2 << "["; - oss2.precision(17); - std::string oss2Str(oss2.str()); - bool isFinished=true; - for(int i=0;i1) - { - oss2 << "("; - for(int j=0;j1) + { + oss2 << "("; + for(int j=0;j1) - { - oss2 << "("; - for(int j=0;j1) + { + oss2 << "("; + for(int j=0;j1) - { - oss2 << "("; - for(int j=0;j1) + { + oss2 << "("; + for(int j=0;j(&other); @@ -2223,43 +2230,7 @@ void DataArrayAsciiChar::reprQuickOverview(std::ostream& stream) const throw(INT { int nbOfTuples=getNumberOfTuples(); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; - const char *data=begin(); - std::ostringstream oss2; oss2 << "["; - std::string oss2Str(oss2.str()); - bool isFinished=true; - for(int i=0;i(&other); -- 2.39.2