diff options
-rwxr-xr-x | scripts/builder.sh | 18 | ||||
-rw-r--r-- | src/CGALEvaluator.cc | 10 | ||||
-rw-r--r-- | src/cgaladv.cc | 2 | ||||
-rw-r--r-- | src/func.cc | 27 | ||||
-rw-r--r-- | testdata/scad/features/resize-tests.scad | 31 | ||||
-rw-r--r-- | testdata/scad/functions/rands.scad | 35 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 8 | ||||
-rwxr-xr-x | tests/echotest | 3 |
8 files changed, 99 insertions, 35 deletions
diff --git a/scripts/builder.sh b/scripts/builder.sh index b00919f..38a235e 100755 --- a/scripts/builder.sh +++ b/scripts/builder.sh @@ -96,11 +96,12 @@ upload_win_generic() opts="$opts $filename" if [ $DRYRUN ]; then echo dry run, not uploading to googlecode - echo cmd - python ./scripts/googlecode_upload.py -s '"'$summary'"' $opts + echo google-code upload is disabled / deprecated echo dry run, not uploading to files.openscad.org echo scp -v $filename openscad@files.openscad.org:www/ else - python ./scripts/googlecode_upload.py -s "$summary" $opts + echo google-code upload is disabled / deprecated + # python ./scripts/googlecode_upload.py -s "$summary" $opts scp -v $filename openscad@files.openscad.org:www/ fi } @@ -147,15 +148,24 @@ upload_win64() read_username_from_user() { if [ $DRYRUN ]; then USERNAME=none;export USERNAME; return; fi + echo 'Google code upload is deprecated' + USERNAME=$USER + echo 'username is ' $USERNAME + return + echo 'Please enter your username for https://code.google.com/hosting/settings' echo -n 'Username:' read USERNAME echo 'username is ' $USERNAME + return } read_password_from_user() { if [ $DRYRUN ]; then return; fi + echo 'Google code upload is deprecated' + return + echo 'Please enter your password for https://code.google.com/hosting/settings' echo -n 'Password:' read -s PASSWORD1 @@ -178,8 +188,8 @@ update_win_www_download_links() cd openscad.github.com cd inc echo `pwd` - BASEURL='https://openscad.googlecode.com/files/' - # BASEURL='http://files.openscad.org' + # BASEURL='https://openscad.googlecode.com/files/' + BASEURL='http://files.openscad.org/' DATECODE=`date +"%Y.%m.%d"` rm win_snapshot_links.js diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 8e1b5eb..adaec4a 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -215,20 +215,24 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node) bbox_size.push_back( bb.xmax()-bb.xmin() ); bbox_size.push_back( bb.ymax()-bb.ymin() ); bbox_size.push_back( bb.zmax()-bb.zmin() ); + int newsizemax_index = 0; for (int i=0;i<3;i++) { if (node.newsize[i]) { if (bbox_size[i]==NT3(0)) { - PRINT("WARNING: Cannot resize in direction normal to flat object"); + PRINT("WARNING: Resize in direction normal to flat object is not implemented"); return N; } else { scale[i] = NT3(node.newsize[i]) / bbox_size[i]; } + if ( node.newsize[i] > node.newsize[newsizemax_index] ) + newsizemax_index = i; } } - NT3 autoscale = std::max( scale[0], std::max( scale[1], scale[2] )); + NT3 autoscale = NT3( node.newsize[ newsizemax_index ] ) / bbox_size[ newsizemax_index ]; for (int i=0;i<3;i++) { - if (node.autosize[i]) scale[i] = autoscale; + if (node.autosize[i] && node.newsize[i]==0) + scale[i] = autoscale; } Eigen::Matrix4d t; diff --git a/src/cgaladv.cc b/src/cgaladv.cc index ee3d657..8fd030a 100644 --- a/src/cgaladv.cc +++ b/src/cgaladv.cc @@ -98,7 +98,7 @@ AbstractNode *CgaladvModule::instantiate(const Context *ctx, const ModuleInstant if ( va.size() >= 3 ) node->autosize[2] = va[2].toBool(); } else if ( autosize.type() == Value::BOOL ) { - node->autosize << true, true, true; + node->autosize << autosize.toBool(),autosize.toBool(),autosize.toBool(); } } diff --git a/src/func.cc b/src/func.cc index eaaae74..20f487a 100644 --- a/src/func.cc +++ b/src/func.cc @@ -153,10 +153,10 @@ Value builtin_rands(const Context *, const EvalContext *evalctx) deterministic = false; } else if (evalctx->numArgs() == 4 && - evalctx->getArgValue(0).type() == Value::NUMBER && - evalctx->getArgValue(1).type() == Value::NUMBER && - evalctx->getArgValue(2).type() == Value::NUMBER && - evalctx->getArgValue(3).type() == Value::NUMBER) + evalctx->getArgValue(0).type() == Value::NUMBER && + evalctx->getArgValue(1).type() == Value::NUMBER && + evalctx->getArgValue(2).type() == Value::NUMBER && + evalctx->getArgValue(3).type() == Value::NUMBER) { deterministic_rng.seed( (unsigned int) evalctx->getArgValue(3).toDouble() ); deterministic = true; @@ -165,19 +165,24 @@ Value builtin_rands(const Context *, const EvalContext *evalctx) { return Value(); } - + double min = std::min( evalctx->getArgValue(0).toDouble(), evalctx->getArgValue(1).toDouble() ); double max = std::max( evalctx->getArgValue(0).toDouble(), evalctx->getArgValue(1).toDouble() ); + size_t numresults = std::max( 0, static_cast<int>( evalctx->getArgValue(2).toDouble() ) ); boost::uniform_real<> distributor( min, max ); Value::VectorType vec; - for (int i=0; i<evalctx->getArgValue(2).toDouble(); i++) { - if ( deterministic ) { - vec.push_back( Value( distributor( deterministic_rng ) ) ); - } else { - vec.push_back( Value( distributor( lessdeterministic_rng ) ) ); + if (min==max) { // workaround boost bug + for (size_t i=0; i < numresults; i++) + vec.push_back( Value( min ) ); + } else { + for (size_t i=0; i < numresults; i++) { + if ( deterministic ) { + vec.push_back( Value( distributor( deterministic_rng ) ) ); + } else { + vec.push_back( Value( distributor( lessdeterministic_rng ) ) ); + } } } - return Value(vec); } diff --git a/testdata/scad/features/resize-tests.scad b/testdata/scad/features/resize-tests.scad index 659848b..3150e86 100644 --- a/testdata/scad/features/resize-tests.scad +++ b/testdata/scad/features/resize-tests.scad @@ -4,6 +4,7 @@ // and should be inscribed in gold row in 'top' view // back row (green) = should be all cubes auto-scaled up // back top (purple) = uses 'auto' feature +// lime green = 'auto' feature where we 'shrink' // pink = recursive resize, negative, <1, wrong syntax, etc $fn=8; @@ -60,22 +61,32 @@ translate([10,90,0]) resize([5,6,7],auto=true) cube(); color("purple"){ translate([10, 0, 10]) cube(); -translate([10,10,10]) resize([5,0,0],auto=[true,true,false]) cube(); +translate([10,10,10]) resize([5,0,0],auto=[true,true,false]) cube(); translate([10,20,10]) resize([6,0,0],auto=[true,true,true]) cube(); translate([13.5,33.5,10]) resize([7,0,0],auto=[true,false,false]) sphere(); translate([10,40,10]) resize([6,0,0],auto=[true,false,true]) cube(); translate([10,50,10]) resize([7,0,7],auto=[false,true,true]) cube(); -translate([13.5,63.5,10]) resize([7,0,0],auto=[false,true,false]) sphere(); translate([10,70,10]) resize([8,0,0],auto=[false,false,false]) cube(); +translate([13.5,63.5,10]) resize([7,0,0],auto=[false,true,false]) sphere(); +translate([10,70,10]) resize([8,0,0],auto=[false,false,false]) cube(); translate([10,80,10]) resize([9,0,0],auto=[false,false,true]) cube(); translate([10,90,10]) resize([0,0,7],auto=[true,true,false]) cube(); } color("pink"){ -translate([10,0,-10]) resize([4,4,4]) resize([5000,100,1000]) cube(); -translate([10,10,-10]) resize([-5,0,0]) cube(); -translate([10,20,-10]) resize([-5,0,0],auto=3) cube(); -translate([10,30,-10]) resize(-5,0,0,auto=3) cube(); -translate([10,40,-10]) resize(5,0,0) cube(); -translate([10,50,-10]) resize([0.5,0,7]) cube([0.5,1,1000]); -translate([10,60,-10]) resize([0,0,0.5]) cube([6,6,10000000000]); -}
\ No newline at end of file +translate([0 , 0,-10]) resize([4,4,4]) resize([5000,100,1000]) cube(); +translate([10,0,-10]) resize([-5,0,0]) cube(); +translate([20,0,-10]) resize([-5,0,0],auto=3) cube(); +translate([30,0,-10]) resize(-5,0,0,auto=3) cube(); +translate([40,0,-10]) resize(5,0,0) cube(); +translate([50,0,-10]) resize([0.5,0,7]) cube([0.5,1,1000]); +translate([60,0,-10]) resize([0,0,0.5]) cube([6,6,10000000000]); +} + +color("lime"){ +translate([20,0,0]) resize([5,0,0],auto=[true,true,false]) cube(9); +translate([30,0,0]) resize([6,0,0],auto=[true,true,true]) cube(9); +translate([40,0,0]) resize([6,0,0],auto=[true,false,true]) cube(9); +translate([50,0,0]) resize([5,0,20],auto=[false,true,true]) cube(9); +translate([60,0,0]) resize([0,0,7],auto=[false,false,true]) cube(9); +translate([70,0,0]) resize([6,0,0],auto=[true,true,false]) cube(9); +} diff --git a/testdata/scad/functions/rands.scad b/testdata/scad/functions/rands.scad new file mode 100644 index 0000000..7733dbb --- /dev/null +++ b/testdata/scad/functions/rands.scad @@ -0,0 +1,35 @@ +v1 = rands(0,0,0,0); +v2 = rands(-10,0,20,0); +v3 = rands(0,0,-20); +v4 = rands(1,2,-20); +v5 = rands(-1,-2,-20); +v6 = rands(-2,-1,-20); +v7 = rands(0,2,0,0); +v8 = rands(0,-3,-10,0); +v9 = rands(-40,-3,1000,0); +va = rands(10,200,1000,-32); +vb = rands("akhma","to","va"); + +vc = rands(0,0,-20); +vd = rands(1,2,-20); +ve = rands(-10,0,20); +vf = rands(0,2,0); +vg = rands(0,-3,0); +vh = rands(1,0,"blah"); +vi = rands(0,-3,-10); +vj = rands(-40,-3,1000); +vk = rands(10,200,1000); + +vq = rands(1, 5); +vp = rands(1, 5); +vo = rands(1); +vn = rands(); +vl = rands(v[0],v[1],v[2]); +vm = rands(1,2,-20); + +sphere(); +echo("i hope rands() did not crash"); + +v = rands(1,1,4); + +echo( v );
\ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f19cacc..f0b31e9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -188,7 +188,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # Turn off Eigen SIMD optimization if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "^FreeBSD") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_ALIGN") endif() endif() @@ -848,8 +848,8 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake ${TMP}) # Add tests -add_cmdline_test(echotest SUFFIX txt ARGS ${GUI_BINPATH} FILES ${ECHO_FILES}) -add_cmdline_test(dumptest SUFFIX csg ARGS ${GUI_BINPATH} FILES ${DUMPTEST_FILES}) +add_cmdline_test(echotest EXE ${CMAKE_SOURCE_DIR}/echotest SUFFIX txt ARGS ${GUI_BINPATH} FILES ${ECHO_FILES}) +add_cmdline_test(dumptest EXE ${CMAKE_SOURCE_DIR}/dumptest SUFFIX csg ARGS ${GUI_BINPATH} FILES ${DUMPTEST_FILES}) add_cmdline_test(moduledumptest EXE ${GUI_BINPATH} ARGS -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allmodules.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allfunctions.scad @@ -867,7 +867,7 @@ add_cmdline_test(opencsgtest EXE ${GUI_BINPATH} ARGS -o SUFFIX png FILES ${OPENC add_cmdline_test(throwntogethertest SUFFIX png FILES ${THROWNTOGETHERTEST_FILES}) # FIXME: We don't actually need to compare the output of cgalstlsanitytest # with anything. It's self-contained and returns != 0 on error -add_cmdline_test(cgalstlsanitytest SUFFIX txt ARGS ${GUI_BINPATH} FILES ${CGALSTLSANITYTEST_FILES}) +add_cmdline_test(cgalstlsanitytest EXE ${CMAKE_SOURCE_DIR}/cgalstlsanitytest SUFFIX txt ARGS ${GUI_BINPATH} FILES ${CGALSTLSANITYTEST_FILES}) # Tests using the actual OpenSCAD binary diff --git a/tests/echotest b/tests/echotest index bad382c..a2302ff 100755 --- a/tests/echotest +++ b/tests/echotest @@ -2,8 +2,7 @@ import re, sys, subprocess -result = subprocess.check_output([sys.argv[2], sys.argv[1], '-o', 'null'], stderr=subprocess.STDOUT) - +result = subprocess.Popen([sys.argv[2], sys.argv[1], '-o', 'null'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1] result = re.sub(r'-?[0-9].[0-9]*e-[0-9]{2,}', '0', result) open(sys.argv[3], 'w').write(result) |