X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCoupling1GTUMesh.cxx;h=a5ae41bd0bc46717ff7f7281a046939d4d6fdef3;hb=1062fa0bd4e00e0ad3ffbb3306de74cd0226df1d;hp=92adc3f2e23d754357e2f40452e40f4939c4ed46;hpb=b33408f1dc045a4d0f2e16d22f4930d7029996a3;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 92adc3f2e..a5ae41bd0 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2021 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; @@ -1743,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.