From 6900160b7d67f2b572b5b3f9d1568904acf9d52f Mon Sep 17 00:00:00 2001 From: Don Bright Date: Thu, 8 Aug 2013 18:07:14 -0500 Subject: commit bugfix per report from chrysn to mailing list 8/8/13 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f19cacc..6a50130 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() -- cgit v0.10.1 From d2933590c23ae3a3d95bd1d2d74d03cdbb7897cc Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 11 Aug 2013 09:54:04 -0500 Subject: fix #452 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( evalctx->getArgValue(2).toDouble() ) ); boost::uniform_real<> distributor( min, max ); Value::VectorType vec; - for (int i=0; igetArgValue(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/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 -- cgit v0.10.1 From 506ed4e693a086eff0ffe9e49ded5ca2edc981d1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 13 Aug 2013 21:14:56 -0500 Subject: first step of dealing with issue #455 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/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); +} -- cgit v0.10.1 From 0dd0a262f9baf305f514a210f8e8655f1348891b Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 13 Aug 2013 22:00:48 -0500 Subject: switch from google-code file hosting to files.openscad.org diff --git a/scripts/builder.sh b/scripts/builder.sh index b00919f..8fc1372 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 } @@ -178,8 +179,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 -- cgit v0.10.1 From af7e8320e2d0fda0e2b8505f50080ff3d33e7531 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 13 Aug 2013 22:24:03 -0500 Subject: more migration from google-code to files.openscad.org diff --git a/scripts/builder.sh b/scripts/builder.sh index 8fc1372..38a235e 100755 --- a/scripts/builder.sh +++ b/scripts/builder.sh @@ -148,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 @@ -180,7 +189,7 @@ update_win_www_download_links() cd inc echo `pwd` # BASEURL='https://openscad.googlecode.com/files/' - BASEURL='http://files.openscad.org' + BASEURL='http://files.openscad.org/' DATECODE=`date +"%Y.%m.%d"` rm win_snapshot_links.js -- cgit v0.10.1