@mlightcad/libredwg-web 0.7.12 → 0.7.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1997,13 +1997,21 @@ class LibreEntityConverter {
1997
1997
  const num_bulges = libredwg.dwg_dynapi_entity_data(entity, "num_bulges");
1998
1998
  const bulges_ptr = libredwg.dwg_dynapi_entity_data(entity, "bulges");
1999
1999
  const bulges = libredwg.dwg_ptr_to_double_array(bulges_ptr, num_bulges);
2000
+ const num_widths = libredwg.dwg_dynapi_entity_data(entity, "num_widths") ?? 0;
2001
+ const widths_ptr = libredwg.dwg_dynapi_entity_data(entity, "widths");
2002
+ const widthDoubles = num_widths > 0 && widths_ptr ? libredwg.dwg_ptr_to_double_array(widths_ptr, num_widths * 2) : [];
2000
2003
  points.forEach((point, index) => {
2001
- vertices.push({
2004
+ const vertex = {
2002
2005
  id: index,
2003
2006
  x: point.x,
2004
2007
  y: point.y,
2005
2008
  bulge: bulges.length > index ? bulges[index] : 0
2006
- });
2009
+ };
2010
+ if (index < num_widths && widthDoubles.length >= (index + 1) * 2) {
2011
+ vertex.startWidth = widthDoubles[index * 2];
2012
+ vertex.endWidth = widthDoubles[index * 2 + 1];
2013
+ }
2014
+ vertices.push(vertex);
2007
2015
  });
2008
2016
  return {
2009
2017
  type: "LWPOLYLINE",
@@ -1999,13 +1999,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1999
1999
  const num_bulges = libredwg.dwg_dynapi_entity_data(entity, "num_bulges");
2000
2000
  const bulges_ptr = libredwg.dwg_dynapi_entity_data(entity, "bulges");
2001
2001
  const bulges = libredwg.dwg_ptr_to_double_array(bulges_ptr, num_bulges);
2002
+ const num_widths = libredwg.dwg_dynapi_entity_data(entity, "num_widths") ?? 0;
2003
+ const widths_ptr = libredwg.dwg_dynapi_entity_data(entity, "widths");
2004
+ const widthDoubles = num_widths > 0 && widths_ptr ? libredwg.dwg_ptr_to_double_array(widths_ptr, num_widths * 2) : [];
2002
2005
  points.forEach((point, index) => {
2003
- vertices.push({
2006
+ const vertex = {
2004
2007
  id: index,
2005
2008
  x: point.x,
2006
2009
  y: point.y,
2007
2010
  bulge: bulges.length > index ? bulges[index] : 0
2008
- });
2011
+ };
2012
+ if (index < num_widths && widthDoubles.length >= (index + 1) * 2) {
2013
+ vertex.startWidth = widthDoubles[index * 2];
2014
+ vertex.endWidth = widthDoubles[index * 2 + 1];
2015
+ }
2016
+ vertices.push(vertex);
2009
2017
  });
2010
2018
  return {
2011
2019
  type: "LWPOLYLINE",
@@ -835,13 +835,26 @@ export class LibreEntityConverter {
835
835
  const num_bulges = libredwg.dwg_dynapi_entity_data(entity, 'num_bulges');
836
836
  const bulges_ptr = libredwg.dwg_dynapi_entity_data(entity, 'bulges');
837
837
  const bulges = libredwg.dwg_ptr_to_double_array(bulges_ptr, num_bulges);
838
+ // Flag bit 32 = HAS_NUM_WIDTHS. Each Dwg_LWPOLYLINE_width is two BITCODE_BD
839
+ // values (start, end). Without copying these, tapered polylines (e.g. valve
840
+ // triangles) become zero-width lines after conversion.
841
+ const num_widths = libredwg.dwg_dynapi_entity_data(entity, 'num_widths') ?? 0;
842
+ const widths_ptr = libredwg.dwg_dynapi_entity_data(entity, 'widths');
843
+ const widthDoubles = num_widths > 0 && widths_ptr
844
+ ? libredwg.dwg_ptr_to_double_array(widths_ptr, num_widths * 2)
845
+ : [];
838
846
  points.forEach((point, index) => {
839
- vertices.push({
847
+ const vertex = {
840
848
  id: index,
841
849
  x: point.x,
842
850
  y: point.y,
843
851
  bulge: bulges.length > index ? bulges[index] : 0
844
- });
852
+ };
853
+ if (index < num_widths && widthDoubles.length >= (index + 1) * 2) {
854
+ vertex.startWidth = widthDoubles[index * 2];
855
+ vertex.endWidth = widthDoubles[index * 2 + 1];
856
+ }
857
+ vertices.push(vertex);
845
858
  });
846
859
  return {
847
860
  type: 'LWPOLYLINE',
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A DWG/DXF JavaScript parser based on libredwg",
4
4
  "license": "GPL-3.0",
5
5
  "private": false,
6
- "version": "0.7.12",
6
+ "version": "0.7.13",
7
7
  "author": "MLight Lee <mlight.lee@outlook.com>",
8
8
  "type": "module",
9
9
  "engines": {