Merge branch 'master' into list-comprehensions

master
Marius Kintel 2014-05-25 16:00:10 -04:00
commit 38c24fe006
30 changed files with 451 additions and 263 deletions

View File

@ -5,8 +5,11 @@ compiler: gcc
before_install:
- echo 'yes' | sudo add-apt-repository ppa:chrysn/openscad
- sudo apt-get update -qq
- sudo apt-get install -qq build-essential libqt4-dev libqt4-opengl-dev libxmu-dev cmake bison flex git-core libboost-all-dev libXi-dev libmpfr-dev libboost-dev libglew-dev libeigen2-dev libeigen3-dev libcgal-dev libgmp3-dev libgmp-dev python-paramiko curl imagemagick
- sudo apt-get install -qq build-essential libqt4-dev libqt4-opengl-dev libxmu-dev cmake bison flex git-core libboost-all-dev libXi-dev libmpfr-dev libboost-dev libglew-dev libeigen3-dev libcgal-dev libgmp3-dev libgmp-dev curl imagemagick libfontconfig-dev
- sudo apt-get install -qq libopencsg-dev
- echo 'yes' | sudo add-apt-repository ppa:mapnik/nightly-trunk
- sudo apt-get update -qq
- sudo apt-get install -qq libharfbuzz-dev
branches:
only:

View File

@ -1,6 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!--
(cc) Michael Thomson <openscad.org@m-thomson.net>
OpenSCAD syntax highlights in BBEdit/TextWrangler by Michael Thomson
is licensed under a Creative Commons Attribution 4.0 International License.
http://creativecommons.org/licenses/by/4.0/
Master copy in OpenSCAD Distribution:
https://github.com/openscad/openscad/tree/master/contrib
Also Published on Thingiverse:
http://www.thingiverse.com/thing:15244/
Based on OpenSCAD 2014.03, documented here:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
Version History
2011-12-31 Initial version
2014-05-24 Updated for OpenSCAD 2014.03
-->
<dict>
<key>BBEditDocumentType</key>
<string>CodelessLanguageModule</string>
@ -10,52 +31,150 @@
<true/>
<key>BBLMIsCaseSensitive</key>
<true/>
<key>BBLMPredefinedNameList</key>
<array>
<!-- Special constants -->
<string>true</string>
<string>false</string>
<string>undef</string>
<string>PI</string>
<!-- Parameters -->
<string>auto</string>
<string>center</string>
<string>invert</string>
<string>size</string>
<string>points</string>
<string>faces</string>
<string>convexity</string>
<string>file</string>
<string>layer</string>
<string>origin</string>
<!-- Modifier Characters -->
<string>%</string>
<string>#</string> <!-- Not highlighted? -->
<string>!</string>
<string>*</string>
<!-- Special Variables -->
<string>$fa</string>
<string>$fs</string>
<string>$fn</string>
<string>$t</string>
<string>$vpr</string>
<string>$vpt</string>
</array>
<key>BBLMKeywordList</key>
<array>
<string>!</string>
<string>#</string>
<string>$fa</string>
<string>$fn</string>
<string>$fs</string>
<string>$t</string>
<string>%</string>
<string>*</string>
<string>assign</string>
<string>center</string>
<string>circle</string>
<string>color</string>
<string>cube</string>
<string>cylinder</string>
<string>difference</string>
<string>echo</string>
<string>for</string>
<string>function</string>
<string>hull</string>
<string>if</string>
<string>import_dxf</string>
<string>import_stl</string>
<string>include</string>
<string>intersection</string>
<string>intersection_for</string>
<string>linear_extrude</string>
<string>minkowski</string>
<string>mirror</string>
<string>module</string>
<string>multmatrix</string>
<string>polygon</string>
<string>polyhedron</string>
<string>projection</string>
<string>render</string>
<string>rotate</string>
<string>rotate_extrude</string>
<string>scale</string>
<string>sphere</string>
<!--
Based on OpenSCAD 2014.3, documented here:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
-->
<!-- 2D Primitives -->
<string>square</string>
<string>circle</string>
<string>polygon</string>
<!-- Primitive Solids -->
<string>cube</string>
<string>sphere</string>
<string>cylinder</string>
<string>polyhedron</string>
<!-- Conditional and Iterator Functions -->
<string>for</string>
<string>intersection_for</string>
<string>if</string>
<string>else</string>
<string>assign</string>
<!-- Mathematical Operators -->
<string>?</string> <!-- Not highlighted? -->
<!-- Trigonometric Functions -->
<string>cos</string>
<string>sin</string>
<string>tan</string>
<string>acos</string>
<string>asin</string>
<string>atan</string>
<string>atan2</string>
<!-- Other Mathematical Functions -->
<string>abs</string>
<string>ceil</string>
<string>cross</string>
<string>exp</string>
<string>floor</string>
<string>ln</string>
<string>len</string>
<string>log</string>
<string>lookup</string>
<string>max</string>
<string>min</string>
<string>norm</string>
<string>pow</string>
<string>rands</string>
<string>round</string>
<string>sign</string>
<string>sqrt</string>
<!-- String Functions -->
<string>str</string>
<string>surface</string>
<!-- Transformations -->
<string>scale</string>
<string>rotate</string>
<string>translate</string>
<string>resize</string>
<string>mirror</string>
<string>multmatrix</string>
<string>color</string>
<string>minkowski</string>
<string>hull</string>
<!-- CSG Modelling -->
<string>union</string>
<string>difference</string>
<string>intersection</string>
<string>linear_extrude</string>
<!-- Modules -->
<string>module</string>
<string>children</string>
<string>function</string>
<!-- Importing Geometry -->
<string>import</string>
<string>include</string>
<string>use</string>
<string>dxf_cross</string>
<!-- Other Language Features -->
<!-- Echo Statements -->
<string>echo</string>
<!-- Render -->
<string>render</string>
<!-- Offset -->
<string>offset</string>
<!-- Surface -->
<string>surface</string>
<!-- Search -->
<string>search</string>
<!-- OpenSCAD Version -->
<string>version</string>
<string>version_num</string>
<string>parent_module</string>
<string>$parent_modules</string>
</array>
<key>BBLMLanguageCode</key>
<string>Oscd</string>

View File

@ -3,10 +3,10 @@
;; Author: Len Trigg
;; Maintainer: Len Trigg <lenbok@gmail.com>
;; Created: March 2010
;; Modified: 06 July 2012
;; Modified: 24 May 2014
;; Keywords: languages
;; URL: https://raw.github.com/openscad/openscad/master/contrib/scad-mode.el
;; Version: 90.0
;; Version: 91.0
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@ -143,6 +143,7 @@
(defvar scad-font-lock-keywords
`(
("\\(module\\|function\\)[ \t]+\\(\\sw+\\)" (1 'font-lock-keyword-face nil) (2 'font-lock-function-name-face nil t))
("\\(use\\|include\\)[ \t]*<\\([^>]+\\)>" (1 'font-lock-preprocessor-face nil) (2 'font-lock-type-face nil t))
("<\\(\\sw+\\)>" (1 'font-lock-builtin-face nil))
("$\\(\\sw+\\)" (1 'font-lock-builtin-face nil))
(,scad-keywords-regexp . font-lock-keyword-face)
@ -173,14 +174,24 @@
)
;; From: http://stackoverflow.com/questions/14520073/add-words-for-dynamic-expansion-to-emacs-mode
(defun scad-prime-dabbrev ()
"Makes a hidden scad-mode buffer containing all the scad keywords, so dabbrev expansion just works."
(unless (get-buffer " *scad words*")
(with-current-buffer (get-buffer-create " *scad words*")
(scad-mode)
(insert "module function use include") ; Explicitly add these -- they're not in the below vars
(insert (mapconcat 'identity (append scad-keywords scad-functions scad-modules) " ")))))
(add-hook 'scad-mode-hook 'scad-prime-dabbrev)
;;; Indentation, based on http://www.emacswiki.org/emacs/download/actionscript-mode-haas-7.0.el
(defun scad-indent-line ()
"Indent current line of SCAD code."
(interactive)
(let ((savep (> (current-column) (current-indentation)))
(indent (condition-case nil (max (scad-calculate-indentation) 0)
(error 0))))
(indent (max (scad-calculate-indentation) 0)))
(if savep
(save-excursion (indent-line-to indent))
(indent-line-to indent))))
@ -224,9 +235,9 @@
;; Don't count if in string or comment.
((scad-face-at-point (- (point) 1)))
((looking-back "\\s)")
(incf close-count))
(setq close-count (+ close-count 1)))
((looking-back "\\s(")
(incf open-count))
(setq open-count (+ open-count 1)))
)))
(- open-count close-count))))

View File

@ -721,8 +721,8 @@ build_gettext 0.18.3.1
build_libffi 3.0.13
build_glib2 2.38.2
build_opencsg 1.3.2
build_harfbuzz 0.9.27 "--with-coretext=auto --with-glib=no"
build_freetype 2.5.3 --without-png
build_harfbuzz 0.9.27 "--with-coretext=auto --with-glib=no"
export FREETYPE_CFLAGS="-I$DEPLOYDIR/include -I$DEPLOYDIR/include/freetype2"
export FREETYPE_LIBS="-L$DEPLOYDIR/lib -lfreetype"
build_libxml2 2.9.1

View File

@ -40,7 +40,7 @@
//#include "Preferences.h"
CGALRenderer::CGALRenderer(shared_ptr<const class Geometry> geom) : polyhedron(NULL)
CGALRenderer::CGALRenderer(shared_ptr<const class Geometry> geom)
{
if (shared_ptr<const PolySet> ps = dynamic_pointer_cast<const PolySet>(geom)) {
this->polyset = ps;
@ -51,7 +51,7 @@ CGALRenderer::CGALRenderer(shared_ptr<const class Geometry> geom) : polyhedron(N
else if (shared_ptr<const CGAL_Nef_polyhedron> new_N = dynamic_pointer_cast<const CGAL_Nef_polyhedron>(geom)) {
assert(new_N->getDimension() == 3);
if (!new_N->isEmpty()) {
this->polyhedron = new Polyhedron();
this->polyhedron.reset(new Polyhedron());
// FIXME: Make independent of Preferences
// this->polyhedron->setColor(Polyhedron::CGAL_NEF3_MARKED_FACET_COLOR,
// Preferences::inst()->color(Preferences::CGAL_FACE_BACK_COLOR).red(),
@ -62,7 +62,7 @@ CGALRenderer::CGALRenderer(shared_ptr<const class Geometry> geom) : polyhedron(N
// Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).green(),
// Preferences::inst()->color(Preferences::CGAL_FACE_FRONT_COLOR).blue());
CGAL::OGL::Nef3_Converter<CGAL_Nef_polyhedron3>::convert_to_OGLPolyhedron(*new_N->p3, this->polyhedron);
CGAL::OGL::Nef3_Converter<CGAL_Nef_polyhedron3>::convert_to_OGLPolyhedron(*new_N->p3, this->polyhedron.get());
this->polyhedron->init();
}
}
@ -70,7 +70,6 @@ CGALRenderer::CGALRenderer(shared_ptr<const class Geometry> geom) : polyhedron(N
CGALRenderer::~CGALRenderer()
{
delete this->polyhedron;
}
void CGALRenderer::draw(bool showfaces, bool showedges) const

View File

@ -10,6 +10,6 @@ public:
void draw(bool showfaces, bool showedges) const;
public:
class Polyhedron *polyhedron;
shared_ptr<class Polyhedron> polyhedron;
shared_ptr<const class PolySet> polyset;
};

View File

@ -23,8 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef DRAWINGCALLBACK_H
#define DRAWINGCALLBACK_H
#pragma once
#include <vector>
#include <math.h>
@ -62,6 +61,3 @@ private:
return pow(1.0 - t, exp);
}
};
#endif /* DRAWINGCALLBACK_H */

View File

@ -23,8 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef FONTCACHE_H
#define FONTCACHE_H
#pragma once
#include <map>
#include <string>
@ -96,5 +95,3 @@ private:
FT_Face find_face_in_path(std::string path, std::string font);
};
#endif /* FONTCACHE_H */

View File

@ -1,5 +1,4 @@
#ifndef FONTLISTDIALOG_H_
#define FONTLISTDIALOG_H_
#pragma once
#include <QStandardItemModel>
@ -19,5 +18,3 @@ public:
private:
QStandardItemModel *model;
};
#endif

View File

@ -23,8 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef FREETYPERENDERER_H
#define FREETYPERENDERER_H
#pragma once
#include <string>
#include <vector>
@ -87,7 +86,7 @@ public:
double size, spacing, fn;
std::string text, font, direction, language, script, halign, valign;
friend FreetypeRenderer;
friend class FreetypeRenderer;
};
FreetypeRenderer();
@ -136,6 +135,3 @@ private:
static int outline_conic_to_func(const FT_Vector *c1, const FT_Vector *to, void *user);
static int outline_cubic_to_func(const FT_Vector *c1, const FT_Vector *c2, const FT_Vector *to, void *user);
};
#endif /* FREETYPERENDERER_H */

View File

@ -1,5 +1,4 @@
#ifndef GEOMETRY_H_
#define GEOMETRY_H_
#pragma once
#include <stddef.h>
#include <string>
@ -29,5 +28,3 @@ public:
protected:
int convexity;
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef GEOMETRYCACHE_H_
#define GEOMETRYCACHE_H_
#pragma once
#include "cache.h"
#include "memory.h"
@ -32,5 +31,3 @@ private:
Cache<std::string, cache_entry> cache;
};
#endif

View File

@ -97,13 +97,14 @@ GeometryEvaluator::ResultObject GeometryEvaluator::applyToChildren3D(const Abstr
if (children.size() == 0) return ResultObject();
if (op == OPENSCAD_HULL) {
CGAL_Polyhedron P;
if (CGALUtils::applyHull(children, P)) {
return ResultObject(new CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron3(P)));
}
else {
return ResultObject();
PolySet *ps = new PolySet(3);
if (CGALUtils::applyHull(children, *ps)) {
return ps;
}
delete ps;
return ResultObject();
}
// Only one child -> this is a noop
@ -150,10 +151,11 @@ Geometry *GeometryEvaluator::applyHull3D(const AbstractNode &node)
{
Geometry::ChildList children = collectChildren3D(node);
CGAL_Polyhedron P;
if (CGALUtils::applyHull(children, P)) {
return new CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron3(P));
PolySet *P = new PolySet(3);
if (CGALUtils::applyHull(children, *P)) {
return P;
}
delete P;
return NULL;
}

View File

@ -2,6 +2,7 @@
#include "PlatformUtils.h"
#include "boosty.h"
#include <Eigen/Core>
extern std::vector<std::string> librarypath;

View File

@ -1,5 +1,4 @@
#ifndef POLYGON2D_H_
#define POLYGON2D_H_
#pragma once
#include "Geometry.h"
#include "linalg.h"
@ -36,5 +35,3 @@ private:
Outlines2d theoutlines;
bool sanitized;
};
#endif

View File

@ -9,6 +9,7 @@
#include "cgal.h"
#include <CGAL/convex_hull_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include "svg.h"
#include "Reindexer.h"
@ -17,25 +18,26 @@
namespace CGALUtils {
bool applyHull(const Geometry::ChildList &children, CGAL_Polyhedron &result)
bool applyHull(const Geometry::ChildList &children, PolySet &result)
{
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
// Collect point cloud
std::vector<CGAL_Polyhedron::Vertex::Point_3> points;
CGAL_Polyhedron P;
std::set<K::Point_3> points;
BOOST_FOREACH(const Geometry::ChildItem &item, children) {
const shared_ptr<const Geometry> &chgeom = item.second;
const CGAL_Nef_polyhedron *N = dynamic_cast<const CGAL_Nef_polyhedron *>(chgeom.get());
if (N) {
for (CGAL_Nef_polyhedron3::Vertex_const_iterator i = N->p3->vertices_begin(); i != N->p3->vertices_end(); ++i) {
points.push_back(i->point());
points.insert(K::Point_3(to_double(i->point()[0]),to_double(i->point()[1]),to_double(i->point()[2])));
}
}
else {
} else {
const PolySet *ps = dynamic_cast<const PolySet *>(chgeom.get());
BOOST_FOREACH(const PolySet::Polygon &p, ps->polygons) {
BOOST_FOREACH(const Vector3d &v, p) {
points.push_back(CGAL_Polyhedron::Vertex::Point_3(v[0], v[1], v[2]));
if (ps) {
BOOST_FOREACH(const PolySet::Polygon &p, ps->polygons) {
BOOST_FOREACH(const Vector3d &v, p) {
points.insert(K::Point_3(v[0], v[1], v[2]));
}
}
}
}
@ -43,23 +45,13 @@ namespace CGALUtils {
if (points.size() <= 3) return false;
// Remove all duplicated points (speeds up the convex_hull computation significantly)
std::vector<CGAL_Polyhedron::Vertex::Point_3> unique_points;
Grid3d<int> grid(GRID_FINE);
BOOST_FOREACH(CGAL_Polyhedron::Vertex::Point_3 const& p, points) {
double x = to_double(p.x()), y = to_double(p.y()), z = to_double(p.z());
int& v = grid.align(x,y,z);
if (v == 0) {
unique_points.push_back(CGAL_Polyhedron::Vertex::Point_3(x,y,z));
v = 1;
}
}
// Apply hull
if (points.size() >= 4) {
CGAL::convex_hull_3(unique_points.begin(), unique_points.end(), result);
return true;
CGAL::Polyhedron_3<K> r;
CGAL::convex_hull_3(points.begin(), points.end(), r);
if (!createPolySetFromPolyhedron(r, result))
return true;
return false;
} else {
return false;
}
@ -345,41 +337,34 @@ namespace CGALUtils {
};
bool createPolySetFromPolyhedron(const CGAL_Polyhedron &p, PolySet &ps)
template <typename Polyhedron>
bool createPolySetFromPolyhedron(const Polyhedron &p, PolySet &ps)
{
bool err = false;
typedef CGAL_Polyhedron::Vertex Vertex;
typedef CGAL_Polyhedron::Vertex_const_iterator VCI;
typedef CGAL_Polyhedron::Facet_const_iterator FCI;
typedef CGAL_Polyhedron::Halfedge_around_facet_const_circulator HFCC;
typedef typename Polyhedron::Vertex Vertex;
typedef typename Polyhedron::Vertex_const_iterator VCI;
typedef typename Polyhedron::Facet_const_iterator FCI;
typedef typename Polyhedron::Halfedge_around_facet_const_circulator HFCC;
for (FCI fi = p.facets_begin(); fi != p.facets_end(); ++fi) {
HFCC hc = fi->facet_begin();
HFCC hc_end = hc;
Vertex v1, v2, v3;
v1 = *VCI((hc++)->vertex());
v3 = *VCI((hc++)->vertex());
ps.append_poly();
do {
v2 = v3;
v3 = *VCI((hc++)->vertex());
double x1 = CGAL::to_double(v1.point().x());
double y1 = CGAL::to_double(v1.point().y());
double z1 = CGAL::to_double(v1.point().z());
double x2 = CGAL::to_double(v2.point().x());
double y2 = CGAL::to_double(v2.point().y());
double z2 = CGAL::to_double(v2.point().z());
double x3 = CGAL::to_double(v3.point().x());
double y3 = CGAL::to_double(v3.point().y());
double z3 = CGAL::to_double(v3.point().z());
ps.append_poly();
ps.append_vertex(x1, y1, z1);
ps.append_vertex(x2, y2, z2);
ps.append_vertex(x3, y3, z3);
Vertex const& v = *((hc++)->vertex());
double x = CGAL::to_double(v.point().x());
double y = CGAL::to_double(v.point().y());
double z = CGAL::to_double(v.point().z());
ps.append_vertex(x, y, z);
} while (hc != hc_end);
}
return err;
}
template bool createPolySetFromPolyhedron(const CGAL_Polyhedron &p, PolySet &ps);
template bool createPolySetFromPolyhedron(const CGAL::Polyhedron_3<CGAL::Epick> &p, PolySet &ps);
/////// Tessellation begin
typedef CGAL::Plane_3<CGAL_Kernel3> CGAL_Plane_3;

View File

@ -6,7 +6,7 @@
#include "enums.h"
namespace CGALUtils {
bool applyHull(const Geometry::ChildList &children, CGAL_Polyhedron &P);
bool applyHull(const Geometry::ChildList &children, PolySet &P);
void applyOperator(const Geometry::ChildList &children, CGAL_Nef_polyhedron &dest, OpenSCADOperator op);
void applyBinaryOperator(CGAL_Nef_polyhedron &target, const CGAL_Nef_polyhedron &src, OpenSCADOperator op);
Polygon2d *project(const CGAL_Nef_polyhedron &N, bool cut);
@ -14,7 +14,7 @@ namespace CGALUtils {
};
CGAL_Nef_polyhedron *createNefPolyhedronFromGeometry(const class Geometry &geom);
bool createPolySetFromPolyhedron(const CGAL_Polyhedron &p, PolySet &ps);
template <typename Polyhedron> bool createPolySetFromPolyhedron(const Polyhedron &p, PolySet &ps);
bool createPolySetFromNefPolyhedron3(const CGAL_Nef_polyhedron3 &N, PolySet &ps);
bool createPolyhedronFromPolySet(const PolySet &ps, CGAL_Polyhedron &p);

View File

@ -1,5 +1,4 @@
#ifndef CLIPPER_UTILS_H_
#define CLIPPER_UTILS_H_
#pragma once
#include "polyclipping/clipper.hpp"
#include "Polygon2d.h"
@ -20,5 +19,3 @@ namespace ClipperUtils {
Polygon2d *apply(const std::vector<const Polygon2d*> &polygons, ClipperLib::ClipType);
Polygon2d *apply(const std::vector<ClipperLib::Paths> &pathsvector, ClipperLib::ClipType);
};
#endif

View File

@ -213,7 +213,7 @@ Value builtin_min(const Context *, const EvalContext *evalctx)
if (n == 1 && v0.type() == Value::VECTOR && !v0.toVector().empty()) {
Value min = v0.toVector()[0];
for (int i = 1; i < v0.toVector().size(); i++) {
for (size_t i = 1; i < v0.toVector().size(); i++) {
if (v0.toVector()[i] < min)
min = v0.toVector()[i];
}
@ -246,7 +246,7 @@ Value builtin_max(const Context *, const EvalContext *evalctx)
if (n == 1 && v0.type() == Value::VECTOR && !v0.toVector().empty()) {
Value max = v0.toVector()[0];
for (int i = 1; i < v0.toVector().size(); i++) {
for (size_t i = 1; i < v0.toVector().size(); i++) {
if (v0.toVector()[i] > max)
max = v0.toVector()[i];
}
@ -620,6 +620,85 @@ Value builtin_lookup(const Context *, const EvalContext *evalctx)
*/
#pragma clang diagnostic ignored "-Wlogical-op-parentheses"
static Value::VectorType search(const std::string &find, const std::string &table,
unsigned int num_returns_per_match, unsigned int index_col_num)
{
Value::VectorType returnvec;
//Unicode glyph count for the length
size_t findThisSize = g_utf8_strlen(find.c_str(), find.size());
size_t searchTableSize = g_utf8_strlen(table.c_str(), table.size());
for (size_t i = 0; i < findThisSize; i++) {
unsigned int matchCount = 0;
Value::VectorType resultvec;
for (size_t j = 0; j < searchTableSize; j++) {
const gchar *ptr_ft = g_utf8_offset_to_pointer(find.c_str(), i);
const gchar *ptr_st = g_utf8_offset_to_pointer(table.c_str(), j);
if (ptr_ft && ptr_st && (g_utf8_get_char(ptr_ft) == g_utf8_get_char(ptr_st)) ) {
matchCount++;
if (num_returns_per_match == 1) {
returnvec.push_back(Value(double(j)));
break;
} else {
resultvec.push_back(Value(double(j)));
}
if (num_returns_per_match > 1 && matchCount >= num_returns_per_match) {
break;
}
}
}
if (matchCount == 0) {
gchar *ptr_ft = g_utf8_offset_to_pointer(find.c_str(), i);
gchar utf8_of_cp[6] = ""; //A buffer for a single unicode character to be copied into
if (ptr_ft) g_utf8_strncpy(utf8_of_cp, ptr_ft, 1);
PRINTB(" WARNING: search term not found: \"%s\"", utf8_of_cp);
}
if (num_returns_per_match == 0 || num_returns_per_match > 1) {
returnvec.push_back(Value(resultvec));
}
}
return returnvec;
}
static Value::VectorType search(const std::string &find, const Value::VectorType &table,
unsigned int num_returns_per_match, unsigned int index_col_num)
{
Value::VectorType returnvec;
//Unicode glyph count for the length
unsigned int findThisSize = g_utf8_strlen(find.c_str(), find.size());
unsigned int searchTableSize = table.size();
for (size_t i = 0; i < findThisSize; i++) {
unsigned int matchCount = 0;
Value::VectorType resultvec;
for (size_t j = 0; j < searchTableSize; j++) {
const gchar *ptr_ft = g_utf8_offset_to_pointer(find.c_str(), i);
const gchar *ptr_st = g_utf8_offset_to_pointer(table[j].toVector()[index_col_num].toString().c_str(), 0);
if (ptr_ft && ptr_st && (g_utf8_get_char(ptr_ft) == g_utf8_get_char(ptr_st)) ) {
matchCount++;
if (num_returns_per_match == 1) {
returnvec.push_back(Value(double(j)));
break;
} else {
resultvec.push_back(Value(double(j)));
}
if (num_returns_per_match > 1 && matchCount >= num_returns_per_match) {
break;
}
}
}
if (matchCount == 0) {
const gchar *ptr_ft = g_utf8_offset_to_pointer(find.c_str(), i);
gchar utf8_of_cp[6] = ""; //A buffer for a single unicode character to be copied into
if (ptr_ft) g_utf8_strncpy(utf8_of_cp, ptr_ft, 1);
PRINTB(" WARNING: search term not found: \"%s\"", utf8_of_cp);
}
if (num_returns_per_match == 0 || num_returns_per_match > 1) {
returnvec.push_back(Value(resultvec));
}
}
return returnvec;
}
Value builtin_search(const Context *, const EvalContext *evalctx)
{
if (evalctx->numArgs() < 2) return Value();
@ -637,59 +716,20 @@ Value builtin_search(const Context *, const EvalContext *evalctx)
for (size_t j = 0; j < searchTable.toVector().size(); j++) {
const Value& search_element = searchTable.toVector()[j];
if (index_col_num == 0 && findThis == search_element
||
index_col_num < search_element.toVector().size() &&
findThis == search_element.toVector()[index_col_num])
{
if (index_col_num == 0 && findThis == search_element ||
index_col_num < search_element.toVector().size() &&
findThis == search_element.toVector()[index_col_num]) {
returnvec.push_back(Value(double(j)));
matchCount++;
if (num_returns_per_match != 0 && matchCount >= num_returns_per_match) break;
}
}
} else if (findThis.type() == Value::STRING) {
unsigned int searchTableSize;
//Unicode glyph count for the length
unsigned int findThisSize = g_utf8_strlen( findThis.toString().c_str(), findThis.toString().size() );
if (searchTable.type() == Value::STRING) {
searchTableSize = g_utf8_strlen( searchTable.toString().c_str(), searchTable.toString().size() );
} else {
searchTableSize = searchTable.toVector().size();
returnvec = search(findThis.toString(), searchTable.toString(), num_returns_per_match, index_col_num);
}
for (size_t i = 0; i < findThisSize; i++) {
unsigned int matchCount = 0;
Value::VectorType resultvec;
for (size_t j = 0; j < searchTableSize; j++) {
gchar* ptr_ft = g_utf8_offset_to_pointer(findThis.toString().c_str(), i);
gchar* ptr_st = NULL;
if(searchTable.type() == Value::VECTOR) {
ptr_st = g_utf8_offset_to_pointer(searchTable.toVector()[j].toVector()[index_col_num].toString().c_str(), 0);
} else if(searchTable.type() == Value::STRING){
ptr_st = g_utf8_offset_to_pointer(searchTable.toString().c_str(), j);
}
if( (ptr_ft) && (ptr_st) && (g_utf8_get_char(ptr_ft) == g_utf8_get_char(ptr_st)) ) {
Value resultValue((double(j)));
matchCount++;
if (num_returns_per_match == 1) {
returnvec.push_back(resultValue);
break;
} else {
resultvec.push_back(resultValue);
}
if (num_returns_per_match > 1 && matchCount >= num_returns_per_match) break;
}
}
if (matchCount == 0) {
gchar* ptr_ft = g_utf8_offset_to_pointer(findThis.toString().c_str(), i);
gchar utf8_of_cp[6] = ""; //A buffer for a single unicode character to be copied into
if(ptr_ft) {
g_utf8_strncpy( utf8_of_cp, ptr_ft, 1 );
}
PRINTB(" WARNING: search term not found: \"%s\"", utf8_of_cp );
}
if (num_returns_per_match == 0 || num_returns_per_match > 1) {
returnvec.push_back(Value(resultvec));
}
else {
returnvec = search(findThis.toString(), searchTable.toVector(), num_returns_per_match, index_col_num);
}
} else if (findThis.type() == Value::VECTOR) {
for (size_t i = 0; i < findThis.toVector().size(); i++) {

View File

@ -164,7 +164,7 @@ bool MainWindow::mdiMode = false;
bool MainWindow::undockMode = false;
MainWindow::MainWindow(const QString &filename)
: root_inst("group"), tempFile(NULL), progresswidget(NULL), font_list_dialog(NULL)
: root_inst("group"), font_list_dialog(NULL), tempFile(NULL), progresswidget(NULL)
{
setupUi(this);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);

View File

@ -99,16 +99,18 @@ std::string OffsetNode::toString() const
{
std::stringstream stream;
stream << this->name()
stream << this->name()
<< "(delta = " << std::dec << this->delta
<< ", join_type = "
<< ", join_type = \""
<< (this->join_type == ClipperLib::jtSquare
? "bevel"
: this->join_type == ClipperLib::jtRound
? "round"
: "miter")
<< ", miter_limit = " << this->miter_limit
<< ", $fn = " << this->fn
: "miter") << "\"";
if (this->join_type == ClipperLib::jtMiter) {
stream << ", miter_limit = " << this->miter_limit;
}
stream << ", $fn = " << this->fn
<< ", $fa = " << this->fa
<< ", $fs = " << this->fs << ")";

View File

@ -1,5 +1,4 @@
#ifndef OFFSETNODE_H_
#define OFFSETNODE_H_
#pragma once
#include "node.h"
#include "visitor.h"
@ -19,5 +18,3 @@ public:
double fn, fs, fa, delta, miter_limit;
ClipperLib::JoinType join_type;
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef POLYSET_UTILS_H_
#define POLYSET_UTILS_H_
#pragma once
class Polygon2d;
class PolySet;
@ -10,5 +9,3 @@ namespace PolysetUtils {
void tessellate_faces(const PolySet &inps, PolySet &outps);
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef TEXTNODE_H_
#define TEXTNODE_H_
#pragma once
#include "node.h"
#include "visitor.h"
@ -26,7 +25,5 @@ public:
virtual FreetypeRenderer::Params get_params() const;
private:
FreetypeRenderer::Params params;
friend TextModule;
friend class TextModule;
};
#endif

View File

@ -455,15 +455,29 @@ inclusion(GLIB2_DIR GLIB2_INCLUDE_DIRS)
# find libraries using pkg-config
find_package(PkgConfig REQUIRED)
include(PkgConfigTools.cmake)
save_pkg_config_env()
pkg_search_module(FONTCONFIG REQUIRED fontconfig>=2.11.0)
message(STATUS "fontconfig found: ${FONTCONFIG_VERSION}")
if (DEFINED ENV{OPENSCAD_LIBRARIES})
set(ENV{PKG_CONFIG_PATH} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
endif()
pkg_search_module(FREETYPE REQUIRED freetype2>=2.4.9)
message(STATUS "freetype2 found: ${FREETYPE_VERSION}")
pkg_check_modules(FONTCONFIG REQUIRED fontconfig>=2.8.0)
if (FONTCONFIG_VERSION)
message(STATUS "fontconfig ${FONTCONFIG_VERSION} found: ${FONTCONFIG_INCLUDE_DIRS}")
endif()
pkg_search_module(HARFBUZZ REQUIRED harfbuzz>=0.9.19)
message(STATUS "harfbuzz found: ${HARFBUZZ_VERSION}")
pkg_check_modules(FREETYPE REQUIRED freetype2>=2.4.9)
if (FREETYPE_VERSION)
message(STATUS "freetype2 ${FREETYPE_VERSION} found: ${FREETYPE_INCLUDE_DIRS}")
endif()
pkg_check_modules(HARFBUZZ REQUIRED harfbuzz>=0.9.19)
if (HARFBUZZ_VERSION)
message(STATUS "harfbuzz ${HARFBUZZ_VERSION} found: ${HARFBUZZ_INCLUDE_DIRS}")
endif()
restore_pkg_config_env()
add_definitions(${FONTCONFIG_CFLAGS})
add_definitions(${FREETYPE_CFLAGS})
@ -663,16 +677,14 @@ if(NULLGL)
endif()
add_library(tests-core STATIC ${CORE_SOURCES})
target_link_libraries(tests-core ${OPENGL_LIBRARIES} ${GLIB2_LIBRARIES} )
set(TESTS-CORE-LIBRARIES ${OPENGL_LIBRARIES} ${GLIB2_LIBRARIES} ${Boost_LIBRARIES} ${COCOA_LIBRARY})
target_link_libraries(tests-core ${OPENGL_LIBRARIES} ${GLIB2_LIBRARIES} ${FONTCONFIG_LDFLAGS} ${FREETYPE_LDFLAGS} ${HARFBUZZ_LDFLAGS} ${Boost_LIBRARIES} ${COCOA_LIBRARY})
add_library(tests-common STATIC ${COMMON_SOURCES})
target_link_libraries(tests-common tests-core)
add_library(tests-cgal STATIC ${CGAL_SOURCES})
set_target_properties(tests-cgal PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
target_link_libraries(tests-cgal tests-common)
set(TESTS-CGAL-LIBRARIES ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${GMP_LIBRARIES} ${MPFR_LIBRARIES} ${TESTS-CORE-LIBRARIES})
target_link_libraries(tests-cgal tests-common ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
#
# Create non-CGAL tests
@ -680,14 +692,12 @@ set(TESTS-CGAL-LIBRARIES ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${GMP_LIBRA
if (NOT NULLGL)
add_library(tests-nocgal STATIC ${NOCGAL_SOURCES})
target_link_libraries(tests-nocgal tests-common)
set(TESTS-NOCGAL-LIBRARIES ${TESTS-CORE-LIBRARIES})
else()
message(STATUS "NULLGL: cannot use GL/GLU tessellator. see dxftess.cc")
message(STATUS "NULLGL: non-CGAL tests will use CGAL's tessellator")
add_library(tests-nocgal STATIC ${CGAL_SOURCES})
set_target_properties(tests-nocgal PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
target_link_libraries(tests-nocgal tests-common)
set(TESTS-NOCGAL-LIBRARIES ${TESTS-CGAL-LIBRARIES})
endif()
add_library(tests-offscreen STATIC ${OFFSCREEN_SOURCES})
@ -697,27 +707,27 @@ set_target_properties(tests-offscreen PROPERTIES COMPILE_FLAGS "${ENABLE_OPENCSG
# modulecachetest
#
add_executable(modulecachetest modulecachetest.cc)
target_link_libraries(modulecachetest tests-nocgal ${TESTS-NOCGAL-LIBRARIES} ${Boost_LIBRARIES} ${FONTCONFIG_LDFLAGS} ${FREETYPE_LDFLAGS} ${HARFBUZZ_LDFLAGS})
target_link_libraries(modulecachetest tests-nocgal)
#
# csgtexttest
#
add_executable(csgtexttest csgtexttest.cc CSGTextRenderer.cc CSGTextCache.cc)
target_link_libraries(csgtexttest tests-nocgal ${TESTS-NOCGAL-LIBRARIES} ${FONTCONFIG_LDFLAGS} ${FREETYPE_LDFLAGS} ${HARFBUZZ_LDFLAGS})
target_link_libraries(csgtexttest tests-nocgal)
#
# cgalcachetest
#
add_executable(cgalcachetest cgalcachetest.cc)
set_target_properties(cgalcachetest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
target_link_libraries(cgalcachetest tests-cgal ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${FONTCONFIG_LDFLAGS} ${FREETYPE_LDFLAGS} ${HARFBUZZ_LDFLAGS})
target_link_libraries(cgalcachetest tests-cgal ${GLEW_LIBRARY})
#
# openscad no-qt
#
add_executable(openscad_nogui ../src/openscad.cc)
set_target_properties(openscad_nogui PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -DEIGEN_DONT_ALIGN -DENABLE_CGAL -DENABLE_OPENCSG ${CGAL_CXX_FLAGS_INIT}")
target_link_libraries(openscad_nogui tests-offscreen tests-cgal tests-nocgal ${TESTS-CORE-LIBRARIES} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${Boost_LIBRARIES} ${OPENCSG_LIBRARY} ${COCOA_LIBRARY} ${APP_SERVICES_LIBRARY} ${FONTCONFIG_LDFLAGS} ${FREETYPE_LDFLAGS} ${HARFBUZZ_LDFLAGS})
target_link_libraries(openscad_nogui tests-offscreen tests-cgal tests-nocgal ${GLEW_LIBRARY} ${OPENCSG_LIBRARY} ${APP_SERVICES_LIBRARY})
#
# GUI binary tests
@ -813,11 +823,12 @@ endfunction()
# This functions adds cmd-line tests given files.
#
# Usage add_cmdline_test(testbasename [EXE <executable>] [ARGS <args to exe>]
# [SCRIPT <script>]
# [EXPECTEDDIR <shared dir>] SUFFIX <suffix> FILES <test files>)
#
find_package(PythonInterp)
function(add_cmdline_test TESTCMD_BASENAME)
cmake_parse_arguments(TESTCMD "" "EXE;SUFFIX;EXPECTEDDIR" "FILES;ARGS" ${ARGN})
cmake_parse_arguments(TESTCMD "" "EXE;SCRIPT;SUFFIX;EXPECTEDDIR" "FILES;ARGS" ${ARGN})
# If sharing results with another test, pass on this to the python script
if (TESTCMD_EXPECTEDDIR)
@ -856,7 +867,7 @@ function(add_cmdline_test TESTCMD_BASENAME)
set(FILENAME_OPTION -f ${FILE_BASENAME})
endif()
add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${FILENAME_OPTION} ${TESTCMD_EXE} "${SCADFILE}" ${TESTCMD_ARGS})
add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTCMD_SUFFIX} ${EXTRA_OPTIONS} ${TESTNAME_OPTION} ${FILENAME_OPTION} ${TESTCMD_EXE} ${TESTCMD_SCRIPT} "${SCADFILE}" ${TESTCMD_ARGS})
set_property(TEST ${TEST_FULLNAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")
endif()
endforeach()
@ -941,17 +952,24 @@ disable_tests(opencsgtest_child-background)
disable_tests(cgalpngtest_child-background
cgalpngtest_highlight-and-background-modifier
cgalpngtest_testcolornames
openscad-cgalpng_child-background
openscad-cgalpng_highlight-and-background-modifier
openscad-cgalpng_testcolornames
csgpngtest_child-background
csgpngtest_highlight-and-background-modifier
csgpngtest_testcolornames
throwntogethertest_testcolornames)
# The inf/nan tests fail when exporting CSG and rendering that output again
# as currently inf/nan is written directly to the CSG file (e.g. r = inf)
# which is not valid or even misleading in case a variable inf exists.
# FIXME: define export behavior for inf/nan when exporting CSG files
disable_tests(csgpngtest_primitive-inf-tests csgpngtest_transform-nan-inf-tests)
# Test config handling
# Heavy tests are tests taking more than 10 seconds on a development computer
set_test_config(Heavy cgalpngtest_rotate_extrude-tests
cgalpngtest_sphere-tests
csgpngtest_rotate_extrude-tests
cgalpngtest_for-nested-tests
csgpngtest_for-nested-tests
cgalpngtest_resize-tests
cgalpngtest_text-search-test
cgalpngtest_text-font-direction-tests
@ -964,8 +982,13 @@ set_test_config(Heavy cgalpngtest_rotate_extrude-tests
throwntogethertest_text-font-tests
throwntogethertest_text-font-alignment-tests
cgalpngtest_fractal
csgpngtest_fractal
cgalpngtest_iteration
cgalpngtest_linear_extrude-scale-zero-tests)
csgpngtest_iteration
cgalpngtest_linear_extrude-scale-zero-tests
csgpngtest_linear_extrude-scale-zero-tests
cgalpngtest_sphere-tests
csgpngtest_resize-tests)
# Bugs
@ -989,6 +1012,8 @@ foreach(FILE ${BUGS_FILES})
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(cgalpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
get_test_fullname(csgpngtest ${FILE} TEST_FULLNAME)
set_test_config(Bugs ${TEST_FULLNAME})
endforeach()
# Examples
@ -1000,9 +1025,7 @@ foreach(FILE ${EXAMPLE_FILES})
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(throwntogethertest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(openscad-cgalpng ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
get_test_fullname(openscad-csgpng ${FILE} TEST_FULLNAME)
get_test_fullname(csgpngtest ${FILE} TEST_FULLNAME)
set_test_config(Examples ${TEST_FULLNAME})
endforeach()
@ -1068,6 +1091,7 @@ add_cmdline_test(dumptest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX csg FILES ${DUM
add_cmdline_test(dumptest-examples EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX csg FILES ${EXAMPLE_FILES})
add_cmdline_test(cgalpngtest EXE ${OPENSCAD_BINPATH} ARGS --render -o SUFFIX png FILES ${CGALPNGTEST_FILES})
add_cmdline_test(opencsgtest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX png FILES ${OPENCSGTEST_FILES})
add_cmdline_test(csgpngtest EXE ${PYTHON_EXECUTABLE} SCRIPT csg-import-test.py ARGS ${OPENSCAD_BINPATH} EXPECTEDDIR cgalpngtest SUFFIX png FILES ${CGALPNGTEST_FILES})
add_cmdline_test(throwntogethertest EXE ${OPENSCAD_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

View File

@ -1,5 +1,8 @@
message(STATUS "running openscad/tests/FindGLIB2.cmake ...")
include(PkgConfigTools.cmake)
save_pkg_config_env()
# GLIB2 requires pkg-config to build.
# If we are did an OPENSCAD_LIBRARIES dependency build of glib2, we need to
# tell pkg-config to look under OPENSCAD_LIBRARIES dir.
@ -8,8 +11,6 @@ if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
if (EXISTS "$ENV{OPENSCAD_LIBRARIES}/include/glib-2.0/glib.h")
message(STATUS "found glib.h under OPENSCAD_LIBRARIES.")
message(STATUS "redirecting pkg-config to look under OPENSCAD_LIBRARIES")
set(SAVED_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH}")
set(SAVED_PKG_CONFIG_LIBDIR "$ENV{PKG_CONFIG_LIBDIR}")
set(ENV{PKG_CONFIG_PATH} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
else()
@ -55,11 +56,4 @@ foreach(glib2libdir ${GLIB2_LIBRARIES})
message(STATUS " " ${glib2libdir})
endforeach()
if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
if (EXISTS "$ENV{OPENSCAD_LIBRARIES}/include/glib-2.0/glib.h")
message(STATUS "resetting pkgconfig as it was")
else()
set(ENV{PKG_CONFIG_PATH} "${SAVED_PKG_CONFIG_PATH}")
set(ENV{PKG_CONFIG_LIBDIR} "${SAVED_PKG_CONFIG_LIBDIR}")
endif()
endif()
restore_pkg_config_env()

View File

@ -0,0 +1,29 @@
# Use this to save the existing pkg-config settings
function(save_pkg_config_env)
message(STATUS "saving pkg-config env")
if (DEFINED ENV{PKG_CONFIG_PATH})
set(SAVED_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH}")
endif()
if (DEFINED ENV{PKG_CONFIG_LIBDIR})
set(SAVED_PKG_CONFIG_LIBDIR "$ENV{PKG_CONFIG_LIBDIR}")
endif()
endfunction()
# Use this to restore to the original pkg-config settings
function(restore_pkg_config_env)
message(STATUS "restoring pkg-config env")
if (SAVED_PKG_CONFIG_PATH)
set(ENV{PKG_CONFIG_PATH} "${SAVED_PKG_CONFIG_PATH}")
unset(SAVED_PKG_CONFIG_PATH)
else()
unset(ENV{PKG_CONFIG_PATH})
endif()
if (SAVED_PKG_CONFIG_LIBDIR)
set(ENV{PKG_CONFIG_LIBDIR} "${SAVED_PKG_CONFIG_LIBDIR}")
unset(SAVED_PKG_CONFIG_LIBDIR)
else()
unset(ENV{PKG_CONFIG_LIBDIR})
endif()
endfunction()

14
tests/csg-import-test.py Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env python
import sys, os, re, subprocess
scad = sys.argv[1]
bin = sys.argv[2]
png = sys.argv[3]
csg = re.sub(r"\.scad$", ".csg", scad)
print(bin, scad, csg, png);
subprocess.call([bin, scad, '-o', csg])
subprocess.call([bin, csg, '--render', '-o', png])
os.remove(csg);

View File

@ -1,7 +1,7 @@
group() {
group();
linear_extrude(height = 20, center = false, convexity = 1, scale = [0.5, 0.5], $fn = 40, $fa = 12, $fs = 2) {
offset(delta = 10, join_type = round, miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
offset(delta = 10, join_type = "round", $fn = 40, $fa = 12, $fs = 2) {
square(size = [50, 50], center = true);
}
}
@ -9,12 +9,12 @@ group() {
linear_extrude(height = 20, center = false, convexity = 1, scale = [1, 1], $fn = 40, $fa = 12, $fs = 2) {
group() {
difference() {
offset(delta = 1, join_type = miter, miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "miter", miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
group() {
circle($fn = 40, $fa = 12, $fs = 2, r = 15);
}
}
offset(delta = -1, join_type = miter, miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "miter", miter_limit = 2, $fn = 40, $fa = 12, $fs = 2) {
group() {
circle($fn = 40, $fa = 12, $fs = 2, r = 15);
}

View File

@ -1,5 +1,5 @@
group() {
offset(delta = -1, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
@ -11,42 +11,42 @@ group() {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
offset(delta = 1, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -1, join_type = miter, miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "miter", miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = 1, join_type = miter, miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "miter", miter_limit = 10, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 150], [0, 1, 0, 100], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -1, join_type = bevel, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -1, join_type = "bevel", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = 1, join_type = bevel, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 1, join_type = "bevel", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 150], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
polygon(points = [[-15, 80], [15, 80], [0, -15], [-8, 60], [8, 60], [0, 5]], paths = [[0, 1, 2], [3, 4, 5]], convexity = 1);
}
}
}
offset(delta = -5, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -5, join_type = "round", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -64,7 +64,7 @@ group() {
}
}
}
offset(delta = 5, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 5, join_type = "round", $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -74,7 +74,7 @@ group() {
}
}
}
offset(delta = -4, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -4, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, -50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -92,7 +92,7 @@ group() {
}
}
}
offset(delta = 4, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 4, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -102,7 +102,7 @@ group() {
}
}
}
offset(delta = -5, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = -5, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 100], [0, 1, 0, 50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -120,7 +120,7 @@ group() {
}
}
}
offset(delta = 5, join_type = miter, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 5, join_type = "miter", miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
group() {
multmatrix([[1, 0, 0, 50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
difference() {
@ -132,7 +132,7 @@ group() {
}
multmatrix([[1, 0, 0, -50], [0, 1, 0, -50], [0, 0, 1, 0], [0, 0, 0, 1]]) {
multmatrix([[25, 0, 0, 0], [0, 25, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
offset(delta = 0.9, join_type = round, miter_limit = 2, $fn = 0, $fa = 12, $fs = 2) {
offset(delta = 0.9, join_type = "round", $fn = 0, $fa = 12, $fs = 2) {
square(size = [0.1, 0.1], center = false);
}
}