+/*!
+ * 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<DataArrayDouble> 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<DataArrayDouble> 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<SPACEDIM>(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<SPACEDIM>(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.
+ * This method returns three objects : The cartesian mesh geometrically equivalent to \a this (within a precision of \a eps) and a permutation of cells
+ * and a permutation of nodes.
+ *
+ * - this[cellPerm[i]]=ret[i]
+ *
+ * \param [out] cellPerm the permutation array of size \c this->getNumberOfCells()
+ * \param [out] nodePerm the permutation array of size \c this->getNumberOfNodes()
+ * \return MEDCouplingCMesh * - a newly allocated mesh that is the result of the structurization of \a this.
+ */
+MEDCouplingCMesh *MEDCoupling1SGTUMesh::structurizeMe(DataArrayIdType *& cellPerm, DataArrayIdType *& nodePerm, double eps) const
+{
+ checkConsistencyLight();
+ int spaceDim(getSpaceDimension()),meshDim(getMeshDimension()); mcIdType nbNodes(getNumberOfNodes());
+ if(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(meshDim)!=getCellModelEnum())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : the unique geo type in this is not compatible with the geometric type regarding mesh dimension !");
+ MCAuto<MEDCouplingCMesh> cm(MEDCouplingCMesh::New());
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::vector<std::size_t> tmp(1,i);
+ MCAuto<DataArrayDouble> elt(static_cast<DataArrayDouble*>(getCoords()->keepSelectedComponents(tmp)));
+ elt=elt->getDifferentValues(eps);
+ elt->sort(true);
+ cm->setCoordsAt(i,elt);
+ }
+ if(nbNodes!=cm->getNumberOfNodes())
+ throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : considering the number of nodes after split per components in space this can't be a cartesian mesh ! Maybe your epsilon parameter is invalid ?");
+ try
+ { cm->copyTinyInfoFrom(this); }
+ catch(INTERP_KERNEL::Exception&) { }
+ MCAuto<MEDCouplingUMesh> um(cm->buildUnstructured()),self(buildUnstructured());
+ self->checkGeoEquivalWith(um,12,eps,cellPerm,nodePerm);
+ return cm.retn();
+}
+