diff options
author | Vicnet <vo.publique@gmail.com> | 2013-09-13 12:52:22 (GMT) |
---|---|---|
committer | Vicnet <vo.publique@gmail.com> | 2013-09-13 12:52:22 (GMT) |
commit | 7b1e423f8214bb42c7668505066507e4d9c7091a (patch) | |
tree | 19e9174a312f35af416f9fa4cd58f31876052e79 | |
parent | f6343949ebc6936880a6cd62bfe3574541a11fb5 (diff) | |
parent | ead8749e99238c18a3d7bb903f98bb7bca6a7685 (diff) |
Merge remote-tracking branch 'upstream/master'
35 files changed, 274 insertions, 945 deletions
diff --git a/doc/openscad.1 b/doc/openscad.1 index 87806f2..bce2e98 100644 --- a/doc/openscad.1 +++ b/doc/openscad.1 @@ -48,9 +48,6 @@ variable's value is an expression, so if this mechanism is used to assign strings, care has to be taken that the shell does not consume quotation marks. More than one \fB-D\fP options can be given. .TP -.B \-v, \-\-version -Show version of program. -.TP .B \-\-render If exporting an image, use a full CGAL render. (Default is an OpenCSG compile) .TP @@ -72,6 +69,13 @@ If exporting an image, specify the pixel width and height .B \-\-projection=[o|p] If exporting an image, specify whether to use orthographic or perspective projection +.TP +.B \-v, \-\-version +Show version of program. +.TP +.B \-\-info +Show which versions of libraries were used to compile the program, and which +OpenGL details are discovered. .SH COMMAND LINE EXAMPLES .PP diff --git a/doc/testing.txt b/doc/testing.txt index 626bae5..f609b65 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -3,8 +3,10 @@ Running regression tests: Prerequisites: cmake, python, ImageMagick 6.5.9.3 or newer -First, get a working qmake GUI build. It is used by the tests. -Next, get MCAD installed by using 'git submodule update --init' +First, get a working qmake GUI build of the main openscad binary. It is +used by the tests. Next, get MCAD installed by using + + 'git submodule update --init' A) Building test environment @@ -67,18 +69,6 @@ This is almost the same as adding a new regression test: Migration away from dedicated regression tests: ----------------------------------------------- -As the main OpenSCAD binary gained the capability to output PNG renderings, -the necessity for dedicated test binaries went away; for many test, OpenSCAD -is now directly called, resulting in better test coverage and less code to -maintain. - -So far, the following tests have been fully converted to use the main binary: - -* moduledumptest -* csgtermtest -* cgalpngtest -* opencsgtest - Two tests still need an intermediate script that mangles away timestamps and near-zero floating point numbers: @@ -89,7 +79,6 @@ near-zero floating point numbers: Some tests are yet to be converted: * csgtexttest -- verify whether this is not redundant with dumptest -* throwntogethertest -- should be a .png output mode These look like tests, but are not actually in use: diff --git a/scripts/LogicLib.nsh b/scripts/LogicLib.nsh index 2f8968c..618bde4 100644 --- a/scripts/LogicLib.nsh +++ b/scripts/LogicLib.nsh @@ -1,4 +1,5 @@ ; NSIS LOGIC LIBRARY - LogicLib.nsh
+; see mingw-file-association.nshmingw-file-association.nsh for license info
; Version 2.6 - 08/12/2007
; By dselkirk@hotmail.com
; and eccles@users.sf.net
diff --git a/scripts/builder.sh b/scripts/builder.sh index 38a235e..552d559 100755 --- a/scripts/builder.sh +++ b/scripts/builder.sh @@ -95,13 +95,9 @@ upload_win_generic() opts="$opts -u $username" opts="$opts $filename" if [ $DRYRUN ]; then - echo dry run, not uploading to googlecode - 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 - echo google-code upload is disabled / deprecated - # python ./scripts/googlecode_upload.py -s "$summary" $opts scp -v $filename openscad@files.openscad.org:www/ fi } diff --git a/scripts/googlecode_upload.py b/scripts/googlecode_upload.py deleted file mode 100755 index c0fe4c9..0000000 --- a/scripts/googlecode_upload.py +++ /dev/null @@ -1,306 +0,0 @@ -#!/usr/bin/env python -# Google Code binary package uploader -# with Insturctions for uploading packages for OpenSCAD -# -# OpenSCAD Usage: -# -# 1. get a google account, get it added to the Google Code OpenSCAD project -# 2. go to https://code.google.com/hosting/settings for username & password -# ----- -# -# security note - -# -# it's not advisable to use a ~/.netrc file to store your password -# keep your googlecode password secret -# only upload from a secure machine -# user's personal data can be at risk if your account -# is compromised and a fake openscad were to be uploaded. -# notify the OpenSCAD maintainer if your computer is stolen or -# your google account is ever compromised. -# ----- -# 4. if you are making a Stable Release, check 'docs/release_checklist.txt' -# 5. create an OpenSCAD package (linux dev snapshot: ./scripts/release-common.sh) -# 6. Run this to do the upload: -# export SUMMARY="Linux x86-64 Snapshot" # replace as appropriate -# export PACKAGEFILE=openscad-2013.01.10.x86-64.tar.gz # replace as appropriate -# python ./scripts/googlecode_upload.py -s '$SUMMARY' -p openscad $PACKAGEFILE -# 7. It will ask for username. Use user.name@gmail.com (include the @ mail address) -# 8. It will ask for password. Copy/paste the password from the https google code settings page above -# Don't use the big bold password, use the 'plain font' password from the 'machine' line -# 9. Wait.... (there is no progress meter). It should say 'success' eventually. -# -# The rest of this file is original from Google with slight modifications by the -# OpenSCAD team. Modifications licensed under the same license as the -# original code from google - the Apache Software License 2.0: -# http://www.apache.org/licenses/LICENSE-2.0 - - -# -# Copyright 2006, 2007 Google Inc. All Rights Reserved. -# Author: danderson@google.com (David Anderson) -# -# Script for uploading files to a Google Code project. -# -# This is intended to be both a useful script for people who want to -# streamline project uploads and a reference implementation for -# uploading files to Google Code projects. -# -# To upload a file to Google Code, you need to provide a path to the -# file on your local machine, a small summary of what the file is, a -# project name, and a valid account that is a member or owner of that -# project. You can optionally provide a list of labels that apply to -# the file. The file will be uploaded under the same name that it has -# in your local filesystem (that is, the "basename" or last path -# component). Run the script with '--help' to get the exact syntax -# and available options. -# -# Note that the upload script requests that you enter your -# googlecode.com password. This is NOT your Gmail account password! -# This is the password you use on googlecode.com for committing to -# Subversion and uploading files. You can find your password by going -# to http://code.google.com/hosting/settings when logged in with your -# Gmail account. If you have already committed to your project's -# Subversion repository, the script will automatically retrieve your -# credentials from there (unless disabled, see the output of '--help' -# for details). -# -# If you are looking at this script as a reference for implementing -# your own Google Code file uploader, then you should take a look at -# the upload() function, which is the meat of the uploader. You -# basically need to build a multipart/form-data POST request with the -# right fields and send it to https://PROJECT.googlecode.com/files . -# Authenticate the request using HTTP Basic authentication, as is -# shown below. -# -# Licensed under the terms of the Apache Software License 2.0: -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Questions, comments, feature requests and patches are most welcome. -# Please direct all of these to the Google Code users group: -# http://groups.google.com/group/google-code-hosting - -"""Google Code file uploader script. -""" - -__author__ = 'danderson@google.com (David Anderson)' - -import httplib -import os.path -import optparse -import getpass -import base64 -import sys - - -def upload(file, project_name, user_name, password, summary, labels=None): - """Upload a file to a Google Code project's file server. - - Args: - file: The local path to the file. - project_name: The name of your project on Google Code. - user_name: Your Google account name. - password: The googlecode.com password for your account. - Note that this is NOT your global Google Account password! - summary: A small description for the file. - labels: an optional list of label strings with which to tag the file. - - Returns: a tuple: - http_status: 201 if the upload succeeded, something else if an - error occured. - http_reason: The human-readable string associated with http_status - file_url: If the upload succeeded, the URL of the file on Google - Code, None otherwise. - """ - # The login is the user part of user@gmail.com. If the login provided - # is in the full user@domain form, strip it down. - if user_name.endswith('@gmail.com'): - user_name = user_name[:user_name.index('@gmail.com')] - - form_fields = [('summary', summary)] - if labels is not None: - form_fields.extend([('label', l.strip()) for l in labels]) - - content_type, body = encode_upload_request(form_fields, file) - - upload_host = '%s.googlecode.com' % project_name - upload_uri = '/files' - auth_token = base64.b64encode('%s:%s'% (user_name, password)) - headers = { - 'Authorization': 'Basic %s' % auth_token, - 'User-Agent': 'Googlecode.com uploader v0.9.4', - 'Content-Type': content_type, - } - - server = httplib.HTTPSConnection(upload_host) - server.request('POST', upload_uri, body, headers) - resp = server.getresponse() - server.close() - - if resp.status == 201: - location = resp.getheader('Location', None) - else: - location = None - return resp.status, resp.reason, location - - -def encode_upload_request(fields, file_path): - """Encode the given fields and file into a multipart form body. - - fields is a sequence of (name, value) pairs. file is the path of - the file to upload. The file will be uploaded to Google Code with - the same file name. - - Returns: (content_type, body) ready for httplib.HTTP instance - """ - BOUNDARY = '----------Googlecode_boundary_reindeer_flotilla' - CRLF = '\r\n' - - body = [] - - # Add the metadata about the upload first - for key, value in fields: - body.extend( - ['--' + BOUNDARY, - 'Content-Disposition: form-data; name="%s"' % key, - '', - value, - ]) - - # Now add the file itself - file_name = os.path.basename(file_path) - f = open(file_path, 'rb') - file_content = f.read() - f.close() - - body.extend( - ['--' + BOUNDARY, - 'Content-Disposition: form-data; name="filename"; filename="%s"' - % file_name, - # The upload server determines the mime-type, no need to set it. - 'Content-Type: application/octet-stream', - '', - file_content, - ]) - - # Finalize the form body - body.extend(['--' + BOUNDARY + '--', '']) - - return 'multipart/form-data; boundary=%s' % BOUNDARY, CRLF.join(body) - - -def upload_find_auth(file_path, project_name, summary, labels=None, - user_name=None, password=None, tries=1): - """Find credentials and upload a file to a Google Code project's file server. - - file_path, project_name, summary, and labels are passed as-is to upload. - - Args: - file_path: The local path to the file. - project_name: The name of your project on Google Code. - summary: A small description for the file. - labels: an optional list of label strings with which to tag the file. - config_dir: Path to Subversion configuration directory, 'none', or None. - user_name: Your Google account name. - tries: How many attempts to make. - """ - print 'uploading. username: ', user_name - print 'password detected:', password!=None - if user_name is None or password is None: - from netrc import netrc - authenticators = None - try: - authenticators = netrc().authenticators("code.google.com") - except: - print "Error accessing netrc authenticator. Trying alternate method" - if authenticators: - if user_name is None: - user_name = authenticators[0] - if password is None: - password = authenticators[2] - - while tries > 0: - if user_name is None: - # Read username if not specified or loaded from svn config, or on - # subsequent tries. - sys.stdout.write('Please enter your googlecode.com username: ') - sys.stdout.flush() - user_name = sys.stdin.readline().rstrip() - if password is None: - # Read password if not loaded from svn config, or on subsequent tries. - print 'Please enter your googlecode.com password.' - print '** Note that this is NOT your Gmail account password! **' - print 'It is the password you use to access Subversion repositories,' - print 'and can be found here: http://code.google.com/hosting/settings' - password = getpass.getpass() - - status, reason, url = upload(file_path, project_name, user_name, password, - summary, labels) - # Returns 403 Forbidden instead of 401 Unauthorized for bad - # credentials as of 2007-07-17. - if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]: - # Rest for another try. - user_name = password = None - tries = tries - 1 - else: - # We're done. - break - - return status, reason, url - - -def main(): - parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY ' - '-p PROJECT [options] FILE') - parser.add_option('-s', '--summary', dest='summary', - help='Short description of the file') - parser.add_option('-p', '--project', dest='project', - help='Google Code project name') - parser.add_option('-u', '--user', dest='user', - help='Your Google Code username') - #this is a massive security hole. anyone using 'ps' could steal p/w - #parser.add_option('-w', '--password', dest='password', - # help='Your Google Code password') - parser.add_option('-l', '--labels', dest='labels', - help='An optional list of comma-separated labels to attach ' - 'to the file') - - options, args = parser.parse_args() - - if os.environ.has_key('OSUPL_PASSWORD'): - options.password=os.environ['OSUPL_PASSWORD'] - else: - options.password=None - - if not options.summary: - parser.error('File summary is missing.') - elif not options.project: - parser.error('Project name is missing.') - elif len(args) < 1: - parser.error('File to upload not provided.') - elif len(args) > 1: - parser.error('Only one file may be specified.') - - file_path = args[0] - - if options.labels: - labels = options.labels.split(',') - else: - labels = None - - print 'read arguments' - status, reason, url = upload_find_auth(file_path, options.project, - options.summary, labels, - options.user, options.password) - if url: - print 'The file was uploaded successfully.' - print 'URL: %s' % url - return 0 - else: - print 'An error occurred. Your file was not uploaded.' - print 'Google Code upload server said: %s (%s)' % (reason, status) - return 1 - - -if __name__ == '__main__': - print sys.argv - sys.exit(main()) diff --git a/scripts/x64.nsh b/scripts/x64.nsh index e694c1e..9b69ff0 100644 --- a/scripts/x64.nsh +++ b/scripts/x64.nsh @@ -1,6 +1,7 @@ ; --------------------- ; x64.nsh ; --------------------- +; see mingw-file-association.nshmingw-file-association.nsh for license info ; ; A few simple macros to handle installations on x64 machines. ; diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index adaec4a..ec01315 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -216,7 +216,7 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node) 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++) { + for (int i=0;i<N.dim;i++) { if (node.newsize[i]) { if (bbox_size[i]==NT3(0)) { PRINT("WARNING: Resize in direction normal to flat object is not implemented"); @@ -229,8 +229,11 @@ CGAL_Nef_polyhedron CGALEvaluator::applyResize(const CgaladvNode &node) newsizemax_index = i; } } - NT3 autoscale = NT3( node.newsize[ newsizemax_index ] ) / bbox_size[ newsizemax_index ]; - for (int i=0;i<3;i++) { + + NT3 autoscale = NT3( 1 ); + if ( node.newsize[ newsizemax_index ] != 0 ) + autoscale = NT3( node.newsize[ newsizemax_index ] ) / bbox_size[ newsizemax_index ]; + for (int i=0;i<N.dim;i++) { if (node.autosize[i] && node.newsize[i]==0) scale[i] = autoscale; } diff --git a/src/Camera.h b/src/Camera.h index dfc71f8..6079672 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -47,7 +47,8 @@ public: projection = Camera::PERSPECTIVE; } - void setup( std::vector<double> params ) { + void setup( std::vector<double> params ) + { if ( params.size() == 7 ) { type = Camera::GIMBAL; object_trans << params[0], params[1], params[2]; @@ -62,6 +63,16 @@ public: } } + void gimbalDefaultTranslate() + { // match the GUI viewport numbers (historical reasons) + object_trans.x() *= -1; + object_trans.y() *= -1; + object_trans.z() *= -1; + object_rot.x() = fmodf(360 - object_rot.x() + 90, 360 ); + object_rot.y() = fmodf(360 - object_rot.y(), 360); + object_rot.z() = fmodf(360 - object_rot.z(), 360); + } + // Vectorcam Eigen::Vector3d eye; Eigen::Vector3d center; // (aka 'target') diff --git a/src/GLView.cc b/src/GLView.cc index 822a246..1cfe82c 100644 --- a/src/GLView.cc +++ b/src/GLView.cc @@ -460,7 +460,7 @@ void GLView::showAxes() void GLView::showCrosshairs() { - // FIXME: this might not work with Vector camera + // FIXME: this might not work with Vector camera // FIXME: Crosshairs and axes are lighted, this doesn't make sense and causes them // to change color based on view orientation. glLineWidth(3); diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc index 5dd007d..ccc2bc0 100644 --- a/src/PlatformUtils.cc +++ b/src/PlatformUtils.cc @@ -38,3 +38,46 @@ std::string PlatformUtils::libraryPath() } return boosty::stringy( path ); } + +#include "version_check.h" +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +std::string PlatformUtils::info() +{ + std::stringstream s; + +#if defined(__GNUG__) && !defined(__clang__) + std::string compiler_info( "GCC " + std::string(TOSTRING(__VERSION__)) ); +#elif defined(_MSC_VER) + std::string compiler_info( "MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) ); +#elif defined(__clang__) + std::string compiler_info( "Clang " + std::string(TOSTRING(__clang_version__)) ); +#else + std::string compiler_info( "unknown compiler" ); +#endif + +#if defined( __MINGW64__ ) + std::string mingwstatus("MingW64"); +#elif defined( __MINGW32__ ) + std::string mingwstatus("MingW32"); +#else + std::string mingwstatus("No"); +#endif + +#ifndef OPENCSG_VERSION_STRING +#define OPENCSG_VERSION_STRING "unknown, <1.3.2" +#endif + + s << "OpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + << "\nCompiler: " << compiler_info + << "\nCompile date: " << __DATE__ + << "\nBoost version: " << BOOST_LIB_VERSION + << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION + << "\nCGAL version: " << TOSTRING(CGAL_VERSION) + << "\nOpenCSG version: " << OPENCSG_VERSION_STRING + << "\nQt version: " << qVersion() + << "\nMingW build: " << mingwstatus; + + return s.str(); +} + diff --git a/src/PlatformUtils.h b/src/PlatformUtils.h index 089b3ca..18dd5fa 100644 --- a/src/PlatformUtils.h +++ b/src/PlatformUtils.h @@ -8,7 +8,7 @@ namespace PlatformUtils { std::string documentsPath(); std::string libraryPath(); bool createLibraryPath(); - + std::string info(); } #endif diff --git a/src/QGLView.cc b/src/QGLView.cc index b23ba8e..8aaeaf2 100644 --- a/src/QGLView.cc +++ b/src/QGLView.cc @@ -147,13 +147,18 @@ void QGLView::resizeGL(int w, int h) void QGLView::paintGL() { - GLView::gimbalCamPaintGL(); + GLView::gimbalCamPaintGL(); if (statusLabel) { QString msg; + + Camera nc( cam ); + nc.gimbalDefaultTranslate(); msg.sprintf("Viewport: translate = [ %.2f %.2f %.2f ], rotate = [ %.2f %.2f %.2f ], distance = %.2f", - -cam.object_trans.x(), -cam.object_trans.y(), -cam.object_trans.z(), - fmodf(360 - cam.object_rot.x() + 90, 360), fmodf(360 - cam.object_rot.y(), 360), fmodf(360 - cam.object_rot.z(), 360), cam.viewer_distance); + nc.object_trans.x(), nc.object_trans.y(), nc.object_trans.z(), + nc.object_rot.x(), nc.object_rot.y(), nc.object_rot.z(), + nc.viewer_distance ); + statusLabel->setText(msg); } diff --git a/src/export.h b/src/export.h index a565561..5dae7e0 100644 --- a/src/export.h +++ b/src/export.h @@ -12,6 +12,7 @@ void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output); void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output); void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, Camera &c, std::ostream &output); void export_png_with_opencsg(Tree &tree, Camera &c, std::ostream &output); +void export_png_with_throwntogether(Tree &tree, Camera &c, std::ostream &output); #endif diff --git a/src/export_png.cc b/src/export_png.cc index c6c191c..744d681 100644 --- a/src/export_png.cc +++ b/src/export_png.cc @@ -41,26 +41,25 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, Camera &cam, std::ostream cam.eye = cam.center - radius*2*cameradir; } - //std::cerr << center << "\n"; - //std::cerr << radius << "\n"; - glview->setCamera( cam ); glview->setRenderer(&cgalRenderer); glview->paintGL(); glview->save(output); } +enum Previewer { OPENCSG, THROWN } previewer; + #ifdef ENABLE_OPENCSG #include "OpenCSGRenderer.h" #include <opencsg.h> #endif +#include "ThrownTogetherRenderer.h" -void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output) +void export_png_preview_common( Tree &tree, Camera &cam, std::ostream &output, Previewer previewer = OPENCSG ) { -#ifdef ENABLE_OPENCSG - CsgInfo csgInfo = CsgInfo(); - if ( !csgInfo.compile_chains( tree ) ) { - fprintf(stderr,"Couldn't initialize OpenCSG chains\n"); + CsgInfo csgInfo = CsgInfo(); + if ( !csgInfo.compile_chains( tree ) ) { + fprintf(stderr,"Couldn't initialize CSG chains\n"); return; } @@ -71,7 +70,16 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output) return; } - OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo); + Renderer *renderer; + if ( previewer == OPENCSG ) { +#ifdef ENABLE_OPENCSG + OpenCSGRenderer openCSGRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo); + renderer = &openCSGRenderer; +#endif + } else { + ThrownTogetherRenderer thrownTogetherRenderer( csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain ); + renderer = &thrownTogetherRenderer; + } if (cam.type == Camera::NONE) { cam.type = Camera::VECTOR; @@ -86,15 +94,28 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output) } csgInfo.glview->setCamera( cam ); - csgInfo.glview->setRenderer(&opencsgRenderer); - OpenCSG::setContext(0); - OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject); + csgInfo.glview->setRenderer( renderer ); +#ifdef ENABLE_OPENCSG + OpenCSG::setContext( 0 ); + OpenCSG::setOption( OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject ); +#endif csgInfo.glview->paintGL(); - csgInfo.glview->save(output); + csgInfo.glview->save( output ); +} + +void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output) +{ +#ifdef ENABLE_OPENCSG + export_png_preview_common( tree, cam, output, OPENCSG ); #else fprintf(stderr,"This openscad was built without OpenCSG support\n"); #endif } +void export_png_with_throwntogether(Tree &tree, Camera &cam, std::ostream &output) +{ + export_png_preview_common( tree, cam, output, THROWN ); +} + #endif // ENABLE_CGAL diff --git a/src/imageutils-lodepng.cc b/src/imageutils-lodepng.cc index cd104d6..a71a017 100644 --- a/src/imageutils-lodepng.cc +++ b/src/imageutils-lodepng.cc @@ -9,7 +9,12 @@ bool write_png(std::ostream &output, unsigned char *pixels, int width, int height) { std::vector<unsigned char> dataout; - unsigned err = lodepng::encode(dataout, pixels, width, height, LCT_RGBA, 8); + lodepng::State state; + state.encoder.auto_convert = LAC_NO; + // some png renderers have different interpretations of alpha, so don't use it + state.info_png.color.colortype = LCT_RGB; + state.info_png.color.bitdepth = 8; + unsigned err = lodepng::encode(dataout, pixels, width, height, state); if ( err ) return false; output.write( reinterpret_cast<const char *>(&dataout[0]), dataout.size()); if ( output.bad() ) std::cerr << "Error writing to ostream\n"; diff --git a/src/mainwin.cc b/src/mainwin.cc index 3d50d6f..783772c 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -101,10 +101,6 @@ #endif // ENABLE_CGAL -#ifndef OPENCSG_VERSION_STRING -#define OPENCSG_VERSION_STRING "unknown, <1.3.2" -#endif - #include "boosty.h" extern QString examplesdir; @@ -1828,34 +1824,16 @@ MainWindow::helpManual() QDesktopServices::openUrl(QUrl("http://www.openscad.org/documentation.html")); } -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) void MainWindow::helpLibrary() { - QString libinfo; - libinfo.sprintf("Boost version: %s\n" - "Eigen version: %d.%d.%d\n" - "CGAL version: %s\n" - "OpenCSG version: %s\n" - "Qt version: %s\n\n", - BOOST_LIB_VERSION, - EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION, - TOSTRING(CGAL_VERSION), - OPENCSG_VERSION_STRING, - qVersion()); - -#if defined( __MINGW64__ ) - libinfo += QString("Compiled for MingW64\n\n"); -#elif defined( __MINGW32__ ) - libinfo += QString("Compiled for MingW32\n\n"); -#endif - + QString info( PlatformUtils::info().c_str() ); + info += QString( qglview->getRendererInfo().c_str() ); if (!this->openglbox) { - this->openglbox = new QMessageBox(QMessageBox::Information, - "OpenGL Info", "OpenSCAD Detailed Library Info ", + this->openglbox = new QMessageBox(QMessageBox::Information, + "OpenGL Info", "OpenSCAD Detailed Library and Build Information", QMessageBox::Ok, this); } - this->openglbox->setDetailedText(libinfo + QString(qglview->getRendererInfo().c_str())); + this->openglbox->setDetailedText( info ); this->openglbox->show(); } diff --git a/src/openscad.cc b/src/openscad.cc index e657cb0..fb5ee44 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -37,6 +37,7 @@ #include "handle_dep.h" #include "parsersettings.h" #include "rendersettings.h" +#include "PlatformUtils.h" #include <string> #include <vector> @@ -50,6 +51,7 @@ #include "csgterm.h" #include "CSGTermEvaluator.h" +#include "CsgInfo.h" #include <QApplication> #include <QString> @@ -82,12 +84,13 @@ static void help(const char *progname) { int tab = int(strlen(progname))+8; fprintf(stderr,"Usage: %s [ -o output_file [ -d deps_file ] ]\\\n" - "%*s[ -m make_command ] [ -D var=val [..] ] [ --render ] \\\n" + "%*s[ -m make_command ] [ -D var=val [..] ] \\\n" "%*s[ --camera=translatex,y,z,rotx,y,z,dist | \\\n" "%*s --camera=eyex,y,z,centerx,y,z ] \\\n" "%*s[ --imgsize=width,height ] [ --projection=(o)rtho|(p)ersp] \\\n" + "%*s[ --render | --preview[=throwntogether] ] \\\n" "%*sfilename\n", - progname, tab, "", tab, "", tab, "", tab, "", tab, ""); + progname, tab, "", tab, "", tab, "", tab, "", tab, "", tab, ""); exit(1); } @@ -99,6 +102,23 @@ static void version() exit(1); } +static void info() +{ + std::cout << PlatformUtils::info() << "\n\n"; + + CsgInfo csgInfo = CsgInfo(); + try { + csgInfo.glview = new OffscreenView(512,512); + } catch (int error) { + fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error); + exit(1); + } + + std::cout << csgInfo.glview->getRendererInfo() << "\n"; + + exit(0); +} + std::string commandline_commands; std::string currentdir; QString examplesdir; @@ -127,6 +147,10 @@ Camera get_camera( po::variables_map vm ) } } + if (camera.type == Camera::GIMBAL) { + camera.gimbalDefaultTranslate(); + } + if (vm.count("projection")) { string proj = vm["projection"].as<string>(); if (proj=="o" || proj=="ortho" || proj=="orthogonal") @@ -199,7 +223,9 @@ int main(int argc, char **argv) desc.add_options() ("help,h", "help message") ("version,v", "print the version") + ("info", "print information about the building process") ("render", "if exporting a png image, do a full CGAL render") + ("preview", po::value<string>(), "if exporting a png image, do an OpenCSG(default) or ThrownTogether preview") ("camera", po::value<string>(), "parameters for camera when exporting png") ("imgsize", po::value<string>(), "=width,height for exporting png") ("projection", po::value<string>(), "(o)rtho or (p)erspective when exporting png") @@ -231,6 +257,7 @@ int main(int argc, char **argv) if (vm.count("help")) help(argv[0]); if (vm.count("version")) version(); + if (vm.count("info")) info(); if (vm.count("o")) { // FIXME: Allow for multiple output files? @@ -513,6 +540,8 @@ int main(int argc, char **argv) else { if (vm.count("render")) { export_png_with_cgal(&root_N, camera, fstream); + } else if (vm.count("preview") && vm["preview"].as<string>() == "throwntogether" ) { + export_png_with_throwntogether(tree, camera, fstream); } else { export_png_with_opencsg(tree, camera, fstream); } diff --git a/testdata/scad/features/resize-2d-tests.scad b/testdata/scad/features/resize-2d-tests.scad index 911a4cd..3b6fe9d 100644 --- a/testdata/scad/features/resize-2d-tests.scad +++ b/testdata/scad/features/resize-2d-tests.scad @@ -53,3 +53,11 @@ translate([32,16]) resize([0,0,15],auto=true) shape2(); translate([32,32]) resize([0,0,15]) shape3(); } +color("blue"){ +translate([-16,-16]) resize([10,8],auto=[false,true]) + scale([0.5,100,20]) shape(); +translate([0,-16]) resize([8,10,15],auto=true) + scale([1000,0.5]) shape2(); +translate([16,-16]) resize([10,8,15]) + scale([200,200]) shape3(); +} diff --git a/testdata/scad/features/resize-tests.scad b/testdata/scad/features/resize-tests.scad index 3150e86..5e78f06 100644 --- a/testdata/scad/features/resize-tests.scad +++ b/testdata/scad/features/resize-tests.scad @@ -73,13 +73,13 @@ translate([10,90,10]) resize([0,0,7],auto=[true,true,false]) cube(); } color("pink"){ -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]); +translate([10 , 0,-10]) resize([4,4,4]) resize([5000,100,1000]) cube(); +translate([20,0,-10]) resize([-5,0,0]) cube(); +translate([30,0,-10]) resize([-5,0,0],auto=3) cube(); +translate([40,0,-10]) resize(-5,0,0,auto=3) cube(); +translate([50,0,-10]) resize(5,0,0) cube(); +translate([60,0,-10]) resize([0.5,0,7]) cube([0.5,1,1000]); +translate([70,0,-10]) resize([0,0,0.5]) cube([6,6,10000000000]); } color("lime"){ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f0b31e9..1845ef5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -541,14 +541,6 @@ set_target_properties(cgalcachetest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CG target_link_libraries(cgalcachetest tests-cgal ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) # -# throwntogethertest -# - -add_executable(throwntogethertest throwntogethertest.cc csgtestcore.cc ../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc ../src/renderer.cc ../src/rendersettings.cc) -set_target_properties(throwntogethertest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") -target_link_libraries(throwntogethertest tests-offscreen tests-cgal ${OPENCSG_LIBRARY} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY}) - -# # GUI binary tests # if(APPLE) @@ -836,6 +828,7 @@ string(REPLACE __cmake_current_source_dir__ ${CMAKE_CURRENT_SOURCE_DIR} TMP ${TM string(REPLACE __python__ ${PYTHON_EXECUTABLE} TMP ${TMP}) string(REPLACE __header__ "Generated by cmake from ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.template" TMP ${TMP}) string(REPLACE __cmake_system_name__ ${CMAKE_SYSTEM_NAME} TMP ${TMP}) +string(REPLACE __gui_binpath__ ${GUI_BINPATH} TMP ${TMP}) if (MINGW_CROSS_ENV_DIR) string(REPLACE __wine__ wine TMP ${TMP}) @@ -864,7 +857,7 @@ add_cmdline_test(csgtermtest EXE ${GUI_BINPATH} ARGS -o SUFFIX term FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/allmodules.scad) add_cmdline_test(cgalpngtest EXE ${GUI_BINPATH} ARGS --render -o SUFFIX png FILES ${CGALPNGTEST_FILES}) add_cmdline_test(opencsgtest EXE ${GUI_BINPATH} ARGS -o SUFFIX png FILES ${OPENCSGTEST_FILES}) -add_cmdline_test(throwntogethertest SUFFIX png FILES ${THROWNTOGETHERTEST_FILES}) +add_cmdline_test(throwntogethertest EXE ${GUI_BINPATH} ARGS --preview=throwntogether -o 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 EXE ${CMAKE_SOURCE_DIR}/cgalstlsanitytest SUFFIX txt ARGS ${GUI_BINPATH} FILES ${CGALSTLSANITYTEST_FILES}) @@ -895,15 +888,15 @@ add_cmdline_test(openscad-camdist EXE ${GUI_BINPATH} SUFFIX png FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) add_cmdline_test(openscad-camrot EXE ${GUI_BINPATH} - ARGS --imgsize=500,500 --camera=0,0,0,10,22.5,45,300 examples/example001.scad -o + ARGS --imgsize=500,500 --camera=0,0,0,440,337.5,315,300 examples/example001.scad -o SUFFIX png FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) add_cmdline_test(openscad-camtrans EXE ${GUI_BINPATH} - ARGS --imgsize=500,500 --camera=20,100,10,0,0,0,300 examples/example001.scad -o + ARGS --imgsize=500,500 --camera=100,-20,-10,90,0,90,300 examples/example001.scad -o SUFFIX png FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) add_cmdline_test(openscad-camortho EXE ${GUI_BINPATH} - ARGS --imgsize=500,500 --camera=20,100,10,0,0,0,300 examples/example001.scad --projection=o -o + ARGS --imgsize=500,500 --camera=100,-20,-10,90,0,90,300 examples/example001.scad --projection=o -o SUFFIX png FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad) add_cmdline_test(openscad-cameye EXE ${GUI_BINPATH} diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template index fd6ba8b..b8d04ce 100644 --- a/tests/CTestCustom.template +++ b/tests/CTestCustom.template @@ -58,8 +58,8 @@ endif() # Part 1. Pretty Printing -message("running 'opencsgtest --info' to generate sysinfo.txt") -execute_process(COMMAND __wine__ __cmake_current_binary_dir__/opencsgtest --info OUTPUT_FILE sysinfo.txt) +message("running '__gui_binpath__ --info' to generate sysinfo.txt") +execute_process(COMMAND __wine__ __gui_binpath__ --info OUTPUT_FILE sysinfo.txt) set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "__cmake_current_binary_dir__/test_pretty_print") if ( ${debug_openscad_template} ) diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc deleted file mode 100644 index 7b9dbab..0000000 --- a/tests/csgtestcore.cc +++ /dev/null @@ -1,212 +0,0 @@ -// csg test core, used by throwntegether test and opencsg test -#include "csgtestcore.h" - -#include "tests-common.h" -#include "system-gl.h" -#include "openscad.h" -#include "parsersettings.h" -#include "builtin.h" -#include "modcontext.h" -#include "node.h" -#include "module.h" -#include "polyset.h" -#include "Tree.h" -#include "CSGTermEvaluator.h" -#include "CGALEvaluator.h" -#include "PolySetCGALEvaluator.h" - -#include <opencsg.h> -#include "OpenCSGRenderer.h" -#include "ThrownTogetherRenderer.h" - -#include "csgterm.h" -#include "csgtermnormalizer.h" -#include "OffscreenView.h" - -#include <sstream> -#include <vector> - -#include <boost/program_options.hpp> -#include <boost/filesystem.hpp> - -#include "CsgInfo.h" - -namespace po = boost::program_options; -namespace fs = boost::filesystem; -#include "boosty.h" - -using std::string; -using std::vector; -using std::cerr; -using std::cout; - -std::string commandline_commands; - -//#define DEBUG - -string info_dump(OffscreenView *glview) -{ - assert(glview); - -#ifdef __GNUG__ -#define compiler_info "GCC " << __VERSION__ -#elif defined(_MSC_VER) -#define compiler_info "MSVC " << _MSC_FULL_VER -#else -#define compiler_info "unknown compiler" -#endif - -#ifndef OPENCSG_VERSION_STRING -#define OPENCSG_VERSION_STRING "unknown, <1.3.2" -#endif - - std::stringstream out; -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) - out << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) - << "\nCompiled by: " << compiler_info - << "\nCompile date: " << __DATE__ - << "\nBoost version: " << BOOST_LIB_VERSION - << "\nEigen version: " << EIGEN_WORLD_VERSION << "." - << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION - << "\nCGAL version: " << TOSTRING(CGAL_VERSION) - << "\nOpenCSG version: " << OPENCSG_VERSION_STRING - << "\n" << glview->getRendererInfo() - << "\n"; - - return out.str(); -} - -po::variables_map parse_options(int argc, char *argv[]) -{ - po::options_description desc("Allowed options"); - desc.add_options() - ("help,h", "help message")//; - ("info,i", "information on GLEW, OpenGL, OpenSCAD, and OS")//; - -// po::options_description hidden("Hidden options"); -// hidden.add_options() - ("input-file", po::value< vector<string> >(), "input file") - ("output-file", po::value< vector<string> >(), "output file"); - - po::positional_options_description p; - p.add("input-file", 1).add("output-file", 1); - - po::options_description all_options; - all_options.add(desc); // .add(hidden); - - po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm); - po::notify(vm); - - return vm; -} - -int csgtestcore(int argc, char *argv[], test_type_e test_type) -{ - bool sysinfo_dump = false; - const char *filename, *outfilename = NULL; - po::variables_map vm; - try { - vm = parse_options(argc, argv); - } catch ( po::error e ) { - cerr << "error parsing options\n"; - } - if (vm.count("info")) sysinfo_dump = true; - if (vm.count("input-file")) - filename = vm["input-file"].as< vector<string> >().begin()->c_str(); - if (vm.count("output-file")) - outfilename = vm["output-file"].as< vector<string> >().begin()->c_str(); - - if ((!filename || !outfilename) && !sysinfo_dump) { - cerr << "Usage: " << argv[0] << " <file.scad> <output.png>\n"; - exit(1); - } - - Builtins::instance()->initialize(); - - fs::path original_path = fs::current_path(); - - std::string currentdir = boosty::stringy( fs::current_path() ); - - parser_init(boosty::stringy(fs::path(argv[0]).branch_path())); - add_librarydir(boosty::stringy(fs::path(argv[0]).branch_path() / "../libraries")); - - ModuleContext top_ctx; - top_ctx.registerBuiltin(); - - FileModule *root_module; - ModuleInstantiation root_inst("group"); - - if (sysinfo_dump) - root_module = parse("sphere();","",false); - else - root_module = parsefile(filename); - - if (!root_module) { - exit(1); - } - - if (!sysinfo_dump) { - fs::path fpath = boosty::absolute(fs::path(filename)); - fs::path fparent = fpath.parent_path(); - fs::current_path(fparent); - top_ctx.setDocumentPath(fparent.string()); - } - - AbstractNode::resetIndexCounter(); - AbstractNode *absolute_root_node = root_module->instantiate(&top_ctx, &root_inst); - AbstractNode *root_node; - // Do we have an explicit root node (! modifier)? - if (!(root_node = find_root_tag(absolute_root_node))) root_node = absolute_root_node; - - Tree tree(root_node); - - CsgInfo csgInfo = CsgInfo(); - if ( !csgInfo.compile_chains( tree ) ) return 1; - - fs::current_path(original_path); - - try { - csgInfo.glview = new OffscreenView(512,512); - } catch (int error) { - fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error); - exit(1); - } - - if (sysinfo_dump) cout << info_dump(csgInfo.glview); - Camera camera(Camera::VECTOR); - camera.center << 0,0,0; - double radius = 1.0; - - if (csgInfo.root_chain) { - BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); - camera.center = (bbox.min() + bbox.max()) / 2; - radius = (bbox.max() - bbox.min()).norm() / 2; - } - Vector3d cameradir(1, 1, -0.5); - camera.eye = camera.center - radius*1.8*cameradir; - csgInfo.glview->setCamera(camera); - - OpenCSGRenderer opencsgRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain, csgInfo.glview->shaderinfo); - ThrownTogetherRenderer thrownTogetherRenderer(csgInfo.root_chain, csgInfo.highlights_chain, csgInfo.background_chain); - - if (test_type == TEST_THROWNTOGETHER) - csgInfo.glview->setRenderer(&thrownTogetherRenderer); - else - csgInfo.glview->setRenderer(&opencsgRenderer); - - OpenCSG::setContext(0); - OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject); - - csgInfo.glview->paintGL(); - - if (outfilename) csgInfo.glview->save(outfilename); - - delete root_node; - delete root_module; - - Builtins::instance(true); - - return 0; -} diff --git a/tests/csgtestcore.h b/tests/csgtestcore.h deleted file mode 100644 index 330c894..0000000 --- a/tests/csgtestcore.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef CSGTESTCORE_H_ -#define CSGTESTCORE_H_ - -enum test_type_e { - TEST_THROWNTOGETHER, - TEST_OPENCSG -}; - -int csgtestcore(int argc, char *argv[], test_type_e test_type); - -#endif - diff --git a/tests/regression/cgalpngtest/resize-2d-tests-expected.png b/tests/regression/cgalpngtest/resize-2d-tests-expected.png Binary files differindex 44e9598..e764ac3 100644 --- a/tests/regression/cgalpngtest/resize-2d-tests-expected.png +++ b/tests/regression/cgalpngtest/resize-2d-tests-expected.png diff --git a/tests/regression/cgalpngtest/resize-tests-expected.png b/tests/regression/cgalpngtest/resize-tests-expected.png Binary files differindex 8f994bf..6a5bb32 100644 --- a/tests/regression/cgalpngtest/resize-tests-expected.png +++ b/tests/regression/cgalpngtest/resize-tests-expected.png diff --git a/tests/regression/dumptest/resize-2d-tests-expected.csg b/tests/regression/dumptest/resize-2d-tests-expected.csg index 5f8d8b5..5cd9a2e 100644 --- a/tests/regression/dumptest/resize-2d-tests-expected.csg +++ b/tests/regression/dumptest/resize-2d-tests-expected.csg @@ -173,4 +173,54 @@ group() { } } } + color([0, 0, 1, 1]) { + multmatrix([[1, 0, 0, -16], [0, 1, 0, -16], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [10,8,0], auto = [0,1,0]) { + multmatrix([[0.5, 0, 0, 0], [0, 100, 0, 0], [0, 0, 20, 0], [0, 0, 0, 1]]) { + group() { + difference() { + square(size = [5, 5], center = false); + multmatrix([[1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [1, 1], center = false); + } + multmatrix([[1, 0, 0, 3], [0, 1, 0, 3], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 10, $fa = 12, $fs = 2, r = 1); + } + } + } + } + } + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, -16], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [8,10,15], auto = [1,1,1]) { + multmatrix([[1000, 0, 0, 0], [0, 0.5, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + difference() { + square(size = [5, 5], center = false); + multmatrix([[1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [1, 1], center = false); + } + multmatrix([[1, 0, 0, 2], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [1, 1], center = false); + } + } + } + } + } + } + multmatrix([[1, 0, 0, 16], [0, 1, 0, -16], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [10,8,15], auto = [0,0,0]) { + multmatrix([[200, 0, 0, 0], [0, 200, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + difference() { + square(size = [5, 5], center = false); + multmatrix([[1, 0, 0, 0], [0, 1, 0, 2.5], [0, 0, 1, 0], [0, 0, 0, 1]]) { + square(size = [5, 1], center = false); + } + } + } + } + } + } + } } diff --git a/tests/regression/dumptest/resize-tests-expected.csg b/tests/regression/dumptest/resize-tests-expected.csg index 1e7888a..98fef74 100644 --- a/tests/regression/dumptest/resize-tests-expected.csg +++ b/tests/regression/dumptest/resize-tests-expected.csg @@ -237,35 +237,67 @@ group() { } } } - multmatrix([[1, 0, 0, 10], [0, 1, 0, 10], [0, 0, 1, -10], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { resize(newsize = [-5,0,0], auto = [0,0,0]) { cube(size = [1, 1, 1], center = false); } } - multmatrix([[1, 0, 0, 10], [0, 1, 0, 20], [0, 0, 1, -10], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { resize(newsize = [-5,0,0], auto = [0,0,0]) { cube(size = [1, 1, 1], center = false); } } - multmatrix([[1, 0, 0, 10], [0, 1, 0, 30], [0, 0, 1, -10], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 40], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { resize(newsize = [0,0,0], auto = [0,0,0]) { cube(size = [1, 1, 1], center = false); } } - multmatrix([[1, 0, 0, 10], [0, 1, 0, 40], [0, 0, 1, -10], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { resize(newsize = [0,0,0], auto = [0,0,0]) { cube(size = [1, 1, 1], center = false); } } - multmatrix([[1, 0, 0, 10], [0, 1, 0, 50], [0, 0, 1, -10], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 60], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { resize(newsize = [0.5,0,7], auto = [0,0,0]) { cube(size = [0.5, 1, 1000], center = false); } } - multmatrix([[1, 0, 0, 10], [0, 1, 0, 60], [0, 0, 1, -10], [0, 0, 0, 1]]) { + multmatrix([[1, 0, 0, 70], [0, 1, 0, 0], [0, 0, 1, -10], [0, 0, 0, 1]]) { resize(newsize = [0,0,0.5], auto = [0,0,0]) { cube(size = [6, 6, 1e+10], center = false); } } } + color([0, 1, 0, 1]) { + multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [5,0,0], auto = [1,1,0]) { + cube(size = [9, 9, 9], center = false); + } + } + multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [6,0,0], auto = [1,1,1]) { + cube(size = [9, 9, 9], center = false); + } + } + multmatrix([[1, 0, 0, 40], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [6,0,0], auto = [1,0,1]) { + cube(size = [9, 9, 9], center = false); + } + } + multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [5,0,20], auto = [0,1,1]) { + cube(size = [9, 9, 9], center = false); + } + } + multmatrix([[1, 0, 0, 60], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [0,0,7], auto = [0,0,1]) { + cube(size = [9, 9, 9], center = false); + } + } + multmatrix([[1, 0, 0, 70], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + resize(newsize = [6,0,0], auto = [1,1,0]) { + cube(size = [9, 9, 9], center = false); + } + } + } } diff --git a/tests/regression/echotest/rands-expected.txt b/tests/regression/echotest/rands-expected.txt new file mode 100644 index 0000000..36ac6cd --- /dev/null +++ b/tests/regression/echotest/rands-expected.txt @@ -0,0 +1,3 @@ +WARNING: Ignoring unknown variable 'v'. +ECHO: "i hope rands() did not crash" +ECHO: [1, 1, 1, 1] diff --git a/tests/regression/opencsgtest/resize-2d-tests-expected.png b/tests/regression/opencsgtest/resize-2d-tests-expected.png Binary files differindex d3bda96..83a1ca7 100644 --- a/tests/regression/opencsgtest/resize-2d-tests-expected.png +++ b/tests/regression/opencsgtest/resize-2d-tests-expected.png diff --git a/tests/regression/opencsgtest/resize-tests-expected.png b/tests/regression/opencsgtest/resize-tests-expected.png Binary files differindex 0334ba6..669835d 100644 --- a/tests/regression/opencsgtest/resize-tests-expected.png +++ b/tests/regression/opencsgtest/resize-tests-expected.png diff --git a/tests/regression/throwntogethertest/resize-2d-tests-expected.png b/tests/regression/throwntogethertest/resize-2d-tests-expected.png Binary files differindex 4737cf7..6c55fa9 100644 --- a/tests/regression/throwntogethertest/resize-2d-tests-expected.png +++ b/tests/regression/throwntogethertest/resize-2d-tests-expected.png diff --git a/tests/regression/throwntogethertest/resize-tests-expected.png b/tests/regression/throwntogethertest/resize-tests-expected.png Binary files differindex 7445c1c..669835d 100644 --- a/tests/regression/throwntogethertest/resize-tests-expected.png +++ b/tests/regression/throwntogethertest/resize-tests-expected.png diff --git a/tests/test_pretty_print.cc b/tests/test_pretty_print.cc index 227d8ad..b07bab5 100644 --- a/tests/test_pretty_print.cc +++ b/tests/test_pretty_print.cc @@ -7,7 +7,6 @@ #include <cstddef> #include <unistd.h> -//#include <stdio.h> #define PREQUOTE(x) #x #define QUOTE(x) PREQUOTE(x) @@ -18,7 +17,6 @@ int main( int argc, char * argv[] ) newargs[1] = const_cast<char *>(QUOTE( PYSRC )); newargs[2] = const_cast<char *>(QUOTE( BUILDDIR )); newargs[3] = NULL; - //printf(":%s:%s:%s\n", newargs[0], newargs[1], newargs[2]); return execv( newargs[0], newargs ); } diff --git a/tests/test_upload.py b/tests/test_upload.py deleted file mode 100755 index 59f4334..0000000 --- a/tests/test_upload.py +++ /dev/null @@ -1,307 +0,0 @@ -#!/usr/bin/python - -# test_upload.py copyright 2013 Don Bright <hugh.m.bright@gmail.com> -# released under Zlib-style license: -# -# This software is provided 'as-is', without any express or implied -# warranty. In no event will the authors be held liable for any damages -# arising from the use of this software. -# -# Permission is granted to anyone to use this software for any purpose, -# including commercial applications, and to alter it and redistribute it -# freely, subject to the following restrictions: -# -# 1. The origin of this software must not be misrepresented; you must -# not claim that you wrote the original software. If you use this -# software in a product, an acknowledgment in the product documentation -# would be appreciated but is not required. -# 2. Altered source versions must be plainly marked as such, and must -# not be misrepresented as being the original software. 3. This notice -# may not be removed or altered from any source distribution. -# -# This license is based on zlib license by Jean-loup Gailly and Mark Adler - - -# This script takes html output by test_pretty_print.py and uploads it -# to a web server into an 'openscad_tests' subdir over ssh using sftp. -# It then modifies the 'index.html' file in that directory to 'add to -# the list' of reports on the remote web server. - - -# -# Design -# -# On the remote web server there is a directory called 'openscad_tests' -# Inside of it is a file, 'index.html', that lists all the test reports -# stored in that directory. -# -# This script uploads the last report created by test_pretty_print.py -# Then it modifies the remote index.html file (if necessary) to display -# a link to the new test report. -# -# Each test report is a single .html file, with all of the .png images -# encoded directly into the file using the Data URI and base64 encoding. -# The name of the report file is something like OS_cpu_GLinfo_hash.html, like -# linux_x86_radeon_abcd.html -# -# See examples under 'usage()' below. -# -# Requirements for remote web server and local system: -# -# 1. Local system must have sftp access to remote server -# This can be tested by runnig this: sftp user@remotehost -# If you are using ssh-agent or an ssh-keyring it will go automatically. -# Otherwise it will request your password to be typed in. -# -# 2. Remote web server only needs static html. There is no requirement -# for php/cgi/etc. -# -# 3. Local system must have the python Paramiko library installed, -# which in turn requires pycript to also be installed. (to PYTHONPATH) -# -# This script returns '1' on failure, '0' on success (shell-style) -# - -# todo: support plain old ftp ?? -# todo: support new-fangled sites like dropbox ?? - -import sys,os,platform,string,getpass - -try: - import paramiko -except: - x=''' -please install the paramiko python library in your PYTHONPATH -If that is not feasible, you can upload the single html report -file by hand to any site that accepts html code. -''' - -from test_pretty_print import ezsearch, read_sysinfo -from test_cmdline_tool import execute_and_redirect - -debug_test_upload = False -dryrun = False -bytecount = 0 - -def help(): - text=''' -test_upload.py - -usage: - - test_upload.py --username=uname --host=host --remotepath=/some/path \ - [--dryrun] [--debug] - -example1: - - $ ctest # result is Testing/Temporary/linux_x86_nvidia_report_abcd.html - $ test_upload.py --username=andreis --host=web.sourceforge.net --remotepath=/home/project-web/projectxyz/htdocs/ - $ firefox http://projectxyz.sourceforge.net/openscad_tests/index.html - # this should display a page with a link to show the test results - -example2: - - $ # run under X11, then run under Xvfb, upload both reports to one site - $ ctest # X11 - result is Testing/Temporary/freebsd_x86_nvidia_abc_report.html - $ test_upload.py --username=annag --host=fontanka.org --remotepath=/var/www/ - $ export DISPLAY= # dont use 'display' X, use Xvfb (different drivers) - $ ctest # XVfb - result is Testing/Temporary/freebsd_x86_mesa_xyz_report.html - $ test_upload.py --username=annag --host=fontanka.org --remotepath=/var/www/ - $ firefox http://fontanka.org/openscad_tests/index.html - # result is 'index.html' with a link to the two separate test .html files - -''' - print text - - -def debug(x): - if debug_test_upload: - print 'test_upload.py:', x - sys.stdout.flush() - - -blankchunk='''<!-- __entry__ -->''' - -index_template=''' -<html> -<head> -OpenSCAD regression test results -</head> -<body> - <h3> - OpenSCAD regression test results - </h3> - <ul> -''' + blankchunk + ''' - </ul> -</body> -</html> -''' - -entry_template=''' - <li><a href="__href__">__rept_name__</a></li> -''' - - -def paramiko_upload( newrept_fname, username, host, remotepath ): - global bytecount - debug("running paramiko upload") - - basepath = 'openscad_tests' - newrept_basefname = os.path.basename( newrept_fname ) - newrept_name = string.split( newrept_basefname,'.html')[0] - debug("local file: "+ newrept_fname ) - debug("base filename: "+ newrept_basefname ) - debug("report name: "+ newrept_name ) - - - - debug("connect to " + username + "@" + host) - client = paramiko.SSHClient() - client.set_missing_host_key_policy(paramiko.AutoAddPolicy) - client.load_system_host_keys() - if dryrun: - debug("dryrun: no client.connect()") - return 0 - try: - client.connect(host,username=username) - except paramiko.PasswordRequiredException, e: - passw = getpass.getpass('enter passphrase for private ssh key: ') - client.connect(host,username=username,password=passw) - - #stdin,stdout,stderr=client.exec_command('ls -l') - - - - debug("find remote path: " + remotepath) - ftp = client.open_sftp() - try: - ftp.chdir( remotepath ) - except: - debug("failed to change dir to remote path: "+remotepath) - return 1 - debug("find basepath ( or create ):" + basepath ) - if not basepath in ftp.listdir(): - ftp.mkdir( basepath ) - ftp.chdir( basepath ) - - - - debug("upload local report file to remote file:") - debug(" local:"+newrept_fname) - localf = open( newrept_fname, 'r' ) - rept_text = localf.read() - localf.close() - debug(" bytes read:"+str(len(rept_text))) - - debug("remote:"+os.path.join(ftp.getcwd(),newrept_basefname)) - f = ftp.file( newrept_basefname, 'w+' ) - f.write( rept_text ) - f.close() - bytecount += len(rept_text) - - - debug( "file uploaded. now, update index.html (or create blank) ") - - if not 'index.html' in ftp.listdir(): - f = ftp.file( 'index.html', 'w+') - f.write(index_template) - f.close() - bytecount += len(index_template) - - f = ftp.file( 'index.html', 'r' ) - text = f.read() - f.close() - - text2 = entry_template - text2 = text2.replace( '__href__', newrept_basefname ) - text2 = text2.replace( '__rept_name__', newrept_name ) - - if newrept_basefname in text: - debug( newrept_basefname + " already linked from index.html") - else: - debug("add new report link to index.html") - text = text.replace( blankchunk, blankchunk+'\n'+text2 ) - - f = ftp.file( 'index.html', 'w+' ) - f.write(text) - f.close() - bytecount += len(text) - - debug("close connections") - ftp.close() - client.close() - return 0 - -def upload_unix( reptfile, username, host, remotepath): - debug("detected unix-like system.") - return paramiko_upload( reptfile, username, host, remotepath ) - -def upload_darwin( reptfile, username, host, remotepath ): - debug("detected osx/darwin") - return upload_unix( reptfile, username, host, remotepath ) - -def upload_windows( reptfile, username, host, remotepath ): - debug("detected windows") - print 'sorry, not implemented on windows' - return 1 - # use pycript and paramiko - # the problem is downloading them and installing them - -def upload( reptfile, username, host, remotepath ): - sysname = platform.system().lower() - result = 1 - if 'linux' in sysname or 'bsd' in sysname: - result = upload_unix( reptfile, username, host, remotepath ) - elif 'darwin' in sysname: - result = upload_darwin( reptfile, username, host, remotepath ) - elif 'windows' in platform.system(): - result = upload_windows( reptfile, username, host, remotepath ) - else: - print "unknown system type. cant upload, sorry" - return result - -def main(): - if '--debug' in string.join(sys.argv): - global debug_test_upload - debug_test_upload = True - if '--dryrun' in string.join(sys.argv): - global dryrun - dryrun = True - - debug('running test_upload') - debug('args: '+str(sys.argv[1:])) - - builddir = ezsearch('--builddir=(.*?) ',string.join(sys.argv)+' ') - if builddir=='': builddir=os.getcwd() - sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) - debug("sysinfo: " + sysinfo[0:60].replace('\n','') + ". . . ") - debug("sysid: " + sysid ) - if len(sysid)<6: - print "unable to find valid system id" - sys.exit(1) - - rept_basename = sysid + '_report' + '.html' - rept_fname = os.path.join(builddir,'Testing','Temporary',rept_basename ) - debug("report filename:\n" + rept_fname ) - - username = ezsearch('--username=(.*?) ',string.join(sys.argv)+' ') - host = ezsearch('--host=(.*?) ',string.join(sys.argv)+' ') - remotepath = ezsearch('--remotepath=(.*?) ',string.join(sys.argv)+' ') - - if rept_fname=='' or username=='' or host=='' or remotepath=='': - help() - sys.exit(1) - - res = upload( rept_fname, username, host, remotepath ) - if res==1: - print "upload failed" - return 1 - else: - print "upload complete:", bytecount, "bytes written" - return 0 - - -if __name__ == '__main__': - sys.exit(main()) - diff --git a/tests/throwntogethertest.cc b/tests/throwntogethertest.cc deleted file mode 100644 index 5a4f14f..0000000 --- a/tests/throwntogethertest.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include "csgtestcore.h" - -int main(int argc, char* argv[]) { - return csgtestcore(argc, argv, TEST_THROWNTOGETHER); -} |