X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FVolSurfUser.txx;h=9e1cd383dc44e19d90ffc2fe8726d5bc9b087714;hb=d426837c21eca9b56b9b8a7a7434aaf3969c8977;hp=5e4f6129dc9015b689620ac97e65dcf6dd623855;hpb=293a6104470482e450701aa8061d9b244f2057d5;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx index 5e4f6129d..9e1cd383d 100644 --- 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-2016 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,16 +34,20 @@ 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 : - case INTERP_KERNEL::NORM_TRI6 : - case INTERP_KERNEL::NORM_TRI7 : { int N1 = OTT::coo2C(connec[0]); int N2 = OTT::coo2C(connec[1]); @@ -56,9 +60,20 @@ namespace INTERP_KERNEL } break; + case INTERP_KERNEL::NORM_TRI6 : + case INTERP_KERNEL::NORM_TRI7 : + { + const double *pts[6]; + pts[0] = coords+SPACEDIM*OTT::coo2C(connec[0]); + pts[1] = coords+SPACEDIM*OTT::coo2C(connec[1]); + pts[2] = coords+SPACEDIM*OTT::coo2C(connec[2]); + pts[3] = coords+SPACEDIM*OTT::coo2C(connec[3]); + pts[4] = coords+SPACEDIM*OTT::coo2C(connec[4]); + pts[5] = coords+SPACEDIM*OTT::coo2C(connec[5]); + return INTERP_KERNEL::calculateAreaForQPolyg(pts,6,SPACEDIM); + } + break; case INTERP_KERNEL::NORM_QUAD4 : - case INTERP_KERNEL::NORM_QUAD8 : - case INTERP_KERNEL::NORM_QUAD9 : { int N1 = OTT::coo2C(connec[0]); int N2 = OTT::coo2C(connec[1]); @@ -72,7 +87,21 @@ namespace INTERP_KERNEL SPACEDIM); } break; - + case INTERP_KERNEL::NORM_QUAD8 : + case INTERP_KERNEL::NORM_QUAD9 : + { + const double *pts[8]; + pts[0] = coords+SPACEDIM*OTT::coo2C(connec[0]); + pts[1] = coords+SPACEDIM*OTT::coo2C(connec[1]); + pts[2] = coords+SPACEDIM*OTT::coo2C(connec[2]); + pts[3] = coords+SPACEDIM*OTT::coo2C(connec[3]); + pts[4] = coords+SPACEDIM*OTT::coo2C(connec[4]); + pts[5] = coords+SPACEDIM*OTT::coo2C(connec[5]); + pts[6] = coords+SPACEDIM*OTT::coo2C(connec[6]); + pts[7] = coords+SPACEDIM*OTT::coo2C(connec[7]); + return INTERP_KERNEL::calculateAreaForQPolyg(pts,8,SPACEDIM); + } + break; case INTERP_KERNEL::NORM_POLYGON : { const double **pts=new const double *[lgth]; @@ -83,6 +112,16 @@ namespace INTERP_KERNEL return val; } break; + case INTERP_KERNEL::NORM_QPOLYG : + { + const double **pts=new const double *[lgth]; + for(int inod=0;inod::coo2C(connec[inod]); + double val=INTERP_KERNEL::calculateAreaForQPolyg(pts,lgth,SPACEDIM); + delete [] pts; + return val; + } + break; case INTERP_KERNEL::NORM_TETRA4 : case INTERP_KERNEL::NORM_TETRA10 : { @@ -199,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]), @@ -208,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]), @@ -219,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: { @@ -233,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])];