diff --git a/dxfdata.cc b/dxfdata.cc index 06c2c3f2..a6d2cd86 100644 --- a/dxfdata.cc +++ b/dxfdata.cc @@ -176,12 +176,18 @@ DxfData::DxfData(double /* fn */, double /* fs */, double /* fa */, QString file } // rotate points if the path is not in non-standard rotation int b = min_x_point; - int a = b == 0 ? paths[i].points.count() - 1 : b - 1; - int c = b == paths[i].points.count() - 1 ? 0 : b + 1; + int a = b == 0 ? paths[i].points.count() - 2 : b - 1; + int c = b == paths[i].points.count() - 1 ? 1 : b + 1; double ax = paths[i].points[a]->x - paths[i].points[b]->x; double ay = paths[i].points[a]->y - paths[i].points[b]->y; - double cx = paths[i].points[c]->x - paths[i].points[c]->x; - double cy = paths[i].points[c]->y - paths[i].points[c]->y; + double cx = paths[i].points[c]->x - paths[i].points[b]->x; + double cy = paths[i].points[c]->y - paths[i].points[b]->y; +#if 0 + printf("Rotate check:\n"); + printf(" a/b/c indices = %d %d %d\n", a, b, c); + printf(" b->a vector = %f %f (%f)\n", ax, ay, atan2(ax, ay)); + printf(" b->c vector = %f %f (%f)\n", cx, cy, atan2(cx, cy)); +#endif if (atan2(ax, ay) < atan2(cx, cy)) { for (int j = 0; j < paths[i].points.count()/2; j++) paths[i].points.swap(j, paths[i].points.count()-1-j); @@ -193,7 +199,8 @@ DxfData::DxfData(double /* fn */, double /* fs */, double /* fa */, QString file #if 0 printf("----- DXF Data -----\n"); for (int i = 0; i < paths.count(); i++) { - printf("Path %d (%s, %s):\n", i, paths[i].is_closed ? "closed" : "open", paths[i].is_inner ? "inner" : "outer"); + printf("Path %d (%s, %s):\n", i, paths[i].is_closed ? "closed" : "open", + paths[i].is_inner ? "inner" : "outer"); for (int j = 0; j < paths[i].points.count(); j++) printf(" %f %f\n", paths[i].points[j]->x, paths[i].points[j]->y); } diff --git a/dxfrotextrude.cc b/dxfrotextrude.cc new file mode 100644 index 00000000..489f2228 --- /dev/null +++ b/dxfrotextrude.cc @@ -0,0 +1,152 @@ +/* + * OpenSCAD (www.openscad.at) + * Copyright (C) 2009 Clifford Wolf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define INCLUDE_ABSTRACT_NODE_DETAILS + +#include "openscad.h" + +class DxfRotateExtrudeModule : public AbstractModule +{ +public: + DxfRotateExtrudeModule() { } + virtual AbstractNode *evaluate(const Context *ctx, const ModuleInstanciation *inst) const; +}; + +class DxfRotateExtrudeNode : public AbstractPolyNode +{ +public: + int convexity; + double fn, fs, fa; + QString filename, layername; + DxfRotateExtrudeNode(const ModuleInstanciation *mi) : AbstractPolyNode(mi) { } + virtual PolySet *render_polyset(render_mode_e mode) const; + virtual QString dump(QString indent) const; +}; + +AbstractNode *DxfRotateExtrudeModule::evaluate(const Context *ctx, const ModuleInstanciation *inst) const +{ + DxfRotateExtrudeNode *node = new DxfRotateExtrudeNode(inst); + + QVector argnames = QVector() << "file" << "layer"; + QVector argexpr; + + Context c(ctx); + c.args(argnames, argexpr, inst->argnames, inst->argvalues); + + node->fn = c.lookup_variable("$fn").num; + node->fs = c.lookup_variable("$fs").num; + node->fa = c.lookup_variable("$fa").num; + + Value file = c.lookup_variable("file"); + Value layer = c.lookup_variable("layer"); + Value convexity = c.lookup_variable("convexity"); + + node->filename = file.text; + node->layername = layer.text; + node->convexity = convexity.num; + + if (node->convexity <= 0) + node->convexity = 1; + + return node; +} + +void register_builtin_dxf_rotate_extrude() +{ + builtin_modules["dxf_rotate_extrude"] = new DxfRotateExtrudeModule(); +} + +PolySet *DxfRotateExtrudeNode::render_polyset(render_mode_e) const +{ + DxfData dxf(fn, fs, fa, filename, layername); + + PolySet *ps = new PolySet(); + ps->convexity = convexity; + + for (int i = 0; i < dxf.paths.count(); i++) + { + double max_x = 0; + for (int j = 0; j < dxf.paths[i].points.count(); j++) { + max_x = fmax(max_x, dxf.paths[i].points[j]->x); + } + + int fragments = get_fragments_from_r(max_x, fn, fs, fa); + + double points[fragments][dxf.paths[i].points.count()][3]; + + for (int j = 0; j < fragments; j++) { + double a = (j*2*M_PI) / fragments; + for (int k = 0; k < dxf.paths[i].points.count(); k++) { + if (dxf.paths[i].points[k]->x == 0) { + points[j][k][0] = 0; + points[j][k][1] = 0; + } else { + points[j][k][0] = dxf.paths[i].points[k]->x * sin(a); + points[j][k][1] = dxf.paths[i].points[k]->x * cos(a); + } + points[j][k][2] = dxf.paths[i].points[k]->y; + } + } + + for (int j = 0; j < fragments; j++) { + int j1 = j + 1 < fragments ? j + 1 : 0; + for (int k = 0; k < dxf.paths[i].points.count(); k++) { + int k1 = k + 1 < dxf.paths[i].points.count() ? k + 1 : 0; + if (points[j][k][0] != points[j1][k][0] || + points[j][k][1] != points[j1][k][1] || + points[j][k][2] != points[j1][k][2]) { + ps->append_poly(); + ps->append_vertex(points[j ][k ][0], + points[j ][k ][1], points[j ][k ][2]); + ps->append_vertex(points[j1][k ][0], + points[j1][k ][1], points[j1][k ][2]); + ps->append_vertex(points[j ][k1][0], + points[j ][k1][1], points[j ][k1][2]); + } + if (points[j][k1][0] != points[j1][k1][0] || + points[j][k1][1] != points[j1][k1][1] || + points[j][k1][2] != points[j1][k1][2]) { + ps->append_poly(); + ps->append_vertex(points[j ][k1][0], + points[j ][k1][1], points[j ][k1][2]); + ps->append_vertex(points[j1][k ][0], + points[j1][k ][1], points[j1][k ][2]); + ps->append_vertex(points[j1][k1][0], + points[j1][k1][1], points[j1][k1][2]); + } + } + } + } + + return ps; +} + +QString DxfRotateExtrudeNode::dump(QString indent) const +{ + if (dump_cache.isEmpty()) { + QString text; + text.sprintf("dxf_rotate_extrude(file = \"%s\", layer = \"%s\", " + "$fn = %f, $fa = %f, $fs = %f);\n", + filename.toAscii().data(), layername.toAscii().data(),fn, fs, fa); + ((AbstractNode*)this)->dump_cache = indent + QString("n%1: ").arg(idx) + text; + } + return dump_cache; +} + diff --git a/examples/example007.dxf b/examples/example007.dxf new file mode 100644 index 00000000..70e2bf37 --- /dev/null +++ b/examples/example007.dxf @@ -0,0 +1,2410 @@ +999 +dxflib 2.0.4.8 + 0 +SECTION + 2 +HEADER + 9 +$ACADVER + 1 +AC1015 + 9 +$HANDSEED + 5 +FFFF + 9 +$DIMASZ + 40 +2.5 + 9 +$DIMGAP + 40 +0.625 + 9 +$INSUNITS + 70 +4 + 9 +$DIMEXO + 40 +0.625 + 9 +$DIMTXT + 40 +2.5 + 9 +$DIMSTYLE + 2 +Standard + 9 +$PLIMMIN + 10 +0.0 + 20 +0.0 + 9 +$PLIMMAX + 10 +210.0 + 20 +297.0 + 9 +$DIMEXE + 40 +1.25 + 0 +ENDSEC + 0 +SECTION + 2 +TABLES + 0 +TABLE + 2 +VPORT + 5 +8 +100 +AcDbSymbolTable + 70 +1 + 0 +VPORT + 5 +30 +100 +AcDbSymbolTableRecord +100 +AcDbViewportTableRecord + 2 +*Active + 70 +0 + 10 +0.0 + 20 +0.0 + 11 +1.0 + 21 +1.0 + 12 +286.3055555555554861 + 22 +148.5 + 13 +0.0 + 23 +0.0 + 14 +10.0 + 24 +10.0 + 15 +10.0 + 25 +10.0 + 16 +0.0 + 26 +0.0 + 36 +1.0 + 17 +0.0 + 27 +0.0 + 37 +0.0 + 40 +297.0 + 41 +1.92798353909465 + 42 +50.0 + 43 +0.0 + 44 +0.0 + 50 +0.0 + 51 +0.0 + 71 +0 + 72 +100 + 73 +1 + 74 +3 + 75 +1 + 76 +1 + 77 +0 + 78 +0 +281 +0 + 65 +1 +110 +0.0 +120 +0.0 +130 +0.0 +111 +1.0 +121 +0.0 +131 +0.0 +112 +0.0 +122 +1.0 +132 +0.0 + 79 +0 +146 +0.0 + 0 +ENDTAB + 0 +TABLE + 2 +LTYPE + 5 +5 +100 +AcDbSymbolTable + 70 +21 + 0 +LTYPE + 5 +14 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +ByBlock + 70 +0 + 3 + + 72 +65 + 73 +0 + 40 +0.0 + 0 +LTYPE + 5 +15 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +ByLayer + 70 +0 + 3 + + 72 +65 + 73 +0 + 40 +0.0 + 0 +LTYPE + 5 +16 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +CONTINUOUS + 70 +0 + 3 +Solid line + 72 +65 + 73 +0 + 40 +0.0 + 0 +LTYPE + 5 +31 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DOT + 70 +0 + 3 +Dot . . . . . . . . . . . . . . . . . . . . . . + 72 +65 + 73 +2 + 40 +6.3499999999999996 + 49 +0.0 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 0 +LTYPE + 5 +32 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DOT2 + 70 +0 + 3 +Dot (.5x) ..................................... + 72 +65 + 73 +2 + 40 +3.1749999999999998 + 49 +0.0 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 0 +LTYPE + 5 +33 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DOTX2 + 70 +0 + 3 +Dot (2x) . . . . . . . . . . . . . + 72 +65 + 73 +2 + 40 +12.6999999999999993 + 49 +0.0 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 0 +LTYPE + 5 +34 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DASHED + 70 +0 + 3 +Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _ + 72 +65 + 73 +2 + 40 +19.0500000000000007 + 49 +12.6999999999999993 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 0 +LTYPE + 5 +35 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DASHED2 + 70 +0 + 3 +Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + 72 +65 + 73 +2 + 40 +9.5250000000000004 + 49 +6.3499999999999996 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 0 +LTYPE + 5 +36 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DASHEDX2 + 70 +0 + 3 +Dashed (2x) ____ ____ ____ ____ ____ ___ + 72 +65 + 73 +2 + 40 +38.1000000000000014 + 49 +25.3999999999999986 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 0 +LTYPE + 5 +37 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DASHDOT + 70 +0 + 3 +Dash dot __ . __ . __ . __ . __ . __ . __ . __ + 72 +65 + 73 +4 + 40 +25.3999999999999986 + 49 +12.6999999999999993 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 0 +LTYPE + 5 +38 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DASHDOT2 + 70 +0 + 3 +Dash dot (.5x) _._._._._._._._._._._._._._._. + 72 +65 + 73 +4 + 40 +12.6999999999999993 + 49 +6.3499999999999996 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 0 +LTYPE + 5 +39 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DASHDOTX2 + 70 +0 + 3 +Dash dot (2x) ____ . ____ . ____ . ___ + 72 +65 + 73 +4 + 40 +50.7999999999999972 + 49 +25.3999999999999986 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 0 +LTYPE + 5 +3A +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DIVIDE + 70 +0 + 3 +Divide ____ . . ____ . . ____ . . ____ . . ____ + 72 +65 + 73 +6 + 40 +31.75 + 49 +12.6999999999999993 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 0 +LTYPE + 5 +3B +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DIVIDE2 + 70 +0 + 3 +Divide (.5x) __..__..__..__..__..__..__..__.._ + 72 +65 + 73 +6 + 40 +15.875 + 49 +6.3499999999999996 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 0 +LTYPE + 5 +3C +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +DIVIDEX2 + 70 +0 + 3 +Divide (2x) ________ . . ________ . . _ + 72 +65 + 73 +6 + 40 +63.5 + 49 +25.3999999999999986 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 0 +LTYPE + 5 +3D +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +CENTER + 70 +0 + 3 +Center ____ _ ____ _ ____ _ ____ _ ____ _ ____ + 72 +65 + 73 +4 + 40 +50.7999999999999972 + 49 +31.75 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 49 +6.3499999999999996 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 0 +LTYPE + 5 +3E +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +CENTER2 + 70 +0 + 3 +Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___ + 72 +65 + 73 +4 + 40 +28.5749999999999993 + 49 +19.0500000000000007 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 49 +3.1749999999999998 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 0 +LTYPE + 5 +3F +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +CENTERX2 + 70 +0 + 3 +Center (2x) ________ __ ________ __ _____ + 72 +65 + 73 +4 + 40 +101.5999999999999943 + 49 +63.5 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 49 +12.6999999999999993 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 0 +LTYPE + 5 +40 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +BORDER + 70 +0 + 3 +Border __ __ . __ __ . __ __ . __ __ . __ __ . + 72 +65 + 73 +6 + 40 +44.4500000000000028 + 49 +12.6999999999999993 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 49 +12.6999999999999993 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-6.3499999999999996 + 74 +0 + 0 +LTYPE + 5 +41 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +BORDER2 + 70 +0 + 3 +Border (.5x) __.__.__.__.__.__.__.__.__.__.__. + 72 +65 + 73 +6 + 40 +22.2250000000000014 + 49 +6.3499999999999996 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 49 +6.3499999999999996 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-3.1749999999999998 + 74 +0 + 0 +LTYPE + 5 +42 +100 +AcDbSymbolTableRecord +100 +AcDbLinetypeTableRecord + 2 +BORDERX2 + 70 +0 + 3 +Border (2x) ____ ____ . ____ ____ . ___ + 72 +65 + 73 +6 + 40 +88.9000000000000057 + 49 +25.3999999999999986 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 49 +25.3999999999999986 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 49 +0.0 + 74 +0 + 49 +-12.6999999999999993 + 74 +0 + 0 +ENDTAB + 0 +TABLE + 2 +LAYER + 5 +2 +100 +AcDbSymbolTable + 70 +4 + 0 +LAYER + 5 +10 +100 +AcDbSymbolTableRecord +100 +AcDbLayerTableRecord + 2 +0 + 70 +0 + 62 +7 + 6 +CONTINUOUS +370 +0 +390 +F + 0 +LAYER + 5 +43 +100 +AcDbSymbolTableRecord +100 +AcDbLayerTableRecord + 2 +cutout1 + 70 +0 + 62 +6 + 6 +CONTINUOUS +370 +0 +390 +F + 0 +LAYER + 5 +44 +100 +AcDbSymbolTableRecord +100 +AcDbLayerTableRecord + 2 +cutout2 + 70 +0 + 62 +5 + 6 +CONTINUOUS +370 +0 +390 +F + 0 +LAYER + 5 +45 +100 +AcDbSymbolTableRecord +100 +AcDbLayerTableRecord + 2 +dorn + 70 +0 + 62 +3 + 6 +CONTINUOUS +370 +0 +390 +F + 0 +ENDTAB + 0 +TABLE + 2 +STYLE + 5 +3 +100 +AcDbSymbolTable + 70 +1 + 0 +STYLE + 5 +11 +100 +AcDbSymbolTableRecord +100 +AcDbTextStyleTableRecord + 2 +Standard + 70 +0 + 40 +0.0 + 41 +0.75 + 50 +0.0 + 71 +0 + 42 +2.5 + 3 +txt + 4 + + 0 +ENDTAB + 0 +TABLE + 2 +VIEW + 5 +6 +100 +AcDbSymbolTable + 70 +0 + 0 +ENDTAB + 0 +TABLE + 2 +UCS + 5 +7 +100 +AcDbSymbolTable + 70 +0 + 0 +ENDTAB + 0 +TABLE + 2 +APPID + 5 +9 +100 +AcDbSymbolTable + 70 +1 + 0 +APPID + 5 +12 +100 +AcDbSymbolTableRecord +100 +AcDbRegAppTableRecord + 2 +ACAD + 70 +0 + 0 +ENDTAB + 0 +TABLE + 2 +DIMSTYLE + 5 +A +100 +AcDbSymbolTable + 70 +1 +100 +AcDbDimStyleTable + 71 +0 + 0 +DIMSTYLE +105 +27 +100 +AcDbSymbolTableRecord +100 +AcDbDimStyleTableRecord + 2 +Standard + 41 +2.5 + 42 +0.625 + 43 +3.75 + 44 +1.25 + 70 +0 + 73 +0 + 74 +0 + 77 +1 + 78 +8 +140 +2.5 +141 +2.5 +143 +0.03937007874016 +147 +0.625 +171 +3 +172 +1 +271 +2 +272 +2 +274 +3 +278 +44 +283 +0 +284 +8 +340 +11 + 0 +ENDTAB + 0 +TABLE + 2 +BLOCK_RECORD + 5 +1 +100 +AcDbSymbolTable + 70 +1 + 0 +BLOCK_RECORD + 5 +1F +100 +AcDbSymbolTableRecord +100 +AcDbBlockTableRecord + 2 +*Model_Space +340 +22 + 0 +BLOCK_RECORD + 5 +1B +100 +AcDbSymbolTableRecord +100 +AcDbBlockTableRecord + 2 +*Paper_Space +340 +1E + 0 +BLOCK_RECORD + 5 +23 +100 +AcDbSymbolTableRecord +100 +AcDbBlockTableRecord + 2 +*Paper_Space0 +340 +26 + 0 +ENDTAB + 0 +ENDSEC + 0 +SECTION + 2 +BLOCKS + 0 +BLOCK + 5 +20 +100 +AcDbEntity + 8 +0 +100 +AcDbBlockBegin + 2 +*Model_Space + 70 +0 + 10 +0.0 + 20 +0.0 + 30 +0.0 + 3 +*Model_Space + 1 + + 0 +ENDBLK + 5 +21 +100 +AcDbEntity + 8 +0 +100 +AcDbBlockEnd + 0 +BLOCK + 5 +1C +100 +AcDbEntity + 67 +1 + 8 +0 +100 +AcDbBlockBegin + 2 +*Paper_Space + 70 +0 + 10 +0.0 + 20 +0.0 + 30 +0.0 + 3 +*Paper_Space + 1 + + 0 +ENDBLK + 5 +1D +100 +AcDbEntity + 67 +1 + 8 +0 +100 +AcDbBlockEnd + 0 +BLOCK + 5 +24 +100 +AcDbEntity + 8 +0 +100 +AcDbBlockBegin + 2 +*Paper_Space0 + 70 +0 + 10 +0.0 + 20 +0.0 + 30 +0.0 + 3 +*Paper_Space0 + 1 + + 0 +ENDBLK + 5 +25 +100 +AcDbEntity + 8 +0 +100 +AcDbBlockEnd + 0 +ENDSEC + 0 +SECTION + 2 +ENTITIES + 0 +LINE + 5 +46 +100 +AcDbEntity +100 +AcDbLine + 8 +cutout1 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +2.0 + 20 +31.0 + 30 +0.0 + 11 +-2.0 + 21 +31.0 + 31 +0.0 + 0 +LINE + 5 +47 +100 +AcDbEntity +100 +AcDbLine + 8 +cutout1 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +-2.0 + 20 +31.0 + 30 +0.0 + 11 +-2.0 + 21 +3.0 + 31 +0.0 + 0 +LINE + 5 +48 +100 +AcDbEntity +100 +AcDbLine + 8 +cutout1 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +-2.0 + 20 +3.0 + 30 +0.0 + 11 +2.0 + 21 +3.0 + 31 +0.0 + 0 +LINE + 5 +49 +100 +AcDbEntity +100 +AcDbLine + 8 +cutout1 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +2.0 + 20 +3.0 + 30 +0.0 + 11 +2.0 + 21 +31.0 + 31 +0.0 + 0 +LINE + 5 +4A +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +11.0 + 20 +31.0 + 30 +0.0 + 11 +11.0 + 21 +15.0 + 31 +0.0 + 0 +LINE + 5 +4B +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +-11.0 + 20 +31.0 + 30 +0.0 + 11 +11.0 + 21 +31.0 + 31 +0.0 + 0 +LINE + 5 +4C +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +11.0 + 20 +15.0 + 30 +0.0 + 11 +6.0 + 21 +12.0 + 31 +0.0 + 0 +LINE + 5 +4D +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +6.0 + 20 +12.0 + 30 +0.0 + 11 +6.0 + 21 +3.0 + 31 +0.0 + 0 +LINE + 5 +4E +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +6.0 + 20 +3.0 + 30 +0.0 + 11 +-6.0 + 21 +3.0 + 31 +0.0 + 0 +LINE + 5 +4F +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +-6.0 + 20 +3.0 + 30 +0.0 + 11 +-6.0 + 21 +12.0 + 31 +0.0 + 0 +LINE + 5 +50 +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +-6.0 + 20 +12.0 + 30 +0.0 + 11 +-11.0 + 21 +15.0 + 31 +0.0 + 0 +LINE + 5 +51 +100 +AcDbEntity +100 +AcDbLine + 8 +cutout2 + 62 +256 +370 +-1 + 6 +ByLayer + 10 +-11.0 + 20 +31.0 + 30 +0.0 + 11 +-11.0 + 21 +15.0 + 31 +0.0 + 0 +LINE + 5 +52 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +0.0 + 20 +30.0 + 30 +0.0 + 11 +8.0 + 21 +15.0 + 31 +0.0 + 0 +LINE + 5 +53 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +8.0 + 20 +15.0 + 30 +0.0 + 11 +5.0 + 21 +12.0 + 31 +0.0 + 0 +LINE + 5 +54 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +5.0 + 20 +12.0 + 30 +0.0 + 11 +5.0 + 21 +2.0 + 31 +0.0 + 0 +LINE + 5 +55 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +5.0 + 20 +2.0 + 30 +0.0 + 11 +7.0 + 21 +2.0 + 31 +0.0 + 0 +LINE + 5 +56 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +7.0 + 20 +2.0 + 30 +0.0 + 11 +7.0 + 21 +11.0 + 31 +0.0 + 0 +LINE + 5 +57 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +7.0 + 20 +11.0 + 30 +0.0 + 11 +11.0 + 21 +11.0 + 31 +0.0 + 0 +LINE + 5 +58 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +11.0 + 20 +11.0 + 30 +0.0 + 11 +11.0 + 21 +0.0 + 31 +0.0 + 0 +LINE + 5 +59 +100 +AcDbEntity +100 +AcDbLine + 8 +dorn + 62 +256 +370 +-1 + 6 +ByLayer + 10 +11.0 + 20 +0.0 + 30 +0.0 + 11 +0.0 + 21 +0.0 + 31 +0.0 + 0 +ENDSEC + 0 +SECTION + 2 +OBJECTS + 0 +DICTIONARY + 5 +C +100 +AcDbDictionary +280 +0 +281 +1 + 3 +ACAD_GROUP +350 +D + 3 +ACAD_LAYOUT +350 +1A + 3 +ACAD_MLINESTYLE +350 +17 + 3 +ACAD_PLOTSETTINGS +350 +19 + 3 +ACAD_PLOTSTYLENAME +350 +E + 3 +AcDbVariableDictionary +350 +5A + 0 +DICTIONARY + 5 +D +100 +AcDbDictionary +280 +0 +281 +1 + 0 +ACDBDICTIONARYWDFLT + 5 +E +100 +AcDbDictionary +281 +1 + 3 +Normal +350 +F +100 +AcDbDictionaryWithDefault +340 +F + 0 +ACDBPLACEHOLDER + 5 +F + 0 +DICTIONARY + 5 +17 +100 +AcDbDictionary +280 +0 +281 +1 + 3 +Standard +350 +18 + 0 +MLINESTYLE + 5 +18 +100 +AcDbMlineStyle + 2 +STANDARD + 70 +0 + 3 + + 62 +256 + 51 +90.0 + 52 +90.0 + 71 +2 + 49 +0.5 + 62 +256 + 6 +BYLAYER + 49 +-0.5 + 62 +256 + 6 +BYLAYER + 0 +DICTIONARY + 5 +19 +100 +AcDbDictionary +280 +0 +281 +1 + 0 +DICTIONARY + 5 +1A +100 +AcDbDictionary +281 +1 + 3 +Layout1 +350 +1E + 3 +Layout2 +350 +26 + 3 +Model +350 +22 + 0 +LAYOUT + 5 +1E +100 +AcDbPlotSettings + 1 + + 2 +C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3 + 4 + + 6 + + 40 +0.0 + 41 +0.0 + 42 +0.0 + 43 +0.0 + 44 +0.0 + 45 +0.0 + 46 +0.0 + 47 +0.0 + 48 +0.0 + 49 +0.0 +140 +0.0 +141 +0.0 +142 +1.0 +143 +1.0 + 70 +688 + 72 +0 + 73 +0 + 74 +5 + 7 + + 75 +16 +147 +1.0 +148 +0.0 +149 +0.0 +100 +AcDbLayout + 1 +Layout1 + 70 +1 + 71 +1 + 10 +0.0 + 20 +0.0 + 11 +420.0 + 21 +297.0 + 12 +0.0 + 22 +0.0 + 32 +0.0 + 14 +100000000000000000000.0 + 24 +100000000000000000000.0 + 34 +100000000000000000000.0 + 15 +-100000000000000000000.0 + 25 +-100000000000000000000.0 + 35 +-100000000000000000000.0 +146 +0.0 + 13 +0.0 + 23 +0.0 + 33 +0.0 + 16 +1.0 + 26 +0.0 + 36 +0.0 + 17 +0.0 + 27 +1.0 + 37 +0.0 + 76 +0 +330 +1B + 0 +LAYOUT + 5 +22 +100 +AcDbPlotSettings + 1 + + 2 +C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3 + 4 + + 6 + + 40 +0.0 + 41 +0.0 + 42 +0.0 + 43 +0.0 + 44 +0.0 + 45 +0.0 + 46 +0.0 + 47 +0.0 + 48 +0.0 + 49 +0.0 +140 +0.0 +141 +0.0 +142 +1.0 +143 +1.0 + 70 +1712 + 72 +0 + 73 +0 + 74 +0 + 7 + + 75 +0 +147 +1.0 +148 +0.0 +149 +0.0 +100 +AcDbLayout + 1 +Model + 70 +1 + 71 +0 + 10 +0.0 + 20 +0.0 + 11 +12.0 + 21 +9.0 + 12 +0.0 + 22 +0.0 + 32 +0.0 + 14 +0.0 + 24 +0.0 + 34 +0.0 + 15 +0.0 + 25 +0.0 + 35 +0.0 +146 +0.0 + 13 +0.0 + 23 +0.0 + 33 +0.0 + 16 +1.0 + 26 +0.0 + 36 +0.0 + 17 +0.0 + 27 +1.0 + 37 +0.0 + 76 +0 +330 +1F + 0 +LAYOUT + 5 +26 +100 +AcDbPlotSettings + 1 + + 2 +C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3 + 4 + + 6 + + 40 +0.0 + 41 +0.0 + 42 +0.0 + 43 +0.0 + 44 +0.0 + 45 +0.0 + 46 +0.0 + 47 +0.0 + 48 +0.0 + 49 +0.0 +140 +0.0 +141 +0.0 +142 +1.0 +143 +1.0 + 70 +688 + 72 +0 + 73 +0 + 74 +5 + 7 + + 75 +16 +147 +1.0 +148 +0.0 +149 +0.0 +100 +AcDbLayout + 1 +Layout2 + 70 +1 + 71 +2 + 10 +0.0 + 20 +0.0 + 11 +12.0 + 21 +9.0 + 12 +0.0 + 22 +0.0 + 32 +0.0 + 14 +0.0 + 24 +0.0 + 34 +0.0 + 15 +0.0 + 25 +0.0 + 35 +0.0 +146 +0.0 + 13 +0.0 + 23 +0.0 + 33 +0.0 + 16 +1.0 + 26 +0.0 + 36 +0.0 + 17 +0.0 + 27 +1.0 + 37 +0.0 + 76 +0 +330 +23 + 0 +DICTIONARY + 5 +5A +100 +AcDbDictionary +281 +1 + 3 +DIMASSOC +350 +5C + 3 +HIDETEXT +350 +5B + 0 +DICTIONARYVAR + 5 +5B +100 +DictionaryVariables +280 +0 + 1 +2 + 0 +DICTIONARYVAR + 5 +5C +100 +DictionaryVariables +280 +0 + 1 +1 + 0 +ENDSEC + 0 +EOF diff --git a/examples/example007.scad b/examples/example007.scad new file mode 100644 index 00000000..e6cd219d --- /dev/null +++ b/examples/example007.scad @@ -0,0 +1,33 @@ + +module cutout() +{ + intersection() + { + rotate(90, [1 0 0]) + translate([0 0 -50]) + dxf_linear_extrude( + file = "example007.dxf", + layer = "cutout1", + height = 100, + convexity = 1); + + rotate(90, [0 0 1]) + rotate(90, [1 0 0]) + translate([0 0 -50]) + dxf_linear_extrude( + file = "example007.dxf", + layer = "cutout2", + height = 100, + convexity = 2); + } +} + +difference() { + dxf_rotate_extrude( + file = "example007.dxf", + layer="dorn", + convexity = 3); + for (r = [0 90]) + rotate(r, [0 0 1]) + cutout(); +} diff --git a/module.cc b/module.cc index f64b21fc..ea59a08d 100644 --- a/module.cc +++ b/module.cc @@ -192,6 +192,7 @@ void initialize_builtin_modules() register_builtin_control(); register_builtin_render(); register_builtin_dxf_linear_extrude(); + register_builtin_dxf_rotate_extrude(); } void destroy_builtin_modules() diff --git a/openscad.h b/openscad.h index f9061472..191df31c 100644 --- a/openscad.h +++ b/openscad.h @@ -265,6 +265,7 @@ extern void register_builtin_primitives(); extern void register_builtin_control(); extern void register_builtin_render(); extern void register_builtin_dxf_linear_extrude(); +extern void register_builtin_dxf_rotate_extrude(); class Context { @@ -593,6 +594,7 @@ private slots: }; extern AbstractModule *parse(const char *text, int debug); +extern int get_fragments_from_r(double r, double fn, double fs, double fa); extern QPointer current_win; diff --git a/openscad.pro b/openscad.pro index 3d24bd86..1d9df651 100644 --- a/openscad.pro +++ b/openscad.pro @@ -16,11 +16,10 @@ SOURCES += openscad.cc mainwin.cc glview.cc SOURCES += value.cc expr.cc func.cc module.cc context.cc SOURCES += csgterm.cc polyset.cc csgops.cc transform.cc SOURCES += primitives.cc control.cc render.cc -SOURCES += dxfdata.cc dxflinextrude.cc +SOURCES += dxfdata.cc dxflinextrude.cc dxfrotextrude.cc QMAKE_CXXFLAGS += -O0 // QMAKE_CXXFLAGS += -O3 -march=pentium -// QMAKE_CXXFLAGS += -O3 -march=athlon64 QT += opengl