mirror of https://github.com/vitalif/openscad
CSGTermRenderer refactor: minor update
parent
d0390c41a2
commit
8a0ddf4e5b
|
@ -24,8 +24,6 @@
|
|||
|
||||
void CSGTermRenderer::applyToChildren(const AbstractNode &node, CSGTermRenderer::CsgOp op)
|
||||
{
|
||||
if (this->visitedchildren[node.index()].size() == 0) return;
|
||||
|
||||
CSGTerm *t1 = NULL;
|
||||
for (ChildList::const_iterator iter = this->visitedchildren[node.index()].begin();
|
||||
iter != this->visitedchildren[node.index()].end();
|
||||
|
@ -50,7 +48,7 @@ void CSGTermRenderer::applyToChildren(const AbstractNode &node, CSGTermRenderer:
|
|||
}
|
||||
if (t1 && node.modinst->tag_background && this->background) {
|
||||
this->background->push_back(t1);
|
||||
// FIXME: don't store in stored_term? return NULL;
|
||||
t1 = NULL; // don't propagate background tagged nodes
|
||||
}
|
||||
this->stored_term[node.index()] = t1;
|
||||
}
|
||||
|
@ -78,9 +76,9 @@ static CSGTerm *render_csg_term_from_ps(const double m[20],
|
|||
vector<CSGTerm*> *background,
|
||||
PolySet *ps,
|
||||
const ModuleInstantiation *modinst,
|
||||
int idx)
|
||||
const AbstractPolyNode &node)
|
||||
{
|
||||
CSGTerm *t = new CSGTerm(ps, m, QString("n%1").arg(idx));
|
||||
CSGTerm *t = new CSGTerm(ps, m, QString("%1%2").arg(node.name().c_str()).arg(node.index()));
|
||||
if (modinst->tag_highlight && highlights)
|
||||
highlights->push_back(t->link());
|
||||
if (modinst->tag_background && background) {
|
||||
|
@ -94,7 +92,7 @@ Response CSGTermRenderer::visit(State &state, const AbstractPolyNode &node)
|
|||
{
|
||||
if (state.isPostfix()) {
|
||||
PolySet *ps = node.render_polyset(AbstractPolyNode::RENDER_OPENCSG);
|
||||
CSGTerm *t1 = render_csg_term_from_ps(state.matrix(), this->highlights, this->background, ps, node.modinst, node.index());
|
||||
CSGTerm *t1 = render_csg_term_from_ps(state.matrix(), this->highlights, this->background, ps, node.modinst, node);
|
||||
this->stored_term[node.index()] = t1;
|
||||
addToParent(state, node);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ private:
|
|||
const AbstractNode *root;
|
||||
typedef list<const AbstractNode *> ChildList;
|
||||
map<int, ChildList> visitedchildren;
|
||||
|
||||
public:
|
||||
map<int, class CSGTerm*> stored_term;
|
||||
|
||||
vector<CSGTerm*> *highlights;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "export.h"
|
||||
#include "builtin.h"
|
||||
#include "Tree.h"
|
||||
#include "csgterm.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
|
@ -42,6 +43,8 @@
|
|||
#include <assert.h>
|
||||
#include <iostream>
|
||||
|
||||
using std::cout;
|
||||
|
||||
QString commandline_commands;
|
||||
const char *make_command = NULL;
|
||||
QSet<QString> dependencies;
|
||||
|
@ -62,13 +65,6 @@ void handle_dep(QString filename)
|
|||
}
|
||||
}
|
||||
|
||||
void csgTree(Tree &tree)
|
||||
{
|
||||
CSGTermRenderer renderer;
|
||||
Traverser render(renderer, *tree.root(), Traverser::PRE_AND_POSTFIX);
|
||||
render.execute();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
|
@ -157,8 +153,29 @@ int main(int argc, char **argv)
|
|||
Tree tree;
|
||||
tree.setRoot(root_node);
|
||||
|
||||
csgTree(tree);
|
||||
// cout << tree.getString(*root_node) << "\n";
|
||||
|
||||
CSGTermRenderer renderer;
|
||||
Traverser render(renderer, *tree.root(), Traverser::PRE_AND_POSTFIX);
|
||||
render.execute();
|
||||
|
||||
// cout << "Stored terms: " << renderer.stored_term.size() << "\n";
|
||||
// for (map<int, class CSGTerm*>::iterator iter = renderer.stored_term.begin();
|
||||
// iter != renderer.stored_term.end();
|
||||
// iter++) {
|
||||
// cout << iter->first << ":" << (iter->second ? iter->second->label : "NULL") << "\n";
|
||||
// }
|
||||
|
||||
// if (renderer.background) cout << "Background terms: " << renderer.background->size() << "\n";
|
||||
// if (renderer.highlights) cout << "Highlights terms: " << renderer.highlights->size() << "\n";
|
||||
|
||||
CSGTerm *root_term = renderer.stored_term[root_node->index()];
|
||||
if (root_term) {
|
||||
cout << root_term->dump() << "\n";
|
||||
}
|
||||
else {
|
||||
cout << "No top-level CSG object\n";
|
||||
}
|
||||
|
||||
destroy_builtin_functions();
|
||||
destroy_builtin_modules();
|
||||
|
|
|
@ -9,9 +9,10 @@ function(add_cmdline_test TESTCMD TESTSUFFIX FILES)
|
|||
get_filename_component(TESTCMD_NAME ${TESTCMD} NAME_WE)
|
||||
foreach (SCADFILE ${SCAD_FILES})
|
||||
get_filename_component(TESTNAME ${SCADFILE} NAME_WE)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/regression/${TESTCMD_NAME}/${TESTNAME}-expected.${TESTSUFFIX})
|
||||
# FIXME: Run tests even if no expected files are found (to facilitate generating expected files)
|
||||
# if (EXISTS ${CMAKE_SOURCE_DIR}/regression/${TESTCMD_NAME}/${TESTNAME}-expected.${TESTSUFFIX})
|
||||
add_test(${TESTCMD_NAME}_${TESTNAME} ${tests_SOURCE_DIR}/test_cmdline_tool.py -s ${TESTSUFFIX} ${TESTCMD} ${SCADFILE})
|
||||
endif()
|
||||
# endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
@ -28,3 +29,5 @@ add_cmdline_test(${CMAKE_SOURCE_DIR}/../test-code/csgtexttest txt ${SCAD_FILES})
|
|||
add_cmdline_test(${CMAKE_SOURCE_DIR}/../test-code/cgaltest stl ${SCAD_FILES})
|
||||
# Add dxfexport tests to CTest
|
||||
add_cmdline_test(${CMAKE_SOURCE_DIR}/../test-code/exportdxf dxf ${SCAD_FILES})
|
||||
# Add csgtermtest tests to CTest
|
||||
add_cmdline_test(${CMAKE_SOURCE_DIR}/../test-code/csgtermtest txt ${SCAD_FILES})
|
||||
|
|
Loading…
Reference in New Issue