X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingUMesh.cxx;h=2ba48b592b804217f45e6ad985a10a9790d98f96;hb=18e56d429e218d5503e4142fe5cde99c80106386;hp=bd2f9b5dc8d71f86b280c3c23e85254012d6519e;hpb=584bab5f7596b65a3a87a34b63e54d2bd1ff8894;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index bd2f9b5dc..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" @@ -5692,13 +5693,25 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly) INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(!polyOnly || (type==INTERP_KERNEL::NORM_POLYGON || type==INTERP_KERNEL::NORM_QPOLYG)) { - bool isQuadratic=INTERP_KERNEL::CellModel::GetCellModel(type).isQuadratic(); + bool isQuadratic(INTERP_KERNEL::CellModel::GetCellModel(type).isQuadratic()); if(!IsPolygonWellOriented(isQuadratic,vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) { isModified=true; - std::vector tmp(connI[i+1]-connI[i]-2); - std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin()); - std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2); + if(!isQuadratic) + { + std::vector tmp(connI[i+1]-connI[i]-2); + std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin()); + std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2); + } + else + { + int sz(((int)(connI[i+1]-connI[i]-1))/2); + std::vector tmp0(sz-1),tmp1(sz); + std::copy(conn+connI[i]+2,conn+connI[i]+1+sz,tmp0.rbegin()); + std::copy(conn+connI[i]+1+sz,conn+connI[i+1],tmp1.rbegin()); + std::copy(tmp0.begin(),tmp0.end(),conn+connI[i]+2); + std::copy(tmp1.begin(),tmp1.end(),conn+connI[i]+1+sz); + } } } } @@ -7176,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 nodes; + pol1->getAllNodes(nodes); pol2->getAllNodes(nodes); + std::size_t szz(nodes.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > nodesSafe(szz); + std::set::const_iterator itt(nodes.begin()); + for(std::size_t iii=0;iiiincrRef(); nodesSafe[iii]=*itt; } + // end of protection pol1->splitAbs(*pol2,map1,map2,offset1,offset2,candidates2,intersectEdge1[i],i,colinear2,subDiv2,addCoo); delete pol2; delete pol1;