X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FVolSurfUser.txx;h=df87849db75d1328ae5b595dea04752348f96bcf;hb=378cb2ebe08f8f4543ef632b2bd5f77fe180f978;hp=adfb965529daf74ce558756d8e8f303962548a26;hpb=c66a21a11fed90a9536b758a162785908cfe87da;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx old mode 100644 new mode 100755 index adfb96552..df87849db --- a/src/INTERP_KERNEL/VolSurfUser.txx +++ b/src/INTERP_KERNEL/VolSurfUser.txx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 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 // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -34,13 +34,19 @@ namespace INTERP_KERNEL switch(type) { case INTERP_KERNEL::NORM_SEG2 : - case INTERP_KERNEL::NORM_SEG3 : case INTERP_KERNEL::NORM_SEG4 : { int N1 = OTT::coo2C(connec[0]); int N2 = OTT::coo2C(connec[1]); return INTERP_KERNEL::calculateLgthForSeg2(coords+(SPACEDIM*N1),coords+(SPACEDIM*N2),SPACEDIM); } + case INTERP_KERNEL::NORM_SEG3 : + { + int beginNode = OTT::coo2C(connec[0]); + int endNode = OTT::coo2C(connec[1]); + int middleNode = OTT::coo2C(connec[2]); + return INTERP_KERNEL::calculateLgthForSeg3(coords+(SPACEDIM*beginNode),coords+(SPACEDIM*endNode),coords+(SPACEDIM*middleNode),SPACEDIM); + } case INTERP_KERNEL::NORM_TRI3 : { int N1 = OTT::coo2C(connec[0]); @@ -115,6 +121,7 @@ namespace INTERP_KERNEL delete [] pts; return val; } + break; case INTERP_KERNEL::NORM_TETRA4 : case INTERP_KERNEL::NORM_TETRA10 : { @@ -231,7 +238,6 @@ namespace INTERP_KERNEL switch(type) { case NORM_SEG2: - case NORM_SEG3: case NORM_SEG4: { std::copy(coords+SPACEDIM*OTT::coo2C(connec[0]), @@ -240,8 +246,30 @@ namespace INTERP_KERNEL std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies(),0.5)); break; } + case NORM_SEG3: + { + if(SPACEDIM==2) + { + Edge *ed=Edge::BuildEdgeFrom3Points(coords+2*OTT::coo2C(connec[0]),coords+2*OTT::coo2C(connec[2]),coords+2*OTT::coo2C(connec[1])); + ed->getBarycenter(res); + ed->decrRef(); + } + else if(SPACEDIM==1) + { + *res=(coords[OTT::coo2C(connec[0])]+coords[OTT::coo2C(connec[1])])/2.; + } + else if(SPACEDIM==3) + { + std::copy(coords+SPACEDIM*OTT::coo2C(connec[0]), + coords+SPACEDIM*OTT::coo2C(connec[0]+1),res); + std::transform(res,res+SPACEDIM,coords+SPACEDIM*OTT::coo2C(connec[1]),res,std::plus()); + std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies(),0.5)); + } + else + throw INTERP_KERNEL::Exception("computeBarycenter for SEG3 only SPACEDIM 1,2 or 3 supported !"); + break; + } case NORM_TRI3: - case NORM_TRI6: case NORM_TRI7: { std::copy(coords+SPACEDIM*OTT::coo2C(connec[0]), @@ -251,6 +279,25 @@ namespace INTERP_KERNEL std::transform(res,res+SPACEDIM,res,std::bind2nd(std::multiplies(),1./3.)); break; } + case NORM_TRI6: + { + if(SPACEDIM==2) + { + double *pts[6]; + pts[0] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[0])); + pts[1] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[1])); + pts[2] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[2])); + pts[3] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[3])); + pts[4] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[4])); + pts[5] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[5])); + computeQPolygonBarycenter2D(pts,6,2,res); + } + else if(SPACEDIM==3) + computePolygonBarycenter3D(connec,lgth/2,coords,res); + else + throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !"); + break; + } case NORM_QUAD4: case NORM_POLYGON: { @@ -265,13 +312,41 @@ namespace INTERP_KERNEL case NORM_QUAD8: { if(SPACEDIM==2) - computePolygonBarycenter2D(connec,lgth/2,coords,res); + { + double *pts[8]; + pts[0] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[0])); + pts[1] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[1])); + pts[2] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[2])); + pts[3] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[3])); + pts[4] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[4])); + pts[5] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[5])); + pts[6] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[6])); + pts[7] = const_cast(coords+SPACEDIM*OTT::coo2C(connec[7])); + computeQPolygonBarycenter2D(pts,8,2,res); + } + else if(SPACEDIM==3) + computePolygonBarycenter3D(connec,lgth/2,coords,res); + else + throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !"); + break; + } + case INTERP_KERNEL::NORM_QPOLYG : + { + if(SPACEDIM==2) + { + double **pts=new double *[lgth]; + for(int i=0;i(coords+2*OTT::coo2C(connec[i])); + computeQPolygonBarycenter2D(pts,lgth,2,res); + delete [] pts; + } else if(SPACEDIM==3) computePolygonBarycenter3D(connec,lgth/2,coords,res); else throw INTERP_KERNEL::Exception("Impossible spacedim linked to cell 2D Cell !"); break; } + break; case NORM_TETRA4: { res[0]=coords[3*OTT::coo2C(connec[0])];