mirror of https://github.com/vitalif/openscad
commit
6b3daa7485
|
@ -49,6 +49,9 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam
|
||||||
double yorigin = 0;
|
double yorigin = 0;
|
||||||
double scale = 1;
|
double scale = 1;
|
||||||
|
|
||||||
|
// FIXME: We don't lookup the file relative to where this function was instantiated
|
||||||
|
// since the path is only available for ModuleInstantiations, not function expressions.
|
||||||
|
// See isse #217
|
||||||
for (size_t i = 0; i < argnames.size() && i < args.size(); i++) {
|
for (size_t i = 0; i < argnames.size() && i < args.size(); i++) {
|
||||||
if (argnames[i] == "file")
|
if (argnames[i] == "file")
|
||||||
filename = ctx->getAbsolutePath(args[i].toString());
|
filename = ctx->getAbsolutePath(args[i].toString());
|
||||||
|
@ -63,9 +66,16 @@ Value builtin_dxf_dim(const Context *ctx, const std::vector<std::string> &argnam
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream keystream;
|
std::stringstream keystream;
|
||||||
|
fs::path filepath(filename);
|
||||||
|
uintmax_t filesize = -1;
|
||||||
|
time_t lastwritetime = -1;
|
||||||
|
if (fs::exists(filepath) && fs::is_regular_file(filepath)) {
|
||||||
|
filesize = fs::file_size(filepath);
|
||||||
|
lastwritetime = fs::last_write_time(filepath);
|
||||||
|
}
|
||||||
keystream << filename << "|" << layername << "|" << name << "|" << xorigin
|
keystream << filename << "|" << layername << "|" << name << "|" << xorigin
|
||||||
<< "|" << yorigin <<"|" << scale << "|" << fs::last_write_time(filename)
|
<< "|" << yorigin <<"|" << scale << "|" << lastwritetime
|
||||||
<< "|" << fs::file_size(filename);
|
<< "|" << filesize;
|
||||||
std::string key = keystream.str();
|
std::string key = keystream.str();
|
||||||
if (dxf_dim_cache.find(key) != dxf_dim_cache.end())
|
if (dxf_dim_cache.find(key) != dxf_dim_cache.end())
|
||||||
return dxf_dim_cache.find(key)->second;
|
return dxf_dim_cache.find(key)->second;
|
||||||
|
@ -133,6 +143,9 @@ Value builtin_dxf_cross(const Context *ctx, const std::vector<std::string> &argn
|
||||||
double yorigin = 0;
|
double yorigin = 0;
|
||||||
double scale = 1;
|
double scale = 1;
|
||||||
|
|
||||||
|
// FIXME: We don't lookup the file relative to where this function was instantiated
|
||||||
|
// since the path is only available for ModuleInstantiations, not function expressions.
|
||||||
|
// See isse #217
|
||||||
for (size_t i = 0; i < argnames.size() && i < args.size(); i++) {
|
for (size_t i = 0; i < argnames.size() && i < args.size(); i++) {
|
||||||
if (argnames[i] == "file")
|
if (argnames[i] == "file")
|
||||||
filename = ctx->getAbsolutePath(args[i].toString());
|
filename = ctx->getAbsolutePath(args[i].toString());
|
||||||
|
|
|
@ -80,7 +80,7 @@ AbstractNode *ImportModule::evaluate(const Context *ctx, const ModuleInstantiati
|
||||||
c.args(argnames, argexpr, inst_argnames, inst->argvalues);
|
c.args(argnames, argexpr, inst_argnames, inst->argvalues);
|
||||||
|
|
||||||
Value v = c.lookup_variable("file");
|
Value v = c.lookup_variable("file");
|
||||||
std::string filename = c.getAbsolutePath(v.isUndefined() ? "" : v.toString());
|
std::string filename = inst->getAbsolutePath(v.isUndefined() ? "" : v.toString());
|
||||||
import_type_e actualtype = this->type;
|
import_type_e actualtype = this->type;
|
||||||
if (actualtype == TYPE_UNKNOWN) {
|
if (actualtype == TYPE_UNKNOWN) {
|
||||||
std::string extraw = boosty::extension_str( fs::path(filename) );
|
std::string extraw = boosty::extension_str( fs::path(filename) );
|
||||||
|
|
|
@ -75,7 +75,7 @@ AbstractNode *LinearExtrudeModule::evaluate(const Context *ctx, const ModuleInst
|
||||||
|
|
||||||
if (!file.isUndefined()) {
|
if (!file.isUndefined()) {
|
||||||
PRINT("DEPRECATED: Support for reading files in linear_extrude will be removed in future releases. Use a child import() instead.");
|
PRINT("DEPRECATED: Support for reading files in linear_extrude will be removed in future releases. Use a child import() instead.");
|
||||||
node->filename = c.getAbsolutePath(file.toString());
|
node->filename = inst->getAbsolutePath(file.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if height not given, and first argument is a number,
|
// if height not given, and first argument is a number,
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
#include "printutils.h"
|
#include "printutils.h"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
namespace fs = boost::filesystem;
|
||||||
|
#include "boosty.h"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -67,6 +70,19 @@ IfElseModuleInstantiation::~IfElseModuleInstantiation()
|
||||||
BOOST_FOREACH (ModuleInstantiation *v, else_children) delete v;
|
BOOST_FOREACH (ModuleInstantiation *v, else_children) delete v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the absolute path to the given filename, unless it's empty.
|
||||||
|
*/
|
||||||
|
std::string ModuleInstantiation::getAbsolutePath(const std::string &filename) const
|
||||||
|
{
|
||||||
|
if (!filename.empty() && !boosty::is_absolute(fs::path(filename))) {
|
||||||
|
return boosty::absolute(fs::path(this->modpath) / filename).string();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string ModuleInstantiation::dump(const std::string &indent) const
|
std::string ModuleInstantiation::dump(const std::string &indent) const
|
||||||
{
|
{
|
||||||
std::stringstream dump;
|
std::stringstream dump;
|
||||||
|
@ -152,15 +168,15 @@ AbstractNode *Module::evaluate(const Context *ctx, const ModuleInstantiation *in
|
||||||
|
|
||||||
c.functions_p = &functions;
|
c.functions_p = &functions;
|
||||||
c.modules_p = &modules;
|
c.modules_p = &modules;
|
||||||
|
|
||||||
if (!usedlibs.empty())
|
if (!usedlibs.empty())
|
||||||
c.usedlibs_p = &usedlibs;
|
c.usedlibs_p = &usedlibs;
|
||||||
else
|
else
|
||||||
c.usedlibs_p = NULL;
|
c.usedlibs_p = NULL;
|
||||||
|
|
||||||
BOOST_FOREACH(const std::string &var, assignments_var) {
|
BOOST_FOREACH(const std::string &var, assignments_var) {
|
||||||
c.set_variable(var, assignments.at(var)->evaluate(&c));
|
c.set_variable(var, assignments.at(var)->evaluate(&c));
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractNode *node = new AbstractNode(inst);
|
AbstractNode *node = new AbstractNode(inst);
|
||||||
for (size_t i = 0; i < children.size(); i++) {
|
for (size_t i = 0; i < children.size(); i++) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
class ModuleInstantiation
|
class ModuleInstantiation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModuleInstantiation(const std::string &name = "")
|
ModuleInstantiation(const std::string &name = "")
|
||||||
: ctx(NULL),
|
: ctx(NULL),
|
||||||
tag_root(false), tag_highlight(false), tag_background(false), modname(name) { }
|
tag_root(false), tag_highlight(false), tag_background(false), modname(name) { }
|
||||||
virtual ~ModuleInstantiation();
|
virtual ~ModuleInstantiation();
|
||||||
|
@ -19,6 +19,10 @@ public:
|
||||||
class AbstractNode *evaluate(const class Context *ctx) const;
|
class AbstractNode *evaluate(const class Context *ctx) const;
|
||||||
std::vector<AbstractNode*> evaluateChildren(const Context *ctx = NULL) const;
|
std::vector<AbstractNode*> evaluateChildren(const Context *ctx = NULL) const;
|
||||||
|
|
||||||
|
void setPath(const std::string &path) { this->modpath = path; }
|
||||||
|
const std::string &path() const { return this->modpath; }
|
||||||
|
std::string getAbsolutePath(const std::string &filename) const;
|
||||||
|
|
||||||
const std::string &name() const { return this->modname; }
|
const std::string &name() const { return this->modname; }
|
||||||
bool isBackground() const { return this->tag_background; }
|
bool isBackground() const { return this->tag_background; }
|
||||||
bool isHighlight() const { return this->tag_highlight; }
|
bool isHighlight() const { return this->tag_highlight; }
|
||||||
|
@ -35,6 +39,7 @@ public:
|
||||||
bool tag_background;
|
bool tag_background;
|
||||||
protected:
|
protected:
|
||||||
std::string modname;
|
std::string modname;
|
||||||
|
std::string modpath;
|
||||||
|
|
||||||
friend class Module;
|
friend class Module;
|
||||||
};
|
};
|
||||||
|
@ -61,6 +66,7 @@ class Module : public AbstractModule
|
||||||
public:
|
public:
|
||||||
Module() : is_handling_dependencies(false) { }
|
Module() : is_handling_dependencies(false) { }
|
||||||
virtual ~Module();
|
virtual ~Module();
|
||||||
|
|
||||||
virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
|
virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
|
||||||
virtual std::string dump(const std::string &indent, const std::string &name) const;
|
virtual std::string dump(const std::string &indent, const std::string &name) const;
|
||||||
|
|
||||||
|
|
50
src/parser.y
50
src/parser.y
|
@ -58,6 +58,12 @@ int lexerlex(void);
|
||||||
std::vector<Module*> module_stack;
|
std::vector<Module*> module_stack;
|
||||||
Module *currmodule;
|
Module *currmodule;
|
||||||
|
|
||||||
|
extern void lexerdestroy();
|
||||||
|
extern FILE *lexerin;
|
||||||
|
extern const char *parser_input_buffer;
|
||||||
|
const char *parser_input_buffer;
|
||||||
|
std::string parser_source_path;
|
||||||
|
|
||||||
class ArgContainer {
|
class ArgContainer {
|
||||||
public:
|
public:
|
||||||
std::string argname;
|
std::string argname;
|
||||||
|
@ -77,6 +83,7 @@ public:
|
||||||
class Value *value;
|
class Value *value;
|
||||||
class Expression *expr;
|
class Expression *expr;
|
||||||
class ModuleInstantiation *inst;
|
class ModuleInstantiation *inst;
|
||||||
|
std::vector<ModuleInstantiation*> *instvec;
|
||||||
class IfElseModuleInstantiation *ifelse;
|
class IfElseModuleInstantiation *ifelse;
|
||||||
class ArgContainer *arg;
|
class ArgContainer *arg;
|
||||||
class ArgsContainer *args;
|
class ArgsContainer *args;
|
||||||
|
@ -117,8 +124,8 @@ public:
|
||||||
%type <inst> module_instantiation
|
%type <inst> module_instantiation
|
||||||
%type <ifelse> if_statement
|
%type <ifelse> if_statement
|
||||||
%type <ifelse> ifelse_statement
|
%type <ifelse> ifelse_statement
|
||||||
%type <inst> children_instantiation
|
%type <instvec> children_instantiation
|
||||||
%type <inst> module_instantiation_list
|
%type <instvec> module_instantiation_list
|
||||||
%type <inst> single_module_instantiation
|
%type <inst> single_module_instantiation
|
||||||
|
|
||||||
%type <args> arguments_call
|
%type <args> arguments_call
|
||||||
|
@ -182,9 +189,9 @@ statement:
|
||||||
/* Will return a dummy parent node with zero or more children */
|
/* Will return a dummy parent node with zero or more children */
|
||||||
children_instantiation:
|
children_instantiation:
|
||||||
module_instantiation {
|
module_instantiation {
|
||||||
$$ = new ModuleInstantiation();
|
$$ = new std::vector<ModuleInstantiation*>;
|
||||||
if ($1) {
|
if ($1) {
|
||||||
$$->children.push_back($1);
|
$$->push_back($1);
|
||||||
}
|
}
|
||||||
} |
|
} |
|
||||||
'{' module_instantiation_list '}' {
|
'{' module_instantiation_list '}' {
|
||||||
|
@ -196,14 +203,14 @@ if_statement:
|
||||||
$$ = new IfElseModuleInstantiation();
|
$$ = new IfElseModuleInstantiation();
|
||||||
$$->argnames.push_back("");
|
$$->argnames.push_back("");
|
||||||
$$->argexpr.push_back($3);
|
$$->argexpr.push_back($3);
|
||||||
|
$$->setPath(parser_source_path);
|
||||||
|
|
||||||
if ($$) {
|
if ($$) {
|
||||||
$$->children = $5->children;
|
$$->children = *$5;
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < $5->children.size(); i++)
|
for (size_t i = 0; i < $5->size(); i++)
|
||||||
delete $5->children[i];
|
delete (*$5)[i];
|
||||||
}
|
}
|
||||||
$5->children.clear();
|
|
||||||
delete $5;
|
delete $5;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -214,12 +221,11 @@ ifelse_statement:
|
||||||
if_statement TOK_ELSE children_instantiation {
|
if_statement TOK_ELSE children_instantiation {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
if ($$) {
|
if ($$) {
|
||||||
$$->else_children = $3->children;
|
$$->else_children = *$3;
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < $3->children.size(); i++)
|
for (size_t i = 0; i < $3->size(); i++)
|
||||||
delete $3->children[i];
|
delete (*$3)[i];
|
||||||
}
|
}
|
||||||
$3->children.clear();
|
|
||||||
delete $3;
|
delete $3;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -246,12 +252,11 @@ module_instantiation:
|
||||||
single_module_instantiation children_instantiation {
|
single_module_instantiation children_instantiation {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
if ($$) {
|
if ($$) {
|
||||||
$$->children = $2->children;
|
$$->children = *$2;
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < $2->children.size(); i++)
|
for (size_t i = 0; i < $2->size(); i++)
|
||||||
delete $2->children[i];
|
delete (*$2)[i];
|
||||||
}
|
}
|
||||||
$2->children.clear();
|
|
||||||
delete $2;
|
delete $2;
|
||||||
} |
|
} |
|
||||||
ifelse_statement {
|
ifelse_statement {
|
||||||
|
@ -260,12 +265,12 @@ module_instantiation:
|
||||||
|
|
||||||
module_instantiation_list:
|
module_instantiation_list:
|
||||||
/* empty */ {
|
/* empty */ {
|
||||||
$$ = new ModuleInstantiation();
|
$$ = new std::vector<ModuleInstantiation*>;
|
||||||
} |
|
} |
|
||||||
module_instantiation_list module_instantiation {
|
module_instantiation_list module_instantiation {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
if ($$) {
|
if ($$) {
|
||||||
if ($2) $$->children.push_back($2);
|
if ($2) $$->push_back($2);
|
||||||
} else {
|
} else {
|
||||||
delete $2;
|
delete $2;
|
||||||
}
|
}
|
||||||
|
@ -276,6 +281,7 @@ single_module_instantiation:
|
||||||
$$ = new ModuleInstantiation($1);
|
$$ = new ModuleInstantiation($1);
|
||||||
$$->argnames = $3->argnames;
|
$$->argnames = $3->argnames;
|
||||||
$$->argexpr = $3->argexpr;
|
$$->argexpr = $3->argexpr;
|
||||||
|
$$->setPath(parser_source_path);
|
||||||
free($1);
|
free($1);
|
||||||
delete $3;
|
delete $3;
|
||||||
}
|
}
|
||||||
|
@ -536,18 +542,12 @@ void yyerror (char const *s)
|
||||||
currmodule = NULL;
|
currmodule = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void lexerdestroy();
|
|
||||||
extern FILE *lexerin;
|
|
||||||
extern const char *parser_input_buffer;
|
|
||||||
const char *parser_input_buffer;
|
|
||||||
std::string parser_source_path;
|
|
||||||
|
|
||||||
Module *parse(const char *text, const char *path, int debug)
|
Module *parse(const char *text, const char *path, int debug)
|
||||||
{
|
{
|
||||||
lexerin = NULL;
|
lexerin = NULL;
|
||||||
parser_error_pos = -1;
|
parser_error_pos = -1;
|
||||||
parser_input_buffer = text;
|
parser_input_buffer = text;
|
||||||
parser_source_path = std::string(path);
|
parser_source_path = boosty::absolute(std::string(path)).string();
|
||||||
|
|
||||||
module_stack.clear();
|
module_stack.clear();
|
||||||
Module *rootmodule = currmodule = new Module();
|
Module *rootmodule = currmodule = new Module();
|
||||||
|
|
|
@ -71,7 +71,7 @@ AbstractNode *RotateExtrudeModule::evaluate(const Context *ctx, const ModuleInst
|
||||||
|
|
||||||
if (!file.isUndefined()) {
|
if (!file.isUndefined()) {
|
||||||
PRINT("DEPRECATED: Support for reading files in rotate_extrude will be removed in future releases. Use a child import() instead.");
|
PRINT("DEPRECATED: Support for reading files in rotate_extrude will be removed in future releases. Use a child import() instead.");
|
||||||
node->filename = c.getAbsolutePath(file.toString());
|
node->filename = inst->getAbsolutePath(file.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
node->layername = layer.isUndefined() ? "" : layer.toString();
|
node->layername = layer.isUndefined() ? "" : layer.toString();
|
||||||
|
|
|
@ -83,7 +83,7 @@ AbstractNode *SurfaceModule::evaluate(const Context *ctx, const ModuleInstantiat
|
||||||
c.args(argnames, argexpr, inst->argnames, inst->argvalues);
|
c.args(argnames, argexpr, inst->argnames, inst->argvalues);
|
||||||
|
|
||||||
Value fileval = c.lookup_variable("file");
|
Value fileval = c.lookup_variable("file");
|
||||||
node->filename = c.getAbsolutePath(fileval.isUndefined() ? "" : fileval.toString());
|
node->filename = inst->getAbsolutePath(fileval.isUndefined() ? "" : fileval.toString());
|
||||||
|
|
||||||
Value center = c.lookup_variable("center", true);
|
Value center = c.lookup_variable("center", true);
|
||||||
if (center.type() == Value::BOOL) {
|
if (center.type() == Value::BOOL) {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
module mymodule(modparam) {
|
||||||
|
inner_variable = 23;
|
||||||
|
inner_variable2 = modparam * 2;
|
||||||
|
cylinder(r1=inner_variable, r2=inner_variable2, h=10);
|
||||||
|
}
|
||||||
|
|
||||||
|
mymodule(5);
|
|
@ -0,0 +1,3 @@
|
||||||
|
use <localfiles_dir/localfiles_module.scad>
|
||||||
|
|
||||||
|
localfiles_module();
|
|
@ -0,0 +1,2 @@
|
||||||
|
0 1
|
||||||
|
2 3
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,10 @@
|
||||||
|
module localfiles_module()
|
||||||
|
{
|
||||||
|
linear_extrude(h=100) import("localfile.dxf");
|
||||||
|
translate([-250,0,0]) linear_extrude(file="localfile.dxf");
|
||||||
|
translate([0,350,0]) rotate_extrude(file="localfile.dxf");
|
||||||
|
translate([250,0,0]) scale([200,200,50]) surface("localfile.dat");
|
||||||
|
|
||||||
|
// This is not supported:
|
||||||
|
// echo(dxf_dim(file="localfile.dxf", name="localfile"));
|
||||||
|
}
|
|
@ -754,12 +754,15 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}
|
||||||
list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES})
|
list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES})
|
||||||
list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad
|
list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad
|
||||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
|
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
|
||||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad)
|
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
|
||||||
|
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad)
|
||||||
|
|
||||||
list(APPEND CGALPNGTEST_FILES ${FEATURES_FILES} ${SCAD_DXF_FILES} ${EXAMPLE_FILES})
|
list(APPEND CGALPNGTEST_FILES ${FEATURES_FILES} ${SCAD_DXF_FILES} ${EXAMPLE_FILES})
|
||||||
list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
|
list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
|
||||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
|
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
|
||||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad)
|
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad
|
||||||
|
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad)
|
||||||
|
|
||||||
list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES})
|
list(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES})
|
||||||
list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/bbox-transform-bug.scad)
|
list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/bbox-transform-bug.scad)
|
||||||
list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad)
|
list(APPEND OPENCSGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/intersection-prune-test.scad)
|
||||||
|
|
|
@ -115,7 +115,6 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::current_path(original_path);
|
|
||||||
std::ofstream outfile;
|
std::ofstream outfile;
|
||||||
outfile.open(outfilename);
|
outfile.open(outfilename);
|
||||||
outfile << dumpstdstr << "\n";
|
outfile << dumpstdstr << "\n";
|
||||||
|
@ -124,21 +123,22 @@ int main(int argc, char **argv)
|
||||||
delete root_node;
|
delete root_node;
|
||||||
delete root_module;
|
delete root_module;
|
||||||
|
|
||||||
|
fs::current_path(original_path);
|
||||||
root_module = parsefile(outfilename);
|
root_module = parsefile(outfilename);
|
||||||
if (!root_module) {
|
if (!root_module) {
|
||||||
fprintf(stderr, "Error: Unable to read back dumped file\n");
|
fprintf(stderr, "Error: Unable to read back dumped file\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs::path(filename).has_parent_path()) {
|
|
||||||
fs::current_path(fs::path(filename).parent_path());
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractNode::resetIndexCounter();
|
AbstractNode::resetIndexCounter();
|
||||||
root_node = root_module->evaluate(&root_ctx, &root_inst);
|
root_node = root_module->evaluate(&root_ctx, &root_inst);
|
||||||
|
|
||||||
tree.setRoot(root_node);
|
tree.setRoot(root_node);
|
||||||
|
|
||||||
|
if (fs::path(outfilename).has_parent_path()) {
|
||||||
|
fs::current_path(fs::path(outfilename).parent_path());
|
||||||
|
}
|
||||||
|
|
||||||
string readbackstr = dumptree(tree, *root_node);
|
string readbackstr = dumptree(tree, *root_node);
|
||||||
if (dumpstdstr != readbackstr) {
|
if (dumpstdstr != readbackstr) {
|
||||||
fprintf(stderr, "Error: Readback is different from original dump:\n");
|
fprintf(stderr, "Error: Readback is different from original dump:\n");
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
|
@ -0,0 +1,17 @@
|
||||||
|
group() {
|
||||||
|
linear_extrude(height = 100, center = false, convexity = 1, $fn = 0, $fa = 12, $fs = 2) {
|
||||||
|
import(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2);
|
||||||
|
}
|
||||||
|
multmatrix([[1, 0, 0, -250], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
|
||||||
|
linear_extrude(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, height = 100, center = false, convexity = 1, $fn = 0, $fa = 12, $fs = 2);
|
||||||
|
}
|
||||||
|
multmatrix([[1, 0, 0, 0], [0, 1, 0, 350], [0, 0, 1, 0], [0, 0, 0, 1]]) {
|
||||||
|
rotate_extrude(file = "localfiles_dir/localfile.dxf", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2);
|
||||||
|
}
|
||||||
|
multmatrix([[1, 0, 0, 250], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
|
||||||
|
multmatrix([[200, 0, 0, 0], [0, 200, 0, 0], [0, 0, 50, 0], [0, 0, 0, 1]]) {
|
||||||
|
surface(file = "localfiles_dir/localfile.dat", center = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
group() {
|
||||||
|
cylinder($fn = 0, $fa = 12, $fs = 2, h = 10, r1 = 23, r2 = 10, center = false);
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
Loading…
Reference in New Issue