summaryrefslogtreecommitdiff
path: root/src/primitives.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-12-15 23:21:51 (GMT)
committerMarius Kintel <marius@kintel.net>2013-12-15 23:21:51 (GMT)
commitdced79fb2d6a4bb1bd5992e611e1c209b910f820 (patch)
treef1491a4331debb8f89098553ceeff377a4053ab3 /src/primitives.cc
parent4fd18f6d72d3690dec11c7241a8127fe37007dec (diff)
parent446dc3d36d36ee3786615c6297a141c01ed972c0 (diff)
Merge pull request #574 from openscad/planar
Planar - see issue #349
Diffstat (limited to 'src/primitives.cc')
-rw-r--r--src/primitives.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/primitives.cc b/src/primitives.cc
index a587d43..a76637d 100644
--- a/src/primitives.cc
+++ b/src/primitives.cc
@@ -103,7 +103,7 @@ public:
double fn, fs, fa;
primitive_type_e type;
int convexity;
- Value points, paths, triangles;
+ Value points, paths, faces;
virtual PolySet *evaluate_polyset(class PolySetEvaluator *) const;
};
@@ -156,7 +156,7 @@ AbstractNode *PrimitiveModule::instantiate(const Context *ctx, const ModuleInsta
args += Assignment("h", NULL), Assignment("r1", NULL), Assignment("r2", NULL), Assignment("center", NULL);
break;
case POLYHEDRON:
- args += Assignment("points", NULL), Assignment("triangles", NULL), Assignment("convexity", NULL);
+ args += Assignment("points", NULL), Assignment("triangles", NULL), Assignment("convexity", NULL), Assignment("faces", NULL);
break;
case SQUARE:
args += Assignment("size", NULL), Assignment("center", NULL);
@@ -235,7 +235,11 @@ AbstractNode *PrimitiveModule::instantiate(const Context *ctx, const ModuleInsta
if (type == POLYHEDRON) {
node->points = c.lookup_variable("points");
- node->triangles = c.lookup_variable("triangles");
+ node->faces = c.lookup_variable("faces");
+ if (node->faces.type() == Value::UNDEFINED) {
+ // backwards compatable
+ node->faces = c.lookup_variable("triangles");
+ }
}
if (type == SQUARE) {
@@ -480,11 +484,11 @@ sphere_next_r2:
if (this->type == POLYHEDRON)
{
p->convexity = this->convexity;
- for (size_t i=0; i<this->triangles.toVector().size(); i++)
+ for (size_t i=0; i<this->faces.toVector().size(); i++)
{
p->append_poly();
- for (size_t j=0; j<this->triangles.toVector()[i].toVector().size(); j++) {
- size_t pt = this->triangles.toVector()[i].toVector()[j].toDouble();
+ for (size_t j=0; j<this->faces.toVector()[i].toVector().size(); j++) {
+ size_t pt = this->faces.toVector()[i].toVector()[j].toDouble();
if (pt < this->points.toVector().size()) {
double px, py, pz;
if (this->points.toVector()[pt].getVec3(px, py, pz))
@@ -610,7 +614,7 @@ std::string PrimitiveNode::toString() const
break;
case POLYHEDRON:
stream << "(points = " << this->points
- << ", triangles = " << this->triangles
+ << ", faces = " << this->faces
<< ", convexity = " << this->convexity << ")";
break;
case SQUARE:
contact: Jan Huwald // Impressum