Changeset: 4ae3458b9886 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4ae3458b9886
Added Files:
geom/monetdb5/sfcgalBulk.c
Modified Files:
geom/monetdb5/Makefile.ag
geom/monetdb5/sfcgal.h
geom/monetdb5/sfcgal.mal
Branch: sfcgal
Log Message:
Bulk verion for 2DZ triangulation
diffs (132 lines):
diff --git a/geom/monetdb5/Makefile.ag b/geom/monetdb5/Makefile.ag
--- a/geom/monetdb5/Makefile.ag
+++ b/geom/monetdb5/Makefile.ag
@@ -40,7 +40,7 @@ lib__sfcgal = {
COND = HAVE_SFCGAL
MODULE
DIR = libdir/monetdb5
- SOURCES = sfcgal.h sfcgal.c
+ SOURCES = sfcgal.h sfcgal.c sfcgalBulk.c
LIBS = ../lib/libgeom \
../../gdk/libbat \
../../common/stream/libstream \
diff --git a/geom/monetdb5/sfcgal.h b/geom/monetdb5/sfcgal.h
--- a/geom/monetdb5/sfcgal.h
+++ b/geom/monetdb5/sfcgal.h
@@ -44,3 +44,4 @@ geom_export str geom_sfcgal_straightSkel
geom_export str geom_sfcgal_tesselate(wkb **res, wkb **geom);
geom_export str geom_sfcgal_triangulate2DZ(wkb **res, wkb **geom, int *flag);
+geom_export str geom_sfcgal_triangulate2DZ_bat(bat *outBAT_id, bat *inBAT_id,
int *flag);
diff --git a/geom/monetdb5/sfcgal.mal b/geom/monetdb5/sfcgal.mal
--- a/geom/monetdb5/sfcgal.mal
+++ b/geom/monetdb5/sfcgal.mal
@@ -6,18 +6,30 @@
module geom;
-command version() :str address geom_sfcgal_version
+command version() :str
+address geom_sfcgal_version
comment "Returns the version number of the SFCGAL library";
-command extrude(geo:wkb, x:dbl, y:dbl, z:dbl) : wkb address geom_sfcgal_extrude
-comment "Extrude a surface to a related volume"
+command extrude(geo:wkb, x:dbl, y:dbl, z:dbl) : wkb
+address geom_sfcgal_extrude
+comment "Extrude a surface to a related volume";
-command straightSkeletion(geo:wkb) : wkb address geom_sfcgal_straightSkeleton
-comment "Compute a straight skeleton from a geometry"
+command straightSkeletion(geo:wkb) : wkb
+address geom_sfcgal_straightSkeleton
+comment "Compute a straight skeleton from a geometry";
-command tesselate(geo:wkb) : wkb address geom_sfcgal_tesselate
-comment "Perform surface Tesselation of a polygon or polyhedralsurface and
returns as a TIN or collection of TINS"
+command tesselate(geo:wkb) : wkb
+address geom_sfcgal_tesselate
+comment "Perform surface Tesselation of a polygon or polyhedralsurface and
returns as a TIN or collection of TINS";
-command triangulate2DZ(geo:wkb, flag:int) : wkb address
geom_sfcgal_triangulate2DZ
-comment "Triangulates a geometry collection"
+command triangulate2DZ(geo:wkb, flag:int) : wkb
+address geom_sfcgal_triangulate2DZ
+comment "Triangulates a geometry collection";
+
+
+module batgeom;
+
+command triangulate2DZ(geo:bat[:oid,:wkb], flag:int) :bat[ :oid, :wkb]
+address geom_sfcgal_triangulate2DZ_bat
+comment "Triangulates a geometry collection";
diff --git a/geom/monetdb5/sfcgalBulk.c b/geom/monetdb5/sfcgalBulk.c
new file mode 100644
--- /dev/null
+++ b/geom/monetdb5/sfcgalBulk.c
@@ -0,0 +1,64 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ */
+
+/*
+ * Romulo Goncalves
+ */
+
+#include "sfcgal.h"
+
+/* triangulates geometry - BULK version*/
+str
+geom_sfcgal_triangulate2DZ_bat(bat *outBAT_id, bat *inBAT_id, int *flag)
+{
+ BAT *outBAT = NULL, *inBAT = NULL;
+ BUN p = 0, q = 0;
+ BATiter inBAT_iter;
+
+ //get the descriptor of the BAT
+ if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
+ throw(MAL, "batgeom.geom_sfcgal_triangle2DZ", "Problem
retrieving BAT");
+ }
+
+ if (!BAThdense(inBAT)) {
+ BBPunfix(inBAT->batCacheid);
+ throw(MAL, "batgeom.geom_sfcgal_triangle2DZ", "The BAT must
have dense head");
+ }
+ //create a new BAT for the output
+ if ((outBAT = BATnew(TYPE_void, ATOMindex("wkb"), BATcount(inBAT),
TRANSIENT)) == NULL) {
+ BBPunfix(inBAT->batCacheid);
+ throw(MAL, "batgeom.geom_sfcgal_triangle2DZ", "Error creating
new BAT");
+ }
+ //set the first idx of the output BAT equal to that of the input BAT
+ BATseqbase(outBAT, inBAT->hseqbase);
+
+ //iterator over the BATs
+ inBAT_iter = bat_iterator(inBAT);
+ BATloop(inBAT, p, q) {
+ str err = NULL;
+ wkb *outWKB = NULL;
+
+ wkb *inWKB = (wkb *) BUNtail(inBAT_iter, p);
+
+ if ((err = geom_sfcgal_triangulate2DZ(&outWKB, &inWKB, flag))
!= MAL_SUCCEED) {
+ BBPunfix(inBAT->batCacheid);
+ BBPunfix(outBAT->batCacheid);
+ return err;
+ }
+ if (outWKB) {
+ BUNappend(outBAT, outWKB, TRUE);
+ GDKfree(outWKB);
+ outWKB = NULL;
+ }
+ }
+
+ BBPunfix(inBAT->batCacheid);
+ BBPkeepref(*outBAT_id = outBAT->batCacheid);
+
+ return MAL_SUCCEED;
+}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list