From 18e56d429e218d5503e4142fe5cde99c80106386 Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 9 Oct 2013 14:34:38 +0000 Subject: [PATCH] MEDCouplingUMesh::computePlaneEquationOf3DFaces method to localize warpped faces --- src/MEDCoupling/MEDCouplingUMesh.cxx | 51 ++++++++++++++++++++++++ src/MEDCoupling/MEDCouplingUMesh.hxx | 1 + src/MEDCoupling_Swig/MEDCouplingCommon.i | 2 + 3 files changed, 54 insertions(+) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index c246f9814..2ba48b592 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -30,6 +30,7 @@ #include "BBTreeDst.txx" #include "SplitterTetra.hxx" #include "DirectedBoundingBox.hxx" +#include "InterpKernelMatrixTools.hxx" #include "InterpKernelMeshQuality.hxx" #include "InterpKernelCellSimplify.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" @@ -7188,6 +7189,56 @@ DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, c return ret; } +/*! + * Returns a DataArrayDouble instance giving for each cell in \a this the equation of plane given by "a*X+b*Y+c*Z+d=0". + * So the returned instance will have 4 components and \c this->getNumberOfCells() tuples. + * So this method expects that \a this has a spaceDimension equal to 3 and meshDimension equal to 2. + * The computation of the plane equation is done using each time the 3 first nodes of 2D cells. + * This method is useful to detect 2D cells in 3D space that are not coplanar. + * + * \return DataArrayDouble * - a new instance of DataArrayDouble having 4 components and a number of tuples equal to number of cells in \a this. + * \throw If spaceDim!=3 or meshDim!=2. + * \throw If connectivity of \a this is invalid. + * \throw If connectivity of a cell in \a this points to an invalid node. + */ +DataArrayDouble *MEDCouplingUMesh::computePlaneEquationOf3DFaces() const +{ + MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); + int nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); + if(getSpaceDimension()!=3 || getMeshDimension()!=2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computePlaneEquationOf3DFaces : This method must be applied on a mesh having meshDimension equal 2 and a spaceDimension equal to 3 !"); + ret->alloc(nbOfCells,4); + double *retPtr(ret->getPointer()); + const int *nodal(_nodal_connec->begin()),*nodalI(_nodal_connec_index->begin()); + const double *coor(_coords->begin()); + for(int i=0;i=3) + { + for(int j=0;j<3;j++) + { + int nodeId(nodal[nodalI[0]+1+j]); + if(nodeId>=0 && nodeId& a); diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 182b5cd46..dfc70a7e7 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -250,6 +250,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField; %newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField; %newobject ParaMEDMEM::MEDCouplingUMesh::getPartBarycenterAndOwner; +%newobject ParaMEDMEM::MEDCouplingUMesh::computePlaneEquationOf3DFaces; %newobject ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField; %newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField; %newobject ParaMEDMEM::MEDCouplingUMesh::keepCellIdsByType; @@ -1520,6 +1521,7 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception); + DataArrayDouble *computePlaneEquationOf3DFaces() const throw(INTERP_KERNEL::Exception); DataArrayInt *convexEnvelop2D() throw(INTERP_KERNEL::Exception); std::string cppRepr() const throw(INTERP_KERNEL::Exception); DataArrayInt *findAndCorrectBadOriented3DExtrudedCells() throw(INTERP_KERNEL::Exception); -- 2.39.2