X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCoupling1GTUMesh.cxx;h=a5ae41bd0bc46717ff7f7281a046939d4d6fdef3;hb=1062fa0bd4e00e0ad3ffbb3306de74cd0226df1d;hp=72a4e2395ef9f00e470611ea4b97e282846729f5;hpb=ffb8188e28b2b60ee207a8644286821bc4e8fcdc;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 72a4e2395..a5ae41bd0 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2020 CEA/DEN, EDF R&D +// Copyright (C) 2007-2022 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 @@ -27,6 +27,7 @@ #include "DiameterCalculator.hxx" #include "OrientationInverter.hxx" #include "InterpKernelAutoPtr.hxx" +#include "VolSurfUser.txx" using namespace MEDCoupling; @@ -781,6 +782,11 @@ std::string MEDCoupling1SGTUMesh::simpleRepr() const { static const char msg0[]="No coordinates specified !"; std::ostringstream ret; + if(!_cm) + { + ret << "No geometric type specified" << std::endl; + return ret.str(); + } ret << "Single static geometic type (" << _cm->getRepr() << ") unstructured mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; @@ -883,7 +889,7 @@ DataArrayDouble *MEDCoupling1SGTUMesh::computeIsoBarycenterOfNodesPerCell() cons std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::computeIsoBarycenterOfNodesPerCell : on cell #" << i << " presence of nodeId #" << *nodal << " should be in [0," << nbOfNodes << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies(),coeff)); + std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind(std::multiplies(),std::placeholders::_1,coeff)); } return ret.retn(); } @@ -1232,7 +1238,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vectorgetNodalConnectivityLength(); const mcIdType *curC=(*it)->_conn->begin(); - cPtr=std::transform(curC,curC+curConnLgth,cPtr,std::bind2nd(std::plus(),offset)); + cPtr=std::transform(curC,curC+curConnLgth,cPtr,std::bind(std::plus(),std::placeholders::_1,offset)); offset+=(*it)->getNumberOfNodes(); } // @@ -1414,7 +1420,13 @@ DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePlanarFace6() void MEDCoupling1SGTUMesh::reprQuickOverview(std::ostream& stream) const { - stream << "MEDCoupling1SGTUMesh C++ instance at " << this << ". Type=" << _cm->getRepr() << ". Name : \"" << getName() << "\"."; + stream << "MEDCoupling1SGTUMesh C++ instance at " << this << ". Type="; + if(!_cm) + { + stream << "Not set"; + return ; + } + stream << _cm->getRepr() << ". Name : \"" << getName() << "\"."; stream << " Mesh dimension : " << getMeshDimension() << "."; if(!_coords) { stream << " No coordinates set !"; return ; } @@ -1611,7 +1623,7 @@ void MEDCoupling1SGTUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal { for(int j=0;j(),-1))=eltId; + *std::find_if(revNodalPtr+revNodalIndxPtr[*conn],revNodalPtr+revNodalIndxPtr[*conn+1],std::bind(std::equal_to(),std::placeholders::_1,-1))=eltId; } } } @@ -1732,6 +1744,52 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4() const return ret.retn(); } +/*! + * This method for each cell in \a this the triangle height for each edge in a newly allocated/created array instance. + * + * \return DataArrayDouble * - a newly allocated instance with this->getNumberOfCells() tuples and 3 components storing for each cell in \a this the corresponding height. + * \throw If \a this is not a mesh containing only NORM_TRI3 cells. + * \throw If \a this is not properly allocated. + * \throw If spaceDimension is not in 2 or 3. + */ +MCAuto MEDCoupling1SGTUMesh::computeTriangleHeight() const +{ + checkConsistencyLight(); + const INTERP_KERNEL::CellModel& cm(getCellModel()); + if(cm.getEnum()!=INTERP_KERNEL::NORM_TRI3) + THROW_IK_EXCEPTION("MEDCoupling1SGTUMesh::computeTriangleHeight : this method can be applied only on TRI3 mesh !"); + MCAuto ret(DataArrayDouble::New()); + mcIdType nbTri3( getNumberOfCells() ); + const double *coordPtr( this->getCoords()->begin() ); + const mcIdType *inConnPtr(getNodalConnectivity()->begin()); + ret->alloc(nbTri3,3); + double *retPtr( ret->getPointer() ); + switch( this->getSpaceDimension()) + { + case 2: + { + constexpr unsigned SPACEDIM = 2; + for(mcIdType iCell = 0 ; iCell < nbTri3 ; ++iCell) + { + INTERP_KERNEL::ComputeTriangleHeight(coordPtr + SPACEDIM*inConnPtr[3*iCell+0], coordPtr + SPACEDIM*inConnPtr[3*iCell+1], coordPtr + SPACEDIM*inConnPtr[3*iCell+2],retPtr+3*iCell); + } + break; + } + case 3: + { + constexpr unsigned SPACEDIM = 3; + for(mcIdType iCell = 0 ; iCell < nbTri3 ; ++iCell) + { + INTERP_KERNEL::ComputeTriangleHeight(coordPtr + SPACEDIM*inConnPtr[3*iCell+0], coordPtr + SPACEDIM*inConnPtr[3*iCell+1], coordPtr + SPACEDIM*inConnPtr[3*iCell+2],retPtr+3*iCell); + } + break; + } + default: + THROW_IK_EXCEPTION("MEDCoupling1SGTUMesh::computeTriangleHeight : only spacedim in [2,3] supported !"); + } + return ret; +} + /*! * This method starts from an unstructured mesh that hides in reality a cartesian mesh. * If it is not the case, an exception will be thrown. @@ -2302,14 +2360,6 @@ bool MEDCoupling1DGTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *o if(!c1->isEqualWithoutConsideringStr(*c2)) return false; return true; - c1=_conn_indx; c2=otherC->_conn_indx; - if(c1==c2) - return true; - if(!c1 || !c2) - return false; - if(!c1->isEqualWithoutConsideringStr(*c2)) - return false; - return true; } /*! @@ -2571,6 +2621,8 @@ mcIdType MEDCoupling1DGTUMesh::getNumberOfNodesInCell(mcIdType cellId) const std::string MEDCoupling1DGTUMesh::simpleRepr() const { static const char msg0[]="No coordinates specified !"; + if(!_cm) + return std::string("Cell type not specified"); std::ostringstream ret; ret << "Single dynamic geometic type (" << _cm->getRepr() << ") unstructured mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; @@ -2664,7 +2716,7 @@ DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() cons std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell : on cell #" << i << " presence of nodeId #" << *nodal << " should be in [0," << nbOfNodes << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies(),1./double(nodali[1]-nodali[0]))); + std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind(std::multiplies(),std::placeholders::_1,1./double(nodali[1]-nodali[0]))); } } else @@ -2697,7 +2749,7 @@ DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() cons } } if(nbOfNod!=0) - std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies(),1./nbOfNod)); + std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind(std::multiplies(),std::placeholders::_1,1./nbOfNod)); else { std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell (polyhedron) : no nodes in cell #" << i << " !"; @@ -2808,7 +2860,13 @@ DataArrayIdType *MEDCoupling1DGTUMesh::simplexize(int policy) void MEDCoupling1DGTUMesh::reprQuickOverview(std::ostream& stream) const { - stream << "MEDCoupling1DGTUMesh C++ instance at " << this << ". Type=" << _cm->getRepr() << ". Name : \"" << getName() << "\"."; + stream << "MEDCoupling1DGTUMesh C++ instance at " << this << ". Type="; + if(!_cm) + { + stream << "Not defined"; + return ; + } + stream << _cm->getRepr() << ". Name : \"" << getName() << "\"."; stream << " Mesh dimension : " << getMeshDimension() << "."; if(!_coords) { stream << " No coordinates set !"; return ; } @@ -2941,7 +2999,7 @@ void MEDCoupling1DGTUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal { mcIdType nodeId=conn[conni[eltId]+j]; if(nodeId!=-1) - *std::find_if(revNodalPtr+revNodalIndxPtr[nodeId],revNodalPtr+revNodalIndxPtr[nodeId+1],std::bind2nd(std::equal_to(),-1))=eltId; + *std::find_if(revNodalPtr+revNodalIndxPtr[nodeId],revNodalPtr+revNodalIndxPtr[nodeId+1],std::bind(std::equal_to(),std::placeholders::_1,-1))=eltId; } } } @@ -3072,7 +3130,6 @@ void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, * Finds nodes not used in any cell and returns an array giving a new id to every node * by excluding the unused nodes, for which the array holds -1. The result array is * a mapping in "Old to New" mode. - * \param [out] nbrOfNodesInUse - number of node ids present in the nodal connectivity. * \return DataArrayIdType * - a new instance of DataArrayIdType. Its length is \a * this->getNumberOfNodes(). It holds for each node of \a this mesh either -1 * if the node is unused or a new id else. The caller is to delete this