mirror of https://github.com/vitalif/openscad
WIP adding support for convex hull operations.
parent
7b3a8a990f
commit
9aa7b94459
|
@ -30,6 +30,7 @@
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
#include "printutils.h"
|
#include "printutils.h"
|
||||||
#include "cgal.h"
|
#include "cgal.h"
|
||||||
|
#include <CGAL/ch_graham_andrew.h>
|
||||||
|
|
||||||
#ifdef ENABLE_CGAL
|
#ifdef ENABLE_CGAL
|
||||||
extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b);
|
extern CGAL_Nef_polyhedron3 minkowski3(CGAL_Nef_polyhedron3 a, CGAL_Nef_polyhedron3 b);
|
||||||
|
@ -39,7 +40,8 @@ extern CGAL_Nef_polyhedron2 minkowski2(CGAL_Nef_polyhedron2 a, CGAL_Nef_polyhedr
|
||||||
enum cgaladv_type_e {
|
enum cgaladv_type_e {
|
||||||
MINKOWSKI,
|
MINKOWSKI,
|
||||||
GLIDE,
|
GLIDE,
|
||||||
SUBDIV
|
SUBDIV,
|
||||||
|
HULL
|
||||||
};
|
};
|
||||||
|
|
||||||
class CgaladvModule : public AbstractModule
|
class CgaladvModule : public AbstractModule
|
||||||
|
@ -103,6 +105,10 @@ AbstractNode *CgaladvModule::evaluate(const Context *ctx, const ModuleInstantiat
|
||||||
level = c.lookup_variable("level", true);
|
level = c.lookup_variable("level", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == HULL) {
|
||||||
|
convexity = c.lookup_variable("convexity", true);
|
||||||
|
}
|
||||||
|
|
||||||
node->convexity = (int)convexity.num;
|
node->convexity = (int)convexity.num;
|
||||||
node->path = path;
|
node->path = path;
|
||||||
node->subdiv_type = subdiv_type.text;
|
node->subdiv_type = subdiv_type.text;
|
||||||
|
@ -125,6 +131,7 @@ void register_builtin_cgaladv()
|
||||||
builtin_modules["minkowski"] = new CgaladvModule(MINKOWSKI);
|
builtin_modules["minkowski"] = new CgaladvModule(MINKOWSKI);
|
||||||
builtin_modules["glide"] = new CgaladvModule(GLIDE);
|
builtin_modules["glide"] = new CgaladvModule(GLIDE);
|
||||||
builtin_modules["subdiv"] = new CgaladvModule(SUBDIV);
|
builtin_modules["subdiv"] = new CgaladvModule(SUBDIV);
|
||||||
|
builtin_modules["hull"] = new CgaladvModule(HULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_CGAL
|
#ifdef ENABLE_CGAL
|
||||||
|
@ -174,6 +181,29 @@ CGAL_Nef_polyhedron CgaladvNode::render_cgal_nef_polyhedron() const
|
||||||
PRINT("WARNING: subdiv() is not implemented yet!");
|
PRINT("WARNING: subdiv() is not implemented yet!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == HULL)
|
||||||
|
{
|
||||||
|
bool first = true;
|
||||||
|
foreach(AbstractNode * v, children) {
|
||||||
|
if (v->modinst->tag_background)
|
||||||
|
continue;
|
||||||
|
if (first) {
|
||||||
|
N = v->render_cgal_nef_polyhedron();
|
||||||
|
if (N.dim != 0)
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
CGAL_Nef_polyhedron tmp = v->render_cgal_nef_polyhedron();
|
||||||
|
if (N.dim == 3 && tmp.dim == 3) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if (N.dim == 2 && tmp.dim == 2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v->progress_report();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight());
|
cgal_nef_cache.insert(cache_id, new cgal_nef_cache_entry(N), N.weight());
|
||||||
print_messages_pop();
|
print_messages_pop();
|
||||||
progress_report();
|
progress_report();
|
||||||
|
|
Loading…
Reference in New Issue