2009-07-14 09:25:55 +04:00
|
|
|
/*
|
|
|
|
* OpenSCAD (www.openscad.at)
|
|
|
|
* Copyright (C) 2009 Clifford Wolf <clifford@clifford.at>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2010-02-01 12:34:18 +03:00
|
|
|
* As a special exception, you have permission to link this program
|
|
|
|
* with the CGAL library and distribute executables, as long as you
|
|
|
|
* follow the requirements of the GNU GPL in regard to all of the
|
|
|
|
* software in the executable aside from CGAL.
|
|
|
|
*
|
2009-07-14 09:25:55 +04:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-03-28 19:57:39 +04:00
|
|
|
#include "rendernode.h"
|
2010-01-30 07:26:05 +03:00
|
|
|
#include "module.h"
|
|
|
|
#include "polyset.h"
|
|
|
|
#include "context.h"
|
|
|
|
#include "dxfdata.h"
|
|
|
|
#include "dxftess.h"
|
|
|
|
#include "csgterm.h"
|
|
|
|
#include "builtin.h"
|
2009-12-09 17:22:50 +03:00
|
|
|
#include "printutils.h"
|
2010-02-09 16:48:09 +03:00
|
|
|
#include "progress.h"
|
2010-03-02 21:22:31 +03:00
|
|
|
#include "visitor.h"
|
2010-01-30 07:26:05 +03:00
|
|
|
#ifdef ENABLE_CGAL
|
|
|
|
# include "cgal.h"
|
|
|
|
#endif
|
2009-12-09 17:22:50 +03:00
|
|
|
|
2009-07-14 09:25:55 +04:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QTime>
|
2010-03-02 21:22:31 +03:00
|
|
|
#include <sstream>
|
2009-07-14 09:25:55 +04:00
|
|
|
|
|
|
|
class RenderModule : public AbstractModule
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RenderModule() { }
|
2010-01-06 22:38:45 +03:00
|
|
|
virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstantiation *inst) const;
|
2009-07-14 09:25:55 +04:00
|
|
|
};
|
|
|
|
|
2010-01-06 22:38:45 +03:00
|
|
|
AbstractNode *RenderModule::evaluate(const Context *ctx, const ModuleInstantiation *inst) const
|
2009-07-14 09:25:55 +04:00
|
|
|
{
|
|
|
|
RenderNode *node = new RenderNode(inst);
|
2009-07-15 01:47:32 +04:00
|
|
|
|
|
|
|
QVector<QString> argnames = QVector<QString>() << "convexity";
|
|
|
|
QVector<Expression*> argexpr;
|
|
|
|
|
|
|
|
Context c(ctx);
|
|
|
|
c.args(argnames, argexpr, inst->argnames, inst->argvalues);
|
|
|
|
|
|
|
|
Value v = c.lookup_variable("convexity");
|
|
|
|
if (v.type == Value::NUMBER)
|
2009-08-10 11:18:35 +04:00
|
|
|
node->convexity = (int)v.num;
|
2009-07-15 01:47:32 +04:00
|
|
|
|
2010-01-06 22:38:45 +03:00
|
|
|
foreach (ModuleInstantiation *v, inst->children) {
|
2009-07-14 09:25:55 +04:00
|
|
|
AbstractNode *n = v->evaluate(inst->ctx);
|
|
|
|
if (n != NULL)
|
|
|
|
node->children.append(n);
|
|
|
|
}
|
2009-07-15 01:47:32 +04:00
|
|
|
|
2009-07-14 09:25:55 +04:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
void register_builtin_render()
|
|
|
|
{
|
|
|
|
builtin_modules["render"] = new RenderModule();
|
|
|
|
}
|
|
|
|
|
2010-03-02 21:22:31 +03:00
|
|
|
std::string RenderNode::toString() const
|
|
|
|
{
|
|
|
|
std::stringstream stream;
|
|
|
|
|
|
|
|
stream << "render(convexity = " << convexity << ")";
|
|
|
|
|
|
|
|
return stream.str();
|
|
|
|
}
|