[Ptinpoly-commits] r27 - in pkg: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Aug 3 20:53:11 CEST 2014


Author: jmaisog
Date: 2014-08-03 20:53:11 +0200 (Sun, 03 Aug 2014)
New Revision: 27

Modified:
   pkg/DESCRIPTION
   pkg/src/kodtree.cc
   pkg/src/pinpolyhedronA.cc
Log:
(1) Catch exception thrown in 2D case.
(2) Fixed DESCRIPTION file.
(3) After deleting pcell, explicitly set pcell to 0. Some compilers may not do this.

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2014-05-08 09:11:48 UTC (rev 26)
+++ pkg/DESCRIPTION	2014-08-03 18:53:11 UTC (rev 27)
@@ -1,13 +1,12 @@
 Package: ptinpoly
 Title: Point-In-Polyhedron Test (2D and 3D)
-Version: 2.2
-Date: 2014-05-07
+Version: 2.3
+Date: 2014-08-03
 Author: Jose M. Maisog, Yuan Wang, George Luta, Jianfei Liu
 Maintainer: Jose M. Maisog <bravas02 at gmail.com>
-Description: This library provides a function 'pip3d', which tests whether a point in 3D space is
-        within, exactly on, or outside an enclosed surface defined by a triangular mesh.
-		Also provided is a 2D version, 'pip2d', which tests whether a point in 2D space is
-		within, exactly on, or outside a polygon.
+Description: Function 'pip3d' tests whether a point in 3D space is
+  within, exactly on, or outside an enclosed surface defined by a triangular mesh.
+  Function 'pip2d' tests whether a point in 2D space is within, exactly on, or outside a polygon.
 License: GPL-2
 LazyLoad: yes
 Depends: misc3d

Modified: pkg/src/kodtree.cc
===================================================================
--- pkg/src/kodtree.cc	2014-05-08 09:11:48 UTC (rev 26)
+++ pkg/src/kodtree.cc	2014-08-03 18:53:11 UTC (rev 27)
@@ -447,6 +447,10 @@
 	for(int i=0; i<2; i++)
 		freeSubTree(pcell->child[i]);
 	delete pcell;
+	// JMM : 8/3/2014 : This shouldn't be necessary, since
+	// pcell shouldn't be used after it is deleted.
+	// But set pcell to 0 after deleting just in case.
+    pcell=0;
 }
 
 

Modified: pkg/src/pinpolyhedronA.cc
===================================================================
--- pkg/src/pinpolyhedronA.cc	2014-05-08 09:11:48 UTC (rev 26)
+++ pkg/src/pinpolyhedronA.cc	2014-08-03 18:53:11 UTC (rev 27)
@@ -1871,6 +1871,10 @@
 	for(int i=0; i<4; i++)
 		freeSubQuadtree(pcell->child[i]);
 	delete pcell;
+	// JMM : 8/3/2014 : This shouldn't be necessary, since
+	// pcell shouldn't be used after it is deleted.
+	// But set pcell to 0 after deleting just in case.
+    pcell=0;
 }
 
 CellNode2D ::CellNode2D(double bd[4]){
@@ -1938,11 +1942,19 @@
 
     // Loop over queries, feed them to the Jianfei method.
     // Don't forget about the minX, minY, and minZ shifts.
+    //
+    // JMM (8/3/2014): Use TRY-CATCH to catch computational
+    // errors and set RESULT[I] accordingly.
     double q[2]={0,0};
     for( i=0; i<(*numQ); i++) {
-        q[0]      = query[i+0*(*numQ)] - minX;
-        q[1]      = query[i+1*(*numQ)] - minY;
-        result[i] = ptpoly->isPinpolygon(q);
+        q[0] = query[i+0*(*numQ)] - minX;
+        q[1] = query[i+1*(*numQ)] - minY;
+        try {
+            result[i] = ptpoly->isPinpolygon(q);
+        }
+        catch (...) {
+            result[i] = -8;
+        }
     }
 
     // RELEASE MEMORY!!



More information about the Ptinpoly-commits mailing list