summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt135
-rw-r--r--tests/csgtestcore.cc21
-rw-r--r--tests/regression/cgalpngtest/cylinder-tests-expected.pngbin12498 -> 11017 bytes
-rw-r--r--tests/regression/dumptest/cylinder-tests-expected.txt3
-rw-r--r--tests/regression/opencsgtest/cylinder-tests-expected.pngbin13165 -> 11612 bytes
-rw-r--r--tests/regression/throwntogethertest/cylinder-tests-expected.pngbin8670 -> 11612 bytes
6 files changed, 90 insertions, 69 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b374188..21cee6b 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -64,43 +64,64 @@ endif()
# Build test apps
#
+function(inclusion user_set_path found_paths)
+ # This function exists as a wrapper for INCLUDE_DIRECTORIES
+ # to deal with systems in which some libraries are found
+ # in the system paths, (/usr) but others are found in customized
+ # paths set in environment variables (CGAL_DIR).
+ # message(STATUS "inclusion ${user_set_path} ${found_paths}")
+ # message(STATUS "inclusion ${${user_set_path}} ${${found_paths}}")
+ set( inclusion_match 0 )
+ foreach( found_path ${${found_paths}} )
+ if (${found_path} MATCHES ${${user_set_path}}.*)
+ set( inclusion_match 1 )
+ endif()
+ endforeach()
+ if (user_set_path AND inclusion_match)
+ include_directories(BEFORE ${${found_paths}})
+ # message(STATUS "inclusion prepend ${${found_paths}} for ${user_set_path}")
+ else()
+ include_directories(AFTER ${${found_paths}})
+ # message(STATUS "inclusion append ${${found_paths}} for ${user_set_path}")
+ endif()
+ set( inclusion_match 0 )
+endfunction()
+
# Boost
+# Update this if FindBoost.cmake gets out of sync with the current boost release
+# set(Boost_ADDITIONAL_VERSIONS "1.47.0" "1.46.0")
+
+if (WIN32)
+ set(Boost_USE_STATIC_LIBS TRUE)
+ set(BOOST_STATIC TRUE)
+ set(BOOST_THREAD_USE_LIB TRUE)
+endif()
+
if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
set(BOOST_ROOT "$ENV{OPENSCAD_LIBRARIES}")
+ if (EXISTS ${BOOST_ROOT}/include/boost)
+ # if boost is under OPENSCAD_LIBRARIES, then
+ # don't look in the system paths (workaround FindBoost.cmake bug)
+ set(Boost_NO_SYSTEM_PATHS "TRUE")
+ message(STATUS "BOOST_ROOT: " ${BOOST_ROOT})
+ endif()
endif()
if (NOT $ENV{BOOSTDIR} STREQUAL "")
- set(BOOST_DIR "$ENV{BOOSTDIR}")
-endif()
-
-if (NOT ${BOOST_DIR} STREQUAL "")
- set(BOOST_ROOT ${BOOST_DIR})
- message(STATUS "BOOST_ROOT: " ${BOOST_ROOT})
+ set(BOOST_ROOT "$ENV{BOOSTDIR}")
set(Boost_NO_SYSTEM_PATHS "TRUE")
set(Boost_DEBUG TRUE)
+ message(STATUS "BOOST_ROOT: " ${BOOST_ROOT})
endif()
-
-if (WIN32)
- set(Boost_USE_STATIC_LIBS TRUE)
- set(BOOST_STATIC TRUE)
- set(BOOST_THREAD_USE_LIB TRUE)
-endif()
-
-# Update this if FindBoost.cmake gets out of sync with the current boost release
-# set(Boost_ADDITIONAL_VERSIONS "1.47.0" "1.46.0")
find_package( Boost 1.35.0 COMPONENTS thread program_options REQUIRED)
-if(Boost_FOUND)
- message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS})
- message(STATUS "Boost libraries found:")
- foreach(boostlib ${Boost_LIBRARIES})
- message(STATUS " " ${boostlib})
- endforeach()
- include_directories(${Boost_INCLUDE_DIRS})
-else()
- message(STATUS "BOOST_ROOT: ${BOOST_ROOT}")
- message(FATAL_ERROR "Boost not found.")
-endif()
+message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS})
+message(STATUS "Boost libraries found:")
+foreach(boostlib ${Boost_LIBRARIES})
+ message(STATUS " " ${boostlib})
+endforeach()
+
+inclusion(BOOST_ROOT Boost_INCLUDE_DIRS)
# Mac OS X
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -109,18 +130,11 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Qt4
-if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- # make /usr/local/include/qt4 come before /usr/local/include (QT4 vs QT3)
- set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
-endif()
-
+set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
find_package(OpenGL REQUIRED)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
include(${QT_USE_FILE})
-
-if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
-endif()
+set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
# Eigen2
@@ -131,24 +145,32 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
endif()
+if (NOT $ENV{EIGEN2DIR} STREQUAL "")
+ set(EIGEN2_DIR "$ENV{EIGEN2DIR}")
+elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
+ set(EIGEN2_DIR "$ENV{OPENSCAD_LIBRARIES}")
+endif()
+
if (NOT EIGEN2_INCLUDE_DIR)
+ if (EIGEN2_DIR)
+ set(EIGEN2_FIND_HINTS "${EIGEN2_DIR}/include/eigen2")
+ endif()
+ if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+ set(EIGEN2_FIND_PATHS /usr/local/include/eigen2)
+ else()
+ set(EIGEN2_FIND_PATHS /opt/local/include/eigen2 /usr/include/eigen2)
+ endif()
find_path(EIGEN2_INCLUDE_DIR
Eigen/Core
- HINTS $ENV{EIGEN2DIR}
- PATHS /opt/local/include/eigen2 /usr/include/eigen2)
- if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- find_path(EIGEN2_INCLUDE_DIR
- Eigen/Core
- HINTS $ENV{EIGEN2DIR}
- PATHS /usr/local/include/eigen2 )
- endif()
+ HINTS ${EIGEN2_FIND_HINTS}
+ PATHS ${EIGEN2_FIND_PATHS})
if (NOT EIGEN2_INCLUDE_DIR)
message(FATAL_ERROR "Eigen2 not found")
else()
message(STATUS "Eigen2 found in " ${EIGEN2_INCLUDE_DIR})
endif()
endif()
-include_directories(${EIGEN2_INCLUDE_DIR})
+inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR)
# OpenCSG
if (NOT $ENV{OPENCSGDIR} STREQUAL "")
@@ -171,10 +193,14 @@ if (NOT OPENCSG_INCLUDE_DIR)
message(STATUS "OpenCSG library found in " ${OPENCSG_LIBRARY})
endif()
endif()
-include_directories(${OPENCSG_INCLUDE_DIR})
+inclusion(OPENCSG_DIR OPENCSG_INCLUDE_DIR)
# GLEW
+if(WIN32_STATIC_BUILD)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLEW_STATIC")
+endif()
+
if (NOT $ENV{GLEWDIR} STREQUAL "")
set(GLEW_DIR "$ENV{GLEWDIR}")
elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
@@ -182,11 +208,8 @@ elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
endif()
find_package(GLEW REQUIRED)
-include_directories(${GLEW_INCLUDE_PATH})
-if(WIN32_STATIC_BUILD)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLEW_STATIC")
-endif()
+inclusion( GLEW_DIR GLEW_INCLUDE_PATH )
# Flex/Bison
find_package(BISON REQUIRED)
@@ -211,8 +234,13 @@ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c PROPERTIES
if (NOT $ENV{CGALDIR} STREQUAL "")
set(CGAL_DIR "$ENV{CGALDIR}")
elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
- set(CGAL_DIR "$ENV{OPENSCAD_LIBRARIES}/lib/CGAL")
- set(CMAKE_MODULE_PATH "${CGAL_DIR}")
+ if (EXISTS "$ENV{OPENSCAD_LIBRARIES}/lib/CGAL")
+ set(CGAL_DIR "$ENV{OPENSCAD_LIBRARIES}/lib/CGAL")
+ set(CMAKE_MODULE_PATH "${CGAL_DIR}")
+ elseif (EXISTS "$ENV{OPENSCAD_LIBRARIES}/include/CGAL")
+ set(CGAL_DIR "$ENV{OPENSCAD_LIBRARIES}")
+ set(CMAKE_MODULE_PATH "${CGAL_DIR}")
+ endif()
endif()
message(STATUS "CGAL_DIR: " ${CGAL_DIR})
find_package(CGAL REQUIRED)
@@ -224,7 +252,7 @@ message(STATUS "CGAL libraries found in " ${CGAL_LIBRARIES_DIR} )
if("${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}" VERSION_LESS 3.6)
message(FATAL_ERROR "CGAL >= 3.6 required")
endif()
-include_directories(${CGAL_INCLUDE_DIRS})
+inclusion(CGAL_DIR CGAL_INCLUDE_DIRS)
# Imagemagick
@@ -253,6 +281,7 @@ set(CORE_SOURCES
../src/node.cc
../src/context.cc
../src/csgterm.cc
+ ../src/csgtermnormalizer.cc
../src/polyset.cc
../src/csgops.cc
../src/transform.cc
@@ -453,8 +482,8 @@ endfunction()
# comparison method to use
if (NOT $ENV{COMPARATOR} STREQUAL "")
set(COMPARATOR "$ENV{COMPARATOR}")
+ message(STATUS "ImageMagick method modified with COMPARATOR: " ${COMPARATOR})
endif()
-message(STATUS "COMPARATOR: " ${COMPARATOR})
#
# This functions adds cmd-line tests given files.
diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc
index c2be326..e8a6878 100644
--- a/tests/csgtestcore.cc
+++ b/tests/csgtestcore.cc
@@ -19,6 +19,7 @@
#include "ThrownTogetherRenderer.h"
#include "csgterm.h"
+#include "csgtermnormalizer.h"
#include "OffscreenView.h"
#include <QApplication>
@@ -315,12 +316,8 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
}
// CSG normalization
- csgInfo.root_norm_term = root_raw_term;
- while (1) {
- shared_ptr<CSGTerm> n = CSGTerm::normalize(csgInfo.root_norm_term);
- if (csgInfo.root_norm_term == n) break;
- csgInfo.root_norm_term = n;
- }
+ CSGTermNormalizer normalizer;
+ csgInfo.root_norm_term = normalizer.normalize(root_raw_term);
assert(csgInfo.root_norm_term);
@@ -333,11 +330,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
csgInfo.highlights_chain = new CSGChain();
for (unsigned int i = 0; i < csgInfo.highlight_terms.size(); i++) {
- while (1) {
- shared_ptr<CSGTerm> n = CSGTerm::normalize(csgInfo.highlight_terms[i]);
- if (csgInfo.highlight_terms[i] == n) break;
- csgInfo.highlight_terms[i] = n;
- }
+ csgInfo.highlight_terms[i] = normalizer.normalize(csgInfo.highlight_terms[i]);
csgInfo.highlights_chain->import(csgInfo.highlight_terms[i]);
}
}
@@ -347,11 +340,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)
csgInfo.background_chain = new CSGChain();
for (unsigned int i = 0; i < csgInfo.background_terms.size(); i++) {
- while (1) {
- shared_ptr<CSGTerm> n = CSGTerm::normalize(csgInfo.background_terms[i]);
- if (csgInfo.background_terms[i] == n) break;
- csgInfo.background_terms[i] = n;
- }
+ csgInfo.background_terms[i] = normalizer.normalize(csgInfo.background_terms[i]);
csgInfo.background_chain->import(csgInfo.background_terms[i]);
}
}
diff --git a/tests/regression/cgalpngtest/cylinder-tests-expected.png b/tests/regression/cgalpngtest/cylinder-tests-expected.png
index 9d96df2..843d70f 100644
--- a/tests/regression/cgalpngtest/cylinder-tests-expected.png
+++ b/tests/regression/cgalpngtest/cylinder-tests-expected.png
Binary files differ
diff --git a/tests/regression/dumptest/cylinder-tests-expected.txt b/tests/regression/dumptest/cylinder-tests-expected.txt
index 2ac2549..b1e8b6e 100644
--- a/tests/regression/dumptest/cylinder-tests-expected.txt
+++ b/tests/regression/dumptest/cylinder-tests-expected.txt
@@ -29,4 +29,7 @@
multmatrix([[1, 0, 0, 22], [0, 1, 0, 11], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cylinder($fn = 0, $fa = 12, $fs = 2, h = 15, r1 = 5, r2 = 5, center = false);
}
+ multmatrix([[1, 0, 0, -10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
+ cylinder($fn = 6, $fa = 12, $fs = 2, h = 2, r1 = 3, r2 = 3, center = false);
+ }
diff --git a/tests/regression/opencsgtest/cylinder-tests-expected.png b/tests/regression/opencsgtest/cylinder-tests-expected.png
index 17c10b8..4c7ab79 100644
--- a/tests/regression/opencsgtest/cylinder-tests-expected.png
+++ b/tests/regression/opencsgtest/cylinder-tests-expected.png
Binary files differ
diff --git a/tests/regression/throwntogethertest/cylinder-tests-expected.png b/tests/regression/throwntogethertest/cylinder-tests-expected.png
index 0a3ed33..4c7ab79 100644
--- a/tests/regression/throwntogethertest/cylinder-tests-expected.png
+++ b/tests/regression/throwntogethertest/cylinder-tests-expected.png
Binary files differ
contact: Jan Huwald // Impressum