From 643e58f856a8c9cfab1db107d01de84d1fc7ecc6 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 24 Nov 2018 00:53:23 +0100 Subject: [PATCH] Merged PR #199 into pymod branch --- src/buddies/src/bd/bdWriterOptions.cc | 3 +- .../streamers/dxf/db_plugin/dbDXFFormat.h | 1 + .../streamers/dxf/db_plugin/dbDXFWriter.cc | 29 +++++++++++++++++++ .../streamers/dxf/db_plugin/gsiDeclDbDXF.cc | 8 ++--- .../dxf/lay_plugin/DXFWriterOptionPage.ui | 5 ++++ 5 files changed, 41 insertions(+), 5 deletions(-) mode change 100644 => 100755 src/plugins/streamers/dxf/db_plugin/gsiDeclDbDXF.cc diff --git a/src/buddies/src/bd/bdWriterOptions.cc b/src/buddies/src/bd/bdWriterOptions.cc index e7ecfd08c..2176416b4 100644 --- a/src/buddies/src/bd/bdWriterOptions.cc +++ b/src/buddies/src/bd/bdWriterOptions.cc @@ -242,7 +242,8 @@ GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::strin "* 0: create POLYLINE (default)\n" "* 1: create LWPOLYLINE\n" "* 2: decompose into SOLID\n" - "* 3: create HATCH" + "* 3: create HATCH\n" + "* 4: create LINE" ) ; diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h b/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h index 35a6173d0..fd23120ff 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFFormat.h @@ -213,6 +213,7 @@ public: * 1: create LWPOLYLINE * 2: decompose into SOLID * 3: create HATCH + * 4: create LINE: refer to 'void DXFWriter::write_polygon()' definition */ int polygon_mode; diff --git a/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.cc b/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.cc index 084fbaadf..8ba1df8f8 100644 --- a/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.cc +++ b/src/plugins/streamers/dxf/db_plugin/dbDXFWriter.cc @@ -507,7 +507,36 @@ DXFWriter::write_polygon (const db::Polygon &polygon, double sf) } } + } else if (m_options.polygon_mode == 4) { + //-------------------------------------------------------------------------------------- + // Last modified by: Kazzz-S on October 21, 2018 (newly added) + // + // Description: When importing a DXF file comprising POLYLINEs or LWPOLYLINEs into + // Abaqus CAE, they are forcibly converted to points! + // *** This is a "specification" of Abaqus CAE. *** + // In contrast, LINEs are kept as lines, which will be then assembled into + // polygonal objects internally if required. + //-------------------------------------------------------------------------------------- + for (unsigned int c = 0; c < polygon.holes () + 1; ++c) { + + for (db::Polygon::polygon_contour_iterator p = polygon.contour (c).begin (); p != polygon.contour (c).end (); ++p) { + db::Polygon::polygon_contour_iterator q = p + 1; + + if (q == polygon.contour (c).end ()) { + q = polygon.contour (c).begin (); + } + + *this << 0 << endl << "LINE" << endl; + *this << 8 << endl; emit_layer (m_layer); + *this << 66 << endl << 1 << endl; // required by TrueView + *this << 10 << endl << (*p).x () * sf << endl; + *this << 20 << endl << (*p).y () * sf << endl; + *this << 11 << endl << (*q).x () * sf << endl; + *this << 21 << endl << (*q).y () * sf << endl; + } + } } + } void diff --git a/src/plugins/streamers/dxf/db_plugin/gsiDeclDbDXF.cc b/src/plugins/streamers/dxf/db_plugin/gsiDeclDbDXF.cc old mode 100644 new mode 100755 index 4a6a9f774..5605ae011 --- a/src/plugins/streamers/dxf/db_plugin/gsiDeclDbDXF.cc +++ b/src/plugins/streamers/dxf/db_plugin/gsiDeclDbDXF.cc @@ -361,7 +361,7 @@ gsi::ClassExt dxf_reader_options ( static void set_dxf_polygon_mode (db::SaveLayoutOptions *options, int mode) { - if (mode < 0 || mode > 3) { + if (mode < 0 || mode > 4) { throw tl::Exception (tl::to_string (tr ("Invalid polygon mode"))); } @@ -379,9 +379,9 @@ gsi::ClassExt dxf_writer_options ( gsi::method_ext ("dxf_polygon_mode=", &set_dxf_polygon_mode, "@brief Specifies how to write polygons.\n" "@args mode\n" - "The mode is 0 (write POLYLINE entities), 1 (write LWPOLYLINE entities), 2 (decompose into SOLID entities) or " - "or 3 (write HATCH entities).\n" - "\nThis property has been added in version 0.21.3.\n" + "The mode is 0 (write POLYLINE entities), 1 (write LWPOLYLINE entities), 2 (decompose into SOLID entities), " + "3 (write HATCH entities), or 4 (write LINE entities).\n" + "\nThis property has been added in version 0.21.3. '4', in version 0.25.6.\n" ) + gsi::method_ext ("dxf_polygon_mode", &get_dxf_polygon_mode, "@brief Specifies how to write polygons.\n" diff --git a/src/plugins/streamers/dxf/lay_plugin/DXFWriterOptionPage.ui b/src/plugins/streamers/dxf/lay_plugin/DXFWriterOptionPage.ui index 35ed52f0a..b3a1f217e 100644 --- a/src/plugins/streamers/dxf/lay_plugin/DXFWriterOptionPage.ui +++ b/src/plugins/streamers/dxf/lay_plugin/DXFWriterOptionPage.ui @@ -73,6 +73,11 @@ Write HATCH entity + + + Write LINE entity + +