Revision: 51601 http://brlcad.svn.sourceforge.net/brlcad/?rev=51601&view=rev Author: starseeker Date: 2012-07-19 20:22:38 +0000 (Thu, 19 Jul 2012) Log Message: ----------- Start adding some tests for tri_tri routines.
Modified Paths: -------------- brlcad/trunk/CMakeLists.txt brlcad/trunk/src/libbn/CMakeLists.txt Added Paths: ----------- brlcad/trunk/src/libbn/tests/ brlcad/trunk/src/libbn/tests/CMakeLists.txt brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c Modified: brlcad/trunk/CMakeLists.txt =================================================================== --- brlcad/trunk/CMakeLists.txt 2012-07-19 20:20:34 UTC (rev 51600) +++ brlcad/trunk/CMakeLists.txt 2012-07-19 20:22:38 UTC (rev 51601) @@ -1279,8 +1279,6 @@ CONFIG_H_APPEND(BRLCAD "#define DEBUG 1\n") endif(BRLCAD_FLAGS_DEBUG) - - # Build with compiler warning flags set(BRLCAD_ENABLE_COMPILER_WARNINGS_ALIASES ENABLE_WARNINGS @@ -1768,6 +1766,11 @@ set(CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT} /NOLOGO) endif(MSVC) +# Enable CTest Testing support - this is done after src/other is +# added to avoid incorporating src/other CTests into BRL-CAD's own +# testing. TODO - probably should control this with an option. +ENABLE_TESTING() + # We've done the toplevel configure steps, now add the subdirectories add_subdirectory(src) add_subdirectory(include) Modified: brlcad/trunk/src/libbn/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libbn/CMakeLists.txt 2012-07-19 20:20:34 UTC (rev 51600) +++ brlcad/trunk/src/libbn/CMakeLists.txt 2012-07-19 20:22:38 UTC (rev 51601) @@ -47,6 +47,8 @@ BRLCAD_ADDEXEC(bntester bntester.c "libbu;libbn" NO_INSTALL) +add_subdirectory(tests) + CMAKEFILES( Makefile.am README Added: brlcad/trunk/src/libbn/tests/CMakeLists.txt =================================================================== --- brlcad/trunk/src/libbn/tests/CMakeLists.txt (rev 0) +++ brlcad/trunk/src/libbn/tests/CMakeLists.txt 2012-07-19 20:22:38 UTC (rev 51601) @@ -0,0 +1,45 @@ +BRLCAD_ADDEXEC(tester_bn_coplanar_tri_tri_isect bn_coplanar_tri_tri_isect.c "libbu;libbn" NO_INSTALL LOCAL) +BRLCAD_ADDEXEC(tester_bn_tri_tri_isect bn_tri_tri_isect.c "libbu;libbn" NO_INSTALL LOCAL) + +# For tester_bn_coplanar_tri_tri_isect, the input format is as follows: +# +# tester_bn_coplanar_tri_tri_isect V0 V1 V2 U0 U1 U2 <area_flag> <expected result> +# +# where P and Q are the two triangles in question. An individual point +# is three integer or floating point numbers separated by commas. The area +# flag tells the function whether or not to require non-zero area for an +# overlap in coplanar cases. + +add_test(bn_coplanar_tri_tri_isect_null tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1.00001,0,0 2,0,0 1.00001,1,0 0 0) +add_test(bn_coplanar_tri_tri_isect_vertex tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1.00001,0,0 2,0,0 1,1,0 0 1) +add_test(bn_coplanar_tri_tri_isect_edge tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,0 2,0,0 1,1,0 0 1) +add_test(bn_coplanar_tri_tri_isect_full tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,0 2,0,0 0.7,0.8,0 0 1) +add_test(bn_coplanar_tri_tri_isect_null tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1.00001,0,0 2,0,0 1.00001,1,0 1 0) +add_test(bn_coplanar_tri_tri_isect_vertex tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1.00001,0,0 2,0,0 1,1,0 1 0) +add_test(bn_coplanar_tri_tri_isect_edge tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,0 2,0,0 1,1,0 1 0) +add_test(bn_coplanar_tri_tri_isect_full tester_bn_coplanar_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,0 2,0,0 0.7,0.8,0 1 1) + + + +# For tester_bn_tri_tri_isect, the input format is as follows: +# +# tester_bn_tri_tri_isect V0 V1 V2 U0 U1 U2 <expected result> +# +# where P and Q are the two triangles in question. An individual point +# is three integer or floating point numbers separated by commas. + +# Test coplanar triangles +add_test(bn_tri_tri_isect_coplanar_null tester_bn_tri_tri_isect 0,0,0 1,0,0 1,1,0 1.00001,0,0 2,0,0 1.00001,1,0 0) +add_test(bn_tri_tri_isect_coplanar_vertex tester_bn_tri_tri_isect 0,0,0 1,0,0 1,1,0 1.00001,0,0 2,0,0 1,1,0 1) +add_test(bn_tri_tri_isect_coplanar_edge tester_bn_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,0 2,0,0 1,1,0 1) +add_test(bn_tri_tri_isect_coplanar_full tester_bn_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,0 2,0,0 0.7,0.8,0 1) + +# Test more general triangles +add_test(bn_tri_tri_isect_null tester_bn_tri_tri_isect 0,0,0 1,0,0 1,1,0 1,0,1 1,0,1 1,1,1 0) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 textwidth=0 wrapmargin=0 Property changes on: brlcad/trunk/src/libbn/tests/CMakeLists.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c =================================================================== --- brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c (rev 0) +++ brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c 2012-07-19 20:22:38 UTC (rev 51601) @@ -0,0 +1,84 @@ +/* B N _ C O P L A N A R _ T R I _ T R I _ ISECT . C + * BRL-CAD + * + * Copyright (c) 2011-2012 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +#include "common.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "bu.h" +#include "bn.h" + + +int +main(int argc, char **argv) +{ + int expected_result = 0; + int actual_result = 0; + int area_flag = 0; + float f1, f2, f3 = 0.0; + point_t V0 = VINIT_ZERO; + point_t V1 = VINIT_ZERO; + point_t V2 = VINIT_ZERO; + point_t U0 = VINIT_ZERO; + point_t U1 = VINIT_ZERO; + point_t U2 = VINIT_ZERO; + + if (argc != 9) + bu_exit(1, "ERROR: input format is V0x,V0y,V0z V1x,V1y,V1z V2x,V2y,V2z U0x,U0y,U0z U1x,U1y,U1z U2x,U2y,U2z area_flag expected_result [%s]\n", argv[0]); + + sscanf(argv[1], "%f,%f,%f", &f1, &f2, &f3); + V0[0] = f1; V0[1] = f2; V0[2] = f3; + sscanf(argv[2], "%f,%f,%f", &f1, &f2, &f3); + V1[0] = f1; V1[1] = f2; V1[2] = f3; + sscanf(argv[3], "%f,%f,%f", &f1, &f2, &f3); + V2[0] = f1; V2[1] = f2; V2[2] = f3; + sscanf(argv[4], "%f,%f,%f", &f1, &f2, &f3); + U0[0] = f1; U0[1] = f2; U0[2] = f3; + sscanf(argv[5], "%f,%f,%f", &f1, &f2, &f3); + U1[0] = f1; U1[1] = f2; U1[2] = f3; + sscanf(argv[6], "%f,%f,%f", &f1, &f2, &f3); + U2[0] = f1; U2[1] = f2; U2[2] = f3; + sscanf(argv[7], "%d", &area_flag); + sscanf(argv[8], "%d", &expected_result); + + actual_result = bn_coplanar_tri_tri_isect(V0,V1,V2,U0,U1,U2,area_flag); + + bu_log("result: %d\n", actual_result); + + if(expected_result == actual_result) { + return 0; + } else { + return -1; + } +} + + +/** @} */ +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libbn/tests/bn_coplanar_tri_tri_isect.c ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c =================================================================== --- brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c (rev 0) +++ brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c 2012-07-19 20:22:38 UTC (rev 51601) @@ -0,0 +1,82 @@ +/* B N _ T R I _ T R I _ ISECT . C + * BRL-CAD + * + * Copyright (c) 2011-2012 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ + +#include "common.h" + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "bu.h" +#include "bn.h" + + +int +main(int argc, char **argv) +{ + int expected_result = 0; + int actual_result = 0; + float f1, f2, f3 = 0.0; + point_t V0 = VINIT_ZERO; + point_t V1 = VINIT_ZERO; + point_t V2 = VINIT_ZERO; + point_t U0 = VINIT_ZERO; + point_t U1 = VINIT_ZERO; + point_t U2 = VINIT_ZERO; + + if (argc != 8) + bu_exit(1, "ERROR: input format is V0x,V0y,V0z V1x,V1y,V1z V2x,V2y,V2z U0x,U0y,U0z U1x,U1y,U1z U2x,U2y,U2z expected_result [%s]\n", argv[0]); + + sscanf(argv[1], "%f,%f,%f", &f1, &f2, &f3); + V0[0] = f1; V0[1] = f2; V0[2] = f3; + sscanf(argv[2], "%f,%f,%f", &f1, &f2, &f3); + V1[0] = f1; V1[1] = f2; V1[2] = f3; + sscanf(argv[3], "%f,%f,%f", &f1, &f2, &f3); + V2[0] = f1; V2[1] = f2; V2[2] = f3; + sscanf(argv[4], "%f,%f,%f", &f1, &f2, &f3); + U0[0] = f1; U0[1] = f2; U0[2] = f3; + sscanf(argv[5], "%f,%f,%f", &f1, &f2, &f3); + U1[0] = f1; U1[1] = f2; U1[2] = f3; + sscanf(argv[6], "%f,%f,%f", &f1, &f2, &f3); + U2[0] = f1; U2[1] = f2; U2[2] = f3; + sscanf(argv[7], "%d", &expected_result); + + actual_result = bn_tri_tri_isect(V0,V1,V2,U0,U1,U2); + + bu_log("result: %d\n", actual_result); + + if(expected_result == actual_result) { + return 0; + } else { + return -1; + } +} + + +/** @} */ +/* + * Local Variables: + * mode: C + * tab-width: 8 + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libbn/tests/bn_tri_tri_isect.c ___________________________________________________________________ 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. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits