summaryrefslogtreecommitdiff
path: root/dxfdim.cc
diff options
context:
space:
mode:
authorkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-01-21 11:25:46 (GMT)
committerkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-01-21 11:25:46 (GMT)
commit135370d418b01ea2aab8fa20ea30b20a04f893b0 (patch)
treea663ef02b4f3df03db0e7d77e709c85b37d59a0c /dxfdim.cc
parent16de8939075496b1ed1451b3c34032c25b94b108 (diff)
Added support for aligned, ordinate, radius and diameter DIMENSION entities
git-svn-id: http://svn.clifford.at/openscad/trunk@326 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'dxfdim.cc')
-rw-r--r--dxfdim.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/dxfdim.cc b/dxfdim.cc
index 5b37e11..359606a 100644
--- a/dxfdim.cc
+++ b/dxfdim.cc
@@ -78,24 +78,31 @@ Value builtin_dxf_dim(const QVector<QString> &argnames, const QVector<Value> &ar
double distance_projected_on_line = fabs(x * cos(angle*M_PI/180) + y * sin(angle*M_PI/180));
return dxf_dim_cache[key] = Value(distance_projected_on_line);
}
- if (type == 1) {
+ else if (type == 1) {
// Aligned
+ double x = d->coords[4][0] - d->coords[3][0];
+ double y = d->coords[4][1] - d->coords[3][1];
+ return dxf_dim_cache[key] = Value(sqrt(x*x + y*y));
}
- if (type == 2) {
+ else if (type == 2) {
// Angular
double a1 = atan2(d->coords[0][0] - d->coords[5][0], d->coords[0][1] - d->coords[5][1]);
double a2 = atan2(d->coords[4][0] - d->coords[3][0], d->coords[4][1] - d->coords[3][1]);
return dxf_dim_cache[key] = Value(fabs(a1 - a2) * 180 / M_PI);
}
- if (type == 3) {
- // Diameter
+ else if (type == 3 || type == 4) {
+ // Diameter or Radius
+ double x = d->coords[5][0] - d->coords[0][0];
+ double y = d->coords[5][1] - d->coords[0][1];
+ return dxf_dim_cache[key] = Value(sqrt(x*x + y*y));
}
- if (type == 4) {
- // Radius
- }
- if (type == 5) {
+ else if (type == 5) {
// Angular 3 Point
}
+ else if (type == 6) {
+ // Ordinate
+ return dxf_dim_cache[key] = Value((d->type & 64) ? d->coords[3][0] : d->coords[3][1]);
+ }
PRINTA("WARNING: Dimension `%1' in `%2', layer `%3' has unsupported type!", name, filename, layername);
return Value();
contact: Jan Huwald // Impressum