Revision: 54502
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54502&view=rev
Author:   indianlarry
Date:     2013-02-27 17:16:57 +0000 (Wed, 27 Feb 2013)
Log Message:
-----------
Split 'utils' class into declaration and definition files utils.h and utils.cc. 
Also added cmake changes for integration into BRL-CAD build.

Modified Paths:
--------------
    brlcad/trunk/src/other/CMakeLists.txt
    brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.h

Added Paths:
-----------
    brlcad/trunk/src/other/poly2tri/CMakeLists.txt
    brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.cc
    brlcad/trunk/src/other/poly2tri.dist

Modified: brlcad/trunk/src/other/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/other/CMakeLists.txt       2013-02-27 16:31:45 UTC (rev 
54501)
+++ brlcad/trunk/src/other/CMakeLists.txt       2013-02-27 17:16:57 UTC (rev 
54502)
@@ -890,6 +890,19 @@
   set(ADAPTAGRAMS_FOUND "${ADAPTAGRAMS_FOUND}" CACHE BOOL "Adaptagrams status" 
FORCE) 
 endif(BRLCAD_LEVEL2)
 
+# Poly2Tri CDT library
+if(BRLCAD_LEVEL2)
+  add_subdirectory(poly2tri)
+  include(${CMAKE_CURRENT_SOURCE_DIR}/poly2tri.dist)
+  CMAKEFILES_IN_DIR(poly2tri_ignore_files poly2tri)
+  DISTCLEAN(${CMAKE_CURRENT_SOURCE_DIR}/poly2tri/Makefile)
+  set(P2T_LIBRARY "p2t" CACHE STRING "Poly2Tri library" FORCE)
+  set(P2T_INCLUDE_DIR "${BRLCAD_SOURCE_DIR}/src/other/poly2tri" CACHE STRING 
"Directory containing poly2tri header" FORCE)
+  mark_as_advanced(P2T_LIBRARY)
+  mark_as_advanced(P2T_INCLUDE_DIR)
+else(BRLCAD_LEVEL2)
+  CMAKEFILES(poly2tri)
+endif(BRLCAD_LEVEL2)
 
 # The jama/tnt headers are installed by default - BRL-CAD requires the
 # altered headers to build (I think?)

Added: brlcad/trunk/src/other/poly2tri/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/other/poly2tri/CMakeLists.txt                              
(rev 0)
+++ brlcad/trunk/src/other/poly2tri/CMakeLists.txt      2013-02-27 17:16:57 UTC 
(rev 54502)
@@ -0,0 +1,123 @@
+# Minimum required version of CMake
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+IF(COMMAND CMAKE_POLICY)
+  CMAKE_POLICY(SET CMP0003 NEW)
+ENDIF(COMMAND CMAKE_POLICY)
+
+# Set CMake project name
+PROJECT(Poly2Tri)
+##enable_testing()
+
+# SET LIBNAME
+set(P2T_LIB_NAME p2t)
+
+# COMMAND LINE OPTIONS
+if(DEFINED P2T_SHARED)
+  option(P2T_SHARED "Build shared lib" ${PNG_SHARED})
+else()
+  option(P2T_SHARED "Build shared lib" ON)
+endif()
+if(DEFINED P2T_STATIC)
+  option(P2T_STATIC "Build static lib" ${PNG_STATIC})
+else()
+  option(P2T_STATIC "Build static lib" ON)
+endif()
+
+##option(P2T_TESTS  "Build libp2t tests" NO)
+# Testing option
+OPTION_WITH_DEFAULT(P2T_TESTS  "Build libp2t tests" NO)
+IF(P2T_TESTS)
+  INCLUDE(CTest)
+  ENABLE_TESTING()
+ENDIF(P2T_TESTS)
+
+INCLUDE_DIRECTORIES(
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  )
+
+set(LIBP2T_SOURCES
+       poly2tri/common/shapes.cc
+       poly2tri/common/utils.cc
+       poly2tri/sweep/advancing_front.cc
+       poly2tri/sweep/cdt.cc
+       poly2tri/sweep/sweep_context.cc
+       poly2tri/sweep/sweep.cc
+)
+set(LIBP2T_TEST_SOURCES
+  testbed/main.cc
+)
+
+IF(NOT LIB_DIR)
+    SET(LIB_DIR lib)
+ENDIF(NOT LIB_DIR)
+IF(NOT BIN_DIR)
+    SET(BIN_DIR bin)
+ENDIF(NOT BIN_DIR)
+
+IF(MSVC)
+  add_definitions("-DP2T_DLL_EXPORTS")
+ENDIF(MSVC)
+add_definitions("-DP2T_NO_GLFW")
+
+if(P2T_SHARED)
+  add_library(${P2T_LIB_NAME} SHARED ${LIBP2T_SOURCES})
+  if(MSVC)
+    # msvc does not append 'lib' - do it here to have consistent name
+    set_target_properties(${P2T_LIB_NAME} PROPERTIES PREFIX "lib")
+    set_target_properties(${P2T_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
+  endif()
+  target_link_libraries(${P2T_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
+  install(TARGETS ${P2T_LIB_NAME}
+       RUNTIME DESTINATION ${BIN_DIR}
+       LIBRARY DESTINATION ${LIB_DIR}
+       ARCHIVE DESTINATION ${LIB_DIR})
+
+endif()
+
+if(P2T_STATIC)
+# does not work without changing name
+  set(P2T_LIB_NAME_STATIC ${P2T_LIB_NAME}_static)
+  add_library(${P2T_LIB_NAME_STATIC} STATIC ${LIBP2T_SOURCES})
+  if(MSVC)
+    # msvc does not append 'lib' - do it here to have consistent name
+    set_target_properties(${P2T_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
+  endif()
+  target_link_libraries(${P2T_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
+  install(TARGETS ${P2T_LIB_NAME_STATIC}
+       RUNTIME DESTINATION ${BIN_DIR}
+       LIBRARY DESTINATION ${LIB_DIR}
+       ARCHIVE DESTINATION ${LIB_DIR})
+endif()
+
+if(P2T_SHARED AND WIN32)
+  set_target_properties(${P2T_LIB_NAME} PROPERTIES DEFINE_SYMBOL P2T_BUILD_DLL)
+endif()
+
+##if(P2T_TESTS)
+##  if(P2T_STATIC)
+##    add_executable(p2t-test ${LIBP2T_TEST_SOURCES})
+##    target_link_libraries(p2t-test ${P2T_LIB_NAME_STATIC})
+##    add_test(p2t-test ./p2t-test ${CMAKE_CURRENT_SOURCE_DIR}/DATA/bird.dat)
+##  else()
+##    add_executable(p2t-test ${LIBP2T_TEST_SOURCES})
+##    target_link_libraries(p2t-test ${P2T_LIB_NAME})
+##    add_test(p2t-test ./p2t-test ${CMAKE_CURRENT_SOURCE_DIR}/DATA/bird.dat)
+##  endif()
+##endif()
+
+install(FILES poly2tri/poly2tri.h DESTINATION include/poly2tri)
+install(FILES poly2tri/common/shapes.h DESTINATION include/poly2tri/common)
+install(FILES poly2tri/common/utils.h DESTINATION include/poly2tri/common)
+install(FILES poly2tri/sweep/cdt.h DESTINATION include/poly2tri/sweep)
+
+
+
+
+
+
+
+
+
+
+
+


Property changes on: brlcad/trunk/src/other/poly2tri/CMakeLists.txt
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.cc
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.cc                    
        (rev 0)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.cc    2013-02-27 
17:16:57 UTC (rev 54502)
@@ -0,0 +1,91 @@
+
+// Otherwise #defines like M_PI are undeclared under Visual Studio
+#define _USE_MATH_DEFINES
+
+#include <exception>
+#ifdef WIN32
+# define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#include <float.h>
+#include "shapes.h"
+#include "utils.h"
+
+namespace p2t {
+
+const double PI_3div4 = 3 * M_PI / 4;
+const double PI_div2 = 1.57079632679489661923;
+const double EPSILON = DBL_MIN;
+
+/**
+ * Forumla to calculate signed area<br>
+ * Positive if CCW<br>
+ * Negative if CW<br>
+ * 0 if collinear<br>
+ * <pre>
+ * A[P1,P2,P3]  =  (x1*y2 - y1*x2) + (x2*y3 - y2*x3) + (x3*y1 - y3*x1)
+ *              =  (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
+ * </pre>
+ */
+Orientation Orient2d(Point& pa, Point& pb, Point& pc)
+{
+  double detleft = (pa.x - pc.x) * (pb.y - pc.y);
+  double detright = (pa.y - pc.y) * (pb.x - pc.x);
+  double val = detleft - detright;
+  if (val > -EPSILON && val < EPSILON) {
+    return COLLINEAR;
+  } else if (val > 0) {
+    return CCW;
+  }
+  return CW;
+}
+
+/*
+bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
+{
+  double pdx = pd.x;
+  double pdy = pd.y;
+  double adx = pa.x - pdx;
+  double ady = pa.y - pdy;
+  double bdx = pb.x - pdx;
+  double bdy = pb.y - pdy;
+
+  double adxbdy = adx * bdy;
+  double bdxady = bdx * ady;
+  double oabd = adxbdy - bdxady;
+
+  if (oabd <= EPSILON) {
+    return false;
+  }
+
+  double cdx = pc.x - pdx;
+  double cdy = pc.y - pdy;
+
+  double cdxady = cdx * ady;
+  double adxcdy = adx * cdy;
+  double ocad = cdxady - adxcdy;
+
+  if (ocad <= EPSILON) {
+    return false;
+  }
+
+  return true;
+}
+
+*/
+
+bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
+{
+  double oadb = (pa.x - pb.x)*(pd.y - pb.y) - (pd.x - pb.x)*(pa.y - pb.y);
+  if (oadb >= -EPSILON) {
+    return false;
+  }
+
+  double oadc = (pa.x - pc.x)*(pd.y - pc.y) - (pd.x - pc.x)*(pa.y - pc.y);
+  if (oadc <= EPSILON) {
+    return false;
+  }
+  return true;
+}
+
+}


Property changes on: brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.cc
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.h
===================================================================
--- brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.h     2013-02-27 
16:31:45 UTC (rev 54501)
+++ brlcad/trunk/src/other/poly2tri/poly2tri/common/utils.h     2013-02-27 
17:16:57 UTC (rev 54502)
@@ -32,17 +32,12 @@
 #ifndef UTILS_H
 #define UTILS_H
 
-// Otherwise #defines like M_PI are undeclared under Visual Studio
-#define _USE_MATH_DEFINES
-
-#include <exception>
-#include <math.h>
-
 namespace p2t {
 
-const double PI_3div4 = 3 * M_PI / 4;
-const double PI_div2 = 1.57079632679489661923;
-const double EPSILON = 1e-12;
+struct Point;
+extern const double PI_3div4;
+extern const double PI_div2;
+extern const double EPSILON;
 
 enum Orientation { CW, CCW, COLLINEAR };
 
@@ -56,67 +51,8 @@
  *              =  (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
  * </pre>
  */
-Orientation Orient2d(Point& pa, Point& pb, Point& pc)
-{
-  double detleft = (pa.x - pc.x) * (pb.y - pc.y);
-  double detright = (pa.y - pc.y) * (pb.x - pc.x);
-  double val = detleft - detright;
-  if (val > -EPSILON && val < EPSILON) {
-    return COLLINEAR;
-  } else if (val > 0) {
-    return CCW;
-  }
-  return CW;
+extern Orientation Orient2d(Point& pa, Point& pb, Point& pc);
+extern bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd);
 }
 
-/*
-bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
-{
-  double pdx = pd.x;
-  double pdy = pd.y;
-  double adx = pa.x - pdx;
-  double ady = pa.y - pdy;
-  double bdx = pb.x - pdx;
-  double bdy = pb.y - pdy;
-
-  double adxbdy = adx * bdy;
-  double bdxady = bdx * ady;
-  double oabd = adxbdy - bdxady;
-
-  if (oabd <= EPSILON) {
-    return false;
-  }
-
-  double cdx = pc.x - pdx;
-  double cdy = pc.y - pdy;
-
-  double cdxady = cdx * ady;
-  double adxcdy = adx * cdy;
-  double ocad = cdxady - adxcdy;
-
-  if (ocad <= EPSILON) {
-    return false;
-  }
-
-  return true;
-}
-
-*/
-
-bool InScanArea(Point& pa, Point& pb, Point& pc, Point& pd)
-{
-  double oadb = (pa.x - pb.x)*(pd.y - pb.y) - (pd.x - pb.x)*(pa.y - pb.y);
-  if (oadb >= -EPSILON) {
-    return false;
-  }
-
-  double oadc = (pa.x - pc.x)*(pd.y - pc.y) - (pd.x - pc.x)*(pa.y - pc.y);
-  if (oadc <= EPSILON) {
-    return false;
-  }
-  return true;
-}
-
-}
-
 #endif
\ No newline at end of file

Added: brlcad/trunk/src/other/poly2tri.dist
===================================================================
--- brlcad/trunk/src/other/poly2tri.dist                                (rev 0)
+++ brlcad/trunk/src/other/poly2tri.dist        2013-02-27 17:16:57 UTC (rev 
54502)
@@ -0,0 +1,6 @@
+set(libp2t_ignored_files
+       AUTHORS
+       LICENSE
+       README
+       testbed
+         )
\ No newline at end of file


Property changes on: brlcad/trunk/src/other/poly2tri.dist
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to