From 9e3b1b5df6f7114d52d00211775b6a9689c45e56 Mon Sep 17 00:00:00 2001 From: Philippe Verley <philippe.verley@ird.fr> Date: Thu, 29 Mar 2018 15:40:27 +0000 Subject: [PATCH] Deleted transpose function in utils.R since the C function is absent from utils.c. Deleted it as well from internal.Rd Deleted utils.c and moved function triangulate to triangulate.c Renamed C function triangulate into c_triangulate and updated triangulate.R Added new file init.c to declare C and Fortran functions as recommanded by outputs of tools::package_native_routine_registration_skeleton(".") Updated NAMESPACE "useDynLib(ads, .registration=TRUE)" as recommanded for R >= 3.4 Updated MD5 --- DESCRIPTION | 2 -- INDEX | 35 +++++++------------- MD5 | 36 +++++++-------------- NAMESPACE | 2 +- R/triangulate.R | 2 +- R/util.R | 10 ------ man/internal.Rd | 2 -- src/init.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ src/triangulate.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ src/triangulate.h | 10 ++---- src/util.c | 80 --------------------------------------------- 11 files changed, 188 insertions(+), 151 deletions(-) create mode 100644 src/init.c delete mode 100755 src/util.c diff --git a/DESCRIPTION b/DESCRIPTION index 4c11bcf..2ec7632 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,8 +13,6 @@ Description: Perform first- and second-order multi-scale analyses derived from R multivariate and marked mapped data in rectangular, circular or irregular shaped sampling windows, with tests of statistical significance based on Monte Carlo simulations. License: GPL-2 -Packaged: 2015-01-13 12:09:18 UTC; root NeedsCompilation: yes Repository: CRAN -Date/Publication: 2015-01-13 14:49:23 RoxygenNote: 6.0.1 diff --git a/INDEX b/INDEX index 18df450..309fd0e 100755 --- a/INDEX +++ b/INDEX @@ -1,31 +1,20 @@ Allogny Spatial pattern of oaks suffering from frost shake in Allogny, France. BPoirier Tree spatial pattern in Beau Poirier plot, Haye forest, France. -Couepia Spatial pattern of Couepia caryophylloides in Paracou, a canopy tree - species of French Guiana. -demopat Artificial data point pattern from \code{spatstat} package. -Paracou15 Spatial pattern of trees in plot 15 of Paracou experimental station, - French Guiana. +Couepia Spatial pattern of Couepia caryophylloides in Paracou, a canopy tree species of French Guiana. +demopat Artificial data point pattern from \code{spatstat} package. +Paracou15 Spatial pattern of trees in plot 15 of Paracou experimental station, French Guiana. area.swin Area of a sampling window. dval Multiscale local density of a spatial point pattern. inside.swin Test wether points are inside a sampling window. -k12fun Multiscale second-order neigbourhood analysis of a bivariate spatial - point pattern. -k12val Multiscale local second-order neighbour density of a bivariate spatial - point pattern. -kdfun Multiscale second-order neigbourhood analysis of phylogentic/functional - spatial structure of a multivariate spatial point pattern. -kfun Multiscale second-order neigbourhood analysis of an univariate spatial - point pattern. -kmfun Multiscale second-order neigbourhood analysis of a marked spatial point - pattern. -kp.fun (Formerly ki.fun) Multiscale second-order neigbourhood analysis of a - multivariate spatial point pattern. -kpqfun (Formerly kijfun) Multiscale second-order neigbourhood analysis of a - multivariate spatial point pattern. -krfun Multiscale second-order neigbourhood analysis of a multivariate spatial - point pattern using Rao quadratic entropy. -ksfun Multiscale second-order neigbourhood analysis of a multivariate spatial - point pattern using Simpson diversity. +k12fun Multiscale second-order neigbourhood analysis of a bivariate spatial point pattern. +k12val Multiscale local second-order neighbour density of a bivariate spatial point pattern. +kdfun Multiscale second-order neigbourhood analysis of phylogentic/functional spatial structure of a multivariate spatial point pattern. +kfun Multiscale second-order neigbourhood analysis of an univariate spatial point pattern. +kmfun Multiscale second-order neigbourhood analysis of a marked spatial point pattern. +kp.fun (Formerly ki.fun) Multiscale second-order neigbourhood analysis of a multivariate spatial point pattern. +kpqfun (Formerly kijfun) Multiscale second-order neigbourhood analysis of a multivariate spatial point pattern. +krfun Multiscale second-order neigbourhood analysis of a multivariate spatial point pattern using Rao quadratic entropy. +ksfun Multiscale second-order neigbourhood analysis of a multivariate spatial point pattern using Simpson diversity. kval Multiscale local second-order neighbour density of a spatial point pattern. mimetic Univariate point pattern replication by mimetic point process. plot.fads Plot second-order neigbourhood functions. diff --git a/MD5 b/MD5 index 83b6579..27c2b03 100644 --- a/MD5 +++ b/MD5 @@ -1,20 +1,9 @@ -f6aac0fb4ef187df6521cbb2d9ffc9cf R/fads.R -7a71372e86fd8aadfc770b261cd953ca R/mimetic.R -7603ca1f27dbbaf85b7b2ec19e059d7d R/plot.fads.R -154b26509aa63d97c2e0cc646e6681a8 R/plot.vads.R -b85a2aa0125801e94f5b4ce8b0f22a12 R/print.fads.R -1a420e10243f4c0df000ac22e0bab60e R/print.vads.R -c4b216a6fb57acb020f5e21682f7ed13 R/spp.R -bbb6ddd2e55fabe14c9e9dfcdfc495e7 R/summary.vads.R -c5d76ac2aa5f6fa68c0cfd08f197989e R/swin.R -318472a4c160e2ac070b5fb390add04e R/triangulate.R -a322bba8d53aff07f9a8ce9a69c89aef R/util.R -9f002a8b5ed00aaf26b4d7dc2f914f40 R/vads.R 31fa89b542936dac1031133b12ef530c data/Allogny.rda 5450b84c345240671b3410af7c70bc44 data/BPoirier.rda 24fea786746fc897f8918300f2f2c544 data/Couepia.rda 674867657e9a3df07b6eced02aa022a1 data/demopat.rda a014cac4bc9abd4f40123a762939c8ca data/Paracou15.rda +c7cd00087730e79e06e8c0d937d0b1f7 inst/CITATION 94a8b147b3d2730b0c3869a7e1a2592f man/Allogny.Rd b3c89a3bcb5db0d5fc9e93d8305df8c8 man/area.swin.Rd 1755cf31329228337e0b8039af2b6daf man/BPoirier.Rd @@ -22,14 +11,13 @@ d912451f743e11a9fbe50c8a6ef13b15 man/Couepia.Rd d7b568c5332aad81bf4fb9f2bd4efed7 man/demopat.Rd 9b09cc667ab5d522e4a3a77c8b711159 man/dval.Rd cd9ec1a82e0ee4e372e7ebd9c11233e4 man/inside.swin.Rd -e85df8cba02e1d7ae44b447ef05f0e3f man/internal.Rd +0656e69ec81de59af7b29e52639eee85 man/internal.Rd 18f7794bc004e9b9599486a725f7da5b man/k12fun.Rd 26a82fbf3be668f7c74dd4f1b9fd93e4 man/k12val.Rd f4c594ec01933acd9d9cae7e797685fe man/kdfun.Rd aa725a3e6b7183290f7dd758d594810c man/kfun.Rd ea3edb1e20ecd5aa794f48c9fa5ee0e5 man/kmfun.Rd 0e606a71b6ec6f730bdd0d1498834dbc man/kp.fun.Rd -b45ac5f58b213884c5b1d9c79d5d1599 man/kpfun.Rd 500b63ba993de0b1f8a7d7f92765403b man/kpqfun.Rd d388b950333aad22313c76d82f51c749 man/krfun.Rd 9970f6e4573f2e241de12d62ab201e23 man/ksfun.Rd @@ -42,7 +30,7 @@ c30babaf1b550ec45fa0f1bd89f967e5 man/plot.vads.Rd 2c61afcc548ad6440240664252a645a5 man/spp.Rd cfe40689a11ec983e9b9bb4b759aaa26 man/swin.Rd c04839dd6cd8eb396d512260a23dc7fd man/triangulate.Rd -f6aac0fb4ef187df6521cbb2d9ffc9cf R/fads.R +301f8891de7b1d08e3acd6c76d550ffb R/fads.R 7a71372e86fd8aadfc770b261cd953ca R/mimetic.R 7603ca1f27dbbaf85b7b2ec19e059d7d R/plot.fads.R 154b26509aa63d97c2e0cc646e6681a8 R/plot.vads.R @@ -51,17 +39,17 @@ b85a2aa0125801e94f5b4ce8b0f22a12 R/print.fads.R c4b216a6fb57acb020f5e21682f7ed13 R/spp.R bbb6ddd2e55fabe14c9e9dfcdfc495e7 R/summary.vads.R c5d76ac2aa5f6fa68c0cfd08f197989e R/swin.R -318472a4c160e2ac070b5fb390add04e R/triangulate.R -a322bba8d53aff07f9a8ce9a69c89aef R/util.R +ba0e4bccaaaf969605faa35b7e01c578 R/triangulate.R +42d0d005b506098da453471b2f327362 R/util.R 9f002a8b5ed00aaf26b4d7dc2f914f40 R/vads.R 3d7a3f0a98ac75ad014cc91fbe2d0579 src/adssub.c -bd642dbad07c62b2f39fae4c5640f93a src/adssub.h +bd1503ee73c209191dc005b9be944175 src/adssub.h +1565adf6ba6c523f85ec70e89faca21c src/init.c 8a3dad68f1826270eef7ea08e098dfc5 src/spatstatsub.f -5aa9f5862ef5b0e8bbcc327021e1489a src/triangulate.c -e482b9d18794f53adaed3f2c98edd19a src/triangulate.h -fb07aec2cf6396cab654966e2757ab5c src/util.c +978998deca214a86ca6405d41a0d3b8f src/triangulate.c +0d9b249698185de8002c8aa767699d04 src/triangulate.h f44e3b71761cdf40a551c450517d20cd src/Zlibs.c -109615f7005a5a6e02b98bcf1a904551 src/Zlibs.h -d9ae8cc82c07551b180991f6d508aedf NAMESPACE -a32d955da46938603fc72e218ce86101 DESCRIPTION +91f57a5dcc09e9babc1b761e95b8e446 src/Zlibs.h +705c1b8142d8d69a8b6df81b00d34739 DESCRIPTION 68a58538a504c7cfa73472d87053be45 INDEX +639184324c5b727794789ee4c72accb1 NAMESPACE diff --git a/NAMESPACE b/NAMESPACE index 1c9cfcd..9b06eab 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -80,4 +80,4 @@ S3method(summary, k12val, summary.vads.k12val) S3method(summary, kval, summary.vads.kval) # load DLL -useDynLib(ads) +useDynLib(ads, .registration=TRUE) diff --git a/R/triangulate.R b/R/triangulate.R index 9453bae..e263ba8 100755 --- a/R/triangulate.R +++ b/R/triangulate.R @@ -44,7 +44,7 @@ triangulate<-function(outer.poly,holes) { vertY<-outer.poly$y nbtri<-(nbpts-2) } - tri<-.C("triangulate", + tri<-.C("c_triangulate", as.integer(nbpoly),as.integer(nbpts),as.integer(nbptot),as.double(vertX),as.double(vertY),as.integer(nbtri), X1=double(nbtri),Y1=double(nbtri),X2=double(nbtri),Y2=double(nbtri),X3=double(nbtri),Y3=double(nbtri), PACKAGE="ads") diff --git a/R/util.R b/R/util.R index 6290578..8bdc178 100755 --- a/R/util.R +++ b/R/util.R @@ -307,16 +307,6 @@ read.tri<-function(X) { return(res) } -transpose<-function(x,y) { - - nbTri<-length(x)/3 - - res<-.C("transpose",x=as.double(x),y=as.double(y),nbTri=as.integer(nbTri), - x1=double(nbTri),y1=double(nbTri),x2=double(nbTri),y2=double(nbTri), - x3=double(nbTri),y3=double(nbTri),PACKAGE="ads") - - list(x1=res$x1,y1=res$y1,x2=res$x2,y2=res$y2,x3=res$x3,y3=res$y3) -} ############## #subsetting dist objects #sub is a logical vector of True/False diff --git a/man/internal.Rd b/man/internal.Rd index 6920a3f..b2d64c4 100755 --- a/man/internal.Rd +++ b/man/internal.Rd @@ -32,7 +32,6 @@ \alias{summary.vads.kval} \alias{testIC} \alias{testInteger} -\alias{transpose} \alias{subsetdist} \title{Internal ads functions} \description{ @@ -59,7 +58,6 @@ sortmat(dis,ind) subsetdist(dis,sub) testIC(nbSimu, lev) testInteger(i) -transpose(x, y) } \details{ These are usually not to be called by the user. diff --git a/src/init.c b/src/init.c new file mode 100644 index 0000000..f7bfb7d --- /dev/null +++ b/src/init.c @@ -0,0 +1,82 @@ +#include <R_ext/RS.h> +#include <stdlib.h> // for NULL +#include <R_ext/Rdynload.h> +#include "Zlibs.h" +#include "triangulate.h" + +/* .Fortran calls */ +extern void F77_NAME(inpoly)(void *, void *, void *, void *, void *, void *, void *, void *); + +static const R_CMethodDef CEntries[] = { + {"corr_disq", (DL_FUNC) &corr_disq, 11}, + {"corr_disq_ic", (DL_FUNC) &corr_disq_ic, 19}, + {"corr_rect", (DL_FUNC) &corr_rect, 12}, + {"corr_rect_ic", (DL_FUNC) &corr_rect_ic, 20}, + {"corr_tr_disq", (DL_FUNC) &corr_tr_disq, 18}, + {"corr_tr_disq_ic", (DL_FUNC) &corr_tr_disq_ic, 26}, + {"corr_tr_rect", (DL_FUNC) &corr_tr_rect, 19}, + {"corr_tr_rect_ic", (DL_FUNC) &corr_tr_rect_ic, 27}, + {"density_disq", (DL_FUNC) &density_disq, 12}, + {"density_rect", (DL_FUNC) &density_rect, 13}, + {"density_tr_disq", (DL_FUNC) &density_tr_disq, 19}, + {"density_tr_rect", (DL_FUNC) &density_tr_rect, 20}, + {"intertype_disq", (DL_FUNC) &intertype_disq, 13}, + {"intertype_disq_ic", (DL_FUNC) &intertype_disq_ic, 29}, + {"intertype_rect", (DL_FUNC) &intertype_rect, 14}, + {"intertype_rect_ic", (DL_FUNC) &intertype_rect_ic, 30}, + {"intertype_tr_disq", (DL_FUNC) &intertype_tr_disq, 20}, + {"intertype_tr_disq_ic", (DL_FUNC) &intertype_tr_disq_ic, 36}, + {"intertype_tr_rect", (DL_FUNC) &intertype_tr_rect, 21}, + {"intertype_tr_rect_ic", (DL_FUNC) &intertype_tr_rect_ic, 37}, + {"intertypelocal_disq", (DL_FUNC) &intertypelocal_disq, 13}, + {"intertypelocal_rect", (DL_FUNC) &intertypelocal_rect, 14}, + {"intertypelocal_tr_disq", (DL_FUNC) &intertypelocal_tr_disq, 20}, + {"intertypelocal_tr_rect", (DL_FUNC) &intertypelocal_tr_rect, 21}, + {"mimetic_disq", (DL_FUNC) &mimetic_disq, 19}, + {"mimetic_rect", (DL_FUNC) &mimetic_rect, 20}, + {"mimetic_tr_disq", (DL_FUNC) &mimetic_tr_disq, 26}, + {"mimetic_tr_rect", (DL_FUNC) &mimetic_tr_rect, 27}, + {"rao_disq", (DL_FUNC) &rao_disq, 19}, + {"rao_disq_ic", (DL_FUNC) &rao_disq_ic, 27}, + {"rao_rect", (DL_FUNC) &rao_rect, 20}, + {"rao_rect_ic", (DL_FUNC) &rao_rect_ic, 28}, + {"rao_tr_disq", (DL_FUNC) &rao_tr_disq, 26}, + {"rao_tr_disq_ic", (DL_FUNC) &rao_tr_disq_ic, 34}, + {"rao_tr_rect", (DL_FUNC) &rao_tr_rect, 27}, + {"rao_tr_rect_ic", (DL_FUNC) &rao_tr_rect_ic, 35}, + {"ripley_disq", (DL_FUNC) &ripley_disq, 10}, + {"ripley_disq_ic", (DL_FUNC) &ripley_disq_ic, 22}, + {"ripley_rect", (DL_FUNC) &ripley_rect, 11}, + {"ripley_rect_ic", (DL_FUNC) &ripley_rect_ic, 23}, + {"ripley_tr_disq", (DL_FUNC) &ripley_tr_disq, 17}, + {"ripley_tr_disq_ic", (DL_FUNC) &ripley_tr_disq_ic, 29}, + {"ripley_tr_rect", (DL_FUNC) &ripley_tr_rect, 18}, + {"ripley_tr_rect_ic", (DL_FUNC) &ripley_tr_rect_ic, 30}, + {"ripleylocal_disq", (DL_FUNC) &ripleylocal_disq, 10}, + {"ripleylocal_rect", (DL_FUNC) &ripleylocal_rect, 11}, + {"ripleylocal_tr_disq", (DL_FUNC) &ripleylocal_tr_disq, 17}, + {"ripleylocal_tr_rect", (DL_FUNC) &ripleylocal_tr_rect, 18}, + {"shen", (DL_FUNC) &shen, 13}, + {"shen_ic", (DL_FUNC) &shen_ic, 21}, + {"shimatani_disq", (DL_FUNC) &shimatani_disq, 14}, + {"shimatani_disq_ic", (DL_FUNC) &shimatani_disq_ic, 23}, + {"shimatani_rect", (DL_FUNC) &shimatani_rect, 15}, + {"shimatani_rect_ic", (DL_FUNC) &shimatani_rect_ic, 24}, + {"shimatani_tr_disq", (DL_FUNC) &shimatani_tr_disq, 21}, + {"shimatani_tr_disq_ic", (DL_FUNC) &shimatani_tr_disq_ic, 30}, + {"shimatani_tr_rect", (DL_FUNC) &shimatani_tr_rect, 22}, + {"shimatani_tr_rect_ic", (DL_FUNC) &shimatani_tr_rect_ic, 31}, + {"c_triangulate", (DL_FUNC) &c_triangulate, 12}, + {NULL, NULL, 0} +}; + +static const R_FortranMethodDef FortranEntries[] = { + {"inpoly", (DL_FUNC) &F77_NAME(inpoly), 8}, + {NULL, NULL, 0} +}; + +void R_init_ads(DllInfo *dll) +{ + R_registerRoutines(dll, CEntries, NULL, FortranEntries, NULL); + R_useDynamicSymbols(dll, FALSE); +} \ No newline at end of file diff --git a/src/triangulate.c b/src/triangulate.c index 3a58f2d..7193f52 100755 --- a/src/triangulate.c +++ b/src/triangulate.c @@ -2126,3 +2126,81 @@ int is_point_inside_polygon(vertex) return _greater_than_equal_to(&seg[rseg].v1, &seg[rseg].v0); } +int c_triangulate(int *npoly, int *tabpt, int *nptTot,double *vertX, double *vertY, int *ntri, double *X1, double *Y1,double *X2, double *Y2,double *X3, double *Y3) { + int i,j,k,l; + int **triangles; + double **vertices; + double *x,*y; + tabintalloc(&triangles,*ntri,3); + taballoc(&vertices,*nptTot+1,2); + l=0; + for(i=0;i<*npoly;i++) { + int npt=tabpt[i]; + vecalloc(&x,npt+1); + vecalloc(&y,npt+1); + for(j=1;j<=npt;j++) { + k=j+l-1; + x[j]=vertX[k]; + y[j]=vertY[k]; + } + if(i==0) { + if(testclock(x,y,npt)) { /*clockwise order*/ +k=npt; + for(j=1;j<=npt;j++) { + vertices[j+l][0]=x[k]; + vertices[j+l][1]=y[k]; + k--; + } + } + else { /*anti-clockwise order*/ +for(j=1;j<=npt;j++) { + vertices[j+l][0]=x[j]; + vertices[j+l][1]=y[j]; +} + } + } + else { + if(!testclock(x,y,npt)) { /*anti-clockwise order*/ +k=npt; + for(j=1;j<=npt;j++) { + vertices[j+l][0]=x[k]; + vertices[j+l][1]=y[k]; + k--; + } + } + else { /*clockwise order*/ +for(j=1;j<=npt;j++) { + vertices[j+l][0]=x[j]; + vertices[j+l][1]=y[j]; +} + } + } + l+=npt; + freevec(x); + freevec(y); + } + + /*Test de l'unicite des points*/ + for(i=2;i<=*nptTot;i++) { + for(j=1;j<i;j++) { + if((vertices[i][0]==vertices[j][0])&&(vertices[i][1]==vertices[j][1])) { + Rprintf("Error : Duplicate input vertices\n"); + return -1; + } + } + } + triangulate_polygon(*npoly,tabpt,vertices,triangles); + for(i=0;i<*ntri;i++) { + X1[i]=vertices[triangles[i][2]][0]; + Y1[i]=vertices[triangles[i][2]][1]; + X2[i]=vertices[triangles[i][1]][0]; + Y2[i]=vertices[triangles[i][1]][1]; + X3[i]=vertices[triangles[i][0]][0]; + Y3[i]=vertices[triangles[i][0]][1]; + } + freeinttab(triangles); + freetab(vertices); + return 0; +} + + diff --git a/src/triangulate.h b/src/triangulate.h index baa3568..50a0b50 100755 --- a/src/triangulate.h +++ b/src/triangulate.h @@ -88,7 +88,7 @@ typedef struct { #define LASTPT 2 -#define INFINITY 1<<30 +#define INFINITY 1<<30 #define C_EPS 1.0e-7 /* tolerance value: Used for making */ /* all decisions about collinearity or */ /* left/right of segment. Decrease */ @@ -140,26 +140,20 @@ extern node_t qs[QSIZE]; /* Query structure */ extern trap_t tr[TRSIZE]; /* Trapezoid structure */ extern segment_t seg[SEGSIZE]; /* Segment table */ - /* Functions */ - +extern int c_triangulate(int*, int *, int *,double *, double *, int *, double *, double *,double *, double *,double *, double *); extern int triangulate_polygon(int, int *, double**,int**); extern int is_point_inside_polygon(double *); - int triangulate_polygon(int, int [], double**, int**); - int testclock(double *,double *,int); - extern int monotonate_trapezoids(int); extern int triangulate_monotone_polygons(int, int, int**); - extern int _greater_than(point_t *, point_t *); extern int _equal_to(point_t *, point_t *); extern int _greater_than_equal_to(point_t *, point_t *); extern int _less_than(point_t *, point_t *); extern int locate_endpoint(point_t *, point_t *, int); extern int construct_trapezoids(int); - extern int generate_random_ordering(int); extern int choose_segment(void); extern int read_segments(char *, int *); diff --git a/src/util.c b/src/util.c deleted file mode 100755 index c6e6a23..0000000 --- a/src/util.c +++ /dev/null @@ -1,80 +0,0 @@ -#include "adssub.h" -#include "triangulate.h" - -int triangulate(int *npoly, int *tabpt, int *nptTot,double *vertX, double *vertY, int *ntri, -double *X1, double *Y1,double *X2, double *Y2,double *X3, double *Y3) { - int i,j,k,l; - int **triangles; - double **vertices; - double *x,*y; - tabintalloc(&triangles,*ntri,3); - taballoc(&vertices,*nptTot+1,2); - l=0; - for(i=0;i<*npoly;i++) { - int npt=tabpt[i]; - vecalloc(&x,npt+1); - vecalloc(&y,npt+1); - for(j=1;j<=npt;j++) { - k=j+l-1; - x[j]=vertX[k]; - y[j]=vertY[k]; - } - if(i==0) { - if(testclock(x,y,npt)) { /*clockwise order*/ - k=npt; - for(j=1;j<=npt;j++) { - vertices[j+l][0]=x[k]; - vertices[j+l][1]=y[k]; - k--; - } - } - else { /*anti-clockwise order*/ - for(j=1;j<=npt;j++) { - vertices[j+l][0]=x[j]; - vertices[j+l][1]=y[j]; - } - } - } - else { - if(!testclock(x,y,npt)) { /*anti-clockwise order*/ - k=npt; - for(j=1;j<=npt;j++) { - vertices[j+l][0]=x[k]; - vertices[j+l][1]=y[k]; - k--; - } - } - else { /*clockwise order*/ - for(j=1;j<=npt;j++) { - vertices[j+l][0]=x[j]; - vertices[j+l][1]=y[j]; - } - } - } - l+=npt; - freevec(x); - freevec(y); - } - - /*Test de l'unicite des points*/ - for(i=2;i<=*nptTot;i++) { - for(j=1;j<i;j++) { - if((vertices[i][0]==vertices[j][0])&&(vertices[i][1]==vertices[j][1])) { - Rprintf("Error : Duplicate input vertices\n"); - return -1; - } - } - } - triangulate_polygon(*npoly,tabpt,vertices,triangles); - for(i=0;i<*ntri;i++) { - X1[i]=vertices[triangles[i][2]][0]; - Y1[i]=vertices[triangles[i][2]][1]; - X2[i]=vertices[triangles[i][1]][0]; - Y2[i]=vertices[triangles[i][1]][1]; - X3[i]=vertices[triangles[i][0]][0]; - Y3[i]=vertices[triangles[i][0]][1]; - } - freeinttab(triangles); - freetab(vertices); - return 0; -} -- GitLab