|
5 | 5 | DwgCodePage, |
6 | 6 | dwgCodePageToEncoding, |
7 | 7 | DwgDatabase, |
| 8 | + DwgGradientColor, |
8 | 9 | DwgPoint2D, |
9 | 10 | DwgPoint3D, |
10 | 11 | DwgPoint4D, |
@@ -89,25 +90,25 @@ export class LibreDwg { |
89 | 90 | }) |
90 | 91 | } |
91 | 92 |
|
92 | | - dwg_read_data(fileContent: string | ArrayBuffer, fileType: number) { |
93 | | - if (fileType == Dwg_File_Type.DWG) { |
94 | | - const fileName = 'tmp.dwg' |
95 | | - try { |
96 | | - this.wasmInstance.FS.writeFile( |
97 | | - fileName, |
98 | | - new Uint8Array(fileContent as ArrayBuffer) |
99 | | - ) |
100 | | - const result = this.wasmInstance.dwg_read_file(fileName) |
101 | | - if (result.error != 0) { |
102 | | - console.log('Open dwg file with error code: ', result.error) |
103 | | - } |
104 | | - return result.data as Dwg_Data_Ptr |
105 | | - } finally { |
106 | | - if (this.wasmInstance.FS.analyzePath(fileName, false).exists) { |
107 | | - this.wasmInstance.FS.unlink(fileName) |
108 | | - } |
109 | | - } |
110 | | - } |
| 93 | + dwg_read_data(fileContent: string | ArrayBuffer, fileType: number) { |
| 94 | + if (fileType == Dwg_File_Type.DWG) { |
| 95 | + const fileName = 'tmp.dwg' |
| 96 | + try { |
| 97 | + this.wasmInstance.FS.writeFile( |
| 98 | + fileName, |
| 99 | + new Uint8Array(fileContent as ArrayBuffer) |
| 100 | + ) |
| 101 | + const result = this.wasmInstance.dwg_read_file(fileName) |
| 102 | + if (result.error != 0) { |
| 103 | + console.log('Open dwg file with error code: ', result.error) |
| 104 | + } |
| 105 | + return result.data as Dwg_Data_Ptr |
| 106 | + } finally { |
| 107 | + if (this.wasmInstance.FS.analyzePath(fileName, false).exists) { |
| 108 | + this.wasmInstance.FS.unlink(fileName) |
| 109 | + } |
| 110 | + } |
| 111 | + } |
111 | 112 | // else if (fileType == Dwg_File_Type.DXF) { |
112 | 113 | // const fileName = "tmp.dxf"; |
113 | 114 | // this.wasmInstance.FS.writeFile(fileName, new Uint8Array(fileContent as ArrayBuffer)); |
@@ -144,12 +145,12 @@ export class LibreDwg { |
144 | 145 | } |
145 | 146 | return this.wasmInstance.FS.readFile(outputFileName) as Uint8Array |
146 | 147 | } finally { |
147 | | - if (this.wasmInstance.FS.analyzePath(inputFileName, false).exists) { |
148 | | - this.wasmInstance.FS.unlink(inputFileName) |
149 | | - } |
150 | | - if (this.wasmInstance.FS.analyzePath(outputFileName, false).exists) { |
151 | | - this.wasmInstance.FS.unlink(outputFileName) |
152 | | - } |
| 148 | + if (this.wasmInstance.FS.analyzePath(inputFileName, false).exists) { |
| 149 | + this.wasmInstance.FS.unlink(inputFileName) |
| 150 | + } |
| 151 | + if (this.wasmInstance.FS.analyzePath(outputFileName, false).exists) { |
| 152 | + this.wasmInstance.FS.unlink(outputFileName) |
| 153 | + } |
153 | 154 | } |
154 | 155 | } |
155 | 156 |
|
@@ -896,6 +897,21 @@ export class LibreDwg { |
896 | 897 | return this.wasmInstance.dwg_ptr_to_hatch_path_array(ptr, size) |
897 | 898 | } |
898 | 899 |
|
| 900 | + /** |
| 901 | + * Converts one C++ hatch gradient color array to one JavaScript hatch gradient color array. |
| 902 | + * @group Array Methods |
| 903 | + * @group Dwg_Entity_HATCH Methods |
| 904 | + * @param ptr Pointer to C++ hatch gradient color array. |
| 905 | + * @param size The size of C++ hatch gradient color array. |
| 906 | + * @returns Returns one JavaScript hatch gradient color array from the specified C++ hatch gradient color array. |
| 907 | + */ |
| 908 | + dwg_ptr_to_hatch_gradient_color_array( |
| 909 | + ptr: Dwg_Array_Ptr, |
| 910 | + size: number |
| 911 | + ): DwgGradientColor[] { |
| 912 | + return this.wasmInstance.dwg_ptr_to_hatch_gradient_color_array(ptr, size) |
| 913 | + } |
| 914 | + |
899 | 915 | /** |
900 | 916 | * Converts one C++ mline vertex array to one JavaScript mline vertex array. |
901 | 917 | * @group Array Methods |
|
0 commit comments