mirror of https://github.com/vitalif/openscad
Allow preview of designs with only background or highlight objects. Fixes #1005
parent
a3a6b66061
commit
90f58ced7d
|
@ -43,8 +43,8 @@ public:
|
||||||
CSGTermEvaluator evaluator(tree, &geomevaluator);
|
CSGTermEvaluator evaluator(tree, &geomevaluator);
|
||||||
boost::shared_ptr<CSGTerm> root_raw_term = evaluator.evaluateCSGTerm( *root_node, this->highlight_terms, this->background_terms );
|
boost::shared_ptr<CSGTerm> root_raw_term = evaluator.evaluateCSGTerm( *root_node, this->highlight_terms, this->background_terms );
|
||||||
|
|
||||||
if (!root_raw_term) {
|
if (!root_raw_term && this->background_terms.empty()) {
|
||||||
PRINT("Error: CSG generation failed! (no top level object found)");
|
PRINT("Error: CSG generation failed! (no objects found)");
|
||||||
call_progress_function();
|
call_progress_function();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -52,16 +52,18 @@ public:
|
||||||
PRINT("Compiling design (CSG Products normalization)...");
|
PRINT("Compiling design (CSG Products normalization)...");
|
||||||
call_progress_function();
|
call_progress_function();
|
||||||
CSGTermNormalizer normalizer( normalizelimit );
|
CSGTermNormalizer normalizer( normalizelimit );
|
||||||
this->root_norm_term = normalizer.normalize(root_raw_term);
|
if (root_raw_term) {
|
||||||
if (this->root_norm_term) {
|
this->root_norm_term = normalizer.normalize(root_raw_term);
|
||||||
this->root_chain = new CSGChain();
|
if (this->root_norm_term) {
|
||||||
this->root_chain->import(this->root_norm_term);
|
this->root_chain = new CSGChain();
|
||||||
PRINTB("Normalized CSG tree has %d elements", int(this->root_chain->objects.size()));
|
this->root_chain->import(this->root_norm_term);
|
||||||
}
|
PRINTB("Normalized CSG tree has %d elements", int(this->root_chain->objects.size()));
|
||||||
else {
|
}
|
||||||
this->root_chain = NULL;
|
else {
|
||||||
PRINT("WARNING: CSG normalization resulted in an empty tree");
|
this->root_chain = NULL;
|
||||||
call_progress_function();
|
PRINT("WARNING: CSG normalization resulted in an empty tree");
|
||||||
|
call_progress_function();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->highlight_terms.size() > 0) {
|
if (this->highlight_terms.size() > 0) {
|
||||||
|
|
|
@ -58,16 +58,16 @@ OpenCSGRenderer::OpenCSGRenderer(CSGChain *root_chain, CSGChain *highlights_chai
|
||||||
|
|
||||||
void OpenCSGRenderer::draw(bool /*showfaces*/, bool showedges) const
|
void OpenCSGRenderer::draw(bool /*showfaces*/, bool showedges) const
|
||||||
{
|
{
|
||||||
|
GLint *shaderinfo = this->shaderinfo;
|
||||||
|
if (!shaderinfo[0]) shaderinfo = NULL;
|
||||||
if (this->root_chain) {
|
if (this->root_chain) {
|
||||||
GLint *shaderinfo = this->shaderinfo;
|
|
||||||
if (!shaderinfo[0]) shaderinfo = NULL;
|
|
||||||
renderCSGChain(this->root_chain, showedges ? shaderinfo : NULL, false, false);
|
renderCSGChain(this->root_chain, showedges ? shaderinfo : NULL, false, false);
|
||||||
if (this->background_chain) {
|
}
|
||||||
renderCSGChain(this->background_chain, showedges ? shaderinfo : NULL, false, true);
|
if (this->background_chain) {
|
||||||
}
|
renderCSGChain(this->background_chain, showedges ? shaderinfo : NULL, false, true);
|
||||||
if (this->highlights_chain) {
|
}
|
||||||
renderCSGChain(this->highlights_chain, showedges ? shaderinfo : NULL, true, false);
|
if (this->highlights_chain) {
|
||||||
}
|
renderCSGChain(this->highlights_chain, showedges ? shaderinfo : NULL, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
105
src/mainwin.cc
105
src/mainwin.cc
|
@ -1031,8 +1031,8 @@ void MainWindow::compileCSG(bool procevents)
|
||||||
CSGTermEvaluator csgrenderer(this->tree, &geomevaluator);
|
CSGTermEvaluator csgrenderer(this->tree, &geomevaluator);
|
||||||
if (procevents) QApplication::processEvents();
|
if (procevents) QApplication::processEvents();
|
||||||
this->root_raw_term = csgrenderer.evaluateCSGTerm(*root_node, highlight_terms, background_terms);
|
this->root_raw_term = csgrenderer.evaluateCSGTerm(*root_node, highlight_terms, background_terms);
|
||||||
if (!root_raw_term) {
|
if (!root_raw_term && background_terms.empty()) {
|
||||||
PRINT("ERROR: CSG generation failed! (no top level object found)");
|
PRINT("ERROR: CSG generation failed! (no objects found)");
|
||||||
}
|
}
|
||||||
GeometryCache::instance()->print();
|
GeometryCache::instance()->print();
|
||||||
#ifdef ENABLE_CGAL
|
#ifdef ENABLE_CGAL
|
||||||
|
@ -1048,12 +1048,13 @@ void MainWindow::compileCSG(bool procevents)
|
||||||
delete this->progresswidget;
|
delete this->progresswidget;
|
||||||
this->progresswidget = NULL;
|
this->progresswidget = NULL;
|
||||||
|
|
||||||
if (root_raw_term) {
|
PRINT("Compiling design (CSG Products normalization)...");
|
||||||
PRINT("Compiling design (CSG Products normalization)...");
|
if (procevents) QApplication::processEvents();
|
||||||
if (procevents) QApplication::processEvents();
|
|
||||||
|
|
||||||
size_t normalizelimit = 2 * Preferences::inst()->getValue("advanced/openCSGLimit").toUInt();
|
size_t normalizelimit = 2 * Preferences::inst()->getValue("advanced/openCSGLimit").toUInt();
|
||||||
CSGTermNormalizer normalizer(normalizelimit);
|
CSGTermNormalizer normalizer(normalizelimit);
|
||||||
|
|
||||||
|
if (root_raw_term) {
|
||||||
this->root_norm_term = normalizer.normalize(this->root_raw_term);
|
this->root_norm_term = normalizer.normalize(this->root_raw_term);
|
||||||
if (this->root_norm_term) {
|
if (this->root_norm_term) {
|
||||||
this->root_chain = new CSGChain();
|
this->root_chain = new CSGChain();
|
||||||
|
@ -1064,53 +1065,51 @@ void MainWindow::compileCSG(bool procevents)
|
||||||
PRINT("WARNING: CSG normalization resulted in an empty tree");
|
PRINT("WARNING: CSG normalization resulted in an empty tree");
|
||||||
if (procevents) QApplication::processEvents();
|
if (procevents) QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlight_terms.size() > 0)
|
|
||||||
{
|
|
||||||
PRINTB("Compiling highlights (%d CSG Trees)...", highlight_terms.size());
|
|
||||||
if (procevents) QApplication::processEvents();
|
|
||||||
|
|
||||||
highlights_chain = new CSGChain();
|
|
||||||
for (unsigned int i = 0; i < highlight_terms.size(); i++) {
|
|
||||||
highlight_terms[i] = normalizer.normalize(highlight_terms[i]);
|
|
||||||
highlights_chain->import(highlight_terms[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (background_terms.size() > 0)
|
|
||||||
{
|
|
||||||
PRINTB("Compiling background (%d CSG Trees)...", background_terms.size());
|
|
||||||
if (procevents) QApplication::processEvents();
|
|
||||||
|
|
||||||
background_chain = new CSGChain();
|
|
||||||
for (unsigned int i = 0; i < background_terms.size(); i++) {
|
|
||||||
background_terms[i] = normalizer.normalize(background_terms[i]);
|
|
||||||
background_chain->import(background_terms[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->root_chain &&
|
|
||||||
(this->root_chain->objects.size() >
|
|
||||||
Preferences::inst()->getValue("advanced/openCSGLimit").toUInt())) {
|
|
||||||
PRINTB("WARNING: Normalized tree has %d elements!", this->root_chain->objects.size());
|
|
||||||
PRINT("WARNING: OpenCSG rendering has been disabled.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PRINTB("Normalized CSG tree has %d elements",
|
|
||||||
(this->root_chain ? this->root_chain->objects.size() : 0));
|
|
||||||
this->opencsgRenderer = new OpenCSGRenderer(this->root_chain,
|
|
||||||
this->highlights_chain,
|
|
||||||
this->background_chain,
|
|
||||||
this->qglview->shaderinfo);
|
|
||||||
}
|
|
||||||
this->thrownTogetherRenderer = new ThrownTogetherRenderer(this->root_chain,
|
|
||||||
this->highlights_chain,
|
|
||||||
this->background_chain);
|
|
||||||
PRINT("CSG generation finished.");
|
|
||||||
int s = t.elapsed() / 1000;
|
|
||||||
PRINTB("Total rendering time: %d hours, %d minutes, %d seconds", (s / (60*60)) % ((s / 60) % 60) % (s % 60));
|
|
||||||
if (procevents) QApplication::processEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (highlight_terms.size() > 0) {
|
||||||
|
PRINTB("Compiling highlights (%d CSG Trees)...", highlight_terms.size());
|
||||||
|
if (procevents) QApplication::processEvents();
|
||||||
|
|
||||||
|
highlights_chain = new CSGChain();
|
||||||
|
for (unsigned int i = 0; i < highlight_terms.size(); i++) {
|
||||||
|
highlight_terms[i] = normalizer.normalize(highlight_terms[i]);
|
||||||
|
highlights_chain->import(highlight_terms[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (background_terms.size() > 0) {
|
||||||
|
PRINTB("Compiling background (%d CSG Trees)...", background_terms.size());
|
||||||
|
if (procevents) QApplication::processEvents();
|
||||||
|
|
||||||
|
background_chain = new CSGChain();
|
||||||
|
for (unsigned int i = 0; i < background_terms.size(); i++) {
|
||||||
|
background_terms[i] = normalizer.normalize(background_terms[i]);
|
||||||
|
background_chain->import(background_terms[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->root_chain &&
|
||||||
|
(this->root_chain->objects.size() >
|
||||||
|
Preferences::inst()->getValue("advanced/openCSGLimit").toUInt())) {
|
||||||
|
PRINTB("WARNING: Normalized tree has %d elements!", this->root_chain->objects.size());
|
||||||
|
PRINT("WARNING: OpenCSG rendering has been disabled.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PRINTB("Normalized CSG tree has %d elements",
|
||||||
|
(this->root_chain ? this->root_chain->objects.size() : 0));
|
||||||
|
this->opencsgRenderer = new OpenCSGRenderer(this->root_chain,
|
||||||
|
this->highlights_chain,
|
||||||
|
this->background_chain,
|
||||||
|
this->qglview->shaderinfo);
|
||||||
|
}
|
||||||
|
this->thrownTogetherRenderer = new ThrownTogetherRenderer(this->root_chain,
|
||||||
|
this->highlights_chain,
|
||||||
|
this->background_chain);
|
||||||
|
PRINT("CSG generation finished.");
|
||||||
|
int s = t.elapsed() / 1000;
|
||||||
|
PRINTB("Total rendering time: %d hours, %d minutes, %d seconds", (s / (60*60)) % ((s / 60) % 60) % (s % 60));
|
||||||
|
if (procevents) QApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::actionUpdateCheck()
|
void MainWindow::actionUpdateCheck()
|
||||||
|
|
Loading…
Reference in New Issue