From: vbd Date: Tue, 12 Feb 2008 13:02:09 +0000 (+0000) Subject: addition for triangulation of polygons X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3bbd5fe1c07402308ab5366bf5d9f202bbd860f7;p=tools%2Fmedcoupling.git addition for triangulation of polygons --- diff --git a/src/INTERP_KERNEL/InterpolationUtils.hxx b/src/INTERP_KERNEL/InterpolationUtils.hxx index 57b8589c9..7a79b962b 100644 --- a/src/INTERP_KERNEL/InterpolationUtils.hxx +++ b/src/INTERP_KERNEL/InterpolationUtils.hxx @@ -3,6 +3,7 @@ #include "NormalizedUnstructuredMesh.hxx" +#include #include #include #include @@ -517,6 +518,58 @@ namespace INTERP_KERNEL return determinant(AB,AC,n)>0; } + + /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ + /* calcul l'intersection de deux polygones COPLANAIRES */ + /* en dimension DIM (2 ou 3). Si DIM=3 l'algorithme ne considère*/ + /* que les deux premières coordonnées de chaque point */ + /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ + template inline void intersec_de_polygone(const double * Coords_A, const double * Coords_B, + int nb_NodesA, int nb_NodesB, + std::vector& inter, double dim_caracteristic, double precision) + { + for(int i_A = 1; i_A3) inter=INTERP_KERNEL::reconstruct_polygon(inter); + } + + /*_ _ _ _ _ _ _ _ _ + /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ + /* fonctions qui calcule l'aire d'un polygone en dimension 2 ou 3 */ + /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ + template inline double polygon_area(std::vector& inter) + { + double result=0.; + double area[DIM]; + + for(int i = 1; i<(int)inter.size()/DIM-1; i++) + { + INTERP_KERNEL::crossprod(&inter[0],&inter[DIM*i],&inter[DIM*(i+1)],area); + result +=0.5*norm(area); + } + return result; + } + + template inline double polygon_area(std::deque& inter) + { + double result=0.; + double area[DIM]; + + for(int i = 1; i<(int)inter.size()/DIM-1; i++) + { + INTERP_KERNEL::crossprod(&inter[0],&inter[DIM*i],&inter[DIM*(i+1)],area); + result +=0.5*norm(area); + } + return result; + } } #endif