1 /*****************************************************************************/
2 /*  LibreDWG - free implementation of the DWG file format                    */
3 /*                                                                           */
4 /*  Copyright (C) 2013,2018-2021 Free Software Foundation, Inc.              */
5 /*                                                                           */
6 /*  This library is free software, licensed under the terms of the GNU       */
7 /*  General Public License as published by the Free Software Foundation,     */
8 /*  either version 3 of the License, or (at your option) any later version.  */
9 /*  You should have received a copy of the GNU General Public License        */
10 /*  along with this program.  If not, see <http://www.gnu.org/licenses/>.    */
11 /*****************************************************************************/
12 
13 /*
14  * dwg_api.c: external C API
15  *
16  * written by Gaganjyot Singh
17  * modified by Reini Urban
18  */
19 
20 #include "config.h"
21 #ifdef HAVE_SINCOS
22 #  define _GNU_SOURCE
23 #endif
24 #include <stdlib.h>
25 #include <stdint.h>
26 #include <inttypes.h>
27 #include <math.h>
28 #include <time.h>
29 #include <assert.h>
30 
31 #ifdef HAVE_MALLOC_H
32 #  include <malloc.h>
33 #endif
34 #include "dwg.h"
35 #include "common.h"
36 #define DWG_LOGLEVEL loglevel
37 #include "logging.h"
38 #include "bits.h"
39 #include "dwg_api.h"
40 #include "classes.h"
41 
42 /** We don't pass in Dwg_Object*'s, so we don't know if the object
43  *  is >= r2007 or <r13 or what. Default is r2000.
44  *  So we need some dwg_api_init_version(&dwg) to store the version.
45  *  This is not thread-safe, don't use different DWG versions in parallel
46  * threads!
47  */
48 static Dwg_Version_Type dwg_version = R_INVALID;
49 static unsigned int loglevel = DWG_LOGLEVEL_ERROR;
50 static unsigned nodeid = 0;
51 
52 /* Non-public imports */
53 /* I don't want to export these. */
54 BITCODE_H dwg_find_tablehandle_silent (Dwg_Data *restrict dwg, const char *restrict name,
55                                        const char *restrict table);
56 void dwg_resolve_objectrefs_silent (Dwg_Data *restrict dwg);
57 Dwg_Class *dwg_encode_get_class (Dwg_Data *restrict dwg, Dwg_Object *restrict obj);
58 /* Initialization hack only */
59 void dwg_set_next_hdl (Dwg_Data *dwg, unsigned long value);
60 void dwg_set_next_objhandle (Dwg_Object *obj);
61 // from dxfclasses */
62 int dwg_dxfclass_require (Dwg_Data *restrict dwg, const char *restrict dxfname);
63 
64 /**
65  * Return an object fieldvalue
66  */
67 #ifndef HAVE_NONNULL
68 #  define dwg_get_OBJECT(name, OBJECT)                                        \
69     EXPORT bool dwg_get_##OBJECT (const dwg_##name *restrict name,            \
70                                   const char *restrict fieldname,             \
71                                   void *restrict out)                         \
72     {                                                                         \
73       if (name && fieldname && out)                                           \
74         return dwg_dynapi_entity_value ((void *)name, #OBJECT, fieldname,     \
75                                         out, NULL);                           \
76       else                                                                    \
77         return false;                                                         \
78     }                                                                         \
79     EXPORT bool dwg_set_##OBJECT (const dwg_##name *restrict name,            \
80                                   const char *restrict fieldname,             \
81                                   void *restrict value)                       \
82     {                                                                         \
83       if (name && fieldname && value)                                         \
84         return dwg_dynapi_entity_set_value ((void *)name, #OBJECT, fieldname, \
85                                             value, 1);                        \
86       else                                                                    \
87         return false;                                                         \
88     }
89 #else
90 #  define dwg_get_OBJECT(name, OBJECT)                                        \
91     EXPORT bool dwg_get_##OBJECT (const dwg_##name *restrict name,            \
92                                   const char *restrict fieldname,             \
93                                   void *restrict out)                         \
94     {                                                                         \
95       return dwg_dynapi_entity_value ((void *)name, #OBJECT, fieldname, out,  \
96                                       NULL);                                  \
97     }                                                                         \
98     EXPORT bool dwg_set_##OBJECT (const dwg_##name *restrict name,            \
99                                   const char *restrict fieldname,             \
100                                   void *restrict value)                       \
101     {                                                                         \
102       return dwg_dynapi_entity_set_value ((void *)name, #OBJECT, fieldname,   \
103                                           value, 0);                          \
104     }
105 #endif
106 
107 #ifndef __AFL_COMPILER
108 
109 // clang-format: off
dwg_get_OBJECT(ent_text,TEXT)110 dwg_get_OBJECT (ent_text, TEXT)
111 dwg_get_OBJECT (ent_attrib, ATTRIB)
112 dwg_get_OBJECT (ent_attdef, ATTDEF)
113 dwg_get_OBJECT (ent_block, BLOCK)
114 dwg_get_OBJECT (ent_endblk, ENDBLK)
115 dwg_get_OBJECT (ent_seqend, SEQEND)
116 dwg_get_OBJECT (ent_insert, INSERT)
117 dwg_get_OBJECT (ent_minsert, MINSERT)
118 dwg_get_OBJECT (ent_vertex_2d, VERTEX_2D)
119 dwg_get_OBJECT (ent_vertex_3d, VERTEX_3D)
120 dwg_get_OBJECT (ent_vertex_3d, VERTEX_MESH)
121 dwg_get_OBJECT (ent_vertex_3d, VERTEX_PFACE)
122 dwg_get_OBJECT (ent_vert_pface_face, VERTEX_PFACE_FACE)
123 dwg_get_OBJECT (ent_polyline_2d, POLYLINE_2D)
124 dwg_get_OBJECT (ent_polyline_3d, POLYLINE_3D)
125 dwg_get_OBJECT (ent_arc, ARC)
126 
127 #endif
128 
129 /* Most API functions are now auto-generated, but excluded
130    from afl-fuzz, because there would be too many.
131    These are the exceptions, needed in dwgwrite, ... */
132 
133 dwg_get_OBJECT (ent_circle, CIRCLE)
134 dwg_get_OBJECT (ent_line, LINE)
135 
136 #ifdef __AFL_COMPILER
137 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_2D)
138 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_3D)
139 #endif
140 
141 #ifndef __AFL_COMPILER
142 
143 dwg_get_OBJECT (ent_dim_ordinate, DIMENSION_ORDINATE)
144 dwg_get_OBJECT (ent_dim_linear, DIMENSION_LINEAR)
145 dwg_get_OBJECT (ent_dim_aligned, DIMENSION_ALIGNED)
146 dwg_get_OBJECT (ent_dim_ang3pt, DIMENSION_ANG3PT)
147 dwg_get_OBJECT (ent_dim_ang2ln, DIMENSION_ANG2LN)
148 dwg_get_OBJECT (ent_dim_radius, DIMENSION_RADIUS)
149 dwg_get_OBJECT (ent_dim_diameter, DIMENSION_DIAMETER)
150 dwg_get_OBJECT (ent_point, POINT)
151 dwg_get_OBJECT (ent_polyline_pface, POLYLINE_PFACE)
152 dwg_get_OBJECT (ent_polyline_mesh, POLYLINE_MESH)
153 dwg_get_OBJECT (ent_solid, SOLID)
154 dwg_get_OBJECT (ent_trace, TRACE)
155 dwg_get_OBJECT (ent_shape, SHAPE)
156 dwg_get_OBJECT (ent_viewport, VIEWPORT)
157 dwg_get_OBJECT (ent_ellipse, ELLIPSE)
158 dwg_get_OBJECT (ent_spline, SPLINE)
159 dwg_get_OBJECT (ent_3dsolid, 3DSOLID)
160 dwg_get_OBJECT (ent_region, REGION)
161 dwg_get_OBJECT (ent_body, BODY)
162 dwg_get_OBJECT (ent_ray, RAY)
163 dwg_get_OBJECT (ent_xline, XLINE)
164 dwg_get_OBJECT (ent_oleframe, OLEFRAME)
165 dwg_get_OBJECT (ent_mtext, MTEXT)
166 dwg_get_OBJECT (ent_leader, LEADER)
167 dwg_get_OBJECT (ent_tolerance, TOLERANCE)
168 dwg_get_OBJECT (ent_mline, MLINE)
169 dwg_get_OBJECT (ent_unknown, UNKNOWN_ENT)
170 
171 /* Start auto-generated content. Do not touch. */
172 /* untyped > 500 */
173 dwg_get_OBJECT (ent_camera, CAMERA)
174 dwg_get_OBJECT (ent_dgnunderlay, DGNUNDERLAY)
175 dwg_get_OBJECT (ent_dwfunderlay, DWFUNDERLAY)
176 dwg_get_OBJECT (ent_hatch, HATCH)
177 dwg_get_OBJECT (ent_image, IMAGE)
178 dwg_get_OBJECT (ent_light, LIGHT)
179 dwg_get_OBJECT (ent_lwpline, LWPOLYLINE)
180 dwg_get_OBJECT (ent_mesh, MESH)
181 dwg_get_OBJECT (ent_mleader, MULTILEADER)
182 dwg_get_OBJECT (ent_ole2frame, OLE2FRAME)
183 dwg_get_OBJECT (ent_pdfunderlay, PDFUNDERLAY)
184 dwg_get_OBJECT (ent_sectionobject, SECTIONOBJECT)
185 /* unstable */
186 dwg_get_OBJECT (ent_arc_dimension, ARC_DIMENSION)
187 dwg_get_OBJECT (ent_helix, HELIX)
188 dwg_get_OBJECT (ent_large_radial_dimension, LARGE_RADIAL_DIMENSION)
189 dwg_get_OBJECT (ent_planesurface, PLANESURFACE)
190 dwg_get_OBJECT (ent_pointcloud, POINTCLOUD)
191 dwg_get_OBJECT (ent_pointcloudex, POINTCLOUDEX)
192 dwg_get_OBJECT (ent_wipeout, WIPEOUT)
193 #ifdef DEBUG_CLASSES
194   dwg_get_OBJECT (ent_alignmentparameterentity, ALIGNMENTPARAMETERENTITY)
195   dwg_get_OBJECT (ent_arcalignedtext, ARCALIGNEDTEXT)
196   dwg_get_OBJECT (ent_basepointparameterentity, BASEPOINTPARAMETERENTITY)
197   dwg_get_OBJECT (ent_extrudedsurface, EXTRUDEDSURFACE)
198   dwg_get_OBJECT (ent_flipparameterentity, FLIPPARAMETERENTITY)
199   dwg_get_OBJECT (ent_geopositionmarker, GEOPOSITIONMARKER)
200   dwg_get_OBJECT (ent_linearparameterentity, LINEARPARAMETERENTITY)
201   dwg_get_OBJECT (ent_loftedsurface, LOFTEDSURFACE)
202   dwg_get_OBJECT (ent_mpolygon, MPOLYGON)
203   dwg_get_OBJECT (ent_navisworksmodel, NAVISWORKSMODEL)
204   dwg_get_OBJECT (ent_nurbsurface, NURBSURFACE)
205   dwg_get_OBJECT (ent_pointparameterentity, POINTPARAMETERENTITY)
206   dwg_get_OBJECT (ent_polargripentity, POLARGRIPENTITY)
207   dwg_get_OBJECT (ent_revolvedsurface, REVOLVEDSURFACE)
208   dwg_get_OBJECT (ent_rotationparameterentity, ROTATIONPARAMETERENTITY)
209   dwg_get_OBJECT (ent_rtext, RTEXT)
210   dwg_get_OBJECT (ent_sweptsurface, SWEPTSURFACE)
211   dwg_get_OBJECT (ent_table, TABLE)
212   dwg_get_OBJECT (ent_visibilitygripentity, VISIBILITYGRIPENTITY)
213   dwg_get_OBJECT (ent_visibilityparameterentity, VISIBILITYPARAMETERENTITY)
214   dwg_get_OBJECT (ent_xyparameterentity, XYPARAMETERENTITY)
215 #endif
216 
217 dwg_get_OBJECT (obj_appid, APPID)
218 dwg_get_OBJECT (obj_appid_control, APPID_CONTROL)
219 dwg_get_OBJECT (obj_block_control, BLOCK_CONTROL)
220 dwg_get_OBJECT (obj_block_header, BLOCK_HEADER)
221 dwg_get_OBJECT (obj_dictionary, DICTIONARY)
222 dwg_get_OBJECT (obj_dimstyle, DIMSTYLE)
223 dwg_get_OBJECT (obj_dimstyle_control, DIMSTYLE_CONTROL)
224 dwg_get_OBJECT (obj_dummy, DUMMY)
225 dwg_get_OBJECT (obj_layer, LAYER)
226 dwg_get_OBJECT (obj_layer_control, LAYER_CONTROL)
227 dwg_get_OBJECT (obj_long_transaction, LONG_TRANSACTION)
228 dwg_get_OBJECT (obj_ltype, LTYPE)
229 dwg_get_OBJECT (obj_ltype_control, LTYPE_CONTROL)
230 dwg_get_OBJECT (obj_mlinestyle, MLINESTYLE)
231 dwg_get_OBJECT (obj_style, STYLE)
232 dwg_get_OBJECT (obj_style_control, STYLE_CONTROL)
233 dwg_get_OBJECT (obj_ucs, UCS)
234 dwg_get_OBJECT (obj_ucs_control, UCS_CONTROL)
235 dwg_get_OBJECT (obj_unknown_obj, UNKNOWN_OBJ)
236 dwg_get_OBJECT (obj_view, VIEW)
237 dwg_get_OBJECT (obj_view_control, VIEW_CONTROL)
238 dwg_get_OBJECT (obj_vport, VPORT)
239 dwg_get_OBJECT (obj_vport_control, VPORT_CONTROL)
240 dwg_get_OBJECT (obj_vx_control, VX_CONTROL)
241 dwg_get_OBJECT (obj_vx_table_record, VX_TABLE_RECORD)
242 /* untyped > 500 */
243 dwg_get_OBJECT (obj_acsh_boolean_class, ACSH_BOOLEAN_CLASS)
244 dwg_get_OBJECT (obj_acsh_box_class, ACSH_BOX_CLASS)
245 dwg_get_OBJECT (obj_acsh_cone_class, ACSH_CONE_CLASS)
246 dwg_get_OBJECT (obj_acsh_cylinder_class, ACSH_CYLINDER_CLASS)
247 dwg_get_OBJECT (obj_acsh_fillet_class, ACSH_FILLET_CLASS)
248 dwg_get_OBJECT (obj_acsh_history_class, ACSH_HISTORY_CLASS)
249 dwg_get_OBJECT (obj_acsh_sphere_class, ACSH_SPHERE_CLASS)
250 dwg_get_OBJECT (obj_acsh_torus_class, ACSH_TORUS_CLASS)
251 dwg_get_OBJECT (obj_acsh_wedge_class, ACSH_WEDGE_CLASS)
252 dwg_get_OBJECT (obj_blockalignmentgrip, BLOCKALIGNMENTGRIP)
253 dwg_get_OBJECT (obj_blockalignmentparameter, BLOCKALIGNMENTPARAMETER)
254 dwg_get_OBJECT (obj_blockbasepointparameter, BLOCKBASEPOINTPARAMETER)
255 dwg_get_OBJECT (obj_blockflipaction, BLOCKFLIPACTION)
256 dwg_get_OBJECT (obj_blockflipgrip, BLOCKFLIPGRIP)
257 dwg_get_OBJECT (obj_blockflipparameter, BLOCKFLIPPARAMETER)
258 dwg_get_OBJECT (obj_blockgriplocationcomponent, BLOCKGRIPLOCATIONCOMPONENT)
259 dwg_get_OBJECT (obj_blocklineargrip, BLOCKLINEARGRIP)
260 dwg_get_OBJECT (obj_blocklookupgrip, BLOCKLOOKUPGRIP)
261 dwg_get_OBJECT (obj_blockmoveaction, BLOCKMOVEACTION)
262 dwg_get_OBJECT (obj_blockrotateaction, BLOCKROTATEACTION)
263 dwg_get_OBJECT (obj_blockrotationgrip, BLOCKROTATIONGRIP)
264 dwg_get_OBJECT (obj_blockscaleaction, BLOCKSCALEACTION)
265 dwg_get_OBJECT (obj_blockvisibilitygrip, BLOCKVISIBILITYGRIP)
266 dwg_get_OBJECT (obj_cellstylemap, CELLSTYLEMAP)
267 dwg_get_OBJECT (obj_detailviewstyle, DETAILVIEWSTYLE)
268 dwg_get_OBJECT (obj_dictionaryvar, DICTIONARYVAR)
269 dwg_get_OBJECT (obj_dictionarywdflt, DICTIONARYWDFLT)
270 dwg_get_OBJECT (obj_dynamicblockpurgepreventer, DYNAMICBLOCKPURGEPREVENTER)
271 dwg_get_OBJECT (obj_field, FIELD)
272 dwg_get_OBJECT (obj_fieldlist, FIELDLIST)
273 dwg_get_OBJECT (obj_geodata, GEODATA)
274 dwg_get_OBJECT (obj_group, GROUP)
275 dwg_get_OBJECT (obj_idbuffer, IDBUFFER)
276 dwg_get_OBJECT (obj_imagedef, IMAGEDEF)
277 dwg_get_OBJECT (obj_imagedef_reactor, IMAGEDEF_REACTOR)
278 dwg_get_OBJECT (obj_index, INDEX)
279 dwg_get_OBJECT (obj_layerfilter, LAYERFILTER)
280 dwg_get_OBJECT (obj_layer_index, LAYER_INDEX)
281 dwg_get_OBJECT (obj_layout, LAYOUT)
282 dwg_get_OBJECT (obj_mleaderstyle, MLEADERSTYLE)
283 dwg_get_OBJECT (obj_placeholder, PLACEHOLDER)
284 dwg_get_OBJECT (obj_plotsettings, PLOTSETTINGS)
285 dwg_get_OBJECT (obj_rastervariables, RASTERVARIABLES)
286 dwg_get_OBJECT (obj_scale, SCALE)
287 dwg_get_OBJECT (obj_sectionviewstyle, SECTIONVIEWSTYLE)
288 dwg_get_OBJECT (obj_section_manager, SECTION_MANAGER)
289 dwg_get_OBJECT (obj_sortentstable, SORTENTSTABLE)
290 dwg_get_OBJECT (obj_spatial_filter, SPATIAL_FILTER)
291 dwg_get_OBJECT (obj_tablegeometry, TABLEGEOMETRY)
292 dwg_get_OBJECT (obj_vba_project, VBA_PROJECT)
293 dwg_get_OBJECT (obj_visualstyle, VISUALSTYLE)
294 dwg_get_OBJECT (obj_wipeoutvariables, WIPEOUTVARIABLES)
295 dwg_get_OBJECT (obj_xrecord, XRECORD)
296 dwg_get_OBJECT (obj_pdfdefinition, PDFDEFINITION)
297 dwg_get_OBJECT (obj_dgndefinition, DGNDEFINITION)
298 dwg_get_OBJECT (obj_dwfdefinition, DWFDEFINITION)
299 /* unstable */
300 dwg_get_OBJECT (obj_acsh_brep_class, ACSH_BREP_CLASS)
301 dwg_get_OBJECT (obj_acsh_chamfer_class, ACSH_CHAMFER_CLASS)
302 dwg_get_OBJECT (obj_acsh_pyramid_class, ACSH_PYRAMID_CLASS)
303 dwg_get_OBJECT (obj_aldimobjectcontextdata, ALDIMOBJECTCONTEXTDATA)
304 dwg_get_OBJECT (obj_assoc2dconstraintgroup, ASSOC2DCONSTRAINTGROUP)
305 dwg_get_OBJECT (obj_assocaction, ASSOCACTION)
306 dwg_get_OBJECT (obj_assocactionparam, ASSOCACTIONPARAM)
307 dwg_get_OBJECT (obj_assocarrayactionbody, ASSOCARRAYACTIONBODY)
308 dwg_get_OBJECT (obj_assocasmbodyactionparam, ASSOCASMBODYACTIONPARAM)
309 dwg_get_OBJECT (obj_assocblendsurfaceactionbody, ASSOCBLENDSURFACEACTIONBODY)
310 dwg_get_OBJECT (obj_assoccompoundactionparam, ASSOCCOMPOUNDACTIONPARAM)
311 dwg_get_OBJECT (obj_assocdependency, ASSOCDEPENDENCY)
312 dwg_get_OBJECT (obj_assocdimdependencybody, ASSOCDIMDEPENDENCYBODY)
313 dwg_get_OBJECT (obj_assocextendsurfaceactionbody, ASSOCEXTENDSURFACEACTIONBODY)
314 dwg_get_OBJECT (obj_assocextrudedsurfaceactionbody, ASSOCEXTRUDEDSURFACEACTIONBODY)
315 dwg_get_OBJECT (obj_assocfaceactionparam, ASSOCFACEACTIONPARAM)
316 dwg_get_OBJECT (obj_assocfilletsurfaceactionbody, ASSOCFILLETSURFACEACTIONBODY)
317 dwg_get_OBJECT (obj_assocgeomdependency, ASSOCGEOMDEPENDENCY)
318 dwg_get_OBJECT (obj_assocloftedsurfaceactionbody, ASSOCLOFTEDSURFACEACTIONBODY)
319 dwg_get_OBJECT (obj_assocnetwork, ASSOCNETWORK)
320 dwg_get_OBJECT (obj_assocnetworksurfaceactionbody, ASSOCNETWORKSURFACEACTIONBODY)
321 dwg_get_OBJECT (obj_assocobjectactionparam, ASSOCOBJECTACTIONPARAM)
322 dwg_get_OBJECT (obj_assocoffsetsurfaceactionbody, ASSOCOFFSETSURFACEACTIONBODY)
323 dwg_get_OBJECT (obj_assocosnappointrefactionparam, ASSOCOSNAPPOINTREFACTIONPARAM)
324 dwg_get_OBJECT (obj_assocpatchsurfaceactionbody, ASSOCPATCHSURFACEACTIONBODY)
325 dwg_get_OBJECT (obj_assocpathactionparam, ASSOCPATHACTIONPARAM)
326 dwg_get_OBJECT (obj_assocplanesurfaceactionbody, ASSOCPLANESURFACEACTIONBODY)
327 dwg_get_OBJECT (obj_assocpointrefactionparam, ASSOCPOINTREFACTIONPARAM)
328 dwg_get_OBJECT (obj_assocrevolvedsurfaceactionbody, ASSOCREVOLVEDSURFACEACTIONBODY)
329 dwg_get_OBJECT (obj_assoctrimsurfaceactionbody, ASSOCTRIMSURFACEACTIONBODY)
330 dwg_get_OBJECT (obj_assocvaluedependency, ASSOCVALUEDEPENDENCY)
331 dwg_get_OBJECT (obj_assocvariable, ASSOCVARIABLE)
332 dwg_get_OBJECT (obj_assocvertexactionparam, ASSOCVERTEXACTIONPARAM)
333 dwg_get_OBJECT (obj_blkrefobjectcontextdata, BLKREFOBJECTCONTEXTDATA)
334 dwg_get_OBJECT (obj_blockalignedconstraintparameter, BLOCKALIGNEDCONSTRAINTPARAMETER)
335 dwg_get_OBJECT (obj_blockangularconstraintparameter, BLOCKANGULARCONSTRAINTPARAMETER)
336 dwg_get_OBJECT (obj_blockarrayaction, BLOCKARRAYACTION)
337 dwg_get_OBJECT (obj_blockdiametricconstraintparameter, BLOCKDIAMETRICCONSTRAINTPARAMETER)
338 dwg_get_OBJECT (obj_blockhorizontalconstraintparameter, BLOCKHORIZONTALCONSTRAINTPARAMETER)
339 dwg_get_OBJECT (obj_blocklinearconstraintparameter, BLOCKLINEARCONSTRAINTPARAMETER)
340 dwg_get_OBJECT (obj_blocklinearparameter, BLOCKLINEARPARAMETER)
341 dwg_get_OBJECT (obj_blocklookupaction, BLOCKLOOKUPACTION)
342 dwg_get_OBJECT (obj_blocklookupparameter, BLOCKLOOKUPPARAMETER)
343 dwg_get_OBJECT (obj_blockparamdependencybody, BLOCKPARAMDEPENDENCYBODY)
344 dwg_get_OBJECT (obj_blockpointparameter, BLOCKPOINTPARAMETER)
345 dwg_get_OBJECT (obj_blockpolargrip, BLOCKPOLARGRIP)
346 dwg_get_OBJECT (obj_blockpolarparameter, BLOCKPOLARPARAMETER)
347 dwg_get_OBJECT (obj_blockpolarstretchaction, BLOCKPOLARSTRETCHACTION)
348 dwg_get_OBJECT (obj_blockradialconstraintparameter, BLOCKRADIALCONSTRAINTPARAMETER)
349 dwg_get_OBJECT (obj_blockrepresentation, BLOCKREPRESENTATION)
350 dwg_get_OBJECT (obj_blockrotationparameter, BLOCKROTATIONPARAMETER)
351 dwg_get_OBJECT (obj_blockstretchaction, BLOCKSTRETCHACTION)
352 dwg_get_OBJECT (obj_blockuserparameter, BLOCKUSERPARAMETER)
353 dwg_get_OBJECT (obj_blockverticalconstraintparameter, BLOCKVERTICALCONSTRAINTPARAMETER)
354 dwg_get_OBJECT (obj_blockvisibilityparameter, BLOCKVISIBILITYPARAMETER)
355 dwg_get_OBJECT (obj_blockxygrip, BLOCKXYGRIP)
356 dwg_get_OBJECT (obj_blockxyparameter, BLOCKXYPARAMETER)
357 dwg_get_OBJECT (obj_datalink, DATALINK)
358 dwg_get_OBJECT (obj_dbcolor, DBCOLOR)
359 dwg_get_OBJECT (obj_evaluation_graph, EVALUATION_GRAPH)
360 dwg_get_OBJECT (obj_fcfobjectcontextdata, FCFOBJECTCONTEXTDATA)
361 dwg_get_OBJECT (obj_gradient_background, GRADIENT_BACKGROUND)
362 dwg_get_OBJECT (obj_ground_plane_background, GROUND_PLANE_BACKGROUND)
363 dwg_get_OBJECT (obj_ibl_background, IBL_BACKGROUND)
364 dwg_get_OBJECT (obj_image_background, IMAGE_BACKGROUND)
365 dwg_get_OBJECT (obj_leaderobjectcontextdata, LEADEROBJECTCONTEXTDATA)
366 dwg_get_OBJECT (obj_lightlist, LIGHTLIST)
367 dwg_get_OBJECT (obj_material, MATERIAL)
368 dwg_get_OBJECT (obj_mentalrayrendersettings, MENTALRAYRENDERSETTINGS)
369 dwg_get_OBJECT (obj_mtextobjectcontextdata, MTEXTOBJECTCONTEXTDATA)
370 dwg_get_OBJECT (obj_object_ptr, OBJECT_PTR)
371 dwg_get_OBJECT (obj_partial_viewing_index, PARTIAL_VIEWING_INDEX)
372 dwg_get_OBJECT (obj_pointcloudcolormap, POINTCLOUDCOLORMAP)
373 dwg_get_OBJECT (obj_pointclouddef, POINTCLOUDDEF)
374 dwg_get_OBJECT (obj_pointclouddefex, POINTCLOUDDEFEX)
375 dwg_get_OBJECT (obj_pointclouddef_reactor, POINTCLOUDDEF_REACTOR)
376 dwg_get_OBJECT (obj_pointclouddef_reactor_ex, POINTCLOUDDEF_REACTOR_EX)
377 dwg_get_OBJECT (obj_proxy_object, PROXY_OBJECT)
378 dwg_get_OBJECT (obj_rapidrtrendersettings, RAPIDRTRENDERSETTINGS)
379 dwg_get_OBJECT (obj_renderentry, RENDERENTRY)
380 dwg_get_OBJECT (obj_renderenvironment, RENDERENVIRONMENT)
381 dwg_get_OBJECT (obj_renderglobal, RENDERGLOBAL)
382 dwg_get_OBJECT (obj_rendersettings, RENDERSETTINGS)
383 dwg_get_OBJECT (obj_section_settings, SECTION_SETTINGS)
384 dwg_get_OBJECT (obj_skylight_background, SKYLIGHT_BACKGROUND)
385 dwg_get_OBJECT (obj_solid_background, SOLID_BACKGROUND)
386 dwg_get_OBJECT (obj_spatial_index, SPATIAL_INDEX)
387 dwg_get_OBJECT (obj_sun, SUN)
388 dwg_get_OBJECT (obj_tablestyle, TABLESTYLE)
389 dwg_get_OBJECT (obj_textobjectcontextdata, TEXTOBJECTCONTEXTDATA)
390 dwg_get_OBJECT (obj_assocarraymodifyparameters, ASSOCARRAYMODIFYPARAMETERS)
391 dwg_get_OBJECT (obj_assocarraypathparameters, ASSOCARRAYPATHPARAMETERS)
392 dwg_get_OBJECT (obj_assocarraypolarparameters, ASSOCARRAYPOLARPARAMETERS)
393 dwg_get_OBJECT (obj_assocarrayrectangularparameters, ASSOCARRAYRECTANGULARPARAMETERS)
394 #ifdef DEBUG_CLASSES
395   dwg_get_OBJECT (obj_acmecommandhistory, ACMECOMMANDHISTORY)
396   dwg_get_OBJECT (obj_acmescope, ACMESCOPE)
397   dwg_get_OBJECT (obj_acmestatemgr, ACMESTATEMGR)
398   dwg_get_OBJECT (obj_acsh_extrusion_class, ACSH_EXTRUSION_CLASS)
399   dwg_get_OBJECT (obj_acsh_loft_class, ACSH_LOFT_CLASS)
400   dwg_get_OBJECT (obj_acsh_revolve_class, ACSH_REVOLVE_CLASS)
401   dwg_get_OBJECT (obj_acsh_sweep_class, ACSH_SWEEP_CLASS)
402   dwg_get_OBJECT (obj_angdimobjectcontextdata, ANGDIMOBJECTCONTEXTDATA)
403   dwg_get_OBJECT (obj_annotscaleobjectcontextdata, ANNOTSCALEOBJECTCONTEXTDATA)
404   dwg_get_OBJECT (obj_assoc3pointangulardimactionbody, ASSOC3POINTANGULARDIMACTIONBODY)
405   dwg_get_OBJECT (obj_assocaligneddimactionbody, ASSOCALIGNEDDIMACTIONBODY)
406   dwg_get_OBJECT (obj_assocarraymodifyactionbody, ASSOCARRAYMODIFYACTIONBODY)
407   dwg_get_OBJECT (obj_assocedgeactionparam, ASSOCEDGEACTIONPARAM)
408   dwg_get_OBJECT (obj_assocedgechamferactionbody, ASSOCEDGECHAMFERACTIONBODY)
409   dwg_get_OBJECT (obj_assocedgefilletactionbody, ASSOCEDGEFILLETACTIONBODY)
410   dwg_get_OBJECT (obj_assocmleaderactionbody, ASSOCMLEADERACTIONBODY)
411   dwg_get_OBJECT (obj_assocordinatedimactionbody, ASSOCORDINATEDIMACTIONBODY)
412   dwg_get_OBJECT (obj_assocperssubentmanager, ASSOCPERSSUBENTMANAGER)
413   dwg_get_OBJECT (obj_assocrestoreentitystateactionbody, ASSOCRESTOREENTITYSTATEACTIONBODY)
414   dwg_get_OBJECT (obj_assocrotateddimactionbody, ASSOCROTATEDDIMACTIONBODY)
415   dwg_get_OBJECT (obj_assocsweptsurfaceactionbody, ASSOCSWEPTSURFACEACTIONBODY)
416   dwg_get_OBJECT (obj_blockpropertiestable, BLOCKPROPERTIESTABLE)
417   dwg_get_OBJECT (obj_blockpropertiestablegrip, BLOCKPROPERTIESTABLEGRIP)
418   dwg_get_OBJECT (obj_contextdatamanager, CONTEXTDATAMANAGER)
419   dwg_get_OBJECT (obj_csacdocumentoptions, CSACDOCUMENTOPTIONS)
420   dwg_get_OBJECT (obj_curvepath, CURVEPATH)
421   dwg_get_OBJECT (obj_datatable, DATATABLE)
422   dwg_get_OBJECT (obj_dimassoc, DIMASSOC)
423   dwg_get_OBJECT (obj_dmdimobjectcontextdata, DMDIMOBJECTCONTEXTDATA)
424   dwg_get_OBJECT (obj_dynamicblockproxynode, DYNAMICBLOCKPROXYNODE)
425   dwg_get_OBJECT (obj_geomapimage, GEOMAPIMAGE)
426   dwg_get_OBJECT (obj_layoutprintconfig, LAYOUTPRINTCONFIG)
427   dwg_get_OBJECT (obj_mleaderobjectcontextdata, MLEADEROBJECTCONTEXTDATA)
428   dwg_get_OBJECT (obj_motionpath, MOTIONPATH)
429   dwg_get_OBJECT (obj_mtextattributeobjectcontextdata, MTEXTATTRIBUTEOBJECTCONTEXTDATA)
430   dwg_get_OBJECT (obj_navisworksmodeldef, NAVISWORKSMODELDEF)
431   dwg_get_OBJECT (obj_orddimobjectcontextdata, ORDDIMOBJECTCONTEXTDATA)
432   dwg_get_OBJECT (obj_persubentmgr, PERSUBENTMGR)
433   dwg_get_OBJECT (obj_pointpath, POINTPATH)
434   dwg_get_OBJECT (obj_radimlgobjectcontextdata, RADIMLGOBJECTCONTEXTDATA)
435   dwg_get_OBJECT (obj_radimobjectcontextdata, RADIMOBJECTCONTEXTDATA)
436   dwg_get_OBJECT (obj_sunstudy, SUNSTUDY)
437   dwg_get_OBJECT (obj_tablecontent, TABLECONTENT)
438   dwg_get_OBJECT (obj_tvdeviceproperties, TVDEVICEPROPERTIES)
439   //dwg_get_OBJECT (obj_acdsrecord, ACDSRECORD)
440   //dwg_get_OBJECT (obj_acdsschema, ACDSSCHEMA)
441   //dwg_get_OBJECT (obj_npocollection, NPOCOLLECTION)
442   //dwg_get_OBJECT (obj_rapidrtrenderenvironment, RAPIDRTRENDERENVIRONMENT)
443   //dwg_get_OBJECT (obj_xrefpanelobject, XREFPANELOBJECT)
444 #endif
445 
446 /********************************************************************
447  * Functions to return NULL-terminated array of all owned entities  *
448  ********************************************************************/
449 
450 /**
451  * \fn Dwg_Entity_ENTITY* dwg_getall_ENTITY(Dwg_Object_Ref *hdr)
452  * \code Usage: Dwg_Entity_TEXT* texts = dwg_getall_TEXT(text,
453  * dwg->header_vars.mspace_block); \endcode \param[in]    hdr Dwg_Object_Ref *
454  * to a BLOCK_CONTROL obj \return       malloced NULL-terminated array
455  *
456  * Extracts all entities of this type from a block header (mspace or pspace),
457  * and returns a malloced NULL-terminated array.
458  */
459 //< \fn Dwg_Entity_TEXT* dwg_getall_TEXT (Dwg_Object_Ref *hdr)
460 DWG_GETALL_ENTITY (_3DFACE)
461 DWG_GETALL_ENTITY (_3DSOLID)
462 DWG_GETALL_ENTITY (ARC)
463 DWG_GETALL_ENTITY (ATTDEF)
464 DWG_GETALL_ENTITY (ATTRIB)
465 DWG_GETALL_ENTITY (BLOCK)
466 DWG_GETALL_ENTITY (BODY)
467 DWG_GETALL_ENTITY (CAMERA)
468 DWG_GETALL_ENTITY (CIRCLE)
469 DWG_GETALL_ENTITY (DGNUNDERLAY)
470 DWG_GETALL_ENTITY (DIMENSION_ALIGNED)
471 DWG_GETALL_ENTITY (DIMENSION_ANG2LN)
472 DWG_GETALL_ENTITY (DIMENSION_ANG3PT)
473 DWG_GETALL_ENTITY (DIMENSION_DIAMETER)
474 DWG_GETALL_ENTITY (DIMENSION_LINEAR)
475 DWG_GETALL_ENTITY (DIMENSION_ORDINATE)
476 DWG_GETALL_ENTITY (DIMENSION_RADIUS)
477 DWG_GETALL_ENTITY (DWFUNDERLAY)
478 DWG_GETALL_ENTITY (ELLIPSE)
479 DWG_GETALL_ENTITY (ENDBLK)
480 DWG_GETALL_ENTITY (HATCH)
481 DWG_GETALL_ENTITY (IMAGE)
482 DWG_GETALL_ENTITY (INSERT)
483 DWG_GETALL_ENTITY (LEADER)
484 DWG_GETALL_ENTITY (LIGHT)
485 DWG_GETALL_ENTITY (LINE)
486 DWG_GETALL_ENTITY (LWPOLYLINE)
487 DWG_GETALL_ENTITY (MESH)
488 DWG_GETALL_ENTITY (MINSERT)
489 DWG_GETALL_ENTITY (MLINE)
490 DWG_GETALL_ENTITY (MTEXT)
491 DWG_GETALL_ENTITY (MULTILEADER)
492 DWG_GETALL_ENTITY (OLE2FRAME)
493 DWG_GETALL_ENTITY (OLEFRAME)
494 DWG_GETALL_ENTITY (PDFUNDERLAY)
495 DWG_GETALL_ENTITY (POINT)
496 DWG_GETALL_ENTITY (POLYLINE_2D)
497 DWG_GETALL_ENTITY (POLYLINE_3D)
498 DWG_GETALL_ENTITY (POLYLINE_MESH)
499 DWG_GETALL_ENTITY (POLYLINE_PFACE)
500 DWG_GETALL_ENTITY (PROXY_ENTITY)
501 DWG_GETALL_ENTITY (RAY)
502 DWG_GETALL_ENTITY (REGION)
503 DWG_GETALL_ENTITY (SECTIONOBJECT)
504 DWG_GETALL_ENTITY (SEQEND)
505 DWG_GETALL_ENTITY (SHAPE)
506 DWG_GETALL_ENTITY (SOLID)
507 DWG_GETALL_ENTITY (SPLINE)
508 DWG_GETALL_ENTITY (TEXT)
509 DWG_GETALL_ENTITY (TOLERANCE)
510 DWG_GETALL_ENTITY (TRACE)
511 DWG_GETALL_ENTITY (UNKNOWN_ENT)
512 DWG_GETALL_ENTITY (VERTEX_2D)
513 DWG_GETALL_ENTITY (VERTEX_3D)
514 DWG_GETALL_ENTITY (VERTEX_MESH)
515 DWG_GETALL_ENTITY (VERTEX_PFACE)
516 DWG_GETALL_ENTITY (VERTEX_PFACE_FACE)
517 DWG_GETALL_ENTITY (VIEWPORT)
518 DWG_GETALL_ENTITY (XLINE)
519 /* unstable */
520 DWG_GETALL_ENTITY (ARC_DIMENSION)
521 DWG_GETALL_ENTITY (HELIX)
522 DWG_GETALL_ENTITY (LARGE_RADIAL_DIMENSION)
523 DWG_GETALL_ENTITY (PLANESURFACE)
524 DWG_GETALL_ENTITY (POINTCLOUD)
525 DWG_GETALL_ENTITY (POINTCLOUDEX)
526 DWG_GETALL_ENTITY (WIPEOUT)
527 /* debugging */
528 DWG_GETALL_ENTITY (ALIGNMENTPARAMETERENTITY)
529 DWG_GETALL_ENTITY (ARCALIGNEDTEXT)
530 DWG_GETALL_ENTITY (BASEPOINTPARAMETERENTITY)
531 DWG_GETALL_ENTITY (EXTRUDEDSURFACE)
532 DWG_GETALL_ENTITY (FLIPPARAMETERENTITY)
533 DWG_GETALL_ENTITY (GEOPOSITIONMARKER)
534 DWG_GETALL_ENTITY (LINEARPARAMETERENTITY)
535 DWG_GETALL_ENTITY (LOFTEDSURFACE)
536 DWG_GETALL_ENTITY (MPOLYGON)
537 DWG_GETALL_ENTITY (NAVISWORKSMODEL)
538 DWG_GETALL_ENTITY (NURBSURFACE)
539 DWG_GETALL_ENTITY (POINTPARAMETERENTITY)
540 DWG_GETALL_ENTITY (POLARGRIPENTITY)
541 DWG_GETALL_ENTITY (REVOLVEDSURFACE)
542 DWG_GETALL_ENTITY (ROTATIONPARAMETERENTITY)
543 DWG_GETALL_ENTITY (RTEXT)
544 DWG_GETALL_ENTITY (SWEPTSURFACE)
545 DWG_GETALL_ENTITY (TABLE)
546 DWG_GETALL_ENTITY (VISIBILITYGRIPENTITY)
547 DWG_GETALL_ENTITY (VISIBILITYPARAMETERENTITY)
548 DWG_GETALL_ENTITY (XYPARAMETERENTITY)
549 
550 /********************************************************************
551  *     Functions to return NULL-terminated array of all objects     *
552  ********************************************************************/
553 
554 /**
555  * \fn Dwg_Object_OBJECT dwg_getall_OBJECT(Dwg_Data *dwg)
556  * Extracts all objects of this type from a dwg, and returns a malloced
557  * NULL-terminated array.
558  */
559 
560 DWG_GETALL_OBJECT (ACSH_BOOLEAN_CLASS)
561 DWG_GETALL_OBJECT (ACSH_BOX_CLASS)
562 DWG_GETALL_OBJECT (ACSH_CONE_CLASS)
563 DWG_GETALL_OBJECT (ACSH_CYLINDER_CLASS)
564 DWG_GETALL_OBJECT (ACSH_FILLET_CLASS)
565 DWG_GETALL_OBJECT (ACSH_HISTORY_CLASS)
566 DWG_GETALL_OBJECT (ACSH_SPHERE_CLASS)
567 DWG_GETALL_OBJECT (ACSH_TORUS_CLASS)
568 DWG_GETALL_OBJECT (ACSH_WEDGE_CLASS)
569 DWG_GETALL_OBJECT (APPID)
570 DWG_GETALL_OBJECT (APPID_CONTROL)
571 DWG_GETALL_OBJECT (BLOCKALIGNMENTGRIP)
572 DWG_GETALL_OBJECT (BLOCKALIGNMENTPARAMETER)
573 DWG_GETALL_OBJECT (BLOCKBASEPOINTPARAMETER)
574 DWG_GETALL_OBJECT (BLOCKFLIPACTION)
575 DWG_GETALL_OBJECT (BLOCKFLIPGRIP)
576 DWG_GETALL_OBJECT (BLOCKFLIPPARAMETER)
577 DWG_GETALL_OBJECT (BLOCKGRIPLOCATIONCOMPONENT)
578 DWG_GETALL_OBJECT (BLOCKLINEARGRIP)
579 DWG_GETALL_OBJECT (BLOCKLOOKUPGRIP)
580 DWG_GETALL_OBJECT (BLOCKMOVEACTION)
581 DWG_GETALL_OBJECT (BLOCKROTATEACTION)
582 DWG_GETALL_OBJECT (BLOCKROTATIONGRIP)
583 DWG_GETALL_OBJECT (BLOCKSCALEACTION)
584 DWG_GETALL_OBJECT (BLOCKVISIBILITYGRIP)
585 DWG_GETALL_OBJECT (BLOCK_CONTROL)
586 DWG_GETALL_OBJECT (BLOCK_HEADER)
587 DWG_GETALL_OBJECT (CELLSTYLEMAP)
588 DWG_GETALL_OBJECT (DETAILVIEWSTYLE)
589 DWG_GETALL_OBJECT (DICTIONARY)
590 DWG_GETALL_OBJECT (DICTIONARYVAR)
591 DWG_GETALL_OBJECT (DICTIONARYWDFLT)
592 DWG_GETALL_OBJECT (DIMSTYLE)
593 DWG_GETALL_OBJECT (DIMSTYLE_CONTROL)
594 DWG_GETALL_OBJECT (DUMMY)
595 DWG_GETALL_OBJECT (DYNAMICBLOCKPURGEPREVENTER)
596 DWG_GETALL_OBJECT (FIELD)
597 DWG_GETALL_OBJECT (FIELDLIST)
598 DWG_GETALL_OBJECT (GEODATA)
599 DWG_GETALL_OBJECT (GROUP)
600 DWG_GETALL_OBJECT (IDBUFFER)
601 DWG_GETALL_OBJECT (IMAGEDEF)
602 DWG_GETALL_OBJECT (IMAGEDEF_REACTOR)
603 DWG_GETALL_OBJECT (INDEX)
604 DWG_GETALL_OBJECT (LAYER)
605 DWG_GETALL_OBJECT (LAYERFILTER)
606 DWG_GETALL_OBJECT (LAYER_CONTROL)
607 DWG_GETALL_OBJECT (LAYER_INDEX)
608 DWG_GETALL_OBJECT (LAYOUT)
609 DWG_GETALL_OBJECT (LONG_TRANSACTION)
610 DWG_GETALL_OBJECT (LTYPE)
611 DWG_GETALL_OBJECT (LTYPE_CONTROL)
612 DWG_GETALL_OBJECT (MLEADERSTYLE)
613 DWG_GETALL_OBJECT (MLINESTYLE)
614 DWG_GETALL_OBJECT (PLACEHOLDER)
615 DWG_GETALL_OBJECT (PLOTSETTINGS)
616 DWG_GETALL_OBJECT (RASTERVARIABLES)
617 DWG_GETALL_OBJECT (SCALE)
618 DWG_GETALL_OBJECT (SECTIONVIEWSTYLE)
619 DWG_GETALL_OBJECT (SECTION_MANAGER)
620 DWG_GETALL_OBJECT (SORTENTSTABLE)
621 DWG_GETALL_OBJECT (SPATIAL_FILTER)
622 DWG_GETALL_OBJECT (STYLE)
623 DWG_GETALL_OBJECT (STYLE_CONTROL)
624 DWG_GETALL_OBJECT (TABLEGEOMETRY)
625 DWG_GETALL_OBJECT (UCS)
626 DWG_GETALL_OBJECT (UCS_CONTROL)
627 DWG_GETALL_OBJECT (UNKNOWN_OBJ)
628 DWG_GETALL_OBJECT (VBA_PROJECT)
629 DWG_GETALL_OBJECT (VIEW)
630 DWG_GETALL_OBJECT (VIEW_CONTROL)
631 DWG_GETALL_OBJECT (VISUALSTYLE)
632 DWG_GETALL_OBJECT (VPORT)
633 DWG_GETALL_OBJECT (VPORT_CONTROL)
634 DWG_GETALL_OBJECT (VX_CONTROL)
635 DWG_GETALL_OBJECT (VX_TABLE_RECORD)
636 DWG_GETALL_OBJECT (WIPEOUTVARIABLES)
637 DWG_GETALL_OBJECT (XRECORD)
638 DWG_GETALL_OBJECT (PDFDEFINITION)
639 DWG_GETALL_OBJECT (DGNDEFINITION)
640 DWG_GETALL_OBJECT (DWFDEFINITION)
641 /* unstable */
642 DWG_GETALL_OBJECT (ACSH_BREP_CLASS)
643 DWG_GETALL_OBJECT (ACSH_CHAMFER_CLASS)
644 DWG_GETALL_OBJECT (ACSH_PYRAMID_CLASS)
645 DWG_GETALL_OBJECT (ALDIMOBJECTCONTEXTDATA)
646 DWG_GETALL_OBJECT (ASSOC2DCONSTRAINTGROUP)
647 DWG_GETALL_OBJECT (ASSOCACTION)
648 DWG_GETALL_OBJECT (ASSOCACTIONPARAM)
649 DWG_GETALL_OBJECT (ASSOCARRAYACTIONBODY)
650 DWG_GETALL_OBJECT (ASSOCASMBODYACTIONPARAM)
651 DWG_GETALL_OBJECT (ASSOCBLENDSURFACEACTIONBODY)
652 DWG_GETALL_OBJECT (ASSOCCOMPOUNDACTIONPARAM)
653 DWG_GETALL_OBJECT (ASSOCDEPENDENCY)
654 DWG_GETALL_OBJECT (ASSOCDIMDEPENDENCYBODY)
655 DWG_GETALL_OBJECT (ASSOCEXTENDSURFACEACTIONBODY)
656 DWG_GETALL_OBJECT (ASSOCEXTRUDEDSURFACEACTIONBODY)
657 DWG_GETALL_OBJECT (ASSOCFACEACTIONPARAM)
658 DWG_GETALL_OBJECT (ASSOCFILLETSURFACEACTIONBODY)
659 DWG_GETALL_OBJECT (ASSOCGEOMDEPENDENCY)
660 DWG_GETALL_OBJECT (ASSOCLOFTEDSURFACEACTIONBODY)
661 DWG_GETALL_OBJECT (ASSOCNETWORK)
662 DWG_GETALL_OBJECT (ASSOCNETWORKSURFACEACTIONBODY)
663 DWG_GETALL_OBJECT (ASSOCOBJECTACTIONPARAM)
664 DWG_GETALL_OBJECT (ASSOCOFFSETSURFACEACTIONBODY)
665 DWG_GETALL_OBJECT (ASSOCOSNAPPOINTREFACTIONPARAM)
666 DWG_GETALL_OBJECT (ASSOCPATCHSURFACEACTIONBODY)
667 DWG_GETALL_OBJECT (ASSOCPATHACTIONPARAM)
668 DWG_GETALL_OBJECT (ASSOCPLANESURFACEACTIONBODY)
669 DWG_GETALL_OBJECT (ASSOCPOINTREFACTIONPARAM)
670 DWG_GETALL_OBJECT (ASSOCREVOLVEDSURFACEACTIONBODY)
671 DWG_GETALL_OBJECT (ASSOCTRIMSURFACEACTIONBODY)
672 DWG_GETALL_OBJECT (ASSOCVALUEDEPENDENCY)
673 DWG_GETALL_OBJECT (ASSOCVARIABLE)
674 DWG_GETALL_OBJECT (ASSOCVERTEXACTIONPARAM)
675 DWG_GETALL_OBJECT (BLKREFOBJECTCONTEXTDATA)
676 DWG_GETALL_OBJECT (BLOCKALIGNEDCONSTRAINTPARAMETER)
677 DWG_GETALL_OBJECT (BLOCKANGULARCONSTRAINTPARAMETER)
678 DWG_GETALL_OBJECT (BLOCKARRAYACTION)
679 DWG_GETALL_OBJECT (BLOCKDIAMETRICCONSTRAINTPARAMETER)
680 DWG_GETALL_OBJECT (BLOCKHORIZONTALCONSTRAINTPARAMETER)
681 DWG_GETALL_OBJECT (BLOCKLINEARCONSTRAINTPARAMETER)
682 DWG_GETALL_OBJECT (BLOCKLINEARPARAMETER)
683 DWG_GETALL_OBJECT (BLOCKLOOKUPACTION)
684 DWG_GETALL_OBJECT (BLOCKLOOKUPPARAMETER)
685 DWG_GETALL_OBJECT (BLOCKPARAMDEPENDENCYBODY)
686 DWG_GETALL_OBJECT (BLOCKPOINTPARAMETER)
687 DWG_GETALL_OBJECT (BLOCKPOLARGRIP)
688 DWG_GETALL_OBJECT (BLOCKPOLARPARAMETER)
689 DWG_GETALL_OBJECT (BLOCKPOLARSTRETCHACTION)
690 DWG_GETALL_OBJECT (BLOCKRADIALCONSTRAINTPARAMETER)
691 DWG_GETALL_OBJECT (BLOCKREPRESENTATION)
692 DWG_GETALL_OBJECT (BLOCKROTATIONPARAMETER)
693 DWG_GETALL_OBJECT (BLOCKSTRETCHACTION)
694 DWG_GETALL_OBJECT (BLOCKUSERPARAMETER)
695 DWG_GETALL_OBJECT (BLOCKVERTICALCONSTRAINTPARAMETER)
696 DWG_GETALL_OBJECT (BLOCKVISIBILITYPARAMETER)
697 DWG_GETALL_OBJECT (BLOCKXYGRIP)
698 DWG_GETALL_OBJECT (BLOCKXYPARAMETER)
699 DWG_GETALL_OBJECT (DATALINK)
700 DWG_GETALL_OBJECT (DBCOLOR)
701 DWG_GETALL_OBJECT (EVALUATION_GRAPH)
702 DWG_GETALL_OBJECT (FCFOBJECTCONTEXTDATA)
703 DWG_GETALL_OBJECT (GRADIENT_BACKGROUND)
704 DWG_GETALL_OBJECT (GROUND_PLANE_BACKGROUND)
705 DWG_GETALL_OBJECT (IBL_BACKGROUND)
706 DWG_GETALL_OBJECT (IMAGE_BACKGROUND)
707 DWG_GETALL_OBJECT (LEADEROBJECTCONTEXTDATA)
708 DWG_GETALL_OBJECT (LIGHTLIST)
709 DWG_GETALL_OBJECT (MATERIAL)
710 DWG_GETALL_OBJECT (MENTALRAYRENDERSETTINGS)
711 DWG_GETALL_OBJECT (MTEXTOBJECTCONTEXTDATA)
712 DWG_GETALL_OBJECT (OBJECT_PTR)
713 DWG_GETALL_OBJECT (PARTIAL_VIEWING_INDEX)
714 DWG_GETALL_OBJECT (POINTCLOUDCOLORMAP)
715 DWG_GETALL_OBJECT (POINTCLOUDDEF)
716 DWG_GETALL_OBJECT (POINTCLOUDDEFEX)
717 DWG_GETALL_OBJECT (POINTCLOUDDEF_REACTOR)
718 DWG_GETALL_OBJECT (POINTCLOUDDEF_REACTOR_EX)
719 DWG_GETALL_OBJECT (PROXY_OBJECT)
720 DWG_GETALL_OBJECT (RAPIDRTRENDERSETTINGS)
721 DWG_GETALL_OBJECT (RENDERENTRY)
722 DWG_GETALL_OBJECT (RENDERENVIRONMENT)
723 DWG_GETALL_OBJECT (RENDERGLOBAL)
724 DWG_GETALL_OBJECT (RENDERSETTINGS)
725 DWG_GETALL_OBJECT (SECTION_SETTINGS)
726 DWG_GETALL_OBJECT (SKYLIGHT_BACKGROUND)
727 DWG_GETALL_OBJECT (SOLID_BACKGROUND)
728 DWG_GETALL_OBJECT (SPATIAL_INDEX)
729 DWG_GETALL_OBJECT (SUN)
730 DWG_GETALL_OBJECT (TABLESTYLE)
731 DWG_GETALL_OBJECT (TEXTOBJECTCONTEXTDATA)
732 DWG_GETALL_OBJECT (ASSOCARRAYMODIFYPARAMETERS)
733 DWG_GETALL_OBJECT (ASSOCARRAYPATHPARAMETERS)
734 DWG_GETALL_OBJECT (ASSOCARRAYPOLARPARAMETERS)
735 DWG_GETALL_OBJECT (ASSOCARRAYRECTANGULARPARAMETERS)
736 #ifdef DEBUG_CLASSES
737   DWG_GETALL_OBJECT (ACMECOMMANDHISTORY)
738   DWG_GETALL_OBJECT (ACMESCOPE)
739   DWG_GETALL_OBJECT (ACMESTATEMGR)
740   DWG_GETALL_OBJECT (ACSH_EXTRUSION_CLASS)
741   DWG_GETALL_OBJECT (ACSH_LOFT_CLASS)
742   DWG_GETALL_OBJECT (ACSH_REVOLVE_CLASS)
743   DWG_GETALL_OBJECT (ACSH_SWEEP_CLASS)
744   DWG_GETALL_OBJECT (ANGDIMOBJECTCONTEXTDATA)
745   DWG_GETALL_OBJECT (ANNOTSCALEOBJECTCONTEXTDATA)
746   DWG_GETALL_OBJECT (ASSOC3POINTANGULARDIMACTIONBODY)
747   DWG_GETALL_OBJECT (ASSOCALIGNEDDIMACTIONBODY)
748   DWG_GETALL_OBJECT (ASSOCARRAYMODIFYACTIONBODY)
749   DWG_GETALL_OBJECT (ASSOCEDGEACTIONPARAM)
750   DWG_GETALL_OBJECT (ASSOCEDGECHAMFERACTIONBODY)
751   DWG_GETALL_OBJECT (ASSOCEDGEFILLETACTIONBODY)
752   DWG_GETALL_OBJECT (ASSOCMLEADERACTIONBODY)
753   DWG_GETALL_OBJECT (ASSOCORDINATEDIMACTIONBODY)
754   DWG_GETALL_OBJECT (ASSOCPERSSUBENTMANAGER)
755   DWG_GETALL_OBJECT (ASSOCRESTOREENTITYSTATEACTIONBODY)
756   DWG_GETALL_OBJECT (ASSOCROTATEDDIMACTIONBODY)
757   DWG_GETALL_OBJECT (ASSOCSWEPTSURFACEACTIONBODY)
758   DWG_GETALL_OBJECT (BLOCKPROPERTIESTABLE)
759   DWG_GETALL_OBJECT (BLOCKPROPERTIESTABLEGRIP)
760   DWG_GETALL_OBJECT (CONTEXTDATAMANAGER)
761   DWG_GETALL_OBJECT (CSACDOCUMENTOPTIONS)
762   DWG_GETALL_OBJECT (CURVEPATH)
763   DWG_GETALL_OBJECT (DATATABLE)
764   DWG_GETALL_OBJECT (DIMASSOC)
765   DWG_GETALL_OBJECT (DMDIMOBJECTCONTEXTDATA)
766   DWG_GETALL_OBJECT (DYNAMICBLOCKPROXYNODE)
767   DWG_GETALL_OBJECT (GEOMAPIMAGE)
768   DWG_GETALL_OBJECT (LAYOUTPRINTCONFIG)
769   DWG_GETALL_OBJECT (MLEADEROBJECTCONTEXTDATA)
770   DWG_GETALL_OBJECT (MOTIONPATH)
771   DWG_GETALL_OBJECT (MTEXTATTRIBUTEOBJECTCONTEXTDATA)
772   DWG_GETALL_OBJECT (NAVISWORKSMODELDEF)
773   DWG_GETALL_OBJECT (ORDDIMOBJECTCONTEXTDATA)
774   DWG_GETALL_OBJECT (PERSUBENTMGR)
775   DWG_GETALL_OBJECT (POINTPATH)
776   DWG_GETALL_OBJECT (RADIMLGOBJECTCONTEXTDATA)
777   DWG_GETALL_OBJECT (RADIMOBJECTCONTEXTDATA)
778   DWG_GETALL_OBJECT (SUNSTUDY)
779   DWG_GETALL_OBJECT (TABLECONTENT)
780   DWG_GETALL_OBJECT (TVDEVICEPROPERTIES)
781   //DWG_GETALL_OBJECT (ACDSRECORD)
782   //DWG_GETALL_OBJECT (ACDSSCHEMA)
783   //DWG_GETALL_OBJECT (NPOCOLLECTION)
784   //DWG_GETALL_OBJECT (RAPIDRTRENDERENVIRONMENT)
785   //DWG_GETALL_OBJECT (XREFPANELOBJECT)
786 #endif
787 
788 /*******************************************************************
789  *     Functions created from macro to cast dwg_object to entity     *
790  *                 Usage :- dwg_object_to_ENTITY(),                  *
791  *                where ENTITY can be LINE or CIRCLE                 *
792  ********************************************************************/
793 
794 /**
795  * \fn Dwg_Entity_ENTITY *dwg_object_to_ENTITY(Dwg_Object *obj)
796  * cast a Dwg_Object to Entity
797  */
798 /* fixed <500 */
799 CAST_DWG_OBJECT_TO_ENTITY (_3DFACE)
800 CAST_DWG_OBJECT_TO_ENTITY (_3DSOLID)
801 CAST_DWG_OBJECT_TO_ENTITY (ARC)
802 CAST_DWG_OBJECT_TO_ENTITY (ATTDEF)
803 CAST_DWG_OBJECT_TO_ENTITY (ATTRIB)
804 CAST_DWG_OBJECT_TO_ENTITY (BLOCK)
805 CAST_DWG_OBJECT_TO_ENTITY (BODY)
806 CAST_DWG_OBJECT_TO_ENTITY (CIRCLE)
807 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_ALIGNED)
808 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_ANG2LN)
809 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_ANG3PT)
810 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_DIAMETER)
811 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_LINEAR)
812 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_ORDINATE)
813 CAST_DWG_OBJECT_TO_ENTITY (DIMENSION_RADIUS)
814 CAST_DWG_OBJECT_TO_ENTITY (ELLIPSE)
815 CAST_DWG_OBJECT_TO_ENTITY (ENDBLK)
816 CAST_DWG_OBJECT_TO_ENTITY (INSERT)
817 CAST_DWG_OBJECT_TO_ENTITY (LEADER)
818 CAST_DWG_OBJECT_TO_ENTITY (LINE)
819 CAST_DWG_OBJECT_TO_ENTITY (MINSERT)
820 CAST_DWG_OBJECT_TO_ENTITY (MLINE)
821 CAST_DWG_OBJECT_TO_ENTITY (MTEXT)
822 CAST_DWG_OBJECT_TO_ENTITY (OLEFRAME)
823 CAST_DWG_OBJECT_TO_ENTITY (POINT)
824 CAST_DWG_OBJECT_TO_ENTITY (POLYLINE_2D)
825 CAST_DWG_OBJECT_TO_ENTITY (POLYLINE_3D)
826 CAST_DWG_OBJECT_TO_ENTITY (POLYLINE_MESH)
827 CAST_DWG_OBJECT_TO_ENTITY (POLYLINE_PFACE)
828 CAST_DWG_OBJECT_TO_ENTITY (PROXY_ENTITY)
829 CAST_DWG_OBJECT_TO_ENTITY (RAY)
830 CAST_DWG_OBJECT_TO_ENTITY (REGION)
831 CAST_DWG_OBJECT_TO_ENTITY (SEQEND)
832 CAST_DWG_OBJECT_TO_ENTITY (SHAPE)
833 CAST_DWG_OBJECT_TO_ENTITY (SOLID)
834 CAST_DWG_OBJECT_TO_ENTITY (SPLINE)
835 CAST_DWG_OBJECT_TO_ENTITY (TEXT)
836 CAST_DWG_OBJECT_TO_ENTITY (TOLERANCE)
837 CAST_DWG_OBJECT_TO_ENTITY (TRACE)
838 CAST_DWG_OBJECT_TO_ENTITY (UNKNOWN_ENT)
839 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_2D)
840 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_3D)
841 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_MESH)
842 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_PFACE)
843 CAST_DWG_OBJECT_TO_ENTITY (VERTEX_PFACE_FACE)
844 CAST_DWG_OBJECT_TO_ENTITY (VIEWPORT)
845 CAST_DWG_OBJECT_TO_ENTITY (XLINE)
846 /* untyped > 500 */
847 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (CAMERA)
848 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (DGNUNDERLAY)
849 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (DWFUNDERLAY)
850 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (HATCH)
851 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (IMAGE)
852 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (LIGHT)
853 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (LWPOLYLINE)
854 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (MESH)
855 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (MULTILEADER)
856 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (OLE2FRAME)
857 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (PDFUNDERLAY)
858 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (SECTIONOBJECT)
859 /* unstable */
860 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (ARC_DIMENSION)
861 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (HELIX)
862 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (LARGE_RADIAL_DIMENSION)
863 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (PLANESURFACE)
864 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (POINTCLOUD)
865 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (POINTCLOUDEX)
866 CAST_DWG_OBJECT_TO_ENTITY_BYNAME (WIPEOUT)
867 #ifdef DEBUG_CLASSES
868   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (ALIGNMENTPARAMETERENTITY)
869   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (ARCALIGNEDTEXT)
870   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (BASEPOINTPARAMETERENTITY)
871   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (EXTRUDEDSURFACE)
872   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (FLIPPARAMETERENTITY)
873   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (GEOPOSITIONMARKER)
874   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (LINEARPARAMETERENTITY)
875   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (LOFTEDSURFACE)
876   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (MPOLYGON)
877   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (NAVISWORKSMODEL)
878   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (NURBSURFACE)
879   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (POINTPARAMETERENTITY)
880   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (POLARGRIPENTITY)
881   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (REVOLVEDSURFACE)
882   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (ROTATIONPARAMETERENTITY)
883   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (RTEXT)
884   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (SWEPTSURFACE)
885   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (TABLE)
886   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (VISIBILITYGRIPENTITY)
887   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (VISIBILITYPARAMETERENTITY)
888   CAST_DWG_OBJECT_TO_ENTITY_BYNAME (XYPARAMETERENTITY)
889 #endif
890 
891 /*******************************************************************
892  *     Functions created from macro to cast dwg object to object     *
893  *                 Usage :- dwg_object_to_OBJECT(),                  *
894  *            where OBJECT can be LAYER or BLOCK_HEADER              *
895  ********************************************************************/
896 /**
897  * \fn Dwg_Object_OBJECT *dwg_object_to_OBJECT(Dwg_Object *obj)
898  * cast a Dwg_Object to Object
899  */
900 CAST_DWG_OBJECT_TO_OBJECT (ACSH_BOOLEAN_CLASS)
901 CAST_DWG_OBJECT_TO_OBJECT (ACSH_BOX_CLASS)
902 CAST_DWG_OBJECT_TO_OBJECT (ACSH_CONE_CLASS)
903 CAST_DWG_OBJECT_TO_OBJECT (ACSH_CYLINDER_CLASS)
904 CAST_DWG_OBJECT_TO_OBJECT (ACSH_FILLET_CLASS)
905 CAST_DWG_OBJECT_TO_OBJECT (ACSH_HISTORY_CLASS)
906 CAST_DWG_OBJECT_TO_OBJECT (ACSH_SPHERE_CLASS)
907 CAST_DWG_OBJECT_TO_OBJECT (ACSH_TORUS_CLASS)
908 CAST_DWG_OBJECT_TO_OBJECT (ACSH_WEDGE_CLASS)
909 CAST_DWG_OBJECT_TO_OBJECT (APPID)
910 CAST_DWG_OBJECT_TO_OBJECT (APPID_CONTROL)
911 CAST_DWG_OBJECT_TO_OBJECT (BLOCKALIGNMENTGRIP)
912 CAST_DWG_OBJECT_TO_OBJECT (BLOCKALIGNMENTPARAMETER)
913 CAST_DWG_OBJECT_TO_OBJECT (BLOCKBASEPOINTPARAMETER)
914 CAST_DWG_OBJECT_TO_OBJECT (BLOCKFLIPACTION)
915 CAST_DWG_OBJECT_TO_OBJECT (BLOCKFLIPGRIP)
916 CAST_DWG_OBJECT_TO_OBJECT (BLOCKFLIPPARAMETER)
917 CAST_DWG_OBJECT_TO_OBJECT (BLOCKGRIPLOCATIONCOMPONENT)
918 CAST_DWG_OBJECT_TO_OBJECT (BLOCKLINEARGRIP)
919 CAST_DWG_OBJECT_TO_OBJECT (BLOCKLOOKUPGRIP)
920 CAST_DWG_OBJECT_TO_OBJECT (BLOCKMOVEACTION)
921 CAST_DWG_OBJECT_TO_OBJECT (BLOCKROTATEACTION)
922 CAST_DWG_OBJECT_TO_OBJECT (BLOCKROTATIONGRIP)
923 CAST_DWG_OBJECT_TO_OBJECT (BLOCKSCALEACTION)
924 CAST_DWG_OBJECT_TO_OBJECT (BLOCKVISIBILITYGRIP)
925 CAST_DWG_OBJECT_TO_OBJECT (BLOCK_CONTROL)
926 CAST_DWG_OBJECT_TO_OBJECT (BLOCK_HEADER)
927 CAST_DWG_OBJECT_TO_OBJECT (CELLSTYLEMAP)
928 CAST_DWG_OBJECT_TO_OBJECT (DETAILVIEWSTYLE)
929 CAST_DWG_OBJECT_TO_OBJECT (DICTIONARY)
930 CAST_DWG_OBJECT_TO_OBJECT (DICTIONARYVAR)
931 CAST_DWG_OBJECT_TO_OBJECT (DICTIONARYWDFLT)
932 CAST_DWG_OBJECT_TO_OBJECT (DIMSTYLE)
933 CAST_DWG_OBJECT_TO_OBJECT (DIMSTYLE_CONTROL)
934 CAST_DWG_OBJECT_TO_OBJECT (DUMMY)
935 CAST_DWG_OBJECT_TO_OBJECT (DYNAMICBLOCKPURGEPREVENTER)
936 CAST_DWG_OBJECT_TO_OBJECT (FIELD)
937 CAST_DWG_OBJECT_TO_OBJECT (FIELDLIST)
938 CAST_DWG_OBJECT_TO_OBJECT (GEODATA)
939 CAST_DWG_OBJECT_TO_OBJECT (GROUP)
940 CAST_DWG_OBJECT_TO_OBJECT (IDBUFFER)
941 CAST_DWG_OBJECT_TO_OBJECT (IMAGEDEF)
942 CAST_DWG_OBJECT_TO_OBJECT (IMAGEDEF_REACTOR)
943 CAST_DWG_OBJECT_TO_OBJECT (INDEX)
944 CAST_DWG_OBJECT_TO_OBJECT (LAYER)
945 CAST_DWG_OBJECT_TO_OBJECT (LAYERFILTER)
946 CAST_DWG_OBJECT_TO_OBJECT (LAYER_CONTROL)
947 CAST_DWG_OBJECT_TO_OBJECT (LAYER_INDEX)
948 CAST_DWG_OBJECT_TO_OBJECT (LAYOUT)
949 CAST_DWG_OBJECT_TO_OBJECT (LONG_TRANSACTION)
950 CAST_DWG_OBJECT_TO_OBJECT (LTYPE)
951 CAST_DWG_OBJECT_TO_OBJECT (LTYPE_CONTROL)
952 CAST_DWG_OBJECT_TO_OBJECT (MLEADERSTYLE)
953 CAST_DWG_OBJECT_TO_OBJECT (MLINESTYLE)
954 CAST_DWG_OBJECT_TO_OBJECT (PLACEHOLDER)
955 CAST_DWG_OBJECT_TO_OBJECT (PLOTSETTINGS)
956 CAST_DWG_OBJECT_TO_OBJECT (RASTERVARIABLES)
957 CAST_DWG_OBJECT_TO_OBJECT (SCALE)
958 CAST_DWG_OBJECT_TO_OBJECT (SECTIONVIEWSTYLE)
959 CAST_DWG_OBJECT_TO_OBJECT (SECTION_MANAGER)
960 CAST_DWG_OBJECT_TO_OBJECT (SORTENTSTABLE)
961 CAST_DWG_OBJECT_TO_OBJECT (SPATIAL_FILTER)
962 CAST_DWG_OBJECT_TO_OBJECT (STYLE)
963 CAST_DWG_OBJECT_TO_OBJECT (STYLE_CONTROL)
964 CAST_DWG_OBJECT_TO_OBJECT (TABLEGEOMETRY)
965 CAST_DWG_OBJECT_TO_OBJECT (UCS)
966 CAST_DWG_OBJECT_TO_OBJECT (UCS_CONTROL)
967 CAST_DWG_OBJECT_TO_OBJECT (UNKNOWN_OBJ)
968 CAST_DWG_OBJECT_TO_OBJECT (VBA_PROJECT)
969 CAST_DWG_OBJECT_TO_OBJECT (VIEW)
970 CAST_DWG_OBJECT_TO_OBJECT (VIEW_CONTROL)
971 CAST_DWG_OBJECT_TO_OBJECT (VISUALSTYLE)
972 CAST_DWG_OBJECT_TO_OBJECT (VPORT)
973 CAST_DWG_OBJECT_TO_OBJECT (VPORT_CONTROL)
974 CAST_DWG_OBJECT_TO_OBJECT (VX_CONTROL)
975 CAST_DWG_OBJECT_TO_OBJECT (VX_TABLE_RECORD)
976 CAST_DWG_OBJECT_TO_OBJECT (WIPEOUTVARIABLES)
977 CAST_DWG_OBJECT_TO_OBJECT (XRECORD)
978 CAST_DWG_OBJECT_TO_OBJECT (PDFDEFINITION)
979 CAST_DWG_OBJECT_TO_OBJECT (DGNDEFINITION)
980 CAST_DWG_OBJECT_TO_OBJECT (DWFDEFINITION)
981 /* unstable */
982 CAST_DWG_OBJECT_TO_OBJECT (ACSH_BREP_CLASS)
983 CAST_DWG_OBJECT_TO_OBJECT (ACSH_CHAMFER_CLASS)
984 CAST_DWG_OBJECT_TO_OBJECT (ACSH_PYRAMID_CLASS)
985 CAST_DWG_OBJECT_TO_OBJECT (ALDIMOBJECTCONTEXTDATA)
986 CAST_DWG_OBJECT_TO_OBJECT (ASSOC2DCONSTRAINTGROUP)
987 CAST_DWG_OBJECT_TO_OBJECT (ASSOCACTION)
988 CAST_DWG_OBJECT_TO_OBJECT (ASSOCACTIONPARAM)
989 CAST_DWG_OBJECT_TO_OBJECT (ASSOCARRAYACTIONBODY)
990 CAST_DWG_OBJECT_TO_OBJECT (ASSOCASMBODYACTIONPARAM)
991 CAST_DWG_OBJECT_TO_OBJECT (ASSOCBLENDSURFACEACTIONBODY)
992 CAST_DWG_OBJECT_TO_OBJECT (ASSOCCOMPOUNDACTIONPARAM)
993 CAST_DWG_OBJECT_TO_OBJECT (ASSOCDEPENDENCY)
994 CAST_DWG_OBJECT_TO_OBJECT (ASSOCDIMDEPENDENCYBODY)
995 CAST_DWG_OBJECT_TO_OBJECT (ASSOCEXTENDSURFACEACTIONBODY)
996 CAST_DWG_OBJECT_TO_OBJECT (ASSOCEXTRUDEDSURFACEACTIONBODY)
997 CAST_DWG_OBJECT_TO_OBJECT (ASSOCFACEACTIONPARAM)
998 CAST_DWG_OBJECT_TO_OBJECT (ASSOCFILLETSURFACEACTIONBODY)
999 CAST_DWG_OBJECT_TO_OBJECT (ASSOCGEOMDEPENDENCY)
1000 CAST_DWG_OBJECT_TO_OBJECT (ASSOCLOFTEDSURFACEACTIONBODY)
1001 CAST_DWG_OBJECT_TO_OBJECT (ASSOCNETWORK)
1002 CAST_DWG_OBJECT_TO_OBJECT (ASSOCNETWORKSURFACEACTIONBODY)
1003 CAST_DWG_OBJECT_TO_OBJECT (ASSOCOBJECTACTIONPARAM)
1004 CAST_DWG_OBJECT_TO_OBJECT (ASSOCOFFSETSURFACEACTIONBODY)
1005 CAST_DWG_OBJECT_TO_OBJECT (ASSOCOSNAPPOINTREFACTIONPARAM)
1006 CAST_DWG_OBJECT_TO_OBJECT (ASSOCPATCHSURFACEACTIONBODY)
1007 CAST_DWG_OBJECT_TO_OBJECT (ASSOCPATHACTIONPARAM)
1008 CAST_DWG_OBJECT_TO_OBJECT (ASSOCPLANESURFACEACTIONBODY)
1009 CAST_DWG_OBJECT_TO_OBJECT (ASSOCPOINTREFACTIONPARAM)
1010 CAST_DWG_OBJECT_TO_OBJECT (ASSOCREVOLVEDSURFACEACTIONBODY)
1011 CAST_DWG_OBJECT_TO_OBJECT (ASSOCTRIMSURFACEACTIONBODY)
1012 CAST_DWG_OBJECT_TO_OBJECT (ASSOCVALUEDEPENDENCY)
1013 CAST_DWG_OBJECT_TO_OBJECT (ASSOCVARIABLE)
1014 CAST_DWG_OBJECT_TO_OBJECT (ASSOCVERTEXACTIONPARAM)
1015 CAST_DWG_OBJECT_TO_OBJECT (BLKREFOBJECTCONTEXTDATA)
1016 CAST_DWG_OBJECT_TO_OBJECT (BLOCKALIGNEDCONSTRAINTPARAMETER)
1017 CAST_DWG_OBJECT_TO_OBJECT (BLOCKANGULARCONSTRAINTPARAMETER)
1018 CAST_DWG_OBJECT_TO_OBJECT (BLOCKARRAYACTION)
1019 CAST_DWG_OBJECT_TO_OBJECT (BLOCKDIAMETRICCONSTRAINTPARAMETER)
1020 CAST_DWG_OBJECT_TO_OBJECT (BLOCKHORIZONTALCONSTRAINTPARAMETER)
1021 CAST_DWG_OBJECT_TO_OBJECT (BLOCKLINEARCONSTRAINTPARAMETER)
1022 CAST_DWG_OBJECT_TO_OBJECT (BLOCKLINEARPARAMETER)
1023 CAST_DWG_OBJECT_TO_OBJECT (BLOCKLOOKUPACTION)
1024 CAST_DWG_OBJECT_TO_OBJECT (BLOCKLOOKUPPARAMETER)
1025 CAST_DWG_OBJECT_TO_OBJECT (BLOCKPARAMDEPENDENCYBODY)
1026 CAST_DWG_OBJECT_TO_OBJECT (BLOCKPOINTPARAMETER)
1027 CAST_DWG_OBJECT_TO_OBJECT (BLOCKPOLARGRIP)
1028 CAST_DWG_OBJECT_TO_OBJECT (BLOCKPOLARPARAMETER)
1029 CAST_DWG_OBJECT_TO_OBJECT (BLOCKPOLARSTRETCHACTION)
1030 CAST_DWG_OBJECT_TO_OBJECT (BLOCKRADIALCONSTRAINTPARAMETER)
1031 CAST_DWG_OBJECT_TO_OBJECT (BLOCKREPRESENTATION)
1032 CAST_DWG_OBJECT_TO_OBJECT (BLOCKROTATIONPARAMETER)
1033 CAST_DWG_OBJECT_TO_OBJECT (BLOCKSTRETCHACTION)
1034 CAST_DWG_OBJECT_TO_OBJECT (BLOCKUSERPARAMETER)
1035 CAST_DWG_OBJECT_TO_OBJECT (BLOCKVERTICALCONSTRAINTPARAMETER)
1036 CAST_DWG_OBJECT_TO_OBJECT (BLOCKVISIBILITYPARAMETER)
1037 CAST_DWG_OBJECT_TO_OBJECT (BLOCKXYGRIP)
1038 CAST_DWG_OBJECT_TO_OBJECT (BLOCKXYPARAMETER)
1039 CAST_DWG_OBJECT_TO_OBJECT (DATALINK)
1040 CAST_DWG_OBJECT_TO_OBJECT (DBCOLOR)
1041 CAST_DWG_OBJECT_TO_OBJECT (EVALUATION_GRAPH)
1042 CAST_DWG_OBJECT_TO_OBJECT (FCFOBJECTCONTEXTDATA)
1043 CAST_DWG_OBJECT_TO_OBJECT (GRADIENT_BACKGROUND)
1044 CAST_DWG_OBJECT_TO_OBJECT (GROUND_PLANE_BACKGROUND)
1045 CAST_DWG_OBJECT_TO_OBJECT (IBL_BACKGROUND)
1046 CAST_DWG_OBJECT_TO_OBJECT (IMAGE_BACKGROUND)
1047 CAST_DWG_OBJECT_TO_OBJECT (LEADEROBJECTCONTEXTDATA)
1048 CAST_DWG_OBJECT_TO_OBJECT (LIGHTLIST)
1049 CAST_DWG_OBJECT_TO_OBJECT (MATERIAL)
1050 CAST_DWG_OBJECT_TO_OBJECT (MENTALRAYRENDERSETTINGS)
1051 CAST_DWG_OBJECT_TO_OBJECT (MTEXTOBJECTCONTEXTDATA)
1052 CAST_DWG_OBJECT_TO_OBJECT (OBJECT_PTR)
1053 CAST_DWG_OBJECT_TO_OBJECT (PARTIAL_VIEWING_INDEX)
1054 CAST_DWG_OBJECT_TO_OBJECT (POINTCLOUDCOLORMAP)
1055 CAST_DWG_OBJECT_TO_OBJECT (POINTCLOUDDEF)
1056 CAST_DWG_OBJECT_TO_OBJECT (POINTCLOUDDEFEX)
1057 CAST_DWG_OBJECT_TO_OBJECT (POINTCLOUDDEF_REACTOR)
1058 CAST_DWG_OBJECT_TO_OBJECT (POINTCLOUDDEF_REACTOR_EX)
1059 CAST_DWG_OBJECT_TO_OBJECT (PROXY_OBJECT)
1060 CAST_DWG_OBJECT_TO_OBJECT (RAPIDRTRENDERSETTINGS)
1061 CAST_DWG_OBJECT_TO_OBJECT (RENDERENTRY)
1062 CAST_DWG_OBJECT_TO_OBJECT (RENDERENVIRONMENT)
1063 CAST_DWG_OBJECT_TO_OBJECT (RENDERGLOBAL)
1064 CAST_DWG_OBJECT_TO_OBJECT (RENDERSETTINGS)
1065 CAST_DWG_OBJECT_TO_OBJECT (SECTION_SETTINGS)
1066 CAST_DWG_OBJECT_TO_OBJECT (SKYLIGHT_BACKGROUND)
1067 CAST_DWG_OBJECT_TO_OBJECT (SOLID_BACKGROUND)
1068 CAST_DWG_OBJECT_TO_OBJECT (SPATIAL_INDEX)
1069 CAST_DWG_OBJECT_TO_OBJECT (SUN)
1070 CAST_DWG_OBJECT_TO_OBJECT (TABLESTYLE)
1071 CAST_DWG_OBJECT_TO_OBJECT (TEXTOBJECTCONTEXTDATA)
1072 CAST_DWG_OBJECT_TO_OBJECT (ASSOCARRAYMODIFYPARAMETERS)
1073 CAST_DWG_OBJECT_TO_OBJECT (ASSOCARRAYPATHPARAMETERS)
1074 CAST_DWG_OBJECT_TO_OBJECT (ASSOCARRAYPOLARPARAMETERS)
1075 CAST_DWG_OBJECT_TO_OBJECT (ASSOCARRAYRECTANGULARPARAMETERS)
1076 #ifdef DEBUG_CLASSES
1077   CAST_DWG_OBJECT_TO_OBJECT (ACMECOMMANDHISTORY)
1078   CAST_DWG_OBJECT_TO_OBJECT (ACMESCOPE)
1079   CAST_DWG_OBJECT_TO_OBJECT (ACMESTATEMGR)
1080   CAST_DWG_OBJECT_TO_OBJECT (ACSH_EXTRUSION_CLASS)
1081   CAST_DWG_OBJECT_TO_OBJECT (ACSH_LOFT_CLASS)
1082   CAST_DWG_OBJECT_TO_OBJECT (ACSH_REVOLVE_CLASS)
1083   CAST_DWG_OBJECT_TO_OBJECT (ACSH_SWEEP_CLASS)
1084   CAST_DWG_OBJECT_TO_OBJECT (ANGDIMOBJECTCONTEXTDATA)
1085   CAST_DWG_OBJECT_TO_OBJECT (ANNOTSCALEOBJECTCONTEXTDATA)
1086   CAST_DWG_OBJECT_TO_OBJECT (ASSOC3POINTANGULARDIMACTIONBODY)
1087   CAST_DWG_OBJECT_TO_OBJECT (ASSOCALIGNEDDIMACTIONBODY)
1088   CAST_DWG_OBJECT_TO_OBJECT (ASSOCARRAYMODIFYACTIONBODY)
1089   CAST_DWG_OBJECT_TO_OBJECT (ASSOCEDGEACTIONPARAM)
1090   CAST_DWG_OBJECT_TO_OBJECT (ASSOCEDGECHAMFERACTIONBODY)
1091   CAST_DWG_OBJECT_TO_OBJECT (ASSOCEDGEFILLETACTIONBODY)
1092   CAST_DWG_OBJECT_TO_OBJECT (ASSOCMLEADERACTIONBODY)
1093   CAST_DWG_OBJECT_TO_OBJECT (ASSOCORDINATEDIMACTIONBODY)
1094   CAST_DWG_OBJECT_TO_OBJECT (ASSOCPERSSUBENTMANAGER)
1095   CAST_DWG_OBJECT_TO_OBJECT (ASSOCRESTOREENTITYSTATEACTIONBODY)
1096   CAST_DWG_OBJECT_TO_OBJECT (ASSOCROTATEDDIMACTIONBODY)
1097   CAST_DWG_OBJECT_TO_OBJECT (ASSOCSWEPTSURFACEACTIONBODY)
1098   CAST_DWG_OBJECT_TO_OBJECT (BLOCKPROPERTIESTABLE)
1099   CAST_DWG_OBJECT_TO_OBJECT (BLOCKPROPERTIESTABLEGRIP)
1100   CAST_DWG_OBJECT_TO_OBJECT (CONTEXTDATAMANAGER)
1101   CAST_DWG_OBJECT_TO_OBJECT (CSACDOCUMENTOPTIONS)
1102   CAST_DWG_OBJECT_TO_OBJECT (CURVEPATH)
1103   CAST_DWG_OBJECT_TO_OBJECT (DATATABLE)
1104   CAST_DWG_OBJECT_TO_OBJECT (DIMASSOC)
1105   CAST_DWG_OBJECT_TO_OBJECT (DMDIMOBJECTCONTEXTDATA)
1106   CAST_DWG_OBJECT_TO_OBJECT (DYNAMICBLOCKPROXYNODE)
1107   CAST_DWG_OBJECT_TO_OBJECT (GEOMAPIMAGE)
1108   CAST_DWG_OBJECT_TO_OBJECT (LAYOUTPRINTCONFIG)
1109   CAST_DWG_OBJECT_TO_OBJECT (MLEADEROBJECTCONTEXTDATA)
1110   CAST_DWG_OBJECT_TO_OBJECT (MOTIONPATH)
1111   CAST_DWG_OBJECT_TO_OBJECT (MTEXTATTRIBUTEOBJECTCONTEXTDATA)
1112   CAST_DWG_OBJECT_TO_OBJECT (NAVISWORKSMODELDEF)
1113   CAST_DWG_OBJECT_TO_OBJECT (ORDDIMOBJECTCONTEXTDATA)
1114   CAST_DWG_OBJECT_TO_OBJECT (PERSUBENTMGR)
1115   CAST_DWG_OBJECT_TO_OBJECT (POINTPATH)
1116   CAST_DWG_OBJECT_TO_OBJECT (RADIMLGOBJECTCONTEXTDATA)
1117   CAST_DWG_OBJECT_TO_OBJECT (RADIMOBJECTCONTEXTDATA)
1118   CAST_DWG_OBJECT_TO_OBJECT (SUNSTUDY)
1119   CAST_DWG_OBJECT_TO_OBJECT (TABLECONTENT)
1120   CAST_DWG_OBJECT_TO_OBJECT (TVDEVICEPROPERTIES)
1121   //CAST_DWG_OBJECT_TO_OBJECT (ACDSRECORD)
1122   //CAST_DWG_OBJECT_TO_OBJECT (ACDSSCHEMA)
1123   //CAST_DWG_OBJECT_TO_OBJECT (NPOCOLLECTION)
1124   //CAST_DWG_OBJECT_TO_OBJECT (RAPIDRTRENDERENVIRONMENT)
1125   //CAST_DWG_OBJECT_TO_OBJECT (XREFPANELOBJECT)
1126 #endif
1127 // clang-format: on
1128 /* End auto-generated content */
1129 
1130 /*******************************************************************
1131  *                FUNCTIONS START HERE ENTITY SPECIFIC               *
1132  ********************************************************************/
1133 
1134 #ifdef USE_DEPRECATED_API
1135 
1136 /** not thread safe. Deprecated.
1137  *  TODO: replace with walking parents up to the dwg.
1138  * \deprecated
1139  */
1140 void
1141 dwg_api_init_version (Dwg_Data *dwg)
1142 {
1143   dwg_version = (Dwg_Version_Type)dwg->header.version;
1144   loglevel = dwg->opts & DWG_OPTS_LOGLEVEL;
1145 }
1146 
1147 #endif
1148 
1149 /** To access the common DIMENSION fields (only).
1150  *  There is no generic call dwg_get_DIMENSION, for this you have to
1151  *  specify the exact DIMENSION_* type.
1152  */
1153 dwg_ent_dim *
dwg_object_to_DIMENSION(dwg_object * obj)1154 dwg_object_to_DIMENSION (dwg_object *obj)
1155 {
1156   dwg_ent_dim *ret_obj = NULL;
1157   if (obj != NULL
1158       && (obj->type == DWG_TYPE_DIMENSION_ORDINATE
1159           || obj->type == DWG_TYPE_DIMENSION_LINEAR
1160           || obj->type == DWG_TYPE_DIMENSION_ALIGNED
1161           || obj->type == DWG_TYPE_DIMENSION_ANG3PT
1162           || obj->type == DWG_TYPE_DIMENSION_ANG2LN
1163           || obj->type == DWG_TYPE_DIMENSION_RADIUS
1164           || obj->type == DWG_TYPE_DIMENSION_DIAMETER
1165           || obj->fixedtype == DWG_TYPE_ARC_DIMENSION))
1166     {
1167       ret_obj = obj->tio.entity->tio.DIMENSION_common;
1168     }
1169   else
1170     {
1171       unsigned int type = obj ? obj->type : 0;
1172       LOG_ERROR ("invalid %s type: got %u/0x%x", "DIMENSION", type, type);
1173     }
1174   return (dwg_ent_dim *)ret_obj;
1175 }
1176 
1177 /********************************************************************
1178  *                    DYNAPI FUNCTIONS                              *
1179  ********************************************************************/
1180 
1181 EXPORT bool
dwg_get_HEADER(const Dwg_Data * restrict dwg,const char * restrict fieldname,void * restrict out)1182 dwg_get_HEADER (const Dwg_Data *restrict dwg, const char *restrict fieldname,
1183                 void *restrict out)
1184 {
1185 #ifndef HAVE_NONNULL
1186   if (dwg && fieldname && out)
1187 #endif
1188     return dwg_dynapi_header_value (dwg, fieldname, out, NULL);
1189 #ifndef HAVE_NONNULL
1190   else
1191     return false;
1192 #endif
1193 }
1194 
1195 EXPORT bool
dwg_get_HEADER_utf8text(const Dwg_Data * restrict dwg,const char * restrict fieldname,char ** restrict textp,int * isnewp)1196 dwg_get_HEADER_utf8text (const Dwg_Data *restrict dwg,
1197                          const char *restrict fieldname, char **restrict textp, int *isnewp)
1198 {
1199 #ifndef HAVE_NONNULL
1200   if (dwg && fieldname && out)
1201 #endif
1202     return dwg_dynapi_header_utf8text (dwg, fieldname, textp, isnewp, NULL);
1203 #ifndef HAVE_NONNULL
1204   else
1205     return false;
1206 #endif
1207 }
1208 
1209 EXPORT bool
dwg_set_HEADER(Dwg_Data * restrict dwg,const char * restrict fieldname,const void * restrict value)1210 dwg_set_HEADER (Dwg_Data *restrict dwg, const char *restrict fieldname,
1211                 const void *restrict value)
1212 {
1213 #ifndef HAVE_NONNULL
1214   if (dwg && fieldname && value)
1215 #endif
1216     return dwg_dynapi_header_set_value (dwg, fieldname, value, 0);
1217 #ifndef HAVE_NONNULL
1218   else
1219     return false;
1220 #endif
1221 }
1222 
1223 EXPORT bool
dwg_set_HEADER_utf8text(Dwg_Data * restrict dwg,const char * restrict fieldname,const char * restrict utf8)1224 dwg_set_HEADER_utf8text (Dwg_Data *restrict dwg,
1225                          const char *restrict fieldname,
1226                          const char *restrict utf8)
1227 {
1228 #ifndef HAVE_NONNULL
1229   if (dwg && fieldname && utf8)
1230 #endif
1231     return dwg_dynapi_header_set_value (dwg, fieldname, utf8, 0);
1232 #ifndef HAVE_NONNULL
1233   else
1234     return false;
1235 #endif
1236 }
1237 
1238 EXPORT bool
dwg_get_ENTITY_common(Dwg_Object_Entity * restrict obj,const char * restrict fieldname,void * restrict out)1239 dwg_get_ENTITY_common (Dwg_Object_Entity *restrict obj,
1240                        const char *restrict fieldname, void *restrict out)
1241 {
1242 #ifndef HAVE_NONNULL
1243   if (obj && fieldname && out)
1244 #endif
1245     return dwg_dynapi_common_value (obj, fieldname, out, NULL);
1246 #ifndef HAVE_NONNULL
1247   else
1248     return false;
1249 #endif
1250 }
1251 
1252 EXPORT bool
dwg_set_ENTITY_common(Dwg_Object_Entity * restrict obj,const char * restrict fieldname,const void * restrict value)1253 dwg_set_ENTITY_common (Dwg_Object_Entity *restrict obj,
1254                        const char *restrict fieldname,
1255                        const void *restrict value)
1256 {
1257 #ifndef HAVE_NONNULL
1258   if (obj && fieldname && value)
1259 #endif
1260     return dwg_dynapi_common_set_value (obj, fieldname, value, 0);
1261 #ifndef HAVE_NONNULL
1262   else
1263     return false;
1264 #endif
1265 }
1266 
1267 EXPORT bool
dwg_get_OBJECT_common(Dwg_Object_Object * restrict obj,const char * restrict fieldname,void * restrict out)1268 dwg_get_OBJECT_common (Dwg_Object_Object *restrict obj,
1269                        const char *restrict fieldname, void *restrict out)
1270 {
1271 #ifndef HAVE_NONNULL
1272   if (obj && fieldname && out)
1273 #endif
1274     return dwg_dynapi_common_value (obj, fieldname, out, NULL);
1275 #ifndef HAVE_NONNULL
1276   else
1277     return false;
1278 #endif
1279 }
1280 
1281 EXPORT bool
dwg_set_OBJECT_common(Dwg_Object_Object * restrict obj,const char * restrict fieldname,const void * restrict value)1282 dwg_set_OBJECT_common (Dwg_Object_Object *restrict obj,
1283                        const char *restrict fieldname,
1284                        const void *restrict value)
1285 {
1286 #ifndef HAVE_NONNULL
1287   if (obj && fieldname && value)
1288 #endif
1289     return dwg_dynapi_common_set_value (obj, fieldname, value, 0);
1290 #ifndef HAVE_NONNULL
1291   else
1292     return false;
1293 #endif
1294 }
1295 
1296 EXPORT bool
dwg_get_ENTITY_common_utf8text(Dwg_Object_Entity * restrict obj,const char * restrict fieldname,char ** restrict textp,int * isnewp)1297 dwg_get_ENTITY_common_utf8text (Dwg_Object_Entity *restrict obj,
1298                                 const char *restrict fieldname,
1299                                 char **restrict textp, int *isnewp)
1300 {
1301 #ifndef HAVE_NONNULL
1302   if (obj && fieldname && textp)
1303 #endif
1304     return dwg_dynapi_common_utf8text (obj, fieldname, textp, isnewp, NULL);
1305 #ifndef HAVE_NONNULL
1306   else
1307     return false;
1308 #endif
1309 }
1310 
1311 EXPORT bool
dwg_set_ENTITY_common_utf8text(Dwg_Object_Entity * restrict obj,const char * restrict fieldname,const char * restrict utf8)1312 dwg_set_ENTITY_common_utf8text (Dwg_Object_Entity *restrict obj,
1313                                 const char *restrict fieldname,
1314                                 const char *restrict utf8)
1315 {
1316 #ifndef HAVE_NONNULL
1317   if (obj && fieldname && utf8)
1318 #endif
1319     return dwg_dynapi_common_set_value (obj, fieldname, utf8, 0);
1320 #ifndef HAVE_NONNULL
1321   else
1322     return false;
1323 #endif
1324 }
1325 
1326 EXPORT bool
dwg_get_OBJECT_common_utf8text(Dwg_Object_Object * restrict obj,const char * restrict fieldname,char ** restrict textp,int * isnewp)1327 dwg_get_OBJECT_common_utf8text (Dwg_Object_Object *restrict obj,
1328                                 const char *restrict fieldname,
1329                                 char **restrict textp, int *isnewp)
1330 {
1331 #ifndef HAVE_NONNULL
1332   if (obj && fieldname && textp)
1333 #endif
1334     return dwg_dynapi_common_utf8text (obj, fieldname, textp, isnewp, NULL);
1335 #ifndef HAVE_NONNULL
1336   else
1337     return false;
1338 #endif
1339 }
1340 
1341 EXPORT bool
dwg_set_OBJECT_common_utf8text(Dwg_Object_Object * restrict obj,const char * restrict fieldname,const char * restrict utf8)1342 dwg_set_OBJECT_common_utf8text (Dwg_Object_Object *restrict obj,
1343                                 const char *restrict fieldname,
1344                                 const char *restrict utf8)
1345 {
1346 #ifndef HAVE_NONNULL
1347   if (obj && fieldname && utf8)
1348 #endif
1349     return dwg_dynapi_common_set_value (obj, fieldname, utf8, 1);
1350 #ifndef HAVE_NONNULL
1351   else
1352     return false;
1353 #endif
1354 }
1355 
1356 /********************************************************************
1357  *                FUNCTIONS TYPE SPECIFIC                            *
1358  *********************************************************************/
1359 
1360 /* Should we accept dwg and entities? or add dwg_header_get_TYPE */
dwg_ent_get_POINT2D(const void * restrict _obj,const char * restrict fieldname)1361 EXPORT dwg_point_2d *dwg_ent_get_POINT2D (const void *restrict _obj,
1362                                           const char *restrict fieldname)
1363 {
1364 #  ifndef HAVE_NONNULL
1365   if (!_obj || !fieldname)
1366     return NULL;
1367 #  endif
1368   {
1369     dwg_point_2d *point;
1370     Dwg_DYNAPI_field field = {0};
1371     int error;
1372     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (_obj, &error);
1373     if (!obj || !obj->name)
1374       return NULL;
1375 
1376     point = (dwg_point_2d *)calloc (1, sizeof (dwg_point_2d));
1377     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &point,
1378                                   &field))
1379       {
1380         free (point);
1381         return NULL;
1382       }
1383     if (strEQc (field.type, "2RD") || strEQc (field.type, "2BD")
1384         || strEQc (field.type, "2DPOINT"))
1385       {
1386         return point;
1387       }
1388     else
1389       {
1390         free (point);
1391         LOG_ERROR (
1392             "%s.%s has type %s, which is not a POINT2D (2RD,2BD,2DPOINT)",
1393             obj->name, fieldname, field.type)
1394         return NULL;
1395       }
1396   }
1397 }
1398 
1399 EXPORT bool
dwg_ent_set_POINT2D(void * restrict _obj,const char * restrict fieldname,const dwg_point_2d * point)1400 dwg_ent_set_POINT2D (void *restrict _obj, const char *restrict fieldname,
1401                      const dwg_point_2d *point)
1402 {
1403 #  ifndef HAVE_NONNULL
1404   if (!_obj || !fieldname || !point)
1405     return false;
1406 #  endif
1407   {
1408     dwg_point_2d dummy;
1409     Dwg_DYNAPI_field field = {0};
1410     int error;
1411     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1412         _obj, &error);
1413     if (!obj || !obj->name)
1414       return false;
1415 
1416     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1417                                   &field))
1418       {
1419         return false;
1420       }
1421     if (strEQc (field.type, "2RD") || strEQc (field.type, "2BD")
1422         || strEQc (field.type, "2DPOINT"))
1423       {
1424         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1425                                             point, 0);
1426       }
1427     else
1428       {
1429         LOG_ERROR (
1430             "%s.%s has type %s, which is not a POINT2D (2RD,2BD,2DPOINT)",
1431             obj->name, fieldname, field.type)
1432         return false;
1433       }
1434   }
1435 }
1436 
1437 EXPORT dwg_point_3d *
dwg_ent_get_POINT3D(const void * restrict _obj,const char * restrict fieldname)1438 dwg_ent_get_POINT3D (const void *restrict _obj, const char *restrict fieldname)
1439 {
1440 #  ifndef HAVE_NONNULL
1441   if (!_obj || !fieldname)
1442     return NULL;
1443 #  endif
1444   {
1445     dwg_point_3d *point;
1446     Dwg_DYNAPI_field field = {0};
1447     int error;
1448     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1449         _obj, &error);
1450     if (!obj || !obj->name)
1451       return NULL;
1452 
1453     point = (dwg_point_3d *)calloc (1, sizeof (dwg_point_3d));
1454     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &point,
1455                                   &field))
1456       {
1457         free (point);
1458         return NULL;
1459       }
1460     if (strEQc (field.type, "3RD") || strEQc (field.type, "3BD")
1461         || strEQc (field.type, "BE") || strEQc (field.type, "3DPOINT"))
1462       {
1463         return point;
1464       }
1465     else
1466       {
1467         free (point);
1468         LOG_ERROR (
1469             "%s.%s has type %s, which is not a POINT3D (3RD,3BD,BE,3DPOINT)",
1470             obj->name, fieldname, field.type)
1471         return NULL;
1472       }
1473   }
1474 }
1475 
1476 EXPORT bool
dwg_ent_set_POINT3D(void * restrict _obj,const char * restrict fieldname,const dwg_point_3d * point)1477 dwg_ent_set_POINT3D (void *restrict _obj, const char *restrict fieldname,
1478                      const dwg_point_3d *point)
1479 {
1480 #  ifndef HAVE_NONNULL
1481   if (!_obj || !fieldname || !point)
1482     return NULL;
1483 #  endif
1484   {
1485     dwg_point_3d dummy;
1486     Dwg_DYNAPI_field field = {0};
1487     int error;
1488     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1489         _obj, &error);
1490     if (!obj || !obj->name)
1491       return false;
1492 
1493     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1494                                   &field))
1495       return false;
1496     if (strEQc (field.type, "3RD") || strEQc (field.type, "3BD")
1497         || strEQc (field.type, "BE") || strEQc (field.type, "3DPOINT"))
1498       {
1499         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1500                                             point, 0);
1501       }
1502     else
1503       {
1504         LOG_ERROR (
1505             "%s.%s has type %s, which is not a POINT3D (3RD,3BD,BE,3DPOINT)",
1506             obj->name, fieldname, field.type)
1507         return false;
1508       }
1509   }
1510 }
1511 
1512 EXPORT char *
dwg_ent_get_STRING(const void * restrict _obj,const char * restrict fieldname)1513 dwg_ent_get_STRING (const void *restrict _obj, const char *restrict fieldname)
1514 {
1515 #  ifndef HAVE_NONNULL
1516   if (!_obj || !fieldname)
1517     return NULL;
1518 #  endif
1519   {
1520     char *str;
1521     Dwg_DYNAPI_field field = {0};
1522     int error;
1523     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1524         _obj, &error);
1525     if (!obj || !obj->name)
1526       return NULL;
1527 
1528     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &str,
1529                                   &field))
1530       return NULL;
1531     if (field.is_string || strEQc (field.type, "TF"))
1532       {
1533         return str;
1534       }
1535     else
1536       {
1537         LOG_ERROR ("%s.%s has type %s, which is not a STRING (T,TV,TU,TF)",
1538                    obj->name, fieldname, field.type)
1539         return NULL;
1540       }
1541   }
1542 }
1543 
1544 // convert string to UTF-8
1545 EXPORT char *
dwg_ent_get_UTF8(const void * restrict _obj,const char * restrict fieldname,int * isnewp)1546 dwg_ent_get_UTF8 (const void *restrict _obj, const char *restrict fieldname, int *isnewp)
1547 {
1548   if (isnewp)
1549     *isnewp = 0;
1550 #  ifndef HAVE_NONNULL
1551   if (!_obj || !fieldname)
1552     return NULL;
1553 #  endif
1554   {
1555     char *str;
1556     Dwg_DYNAPI_field field = {0};
1557     int error;
1558     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1559         _obj, &error);
1560     if (!obj || !obj->name)
1561       return NULL;
1562 
1563     if (!dwg_dynapi_entity_utf8text ((void *)_obj, obj->name, fieldname, &str,
1564                                      isnewp, &field))
1565       return NULL;
1566     if (field.is_string || strEQc (field.type, "TF"))
1567       {
1568         return str;
1569       }
1570     else
1571       {
1572         LOG_ERROR ("%s.%s has type %s, which is not a STRING (T,TV,TU,TF)",
1573                    obj->name, fieldname, field.type)
1574         return NULL;
1575       }
1576   }
1577 }
1578 
1579 EXPORT bool
dwg_ent_set_STRING(void * restrict _obj,const char * restrict fieldname,const char * restrict str)1580 dwg_ent_set_STRING (void *restrict _obj, const char *restrict fieldname,
1581                     const char *restrict str)
1582 {
1583 #  ifndef HAVE_NONNULL
1584   if (!_obj || !fieldname || !str)
1585     return false;
1586 #  endif
1587   {
1588     char *dummy;
1589     Dwg_DYNAPI_field field = {0};
1590     int error;
1591     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1592         _obj, &error);
1593     if (!obj || !obj->name)
1594       return false;
1595 
1596     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1597                                   &field))
1598       return false;
1599     if (field.is_string || strEQc (field.type, "TF"))
1600       {
1601         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1602                                             str, 0);
1603       }
1604     else
1605       {
1606         LOG_ERROR ("%s.%s has type %s, which is not a STRING (T,TV,TU,TF)",
1607                    obj->name, fieldname, field.type)
1608         return false;
1609       }
1610   }
1611 }
1612 
1613 EXPORT bool
dwg_ent_set_UTF8(void * restrict _obj,const char * restrict fieldname,const char * restrict utf8text)1614 dwg_ent_set_UTF8 (void *restrict _obj, const char *restrict fieldname,
1615                   const char *restrict utf8text)
1616 {
1617 #  ifndef HAVE_NONNULL
1618   if (!_obj || !fieldname || !utf8text)
1619     return false;
1620 #  endif
1621   {
1622     char *dummy;
1623     Dwg_DYNAPI_field field = {0};
1624     int error;
1625     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1626         _obj, &error);
1627     if (!obj || !obj->name)
1628       return false;
1629 
1630     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1631                                   &field))
1632       return false;
1633     if (field.is_string || strEQc (field.type, "TF"))
1634       {
1635         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1636                                             utf8text, 1);
1637       }
1638     else
1639       {
1640         LOG_ERROR ("%s.%s has type %s, which is not a STRING (T,TV,TU,TF)",
1641                    obj->name, fieldname, field.type)
1642         return false;
1643       }
1644   }
1645 }
1646 
1647 EXPORT BITCODE_BD
dwg_ent_get_REAL(const void * restrict _obj,const char * restrict fieldname)1648 dwg_ent_get_REAL (const void *restrict _obj, const char *restrict fieldname)
1649 {
1650 #  ifndef HAVE_NONNULL
1651   if (!_obj || !fieldname)
1652     return 0.0;
1653 #  endif
1654   {
1655     BITCODE_BD num;
1656     Dwg_DYNAPI_field field = {0};
1657     int error;
1658     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1659         _obj, &error);
1660     if (!obj || !obj->name)
1661       return 0.0;
1662 
1663     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &num,
1664                                   &field))
1665       return 0.0;
1666     if (strEQc (field.type, "RD") || strEQc (field.type, "BD"))
1667       {
1668         return num;
1669       }
1670     else
1671       {
1672         LOG_ERROR ("%s.%s has type %s, which is not a REAL (RD,BD)", fieldname,
1673                    obj->name, field.type)
1674         return 0.0;
1675       }
1676   }
1677 }
1678 
1679 EXPORT bool
dwg_ent_set_REAL(void * restrict _obj,const char * restrict fieldname,const BITCODE_BD num)1680 dwg_ent_set_REAL (void *restrict _obj, const char *restrict fieldname,
1681                   const BITCODE_BD num)
1682 {
1683 #  ifndef HAVE_NONNULL
1684   if (!_obj || !fieldname)
1685     return false;
1686 #  endif
1687   {
1688     BITCODE_BD dummy;
1689     Dwg_DYNAPI_field field = {0};
1690     int error;
1691     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1692         _obj, &error);
1693     if (!obj || !obj->name)
1694       return false;
1695     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1696                                   &field))
1697       return false;
1698     if (strEQc (field.type, "RD") || strEQc (field.type, "BD"))
1699       {
1700         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1701                                             &num, 0);
1702       }
1703     else
1704       {
1705         LOG_ERROR ("%s.%s has type %s, which is not a REAL (RD,BD)", fieldname,
1706                    obj->name, field.type)
1707         return false;
1708       }
1709   }
1710 }
1711 
1712 EXPORT BITCODE_BS
dwg_ent_get_INT16(const void * restrict _obj,const char * restrict fieldname)1713 dwg_ent_get_INT16 (const void *restrict _obj, const char *restrict fieldname)
1714 {
1715 #  ifndef HAVE_NONNULL
1716   if (!_obj || !fieldname)
1717     return 0;
1718 #  endif
1719   {
1720     BITCODE_BS num;
1721     Dwg_DYNAPI_field field = {0};
1722     int error;
1723     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1724         _obj, &error);
1725     if (!obj || !obj->name)
1726       return 0;
1727 
1728     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &num,
1729                                   &field))
1730       return 0;
1731     if (strEQc (field.type, "RS") || strEQc (field.type, "BS"))
1732       {
1733         return num;
1734       }
1735     else
1736       {
1737         LOG_ERROR ("%s.%s has type %s, which is not a INT16 (RS,BS)",
1738                    obj->name, fieldname, field.type)
1739         return 0;
1740       }
1741   }
1742 }
1743 
1744 EXPORT bool
dwg_ent_set_INT16(void * restrict _obj,const char * restrict fieldname,const BITCODE_BS num)1745 dwg_ent_set_INT16 (void *restrict _obj, const char *restrict fieldname,
1746                    const BITCODE_BS num)
1747 {
1748 #  ifndef HAVE_NONNULL
1749   if (!_obj || !fieldname)
1750     return false;
1751 #  endif
1752   {
1753     BITCODE_BS dummy;
1754     Dwg_DYNAPI_field field = {0};
1755     int error;
1756     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1757         _obj, &error);
1758     if (!obj || !obj->name)
1759       return false;
1760 
1761     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1762                                   &field))
1763       return false;
1764     if (strEQc (field.type, "RS") || strEQc (field.type, "BS"))
1765       {
1766         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1767                                             &num, 0);
1768       }
1769     else
1770       {
1771         LOG_ERROR ("%s.%s has type %s, which is not a INT16 (RS,BS)",
1772                    obj->name, fieldname, field.type)
1773         return false;
1774       }
1775   }
1776 }
1777 
1778 EXPORT BITCODE_BL
dwg_ent_get_INT32(const void * restrict _obj,const char * restrict fieldname)1779 dwg_ent_get_INT32 (const void *restrict _obj, const char *restrict fieldname)
1780 {
1781 #  ifndef HAVE_NONNULL
1782   if (!_obj || !fieldname)
1783     return 0;
1784 #  endif
1785   {
1786     BITCODE_BL num;
1787     Dwg_DYNAPI_field field = {0};
1788     int error;
1789     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1790         _obj, &error);
1791     if (!obj || !obj->name)
1792       return 0;
1793 
1794     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &num,
1795                                   &field))
1796       return 0;
1797     if (strEQc (field.type, "RL") || strEQc (field.type, "BL")
1798         || strEQc (field.type, "MS"))
1799       {
1800         return num;
1801       }
1802     else
1803       {
1804         LOG_ERROR ("%s.%s has type %s, which is not a INT32 (RL,BL,MS)",
1805                    obj->name, fieldname, field.type)
1806         return 0;
1807       }
1808   }
1809 }
1810 
1811 EXPORT bool
dwg_ent_set_INT32(void * restrict _obj,const char * restrict fieldname,const BITCODE_BL num)1812 dwg_ent_set_INT32 (void *restrict _obj, const char *restrict fieldname,
1813                    const BITCODE_BL num)
1814 {
1815 #  ifndef HAVE_NONNULL
1816   if (!_obj || !fieldname)
1817     return false;
1818 #  endif
1819   {
1820     BITCODE_BL dummy;
1821     Dwg_DYNAPI_field field = {0};
1822     int error;
1823     const Dwg_Object *obj = (const Dwg_Object *)dwg_obj_generic_to_object (
1824         _obj, &error);
1825     if (!obj || !obj->name)
1826       return false;
1827 
1828     if (!dwg_dynapi_entity_value ((void *)_obj, obj->name, fieldname, &dummy,
1829                                   &field))
1830       return false;
1831     if (strEQc (field.type, "RL") || strEQc (field.type, "BL")
1832         || strEQc (field.type, "MS"))
1833       {
1834         return dwg_dynapi_entity_set_value ((void *)_obj, obj->name, fieldname,
1835                                             &num, 0);
1836       }
1837     else
1838       {
1839         LOG_ERROR ("%s.%s has type %s, which is not a INT32 (RL,BL,MS)",
1840                    obj->name, fieldname, field.type)
1841         return false;
1842       }
1843   }
1844 }
1845 
1846 #ifdef USE_DEPRECATED_API
1847 
1848 /*******************************************************************
1849  *                    FUNCTIONS FOR CIRCLE ENTITY                    *
1850  ********************************************************************/
1851 
1852 /** Returns the _dwg_entity_CIRCLE::center, DXF 10.
1853 \code Usage: dwg_ent_circle_get_center(circle, &point, &error);
1854 \encode
1855 \param[in]  circle  dwg_ent_circle*
1856 \param[out] point   dwg_point_3d*
1857 \param[out] error   int*, is set to 0 for ok, 1 on error
1858 \deprecated
1859 */
1860 void
dwg_ent_circle_get_center(const dwg_ent_circle * restrict circle,dwg_point_3d * restrict point,int * restrict error)1861 dwg_ent_circle_get_center (const dwg_ent_circle *restrict circle,
1862                            dwg_point_3d *restrict point, int *restrict error)
1863 {
1864   if (circle
1865 #  ifndef HAVE_NONNULL
1866       && point
1867 #  endif
1868   )
1869     {
1870       *error = 0;
1871       point->x = circle->center.x;
1872       point->y = circle->center.y;
1873       point->z = circle->center.z;
1874     }
1875   else
1876     {
1877       LOG_ERROR ("%s: empty point or circle", __FUNCTION__)
1878       *error = 1;
1879     }
1880 }
1881 
1882 /** Sets the _dwg_entity_CIRCLE::center, DXF 10.
1883 \code Usage: dwg_ent_circle_set_center(circle, &point, &error);
1884 \endcode
1885 \param[in,out] circle dwg_ent_circle*
1886 \param[in]     point  dwg_point_3d*
1887 \param[out]    error  set to 0 for ok, 1 on error
1888 \deprecated
1889 */
1890 void
dwg_ent_circle_set_center(dwg_ent_circle * restrict circle,const dwg_point_3d * restrict point,int * restrict error)1891 dwg_ent_circle_set_center (dwg_ent_circle *restrict circle,
1892                            const dwg_point_3d *restrict point,
1893                            int *restrict error)
1894 {
1895   if (circle
1896 #  ifndef HAVE_NONNULL
1897       && point
1898 #  endif
1899       && dwg_dynapi_entity_set_value (circle, "CIRCLE", "center", point, 0))
1900     *error = 0;
1901   else
1902     {
1903       LOG_ERROR ("%s: empty point or circle", __FUNCTION__)
1904       *error = 1;
1905     }
1906 }
1907 
1908 /** Returns the _dwg_entity_CIRCLE::radius, DXF 40.
1909 \code Usage: double radius = dwg_ent_circle_get_radius(circle, &error);
1910 \endcode
1911 \param[in]  circle  dwg_ent_circle*
1912 \param[out] error   int*, on gcc<3.3 is set to 0 for ok, 1 on error
1913 \deprecated
1914 */
1915 double
dwg_ent_circle_get_radius(const dwg_ent_circle * restrict circle,int * restrict error)1916 dwg_ent_circle_get_radius (const dwg_ent_circle *restrict circle,
1917                            int *restrict error)
1918 {
1919   if (circle)
1920     {
1921       *error = 0;
1922       return circle->radius;
1923     }
1924   else
1925     {
1926       LOG_ERROR ("%s: empty circle", __FUNCTION__)
1927       *error = 1;
1928       return bit_nan ();
1929     }
1930 }
1931 
1932 /** Sets the _dwg_entity_CIRCLE::radius, DXF 40.
1933 \code Usage: dwg_ent_circle_set_radius(circle, radius, &error);
1934 \endcode
1935 \param[in,out] circle  dwg_ent_circle*
1936 \param[in]     radius  double
1937 \param[out]    error   int*, on gcc<3.3 is set to 0 for ok, 1 on error
1938 \deprecated
1939 */
1940 void
dwg_ent_circle_set_radius(dwg_ent_circle * restrict circle,const double radius,int * restrict error)1941 dwg_ent_circle_set_radius (dwg_ent_circle *restrict circle,
1942                            const double radius, int *restrict error)
1943 {
1944   if (circle
1945       && dwg_dynapi_entity_set_value ((void *)circle, "CIRCLE", "radius",
1946                                       &radius, 0))
1947     {
1948       *error = 0;
1949     }
1950   else
1951     {
1952       LOG_ERROR ("%s: empty circle", __FUNCTION__)
1953       *error = 1;
1954     }
1955 }
1956 
1957 /** Returns the_dwg_entity_CIRCLE::thickness, DXF 39 (the cylinder height)
1958 \code Usage: double thickness = dwg_ent_circle_get_thickness(circle, &error);
1959 \endcode
1960 \param[in]  circle  dwg_ent_circle*
1961 \param[out] error   int*, is set to 0 for ok, 1 on error
1962 \deprecated
1963 */
1964 double
dwg_ent_circle_get_thickness(const dwg_ent_circle * restrict circle,int * restrict error)1965 dwg_ent_circle_get_thickness (const dwg_ent_circle *restrict circle,
1966                               int *restrict error)
1967 {
1968   if (circle)
1969     {
1970       *error = 0;
1971       return circle->thickness;
1972     }
1973   else
1974     {
1975       LOG_ERROR ("%s: empty circle", __FUNCTION__)
1976       *error = 1;
1977       return bit_nan ();
1978     }
1979 }
1980 
1981 /** Sets the_dwg_entity_CIRCLE::thickness, DXF 39 (the cylinder height)
1982 \code Usage: dwg_ent_circle_set_thickness(circle, thickness, &error);
1983 \endcode
1984 \param[in,out] circle dwg_ent_circle*
1985 \param[in]  thickness double
1986 \param[out] error     int*, set to 0 for ok, 1 on error
1987 \deprecated
1988 */
1989 void
dwg_ent_circle_set_thickness(dwg_ent_circle * restrict circle,const double thickness,int * restrict error)1990 dwg_ent_circle_set_thickness (dwg_ent_circle *restrict circle,
1991                               const double thickness, int *restrict error)
1992 {
1993   if (circle)
1994     {
1995       *error = 0;
1996       circle->thickness = thickness;
1997     }
1998   else
1999     {
2000       LOG_ERROR ("%s: empty circle", __FUNCTION__)
2001       *error = 1;
2002     }
2003 }
2004 
2005 /** Sets the_dwg_entity_CIRCLE::extrusion vector, DXF 210
2006 \code Usage: dwg_ent_circle_set_extrusion(circle, &vector, &error);
2007 \endcode
2008 \param[in,out] circle dwg_ent_circle*
2009 \param[out] vector  dwg_point_3d*
2010 \param[out] error   int*, set to 0 for ok, 1 on error
2011 \deprecated
2012 */
2013 void
dwg_ent_circle_set_extrusion(dwg_ent_circle * restrict circle,const dwg_point_3d * restrict vector,int * restrict error)2014 dwg_ent_circle_set_extrusion (dwg_ent_circle *restrict circle,
2015                               const dwg_point_3d *restrict vector,
2016                               int *restrict error)
2017 {
2018   if (circle
2019 #  ifndef HAVE_NONNULL
2020       && vector
2021 #  endif
2022       && dwg_dynapi_entity_set_value ((void *)circle, "CIRCLE", "extrusion",
2023                                       vector, 0))
2024     {
2025       *error = 0;
2026     }
2027   else
2028     {
2029       LOG_ERROR ("%s: empty vector or circle", __FUNCTION__)
2030       *error = 1;
2031     }
2032 }
2033 
2034 /** Returns the _dwg_entity_CIRCLE::extrusion vector, DXF 210
2035 \code Usage: dwg_ent_circle_get_extrusion(circle, &point, &error);
2036 \endcode
2037 \param[in]  circle dwg_ent_circle*
2038 \param[out] vector dwg_point_3d*
2039 \param[out] error  int*, is set to 0 for ok, 1 on error
2040 */
2041 void
dwg_ent_circle_get_extrusion(const dwg_ent_circle * restrict circle,dwg_point_3d * restrict vector,int * restrict error)2042 dwg_ent_circle_get_extrusion (const dwg_ent_circle *restrict circle,
2043                               dwg_point_3d *restrict vector,
2044                               int *restrict error)
2045 {
2046   if (circle
2047 #  ifndef HAVE_NONNULL
2048       && vector
2049 #  endif
2050       && dwg_dynapi_entity_value ((void *)circle, "CIRCLE", "extrusion",
2051                                   vector, NULL))
2052     {
2053       *error = 0;
2054     }
2055   else
2056     {
2057       LOG_ERROR ("%s: empty vector or circle", __FUNCTION__)
2058       *error = 1;
2059     }
2060 }
2061 
2062 /*******************************************************************
2063  *                    FUNCTIONS FOR LINE ENTITY                      *
2064  ********************************************************************/
2065 
2066 /** Returns the _dwg_entity_LINE::start point, DXF 10.
2067 \code Usage: dwg_ent_line_get_start_point(line, &point, &error);
2068 \endcode
2069 \param[in]  line    dwg_ent_line*
2070 \param[out] point   dwg_point_2d*
2071 \param[out] error   int*, is set to 0 for ok, 1 on error
2072 \deprecated
2073 */
2074 void
dwg_ent_line_get_start_point(const dwg_ent_line * restrict line,dwg_point_3d * restrict point,int * restrict error)2075 dwg_ent_line_get_start_point (const dwg_ent_line *restrict line,
2076                               dwg_point_3d *restrict point,
2077                               int *restrict error)
2078 {
2079   if (line
2080 #  ifndef HAVE_NONNULL
2081       && point
2082 #  endif
2083       && dwg_dynapi_entity_value ((void *)line, "LINE", "start", point, NULL))
2084     {
2085       *error = 0;
2086     }
2087   else
2088     {
2089       LOG_ERROR ("%s: empty line", __FUNCTION__)
2090       *error = 1;
2091     }
2092 }
2093 
2094 /** Sets the _dwg_entity_LINE::start point, DXF 10.
2095 \code Usage: dwg_ent_line_set_start_point(line, point, &error);
2096 \endcode
2097 \param[in,out] line dwg_ent_line*
2098 \param[out] point   dwg_point_2d*
2099 \param[out] error   int*, is set to 0 for ok, 1 on error
2100 \deprecated
2101 */
2102 void
dwg_ent_line_set_start_point(dwg_ent_line * restrict line,const dwg_point_3d * restrict point,int * restrict error)2103 dwg_ent_line_set_start_point (dwg_ent_line *restrict line,
2104                               const dwg_point_3d *restrict point,
2105                               int *restrict error)
2106 {
2107   if (line
2108 #  ifndef HAVE_NONNULL
2109       && point
2110 #  endif
2111       && dwg_dynapi_entity_set_value ((void *)line, "LINE", "start", point, 0))
2112     {
2113       *error = 0;
2114     }
2115   else
2116     {
2117       LOG_ERROR ("%s: empty line", __FUNCTION__)
2118       *error = 1;
2119     }
2120 }
2121 
2122 /** Returns the _dwg_entity_LINE::end point, DXF 11.
2123 \code Usage: dwg_ent_line_get_end_point(line, &point, &error);
2124 \endcode
2125 \param[in]  line    dwg_ent_line*
2126 \param[out] point   dwg_point_2d*
2127 \param[out] error   int*, is set to 0 for ok, 1 on error
2128 \deprecated
2129 */
2130 void
dwg_ent_line_get_end_point(const dwg_ent_line * restrict line,dwg_point_3d * restrict point,int * restrict error)2131 dwg_ent_line_get_end_point (const dwg_ent_line *restrict line,
2132                             dwg_point_3d *restrict point, int *restrict error)
2133 {
2134   if (line
2135 #  ifndef HAVE_NONNULL
2136       && point
2137 #  endif
2138   )
2139     {
2140       *error = 0;
2141       point->x = line->end.x;
2142       point->y = line->end.y;
2143       point->z = line->end.z;
2144     }
2145   else
2146     {
2147       LOG_ERROR ("%s: empty line", __FUNCTION__)
2148       *error = 1;
2149     }
2150 }
2151 
2152 /** Sets the _dwg_entity_LINE::end point, DXF 11.
2153 \code Usage: dwg_ent_line_set_start_end(line, &end_points, &error);
2154 \endcode
2155 \param[in,out] line dwg_ent_line*
2156 \param[out] point   dwg_point_2d*
2157 \param[out] error   int*, is set to 0 for ok, 1 on error
2158 \deprecated
2159 */
2160 void
dwg_ent_line_set_end_point(dwg_ent_line * restrict line,const dwg_point_3d * restrict point,int * restrict error)2161 dwg_ent_line_set_end_point (dwg_ent_line *restrict line,
2162                             const dwg_point_3d *restrict point,
2163                             int *restrict error)
2164 {
2165   if (line
2166 #  ifndef HAVE_NONNULL
2167       && point
2168 #  endif
2169   )
2170     {
2171       *error = 0;
2172       line->end.x = point->x;
2173       line->end.y = point->y;
2174       line->end.z = point->z;
2175     }
2176   else
2177     {
2178       LOG_ERROR ("%s: empty line", __FUNCTION__)
2179       *error = 1;
2180     }
2181 }
2182 
2183 /** Returns the _dwg_entity_LINE::thickness, DXF 39.
2184 \code Usage: double thickness = dwg_ent_line_get_thickness(line, &error);
2185 \endcode
2186 \param[in]  line    dwg_ent_line*
2187 \param[out] error   int*, is set to 0 for ok, 1 on error
2188 */
2189 double
dwg_ent_line_get_thickness(const dwg_ent_line * restrict line,int * restrict error)2190 dwg_ent_line_get_thickness (const dwg_ent_line *restrict line,
2191                             int *restrict error)
2192 {
2193   if (line)
2194     {
2195       *error = 0;
2196       return line->thickness;
2197     }
2198   else
2199     {
2200       LOG_ERROR ("%s: empty line", __FUNCTION__)
2201       *error = 1;
2202       return bit_nan ();
2203     }
2204 }
2205 
2206 /** Sets the _dwg_entity_LINE::thickness, DXF 39.
2207 \code Usage: dwg_ent_line_get_thickness(line, thickness, &error);
2208 \endcode
2209 \param[in,out] line   dwg_ent_line*
2210 \param[out] thickness double
2211 \param[out] error     int*, is set to 0 for ok, 1 on error
2212 \deprecated
2213 */
2214 void
dwg_ent_line_set_thickness(dwg_ent_line * restrict line,const double thickness,int * restrict error)2215 dwg_ent_line_set_thickness (dwg_ent_line *restrict line,
2216                             const double thickness, int *restrict error)
2217 {
2218   if (line)
2219     {
2220       *error = 0;
2221       line->thickness = thickness;
2222     }
2223   else
2224     {
2225       LOG_ERROR ("%s: empty line", __FUNCTION__)
2226       *error = 1;
2227     }
2228 }
2229 
2230 /** Returns the _dwg_entity_LINE::extrusion vector, DXF 210.
2231 \code Usage: dwg_ent_line_get_extrusion(line, &vector, &error);
2232 \endcode
2233 \param[in]  line    dwg_ent_line*
2234 \param[out] vector  dwg_point_3d*
2235 \param[out] error   int*, is set to 0 for ok, 1 on error
2236 \deprecated
2237 */
2238 void
dwg_ent_line_get_extrusion(const dwg_ent_line * restrict line,dwg_point_3d * restrict vector,int * restrict error)2239 dwg_ent_line_get_extrusion (const dwg_ent_line *restrict line,
2240                             dwg_point_3d *restrict vector, int *restrict error)
2241 {
2242   if (line
2243 #  ifndef HAVE_NONNULL
2244       && vector
2245 #  endif
2246   )
2247     {
2248       *error = 0;
2249       vector->x = line->extrusion.x;
2250       vector->y = line->extrusion.y;
2251       vector->z = line->extrusion.z;
2252     }
2253   else
2254     {
2255       LOG_ERROR ("%s: empty vector or line", __FUNCTION__)
2256       *error = 1;
2257     }
2258 }
2259 
2260 /** Sets the _dwg_entity_LINE::extrusion vector, DXF 210.
2261 \code Usage: dwg_ent_line_set_extrusion(line, vector, &error);
2262 \endcode
2263 \param[in,out] line  dwg_ent_line*
2264 \param[out] vector   dwg_point_3d*
2265 \param[out] error    int*, is set to 0 for ok, 1 on error
2266 \deprecated
2267 */
2268 void
dwg_ent_line_set_extrusion(dwg_ent_line * restrict line,const dwg_point_3d * restrict vector,int * restrict error)2269 dwg_ent_line_set_extrusion (dwg_ent_line *restrict line,
2270                             const dwg_point_3d *restrict vector,
2271                             int *restrict error)
2272 {
2273   if (line
2274 #  ifndef HAVE_NONNULL
2275       && vector
2276 #  endif
2277   )
2278     {
2279       *error = 0;
2280       line->extrusion.x = vector->x;
2281       line->extrusion.y = vector->y;
2282       line->extrusion.z = vector->z;
2283     }
2284   else
2285     {
2286       LOG_ERROR ("%s: empty vector or line", __FUNCTION__)
2287       *error = 1;
2288     }
2289 }
2290 
2291 /*******************************************************************
2292  *                    FUNCTIONS FOR ARC ENTITY                       *
2293  ********************************************************************/
2294 
2295 /** Returns the _dwg_entity_ARC::center, DXF 10.
2296 \code Usage: dwg_ent_arc_get_center(arc, &point, &error);
2297 \endcode
2298 \param[in]   arc    dwg_ent_arc*
2299 \param[out] dwg_point_3d
2300 \param[out] error   int*, is set to 0 for ok, 1 on error
2301 \deprecated
2302 */
2303 void
dwg_ent_arc_get_center(const dwg_ent_arc * restrict arc,dwg_point_3d * restrict point,int * restrict error)2304 dwg_ent_arc_get_center (const dwg_ent_arc *restrict arc,
2305                         dwg_point_3d *restrict point, int *restrict error)
2306 {
2307   if (arc
2308 #  ifndef HAVE_NONNULL
2309       && point
2310 #  endif
2311   )
2312     {
2313       *error = 0;
2314       point->x = arc->center.x;
2315       point->y = arc->center.y;
2316       point->z = arc->center.z;
2317     }
2318   else
2319     {
2320       LOG_ERROR ("%s: empty arc or point", __FUNCTION__)
2321       *error = 1;
2322     }
2323 }
2324 
2325 /** Sets the _dwg_entity_ARC::center, DXF 10.
2326 \code Usage: dwg_ent_arc_set_center(arc, &point, &error);
2327 \endcode
2328 \param[in,out] arc     dwg_ent_arc*
2329 \param[out]    center  dwg_point_3d*
2330 \param[out]    error   int*, is set to 0 for ok, 1 on error
2331 \deprecated
2332 */
2333 void
dwg_ent_arc_set_center(dwg_ent_arc * restrict arc,const dwg_point_3d * restrict point,int * restrict error)2334 dwg_ent_arc_set_center (dwg_ent_arc *restrict arc,
2335                         const dwg_point_3d *restrict point,
2336                         int *restrict error)
2337 {
2338   if (arc
2339 #  ifndef HAVE_NONNULL
2340       && point
2341 #  endif
2342   )
2343     {
2344       *error = 0;
2345       arc->center.x = point->x;
2346       arc->center.y = point->y;
2347       arc->center.z = point->z;
2348     }
2349   else
2350     {
2351       LOG_ERROR ("%s: empty arc or point", __FUNCTION__)
2352       *error = 1;
2353     }
2354 }
2355 
2356 /** Returns the _dwg_entity_ARC::radius, DXF 40.
2357 \code Usage: double radius = dwg_ent_arc_get_radius(arc, &error);
2358 \endcode
2359 \param[in]   arc    dwg_ent_arc*
2360 \param[out] error   int*, is set to 0 for ok, 1 on error
2361 \deprecated
2362 */
2363 double
dwg_ent_arc_get_radius(const dwg_ent_arc * restrict arc,int * restrict error)2364 dwg_ent_arc_get_radius (const dwg_ent_arc *restrict arc, int *restrict error)
2365 {
2366   if (arc)
2367     {
2368       *error = 0;
2369       return arc->radius;
2370     }
2371   else
2372     {
2373       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2374       *error = 1;
2375       return bit_nan ();
2376     }
2377 }
2378 
2379 /** Sets the _dwg_entity_ARC::radius, DXF 40.
2380 \code Usage: dwg_ent_arc_set_radius(arc, radius, &error);
2381 \endcode
2382 \param[in,out] arc     dwg_ent_arc*
2383 \param[out]    radius  double
2384 \param[out]    error   int*, is set to 0 for ok, 1 on error
2385 \deprecated
2386 */
2387 void
dwg_ent_arc_set_radius(dwg_ent_arc * restrict arc,const double radius,int * restrict error)2388 dwg_ent_arc_set_radius (dwg_ent_arc *restrict arc, const double radius,
2389                         int *restrict error)
2390 {
2391   if (arc)
2392     {
2393       *error = 0;
2394       arc->radius = radius;
2395     }
2396   else
2397     {
2398       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2399       *error = 1;
2400     }
2401 }
2402 
2403 /** Returns the _dwg_entity_ARC::thickness, DXF 39.
2404 \code Usage: double thickness = dwg_ent_arc_get_thickness(arc, &error);
2405 \endcode
2406 \param[in]   arc    dwg_ent_arc*
2407 \param[out] error   int*, is set to 0 for ok, 1 on error
2408 \deprecated
2409 */
2410 double
dwg_ent_arc_get_thickness(const dwg_ent_arc * restrict arc,int * restrict error)2411 dwg_ent_arc_get_thickness (const dwg_ent_arc *restrict arc,
2412                            int *restrict error)
2413 {
2414   if (arc)
2415     {
2416       *error = 0;
2417       return arc->thickness;
2418     }
2419   else
2420     {
2421       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2422       *error = 1;
2423       return bit_nan ();
2424     }
2425 }
2426 
2427 /** Sets the _dwg_entity_ARC::thickness, DXF 39.
2428 \code Usage: dwg_ent_arc_get_thickness(arc, thickness, &error);
2429 \endcode
2430 \param[in,out] arc       dwg_ent_arc*
2431 \param[out]    thickness double
2432 \param[out]    error     int*, is set to 0 for ok, 1 on error
2433 \deprecated
2434 */
2435 void
dwg_ent_arc_set_thickness(dwg_ent_arc * restrict arc,const double thickness,int * restrict error)2436 dwg_ent_arc_set_thickness (dwg_ent_arc *restrict arc, const double thickness,
2437                            int *restrict error)
2438 {
2439   if (arc)
2440     {
2441       *error = 0;
2442       arc->thickness = thickness;
2443     }
2444   else
2445     {
2446       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2447       *error = 1;
2448     }
2449 }
2450 
2451 /** Returns the _dwg_entity_ARC::extrusion vector, DXF 210.
2452 \code Usage: dwg_ent_arc_get_extrusion(arc, &vector, &error);
2453 \endcode
2454 \param[in]     arc      dwg_ent_arc*
2455 \param[out]    vector   dwg_point_3d*
2456 \param[out]    error    int*, is set to 0 for ok, 1 on error
2457 \deprecated
2458 */
2459 void
dwg_ent_arc_get_extrusion(const dwg_ent_arc * restrict arc,dwg_point_3d * restrict vector,int * restrict error)2460 dwg_ent_arc_get_extrusion (const dwg_ent_arc *restrict arc,
2461                            dwg_point_3d *restrict vector, int *restrict error)
2462 {
2463   if (arc
2464 #  ifndef HAVE_NONNULL
2465       && vector
2466 #  endif
2467   )
2468     {
2469       *error = 0;
2470       vector->x = arc->extrusion.x;
2471       vector->y = arc->extrusion.y;
2472       vector->z = arc->extrusion.z;
2473     }
2474   else
2475     {
2476       LOG_ERROR ("%s: empty arc or vector", __FUNCTION__)
2477       *error = 1;
2478     }
2479 }
2480 
2481 /** Sets the _dwg_entity_ARC::extrusion vector, DXF 210.
2482 \code Usage: dwg_ent_arc_set_extrusion(arc, vector, &error);
2483 \endcode
2484 \param[in,out] arc      dwg_ent_arc*
2485 \param[in]     vector   dwg_point_3d*
2486 \param[out]    error    int*, is set to 0 for ok, 1 on error
2487 \deprecated
2488 */
2489 void
dwg_ent_arc_set_extrusion(dwg_ent_arc * restrict arc,const dwg_point_3d * restrict vector,int * restrict error)2490 dwg_ent_arc_set_extrusion (dwg_ent_arc *restrict arc,
2491                            const dwg_point_3d *restrict vector,
2492                            int *restrict error)
2493 {
2494   if (arc
2495 #  ifndef HAVE_NONNULL
2496       && vector
2497 #  endif
2498   )
2499     {
2500       *error = 0;
2501       arc->extrusion.x = vector->x;
2502       arc->extrusion.y = vector->y;
2503       arc->extrusion.z = vector->z;
2504     }
2505   else
2506     {
2507       LOG_ERROR ("%s: empty arc or vector", __FUNCTION__)
2508       *error = 1;
2509     }
2510 }
2511 
2512 /** Returns the _dwg_entity_ARC::start_angle, DXF 50, in radians.
2513 \code Usage: double start_angle = dwg_ent_arc_get_start_angle(line, &error);
2514 \endcode
2515 \param[in]  arc     dwg_ent_arc*
2516 \param[out] error   int*, is set to 0 for ok, 1 on error
2517 \deprecated
2518 */
2519 double
dwg_ent_arc_get_start_angle(const dwg_ent_arc * restrict arc,int * restrict error)2520 dwg_ent_arc_get_start_angle (const dwg_ent_arc *restrict arc,
2521                              int *restrict error)
2522 {
2523   if (arc)
2524     {
2525       *error = 0;
2526       return arc->start_angle;
2527     }
2528   else
2529     {
2530       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2531       *error = 1;
2532       return bit_nan ();
2533     }
2534 }
2535 
2536 /** Sets the _dwg_entity_ARC::start_angle, DXF 50.
2537 \code Usage: dwg_ent_arc_set_start_angle(arc, angle, &error);
2538 \endcode
2539 \param[in,out] arc      dwg_ent_arc*
2540 \param[in]     angle    double (in radians)
2541 \param[out]    error    int*, is set to 0 for ok, 1 on error
2542 \deprecated
2543 */
2544 void
dwg_ent_arc_set_start_angle(dwg_ent_arc * restrict arc,const double angle,int * restrict error)2545 dwg_ent_arc_set_start_angle (dwg_ent_arc *restrict arc, const double angle,
2546                              int *restrict error)
2547 {
2548   if (arc)
2549     {
2550       *error = 0;
2551       // TODO: normalize to PI? There are some DWG's with 2*PI or 4.623770
2552       arc->start_angle = angle;
2553     }
2554   else
2555     {
2556       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2557       *error = 1;
2558     }
2559 }
2560 
2561 /** Returns the _dwg_entity_ARC::end_angle, DXF 51, in radians.
2562 \code Usage: double end_angle = dwg_ent_arc_get_end_angle(arc, &error);
2563 \endcode
2564 \param[in]  arc     dwg_ent_arc*
2565 \param[out] error   int*, is set to 0 for ok, 1 on error
2566 \deprecated
2567 */
2568 double
dwg_ent_arc_get_end_angle(const dwg_ent_arc * restrict arc,int * restrict error)2569 dwg_ent_arc_get_end_angle (const dwg_ent_arc *restrict arc,
2570                            int *restrict error)
2571 {
2572   if (arc)
2573     {
2574       *error = 0;
2575       return arc->end_angle;
2576     }
2577   else
2578     {
2579       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2580       *error = 1;
2581       return bit_nan ();
2582     }
2583 }
2584 
2585 /** Sets the _dwg_entity_ARC::end_angle, DXF 51.
2586 \code Usage: dwg_ent_arc_set_end_angle(arc, angle, &error);
2587 \endcode
2588 \param[in,out] arc      dwg_ent_arc*
2589 \param[in]     angle    double (in radians)
2590 \param[out]    error    int*, is set to 0 for ok, 1 on error
2591 \deprecated
2592 */
2593 void
dwg_ent_arc_set_end_angle(dwg_ent_arc * restrict arc,const double angle,int * restrict error)2594 dwg_ent_arc_set_end_angle (dwg_ent_arc *restrict arc, const double angle,
2595                            int *restrict error)
2596 {
2597   if (arc)
2598     {
2599       *error = 0;
2600       // TODO: normalize to PI?
2601       arc->end_angle = angle;
2602     }
2603   else
2604     {
2605       LOG_ERROR ("%s: empty arc", __FUNCTION__)
2606       *error = 1;
2607     }
2608 }
2609 
2610 /*******************************************************************
2611  *                   FUNCTIONS FOR ELLIPSE ENTITY                    *
2612  ********************************************************************/
2613 
2614 /**  Returns the _dwg_entity_ELLIPSE::center, DXF 10
2615 \code Usage: dwg_ent_ellipse_get_center(ellipse, &center, &error);
2616 \endcode
2617 \param[in]  ellipse dwg_ent_ellipse*
2618 \param[out] point   dwg_point_3d*
2619 \param[out] error   int*, is set to 0 for ok, 1 on error
2620 \deprecated
2621 */
2622 void
dwg_ent_ellipse_get_center(const dwg_ent_ellipse * restrict ellipse,dwg_point_3d * restrict point,int * restrict error)2623 dwg_ent_ellipse_get_center (const dwg_ent_ellipse *restrict ellipse,
2624                             dwg_point_3d *restrict point, int *restrict error)
2625 {
2626   if (ellipse
2627 #  ifndef HAVE_NONNULL
2628       && point
2629 #  endif
2630   )
2631     {
2632       *error = 0;
2633       point->x = ellipse->center.x;
2634       point->y = ellipse->center.y;
2635       point->z = ellipse->center.z;
2636     }
2637   else
2638     {
2639       LOG_ERROR ("%s: empty ellipse or point", __FUNCTION__)
2640       *error = 1;
2641     }
2642 }
2643 
2644 /**  Sets the _dwg_entity_ELLIPSE::center, DXF 10
2645 \code Usage: dwg_ent_ellipse_set_center(ellipse, &center &error);
2646 \endcode
2647 \param[in,out] ellipse dwg_ent_ellipse*
2648 \param[in]     point   dwg_point_3d*
2649 \param[out]    error   int*, is set to 0 for ok, 1 on error
2650 \deprecated
2651 */
2652 void
dwg_ent_ellipse_set_center(dwg_ent_ellipse * restrict ellipse,const dwg_point_3d * restrict point,int * restrict error)2653 dwg_ent_ellipse_set_center (dwg_ent_ellipse *restrict ellipse,
2654                             const dwg_point_3d *restrict point,
2655                             int *restrict error)
2656 {
2657   if (ellipse
2658 #  ifndef HAVE_NONNULL
2659       && point
2660 #  endif
2661   )
2662     {
2663       *error = 0;
2664       ellipse->center.x = point->x;
2665       ellipse->center.y = point->y;
2666       ellipse->center.z = point->z;
2667     }
2668   else
2669     {
2670       LOG_ERROR ("%s: empty ellipse or point", __FUNCTION__)
2671       *error = 1;
2672     }
2673 }
2674 
2675 /** Returns the _dwg_entity_ELLIPSE::sm_axis, DXF 11.
2676 \code Usage: dwg_ent_ellipse_get_sm_axis(ellipse, &point, &error);
2677 \endcode
2678 \param[in]  ellipse dwg_ent_ellipse*
2679 \param[out] point   dwg_point_3d*
2680 \param[out] error   int*, is set to 0 for ok, 1 on error
2681 \deprecated
2682 */
2683 void
dwg_ent_ellipse_get_sm_axis(const dwg_ent_ellipse * restrict ellipse,dwg_point_3d * restrict point,int * restrict error)2684 dwg_ent_ellipse_get_sm_axis (const dwg_ent_ellipse *restrict ellipse,
2685                              dwg_point_3d *restrict point, int *restrict error)
2686 {
2687   if (ellipse
2688 #  ifndef HAVE_NONNULL
2689       && point
2690 #  endif
2691   )
2692     {
2693       *error = 0;
2694       point->x = ellipse->sm_axis.x;
2695       point->y = ellipse->sm_axis.y;
2696       point->z = ellipse->sm_axis.z;
2697     }
2698   else
2699     {
2700       LOG_ERROR ("%s: empty ellipse or point", __FUNCTION__)
2701       *error = 1;
2702     }
2703 }
2704 
2705 /** Sets the _dwg_entity_ELLIPSE::sm_axis, DXF 11.
2706 \code Usage: dwg_ent_ellipse_set_sm_axis(ellipse, &point, &error);
2707 \endcode
2708 \param[in,out] ellipse dwg_ent_ellipse*
2709 \param[in]  point   dwg_point_3d*
2710 \param[out] error   int*, is set to 0 for ok, 1 on error
2711 \deprecated
2712 */
2713 void
dwg_ent_ellipse_set_sm_axis(dwg_ent_ellipse * restrict ellipse,const dwg_point_3d * restrict point,int * restrict error)2714 dwg_ent_ellipse_set_sm_axis (dwg_ent_ellipse *restrict ellipse,
2715                              const dwg_point_3d *restrict point,
2716                              int *restrict error)
2717 {
2718   if (ellipse
2719 #  ifndef HAVE_NONNULL
2720       && point
2721 #  endif
2722   )
2723     {
2724       *error = 0;
2725       ellipse->sm_axis.x = point->x;
2726       ellipse->sm_axis.y = point->y;
2727       ellipse->sm_axis.z = point->z;
2728     }
2729   else
2730     {
2731       LOG_ERROR ("%s: empty ellipse or point", __FUNCTION__)
2732       *error = 1;
2733     }
2734 }
2735 
2736 /** Returns the _dwg_entity_ELLIPSE::extrusion vector, DXF 210.
2737 \code Usage: dwg_ent_ellipse_get_extrusion(ellipse, &ext_points, &error);
2738 \endcode
2739 \param[in] ellipse  dwg_ent_ellipse*
2740 \param[out] vector  dwg_point_3d*
2741 \param[out] error   int*, is set to 0 for ok, 1 on error
2742 \deprecated
2743 */
2744 void
dwg_ent_ellipse_get_extrusion(const dwg_ent_ellipse * restrict ellipse,dwg_point_3d * restrict vector,int * restrict error)2745 dwg_ent_ellipse_get_extrusion (const dwg_ent_ellipse *restrict ellipse,
2746                                dwg_point_3d *restrict vector,
2747                                int *restrict error)
2748 {
2749   if (ellipse
2750 #  ifndef HAVE_NONNULL
2751       && vector
2752 #  endif
2753   )
2754     {
2755       *error = 0;
2756       vector->x = ellipse->extrusion.x;
2757       vector->y = ellipse->extrusion.y;
2758       vector->z = ellipse->extrusion.z;
2759     }
2760   else
2761     {
2762       LOG_ERROR ("%s: empty ellipse or vector", __FUNCTION__)
2763       *error = 1;
2764     }
2765 }
2766 
2767 /** Sets the _dwg_entity_ELLIPSE::extrusion vector, DXF 210.
2768 \code Usage: dwg_ent_ellipse_set_extrusion(ellipse, &vector, &error);
2769 \endcode
2770 \param[in,out] ellipse dwg_ent_ellipse*
2771 \param[in]  vector  dwg_point_3d*
2772 \param[out] error   int*, is set to 0 for ok, 1 on error
2773 \deprecated
2774 */
2775 void
dwg_ent_ellipse_set_extrusion(dwg_ent_ellipse * restrict ellipse,const dwg_point_3d * restrict vector,int * restrict error)2776 dwg_ent_ellipse_set_extrusion (dwg_ent_ellipse *restrict ellipse,
2777                                const dwg_point_3d *restrict vector,
2778                                int *restrict error)
2779 {
2780   if (ellipse
2781 #  ifndef HAVE_NONNULL
2782       && vector
2783 #  endif
2784   )
2785     {
2786       *error = 0;
2787       ellipse->extrusion.x = vector->x;
2788       ellipse->extrusion.y = vector->y;
2789       ellipse->extrusion.z = vector->z;
2790     }
2791   else
2792     {
2793       LOG_ERROR ("%s: empty ellipse or vector", __FUNCTION__)
2794       *error = 1;
2795     }
2796 }
2797 
2798 /** Returns the _dwg_entity_ELLIPSE::axis_ratio, DXF 40.
2799 \code Usage: double axis_ratio = dwg_ent_ellipse_get_axis_ratio(ellipse,
2800 &error); \endcode \param[in] ellipse dwg_ent_ellipse* \param[out] error   int*,
2801 is set to 0 for ok, 1 on error \deprecated
2802 */
2803 double
dwg_ent_ellipse_get_axis_ratio(const dwg_ent_ellipse * restrict ellipse,int * restrict error)2804 dwg_ent_ellipse_get_axis_ratio (const dwg_ent_ellipse *restrict ellipse,
2805                                 int *restrict error)
2806 {
2807   if (ellipse)
2808     {
2809       *error = 0;
2810       return ellipse->axis_ratio;
2811     }
2812   else
2813     {
2814       *error = 1;
2815       LOG_ERROR ("%s: empty ellipse", __FUNCTION__)
2816       return bit_nan ();
2817     }
2818 }
2819 
2820 /** Sets the _dwg_entity_ELLIPSE::axis ratio, DXF 40.
2821 \code Usage: dwg_ent_ellipse_set_axis_ratio(ellipse, axis_ratio, &error);
2822 \endcode
2823 \param[in] ellipse dwg_ent_ellipse*
2824 \param[in] double
2825 \param[out] error   int*, is set to 0 for ok, 1 on error
2826 \deprecated
2827 */
2828 void
dwg_ent_ellipse_set_axis_ratio(dwg_ent_ellipse * restrict ellipse,const double ratio,int * restrict error)2829 dwg_ent_ellipse_set_axis_ratio (dwg_ent_ellipse *restrict ellipse,
2830                                 const double ratio, int *restrict error)
2831 {
2832   if (ellipse)
2833     {
2834       *error = 0;
2835       ellipse->axis_ratio = ratio;
2836     }
2837   else
2838     {
2839       LOG_ERROR ("%s: empty ellipse", __FUNCTION__)
2840       *error = 1;
2841     }
2842 }
2843 
2844 /** Returns the _dwg_entity_ELLIPSE::start_angle, DXF 41.
2845 \code Usage: double start_angle = dwg_ent_ellipse_get_start_angle(ellipse,
2846 &error); \endcode \param[in] ellipse dwg_ent_ellipse* \param[out] error   int*,
2847 is set to 0 for ok, 1 on error \deprecated
2848 */
2849 double
dwg_ent_ellipse_get_start_angle(const dwg_ent_ellipse * restrict ellipse,int * restrict error)2850 dwg_ent_ellipse_get_start_angle (const dwg_ent_ellipse *restrict ellipse,
2851                                  int *restrict error)
2852 {
2853   if (ellipse)
2854     {
2855       *error = 0;
2856       return ellipse->start_angle;
2857     }
2858   else
2859     {
2860       LOG_ERROR ("%s: empty ellipse", __FUNCTION__)
2861       *error = 1;
2862       return bit_nan ();
2863     }
2864 }
2865 
2866 /** Sets the _dwg_entity_ELLIPSE::start angle, DXF 41.
2867 \code Usage: dwg_ent_ellipse_set_start_angle(ellipse, start_angle, &error);
2868 \endcode
2869 \param[in] ellipse dwg_ent_ellipse*
2870 \param[in] double
2871 \param[out] error   int*, is set to 0 for ok, 1 on error
2872 \deprecated
2873 */
2874 void
dwg_ent_ellipse_set_start_angle(dwg_ent_ellipse * restrict ellipse,const double start_angle,int * restrict error)2875 dwg_ent_ellipse_set_start_angle (dwg_ent_ellipse *restrict ellipse,
2876                                  const double start_angle, int *restrict error)
2877 {
2878   if (ellipse)
2879     {
2880       *error = 0;
2881       ellipse->start_angle = start_angle;
2882     }
2883   else
2884     {
2885       LOG_ERROR ("%s: empty ellipse", __FUNCTION__)
2886       *error = 1;
2887     }
2888 }
2889 
2890 /** Returns the _dwg_entity_ELLIPSE::end_angle, DXF 42.
2891 \code Usage: double end_angle = dwg_ent_ellipse_get_end_angle(ellipse, &error);
2892 \endcode
2893 \param[in]  ellipse dwg_ent_ellipse*
2894 \param[out] error   int*, is set to 0 for ok, 1 on error
2895 \deprecated
2896 */
2897 double
dwg_ent_ellipse_get_end_angle(const dwg_ent_ellipse * restrict ellipse,int * restrict error)2898 dwg_ent_ellipse_get_end_angle (const dwg_ent_ellipse *restrict ellipse,
2899                                int *restrict error)
2900 {
2901   if (ellipse)
2902     {
2903       *error = 0;
2904       return ellipse->end_angle;
2905     }
2906   else
2907     {
2908       LOG_ERROR ("%s: empty ellipse", __FUNCTION__)
2909       *error = 1;
2910       return bit_nan ();
2911     }
2912 }
2913 
2914 /** Sets the _dwg_entity_ELLIPSE::end_angle, DXF 42.
2915 \code Usage: dwg_ent_ellipse_set_end_angle(ellipse, end_angle, &error);
2916 \endcode
2917 \param[in,out] ellipse    dwg_ent_ellipse*
2918 \param[in]     end_angle  double
2919 \param[out]    error      int*, is set to 0 for ok, 1 on error
2920 \deprecated
2921 */
2922 void
dwg_ent_ellipse_set_end_angle(dwg_ent_ellipse * restrict ellipse,const double end_angle,int * restrict error)2923 dwg_ent_ellipse_set_end_angle (dwg_ent_ellipse *restrict ellipse,
2924                                const double end_angle, int *restrict error)
2925 {
2926   if (ellipse)
2927     {
2928       *error = 0;
2929       ellipse->end_angle = end_angle;
2930     }
2931   else
2932     {
2933       LOG_ERROR ("%s: empty ellipse", __FUNCTION__)
2934       *error = 1;
2935     }
2936 }
2937 
2938 /*******************************************************************
2939  *                    FUNCTIONS FOR TEXT ENTITY                      *
2940  ********************************************************************/
2941 
2942 /** Sets the _dwg_entity_TEXT::text string, utf-8 encoded, DXF 1.
2943 \code Usage: dwg_ent_text_set_text(text, "Hello world", &error);
2944 \endcode
2945 \param[in] text dwg_ent_text*
2946 \param[in] utf-8 string ( char * )
2947 \param[out] error   int*, is set to 0 for ok, 1 on error
2948 \deprecated
2949 */
2950 void
dwg_ent_text_set_text(dwg_ent_text * restrict ent,const char * restrict text_value,int * restrict error)2951 dwg_ent_text_set_text (dwg_ent_text *restrict ent,
2952                        const char *restrict text_value, int *restrict error)
2953 {
2954   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
2955   if (ent && !error)
2956     {
2957       ent->text_value = dwg_add_u8_input (dwg, text_value);
2958     }
2959   else
2960     {
2961       LOG_ERROR ("%s: empty ent", __FUNCTION__)
2962       *error = 1;
2963     }
2964 }
2965 
2966 /** Returns the _dwg_entity_TEXT::text string, utf-8 encoded, DXF 1.
2967 \code Usage: dwg_ent_text_get_text(text, &error);
2968 \endcode
2969 \param[in] text dwg_ent_text*
2970 \param[out] error   int*, is set to 0 for ok, 1 on error
2971 \deprecated
2972 */
2973 char *
dwg_ent_text_get_text(const dwg_ent_text * restrict ent,int * restrict error)2974 dwg_ent_text_get_text (const dwg_ent_text *restrict ent, int *restrict error)
2975 {
2976   if (ent)
2977     {
2978       *error = 0;
2979       if (dwg_version >= R_2007)
2980         return bit_convert_TU ((BITCODE_TU)ent->text_value);
2981       else
2982         return ent->text_value;
2983     }
2984   else
2985     {
2986       LOG_ERROR ("%s: empty ent", __FUNCTION__)
2987       *error = 1;
2988       return NULL;
2989     }
2990 }
2991 
2992 /** Returns the _dwg_entity_TEXT::ins_pt, DXF 10.
2993 \code Usage: dwg_ent_text_get_insertion_pt(text, &point, &error);
2994 \endcode
2995 \param[in] text     dwg_ent_text*
2996 \param[out] point   dwg_2d_point*
2997 \param[out] error   int*, is set to 0 for ok, 1 on error
2998 \deprecated
2999 */
3000 void
dwg_ent_text_get_insertion_pt(const dwg_ent_text * restrict text,dwg_point_2d * restrict point,int * restrict error)3001 dwg_ent_text_get_insertion_pt (const dwg_ent_text *restrict text,
3002                                   dwg_point_2d *restrict point,
3003                                   int *restrict error)
3004 {
3005   if (text
3006 #  ifndef HAVE_NONNULL
3007       && point
3008 #  endif
3009   )
3010     {
3011       *error = 0;
3012       point->x = text->ins_pt.x;
3013       point->y = text->ins_pt.y;
3014     }
3015   else
3016     {
3017       LOG_ERROR ("%s: empty text or point", __FUNCTION__)
3018       *error = 1;
3019     }
3020 }
3021 
3022 /** Sets the _dwg_entity_TEXT::insertion_pt, DXF 10.
3023 \code Usage: dwg_ent_text_set_insertion_pt(text, &point, &error)
3024 \endcode
3025 \param[in,out] text    dwg_ent_text*
3026 \param[in]     point   dwg_2d_point*
3027 \param[out]    error   int*, is set to 0 for ok, 1 on error
3028 \deprecated
3029 */
3030 void
dwg_ent_text_set_insertion_pt(dwg_ent_text * restrict text,const dwg_point_2d * restrict point,int * restrict error)3031 dwg_ent_text_set_insertion_pt (dwg_ent_text *restrict text,
3032                                   const dwg_point_2d *restrict point,
3033                                   int *restrict error)
3034 {
3035   if (text
3036 #  ifndef HAVE_NONNULL
3037       && point
3038 #  endif
3039   )
3040     {
3041       *error = 0;
3042       text->ins_pt.x = point->x;
3043       text->ins_pt.y = point->y;
3044     }
3045   else
3046     {
3047       LOG_ERROR ("%s: empty text or point", __FUNCTION__)
3048       *error = 1;
3049     }
3050 }
3051 
3052 /** Returns the _dwg_entity_TEXT::height, DXF 40. i.e. the fontsize
3053 \code Usage: double height = dwg_ent_text_get_height(text);
3054 \endcode
3055 \param[in]  text    dwg_ent_text*
3056 \param[out] error   int*, is set to 0 for ok, 1 on error
3057 \deprecated
3058 */
3059 double
dwg_ent_text_get_height(const dwg_ent_text * restrict text,int * restrict error)3060 dwg_ent_text_get_height (const dwg_ent_text *restrict text,
3061                          int *restrict error)
3062 {
3063   if (text)
3064     {
3065       *error = 0;
3066       return text->height;
3067     }
3068   else
3069     {
3070       *error = 1;
3071       LOG_ERROR ("%s: empty text", __FUNCTION__)
3072       return bit_nan ();
3073     }
3074 }
3075 
3076 /** Sets the _dwg_entity_TEXT::height, DXF 40.
3077 \code Usage: dwg_ent_text_set_height(text, 100.0, &error);
3078 \endcode
3079 \param[in,out] text    dwg_ent_text*
3080 \param[in]    height  double
3081 \param[out]    error   int*, is set to 0 for ok, 1 on error
3082 \deprecated
3083 */
3084 void
dwg_ent_text_set_height(dwg_ent_text * restrict text,const double height,int * restrict error)3085 dwg_ent_text_set_height (dwg_ent_text *restrict text, const double height,
3086                          int *restrict error)
3087 {
3088   if (text)
3089     {
3090       *error = 0;
3091       text->height = height;
3092     }
3093   else
3094     {
3095       LOG_ERROR ("%s: empty text", __FUNCTION__)
3096       *error = 1;
3097     }
3098 }
3099 
3100 /** Returns the _dwg_entity_TEXT::extrusion vector, DXF 210.
3101 \code dwg_ent_text_get_extrusion(text, &point, &error);
3102 \endcode
3103 \param[in]  text   dwg_ent_text*
3104 \param[out] vector dwg_point_3d*
3105 \param[out] error  int*, is set to 0 for ok, 1 on error
3106 \deprecated
3107 */
3108 void
dwg_ent_text_get_extrusion(const dwg_ent_text * restrict text,dwg_point_3d * restrict vector,int * restrict error)3109 dwg_ent_text_get_extrusion (const dwg_ent_text *restrict text,
3110                             dwg_point_3d *restrict vector, int *restrict error)
3111 {
3112   if (text
3113 #  ifndef HAVE_NONNULL
3114       && vector
3115 #  endif
3116   )
3117     {
3118       *error = 0;
3119       vector->x = text->extrusion.x;
3120       vector->y = text->extrusion.y;
3121       vector->z = text->extrusion.z;
3122     }
3123   else
3124     {
3125       LOG_ERROR ("%s: empty text or vector", __FUNCTION__)
3126       *error = 1;
3127     }
3128 }
3129 
3130 /** Sets the _dwg_entity_TEXT::extrusion vector, DXF 210.
3131 \code Usage: dwg_ent_text_set_extrusion(text, &vector, &error);
3132 \encode
3133 \param[in,out] text dwg_ent_text*
3134 \param[in]     vector dwg_point_3d*
3135 \param[out]    error  int*, is set to 0 for ok, 1 on error
3136 \deprecated
3137 */
3138 void
dwg_ent_text_set_extrusion(dwg_ent_text * restrict text,const dwg_point_3d * restrict vector,int * restrict error)3139 dwg_ent_text_set_extrusion (dwg_ent_text *restrict text,
3140                             const dwg_point_3d *restrict vector,
3141                             int *restrict error)
3142 {
3143   if (text
3144 #  ifndef HAVE_NONNULL
3145       && vector
3146 #  endif
3147   )
3148     {
3149       *error = 0;
3150       text->extrusion.x = vector->x;
3151       text->extrusion.y = vector->y;
3152       text->extrusion.z = vector->z;
3153     }
3154   else
3155     {
3156       LOG_ERROR ("%s: empty text or vector", __FUNCTION__)
3157       *error = 1;
3158     }
3159 }
3160 
3161 /** Returns the _dwg_entity_TEXT::thickness, DXF 39.
3162 \code Usage: thickness = dwg_ent_text_get_thickness(text, &error);
3163 \endcode
3164 \param[in]  text  dwg_ent_text*
3165 \param[out] error int*, is set to 0 for ok, 1 on error
3166 \deprecated
3167 */
3168 double
dwg_ent_text_get_thickness(const dwg_ent_text * restrict text,int * restrict error)3169 dwg_ent_text_get_thickness (const dwg_ent_text *restrict text,
3170                             int *restrict error)
3171 {
3172   if (text)
3173     {
3174       *error = 0;
3175       return text->thickness;
3176     }
3177   else
3178     {
3179       LOG_ERROR ("%s: empty text", __FUNCTION__)
3180       *error = 1;
3181       return bit_nan ();
3182     }
3183 }
3184 
3185 /** Sets the _dwg_entity_TEXT::thickness, DXF 39.
3186 \code Usage: dwg_ent_text_set_thickness(text, 0.0 &error);
3187 \endcode
3188 \param[in,out] text      dwg_ent_text*
3189 \param[in]     thickness double
3190 \param[out]    error   int*, is set to 0 for ok, 1 on error
3191 \deprecated
3192 */
3193 void
dwg_ent_text_set_thickness(dwg_ent_text * restrict text,const double thickness,int * restrict error)3194 dwg_ent_text_set_thickness (dwg_ent_text *restrict text,
3195                             const double thickness, int *restrict error)
3196 {
3197   if (text)
3198     {
3199       *error = 0;
3200       text->thickness = thickness;
3201     }
3202   else
3203     {
3204       LOG_ERROR ("%s: empty text", __FUNCTION__)
3205       *error = 1;
3206     }
3207 }
3208 
3209 /** Returns the _dwg_entity_TEXT::rotation. DXF 50 (radians)
3210 \code Usage: double rot_ang = dwg_ent_text_get_rotation(text, &error);
3211 \endcode
3212 \param[in] text dwg_ent_text*
3213 \param[out] error   int*, is set to 0 for ok, 1 on error
3214 \deprecated
3215 */
3216 double
dwg_ent_text_get_rotation(const dwg_ent_text * restrict text,int * restrict error)3217 dwg_ent_text_get_rotation (const dwg_ent_text *restrict text,
3218                            int *restrict error)
3219 {
3220   if (text)
3221     {
3222       *error = 0;
3223       return text->rotation;
3224     }
3225   else
3226     {
3227       LOG_ERROR ("%s: empty text", __FUNCTION__)
3228       *error = 1;
3229       return bit_nan ();
3230     }
3231 }
3232 
3233 /** Sets the _dwg_entity_TEXT::rotation angle, in radians, DXF 50.
3234 \code Usage: dwg_ent_text_set_rotation(text, angle, &error);
3235 \endcode
3236 \param[in,out] text   dwg_ent_text*
3237 \param[in] angle  double
3238 \param[out] error int*, is set to 0 for ok, 1 on error
3239 \deprecated
3240 */
3241 void
dwg_ent_text_set_rotation(dwg_ent_text * restrict text,const double angle,int * restrict error)3242 dwg_ent_text_set_rotation (dwg_ent_text *restrict text, const double angle,
3243                            int *restrict error)
3244 {
3245   if (text)
3246     {
3247       *error = 0;
3248       text->rotation = angle;
3249     }
3250   else
3251     {
3252       LOG_ERROR ("%s: empty text", __FUNCTION__)
3253       *error = 1;
3254     }
3255 }
3256 
3257 /** Returns the _dwg_entity_TEXT::vert_alignment, DXF 73.
3258 \code Usage: short align = dwg_ent_text_get_vert_alignment(text, &error);
3259 \endcode
3260 \param[in] text dwg_ent_text*
3261 \param[out] error   int*, is set to 0 for ok, 1 on error
3262 \return short(1 = bottom, 2 = middle, 3 = top)
3263 */
3264 BITCODE_BS
dwg_ent_text_get_vert_alignment(const dwg_ent_text * restrict text,int * restrict error)3265 dwg_ent_text_get_vert_alignment (const dwg_ent_text *restrict text,
3266                                  int *restrict error)
3267 {
3268   if (text)
3269     {
3270       *error = 0;
3271       return text->vert_alignment;
3272     }
3273   else
3274     {
3275       LOG_ERROR ("%s: empty text", __FUNCTION__)
3276       *error = 1;
3277       return -1;
3278     }
3279 }
3280 
3281 /** Sets the _dwg_entity_TEXT::vert_alignment, DXF 73.
3282 \code Usage: dwg_ent_text_set_vert_alignment(text, angle, &error);
3283 \endcode
3284 \param[in] text dwg_ent_text*
3285 \param[in] alignment  short (1 = bottom, 2 = middle, 3 = top)
3286 \param[out] error   int*, is set to 0 for ok, 1 on error
3287 \deprecated
3288 */
3289 void
dwg_ent_text_set_vert_alignment(dwg_ent_text * restrict text,const BITCODE_BS alignment,int * restrict error)3290 dwg_ent_text_set_vert_alignment (dwg_ent_text *restrict text,
3291                                  const BITCODE_BS alignment,
3292                                  int *restrict error)
3293 {
3294   if (text)
3295     {
3296       *error = 0;
3297       // TODO: validation 1-3
3298       text->vert_alignment = alignment;
3299     }
3300   else
3301     {
3302       LOG_ERROR ("%s: empty text", __FUNCTION__)
3303       *error = 1;
3304     }
3305 }
3306 
3307 /** Returns the _dwg_entity_TEXT::horiz_alignment, DXF 72.
3308 \code Usage: short align = dwg_ent_text_get_horiz_alignment(text, &error);
3309 \endcode
3310 \param[in] text dwg_ent_text*
3311 \param[out] error   int*, is set to 0 for ok, 1 on error
3312 \return (1 = left, 2 = center, 3 = right)
3313 */
3314 BITCODE_BS
dwg_ent_text_get_horiz_alignment(const dwg_ent_text * restrict text,int * restrict error)3315 dwg_ent_text_get_horiz_alignment (const dwg_ent_text *restrict text,
3316                                   int *restrict error)
3317 {
3318   if (text)
3319     {
3320       *error = 0;
3321       return text->horiz_alignment;
3322     }
3323   else
3324     {
3325       LOG_ERROR ("%s: empty text", __FUNCTION__)
3326       *error = 1;
3327       return 0;
3328     }
3329 }
3330 
3331 /** Sets the _dwg_entity_TEXT::horiz_alignment, DXF 72.
3332 \code Usage: dwg_ent_text_set_horiz_alignment(text, angle, &error);
3333 \endcode
3334 \param[in] text      dwg_ent_text*
3335 \param[in] alignment short (1 = left, 2 = center, 3 = right)
3336 \param[out] error    int*, is set to 0 for ok, 1 on error
3337 \deprecated
3338 */
3339 void
dwg_ent_text_set_horiz_alignment(dwg_ent_text * restrict text,const BITCODE_BS alignment,int * restrict error)3340 dwg_ent_text_set_horiz_alignment (dwg_ent_text *restrict text,
3341                                   const BITCODE_BS alignment,
3342                                   int *restrict error)
3343 {
3344   if (text)
3345     {
3346       *error = 0;
3347       // TODO: validation 1-3
3348       text->horiz_alignment = alignment;
3349     }
3350   else
3351     {
3352       LOG_ERROR ("%s: empty text", __FUNCTION__)
3353       *error = 1;
3354     }
3355 }
3356 
3357 /*******************************************************************
3358  *                   FUNCTIONS FOR ATTRIB ENTITY                     *
3359  ********************************************************************/
3360 
3361 /** Sets the _dwg_entity_ATTRIB::text_value (utf-8 encoded), DXF 1
3362 \code Usage: dwg_ent_attrib_set_text(attrib, "Hello world", &error);
3363 \endcode
3364 \param[out] attrib     dwg_ent_attrib*
3365 \param[in]  text_value utf-8 string (char *)
3366 \param[out] error      int*, is set to 0 for ok, 1 on error
3367 \deprecated
3368 */
3369 void
dwg_ent_attrib_set_text(dwg_ent_attrib * restrict ent,const char * restrict text_value,int * restrict error)3370 dwg_ent_attrib_set_text (dwg_ent_attrib *restrict ent,
3371                          const char *restrict text_value, int *restrict error)
3372 {
3373   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
3374   if (ent && !error)
3375     {
3376       ent->text_value = dwg_add_u8_input (dwg, text_value);
3377     }
3378   else
3379     {
3380       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3381       *error = 1;
3382     }
3383 }
3384 
3385 /** Returns the _dwg_entity_ATTRIB::text_value (utf-8 encoded), DXF 1.
3386 \code Usage: char * text_val = dwg_ent_attrib_get_text(attrib, &error);
3387 \endcode
3388 \param[in] attrib dwg_ent_attrib*
3389 \param[out] error   int*, is set to 0 for ok, 1 on error
3390 \deprecated
3391 */
3392 char *
dwg_ent_attrib_get_text(const dwg_ent_attrib * restrict ent,int * restrict error)3393 dwg_ent_attrib_get_text (const dwg_ent_attrib *restrict ent,
3394                          int *restrict error)
3395 {
3396   if (ent)
3397     {
3398       *error = 0;
3399       if (dwg_version >= R_2007)
3400         return bit_convert_TU ((BITCODE_TU)ent->text_value);
3401       else
3402         return ent->text_value;
3403     }
3404   else
3405     {
3406       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3407       *error = 1;
3408       return NULL;
3409     }
3410 }
3411 
3412 /** Returns the _dwg_entity_ATTRIB::ins_pt, DXF 10.
3413 \code Usage: dwg_ent_attrib_get_insertion_pt(attrib, &point, &error);
3414 \endcode
3415 \param[in] attrib   dwg_ent_attrib*
3416 \param[out] point   dwg_point_3d
3417 \param[out] error   int*, is set to 0 for ok, 1 on error
3418 \deprecated
3419 */
3420 void
dwg_ent_attrib_get_insertion_pt(const dwg_ent_attrib * restrict attrib,dwg_point_2d * restrict point,int * restrict error)3421 dwg_ent_attrib_get_insertion_pt (const dwg_ent_attrib *restrict attrib,
3422                                     dwg_point_2d *restrict point,
3423                                     int *restrict error)
3424 {
3425   if (attrib
3426 #  ifndef HAVE_NONNULL
3427       && point
3428 #  endif
3429   )
3430     {
3431       *error = 0;
3432       point->x = attrib->ins_pt.x;
3433       point->y = attrib->ins_pt.y;
3434     }
3435   else
3436     {
3437       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3438       *error = 1;
3439     }
3440 }
3441 
3442 /** Sets the _dwg_entity_ATTRIB::ins_pt, DXF 10
3443 \code Usage: dwg_ent_attrib_set_insertion_pt(attrib, &point, &error)
3444 \endcode
3445 \param[in] attrib   dwg_ent_attrib*
3446 \param[in] point    dwg_point_3d
3447 \param[out] error   int*, is set to 0 for ok, 1 on error
3448 \deprecated
3449 */
3450 void
dwg_ent_attrib_set_insertion_pt(dwg_ent_attrib * restrict attrib,const dwg_point_2d * restrict point,int * restrict error)3451 dwg_ent_attrib_set_insertion_pt (dwg_ent_attrib *restrict attrib,
3452                                     const dwg_point_2d *restrict point,
3453                                     int *restrict error)
3454 {
3455   if (attrib
3456 #  ifndef HAVE_NONNULL
3457       && point
3458 #  endif
3459   )
3460     {
3461       *error = 0;
3462       attrib->ins_pt.x = point->x;
3463       attrib->ins_pt.y = point->y;
3464     }
3465   else
3466     {
3467       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3468       *error = 1;
3469     }
3470 }
3471 
3472 /** Returns the _dwg_entity_ATTRIB::height, DXF 40
3473 \code Usage: double height = dwg_ent_attrib_get_height(attrib, &error);
3474 \endcode
3475 \param[in] attrib dwg_ent_attrib*
3476 \param[out] error   int*, is set to 0 for ok, 1 on error
3477 \deprecated
3478 */
3479 double
dwg_ent_attrib_get_height(const dwg_ent_attrib * restrict attrib,int * restrict error)3480 dwg_ent_attrib_get_height (const dwg_ent_attrib *restrict attrib,
3481                            int *restrict error)
3482 {
3483   if (attrib)
3484     {
3485       *error = 0;
3486       return attrib->height;
3487     }
3488   else
3489     {
3490       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3491       *error = 1;
3492       return bit_nan ();
3493     }
3494 }
3495 
3496 /** Sets the _dwg_entity_ATTRIB::height, DXF 40
3497 \code Usage: dwg_ent_attrib_set_height(attrib, 100, &error);
3498 \endcode
3499 \param[in] attrib   dwg_ent_attrib*
3500 \param[in] height   double
3501 \param[out] error   int*, is set to 0 for ok, 1 on error
3502 \deprecated
3503 */
3504 void
dwg_ent_attrib_set_height(dwg_ent_attrib * restrict attrib,const double height,int * restrict error)3505 dwg_ent_attrib_set_height (dwg_ent_attrib *restrict attrib,
3506                            const double height, int *restrict error)
3507 {
3508   if (attrib)
3509     {
3510       *error = 0;
3511       attrib->height = height;
3512     }
3513   else
3514     {
3515       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3516       *error = 1;
3517     }
3518 }
3519 
3520 /** Returns the _dwg_entity_ATTRIB::extrusion vector, DXF 210
3521 \code Usage: dwg_ent_attrib_get_extrusion(attrib, &point, &error);
3522 \endcode
3523 \param[in]  attrib  dwg_ent_attrib*
3524 \param[out] vector  dwg_point_3d *
3525 \param[out] error   int*, is set to 0 for ok, 1 on error
3526 \deprecated
3527 */
3528 void
dwg_ent_attrib_get_extrusion(const dwg_ent_attrib * restrict attrib,dwg_point_3d * restrict vector,int * restrict error)3529 dwg_ent_attrib_get_extrusion (const dwg_ent_attrib *restrict attrib,
3530                               dwg_point_3d *restrict vector,
3531                               int *restrict error)
3532 {
3533   if (attrib
3534 #  ifndef HAVE_NONNULL
3535       && vector
3536 #  endif
3537   )
3538     {
3539       *error = 0;
3540       vector->x = attrib->extrusion.x;
3541       vector->y = attrib->extrusion.y;
3542       vector->z = attrib->extrusion.z;
3543     }
3544   else
3545     {
3546       LOG_ERROR ("%s: empty attrib or vector", __FUNCTION__)
3547       *error = 1;
3548     }
3549 }
3550 
3551 /** Sets the _dwg_entity_ATTRIB::extrusion vector, DXF 210
3552 \code Usage: dwg_ent_attrib_set_extrusion(attrib, &point, &error);
3553 \endcode
3554 \param[out]  attrib  dwg_ent_attrib*
3555 \param[in] vector  dwg_point_3d
3556 \param[out] error   int*, is set to 0 for ok, 1 on error
3557 \deprecated
3558 */
3559 void
dwg_ent_attrib_set_extrusion(dwg_ent_attrib * restrict attrib,const dwg_point_3d * restrict vector,int * restrict error)3560 dwg_ent_attrib_set_extrusion (dwg_ent_attrib *restrict attrib,
3561                               const dwg_point_3d *restrict vector,
3562                               int *restrict error)
3563 {
3564   if (attrib
3565 #  ifndef HAVE_NONNULL
3566       && vector
3567 #  endif
3568   )
3569     {
3570       *error = 0;
3571       attrib->extrusion.x = vector->x;
3572       attrib->extrusion.y = vector->y;
3573       attrib->extrusion.z = vector->z;
3574     }
3575   else
3576     {
3577       LOG_ERROR ("%s: empty attrib or vector", __FUNCTION__)
3578       *error = 1;
3579     }
3580 }
3581 
3582 /** Returns the _dwg_entity_ATTRIB::thickness, DXF 39
3583 \code Usage: double thick = dwg_ent_attrib_get_thickness(attrib, &error);
3584 \endcode
3585 \param[in] attrib dwg_ent_attrib*
3586 \param[out] error   int*, is set to 0 for ok, 1 on error
3587 \deprecated
3588 */
3589 double
dwg_ent_attrib_get_thickness(const dwg_ent_attrib * restrict attrib,int * restrict error)3590 dwg_ent_attrib_get_thickness (const dwg_ent_attrib *restrict attrib,
3591                               int *restrict error)
3592 {
3593   if (attrib)
3594     {
3595       *error = 0;
3596       return attrib->thickness;
3597     }
3598   else
3599     {
3600       *error = 1;
3601       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3602       return bit_nan ();
3603     }
3604 }
3605 
3606 /** Sets the _dwg_entity_ATTRIB::thickness, DXF 39
3607 \code Usage: dwg_ent_attrib_set_thickness(attrib, thick, &error);
3608 \endcode
3609 \param[out] attrib dwg_ent_attrib*
3610 \param[in] thickness double
3611 \param[out] error   int*, is set to 0 for ok, 1 on error
3612 \deprecated
3613 */
3614 void
dwg_ent_attrib_set_thickness(dwg_ent_attrib * restrict attrib,const double thickness,int * restrict error)3615 dwg_ent_attrib_set_thickness (dwg_ent_attrib *restrict attrib,
3616                               const double thickness, int *restrict error)
3617 {
3618   if (attrib)
3619     {
3620       *error = 0;
3621       attrib->thickness = thickness;
3622     }
3623   else
3624     {
3625       *error = 1;
3626       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3627     }
3628 }
3629 
3630 /** Returns the _dwg_entity_ATTRIB::rotation, DXF 50 (in radians)
3631 \code Usage: double angle = dwg_ent_attrib_get_rot_angle(attrib, &error);
3632 \endcode
3633 \param[in] attrib dwg_ent_attrib*
3634 \param[out] error   int*, is set to 0 for ok, 1 on error
3635 \deprecated
3636 */
3637 double
dwg_ent_attrib_get_rotation(const dwg_ent_attrib * restrict attrib,int * restrict error)3638 dwg_ent_attrib_get_rotation (const dwg_ent_attrib *restrict attrib,
3639                              int *restrict error)
3640 {
3641   if (attrib)
3642     {
3643       *error = 0;
3644       return attrib->rotation;
3645     }
3646   else
3647     {
3648       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3649       *error = 1;
3650       return bit_nan ();
3651     }
3652 }
3653 
3654 /** Sets the _dwg_entity_ATTRIB::rotation, DXF 50 (in radians)
3655 \code Usage: dwg_ent_attrib_set_rotation(attrib, angle, &error);
3656 \endcode
3657 \param[out] attrib  dwg_ent_attrib*
3658 \param[in] angle   double
3659 \param[out] error   int*, is set to 0 for ok, 1 on error
3660 \deprecated
3661 */
3662 void
dwg_ent_attrib_set_rotation(dwg_ent_attrib * restrict attrib,const double angle,int * restrict error)3663 dwg_ent_attrib_set_rotation (dwg_ent_attrib *restrict attrib,
3664                              const double angle, int *restrict error)
3665 {
3666   if (attrib)
3667     {
3668       *error = 0;
3669       attrib->rotation = angle;
3670     }
3671   else
3672     {
3673       *error = 1;
3674       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3675     }
3676 }
3677 
3678 /** Returns the _dwg_entity_ATTRIB::vert_alignment, DXF 73
3679 \code Usage: short vert_align = dwg_ent_attrib_get_vert_alignment(attrib,
3680 &error); \endcode \param[in] attrib dwg_ent_attrib* \param[out] error   int*,
3681 is set to 0 for ok, 1 on error \return short(1 = bottom, 2 = middle, 3 = top)
3682 */
3683 BITCODE_BS
dwg_ent_attrib_get_vert_alignment(const dwg_ent_attrib * restrict attrib,int * restrict error)3684 dwg_ent_attrib_get_vert_alignment (const dwg_ent_attrib *restrict attrib,
3685                                    int *restrict error)
3686 {
3687   if (attrib)
3688     {
3689       *error = 0;
3690       return attrib->vert_alignment;
3691     }
3692   else
3693     {
3694       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3695       *error = 1;
3696       return -1;
3697     }
3698 }
3699 
3700 /** Sets the  _dwg_entity_ATTRIB::vert_alignment, DXF 73
3701 \code Usage: dwg_ent_attrib_set_vert_alignment(attrib, angle, &error);
3702 \endcode
3703 \param[in] attrib dwg_ent_attrib*
3704 \param[in] short (1 = bottom, 2 = middle, 3 = top)
3705 \param[out] error   int*, is set to 0 for ok, 1 on error
3706 \deprecated
3707 */
3708 void
dwg_ent_attrib_set_vert_alignment(dwg_ent_attrib * restrict attrib,BITCODE_BS alignment,int * restrict error)3709 dwg_ent_attrib_set_vert_alignment (dwg_ent_attrib *restrict attrib,
3710                                    BITCODE_BS alignment, int *restrict error)
3711 {
3712   if (attrib)
3713     {
3714       *error = 0;
3715       attrib->vert_alignment = alignment;
3716     }
3717   else
3718     {
3719       LOG_ERROR ("%s: empty attrib", __FUNCTION__)
3720       *error = 1;
3721     }
3722 }
3723 
3724 /** Returns the _dwg_entity_ATTRIB::horiz_alignment, DXF 72
3725 \code Usage: short horiz_align =  dwg_ent_attrib_get_horiz_alignment(attrib,
3726 &error); \endcode \param[in] attrib dwg_ent_attrib* \param[out] error int*, is
3727 set to 0 for ok, 1 on error \return (1 = left, 2 = center, 3 = right)
3728 */
3729 BITCODE_BS
dwg_ent_attrib_get_horiz_alignment(const dwg_ent_attrib * restrict attrib,int * restrict error)3730 dwg_ent_attrib_get_horiz_alignment (const dwg_ent_attrib *restrict attrib,
3731                                     int *restrict error)
3732 {
3733   if (attrib)
3734     {
3735       *error = 0;
3736       return attrib->horiz_alignment;
3737     }
3738   else
3739     {
3740       *error = 1;
3741       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3742       return -1;
3743     }
3744 }
3745 
3746 /** Sets the  _dwg_entity_ATTRIB::horiz_alignment, DXF 72
3747 \code Usage: dwg_ent_attrib_set_horiz_alignment(attrib, angle, &error);
3748 \endcode
3749 \param[out] attrib dwg_ent_attrib*
3750 \param[in]  alignment short (1 = left, 2 = center, 3 = right)
3751 \param[out] error   int*, is set to 0 for ok, 1 on error
3752 \deprecated
3753 */
3754 void
dwg_ent_attrib_set_horiz_alignment(dwg_ent_attrib * restrict attrib,const BITCODE_BS alignment,int * restrict error)3755 dwg_ent_attrib_set_horiz_alignment (dwg_ent_attrib *restrict attrib,
3756                                     const BITCODE_BS alignment,
3757                                     int *restrict error)
3758 {
3759   if (attrib)
3760     {
3761       *error = 0;
3762       attrib->horiz_alignment = alignment;
3763     }
3764   else
3765     {
3766       *error = 1;
3767       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3768     }
3769 }
3770 
3771 /*******************************************************************
3772  *                   FUNCTIONS FOR ATTDEF ENTITY                     *
3773  ********************************************************************/
3774 
3775 /** Sets the _dwg_entity_ATTDEF::default_value, DXF 1 (utf-8 encoded).
3776 \code Usage: dwg_ent_attdef_set_text(attdef, "Hello world", &error);
3777 \endcode
3778 \param[in]  attdef dwg_ent_attdef*
3779 \param[in]  default_value utf-8 string (char *)
3780 \param[out] error   int*, is set to 0 for ok, 1 on error
3781 \deprecated
3782 */
3783 void
dwg_ent_attdef_set_default_value(dwg_ent_attdef * restrict ent,const char * restrict default_value,int * restrict error)3784 dwg_ent_attdef_set_default_value (dwg_ent_attdef *restrict ent,
3785                                   const char *restrict default_value,
3786                                   int *restrict error)
3787 {
3788   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
3789   if (ent && !error)
3790     {
3791       ent->default_value = dwg_add_u8_input (dwg, default_value);
3792     }
3793   else
3794     {
3795       *error = 1;
3796       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3797     }
3798 }
3799 
3800 /** Returns the _dwg_entity_ATTDEF::default_value, DXF 1 (utf-8 encoded).
3801 \code Usage: char * text = dwg_ent_attdef_get_text(attdef, &error);
3802 \endcode
3803 \param[in] attdef dwg_ent_attdef*
3804 \param[out] error   int*, is set to 0 for ok, 1 on error
3805 \deprecated
3806 */
3807 char *
dwg_ent_attdef_get_default_value(const dwg_ent_attdef * restrict ent,int * restrict error)3808 dwg_ent_attdef_get_default_value (const dwg_ent_attdef *restrict ent,
3809                                   int *restrict error)
3810 {
3811   if (ent)
3812     {
3813       *error = 0;
3814       if (dwg_version >= R_2007)
3815         return bit_convert_TU ((BITCODE_TU)ent->default_value);
3816       else
3817         return ent->default_value;
3818     }
3819   else
3820     {
3821       LOG_ERROR ("%s: empty attdef", __FUNCTION__)
3822       *error = 1;
3823       return NULL;
3824     }
3825 }
3826 
3827 /** Returns the _dwg_entity_ATTDEF::ins_pt, DXF 10
3828 \code Usage: dwg_ent_attdef_get_insertion_pt(attdef, &point, &error);
3829 \endcode
3830 \param[in]  attdef  dwg_ent_attdef*
3831 \param[out] point   dwg_point_2d*
3832 \param[out] error   int*, is set to 0 for ok, 1 on error
3833 \deprecated
3834 */
3835 void
dwg_ent_attdef_get_insertion_pt(const dwg_ent_attdef * restrict attdef,dwg_point_2d * restrict point,int * restrict error)3836 dwg_ent_attdef_get_insertion_pt (const dwg_ent_attdef *restrict attdef,
3837                                     dwg_point_2d *restrict point,
3838                                     int *restrict error)
3839 {
3840   if (attdef
3841 #  ifndef HAVE_NONNULL
3842       && point
3843 #  endif
3844   )
3845     {
3846       *error = 0;
3847       point->x = attdef->ins_pt.x;
3848       point->y = attdef->ins_pt.y;
3849     }
3850   else
3851     {
3852       *error = 1;
3853       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3854     }
3855 }
3856 
3857 /** Sets the _dwg_entity_ATTDEF::ins_pt, DXF 10
3858 \code Usage: dwg_ent_attdef_set_insertion_pt(attdef, &point, &error)
3859 \endcode
3860 \param[in] attdef   dwg_ent_attdef*
3861 \param[in] point    dwg_point_2d*
3862 \param[out] error   int*, is set to 0 for ok, 1 on error
3863 \deprecated
3864 */
3865 void
dwg_ent_attdef_set_insertion_pt(dwg_ent_attdef * restrict attdef,const dwg_point_2d * restrict point,int * restrict error)3866 dwg_ent_attdef_set_insertion_pt (dwg_ent_attdef *restrict attdef,
3867                                     const dwg_point_2d *restrict point,
3868                                     int *restrict error)
3869 {
3870   if (attdef
3871 #  ifndef HAVE_NONNULL
3872       && point
3873 #  endif
3874   )
3875     {
3876       *error = 0;
3877       attdef->ins_pt.x = point->x;
3878       attdef->ins_pt.y = point->y;
3879     }
3880   else
3881     {
3882       *error = 1;
3883       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3884     }
3885 }
3886 
3887 /** Returns the _dwg_entity_ATTDEF::height, DXF 40.
3888 \code Usage: dwg_ent_attdef_get_height(attdef, &error);
3889 \endcode
3890 \param[in] attdef dwg_ent_attdef*
3891 \param[out] error   int*, is set to 0 for ok, 1 on error
3892 \deprecated
3893 */
3894 double
dwg_ent_attdef_get_height(const dwg_ent_attdef * restrict attdef,int * restrict error)3895 dwg_ent_attdef_get_height (const dwg_ent_attdef *restrict attdef,
3896                            int *restrict error)
3897 {
3898   if (attdef)
3899     {
3900       *error = 0;
3901       return attdef->height;
3902     }
3903   else
3904     {
3905       *error = 1;
3906       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3907       return bit_nan ();
3908     }
3909 }
3910 
3911 /** Sets the _dwg_entity_ATTDEF::height, DXF 40.
3912 \code Usage: dwg_ent_attdef_set_height(attdef, 10.0, &error);
3913 \endcode
3914 \param[in] attdef dwg_ent_attdef*
3915 \param[in] height double
3916 \param[out] error int*, is set to 0 for ok, 1 on error
3917 \deprecated
3918 */
3919 void
dwg_ent_attdef_set_height(dwg_ent_attdef * restrict attdef,const double height,int * restrict error)3920 dwg_ent_attdef_set_height (dwg_ent_attdef *restrict attdef,
3921                            const double height, int *restrict error)
3922 {
3923   if (attdef)
3924     {
3925       *error = 0;
3926       attdef->height = height;
3927     }
3928   else
3929     {
3930       *error = 1;
3931       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3932     }
3933 }
3934 
3935 /** Returns the _dwg_entity_ATTDEF::extrusion vector, DXF 210
3936 \code Usage: dwg_ent_attdef_get_extrusion(attdef, &point, &error);
3937 \endcode
3938 \param[in]  attdef  dwg_ent_attdef*
3939 \param[out] vector  dwg_point_3d*
3940 \param[out] error   int*, is set to 0 for ok, 1 on error
3941 \deprecated
3942 */
3943 void
dwg_ent_attdef_get_extrusion(const dwg_ent_attdef * restrict attdef,dwg_point_3d * restrict vector,int * restrict error)3944 dwg_ent_attdef_get_extrusion (const dwg_ent_attdef *restrict attdef,
3945                               dwg_point_3d *restrict vector,
3946                               int *restrict error)
3947 {
3948   if (attdef
3949 #  ifndef HAVE_NONNULL
3950       && vector
3951 #  endif
3952   )
3953     {
3954       *error = 0;
3955       vector->x = attdef->extrusion.x;
3956       vector->y = attdef->extrusion.y;
3957       vector->z = attdef->extrusion.z;
3958     }
3959   else
3960     {
3961       *error = 1;
3962       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3963     }
3964 }
3965 
3966 /** Sets the _dwg_entity_ATTDEF::extrusion vector, DXF 210
3967 \code Usage: dwg_ent_attdef_set_extrusion(attdef, &point, &error);
3968 \endcode
3969 \param[in] attdef dwg_ent_attdef*
3970 \param[in] vector  dwg_point_3d*
3971 \param[out] error   int*, is set to 0 for ok, 1 on error
3972 \deprecated
3973 */
3974 void
dwg_ent_attdef_set_extrusion(dwg_ent_attdef * restrict attdef,const dwg_point_3d * restrict vector,int * restrict error)3975 dwg_ent_attdef_set_extrusion (dwg_ent_attdef *restrict attdef,
3976                               const dwg_point_3d *restrict vector,
3977                               int *restrict error)
3978 {
3979   if (attdef
3980 #  ifndef HAVE_NONNULL
3981       && vector
3982 #  endif
3983   )
3984     {
3985       *error = 0;
3986       attdef->extrusion.x = vector->x;
3987       attdef->extrusion.y = vector->y;
3988       attdef->extrusion.z = vector->z;
3989     }
3990   else
3991     {
3992       *error = 1;
3993       LOG_ERROR ("%s: empty arg", __FUNCTION__)
3994     }
3995 }
3996 
3997 /** Returns the _dwg_entity_ATTDEF::thickness vector, DXF 39.
3998 \code Usage: double thickness = dwg_ent_attdef_get_thickness(attdef, &error);
3999 \endcode
4000 \param[in] attdef dwg_ent_attdef*
4001 \param[out] error   int*, is set to 0 for ok, 1 on error
4002 \deprecated
4003 */
4004 double
dwg_ent_attdef_get_thickness(const dwg_ent_attdef * restrict attdef,int * restrict error)4005 dwg_ent_attdef_get_thickness (const dwg_ent_attdef *restrict attdef,
4006                               int *restrict error)
4007 {
4008   if (attdef)
4009     {
4010       *error = 0;
4011       return attdef->thickness;
4012     }
4013   else
4014     {
4015       *error = 1;
4016       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4017       return bit_nan ();
4018     }
4019 }
4020 
4021 /** Sets the _dwg_entity_ATTDEF::thickness vector, DXF 39.
4022 \code Usage: dwg_ent_attdef_set_thickness(attdef, thickness, &error);
4023 \endcode
4024 \param[in] attdef dwg_ent_attdef*
4025 \param[in] thickness double
4026 \param[out] error   int*, is set to 0 for ok, 1 on error
4027 \deprecated
4028 */
4029 void
dwg_ent_attdef_set_thickness(dwg_ent_attdef * restrict attdef,const double thickness,int * restrict error)4030 dwg_ent_attdef_set_thickness (dwg_ent_attdef *restrict attdef,
4031                               const double thickness, int *restrict error)
4032 {
4033   if (attdef)
4034     {
4035       *error = 0;
4036       attdef->thickness = thickness;
4037     }
4038   else
4039     {
4040       *error = 1;
4041       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4042     }
4043 }
4044 
4045 /** Returns the _dwg_entity_ATTDEF::rotation agle, DXF 50 (radian).
4046 \code Usage: double angle = dwg_ent_attdef_get_rotation(attdef, &error);
4047 \endcode
4048 \param[in] attdef dwg_ent_attdef*
4049 \param[out] error   int*, is set to 0 for ok, 1 on error
4050 \deprecated
4051 */
4052 double
dwg_ent_attdef_get_rotation(const dwg_ent_attdef * restrict attdef,int * restrict error)4053 dwg_ent_attdef_get_rotation (const dwg_ent_attdef *restrict attdef,
4054                              int *restrict error)
4055 {
4056   if (attdef)
4057     {
4058       *error = 0;
4059       return attdef->rotation;
4060     }
4061   else
4062     {
4063       *error = 1;
4064       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4065       return bit_nan ();
4066     }
4067 }
4068 
4069 /** Sets the _dwg_entity_ATTDEF::rotation angle, DXF 50 (radian).
4070 \code Usage: dwg_ent_attdef_set_rotation(attdef, angle, &error);
4071 \endcode
4072 \param[in] attdef dwg_ent_attdef*
4073 \param[in] angle double
4074 \param[out] error   int*, is set to 0 for ok, 1 on error
4075 \deprecated
4076 */
4077 void
dwg_ent_attdef_set_rotation(dwg_ent_attdef * restrict attdef,const double angle,int * restrict error)4078 dwg_ent_attdef_set_rotation (dwg_ent_attdef *restrict attdef,
4079                              const double angle, int *restrict error)
4080 {
4081   if (attdef)
4082     {
4083       *error = 0;
4084       attdef->rotation = angle;
4085     }
4086   else
4087     {
4088       *error = 1;
4089       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4090     }
4091 }
4092 
4093 /** Returns the _dwg_entity_ATTDEF::vert_alignment, DXF 74.
4094 \code Usage: short vert_align = dwg_ent_attdef_get_vert_alignment(attdef,
4095 &error); \endcode \param[in] attdef dwg_ent_attdef* \param[out] error   int*,
4096 is set to 0 for ok, 1 on error \return (1 = bottom, 2 = middle, 3 = top)
4097 */
4098 BITCODE_BS
dwg_ent_attdef_get_vert_alignment(const dwg_ent_attdef * restrict attdef,int * restrict error)4099 dwg_ent_attdef_get_vert_alignment (const dwg_ent_attdef *restrict attdef,
4100                                    int *restrict error)
4101 {
4102   if (attdef)
4103     {
4104       *error = 0;
4105       return attdef->vert_alignment;
4106     }
4107   else
4108     {
4109       *error = 1;
4110       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4111       return -1;
4112     }
4113 }
4114 
4115 /** Sets the _dwg_entity_ATTDEF::vert_alignment, DXF 74.
4116 \code Usage: dwg_ent_attdef_set_vert_alignment(attdef, angle, &error);
4117 \endcode
4118 \param[in] attdef dwg_ent_attdef*
4119 \param[in] alignment (1 = bottom, 2 = middle, 3 = top)
4120 \param[out] error   int*, is set to 0 for ok, 1 on error
4121 \deprecated
4122 */
4123 void
dwg_ent_attdef_set_vert_alignment(dwg_ent_attdef * restrict attdef,const BITCODE_BS alignment,int * restrict error)4124 dwg_ent_attdef_set_vert_alignment (dwg_ent_attdef *restrict attdef,
4125                                    const BITCODE_BS alignment,
4126                                    int *restrict error)
4127 {
4128   if (attdef)
4129     {
4130       *error = 0;
4131       attdef->vert_alignment = alignment;
4132     }
4133   else
4134     {
4135       *error = 1;
4136       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4137     }
4138 }
4139 
4140 /** Returns the _dwg_entity_ATTDEF::horiz_alignment, DXF 72.
4141 \code Usage: short horiz_align = dwg_ent_attdef_get_horiz_alignment(attdef,
4142 &error); \endcode \param[in] attdef dwg_ent_attdef* \param[out] error   int*,
4143 is set to 0 for ok, 1 on error \return (1 = left, 2 = center, 3 = right)
4144 */
4145 BITCODE_BS
dwg_ent_attdef_get_horiz_alignment(const dwg_ent_attdef * restrict attdef,int * restrict error)4146 dwg_ent_attdef_get_horiz_alignment (const dwg_ent_attdef *restrict attdef,
4147                                     int *restrict error)
4148 {
4149   if (attdef)
4150     {
4151       *error = 0;
4152       return attdef->horiz_alignment;
4153     }
4154   else
4155     {
4156       *error = 1;
4157       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4158       return -1;
4159     }
4160 }
4161 
4162 /** Sets the _dwg_entity_ATTDEF::horiz_alignment, DXF 72.
4163 \code Usage: dwg_ent_attdef_set_horiz_alignment(attdef, alignment, &error);
4164 \endcode
4165 \param[in] attdef dwg_ent_attdef*
4166 \param[in] alignment short (1 = left, 2 = center, 3 = right)
4167 \param[out] error   int*, is set to 0 for ok, 1 on error
4168 \deprecated
4169 */
4170 void
dwg_ent_attdef_set_horiz_alignment(dwg_ent_attdef * restrict attdef,const BITCODE_BS alignment,int * restrict error)4171 dwg_ent_attdef_set_horiz_alignment (dwg_ent_attdef *restrict attdef,
4172                                     const BITCODE_BS alignment,
4173                                     int *restrict error)
4174 {
4175   if (attdef)
4176     {
4177       *error = 0;
4178       attdef->horiz_alignment = alignment;
4179     }
4180   else
4181     {
4182       *error = 1;
4183       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4184     }
4185 }
4186 
4187 /*******************************************************************
4188  *                   FUNCTIONS FOR POINT ENTITY                      *
4189  ********************************************************************/
4190 
4191 /** Sets the _dwg_entity_POINT::point, DXF 10.
4192 \code Usage: dwg_ent_point_set_point(point, &retpoint, &error);
4193 \endcode
4194 \param[out] point dwg_ent_point*
4195 \param[in]  retpoint dwg_point_3d
4196 \param[out] error   int*, is set to 0 for ok, 1 on error
4197 \deprecated
4198 */
4199 void
dwg_ent_point_set_point(dwg_ent_point * restrict point,const dwg_point_3d * restrict retpoint,int * restrict error)4200 dwg_ent_point_set_point (dwg_ent_point *restrict point,
4201                          const dwg_point_3d *restrict retpoint,
4202                          int *restrict error)
4203 {
4204   if (point
4205 #  ifndef HAVE_NONNULL
4206       && retpoint
4207 #  endif
4208   )
4209     {
4210       *error = 0;
4211       point->x = retpoint->x;
4212       point->y = retpoint->y;
4213       point->z = retpoint->z;
4214     }
4215   else
4216     {
4217       *error = 1;
4218       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4219     }
4220 }
4221 
4222 /** Returns the  _dwg_entity_POINT::point, DXF 10.
4223 \code Usage: dwg_ent_point_get_point(point, &retpoint, &error);
4224 \endcode
4225 \param[in]  point dwg_ent_point*
4226 \param[out] retpoint dwg_point_3d
4227 \param[out] error   int*, is set to 0 for ok, 1 on error
4228 \deprecated
4229 */
4230 void
dwg_ent_point_get_point(const dwg_ent_point * restrict point,dwg_point_3d * restrict retpoint,int * restrict error)4231 dwg_ent_point_get_point (const dwg_ent_point *restrict point,
4232                          dwg_point_3d *restrict retpoint, int *restrict error)
4233 {
4234   if (point
4235 #  ifndef HAVE_NONNULL
4236       && retpoint
4237 #  endif
4238   )
4239     {
4240       *error = 0;
4241       retpoint->x = point->x;
4242       retpoint->y = point->y;
4243       retpoint->z = point->z;
4244     }
4245   else
4246     {
4247       *error = 1;
4248       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4249     }
4250 }
4251 
4252 /** Returns the _dwg_entity_POINT::thickness, DXF 39.
4253 \code Usage: double thickness = dwg_ent_point_get_thickness(point, &error);
4254 \endcode
4255 \param[in] point dwg_ent_point*
4256 \param[out] error   int*, is set to 0 for ok, 1 on error
4257 \deprecated
4258 */
4259 double
dwg_ent_point_get_thickness(const dwg_ent_point * restrict point,int * restrict error)4260 dwg_ent_point_get_thickness (const dwg_ent_point *restrict point,
4261                              int *restrict error)
4262 {
4263   if (point)
4264     {
4265       *error = 0;
4266       return point->thickness;
4267     }
4268   else
4269     {
4270       *error = 1;
4271       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4272       return bit_nan ();
4273     }
4274 }
4275 
4276 /** Sets the  _dwg_entity_POINT::thickness, DXF 39.
4277 \code Usage: dwg_ent_point_set_thickness(point, thickness, &error);
4278 \endcode
4279 \param[out] point dwg_ent_point*
4280 \param[in] double
4281 \param[out] error   int*, is set to 0 for ok, 1 on error
4282 \deprecated
4283 */
4284 void
dwg_ent_point_set_thickness(dwg_ent_point * restrict point,const double thickness,int * restrict error)4285 dwg_ent_point_set_thickness (dwg_ent_point *restrict point,
4286                              const double thickness, int *restrict error)
4287 {
4288   if (point)
4289     {
4290       *error = 0;
4291       point->thickness = thickness;
4292     }
4293   else
4294     {
4295       *error = 1;
4296       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4297     }
4298 }
4299 
4300 /** Sets the _dwg_entity_POINT::extrusion vector, DXF 210.
4301 \code Usage: dwg_ent_point_set_extrusion(point, &retpoint, &error);
4302 \endcode
4303 \param[out]  point dwg_ent_point*
4304 \param[in] vector dwg_point_3d
4305 \param[out] error   int*, is set to 0 for ok, 1 on error
4306 \deprecated
4307 */
4308 void
dwg_ent_point_set_extrusion(dwg_ent_point * restrict point,const dwg_point_3d * restrict vector,int * restrict error)4309 dwg_ent_point_set_extrusion (dwg_ent_point *restrict point,
4310                              const dwg_point_3d *restrict vector,
4311                              int *restrict error)
4312 {
4313   if (point
4314 #  ifndef HAVE_NONNULL
4315       && vector
4316 #  endif
4317   )
4318     {
4319       *error = 0;
4320       point->extrusion.x = vector->x;
4321       point->extrusion.y = vector->y;
4322       point->extrusion.z = vector->z;
4323     }
4324   else
4325     {
4326       *error = 1;
4327       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4328     }
4329 }
4330 
4331 /** Returns the _dwg_entity_POINT::extrusion vector, DXF 210.
4332 \code Usage: dwg_ent_point_get_extrusion(point, &retpoint, &error);
4333 \endcode
4334 \param[in]  point dwg_ent_point*
4335 \param[out] vector dwg_point_3d
4336 \param[out] error   int*, is set to 0 for ok, 1 on error
4337 \deprecated
4338 */
4339 void
dwg_ent_point_get_extrusion(const dwg_ent_point * restrict point,dwg_point_3d * restrict vector,int * restrict error)4340 dwg_ent_point_get_extrusion (const dwg_ent_point *restrict point,
4341                              dwg_point_3d *restrict vector,
4342                              int *restrict error)
4343 {
4344   if (point
4345 #  ifndef HAVE_NONNULL
4346       && vector
4347 #  endif
4348   )
4349     {
4350       *error = 0;
4351       vector->x = point->extrusion.x;
4352       vector->y = point->extrusion.y;
4353       vector->z = point->extrusion.z;
4354     }
4355   else
4356     {
4357       *error = 1;
4358       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4359     }
4360 }
4361 
4362 /*******************************************************************
4363  *                   FUNCTIONS FOR SOLID ENTITY                      *
4364  ********************************************************************/
4365 
4366 /** Returns the _dwg_entity_SOLID::thickness, DXF 39.
4367 \code Usage: double thickness = dwg_ent_solid_get_thickness(solid, &error);
4368 \endcode
4369 \param[in] solid dwg_ent_solid*
4370 \param[out] error   int*, is set to 0 for ok, 1 on error
4371 \deprecated
4372 */
4373 double
dwg_ent_solid_get_thickness(const dwg_ent_solid * restrict solid,int * restrict error)4374 dwg_ent_solid_get_thickness (const dwg_ent_solid *restrict solid,
4375                              int *restrict error)
4376 {
4377   if (solid)
4378     {
4379       *error = 0;
4380       return solid->thickness;
4381     }
4382   else
4383     {
4384       *error = 1;
4385       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4386       return bit_nan ();
4387     }
4388 }
4389 
4390 /** Sets the _dwg_entity_SOLID::thickness, DXF 39.
4391 \code Usage: dwg_ent_solid_set_thickness(solid, 2.0, &error);
4392 \endcode
4393 \param[out] solid dwg_ent_solid*
4394 \param[in] thickness double
4395 \param[out] error   int*, is set to 0 for ok, 1 on error
4396 \deprecated
4397 */
4398 void
dwg_ent_solid_set_thickness(dwg_ent_solid * restrict solid,const double thickness,int * restrict error)4399 dwg_ent_solid_set_thickness (dwg_ent_solid *restrict solid,
4400                              const double thickness, int *restrict error)
4401 {
4402   if (solid)
4403     {
4404       *error = 0;
4405       solid->thickness = thickness;
4406     }
4407   else
4408     {
4409       *error = 1;
4410       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4411     }
4412 }
4413 
4414 /** Returns the _dwg_entity_SOLID::elevation (z-coord), DXF 38.
4415 \code Usage: double elev = dwg_ent_solid_get_elevation(solid, &error);
4416 \endcode
4417 \param[in] solid dwg_ent_solid*
4418 \param[out] error   int*, is set to 0 for ok, 1 on error
4419 \deprecated
4420 */
4421 double
dwg_ent_solid_get_elevation(const dwg_ent_solid * restrict solid,int * restrict error)4422 dwg_ent_solid_get_elevation (const dwg_ent_solid *restrict solid,
4423                              int *restrict error)
4424 {
4425   if (solid)
4426     {
4427       *error = 0;
4428       return solid->elevation;
4429     }
4430   else
4431     {
4432       *error = 1;
4433       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4434       return bit_nan ();
4435     }
4436 }
4437 
4438 /** Sets the _dwg_entity_SOLID::elevation (z-coord), DXF 38.
4439 \code Usage: dwg_ent_solid_set_elevation(solid, 20.0, &error);
4440 \endcode
4441 \param[in] solid dwg_ent_solid*
4442 \param[in] elevation double
4443 \param[out] error   int*, is set to 0 for ok, 1 on error
4444 \deprecated
4445 */
4446 void
dwg_ent_solid_set_elevation(dwg_ent_solid * restrict solid,const double elevation,int * restrict error)4447 dwg_ent_solid_set_elevation (dwg_ent_solid *restrict solid,
4448                              const double elevation, int *restrict error)
4449 {
4450   if (solid)
4451     {
4452       *error = 0;
4453       solid->elevation = elevation;
4454     }
4455   else
4456     {
4457       *error = 1;
4458       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4459     }
4460 }
4461 
4462 /** Returns the _dwg_entity_SOLID::corner1 2dpoint, DXF 10.
4463 \code Usage: dwg_ent_solid_get_corner1(solid, &point, &error);
4464 \endcode
4465 \param[in] solid dwg_ent_solid*
4466 \param[out] dwg_point_2d
4467 \param[out] error   int*, is set to 0 for ok, 1 on error
4468 \deprecated
4469 */
4470 void
dwg_ent_solid_get_corner1(const dwg_ent_solid * restrict solid,dwg_point_2d * restrict point,int * restrict error)4471 dwg_ent_solid_get_corner1 (const dwg_ent_solid *restrict solid,
4472                            dwg_point_2d *restrict point, int *restrict error)
4473 {
4474   if (solid
4475 #  ifndef HAVE_NONNULL
4476       && point
4477 #  endif
4478   )
4479     {
4480       *error = 0;
4481       point->x = solid->corner1.x;
4482       point->y = solid->corner1.y;
4483     }
4484   else
4485     {
4486       *error = 1;
4487       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4488     }
4489 }
4490 
4491 /** Sets the _dwg_entity_SOLID::corner1 2dpoint, DXF 10.
4492 \code Usage: dwg_ent_solid_set_corner1(solid, &point, &error);
4493 \endcode
4494 \param[out] solid dwg_ent_solid*
4495 \param[in]  point dwg_point_2d
4496 \param[out] error   int*, is set to 0 for ok, 1 on error
4497 \deprecated
4498 */
4499 void
dwg_ent_solid_set_corner1(dwg_ent_solid * restrict solid,const dwg_point_2d * restrict point,int * restrict error)4500 dwg_ent_solid_set_corner1 (dwg_ent_solid *restrict solid,
4501                            const dwg_point_2d *restrict point,
4502                            int *restrict error)
4503 {
4504   if (solid
4505 #  ifndef HAVE_NONNULL
4506       && point
4507 #  endif
4508   )
4509     {
4510       *error = 0;
4511       solid->corner1.x = point->x;
4512       solid->corner1.y = point->y;
4513     }
4514   else
4515     {
4516       *error = 1;
4517       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4518     }
4519 }
4520 
4521 /** Returns the _dwg_entity_SOLID::corner2 2dpoint, DXF 11.
4522 \code Usage: dwg_ent_solid_get_corner2(solid, &point, &error);
4523 \endcode
4524 \param[in] solid dwg_ent_solid*
4525 \param[out] point dwg_point_2d
4526 \param[out] error   int*, is set to 0 for ok, 1 on error
4527 \deprecated
4528 */
4529 void
dwg_ent_solid_get_corner2(const dwg_ent_solid * restrict solid,dwg_point_2d * restrict point,int * restrict error)4530 dwg_ent_solid_get_corner2 (const dwg_ent_solid *restrict solid,
4531                            dwg_point_2d *restrict point, int *restrict error)
4532 {
4533   if (solid
4534 #  ifndef HAVE_NONNULL
4535       && point
4536 #  endif
4537   )
4538     {
4539       *error = 0;
4540       point->x = solid->corner2.x;
4541       point->y = solid->corner2.y;
4542     }
4543   else
4544     {
4545       *error = 1;
4546       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4547     }
4548 }
4549 
4550 /** Sets the _dwg_entity_SOLID::corner2 2dpoint, DXF 11.
4551 \code Usage: dwg_ent_solid_set_corner2(solid, &point, &error);
4552 \endcode
4553 \param[in] solid dwg_ent_solid*
4554 \param[out] dwg_point_2d
4555 \param[out] error   int*, is set to 0 for ok, 1 on error
4556 \deprecated
4557 */
4558 void
dwg_ent_solid_set_corner2(dwg_ent_solid * restrict solid,const dwg_point_2d * restrict point,int * restrict error)4559 dwg_ent_solid_set_corner2 (dwg_ent_solid *restrict solid,
4560                            const dwg_point_2d *restrict point,
4561                            int *restrict error)
4562 {
4563   if (solid
4564 #  ifndef HAVE_NONNULL
4565       && point
4566 #  endif
4567   )
4568     {
4569       *error = 0;
4570       solid->corner2.x = point->x;
4571       solid->corner2.y = point->y;
4572     }
4573   else
4574     {
4575       *error = 1;
4576       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4577     }
4578 }
4579 
4580 /** Returns the _dwg_entity_SOLID::corner3 2dpoint, DXF 12.
4581 \code Usage: dwg_ent_solid_get_corner3(solid, &point, &error);
4582 \endcode
4583 \param[in] solid dwg_ent_solid*
4584 \param[out] point dwg_point_2d
4585 \param[out] error   int*, is set to 0 for ok, 1 on error
4586 \deprecated
4587 */
4588 void
dwg_ent_solid_get_corner3(const dwg_ent_solid * restrict solid,dwg_point_2d * restrict point,int * restrict error)4589 dwg_ent_solid_get_corner3 (const dwg_ent_solid *restrict solid,
4590                            dwg_point_2d *restrict point, int *restrict error)
4591 {
4592   if (solid
4593 #  ifndef HAVE_NONNULL
4594       && point
4595 #  endif
4596   )
4597     {
4598       *error = 0;
4599       point->x = solid->corner3.x;
4600       point->y = solid->corner3.y;
4601     }
4602   else
4603     {
4604       *error = 1;
4605       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4606     }
4607 }
4608 
4609 /** Sets the _dwg_entity_SOLID::corner3 2dpoint, DXF 12.
4610 \code Usage: dwg_ent_solid_set_corner3(solid, &point, &error);
4611 \endcode
4612 \param[in] solid dwg_ent_solid*
4613 \param[out] point dwg_point_2d
4614 \param[out] error   int*, is set to 0 for ok, 1 on error
4615 \deprecated
4616 */
4617 void
dwg_ent_solid_set_corner3(dwg_ent_solid * restrict solid,const dwg_point_2d * restrict point,int * restrict error)4618 dwg_ent_solid_set_corner3 (dwg_ent_solid *restrict solid,
4619                            const dwg_point_2d *restrict point,
4620                            int *restrict error)
4621 {
4622   if (solid
4623 #  ifndef HAVE_NONNULL
4624       && point
4625 #  endif
4626   )
4627     {
4628       *error = 0;
4629       solid->corner3.x = point->x;
4630       solid->corner3.y = point->y;
4631     }
4632   else
4633     {
4634       *error = 1;
4635       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4636     }
4637 }
4638 
4639 /** Returns the _dwg_entity_SOLID::corner4 2dpoint, DXF 13.
4640 \code Usage: dwg_ent_solid_get_corner4(solid, &point, &error);
4641 \endcode
4642 \param[in] solid dwg_ent_solid*
4643 \param[out] point dwg_point_2d
4644 \param[out] error   int*, is set to 0 for ok, 1 on error
4645 \deprecated
4646 */
4647 void
dwg_ent_solid_get_corner4(const dwg_ent_solid * restrict solid,dwg_point_2d * restrict point,int * restrict error)4648 dwg_ent_solid_get_corner4 (const dwg_ent_solid *restrict solid,
4649                            dwg_point_2d *restrict point, int *restrict error)
4650 {
4651   if (solid
4652 #  ifndef HAVE_NONNULL
4653       && point
4654 #  endif
4655   )
4656     {
4657       *error = 0;
4658       point->x = solid->corner4.x;
4659       point->y = solid->corner4.y;
4660     }
4661   else
4662     {
4663       *error = 1;
4664       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4665     }
4666 }
4667 
4668 /** Sets the _dwg_entity_SOLID::corner4 2dpoint, DXF 13.
4669 \code Usage: dwg_ent_solid_set_corner4(solid, &point, &error);
4670 \endcode
4671 \param[in] solid dwg_ent_solid*
4672 \param[out] point dwg_point_2d
4673 \param[out] error   int*, is set to 0 for ok, 1 on error
4674 \deprecated
4675 */
4676 void
dwg_ent_solid_set_corner4(dwg_ent_solid * restrict solid,const dwg_point_2d * restrict point,int * restrict error)4677 dwg_ent_solid_set_corner4 (dwg_ent_solid *restrict solid,
4678                            const dwg_point_2d *restrict point,
4679                            int *restrict error)
4680 {
4681   if (solid
4682 #  ifndef HAVE_NONNULL
4683       && point
4684 #  endif
4685   )
4686     {
4687       *error = 0;
4688       solid->corner4.x = point->x;
4689       solid->corner4.y = point->y;
4690     }
4691   else
4692     {
4693       *error = 1;
4694       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4695     }
4696 }
4697 
4698 /** Returns the _dwg_entity_SOLID::extrusion vector, DXF 210.
4699 \code Usage: dwg_ent_solid_get_extrusion(solid, &point, &error);
4700 \endcode
4701 \param[in] solid dwg_ent_solid*
4702 \param[out] vector dwg_point_3d
4703 \param[out] error   int*, is set to 0 for ok, 1 on error
4704 \deprecated
4705 */
4706 void
dwg_ent_solid_get_extrusion(const dwg_ent_solid * restrict solid,dwg_point_3d * restrict vector,int * restrict error)4707 dwg_ent_solid_get_extrusion (const dwg_ent_solid *restrict solid,
4708                              dwg_point_3d *restrict vector,
4709                              int *restrict error)
4710 {
4711   if (solid
4712 #  ifndef HAVE_NONNULL
4713       && vector
4714 #  endif
4715   )
4716     {
4717       *error = 0;
4718       vector->x = solid->extrusion.x;
4719       vector->y = solid->extrusion.y;
4720       vector->z = solid->extrusion.z;
4721     }
4722   else
4723     {
4724       *error = 1;
4725       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4726     }
4727 }
4728 
4729 /** Sets the _dwg_entity_SOLID::extrusion vector, DXF 210.
4730 \code Usage: dwg_ent_solid_set_extrusion(solid, &point, &error);
4731 \endcode
4732 \param[in] solid dwg_ent_solid*
4733 \param[out] vector dwg_point_3d
4734 \param[out] error   int*, is set to 0 for ok, 1 on error
4735 \deprecated
4736 */
4737 void
dwg_ent_solid_set_extrusion(dwg_ent_solid * restrict solid,const dwg_point_3d * restrict vector,int * restrict error)4738 dwg_ent_solid_set_extrusion (dwg_ent_solid *restrict solid,
4739                              const dwg_point_3d *restrict vector,
4740                              int *restrict error)
4741 {
4742   if (solid
4743 #  ifndef HAVE_NONNULL
4744       && vector
4745 #  endif
4746   )
4747     {
4748       *error = 0;
4749       solid->extrusion.x = vector->x;
4750       solid->extrusion.y = vector->y;
4751       solid->extrusion.z = vector->z;
4752     }
4753   else
4754     {
4755       *error = 1;
4756       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4757     }
4758 }
4759 
4760 /*******************************************************************
4761  *                   FUNCTIONS FOR BLOCK ENTITY                      *
4762  ********************************************************************/
4763 
4764 /** Sets the _dwg_entity_BLOCK::name, DXF 1 (utf-8 encoded)
4765 \code Usage: dwg_ent_block_set_name(block, "block_name", &error);
4766 \endcode
4767 \param[out] block dwg_ent_block*
4768 \param[in]  name utf-8 char *
4769 \param[out] error   int*, is set to 0 for ok, 1 on error
4770 \deprecated
4771 */
4772 void
dwg_ent_block_set_name(dwg_ent_block * restrict ent,const char * name,int * restrict error)4773 dwg_ent_block_set_name (dwg_ent_block *restrict ent, const char *name,
4774                         int *restrict error)
4775 {
4776   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
4777   if (ent && !error)
4778     {
4779       ent->name = dwg_add_u8_input (dwg, default_value);
4780     }
4781   else
4782     {
4783       *error = 1;
4784       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4785     }
4786 }
4787 
4788 /** Returns the _dwg_entity_BLOCK::name, DXF 1 (utf-8 encoded).
4789 If dwg_version >= R_2007, the return value is malloc'ed
4790 \code Usage: char * name = dwg_ent_block_get_name(block, &error);
4791 \endcode
4792 \param[in] block dwg_ent_block*
4793 \param[out] error   int*, is set to 0 for ok, 1 on error
4794 \deprecated
4795 */
4796 char *
dwg_ent_block_get_name(const dwg_ent_block * restrict block,int * restrict error)4797 dwg_ent_block_get_name (const dwg_ent_block *restrict block,
4798                         int *restrict error)
4799 {
4800   if (block)
4801     {
4802       *error = 0;
4803       if (dwg_version >= R_2007)
4804         return bit_convert_TU ((BITCODE_TU)block->name);
4805       else
4806         return block->name;
4807     }
4808   else
4809     {
4810       LOG_ERROR ("%s: empty block", __FUNCTION__)
4811       *error = 1;
4812       return NULL;
4813     }
4814 }
4815 
4816 /*******************************************************************
4817  *                    FUNCTIONS FOR RAY ENTITY                       *
4818  ********************************************************************/
4819 
4820 /** Returns the _dwg_entity_RAY::point, DXF 10
4821 \code Usage: dwg_ent_ray_get_point(ray, &point, &error);
4822 \endcode
4823 \param[in] ray dwg_ent_ray*
4824 \param[out] point dwg_point_3d
4825 \param[out] error   int*, is set to 0 for ok, 1 on error
4826 \deprecated
4827 */
4828 void
dwg_ent_ray_get_point(const dwg_ent_ray * restrict ray,dwg_point_3d * restrict point,int * restrict error)4829 dwg_ent_ray_get_point (const dwg_ent_ray *restrict ray,
4830                        dwg_point_3d *restrict point, int *restrict error)
4831 {
4832   if (ray
4833 #  ifndef HAVE_NONNULL
4834       && point
4835 #  endif
4836   )
4837     {
4838       *error = 0;
4839       point->x = ray->point.x;
4840       point->y = ray->point.y;
4841       point->z = ray->point.z;
4842     }
4843   else
4844     {
4845       *error = 1;
4846       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4847     }
4848 }
4849 
4850 /** Sets the _dwg_entity_RAY::point, DXF 10
4851 \code Usage: dwg_ent_ray_set_point(ray, &point, &error);
4852 \endcode
4853 \param[in] ray dwg_ent_ray*
4854 \param[out] point dwg_point_3d
4855 \param[out] error   int*, is set to 0 for ok, 1 on error
4856 \deprecated
4857 */
4858 void
dwg_ent_ray_set_point(dwg_ent_ray * restrict ray,const dwg_point_3d * restrict point,int * restrict error)4859 dwg_ent_ray_set_point (dwg_ent_ray *restrict ray,
4860                        const dwg_point_3d *restrict point, int *restrict error)
4861 {
4862   if (ray
4863 #  ifndef HAVE_NONNULL
4864       && point
4865 #  endif
4866   )
4867     {
4868       *error = 0;
4869       ray->point.x = point->x;
4870       ray->point.y = point->y;
4871       ray->point.z = point->z;
4872     }
4873   else
4874     {
4875       *error = 1;
4876       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4877     }
4878 }
4879 
4880 /** Returns the _dwg_entity_RAY::vector, DXF 11
4881 \code Usage: dwg_ent_ray_get_vector(ray, &point, &error);
4882 \endcode
4883 \param[in] ray dwg_ent_ray*
4884 \param[out] vector dwg_point_3d
4885 \param[out] error   int*, is set to 0 for ok, 1 on error
4886 \deprecated
4887 */
4888 void
dwg_ent_ray_get_vector(const dwg_ent_ray * restrict ray,dwg_point_3d * restrict vector,int * restrict error)4889 dwg_ent_ray_get_vector (const dwg_ent_ray *restrict ray,
4890                         dwg_point_3d *restrict vector, int *restrict error)
4891 {
4892   if (ray
4893 #  ifndef HAVE_NONNULL
4894       && vector
4895 #  endif
4896   )
4897     {
4898       *error = 0;
4899       vector->x = ray->vector.x;
4900       vector->y = ray->vector.y;
4901       vector->z = ray->vector.z;
4902     }
4903   else
4904     {
4905       *error = 1;
4906       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4907     }
4908 }
4909 
4910 /** Sets the _dwg_entity_RAY::vector, DXF 11
4911 \code Usage: dwg_ent_ray_set_vector(ray, &point, &error);
4912 \endcode
4913 \param[in] ray dwg_ent_ray*
4914 \param[out] vector dwg_point_3d
4915 \param[out] error   int*, is set to 0 for ok, 1 on error
4916 \deprecated
4917 */
4918 void
dwg_ent_ray_set_vector(dwg_ent_ray * restrict ray,const dwg_point_3d * restrict vector,int * restrict error)4919 dwg_ent_ray_set_vector (dwg_ent_ray *restrict ray,
4920                         const dwg_point_3d *restrict vector,
4921                         int *restrict error)
4922 {
4923   if (ray
4924 #  ifndef HAVE_NONNULL
4925       && vector
4926 #  endif
4927   )
4928     {
4929       *error = 0;
4930       ray->vector.x = vector->x;
4931       ray->vector.y = vector->y;
4932       ray->vector.z = vector->z;
4933     }
4934   else
4935     {
4936       *error = 1;
4937       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4938     }
4939 }
4940 
4941 /*******************************************************************
4942  *                   FUNCTIONS FOR XLINE ENTITY                      *
4943  ********************************************************************/
4944 
4945 /** Returns the _dwg_entity_XLINE::point, DXF 10
4946 \code Usage: dwg_ent_xline_get_point(xline, &point, &error);
4947 \endcode
4948 \param[in] xline dwg_ent_xline*
4949 \param[out] point dwg_point_3d
4950 \param[out] error   int*, is set to 0 for ok, 1 on error
4951 \deprecated
4952 */
4953 void
dwg_ent_xline_get_point(const dwg_ent_xline * restrict xline,dwg_point_3d * restrict point,int * restrict error)4954 dwg_ent_xline_get_point (const dwg_ent_xline *restrict xline,
4955                          dwg_point_3d *restrict point, int *restrict error)
4956 {
4957   if (xline
4958 #  ifndef HAVE_NONNULL
4959       && point
4960 #  endif
4961   )
4962     {
4963       *error = 0;
4964       point->x = xline->point.x;
4965       point->y = xline->point.y;
4966       point->z = xline->point.z;
4967     }
4968   else
4969     {
4970       *error = 1;
4971       LOG_ERROR ("%s: empty arg", __FUNCTION__)
4972     }
4973 }
4974 
4975 /** Sets the _dwg_entity_XLINE::point, DXF 10
4976 \code Usage: dwg_ent_xline_set_point(xline, &point, &error);
4977 \endcode
4978 \param[out]  xline dwg_ent_xline*
4979 \param[in] point dwg_point_3d
4980 \param[out] error   int*, is set to 0 for ok, 1 on error
4981 \deprecated
4982 */
4983 void
dwg_ent_xline_set_point(dwg_ent_xline * restrict xline,const dwg_point_3d * restrict point,int * restrict error)4984 dwg_ent_xline_set_point (dwg_ent_xline *restrict xline,
4985                          const dwg_point_3d *restrict point,
4986                          int *restrict error)
4987 {
4988   if (xline
4989 #  ifndef HAVE_NONNULL
4990       && point
4991 #  endif
4992   )
4993     {
4994       *error = 0;
4995       xline->point.x = point->x;
4996       xline->point.y = point->y;
4997       xline->point.z = point->z;
4998     }
4999   else
5000     {
5001       *error = 1;
5002       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5003     }
5004 }
5005 
5006 /** Returns the _dwg_entity_RAY::vector, DXF 11
5007 \code Usage: dwg_ent_xline_get_vector(xline, &point, &error);
5008 \endcode
5009 \param[in] xline dwg_ent_xline*
5010 \param[out] vector dwg_point_3d
5011 \param[out] error   int*, is set to 0 for ok, 1 on error
5012 \deprecated
5013 */
5014 void
dwg_ent_xline_get_vector(const dwg_ent_xline * restrict xline,dwg_point_3d * restrict vector,int * restrict error)5015 dwg_ent_xline_get_vector (const dwg_ent_xline *restrict xline,
5016                           dwg_point_3d *restrict vector, int *restrict error)
5017 {
5018   if (xline
5019 #  ifndef HAVE_NONNULL
5020       && vector
5021 #  endif
5022   )
5023     {
5024       *error = 0;
5025       vector->x = xline->vector.x;
5026       vector->y = xline->vector.y;
5027       vector->z = xline->vector.z;
5028     }
5029   else
5030     {
5031       *error = 1;
5032       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5033     }
5034 }
5035 
5036 /** Sets the _dwg_entity_RAY::vector, DXF 11
5037 Usage: dwg_ent_xline_set_vector(xline, &point, &error);
5038 \param[out]  xline dwg_ent_xline*
5039 \param[in] vector dwg_point_3d
5040 \param[out] error   int*, is set to 0 for ok, 1 on error
5041 \deprecated
5042 */
5043 void
dwg_ent_xline_set_vector(dwg_ent_xline * restrict xline,const dwg_point_3d * restrict vector,int * restrict error)5044 dwg_ent_xline_set_vector (dwg_ent_xline *restrict xline,
5045                           const dwg_point_3d *restrict vector,
5046                           int *restrict error)
5047 {
5048   if (xline
5049 #  ifndef HAVE_NONNULL
5050       && vector
5051 #  endif
5052   )
5053     {
5054       *error = 0;
5055       xline->vector.x = vector->x;
5056       xline->vector.y = vector->y;
5057       xline->vector.z = vector->z;
5058     }
5059   else
5060     {
5061       *error = 1;
5062       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5063     }
5064 }
5065 
5066 /*******************************************************************
5067  *                   FUNCTIONS FOR TRACE ENTITY                      *
5068  ********************************************************************/
5069 
5070 /** Returns the _dwg_entity_TRACE::thickness, DXF 39
5071 \code Usage: double thickness = dwg_ent_trace_get_thickness(trace, &error);
5072 \endcode
5073 \param[in] trace dwg_ent_trace*
5074 \param[out] error   int*, is set to 0 for ok, 1 on error
5075 \deprecated
5076 */
5077 double
dwg_ent_trace_get_thickness(const dwg_ent_trace * restrict trace,int * restrict error)5078 dwg_ent_trace_get_thickness (const dwg_ent_trace *restrict trace,
5079                              int *restrict error)
5080 {
5081   if (trace)
5082     {
5083       *error = 0;
5084       return trace->thickness;
5085     }
5086   else
5087     {
5088       *error = 1;
5089       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5090       return bit_nan ();
5091     }
5092 }
5093 
5094 /** Sets the _dwg_entity_TRACE::thickness, DXF 39
5095 \code Usage: dwg_ent_trace_set_thickness(trace, 2.0, &error);
5096 \endcode
5097 \param[out] trace dwg_ent_trace*
5098 \param[in] thickness double
5099 \param[out] error   int*, is set to 0 for ok, 1 on error
5100 \deprecated
5101 */
5102 void
dwg_ent_trace_set_thickness(dwg_ent_trace * restrict trace,const double thickness,int * restrict error)5103 dwg_ent_trace_set_thickness (dwg_ent_trace *restrict trace,
5104                              const double thickness, int *restrict error)
5105 {
5106   if (trace)
5107     {
5108       *error = 0;
5109       trace->thickness = thickness;
5110     }
5111   else
5112     {
5113       *error = 1;
5114       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5115     }
5116 }
5117 
5118 /** Returns the _dwg_entity_TRACE::elevation (z-coord), DXF 38
5119 \code Usage: double elev = dwg_ent_trace_get_elevation(trace, &error);
5120 \endcode
5121 \param[in] trace dwg_ent_trace*
5122 \param[out] error   int*, is set to 0 for ok, 1 on error
5123 \deprecated
5124 */
5125 double
dwg_ent_trace_get_elevation(const dwg_ent_trace * restrict trace,int * restrict error)5126 dwg_ent_trace_get_elevation (const dwg_ent_trace *restrict trace,
5127                              int *restrict error)
5128 {
5129   if (trace)
5130     {
5131       *error = 0;
5132       return trace->elevation;
5133     }
5134   else
5135     {
5136       *error = 1;
5137       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5138       return bit_nan ();
5139     }
5140 }
5141 
5142 /** Sets the _dwg_entity_TRACE::elevation (z-coord), DXF 38
5143 \code Usage: dwg_ent_trace_set_elevation(trace, 20, &error);
5144 \endcode
5145 \param[out] trace dwg_ent_trace*
5146 \param[in] elevation double
5147 \param[out] error   int*, is set to 0 for ok, 1 on error
5148 \deprecated
5149 */
5150 void
dwg_ent_trace_set_elevation(dwg_ent_trace * restrict trace,const double elevation,int * restrict error)5151 dwg_ent_trace_set_elevation (dwg_ent_trace *restrict trace,
5152                              const double elevation, int *restrict error)
5153 {
5154   if (trace)
5155     {
5156       *error = 0;
5157       trace->elevation = elevation;
5158     }
5159   else
5160     {
5161       *error = 1;
5162       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5163     }
5164 }
5165 
5166 /** Returns the _dwg_entity_TRACE::corner1 2dpoint, DXF 10
5167 \code Usage: dwg_ent_trace_get_corner1(trace, &point, &error);
5168 \endcode
5169 \param[in] trace dwg_ent_trace*
5170 \param[out] point dwg_point_2d
5171 \param[out] error   int*, is set to 0 for ok, 1 on error
5172 \deprecated
5173 */
5174 void
dwg_ent_trace_get_corner1(const dwg_ent_trace * restrict trace,dwg_point_2d * restrict point,int * restrict error)5175 dwg_ent_trace_get_corner1 (const dwg_ent_trace *restrict trace,
5176                            dwg_point_2d *restrict point, int *restrict error)
5177 {
5178   if (trace
5179 #  ifndef HAVE_NONNULL
5180       && point
5181 #  endif
5182   )
5183     {
5184       *error = 0;
5185       point->x = trace->corner1.x;
5186       point->y = trace->corner1.y;
5187     }
5188   else
5189     {
5190       *error = 1;
5191       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5192     }
5193 }
5194 
5195 /** Sets the _dwg_entity_TRACE::corner1 2dpoint, DXF 10
5196 \code Usage: dwg_ent_trace_set_corner1(trace, &point, &error);
5197 \endcode
5198 \param[in] trace dwg_ent_trace*
5199 \param[out] point dwg_point_2d
5200 \param[out] error   int*, is set to 0 for ok, 1 on error
5201 \deprecated
5202 */
5203 void
dwg_ent_trace_set_corner1(dwg_ent_trace * restrict trace,const dwg_point_2d * restrict point,int * restrict error)5204 dwg_ent_trace_set_corner1 (dwg_ent_trace *restrict trace,
5205                            const dwg_point_2d *restrict point,
5206                            int *restrict error)
5207 {
5208   if (trace
5209 #  ifndef HAVE_NONNULL
5210       && point
5211 #  endif
5212   )
5213     {
5214       *error = 0;
5215       trace->corner1.x = point->x;
5216       trace->corner1.y = point->y;
5217     }
5218   else
5219     {
5220       *error = 1;
5221       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5222     }
5223 }
5224 
5225 /** Returns the _dwg_entity_TRACE::corner2 2dpoint, DXF 11
5226 \code Usage: dwg_ent_trace_get_corner2(trace, &point, &error);
5227 \endcode
5228 \param[in] trace dwg_ent_trace*
5229 \param[out] point dwg_point_2d
5230 \param[out] error   int*, is set to 0 for ok, 1 on error
5231 \deprecated
5232 */
5233 void
dwg_ent_trace_get_corner2(const dwg_ent_trace * restrict trace,dwg_point_2d * restrict point,int * restrict error)5234 dwg_ent_trace_get_corner2 (const dwg_ent_trace *restrict trace,
5235                            dwg_point_2d *restrict point, int *restrict error)
5236 {
5237   if (trace
5238 #  ifndef HAVE_NONNULL
5239       && point
5240 #  endif
5241   )
5242     {
5243       *error = 0;
5244       point->x = trace->corner2.x;
5245       point->y = trace->corner2.y;
5246     }
5247   else
5248     {
5249       *error = 1;
5250       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5251     }
5252 }
5253 
5254 /** Sets the _dwg_entity_TRACE::corner2 2dpoint, DXF 11
5255 \code Usage: dwg_ent_trace_set_corner2(trace, &point, &error);
5256 \endcode
5257 \param[out] trace dwg_ent_trace*
5258 \param[in] point dwg_point_2d
5259 \param[out] error   int*, is set to 0 for ok, 1 on error
5260 \deprecated
5261 */
5262 void
dwg_ent_trace_set_corner2(dwg_ent_trace * restrict trace,const dwg_point_2d * restrict point,int * restrict error)5263 dwg_ent_trace_set_corner2 (dwg_ent_trace *restrict trace,
5264                            const dwg_point_2d *restrict point,
5265                            int *restrict error)
5266 {
5267   if (trace
5268 #  ifndef HAVE_NONNULL
5269       && point
5270 #  endif
5271   )
5272     {
5273       *error = 0;
5274       trace->corner2.x = point->x;
5275       trace->corner2.y = point->y;
5276     }
5277   else
5278     {
5279       *error = 1;
5280       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5281     }
5282 }
5283 
5284 /** Returns the _dwg_entity_TRACE::corner3 2dpoint, DXF 12
5285 \code Usage: dwg_ent_trace_get_corner3(trace, &point, &error);
5286 \endcode
5287 \param[in] trace dwg_ent_trace*
5288 \param[out] point dwg_point_2d
5289 \param[out] error   int*, is set to 0 for ok, 1 on error
5290 \deprecated
5291 */
5292 void
dwg_ent_trace_get_corner3(const dwg_ent_trace * restrict trace,dwg_point_2d * restrict point,int * restrict error)5293 dwg_ent_trace_get_corner3 (const dwg_ent_trace *restrict trace,
5294                            dwg_point_2d *restrict point, int *restrict error)
5295 {
5296   if (trace
5297 #  ifndef HAVE_NONNULL
5298       && point
5299 #  endif
5300   )
5301     {
5302       *error = 0;
5303       point->x = trace->corner3.x;
5304       point->y = trace->corner3.y;
5305     }
5306   else
5307     {
5308       *error = 1;
5309       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5310     }
5311 }
5312 
5313 /** Sets the _dwg_entity_TRACE::corner3 2dpoint, DXF 12
5314 \code Usage: dwg_ent_trace_set_corner3(trace, &point, &error);
5315 \endcode
5316 \param[out] trace dwg_ent_trace*
5317 \param[in] point dwg_point_2d
5318 \param[out] error   int*, is set to 0 for ok, 1 on error
5319 \deprecated
5320 */
5321 void
dwg_ent_trace_set_corner3(dwg_ent_trace * restrict trace,const dwg_point_2d * restrict point,int * restrict error)5322 dwg_ent_trace_set_corner3 (dwg_ent_trace *restrict trace,
5323                            const dwg_point_2d *restrict point,
5324                            int *restrict error)
5325 {
5326   if (trace
5327 #  ifndef HAVE_NONNULL
5328       && point
5329 #  endif
5330   )
5331     {
5332       *error = 0;
5333       trace->corner3.x = point->x;
5334       trace->corner3.y = point->y;
5335     }
5336   else
5337     {
5338       *error = 1;
5339       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5340     }
5341 }
5342 
5343 /** Returns the _dwg_entity_TRACE::corner4 2dpoint, DXF 13
5344 \code Usage: dwg_ent_trace_get_corner4(trace, &point, &error);
5345 \endcode
5346 \param[in] trace dwg_ent_trace*
5347 \param[out] point dwg_point_2d
5348 \param[out] error   int*, is set to 0 for ok, 1 on error
5349 \deprecated
5350 */
5351 void
dwg_ent_trace_get_corner4(const dwg_ent_trace * restrict trace,dwg_point_2d * restrict point,int * restrict error)5352 dwg_ent_trace_get_corner4 (const dwg_ent_trace *restrict trace,
5353                            dwg_point_2d *restrict point, int *restrict error)
5354 {
5355   if (trace
5356 #  ifndef HAVE_NONNULL
5357       && point
5358 #  endif
5359   )
5360     {
5361       *error = 0;
5362       point->x = trace->corner4.x;
5363       point->y = trace->corner4.y;
5364     }
5365   else
5366     {
5367       *error = 1;
5368       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5369     }
5370 }
5371 
5372 /** Sets the _dwg_entity_TRACE::corner4 2dpoint, DXF 13.
5373 \code Usage: dwg_ent_trace_set_corner4(trace, &point, &error);
5374 \endcode
5375 \param[out] trace dwg_ent_trace*
5376 \param[in] point dwg_point_2d
5377 \param[out] error   int*, is set to 0 for ok, 1 on error
5378 \deprecated
5379 */
5380 void
dwg_ent_trace_set_corner4(dwg_ent_trace * restrict trace,const dwg_point_2d * restrict point,int * restrict error)5381 dwg_ent_trace_set_corner4 (dwg_ent_trace *restrict trace,
5382                            const dwg_point_2d *restrict point,
5383                            int *restrict error)
5384 {
5385   if (trace
5386 #  ifndef HAVE_NONNULL
5387       && point
5388 #  endif
5389   )
5390     {
5391       *error = 0;
5392       trace->corner4.x = point->x;
5393       trace->corner4.y = point->y;
5394     }
5395   else
5396     {
5397       *error = 1;
5398       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5399     }
5400 }
5401 
5402 /** Returns the _dwg_entity_TRACE::extrusion vector, DXF 210.
5403 \code Usage: dwg_ent_trace_get_extrusion(trace, &ext, &error);
5404 \endcode
5405 \param[in] trace dwg_ent_trace*
5406 \param[out] vector dwg_point_3d
5407 \param[out] error   int*, is set to 0 for ok, 1 on error
5408 \deprecated
5409 */
5410 void
dwg_ent_trace_get_extrusion(const dwg_ent_trace * restrict trace,dwg_point_3d * restrict vector,int * restrict error)5411 dwg_ent_trace_get_extrusion (const dwg_ent_trace *restrict trace,
5412                              dwg_point_3d *restrict vector,
5413                              int *restrict error)
5414 {
5415   if (trace
5416 #  ifndef HAVE_NONNULL
5417       && vector
5418 #  endif
5419   )
5420     {
5421       *error = 0;
5422       vector->x = trace->extrusion.x;
5423       vector->y = trace->extrusion.y;
5424       vector->z = trace->extrusion.z;
5425     }
5426   else
5427     {
5428       *error = 1;
5429       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5430     }
5431 }
5432 
5433 /** Sets the _dwg_entity_TRACE::extrusion vector, DXF 210.
5434 \code Usage: dwg_ent_trace_set_extrusion(trace, &ext, &error);
5435 \endcode
5436 \param[in] trace dwg_ent_trace*
5437 \param[out] vector dwg_point_3d
5438 \param[out] error   int*, is set to 0 for ok, 1 on error
5439 \deprecated
5440 */
5441 void
dwg_ent_trace_set_extrusion(dwg_ent_trace * restrict trace,const dwg_point_3d * restrict vector,int * restrict error)5442 dwg_ent_trace_set_extrusion (dwg_ent_trace *restrict trace,
5443                              const dwg_point_3d *restrict vector,
5444                              int *restrict error)
5445 {
5446   if (trace
5447 #  ifndef HAVE_NONNULL
5448       && vector
5449 #  endif
5450   )
5451     {
5452       *error = 0;
5453       trace->extrusion.x = vector->x;
5454       trace->extrusion.y = vector->y;
5455       trace->extrusion.z = vector->z;
5456     }
5457   else
5458     {
5459       *error = 1;
5460       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5461     }
5462 }
5463 
5464 /*******************************************************************
5465  *                 FUNCTIONS FOR VERTEX_3D ENTITY                    *
5466  ********************************************************************/
5467 
5468 /** Returns the _dwg_entity_VERTEX_3D::flag, DXF 70.
5469 \code Usage: char flag = dwg_ent_vertex_3d_get_flag(vert, &error);
5470 \endcode
5471 \param[in]  vert    dwg_ent_vertex_3d*
5472 \param[out] error   int*, is set to 0 for ok, 1 on error
5473 \deprecated
5474 */
5475 char
dwg_ent_vertex_3d_get_flag(const dwg_ent_vertex_3d * restrict vert,int * restrict error)5476 dwg_ent_vertex_3d_get_flag (const dwg_ent_vertex_3d *restrict vert,
5477                             int *restrict error)
5478 {
5479   if (vert)
5480     {
5481       *error = 0;
5482       return vert->flag;
5483     }
5484   else
5485     {
5486       *error = 1;
5487       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5488       return '\0';
5489     }
5490 }
5491 
5492 /** Sets the _dwg_entity_VERTEX_3D::flag, DXF 70.
5493 \code Usage: dwg_ent_vertex_3d_set_flag(vert, flag, &error);
5494 \endcode
5495 \param[out] vert   dwg_ent_vertex_3d*
5496 \param[in]  flag   char
5497 \param[out] error  int*, is set to 0 for ok, 1 on error
5498 \deprecated
5499 */
5500 void
dwg_ent_vertex_3d_set_flag(dwg_ent_vertex_3d * restrict vert,const char flag,int * restrict error)5501 dwg_ent_vertex_3d_set_flag (dwg_ent_vertex_3d *restrict vert, const char flag,
5502                             int *restrict error)
5503 {
5504   if (vert)
5505     {
5506       *error = 0;
5507       vert->flag = flag;
5508     }
5509   else
5510     {
5511       *error = 1;
5512       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5513     }
5514 }
5515 
5516 /** Returns the _dwg_entity_VERTEX_3D::point, DXF 10.
5517 \code Usage: dwg_ent_vertex_3d_get_point(vert, &point, &error);
5518 \endcode
5519 \param[in]  vert   dwg_ent_vertex_3d*
5520 \param[out] point  dwg_point_3d
5521 \param[out] error  int*, is set to 0 for ok, 1 on error
5522 \deprecated
5523 */
5524 void
dwg_ent_vertex_3d_get_point(const dwg_ent_vertex_3d * restrict vert,dwg_point_3d * restrict point,int * restrict error)5525 dwg_ent_vertex_3d_get_point (const dwg_ent_vertex_3d *restrict vert,
5526                              dwg_point_3d *restrict point, int *restrict error)
5527 {
5528   if (vert
5529 #  ifndef HAVE_NONNULL
5530       && point
5531 #  endif
5532   )
5533     {
5534       *error = 0;
5535       point->x = vert->point.x;
5536       point->y = vert->point.y;
5537       point->z = vert->point.z;
5538     }
5539   else
5540     {
5541       *error = 1;
5542       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5543     }
5544 }
5545 
5546 /** Sets the_dwg_entity_VERTEX_3D::point, DXF 10.
5547 \code Usage: dwg_ent_vertex_3d_set_point(vert, &point, &error);
5548 \endcode
5549 \param[in]  vert  dwg_ent_vertex_3d*
5550 \param[out] point dwg_point_3d
5551 \param[out] error   int*, is set to 0 for ok, 1 on error
5552 \deprecated
5553 */
5554 void
dwg_ent_vertex_3d_set_point(dwg_ent_vertex_3d * restrict vert,const dwg_point_3d * restrict point,int * restrict error)5555 dwg_ent_vertex_3d_set_point (dwg_ent_vertex_3d *restrict vert,
5556                              const dwg_point_3d *restrict point,
5557                              int *restrict error)
5558 {
5559   if (vert
5560 #  ifndef HAVE_NONNULL
5561       && point
5562 #  endif
5563   )
5564     {
5565       *error = 0;
5566       vert->point.x = point->x;
5567       vert->point.y = point->y;
5568       vert->point.z = point->z;
5569     }
5570   else
5571     {
5572       *error = 1;
5573       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5574     }
5575 }
5576 
5577 /*******************************************************************
5578  *               FUNCTIONS FOR VERTEX_MESH ENTITY                    *
5579  ********************************************************************/
5580 
5581 /** Returns the _dwg_entity_VERTEX_MESH::flag, DXF 70.
5582 \code Usage: char flag = dwg_ent_vertex_mesh_get_flag(vert, &error);
5583 \endcode
5584 \param[in]  vert   dwg_ent_vertex_mesh*
5585 \param[out] error   int*, is set to 0 for ok, 1 on error
5586 \deprecated
5587 */
5588 char
dwg_ent_vertex_mesh_get_flag(const dwg_ent_vertex_mesh * restrict vert,int * restrict error)5589 dwg_ent_vertex_mesh_get_flag (const dwg_ent_vertex_mesh *restrict vert,
5590                               int *restrict error)
5591 {
5592   if (vert)
5593     {
5594       *error = 0;
5595       return vert->flag;
5596     }
5597   else
5598     {
5599       *error = 1;
5600       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5601       return '\0';
5602     }
5603 }
5604 
5605 /** Sets the _dwg_entity_VERTEX_MESH::flag, DXF 70.
5606 \code Usage: dwg_ent_vertex_mesh_set_flag(vert, flag, &error);
5607 \endcode
5608 \param[out] vert   dwg_ent_vertex_mesh*
5609 \param[in] flag    char
5610 \param[out] error  int*, is set to 0 for ok, 1 on error
5611 \deprecated
5612 */
5613 void
dwg_ent_vertex_mesh_set_flag(dwg_ent_vertex_mesh * restrict vert,const char flag,int * restrict error)5614 dwg_ent_vertex_mesh_set_flag (dwg_ent_vertex_mesh *restrict vert,
5615                               const char flag, int *restrict error)
5616 {
5617   if (vert)
5618     {
5619       *error = 0;
5620       vert->flag = flag;
5621     }
5622   else
5623     {
5624       *error = 1;
5625       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5626     }
5627 }
5628 
5629 /** Returns the _dwg_entity_VERTEX_MESH::point, DXF 10.
5630 \code Usage: dwg_ent_vertex_mesh_get_point(vert, &point, &error);
5631 \endcode
5632 \param[in]  vert    dwg_ent_vertex_mesh*
5633 \param[out] point   dwg_point_3d
5634 \param[out] error   int*, is set to 0 for ok, 1 on error
5635 \deprecated
5636 */
5637 void
dwg_ent_vertex_mesh_get_point(const dwg_ent_vertex_mesh * restrict vert,dwg_point_3d * restrict point,int * restrict error)5638 dwg_ent_vertex_mesh_get_point (const dwg_ent_vertex_mesh *restrict vert,
5639                                dwg_point_3d *restrict point,
5640                                int *restrict error)
5641 {
5642   if (vert
5643 #  ifndef HAVE_NONNULL
5644       && point
5645 #  endif
5646   )
5647     {
5648       *error = 0;
5649       point->x = vert->point.x;
5650       point->y = vert->point.y;
5651       point->z = vert->point.z;
5652     }
5653   else
5654     {
5655       *error = 1;
5656       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5657     }
5658 }
5659 
5660 /** Sets the _dwg_entity_VERTEX_MESH::point, DXF 10.
5661 \code Usage: dwg_ent_vertex_mesh_set_point(vert, &point, &error);
5662 \endcode
5663 \param[in]  vert    dwg_ent_vertex_mesh*
5664 \param[out] point   dwg_point_3d
5665 \param[out] error   int*, is set to 0 for ok, 1 on error
5666 \deprecated
5667 */
5668 void
dwg_ent_vertex_mesh_set_point(dwg_ent_vertex_mesh * restrict vert,const dwg_point_3d * restrict point,int * restrict error)5669 dwg_ent_vertex_mesh_set_point (dwg_ent_vertex_mesh *restrict vert,
5670                                const dwg_point_3d *restrict point,
5671                                int *restrict error)
5672 {
5673   if (vert
5674 #  ifndef HAVE_NONNULL
5675       && point
5676 #  endif
5677   )
5678     {
5679       *error = 0;
5680       vert->point.x = point->x;
5681       vert->point.y = point->y;
5682       vert->point.z = point->z;
5683     }
5684   else
5685     {
5686       *error = 1;
5687       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5688     }
5689 }
5690 
5691 /*******************************************************************
5692  *               FUNCTIONS FOR VERTEX_PFACE ENTITY                   *
5693  ********************************************************************/
5694 
5695 /** Returns the _dwg_entity_VERTEX_PFACE::flag, DXF 70.
5696 \code Usage: char flag = dwg_ent_vertex_pface_get_flag(vert, &error);
5697 \endcode
5698 \param[in] vertex_pface dwg_ent_vertex_pface*
5699 \param[out] error   int*, is set to 0 for ok, 1 on error
5700 \deprecated
5701 */
5702 char
dwg_ent_vertex_pface_get_flag(const dwg_ent_vertex_pface * restrict vert,int * restrict error)5703 dwg_ent_vertex_pface_get_flag (const dwg_ent_vertex_pface *restrict vert,
5704                                int *restrict error)
5705 {
5706   if (vert)
5707     {
5708       *error = 0;
5709       return vert->flag;
5710     }
5711   else
5712     {
5713       *error = 1;
5714       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5715       return '\0';
5716     }
5717 }
5718 
5719 /** Sets the _dwg_entity_VERTEX_PFACE::flag, DXF 70.
5720 \code Usage: dwg_ent_vertex_pface_set_flag(vert, flag, &error);
5721 \endcode
5722 \param[out] vertex_pface dwg_ent_vertex_pface*
5723 \param[in] flag
5724 \param[out] error   int*, is set to 0 for ok, 1 on error
5725 \deprecated
5726 */
5727 void
dwg_ent_vertex_pface_set_flag(dwg_ent_vertex_pface * restrict vert,const char flag,int * restrict error)5728 dwg_ent_vertex_pface_set_flag (dwg_ent_vertex_pface *restrict vert,
5729                                const char flag, int *restrict error)
5730 {
5731   if (vert)
5732     {
5733       *error = 0;
5734       vert->flag = flag;
5735     }
5736   else
5737     {
5738       *error = 1;
5739       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5740     }
5741 }
5742 
5743 /** Returns the _dwg_entity_VERTEX_PFACE::point, DXF 10.
5744 \code Usage: dwg_ent_vertex_pface_get_point(vert, &point, &error);
5745 \endcode
5746 \param[in]  vert    dwg_ent_vertex_pface*
5747 \param[out] point   dwg_point_3d
5748 \param[out] error   int*, is set to 0 for ok, 1 on error
5749 \deprecated
5750 */
5751 void
dwg_ent_vertex_pface_get_point(const dwg_ent_vertex_pface * restrict vert,dwg_point_3d * restrict point,int * restrict error)5752 dwg_ent_vertex_pface_get_point (const dwg_ent_vertex_pface *restrict vert,
5753                                 dwg_point_3d *restrict point,
5754                                 int *restrict error)
5755 {
5756   if (vert
5757 #  ifndef HAVE_NONNULL
5758       && point
5759 #  endif
5760   )
5761     {
5762       *error = 0;
5763       point->x = vert->point.x;
5764       point->y = vert->point.y;
5765       point->z = vert->point.z;
5766     }
5767   else
5768     {
5769       *error = 1;
5770       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5771     }
5772 }
5773 
5774 /** Sets the _dwg_entity_VERTEX_PFACE::point, DXF 10.
5775 \code Usage: dwg_ent_vertex_pface_set_point(vert, &point, &error);
5776 \endcode
5777 \param[out] vert    dwg_ent_vertex_pface*
5778 \param[in]  point   dwg_point_3d
5779 \param[out] error   int*, is set to 0 for ok, 1 on error
5780 \deprecated
5781 */
5782 void
dwg_ent_vertex_pface_set_point(dwg_ent_vertex_pface * restrict vert,const dwg_point_3d * restrict point,int * restrict error)5783 dwg_ent_vertex_pface_set_point (dwg_ent_vertex_pface *restrict vert,
5784                                 const dwg_point_3d *restrict point,
5785                                 int *restrict error)
5786 {
5787   if (vert
5788 #  ifndef HAVE_NONNULL
5789       && point
5790 #  endif
5791   )
5792     {
5793       *error = 0;
5794       vert->point.x = point->x;
5795       vert->point.y = point->y;
5796       vert->point.z = point->z;
5797     }
5798   else
5799     {
5800       *error = 1;
5801       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5802     }
5803 }
5804 
5805 /*******************************************************************
5806  *                 FUNCTIONS FOR VERTEX_2D ENTITY                    *
5807  ********************************************************************/
5808 
5809 /** Returns the _dwg_entity_VERTEX_2D::flag, DXF 70.
5810 \code Usage: dwg_ent_vertex_2d_get_flag(vert, &error);
5811 \endcode
5812 \param[in]  vert    dwg_ent_vertex_2d*
5813 \param[out] error   int*, is set to 0 for ok, 1 on error
5814 \deprecated
5815 */
5816 char
dwg_ent_vertex_2d_get_flag(const dwg_ent_vertex_2d * restrict vert,int * restrict error)5817 dwg_ent_vertex_2d_get_flag (const dwg_ent_vertex_2d *restrict vert,
5818                             int *restrict error)
5819 {
5820   if (vert)
5821     {
5822       *error = 0;
5823       return vert->flag;
5824     }
5825   else
5826     {
5827       *error = 1;
5828       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5829       return '\0';
5830     }
5831 }
5832 
5833 /** Sets the _dwg_entity_VERTEX_2D::flag, DXF 70.
5834 \code Usage: dwg_ent_vertex_2d_set_flag(vert, flag, &error);
5835 \endcode
5836 \param[out] vert dwg_ent_vertex_mesh*
5837 \param[in]  flag char
5838 \param[out] error   int*, is set to 0 for ok, 1 on error
5839 \deprecated
5840 */
5841 void
dwg_ent_vertex_2d_set_flag(dwg_ent_vertex_2d * restrict vert,const char flag,int * restrict error)5842 dwg_ent_vertex_2d_set_flag (dwg_ent_vertex_2d *restrict vert, const char flag,
5843                             int *restrict error)
5844 {
5845   if (vert)
5846     {
5847       *error = 0;
5848       vert->flag = flag;
5849     }
5850   else
5851     {
5852       *error = 1;
5853       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5854     }
5855 }
5856 
5857 /** Returns the _dwg_entity_VERTEX_2D::point, DXF 10.
5858 \code Usage: dwg_ent_vertex_2d_get_point(vert, &point, &error);
5859 \endcode
5860 \param[in]  vert    dwg_ent_vertex_2d*
5861 \param[out] point   dwg_point_3d
5862 \param[out] error   int*, is set to 0 for ok, 1 on error
5863 \deprecated
5864 */
5865 void
dwg_ent_vertex_2d_get_point(const dwg_ent_vertex_2d * restrict vert,dwg_point_3d * restrict point,int * restrict error)5866 dwg_ent_vertex_2d_get_point (const dwg_ent_vertex_2d *restrict vert,
5867                              dwg_point_3d *restrict point, int *restrict error)
5868 {
5869   if (vert
5870 #  ifndef HAVE_NONNULL
5871       && point
5872 #  endif
5873   )
5874     {
5875       *error = 0;
5876       point->x = vert->point.x;
5877       point->y = vert->point.y;
5878       point->z = vert->point.z;
5879     }
5880   else
5881     {
5882       *error = 1;
5883       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5884     }
5885 }
5886 
5887 /** Sets the _dwg_entity_VERTEX_2D::point, DXF 10.
5888 \code Usage: dwg_ent_vertex_2d_set_point(vert, &point, &error);
5889 \endcode
5890 \param[out] vert    dwg_ent_vertex_2d*
5891 \param[in]  point   dwg_point_3d
5892 \param[out] error   int*, is set to 0 for ok, 1 on error
5893 \deprecated
5894 */
5895 void
dwg_ent_vertex_2d_set_point(dwg_ent_vertex_2d * restrict vert,const dwg_point_3d * restrict point,int * restrict error)5896 dwg_ent_vertex_2d_set_point (dwg_ent_vertex_2d *restrict vert,
5897                              const dwg_point_3d *restrict point,
5898                              int *restrict error)
5899 {
5900   if (vert
5901 #  ifndef HAVE_NONNULL
5902       && point
5903 #  endif
5904   )
5905     {
5906       *error = 0;
5907       vert->point.x = point->x;
5908       vert->point.y = point->y;
5909       vert->point.z = point->z;
5910     }
5911   else
5912     {
5913       *error = 1;
5914       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5915     }
5916 }
5917 
5918 /** Returns the _dwg_entity_VERTEX_2D::start_width, DXF 40.
5919 \code Usage: double width = dwg_ent_vertex_2d_get_start_width(vert, &error);
5920 \endcode
5921 \param[in]  vert    dwg_ent_vertex_2d*
5922 \param[out] error   int*, is set to 0 for ok, 1 on error
5923 \deprecated
5924 */
5925 double
dwg_ent_vertex_2d_get_start_width(const dwg_ent_vertex_2d * restrict vert,int * restrict error)5926 dwg_ent_vertex_2d_get_start_width (const dwg_ent_vertex_2d *restrict vert,
5927                                    int *restrict error)
5928 {
5929   if (vert)
5930     {
5931       *error = 0;
5932       return vert->start_width;
5933     }
5934   else
5935     {
5936       *error = 1;
5937       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5938       return bit_nan ();
5939     }
5940 }
5941 
5942 /** Sets the _dwg_entity_VERTEX_2D::start_width, DXF 40.
5943 \code Usage: dwg_ent_vertex_2d_set_start_width(vert, 20, &error);
5944 \endcode
5945 \param[out] vert        dwg_ent_vertex_2d*
5946 \param[in] start_width double
5947 \param[out] error      int*, is set to 0 for ok, 1 on error
5948 \deprecated
5949 */
5950 void
dwg_ent_vertex_2d_set_start_width(dwg_ent_vertex_2d * restrict vert,const double start_width,int * restrict error)5951 dwg_ent_vertex_2d_set_start_width (dwg_ent_vertex_2d *restrict vert,
5952                                    const double start_width,
5953                                    int *restrict error)
5954 {
5955   if (vert)
5956     {
5957       *error = 0;
5958       vert->start_width = start_width;
5959     }
5960   else
5961     {
5962       *error = 1;
5963       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5964     }
5965 }
5966 
5967 /** Returns the _dwg_entity_VERTEX_2D::end_width, DXF 41.
5968 \code Usage: double width = dwg_ent_vertex_2d_get_end_width(vert, &error);
5969 \endcode
5970 \param[in] vert     dwg_ent_vertex_2d*
5971 \param[out] error   int*, is set to 0 for ok, 1 on error
5972 \deprecated
5973 */
5974 double
dwg_ent_vertex_2d_get_end_width(const dwg_ent_vertex_2d * restrict vert,int * restrict error)5975 dwg_ent_vertex_2d_get_end_width (const dwg_ent_vertex_2d *restrict vert,
5976                                  int *restrict error)
5977 {
5978   if (vert)
5979     {
5980       *error = 0;
5981       return vert->end_width;
5982     }
5983   else
5984     {
5985       *error = 1;
5986       LOG_ERROR ("%s: empty arg", __FUNCTION__)
5987       return bit_nan ();
5988     }
5989 }
5990 
5991 /** Sets the _dwg_entity_VERTEX_2D::end_width, DXF 41.
5992 \code Usage: dwg_ent_vertex_2d_set_end_width(vert, 20, &error);
5993 \endcode
5994 \param[out] vert dwg_ent_vertex_2d*
5995 \param[in] end_width double
5996 \param[out] error   int*, is set to 0 for ok, 1 on error
5997 \deprecated
5998 */
5999 void
dwg_ent_vertex_2d_set_end_width(dwg_ent_vertex_2d * restrict vert,const double end_width,int * restrict error)6000 dwg_ent_vertex_2d_set_end_width (dwg_ent_vertex_2d *restrict vert,
6001                                  const double end_width, int *restrict error)
6002 {
6003   if (vert)
6004     {
6005       *error = 0;
6006       vert->end_width = end_width;
6007     }
6008   else
6009     {
6010       *error = 1;
6011       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6012     }
6013 }
6014 
6015 /** Returns the _dwg_entity_VERTEX_2D::bulge, DXF 42. (radians)
6016 \code Usage: double bulge = dwg_ent_vertex_2d_get_bulge(vert, &error);
6017 \endcode
6018 \param[in] vert dwg_ent_vertex_2d*
6019 \param[out] error   int*, is set to 0 for ok, 1 on error
6020 \deprecated
6021 */
6022 double
dwg_ent_vertex_2d_get_bulge(const dwg_ent_vertex_2d * restrict vert,int * restrict error)6023 dwg_ent_vertex_2d_get_bulge (const dwg_ent_vertex_2d *restrict vert,
6024                              int *restrict error)
6025 {
6026   if (vert)
6027     {
6028       *error = 0;
6029       return vert->bulge;
6030     }
6031   else
6032     {
6033       *error = 1;
6034       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6035       return bit_nan ();
6036     }
6037 }
6038 
6039 /** Sets the _dwg_entity_VERTEX_2D::bulge, DXF 42. (radians)
6040 \code Usage: dwg_ent_vertex_2d_set_bulge(vert, 20, &error);
6041 \endcode
6042 \param[in] vert dwg_ent_vertex_2d*
6043 \param[in] bulge double
6044 \param[out] error   int*, is set to 0 for ok, 1 on error
6045 \deprecated
6046 */
6047 void
dwg_ent_vertex_2d_set_bulge(dwg_ent_vertex_2d * restrict vert,const double bulge,int * restrict error)6048 dwg_ent_vertex_2d_set_bulge (dwg_ent_vertex_2d *restrict vert,
6049                              const double bulge, int *restrict error)
6050 {
6051   if (vert)
6052     {
6053       *error = 0;
6054       vert->bulge = bulge;
6055     }
6056   else
6057     {
6058       *error = 1;
6059       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6060     }
6061 }
6062 
6063 /** Returns the _dwg_entity_VERTEX_2D::tangent_dir, DXF 50. (radians)
6064 \code Usage: double tangent_dir = dwg_ent_vertex_2d_get_tangent_dir(vert,
6065 &error); \endcode \param[in] vert dwg_ent_vertex_2d* \param[out] error   int*,
6066 is set to 0 for ok, 1 on error \deprecated
6067 */
6068 double
dwg_ent_vertex_2d_get_tangent_dir(const dwg_ent_vertex_2d * restrict vert,int * restrict error)6069 dwg_ent_vertex_2d_get_tangent_dir (const dwg_ent_vertex_2d *restrict vert,
6070                                    int *restrict error)
6071 {
6072   if (vert)
6073     {
6074       *error = 0;
6075       return vert->tangent_dir;
6076     }
6077   else
6078     {
6079       *error = 1;
6080       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6081       return bit_nan ();
6082     }
6083 }
6084 
6085 /** Sets the _dwg_entity_VERTEX_2D::tangent_dir, DXF 50. (radians)
6086 \code Usage: dwg_ent_vertex_2d_set_tangent_dir(vert, 20, &error);
6087 \endcode
6088 \param[in] vert dwg_ent_vertex_2d*
6089 \param[in] tangent_dir double
6090 \param[out] error   int*, is set to 0 for ok, 1 on error
6091 \deprecated
6092 */
6093 void
dwg_ent_vertex_2d_set_tangent_dir(dwg_ent_vertex_2d * restrict vert,const double tangent_dir,int * restrict error)6094 dwg_ent_vertex_2d_set_tangent_dir (dwg_ent_vertex_2d *restrict vert,
6095                                    const double tangent_dir,
6096                                    int *restrict error)
6097 {
6098   if (vert)
6099     {
6100       *error = 0;
6101       vert->tangent_dir = tangent_dir;
6102     }
6103   else
6104     {
6105       *error = 1;
6106       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6107     }
6108 }
6109 
6110 /*******************************************************************
6111  *                   FUNCTIONS FOR INSERT ENTITY                     *
6112  ********************************************************************/
6113 
6114 /** Returns the _dwg_entity_VERTEX_2D::ins_pt, DXF 10.
6115 \code Usage: dwg_ent_insert_get_ins_pt(insert, &point, &error);
6116 \endcode
6117 \param[in] insert dwg_ent_insert*
6118 \param[out] point dwg_point_3d
6119 \param[out] error   int*, is set to 0 for ok, 1 on error
6120 \deprecated
6121 */
6122 void
dwg_ent_insert_get_ins_pt(const dwg_ent_insert * restrict insert,dwg_point_3d * restrict point,int * restrict error)6123 dwg_ent_insert_get_ins_pt (const dwg_ent_insert *restrict insert,
6124                            dwg_point_3d *restrict point, int *restrict error)
6125 {
6126   if (insert
6127 #  ifndef HAVE_NONNULL
6128       && point
6129 #  endif
6130   )
6131     {
6132       *error = 0;
6133       point->x = insert->ins_pt.x;
6134       point->y = insert->ins_pt.y;
6135       point->z = insert->ins_pt.z;
6136     }
6137   else
6138     {
6139       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6140       *error = 1;
6141     }
6142 }
6143 
6144 /** Sets the  _dwg_entity_VERTEX_2D::ins_pt, DXF 10.
6145 \code Usage: dwg_ent_insert_set_ins_pt(insert, &point, &error);
6146 \endcode
6147 \param[out] insert dwg_ent_insert*
6148 \param[in] point dwg_point_3d
6149 \param error[out]   int*
6150 */
6151 void
dwg_ent_insert_set_ins_pt(dwg_ent_insert * restrict insert,const dwg_point_3d * restrict point,int * restrict error)6152 dwg_ent_insert_set_ins_pt (dwg_ent_insert *restrict insert,
6153                            const dwg_point_3d *restrict point,
6154                            int *restrict error)
6155 {
6156   if (insert
6157 #  ifndef HAVE_NONNULL
6158       && point
6159 #  endif
6160   )
6161     {
6162       *error = 0;
6163       insert->ins_pt.x = point->x;
6164       insert->ins_pt.y = point->y;
6165       insert->ins_pt.z = point->z;
6166     }
6167   else
6168     {
6169       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6170       *error = 1;
6171     }
6172 }
6173 
6174 /** Returns the  _dwg_entity_INSERT::scale vector, DXF 41-43.
6175 \code Usage: dwg_ent_insert_get_scale(insert, &point, &error);
6176 \endcode
6177 \param[in]  insert   dwg_ent_insert*
6178 \param[out] scale3d  dwg_point_3d*
6179 \param[in]  error    int*
6180 */
6181 void
dwg_ent_insert_get_scale(const dwg_ent_insert * restrict insert,dwg_point_3d * restrict scale3d,int * restrict error)6182 dwg_ent_insert_get_scale (const dwg_ent_insert *restrict insert,
6183                           dwg_point_3d *restrict scale3d, int *restrict error)
6184 {
6185   if (insert
6186 #  ifndef HAVE_NONNULL
6187       && scale3d
6188 #  endif
6189   )
6190     {
6191       *error = 0;
6192       scale3d->x = insert->scale.x;
6193       scale3d->y = insert->scale.y;
6194       scale3d->z = insert->scale.z;
6195     }
6196   else
6197     {
6198       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6199       *error = 1;
6200     }
6201 }
6202 
6203 /** Sets the _dwg_entity_INSERT::scale vector, DXF 41-43.
6204 \code Usage: dwg_ent_insert_set_scale(insert, &point, &error);
6205 \endcode
6206 \param[out] insert   dwg_ent_insert*
6207 \param[in]  scale3d  dwg_point_3d*
6208 \param[out] error    int*
6209 */
6210 void
dwg_ent_insert_set_scale(dwg_ent_insert * restrict insert,const dwg_point_3d * restrict scale3d,int * restrict error)6211 dwg_ent_insert_set_scale (dwg_ent_insert *restrict insert,
6212                           const dwg_point_3d *restrict scale3d,
6213                           int *restrict error)
6214 {
6215   if (insert
6216 #  ifndef HAVE_NONNULL
6217       && scale3d
6218 #  endif
6219   )
6220     {
6221       *error = 0;
6222       insert->scale.x = scale3d->x;
6223       insert->scale.y = scale3d->y;
6224       insert->scale.z = scale3d->z;
6225     }
6226   else
6227     {
6228       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6229       *error = 1;
6230     }
6231 }
6232 
6233 /** Returns the _dwg_entity_INSERT::rotation angle, DXF 50 (radians).
6234 \code Usage: double angle = dwg_ent_insert_get_rotation(insert, &error);
6235 \endcode
6236 \param[in] insert dwg_ent_insert*
6237 \param[out] error   int*, is set to 0 for ok, 1 on error
6238 \deprecated
6239 */
6240 double
dwg_ent_insert_get_rotation(const dwg_ent_insert * restrict insert,int * restrict error)6241 dwg_ent_insert_get_rotation (const dwg_ent_insert *restrict insert,
6242                              int *restrict error)
6243 {
6244   if (insert)
6245     {
6246       *error = 0;
6247       return insert->rotation;
6248     }
6249   else
6250     {
6251       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6252       *error = 1;
6253       return bit_nan ();
6254     }
6255 }
6256 
6257 /** Sets the _dwg_entity_INSERT::rotation angle, DXF 50 (radians).
6258 \code Usage: dwg_ent_insert_set_rotation(insert, angle, &error);
6259 \endcode
6260 \param[in] insert dwg_ent_insert*
6261 \param[in] rotation double
6262 \param[out] error   int*, is set to 0 for ok, 1 on error
6263 \deprecated
6264 */
6265 void
dwg_ent_insert_set_rotation(dwg_ent_insert * restrict insert,const double rotation,int * restrict error)6266 dwg_ent_insert_set_rotation (dwg_ent_insert *restrict insert,
6267                              const double rotation, int *restrict error)
6268 {
6269   if (insert)
6270     {
6271       *error = 0;
6272       insert->rotation = rotation;
6273     }
6274   else
6275     {
6276       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6277       *error = 1;
6278     }
6279 }
6280 
6281 /** Returns the _dwg_entity_INSERT::extrusion vector, DXF 210.
6282 \code Usage: dwg_ent_insert_get_extrusion(insert, &point, &error);
6283 \endcode
6284 \param[in]  insert  dwg_ent_insert*
6285 \param[out] vector  dwg_point_3d
6286 \param[out] error   int*, is set to 0 for ok, 1 on error
6287 \deprecated
6288 */
6289 void
dwg_ent_insert_get_extrusion(const dwg_ent_insert * restrict insert,dwg_point_3d * restrict vector,int * restrict error)6290 dwg_ent_insert_get_extrusion (const dwg_ent_insert *restrict insert,
6291                               dwg_point_3d *restrict vector,
6292                               int *restrict error)
6293 {
6294   if (insert
6295 #  ifndef HAVE_NONNULL
6296       && vector
6297 #  endif
6298   )
6299     {
6300       *error = 0;
6301       vector->x = insert->extrusion.x;
6302       vector->y = insert->extrusion.y;
6303       vector->z = insert->extrusion.z;
6304     }
6305   else
6306     {
6307       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6308       *error = 1;
6309     }
6310 }
6311 
6312 /** Sets the _dwg_entity_INSERT::extrusion vector, DXF 210.
6313 \code Usage: dwg_ent_insert_set_extrusion(insert, &point, &error);
6314 \endcode
6315 \param[out] insert  dwg_ent_insert*
6316 \param[in]  vector  dwg_point_3d
6317 \param[out] error   int*, is set to 0 for ok, 1 on error
6318 \deprecated
6319 */
6320 void
dwg_ent_insert_set_extrusion(dwg_ent_insert * restrict insert,const dwg_point_3d * restrict vector,int * restrict error)6321 dwg_ent_insert_set_extrusion (dwg_ent_insert *restrict insert,
6322                               const dwg_point_3d *restrict vector,
6323                               int *restrict error)
6324 {
6325   if (insert
6326 #  ifndef HAVE_NONNULL
6327       && vector
6328 #  endif
6329   )
6330     {
6331       *error = 0;
6332       insert->extrusion.x = vector->x;
6333       insert->extrusion.y = vector->y;
6334       insert->extrusion.z = vector->z;
6335     }
6336   else
6337     {
6338       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6339       *error = 1;
6340     }
6341 }
6342 
6343 /** Returns the _dwg_entity_INSERT::has_attribs value, DXF 66.
6344 \code Usage: double attribs = dwg_ent_insert_has_attribs(insert, &error);
6345 \endcode
6346 \param[in] insert dwg_ent_insert*
6347 \param[out] error   int*, is set to 0 for ok, 1 on error
6348 \deprecated
6349 */
6350 char
dwg_ent_insert_has_attribs(dwg_ent_insert * restrict insert,int * restrict error)6351 dwg_ent_insert_has_attribs (dwg_ent_insert *restrict insert,
6352                             int *restrict error)
6353 {
6354   if (insert)
6355     {
6356       *error = 0;
6357       return insert->has_attribs;
6358     }
6359   else
6360     {
6361       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6362       *error = 1;
6363       return '\0';
6364     }
6365 }
6366 
6367 /** Returns the  _dwg_entity_INSERT::num_owned count.
6368 \code Usage: BITCODE_BL count = dwg_ent_insert_get_num_owned(insert, &error);
6369 \endcode
6370 \param[in] insert dwg_ent_insert*
6371 \param[out] error int*, is set to 0 for ok, 1 on error
6372 \deprecated
6373 */
6374 BITCODE_BL
dwg_ent_insert_get_num_owned(const dwg_ent_insert * restrict insert,int * restrict error)6375 dwg_ent_insert_get_num_owned (const dwg_ent_insert *restrict insert,
6376                               int *restrict error)
6377 {
6378   if (insert)
6379     {
6380       *error = 0;
6381       return insert->num_owned;
6382     }
6383   else
6384     {
6385       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6386       *error = 1;
6387       return 0L;
6388     }
6389 }
6390 
6391 /// FIXME needs to adjust handle array instead: add/delete
6392 // TODO dwg_ent_insert_add_owned, dwg_ent_insert_delete_owned
6393 // TODO get_name
6394 
6395 /** Returns the _dwg_entity_INSERT::block_header.
6396 \code Usage: dwg_object* block_header = dwg_ent_insert_get_block_header(insert,
6397 &error); \endcode \param[in]  insert  dwg_ent_insert* \param[out] error   int*,
6398 is set to 0 for ok, 1 on error \deprecated
6399 */
6400 dwg_object *
dwg_ent_insert_get_block_header(const dwg_ent_insert * restrict insert,int * restrict error)6401 dwg_ent_insert_get_block_header (const dwg_ent_insert *restrict insert,
6402                                  int *restrict error)
6403 {
6404   if (insert)
6405     {
6406       *error = 0;
6407       return dwg_ref_get_object (insert->block_header, error);
6408     }
6409   else
6410     {
6411       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6412       *error = 1;
6413       return NULL;
6414     }
6415 }
6416 
6417 /*******************************************************************
6418  *                  FUNCTIONS FOR MINSERT ENTITY                     *
6419  ********************************************************************/
6420 
6421 /** Returns the _dwg_entity_MINSERT::ins_pt, DXF 10.
6422 \code Usage: dwg_ent_minsert_get_ins_pt(minsert, &point, &error);
6423 \endcode
6424 \param[in]  minsert dwg_ent_minsert*
6425 \param[out] point dwg_point_3d
6426 \param[out] error   int*, is set to 0 for ok, 1 on error
6427 \deprecated
6428 */
6429 void
dwg_ent_minsert_get_ins_pt(const dwg_ent_minsert * restrict minsert,dwg_point_3d * restrict point,int * restrict error)6430 dwg_ent_minsert_get_ins_pt (const dwg_ent_minsert *restrict minsert,
6431                             dwg_point_3d *restrict point, int *restrict error)
6432 {
6433   if (minsert
6434 #  ifndef HAVE_NONNULL
6435       && point
6436 #  endif
6437   )
6438     {
6439       *error = 0;
6440       point->x = minsert->ins_pt.x;
6441       point->y = minsert->ins_pt.y;
6442       point->z = minsert->ins_pt.z;
6443     }
6444   else
6445     {
6446       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6447       *error = 1;
6448     }
6449 }
6450 
6451 /** Sets the _dwg_entity_MINSERT::ins_pt, DXF 10.
6452 \code Usage: dwg_ent_minsert_set_ins_pt(minsert, &point, &error);
6453 \endcode
6454 \param[out] minsert dwg_ent_minsert*
6455 \param[in]  point dwg_point_3d
6456 \param[out] error   int*, is set to 0 for ok, 1 on error
6457 \deprecated
6458 */
6459 void
dwg_ent_minsert_set_ins_pt(dwg_ent_minsert * restrict minsert,const dwg_point_3d * restrict point,int * restrict error)6460 dwg_ent_minsert_set_ins_pt (dwg_ent_minsert *restrict minsert,
6461                             const dwg_point_3d *restrict point,
6462                             int *restrict error)
6463 {
6464   if (minsert
6465 #  ifndef HAVE_NONNULL
6466       && point
6467 #  endif
6468   )
6469     {
6470       *error = 0;
6471       minsert->ins_pt.x = point->x;
6472       minsert->ins_pt.y = point->y;
6473       minsert->ins_pt.z = point->z;
6474     }
6475   else
6476     {
6477       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6478       *error = 1;
6479     }
6480 }
6481 
6482 /** Returns the _dwg_entity_MINSERT::scale vector, DXF 41-43.
6483 \code Usage: dwg_ent_minsert_get_scale(minsert, &scale3d, &error);
6484 \endcode
6485 \param minsert[in]   dwg_ent_insert*
6486 \param scale3d[out]  dwg_point_3d*
6487 \param error[out]    int*
6488 */
6489 void
dwg_ent_minsert_get_scale(const dwg_ent_minsert * restrict minsert,dwg_point_3d * restrict scale3d,int * restrict error)6490 dwg_ent_minsert_get_scale (const dwg_ent_minsert *restrict minsert,
6491                            dwg_point_3d *restrict scale3d, int *restrict error)
6492 {
6493   if (minsert
6494 #  ifndef HAVE_NONNULL
6495       && scale3d
6496 #  endif
6497   )
6498     {
6499       *error = 0;
6500       scale3d->x = minsert->scale.x;
6501       scale3d->y = minsert->scale.y;
6502       scale3d->z = minsert->scale.z;
6503     }
6504   else
6505     {
6506       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6507       *error = 1;
6508     }
6509 }
6510 
6511 /** Sets the _dwg_entity_MINSERT::scale vector, DXF 41-43. (TODO scale_flag)
6512 \code Usage: dwg_ent_minsert_set_scale(minsert, &scale3d, &error);
6513 \endcode
6514 \param minsert[out]  minsert  dwg_ent_insert*
6515 \param scale3d[in]   scale3d  dwg_point_3d*
6516 \param error[out]    int*
6517 */
6518 void
dwg_ent_minsert_set_scale(dwg_ent_minsert * restrict minsert,const dwg_point_3d * restrict scale3d,int * restrict error)6519 dwg_ent_minsert_set_scale (dwg_ent_minsert *restrict minsert,
6520                            const dwg_point_3d *restrict scale3d,
6521                            int *restrict error)
6522 {
6523   if (minsert
6524 #  ifndef HAVE_NONNULL
6525       && scale3d
6526 #  endif
6527   )
6528     {
6529       *error = 0;
6530       // TODO: set scale_flag
6531       minsert->scale.x = scale3d->x;
6532       minsert->scale.y = scale3d->y;
6533       minsert->scale.z = scale3d->z;
6534     }
6535   else
6536     {
6537       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6538       *error = 1;
6539     }
6540 }
6541 
6542 /** Returns the _dwg_entity_MINSERT::rotation angle, DXF 50. (radians)
6543 \code Usage: double angle = dwg_ent_minsert_get_rotation(minsert, &error);
6544 \endcode
6545 \param[in] minsert dwg_ent_minsert*
6546 \param[out] error   int*, is set to 0 for ok, 1 on error
6547 \deprecated
6548 */
6549 double
dwg_ent_minsert_get_rotation(const dwg_ent_minsert * restrict minsert,int * restrict error)6550 dwg_ent_minsert_get_rotation (const dwg_ent_minsert *restrict minsert,
6551                               int *restrict error)
6552 {
6553   if (minsert)
6554     {
6555       *error = 0;
6556       return minsert->rotation;
6557     }
6558   else
6559     {
6560       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6561       *error = 1;
6562       return bit_nan ();
6563     }
6564 }
6565 
6566 /** Sets the _dwg_entity_MINSERT::rotation angle, DXF 50. (radians)
6567 \code Usage: dwg_ent_minsert_set_rotation(minsert, angle, &error);
6568 \endcode
6569 \param[in] minsert dwg_ent_minsert*
6570 \param[in] double
6571 \param[out] error   int*, is set to 0 for ok, 1 on error
6572 \deprecated
6573 */
6574 void
dwg_ent_minsert_set_rotation(dwg_ent_minsert * restrict minsert,const double rot_ang,int * restrict error)6575 dwg_ent_minsert_set_rotation (dwg_ent_minsert *restrict minsert,
6576                               const double rot_ang, int *restrict error)
6577 {
6578   if (minsert)
6579     {
6580       *error = 0;
6581       minsert->rotation = rot_ang;
6582     }
6583   else
6584     {
6585       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6586       *error = 1;
6587     }
6588 }
6589 
6590 /** Returns the _dwg_entity_MINSERT::extrusion vector, DXF 210.
6591 \code Usage: dwg_ent_minsert_get_extrusion(minsert, &point, &error);
6592 \endcode
6593 \param[in]  minsert dwg_ent_minsert*
6594 \param[out] vector dwg_point_3d
6595 \param[out] error   int*, is set to 0 for ok, 1 on error
6596 \deprecated
6597 */
6598 void
dwg_ent_minsert_get_extrusion(const dwg_ent_minsert * restrict minsert,dwg_point_3d * restrict vector,int * restrict error)6599 dwg_ent_minsert_get_extrusion (const dwg_ent_minsert *restrict minsert,
6600                                dwg_point_3d *restrict vector,
6601                                int *restrict error)
6602 {
6603   if (minsert
6604 #  ifndef HAVE_NONNULL
6605       && vector
6606 #  endif
6607   )
6608     {
6609       *error = 0;
6610       vector->x = minsert->extrusion.x;
6611       vector->y = minsert->extrusion.y;
6612       vector->z = minsert->extrusion.z;
6613     }
6614   else
6615     {
6616       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6617       *error = 1;
6618     }
6619 }
6620 
6621 /** Sets the _dwg_entity_MINSERT::extrusion vector, DXF 210.
6622 \code Usage: dwg_ent_minsert_set_extrusion(minsert, &point, &error);
6623 \endcode
6624 \param[out] minsert dwg_ent_minsert*
6625 \param[in]  vector dwg_point_3d
6626 \param[out] error   int*, is set to 0 for ok, 1 on error
6627 \deprecated
6628 */
6629 void
dwg_ent_minsert_set_extrusion(dwg_ent_minsert * restrict minsert,const dwg_point_3d * restrict vector,int * restrict error)6630 dwg_ent_minsert_set_extrusion (dwg_ent_minsert *restrict minsert,
6631                                const dwg_point_3d *restrict vector,
6632                                int *restrict error)
6633 {
6634   if (minsert
6635 #  ifndef HAVE_NONNULL
6636       && vector
6637 #  endif
6638   )
6639     {
6640       *error = 0;
6641       minsert->extrusion.x = vector->x;
6642       minsert->extrusion.y = vector->y;
6643       minsert->extrusion.z = vector->z;
6644     }
6645   else
6646     {
6647       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6648       *error = 1;
6649     }
6650 }
6651 
6652 /** Returns the _dwg_entity_MINSERT::has_attrib value, DXF 66
6653 \code Usage: double attribs = dwg_ent_minsert_has_attribs(mintrest, &error);
6654 \endcode
6655 \param[in] minsert dwg_ent_minsert*
6656 \param[out] error   int*, is set to 0 for ok, 1 on error
6657 \deprecated
6658 */
6659 char
dwg_ent_minsert_has_attribs(dwg_ent_minsert * restrict minsert,int * restrict error)6660 dwg_ent_minsert_has_attribs (dwg_ent_minsert *restrict minsert,
6661                              int *restrict error)
6662 {
6663   if (minsert)
6664     {
6665       *error = 0;
6666       return minsert->has_attribs;
6667     }
6668   else
6669     {
6670       LOG_ERROR ("%s: empty minsert", __FUNCTION__)
6671       *error = 1;
6672       return '\0';
6673     }
6674 }
6675 
6676 /** Returns the  _dwg_entity_MINSERT::num_owned count, no DXF.
6677 \code Usage: BITCODE_BL count = dwg_ent_minsert_get_num_owned(minsert, &error);
6678 \endcode
6679 \param[in] minsert dwg_ent_minsert*
6680 \param[out] error   int*, is set to 0 for ok, 1 on error
6681 \deprecated
6682 */
6683 BITCODE_BL
dwg_ent_minsert_get_num_owned(const dwg_ent_minsert * restrict minsert,int * restrict error)6684 dwg_ent_minsert_get_num_owned (const dwg_ent_minsert *restrict minsert,
6685                                int *restrict error)
6686 {
6687   if (minsert)
6688     {
6689       *error = 0;
6690       return minsert->num_owned;
6691     }
6692   else
6693     {
6694       *error = 1;
6695       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6696       return 0L;
6697     }
6698 }
6699 
6700 /// FIXME needs to adjust attribs array: add/delete
6701 
6702 // TODO dwg_ent_minsert_add_owned, dwg_ent_minsert_delete_owned
6703 
6704 /** Sets the  _dwg_entity_MINSERT::num_cols count, DXF 70.
6705 \code Usage: dwg_ent_minsert_set_num_cols(minsert, 2, &error);
6706 \endcode
6707 \param[out] minsert dwg_ent_minsert*
6708 \param[in] num_cols
6709 \param[out] error   int*, is set to 0 for ok, 1 on error
6710 \deprecated
6711 */
6712 void
dwg_ent_minsert_set_num_cols(dwg_ent_minsert * restrict minsert,const BITCODE_BL num_cols,int * restrict error)6713 dwg_ent_minsert_set_num_cols (dwg_ent_minsert *restrict minsert,
6714                               const BITCODE_BL num_cols, int *restrict error)
6715 {
6716   if (minsert)
6717     {
6718       *error = 0;
6719       minsert->num_cols = num_cols;
6720     }
6721   else
6722     {
6723       *error = 1;
6724       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6725     }
6726 }
6727 
6728 /** Returns the  _dwg_entity_MINSERT::num_cols count, DXF 70.
6729 \code Usage: BITCODE_BL num_cols = dwg_ent_minsert_get_num_cols(minsert,
6730 &error); \endcode \param[in] minsert dwg_ent_minsert* \param[out] error   int*,
6731 is set to 0 for ok, 1 on error \deprecated
6732 */
6733 BITCODE_BL
dwg_ent_minsert_get_num_cols(const dwg_ent_minsert * restrict minsert,int * restrict error)6734 dwg_ent_minsert_get_num_cols (const dwg_ent_minsert *restrict minsert,
6735                               int *restrict error)
6736 {
6737   if (minsert)
6738     {
6739       *error = 0;
6740       return minsert->num_cols;
6741     }
6742   else
6743     {
6744       *error = 1;
6745       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6746       return 0L;
6747     }
6748 }
6749 
6750 /** Sets the  _dwg_entity_MINSERT::num_rows count, DXF 71.
6751 \code Usage: dwg_ent_minsert_set_num_rows(minsert, 2, &error);
6752 \endcode
6753 \param[out] minsert dwg_ent_minsert*
6754 \param[in]  num_rows
6755 \param[out] error   int*, is set to 0 for ok, 1 on error
6756 \deprecated
6757 */
6758 void
dwg_ent_minsert_set_num_rows(dwg_ent_minsert * restrict minsert,const BITCODE_BL num_rows,int * restrict error)6759 dwg_ent_minsert_set_num_rows (dwg_ent_minsert *restrict minsert,
6760                               const BITCODE_BL num_rows, int *restrict error)
6761 {
6762   if (minsert)
6763     {
6764       *error = 0;
6765       minsert->num_rows = num_rows;
6766     }
6767   else
6768     {
6769       *error = 1;
6770       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6771     }
6772 }
6773 
6774 /** Returns the  _dwg_entity_MINSERT::num_rows count, DXF 71.
6775 \code Usage: BITCODE_BL num_rows = dwg_ent_minsert_get_num_rows(minsert,
6776 &error); \endcode \param[in] minsert dwg_ent_minsert* \param[out] error   int*,
6777 is set to 0 for ok, 1 on error \deprecated
6778 */
6779 BITCODE_BL
dwg_ent_minsert_get_num_rows(const dwg_ent_minsert * restrict minsert,int * restrict error)6780 dwg_ent_minsert_get_num_rows (const dwg_ent_minsert *restrict minsert,
6781                               int *restrict error)
6782 {
6783   if (minsert)
6784     {
6785       *error = 0;
6786       return minsert->num_rows;
6787     }
6788   else
6789     {
6790       *error = 1;
6791       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6792       return 0L;
6793     }
6794 }
6795 
6796 /** Returns the _dwg_entity_MINSERT::col_spacing, DXF 44.
6797 \code Usage: double spacing = dwg_ent_minsert_get_col_spacing(minsert, &error);
6798 \endcode
6799 \param[in] minsert dwg_ent_minsert*
6800 \param[out] error   int*, is set to 0 for ok, 1 on error
6801 \deprecated
6802 */
6803 double
dwg_ent_minsert_get_col_spacing(const dwg_ent_minsert * restrict minsert,int * restrict error)6804 dwg_ent_minsert_get_col_spacing (const dwg_ent_minsert *restrict minsert,
6805                                  int *restrict error)
6806 {
6807   if (minsert)
6808     {
6809       *error = 0;
6810       return minsert->col_spacing;
6811     }
6812   else
6813     {
6814       *error = 1;
6815       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6816       return bit_nan ();
6817     }
6818 }
6819 
6820 /** Sets the _dwg_entity_MINSERT::col_spacing, DXF 44.
6821 \code Usage: dwg_ent_minsert_set_col_spacing(minsert, 20, &error);
6822 \endcode
6823 \param[out] minsert dwg_ent_insert*
6824 \param[in]  spacing double
6825 \param[out] error   int*, is set to 0 for ok, 1 on error
6826 \deprecated
6827 */
6828 void
dwg_ent_minsert_set_col_spacing(dwg_ent_minsert * restrict minsert,const double spacing,int * restrict error)6829 dwg_ent_minsert_set_col_spacing (dwg_ent_minsert *restrict minsert,
6830                                  const double spacing, int *restrict error)
6831 {
6832   if (minsert)
6833     {
6834       *error = 0;
6835       minsert->col_spacing = spacing;
6836     }
6837   else
6838     {
6839       *error = 1;
6840       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6841     }
6842 }
6843 
6844 /** Returns the _dwg_entity_MINSERT::row_spacing, DXF 45.
6845 \code Usage: double spacing = dwg_ent_minsert_get_row_spacing(minsert, &error);
6846 \endcode
6847 \param[in] minsert dwg_ent_minsert*
6848 \param[out] error   int*, is set to 0 for ok, 1 on error
6849 \deprecated
6850 */
6851 double
dwg_ent_minsert_get_row_spacing(const dwg_ent_minsert * restrict minsert,int * restrict error)6852 dwg_ent_minsert_get_row_spacing (const dwg_ent_minsert *restrict minsert,
6853                                  int *restrict error)
6854 {
6855   if (minsert)
6856     {
6857       *error = 0;
6858       return minsert->row_spacing;
6859     }
6860   else
6861     {
6862       *error = 1;
6863       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6864       return bit_nan ();
6865     }
6866 }
6867 
6868 /** Sets the  _dwg_entity_MINSERT::row_spacing, DXF 45.
6869 \code Usage: dwg_ent_minsert_set_row_spacing(minsert, 20, &error);
6870 \endcode
6871 \param[out] insert dwg_ent_insert*
6872 \param[in]  spacing double
6873 \param[out] error   int*, is set to 0 for ok, 1 on error
6874 \deprecated
6875 */
6876 void
dwg_ent_minsert_set_row_spacing(dwg_ent_minsert * restrict minsert,const double spacing,int * restrict error)6877 dwg_ent_minsert_set_row_spacing (dwg_ent_minsert *restrict minsert,
6878                                  const double spacing, int *restrict error)
6879 {
6880   if (minsert)
6881     {
6882       *error = 0;
6883       minsert->row_spacing = spacing;
6884     }
6885   else
6886     {
6887       *error = 1;
6888       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6889     }
6890 }
6891 
6892 /** Returns the  _dwg_entity_MINSERT::block_header object, DXF 2.
6893 \code Usage: dwg_object* block_header =
6894 dwg_ent_minsert_get_block_header(minsert, &error); \endcode \param[in]  minsert
6895 dwg_ent_minsert* \param[out] error   int*, is set to 0 for ok, 1 on error
6896 \deprecated
6897 */
6898 dwg_object *
dwg_ent_minsert_get_block_header(const dwg_ent_minsert * restrict minsert,int * restrict error)6899 dwg_ent_minsert_get_block_header (const dwg_ent_minsert *restrict minsert,
6900                                   int *restrict error)
6901 {
6902   if (minsert)
6903     {
6904       *error = 0;
6905       return dwg_ref_get_object (minsert->block_header, error);
6906     }
6907   else
6908     {
6909       LOG_ERROR ("%s: empty insert", __FUNCTION__)
6910       *error = 1;
6911       return NULL;
6912     }
6913 }
6914 
6915 /*******************************************************************
6916  *                FUNCTIONS FOR MLINESTYLE OBJECT                    *
6917  ********************************************************************/
6918 
6919 /** Returns the  _dwg_object_MLINESTYLE::name, DXF 2 (utf-8 encoded)
6920 \code Usage: char * name = dwg_obj_mlinestyle_get_name(mlinestyle, &error);
6921 \endcode
6922 \param[in]  mlinestyle dwg_obj_mlinestyle
6923 \param[out] error   int*, is set to 0 for ok, 1 on error
6924 \deprecated
6925 */
6926 char *
dwg_obj_mlinestyle_get_name(const dwg_obj_mlinestyle * restrict mlinestyle,int * restrict error)6927 dwg_obj_mlinestyle_get_name (const dwg_obj_mlinestyle *restrict mlinestyle,
6928                              int *restrict error)
6929 {
6930   if (mlinestyle)
6931     {
6932       *error = 0;
6933       if (dwg_version >= R_2007)
6934         return bit_convert_TU ((BITCODE_TU)mlinestyle->name);
6935       else
6936         return mlinestyle->name;
6937     }
6938   else
6939     {
6940       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
6941       *error = 1;
6942       return NULL;
6943     }
6944 }
6945 
6946 /** Sets the _dwg_object_MLINESTYLE::name
6947 \code Usage: dwg_obj_mlinestyle_set_name(minsert, "mstylename", &error);
6948 \endcode
6949 \param[out] mlinestyle dwg_obj_mlinestyle
6950 \param[in]  name char *
6951 \param[out] error   int*, is set to 0 for ok, 1 on error
6952 \deprecated
6953 */
6954 void
dwg_obj_mlinestyle_set_name(dwg_obj_mlinestyle * restrict mlinestyle,const char * restrict name,int * restrict error)6955 dwg_obj_mlinestyle_set_name (dwg_obj_mlinestyle *restrict mlinestyle,
6956                              const char *restrict name, int *restrict error)
6957 {
6958   Dwg_Data *dwg = dwg_obj_generic_dwg (mlinestyle, error);
6959   if (mlinestyle && !error)
6960     {
6961       mlinestyle->name = dwg_add_u8_input (dwg, name);
6962     }
6963   else
6964     {
6965       *error = 1;
6966       LOG_ERROR ("%s: empty arg", __FUNCTION__)
6967     }
6968 }
6969 
6970 /** Returns the _dwg_object_MLINESTYLE::desc, DXF 3 (utf-8 encoded)
6971 \code Usage: char * desc = dwg_obj_mlinestyle_get_desc(mlinestyle, &error);
6972 \endcode
6973 \param[in]  mlinestyle dwg_obj_mlinestyle
6974 \param[out] error   int*, is set to 0 for ok, 1 on error
6975 \deprecated
6976 */
6977 char *
dwg_obj_mlinestyle_get_desc(const dwg_obj_mlinestyle * restrict mlinestyle,int * restrict error)6978 dwg_obj_mlinestyle_get_desc (const dwg_obj_mlinestyle *restrict mlinestyle,
6979                              int *restrict error)
6980 {
6981   if (mlinestyle)
6982     {
6983       *error = 0;
6984       if (dwg_version >= R_2007)
6985         return bit_convert_TU ((BITCODE_TU)mlinestyle->description);
6986       else
6987         return mlinestyle->description;
6988     }
6989   else
6990     {
6991       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
6992       *error = 1;
6993       return NULL;
6994     }
6995 }
6996 
6997 /** Sets the _dwg_object_MLINESTYLE::desc, DXF 3. (utf-8 encoded)
6998 \code Usage: dwg_obj_mlinestyle_set_desc(minsert, desc, &error);
6999 \endcode
7000 \param[out] mlinestyle dwg_obj_mlinestyle
7001 \param[in] desc utf-8 char *
7002 \param[out] error   int*, is set to 0 for ok, 1 on error
7003 \deprecated
7004 */
7005 void
dwg_obj_mlinestyle_set_desc(dwg_obj_mlinestyle * restrict mlinestyle,const char * restrict desc,int * restrict error)7006 dwg_obj_mlinestyle_set_desc (dwg_obj_mlinestyle *restrict mlinestyle,
7007                              const char *restrict desc, int *restrict error)
7008 {
7009   Dwg_Data *dwg = dwg_obj_generic_dwg (mlinestyle, error);
7010   if (mlinestyle && !error)
7011     {
7012       mlinestyle->description = dwg_add_u8_input (dwg, desc);
7013     }
7014   else
7015     {
7016       *error = 1;
7017       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7018     }
7019 }
7020 
7021 /** Returns the _dwg_object_MLINESTYLE::flag, DXF 70
7022 \code Usage: int flag = dwg_obj_mlinestyle_get_flag(minsert, &error);
7023 \endcode
7024 \param[in]  mlinestyle dwg_obj_mlinestyle
7025 \param[out] error      int*, is set to 0 for ok, 1 on error
7026 \deprecated
7027 */
7028 int
dwg_obj_mlinestyle_get_flag(const dwg_obj_mlinestyle * restrict mlinestyle,int * restrict error)7029 dwg_obj_mlinestyle_get_flag (const dwg_obj_mlinestyle *restrict mlinestyle,
7030                              int *restrict error)
7031 {
7032   if (mlinestyle)
7033     {
7034       *error = 0;
7035       return mlinestyle->flag;
7036     }
7037   else
7038     {
7039       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
7040       *error = 1;
7041       return '\0';
7042     }
7043 }
7044 
7045 /** Sets the _dwg_object_MLINESTYLE::flag, DXF 70
7046 \code Usage: dwg_obj_mlinestyle_set_flag(mlinestyle, 1+2, &error);
7047 \endcode
7048 \param[out] mlinestyle  dwg_ent_mlinestyle*
7049 \param[in]  flags int
7050 \param[out] error   int*, is set to 0 for ok, 1 on error
7051 \deprecated
7052 */
7053 void
dwg_obj_mlinestyle_set_flag(dwg_obj_mlinestyle * restrict mlinestyle,const int flags,int * restrict error)7054 dwg_obj_mlinestyle_set_flag (dwg_obj_mlinestyle *restrict mlinestyle,
7055                              const int flags, int *restrict error)
7056 {
7057   if (mlinestyle)
7058     {
7059       *error = 0;
7060       mlinestyle->flag = flags;
7061     }
7062   else
7063     {
7064       *error = 1;
7065       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7066     }
7067 }
7068 
7069 /** Returns the _dwg_object_MLINESTYLE::start_angle, DXF 51 (radians)
7070 \code Usage: double start_angle =
7071 dwg_obj_mlinestyle_get_start_angle(mlinestyle, &error); \endcode \param[in]
7072 mlinestyle  dwg_obj_mlinestyle \param[out] error   int*, is set to 0 for ok, 1
7073 on error \deprecated
7074 */
7075 double
dwg_obj_mlinestyle_get_start_angle(const dwg_obj_mlinestyle * restrict mlinestyle,int * restrict error)7076 dwg_obj_mlinestyle_get_start_angle (
7077     const dwg_obj_mlinestyle *restrict mlinestyle, int *restrict error)
7078 {
7079   if (mlinestyle)
7080     {
7081       *error = 0;
7082       return mlinestyle->start_angle;
7083     }
7084   else
7085     {
7086       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
7087       *error = 1;
7088       return '\0';
7089     }
7090 }
7091 
7092 /** Sets the _dwg_object_MLINESTYLE::start_angle, DXF 51 (radians)
7093 \code Usage: dwg_obj_mlinestyle_set_start_angle(mlinestyle, M_PI_2, &error);
7094 \endcode
7095 \param[out] mlinestyle  dwg_obj_mlinestyle
7096 \param[in]  start_angle double
7097 \param[out] error   int*, is set to 0 for ok, 1 on error
7098 \deprecated
7099 */
7100 void
dwg_obj_mlinestyle_set_start_angle(dwg_obj_mlinestyle * restrict mlinestyle,const double start_angle,int * restrict error)7101 dwg_obj_mlinestyle_set_start_angle (dwg_obj_mlinestyle *restrict mlinestyle,
7102                                     const double start_angle,
7103                                     int *restrict error)
7104 {
7105   if (mlinestyle)
7106     {
7107       *error = 0;
7108       mlinestyle->start_angle = start_angle;
7109     }
7110   else
7111     {
7112       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
7113       *error = 1;
7114     }
7115 }
7116 
7117 /** Returns the _dwg_object_MLINESTYLE::end_angle, DXF 52 (radians)
7118 \code Usage: double angle = dwg_obj_mlinestyle_get_end_angle(mlinestyle,
7119 &error); \endcode \param[in]  mlinestyle dwg_obj_mlinestyle \param[out] error
7120 int*, is set to 0 for ok, 1 on error \deprecated
7121 */
7122 double
dwg_obj_mlinestyle_get_end_angle(const dwg_obj_mlinestyle * restrict mlinestyle,int * restrict error)7123 dwg_obj_mlinestyle_get_end_angle (
7124     const dwg_obj_mlinestyle *restrict mlinestyle, int *restrict error)
7125 {
7126   if (mlinestyle)
7127     {
7128       *error = 0;
7129       return mlinestyle->end_angle;
7130     }
7131   else
7132     {
7133       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
7134       *error = 1;
7135       return '\0';
7136     }
7137 }
7138 
7139 /** Sets the _dwg_object_MLINESTYLE::end_angle, DXF 51 (radians)
7140 \code Usage: dwg_obj_mlinestyle_set_end_angle(mlinestyle, M_PI_2, &error);
7141 \endcode
7142 \param[out] mlinestyle dwg_obj_mlinestyle
7143 \param[in]  end_angle double
7144 \param[out] error   int*, is set to 0 for ok, 1 on error
7145 \deprecated
7146 */
7147 void
dwg_obj_mlinestyle_set_end_angle(dwg_obj_mlinestyle * restrict mlinestyle,const double end_angle,int * restrict error)7148 dwg_obj_mlinestyle_set_end_angle (dwg_obj_mlinestyle *restrict mlinestyle,
7149                                   const double end_angle, int *restrict error)
7150 {
7151   if (mlinestyle)
7152     {
7153       *error = 0;
7154       mlinestyle->end_angle = end_angle;
7155     }
7156   else
7157     {
7158       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
7159       *error = 1;
7160     }
7161 }
7162 
7163 /** Returns the _dwg_object_MLINESTYLE::num_lines, DXF 71.
7164 \code Usage: char lines = dwg_obj_mlinestyle_get_num_lines(mlinestyle, &error);
7165 \endcode
7166 \param[in]  mlinestyle dwg_obj_mlinestyle
7167 \param[out] error   int*, is set to 0 for ok, 1 on error
7168 \deprecated
7169 */
7170 char
dwg_obj_mlinestyle_get_num_lines(const dwg_obj_mlinestyle * restrict mlinestyle,int * restrict error)7171 dwg_obj_mlinestyle_get_num_lines (
7172     const dwg_obj_mlinestyle *restrict mlinestyle, int *restrict error)
7173 {
7174   if (mlinestyle)
7175     {
7176       *error = 0;
7177       return mlinestyle->num_lines;
7178     }
7179   else
7180     {
7181       LOG_ERROR ("%s: empty mlinestyle", __FUNCTION__)
7182       *error = 1;
7183       return '\0';
7184     }
7185 }
7186 
7187 /*******************************************************************
7188  *               FUNCTIONS FOR APPID_CONTROL OBJECT                  *
7189  ********************************************************************/
7190 
7191 /** Returns the _dwg_entity_APPID_CONTROL::num_entries, DXF 70.
7192 \code Usage: int num = dwg_obj_appid_control_get_num_entries(appcontrol,
7193 &error); \endcode \param[in]  appid dwg_obj_appid_control \param[out] error
7194 int*, is set to 0 for ok, 1 on error \deprecated
7195 */
7196 BITCODE_BS
dwg_obj_appid_control_get_num_entries(const dwg_obj_appid_control * restrict appid,int * restrict error)7197 dwg_obj_appid_control_get_num_entries (
7198     const dwg_obj_appid_control *restrict appid, int *restrict error)
7199 {
7200   if (appid)
7201     {
7202       *error = 0;
7203       return appid->num_entries;
7204     }
7205   else
7206     {
7207       LOG_ERROR ("%s: empty appid", __FUNCTION__)
7208       *error = 1;
7209       return 0;
7210     }
7211 }
7212 
7213 /** Returns the idx'th _dwg_entity_APPID:: object.
7214 \code Usage: int num = dwg_obj_appid_control_get_appid(appcontrol, 0, &error);
7215 \endcode
7216 \param[in]  appid dwg_obj_appid_control*
7217 \param[in]  idx
7218 \param[out] error   int*, is set to 0 for ok, 1 on error
7219 \deprecated
7220 */
7221 dwg_object_ref *
dwg_obj_appid_control_get_appid(const dwg_obj_appid_control * restrict appid,const BITCODE_BS idx,int * restrict error)7222 dwg_obj_appid_control_get_appid (const dwg_obj_appid_control *restrict appid,
7223                                  const BITCODE_BS idx, int *restrict error)
7224 {
7225   if (appid != NULL && idx < appid->num_entries)
7226     {
7227       *error = 0;
7228       return appid->entries[idx];
7229     }
7230   else
7231     {
7232       *error = 1;
7233       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7234       return NULL;
7235     }
7236 }
7237 
7238 /*******************************************************************
7239  *                    FUNCTIONS FOR APPID OBJECT                     *
7240  ********************************************************************/
7241 
7242 /** Returns the _dwg_entity_APPID::name, DXF 2. (utf-8 encoded)
7243 \code Usage: char * name = dwg_obj_appid_get_name(mlinestyle, &error);
7244 \endcode
7245 \param[in]  appid  dwg_obj_appid
7246 \param[out] error   int*, is set to 0 for ok, 1 on error
7247 \deprecated
7248 */
7249 char *
dwg_obj_appid_get_name(const dwg_obj_appid * restrict appid,int * restrict error)7250 dwg_obj_appid_get_name (const dwg_obj_appid *restrict appid,
7251                         int *restrict error)
7252 {
7253   if (appid)
7254     {
7255       *error = 0;
7256       if (dwg_version >= R_2007)
7257         return bit_convert_TU ((BITCODE_TU)appid->name);
7258       else
7259         return appid->name;
7260     }
7261   else
7262     {
7263       LOG_ERROR ("%s: empty appid", __FUNCTION__)
7264       *error = 1;
7265       return NULL;
7266     }
7267 }
7268 
7269 /** Returns the _dwg_entity_APPID::flag, DXF 70.
7270 \code Usage: char flag = dwg_obj_appid_get_flag(appid, &error);
7271 \endcode
7272 \param[in]  appid   dwg_obj_appid
7273 \param[out] error   int*, is set to 0 for ok, 1 on error
7274 \deprecated
7275 */
7276 BITCODE_RC
dwg_obj_appid_get_flag(const dwg_obj_appid * restrict appid,int * restrict error)7277 dwg_obj_appid_get_flag (const dwg_obj_appid *restrict appid,
7278                         int *restrict error)
7279 {
7280   if (appid)
7281     {
7282       *error = 0;
7283       return appid->flag & 1 || appid->is_xref_ref >> 4 || appid->is_xref_dep >> 6;
7284     }
7285   else
7286     {
7287       LOG_ERROR ("%s: empty appid", __FUNCTION__)
7288       *error = 1;
7289       return 0;
7290     }
7291 }
7292 
7293 /** Sets the _dwg_entity_APPID::flag, DXF 70.
7294     and the other related xref flags.
7295 \code Usage: dwg_obj_appid_set_flag(appid, flag, &error);
7296 \endcode
7297 \param[out] appid  dwg_obj_appid*
7298 \param[in]  flag
7299 \param[out] error   int*, is set to 0 for ok, 1 on error
7300 \deprecated
7301 */
7302 void
dwg_obj_appid_set_flag(dwg_obj_appid * restrict appid,const BITCODE_RC flag,int * restrict error)7303 dwg_obj_appid_set_flag (dwg_obj_appid *restrict appid, const BITCODE_RC flag,
7304                         int *restrict error)
7305 {
7306   if (appid)
7307     {
7308       *error = 0;
7309       appid->flag = flag;
7310       appid->is_xref_ref = flag & 16;
7311       appid->is_xref_dep = flag & 64;
7312     }
7313   else
7314     {
7315       LOG_ERROR ("%s: empty appid", __FUNCTION__)
7316       *error = 1;
7317     }
7318 }
7319 
7320 /** Returns the  _dwg_entity_APPID_CONTROL:: object for the appid object.
7321 \code Usage: dwg_obj_appid_control* appid =
7322 dwg_obj_appid_get_appid_control(appid, &error); \endcode \param[in]  appid
7323 dwg_obj_appid* \param[out] error   int*, is set to 0 for ok, 1 on error
7324 \deprecated
7325 */
7326 dwg_obj_appid_control *
dwg_obj_appid_get_appid_control(const dwg_obj_appid * restrict appid,int * restrict error)7327 dwg_obj_appid_get_appid_control (const dwg_obj_appid *restrict appid,
7328                                  int *restrict error)
7329 {
7330   if (appid)
7331     {
7332       *error = 0;
7333       return appid->parent->ownerhandle->obj->tio.object->tio.APPID_CONTROL;
7334     }
7335   else
7336     {
7337       LOG_ERROR ("%s: empty appid", __FUNCTION__)
7338       *error = 1;
7339       return NULL;
7340     }
7341 }
7342 
7343 /*******************************************************************
7344  *            FUNCTIONS FOR ALL DIMENSION ENTITIES                *
7345  ********************************************************************/
7346 
7347 /** Returns the _dwg_entity_DIMENSION_common:::: block name, DXF 2. (utf-8
7348 encoded) \code Usage: char * name = dwg_ent_dim_get_block_name(dim, &error);
7349 \endcode
7350 \param[in]  dim     dwg_ent_dim *
7351 \param[out] error   int*, is set to 0 for ok, 1 on error
7352 \deprecated
7353 */
7354 char *
dwg_ent_dim_get_block_name(const dwg_ent_dim * restrict dim,int * restrict error)7355 dwg_ent_dim_get_block_name (const dwg_ent_dim *restrict dim,
7356                             int *restrict error)
7357 {
7358   if (dim)
7359     {
7360       char *name = ((dwg_ent_dim_linear *)dim)
7361                        ->block->obj->tio.object->tio.BLOCK_HEADER->name;
7362       *error = 0;
7363       if (dwg_version >= R_2007)
7364         return bit_convert_TU ((BITCODE_TU)name);
7365       else
7366         return name;
7367     }
7368   else
7369     {
7370       LOG_ERROR ("%s: empty dim", __FUNCTION__)
7371       *error = 1;
7372       return NULL;
7373     }
7374 }
7375 
7376 /** Returns the _dwg_entity_DIMENSION_common::elevation, the z-coord for all
7377 11,12, 16 ECS points. \code Usage: double elevation =
7378 dwg_ent_dim_get_elevation(dim, &error); \endcode \param[in]  dim dwg_ent_dim*
7379 \param[out] error   int*, is set to 0 for ok, 1 on error
7380 \deprecated
7381 */
7382 double
dwg_ent_dim_get_elevation(const dwg_ent_dim * restrict dim,int * restrict error)7383 dwg_ent_dim_get_elevation (const dwg_ent_dim *restrict dim,
7384                            int *restrict error)
7385 {
7386   if (dim)
7387     {
7388       *error = 0;
7389       return dim->elevation;
7390     }
7391   else
7392     {
7393       LOG_ERROR ("%s: empty dim", __FUNCTION__)
7394       *error = 1;
7395       return bit_nan ();
7396     }
7397 }
7398 
7399 /** Sets the _dwg_entity_DIMENSION_common::elevation for the 11, 12, 16 ECS
7400 points \code Usage: dwg_ent_dim_set_elevation(dim, z, &error); \endcode
7401 \param[out] dim       dwg_ent_dim*
7402 \param[in]  elevation double
7403 \param[out] error     int*, is set to 0 for ok, 1 on error
7404 \deprecated
7405 */
7406 void
dwg_ent_dim_set_elevation(dwg_ent_dim * restrict dim,const double elevation,int * restrict error)7407 dwg_ent_dim_set_elevation (dwg_ent_dim *restrict dim, const double elevation,
7408                            int *restrict error)
7409 {
7410   if (dim)
7411     {
7412       *error = 0;
7413       dim->elevation = elevation;
7414     }
7415   else
7416     {
7417       *error = 1;
7418       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7419     }
7420 }
7421 
7422 /** Returns the _dwg_entity_DIMENSION_common::flag1, DXF 70.
7423 \code Usage: char flag1 = dwg_ent_dim_get_flag1(dim, &error);
7424 \endcode
7425 \param[in]  dim     dwg_ent_dim*
7426 \param[out] error   int*, is set to 0 for ok, 1 on error
7427 \deprecated
7428 */
7429 char
dwg_ent_dim_get_flag1(const dwg_ent_dim * restrict dim,int * restrict error)7430 dwg_ent_dim_get_flag1 (const dwg_ent_dim *restrict dim, int *restrict error)
7431 {
7432   if (dim)
7433     {
7434       *error = 0;
7435       return dim->flag1;
7436     }
7437   else
7438     {
7439       *error = 1;
7440       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7441       return '\0';
7442     }
7443 }
7444 
7445 /** Sets the _dwg_entity_DIMENSION_common::flag1, DXF 70.
7446 \code Usage: dwg_ent_dim_set_flag1(dim, flag1, &error);
7447 \endcode
7448 \param[in] dim dwg_ent_dim*
7449 \param 2 char
7450 \param[out] error   int*, is set to 0 for ok, 1 on error
7451 \deprecated
7452 */
7453 void
dwg_ent_dim_set_flag1(dwg_ent_dim * restrict dim,const char flag,int * restrict error)7454 dwg_ent_dim_set_flag1 (dwg_ent_dim *restrict dim, const char flag,
7455                        int *restrict error)
7456 {
7457   if (dim)
7458     {
7459       *error = 0;
7460       dim->flag1 = flag;
7461     }
7462   else
7463     {
7464       *error = 1;
7465       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7466     }
7467 }
7468 
7469 /** Returns the _dwg_entity_DIMENSION_common::act_measurement, DXF 42.
7470 \code Usage: double measure = dwg_ent_dim_get_act_measurement(dim, &error);
7471 \endcode
7472 \param[in] dim dwg_ent_dim*
7473 \param[out] error   int*, is set to 0 for ok, 1 on error
7474 \deprecated
7475 */
7476 double
dwg_ent_dim_get_act_measurement(const dwg_ent_dim * restrict dim,int * restrict error)7477 dwg_ent_dim_get_act_measurement (const dwg_ent_dim *restrict dim,
7478                                  int *restrict error)
7479 {
7480   if (dim)
7481     {
7482       *error = 0;
7483       return dim->act_measurement;
7484     }
7485   else
7486     {
7487       *error = 1;
7488       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7489       return bit_nan ();
7490     }
7491 }
7492 
7493 /** Sets the _dwg_entity_DIMENSION_common::act_measurement, DXF 42.
7494 \code Usage: dwg_ent_dim_set_act_measurement(dim, measure, &error);
7495 \endcode
7496 \param[out]  dim     dwg_ent_dim*
7497 \param[in]   act_measurement double
7498 \param[out]  error   int*, is set to 0 for ok, 1 on error
7499 \deprecated
7500 */
7501 void
dwg_ent_dim_set_act_measurement(dwg_ent_dim * restrict dim,double act_measurement,int * restrict error)7502 dwg_ent_dim_set_act_measurement (dwg_ent_dim *restrict dim,
7503                                  double act_measurement, int *restrict error)
7504 {
7505   if (dim)
7506     {
7507       *error = 0;
7508       dim->act_measurement = act_measurement;
7509     }
7510   else
7511     {
7512       *error = 1;
7513       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7514     }
7515 }
7516 
7517 /** Returns the _dwg_entity_DIMENSION_common::horiz_dir, DXF 51.
7518 \code Usage: double horiz_dir = dwg_ent_dim_get_horiz_dir(dim, &error);
7519 \endcode
7520 \param[in]  dim     dwg_ent_dim*
7521 \param[out] error   int*, is set to 0 for ok, 1 on error
7522 \deprecated
7523 */
7524 double
dwg_ent_dim_get_horiz_dir(const dwg_ent_dim * restrict dim,int * restrict error)7525 dwg_ent_dim_get_horiz_dir (const dwg_ent_dim *restrict dim,
7526                            int *restrict error)
7527 {
7528   if (dim)
7529     {
7530       *error = 0;
7531       return dim->horiz_dir;
7532     }
7533   else
7534     {
7535       *error = 1;
7536       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7537       return bit_nan ();
7538     }
7539 }
7540 
7541 /** Sets the _dwg_entity_DIMENSION_common::horiz_dir, DXF 51.
7542 \code Usage: dwg_ent_dim_set_horiz_dir(dim, horiz_dir, &error);
7543 \endcode
7544 \param[out] dim      dwg_ent_dim*
7545 \param[in]  horiz_dir  double
7546 \param[out] error   int*, is set to 0 for ok, 1 on error
7547 \deprecated
7548 */
7549 void
dwg_ent_dim_set_horiz_dir(dwg_ent_dim * restrict dim,const double horiz_dir,int * restrict error)7550 dwg_ent_dim_set_horiz_dir (dwg_ent_dim *restrict dim, const double horiz_dir,
7551                            int *restrict error)
7552 {
7553   if (dim)
7554     {
7555       *error = 0;
7556       dim->horiz_dir = horiz_dir;
7557     }
7558   else
7559     {
7560       *error = 1;
7561       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7562     }
7563 }
7564 
7565 /** Returns the _dwg_entity_DIMENSION_common::lspace_factor, DXF 41.
7566 \code Usage: double lspace_factor = dwg_ent_dim_get_lspace_factor(dim, &error);
7567 \endcode
7568 \param[in]  dim dwg_ent_dim*
7569 \param[out] error   int*, is set to 0 for ok, 1 on error
7570 \deprecated
7571 */
7572 double
dwg_ent_dim_get_lspace_factor(const dwg_ent_dim * restrict dim,int * restrict error)7573 dwg_ent_dim_get_lspace_factor (const dwg_ent_dim *restrict dim,
7574                                int *restrict error)
7575 {
7576   if (dim)
7577     {
7578       *error = 0;
7579       return dim->lspace_factor;
7580     }
7581   else
7582     {
7583       *error = 1;
7584       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7585       return bit_nan ();
7586     }
7587 }
7588 
7589 /** Sets the _dwg_entity_DIMENSION_common::lspace_factor, DXF 41.
7590 \code Usage: dwg_ent_dim_set_lspace_factor(dim, factor, &error);
7591 \endcode
7592 \param[out] dim     dwg_ent_dim*
7593 \param[in] factor   double
7594 \param[out] error   int*, is set to 0 for ok, 1 on error
7595 \deprecated
7596 */
7597 void
dwg_ent_dim_set_lspace_factor(dwg_ent_dim * restrict dim,const double factor,int * restrict error)7598 dwg_ent_dim_set_lspace_factor (dwg_ent_dim *restrict dim, const double factor,
7599                                int *restrict error)
7600 {
7601   if (dim)
7602     {
7603       *error = 0;
7604       dim->lspace_factor = factor;
7605     }
7606   else
7607     {
7608       *error = 1;
7609       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7610     }
7611 }
7612 
7613 /** Returns the _dwg_entity_DIMENSION_common::lspace_style idx, DXF 72.
7614 \code Usage: BITCODE_BS lspace_style = dwg_ent_dim_get_lspace_style(dim,
7615 &error); \endcode \param[in] dim dwg_ent_dim* \param[out] error   int*, is set
7616 to 0 for ok, 1 on error \deprecated
7617 */
7618 BITCODE_BS
dwg_ent_dim_get_lspace_style(const dwg_ent_dim * restrict dim,int * restrict error)7619 dwg_ent_dim_get_lspace_style (const dwg_ent_dim *restrict dim,
7620                               int *restrict error)
7621 {
7622   if (dim)
7623     {
7624       *error = 0;
7625       return dim->lspace_style;
7626     }
7627   else
7628     {
7629       *error = 1;
7630       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7631       return '\0';
7632     }
7633 }
7634 
7635 /** Sets the _dwg_entity_DIMENSION_common::lspace_style idx, DXF 72.
7636 \code Usage: dwg_ent_dim_set_lspace_style(dim, style, &error);
7637 \endcode
7638 \param[out] dim     dwg_ent_dim*
7639 \param[in]  style   BITCODE_BS
7640 \param[out] error   int*, is set to 0 for ok, 1 on error
7641 \deprecated
7642 */
7643 void
dwg_ent_dim_set_lspace_style(dwg_ent_dim * restrict dim,const BITCODE_BS style,int * restrict error)7644 dwg_ent_dim_set_lspace_style (dwg_ent_dim *restrict dim,
7645                               const BITCODE_BS style, int *restrict error)
7646 {
7647   if (dim)
7648     {
7649       *error = 0;
7650       dim->lspace_style = style;
7651     }
7652   else
7653     {
7654       *error = 1;
7655       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7656     }
7657 }
7658 
7659 /** Returns the _dwg_entity_DIMENSION_common::attachment idx, DXF 71.
7660 \code Usage: BITCODE_BS attachment = dwg_ent_dim_get_attachment(dim, &error);
7661 \endcode
7662 \param[in] dim dwg_ent_dim*
7663 \param[out] error   int*, is set to 0 for ok, 1 on error
7664 \deprecated
7665 */
7666 BITCODE_BS
dwg_ent_dim_get_attachment(const dwg_ent_dim * restrict dim,int * restrict error)7667 dwg_ent_dim_get_attachment (const dwg_ent_dim *restrict dim,
7668                             int *restrict error)
7669 {
7670   if (dim)
7671     {
7672       *error = 0;
7673       return dim->attachment;
7674     }
7675   else
7676     {
7677       *error = 1;
7678       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7679       return 0;
7680     }
7681 }
7682 
7683 /** Sets the _dwg_entity_DIMENSION_common::attachment idx, DXF 71.
7684 \code Usage: dwg_ent_dim_set_attachment(dim, attachment, &error);
7685 \endcode
7686 \param[out] dim        dwg_ent_dim*
7687 \param[in]  attachment BITCODE_BS point idx
7688 \param[out] error      int*, is set to 0 for ok, 1 on error
7689 \deprecated
7690 */
7691 void
dwg_ent_dim_set_attachment(dwg_ent_dim * restrict dim,const BITCODE_BS attachment,int * restrict error)7692 dwg_ent_dim_set_attachment (dwg_ent_dim *restrict dim,
7693                             const BITCODE_BS attachment, int *restrict error)
7694 {
7695   if (dim)
7696     {
7697       *error = 0;
7698       dim->attachment = attachment;
7699     }
7700   else
7701     {
7702       *error = 1;
7703       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7704     }
7705 }
7706 
7707 /** Sets the _dwg_entity_DIMENSION_common::extrusion, DXF 210.
7708 \code Usage: dwg_ent_dim_get_extrusion(dim, &point, &error);
7709 \endcode
7710 \param[out] dim     dwg_ent_dim*
7711 \param[in]  vector  dwg_point_3d
7712 \param[out] error   int*, is set to 0 for ok, 1 on error
7713 \deprecated
7714 */
7715 void
dwg_ent_dim_set_extrusion(dwg_ent_dim * restrict dim,const dwg_point_3d * restrict vector,int * restrict error)7716 dwg_ent_dim_set_extrusion (dwg_ent_dim *restrict dim,
7717                            const dwg_point_3d *restrict vector,
7718                            int *restrict error)
7719 {
7720   if (dim
7721 #  ifndef HAVE_NONNULL
7722       && vector
7723 #  endif
7724   )
7725     {
7726       *error = 0;
7727       dim->extrusion.x = vector->x;
7728       dim->extrusion.y = vector->y;
7729       dim->extrusion.z = vector->z;
7730     }
7731   else
7732     {
7733       *error = 1;
7734       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7735     }
7736 }
7737 
7738 /** Sets the _dwg_entity_DIMENSION_common::extrusion, DXF 210.
7739 \code Usage: dwg_ent_dim_set_extrusion(dim, &point, &error);
7740 \endcode
7741 \param[in]  dim     dwg_ent_dim*
7742 \param[out] vector  dwg_point_3d*
7743 \param[out] error   int*, is set to 0 for ok, 1 on error
7744 \deprecated
7745 */
7746 void
dwg_ent_dim_get_extrusion(const dwg_ent_dim * restrict dim,dwg_point_3d * restrict vector,int * restrict error)7747 dwg_ent_dim_get_extrusion (const dwg_ent_dim *restrict dim,
7748                            dwg_point_3d *restrict vector, int *restrict error)
7749 {
7750   if (dim
7751 #  ifndef HAVE_NONNULL
7752       && vector
7753 #  endif
7754   )
7755     {
7756       *error = 0;
7757       vector->x = dim->extrusion.x;
7758       vector->y = dim->extrusion.y;
7759       vector->z = dim->extrusion.z;
7760     }
7761   else
7762     {
7763       *error = 1;
7764       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7765     }
7766 }
7767 
7768 /** Returns the _dwg_entity_DIMENSION_common::user_text, DXF 1. (utf-8 encoded)
7769 \code Usage: char * text  = dwg_ent_dim_get_user_text(dim, &error);
7770 \endcode
7771 \param[in]  dim dwg_ent_dim*
7772 \param[out] error   int*, is set to 0 for ok, 1 on error
7773 \deprecated
7774 */
7775 char *
dwg_ent_dim_get_user_text(const dwg_ent_dim * restrict dim,int * restrict error)7776 dwg_ent_dim_get_user_text (const dwg_ent_dim *restrict dim,
7777                            int *restrict error)
7778 {
7779   if (dim)
7780     {
7781       *error = 0;
7782       if (dwg_version >= R_2007)
7783         return bit_convert_TU ((BITCODE_TU)dim->user_text);
7784       else
7785         return dim->user_text;
7786     }
7787   else
7788     {
7789       LOG_ERROR ("%s: empty dim", __FUNCTION__)
7790       *error = 1;
7791       return NULL;
7792     }
7793 }
7794 
7795 /** Sets the _dwg_entity_DIMENSION_common::user_text, DXF 1. (utf-8 encoded)
7796 \code Usage: dwg_ent_dim_set_user_text(dim, "dimension text", &error);
7797 \endcode
7798 \param[out] dim    dwg_ent_dim*
7799 \param[in]  text   char*
7800 \param[out] error  int*, is set to 0 for ok, 1 on error
7801 \deprecated
7802 */
7803 void
dwg_ent_dim_set_user_text(dwg_ent_dim * restrict dim,const char * restrict text,int * restrict error)7804 dwg_ent_dim_set_user_text (dwg_ent_dim *restrict dim,
7805                            const char *restrict text, int *restrict error)
7806 {
7807   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
7808   if (ent && !error)
7809     {
7810       ent->user_text = dwg_add_u8_input (dwg, text);
7811     }
7812   else
7813     {
7814       *error = 1;
7815       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7816     }
7817 }
7818 
7819 /** Returns the _dwg_entity_DIMENSION_common::text_rotation, DXF 53 (radian).
7820 \code Usage: double text_rot  = dwg_ent_dim_get_text_rotation(dim, &error);
7821 \endcode
7822 \param[in]  dim     dwg_ent_dim*
7823 \param[out] error   int*, is set to 0 for ok, 1 on error
7824 \deprecated
7825 */
7826 double
dwg_ent_dim_get_text_rotation(const dwg_ent_dim * restrict dim,int * restrict error)7827 dwg_ent_dim_get_text_rotation (const dwg_ent_dim *restrict dim,
7828                                int *restrict error)
7829 {
7830   if (dim)
7831     {
7832       *error = 0;
7833       return dim->text_rotation;
7834     }
7835   else
7836     {
7837       *error = 1;
7838       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7839       return bit_nan ();
7840     }
7841 }
7842 
7843 /** Sets the _dwg_entity_DIMENSION_common::text_rotation, DXF 53 (radian).
7844 \code Usage: dwg_ent_dim_set_text_rotation(dim, 0.0, &error);
7845 \endcode
7846 \param[out] dim      dwg_ent_dim*
7847 \param[in]  rotation double
7848 \param[out] error    int*, is set to 0 for ok, 1 on error
7849 \deprecated
7850 */
7851 void
dwg_ent_dim_set_text_rotation(dwg_ent_dim * restrict dim,const double rotation,int * restrict error)7852 dwg_ent_dim_set_text_rotation (dwg_ent_dim *restrict dim,
7853                                const double rotation, int *restrict error)
7854 {
7855   if (dim)
7856     {
7857       *error = 0;
7858       dim->text_rotation = rotation;
7859     }
7860   else
7861     {
7862       *error = 1;
7863       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7864     }
7865 }
7866 
7867 /** Returns the _dwg_entity_DIMENSION_common::ins_rotation, DXF 54 (radian).
7868 \code Usage: double ins_rot  = dwg_ent_dim_get_ins_rotation(dim, &error);
7869 \endcode
7870 \param[in] dim dwg_ent_dim*
7871 \param[out] error   int*, is set to 0 for ok, 1 on error
7872 \deprecated
7873 */
7874 double
dwg_ent_dim_get_ins_rotation(const dwg_ent_dim * restrict dim,int * restrict error)7875 dwg_ent_dim_get_ins_rotation (const dwg_ent_dim *restrict dim,
7876                               int *restrict error)
7877 {
7878   if (dim)
7879     {
7880       *error = 0;
7881       return dim->ins_rotation;
7882     }
7883   else
7884     {
7885       *error = 1;
7886       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7887       return bit_nan ();
7888     }
7889 }
7890 
7891 /** Sets the _dwg_entity_DIMENSION_common::ins_rotation, DXF 54 (radian).
7892 \code Usage: dwg_ent_dim_set_ins_rotation(dim, 0.0, &error);
7893 \endcode
7894 \param[out] dim      dwg_ent_dim*
7895 \param[in]  rotation double
7896 \param[out] error    int*, is set to 0 for ok, 1 on error
7897 \deprecated
7898 */
7899 void
dwg_ent_dim_set_ins_rotation(dwg_ent_dim * restrict dim,const double rotation,int * restrict error)7900 dwg_ent_dim_set_ins_rotation (dwg_ent_dim *restrict dim, const double rotation,
7901                               int *restrict error)
7902 {
7903   if (dim)
7904     {
7905       *error = 0;
7906       dim->ins_rotation = rotation;
7907     }
7908   else
7909     {
7910       *error = 1;
7911       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7912     }
7913 }
7914 
7915 /** Returns _dwg_entity_DIMENSION_common::flip_arrow1, DXF 74
7916 \code Usage: char arrow1 = dwg_ent_dim_get_flip_arrow1(dim, &error);
7917 \endcode
7918 \param[in]  dim     dwg_ent_dim*
7919 \param[out] error   int*, is set to 0 for ok, 1 on error
7920 \deprecated
7921 */
7922 char
dwg_ent_dim_get_flip_arrow1(const dwg_ent_dim * restrict dim,int * restrict error)7923 dwg_ent_dim_get_flip_arrow1 (const dwg_ent_dim *restrict dim,
7924                              int *restrict error)
7925 {
7926   if (dim)
7927     {
7928       *error = 0;
7929       return dim->flip_arrow1;
7930     }
7931   else
7932     {
7933       *error = 1;
7934       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7935       return '\0';
7936     }
7937 }
7938 
7939 /** Sets the _dwg_entity_DIMENSION_common::flip_arrow1 to 1 or 0, DXF 74.
7940 \code Usage: dwg_ent_dim_set_flip_arrow1(dim, arrow1, &error);
7941 \endcode
7942 \param[out] dim        dwg_ent_dim*
7943 \param[in]  flip_arrow char
7944 \param[out] error      int*, is set to 0 for ok, 1 on error
7945 \deprecated
7946 */
7947 void
dwg_ent_dim_set_flip_arrow1(dwg_ent_dim * restrict dim,const char flip_arrow,int * restrict error)7948 dwg_ent_dim_set_flip_arrow1 (dwg_ent_dim *restrict dim, const char flip_arrow,
7949                              int *restrict error)
7950 {
7951   if (dim && (flip_arrow == 0 || flip_arrow == 1))
7952     {
7953       *error = 0;
7954       dim->flip_arrow1 = flip_arrow;
7955     }
7956   else
7957     {
7958       *error = 1;
7959       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7960     }
7961 }
7962 
7963 /** Returns _dwg_entity_DIMENSION_common::flip_arrow2 to 1 or 0, DXF 75.
7964 \code Usage: has_arrow2 = dwg_ent_dim_get_flip_arrow2(dim, &error);
7965 \endcode
7966 \param[in] dim dwg_ent_dim*
7967 \param[out] error   int*, is set to 0 for ok, 1 on error
7968 \deprecated
7969 */
7970 char
dwg_ent_dim_get_flip_arrow2(const dwg_ent_dim * restrict dim,int * restrict error)7971 dwg_ent_dim_get_flip_arrow2 (const dwg_ent_dim *restrict dim,
7972                              int *restrict error)
7973 {
7974   if (dim)
7975     {
7976       *error = 0;
7977       return dim->flip_arrow2;
7978     }
7979   else
7980     {
7981       *error = 1;
7982       LOG_ERROR ("%s: empty arg", __FUNCTION__)
7983       return '\0';
7984     }
7985 }
7986 
7987 /** Sets the _dwg_entity_DIMENSION_common::flip_arrow1 to 1 or 0, DXF 75.
7988 \code Usage: dwg_ent_dim_set_flip_arrow2(dim, arrow2, &error);
7989 \endcode
7990 \param[out] dim        dwg_ent_dim*
7991 \param[in]  flip_arrow char
7992 \param[out] error      int*, is set to 0 for ok, 1 on error
7993 \deprecated
7994 */
7995 void
dwg_ent_dim_set_flip_arrow2(dwg_ent_dim * restrict dim,const char flip_arrow,int * restrict error)7996 dwg_ent_dim_set_flip_arrow2 (dwg_ent_dim *restrict dim, const char flip_arrow,
7997                              int *restrict error)
7998 {
7999   if (dim && (flip_arrow == 0 || flip_arrow == 1))
8000     {
8001       *error = 0;
8002       dim->flip_arrow2 = flip_arrow;
8003     }
8004   else
8005     {
8006       *error = 1;
8007       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8008     }
8009 }
8010 
8011 /** Returns the _dwg_entity_DIMENSION_common::text_midpt, DXF 11.
8012 \code Usage: dwg_ent_dim_get_text_midpt(dim, &point, &error);
8013 \endcode
8014 \param[out] dim     dwg_ent_dim*
8015 \param[in]  point   dwg_point_2d
8016 \param[out] error   int*, is set to 0 for ok, 1 on error
8017 \deprecated
8018 */
8019 void
dwg_ent_dim_set_text_midpt(dwg_ent_dim * restrict dim,const dwg_point_2d * restrict point,int * restrict error)8020 dwg_ent_dim_set_text_midpt (dwg_ent_dim *restrict dim,
8021                             const dwg_point_2d *restrict point,
8022                             int *restrict error)
8023 {
8024   if (dim
8025 #  ifndef HAVE_NONNULL
8026       && point
8027 #  endif
8028   )
8029     {
8030       *error = 0;
8031       dim->text_midpt.x = point->x;
8032       dim->text_midpt.y = point->y;
8033     }
8034   else
8035     {
8036       *error = 1;
8037       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8038     }
8039 }
8040 
8041 /** Sets the  _dwg_entity_DIMENSION_common::text_midpt, DXF 11.
8042 \code Usage: dwg_ent_dim_set_text_mid_pt(dim, &point, &error);
8043 \endcode
8044 \param[in]  dim     dwg_ent_dim*
8045 \param[out] point   dwg_point_2d
8046 \param[out] error   int*, is set to 0 for ok, 1 on error
8047 \deprecated
8048 */
8049 void
dwg_ent_dim_get_text_midpt(const dwg_ent_dim * restrict dim,dwg_point_2d * restrict point,int * restrict error)8050 dwg_ent_dim_get_text_midpt (const dwg_ent_dim *restrict dim,
8051                             dwg_point_2d *restrict point, int *restrict error)
8052 {
8053   if (dim
8054 #  ifndef HAVE_NONNULL
8055       && point
8056 #  endif
8057   )
8058     {
8059       *error = 0;
8060       point->x = dim->text_midpt.x;
8061       point->y = dim->text_midpt.y;
8062     }
8063   else
8064     {
8065       *error = 1;
8066       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8067     }
8068 }
8069 
8070 /** Sets the  _dwg_entity_DIMENSION_common::ins_scale vector, DXF 41.
8071 \code Usage: dwg_ent_dim_set_ins_scale(dim, &point, &error);
8072 \endcode
8073 \param[out] dim     dwg_ent_dim*
8074 \param[in]  scale3d dwg_point_3d*
8075 \param[out] error   int*
8076 */
8077 void
dwg_ent_dim_set_ins_scale(dwg_ent_dim * restrict dim,const dwg_point_3d * restrict scale3d,int * restrict error)8078 dwg_ent_dim_set_ins_scale (dwg_ent_dim *restrict dim,
8079                            const dwg_point_3d *restrict scale3d,
8080                            int *restrict error)
8081 {
8082   if (dim
8083 #  ifndef HAVE_NONNULL
8084       && scale3d
8085 #  endif
8086   )
8087     {
8088       *error = 0;
8089       dim->ins_scale.x = scale3d->x;
8090       dim->ins_scale.y = scale3d->y;
8091       dim->ins_scale.z = scale3d->z;
8092     }
8093   else
8094     {
8095       *error = 1;
8096       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8097     }
8098 }
8099 
8100 /** Returns the _dwg_entity_DIMENSION_common::ins_scale vector, DXF 41.
8101 \code Usage: dwg_ent_dim_get_ins_scale(dim, &point, &error);
8102 \endcode
8103 \param dim[in]      dwg_ent_dim*
8104 \param scale3d[out] dwg_point_3d*
8105 \param error[out]   int*
8106 */
8107 void
dwg_ent_dim_get_ins_scale(const dwg_ent_dim * restrict dim,dwg_point_3d * restrict scale3d,int * restrict error)8108 dwg_ent_dim_get_ins_scale (const dwg_ent_dim *restrict dim,
8109                            dwg_point_3d *restrict scale3d, int *restrict error)
8110 {
8111   if (dim
8112 #  ifndef HAVE_NONNULL
8113       && scale3d
8114 #  endif
8115   )
8116     {
8117       *error = 0;
8118       scale3d->x = dim->ins_scale.x;
8119       scale3d->y = dim->ins_scale.y;
8120       scale3d->z = dim->ins_scale.z;
8121     }
8122   else
8123     {
8124       *error = 1;
8125       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8126     }
8127 }
8128 
8129 /** Sets the _dwg_entity_DIMENSION_common::clone_ins_pt, DXF 12.
8130 \code Usage: dwg_ent_dim_set_clone_ins_pt(dim, &point, &error);
8131 \endcode
8132 \param[out] dim    dwg_ent_dim*
8133 \param[in]  point  dwg_point_2d
8134 \param[out] error  int*, is set to 0 for ok, 1 on error
8135 \deprecated
8136 */
8137 void
dwg_ent_dim_set_clone_ins_pt(dwg_ent_dim * restrict dim,const dwg_point_2d * restrict point,int * restrict error)8138 dwg_ent_dim_set_clone_ins_pt (dwg_ent_dim *restrict dim,
8139                               const dwg_point_2d *restrict point,
8140                               int *restrict error)
8141 {
8142   if (dim
8143 #  ifndef HAVE_NONNULL
8144       && point
8145 #  endif
8146   )
8147     {
8148       *error = 0;
8149       dim->clone_ins_pt.x = point->x;
8150       dim->clone_ins_pt.y = point->y;
8151     }
8152   else
8153     {
8154       *error = 1;
8155       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8156     }
8157 }
8158 
8159 /** Returns the _dwg_entity_DIMENSION_common::clone_ins_pt, DXF 12.
8160 \code Usage: dwg_ent_dim_get_clone_ins_pt(dim, &point, &error);
8161 \endcode
8162 \param[in]  dim    dwg_ent_dim*
8163 \param[out] point  dwg_point_2d
8164 \param[out] error  int*, is set to 0 for ok, 1 on error
8165 \deprecated
8166 */
8167 void
dwg_ent_dim_get_clone_ins_pt(const dwg_ent_dim * restrict dim,dwg_point_2d * restrict point,int * restrict error)8168 dwg_ent_dim_get_clone_ins_pt (const dwg_ent_dim *restrict dim,
8169                               dwg_point_2d *restrict point,
8170                               int *restrict error)
8171 {
8172   if (dim
8173 #  ifndef HAVE_NONNULL
8174       && point
8175 #  endif
8176   )
8177     {
8178       *error = 0;
8179       point->x = dim->clone_ins_pt.x;
8180       point->y = dim->clone_ins_pt.y;
8181     }
8182   else
8183     {
8184       *error = 1;
8185       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8186     }
8187 }
8188 
8189 /*******************************************************************
8190  *              FUNCTIONS FOR ORDINATE DIMENSION ENTITY             *
8191  ********************************************************************/
8192 
8193 /** Returns the _dwg_entity_DIMENSION_ORDINATE::flag2, DXF 70.
8194 \code Usage: char flag2 = dwg_ent_dim_ordinate_get_flag2(dim, &error);
8195 \endcode
8196 \param[in]  dim     dwg_ent_dim_ordinate*
8197 \param[out] error   int*, is set to 0 for ok, 1 on error
8198 \deprecated
8199 */
8200 char
dwg_ent_dim_ordinate_get_flag2(const dwg_ent_dim_ordinate * restrict dim,int * restrict error)8201 dwg_ent_dim_ordinate_get_flag2 (const dwg_ent_dim_ordinate *restrict dim,
8202                                 int *restrict error)
8203 {
8204   if (dim)
8205     {
8206       *error = 0;
8207       return dim->flag2;
8208     }
8209   else
8210     {
8211       *error = 1;
8212       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8213       return '\0';
8214     }
8215 }
8216 
8217 /** Sets _dwg_entity_DIMENSION_ORDINATE::flag2, DXF 70.
8218 \code Usage: dwg_ent_dim_ordinate_set_flag2(dim, flag2, &error);
8219 \endcode
8220 \param[out] dim    dwg_ent_dim_ordinate*
8221 \param[in]  flag   char
8222 \param[out] error  int*, is set to 0 for ok, 1 on error
8223 \deprecated
8224 */
8225 void
dwg_ent_dim_ordinate_set_flag2(dwg_ent_dim_ordinate * restrict dim,const char flag,int * restrict error)8226 dwg_ent_dim_ordinate_set_flag2 (dwg_ent_dim_ordinate *restrict dim,
8227                                 const char flag, int *restrict error)
8228 {
8229   if (dim)
8230     {
8231       *error = 0;
8232       dim->flag2 = flag;
8233     }
8234   else
8235     {
8236       *error = 1;
8237       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8238     }
8239 }
8240 
8241 /** Sets the 10 ucsorigin point
8242 \code Usage: dwg_ent_dim_ordinate_set_def_pt(dim, &point, &error);
8243 \endcode
8244 \param[in] dim_ordinate dwg_ent_dim_ordinate*
8245 \param[out] dwg_point_3d
8246 \param[out] error   int*, is set to 0 for ok, 1 on error
8247 \deprecated
8248 */
8249 void
dwg_ent_dim_ordinate_set_def_pt(dwg_ent_dim_ordinate * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8250 dwg_ent_dim_ordinate_set_def_pt (dwg_ent_dim_ordinate *restrict dim,
8251                                  const dwg_point_3d *restrict point,
8252                                  int *restrict error)
8253 {
8254   if (dim
8255 #  ifndef HAVE_NONNULL
8256       && point
8257 #  endif
8258   )
8259     {
8260       *error = 0;
8261       dim->def_pt.x = point->x;
8262       dim->def_pt.y = point->y;
8263       dim->def_pt.z = point->z;
8264     }
8265   else
8266     {
8267       *error = 1;
8268       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8269     }
8270 }
8271 
8272 /** Returns the 10 def point (ucsorigin)
8273 \code Usage: dwg_ent_dim_ordinate_get_def_pt(dim, &point, &error);
8274 \endcode
8275 \param[in] dim_ordinate dwg_ent_dim_ordinate*
8276 \param[out] dwg_point_3d
8277 \param[out] error   int*, is set to 0 for ok, 1 on error
8278 \deprecated
8279 */
8280 void
dwg_ent_dim_ordinate_get_def_pt(const dwg_ent_dim_ordinate * restrict dim,dwg_point_3d * restrict point,int * restrict error)8281 dwg_ent_dim_ordinate_get_def_pt (const dwg_ent_dim_ordinate *restrict dim,
8282                                  dwg_point_3d *restrict point,
8283                                  int *restrict error)
8284 {
8285   if (dim
8286 #  ifndef HAVE_NONNULL
8287       && point
8288 #  endif
8289   )
8290     {
8291       *error = 0;
8292       point->x = dim->def_pt.x;
8293       point->y = dim->def_pt.y;
8294       point->z = dim->def_pt.z;
8295     }
8296   else
8297     {
8298       *error = 1;
8299       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8300     }
8301 }
8302 
8303 /** Sets the 13 feature_location point
8304 \code Usage: dwg_ent_dim_ordinate_set_feature_location_pt(dim, &point, &error);
8305 \endcode
8306 \param[in] dim_ordinate dwg_ent_dim_ordinate*
8307 \param[out] dwg_point_3d
8308 \param[out] error   int*, is set to 0 for ok, 1 on error
8309 \deprecated
8310 */
8311 void
dwg_ent_dim_ordinate_set_feature_location_pt(dwg_ent_dim_ordinate * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8312 dwg_ent_dim_ordinate_set_feature_location_pt (
8313     dwg_ent_dim_ordinate *restrict dim, const dwg_point_3d *restrict point,
8314     int *restrict error)
8315 {
8316   if (dim
8317 #  ifndef HAVE_NONNULL
8318       && point
8319 #  endif
8320   )
8321     {
8322       *error = 0;
8323       dim->feature_location_pt.x = point->x;
8324       dim->feature_location_pt.y = point->y;
8325       dim->feature_location_pt.z = point->z;
8326     }
8327   else
8328     {
8329       *error = 1;
8330       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8331     }
8332 }
8333 
8334 /** Returns the 13 feature_location point
8335 \code Usage: dwg_ent_dim_ordinate_get_feature_location_pt(dim, &point, &error);
8336 \endcode
8337 \param[in] dim_ordinate dwg_ent_dim_ordinate*
8338 \param[out] dwg_point_3d
8339 \param[out] error   int*, is set to 0 for ok, 1 on error
8340 \deprecated
8341 */
8342 void
dwg_ent_dim_ordinate_get_feature_location_pt(const dwg_ent_dim_ordinate * restrict dim,dwg_point_3d * restrict point,int * restrict error)8343 dwg_ent_dim_ordinate_get_feature_location_pt (
8344     const dwg_ent_dim_ordinate *restrict dim, dwg_point_3d *restrict point,
8345     int *restrict error)
8346 {
8347   if (dim
8348 #  ifndef HAVE_NONNULL
8349       && point
8350 #  endif
8351   )
8352     {
8353       *error = 0;
8354       point->x = dim->feature_location_pt.x;
8355       point->y = dim->feature_location_pt.y;
8356       point->z = dim->feature_location_pt.z;
8357     }
8358   else
8359     {
8360       *error = 1;
8361       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8362     }
8363 }
8364 
8365 /** Sets the 14 leader_endpt
8366 \code Usage: dwg_ent_dim_ordinate_set_leader_endpt(dim, &point, &error);
8367 \endcode
8368 \param[in] dim_ordinate dwg_ent_dim_ordinate*
8369 \param[out] dwg_point_3d
8370 \param[out] error   int*, is set to 0 for ok, 1 on error
8371 \deprecated
8372 */
8373 void
dwg_ent_dim_ordinate_set_leader_endpt(dwg_ent_dim_ordinate * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8374 dwg_ent_dim_ordinate_set_leader_endpt (dwg_ent_dim_ordinate *restrict dim,
8375                                        const dwg_point_3d *restrict point,
8376                                        int *restrict error)
8377 {
8378   if (dim
8379 #  ifndef HAVE_NONNULL
8380       && point
8381 #  endif
8382   )
8383     {
8384       *error = 0;
8385       dim->leader_endpt.x = point->x;
8386       dim->leader_endpt.y = point->y;
8387       dim->leader_endpt.z = point->z;
8388     }
8389   else
8390     {
8391       *error = 1;
8392       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8393     }
8394 }
8395 
8396 /** Returns the 14 leader_endpoint point
8397 \code Usage: dwg_ent_dim_ordinate_get_leader_endpt(dim, &point, &error);
8398 \endcode
8399 \param[in] dim_ordinate dwg_ent_dim_ordinate*
8400 \param[out] dwg_point_3d
8401 \param[out] error   int*, is set to 0 for ok, 1 on error
8402 \deprecated
8403 */
8404 void
dwg_ent_dim_ordinate_get_leader_endpt(const dwg_ent_dim_ordinate * restrict dim,dwg_point_3d * restrict point,int * restrict error)8405 dwg_ent_dim_ordinate_get_leader_endpt (
8406     const dwg_ent_dim_ordinate *restrict dim, dwg_point_3d *restrict point,
8407     int *restrict error)
8408 {
8409   if (dim
8410 #  ifndef HAVE_NONNULL
8411       && point
8412 #  endif
8413   )
8414     {
8415       *error = 0;
8416       point->x = dim->leader_endpt.x;
8417       point->y = dim->leader_endpt.y;
8418       point->z = dim->leader_endpt.z;
8419     }
8420   else
8421     {
8422       *error = 1;
8423       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8424     }
8425 }
8426 
8427 /*******************************************************************
8428  *              FUNCTIONS FOR LINEAR DIMENSION ENTITY                *
8429  ********************************************************************/
8430 
8431 /** Sets the 10 def point
8432 \code Usage: dwg_ent_dim_linear_set_def_pt(dim, &point, &error);
8433 \endcode
8434 \param[in] dim_linear dwg_ent_dim_linear*
8435 \param[out] dwg_point_3d
8436 \param[out] error   int*, is set to 0 for ok, 1 on error
8437 \deprecated
8438 */
8439 void
dwg_ent_dim_linear_set_def_pt(dwg_ent_dim_linear * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8440 dwg_ent_dim_linear_set_def_pt (dwg_ent_dim_linear *restrict dim,
8441                                const dwg_point_3d *restrict point,
8442                                int *restrict error)
8443 {
8444   if (dim
8445 #  ifndef HAVE_NONNULL
8446       && point
8447 #  endif
8448   )
8449     {
8450       *error = 0;
8451       dim->def_pt.x = point->x;
8452       dim->def_pt.y = point->y;
8453       dim->def_pt.z = point->z;
8454     }
8455   else
8456     {
8457       *error = 1;
8458       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8459     }
8460 }
8461 
8462 /** Sets the 10 def point
8463 \code Usage: dwg_ent_dim_linear_set_def_pt(dim, &point, &error);
8464 \endcode
8465 \param[in] dim_linear dwg_ent_dim_linear*
8466 \param[out] dwg_point_3d
8467 \param[out] error   int*, is set to 0 for ok, 1 on error
8468 \deprecated
8469 */
8470 void
dwg_ent_dim_linear_get_def_pt(const dwg_ent_dim_linear * restrict dim,dwg_point_3d * restrict point,int * restrict error)8471 dwg_ent_dim_linear_get_def_pt (const dwg_ent_dim_linear *restrict dim,
8472                                dwg_point_3d *restrict point,
8473                                int *restrict error)
8474 {
8475   if (dim
8476 #  ifndef HAVE_NONNULL
8477       && point
8478 #  endif
8479   )
8480     {
8481       *error = 0;
8482       point->x = dim->def_pt.x;
8483       point->y = dim->def_pt.y;
8484       point->z = dim->def_pt.z;
8485     }
8486   else
8487     {
8488       *error = 1;
8489       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8490     }
8491 }
8492 
8493 /** Sets the xline1 point
8494 \code Usage: dwg_ent_dim_linear_set_13_pt(dim, &point, &error);
8495 \endcode
8496 \param[in] dim_linear dwg_ent_dim_linear*
8497 \param[out] dwg_point_3d
8498 \param[out] error   int*, is set to 0 for ok, 1 on error
8499 \deprecated
8500 */
8501 void
dwg_ent_dim_linear_set_13_pt(dwg_ent_dim_linear * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8502 dwg_ent_dim_linear_set_13_pt (dwg_ent_dim_linear *restrict dim,
8503                               const dwg_point_3d *restrict point,
8504                               int *restrict error)
8505 {
8506   if (dim
8507 #  ifndef HAVE_NONNULL
8508       && point
8509 #  endif
8510   )
8511     {
8512       *error = 0;
8513       dim->xline1_pt.x = point->x;
8514       dim->xline1_pt.y = point->y;
8515       dim->xline1_pt.z = point->z;
8516     }
8517   else
8518     {
8519       *error = 1;
8520       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8521     }
8522 }
8523 
8524 /** Sets the xline1 point
8525 \code Usage: dwg_ent_dim_linear_set_13_pt(dim, &point, &error);
8526 \endcode
8527 \param[in] dim_linear dwg_ent_dim_linear*
8528 \param[out] dwg_point_3d
8529 \param[out] error   int*, is set to 0 for ok, 1 on error
8530 \deprecated
8531 */
8532 void
dwg_ent_dim_linear_get_13_pt(const dwg_ent_dim_linear * restrict dim,dwg_point_3d * restrict point,int * restrict error)8533 dwg_ent_dim_linear_get_13_pt (const dwg_ent_dim_linear *restrict dim,
8534                               dwg_point_3d *restrict point,
8535                               int *restrict error)
8536 {
8537   if (dim
8538 #  ifndef HAVE_NONNULL
8539       && point
8540 #  endif
8541   )
8542     {
8543       *error = 0;
8544       point->x = dim->xline1_pt.x;
8545       point->y = dim->xline1_pt.y;
8546       point->z = dim->xline1_pt.z;
8547     }
8548   else
8549     {
8550       *error = 1;
8551       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8552     }
8553 }
8554 
8555 /** Sets the xline2 point
8556 \code Usage: dwg_ent_dim_linear_set_14_pt(dim, &point, &error);
8557 \endcode
8558 \param[in] dim   dwg_ent_dim_linear*
8559 \param[out] dwg_point_3d
8560 \param[out] error   int*, is set to 0 for ok, 1 on error
8561 \deprecated
8562 */
8563 void
dwg_ent_dim_linear_set_14_pt(dwg_ent_dim_linear * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8564 dwg_ent_dim_linear_set_14_pt (dwg_ent_dim_linear *restrict dim,
8565                               const dwg_point_3d *restrict point,
8566                               int *restrict error)
8567 {
8568   if (dim
8569 #  ifndef HAVE_NONNULL
8570       && point
8571 #  endif
8572   )
8573     {
8574       *error = 0;
8575       dim->xline2_pt.x = point->x;
8576       dim->xline2_pt.y = point->y;
8577       dim->xline2_pt.z = point->z;
8578     }
8579   else
8580     {
8581       *error = 1;
8582       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8583     }
8584 }
8585 
8586 /** Returns the 14 point
8587 \code Usage: dwg_ent_dim_linear_get_14_pt(dim, &point, &error);
8588 \endcode
8589 \param[in] dim   dwg_ent_dim_linear*
8590 \param[out] dwg_point_3d
8591 \param[out] error   int*, is set to 0 for ok, 1 on error
8592 \deprecated
8593 */
8594 void
dwg_ent_dim_linear_get_14_pt(const dwg_ent_dim_linear * restrict dim,dwg_point_3d * restrict point,int * restrict error)8595 dwg_ent_dim_linear_get_14_pt (const dwg_ent_dim_linear *restrict dim,
8596                               dwg_point_3d *restrict point,
8597                               int *restrict error)
8598 {
8599   if (dim
8600 #  ifndef HAVE_NONNULL
8601       && point
8602 #  endif
8603   )
8604     {
8605       *error = 0;
8606       point->x = dim->xline2_pt.x;
8607       point->y = dim->xline2_pt.y;
8608       point->z = dim->xline2_pt.z;
8609     }
8610   else
8611     {
8612       *error = 1;
8613       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8614     }
8615 }
8616 
8617 /** Returns the oblique angle
8618 \code Usage: double rot = dwg_ent_dim_linear_get_ext_line_rotation(dim,
8619 &error); \endcode \param[in] dim   dwg_ent_dim_linear* \param[out] error int*,
8620 is set to 0 for ok, 1 on error \deprecated
8621 */
8622 double
dwg_ent_dim_linear_get_ext_line_rotation(const dwg_ent_dim_linear * restrict dim,int * restrict error)8623 dwg_ent_dim_linear_get_ext_line_rotation (
8624     const dwg_ent_dim_linear *restrict dim, int *restrict error)
8625 {
8626   if (dim)
8627     {
8628       *error = 0;
8629       return dim->oblique_angle;
8630     }
8631   else
8632     {
8633       *error = 1;
8634       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8635       return bit_nan ();
8636     }
8637 }
8638 
8639 /** Sets the oblique_angle.
8640 \code Usage: dwg_ent_dim_linear_set_ext_line_rotation(dim, rot, &error);
8641 \endcode
8642 \param[out] dim   dwg_ent_dim_linear*
8643 \param[in]  rotation double
8644 \param[out] error   int*, is set to 0 for ok, 1 on error
8645 \deprecated
8646 */
8647 void
dwg_ent_dim_linear_set_ext_line_rotation(dwg_ent_dim_linear * restrict dim,const double angle,int * restrict error)8648 dwg_ent_dim_linear_set_ext_line_rotation (dwg_ent_dim_linear *restrict dim,
8649                                           const double angle,
8650                                           int *restrict error)
8651 {
8652   if (dim)
8653     {
8654       *error = 0;
8655       dim->oblique_angle = angle;
8656     }
8657   else
8658     {
8659       *error = 1;
8660       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8661     }
8662 }
8663 
8664 /** Returns the dim rotation
8665 \code Usage: double rot = dwg_ent_dim_linear_get_dim_rotation(dim, &error);
8666 \endcode
8667 \param[in]  dim   dwg_ent_dim_linear*
8668 \param[out] error   int*, is set to 0 for ok, 1 on error
8669 \deprecated
8670 */
8671 double
dwg_ent_dim_linear_get_dim_rotation(const dwg_ent_dim_linear * restrict dim,int * restrict error)8672 dwg_ent_dim_linear_get_dim_rotation (const dwg_ent_dim_linear *restrict dim,
8673                                      int *restrict error)
8674 {
8675   if (dim)
8676     {
8677       *error = 0;
8678       return dim->dim_rotation;
8679     }
8680   else
8681     {
8682       *error = 1;
8683       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8684       return bit_nan ();
8685     }
8686 }
8687 
8688 /** Sets the dim rotation
8689 \code Usage: dwg_ent_dim_linear_set_dim_rotation(dim, rot, &error);
8690 \endcode
8691 \param[out] dim   dwg_ent_dim_linear*
8692 \param[in]  rotation double
8693 \param[out] error   int*, is set to 0 for ok, 1 on error
8694 \deprecated
8695 */
8696 void
dwg_ent_dim_linear_set_dim_rotation(dwg_ent_dim_linear * restrict dim,const double rotation,int * restrict error)8697 dwg_ent_dim_linear_set_dim_rotation (dwg_ent_dim_linear *restrict dim,
8698                                      const double rotation,
8699                                      int *restrict error)
8700 {
8701   if (dim)
8702     {
8703       *error = 0;
8704       dim->dim_rotation = rotation;
8705     }
8706   else
8707     {
8708       *error = 1;
8709       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8710     }
8711 }
8712 
8713 /*******************************************************************
8714  *             FUNCTIONS FOR ALIGNED DIMENSION ENTITY                *
8715  ********************************************************************/
8716 
8717 /** Sets the 10 def point
8718 \code Usage: dwg_ent_dim_aligned_set_def_pt(dim, &point, &error);
8719 \endcode
8720 \param[out] dim   dwg_ent_dim_aligned*
8721 \param[in] dwg_point_3d
8722 \param[out] error   int*, is set to 0 for ok, 1 on error
8723 \deprecated
8724 */
8725 void
dwg_ent_dim_aligned_set_def_pt(dwg_ent_dim_aligned * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8726 dwg_ent_dim_aligned_set_def_pt (dwg_ent_dim_aligned *restrict dim,
8727                                 const dwg_point_3d *restrict point,
8728                                 int *restrict error)
8729 {
8730   if (dim
8731 #  ifndef HAVE_NONNULL
8732       && point
8733 #  endif
8734   )
8735     {
8736       *error = 0;
8737       dim->def_pt.x = point->x;
8738       dim->def_pt.y = point->y;
8739       dim->def_pt.z = point->z;
8740     }
8741   else
8742     {
8743       *error = 1;
8744       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8745     }
8746 }
8747 
8748 /** Returns the 10 def point
8749 \code Usage: dwg_ent_dim_aligned_get_def_pt(dim, &point, &error);
8750 \endcode
8751 \param[in] dim   dwg_ent_dim_aligned*
8752 \param[out] dwg_point_3d
8753 \param[out] error   int*, is set to 0 for ok, 1 on error
8754 \deprecated
8755 */
8756 void
dwg_ent_dim_aligned_get_def_pt(const dwg_ent_dim_aligned * restrict dim,dwg_point_3d * restrict point,int * restrict error)8757 dwg_ent_dim_aligned_get_def_pt (const dwg_ent_dim_aligned *restrict dim,
8758                                 dwg_point_3d *restrict point,
8759                                 int *restrict error)
8760 {
8761   if (dim
8762 #  ifndef HAVE_NONNULL
8763       && point
8764 #  endif
8765   )
8766     {
8767       *error = 0;
8768       point->x = dim->def_pt.x;
8769       point->y = dim->def_pt.y;
8770       point->z = dim->def_pt.z;
8771     }
8772   else
8773     {
8774       *error = 1;
8775       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8776     }
8777 }
8778 
8779 /** Sets the xline1 point
8780 \code Usage: dwg_ent_dim_aligned_set_13_pt(dim, &point, &error);
8781 \endcode
8782 \param[out] dim   dwg_ent_dim_aligned*
8783 \param[in] dwg_point_3d
8784 \param[out] error   int*, is set to 0 for ok, 1 on error
8785 \deprecated
8786 */
8787 void
dwg_ent_dim_aligned_set_13_pt(dwg_ent_dim_aligned * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8788 dwg_ent_dim_aligned_set_13_pt (dwg_ent_dim_aligned *restrict dim,
8789                                const dwg_point_3d *restrict point,
8790                                int *restrict error)
8791 {
8792   if (dim
8793 #  ifndef HAVE_NONNULL
8794       && point
8795 #  endif
8796   )
8797     {
8798       *error = 0;
8799       dim->xline1_pt.x = point->x;
8800       dim->xline1_pt.y = point->y;
8801       dim->xline1_pt.z = point->z;
8802     }
8803   else
8804     {
8805       *error = 1;
8806       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8807     }
8808 }
8809 
8810 /** Returns the xline1 point
8811 \code Usage: dwg_ent_dim_aligned_get_13_pt(dim, &point, &error);
8812 \endcode
8813 \param[in]  dim   dwg_ent_dim_aligned*
8814 \param[out] dwg_point_3d
8815 \param[out] error   int*, is set to 0 for ok, 1 on error
8816 \deprecated
8817 */
8818 void
dwg_ent_dim_aligned_get_13_pt(const dwg_ent_dim_aligned * restrict dim,dwg_point_3d * restrict point,int * restrict error)8819 dwg_ent_dim_aligned_get_13_pt (const dwg_ent_dim_aligned *restrict dim,
8820                                dwg_point_3d *restrict point,
8821                                int *restrict error)
8822 {
8823   if (dim
8824 #  ifndef HAVE_NONNULL
8825       && point
8826 #  endif
8827   )
8828     {
8829       *error = 0;
8830       point->x = dim->xline1_pt.x;
8831       point->y = dim->xline1_pt.y;
8832       point->z = dim->xline1_pt.z;
8833     }
8834   else
8835     {
8836       *error = 1;
8837       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8838     }
8839 }
8840 
8841 /** Sets the 14 point
8842 \code Usage: dwg_ent_dim_aligned_set_14_pt(dim, &point, &error);
8843 \endcode
8844 \param[out] dim   dwg_ent_dim_aligned*
8845 \param[in]  dwg_point_3d
8846 \param[out] error   int*, is set to 0 for ok, 1 on error
8847 \deprecated
8848 */
8849 void
dwg_ent_dim_aligned_set_14_pt(dwg_ent_dim_aligned * restrict dim,const dwg_point_3d * restrict point,int * restrict error)8850 dwg_ent_dim_aligned_set_14_pt (dwg_ent_dim_aligned *restrict dim,
8851                                const dwg_point_3d *restrict point,
8852                                int *restrict error)
8853 {
8854   if (dim
8855 #  ifndef HAVE_NONNULL
8856       && point
8857 #  endif
8858   )
8859     {
8860       *error = 0;
8861       dim->xline2_pt.x = point->x;
8862       dim->xline2_pt.y = point->y;
8863       dim->xline2_pt.z = point->z;
8864     }
8865   else
8866     {
8867       *error = 1;
8868       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8869     }
8870 }
8871 
8872 /** Returns the 14 point
8873 \code Usage: dwg_ent_dim_aligned_get_14_pt(dim, &point, &error);
8874 \endcode
8875 \param[in] dim   dwg_ent_dim_aligned*
8876 \param[out] dwg_point_3d
8877 \param[out] error   int*, is set to 0 for ok, 1 on error
8878 \deprecated
8879 */
8880 void
dwg_ent_dim_aligned_get_14_pt(const dwg_ent_dim_aligned * restrict dim,dwg_point_3d * restrict point,int * restrict error)8881 dwg_ent_dim_aligned_get_14_pt (const dwg_ent_dim_aligned *restrict dim,
8882                                dwg_point_3d *restrict point,
8883                                int *restrict error)
8884 {
8885   if (dim)
8886     {
8887       *error = 0;
8888       point->x = dim->xline2_pt.x;
8889       point->y = dim->xline2_pt.y;
8890       point->z = dim->xline2_pt.z;
8891     }
8892   else
8893     {
8894       *error = 1;
8895       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8896     }
8897 }
8898 
8899 /** Returns the oblique_angle
8900 \code Usage: double rot = dwg_ent_dim_aligned_get_ext_line_rotation(dim,
8901 &error); \endcode \param[in] dim   dwg_ent_dim_aligned* \param[out] error int*,
8902 is set to 0 for ok, 1 on error \deprecated
8903 */
8904 double
dwg_ent_dim_aligned_get_ext_line_rotation(const dwg_ent_dim_aligned * restrict dim,int * restrict error)8905 dwg_ent_dim_aligned_get_ext_line_rotation (
8906     const dwg_ent_dim_aligned *restrict dim, int *restrict error)
8907 {
8908   if (dim)
8909     {
8910       *error = 0;
8911       return dim->oblique_angle;
8912     }
8913   else
8914     {
8915       *error = 1;
8916       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8917       return bit_nan ();
8918     }
8919 }
8920 
8921 /** Sets the oblique_angle
8922 \code Usage: dwg_ent_dim_aligned_set_ext_line_rotation(dim, rot, &error);
8923 \endcode
8924 \param[out] dim   dwg_ent_dim_aligned*
8925 \param[in]  rotation double
8926 \param[out] error   int*, is set to 0 for ok, 1 on error
8927 \deprecated
8928 */
8929 void
dwg_ent_dim_aligned_set_ext_line_rotation(dwg_ent_dim_aligned * restrict dim,const double rotation,int * restrict error)8930 dwg_ent_dim_aligned_set_ext_line_rotation (dwg_ent_dim_aligned *restrict dim,
8931                                            const double rotation,
8932                                            int *restrict error)
8933 {
8934   if (dim)
8935     {
8936       *error = 0;
8937       dim->oblique_angle = rotation;
8938     }
8939   else
8940     {
8941       *error = 1;
8942       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8943     }
8944 }
8945 
8946 /*******************************************************************
8947  *              FUNCTIONS FOR ANG3PT DIMENSION ENTITY                *
8948  ********************************************************************/
8949 
8950 /** Sets the 10 point
8951 \code Usage: dwg_ent_dim_ang3pt_set_10_pt(dim, &point, &error);
8952 \endcode
8953 \param[out] ang    dwg_ent_dim_ang3pt*
8954 \param[in]  point  dwg_point_3d
8955 \param[out] error  int*, is set to 0 for ok, 1 on error
8956 \deprecated
8957 */
8958 void
dwg_ent_dim_ang3pt_set_def_pt(dwg_ent_dim_ang3pt * restrict ang,const dwg_point_3d * restrict point,int * restrict error)8959 dwg_ent_dim_ang3pt_set_def_pt (dwg_ent_dim_ang3pt *restrict ang,
8960                                const dwg_point_3d *restrict point,
8961                                int *restrict error)
8962 {
8963   if (ang
8964 #  ifndef HAVE_NONNULL
8965       && point
8966 #  endif
8967   )
8968     {
8969       *error = 0;
8970       ang->def_pt.x = point->x;
8971       ang->def_pt.y = point->y;
8972       ang->def_pt.z = point->z;
8973     }
8974   else
8975     {
8976       *error = 1;
8977       LOG_ERROR ("%s: empty arg", __FUNCTION__)
8978     }
8979 }
8980 
8981 /** Returns the 10 def pt
8982 \code Usage: dwg_ent_dim_ang3pt_get_def_pt(dim, &point, &error);
8983 \endcode
8984 \param[in]  ang     dwg_ent_dim_ang3pt*
8985 \param[out] point   dwg_point_3d
8986 \param[out] error   int*, is set to 0 for ok, 1 on error
8987 \deprecated
8988 */
8989 void
dwg_ent_dim_ang3pt_get_def_pt(const dwg_ent_dim_ang3pt * restrict ang,dwg_point_3d * restrict point,int * restrict error)8990 dwg_ent_dim_ang3pt_get_def_pt (const dwg_ent_dim_ang3pt *restrict ang,
8991                                dwg_point_3d *restrict point,
8992                                int *restrict error)
8993 {
8994   if (ang)
8995     {
8996       *error = 0;
8997       point->x = ang->def_pt.x;
8998       point->y = ang->def_pt.y;
8999       point->z = ang->def_pt.z;
9000     }
9001   else
9002     {
9003       *error = 1;
9004       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9005     }
9006 }
9007 
9008 /** Sets the xline1 point
9009 \code Usage: dwg_ent_dim_ang3pt_set_13_pt(dim, &point, &error);
9010 \endcode
9011 \param[out] ang     dwg_ent_dim_ang3pt*
9012 \param[in]  point   dwg_point_3d
9013 \param[out] error   int*, is set to 0 for ok, 1 on error
9014 \deprecated
9015 */
9016 void
dwg_ent_dim_ang3pt_set_13_pt(dwg_ent_dim_ang3pt * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9017 dwg_ent_dim_ang3pt_set_13_pt (dwg_ent_dim_ang3pt *restrict ang,
9018                               const dwg_point_3d *restrict point,
9019                               int *restrict error)
9020 {
9021   if (ang
9022 #  ifndef HAVE_NONNULL
9023       && point
9024 #  endif
9025   )
9026     {
9027       *error = 0;
9028       ang->xline1_pt.x = point->x;
9029       ang->xline1_pt.y = point->y;
9030       ang->xline1_pt.z = point->z;
9031     }
9032   else
9033     {
9034       *error = 1;
9035       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9036     }
9037 }
9038 
9039 /** Returns the xline1 pt
9040 \code Usage: dwg_ent_dim_ang3pt_get_13_pt(dim, &point, &error);
9041 \endcode
9042 \param[in]  ang     dwg_ent_dim_ang3pt*
9043 \param[out] point   dwg_point_3d
9044 \param[out] error   int*, is set to 0 for ok, 1 on error
9045 \deprecated
9046 */
9047 void
dwg_ent_dim_ang3pt_get_13_pt(const dwg_ent_dim_ang3pt * restrict ang,dwg_point_3d * restrict point,int * restrict error)9048 dwg_ent_dim_ang3pt_get_13_pt (const dwg_ent_dim_ang3pt *restrict ang,
9049                               dwg_point_3d *restrict point,
9050                               int *restrict error)
9051 {
9052   if (ang
9053 #  ifndef HAVE_NONNULL
9054       && point
9055 #  endif
9056   )
9057     {
9058       *error = 0;
9059       point->x = ang->xline1_pt.x;
9060       point->y = ang->xline1_pt.y;
9061       point->z = ang->xline1_pt.z;
9062     }
9063   else
9064     {
9065       *error = 1;
9066       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9067     }
9068 }
9069 
9070 /** Sets the xline2 point
9071 \code Usage: dwg_ent_dim_ang3pt_set_14_pt(dim, &point, &error);
9072 \endcode
9073 \param[out] ang     dwg_ent_dim_ang3pt*
9074 \param[in]  point   dwg_point_3d
9075 \param[out] error   int*, is set to 0 for ok, 1 on error
9076 \deprecated
9077 */
9078 void
dwg_ent_dim_ang3pt_set_14_pt(dwg_ent_dim_ang3pt * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9079 dwg_ent_dim_ang3pt_set_14_pt (dwg_ent_dim_ang3pt *restrict ang,
9080                               const dwg_point_3d *restrict point,
9081                               int *restrict error)
9082 {
9083   if (ang
9084 #  ifndef HAVE_NONNULL
9085       && point
9086 #  endif
9087   )
9088     {
9089       *error = 0;
9090       ang->xline2_pt.x = point->x;
9091       ang->xline2_pt.y = point->y;
9092       ang->xline2_pt.z = point->z;
9093     }
9094   else
9095     {
9096       *error = 1;
9097       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9098     }
9099 }
9100 
9101 /** Returns the xline2 pt
9102 \code Usage: dwg_ent_dim_ang3pt_get_14_pt(dim, &point, &error);
9103 \endcode
9104 \param[in]  ang     dwg_ent_dim_ang3pt*
9105 \param[out] point   dwg_point_3d
9106 \param[out] error   int*, is set to 0 for ok, 1 on error
9107 \deprecated
9108 */
9109 void
dwg_ent_dim_ang3pt_get_14_pt(const dwg_ent_dim_ang3pt * restrict ang,dwg_point_3d * restrict point,int * restrict error)9110 dwg_ent_dim_ang3pt_get_14_pt (const dwg_ent_dim_ang3pt *restrict ang,
9111                               dwg_point_3d *restrict point,
9112                               int *restrict error)
9113 {
9114   if (ang
9115 #  ifndef HAVE_NONNULL
9116       && point
9117 #  endif
9118   )
9119     {
9120       *error = 0;
9121       point->x = ang->xline2_pt.x;
9122       point->y = ang->xline2_pt.y;
9123       point->z = ang->xline2_pt.z;
9124     }
9125   else
9126     {
9127       *error = 1;
9128       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9129     }
9130 }
9131 
9132 /** Sets the center_pt 15
9133 \code Usage: dwg_ent_dim_ang3pt_set_first_arc_pt(dim, &point, &error);
9134 \endcode
9135 \param[out] ang dwg_ent_dim_ang3pt*
9136 \param[in]  dwg_point_3d
9137 \param[out] error   int*, is set to 0 for ok, 1 on error
9138 \deprecated
9139 */
9140 void
dwg_ent_dim_ang3pt_set_first_arc_pt(dwg_ent_dim_ang3pt * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9141 dwg_ent_dim_ang3pt_set_first_arc_pt (dwg_ent_dim_ang3pt *restrict ang,
9142                                      const dwg_point_3d *restrict point,
9143                                      int *restrict error)
9144 {
9145   if (ang
9146 #  ifndef HAVE_NONNULL
9147       && point
9148 #  endif
9149   )
9150     {
9151       *error = 0;
9152       ang->center_pt.x = point->x;
9153       ang->center_pt.y = point->y;
9154       ang->center_pt.z = point->z;
9155     }
9156   else
9157     {
9158       *error = 1;
9159       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9160     }
9161 }
9162 
9163 /** Returns the center_pt 15
9164 \code Usage: dwg_ent_dim_ang3pt_get_first_arc_pt(dim, &point, &error);
9165 \endcode
9166 \param[in] ang dwg_ent_dim_ang3pt*
9167 \param[out] dwg_point_3d
9168 \param[out] error   int*, is set to 0 for ok, 1 on error
9169 \deprecated
9170 */
9171 void
dwg_ent_dim_ang3pt_get_first_arc_pt(const dwg_ent_dim_ang3pt * restrict ang,dwg_point_3d * restrict point,int * restrict error)9172 dwg_ent_dim_ang3pt_get_first_arc_pt (const dwg_ent_dim_ang3pt *restrict ang,
9173                                      dwg_point_3d *restrict point,
9174                                      int *restrict error)
9175 {
9176   if (ang
9177 #  ifndef HAVE_NONNULL
9178       && point
9179 #  endif
9180   )
9181     {
9182       *error = 0;
9183       point->x = ang->center_pt.x;
9184       point->y = ang->center_pt.y;
9185       point->z = ang->center_pt.z;
9186     }
9187   else
9188     {
9189       *error = 1;
9190       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9191     }
9192 }
9193 
9194 /*******************************************************************
9195  *              FUNCTIONS FOR ANG2LN DIMENSION ENTITY                *
9196  ********************************************************************/
9197 
9198 /** Sets dim ang2ln 10 def point. The z-coord is ignored, it is the eleavtion.
9199  */
9200 void
dwg_ent_dim_ang2ln_set_def_pt(dwg_ent_dim_ang2ln * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9201 dwg_ent_dim_ang2ln_set_def_pt (dwg_ent_dim_ang2ln *restrict ang,
9202                                const dwg_point_3d *restrict point,
9203                                int *restrict error)
9204 {
9205   if (ang
9206 #  ifndef HAVE_NONNULL
9207       && point
9208 #  endif
9209   )
9210     {
9211       *error = 0;
9212       ang->def_pt.x = point->x;
9213       ang->def_pt.y = point->y;
9214     }
9215   else
9216     {
9217       *error = 1;
9218       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9219     }
9220 }
9221 
9222 /** Returns dim ang2ln 10 def point, The z-coord is the elevation.
9223  */
9224 void
dwg_ent_dim_ang2ln_get_def_pt(const dwg_ent_dim_ang2ln * restrict ang,dwg_point_3d * restrict point,int * restrict error)9225 dwg_ent_dim_ang2ln_get_def_pt (const dwg_ent_dim_ang2ln *restrict ang,
9226                                dwg_point_3d *restrict point,
9227                                int *restrict error)
9228 {
9229   if (ang
9230 #  ifndef HAVE_NONNULL
9231       && point
9232 #  endif
9233   )
9234     {
9235       *error = 0;
9236       point->x = ang->def_pt.x;
9237       point->y = ang->def_pt.y;
9238       point->z = ang->elevation;
9239     }
9240   else
9241     {
9242       *error = 1;
9243       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9244     }
9245 }
9246 
9247 /** Sets dim ang2ln 13 xline1start point
9248  */
9249 void
dwg_ent_dim_ang2ln_set_13_pt(dwg_ent_dim_ang2ln * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9250 dwg_ent_dim_ang2ln_set_13_pt (dwg_ent_dim_ang2ln *restrict ang,
9251                               const dwg_point_3d *restrict point,
9252                               int *restrict error)
9253 {
9254   if (ang
9255 #  ifndef HAVE_NONNULL
9256       && point
9257 #  endif
9258   )
9259     {
9260       *error = 0;
9261       ang->xline1start_pt.x = point->x;
9262       ang->xline1start_pt.y = point->y;
9263       ang->xline1start_pt.z = point->z;
9264     }
9265   else
9266     {
9267       *error = 1;
9268       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9269     }
9270 }
9271 
9272 /** Returns dim ang2ln 13 xline1start point
9273  */
9274 void
dwg_ent_dim_ang2ln_get_13_pt(const dwg_ent_dim_ang2ln * restrict ang,dwg_point_3d * restrict point,int * restrict error)9275 dwg_ent_dim_ang2ln_get_13_pt (const dwg_ent_dim_ang2ln *restrict ang,
9276                               dwg_point_3d *restrict point,
9277                               int *restrict error)
9278 {
9279   if (ang
9280 #  ifndef HAVE_NONNULL
9281       && point
9282 #  endif
9283   )
9284     {
9285       *error = 0;
9286       point->x = ang->xline1start_pt.x;
9287       point->y = ang->xline1start_pt.y;
9288       point->z = ang->xline1start_pt.z;
9289     }
9290   else
9291     {
9292       *error = 1;
9293       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9294     }
9295 }
9296 
9297 /** Sets dim ang2ln 14 xline1end point
9298  */
9299 void
dwg_ent_dim_ang2ln_set_14_pt(dwg_ent_dim_ang2ln * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9300 dwg_ent_dim_ang2ln_set_14_pt (dwg_ent_dim_ang2ln *restrict ang,
9301                               const dwg_point_3d *restrict point,
9302                               int *restrict error)
9303 {
9304   if (ang
9305 #  ifndef HAVE_NONNULL
9306       && point
9307 #  endif
9308   )
9309     {
9310       *error = 0;
9311       ang->xline1end_pt.x = point->x;
9312       ang->xline1end_pt.y = point->y;
9313       ang->xline1end_pt.z = point->z;
9314     }
9315   else
9316     {
9317       *error = 1;
9318       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9319     }
9320 }
9321 
9322 /** Returns dim ang2ln 14 xline1end point
9323  */
9324 void
dwg_ent_dim_ang2ln_get_14_pt(const dwg_ent_dim_ang2ln * restrict ang,dwg_point_3d * restrict point,int * restrict error)9325 dwg_ent_dim_ang2ln_get_14_pt (const dwg_ent_dim_ang2ln *restrict ang,
9326                               dwg_point_3d *restrict point,
9327                               int *restrict error)
9328 {
9329   if (ang
9330 #  ifndef HAVE_NONNULL
9331       && point
9332 #  endif
9333   )
9334     {
9335       *error = 0;
9336       point->x = ang->xline1end_pt.x;
9337       point->y = ang->xline1end_pt.y;
9338       point->z = ang->xline1end_pt.z;
9339     }
9340   else
9341     {
9342       *error = 1;
9343       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9344     }
9345 }
9346 
9347 /** Sets dim ang2ln xline2start 15 point
9348  */
9349 void
dwg_ent_dim_ang2ln_set_first_arc_pt(dwg_ent_dim_ang2ln * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9350 dwg_ent_dim_ang2ln_set_first_arc_pt (dwg_ent_dim_ang2ln *restrict ang,
9351                                      const dwg_point_3d *restrict point,
9352                                      int *restrict error)
9353 {
9354   if (ang
9355 #  ifndef HAVE_NONNULL
9356       && point
9357 #  endif
9358   )
9359     {
9360       *error = 0;
9361       ang->xline2start_pt.x = point->x;
9362       ang->xline2start_pt.y = point->y;
9363       ang->xline2start_pt.z = point->z;
9364     }
9365   else
9366     {
9367       *error = 1;
9368       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9369     }
9370 }
9371 
9372 /** Returns dim ang2ln xline2start 15 point
9373  */
9374 void
dwg_ent_dim_ang2ln_get_first_arc_pt(const dwg_ent_dim_ang2ln * restrict ang,dwg_point_3d * restrict point,int * restrict error)9375 dwg_ent_dim_ang2ln_get_first_arc_pt (const dwg_ent_dim_ang2ln *restrict ang,
9376                                      dwg_point_3d *restrict point,
9377                                      int *restrict error)
9378 {
9379   if (ang
9380 #  ifndef HAVE_NONNULL
9381       && point
9382 #  endif
9383   )
9384     {
9385       *error = 0;
9386       point->x = ang->xline2start_pt.x;
9387       point->y = ang->xline2start_pt.y;
9388       point->z = ang->xline2start_pt.z;
9389     }
9390   else
9391     {
9392       *error = 1;
9393       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9394     }
9395 }
9396 
9397 /** Sets dim ang2ln xline2end 16 point
9398  */
9399 void
dwg_ent_dim_ang2ln_set_16_pt(dwg_ent_dim_ang2ln * restrict ang,const dwg_point_3d * restrict point,int * restrict error)9400 dwg_ent_dim_ang2ln_set_16_pt (dwg_ent_dim_ang2ln *restrict ang,
9401                               const dwg_point_3d *restrict point,
9402                               int *restrict error)
9403 {
9404   if (ang
9405 #  ifndef HAVE_NONNULL
9406       && point
9407 #  endif
9408   )
9409     {
9410       *error = 0;
9411       ang->xline2end_pt.x = point->x;
9412       ang->xline2end_pt.y = point->y;
9413       ang->xline2end_pt.z = point->z;
9414     }
9415   else
9416     {
9417       *error = 1;
9418       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9419     }
9420 }
9421 
9422 /** Returns dim ang2ln xline2end 16 point
9423  */
9424 void
dwg_ent_dim_ang2ln_get_16_pt(const dwg_ent_dim_ang2ln * restrict ang,dwg_point_3d * restrict point,int * restrict error)9425 dwg_ent_dim_ang2ln_get_16_pt (const dwg_ent_dim_ang2ln *restrict ang,
9426                               dwg_point_3d *restrict point,
9427                               int *restrict error)
9428 {
9429   if (ang
9430 #  ifndef HAVE_NONNULL
9431       && point
9432 #  endif
9433   )
9434     {
9435       *error = 0;
9436       point->x = ang->xline2end_pt.x;
9437       point->y = ang->xline2end_pt.y;
9438       point->z = ang->xline2end_pt.z;
9439     }
9440   else
9441     {
9442       *error = 1;
9443       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9444     }
9445 }
9446 
9447 /*******************************************************************
9448  *              FUNCTIONS FOR RADIUS DIMENSION ENTITY                *
9449  ********************************************************************/
9450 
9451 /** Sets dim radius def 10 point
9452  */
9453 void
dwg_ent_dim_radius_set_def_pt(dwg_ent_dim_radius * restrict radius,const dwg_point_3d * restrict point,int * restrict error)9454 dwg_ent_dim_radius_set_def_pt (dwg_ent_dim_radius *restrict radius,
9455                                const dwg_point_3d *restrict point,
9456                                int *restrict error)
9457 {
9458   if (radius
9459 #  ifndef HAVE_NONNULL
9460       && point
9461 #  endif
9462   )
9463     {
9464       *error = 0;
9465       radius->def_pt.x = point->x;
9466       radius->def_pt.y = point->y;
9467       radius->def_pt.z = point->z;
9468     }
9469   else
9470     {
9471       LOG_ERROR ("%s: empty radius", __FUNCTION__)
9472       *error = 1;
9473     }
9474 }
9475 
9476 /** Returns dim radius def 10 point
9477  */
9478 void
dwg_ent_dim_radius_get_def_pt(const dwg_ent_dim_radius * restrict radius,dwg_point_3d * restrict point,int * restrict error)9479 dwg_ent_dim_radius_get_def_pt (const dwg_ent_dim_radius *restrict radius,
9480                                dwg_point_3d *restrict point,
9481                                int *restrict error)
9482 {
9483   if (radius
9484 #  ifndef HAVE_NONNULL
9485       && point
9486 #  endif
9487   )
9488     {
9489       *error = 0;
9490       point->x = radius->def_pt.x;
9491       point->y = radius->def_pt.y;
9492       point->z = radius->def_pt.z;
9493     }
9494   else
9495     {
9496       LOG_ERROR ("%s: empty radius", __FUNCTION__)
9497       *error = 1;
9498     }
9499 }
9500 
9501 /** Sets dim radius first_arc 15 point
9502  */
9503 void
dwg_ent_dim_radius_set_first_arc_pt(dwg_ent_dim_radius * restrict radius,const dwg_point_3d * restrict point,int * restrict error)9504 dwg_ent_dim_radius_set_first_arc_pt (dwg_ent_dim_radius *restrict radius,
9505                                      const dwg_point_3d *restrict point,
9506                                      int *restrict error)
9507 {
9508   if (radius
9509 #  ifndef HAVE_NONNULL
9510       && point
9511 #  endif
9512   )
9513     {
9514       *error = 0;
9515       radius->first_arc_pt.x = point->x;
9516       radius->first_arc_pt.y = point->y;
9517       radius->first_arc_pt.z = point->z;
9518     }
9519   else
9520     {
9521       LOG_ERROR ("%s: empty radius", __FUNCTION__)
9522       *error = 1;
9523     }
9524 }
9525 
9526 /** Returns dim radius first_arc 15 point
9527  */
9528 void
dwg_ent_dim_radius_get_first_arc_pt(const dwg_ent_dim_radius * restrict radius,dwg_point_3d * restrict point,int * restrict error)9529 dwg_ent_dim_radius_get_first_arc_pt (const dwg_ent_dim_radius *restrict radius,
9530                                      dwg_point_3d *restrict point,
9531                                      int *restrict error)
9532 {
9533   if (radius
9534 #  ifndef HAVE_NONNULL
9535       && point
9536 #  endif
9537   )
9538     {
9539       *error = 0;
9540       point->x = radius->first_arc_pt.x;
9541       point->y = radius->first_arc_pt.y;
9542       point->z = radius->first_arc_pt.z;
9543     }
9544   else
9545     {
9546       LOG_ERROR ("%s: empty radius", __FUNCTION__)
9547       *error = 1;
9548     }
9549 }
9550 
9551 /** Returns dim radius leader length
9552  */
9553 double
dwg_ent_dim_radius_get_leader_length(const dwg_ent_dim_radius * restrict radius,int * restrict error)9554 dwg_ent_dim_radius_get_leader_length (
9555     const dwg_ent_dim_radius *restrict radius, int *restrict error)
9556 {
9557   if (radius)
9558     {
9559       *error = 0;
9560       return radius->leader_len;
9561     }
9562   else
9563     {
9564       LOG_ERROR ("%s: empty radius", __FUNCTION__)
9565       *error = 1;
9566       return bit_nan ();
9567     }
9568 }
9569 
9570 /** Sets dim radius leader length
9571  */
9572 void
dwg_ent_dim_radius_set_leader_length(dwg_ent_dim_radius * restrict radius,const double length,int * restrict error)9573 dwg_ent_dim_radius_set_leader_length (dwg_ent_dim_radius *restrict radius,
9574                                       const double length, int *restrict error)
9575 {
9576   if (radius)
9577     {
9578       *error = 0;
9579       radius->leader_len = length;
9580     }
9581   else
9582     {
9583       LOG_ERROR ("%s: empty radius", __FUNCTION__)
9584       *error = 1;
9585     }
9586 }
9587 
9588 /*******************************************************************
9589  *             FUNCTIONS FOR DIAMETER DIMENSION ENTITY               *
9590  ********************************************************************/
9591 
9592 /** Sets dim diameter def 10 point
9593  */
9594 void
dwg_ent_dim_diameter_set_def_pt(dwg_ent_dim_diameter * restrict dia,const dwg_point_3d * restrict point,int * restrict error)9595 dwg_ent_dim_diameter_set_def_pt (dwg_ent_dim_diameter *restrict dia,
9596                                  const dwg_point_3d *restrict point,
9597                                  int *restrict error)
9598 {
9599   if (dia
9600 #  ifndef HAVE_NONNULL
9601       && point
9602 #  endif
9603   )
9604     {
9605       *error = 0;
9606       dia->def_pt.x = point->x;
9607       dia->def_pt.y = point->y;
9608       dia->def_pt.z = point->z;
9609     }
9610   else
9611     {
9612       *error = 1;
9613       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9614     }
9615 }
9616 
9617 /** Returns dim diameter def 10 point
9618  */
9619 void
dwg_ent_dim_diameter_get_def_pt(const dwg_ent_dim_diameter * restrict dia,dwg_point_3d * restrict point,int * restrict error)9620 dwg_ent_dim_diameter_get_def_pt (const dwg_ent_dim_diameter *restrict dia,
9621                                  dwg_point_3d *restrict point,
9622                                  int *restrict error)
9623 {
9624   if (dia
9625 #  ifndef HAVE_NONNULL
9626       && point
9627 #  endif
9628   )
9629     {
9630       *error = 0;
9631       point->x = dia->def_pt.x;
9632       point->y = dia->def_pt.y;
9633       point->z = dia->def_pt.z;
9634     }
9635   else
9636     {
9637       *error = 1;
9638       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9639     }
9640 }
9641 
9642 /** Sets dim diameter first_arc 15 point
9643  */
9644 void
dwg_ent_dim_diameter_set_first_arc_pt(dwg_ent_dim_diameter * restrict dia,const dwg_point_3d * restrict point,int * restrict error)9645 dwg_ent_dim_diameter_set_first_arc_pt (dwg_ent_dim_diameter *restrict dia,
9646                                        const dwg_point_3d *restrict point,
9647                                        int *restrict error)
9648 {
9649   if (dia
9650 #  ifndef HAVE_NONNULL
9651       && point
9652 #  endif
9653   )
9654     {
9655       *error = 0;
9656       dia->first_arc_pt.x = point->x;
9657       dia->first_arc_pt.y = point->y;
9658       dia->first_arc_pt.z = point->z;
9659     }
9660   else
9661     {
9662       *error = 1;
9663       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9664     }
9665 }
9666 
9667 /** Returns dim diameter first_arc 15 point
9668  */
9669 void
dwg_ent_dim_diameter_get_first_arc_pt(const dwg_ent_dim_diameter * restrict dia,dwg_point_3d * restrict point,int * restrict error)9670 dwg_ent_dim_diameter_get_first_arc_pt (
9671     const dwg_ent_dim_diameter *restrict dia, dwg_point_3d *restrict point,
9672     int *restrict error)
9673 {
9674   if (dia
9675 #  ifndef HAVE_NONNULL
9676       && point
9677 #  endif
9678   )
9679     {
9680       *error = 0;
9681       point->x = dia->first_arc_pt.x;
9682       point->y = dia->first_arc_pt.y;
9683       point->z = dia->first_arc_pt.z;
9684     }
9685   else
9686     {
9687       *error = 1;
9688       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9689     }
9690 }
9691 
9692 /** Returns dim diameter leader length
9693  */
9694 double
dwg_ent_dim_diameter_get_leader_length(const dwg_ent_dim_diameter * restrict dia,int * restrict error)9695 dwg_ent_dim_diameter_get_leader_length (
9696     const dwg_ent_dim_diameter *restrict dia, int *restrict error)
9697 {
9698   if (dia)
9699     {
9700       *error = 0;
9701       return dia->leader_len;
9702     }
9703   else
9704     {
9705       LOG_ERROR ("%s: empty dia", __FUNCTION__)
9706       *error = 1;
9707       return bit_nan ();
9708     }
9709 }
9710 
9711 /** Sets dim diameter leader length
9712  */
9713 void
dwg_ent_dim_diameter_set_leader_length(dwg_ent_dim_diameter * restrict dia,const double length,int * restrict error)9714 dwg_ent_dim_diameter_set_leader_length (dwg_ent_dim_diameter *restrict dia,
9715                                         const double length,
9716                                         int *restrict error)
9717 {
9718   if (dia)
9719     {
9720       *error = 0;
9721       dia->leader_len = length;
9722     }
9723   else
9724     {
9725       LOG_ERROR ("%s: empty dia", __FUNCTION__)
9726       *error = 1;
9727     }
9728 }
9729 
9730 /*******************************************************************
9731  *                    FUNCTIONS FOR SHAPE ENTITY                     *
9732  ********************************************************************/
9733 
9734 /** Returns shape ins point
9735  */
9736 void
dwg_ent_shape_get_ins_pt(const dwg_ent_shape * restrict shape,dwg_point_3d * restrict point,int * restrict error)9737 dwg_ent_shape_get_ins_pt (const dwg_ent_shape *restrict shape,
9738                           dwg_point_3d *restrict point, int *restrict error)
9739 {
9740   if (shape
9741 #  ifndef HAVE_NONNULL
9742       && point
9743 #  endif
9744   )
9745     {
9746       *error = 0;
9747       point->x = shape->ins_pt.x;
9748       point->y = shape->ins_pt.y;
9749       point->z = shape->ins_pt.z;
9750     }
9751   else
9752     {
9753       LOG_ERROR ("%s: empty shape or point", __FUNCTION__)
9754       *error = 1;
9755     }
9756 }
9757 
9758 /** Sets shape ins point
9759  */
9760 void
dwg_ent_shape_set_ins_pt(dwg_ent_shape * restrict shape,const dwg_point_3d * restrict point,int * restrict error)9761 dwg_ent_shape_set_ins_pt (dwg_ent_shape *restrict shape,
9762                           const dwg_point_3d *restrict point,
9763                           int *restrict error)
9764 {
9765   if (shape
9766 #  ifndef HAVE_NONNULL
9767       && point
9768 #  endif
9769   )
9770     {
9771       *error = 0;
9772       shape->ins_pt.x = point->x;
9773       shape->ins_pt.y = point->y;
9774       shape->ins_pt.z = point->z;
9775     }
9776   else
9777     {
9778       LOG_ERROR ("%s: empty shape or point", __FUNCTION__)
9779       *error = 1;
9780     }
9781 }
9782 
9783 /** Returns shape scale
9784  */
9785 double
dwg_ent_shape_get_scale(const dwg_ent_shape * restrict shape,int * restrict error)9786 dwg_ent_shape_get_scale (const dwg_ent_shape *restrict shape,
9787                          int *restrict error)
9788 {
9789   if (shape)
9790     {
9791       *error = 0;
9792       return shape->scale;
9793     }
9794   else
9795     {
9796       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9797       *error = 1;
9798       return bit_nan ();
9799     }
9800 }
9801 
9802 /** Sets shape scale
9803  */
9804 void
dwg_ent_shape_set_scale(dwg_ent_shape * restrict shape,const double scale,int * restrict error)9805 dwg_ent_shape_set_scale (dwg_ent_shape *restrict shape, const double scale,
9806                          int *restrict error)
9807 {
9808   if (shape)
9809     {
9810       *error = 0;
9811       shape->scale = scale;
9812     }
9813   else
9814     {
9815       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9816       *error = 1;
9817     }
9818 }
9819 
9820 /** Returns shape rotation
9821  */
9822 double
dwg_ent_shape_get_rotation(const dwg_ent_shape * restrict shape,int * restrict error)9823 dwg_ent_shape_get_rotation (const dwg_ent_shape *restrict shape,
9824                             int *restrict error)
9825 {
9826   if (shape)
9827     {
9828       *error = 0;
9829       return shape->rotation;
9830     }
9831   else
9832     {
9833       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9834       *error = 1;
9835       return bit_nan ();
9836     }
9837 }
9838 
9839 /** Sets shape rotation
9840  */
9841 void
dwg_ent_shape_set_rotation(dwg_ent_shape * restrict shape,const double rotation,int * restrict error)9842 dwg_ent_shape_set_rotation (dwg_ent_shape *restrict shape,
9843                             const double rotation, int *restrict error)
9844 {
9845   if (shape)
9846     {
9847       *error = 0;
9848       shape->rotation = rotation;
9849     }
9850   else
9851     {
9852       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9853       *error = 1;
9854     }
9855 }
9856 
9857 /** Returns shape width factor
9858  */
9859 double
dwg_ent_shape_get_width_factor(const dwg_ent_shape * restrict shape,int * restrict error)9860 dwg_ent_shape_get_width_factor (const dwg_ent_shape *restrict shape,
9861                                 int *restrict error)
9862 {
9863   if (shape)
9864     {
9865       *error = 0;
9866       return shape->width_factor;
9867     }
9868   else
9869     {
9870       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9871       *error = 1;
9872       return bit_nan ();
9873     }
9874 }
9875 
9876 /** Sets shape width factor
9877  */
9878 void
dwg_ent_shape_set_width_factor(dwg_ent_shape * restrict shape,const double width_factor,int * restrict error)9879 dwg_ent_shape_set_width_factor (dwg_ent_shape *restrict shape,
9880                                 const double width_factor, int *restrict error)
9881 {
9882   if (shape)
9883     {
9884       *error = 0;
9885       shape->width_factor = width_factor;
9886     }
9887   else
9888     {
9889       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9890       *error = 1;
9891     }
9892 }
9893 
9894 /** Returns shape oblique
9895  */
9896 double
dwg_ent_shape_get_oblique(const dwg_ent_shape * restrict shape,int * restrict error)9897 dwg_ent_shape_get_oblique (const dwg_ent_shape *restrict shape,
9898                            int *restrict error)
9899 {
9900   if (shape)
9901     {
9902       *error = 0;
9903       return shape->oblique_angle;
9904     }
9905   else
9906     {
9907       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9908       *error = 1;
9909       return bit_nan ();
9910     }
9911 }
9912 
9913 /** Sets shape oblique
9914  */
9915 void
dwg_ent_shape_set_oblique(dwg_ent_shape * restrict shape,const double oblique,int * restrict error)9916 dwg_ent_shape_set_oblique (dwg_ent_shape *restrict shape, const double oblique,
9917                            int *restrict error)
9918 {
9919   if (shape)
9920     {
9921       *error = 0;
9922       shape->oblique_angle = oblique;
9923     }
9924   else
9925     {
9926       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9927       *error = 1;
9928     }
9929 }
9930 
9931 /** Returns shape thickness
9932  */
9933 double
dwg_ent_shape_get_thickness(const dwg_ent_shape * restrict shape,int * restrict error)9934 dwg_ent_shape_get_thickness (const dwg_ent_shape *restrict shape,
9935                              int *restrict error)
9936 {
9937   if (shape)
9938     {
9939       *error = 0;
9940       return shape->thickness;
9941     }
9942   else
9943     {
9944       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9945       *error = 1;
9946       return bit_nan ();
9947     }
9948 }
9949 
9950 /** Sets shape thickness
9951  */
9952 void
dwg_ent_shape_set_thickness(dwg_ent_shape * restrict shape,const double thickness,int * restrict error)9953 dwg_ent_shape_set_thickness (dwg_ent_shape *restrict shape,
9954                              const double thickness, int *restrict error)
9955 {
9956   if (shape)
9957     {
9958       *error = 0;
9959       shape->thickness = thickness;
9960     }
9961   else
9962     {
9963       LOG_ERROR ("%s: empty shape", __FUNCTION__)
9964       *error = 1;
9965     }
9966 }
9967 
9968 /** Returns SHAPE.style_id
9969  */
9970 BITCODE_BS
dwg_ent_shape_get_shape_no(const dwg_ent_shape * restrict shape,int * restrict error)9971 dwg_ent_shape_get_shape_no (const dwg_ent_shape *restrict shape,
9972                             int *restrict error)
9973 {
9974   if (shape)
9975     {
9976       *error = 0;
9977       return shape->style_id;
9978     }
9979   else
9980     {
9981       *error = 1;
9982       LOG_ERROR ("%s: empty arg", __FUNCTION__)
9983       return bit_nan ();
9984     }
9985 }
9986 
9987 /** Sets SHAPE.style_id by index, not name.
9988  */
9989 void
dwg_ent_shape_set_shape_no(dwg_ent_shape * restrict shape,const BITCODE_BS id,int * restrict error)9990 dwg_ent_shape_set_shape_no (dwg_ent_shape *restrict shape, const BITCODE_BS id,
9991                             int *restrict error)
9992 {
9993   if (shape)
9994     {
9995       *error = 0;
9996       // FIXME: check valid index: STYLE_CONTROL.num_entries
9997       shape->style_id = id;
9998     }
9999   else
10000     {
10001       *error = 1;
10002       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10003     }
10004 }
10005 
10006 /** Returns SHAPE.style_id
10007  */
10008 BITCODE_BS
dwg_ent_shape_get_style_id(const dwg_ent_shape * restrict shape,int * restrict error)10009 dwg_ent_shape_get_style_id (const dwg_ent_shape *restrict shape,
10010                             int *restrict error)
10011 {
10012   if (shape)
10013     {
10014       *error = 0;
10015       return shape->style_id;
10016     }
10017   else
10018     {
10019       *error = 1;
10020       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10021       return bit_nan ();
10022     }
10023 }
10024 
10025 /** Sets SHAPE.style_id by index, not name.
10026  */
10027 void
dwg_ent_shape_set_style_id(dwg_ent_shape * restrict shape,const BITCODE_BS id,int * restrict error)10028 dwg_ent_shape_set_style_id (dwg_ent_shape *restrict shape, const BITCODE_BS id,
10029                             int *restrict error)
10030 {
10031   if (shape)
10032     {
10033       *error = 0;
10034       // FIXME: check valid index: STYLE_CONTROL.num_entries
10035       shape->style_id = id;
10036     }
10037   else
10038     {
10039       *error = 1;
10040       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10041     }
10042 }
10043 
10044 /** Returns shape extrusion
10045  */
10046 void
dwg_ent_shape_get_extrusion(const dwg_ent_shape * restrict shape,dwg_point_3d * restrict point,int * restrict error)10047 dwg_ent_shape_get_extrusion (const dwg_ent_shape *restrict shape,
10048                              dwg_point_3d *restrict point, int *restrict error)
10049 {
10050   if (shape
10051 #  ifndef HAVE_NONNULL
10052       && point
10053 #  endif
10054   )
10055     {
10056       *error = 0;
10057       point->x = shape->extrusion.x;
10058       point->y = shape->extrusion.y;
10059       point->z = shape->extrusion.z;
10060     }
10061   else
10062     {
10063       *error = 1;
10064       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10065     }
10066 }
10067 
10068 /** Sets shape extrusion
10069  */
10070 void
dwg_ent_shape_set_extrusion(dwg_ent_shape * restrict shape,const dwg_point_3d * restrict point,int * restrict error)10071 dwg_ent_shape_set_extrusion (dwg_ent_shape *restrict shape,
10072                              const dwg_point_3d *restrict point,
10073                              int *restrict error)
10074 {
10075   if (shape
10076 #  ifndef HAVE_NONNULL
10077       && point
10078 #  endif
10079   )
10080     {
10081       *error = 0;
10082       shape->extrusion.x = point->x;
10083       shape->extrusion.y = point->y;
10084       shape->extrusion.z = point->z;
10085     }
10086   else
10087     {
10088       *error = 1;
10089       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10090     }
10091 }
10092 
10093 /*******************************************************************
10094  *                    FUNCTIONS FOR MTEXT ENTITY                     *
10095  ********************************************************************/
10096 
10097 /** Sets the _dwg_entity_MTEXT::ins_pt, DXF 10
10098  */
10099 void
dwg_ent_mtext_set_insertion_pt(dwg_ent_mtext * restrict mtext,const dwg_point_3d * restrict point,int * restrict error)10100 dwg_ent_mtext_set_insertion_pt (dwg_ent_mtext *restrict mtext,
10101                                 const dwg_point_3d *restrict point,
10102                                 int *restrict error)
10103 {
10104   if (mtext
10105 #  ifndef HAVE_NONNULL
10106       && point
10107 #  endif
10108   )
10109     {
10110       *error = 0;
10111       mtext->ins_pt.x = point->x;
10112       mtext->ins_pt.y = point->y;
10113       mtext->ins_pt.z = point->z;
10114     }
10115   else
10116     {
10117       *error = 1;
10118       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10119     }
10120 }
10121 
10122 /** Returns the _dwg_entity_MTEXT::ins_pt, DXF 10
10123  */
10124 void
dwg_ent_mtext_get_insertion_pt(const dwg_ent_mtext * restrict mtext,dwg_point_3d * restrict point,int * restrict error)10125 dwg_ent_mtext_get_insertion_pt (const dwg_ent_mtext *restrict mtext,
10126                                 dwg_point_3d *restrict point,
10127                                 int *restrict error)
10128 {
10129   if (mtext
10130 #  ifndef HAVE_NONNULL
10131       && point
10132 #  endif
10133   )
10134     {
10135       *error = 0;
10136       point->x = mtext->ins_pt.x;
10137       point->y = mtext->ins_pt.y;
10138       point->z = mtext->ins_pt.z;
10139     }
10140   else
10141     {
10142       *error = 1;
10143       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10144     }
10145 }
10146 
10147 /** Sets the _dwg_entity_MTEXT::extrusion vector, DXF 210
10148  */
10149 void
dwg_ent_mtext_set_extrusion(dwg_ent_mtext * restrict mtext,const dwg_point_3d * restrict vector,int * restrict error)10150 dwg_ent_mtext_set_extrusion (dwg_ent_mtext *restrict mtext,
10151                              const dwg_point_3d *restrict vector,
10152                              int *restrict error)
10153 {
10154   if (mtext
10155 #  ifndef HAVE_NONNULL
10156       && vector
10157 #  endif
10158   )
10159     {
10160       *error = 0;
10161       mtext->extrusion.x = vector->x;
10162       mtext->extrusion.y = vector->y;
10163       mtext->extrusion.z = vector->z;
10164     }
10165   else
10166     {
10167       *error = 1;
10168       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10169     }
10170 }
10171 
10172 /** Returns the _dwg_entity_MTEXT::extrusion vector, DXF 210
10173  */
10174 void
dwg_ent_mtext_get_extrusion(const dwg_ent_mtext * restrict mtext,dwg_point_3d * restrict point,int * restrict error)10175 dwg_ent_mtext_get_extrusion (const dwg_ent_mtext *restrict mtext,
10176                              dwg_point_3d *restrict point, int *restrict error)
10177 {
10178   if (mtext
10179 #  ifndef HAVE_NONNULL
10180       && point
10181 #  endif
10182   )
10183     {
10184       *error = 0;
10185       point->x = mtext->extrusion.x;
10186       point->y = mtext->extrusion.y;
10187       point->z = mtext->extrusion.z;
10188     }
10189   else
10190     {
10191       *error = 1;
10192       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10193     }
10194 }
10195 
10196 /** Sets the _dwg_entity_MTEXT::x_axis_dir vector, DXF 11 (in WCS)
10197  */
10198 void
dwg_ent_mtext_set_x_axis_dir(dwg_ent_mtext * restrict mtext,const dwg_point_3d * restrict vector,int * restrict error)10199 dwg_ent_mtext_set_x_axis_dir (dwg_ent_mtext *restrict mtext,
10200                               const dwg_point_3d *restrict vector,
10201                               int *restrict error)
10202 {
10203   if (mtext
10204 #  ifndef HAVE_NONNULL
10205       && vector
10206 #  endif
10207   )
10208     {
10209       *error = 0;
10210       mtext->x_axis_dir.x = vector->x;
10211       mtext->x_axis_dir.y = vector->y;
10212       mtext->x_axis_dir.z = vector->z;
10213     }
10214   else
10215     {
10216       *error = 1;
10217       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10218     }
10219 }
10220 
10221 /** Returns the _dwg_entity_MTEXT::x_axis_dir vector, DXF 11 (in WCS)
10222  */
10223 void
dwg_ent_mtext_get_x_axis_dir(const dwg_ent_mtext * restrict mtext,dwg_point_3d * restrict vector,int * restrict error)10224 dwg_ent_mtext_get_x_axis_dir (const dwg_ent_mtext *restrict mtext,
10225                               dwg_point_3d *restrict vector,
10226                               int *restrict error)
10227 {
10228   if (mtext
10229 #  ifndef HAVE_NONNULL
10230       && vector
10231 #  endif
10232   )
10233     {
10234       *error = 0;
10235       vector->x = mtext->x_axis_dir.x;
10236       vector->y = mtext->x_axis_dir.y;
10237       vector->z = mtext->x_axis_dir.z;
10238     }
10239   else
10240     {
10241       *error = 1;
10242       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10243     }
10244 }
10245 
10246 /** Sets the _dwg_entity_MTEXT::rect_height, no DXF
10247  */
10248 void
dwg_ent_mtext_set_rect_height(dwg_ent_mtext * restrict mtext,const double rect_height,int * restrict error)10249 dwg_ent_mtext_set_rect_height (dwg_ent_mtext *restrict mtext,
10250                                const double rect_height, int *restrict error)
10251 {
10252   if (mtext)
10253     {
10254       *error = 0;
10255       mtext->rect_height = rect_height;
10256     }
10257   else
10258     {
10259       *error = 1;
10260       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10261     }
10262 }
10263 
10264 /** Returns the _dwg_entity_MTEXT::rect_height, no DXF
10265  */
10266 double
dwg_ent_mtext_get_rect_height(const dwg_ent_mtext * restrict mtext,int * restrict error)10267 dwg_ent_mtext_get_rect_height (const dwg_ent_mtext *restrict mtext,
10268                                int *restrict error)
10269 {
10270   if (mtext)
10271     {
10272       *error = 0;
10273       return mtext->rect_height;
10274     }
10275   else
10276     {
10277       *error = 1;
10278       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10279       return bit_nan ();
10280     }
10281 }
10282 
10283 /** Sets the _dwg_entity_MTEXT::rect_width, DXF 41.
10284  */
10285 void
dwg_ent_mtext_set_rect_width(dwg_ent_mtext * restrict mtext,const double rect_width,int * restrict error)10286 dwg_ent_mtext_set_rect_width (dwg_ent_mtext *restrict mtext,
10287                               const double rect_width, int *restrict error)
10288 {
10289   if (mtext)
10290     {
10291       *error = 0;
10292       mtext->rect_width = rect_width;
10293     }
10294   else
10295     {
10296       *error = 1;
10297       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10298     }
10299 }
10300 
10301 /** Returns the _dwg_entity_MTEXT::rect_width, DXF 41.
10302  */
10303 double
dwg_ent_mtext_get_rect_width(const dwg_ent_mtext * restrict mtext,int * restrict error)10304 dwg_ent_mtext_get_rect_width (const dwg_ent_mtext *restrict mtext,
10305                               int *restrict error)
10306 {
10307   if (mtext)
10308     {
10309       *error = 0;
10310       return mtext->rect_width;
10311     }
10312   else
10313     {
10314       *error = 1;
10315       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10316       return bit_nan ();
10317     }
10318 }
10319 
10320 /** Sets the _dwg_entity_MTEXT::text_height, DXF 40.
10321  */
10322 void
dwg_ent_mtext_set_text_height(dwg_ent_mtext * restrict mtext,const double text_height,int * restrict error)10323 dwg_ent_mtext_set_text_height (dwg_ent_mtext *restrict mtext,
10324                                const double text_height, int *restrict error)
10325 {
10326   if (mtext)
10327     {
10328       *error = 0;
10329       mtext->text_height = text_height;
10330     }
10331   else
10332     {
10333       *error = 1;
10334       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10335     }
10336 }
10337 
10338 /** Returns the _dwg_entity_MTEXT::text_height, DXF 40.
10339  */
10340 double
dwg_ent_mtext_get_text_height(const dwg_ent_mtext * restrict mtext,int * restrict error)10341 dwg_ent_mtext_get_text_height (const dwg_ent_mtext *restrict mtext,
10342                                int *restrict error)
10343 {
10344   if (mtext)
10345     {
10346       *error = 0;
10347       return mtext->text_height;
10348     }
10349   else
10350     {
10351       *error = 1;
10352       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10353       return bit_nan ();
10354     }
10355 }
10356 
10357 /** Returns the _dwg_entity_MTEXT::attachment flag, DXF 71.
10358  */
10359 BITCODE_BS
dwg_ent_mtext_get_attachment(const dwg_ent_mtext * restrict mtext,int * restrict error)10360 dwg_ent_mtext_get_attachment (const dwg_ent_mtext *restrict mtext,
10361                               int *restrict error)
10362 {
10363   if (mtext)
10364     {
10365       *error = 0;
10366       return mtext->attachment;
10367     }
10368   else
10369     {
10370       *error = 1;
10371       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10372       return 0;
10373     }
10374 }
10375 
10376 /** Sets the _dwg_entity_MTEXT::attachment flag, DXF 71.
10377  */
10378 void
dwg_ent_mtext_set_attachment(dwg_ent_mtext * restrict mtext,const BITCODE_BS attachment,int * restrict error)10379 dwg_ent_mtext_set_attachment (dwg_ent_mtext *restrict mtext,
10380                               const BITCODE_BS attachment, int *restrict error)
10381 {
10382   if (mtext && attachment < 10)
10383     {
10384       *error = 0;
10385       mtext->attachment = attachment;
10386     }
10387   else
10388     {
10389       *error = 1;
10390       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
10391     }
10392 }
10393 
10394 /** Returns the _dwg_entity_MTEXT::flow_dir flag, DXF 72.
10395  */
10396 BITCODE_BS
dwg_ent_mtext_get_drawing_dir(const dwg_ent_mtext * restrict mtext,int * restrict error)10397 dwg_ent_mtext_get_drawing_dir (const dwg_ent_mtext *restrict mtext,
10398                                int *restrict error)
10399 {
10400   if (mtext)
10401     {
10402       *error = 0;
10403       return mtext->flow_dir;
10404     }
10405   else
10406     {
10407       *error = 1;
10408       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10409       return 0;
10410     }
10411 }
10412 
10413 /** Sets the _dwg_entity_MTEXT::flow_dir flag, DXF 72.
10414  */
10415 void
dwg_ent_mtext_set_drawing_dir(dwg_ent_mtext * restrict mtext,const BITCODE_BS dir,int * restrict error)10416 dwg_ent_mtext_set_drawing_dir (dwg_ent_mtext *restrict mtext,
10417                                const BITCODE_BS dir, int *restrict error)
10418 {
10419   if (mtext && dir < 6)
10420     {
10421       *error = 0;
10422       mtext->flow_dir = dir;
10423     }
10424   else
10425     {
10426       *error = 1;
10427       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
10428     }
10429 }
10430 
10431 /** Returns the _dwg_entity_MTEXT::extents_height, DXF 42.
10432  */
10433 double
dwg_ent_mtext_get_extents_height(const dwg_ent_mtext * restrict mtext,int * restrict error)10434 dwg_ent_mtext_get_extents_height (const dwg_ent_mtext *restrict mtext,
10435                                   int *restrict error)
10436 {
10437   if (mtext)
10438     {
10439       *error = 0;
10440       return mtext->extents_height;
10441     }
10442   else
10443     {
10444       *error = 1;
10445       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10446       return bit_nan ();
10447     }
10448 }
10449 
10450 /** Sets the _dwg_entity_MTEXT::extents_height, DXF 42.
10451  */
10452 void
dwg_ent_mtext_set_extents_height(dwg_ent_mtext * restrict mtext,const double height,int * restrict error)10453 dwg_ent_mtext_set_extents_height (dwg_ent_mtext *restrict mtext,
10454                                   const double height, int *restrict error)
10455 {
10456   if (mtext)
10457     {
10458       *error = 0;
10459       mtext->extents_height = height;
10460     }
10461   else
10462     {
10463       *error = 1;
10464       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10465     }
10466 }
10467 
10468 /** Returns the _dwg_entity_MTEXT::extents_width, DXF 43.
10469  */
10470 double
dwg_ent_mtext_get_extents_width(const dwg_ent_mtext * restrict mtext,int * restrict error)10471 dwg_ent_mtext_get_extents_width (const dwg_ent_mtext *restrict mtext,
10472                                  int *restrict error)
10473 {
10474   if (mtext)
10475     {
10476       *error = 0;
10477       return mtext->extents_width;
10478     }
10479   else
10480     {
10481       *error = 1;
10482       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10483       return bit_nan ();
10484     }
10485 }
10486 
10487 /** Sets the _dwg_entity_MTEXT::extents_width, DXF 43.
10488  */
10489 void
dwg_ent_mtext_set_extents_width(dwg_ent_mtext * restrict mtext,const double wid,int * restrict error)10490 dwg_ent_mtext_set_extents_width (dwg_ent_mtext *restrict mtext,
10491                                  const double wid, int *restrict error)
10492 {
10493   if (mtext)
10494     {
10495       *error = 0;
10496       mtext->extents_width = wid;
10497     }
10498   else
10499     {
10500       *error = 1;
10501       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10502     }
10503 }
10504 
10505 /** Returns mtext text value (utf-8 encoded)
10506  */
10507 char *
dwg_ent_mtext_get_text(const dwg_ent_mtext * restrict ent,int * restrict error)10508 dwg_ent_mtext_get_text (const dwg_ent_mtext *restrict ent, int *restrict error)
10509 {
10510   if (ent)
10511     {
10512       *error = 0;
10513       if (dwg_version >= R_2007)
10514         return bit_convert_TU ((BITCODE_TU)ent->text); // a copy
10515       else
10516         return ent->text; // the ref
10517     }
10518   else
10519     {
10520       *error = 1;
10521       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10522       return NULL;
10523     }
10524 }
10525 
10526 /** Sets mtext text value (utf-8 encoded)
10527  */
10528 void
dwg_ent_mtext_set_text(dwg_ent_mtext * restrict ent,char * text,int * restrict error)10529 dwg_ent_mtext_set_text (dwg_ent_mtext *restrict ent, char *text,
10530                         int *restrict error)
10531 {
10532   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
10533   if (ent && !error)
10534     {
10535       ent->text = dwg_add_u8_input (dwg, text);
10536     }
10537   else
10538     {
10539       *error = 1;
10540       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10541     }
10542 }
10543 
10544 /** Returns mtext linespace style
10545  */
10546 BITCODE_BS
dwg_ent_mtext_get_linespace_style(const dwg_ent_mtext * restrict mtext,int * restrict error)10547 dwg_ent_mtext_get_linespace_style (const dwg_ent_mtext *restrict mtext,
10548                                    int *restrict error)
10549 {
10550   if (mtext)
10551     {
10552       *error = 0;
10553       return mtext->linespace_style;
10554     }
10555   else
10556     {
10557       *error = 1;
10558       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10559       return 0;
10560     }
10561 }
10562 
10563 /** Sets mtext linespace style
10564  */
10565 void
dwg_ent_mtext_set_linespace_style(dwg_ent_mtext * restrict mtext,BITCODE_BS style,int * restrict error)10566 dwg_ent_mtext_set_linespace_style (dwg_ent_mtext *restrict mtext,
10567                                    BITCODE_BS style, int *restrict error)
10568 {
10569   if (mtext)
10570     {
10571       *error = 0;
10572       mtext->linespace_style = style;
10573     }
10574   else
10575     {
10576       *error = 1;
10577       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10578     }
10579 }
10580 
10581 /** Returns mtext linespace factor
10582  */
10583 double
dwg_ent_mtext_get_linespace_factor(const dwg_ent_mtext * restrict mtext,int * restrict error)10584 dwg_ent_mtext_get_linespace_factor (const dwg_ent_mtext *restrict mtext,
10585                                     int *restrict error)
10586 {
10587   if (mtext)
10588     {
10589       *error = 0;
10590       return mtext->linespace_factor;
10591     }
10592   else
10593     {
10594       *error = 1;
10595       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10596       return bit_nan ();
10597     }
10598 }
10599 
10600 /** Sets mtext linespace factor
10601  */
10602 void
dwg_ent_mtext_set_linespace_factor(dwg_ent_mtext * restrict mtext,const double factor,int * restrict error)10603 dwg_ent_mtext_set_linespace_factor (dwg_ent_mtext *restrict mtext,
10604                                     const double factor, int *restrict error)
10605 {
10606   if (mtext)
10607     {
10608       *error = 0;
10609       mtext->linespace_factor = factor;
10610     }
10611   else
10612     {
10613       *error = 1;
10614       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10615     }
10616 }
10617 
10618 /*******************************************************************
10619  *                   FUNCTIONS FOR LEADER ENTITY                     *
10620  ********************************************************************/
10621 
10622 /** Sets leader annot type
10623  */
10624 void
dwg_ent_leader_set_annot_type(dwg_ent_leader * restrict leader,const BITCODE_BS type,int * restrict error)10625 dwg_ent_leader_set_annot_type (dwg_ent_leader *restrict leader,
10626                                const BITCODE_BS type, int *restrict error)
10627 {
10628   if (leader)
10629     {
10630       *error = 0;
10631       leader->annot_type = type;
10632     }
10633   else
10634     {
10635       *error = 1;
10636       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10637     }
10638 }
10639 
10640 /** Returns leader annot type
10641  */
10642 BITCODE_BS
dwg_ent_leader_get_annot_type(const dwg_ent_leader * restrict leader,int * restrict error)10643 dwg_ent_leader_get_annot_type (const dwg_ent_leader *restrict leader,
10644                                int *restrict error)
10645 {
10646   if (leader)
10647     {
10648       *error = 0;
10649       return leader->annot_type;
10650     }
10651   else
10652     {
10653       *error = 1;
10654       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10655       return 0;
10656     }
10657 }
10658 
10659 /** Sets leader path type
10660  */
10661 void
dwg_ent_leader_set_path_type(dwg_ent_leader * restrict leader,const BITCODE_BS type,int * restrict error)10662 dwg_ent_leader_set_path_type (dwg_ent_leader *restrict leader,
10663                               const BITCODE_BS type, int *restrict error)
10664 {
10665   if (leader)
10666     {
10667       *error = 0;
10668       leader->path_type = type;
10669     }
10670   else
10671     {
10672       *error = 1;
10673       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10674     }
10675 }
10676 
10677 /** Returns leader path type
10678  */
10679 BITCODE_BS
dwg_ent_leader_get_path_type(const dwg_ent_leader * restrict leader,int * restrict error)10680 dwg_ent_leader_get_path_type (const dwg_ent_leader *restrict leader,
10681                               int *restrict error)
10682 {
10683   if (leader)
10684     {
10685       *error = 0;
10686       return leader->path_type;
10687     }
10688   else
10689     {
10690       *error = 1;
10691       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10692       return 0;
10693     }
10694 }
10695 
10696 /** Returns leader num_points
10697  */
10698 BITCODE_BL
dwg_ent_leader_get_num_points(const dwg_ent_leader * restrict leader,int * restrict error)10699 dwg_ent_leader_get_num_points (const dwg_ent_leader *restrict leader,
10700                                int *restrict error)
10701 {
10702   if (leader)
10703     {
10704       *error = 0;
10705       return leader->num_points;
10706     }
10707   else
10708     {
10709       *error = 1;
10710       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10711       return 0L;
10712     }
10713 }
10714 
10715 // TODO: dwg_ent_leader_add_point, dwg_ent_leader_delete_pts
10716 
10717 /** Sets leader end point proj
10718  */
10719 void
dwg_ent_leader_set_origin(dwg_ent_leader * restrict leader,const dwg_point_3d * restrict point,int * restrict error)10720 dwg_ent_leader_set_origin (dwg_ent_leader *restrict leader,
10721                            const dwg_point_3d *restrict point,
10722                            int *restrict error)
10723 {
10724   if (leader
10725 #  ifndef HAVE_NONNULL
10726       && point
10727 #  endif
10728   )
10729     {
10730       *error = 0;
10731       leader->origin.x = point->x;
10732       leader->origin.y = point->y;
10733       leader->origin.z = point->z;
10734     }
10735   else
10736     {
10737       *error = 1;
10738       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10739     }
10740 }
10741 
10742 /** Returns leader origin
10743  */
10744 void
dwg_ent_leader_get_origin(const dwg_ent_leader * restrict leader,dwg_point_3d * restrict point,int * restrict error)10745 dwg_ent_leader_get_origin (const dwg_ent_leader *restrict leader,
10746                            dwg_point_3d *restrict point, int *restrict error)
10747 {
10748   if (leader
10749 #  ifndef HAVE_NONNULL
10750       && point
10751 #  endif
10752   )
10753     {
10754       *error = 0;
10755       point->x = leader->origin.x;
10756       point->y = leader->origin.y;
10757       point->z = leader->origin.z;
10758     }
10759   else
10760     {
10761       *error = 1;
10762       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10763     }
10764 }
10765 
10766 /** Sets leader extrusion value
10767  */
10768 void
dwg_ent_leader_set_extrusion(dwg_ent_leader * restrict leader,const dwg_point_3d * restrict point,int * restrict error)10769 dwg_ent_leader_set_extrusion (dwg_ent_leader *restrict leader,
10770                               const dwg_point_3d *restrict point,
10771                               int *restrict error)
10772 {
10773   if (leader
10774 #  ifndef HAVE_NONNULL
10775       && point
10776 #  endif
10777   )
10778     {
10779       *error = 0;
10780       leader->extrusion.x = point->x;
10781       leader->extrusion.y = point->y;
10782       leader->extrusion.z = point->z;
10783     }
10784   else
10785     {
10786       *error = 1;
10787       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10788     }
10789 }
10790 
10791 /** Returns leader extrusion value
10792  */
10793 void
dwg_ent_leader_get_extrusion(const dwg_ent_leader * restrict leader,dwg_point_3d * restrict point,int * restrict error)10794 dwg_ent_leader_get_extrusion (const dwg_ent_leader *restrict leader,
10795                               dwg_point_3d *restrict point,
10796                               int *restrict error)
10797 {
10798   if (leader
10799 #  ifndef HAVE_NONNULL
10800       && point
10801 #  endif
10802   )
10803     {
10804       *error = 0;
10805       point->x = leader->extrusion.x;
10806       point->y = leader->extrusion.y;
10807       point->z = leader->extrusion.z;
10808     }
10809   else
10810     {
10811       *error = 1;
10812       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10813     }
10814 }
10815 
10816 /** Sets leader x direction value
10817  */
10818 void
dwg_ent_leader_set_x_direction(dwg_ent_leader * restrict leader,const dwg_point_3d * restrict point,int * restrict error)10819 dwg_ent_leader_set_x_direction (dwg_ent_leader *restrict leader,
10820                                 const dwg_point_3d *restrict point,
10821                                 int *restrict error)
10822 {
10823   if (leader
10824 #  ifndef HAVE_NONNULL
10825       && point
10826 #  endif
10827   )
10828     {
10829       *error = 0;
10830       leader->x_direction.x = point->x;
10831       leader->x_direction.y = point->y;
10832       leader->x_direction.z = point->z;
10833     }
10834   else
10835     {
10836       *error = 1;
10837       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10838     }
10839 }
10840 
10841 /** Returns leader x direction value
10842  */
10843 void
dwg_ent_leader_get_x_direction(const dwg_ent_leader * restrict leader,dwg_point_3d * restrict point,int * restrict error)10844 dwg_ent_leader_get_x_direction (const dwg_ent_leader *restrict leader,
10845                                 dwg_point_3d *restrict point,
10846                                 int *restrict error)
10847 {
10848   if (leader
10849 #  ifndef HAVE_NONNULL
10850       && point
10851 #  endif
10852   )
10853     {
10854       *error = 0;
10855       point->x = leader->x_direction.x;
10856       point->y = leader->x_direction.y;
10857       point->z = leader->x_direction.z;
10858     }
10859   else
10860     {
10861       *error = 1;
10862       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10863     }
10864 }
10865 
10866 /** Sets leader offset to block insert point
10867  */
10868 void
dwg_ent_leader_set_inspt_offset(dwg_ent_leader * restrict leader,const dwg_point_3d * restrict point,int * restrict error)10869 dwg_ent_leader_set_inspt_offset (dwg_ent_leader *restrict leader,
10870                                            const dwg_point_3d *restrict point,
10871                                            int *restrict error)
10872 {
10873   if (leader
10874 #  ifndef HAVE_NONNULL
10875       && point
10876 #  endif
10877   )
10878     {
10879       *error = 0;
10880       leader->inspt_offset.x = point->x;
10881       leader->inspt_offset.y = point->y;
10882       leader->inspt_offset.z = point->z;
10883     }
10884   else
10885     {
10886       *error = 1;
10887       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10888     }
10889 }
10890 
10891 /** Returns leader offset to block ins point
10892  */
10893 void
dwg_ent_leader_get_inspt_offset(const dwg_ent_leader * restrict leader,dwg_point_3d * restrict point,int * restrict error)10894 dwg_ent_leader_get_inspt_offset (
10895     const dwg_ent_leader *restrict leader, dwg_point_3d *restrict point,
10896     int *restrict error)
10897 {
10898   if (leader
10899 #  ifndef HAVE_NONNULL
10900       && point
10901 #  endif
10902   )
10903     {
10904       *error = 0;
10905       point->x = leader->inspt_offset.x;
10906       point->y = leader->inspt_offset.y;
10907       point->z = leader->inspt_offset.z;
10908     }
10909   else
10910     {
10911       *error = 1;
10912       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10913     }
10914 }
10915 
10916 /** Sets leader dimgap
10917  */
10918 void
dwg_ent_leader_set_dimgap(dwg_ent_leader * restrict leader,const double dimgap,int * restrict error)10919 dwg_ent_leader_set_dimgap (dwg_ent_leader *restrict leader,
10920                            const double dimgap, int *restrict error)
10921 {
10922   if (leader)
10923     {
10924       *error = 0;
10925       leader->dimgap = dimgap;
10926     }
10927   else
10928     {
10929       *error = 1;
10930       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10931     }
10932 }
10933 
10934 /** Returns leader dimgap
10935  */
10936 double
dwg_ent_leader_get_dimgap(const dwg_ent_leader * restrict leader,int * restrict error)10937 dwg_ent_leader_get_dimgap (const dwg_ent_leader *restrict leader,
10938                            int *restrict error)
10939 {
10940   if (leader)
10941     {
10942       *error = 0;
10943       return leader->dimgap;
10944     }
10945   else
10946     {
10947       *error = 1;
10948       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10949       return bit_nan ();
10950     }
10951 }
10952 
10953 /** Sets leader box height
10954  */
10955 void
dwg_ent_leader_set_box_height(dwg_ent_leader * restrict leader,const double height,int * restrict error)10956 dwg_ent_leader_set_box_height (dwg_ent_leader *restrict leader,
10957                                const double height, int *restrict error)
10958 {
10959   if (leader)
10960     {
10961       *error = 0;
10962       leader->box_height = height;
10963     }
10964   else
10965     {
10966       *error = 1;
10967       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10968     }
10969 }
10970 
10971 /** Returns leader box height
10972  */
10973 double
dwg_ent_leader_get_box_height(const dwg_ent_leader * restrict leader,int * restrict error)10974 dwg_ent_leader_get_box_height (const dwg_ent_leader *restrict leader,
10975                                int *restrict error)
10976 {
10977   if (leader)
10978     {
10979       *error = 0;
10980       return leader->box_height;
10981     }
10982   else
10983     {
10984       *error = 1;
10985       LOG_ERROR ("%s: empty arg", __FUNCTION__)
10986       return bit_nan ();
10987     }
10988 }
10989 
10990 /** Sets leader box width
10991  */
10992 void
dwg_ent_leader_set_box_width(dwg_ent_leader * restrict leader,const double width,int * restrict error)10993 dwg_ent_leader_set_box_width (dwg_ent_leader *restrict leader,
10994                               const double width, int *restrict error)
10995 {
10996   if (leader)
10997     {
10998       *error = 0;
10999       leader->box_width = width;
11000     }
11001   else
11002     {
11003       *error = 1;
11004       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11005     }
11006 }
11007 
11008 /** Returns leader box width
11009  */
11010 double
dwg_ent_leader_get_box_width(const dwg_ent_leader * restrict leader,int * restrict error)11011 dwg_ent_leader_get_box_width (const dwg_ent_leader *restrict leader,
11012                               int *restrict error)
11013 {
11014   if (leader)
11015     {
11016       *error = 0;
11017       return leader->box_width;
11018     }
11019   else
11020     {
11021       *error = 1;
11022       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11023       return bit_nan ();
11024     }
11025 }
11026 
11027 /** Sets leader hookline_dir value
11028  */
11029 void
dwg_ent_leader_set_hookline_dir(dwg_ent_leader * restrict leader,char dir,int * restrict error)11030 dwg_ent_leader_set_hookline_dir (dwg_ent_leader *restrict leader, char dir,
11031                                  int *restrict error)
11032 {
11033   if (leader)
11034     {
11035       *error = 0;
11036       leader->hookline_dir = dir;
11037     }
11038   else
11039     {
11040       *error = 1;
11041       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11042     }
11043 }
11044 
11045 /** Returns leader hook line on x dir value
11046  */
11047 char
dwg_ent_leader_get_hookline_dir(const dwg_ent_leader * restrict leader,int * restrict error)11048 dwg_ent_leader_get_hookline_dir (const dwg_ent_leader *restrict leader,
11049                                  int *restrict error)
11050 {
11051   if (leader)
11052     {
11053       *error = 0;
11054       return leader->hookline_dir;
11055     }
11056   else
11057     {
11058       *error = 1;
11059       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11060       return '\0';
11061     }
11062 }
11063 
11064 /** Sets leader arrowhead on
11065  */
11066 void
dwg_ent_leader_set_arrowhead_on(dwg_ent_leader * restrict leader,const char arrow,int * restrict error)11067 dwg_ent_leader_set_arrowhead_on (dwg_ent_leader *restrict leader,
11068                                  const char arrow, int *restrict error)
11069 {
11070   if (leader)
11071     {
11072       *error = 0;
11073       leader->arrowhead_on = arrow;
11074     }
11075   else
11076     {
11077       *error = 1;
11078       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11079     }
11080 }
11081 
11082 /** Returns leader arrow head on
11083  */
11084 char
dwg_ent_leader_get_arrowhead_on(const dwg_ent_leader * restrict leader,int * restrict error)11085 dwg_ent_leader_get_arrowhead_on (const dwg_ent_leader *restrict leader,
11086                                  int *restrict error)
11087 {
11088   if (leader)
11089     {
11090       *error = 0;
11091       return leader->arrowhead_on;
11092     }
11093   else
11094     {
11095       *error = 1;
11096       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11097       return '\0';
11098     }
11099 }
11100 
11101 /** Sets leader arrow head type
11102  */
11103 void
dwg_ent_leader_set_arrowhead_type(dwg_ent_leader * restrict leader,const BITCODE_BS type,int * restrict error)11104 dwg_ent_leader_set_arrowhead_type (dwg_ent_leader *restrict leader,
11105                                    const BITCODE_BS type, int *restrict error)
11106 {
11107   if (leader)
11108     {
11109       leader->arrowhead_type = type;
11110       *error = 0;
11111     }
11112   else
11113     {
11114       *error = 1;
11115       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11116     }
11117 }
11118 
11119 /** Returns leader arrowhead type
11120  */
11121 BITCODE_BS
dwg_ent_leader_get_arrowhead_type(const dwg_ent_leader * restrict leader,int * restrict error)11122 dwg_ent_leader_get_arrowhead_type (const dwg_ent_leader *restrict leader,
11123                                    int *restrict error)
11124 {
11125   if (leader)
11126     {
11127       *error = 0;
11128       return leader->arrowhead_type;
11129     }
11130   else
11131     {
11132       *error = 1;
11133       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11134       return 0;
11135     }
11136 }
11137 
11138 /** Sets leader dimasz
11139  */
11140 void
dwg_ent_leader_set_dimasz(dwg_ent_leader * restrict leader,const double dimasz,int * restrict error)11141 dwg_ent_leader_set_dimasz (dwg_ent_leader *restrict leader,
11142                            const double dimasz, int *restrict error)
11143 {
11144   if (leader)
11145     {
11146       *error = 0;
11147       leader->dimasz = dimasz;
11148     }
11149   else
11150     {
11151       *error = 1;
11152       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11153     }
11154 }
11155 
11156 /** Returns leader dimasz
11157  */
11158 double
dwg_ent_leader_get_dimasz(const dwg_ent_leader * restrict leader,int * restrict error)11159 dwg_ent_leader_get_dimasz (const dwg_ent_leader *restrict leader,
11160                            int *restrict error)
11161 {
11162   if (leader)
11163     {
11164       *error = 0;
11165       return leader->dimasz;
11166     }
11167   else
11168     {
11169       *error = 1;
11170       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11171       return bit_nan ();
11172     }
11173 }
11174 
11175 /** Sets leader byblock color
11176  */
11177 void
dwg_ent_leader_set_byblock_color(dwg_ent_leader * restrict leader,const BITCODE_BS color,int * restrict error)11178 dwg_ent_leader_set_byblock_color (dwg_ent_leader *restrict leader,
11179                                   const BITCODE_BS color, int *restrict error)
11180 {
11181   if (leader)
11182     {
11183       *error = 0;
11184       leader->byblock_color = color;
11185     }
11186   else
11187     {
11188       *error = 1;
11189       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11190     }
11191 }
11192 
11193 /** Returns leader byblock color
11194  */
11195 BITCODE_BS
dwg_ent_leader_get_byblock_color(const dwg_ent_leader * restrict leader,int * restrict error)11196 dwg_ent_leader_get_byblock_color (const dwg_ent_leader *restrict leader,
11197                                   int *restrict error)
11198 {
11199   if (leader)
11200     {
11201       *error = 0;
11202       return leader->byblock_color;
11203     }
11204   else
11205     {
11206       *error = 1;
11207       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11208       return 0;
11209     }
11210 }
11211 
11212 /*******************************************************************
11213  *                  FUNCTIONS FOR TOLERANCE ENTITY                   *
11214  ********************************************************************/
11215 
11216 /** Sets tolerance height
11217  */
11218 void
dwg_ent_tolerance_set_height(dwg_ent_tolerance * restrict tol,const double height,int * restrict error)11219 dwg_ent_tolerance_set_height (dwg_ent_tolerance *restrict tol,
11220                               const double height, int *restrict error)
11221 {
11222   if (tol)
11223     {
11224       *error = 0;
11225       tol->height = height;
11226     }
11227   else
11228     {
11229       *error = 1;
11230       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11231     }
11232 }
11233 
11234 /** Returns tolerance height
11235  */
11236 double
dwg_ent_tolerance_get_height(const dwg_ent_tolerance * restrict tol,int * restrict error)11237 dwg_ent_tolerance_get_height (const dwg_ent_tolerance *restrict tol,
11238                               int *restrict error)
11239 {
11240   if (tol)
11241     {
11242       *error = 0;
11243       return tol->height;
11244     }
11245   else
11246     {
11247       *error = 1;
11248       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11249       return bit_nan ();
11250     }
11251 }
11252 
11253 /** Sets tolerance dimgap
11254  */
11255 void
dwg_ent_tolerance_set_dimgap(dwg_ent_tolerance * restrict tol,const double dimgap,int * restrict error)11256 dwg_ent_tolerance_set_dimgap (dwg_ent_tolerance *restrict tol,
11257                               const double dimgap, int *restrict error)
11258 {
11259   if (tol)
11260     {
11261       *error = 0;
11262       tol->dimgap = dimgap;
11263     }
11264   else
11265     {
11266       *error = 1;
11267       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11268     }
11269 }
11270 
11271 /** Returns tolerance dimgap
11272  */
11273 double
dwg_ent_tolerance_get_dimgap(const dwg_ent_tolerance * restrict tol,int * restrict error)11274 dwg_ent_tolerance_get_dimgap (const dwg_ent_tolerance *restrict tol,
11275                               int *restrict error)
11276 {
11277   if (tol)
11278     {
11279       *error = 0;
11280       return tol->dimgap;
11281     }
11282   else
11283     {
11284       *error = 1;
11285       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11286       return bit_nan ();
11287     }
11288 }
11289 
11290 /** Sets tolerance insertion point
11291  */
11292 void
dwg_ent_tolerance_set_ins_pt(dwg_ent_tolerance * restrict tol,const dwg_point_3d * restrict point,int * restrict error)11293 dwg_ent_tolerance_set_ins_pt (dwg_ent_tolerance *restrict tol,
11294                               const dwg_point_3d *restrict point,
11295                               int *restrict error)
11296 {
11297   if (tol
11298 #  ifndef HAVE_NONNULL
11299       && point
11300 #  endif
11301   )
11302     {
11303       *error = 0;
11304       tol->ins_pt.x = point->x;
11305       tol->ins_pt.y = point->y;
11306       tol->ins_pt.z = point->z;
11307     }
11308   else
11309     {
11310       *error = 1;
11311       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11312     }
11313 }
11314 
11315 /** Returns tolerance insertion point
11316  */
11317 void
dwg_ent_tolerance_get_ins_pt(const dwg_ent_tolerance * restrict tol,dwg_point_3d * restrict point,int * restrict error)11318 dwg_ent_tolerance_get_ins_pt (const dwg_ent_tolerance *restrict tol,
11319                               dwg_point_3d *restrict point,
11320                               int *restrict error)
11321 {
11322   if (tol
11323 #  ifndef HAVE_NONNULL
11324       && point
11325 #  endif
11326   )
11327     {
11328       *error = 0;
11329       point->x = tol->ins_pt.x;
11330       point->y = tol->ins_pt.y;
11331       point->z = tol->ins_pt.z;
11332     }
11333   else
11334     {
11335       *error = 1;
11336       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11337     }
11338 }
11339 
11340 /** Sets tolerance x direction
11341  */
11342 void
dwg_ent_tolerance_set_x_direction(dwg_ent_tolerance * restrict tol,const dwg_point_3d * restrict point,int * restrict error)11343 dwg_ent_tolerance_set_x_direction (dwg_ent_tolerance *restrict tol,
11344                                    const dwg_point_3d *restrict point,
11345                                    int *restrict error)
11346 {
11347   if (tol
11348 #  ifndef HAVE_NONNULL
11349       && point
11350 #  endif
11351   )
11352     {
11353       *error = 0;
11354       tol->x_direction.x = point->x;
11355       tol->x_direction.y = point->y;
11356       tol->x_direction.z = point->z;
11357     }
11358   else
11359     {
11360       *error = 1;
11361       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11362     }
11363 }
11364 
11365 /** Returns tolerance x direction
11366  */
11367 void
dwg_ent_tolerance_get_x_direction(const dwg_ent_tolerance * restrict tol,dwg_point_3d * restrict point,int * restrict error)11368 dwg_ent_tolerance_get_x_direction (const dwg_ent_tolerance *restrict tol,
11369                                    dwg_point_3d *restrict point,
11370                                    int *restrict error)
11371 {
11372   if (tol
11373 #  ifndef HAVE_NONNULL
11374       && point
11375 #  endif
11376   )
11377     {
11378       *error = 0;
11379       point->x = tol->x_direction.x;
11380       point->y = tol->x_direction.y;
11381       point->z = tol->x_direction.z;
11382     }
11383   else
11384     {
11385       *error = 1;
11386       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11387     }
11388 }
11389 
11390 /** Sets tolerance extrusion
11391  */
11392 void
dwg_ent_tolerance_set_extrusion(dwg_ent_tolerance * restrict tol,const dwg_point_3d * restrict point,int * restrict error)11393 dwg_ent_tolerance_set_extrusion (dwg_ent_tolerance *restrict tol,
11394                                  const dwg_point_3d *restrict point,
11395                                  int *restrict error)
11396 {
11397   if (tol
11398 #  ifndef HAVE_NONNULL
11399       && point
11400 #  endif
11401   )
11402     {
11403       *error = 0;
11404       tol->extrusion.x = point->x;
11405       tol->extrusion.y = point->y;
11406       tol->extrusion.z = point->z;
11407     }
11408   else
11409     {
11410       *error = 1;
11411       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11412     }
11413 }
11414 
11415 /** Returns tolerance extrusion
11416  */
11417 void
dwg_ent_tolerance_get_extrusion(const dwg_ent_tolerance * restrict tol,dwg_point_3d * restrict point,int * restrict error)11418 dwg_ent_tolerance_get_extrusion (const dwg_ent_tolerance *restrict tol,
11419                                  dwg_point_3d *restrict point,
11420                                  int *restrict error)
11421 {
11422   if (tol
11423 #  ifndef HAVE_NONNULL
11424       && point
11425 #  endif
11426   )
11427     {
11428       *error = 0;
11429       point->x = tol->extrusion.x;
11430       point->y = tol->extrusion.y;
11431       point->z = tol->extrusion.z;
11432     }
11433   else
11434     {
11435       *error = 1;
11436       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11437     }
11438 }
11439 
11440 /** Sets tolerance text string (utf-8 encoded)
11441  */
11442 void
dwg_ent_tolerance_set_text_string(dwg_ent_tolerance * restrict tol,const char * restrict string,int * restrict error)11443 dwg_ent_tolerance_set_text_string (dwg_ent_tolerance *restrict tol,
11444                                    const char *restrict string,
11445                                    int *restrict error)
11446 {
11447   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
11448   if (ent && !error)
11449     {
11450       ent->text_value = dwg_add_u8_input (dwg, string);
11451     }
11452   else
11453     {
11454       *error = 1;
11455       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11456     }
11457 }
11458 
11459 /** Returns tolerance text string (utf-8 encoded)
11460  */
11461 char *
dwg_ent_tolerance_get_text_string(const dwg_ent_tolerance * restrict tol,int * restrict error)11462 dwg_ent_tolerance_get_text_string (const dwg_ent_tolerance *restrict tol,
11463                                    int *restrict error)
11464 {
11465   if (tol)
11466     {
11467       *error = 0;
11468       if (dwg_version >= R_2007)
11469         return bit_convert_TU ((BITCODE_TU)tol->text_value);
11470       else
11471         return tol->text_value;
11472     }
11473   else
11474     {
11475       *error = 1;
11476       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11477       return NULL;
11478     }
11479 }
11480 
11481 /*******************************************************************
11482  *                   FUNCTIONS FOR LWPOLYLINE ENTITY                    *
11483  ********************************************************************/
11484 /** Returns lwpline flags
11485  */
11486 BITCODE_BS
dwg_ent_lwpline_get_flag(const dwg_ent_lwpline * restrict lwpline,int * restrict error)11487 dwg_ent_lwpline_get_flag (const dwg_ent_lwpline *restrict lwpline,
11488                           int *restrict error)
11489 {
11490   if (lwpline)
11491     {
11492       *error = 0;
11493       return lwpline->flag;
11494     }
11495   else
11496     {
11497       *error = 1;
11498       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11499       return '\0';
11500     }
11501 }
11502 
11503 /** Sets lwpline flags
11504  */
11505 void
dwg_ent_lwpline_set_flag(dwg_ent_lwpline * restrict lwpline,char flags,int * restrict error)11506 dwg_ent_lwpline_set_flag (dwg_ent_lwpline *restrict lwpline, char flags,
11507                           int *restrict error)
11508 {
11509   if (lwpline)
11510     {
11511       *error = 0;
11512       lwpline->flag = flags;
11513     }
11514   else
11515     {
11516       *error = 1;
11517       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11518     }
11519 }
11520 
11521 /** Returns lwpline const width
11522  */
11523 double
dwg_ent_lwpline_get_const_width(const dwg_ent_lwpline * restrict lwpline,int * restrict error)11524 dwg_ent_lwpline_get_const_width (const dwg_ent_lwpline *restrict lwpline,
11525                                  int *restrict error)
11526 {
11527   if (lwpline)
11528     {
11529       *error = 0;
11530       return lwpline->const_width;
11531     }
11532   else
11533     {
11534       *error = 1;
11535       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11536       return bit_nan ();
11537     }
11538 }
11539 
11540 /** Sets lwpline const width
11541  */
11542 void
dwg_ent_lwpline_set_const_width(dwg_ent_lwpline * restrict lwpline,const double const_width,int * restrict error)11543 dwg_ent_lwpline_set_const_width (dwg_ent_lwpline *restrict lwpline,
11544                                  const double const_width, int *restrict error)
11545 {
11546   if (lwpline)
11547     {
11548       *error = 0;
11549       lwpline->const_width = const_width;
11550     }
11551   else
11552     {
11553       *error = 1;
11554       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11555     }
11556 }
11557 /** Returns lwpline elevation
11558  */
11559 double
dwg_ent_lwpline_get_elevation(const dwg_ent_lwpline * restrict lwpline,int * restrict error)11560 dwg_ent_lwpline_get_elevation (const dwg_ent_lwpline *restrict lwpline,
11561                                int *restrict error)
11562 {
11563   if (lwpline)
11564     {
11565       *error = 0;
11566       return lwpline->elevation;
11567     }
11568   else
11569     {
11570       *error = 1;
11571       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11572       return bit_nan ();
11573     }
11574 }
11575 
11576 /** Sets lwpline elevation
11577  */
11578 void
dwg_ent_lwpline_set_elevation(dwg_ent_lwpline * restrict lwpline,const double elevation,int * restrict error)11579 dwg_ent_lwpline_set_elevation (dwg_ent_lwpline *restrict lwpline,
11580                                const double elevation, int *restrict error)
11581 {
11582   if (lwpline)
11583     {
11584       *error = 0;
11585       lwpline->elevation = elevation;
11586     }
11587   else
11588     {
11589       *error = 1;
11590       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11591     }
11592 }
11593 /** Returns lwpline thickness
11594  */
11595 double
dwg_ent_lwpline_get_thickness(const dwg_ent_lwpline * restrict lwpline,int * restrict error)11596 dwg_ent_lwpline_get_thickness (const dwg_ent_lwpline *restrict lwpline,
11597                                int *restrict error)
11598 {
11599   if (lwpline)
11600     {
11601       *error = 0;
11602       return lwpline->thickness;
11603     }
11604   else
11605     {
11606       *error = 1;
11607       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11608       return bit_nan ();
11609     }
11610 }
11611 
11612 /** Sets lwpline thickness
11613  */
11614 void
dwg_ent_lwpline_set_thickness(dwg_ent_lwpline * restrict lwpline,const double thickness,int * restrict error)11615 dwg_ent_lwpline_set_thickness (dwg_ent_lwpline *restrict lwpline,
11616                                const double thickness, int *restrict error)
11617 {
11618   if (lwpline)
11619     {
11620       *error = 0;
11621       lwpline->thickness = thickness;
11622     }
11623   else
11624     {
11625       *error = 1;
11626       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11627     }
11628 }
11629 
11630 /** Returns lwpline bulges count
11631  */
11632 BITCODE_BL
dwg_ent_lwpline_get_numbulges(const dwg_ent_lwpline * restrict lwpline,int * restrict error)11633 dwg_ent_lwpline_get_numbulges (const dwg_ent_lwpline *restrict lwpline,
11634                                int *restrict error)
11635 {
11636   if (lwpline)
11637     {
11638       *error = 0;
11639       return lwpline->num_bulges;
11640     }
11641   else
11642     {
11643       *error = 1;
11644       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11645       return 0L;
11646     }
11647 }
11648 
11649 /** Returns lwpline width count
11650  */
11651 BITCODE_BL
dwg_ent_lwpline_get_numwidths(const dwg_ent_lwpline * restrict lwpline,int * restrict error)11652 dwg_ent_lwpline_get_numwidths (const dwg_ent_lwpline *restrict lwpline,
11653                                int *restrict error)
11654 {
11655   if (lwpline)
11656     {
11657       *error = 0;
11658       return lwpline->num_widths;
11659     }
11660   else
11661     {
11662       *error = 1;
11663       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11664       return 0L;
11665     }
11666 }
11667 
11668 /** Returns lwpline normal
11669  */
11670 void
dwg_ent_lwpline_get_extrusion(const dwg_ent_lwpline * restrict lwpline,dwg_point_3d * restrict point,int * restrict error)11671 dwg_ent_lwpline_get_extrusion (const dwg_ent_lwpline *restrict lwpline,
11672                                dwg_point_3d *restrict point,
11673                                int *restrict error)
11674 {
11675   if (lwpline
11676 #  ifndef HAVE_NONNULL
11677       && point
11678 #  endif
11679   )
11680     {
11681       *error = 0;
11682       point->x = lwpline->extrusion.x;
11683       point->y = lwpline->extrusion.y;
11684       point->z = lwpline->extrusion.z;
11685     }
11686   else
11687     {
11688       *error = 1;
11689       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11690     }
11691 }
11692 
11693 /** Sets lwpline normal
11694  */
11695 void
dwg_ent_lwpline_set_extrusion(dwg_ent_lwpline * restrict lwpline,const dwg_point_3d * restrict point,int * restrict error)11696 dwg_ent_lwpline_set_extrusion (dwg_ent_lwpline *restrict lwpline,
11697                                const dwg_point_3d *restrict point,
11698                                int *restrict error)
11699 {
11700   if (lwpline
11701 #  ifndef HAVE_NONNULL
11702       && point
11703 #  endif
11704   )
11705     {
11706       *error = 0;
11707       lwpline->extrusion.x = point->x;
11708       lwpline->extrusion.y = point->y;
11709       lwpline->extrusion.z = point->z;
11710     }
11711   else
11712     {
11713       *error = 1;
11714       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11715     }
11716 }
11717 
11718 /*******************************************************************
11719  *                  FUNCTIONS FOR OLE2FRAME ENTITY                   *
11720  ********************************************************************/
11721 
11722 /** Returns ole2frame type: 1: Link, 2: Embedded, 3: Static
11723  */
11724 BITCODE_BS
dwg_ent_ole2frame_get_type(const dwg_ent_ole2frame * restrict frame,int * restrict error)11725 dwg_ent_ole2frame_get_type (const dwg_ent_ole2frame *restrict frame,
11726                             int *restrict error)
11727 {
11728   if (frame)
11729     {
11730       *error = 0;
11731       return frame->type;
11732     }
11733   else
11734     {
11735       *error = 1;
11736       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11737       return (BITCODE_BS)-1;
11738     }
11739 }
11740 
11741 /** Sets ole2frame type. 1, 2 or 3
11742  */
11743 void
dwg_ent_ole2frame_set_type(dwg_ent_ole2frame * restrict frame,const BITCODE_BS type,int * restrict error)11744 dwg_ent_ole2frame_set_type (dwg_ent_ole2frame *restrict frame,
11745                             const BITCODE_BS type, int *restrict error)
11746 {
11747   if (frame && type >= 1 && type <= 3)
11748     {
11749       *error = 0;
11750       frame->type = type;
11751     }
11752   else
11753     {
11754       *error = 1;
11755       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
11756     }
11757 }
11758 
11759 /** Returns ole2frame mode, 0 or 1
11760  */
11761 BITCODE_BS
dwg_ent_ole2frame_get_mode(const dwg_ent_ole2frame * restrict frame,int * restrict error)11762 dwg_ent_ole2frame_get_mode (const dwg_ent_ole2frame *restrict frame,
11763                             int *restrict error)
11764 {
11765   if (frame)
11766     {
11767       *error = 0;
11768       return frame->mode;
11769     }
11770   else
11771     {
11772       *error = 1;
11773       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11774       return (BITCODE_BS)-1;
11775     }
11776 }
11777 
11778 /// set ole2frame mode
11779 void
dwg_ent_ole2frame_set_mode(dwg_ent_ole2frame * restrict frame,const BITCODE_BS mode,int * restrict error)11780 dwg_ent_ole2frame_set_mode (dwg_ent_ole2frame *restrict frame,
11781                             const BITCODE_BS mode, int *restrict error)
11782 {
11783   // assert: mode is unsigned
11784   if (frame && mode <= 1)
11785     {
11786       *error = 0;
11787       frame->mode = mode;
11788     }
11789   else
11790     {
11791       *error = 1;
11792       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
11793     }
11794 }
11795 
11796 /** Returns ole2frame data length
11797  */
11798 BITCODE_BL
dwg_ent_ole2frame_get_data_size(const dwg_ent_ole2frame * restrict frame,int * restrict error)11799 dwg_ent_ole2frame_get_data_size (const dwg_ent_ole2frame *restrict frame,
11800                                  int *restrict error)
11801 {
11802   if (frame)
11803     {
11804       *error = 0;
11805       return frame->data_size;
11806     }
11807   else
11808     {
11809       *error = 1;
11810       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11811       return 0L;
11812     }
11813 }
11814 
11815 /** Returns ole2frame data (binary)
11816  */
11817 BITCODE_TF
dwg_ent_ole2frame_get_data(const dwg_ent_ole2frame * restrict frame,int * restrict error)11818 dwg_ent_ole2frame_get_data (const dwg_ent_ole2frame *restrict frame,
11819                             int *restrict error)
11820 {
11821   if (frame)
11822     {
11823       *error = 0;
11824       return frame->data;
11825     }
11826   else
11827     {
11828       *error = 1;
11829       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11830       return NULL;
11831     }
11832 }
11833 
11834 /** Sets ole2frame data
11835  */
11836 void
dwg_ent_ole2frame_set_data(dwg_ent_ole2frame * restrict frame,const BITCODE_TF restrict data,const BITCODE_BL data_size,int * restrict error)11837 dwg_ent_ole2frame_set_data (dwg_ent_ole2frame *restrict frame,
11838                             const BITCODE_TF restrict data,
11839                             const BITCODE_BL data_size, int *restrict error)
11840 {
11841   if (frame)
11842     {
11843       *error = 0;
11844       frame->data = data;
11845       frame->data_size = data_size;
11846     }
11847   else
11848     {
11849       *error = 1;
11850       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11851     }
11852 }
11853 
11854 /********************************************************************
11855  *                  FUNCTIONS FOR PROXY OBJECT                       *
11856  ********************************************************************/
11857 
11858 BITCODE_BL
dwg_obj_proxy_get_class_id(const dwg_obj_proxy * restrict proxy,int * restrict error)11859 dwg_obj_proxy_get_class_id (const dwg_obj_proxy *restrict proxy,
11860                             int *restrict error)
11861 {
11862   if (proxy)
11863     {
11864       *error = 0;
11865       return proxy->class_id;
11866     }
11867   else
11868     {
11869       *error = 1;
11870       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11871       return 0L;
11872     }
11873 }
11874 
11875 void
dwg_obj_proxy_set_class_id(dwg_obj_proxy * restrict proxy,const BITCODE_BL class_id,int * restrict error)11876 dwg_obj_proxy_set_class_id (dwg_obj_proxy *restrict proxy,
11877                             const BITCODE_BL class_id, int *restrict error)
11878 {
11879   if (proxy)
11880     {
11881       *error = 0;
11882       proxy->class_id = class_id;
11883     }
11884   else
11885     {
11886       *error = 1;
11887       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11888     }
11889 }
11890 
11891 BITCODE_BL
dwg_obj_proxy_get_version(const dwg_obj_proxy * restrict proxy,int * restrict error)11892 dwg_obj_proxy_get_version (const dwg_obj_proxy *restrict proxy,
11893                            int *restrict error)
11894 {
11895   if (proxy)
11896     {
11897       *error = 0;
11898       return proxy->version;
11899     }
11900   else
11901     {
11902       *error = 1;
11903       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11904       return 0L;
11905     }
11906 }
11907 
11908 void
dwg_obj_proxy_set_version(dwg_obj_proxy * restrict proxy,const BITCODE_BL version,int * restrict error)11909 dwg_obj_proxy_set_version (dwg_obj_proxy *restrict proxy,
11910                            const BITCODE_BL version, int *restrict error)
11911 {
11912   if (proxy)
11913     {
11914       *error = 0;
11915       proxy->version = version;
11916     }
11917   else
11918     {
11919       *error = 1;
11920       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11921     }
11922 }
11923 
11924 BITCODE_B
dwg_obj_proxy_get_from_dxf(const dwg_obj_proxy * restrict proxy,int * restrict error)11925 dwg_obj_proxy_get_from_dxf (const dwg_obj_proxy *restrict proxy,
11926                             int *restrict error)
11927 {
11928   if (proxy)
11929     {
11930       *error = 0;
11931       return proxy->from_dxf;
11932     }
11933   else
11934     {
11935       *error = 1;
11936       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11937       return 0L;
11938     }
11939 }
11940 
11941 void
dwg_obj_proxy_set_from_dxf(dwg_obj_proxy * restrict proxy,const BITCODE_B from_dxf,int * restrict error)11942 dwg_obj_proxy_set_from_dxf (dwg_obj_proxy *restrict proxy,
11943                             const BITCODE_B from_dxf, int *restrict error)
11944 {
11945   if (proxy)
11946     {
11947       *error = 0;
11948       proxy->from_dxf = from_dxf;
11949     }
11950   else
11951     {
11952       *error = 1;
11953       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11954     }
11955 }
11956 
11957 BITCODE_RC *
dwg_obj_proxy_get_data(const dwg_obj_proxy * restrict proxy,int * restrict error)11958 dwg_obj_proxy_get_data (const dwg_obj_proxy *restrict proxy,
11959                         int *restrict error)
11960 {
11961   if (proxy)
11962     {
11963       *error = 0;
11964       return proxy->data;
11965     }
11966   else
11967     {
11968       *error = 1;
11969       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11970       return NULL;
11971     }
11972 }
11973 
11974 void
dwg_obj_proxy_set_data(dwg_obj_proxy * restrict proxy,const BITCODE_RC * restrict data,int * restrict error)11975 dwg_obj_proxy_set_data (dwg_obj_proxy *restrict proxy,
11976                         const BITCODE_RC *restrict data, int *restrict error)
11977 {
11978   if (proxy)
11979     {
11980       *error = 0;
11981       proxy->data = (BITCODE_RC*)data;
11982     }
11983   else
11984     {
11985       *error = 1;
11986       LOG_ERROR ("%s: empty arg", __FUNCTION__)
11987     }
11988 }
11989 
11990 dwg_object_ref **
dwg_obj_proxy_get_objids(const dwg_obj_proxy * restrict proxy,int * restrict error)11991 dwg_obj_proxy_get_objids (const dwg_obj_proxy *restrict proxy,
11992                           int *restrict error)
11993 {
11994   if (proxy)
11995     {
11996       *error = 0;
11997       return proxy->objids;
11998     }
11999   else
12000     {
12001       *error = 1;
12002       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12003       return NULL;
12004     }
12005 }
12006 
12007 /********************************************************************
12008  *                  FUNCTIONS FOR XRECORD OBJECT                       *
12009  ********************************************************************/
12010 
12011 BITCODE_BL
dwg_obj_xrecord_get_xdata_size(const dwg_obj_xrecord * restrict xrecord,int * restrict error)12012 dwg_obj_xrecord_get_xdata_size (const dwg_obj_xrecord *restrict xrecord,
12013                                 int *restrict error)
12014 {
12015   if (xrecord)
12016     {
12017       *error = 0;
12018       return xrecord->xdata_size;
12019     }
12020   else
12021     {
12022       *error = 1;
12023       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12024       return 0L;
12025     }
12026 }
12027 
12028 BITCODE_BS
dwg_obj_xrecord_get_cloning_flags(const dwg_obj_xrecord * restrict xrecord,int * restrict error)12029 dwg_obj_xrecord_get_cloning_flags (const dwg_obj_xrecord *restrict xrecord,
12030                                    int *restrict error)
12031 {
12032   if (xrecord)
12033     {
12034       *error = 0;
12035       return xrecord->cloning;
12036     }
12037   else
12038     {
12039       *error = 1;
12040       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12041       return 0L;
12042     }
12043 }
12044 
12045 void
dwg_obj_xrecord_set_cloning_flags(dwg_obj_xrecord * restrict xrecord,const BITCODE_BS cloning_flags,int * restrict error)12046 dwg_obj_xrecord_set_cloning_flags (dwg_obj_xrecord *restrict xrecord,
12047                                    const BITCODE_BS cloning_flags,
12048                                    int *restrict error)
12049 {
12050   if (xrecord)
12051     {
12052       *error = 0;
12053       xrecord->cloning = cloning_flags;
12054     }
12055   else
12056     {
12057       *error = 1;
12058       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12059     }
12060 }
12061 
12062 BITCODE_BL
dwg_obj_xrecord_get_num_xdata(const dwg_obj_xrecord * restrict xrecord,int * restrict error)12063 dwg_obj_xrecord_get_num_xdata (const dwg_obj_xrecord *restrict xrecord,
12064                                int *restrict error)
12065 {
12066   if (xrecord)
12067     {
12068       *error = 0;
12069       return xrecord->num_xdata;
12070     }
12071   else
12072     {
12073       *error = 1;
12074       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12075       return 0U;
12076     }
12077 }
12078 
12079 Dwg_Resbuf *
dwg_obj_xrecord_get_xdata(const dwg_obj_xrecord * restrict xrecord,int * restrict error)12080 dwg_obj_xrecord_get_xdata (const dwg_obj_xrecord *restrict xrecord,
12081                            int *restrict error)
12082 {
12083   if (xrecord)
12084     {
12085       *error = 0;
12086       return xrecord->xdata;
12087     }
12088   else
12089     {
12090       *error = 1;
12091       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12092       return NULL;
12093     }
12094 }
12095 
12096 void
dwg_obj_xrecord_set_xdata(dwg_obj_xrecord * restrict xrecord,const Dwg_Resbuf * xdata,int * restrict error)12097 dwg_obj_xrecord_set_xdata (dwg_obj_xrecord *restrict xrecord,
12098                            const Dwg_Resbuf *xdata, int *restrict error)
12099 {
12100   if (xrecord)
12101     {
12102       *error = 0;
12103       xrecord->xdata = (Dwg_Resbuf *)xdata;
12104     }
12105   else
12106     {
12107       *error = 1;
12108       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12109     }
12110 }
12111 
12112 BITCODE_BL
dwg_obj_xrecord_get_num_objid_handles(const dwg_obj_xrecord * restrict xrecord,int * restrict error)12113 dwg_obj_xrecord_get_num_objid_handles (const dwg_obj_xrecord *restrict xrecord,
12114                                        int *restrict error)
12115 {
12116   if (xrecord)
12117     {
12118       *error = 0;
12119       return xrecord->num_objid_handles;
12120     }
12121   else
12122     {
12123       *error = 1;
12124       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12125       return 0;
12126     }
12127 }
12128 
12129 dwg_object_ref **
dwg_obj_xrecord_get_objid_handles(const dwg_obj_xrecord * restrict xrecord,int * restrict error)12130 dwg_obj_xrecord_get_objid_handles (const dwg_obj_xrecord *restrict xrecord,
12131                                    int *restrict error)
12132 {
12133   if (xrecord)
12134     {
12135       *error = 0;
12136       return xrecord->objid_handles;
12137     }
12138   else
12139     {
12140       *error = 1;
12141       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12142       return NULL;
12143     }
12144 }
12145 
12146 /*******************************************************************
12147  *                   FUNCTIONS FOR SPLINE ENTITY                     *
12148  ********************************************************************/
12149 
12150 /** Returns spline scenario
12151  */
12152 BITCODE_BS
dwg_ent_spline_get_scenario(const dwg_ent_spline * restrict spline,int * restrict error)12153 dwg_ent_spline_get_scenario (const dwg_ent_spline *restrict spline,
12154                              int *restrict error)
12155 {
12156   if (spline)
12157     {
12158       *error = 0;
12159       return spline->scenario;
12160     }
12161   else
12162     {
12163       *error = 1;
12164       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12165       return 0;
12166     }
12167 }
12168 
12169 /** Sets spline scenario
12170  */
12171 void
dwg_ent_spline_set_scenario(dwg_ent_spline * restrict spline,const BITCODE_BS scenario,int * restrict error)12172 dwg_ent_spline_set_scenario (dwg_ent_spline *restrict spline,
12173                              const BITCODE_BS scenario, int *restrict error)
12174 {
12175   if (spline)
12176     {
12177       *error = 0;
12178       spline->scenario = scenario;
12179     }
12180   else
12181     {
12182       *error = 1;
12183       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12184     }
12185 }
12186 
12187 /** Returns spline degree
12188  */
12189 BITCODE_BS
dwg_ent_spline_get_degree(const dwg_ent_spline * restrict spline,int * restrict error)12190 dwg_ent_spline_get_degree (const dwg_ent_spline *restrict spline,
12191                            int *restrict error)
12192 {
12193   if (spline)
12194     {
12195       *error = 0;
12196       return spline->degree;
12197     }
12198   else
12199     {
12200       *error = 1;
12201       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12202       return 0;
12203     }
12204 }
12205 
12206 /** Sets spline degree
12207  */
12208 void
dwg_ent_spline_set_degree(dwg_ent_spline * restrict spline,const BITCODE_BS degree,int * restrict error)12209 dwg_ent_spline_set_degree (dwg_ent_spline *restrict spline,
12210                            const BITCODE_BS degree, int *restrict error)
12211 {
12212   if (spline)
12213     {
12214       *error = 0;
12215       spline->degree = degree;
12216     }
12217   else
12218     {
12219       *error = 1;
12220       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12221     }
12222 }
12223 
12224 /** Returns spline fit tol
12225  */
12226 double
dwg_ent_spline_get_fit_tol(const dwg_ent_spline * restrict spline,int * restrict error)12227 dwg_ent_spline_get_fit_tol (const dwg_ent_spline *restrict spline,
12228                             int *restrict error)
12229 {
12230   if (spline)
12231     {
12232       *error = 0;
12233       return spline->fit_tol;
12234     }
12235   else
12236     {
12237       *error = 1;
12238       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12239       return bit_nan ();
12240     }
12241 }
12242 
12243 /** Sets spline fit tol
12244  */
12245 void
dwg_ent_spline_set_fit_tol(dwg_ent_spline * restrict spline,int fit_tol,int * restrict error)12246 dwg_ent_spline_set_fit_tol (dwg_ent_spline *restrict spline, int fit_tol,
12247                             int *restrict error)
12248 {
12249   if (spline)
12250     {
12251       *error = 0;
12252       spline->fit_tol = fit_tol;
12253     }
12254   else
12255     {
12256       *error = 1;
12257       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12258     }
12259 }
12260 
12261 /** Returns spline begin tan vector
12262  */
12263 void
dwg_ent_spline_get_begin_tan_vector(const dwg_ent_spline * restrict spline,dwg_point_3d * restrict point,int * restrict error)12264 dwg_ent_spline_get_begin_tan_vector (const dwg_ent_spline *restrict spline,
12265                                      dwg_point_3d *restrict point,
12266                                      int *restrict error)
12267 {
12268   if (spline
12269 #  ifndef HAVE_NONNULL
12270       && point
12271 #  endif
12272   )
12273     {
12274       *error = 0;
12275       point->x = spline->beg_tan_vec.x;
12276       point->y = spline->beg_tan_vec.y;
12277       point->z = spline->beg_tan_vec.z;
12278     }
12279   else
12280     {
12281       *error = 1;
12282       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12283     }
12284 }
12285 
12286 /** Sets spline begin tan vector
12287  */
12288 void
dwg_ent_spline_set_begin_tan_vector(dwg_ent_spline * restrict spline,const dwg_point_3d * restrict point,int * restrict error)12289 dwg_ent_spline_set_begin_tan_vector (dwg_ent_spline *restrict spline,
12290                                      const dwg_point_3d *restrict point,
12291                                      int *restrict error)
12292 {
12293   if (spline
12294 #  ifndef HAVE_NONNULL
12295       && point
12296 #  endif
12297   )
12298     {
12299       *error = 0;
12300       spline->beg_tan_vec.x = point->x;
12301       spline->beg_tan_vec.y = point->y;
12302       spline->beg_tan_vec.z = point->z;
12303     }
12304   else
12305     {
12306       *error = 1;
12307       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12308     }
12309 }
12310 
12311 /** Returns spline end tan vector points
12312  */
12313 void
dwg_ent_spline_get_end_tan_vector(const dwg_ent_spline * restrict spline,dwg_point_3d * restrict point,int * restrict error)12314 dwg_ent_spline_get_end_tan_vector (const dwg_ent_spline *restrict spline,
12315                                    dwg_point_3d *restrict point,
12316                                    int *restrict error)
12317 {
12318   if (spline
12319 #  ifndef HAVE_NONNULL
12320       && point
12321 #  endif
12322   )
12323     {
12324       *error = 0;
12325       point->x = spline->end_tan_vec.x;
12326       point->y = spline->end_tan_vec.y;
12327       point->z = spline->end_tan_vec.z;
12328     }
12329   else
12330     {
12331       *error = 1;
12332       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12333     }
12334 }
12335 
12336 /** Sets spline end tan vector
12337  */
12338 void
dwg_ent_spline_set_end_tan_vector(dwg_ent_spline * restrict spline,const dwg_point_3d * restrict point,int * restrict error)12339 dwg_ent_spline_set_end_tan_vector (dwg_ent_spline *restrict spline,
12340                                    const dwg_point_3d *restrict point,
12341                                    int *restrict error)
12342 {
12343   if (spline
12344 #  ifndef HAVE_NONNULL
12345       && point
12346 #  endif
12347   )
12348     {
12349       *error = 0;
12350       spline->end_tan_vec.x = point->x;
12351       spline->end_tan_vec.y = point->y;
12352       spline->end_tan_vec.z = point->z;
12353     }
12354   else
12355     {
12356       *error = 1;
12357       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12358     }
12359 }
12360 
12361 /** Returns spline knot tol value
12362  */
12363 double
dwg_ent_spline_get_knot_tol(const dwg_ent_spline * restrict spline,int * restrict error)12364 dwg_ent_spline_get_knot_tol (const dwg_ent_spline *restrict spline,
12365                              int *restrict error)
12366 {
12367   if (spline)
12368     {
12369       *error = 0;
12370       return spline->knot_tol;
12371     }
12372   else
12373     {
12374       *error = 1;
12375       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12376       return bit_nan ();
12377     }
12378 }
12379 
12380 /** Sets spline knot tol value
12381  */
12382 void
dwg_ent_spline_set_knot_tol(dwg_ent_spline * restrict spline,const double knot_tol,int * restrict error)12383 dwg_ent_spline_set_knot_tol (dwg_ent_spline *restrict spline,
12384                              const double knot_tol, int *restrict error)
12385 {
12386   if (spline)
12387     {
12388       *error = 0;
12389       spline->knot_tol = knot_tol;
12390     }
12391   else
12392     {
12393       *error = 1;
12394       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12395     }
12396 }
12397 
12398 /** Returns spline control tol value
12399  */
12400 double
dwg_ent_spline_get_ctrl_tol(const dwg_ent_spline * restrict spline,int * restrict error)12401 dwg_ent_spline_get_ctrl_tol (const dwg_ent_spline *restrict spline,
12402                              int *restrict error)
12403 {
12404   if (spline)
12405     {
12406       *error = 0;
12407       return spline->ctrl_tol;
12408     }
12409   else
12410     {
12411       *error = 1;
12412       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12413       return bit_nan ();
12414     }
12415 }
12416 
12417 /** Sets spline control tol
12418  */
12419 void
dwg_ent_spline_set_ctrl_tol(dwg_ent_spline * restrict spline,const double ctrl_tol,int * restrict error)12420 dwg_ent_spline_set_ctrl_tol (dwg_ent_spline *restrict spline,
12421                              const double ctrl_tol, int *restrict error)
12422 {
12423   if (spline)
12424     {
12425       *error = 0;
12426       spline->ctrl_tol = ctrl_tol;
12427     }
12428   else
12429     {
12430       *error = 1;
12431       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12432     }
12433 }
12434 
12435 /** Returns spline  number of fit points
12436  */
12437 BITCODE_BS
dwg_ent_spline_get_num_fit_pts(const dwg_ent_spline * restrict spline,int * restrict error)12438 dwg_ent_spline_get_num_fit_pts (const dwg_ent_spline *restrict spline,
12439                                 int *restrict error)
12440 {
12441   if (spline)
12442     {
12443       *error = 0;
12444       return spline->num_fit_pts;
12445     }
12446   else
12447     {
12448       *error = 1;
12449       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12450       return 0;
12451     }
12452 }
12453 
12454 /** Returns spline rational
12455  */
12456 char
dwg_ent_spline_get_rational(const dwg_ent_spline * restrict spline,int * restrict error)12457 dwg_ent_spline_get_rational (const dwg_ent_spline *restrict spline,
12458                              int *restrict error)
12459 {
12460   if (spline)
12461     {
12462       *error = 0;
12463       return spline->rational;
12464     }
12465   else
12466     {
12467       *error = 1;
12468       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12469       return '\0';
12470     }
12471 }
12472 
12473 /** Sets rational value
12474  */
12475 void
dwg_ent_spline_set_rational(dwg_ent_spline * restrict spline,char rational,int * restrict error)12476 dwg_ent_spline_set_rational (dwg_ent_spline *restrict spline, char rational,
12477                              int *restrict error)
12478 {
12479   if (spline)
12480     {
12481       *error = 0;
12482       spline->rational = rational;
12483     }
12484   else
12485     {
12486       *error = 1;
12487       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12488     }
12489 }
12490 
12491 /** Returns spline closed_b
12492  */
12493 char
dwg_ent_spline_get_closed_b(const dwg_ent_spline * restrict spline,int * restrict error)12494 dwg_ent_spline_get_closed_b (const dwg_ent_spline *restrict spline,
12495                              int *restrict error)
12496 {
12497   if (spline)
12498     {
12499       *error = 0;
12500       return spline->closed_b;
12501     }
12502   else
12503     {
12504       *error = 1;
12505       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12506       return '\0';
12507     }
12508 }
12509 
12510 /** Sets spline closed_b
12511  */
12512 void
dwg_ent_spline_set_closed_b(dwg_ent_spline * restrict spline,char closed_b,int * restrict error)12513 dwg_ent_spline_set_closed_b (dwg_ent_spline *restrict spline, char closed_b,
12514                              int *restrict error)
12515 {
12516   if (spline)
12517     {
12518       *error = 0;
12519       spline->closed_b = closed_b;
12520     }
12521   else
12522     {
12523       *error = 1;
12524       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12525     }
12526 }
12527 
12528 /** Returns spline weighted value
12529  */
12530 char
dwg_ent_spline_get_weighted(const dwg_ent_spline * restrict spline,int * restrict error)12531 dwg_ent_spline_get_weighted (const dwg_ent_spline *restrict spline,
12532                              int *restrict error)
12533 {
12534   if (spline)
12535     {
12536       *error = 0;
12537       return spline->weighted;
12538     }
12539   else
12540     {
12541       *error = 1;
12542       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12543       return '\0';
12544     }
12545 }
12546 
12547 /** Sets spline weighted
12548  */
12549 void
dwg_ent_spline_set_weighted(dwg_ent_spline * restrict spline,char weighted,int * restrict error)12550 dwg_ent_spline_set_weighted (dwg_ent_spline *restrict spline, char weighted,
12551                              int *restrict error)
12552 {
12553   if (spline)
12554     {
12555       *error = 0;
12556       spline->weighted = weighted;
12557     }
12558   else
12559     {
12560       *error = 1;
12561       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12562     }
12563 }
12564 
12565 /** Returns spline periodic
12566  */
12567 char
dwg_ent_spline_get_periodic(const dwg_ent_spline * restrict spline,int * restrict error)12568 dwg_ent_spline_get_periodic (const dwg_ent_spline *restrict spline,
12569                              int *restrict error)
12570 {
12571   if (spline)
12572     {
12573       *error = 0;
12574       return spline->periodic;
12575     }
12576   else
12577     {
12578       *error = 1;
12579       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12580       return '\0';
12581     }
12582 }
12583 
12584 /** Sets spline periodic
12585  */
12586 void
dwg_ent_spline_set_periodic(dwg_ent_spline * restrict spline,char periodic,int * restrict error)12587 dwg_ent_spline_set_periodic (dwg_ent_spline *restrict spline, char periodic,
12588                              int *restrict error)
12589 {
12590   if (spline)
12591     {
12592       *error = 0;
12593       spline->periodic = periodic;
12594     }
12595   else
12596     {
12597       *error = 1;
12598       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12599     }
12600 }
12601 
12602 /** Returns spline knots number
12603  */
12604 BITCODE_BL
dwg_ent_spline_get_num_knots(const dwg_ent_spline * restrict spline,int * restrict error)12605 dwg_ent_spline_get_num_knots (const dwg_ent_spline *restrict spline,
12606                               int *restrict error)
12607 {
12608   if (spline)
12609     {
12610       *error = 0;
12611       return spline->num_knots;
12612     }
12613   else
12614     {
12615       *error = 1;
12616       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12617       return 0L;
12618     }
12619 }
12620 
12621 // TODO: dwg_ent_spline_add_fit_pts, dwg_ent_spline_delete_fit_pts
12622 // TODO: dwg_ent_spline_add_knots, dwg_ent_spline_delete_knots
12623 // TODO: dwg_ent_spline_add_ctrl_pts, dwg_ent_spline_delete_ctrl_pts
12624 
12625 /** Returns spline control points number
12626  */
12627 BITCODE_BL
dwg_ent_spline_get_num_ctrl_pts(const dwg_ent_spline * restrict spline,int * restrict error)12628 dwg_ent_spline_get_num_ctrl_pts (const dwg_ent_spline *restrict spline,
12629                                  int *restrict error)
12630 {
12631   if (spline)
12632     {
12633       *error = 0;
12634       return spline->num_ctrl_pts;
12635     }
12636   else
12637     {
12638       *error = 1;
12639       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12640       return 0L;
12641     }
12642 }
12643 
12644 /// Return all spline fit points
12645 dwg_point_3d*
dwg_ent_spline_get_fit_pts(const dwg_ent_spline * restrict spline,int * restrict error)12646 dwg_ent_spline_get_fit_pts (const dwg_ent_spline *restrict spline,
12647                             int *restrict error)
12648 {
12649   dwg_point_3d *ptx
12650       = (dwg_point_3d *)calloc (spline->num_fit_pts, sizeof (dwg_point_3d));
12651   if (ptx)
12652     {
12653       BITCODE_BS i;
12654       *error = 0;
12655       for (i = 0; i < spline->num_fit_pts; i++)
12656         {
12657           memcpy (&ptx[i], &spline->fit_pts[i], sizeof(dwg_point_3d));
12658         }
12659       return ptx;
12660     }
12661   else
12662     {
12663       *error = 1;
12664       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
12665       return NULL;
12666     }
12667 }
12668 
12669 /** Returns spline control points
12670  */
12671 dwg_spline_control_point *
dwg_ent_spline_get_ctrl_pts(const dwg_ent_spline * restrict spline,int * restrict error)12672 dwg_ent_spline_get_ctrl_pts (const dwg_ent_spline *restrict spline,
12673                              int *restrict error)
12674 {
12675   dwg_spline_control_point *ptx = (dwg_spline_control_point *)calloc (
12676       spline->num_ctrl_pts, sizeof (dwg_spline_control_point));
12677   if (ptx)
12678     {
12679       BITCODE_BL i;
12680       *error = 0;
12681       for (i = 0; i < spline->num_ctrl_pts; i++)
12682         {
12683           ptx[i] = spline->ctrl_pts[i];
12684         }
12685       return ptx;
12686     }
12687   else
12688     {
12689       *error = 1;
12690       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
12691       return NULL;
12692     }
12693 }
12694 
12695 /** Returns spline knots
12696  */
12697 double *
dwg_ent_spline_get_knots(const dwg_ent_spline * restrict spline,int * restrict error)12698 dwg_ent_spline_get_knots (const dwg_ent_spline *restrict spline,
12699                           int *restrict error)
12700 {
12701   double *ptx = (double *)malloc (sizeof (double) * spline->num_knots);
12702   if (ptx)
12703     {
12704       BITCODE_BL i;
12705       *error = 0;
12706       for (i = 0; i < spline->num_knots; i++)
12707         {
12708           ptx[i] = spline->knots[i];
12709         }
12710       return ptx;
12711     }
12712   else
12713     {
12714       *error = 1;
12715       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
12716       return NULL;
12717     }
12718 }
12719 
12720 /*******************************************************************
12721  *                   FUNCTIONS FOR VIEWPORT ENTITY                   *
12722  ********************************************************************/
12723 
12724 /** Returns viewport center points
12725  */
12726 void
dwg_ent_viewport_get_center(const dwg_ent_viewport * restrict vp,dwg_point_3d * restrict point,int * restrict error)12727 dwg_ent_viewport_get_center (const dwg_ent_viewport *restrict vp,
12728                              dwg_point_3d *restrict point, int *restrict error)
12729 {
12730   if (vp
12731 #  ifndef HAVE_NONNULL
12732       && point
12733 #  endif
12734   )
12735     {
12736       *error = 0;
12737       point->x = vp->center.x;
12738       point->y = vp->center.y;
12739       point->z = vp->center.z;
12740     }
12741   else
12742     {
12743       *error = 1;
12744       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12745     }
12746 }
12747 
12748 /** Sets viewport center
12749  */
12750 void
dwg_ent_viewport_set_center(dwg_ent_viewport * restrict vp,const dwg_point_3d * restrict point,int * restrict error)12751 dwg_ent_viewport_set_center (dwg_ent_viewport *restrict vp,
12752                              const dwg_point_3d *restrict point,
12753                              int *restrict error)
12754 {
12755   if (vp
12756 #  ifndef HAVE_NONNULL
12757       && point
12758 #  endif
12759   )
12760     {
12761       *error = 0;
12762       vp->center.x = point->x;
12763       vp->center.y = point->y;
12764       vp->center.z = point->z;
12765     }
12766   else
12767     {
12768       *error = 1;
12769       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12770     }
12771 }
12772 
12773 /** Returns viewport width
12774  */
12775 double
dwg_ent_viewport_get_width(const dwg_ent_viewport * restrict vp,int * restrict error)12776 dwg_ent_viewport_get_width (const dwg_ent_viewport *restrict vp,
12777                             int *restrict error)
12778 {
12779   if (vp)
12780     {
12781       *error = 0;
12782       return vp->width;
12783     }
12784   else
12785     {
12786       *error = 1;
12787       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12788       return bit_nan ();
12789     }
12790 }
12791 
12792 /** Sets viewport width
12793  */
12794 void
dwg_ent_viewport_set_width(dwg_ent_viewport * restrict vp,const double width,int * restrict error)12795 dwg_ent_viewport_set_width (dwg_ent_viewport *restrict vp, const double width,
12796                             int *restrict error)
12797 {
12798   if (vp)
12799     {
12800       *error = 0;
12801       vp->width = width;
12802     }
12803   else
12804     {
12805       *error = 1;
12806       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12807     }
12808 }
12809 
12810 /** Returns viewport height
12811  */
12812 double
dwg_ent_viewport_get_height(const dwg_ent_viewport * restrict vp,int * restrict error)12813 dwg_ent_viewport_get_height (const dwg_ent_viewport *restrict vp,
12814                              int *restrict error)
12815 {
12816   if (vp)
12817     {
12818       *error = 0;
12819       return vp->height;
12820     }
12821   else
12822     {
12823       *error = 1;
12824       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12825       return bit_nan ();
12826     }
12827 }
12828 
12829 /** Sets viewport height
12830  */
12831 void
dwg_ent_viewport_set_height(dwg_ent_viewport * restrict vp,const double height,int * restrict error)12832 dwg_ent_viewport_set_height (dwg_ent_viewport *restrict vp,
12833                              const double height, int *restrict error)
12834 {
12835   if (vp)
12836     {
12837       *error = 0;
12838       vp->height = height;
12839     }
12840   else
12841     {
12842       *error = 1;
12843       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12844     }
12845 }
12846 
12847 /** Returns viewport grid major
12848  */
12849 BITCODE_BS
dwg_ent_viewport_get_grid_major(const dwg_ent_viewport * restrict vp,int * restrict error)12850 dwg_ent_viewport_get_grid_major (const dwg_ent_viewport *restrict vp,
12851                                  int *restrict error)
12852 {
12853   if (vp)
12854     {
12855       *error = 0;
12856       return vp->grid_major;
12857     }
12858   else
12859     {
12860       *error = 1;
12861       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12862       return 0;
12863     }
12864 }
12865 
12866 /** Sets viewport grid major
12867  */
12868 void
dwg_ent_viewport_set_grid_major(dwg_ent_viewport * restrict vp,const BITCODE_BS major,int * restrict error)12869 dwg_ent_viewport_set_grid_major (dwg_ent_viewport *restrict vp,
12870                                  const BITCODE_BS major, int *restrict error)
12871 {
12872   if (vp)
12873     {
12874       *error = 0;
12875       vp->grid_major = major;
12876     }
12877   else
12878     {
12879       *error = 1;
12880       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12881     }
12882 }
12883 
12884 /** Returns viewport frozen layer count
12885  */
12886 BITCODE_BL
dwg_ent_viewport_get_num_frozen_layers(const dwg_ent_viewport * restrict vp,int * restrict error)12887 dwg_ent_viewport_get_num_frozen_layers (const dwg_ent_viewport *restrict vp,
12888                                         int *restrict error)
12889 {
12890   if (vp)
12891     {
12892       *error = 0;
12893       return vp->num_frozen_layers;
12894     }
12895   else
12896     {
12897       *error = 1;
12898       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12899       return 0L;
12900     }
12901 }
12902 
12903 /** Sets viewport frozen layer count (apparently safe to set)
12904  */
12905 void
dwg_ent_viewport_set_num_frozen_layers(dwg_ent_viewport * restrict vp,const BITCODE_BL count,int * restrict error)12906 dwg_ent_viewport_set_num_frozen_layers (dwg_ent_viewport *restrict vp,
12907                                         const BITCODE_BL count,
12908                                         int *restrict error)
12909 {
12910   if (vp)
12911     {
12912       *error = 0;
12913       vp->num_frozen_layers = count;
12914     }
12915   else
12916     {
12917       *error = 1;
12918       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12919     }
12920 }
12921 
12922 /** Returns viewport style sheet name (utf-8 encoded)
12923  */
12924 char *
dwg_ent_viewport_get_style_sheet(const dwg_ent_viewport * restrict vp,int * restrict error)12925 dwg_ent_viewport_get_style_sheet (const dwg_ent_viewport *restrict vp,
12926                                   int *restrict error)
12927 {
12928   if (vp)
12929     {
12930       *error = 0;
12931       if (dwg_version >= R_2007)
12932         return bit_convert_TU ((BITCODE_TU)vp->style_sheet);
12933       else
12934         return vp->style_sheet;
12935     }
12936   else
12937     {
12938       *error = 1;
12939       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12940       return NULL;
12941     }
12942 }
12943 
12944 /** Sets viewport style sheet name (utf-8 encoded)
12945  */
12946 void
dwg_ent_viewport_set_style_sheet(dwg_ent_viewport * restrict ent,char * sheet,int * restrict error)12947 dwg_ent_viewport_set_style_sheet (dwg_ent_viewport *restrict ent, char *sheet,
12948                                   int *restrict error)
12949 {
12950   Dwg_Data *dwg = dwg_obj_generic_dwg (ent, error);
12951   if (ent && !error)
12952     {
12953       ent->style_sheet = dwg_add_u8_input (dwg, sheet);
12954     }
12955   else
12956     {
12957       *error = 1;
12958       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12959     }
12960 }
12961 
12962 /** Sets circle zoom value
12963  */
12964 void
dwg_ent_viewport_set_circle_zoom(dwg_ent_viewport * restrict vp,const BITCODE_BS zoom,int * restrict error)12965 dwg_ent_viewport_set_circle_zoom (dwg_ent_viewport *restrict vp,
12966                                   const BITCODE_BS zoom, int *restrict error)
12967 {
12968   if (vp)
12969     {
12970       *error = 0;
12971       vp->circle_zoom = zoom;
12972     }
12973   else
12974     {
12975       *error = 1;
12976       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12977     }
12978 }
12979 
12980 /** Returns circle zoom value
12981  */
12982 BITCODE_BS
dwg_ent_viewport_get_circle_zoom(const dwg_ent_viewport * restrict vp,int * restrict error)12983 dwg_ent_viewport_get_circle_zoom (const dwg_ent_viewport *restrict vp,
12984                                   int *restrict error)
12985 {
12986   if (vp)
12987     {
12988       *error = 0;
12989       return vp->circle_zoom;
12990     }
12991   else
12992     {
12993       *error = 1;
12994       LOG_ERROR ("%s: empty arg", __FUNCTION__)
12995       return 0;
12996     }
12997 }
12998 
12999 /** Sets viewport status flags
13000  */
13001 void
dwg_ent_viewport_set_status_flag(dwg_ent_viewport * restrict vp,const BITCODE_BL flags,int * restrict error)13002 dwg_ent_viewport_set_status_flag (dwg_ent_viewport *restrict vp,
13003                                   const BITCODE_BL flags, int *restrict error)
13004 {
13005   if (vp)
13006     {
13007       *error = 0;
13008       vp->status_flag = flags;
13009     }
13010   else
13011     {
13012       *error = 1;
13013       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13014     }
13015 }
13016 
13017 /** Returns viewport status flag
13018  */
13019 BITCODE_BL
dwg_ent_viewport_get_status_flag(const dwg_ent_viewport * restrict vp,int * restrict error)13020 dwg_ent_viewport_get_status_flag (const dwg_ent_viewport *restrict vp,
13021                                   int *restrict error)
13022 {
13023   if (vp)
13024     {
13025       *error = 0;
13026       return vp->status_flag;
13027     }
13028   else
13029     {
13030       *error = 1;
13031       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13032       return 0L;
13033     }
13034 }
13035 
13036 /** Returns VIEWPORT.render_mode
13037  */
13038 char
dwg_ent_viewport_get_render_mode(const dwg_ent_viewport * restrict vp,int * restrict error)13039 dwg_ent_viewport_get_render_mode (const dwg_ent_viewport *restrict vp,
13040                                   int *restrict error)
13041 {
13042   if (vp)
13043     {
13044       *error = 0;
13045       return vp->render_mode;
13046     }
13047   else
13048     {
13049       *error = 1;
13050       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13051       return '\0';
13052     }
13053 }
13054 
13055 /** Sets VIEWPORT.render_mode
13056  */
13057 void
dwg_ent_viewport_set_render_mode(dwg_ent_viewport * restrict vp,char mode,int * restrict error)13058 dwg_ent_viewport_set_render_mode (dwg_ent_viewport *restrict vp, char mode,
13059                                   int *restrict error)
13060 {
13061   if (vp)
13062     {
13063       *error = 0;
13064       vp->render_mode = mode;
13065     }
13066   else
13067     {
13068       *error = 1;
13069       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13070     }
13071 }
13072 
13073 /** Sets VIEWPORT.ucs_at_origin
13074  */
13075 void
dwg_ent_viewport_set_ucs_at_origin(dwg_ent_viewport * restrict vp,unsigned char origin,int * restrict error)13076 dwg_ent_viewport_set_ucs_at_origin (dwg_ent_viewport *restrict vp,
13077                                     unsigned char origin, int *restrict error)
13078 {
13079   if (vp)
13080     {
13081       *error = 0;
13082       vp->ucs_at_origin = origin;
13083     }
13084   else
13085     {
13086       *error = 1;
13087       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13088     }
13089 }
13090 
13091 /** Returns VIEWPORT.ucs_at_origin
13092  */
13093 unsigned char
dwg_ent_viewport_get_ucs_at_origin(const dwg_ent_viewport * restrict vp,int * restrict error)13094 dwg_ent_viewport_get_ucs_at_origin (const dwg_ent_viewport *restrict vp,
13095                                     int *restrict error)
13096 {
13097   if (vp)
13098     {
13099       *error = 0;
13100       return vp->ucs_at_origin;
13101     }
13102   else
13103     {
13104       *error = 1;
13105       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13106       return '\0';
13107     }
13108 }
13109 
13110 /** Sets VIEWPORT.UCSVP
13111  */
13112 void
dwg_ent_viewport_set_UCSVP(dwg_ent_viewport * restrict vp,unsigned char ucsvp,int * restrict error)13113 dwg_ent_viewport_set_UCSVP (dwg_ent_viewport *restrict vp,
13114                                        unsigned char ucsvp,
13115                                        int *restrict error)
13116 {
13117   if (vp)
13118     {
13119       *error = 0;
13120       vp->UCSVP = ucsvp;
13121     }
13122   else
13123     {
13124       *error = 1;
13125       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13126     }
13127 }
13128 
13129 /** Returns VIEWPORT.UCSVP
13130  */
13131 unsigned char
dwg_ent_viewport_get_UCSVP(const dwg_ent_viewport * restrict vp,int * restrict error)13132 dwg_ent_viewport_get_UCSVP (const dwg_ent_viewport *restrict vp,
13133                             int *restrict error)
13134 {
13135   if (vp)
13136     {
13137       *error = 0;
13138       return vp->UCSVP;
13139     }
13140   else
13141     {
13142       *error = 1;
13143       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13144       return '\0';
13145     }
13146 }
13147 
13148 /** Sets viewport view target
13149  */
13150 void
dwg_ent_viewport_set_view_target(dwg_ent_viewport * restrict vp,const dwg_point_3d * restrict point,int * restrict error)13151 dwg_ent_viewport_set_view_target (dwg_ent_viewport *restrict vp,
13152                                   const dwg_point_3d *restrict point,
13153                                   int *restrict error)
13154 {
13155   if (vp
13156 #  ifndef HAVE_NONNULL
13157       && point
13158 #  endif
13159   )
13160     {
13161       *error = 0;
13162       vp->view_target.x = point->x;
13163       vp->view_target.y = point->y;
13164       vp->view_target.z = point->z;
13165     }
13166   else
13167     {
13168       *error = 1;
13169       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13170     }
13171 }
13172 
13173 /** Returns viewport view target
13174  */
13175 void
dwg_ent_viewport_get_view_target(const dwg_ent_viewport * restrict vp,dwg_point_3d * restrict point,int * restrict error)13176 dwg_ent_viewport_get_view_target (const dwg_ent_viewport *restrict vp,
13177                                   dwg_point_3d *restrict point,
13178                                   int *restrict error)
13179 {
13180   if (vp
13181 #  ifndef HAVE_NONNULL
13182       && point
13183 #  endif
13184   )
13185     {
13186       *error = 0;
13187       point->x = vp->view_target.x;
13188       point->y = vp->view_target.y;
13189       point->z = vp->view_target.z;
13190     }
13191   else
13192     {
13193       *error = 1;
13194       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13195     }
13196 }
13197 
13198 /** Sets VIEWPORT.VIEWDIR
13199  */
13200 void
dwg_ent_viewport_set_VIEWDIR(dwg_ent_viewport * restrict vp,const dwg_point_3d * restrict point,int * restrict error)13201 dwg_ent_viewport_set_VIEWDIR (dwg_ent_viewport *restrict vp,
13202                               const dwg_point_3d *restrict point,
13203                               int *restrict error)
13204 {
13205   if (vp
13206 #  ifndef HAVE_NONNULL
13207       && point
13208 #  endif
13209   )
13210     {
13211       *error = 0;
13212       vp->VIEWDIR.x = point->x;
13213       vp->VIEWDIR.y = point->y;
13214       vp->VIEWDIR.z = point->z;
13215     }
13216   else
13217     {
13218       *error = 1;
13219       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13220     }
13221 }
13222 
13223 /** Returns viewport view direction
13224  */
13225 void
dwg_ent_viewport_get_VIEWDIR(const dwg_ent_viewport * restrict vp,dwg_point_3d * restrict point,int * restrict error)13226 dwg_ent_viewport_get_VIEWDIR (const dwg_ent_viewport *restrict vp,
13227                               dwg_point_3d *restrict point,
13228                               int *restrict error)
13229 {
13230   if (vp
13231 #  ifndef HAVE_NONNULL
13232       && point
13233 #  endif
13234   )
13235     {
13236       *error = 0;
13237       point->x = vp->VIEWDIR.x;
13238       point->y = vp->VIEWDIR.y;
13239       point->z = vp->VIEWDIR.z;
13240     }
13241   else
13242     {
13243       *error = 1;
13244       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13245     }
13246 }
13247 
13248 /** Sets VIEWPORT.twist_angle
13249  */
13250 void
dwg_ent_viewport_set_twist_angle(dwg_ent_viewport * restrict vp,const double angle,int * restrict error)13251 dwg_ent_viewport_set_twist_angle (dwg_ent_viewport *restrict vp,
13252                                  const double angle, int *restrict error)
13253 {
13254   if (vp)
13255     {
13256       *error = 0;
13257       vp->twist_angle = angle;
13258     }
13259   else
13260     {
13261       *error = 1;
13262       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13263     }
13264 }
13265 
13266 /** Returns VIEWPORT.twist_angle
13267  */
13268 double
dwg_ent_viewport_get_twist_angle(const dwg_ent_viewport * restrict vp,int * restrict error)13269 dwg_ent_viewport_get_twist_angle (const dwg_ent_viewport *restrict vp,
13270                                  int *restrict error)
13271 {
13272   if (vp)
13273     {
13274       *error = 0;
13275       return vp->twist_angle;
13276     }
13277   else
13278     {
13279       *error = 1;
13280       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13281       return bit_nan ();
13282     }
13283 }
13284 
13285 /** Sets VIEWPORT.VIEWSIZE
13286  */
13287 void
dwg_ent_viewport_set_VIEWSIZE(dwg_ent_viewport * restrict vp,const double height,int * restrict error)13288 dwg_ent_viewport_set_VIEWSIZE (dwg_ent_viewport *restrict vp,
13289                                   const double height, int *restrict error)
13290 {
13291   if (vp)
13292     {
13293       *error = 0;
13294       vp->VIEWSIZE = height;
13295     }
13296   else
13297     {
13298       *error = 1;
13299       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13300     }
13301 }
13302 
13303 /** Returns VIEWPORT.VIEWSIZE
13304  */
13305 double
dwg_ent_viewport_get_VIEWSIZE(const dwg_ent_viewport * restrict vp,int * restrict error)13306 dwg_ent_viewport_get_VIEWSIZE (const dwg_ent_viewport *restrict vp,
13307                                int *restrict error)
13308 {
13309   if (vp)
13310     {
13311       *error = 0;
13312       return vp->VIEWSIZE;
13313     }
13314   else
13315     {
13316       *error = 1;
13317       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13318       return bit_nan ();
13319     }
13320 }
13321 
13322 /** Sets viewport lens length
13323  */
13324 void
dwg_ent_viewport_set_lens_length(dwg_ent_viewport * restrict vp,const double length,int * restrict error)13325 dwg_ent_viewport_set_lens_length (dwg_ent_viewport *restrict vp,
13326                                   const double length, int *restrict error)
13327 {
13328   if (vp)
13329     {
13330       *error = 0;
13331       vp->lens_length = length;
13332     }
13333   else
13334     {
13335       *error = 1;
13336       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13337     }
13338 }
13339 
13340 /** Returns lens length
13341  */
13342 double
dwg_ent_viewport_get_lens_length(const dwg_ent_viewport * restrict vp,int * restrict error)13343 dwg_ent_viewport_get_lens_length (const dwg_ent_viewport *restrict vp,
13344                                   int *restrict error)
13345 {
13346   if (vp)
13347     {
13348       *error = 0;
13349       return vp->lens_length;
13350     }
13351   else
13352     {
13353       *error = 1;
13354       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13355       return bit_nan ();
13356     }
13357 }
13358 
13359 /** Sets viewport front clip z value
13360  */
13361 void
dwg_ent_viewport_set_front_clip_z(dwg_ent_viewport * restrict vp,const double front_z,int * restrict error)13362 dwg_ent_viewport_set_front_clip_z (dwg_ent_viewport *restrict vp,
13363                                    const double front_z, int *restrict error)
13364 {
13365   if (vp)
13366     {
13367       *error = 0;
13368       vp->front_clip_z = front_z;
13369     }
13370   else
13371     {
13372       *error = 1;
13373       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13374     }
13375 }
13376 
13377 /** Returns viewport front clip z value
13378  */
13379 double
dwg_ent_viewport_get_front_clip_z(const dwg_ent_viewport * restrict vp,int * restrict error)13380 dwg_ent_viewport_get_front_clip_z (const dwg_ent_viewport *restrict vp,
13381                                    int *restrict error)
13382 {
13383   if (vp)
13384     {
13385       *error = 0;
13386       return vp->front_clip_z;
13387     }
13388   else
13389     {
13390       *error = 1;
13391       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13392       return bit_nan ();
13393     }
13394 }
13395 
13396 /** Sets viewport back clip z value
13397  */
13398 void
dwg_ent_viewport_set_back_clip_z(dwg_ent_viewport * restrict vp,const double back_z,int * restrict error)13399 dwg_ent_viewport_set_back_clip_z (dwg_ent_viewport *restrict vp,
13400                                   const double back_z, int *restrict error)
13401 {
13402   if (vp)
13403     {
13404       *error = 0;
13405       vp->back_clip_z = back_z;
13406     }
13407   else
13408     {
13409       *error = 1;
13410       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13411     }
13412 }
13413 
13414 /** Returns viewport back clip z value
13415  */
13416 double
dwg_ent_viewport_get_back_clip_z(const dwg_ent_viewport * restrict vp,int * restrict error)13417 dwg_ent_viewport_get_back_clip_z (const dwg_ent_viewport *restrict vp,
13418                                   int *restrict error)
13419 {
13420   if (vp)
13421     {
13422       *error = 0;
13423       return vp->back_clip_z;
13424     }
13425   else
13426     {
13427       *error = 1;
13428       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13429       return bit_nan ();
13430     }
13431 }
13432 
13433 /** Sets viewport snap angle
13434  */
13435 void
dwg_ent_viewport_set_SNAPANG(dwg_ent_viewport * restrict vp,const double angle,int * restrict error)13436 dwg_ent_viewport_set_SNAPANG (dwg_ent_viewport *restrict vp,
13437                                  const double angle, int *restrict error)
13438 {
13439   if (vp)
13440     {
13441       *error = 0;
13442       vp->SNAPANG = angle;
13443     }
13444   else
13445     {
13446       *error = 1;
13447       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13448     }
13449 }
13450 
13451 /** Returns viewport snap angle
13452  */
13453 double
dwg_ent_viewport_get_SNAPANG(const dwg_ent_viewport * restrict vp,int * restrict error)13454 dwg_ent_viewport_get_SNAPANG (const dwg_ent_viewport *restrict vp,
13455                                  int *restrict error)
13456 {
13457   if (vp)
13458     {
13459       *error = 0;
13460       return vp->SNAPANG;
13461     }
13462   else
13463     {
13464       *error = 1;
13465       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13466       return bit_nan ();
13467     }
13468 }
13469 
13470 /** Returns viewport view center
13471  */
13472 void
dwg_ent_viewport_get_VIEWCTR(const dwg_ent_viewport * restrict vp,dwg_point_2d * restrict point,int * restrict error)13473 dwg_ent_viewport_get_VIEWCTR (const dwg_ent_viewport *restrict vp,
13474                                   dwg_point_2d *restrict point,
13475                                   int *restrict error)
13476 {
13477   if (vp
13478 #  ifndef HAVE_NONNULL
13479       && point
13480 #  endif
13481   )
13482     {
13483       *error = 0;
13484       point->x = vp->VIEWCTR.x;
13485       point->y = vp->VIEWCTR.y;
13486     }
13487   else
13488     {
13489       *error = 1;
13490       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13491     }
13492 }
13493 
13494 /** Sets viewport view center
13495  */
13496 void
dwg_ent_viewport_set_VIEWCTR(dwg_ent_viewport * restrict vp,const dwg_point_2d * restrict point,int * restrict error)13497 dwg_ent_viewport_set_VIEWCTR (dwg_ent_viewport *restrict vp,
13498                                   const dwg_point_2d *restrict point,
13499                                   int *restrict error)
13500 {
13501   if (vp)
13502     {
13503       *error = 0;
13504       vp->VIEWCTR.x = point->x;
13505       vp->VIEWCTR.y = point->y;
13506     }
13507   else
13508     {
13509       *error = 1;
13510       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13511     }
13512 }
13513 
13514 /** Returns grid spacing
13515  */
13516 void
dwg_ent_viewport_get_GRIDUNIT(const dwg_ent_viewport * restrict vp,dwg_point_2d * restrict point,int * restrict error)13517 dwg_ent_viewport_get_GRIDUNIT (const dwg_ent_viewport *restrict vp,
13518                                    dwg_point_2d *restrict point,
13519                                    int *restrict error)
13520 {
13521   if (vp
13522 #  ifndef HAVE_NONNULL
13523       && point
13524 #  endif
13525   )
13526     {
13527       *error = 0;
13528       point->x = vp->GRIDUNIT.x;
13529       point->y = vp->GRIDUNIT.y;
13530     }
13531   else
13532     {
13533       *error = 1;
13534       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13535     }
13536 }
13537 
13538 /** Sets grid spacing
13539  */
13540 void
dwg_ent_viewport_set_GRIDUNIT(dwg_ent_viewport * restrict vp,const dwg_point_2d * restrict point,int * restrict error)13541 dwg_ent_viewport_set_GRIDUNIT (dwg_ent_viewport *restrict vp,
13542                                    const dwg_point_2d *restrict point,
13543                                    int *restrict error)
13544 {
13545   if (vp
13546 #  ifndef HAVE_NONNULL
13547       && point
13548 #  endif
13549   )
13550     {
13551       *error = 0;
13552       vp->GRIDUNIT.x = point->x;
13553       vp->GRIDUNIT.y = point->y;
13554     }
13555   else
13556     {
13557       *error = 1;
13558       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13559     }
13560 }
13561 
13562 /** Returns viewport snap base
13563  */
13564 void
dwg_ent_viewport_get_SNAPBASE(const dwg_ent_viewport * restrict vp,dwg_point_2d * restrict point,int * restrict error)13565 dwg_ent_viewport_get_SNAPBASE (const dwg_ent_viewport *restrict vp,
13566                                 dwg_point_2d *restrict point,
13567                                 int *restrict error)
13568 {
13569   if (vp
13570 #  ifndef HAVE_NONNULL
13571       && point
13572 #  endif
13573   )
13574     {
13575       *error = 0;
13576       point->x = vp->SNAPBASE.x;
13577       point->y = vp->SNAPBASE.y;
13578     }
13579   else
13580     {
13581       *error = 1;
13582       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13583     }
13584 }
13585 
13586 /** Sets viewport snap base
13587  */
13588 void
dwg_ent_viewport_set_SNAPBASE(dwg_ent_viewport * restrict vp,const dwg_point_2d * restrict point,int * restrict error)13589 dwg_ent_viewport_set_SNAPBASE (dwg_ent_viewport *restrict vp,
13590                                 const dwg_point_2d *restrict point,
13591                                 int *restrict error)
13592 {
13593   if (vp
13594 #  ifndef HAVE_NONNULL
13595       && point
13596 #  endif
13597   )
13598     {
13599       *error = 0;
13600       vp->SNAPBASE.x = point->x;
13601       vp->SNAPBASE.y = point->y;
13602     }
13603   else
13604     {
13605       *error = 1;
13606       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13607     }
13608 }
13609 
13610 /** Returns viewport snap spacing
13611  */
13612 void
dwg_ent_viewport_get_SNAPUNIT(const dwg_ent_viewport * restrict vp,dwg_point_2d * restrict point,int * restrict error)13613 dwg_ent_viewport_get_SNAPUNIT (const dwg_ent_viewport *restrict vp,
13614                                    dwg_point_2d *restrict point,
13615                                    int *restrict error)
13616 {
13617   if (vp
13618 #  ifndef HAVE_NONNULL
13619       && point
13620 #  endif
13621   )
13622     {
13623       *error = 0;
13624       point->x = vp->SNAPUNIT.x;
13625       point->y = vp->SNAPUNIT.y;
13626     }
13627   else
13628     {
13629       *error = 1;
13630       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13631     }
13632 }
13633 
13634 /** Sets viewport snap spacing
13635  */
13636 void
dwg_ent_viewport_set_SNAPUNIT(dwg_ent_viewport * restrict vp,const dwg_point_2d * restrict point,int * restrict error)13637 dwg_ent_viewport_set_SNAPUNIT (dwg_ent_viewport *restrict vp,
13638                                    const dwg_point_2d *restrict point,
13639                                    int *restrict error)
13640 {
13641   if (vp
13642 #  ifndef HAVE_NONNULL
13643       && point
13644 #  endif
13645   )
13646     {
13647       *error = 0;
13648       vp->SNAPUNIT.x = point->x;
13649       vp->SNAPUNIT.y = point->y;
13650     }
13651   else
13652     {
13653       *error = 1;
13654       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13655     }
13656 }
13657 
13658 /** Sets viewport ucs origin
13659  */
13660 void
dwg_ent_viewport_set_ucsorg(dwg_ent_viewport * restrict vp,const dwg_point_3d * restrict point,int * restrict error)13661 dwg_ent_viewport_set_ucsorg (dwg_ent_viewport *restrict vp,
13662                                  const dwg_point_3d *restrict point,
13663                                  int *restrict error)
13664 {
13665   if (vp
13666 #  ifndef HAVE_NONNULL
13667       && point
13668 #  endif
13669   )
13670     {
13671       *error = 0;
13672       vp->ucsorg.x = point->x;
13673       vp->ucsorg.y = point->y;
13674       vp->ucsorg.z = point->z;
13675     }
13676   else
13677     {
13678       *error = 1;
13679       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13680     }
13681 }
13682 
13683 /** Returns viewport ucs origin
13684  */
13685 void
dwg_ent_viewport_get_ucsorg(const dwg_ent_viewport * restrict vp,dwg_point_3d * restrict point,int * restrict error)13686 dwg_ent_viewport_get_ucsorg (const dwg_ent_viewport *restrict vp,
13687                                  dwg_point_3d *restrict point,
13688                                  int *restrict error)
13689 {
13690   if (vp
13691 #  ifndef HAVE_NONNULL
13692       && point
13693 #  endif
13694   )
13695     {
13696       *error = 0;
13697       point->x = vp->ucsorg.x;
13698       point->y = vp->ucsorg.y;
13699       point->z = vp->ucsorg.z;
13700     }
13701   else
13702     {
13703       *error = 1;
13704       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13705     }
13706 }
13707 
13708 /** Sets viewport ucs X axis
13709  */
13710 void
dwg_ent_viewport_set_ucsxdir(dwg_ent_viewport * restrict vp,const dwg_point_3d * restrict point,int * restrict error)13711 dwg_ent_viewport_set_ucsxdir (dwg_ent_viewport *restrict vp,
13712                                  const dwg_point_3d *restrict point,
13713                                  int *restrict error)
13714 {
13715   if (vp
13716 #  ifndef HAVE_NONNULL
13717       && point
13718 #  endif
13719   )
13720     {
13721       *error = 0;
13722       vp->ucsxdir.x = point->x;
13723       vp->ucsxdir.y = point->y;
13724       vp->ucsxdir.z = point->z;
13725     }
13726   else
13727     {
13728       *error = 1;
13729       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13730     }
13731 }
13732 
13733 /** Returns viewport ucs X axis
13734  */
13735 void
dwg_ent_viewport_get_ucsxdir(const dwg_ent_viewport * restrict vp,dwg_point_3d * restrict point,int * restrict error)13736 dwg_ent_viewport_get_ucsxdir (const dwg_ent_viewport *restrict vp,
13737                                  dwg_point_3d *restrict point,
13738                                  int *restrict error)
13739 {
13740   if (vp
13741 #  ifndef HAVE_NONNULL
13742       && point
13743 #  endif
13744   )
13745     {
13746       *error = 0;
13747       point->x = vp->ucsxdir.x;
13748       point->y = vp->ucsxdir.y;
13749       point->z = vp->ucsxdir.z;
13750     }
13751   else
13752     {
13753       *error = 1;
13754       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13755     }
13756 }
13757 
13758 /** Sets viewport ucs y axis
13759  */
13760 void
dwg_ent_viewport_set_ucsydir(dwg_ent_viewport * restrict vp,const dwg_point_3d * restrict point,int * restrict error)13761 dwg_ent_viewport_set_ucsydir (dwg_ent_viewport *restrict vp,
13762                                  const dwg_point_3d *restrict point,
13763                                  int *restrict error)
13764 {
13765   if (vp
13766 #  ifndef HAVE_NONNULL
13767       && point
13768 #  endif
13769   )
13770     {
13771       *error = 0;
13772       vp->ucsydir.x = point->x;
13773       vp->ucsydir.y = point->y;
13774       vp->ucsydir.z = point->z;
13775     }
13776   else
13777     {
13778       *error = 1;
13779       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13780     }
13781 }
13782 
13783 /** Returns viewport ucs y axis
13784  */
13785 void
dwg_ent_viewport_get_ucsydir(const dwg_ent_viewport * restrict vp,dwg_point_3d * restrict point,int * restrict error)13786 dwg_ent_viewport_get_ucsydir (const dwg_ent_viewport *restrict vp,
13787                                  dwg_point_3d *restrict point,
13788                                  int *restrict error)
13789 {
13790   if (vp
13791 #  ifndef HAVE_NONNULL
13792       && point
13793 #  endif
13794   )
13795     {
13796       *error = 0;
13797       point->x = vp->ucsydir.x;
13798       point->y = vp->ucsydir.y;
13799       point->z = vp->ucsydir.z;
13800     }
13801   else
13802     {
13803       *error = 1;
13804       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13805     }
13806 }
13807 
13808 /** Sets viewport ucs elevation
13809  */
13810 void
dwg_ent_viewport_set_ucs_elevation(dwg_ent_viewport * restrict vp,const double elevation,int * restrict error)13811 dwg_ent_viewport_set_ucs_elevation (dwg_ent_viewport *restrict vp,
13812                                     const double elevation,
13813                                     int *restrict error)
13814 {
13815   if (vp)
13816     {
13817       *error = 0;
13818       vp->ucs_elevation = elevation;
13819     }
13820   else
13821     {
13822       *error = 1;
13823       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13824     }
13825 }
13826 
13827 /** Returns ucs elevation
13828  */
13829 double
dwg_ent_viewport_get_ucs_elevation(const dwg_ent_viewport * restrict vp,int * restrict error)13830 dwg_ent_viewport_get_ucs_elevation (const dwg_ent_viewport *restrict vp,
13831                                     int *restrict error)
13832 {
13833   if (vp)
13834     {
13835       *error = 0;
13836       return vp->ucs_elevation;
13837     }
13838   else
13839     {
13840       *error = 1;
13841       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13842       return bit_nan ();
13843     }
13844 }
13845 
13846 /** Sets UCS ortho view type
13847  */
13848 void
dwg_ent_viewport_set_UCSORTHOVIEW(dwg_ent_viewport * restrict vp,const BITCODE_BS type,int * restrict error)13849 dwg_ent_viewport_set_UCSORTHOVIEW (dwg_ent_viewport *restrict vp,
13850                                           const BITCODE_BS type,
13851                                           int *restrict error)
13852 {
13853   if (vp)
13854     {
13855       *error = 0;
13856       vp->UCSORTHOVIEW = type;
13857     }
13858   else
13859     {
13860       *error = 1;
13861       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13862     }
13863 }
13864 
13865 /** Returns UCS ortho view type
13866  */
13867 BITCODE_BS
dwg_ent_viewport_get_UCSORTHOVIEW(const dwg_ent_viewport * restrict vp,int * restrict error)13868 dwg_ent_viewport_get_UCSORTHOVIEW (const dwg_ent_viewport *restrict vp,
13869                                           int *restrict error)
13870 {
13871   if (vp)
13872     {
13873       *error = 0;
13874       return vp->UCSORTHOVIEW;
13875     }
13876   else
13877     {
13878       *error = 1;
13879       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13880       return 0;
13881     }
13882 }
13883 
13884 /** Sets shade plot mode value
13885  */
13886 void
dwg_ent_viewport_set_shadeplot_mode(dwg_ent_viewport * restrict vp,const BITCODE_BS shadeplot,int * restrict error)13887 dwg_ent_viewport_set_shadeplot_mode (dwg_ent_viewport *restrict vp,
13888                                      const BITCODE_BS shadeplot,
13889                                      int *restrict error)
13890 {
13891   if (vp)
13892     {
13893       *error = 0;
13894       vp->shadeplot_mode = shadeplot;
13895     }
13896   else
13897     {
13898       *error = 1;
13899       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13900     }
13901 }
13902 
13903 /** Returns shade plot mode value
13904  */
13905 BITCODE_BS
dwg_ent_viewport_get_shadeplot_mode(const dwg_ent_viewport * restrict vp,int * restrict error)13906 dwg_ent_viewport_get_shadeplot_mode (const dwg_ent_viewport *restrict vp,
13907                                      int *restrict error)
13908 {
13909   if (vp)
13910     {
13911       *error = 0;
13912       return vp->shadeplot_mode;
13913     }
13914   else
13915     {
13916       *error = 1;
13917       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13918       return 0;
13919     }
13920 }
13921 
13922 /** Sets viewport default lightning usage
13923  */
13924 void
dwg_ent_viewport_set_use_default_lights(dwg_ent_viewport * restrict vp,const unsigned char lights,int * restrict error)13925 dwg_ent_viewport_set_use_default_lights (dwg_ent_viewport *restrict vp,
13926                                          const unsigned char lights,
13927                                          int *restrict error)
13928 {
13929   if (vp)
13930     {
13931       *error = 0;
13932       vp->use_default_lights = lights;
13933     }
13934   else
13935     {
13936       *error = 1;
13937       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13938     }
13939 }
13940 
13941 /** Returns viewport default lightning usage
13942  */
13943 unsigned char
dwg_ent_viewport_get_use_default_lights(const dwg_ent_viewport * restrict vp,int * restrict error)13944 dwg_ent_viewport_get_use_default_lights (const dwg_ent_viewport *restrict vp,
13945                                          int *restrict error)
13946 {
13947   if (vp)
13948     {
13949       *error = 0;
13950       return vp->use_default_lights;
13951     }
13952   else
13953     {
13954       *error = 1;
13955       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13956       return '\0';
13957     }
13958 }
13959 
13960 /** Sets viewport default lightning type
13961  */
13962 void
dwg_ent_viewport_set_default_lighting_type(dwg_ent_viewport * restrict vp,const char type,int * restrict error)13963 dwg_ent_viewport_set_default_lighting_type (dwg_ent_viewport *restrict vp,
13964                                             const char type,
13965                                             int *restrict error)
13966 {
13967   if (vp)
13968     {
13969       *error = 0;
13970       vp->default_lighting_type = type;
13971     }
13972   else
13973     {
13974       *error = 1;
13975       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13976     }
13977 }
13978 
13979 /** Returns viewport default lightning type
13980  */
13981 char
dwg_ent_viewport_get_default_lighting_type(const dwg_ent_viewport * restrict vp,int * restrict error)13982 dwg_ent_viewport_get_default_lighting_type (
13983     const dwg_ent_viewport *restrict vp, int *restrict error)
13984 {
13985   if (vp)
13986     {
13987       *error = 0;
13988       return vp->default_lighting_type;
13989     }
13990   else
13991     {
13992       *error = 1;
13993       LOG_ERROR ("%s: empty arg", __FUNCTION__)
13994       return '\0';
13995     }
13996 }
13997 
13998 /** Sets viewport brightness
13999  */
14000 void
dwg_ent_viewport_set_brightness(dwg_ent_viewport * restrict vp,const double brightness,int * restrict error)14001 dwg_ent_viewport_set_brightness (dwg_ent_viewport *restrict vp,
14002                                  const double brightness, int *restrict error)
14003 {
14004   if (vp)
14005     {
14006       *error = 0;
14007       vp->brightness = brightness;
14008     }
14009   else
14010     {
14011       *error = 1;
14012       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14013     }
14014 }
14015 
14016 /** Returns viewport brightness
14017  */
14018 double
dwg_ent_viewport_get_brightness(const dwg_ent_viewport * restrict vp,int * restrict error)14019 dwg_ent_viewport_get_brightness (const dwg_ent_viewport *restrict vp,
14020                                  int *restrict error)
14021 {
14022   if (vp)
14023     {
14024       *error = 0;
14025       return vp->brightness;
14026     }
14027   else
14028     {
14029       *error = 1;
14030       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14031       return bit_nan ();
14032     }
14033 }
14034 
14035 /** Sets viewport contrast
14036  */
14037 void
dwg_ent_viewport_set_contrast(dwg_ent_viewport * restrict vp,const double contrast,int * restrict error)14038 dwg_ent_viewport_set_contrast (dwg_ent_viewport *restrict vp,
14039                                const double contrast, int *restrict error)
14040 {
14041   if (vp)
14042     {
14043       *error = 0;
14044       vp->contrast = contrast;
14045     }
14046   else
14047     {
14048       *error = 1;
14049       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14050     }
14051 }
14052 
14053 /** Returns viewport contrast
14054  */
14055 double
dwg_ent_viewport_get_contrast(const dwg_ent_viewport * restrict vp,int * restrict error)14056 dwg_ent_viewport_get_contrast (const dwg_ent_viewport *restrict vp,
14057                                int *restrict error)
14058 {
14059   if (vp)
14060     {
14061       *error = 0;
14062       return vp->contrast;
14063     }
14064   else
14065     {
14066       *error = 1;
14067       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14068       return bit_nan ();
14069     }
14070 }
14071 
14072 /*******************************************************************
14073  *                FUNCTIONS FOR POLYLINE PFACE ENTITY                *
14074  ********************************************************************/
14075 
14076 /** Returns polyline pface num verts
14077  */
14078 BITCODE_BS
dwg_ent_polyline_pface_get_numpoints(const dwg_ent_polyline_pface * restrict pface,int * restrict error)14079 dwg_ent_polyline_pface_get_numpoints (
14080     const dwg_ent_polyline_pface *restrict pface, int *restrict error)
14081 {
14082   if (pface)
14083     {
14084       *error = 0;
14085       return pface->numverts;
14086     }
14087   else
14088     {
14089       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14090       *error = 1;
14091       return 0;
14092     }
14093 }
14094 
14095 /** Returns polyline pface numfaces
14096  */
14097 BITCODE_BS
dwg_ent_polyline_pface_get_numfaces(const dwg_ent_polyline_pface * restrict pface,int * restrict error)14098 dwg_ent_polyline_pface_get_numfaces (
14099     const dwg_ent_polyline_pface *restrict pface, int *restrict error)
14100 {
14101   if (pface)
14102     {
14103       *error = 0;
14104       return pface->numfaces;
14105     }
14106   else
14107     {
14108       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14109       *error = 1;
14110       return 0;
14111     }
14112 }
14113 
14114 dwg_point_3d *
dwg_ent_polyline_pface_get_points(const dwg_object * restrict obj,int * restrict error)14115 dwg_ent_polyline_pface_get_points (const dwg_object *restrict obj,
14116                                    int *restrict error)
14117 {
14118   if (obj && obj->type == DWG_TYPE_POLYLINE_PFACE)
14119     {
14120       *error = 0;
14121       LOG_ERROR ("%s: nyi", __FUNCTION__);
14122       return NULL; // TODO
14123     }
14124   else
14125     {
14126       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
14127       *error = 1;
14128       return NULL;
14129     }
14130 }
14131 
14132 /*******************************************************************
14133  *                FUNCTIONS FOR POLYLINE_MESH ENTITY                 *
14134  ********************************************************************/
14135 
14136 /** Returns polyline mesh flags
14137  */
14138 BITCODE_BS
dwg_ent_polyline_mesh_get_flag(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14139 dwg_ent_polyline_mesh_get_flag (const dwg_ent_polyline_mesh *restrict mesh,
14140                                 int *restrict error)
14141 {
14142   if (mesh)
14143     {
14144       *error = 0;
14145       return mesh->flag;
14146     }
14147   else
14148     {
14149       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14150       *error = 1;
14151       return 0;
14152     }
14153 }
14154 
14155 /** Sets polyline mesh flags
14156  */
14157 void
dwg_ent_polyline_mesh_set_flag(dwg_ent_polyline_mesh * restrict mesh,const BITCODE_BS flags,int * restrict error)14158 dwg_ent_polyline_mesh_set_flag (dwg_ent_polyline_mesh *restrict mesh,
14159                                 const BITCODE_BS flags, int *restrict error)
14160 {
14161   if (mesh)
14162     {
14163       *error = 0;
14164       mesh->flag = flags;
14165     }
14166   else
14167     {
14168       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14169       *error = 1;
14170     }
14171 }
14172 
14173 /** Returns polyline mesh curve type
14174  */
14175 BITCODE_BS
dwg_ent_polyline_mesh_get_curve_type(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14176 dwg_ent_polyline_mesh_get_curve_type (
14177     const dwg_ent_polyline_mesh *restrict mesh, int *restrict error)
14178 {
14179   if (mesh)
14180     {
14181       *error = 0;
14182       return mesh->curve_type;
14183     }
14184   else
14185     {
14186       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14187       *error = 1;
14188       return 0;
14189     }
14190 }
14191 
14192 /** Sets polyline mesh curve type
14193  */
14194 void
dwg_ent_polyline_mesh_set_curve_type(dwg_ent_polyline_mesh * restrict mesh,const BITCODE_BS curve_type,int * restrict error)14195 dwg_ent_polyline_mesh_set_curve_type (dwg_ent_polyline_mesh *restrict mesh,
14196                                       const BITCODE_BS curve_type,
14197                                       int *restrict error)
14198 {
14199   if (mesh)
14200     {
14201       *error = 0;
14202       mesh->curve_type = curve_type;
14203     }
14204   else
14205     {
14206       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14207       *error = 1;
14208     }
14209 }
14210 
14211 /** Returns polyline mesh n vert count
14212  */
14213 BITCODE_BS
dwg_ent_polyline_mesh_get_num_m_verts(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14214 dwg_ent_polyline_mesh_get_num_m_verts (
14215     const dwg_ent_polyline_mesh *restrict mesh, int *restrict error)
14216 {
14217   if (mesh)
14218     {
14219       *error = 0;
14220       return mesh->num_m_verts;
14221     }
14222   else
14223     {
14224       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14225       *error = 1;
14226       return 0;
14227     }
14228 }
14229 
14230 /// TODO: dwg_ent_polyline_mesh_add_{m,n}_vert,
14231 /// dwg_ent_polyline_mesh_delete_{m,n}_vert
14232 
14233 /** Returns polyline mesh n vert count
14234  */
14235 BITCODE_BS
dwg_ent_polyline_mesh_get_num_n_verts(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14236 dwg_ent_polyline_mesh_get_num_n_verts (
14237     const dwg_ent_polyline_mesh *restrict mesh, int *restrict error)
14238 {
14239   if (mesh)
14240     {
14241       *error = 0;
14242       return mesh->num_n_verts;
14243     }
14244   else
14245     {
14246       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14247       *error = 1;
14248       return 0;
14249     }
14250 }
14251 
14252 /** Returns polyline mesh n density
14253  */
14254 BITCODE_BS
dwg_ent_polyline_mesh_get_m_density(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14255 dwg_ent_polyline_mesh_get_m_density (
14256     const dwg_ent_polyline_mesh *restrict mesh, int *restrict error)
14257 {
14258   if (mesh)
14259     {
14260       *error = 0;
14261       return mesh->m_density;
14262     }
14263   else
14264     {
14265       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14266       *error = 1;
14267       return 0;
14268     }
14269 }
14270 
14271 /** Sets polyline mesh M density
14272  */
14273 void
dwg_ent_polyline_mesh_set_m_density(dwg_ent_polyline_mesh * restrict mesh,const BITCODE_BS m_density,int * restrict error)14274 dwg_ent_polyline_mesh_set_m_density (dwg_ent_polyline_mesh *restrict mesh,
14275                                      const BITCODE_BS m_density,
14276                                      int *restrict error)
14277 {
14278   if (mesh)
14279     {
14280       *error = 0;
14281       mesh->m_density = m_density;
14282     }
14283   else
14284     {
14285       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14286       *error = 1;
14287     }
14288 }
14289 
14290 /** Returns polyline mesh n density
14291  */
14292 BITCODE_BS
dwg_ent_polyline_mesh_get_n_density(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14293 dwg_ent_polyline_mesh_get_n_density (
14294     const dwg_ent_polyline_mesh *restrict mesh, int *restrict error)
14295 {
14296   if (mesh)
14297     {
14298       *error = 0;
14299       return mesh->n_density;
14300     }
14301   else
14302     {
14303       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14304       *error = 1;
14305       return 0;
14306     }
14307 }
14308 
14309 /** Sets polyline mesh n density
14310  */
14311 void
dwg_ent_polyline_mesh_set_n_density(dwg_ent_polyline_mesh * restrict mesh,const BITCODE_BS n_density,int * restrict error)14312 dwg_ent_polyline_mesh_set_n_density (dwg_ent_polyline_mesh *restrict mesh,
14313                                      const BITCODE_BS n_density,
14314                                      int *restrict error)
14315 {
14316   if (mesh)
14317     {
14318       *error = 0;
14319       mesh->n_density = n_density;
14320     }
14321   else
14322     {
14323       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14324       *error = 1;
14325     }
14326 }
14327 
14328 /** Returns polyline mesh owned object count
14329  */
14330 BITCODE_BL
dwg_ent_polyline_mesh_get_num_owned(const dwg_ent_polyline_mesh * restrict mesh,int * restrict error)14331 dwg_ent_polyline_mesh_get_num_owned (
14332     const dwg_ent_polyline_mesh *restrict mesh, int *restrict error)
14333 {
14334   if (mesh)
14335     {
14336       *error = 0;
14337       return mesh->num_owned;
14338     }
14339   else
14340     {
14341       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14342       *error = 1;
14343       return 0L;
14344     }
14345 }
14346 
14347 /*******************************************************************
14348  *                 FUNCTIONS FOR POLYLINE_2D ENTITY                  *
14349  ********************************************************************/
14350 
14351 /** Returns the _dwg_entity_POLYLINE_2D::extrusion vector, DXF 210.
14352 \param[in]  pline2d dwg_ent_polyline_2d*
14353 \param[out] vector  dwg_point_3d*
14354 \param[out] error   int*, is set to 0 for ok, 1 on error
14355 \deprecated
14356 */
14357 void
dwg_ent_polyline_2d_get_extrusion(const dwg_ent_polyline_2d * restrict pline2d,dwg_point_3d * restrict vector,int * restrict error)14358 dwg_ent_polyline_2d_get_extrusion (const dwg_ent_polyline_2d *restrict pline2d,
14359                                    dwg_point_3d *restrict vector,
14360                                    int *restrict error)
14361 {
14362   if (pline2d
14363 #  ifndef HAVE_NONNULL
14364       && vector
14365 #  endif
14366   )
14367     {
14368       *error = 0;
14369       vector->x = pline2d->extrusion.x;
14370       vector->y = pline2d->extrusion.y;
14371       vector->z = pline2d->extrusion.z;
14372     }
14373   else
14374     {
14375       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14376       *error = 1;
14377     }
14378 }
14379 
14380 /** Sets the _dwg_entity_POLYLINE_2D::extrusion vector, DXF 210.
14381 \param[out] pline2d dwg_ent_polyline_2d*
14382 \param[in]  vector  dwg_point_3d*
14383 \param[out] error   int*, is set to 0 for ok, 1 on error
14384 \deprecated
14385 */
14386 void
dwg_ent_polyline_2d_set_extrusion(dwg_ent_polyline_2d * restrict pline2d,const dwg_point_3d * restrict vector,int * restrict error)14387 dwg_ent_polyline_2d_set_extrusion (dwg_ent_polyline_2d *restrict pline2d,
14388                                    const dwg_point_3d *restrict vector,
14389                                    int *restrict error)
14390 {
14391   if (pline2d
14392 #  ifndef HAVE_NONNULL
14393       && vector
14394 #  endif
14395   )
14396     {
14397       *error = 0;
14398       pline2d->extrusion.x = vector->x;
14399       pline2d->extrusion.y = vector->y;
14400       pline2d->extrusion.z = vector->z;
14401     }
14402   else
14403     {
14404       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14405       *error = 1;
14406     }
14407 }
14408 
14409 /** Returns the _dwg_entity_POLYLINE_2D::start_width, DXF 40.
14410 \param[in]  pline2d dwg_ent_polyline_2d*
14411 \param[out] error   int*, is set to 0 for ok, 1 on error
14412 \deprecated
14413 */
14414 double
dwg_ent_polyline_2d_get_start_width(const dwg_ent_polyline_2d * restrict pline2d,int * restrict error)14415 dwg_ent_polyline_2d_get_start_width (
14416     const dwg_ent_polyline_2d *restrict pline2d, int *restrict error)
14417 {
14418   if (pline2d)
14419     {
14420       *error = 0;
14421       return pline2d->start_width;
14422     }
14423   else
14424     {
14425       *error = 1;
14426       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14427       return bit_nan ();
14428     }
14429 }
14430 
14431 /** Sets the _dwg_entity_POLYLINE_2D::start_width, DXF 40.
14432 \param[out] pline2d     dwg_ent_polyline_2d*
14433 \param[in]  start_width double
14434 \param[out] error       int*, is set to 0 for ok, 1 on error
14435 \deprecated
14436 */
14437 void
dwg_ent_polyline_2d_set_start_width(dwg_ent_polyline_2d * restrict pline2d,const double start_width,int * restrict error)14438 dwg_ent_polyline_2d_set_start_width (dwg_ent_polyline_2d *restrict pline2d,
14439                                      const double start_width,
14440                                      int *restrict error)
14441 {
14442   if (pline2d)
14443     {
14444       *error = 0;
14445       pline2d->start_width = start_width;
14446     }
14447   else
14448     {
14449       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14450       *error = 1;
14451     }
14452 }
14453 
14454 /** Returns polyline 2d end width
14455  */
14456 double
dwg_ent_polyline_2d_get_end_width(const dwg_ent_polyline_2d * restrict pline2d,int * restrict error)14457 dwg_ent_polyline_2d_get_end_width (const dwg_ent_polyline_2d *restrict pline2d,
14458                                    int *restrict error)
14459 {
14460   if (pline2d)
14461     {
14462       *error = 0;
14463       return pline2d->end_width;
14464     }
14465   else
14466     {
14467       *error = 1;
14468       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14469       return bit_nan ();
14470     }
14471 }
14472 
14473 /** Sets polyline 2d end width
14474  */
14475 void
dwg_ent_polyline_2d_set_end_width(dwg_ent_polyline_2d * restrict pline2d,const double end_width,int * restrict error)14476 dwg_ent_polyline_2d_set_end_width (dwg_ent_polyline_2d *restrict pline2d,
14477                                    const double end_width, int *restrict error)
14478 {
14479   if (pline2d)
14480     {
14481       *error = 0;
14482       pline2d->end_width = end_width;
14483     }
14484   else
14485     {
14486       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14487       *error = 1;
14488     }
14489 }
14490 
14491 /** Returns polyline 2d thickness
14492  */
14493 double
dwg_ent_polyline_2d_get_thickness(const dwg_ent_polyline_2d * restrict pline2d,int * restrict error)14494 dwg_ent_polyline_2d_get_thickness (const dwg_ent_polyline_2d *restrict pline2d,
14495                                    int *restrict error)
14496 {
14497   if (pline2d)
14498     {
14499       *error = 0;
14500       return pline2d->thickness;
14501     }
14502   else
14503     {
14504       *error = 1;
14505       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14506       return bit_nan ();
14507     }
14508 }
14509 
14510 /** Sets polyline 2d thickness
14511  */
14512 void
dwg_ent_polyline_2d_set_thickness(dwg_ent_polyline_2d * restrict pline2d,const double thickness,int * restrict error)14513 dwg_ent_polyline_2d_set_thickness (dwg_ent_polyline_2d *restrict pline2d,
14514                                    const double thickness, int *restrict error)
14515 {
14516   if (pline2d)
14517     {
14518       *error = 0;
14519       pline2d->thickness = thickness;
14520     }
14521   else
14522     {
14523       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14524       *error = 1;
14525     }
14526 }
14527 
14528 /** Returns polyline 2d elevation
14529  */
14530 double
dwg_ent_polyline_2d_get_elevation(const dwg_ent_polyline_2d * restrict pline2d,int * restrict error)14531 dwg_ent_polyline_2d_get_elevation (const dwg_ent_polyline_2d *restrict pline2d,
14532                                    int *restrict error)
14533 {
14534   if (pline2d)
14535     {
14536       *error = 0;
14537       return pline2d->elevation;
14538     }
14539   else
14540     {
14541       *error = 1;
14542       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14543       return bit_nan ();
14544     }
14545 }
14546 
14547 /** Sets polyline 2d elevation
14548  */
14549 void
dwg_ent_polyline_2d_set_elevation(dwg_ent_polyline_2d * restrict pline2d,const double elevation,int * restrict error)14550 dwg_ent_polyline_2d_set_elevation (dwg_ent_polyline_2d *restrict pline2d,
14551                                    const double elevation, int *restrict error)
14552 {
14553   if (pline2d)
14554     {
14555       *error = 0;
14556       pline2d->elevation = elevation;
14557     }
14558   else
14559     {
14560       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14561       *error = 1;
14562     }
14563 }
14564 
14565 /** Returns the _dwg_entity_POLYLINE_2D::flag, DXF 70.
14566 \param[in]  pline2d dwg_ent_polyline_2d *
14567 \param[out] error   int*, is set to 0 for ok, 1 on error
14568 \deprecated
14569 */
14570 BITCODE_BS
dwg_ent_polyline_2d_get_flag(const dwg_ent_polyline_2d * restrict pline2d,int * restrict error)14571 dwg_ent_polyline_2d_get_flag (const dwg_ent_polyline_2d *restrict pline2d,
14572                               int *restrict error)
14573 {
14574   if (pline2d)
14575     {
14576       *error = 0;
14577       return pline2d->flag;
14578     }
14579   else
14580     {
14581       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14582       *error = 1;
14583       return 0;
14584     }
14585 }
14586 
14587 /** Sets the _dwg_entity_POLYLINE_2D:: flag, DXF 70.
14588 \param[out] pline2d dwg_ent_polyline_2d*
14589 \param[in]  flag    BITCODE_RC
14590 \param[out] error   int*, is set to 0 for ok, 1 on error
14591 \deprecated
14592 */
14593 void
dwg_ent_polyline_2d_set_flag(dwg_ent_polyline_2d * restrict pline2d,const BITCODE_BS flags,int * restrict error)14594 dwg_ent_polyline_2d_set_flag (dwg_ent_polyline_2d *restrict pline2d,
14595                               const BITCODE_BS flags, int *restrict error)
14596 {
14597   if (pline2d)
14598     {
14599       *error = 0;
14600       pline2d->flag = flags;
14601     }
14602   else
14603     {
14604       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14605       *error = 1;
14606     }
14607 }
14608 
14609 /** Returns curve type value
14610  */
14611 BITCODE_BS
dwg_ent_polyline_2d_get_curve_type(const dwg_ent_polyline_2d * restrict pline2d,int * restrict error)14612 dwg_ent_polyline_2d_get_curve_type (
14613     const dwg_ent_polyline_2d *restrict pline2d, int *restrict error)
14614 {
14615   if (pline2d)
14616     {
14617       *error = 0;
14618       return pline2d->curve_type;
14619     }
14620   else
14621     {
14622       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14623       *error = 1;
14624       return 0;
14625     }
14626 }
14627 
14628 /** Sets curve type value
14629  */
14630 void
dwg_ent_polyline_2d_set_curve_type(dwg_ent_polyline_2d * restrict pline2d,const BITCODE_BS curve_type,int * restrict error)14631 dwg_ent_polyline_2d_set_curve_type (dwg_ent_polyline_2d *restrict pline2d,
14632                                     const BITCODE_BS curve_type,
14633                                     int *restrict error)
14634 {
14635   if (pline2d)
14636     {
14637       *error = 0;
14638       pline2d->curve_type = curve_type;
14639     }
14640   else
14641     {
14642       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14643       *error = 1;
14644     }
14645 }
14646 
14647 /*******************************************************************
14648  *                 FUNCTIONS FOR POLYLINE_3D ENTITY                  *
14649  ********************************************************************/
14650 
14651 /** Returns the _dwg_entity_POLYLINE_3D:: flag, DXF 70.
14652 \param[in]  pline3d dwg_ent_polyline_3d *
14653 \param[out] error   int*, is set to 0 for ok, 1 on error
14654 \deprecated
14655 */
14656 BITCODE_RC
dwg_ent_polyline_3d_get_flag(const dwg_ent_polyline_3d * restrict pline3d,int * restrict error)14657 dwg_ent_polyline_3d_get_flag (const dwg_ent_polyline_3d *restrict pline3d,
14658                               int *restrict error)
14659 {
14660   if (pline3d)
14661     {
14662       *error = 0;
14663       return pline3d->flag;
14664     }
14665   else
14666     {
14667       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14668       *error = 1;
14669       return '\0';
14670     }
14671 }
14672 
14673 /** Sets the _dwg_entity_POLYLINE_3D:: flag, DXF 70.
14674 \param[out] pline3d dwg_ent_polyline_3d *
14675 \param[in]  flag    BITCODE_RC
14676 \param[out] error   int*, is set to 0 for ok, 1 on error
14677 \deprecated
14678 */
14679 void
dwg_ent_polyline_3d_set_flag(dwg_ent_polyline_3d * restrict pline3d,const BITCODE_RC flag,int * restrict error)14680 dwg_ent_polyline_3d_set_flag (dwg_ent_polyline_3d *restrict pline3d,
14681                               const BITCODE_RC flag, int *restrict error)
14682 {
14683   if (pline3d)
14684     {
14685       *error = 0;
14686       pline3d->flag = flag;
14687     }
14688   else
14689     {
14690       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14691       *error = 1;
14692     }
14693 }
14694 
14695 /** Returns polyline 3d curve_type
14696  */
14697 BITCODE_RC
dwg_ent_polyline_3d_get_curve_type(const dwg_ent_polyline_3d * restrict pline3d,int * restrict error)14698 dwg_ent_polyline_3d_get_curve_type (
14699     const dwg_ent_polyline_3d *restrict pline3d, int *restrict error)
14700 {
14701   if (pline3d)
14702     {
14703       *error = 0;
14704       return pline3d->curve_type;
14705     }
14706   else
14707     {
14708       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14709       *error = 1;
14710       return '\0';
14711     }
14712 }
14713 
14714 /** Sets polyline 3d curve_type
14715  */
14716 void
dwg_ent_polyline_3d_set_curve_type(dwg_ent_polyline_3d * restrict pline3d,const BITCODE_RC curve_type,int * restrict error)14717 dwg_ent_polyline_3d_set_curve_type (dwg_ent_polyline_3d *restrict pline3d,
14718                                     const BITCODE_RC curve_type,
14719                                     int *restrict error)
14720 {
14721   if (pline3d)
14722     {
14723       *error = 0;
14724       pline3d->curve_type = curve_type;
14725     }
14726   else
14727     {
14728       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14729       *error = 1;
14730     }
14731 }
14732 
14733 /*******************************************************************
14734  *                   FUNCTIONS FOR 3DFACE ENTITY                     *
14735  ********************************************************************/
14736 
14737 /** Returns the _dwg_entity_3DFACE::invis_flags, DXF 70.
14738 \code Usage: BITCODE_BS flag = dwg_ent_3dface_get_invis_flags(_3dface, &error);
14739 \endcode
14740 \param[in] _3dface  dwg_ent_3dface*
14741 \param[out] error   set to 0 for ok, 1 on error
14742 \deprecated
14743 */
14744 BITCODE_BS
dwg_ent_3dface_get_invis_flags(const dwg_ent_3dface * restrict _3dface,int * restrict error)14745 dwg_ent_3dface_get_invis_flags (const dwg_ent_3dface *restrict _3dface,
14746                                 int *restrict error)
14747 {
14748   if (_3dface)
14749     {
14750       *error = 0;
14751       return _3dface->invis_flags;
14752     }
14753   else
14754     {
14755       *error = 1;
14756       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14757       return 0;
14758     }
14759 }
14760 
14761 /** Sets the _dwg_entity_3DFACE::invis_flags, DXF 70.
14762 \code Usage: dwg_ent_3dface_set_invis_flagsx(_3dface, flags, &error);
14763 \endcode
14764 \param[in,out] 3dface      dwg_ent_3dface*
14765 \param[in]     invis_flags BITCODE_BS
14766 \param[out]    error       int*, is set to 0 for ok, 1 on error
14767 \deprecated
14768 */
14769 void
dwg_ent_3dface_set_invis_flags(dwg_ent_3dface * restrict _3dface,const BITCODE_BS invis_flags,int * restrict error)14770 dwg_ent_3dface_set_invis_flags (dwg_ent_3dface *restrict _3dface,
14771                                 const BITCODE_BS invis_flags,
14772                                 int *restrict error)
14773 {
14774   if (_3dface)
14775     {
14776       *error = 0;
14777       _3dface->invis_flags = invis_flags;
14778     }
14779   else
14780     {
14781       *error = 1;
14782       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14783     }
14784 }
14785 
14786 /** Returns the _dwg_entity_3DFACE::corner1 point, DXF 10.
14787 \code Usage: dwg_ent_3dface_get_corner1(face, &point, &error);
14788 \endcode
14789 \param[in]  3dface  dwg_ent_3dface*
14790 \param[out] point   dwg_point_3d*
14791 \param[out] error   int*, is set to 0 for ok, 1 on error
14792 \deprecated
14793 */
14794 void
dwg_ent_3dface_get_corner1(const dwg_ent_3dface * restrict _3dface,dwg_point_3d * restrict point,int * restrict error)14795 dwg_ent_3dface_get_corner1 (const dwg_ent_3dface *restrict _3dface,
14796                             dwg_point_3d *restrict point, int *restrict error)
14797 {
14798   if (_3dface
14799 #  ifndef HAVE_NONNULL
14800       && point
14801 #  endif
14802   )
14803     {
14804       *error = 0;
14805       point->x = _3dface->corner1.x;
14806       point->y = _3dface->corner1.y;
14807       point->z = _3dface->corner1.z;
14808     }
14809   else
14810     {
14811       *error = 1;
14812       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14813     }
14814 }
14815 
14816 /** Sets the _dwg_entity_3DFACE::corner1 point, DXF 10.
14817 \code Usage: dwg_ent_3dface_set_corner1(face, &point, &error);
14818 \endcode
14819 \param[in,out] 3dface   dwg_ent_3dface*
14820 \param[in]     point    dwg_point_3d*
14821 \param[out]    error    int*, is set to 0 for ok, 1 on error
14822 \deprecated
14823 */
14824 void
dwg_ent_3dface_set_corner1(dwg_ent_3dface * restrict _3dface,const dwg_point_3d * restrict point,int * restrict error)14825 dwg_ent_3dface_set_corner1 (dwg_ent_3dface *restrict _3dface,
14826                             const dwg_point_3d *restrict point,
14827                             int *restrict error)
14828 {
14829   if (_3dface
14830 #  ifndef HAVE_NONNULL
14831       && point
14832 #  endif
14833   )
14834     {
14835       *error = 0;
14836       _3dface->corner1.x = point->x;
14837       _3dface->corner1.y = point->y;
14838       _3dface->corner1.z = point->z;
14839     }
14840   else
14841     {
14842       *error = 1;
14843       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14844     }
14845 }
14846 
14847 /** Returns the _dwg_entity_3DFACE::corner2 point, DXF 11.
14848 \code Usage: dwg_ent_3dface_get_corner2(face, &point, &error);
14849 \endcode
14850 \param[in]  3dface  dwg_ent_3dface*
14851 \param[out] point   dwg_point_3d*
14852 \param[out] error   int*, is set to 0 for ok, 1 on error
14853 \deprecated
14854 */
14855 void
dwg_ent_3dface_get_corner2(const dwg_ent_3dface * restrict _3dface,dwg_point_3d * restrict point,int * restrict error)14856 dwg_ent_3dface_get_corner2 (const dwg_ent_3dface *restrict _3dface,
14857                             dwg_point_3d *restrict point, int *restrict error)
14858 {
14859   if (_3dface
14860 #  ifndef HAVE_NONNULL
14861       && point
14862 #  endif
14863   )
14864     {
14865       *error = 0;
14866       point->x = _3dface->corner2.x;
14867       point->y = _3dface->corner2.y;
14868       point->z = _3dface->corner2.z;
14869     }
14870   else
14871     {
14872       *error = 1;
14873       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14874     }
14875 }
14876 
14877 /** Sets the _dwg_entity_3DFACE::corner2 point, DXF 11.
14878 \code Usage: dwg_ent_3dface_set_corner2(face, &point, &error);
14879 \endcode
14880 \param[in,out] 3dface   dwg_ent_3dface*
14881 \param[in]     point    dwg_point_3d*
14882 \param[out]    error    int*, is set to 0 for ok, 1 on error
14883 \deprecated
14884 */
14885 void
dwg_ent_3dface_set_corner2(dwg_ent_3dface * restrict _3dface,const dwg_point_3d * restrict point,int * restrict error)14886 dwg_ent_3dface_set_corner2 (dwg_ent_3dface *restrict _3dface,
14887                             const dwg_point_3d *restrict point,
14888                             int *restrict error)
14889 {
14890   if (_3dface
14891 #  ifndef HAVE_NONNULL
14892       && point
14893 #  endif
14894   )
14895     {
14896       *error = 0;
14897       _3dface->corner2.x = point->x;
14898       _3dface->corner2.y = point->y;
14899       _3dface->corner2.z = point->z;
14900     }
14901   else
14902     {
14903       *error = 1;
14904       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14905     }
14906 }
14907 
14908 /** Returns the _dwg_entity_3DFACE::corner1 point, DXF 12.
14909 \code Usage: dwg_ent_3dface_get_corner3(face, &point, &error);
14910 \endcode
14911 \param[in]  3dface  dwg_ent_3dface*
14912 \param[out] point   dwg_point_3d*
14913 \param[out] error   int*, is set to 0 for ok, 1 on error
14914 \deprecated
14915 */
14916 void
dwg_ent_3dface_get_corner3(const dwg_ent_3dface * restrict _3dface,dwg_point_3d * restrict point,int * restrict error)14917 dwg_ent_3dface_get_corner3 (const dwg_ent_3dface *restrict _3dface,
14918                             dwg_point_3d *restrict point, int *restrict error)
14919 {
14920   if (_3dface
14921 #  ifndef HAVE_NONNULL
14922       && point
14923 #  endif
14924   )
14925     {
14926       *error = 0;
14927       point->x = _3dface->corner3.x;
14928       point->y = _3dface->corner3.y;
14929       point->z = _3dface->corner3.z;
14930     }
14931   else
14932     {
14933       *error = 1;
14934       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14935     }
14936 }
14937 
14938 /** Sets the _dwg_entity_3DFACE::corner3 point, DXF 12.
14939 \code Usage: dwg_ent_3dface_set_corner3(face, &point, &error);
14940 \endcode
14941 \param[in,out] 3dface   dwg_ent_3dface*
14942 \param[in]     point    dwg_point_3d*
14943 \param[out]    error    int*, is set to 0 for ok, 1 on error
14944 \deprecated
14945 */
14946 void
dwg_ent_3dface_set_corner3(dwg_ent_3dface * restrict _3dface,const dwg_point_3d * restrict point,int * restrict error)14947 dwg_ent_3dface_set_corner3 (dwg_ent_3dface *restrict _3dface,
14948                             const dwg_point_3d *restrict point,
14949                             int *restrict error)
14950 {
14951   if (_3dface
14952 #  ifndef HAVE_NONNULL
14953       && point
14954 #  endif
14955   )
14956     {
14957       *error = 0;
14958       _3dface->corner3.x = point->x;
14959       _3dface->corner3.y = point->y;
14960       _3dface->corner3.z = point->z;
14961   }
14962   else
14963     {
14964       *error = 1;
14965       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14966     }
14967 }
14968 
14969 /** Returns the _dwg_entity_3DFACE::corner1 point, DXF 13.
14970 \code Usage: dwg_ent_3dface_get_corner4(face, &point, &error);
14971 \endcode
14972 \param[in]  3dface  dwg_ent_3dface*
14973 \param[out] point   dwg_point_3d
14974 \param[out] error   int*, is set to 0 for ok, 1 on error
14975 \deprecated
14976 */
14977 void
dwg_ent_3dface_get_corner4(const dwg_ent_3dface * restrict _3dface,dwg_point_3d * restrict point,int * restrict error)14978 dwg_ent_3dface_get_corner4 (const dwg_ent_3dface *restrict _3dface,
14979                             dwg_point_3d *restrict point, int *restrict error)
14980 {
14981   if (_3dface
14982 #  ifndef HAVE_NONNULL
14983       && point
14984 #  endif
14985   )
14986     {
14987       *error = 0;
14988       point->x = _3dface->corner4.x;
14989       point->y = _3dface->corner4.y;
14990       point->z = _3dface->corner4.z;
14991     }
14992   else
14993     {
14994       *error = 1;
14995       LOG_ERROR ("%s: empty arg", __FUNCTION__)
14996     }
14997 }
14998 
14999 /** Sets the _dwg_entity_3DFACE::corner4 point, DXF 13.
15000 \code Usage: dwg_ent_3dface_set_corner4(face, &point, &error);
15001 \endcode
15002 \param[out]  3dface  dwg_ent_3dface*
15003 \param[in]   point   dwg_point_3d*
15004 \param[out]  error   int*, is set to 0 for ok, 1 on error
15005 \deprecated
15006 */
15007 void
dwg_ent_3dface_set_corner4(dwg_ent_3dface * restrict _3dface,const dwg_point_3d * restrict point,int * restrict error)15008 dwg_ent_3dface_set_corner4 (dwg_ent_3dface *restrict _3dface,
15009                             const dwg_point_3d *restrict point,
15010                             int *restrict error)
15011 {
15012   if (_3dface
15013 #  ifndef HAVE_NONNULL
15014       && point
15015 #  endif
15016   )
15017     {
15018       *error = 0;
15019       _3dface->corner4.x = point->x;
15020       _3dface->corner4.y = point->y;
15021       _3dface->corner4.z = point->z;
15022     }
15023   else
15024     {
15025       *error = 1;
15026       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15027     }
15028 }
15029 
15030 /*******************************************************************
15031  *                    FUNCTIONS FOR IMAGE ENTITY                     *
15032  ********************************************************************/
15033 
15034 /** Returns image class version
15035  */
15036 BITCODE_BL
dwg_ent_image_get_class_version(const dwg_ent_image * restrict image,int * restrict error)15037 dwg_ent_image_get_class_version (const dwg_ent_image *restrict image,
15038                                  int *restrict error)
15039 {
15040   if (image)
15041     {
15042       *error = 0;
15043       return image->class_version;
15044     }
15045   else
15046     {
15047       *error = 1;
15048       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15049       return 0L;
15050     }
15051 }
15052 
15053 /** Sets image class version
15054  */
15055 void
dwg_ent_image_set_class_version(dwg_ent_image * restrict image,const BITCODE_BL class_version,int * restrict error)15056 dwg_ent_image_set_class_version (dwg_ent_image *restrict image,
15057                                  const BITCODE_BL class_version,
15058                                  int *restrict error)
15059 {
15060   if (image)
15061     {
15062       *error = 0;
15063       image->class_version = class_version;
15064     }
15065   else
15066     {
15067       *error = 1;
15068       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15069     }
15070 }
15071 
15072 /** Returns image point 0 points
15073  */
15074 void
dwg_ent_image_get_pt0(const dwg_ent_image * restrict image,dwg_point_3d * restrict point,int * restrict error)15075 dwg_ent_image_get_pt0 (const dwg_ent_image *restrict image,
15076                        dwg_point_3d *restrict point, int *restrict error)
15077 {
15078   if (image
15079 #  ifndef HAVE_NONNULL
15080       && point
15081 #  endif
15082   )
15083     {
15084       *error = 0;
15085       point->x = image->pt0.x;
15086       point->y = image->pt0.y;
15087       point->z = image->pt0.z;
15088     }
15089   else
15090     {
15091       *error = 1;
15092       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15093     }
15094 }
15095 
15096 /** Sets image point 0 points
15097  */
15098 void
dwg_ent_image_set_pt0(dwg_ent_image * restrict image,const dwg_point_3d * restrict point,int * restrict error)15099 dwg_ent_image_set_pt0 (dwg_ent_image *restrict image,
15100                        const dwg_point_3d *restrict point, int *restrict error)
15101 {
15102   if (image
15103 #  ifndef HAVE_NONNULL
15104       && point
15105 #  endif
15106   )
15107     {
15108       *error = 0;
15109       image->pt0.x = point->x;
15110       image->pt0.y = point->y;
15111       image->pt0.z = point->z;
15112     }
15113   else
15114     {
15115       *error = 1;
15116       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15117     }
15118 }
15119 
15120 /** Returns image U_vector points
15121  */
15122 void
dwg_ent_image_get_u_vector(const dwg_ent_image * restrict image,dwg_point_3d * restrict point,int * restrict error)15123 dwg_ent_image_get_u_vector (const dwg_ent_image *restrict image,
15124                             dwg_point_3d *restrict point, int *restrict error)
15125 {
15126   if (image
15127 #  ifndef HAVE_NONNULL
15128       && point
15129 #  endif
15130   )
15131     {
15132       *error = 0;
15133       point->x = image->uvec.x;
15134       point->y = image->uvec.y;
15135       point->z = image->uvec.z;
15136     }
15137   else
15138     {
15139       *error = 1;
15140       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15141     }
15142 }
15143 
15144 /** Sets image U_vector points
15145  */
15146 void
dwg_ent_image_set_u_vector(dwg_ent_image * restrict image,const dwg_point_3d * restrict point,int * restrict error)15147 dwg_ent_image_set_u_vector (dwg_ent_image *restrict image,
15148                             const dwg_point_3d *restrict point,
15149                             int *restrict error)
15150 {
15151   if (image
15152 #  ifndef HAVE_NONNULL
15153       && point
15154 #  endif
15155   )
15156     {
15157       *error = 0;
15158       image->uvec.x = point->x;
15159       image->uvec.y = point->y;
15160       image->uvec.z = point->z;
15161     }
15162   else
15163     {
15164       *error = 1;
15165       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15166     }
15167 }
15168 
15169 /** Returns image v_vector points
15170  */
15171 void
dwg_ent_image_get_v_vector(const dwg_ent_image * restrict image,dwg_point_3d * restrict point,int * restrict error)15172 dwg_ent_image_get_v_vector (const dwg_ent_image *restrict image,
15173                             dwg_point_3d *restrict point, int *restrict error)
15174 {
15175   if (image
15176 #  ifndef HAVE_NONNULL
15177       && point
15178 #  endif
15179   )
15180     {
15181       *error = 0;
15182       point->x = image->vvec.x;
15183       point->y = image->vvec.y;
15184       point->z = image->vvec.z;
15185     }
15186   else
15187     {
15188       *error = 1;
15189       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15190     }
15191 }
15192 
15193 /** Sets v vector points
15194  */
15195 void
dwg_ent_image_set_v_vector(dwg_ent_image * restrict image,const dwg_point_3d * restrict point,int * restrict error)15196 dwg_ent_image_set_v_vector (dwg_ent_image *restrict image,
15197                             const dwg_point_3d *restrict point,
15198                             int *restrict error)
15199 {
15200   if (image
15201 #  ifndef HAVE_NONNULL
15202       && point
15203 #  endif
15204   )
15205     {
15206       *error = 0;
15207       image->vvec.x = point->x;
15208       image->vvec.y = point->y;
15209       image->vvec.z = point->z;
15210     }
15211   else
15212     {
15213       *error = 1;
15214       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15215     }
15216 }
15217 
15218 /** Returns image size height
15219  */
15220 double
dwg_ent_image_get_size_height(const dwg_ent_image * restrict image,int * restrict error)15221 dwg_ent_image_get_size_height (const dwg_ent_image *restrict image,
15222                                int *restrict error)
15223 {
15224   if (image)
15225     {
15226       *error = 0;
15227       return image->size.y;
15228     }
15229   else
15230     {
15231       *error = 1;
15232       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15233       return bit_nan ();
15234     }
15235 }
15236 
15237 /** Sets image size height
15238  */
15239 void
dwg_ent_image_set_size_height(dwg_ent_image * restrict image,const double size_height,int * restrict error)15240 dwg_ent_image_set_size_height (dwg_ent_image *restrict image,
15241                                const double size_height, int *restrict error)
15242 {
15243   if (image)
15244     {
15245       *error = 0;
15246       image->size.y = size_height;
15247     }
15248   else
15249     {
15250       *error = 1;
15251       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15252     }
15253 }
15254 
15255 /** Returns image size width
15256  */
15257 double
dwg_ent_image_get_size_width(const dwg_ent_image * restrict image,int * restrict error)15258 dwg_ent_image_get_size_width (const dwg_ent_image *restrict image,
15259                               int *restrict error)
15260 {
15261   if (image)
15262     {
15263       *error = 0;
15264       return image->size.x;
15265     }
15266   else
15267     {
15268       *error = 1;
15269       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15270       return bit_nan ();
15271     }
15272 }
15273 
15274 /** Sets image size width
15275  */
15276 void
dwg_ent_image_set_size_width(dwg_ent_image * restrict image,const double size_width,int * restrict error)15277 dwg_ent_image_set_size_width (dwg_ent_image *restrict image,
15278                               const double size_width, int *restrict error)
15279 {
15280   if (image)
15281     {
15282       *error = 0;
15283       image->size.x = size_width;
15284     }
15285   else
15286     {
15287       *error = 1;
15288       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15289     }
15290 }
15291 
15292 /** Returns image display props
15293  */
15294 BITCODE_BS
dwg_ent_image_get_display_props(const dwg_ent_image * restrict image,int * restrict error)15295 dwg_ent_image_get_display_props (const dwg_ent_image *restrict image,
15296                                  int *restrict error)
15297 {
15298   if (image)
15299     {
15300       *error = 0;
15301       return image->display_props;
15302     }
15303   else
15304     {
15305       *error = 1;
15306       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15307       return 0;
15308     }
15309 }
15310 
15311 /** Sets image display props
15312  */
15313 void
dwg_ent_image_set_display_props(dwg_ent_image * restrict image,const BITCODE_BS display_props,int * restrict error)15314 dwg_ent_image_set_display_props (dwg_ent_image *restrict image,
15315                                  const BITCODE_BS display_props,
15316                                  int *restrict error)
15317 {
15318   if (image)
15319     {
15320       *error = 0;
15321       image->display_props = display_props;
15322     }
15323   else
15324     {
15325       *error = 1;
15326       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15327     }
15328 }
15329 
15330 /** Returns image clipping
15331  */
15332 BITCODE_B
dwg_ent_image_get_clipping(const dwg_ent_image * restrict image,int * restrict error)15333 dwg_ent_image_get_clipping (const dwg_ent_image *restrict image,
15334                             int *restrict error)
15335 {
15336   if (image)
15337     {
15338       *error = 0;
15339       return image->clipping;
15340     }
15341   else
15342     {
15343       *error = 1;
15344       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15345       return '\0';
15346     }
15347 }
15348 
15349 /** Sets image clipping
15350  */
15351 void
dwg_ent_image_set_clipping(dwg_ent_image * restrict image,BITCODE_B clipping,int * restrict error)15352 dwg_ent_image_set_clipping (dwg_ent_image *restrict image, BITCODE_B clipping,
15353                             int *restrict error)
15354 {
15355   if (image)
15356     {
15357       *error = 0;
15358       image->clipping = clipping;
15359     }
15360   else
15361     {
15362       *error = 1;
15363       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15364     }
15365 }
15366 
15367 /** Returns image brightness
15368  */
15369 char
dwg_ent_image_get_brightness(const dwg_ent_image * restrict image,int * restrict error)15370 dwg_ent_image_get_brightness (const dwg_ent_image *restrict image,
15371                               int *restrict error)
15372 {
15373   if (image)
15374     {
15375       *error = 0;
15376       return image->brightness;
15377     }
15378   else
15379     {
15380       *error = 1;
15381       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15382       return '\0';
15383     }
15384 }
15385 
15386 /** Sets image brightness
15387  */
15388 void
dwg_ent_image_set_brightness(dwg_ent_image * restrict image,const char brightness,int * restrict error)15389 dwg_ent_image_set_brightness (dwg_ent_image *restrict image,
15390                               const char brightness, int *restrict error)
15391 {
15392   if (image)
15393     {
15394       *error = 0;
15395       image->brightness = brightness;
15396     }
15397   else
15398     {
15399       *error = 1;
15400       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15401     }
15402 }
15403 
15404 /// Return image contrast
15405 char
dwg_ent_image_get_contrast(const dwg_ent_image * restrict image,int * restrict error)15406 dwg_ent_image_get_contrast (const dwg_ent_image *restrict image,
15407                             int *restrict error)
15408 {
15409   if (image)
15410     {
15411       *error = 0;
15412       return image->contrast;
15413     }
15414   else
15415     {
15416       *error = 1;
15417       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15418       return '\0';
15419     }
15420 }
15421 
15422 /** Sets image contrast
15423  */
15424 void
dwg_ent_image_set_contrast(dwg_ent_image * restrict image,const char contrast,int * restrict error)15425 dwg_ent_image_set_contrast (dwg_ent_image *restrict image, const char contrast,
15426                             int *restrict error)
15427 {
15428   if (image)
15429     {
15430       *error = 0;
15431       image->contrast = contrast;
15432     }
15433   else
15434     {
15435       *error = 1;
15436       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15437     }
15438 }
15439 
15440 /** Returns image fade
15441  */
15442 char
dwg_ent_image_get_fade(const dwg_ent_image * restrict image,int * restrict error)15443 dwg_ent_image_get_fade (const dwg_ent_image *restrict image,
15444                         int *restrict error)
15445 {
15446   if (image)
15447     {
15448       *error = 0;
15449       return image->fade;
15450     }
15451   else
15452     {
15453       *error = 1;
15454       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15455       return '\0';
15456     }
15457 }
15458 
15459 /** Sets image fade
15460  */
15461 void
dwg_ent_image_set_fade(dwg_ent_image * restrict image,const char fade,int * restrict error)15462 dwg_ent_image_set_fade (dwg_ent_image *restrict image, const char fade,
15463                         int *restrict error)
15464 {
15465   if (image)
15466     {
15467       *error = 0;
15468       image->fade = fade;
15469     }
15470   else
15471     {
15472       *error = 1;
15473       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15474     }
15475 }
15476 
15477 /** Returns image clip boundary type
15478  */
15479 BITCODE_BS
dwg_ent_image_get_clip_boundary_type(const dwg_ent_image * restrict image,int * restrict error)15480 dwg_ent_image_get_clip_boundary_type (const dwg_ent_image *restrict image,
15481                                       int *restrict error)
15482 {
15483   if (image)
15484     {
15485       *error = 0;
15486       return image->clip_boundary_type;
15487     }
15488   else
15489     {
15490       *error = 1;
15491       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15492       return 0;
15493     }
15494 }
15495 
15496 /** Sets image clip boundary type
15497  */
15498 void
dwg_ent_image_set_clip_boundary_type(dwg_ent_image * restrict image,const BITCODE_BS type,int * restrict error)15499 dwg_ent_image_set_clip_boundary_type (dwg_ent_image *restrict image,
15500                                       const BITCODE_BS type,
15501                                       int *restrict error)
15502 {
15503   if (image)
15504     {
15505       *error = 0;
15506       image->clip_boundary_type = type;
15507     }
15508   else
15509     {
15510       *error = 1;
15511       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15512     }
15513 }
15514 
15515 /** Returns image boundary point 0
15516  */
15517 void
dwg_ent_image_get_boundary_pt0(const dwg_ent_image * restrict image,dwg_point_2d * restrict point,int * restrict error)15518 dwg_ent_image_get_boundary_pt0 (const dwg_ent_image *restrict image,
15519                                 dwg_point_2d *restrict point,
15520                                 int *restrict error)
15521 {
15522   if (image
15523 #  ifndef HAVE_NONNULL
15524       && point
15525 #  endif
15526   )
15527     {
15528       *error = 0;
15529       point->x = image->clip_verts[0].x;
15530       point->y = image->clip_verts[0].y;
15531     }
15532   else
15533     {
15534       *error = 1;
15535       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15536     }
15537 }
15538 
15539 /** Sets image boundary point 0
15540  */
15541 void
dwg_ent_image_set_boundary_pt0(dwg_ent_image * restrict image,const dwg_point_2d * restrict point,int * restrict error)15542 dwg_ent_image_set_boundary_pt0 (dwg_ent_image *restrict image,
15543                                 const dwg_point_2d *restrict point,
15544                                 int *restrict error)
15545 {
15546   if (image
15547 #  ifndef HAVE_NONNULL
15548       && point
15549 #  endif
15550   )
15551     {
15552       *error = 0;
15553       image->clip_verts[0].x = point->x;
15554       image->clip_verts[0].y = point->y;
15555     }
15556   else
15557     {
15558       *error = 1;
15559       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15560     }
15561 }
15562 
15563 /** Returns boundary point1
15564  */
15565 void
dwg_ent_image_get_boundary_pt1(const dwg_ent_image * restrict image,dwg_point_2d * restrict point,int * restrict error)15566 dwg_ent_image_get_boundary_pt1 (const dwg_ent_image *restrict image,
15567                                 dwg_point_2d *restrict point,
15568                                 int *restrict error)
15569 {
15570   if (image
15571 #  ifndef HAVE_NONNULL
15572       && point
15573 #  endif
15574   )
15575     {
15576       *error = 0;
15577       point->x = image->clip_verts[1].x;
15578       point->y = image->clip_verts[1].y;
15579     }
15580   else
15581     {
15582       *error = 1;
15583       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15584     }
15585 }
15586 
15587 /** Sets boundary point1
15588  */
15589 void
dwg_ent_image_set_boundary_pt1(dwg_ent_image * restrict image,const dwg_point_2d * restrict point,int * restrict error)15590 dwg_ent_image_set_boundary_pt1 (dwg_ent_image *restrict image,
15591                                 const dwg_point_2d *restrict point,
15592                                 int *restrict error)
15593 {
15594   if (image
15595 #  ifndef HAVE_NONNULL
15596       && point
15597 #  endif
15598   )
15599     {
15600       *error = 0;
15601       image->clip_verts[1].x = point->x;
15602       image->clip_verts[1].y = point->y;
15603     }
15604   else
15605     {
15606       *error = 1;
15607       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15608     }
15609 }
15610 
15611 /// Returns number of clip verts
15612 double
dwg_ent_image_get_num_clip_verts(const dwg_ent_image * restrict image,int * restrict error)15613 dwg_ent_image_get_num_clip_verts (const dwg_ent_image *restrict image,
15614                                   int *restrict error)
15615 {
15616   if (image)
15617     {
15618       *error = 0;
15619       return image->num_clip_verts;
15620     }
15621   else
15622     {
15623       *error = 1;
15624       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15625       return bit_nan ();
15626     }
15627 }
15628 
15629 /** Returns image clip verts
15630  */
15631 BITCODE_2RD *
dwg_ent_image_get_clip_verts(const dwg_ent_image * restrict image,int * restrict error)15632 dwg_ent_image_get_clip_verts (const dwg_ent_image *restrict image,
15633                               int *restrict error)
15634 {
15635   BITCODE_2RD *ptx = (BITCODE_2RD *)calloc (image->num_clip_verts, sizeof (BITCODE_2RD));
15636   if (ptx)
15637     {
15638       BITCODE_BL i;
15639       *error = 0;
15640       for (i = 0; i < image->num_clip_verts; i++)
15641         {
15642           ptx[i] = image->clip_verts[i];
15643         }
15644       return ptx;
15645     }
15646   else
15647     {
15648       *error = 1;
15649       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
15650       return NULL;
15651     }
15652 }
15653 
15654 /*******************************************************************
15655  *                    FUNCTIONS FOR MLINE ENTITY                     *
15656  ********************************************************************/
15657 
15658 /** Sets mline scale value
15659  */
15660 void
dwg_ent_mline_set_scale(dwg_ent_mline * restrict mline,const double scale,int * restrict error)15661 dwg_ent_mline_set_scale (dwg_ent_mline *restrict mline, const double scale,
15662                          int *restrict error)
15663 {
15664   if (mline)
15665     {
15666       *error = 0;
15667       mline->scale = scale;
15668     }
15669   else
15670     {
15671       *error = 1;
15672       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15673     }
15674 }
15675 
15676 /** Returns scale value
15677  */
15678 double
dwg_ent_mline_get_scale(const dwg_ent_mline * restrict mline,int * restrict error)15679 dwg_ent_mline_get_scale (const dwg_ent_mline *restrict mline,
15680                          int *restrict error)
15681 {
15682   if (mline)
15683     {
15684       *error = 0;
15685       return mline->scale;
15686     }
15687   else
15688     {
15689       *error = 1;
15690       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15691       return bit_nan ();
15692     }
15693 }
15694 
15695 /** Sets justification value
15696  */
15697 void
dwg_ent_mline_set_justification(dwg_ent_mline * restrict mline,const BITCODE_RC justification,int * restrict error)15698 dwg_ent_mline_set_justification (dwg_ent_mline *restrict mline,
15699                                  const BITCODE_RC justification,
15700                                  int *restrict error)
15701 {
15702   if (mline)
15703     {
15704       *error = 0;
15705       mline->justification = justification;
15706     }
15707   else
15708     {
15709       *error = 1;
15710       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15711     }
15712 }
15713 
15714 /** Returns justification value
15715  */
15716 BITCODE_RC
dwg_ent_mline_get_justification(const dwg_ent_mline * restrict mline,int * restrict error)15717 dwg_ent_mline_get_justification (const dwg_ent_mline *restrict mline,
15718                                  int *restrict error)
15719 {
15720   if (mline)
15721     {
15722       *error = 0;
15723       return mline->justification;
15724     }
15725   else
15726     {
15727       *error = 1;
15728       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15729       return '\0';
15730     }
15731 }
15732 
15733 /** Sets base point value
15734  */
15735 void
dwg_ent_mline_set_base_point(dwg_ent_mline * restrict mline,const dwg_point_3d * restrict point,int * restrict error)15736 dwg_ent_mline_set_base_point (dwg_ent_mline *restrict mline,
15737                               const dwg_point_3d *restrict point,
15738                               int *restrict error)
15739 {
15740   if (mline
15741 #  ifndef HAVE_NONNULL
15742       && point
15743 #  endif
15744   )
15745     {
15746       *error = 0;
15747       mline->base_point.x = point->x;
15748       mline->base_point.y = point->y;
15749       mline->base_point.z = point->z;
15750     }
15751   else
15752     {
15753       *error = 1;
15754       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15755     }
15756 }
15757 
15758 /** Returns base point value
15759  */
15760 void
dwg_ent_mline_get_base_point(const dwg_ent_mline * restrict mline,dwg_point_3d * restrict point,int * restrict error)15761 dwg_ent_mline_get_base_point (const dwg_ent_mline *restrict mline,
15762                               dwg_point_3d *restrict point,
15763                               int *restrict error)
15764 {
15765   if (mline
15766 #  ifndef HAVE_NONNULL
15767       && point
15768 #  endif
15769   )
15770     {
15771       *error = 0;
15772       point->x = mline->base_point.x;
15773       point->y = mline->base_point.y;
15774       point->z = mline->base_point.z;
15775     }
15776   else
15777     {
15778       *error = 1;
15779       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15780     }
15781 }
15782 
15783 /** Sets extrusion points
15784  */
15785 void
dwg_ent_mline_set_extrusion(dwg_ent_mline * restrict mline,const dwg_point_3d * restrict point,int * restrict error)15786 dwg_ent_mline_set_extrusion (dwg_ent_mline *restrict mline,
15787                              const dwg_point_3d *restrict point,
15788                              int *restrict error)
15789 {
15790   if (mline
15791 #  ifndef HAVE_NONNULL
15792       && point
15793 #  endif
15794   )
15795     {
15796       *error = 0;
15797       mline->extrusion.x = point->x;
15798       mline->extrusion.y = point->y;
15799       mline->extrusion.z = point->z;
15800     }
15801   else
15802     {
15803       *error = 1;
15804       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15805     }
15806 }
15807 
15808 /** Returns extrusion points
15809  */
15810 void
dwg_ent_mline_get_extrusion(const dwg_ent_mline * restrict mline,dwg_point_3d * restrict point,int * restrict error)15811 dwg_ent_mline_get_extrusion (const dwg_ent_mline *restrict mline,
15812                              dwg_point_3d *restrict point, int *restrict error)
15813 {
15814   if (mline
15815 #  ifndef HAVE_NONNULL
15816       && point
15817 #  endif
15818   )
15819     {
15820       *error = 0;
15821       point->x = mline->extrusion.x;
15822       point->y = mline->extrusion.y;
15823       point->z = mline->extrusion.z;
15824     }
15825   else
15826     {
15827       *error = 1;
15828       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15829     }
15830 }
15831 
15832 /** Sets open closed value
15833  */
15834 void
dwg_ent_mline_set_flags(dwg_ent_mline * restrict mline,const BITCODE_BS oc,int * restrict error)15835 dwg_ent_mline_set_flags (dwg_ent_mline *restrict mline, const BITCODE_BS oc,
15836                          int *restrict error)
15837 {
15838   if (mline)
15839     {
15840       *error = 0;
15841       mline->flags = oc;
15842     }
15843   else
15844     {
15845       *error = 1;
15846       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15847     }
15848 }
15849 
15850 /** Returns flags value
15851  */
15852 BITCODE_BS
dwg_ent_mline_get_flags(const dwg_ent_mline * restrict mline,int * restrict error)15853 dwg_ent_mline_get_flags (const dwg_ent_mline *restrict mline,
15854                          int *restrict error)
15855 {
15856   if (mline)
15857     {
15858       *error = 0;
15859       return mline->flags;
15860     }
15861   else
15862     {
15863       *error = 1;
15864       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15865       return 0;
15866     }
15867 }
15868 
15869 /** Returns number of lines
15870  */
15871 BITCODE_RC
dwg_ent_mline_get_num_lines(const dwg_ent_mline * restrict mline,int * restrict error)15872 dwg_ent_mline_get_num_lines (const dwg_ent_mline *restrict mline,
15873                              int *restrict error)
15874 {
15875   if (mline)
15876     {
15877       *error = 0;
15878       return mline->num_lines;
15879     }
15880   else
15881     {
15882       *error = 1;
15883       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15884       return '\0';
15885     }
15886 }
15887 
15888 /** Returns all mline vertex lines
15889  */
15890 dwg_mline_line *
dwg_mline_vertex_get_lines(const dwg_mline_vertex * restrict vertex,int * restrict error)15891 dwg_mline_vertex_get_lines (const dwg_mline_vertex *restrict vertex,
15892                             int *restrict error)
15893 {
15894   dwg_mline_line *ptx
15895       = (dwg_mline_line *)calloc (vertex->num_lines, sizeof (dwg_mline_line));
15896   if (ptx)
15897     {
15898       BITCODE_BS i;
15899       *error = 0;
15900       for (i = 0; i < vertex->num_lines; i++)
15901         {
15902           ptx[i] = vertex->lines[i];
15903         }
15904       return ptx;
15905     }
15906   else
15907     {
15908       *error = 1;
15909       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
15910       return NULL;
15911     }
15912 }
15913 
15914 /** Returns number of vertices
15915  */
15916 BITCODE_BS
dwg_ent_mline_get_num_verts(const dwg_ent_mline * restrict mline,int * restrict error)15917 dwg_ent_mline_get_num_verts (const dwg_ent_mline *restrict mline,
15918                              int *restrict error)
15919 {
15920   if (mline)
15921     {
15922       *error = 0;
15923       return mline->num_verts;
15924     }
15925   else
15926     {
15927       *error = 1;
15928       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15929       return 0;
15930     }
15931 }
15932 
15933 /** Returns mline vertices
15934  */
15935 dwg_mline_vertex *
dwg_ent_mline_get_verts(const dwg_ent_mline * restrict mline,int * restrict error)15936 dwg_ent_mline_get_verts (const dwg_ent_mline *restrict mline,
15937                          int *restrict error)
15938 {
15939   dwg_mline_vertex *ptx = (dwg_mline_vertex *)calloc (
15940       mline->num_verts, sizeof (dwg_mline_vertex));
15941   if (ptx)
15942     {
15943       BITCODE_BS i;
15944       *error = 0;
15945       for (i = 0; i < mline->num_verts; i++)
15946         {
15947           ptx[i] = mline->verts[i];
15948         }
15949       return ptx;
15950     }
15951   else
15952     {
15953       *error = 1;
15954       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
15955       return NULL;
15956     }
15957 }
15958 
15959 /*******************************************************************
15960  *              FUNCTIONS FOR VERTEX_PFACE_FACE ENTITY               *
15961  ********************************************************************/
15962 
15963 /** Returns vertex_pface vertind
15964  */
15965 BITCODE_BS
dwg_ent_vertex_pface_face_get_vertind(const dwg_ent_vert_pface_face * face)15966 dwg_ent_vertex_pface_face_get_vertind (const dwg_ent_vert_pface_face *face)
15967 {
15968   if (face)
15969     {
15970       return face->vertind[3];
15971     }
15972   else
15973     {
15974       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15975       return (BITCODE_BS)-1;
15976     }
15977 }
15978 
15979 /** Sets vertex_pface vertind
15980  */
15981 void
dwg_ent_vertex_pface_face_set_vertind(dwg_ent_vert_pface_face * restrict face,const BITCODE_BS vertind[4])15982 dwg_ent_vertex_pface_face_set_vertind (dwg_ent_vert_pface_face *restrict face,
15983                                        const BITCODE_BS vertind[4])
15984 {
15985   if (face
15986 #  ifndef HAVE_NONNULL
15987       && vertind
15988 #  endif
15989   )
15990     {
15991       face->vertind[0] = vertind[0];
15992       face->vertind[1] = vertind[1];
15993       face->vertind[2] = vertind[2];
15994       face->vertind[3] = vertind[3];
15995     }
15996   else
15997     {
15998       LOG_ERROR ("%s: empty arg", __FUNCTION__)
15999     }
16000 }
16001 
16002 /*******************************************************************
16003  *                  FUNCTIONS FOR 3DSOLID ENTITY                     *
16004  ********************************************************************/
16005 
16006 /** Returns the _dwg_entity_3DSOLID::acis_empty bit
16007  */
16008 unsigned char
dwg_ent_3dsolid_get_acis_empty(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16009 dwg_ent_3dsolid_get_acis_empty (const dwg_ent_3dsolid *restrict _3dsolid,
16010                                 int *restrict error)
16011 {
16012   if (_3dsolid)
16013     {
16014       *error = 0;
16015       return _3dsolid->acis_empty;
16016     }
16017   else
16018     {
16019       *error = 1;
16020       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16021       return '\0';
16022     }
16023 }
16024 
16025 /** Sets the _dwg_entity_3DSOLID::acis_empty bit
16026  */
16027 void
dwg_ent_3dsolid_set_acis_empty(dwg_ent_3dsolid * restrict _3dsolid,const unsigned char empty,int * restrict error)16028 dwg_ent_3dsolid_set_acis_empty (dwg_ent_3dsolid *restrict _3dsolid,
16029                                 const unsigned char empty, int *restrict error)
16030 {
16031   if (_3dsolid)
16032     {
16033       *error = 0;
16034       _3dsolid->acis_empty = empty;
16035     }
16036   else
16037     {
16038       *error = 1;
16039       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16040     }
16041 }
16042 
16043 /** Returns the _dwg_entity_3DSOLID::version
16044 /// the modeler format version number, DXF 70.
16045 /// Should be 1, we cannot handle 2 yet
16046  */
16047 BITCODE_BS
dwg_ent_3dsolid_get_version(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16048 dwg_ent_3dsolid_get_version (const dwg_ent_3dsolid *restrict _3dsolid,
16049                              int *restrict error)
16050 {
16051   if (_3dsolid)
16052     {
16053       *error = 0;
16054       return _3dsolid->version;
16055     }
16056   else
16057     {
16058       *error = 1;
16059       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16060       return 0;
16061     }
16062 }
16063 
16064 /** Returns the decrypted _dwg_entity_3DSOLID::acis_data string.
16065  */
16066 unsigned char *
dwg_ent_3dsolid_get_acis_data(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16067 dwg_ent_3dsolid_get_acis_data (const dwg_ent_3dsolid *restrict _3dsolid,
16068                                int *restrict error)
16069 {
16070   if (_3dsolid)
16071     {
16072       *error = 0;
16073       return _3dsolid->acis_data;
16074     }
16075   else
16076     {
16077       *error = 1;
16078       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16079       return NULL;
16080     }
16081 }
16082 
16083 /** Sets the _dwg_entity_3DSOLID::acis_data string.
16084  */
16085 void
dwg_ent_3dsolid_set_acis_data(dwg_ent_3dsolid * restrict _3dsolid,const unsigned char * restrict acis_data,int * restrict error)16086 dwg_ent_3dsolid_set_acis_data (dwg_ent_3dsolid *restrict _3dsolid,
16087                                const unsigned char *restrict acis_data,
16088                                int *restrict error)
16089 {
16090   if (_3dsolid)
16091     {
16092       *error = 0;
16093       _3dsolid->acis_data = (unsigned char *)acis_data;
16094     }
16095   else
16096     {
16097       *error = 1;
16098       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16099     }
16100 }
16101 
16102 /** Returns the _dwg_entity_3DSOLID::wireframe_data_present bit
16103  */
16104 char
dwg_ent_3dsolid_get_wireframe_data_present(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16105 dwg_ent_3dsolid_get_wireframe_data_present (
16106     const dwg_ent_3dsolid *restrict _3dsolid, int *restrict error)
16107 {
16108   if (_3dsolid)
16109     {
16110       *error = 0;
16111       return _3dsolid->wireframe_data_present;
16112     }
16113   else
16114     {
16115       *error = 1;
16116       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16117       return '\0';
16118     }
16119 }
16120 
16121 /** Sets the _dwg_entity_3DSOLID::wireframe_data_present bit
16122  */
16123 void
dwg_ent_3dsolid_set_wireframe_data_present(dwg_ent_3dsolid * restrict _3dsolid,const char present,int * restrict error)16124 dwg_ent_3dsolid_set_wireframe_data_present (dwg_ent_3dsolid *restrict _3dsolid,
16125                                             const char present,
16126                                             int *restrict error)
16127 {
16128   if (_3dsolid)
16129     {
16130       *error = 0;
16131       _3dsolid->wireframe_data_present = present;
16132     }
16133   else
16134     {
16135       *error = 1;
16136       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16137     }
16138 }
16139 
16140 /** Returns the _dwg_entity_3DSOLID::point_present bit
16141  */
16142 char
dwg_ent_3dsolid_get_point_present(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16143 dwg_ent_3dsolid_get_point_present (const dwg_ent_3dsolid *restrict _3dsolid,
16144                                    int *restrict error)
16145 {
16146   if (_3dsolid)
16147     {
16148       *error = 0;
16149       return _3dsolid->point_present;
16150     }
16151   else
16152     {
16153       *error = 1;
16154       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16155       return '\0';
16156     }
16157 }
16158 
16159 /** Sets the _dwg_entity_3DSOLID::point_present bit
16160  */
16161 void
dwg_ent_3dsolid_set_point_present(dwg_ent_3dsolid * restrict _3dsolid,const char present,int * restrict error)16162 dwg_ent_3dsolid_set_point_present (dwg_ent_3dsolid *restrict _3dsolid,
16163                                    const char present, int *restrict error)
16164 {
16165   if (_3dsolid)
16166     {
16167       *error = 0;
16168       _3dsolid->point_present = present;
16169     }
16170   else
16171     {
16172       *error = 1;
16173       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16174     }
16175 }
16176 
16177 /** Returns the _dwg_entity_3DSOLID::point
16178  */
16179 void
dwg_ent_3dsolid_get_point(const dwg_ent_3dsolid * restrict _3dsolid,dwg_point_3d * restrict point,int * restrict error)16180 dwg_ent_3dsolid_get_point (const dwg_ent_3dsolid *restrict _3dsolid,
16181                            dwg_point_3d *restrict point, int *restrict error)
16182 {
16183   if (_3dsolid
16184 #  ifndef HAVE_NONNULL
16185       && point
16186 #  endif
16187   )
16188     {
16189       *error = 0;
16190       point->x = _3dsolid->point.x;
16191       point->y = _3dsolid->point.y;
16192       point->z = _3dsolid->point.z;
16193     }
16194   else
16195     {
16196       *error = 1;
16197       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16198     }
16199 }
16200 
16201 /** Sets the _dwg_entity_3DSOLID::point
16202  */
16203 void
dwg_ent_3dsolid_set_point(dwg_ent_3dsolid * restrict _3dsolid,const dwg_point_3d * restrict point,int * restrict error)16204 dwg_ent_3dsolid_set_point (dwg_ent_3dsolid *restrict _3dsolid,
16205                            const dwg_point_3d *restrict point,
16206                            int *restrict error)
16207 {
16208   if (_3dsolid
16209 #  ifndef HAVE_NONNULL
16210       && point
16211 #  endif
16212   )
16213     {
16214       *error = 0;
16215       _3dsolid->point.x = point->x;
16216       _3dsolid->point.y = point->y;
16217       _3dsolid->point.z = point->z;
16218     }
16219   else
16220     {
16221       *error = 1;
16222       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16223     }
16224 }
16225 
16226 /** Returns the number of _dwg_entity_3DSOLID::isolines
16227  */
16228 BITCODE_BL
dwg_ent_3dsolid_get_isolines(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16229 dwg_ent_3dsolid_get_isolines (const dwg_ent_3dsolid *restrict _3dsolid,
16230                               int *restrict error)
16231 {
16232   if (_3dsolid)
16233     {
16234       *error = 0;
16235       return _3dsolid->isolines;
16236     }
16237   else
16238     {
16239       *error = 1;
16240       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16241       return 0L;
16242     }
16243 }
16244 
16245 /** Sets the number of _dwg_entity_3DSOLID::isolines
16246     (apparently safe to set)
16247  */
16248 void
dwg_ent_3dsolid_set_isolines(dwg_ent_3dsolid * restrict _3dsolid,const BITCODE_BL num,int * restrict error)16249 dwg_ent_3dsolid_set_isolines (dwg_ent_3dsolid *restrict _3dsolid,
16250                               const BITCODE_BL num, int *restrict error)
16251 {
16252   if (_3dsolid)
16253     {
16254       *error = 0;
16255       _3dsolid->isolines = num;
16256     }
16257   else
16258     {
16259       *error = 1;
16260       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16261     }
16262 }
16263 
16264 /** Returns the _dwg_entity_3DSOLID::isoline_present bit
16265     If set, wires and silhouettes are present.
16266  */
16267 char
dwg_ent_3dsolid_get_isoline_present(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16268 dwg_ent_3dsolid_get_isoline_present (const dwg_ent_3dsolid *restrict _3dsolid,
16269                                      int *restrict error)
16270 {
16271   if (_3dsolid)
16272     {
16273       *error = 0;
16274       return _3dsolid->isoline_present;
16275     }
16276   else
16277     {
16278       *error = 1;
16279       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16280       return '\0';
16281     }
16282 }
16283 
16284 /** Sets the _dwg_entity_3DSOLID::isoline_present bit
16285     If set, wires and silhouettes are present.
16286  */
16287 void
dwg_ent_3dsolid_set_isoline_present(dwg_ent_3dsolid * restrict _3dsolid,const char present,int * restrict error)16288 dwg_ent_3dsolid_set_isoline_present (dwg_ent_3dsolid *restrict _3dsolid,
16289                                      const char present, int *restrict error)
16290 {
16291   if (_3dsolid)
16292     {
16293       *error = 0;
16294       _3dsolid->isoline_present = present;
16295     }
16296   else
16297     {
16298       *error = 1;
16299       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16300     }
16301 }
16302 
16303 /** Returns the number of _dwg_entity_3DSOLID::num_wires wires
16304  */
16305 BITCODE_BL
dwg_ent_3dsolid_get_num_wires(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16306 dwg_ent_3dsolid_get_num_wires (const dwg_ent_3dsolid *restrict _3dsolid,
16307                                int *restrict error)
16308 {
16309   if (_3dsolid)
16310     {
16311       *error = 0;
16312       return _3dsolid->num_wires;
16313     }
16314   else
16315     {
16316       *error = 1;
16317       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16318       return 0L;
16319     }
16320 }
16321 
16322 /** Returns all _dwg_entity_3DSOLID::wire structs, as array of
16323  * _dwg_3DSOLID_wire::
16324  */
16325 dwg_3dsolid_wire *
dwg_ent_3dsolid_get_wires(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16326 dwg_ent_3dsolid_get_wires (const dwg_ent_3dsolid *restrict _3dsolid,
16327                            int *restrict error)
16328 {
16329   dwg_3dsolid_wire *wire = (dwg_3dsolid_wire *)calloc (
16330       _3dsolid->num_wires, sizeof (dwg_3dsolid_wire));
16331   if (wire)
16332     {
16333       BITCODE_BL i;
16334       *error = 0;
16335       for (i = 0; i < _3dsolid->num_wires; i++)
16336         {
16337           wire[i] = _3dsolid->wires[i];
16338         }
16339       return wire;
16340     }
16341   else
16342     {
16343       *error = 1;
16344       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
16345       return NULL;
16346     }
16347 }
16348 
16349 /** Returns the number of _dwg_entity_3DSOLID::num_silhouettes entries.
16350  */
16351 BITCODE_BL
dwg_ent_3dsolid_get_num_silhouettes(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16352 dwg_ent_3dsolid_get_num_silhouettes (const dwg_ent_3dsolid *restrict _3dsolid,
16353                                      int *restrict error)
16354 {
16355   if (_3dsolid)
16356     {
16357       *error = 0;
16358       return _3dsolid->num_silhouettes;
16359     }
16360   else
16361     {
16362       *error = 1;
16363       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16364       return 0L;
16365     }
16366 }
16367 
16368 /** Returns all _dwg_entity_3DSOLID::silhouettes structs,
16369     as array of _dwg_3DSOLID_silhouette:: structs.
16370  */
16371 dwg_3dsolid_silhouette *
dwg_ent_3dsolid_get_silhouettes(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16372 dwg_ent_3dsolid_get_silhouettes (const dwg_ent_3dsolid *restrict _3dsolid,
16373                                  int *restrict error)
16374 {
16375   dwg_3dsolid_silhouette *sh = (dwg_3dsolid_silhouette *)calloc (
16376       _3dsolid->num_silhouettes, sizeof (dwg_3dsolid_silhouette));
16377   if (sh)
16378     {
16379       BITCODE_BL i;
16380       *error = 0;
16381       for (i = 0; i < _3dsolid->num_silhouettes; i++)
16382         {
16383           sh[i] = _3dsolid->silhouettes[i];
16384         }
16385       return sh;
16386     }
16387   else
16388     {
16389       *error = 1;
16390       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
16391       return NULL;
16392     }
16393 }
16394 
16395 /** Returns the _dwg_entity_3DSOLID::acis_empty2 bit
16396  */
16397 unsigned char
dwg_ent_3dsolid_get_acis_empty2(const dwg_ent_3dsolid * restrict _3dsolid,int * restrict error)16398 dwg_ent_3dsolid_get_acis_empty2 (const dwg_ent_3dsolid *restrict _3dsolid,
16399                                  int *restrict error)
16400 {
16401   if (_3dsolid)
16402     {
16403       *error = 0;
16404       return _3dsolid->acis_empty2;
16405     }
16406   else
16407     {
16408       *error = 1;
16409       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16410       return '\0';
16411     }
16412 }
16413 
16414 /** Sets the _dwg_entity_3DSOLID::acis_empty2 bit
16415  */
16416 void
dwg_ent_3dsolid_set_acis_empty2(dwg_ent_3dsolid * restrict _3dsolid,unsigned char acis,int * restrict error)16417 dwg_ent_3dsolid_set_acis_empty2 (dwg_ent_3dsolid *restrict _3dsolid,
16418                                  unsigned char acis, int *restrict error)
16419 {
16420   if (_3dsolid)
16421     {
16422       *error = 0;
16423       _3dsolid->acis_empty2 = acis;
16424     }
16425   else
16426     {
16427       *error = 1;
16428       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16429     }
16430 }
16431 
16432 /*******************************************************************
16433  *                   FUNCTIONS FOR REGION ENTITY                     *
16434  ********************************************************************/
16435 
16436 /// Returns the Dwg_Entity_REGION::acis_empty bit
16437 unsigned char
dwg_ent_region_get_acis_empty(const dwg_ent_region * restrict region,int * restrict error)16438 dwg_ent_region_get_acis_empty (const dwg_ent_region *restrict region,
16439                                int *restrict error)
16440 {
16441   return dwg_ent_3dsolid_get_acis_empty ((const dwg_ent_3dsolid *)region,
16442                                          error);
16443 }
16444 
16445 /** Sets the Dwg_Entity_REGION::acis_empty bit
16446  */
16447 void
dwg_ent_region_set_acis_empty(dwg_ent_region * restrict region,unsigned char empty,int * restrict error)16448 dwg_ent_region_set_acis_empty (dwg_ent_region *restrict region,
16449                                unsigned char empty, int *restrict error)
16450 {
16451   dwg_ent_3dsolid_set_acis_empty ((dwg_ent_3dsolid *)region, empty, error);
16452 }
16453 
16454 /** Returns the Dwg_Entity_REGION::version
16455     the modeler format version number, DXF 70.
16456     Should be 1, we cannot handle 2 yet
16457  */
16458 BITCODE_BS
dwg_ent_region_get_version(const dwg_ent_region * restrict region,int * restrict error)16459 dwg_ent_region_get_version (const dwg_ent_region *restrict region,
16460                             int *restrict error)
16461 {
16462   return dwg_ent_3dsolid_get_version ((const dwg_ent_3dsolid *)region, error);
16463 }
16464 
16465 /** Returns the decrypted Dwg_Entity_REGION::acis_data string.
16466  */
16467 unsigned char *
dwg_ent_region_get_acis_data(const dwg_ent_region * restrict region,int * restrict error)16468 dwg_ent_region_get_acis_data (const dwg_ent_region *restrict region,
16469                               int *restrict error)
16470 {
16471   return dwg_ent_3dsolid_get_acis_data ((const dwg_ent_3dsolid *)region,
16472                                         error);
16473 }
16474 
16475 /** Sets the Dwg_Entity_REGION::acis_data string.
16476  */
16477 void
dwg_ent_region_set_acis_data(dwg_ent_region * restrict region,const unsigned char * restrict sat_data,int * restrict error)16478 dwg_ent_region_set_acis_data (dwg_ent_region *restrict region,
16479                               const unsigned char *restrict sat_data,
16480                               int *restrict error)
16481 {
16482   dwg_ent_3dsolid_set_acis_data ((dwg_ent_3dsolid *)region, sat_data, error);
16483 }
16484 
16485 /** Returns the Dwg_Entity_REGION::wireframe_data_present bit
16486  */
16487 char
dwg_ent_region_get_wireframe_data_present(const dwg_ent_region * restrict region,int * restrict error)16488 dwg_ent_region_get_wireframe_data_present (
16489     const dwg_ent_region *restrict region, int *restrict error)
16490 {
16491   return dwg_ent_3dsolid_get_wireframe_data_present (
16492       (const dwg_ent_3dsolid *)region, error);
16493 }
16494 
16495 /** Sets the Dwg_Entity_REGION::wireframe_data_present bit
16496  */
16497 void
dwg_ent_region_set_wireframe_data_present(dwg_ent_region * restrict region,const char present,int * restrict error)16498 dwg_ent_region_set_wireframe_data_present (dwg_ent_region *restrict region,
16499                                            const char present,
16500                                            int *restrict error)
16501 {
16502   dwg_ent_3dsolid_set_wireframe_data_present ((dwg_ent_3dsolid *)region,
16503                                               present, error);
16504 }
16505 
16506 /** Returns the Dwg_Entity_REGION::point_present bit
16507  */
16508 char
dwg_ent_region_get_point_present(const dwg_ent_region * restrict region,int * restrict error)16509 dwg_ent_region_get_point_present (const dwg_ent_region *restrict region,
16510                                   int *restrict error)
16511 {
16512   return dwg_ent_3dsolid_get_point_present ((const dwg_ent_3dsolid *)region,
16513                                             error);
16514 }
16515 
16516 /** Sets the Dwg_Entity_REGION::point_present bit
16517  */
16518 void
dwg_ent_region_set_point_present(dwg_ent_region * restrict region,const char present,int * restrict error)16519 dwg_ent_region_set_point_present (dwg_ent_region *restrict region,
16520                                   const char present, int *restrict error)
16521 {
16522   dwg_ent_3dsolid_set_point_present ((dwg_ent_3dsolid *)region, present,
16523                                      error);
16524 }
16525 
16526 /** Returns the Dwg_Entity_REGION::point
16527  */
16528 void
dwg_ent_region_get_point(const dwg_ent_region * restrict region,dwg_point_3d * restrict point,int * restrict error)16529 dwg_ent_region_get_point (const dwg_ent_region *restrict region,
16530                           dwg_point_3d *restrict point, int *restrict error)
16531 {
16532   return dwg_ent_3dsolid_get_point ((const dwg_ent_3dsolid *)region, point,
16533                                     error);
16534 }
16535 
16536 /** Sets the Dwg_Entity_REGION::point
16537  */
16538 void
dwg_ent_region_set_point(dwg_ent_region * restrict region,const dwg_point_3d * restrict point,int * restrict error)16539 dwg_ent_region_set_point (dwg_ent_region *restrict region,
16540                           const dwg_point_3d *restrict point,
16541                           int *restrict error)
16542 {
16543   dwg_ent_3dsolid_set_point ((dwg_ent_3dsolid *)region, point, error);
16544 }
16545 
16546 /** Returns the Dwg_Entity_REGION::isolines
16547  */
16548 BITCODE_BL
dwg_ent_region_get_isolines(const dwg_ent_region * restrict region,int * restrict error)16549 dwg_ent_region_get_isolines (const dwg_ent_region *restrict region,
16550                              int *restrict error)
16551 {
16552   return dwg_ent_3dsolid_get_isolines ((const dwg_ent_3dsolid *)region,
16553                                        error);
16554 }
16555 
16556 /** Sets the Dwg_Entity_REGION::isolines (??)
16557  */
16558 void
dwg_ent_region_set_isolines(dwg_ent_region * restrict region,const BITCODE_BL num,int * restrict error)16559 dwg_ent_region_set_isolines (dwg_ent_region *restrict region,
16560                                  const BITCODE_BL num, int *restrict error)
16561 {
16562   dwg_ent_3dsolid_set_isolines ((dwg_ent_3dsolid *)region, num, error);
16563 }
16564 
16565 /** Returns the Dwg_Entity_REGION::isoline_present bit
16566 /// If set, wires and silhouettes are present.
16567  */
16568 char
dwg_ent_region_get_isoline_present(const dwg_ent_region * restrict region,int * restrict error)16569 dwg_ent_region_get_isoline_present (const dwg_ent_region *restrict region,
16570                                     int *restrict error)
16571 {
16572   return dwg_ent_3dsolid_get_isoline_present ((const dwg_ent_3dsolid *)region,
16573                                               error);
16574 }
16575 
16576 /** Sets the Dwg_Entity_REGION::isoline_present bit
16577 /// If set, wires and silhouettes are present.
16578  */
16579 void
dwg_ent_region_set_isoline_present(dwg_ent_region * restrict region,char present,int * restrict error)16580 dwg_ent_region_set_isoline_present (dwg_ent_region *restrict region,
16581                                     char present, int *restrict error)
16582 {
16583   dwg_ent_3dsolid_set_isoline_present ((dwg_ent_3dsolid *)region, present,
16584                                        error);
16585 }
16586 
16587 /** Returns the number of Dwg_Entity_REGION::num_wires wires
16588  */
16589 BITCODE_BL
dwg_ent_region_get_num_wires(const dwg_ent_region * restrict region,int * restrict error)16590 dwg_ent_region_get_num_wires (const dwg_ent_region *restrict region,
16591                               int *restrict error)
16592 {
16593   return dwg_ent_3dsolid_get_num_wires ((const dwg_ent_3dsolid *)region,
16594                                         error);
16595 }
16596 
16597 // TODO dwg_ent_region_add_wire, dwg_ent_region_delete_wire
16598 
16599 /** Returns all Dwg_Entity_REGION::wire structs, as array of
16600  * _dwg_3DSOLID_wire::
16601  */
16602 dwg_3dsolid_wire *
dwg_ent_region_get_wires(const dwg_ent_region * restrict region,int * restrict error)16603 dwg_ent_region_get_wires (const dwg_ent_region *restrict region,
16604                           int *restrict error)
16605 {
16606   return dwg_ent_3dsolid_get_wires ((const dwg_ent_3dsolid *)region, error);
16607 }
16608 
16609 /** Returns the number of Dwg_Entity_REGION::num_silhouettes entries.
16610  */
16611 BITCODE_BL
dwg_ent_region_get_num_silhouettes(const dwg_ent_region * restrict region,int * restrict error)16612 dwg_ent_region_get_num_silhouettes (const dwg_ent_region *restrict region,
16613                                     int *restrict error)
16614 {
16615   return dwg_ent_3dsolid_get_num_silhouettes ((const dwg_ent_3dsolid *)region,
16616                                               error);
16617 }
16618 
16619 // TODO dwg_ent_region_add_silhouette, dwg_ent_region_delete_silhouette
16620 
16621 /** Returns all Dwg_Entity_REGION::silhouettes structs, as array of
16622  * _dwg_3DSOLID_silhouette::
16623  */
16624 dwg_3dsolid_silhouette *
dwg_ent_region_get_silhouettes(const dwg_ent_region * restrict region,int * restrict error)16625 dwg_ent_region_get_silhouettes (const dwg_ent_region *restrict region,
16626                                 int *restrict error)
16627 {
16628   return dwg_ent_3dsolid_get_silhouettes ((const dwg_ent_3dsolid *)region,
16629                                           error);
16630 }
16631 
16632 /** Returns the Dwg_Entity_REGION::acis_empty2 bit
16633  */
16634 unsigned char
dwg_ent_region_get_acis_empty2(const dwg_ent_region * restrict region,int * restrict error)16635 dwg_ent_region_get_acis_empty2 (const dwg_ent_region *restrict region,
16636                                 int *restrict error)
16637 {
16638   return dwg_ent_3dsolid_get_acis_empty2 ((const dwg_ent_3dsolid *)region,
16639                                           error);
16640 }
16641 
16642 /** Sets the Dwg_Entity_REGION::acis_empty2 bit
16643  */
16644 void
dwg_ent_region_set_acis_empty2(dwg_ent_region * restrict region,unsigned char empty2,int * restrict error)16645 dwg_ent_region_set_acis_empty2 (dwg_ent_region *restrict region,
16646                                 unsigned char empty2, int *restrict error)
16647 {
16648   dwg_ent_3dsolid_set_acis_empty2 ((dwg_ent_3dsolid *)region, empty2, error);
16649 }
16650 
16651 /*******************************************************************
16652  *                    FUNCTIONS FOR BODY ENTITY                      *
16653  ********************************************************************/
16654 
16655 // Returns the Dwg_Entity_BODY::acis_empty bit
16656 unsigned char
dwg_ent_body_get_acis_empty(const dwg_ent_body * restrict body,int * restrict error)16657 dwg_ent_body_get_acis_empty (const dwg_ent_body *restrict body,
16658                              int *restrict error)
16659 {
16660   return dwg_ent_3dsolid_get_acis_empty ((const dwg_ent_3dsolid *)body, error);
16661 }
16662 
16663 /** Sets the Dwg_Entity_BODY::acis_empty bit
16664  */
16665 void
dwg_ent_body_set_acis_empty(dwg_ent_body * restrict body,unsigned char empty,int * restrict error)16666 dwg_ent_body_set_acis_empty (dwg_ent_body *restrict body, unsigned char empty,
16667                              int *restrict error)
16668 {
16669   dwg_ent_3dsolid_set_acis_empty ((dwg_ent_3dsolid *)body, empty, error);
16670 }
16671 
16672 /** Returns the Dwg_Entity_BODY::version
16673 /// the modeler format version number, DXF 70.
16674 /// Should be 1, we cannot handle 2 yet
16675  */
16676 BITCODE_BS
dwg_ent_body_get_version(const dwg_ent_body * restrict body,int * restrict error)16677 dwg_ent_body_get_version (const dwg_ent_body *restrict body,
16678                           int *restrict error)
16679 {
16680   return dwg_ent_3dsolid_get_version ((const dwg_ent_3dsolid *)body, error);
16681 }
16682 
16683 /** Returns the decrypted Dwg_Entity_BODY::acis_data string.
16684  */
16685 unsigned char *
dwg_ent_body_get_acis_data(const dwg_ent_body * restrict body,int * restrict error)16686 dwg_ent_body_get_acis_data (const dwg_ent_body *restrict body,
16687                             int *restrict error)
16688 {
16689   return dwg_ent_3dsolid_get_acis_data ((const dwg_ent_3dsolid *)body, error);
16690 }
16691 
16692 /** Sets the Dwg_Entity_BODY::acis_data string.
16693  */
16694 void
dwg_ent_body_set_acis_data(dwg_ent_body * restrict body,const unsigned char * restrict sat_data,int * restrict error)16695 dwg_ent_body_set_acis_data (dwg_ent_body *restrict body,
16696                             const unsigned char *restrict sat_data,
16697                             int *restrict error)
16698 {
16699   dwg_ent_3dsolid_set_acis_data ((dwg_ent_3dsolid *)body, sat_data, error);
16700 }
16701 
16702 /** Returns the Dwg_Entity_BODY::wireframe_data_present bit
16703  */
16704 char
dwg_ent_body_get_wireframe_data_present(const dwg_ent_body * restrict body,int * restrict error)16705 dwg_ent_body_get_wireframe_data_present (const dwg_ent_body *restrict body,
16706                                          int *restrict error)
16707 {
16708   return dwg_ent_3dsolid_get_wireframe_data_present (
16709       (const dwg_ent_3dsolid *)body, error);
16710 }
16711 
16712 /** Sets the Dwg_Entity_BODY::wireframe_data_present bit
16713  */
16714 void
dwg_ent_body_set_wireframe_data_present(dwg_ent_body * restrict body,const char present,int * restrict error)16715 dwg_ent_body_set_wireframe_data_present (dwg_ent_body *restrict body,
16716                                          const char present,
16717                                          int *restrict error)
16718 {
16719   dwg_ent_3dsolid_set_wireframe_data_present ((dwg_ent_3dsolid *)body, present,
16720                                               error);
16721 }
16722 
16723 /** Returns the Dwg_Entity_BODY::point_present bit
16724  */
16725 char
dwg_ent_body_get_point_present(const dwg_ent_body * restrict body,int * restrict error)16726 dwg_ent_body_get_point_present (const dwg_ent_body *restrict body,
16727                                 int *restrict error)
16728 {
16729   return dwg_ent_3dsolid_get_point_present ((const dwg_ent_3dsolid *)body,
16730                                             error);
16731 }
16732 
16733 /** Sets the Dwg_Entity_BODY::point_present bit
16734  */
16735 void
dwg_ent_body_set_point_present(dwg_ent_body * restrict body,const char present,int * restrict error)16736 dwg_ent_body_set_point_present (dwg_ent_body *restrict body,
16737                                 const char present, int *restrict error)
16738 {
16739   dwg_ent_3dsolid_set_point_present ((dwg_ent_3dsolid *)body, present, error);
16740 }
16741 
16742 /** Returns the Dwg_Entity_BODY::point
16743  */
16744 void
dwg_ent_body_get_point(const dwg_ent_body * restrict body,dwg_point_3d * restrict point,int * restrict error)16745 dwg_ent_body_get_point (const dwg_ent_body *restrict body,
16746                         dwg_point_3d *restrict point, int *restrict error)
16747 {
16748   return dwg_ent_3dsolid_get_point ((const dwg_ent_3dsolid *)body, point,
16749                                     error);
16750 }
16751 
16752 /** Sets the Dwg_Entity_BODY::point
16753  */
16754 void
dwg_ent_body_set_point(dwg_ent_body * restrict body,const dwg_point_3d * restrict point,int * restrict error)16755 dwg_ent_body_set_point (dwg_ent_body *restrict body,
16756                         const dwg_point_3d *restrict point,
16757                         int *restrict error)
16758 {
16759   dwg_ent_3dsolid_set_point ((dwg_ent_3dsolid *)body, point, error);
16760 }
16761 
16762 /** Returns the Dwg_Entity_BODY::isolines
16763  */
16764 BITCODE_BL
dwg_ent_body_get_isolines(const dwg_ent_body * restrict body,int * restrict error)16765 dwg_ent_body_get_isolines (const dwg_ent_body *restrict body,
16766                                int *restrict error)
16767 {
16768   return dwg_ent_3dsolid_get_isolines ((const dwg_ent_3dsolid *)body,
16769                                            error);
16770 }
16771 
16772 /** Sets the Dwg_Entity_BODY::isolines (??)
16773  */
16774 void
dwg_ent_body_set_isolines(dwg_ent_body * restrict body,const BITCODE_BL num,int * restrict error)16775 dwg_ent_body_set_isolines (dwg_ent_body *restrict body,
16776                                const BITCODE_BL num, int *restrict error)
16777 {
16778   dwg_ent_3dsolid_set_isolines ((dwg_ent_3dsolid *)body, num, error);
16779 }
16780 
16781 /** Returns the Dwg_Entity_BODY::isoline_present bit
16782     If set, wires and silhouettes are present.
16783  */
16784 char
dwg_ent_body_get_isoline_present(const dwg_ent_body * restrict body,int * restrict error)16785 dwg_ent_body_get_isoline_present (const dwg_ent_body *restrict body,
16786                                   int *restrict error)
16787 {
16788   return dwg_ent_3dsolid_get_isoline_present ((const dwg_ent_3dsolid *)body,
16789                                               error);
16790 }
16791 
16792 /** Sets the Dwg_Entity_BODY::isoline_present bit
16793     If set, wires and silhouettes are present.
16794  */
16795 void
dwg_ent_body_set_isoline_present(dwg_ent_body * restrict body,char present,int * restrict error)16796 dwg_ent_body_set_isoline_present (dwg_ent_body *restrict body, char present,
16797                                   int *restrict error)
16798 {
16799   dwg_ent_3dsolid_set_isoline_present ((dwg_ent_3dsolid *)body, present,
16800                                        error);
16801 }
16802 
16803 /** Returns the number of Dwg_Entity_BODY::num_wires wires
16804  */
16805 BITCODE_BL
dwg_ent_body_get_num_wires(const dwg_ent_body * restrict body,int * restrict error)16806 dwg_ent_body_get_num_wires (const dwg_ent_body *restrict body,
16807                             int *restrict error)
16808 {
16809   return dwg_ent_3dsolid_get_num_wires ((const dwg_ent_3dsolid *)body, error);
16810 }
16811 
16812 // TODO dwg_ent_body_add_wire, dwg_ent_body_delete_wire
16813 
16814 /** Returns all Dwg_Entity_BODY::wire structs, as array of _dwg_3DSOLID_wire::
16815  */
16816 dwg_3dsolid_wire *
dwg_ent_body_get_wires(const dwg_ent_body * restrict body,int * restrict error)16817 dwg_ent_body_get_wires (const dwg_ent_body *restrict body, int *restrict error)
16818 {
16819   return dwg_ent_3dsolid_get_wires ((const dwg_ent_3dsolid *)body, error);
16820 }
16821 
16822 /** Returns the number of Dwg_Entity_BODY::num_silhouettes entries.
16823  */
16824 BITCODE_BL
dwg_ent_body_get_num_silhouettes(const dwg_ent_body * restrict body,int * restrict error)16825 dwg_ent_body_get_num_silhouettes (const dwg_ent_body *restrict body,
16826                                   int *restrict error)
16827 {
16828   return dwg_ent_3dsolid_get_num_silhouettes ((const dwg_ent_3dsolid *)body,
16829                                               error);
16830 }
16831 
16832 // TODO dwg_ent_body_add_silhouette, dwg_ent_body_delete_silhouette
16833 
16834 /** Returns all Dwg_Entity_BODY::silhouettes structs, as array of
16835  * _dwg_3DSOLID_silhouette::
16836  */
16837 dwg_3dsolid_silhouette *
dwg_ent_body_get_silhouettes(const dwg_ent_body * restrict body,int * restrict error)16838 dwg_ent_body_get_silhouettes (const dwg_ent_body *restrict body,
16839                               int *restrict error)
16840 {
16841   return dwg_ent_3dsolid_get_silhouettes ((const dwg_ent_3dsolid *)body,
16842                                           error);
16843 }
16844 
16845 /** Returns the Dwg_Entity_BODY::acis_empty2 bit
16846  */
16847 unsigned char
dwg_ent_body_get_acis_empty2(const dwg_ent_body * restrict body,int * restrict error)16848 dwg_ent_body_get_acis_empty2 (const dwg_ent_body *restrict body,
16849                               int *restrict error)
16850 {
16851   return dwg_ent_3dsolid_get_acis_empty2 ((const dwg_ent_3dsolid *)body,
16852                                           error);
16853 }
16854 
16855 /** Sets the Dwg_Entity_BODY::acis_empty2 bit
16856  */
16857 void
dwg_ent_body_set_acis_empty2(dwg_ent_body * restrict body,unsigned char empty2,int * restrict error)16858 dwg_ent_body_set_acis_empty2 (dwg_ent_body *restrict body,
16859                               unsigned char empty2, int *restrict error)
16860 {
16861   dwg_ent_3dsolid_set_acis_empty2 ((dwg_ent_3dsolid *)body, empty2, error);
16862 }
16863 
16864 /*******************************************************************
16865  *                    FUNCTIONS FOR TABLE ENTITY                     *
16866  ********************************************************************/
16867 
16868 /** Sets _dwg_entity_TABLE::ins_pt, DXF 10.
16869 \param[in,out] table      dwg_ent_table*
16870 \param[in]     point      dwg_point_3d *
16871 \param[out]    error      set to 0 for ok, 1 on error
16872 \deprecated
16873 */
16874 void
dwg_ent_table_set_insertion_pt(dwg_ent_table * restrict table,const dwg_point_3d * restrict point,int * restrict error)16875 dwg_ent_table_set_insertion_pt (dwg_ent_table *restrict table,
16876                                    const dwg_point_3d *restrict point,
16877                                    int *restrict error)
16878 {
16879   if (table
16880 #  ifndef HAVE_NONNULL
16881       && point
16882 #  endif
16883   )
16884     {
16885       *error = 0;
16886       table->ins_pt.x = point->x;
16887       table->ins_pt.y = point->y;
16888       table->ins_pt.z = point->z;
16889     }
16890   else
16891     {
16892       *error = 1;
16893       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16894     }
16895 }
16896 
16897 /** Returns _dwg_entity_TABLE::ins_pt, DXF 10.
16898 \param[in]  table      dwg_ent_table *
16899 \param[out] point      dwg_point_3d *
16900 \param[out] error      set to 0 for ok, 1 on error
16901 \deprecated
16902 */
16903 void
dwg_ent_table_get_insertion_pt(const dwg_ent_table * restrict table,dwg_point_3d * restrict point,int * restrict error)16904 dwg_ent_table_get_insertion_pt (const dwg_ent_table *restrict table,
16905                                 dwg_point_3d *restrict point,
16906                                 int *restrict error)
16907 {
16908   if (table
16909 #  ifndef HAVE_NONNULL
16910       && point
16911 #  endif
16912   )
16913     {
16914       *error = 0;
16915       point->x = table->ins_pt.x;
16916       point->y = table->ins_pt.y;
16917       point->z = table->ins_pt.z;
16918     }
16919   else
16920     {
16921       *error = 1;
16922       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16923     }
16924 }
16925 
16926 /** Sets _dwg_entity_TABLE::scale, DXF 41. and the internal scale_flag.
16927 \param[in,out] table      dwg_ent_table*
16928 \param[in]     scale3d    dwg_point_3d*, scale in x, y, z
16929 \param[out]    error      set to 0 for ok, 1 on error
16930 \deprecated
16931 */
16932 void
dwg_ent_table_set_scale(dwg_ent_table * restrict table,const dwg_point_3d * restrict scale3d,int * restrict error)16933 dwg_ent_table_set_scale (dwg_ent_table *restrict table,
16934                          const dwg_point_3d *restrict scale3d,
16935                          int *restrict error)
16936 {
16937   if (table
16938 #  ifndef HAVE_NONNULL
16939       && scale3d
16940 #  endif
16941   )
16942     {
16943       *error = 0;
16944       // set scale_flag (for r2000+)
16945       if (scale3d->x == 1.0)
16946         {
16947           if (scale3d->y == 1.0 && scale3d->z == 1.0)
16948             table->scale_flag = 3;
16949           else
16950             table->scale_flag = 1;
16951         }
16952       else if (scale3d->x == scale3d->y && scale3d->x == scale3d->z)
16953         table->scale_flag = 2;
16954       else
16955         table->scale_flag = 0;
16956 
16957       table->scale.x = scale3d->x;
16958       table->scale.y = scale3d->y;
16959       table->scale.z = scale3d->z;
16960     }
16961   else
16962     {
16963       *error = 1;
16964       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16965     }
16966 }
16967 
16968 /** Returns _dwg_entity_TABLE::scale, DXF 41. if r13+
16969 \param[in]  table      dwg_ent_table *
16970 \param[out] scale3d    dwg_point_3d *
16971 \param[out] error      set to 0 for ok, 1 on error
16972 \deprecated
16973 */
16974 void
dwg_ent_table_get_scale(const dwg_ent_table * restrict table,dwg_point_3d * restrict scale3d,int * restrict error)16975 dwg_ent_table_get_scale (const dwg_ent_table *restrict table,
16976                          dwg_point_3d *restrict scale3d, int *restrict error)
16977 {
16978   if (table
16979 #  ifndef HAVE_NONNULL
16980       && scale3d
16981 #  endif
16982   )
16983     {
16984       *error = 0;
16985       scale3d->x = table->scale.x;
16986       scale3d->y = table->scale.y;
16987       scale3d->z = table->scale.z;
16988     }
16989   else
16990     {
16991       *error = 1;
16992       LOG_ERROR ("%s: empty arg", __FUNCTION__)
16993     }
16994 }
16995 
16996 /** Sets _dwg_entity_TABLE::rotation, DXF 50.
16997 \param[in]  table      dwg_ent_table *
16998 \param[in]  rotation   double
16999 \param[out] error      set to 0 for ok, 1 on error
17000 \deprecated
17001 */
17002 void
dwg_ent_table_set_rotation(dwg_ent_table * restrict table,const double rotation,int * restrict error)17003 dwg_ent_table_set_rotation (dwg_ent_table *restrict table,
17004                             const double rotation, int *restrict error)
17005 {
17006   if (table)
17007     {
17008       *error = 0;
17009       table->rotation = rotation;
17010     }
17011   else
17012     {
17013       *error = 1;
17014       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17015     }
17016 }
17017 
17018 /** Returns _dwg_entity_TABLE::rotation, DXF 50.
17019 \param[in]  table      dwg_ent_table *
17020 \param[out] error      set to 0 for ok, 1 on error
17021 \deprecated
17022 */
17023 double
dwg_ent_table_get_rotation(const dwg_ent_table * restrict table,int * restrict error)17024 dwg_ent_table_get_rotation (const dwg_ent_table *restrict table,
17025                             int *restrict error)
17026 {
17027   if (table)
17028     {
17029       *error = 0;
17030       return table->rotation;
17031     }
17032   else
17033     {
17034       *error = 1;
17035       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17036       return bit_nan ();
17037     }
17038 }
17039 
17040 /** Sets _dwg_entity_TABLE::extrusion, DXF 210.
17041 \param[in,out] table      dwg_ent_table *
17042 \param[in]     vector     dwg_point_3d *
17043 \param[out]    error      set to 0 for ok, 1 on error
17044 \deprecated
17045 */
17046 void
dwg_ent_table_set_extrusion(dwg_ent_table * restrict table,const dwg_point_3d * restrict vector,int * restrict error)17047 dwg_ent_table_set_extrusion (dwg_ent_table *restrict table,
17048                              const dwg_point_3d *restrict vector,
17049                              int *restrict error)
17050 {
17051   if (table
17052 #  ifndef HAVE_NONNULL
17053       && vector
17054 #  endif
17055   )
17056     {
17057       *error = 0;
17058       table->extrusion.x = vector->x;
17059       table->extrusion.y = vector->y;
17060       table->extrusion.z = vector->z;
17061     }
17062   else
17063     {
17064       *error = 1;
17065       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17066     }
17067 }
17068 
17069 /** Returns _dwg_entity_TABLE::extrusion, DXF 210.
17070 \param[in]  table      dwg_ent_table *
17071 \param[out] vector     dwg_point_3d *
17072 \param[out] error      set to 0 for ok, 1 on error
17073 \deprecated
17074 */
17075 void
dwg_ent_table_get_extrusion(const dwg_ent_table * restrict table,dwg_point_3d * restrict vector,int * restrict error)17076 dwg_ent_table_get_extrusion (const dwg_ent_table *restrict table,
17077                              dwg_point_3d *restrict vector,
17078                              int *restrict error)
17079 {
17080   if (table
17081 #  ifndef HAVE_NONNULL
17082       && vector
17083 #  endif
17084   )
17085     {
17086       *error = 0;
17087       vector->x = table->extrusion.x;
17088       vector->y = table->extrusion.y;
17089       vector->z = table->extrusion.z;
17090     }
17091   else
17092     {
17093       *error = 1;
17094       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17095     }
17096 }
17097 
17098 /** Returns _dwg_entity_TABLE::has_attribs boolean, DXF 66.
17099 \param[in]  table      dwg_ent_table *
17100 \param[out] error      set to 0 for ok, 1 on error
17101 \deprecated
17102 */
17103 unsigned char
dwg_ent_table_has_attribs(dwg_ent_table * restrict table,int * restrict error)17104 dwg_ent_table_has_attribs (dwg_ent_table *restrict table, int *restrict error)
17105 {
17106   if (table)
17107     {
17108       *error = 0;
17109       return table->has_attribs;
17110     }
17111   else
17112     {
17113       *error = 1;
17114       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17115       return '\0';
17116     }
17117 }
17118 
17119 // needs to adjust handle array: add/delete
17120 // TODO dwg_ent_table_add_owned, dwg_ent_table_delete_owned
17121 
17122 /** Returns _dwg_entity_TABLE::num_owned, no DXF.
17123 \param[in]  table      dwg_ent_table *
17124 \param[out] error      set to 0 for ok, 1 on error
17125 \deprecated
17126 */
17127 BITCODE_BL
dwg_ent_table_get_num_owned(const dwg_ent_table * restrict table,int * restrict error)17128 dwg_ent_table_get_num_owned (const dwg_ent_table *restrict table,
17129                              int *restrict error)
17130 {
17131   if (table)
17132     {
17133       *error = 0;
17134       return table->num_owned;
17135     }
17136   else
17137     {
17138       *error = 1;
17139       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17140       return 0L;
17141     }
17142 }
17143 
17144 /** Sets _dwg_entity_TABLE::flag_for_table_value, DXF 90.
17145 \param[in]  table      dwg_ent_table *
17146 \param[in]  value      short
17147 
17148     Bit flags, 0x06 (0x02 + 0x04): has block, 0x10: table direction, 0
17149     = up, 1 = down, 0x20: title suppressed. Normally 0x06 is always
17150     set.
17151 
17152 \param[out] error      set to 0 for ok, 1 on error
17153 \deprecated
17154 */
17155 void
dwg_ent_table_set_flag_for_table_value(dwg_ent_table * restrict table,const BITCODE_BS value,int * restrict error)17156 dwg_ent_table_set_flag_for_table_value (dwg_ent_table *restrict table,
17157                                         const BITCODE_BS value,
17158                                         int *restrict error)
17159 {
17160   if (table
17161 #  ifndef HAVE_NONNULL
17162       && value < 0x30
17163 #  endif
17164   )
17165     {
17166       *error = 0;
17167       table->flag_for_table_value = value;
17168     }
17169   else
17170     {
17171       *error = 1;
17172       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17173     }
17174 }
17175 
17176 /** Returns _dwg_entity_TABLE::flag_for_table_value, DXF 90.
17177     \sa dwg_ent_table_set_flag_for_table_value
17178 \param[in]  table      dwg_ent_table *
17179 \param[out] error      set to 0 for ok, 1 on error
17180 \deprecated
17181 */
17182 BITCODE_BS
dwg_ent_table_get_flag_for_table_value(const dwg_ent_table * restrict table,int * restrict error)17183 dwg_ent_table_get_flag_for_table_value (const dwg_ent_table *restrict table,
17184                                         int *restrict error)
17185 {
17186   if (table)
17187     {
17188       *error = 0;
17189       return table->flag_for_table_value;
17190     }
17191   else
17192     {
17193       *error = 1;
17194       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17195       return 0;
17196     }
17197 }
17198 
17199 /** Sets _dwg_entity_TABLE::horiz_direction, DXF 11.
17200 \param[out] table      dwg_ent_table *
17201 \param[in]  vector      dwg_point_3d *
17202 \param[out] error      set to 0 for ok, 1 on error
17203 \deprecated
17204 */
17205 void
dwg_ent_table_set_horiz_direction(dwg_ent_table * restrict table,const dwg_point_3d * restrict vector,int * restrict error)17206 dwg_ent_table_set_horiz_direction (dwg_ent_table *restrict table,
17207                                    const dwg_point_3d *restrict vector,
17208                                    int *restrict error)
17209 {
17210   if (table
17211 #  ifndef HAVE_NONNULL
17212       && vector
17213 #  endif
17214   )
17215     {
17216       *error = 0;
17217       table->horiz_direction.x = vector->x;
17218       table->horiz_direction.y = vector->y;
17219       table->horiz_direction.z = vector->z;
17220     }
17221   else
17222     {
17223       *error = 1;
17224       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17225     }
17226 }
17227 
17228 /** Returns _dwg_entity_TABLE::horiz_direction, DXF 11.
17229 \param[in]  table      dwg_ent_table *
17230 \param[out]  vector      dwg_point_3d *
17231 \param[out] error      set to 0 for ok, 1 on error
17232 \deprecated
17233 */
17234 void
dwg_ent_table_get_horiz_direction(const dwg_ent_table * restrict table,dwg_point_3d * restrict vector,int * restrict error)17235 dwg_ent_table_get_horiz_direction (const dwg_ent_table *restrict table,
17236                                    dwg_point_3d *restrict vector,
17237                                    int *restrict error)
17238 {
17239   if (table
17240 #  ifndef HAVE_NONNULL
17241       && vector
17242 #  endif
17243   )
17244     {
17245       *error = 0;
17246       vector->x = table->horiz_direction.x;
17247       vector->y = table->horiz_direction.y;
17248       vector->z = table->horiz_direction.z;
17249     }
17250   else
17251     {
17252       *error = 1;
17253       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17254     }
17255 }
17256 
17257 /** Returns _dwg_entity_TABLE::num_cols number of columns, DXF 91.
17258 \param[in]  table      dwg_ent_table *
17259 \param[out] error      set to 0 for ok, 1 on error
17260 \deprecated
17261 */
17262 BITCODE_BL
dwg_ent_table_get_num_cols(const dwg_ent_table * restrict table,int * restrict error)17263 dwg_ent_table_get_num_cols (const dwg_ent_table *restrict table,
17264                             int *restrict error)
17265 {
17266   if (table)
17267     {
17268       *error = 0;
17269       return table->num_cols;
17270     }
17271   else
17272     {
17273       *error = 1;
17274       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17275       return 0L;
17276     }
17277 }
17278 
17279 /** Returns _dwg_entity_TABLE::num_cols number of rows, DXF 92.
17280 \param[in]  table      dwg_ent_table *
17281 \param[out] error      set to 0 for ok, 1 on error
17282 \deprecated
17283 */
17284 BITCODE_BL
dwg_ent_table_get_num_rows(const dwg_ent_table * restrict table,int * restrict error)17285 dwg_ent_table_get_num_rows (const dwg_ent_table *restrict table,
17286                             int *restrict error)
17287 {
17288   if (table)
17289     {
17290       *error = 0;
17291       return table->num_rows;
17292     }
17293   else
17294     {
17295       *error = 1;
17296       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17297       return 0L;
17298     }
17299 }
17300 
17301 //  TODO dwg_ent_table_add_col, dwg_ent_table_delete_col
17302 //  TODO dwg_ent_table_add_row, dwg_ent_table_delete_row
17303 
17304 /** Returns array of _dwg_entity_TABLE::col_widths, DXF 142
17305 \param[in]  table      dwg_ent_table *
17306 \param[out] error      set to 0 for ok, 1 on error
17307 \deprecated
17308 */
17309 double *
dwg_ent_table_get_col_widths(const dwg_ent_table * restrict table,int * restrict error)17310 dwg_ent_table_get_col_widths (const dwg_ent_table *restrict table,
17311                               int *restrict error)
17312 {
17313   if (table)
17314     {
17315       *error = 0;
17316       return table->col_widths;
17317     }
17318   else
17319     {
17320       *error = 1;
17321       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17322       return NULL;
17323     }
17324 }
17325 
17326 /** Returns array of _dwg_entity_TABLE::row_heights, DXF 141
17327 \param[in]  table      dwg_ent_table *
17328 \param[out] error      set to 0 for ok, 1 on error
17329 \deprecated
17330 */
17331 double *
dwg_ent_table_get_row_heights(const dwg_ent_table * restrict table,int * restrict error)17332 dwg_ent_table_get_row_heights (const dwg_ent_table *restrict table,
17333                                int *restrict error)
17334 {
17335   if (table)
17336     {
17337       *error = 0;
17338       return table->row_heights;
17339     }
17340   else
17341     {
17342       *error = 1;
17343       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17344       return NULL;
17345     }
17346 }
17347 
17348 /** Returns _dwg_entity_TABLE::has_table_overrides boolean, no DXF.
17349 \param[in]  table      dwg_ent_table *
17350 \param[out] error      set to 0 for ok, 1 on error
17351 \deprecated
17352 */
17353 BITCODE_B
dwg_ent_table_has_table_overrides(dwg_ent_table * restrict table,int * restrict error)17354 dwg_ent_table_has_table_overrides (dwg_ent_table *restrict table,
17355                                    int *restrict error)
17356 {
17357   if (table)
17358     {
17359       *error = 0;
17360       return table->has_table_overrides;
17361     }
17362   else
17363     {
17364       *error = 1;
17365       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17366       return '\0';
17367     }
17368 }
17369 
17370 /** Sets _dwg_entity_TABLE::table_flag_override, DXF 90.
17371 \param[in]  table      dwg_ent_table *
17372 \param[in]  override   0 - 0x7fffff
17373 \param[out] error      set to 0 for ok, 1 on error
17374 \deprecated
17375 */
17376 void
dwg_ent_table_set_table_flag_override(dwg_ent_table * restrict table,const BITCODE_BL override,int * restrict error)17377 dwg_ent_table_set_table_flag_override (dwg_ent_table *restrict table,
17378                                        const BITCODE_BL override,
17379                                        int *restrict error)
17380 {
17381   if (table != NULL && override < 0x800000)
17382     {
17383       *error = 0;
17384       table->table_flag_override = override;
17385     }
17386   else
17387     {
17388       *error = 1;
17389       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17390     }
17391 }
17392 
17393 /** Returns _dwg_entity_TABLE::table_flag_override, DXF 93.
17394 \param[in]  table      dwg_ent_table *
17395 \param[out] error      set to 0 for ok, 1 on error
17396 \deprecated
17397 */
17398 BITCODE_BL
dwg_ent_table_get_table_flag_override(const dwg_ent_table * restrict table,int * restrict error)17399 dwg_ent_table_get_table_flag_override (const dwg_ent_table *restrict table,
17400                                        int *restrict error)
17401 {
17402   if (table)
17403     {
17404       *error = 0;
17405       return table->table_flag_override;
17406     }
17407   else
17408     {
17409       *error = 1;
17410       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17411       return 0L;
17412     }
17413 }
17414 
17415 /** Sets _dwg_entity_TABLE::title_suppressed, DXF 280.
17416 \param[in]  table      dwg_ent_table *
17417 \param[in]  yesno      0 or 1
17418 \param[out] error      set to 0 for ok, 1 on error
17419 \deprecated
17420 */
17421 void
dwg_ent_table_set_title_suppressed(dwg_ent_table * restrict table,const unsigned char yesno,int * restrict error)17422 dwg_ent_table_set_title_suppressed (dwg_ent_table *restrict table,
17423                                     const unsigned char yesno,
17424                                     int *restrict error)
17425 {
17426   if (table != NULL && yesno <= 1)
17427     {
17428       *error = 0;
17429       if (yesno)
17430         table->table_flag_override |= 0x1;
17431       table->title_suppressed = yesno;
17432     }
17433   else
17434     {
17435       *error = 1;
17436       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17437     }
17438 }
17439 
17440 /** Returns _dwg_entity_TABLE::title_suppressed, DXF 280.
17441 \param[in]  table      dwg_ent_table *
17442 \param[out] error      set to 0 for ok, 1 on error
17443 \deprecated
17444 */
17445 unsigned char
dwg_ent_table_get_title_suppressed(const dwg_ent_table * restrict table,int * restrict error)17446 dwg_ent_table_get_title_suppressed (const dwg_ent_table *restrict table,
17447                                     int *restrict error)
17448 {
17449   if (table)
17450     {
17451       *error = 0;
17452       return table->title_suppressed;
17453     }
17454   else
17455     {
17456       *error = 1;
17457       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17458       return '\0';
17459     }
17460 }
17461 
17462 /** Sets _dwg_entity_TABLE::header_suppressed, DXF 281.
17463 \param[in]  table      dwg_ent_table *
17464 \param[in]  header     0 or 1
17465 \param[out] error      set to 0 for ok, 1 on error
17466 \deprecated
17467 */
17468 void
dwg_ent_table_set_header_suppressed(dwg_ent_table * restrict table,const unsigned char header,int * restrict error)17469 dwg_ent_table_set_header_suppressed (dwg_ent_table *restrict table,
17470                                      const unsigned char header,
17471                                      int *restrict error)
17472 {
17473   if (table != NULL && header <= 1)
17474     {
17475       *error = 0;
17476       table->header_suppressed = header;
17477     }
17478   else
17479     {
17480       *error = 1;
17481       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17482     }
17483 }
17484 
17485 /** Returns _dwg_entity_TABLE::header_suppressed, DXF 281.
17486 \param[in]  table      dwg_ent_table *
17487 \param[out] error      set to 0 for ok, 1 on error
17488 \deprecated
17489 */
17490 unsigned char
dwg_ent_table_get_header_suppressed(const dwg_ent_table * restrict table,int * restrict error)17491 dwg_ent_table_get_header_suppressed (const dwg_ent_table *restrict table,
17492                                      int *restrict error)
17493 {
17494   if (table)
17495     {
17496       *error = 0;
17497       return table->header_suppressed;
17498     }
17499   else
17500     {
17501       *error = 1;
17502       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17503       return '\0';
17504     }
17505 }
17506 
17507 /** Sets _dwg_entity_TABLE::flow_direction, DXF 70.
17508 \param[in]  table      dwg_ent_table *
17509 \param[in]  dir        short?
17510 \param[out] error      set to 0 for ok, 1 on error
17511 \deprecated
17512 */
17513 void
dwg_ent_table_set_flow_direction(dwg_ent_table * restrict table,const BITCODE_BS dir,int * restrict error)17514 dwg_ent_table_set_flow_direction (dwg_ent_table *restrict table,
17515                                   const BITCODE_BS dir, int *restrict error)
17516 {
17517   if (table)
17518     {
17519       *error = 0;
17520       if (dir)
17521         table->table_flag_override |= 0x4;
17522       table->flow_direction = dir;
17523     }
17524   else
17525     {
17526       *error = 1;
17527       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17528     }
17529 }
17530 
17531 /** Returns _dwg_entity_TABLE::flow_direction, DXF 70.
17532 \param[in]  table      dwg_ent_table *
17533 \param[out] error      set to 0 for ok, 1 on error
17534 \deprecated
17535 */
17536 BITCODE_BS
dwg_ent_table_get_flow_direction(const dwg_ent_table * restrict table,int * restrict error)17537 dwg_ent_table_get_flow_direction (const dwg_ent_table *restrict table,
17538                                   int *restrict error)
17539 {
17540   if (table)
17541     {
17542       *error = 0;
17543       return table->flow_direction;
17544     }
17545   else
17546     {
17547       *error = 1;
17548       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17549       return 0;
17550     }
17551 }
17552 
17553 /** Sets _dwg_entity_TABLE::horiz_cell_margin, DXF 41.
17554 \param[in]  table      dwg_ent_table *
17555 \param[in]  margin     double
17556 \param[out] error      set to 0 for ok, 1 on error
17557 \deprecated
17558 */
17559 void
dwg_ent_table_set_horiz_cell_margin(dwg_ent_table * restrict table,const double margin,int * restrict error)17560 dwg_ent_table_set_horiz_cell_margin (dwg_ent_table *restrict table,
17561                                      const double margin, int *restrict error)
17562 {
17563   if (table)
17564     {
17565       *error = 0;
17566       if (margin > 0.0)
17567         table->table_flag_override |= 0x8;
17568       else
17569         table->table_flag_override &= ~0x8;
17570       table->horiz_cell_margin = margin;
17571     }
17572   else
17573     {
17574       *error = 1;
17575       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17576     }
17577 }
17578 
17579 /** Returns _dwg_entity_TABLE::horiz_cell_margin, DXF 41.
17580 \param[in]  table      dwg_ent_table *
17581 \param[out] error      set to 0 for ok, 1 on error
17582 \deprecated
17583 */
17584 double
dwg_ent_table_get_horiz_cell_margin(const dwg_ent_table * restrict table,int * restrict error)17585 dwg_ent_table_get_horiz_cell_margin (const dwg_ent_table *restrict table,
17586                                      int *restrict error)
17587 {
17588   if (table)
17589     {
17590       *error = 0;
17591       return table->horiz_cell_margin;
17592     }
17593   else
17594     {
17595       *error = 1;
17596       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17597       return bit_nan ();
17598     }
17599 }
17600 
17601 /** Sets _dwg_entity_TABLE::vert_cell_margin, DXF 41.
17602 \param[in]  table      dwg_ent_table *
17603 \param[in]  margin     double
17604 \param[out] error      set to 0 for ok, 1 on error
17605 \deprecated
17606 */
17607 void
dwg_ent_table_set_vert_cell_margin(dwg_ent_table * restrict table,const double margin,int * restrict error)17608 dwg_ent_table_set_vert_cell_margin (dwg_ent_table *restrict table,
17609                                     const double margin, int *restrict error)
17610 {
17611   if (table)
17612     {
17613       *error = 0;
17614       if (margin > 0.0)
17615         table->table_flag_override |= 0x10;
17616       else
17617         table->table_flag_override &= ~0x10;
17618       table->vert_cell_margin = margin;
17619     }
17620   else
17621     {
17622       *error = 1;
17623       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17624     }
17625 }
17626 
17627 /** Returns _dwg_entity_TABLE::vert_cell_margin, DXF 41.
17628 \param[in]  table      dwg_ent_table *
17629 \param[out] error      set to 0 for ok, 1 on error
17630 \deprecated
17631 */
17632 double
dwg_ent_table_get_vert_cell_margin(const dwg_ent_table * restrict table,int * restrict error)17633 dwg_ent_table_get_vert_cell_margin (const dwg_ent_table *restrict table,
17634                                     int *restrict error)
17635 {
17636   if (table)
17637     {
17638       *error = 0;
17639       return table->vert_cell_margin;
17640     }
17641   else
17642     {
17643       *error = 1;
17644       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17645       return bit_nan ();
17646     }
17647 }
17648 
17649 /** Sets _dwg_entity_TABLE::title_row_fill_none, DXF 283.
17650 \param[in]  table      dwg_ent_table *
17651 \param[in]  fill       ?
17652 \param[out] error      set to 0 for ok, 1 on error
17653 \deprecated
17654 */
17655 void
dwg_ent_table_set_title_row_fill_none(dwg_ent_table * restrict table,const unsigned char fill,int * restrict error)17656 dwg_ent_table_set_title_row_fill_none (dwg_ent_table *restrict table,
17657                                        const unsigned char fill,
17658                                        int *restrict error)
17659 {
17660   if (table)
17661     {
17662       *error = 0;
17663       if (fill)
17664         table->table_flag_override |= 0x100;
17665       table->title_row_fill_none = fill;
17666     }
17667   else
17668     {
17669       *error = 1;
17670       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17671     }
17672 }
17673 
17674 /** Returns _dwg_entity_TABLE::title_row_fill_none, DXF 283.
17675 \param[in]  table      dwg_ent_table *
17676 \param[out] error      set to 0 for ok, 1 on error
17677 \deprecated
17678 */
17679 unsigned char
dwg_ent_table_get_title_row_fill_none(const dwg_ent_table * restrict table,int * restrict error)17680 dwg_ent_table_get_title_row_fill_none (const dwg_ent_table *restrict table,
17681                                        int *restrict error)
17682 {
17683   if (table)
17684     {
17685       *error = 0;
17686       return table->title_row_fill_none;
17687     }
17688   else
17689     {
17690       *error = 1;
17691       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17692       return '\0';
17693     }
17694 }
17695 
17696 /** Sets _dwg_entity_TABLE::header_row_fill_none, DXF 283.
17697 \param[in]  table      dwg_ent_table *
17698 \param[in]  fill       ?
17699 \param[out] error      set to 0 for ok, 1 on error
17700 \deprecated
17701 */
17702 void
dwg_ent_table_set_header_row_fill_none(dwg_ent_table * restrict table,const unsigned char fill,int * restrict error)17703 dwg_ent_table_set_header_row_fill_none (dwg_ent_table *restrict table,
17704                                         const unsigned char fill,
17705                                         int *restrict error)
17706 {
17707   if (table)
17708     {
17709       *error = 0;
17710       if (fill)
17711         table->table_flag_override |= 0x200;
17712       table->header_row_fill_none = fill;
17713     }
17714   else
17715     {
17716       *error = 1;
17717       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17718     }
17719 }
17720 
17721 /** Returns _dwg_entity_TABLE::header_row_fill_none, DXF 283.
17722 \param[in]  table      dwg_ent_table *
17723 \param[out] error      set to 0 for ok, 1 on error
17724 \deprecated
17725 */
17726 unsigned char
dwg_ent_table_get_header_row_fill_none(const dwg_ent_table * restrict table,int * restrict error)17727 dwg_ent_table_get_header_row_fill_none (const dwg_ent_table *restrict table,
17728                                         int *restrict error)
17729 {
17730   if (table)
17731     {
17732       *error = 0;
17733       return table->header_row_fill_none;
17734     }
17735   else
17736     {
17737       *error = 1;
17738       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17739       return '\0';
17740     }
17741 }
17742 
17743 /** Sets _dwg_entity_TABLE::data_row_fill_none, DXF 283.
17744 \param[in]  table      dwg_ent_table *
17745 \param[in]  fill       ?
17746 \param[out] error      set to 0 for ok, 1 on error
17747 \deprecated
17748 */
17749 void
dwg_ent_table_set_data_row_fill_none(dwg_ent_table * restrict table,const unsigned char fill,int * restrict error)17750 dwg_ent_table_set_data_row_fill_none (dwg_ent_table *restrict table,
17751                                       const unsigned char fill,
17752                                       int *restrict error)
17753 {
17754   if (table)
17755     {
17756       *error = 0;
17757       if (fill)
17758         table->table_flag_override |= 0x400;
17759       table->data_row_fill_none = fill;
17760     }
17761   else
17762     {
17763       *error = 1;
17764       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17765     }
17766 }
17767 
17768 /** Returns _dwg_entity_TABLE::data_row_fill_none, DXF 283.
17769 \param[in]  table      dwg_ent_table *
17770 \param[out] error      set to 0 for ok, 1 on error
17771 \deprecated
17772 */
17773 unsigned char
dwg_ent_table_get_data_row_fill_none(const dwg_ent_table * restrict table,int * restrict error)17774 dwg_ent_table_get_data_row_fill_none (const dwg_ent_table *restrict table,
17775                                       int *restrict error)
17776 {
17777   if (table)
17778     {
17779       *error = 0;
17780       return table->data_row_fill_none;
17781     }
17782   else
17783     {
17784       *error = 1;
17785       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17786       return '\0';
17787     }
17788 }
17789 
17790 /** Sets _dwg_entity_TABLE::title_row_align, DXF 170.
17791     and possibly enables bitmask 0x4000 of
17792     _dwg_entity_TABLE::table_flag_override, DXF 93 .
17793 \param[in]  table      dwg_ent_table *
17794 \param[in]  align      short?
17795 \param[out] error      set to 0 for ok, 1 on error
17796 \deprecated
17797 */
17798 void
dwg_ent_table_set_title_row_alignment(dwg_ent_table * restrict table,const unsigned char align,int * restrict error)17799 dwg_ent_table_set_title_row_alignment (dwg_ent_table *restrict table,
17800                                        const unsigned char align,
17801                                        int *restrict error)
17802 {
17803   if (table)
17804     {
17805       *error = 0;
17806       if (align)
17807         table->table_flag_override |= 0x4000;
17808       table->title_row_alignment = align;
17809     }
17810   else
17811     {
17812       *error = 1;
17813       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17814     }
17815 }
17816 
17817 /** Returns _dwg_entity_TABLE::title_row_align, DXF 170.
17818 \param[in]  table      dwg_ent_table *
17819 \param[out] error      set to 0 for ok, 1 on error
17820 \deprecated
17821 */
17822 BITCODE_BS
dwg_ent_table_get_title_row_alignment(const dwg_ent_table * restrict table,int * restrict error)17823 dwg_ent_table_get_title_row_alignment (const dwg_ent_table *restrict table,
17824                                        int *restrict error)
17825 {
17826   if (table)
17827     {
17828       *error = 0;
17829       return table->title_row_alignment;
17830     }
17831   else
17832     {
17833       *error = 1;
17834       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17835       return 0;
17836     }
17837 }
17838 
17839 /** Sets _dwg_entity_TABLE::header_row_align, DXF 170.
17840     and possibly enables bitmask 0x8000 of
17841 _dwg_entity_TABLE::table_flag_override, DXF 93 . \param[in]  table
17842 dwg_ent_table * \param[in]  alignment      short? \param[out] error      set to
17843 0 for ok, 1 on error \deprecated
17844 */
17845 void
dwg_ent_table_set_header_row_alignment(dwg_ent_table * restrict table,const BITCODE_BS align,int * restrict error)17846 dwg_ent_table_set_header_row_alignment (dwg_ent_table *restrict table,
17847                                         const BITCODE_BS align,
17848                                         int *restrict error)
17849 {
17850   if (table)
17851     {
17852       *error = 0;
17853       if (align)
17854         table->table_flag_override |= 0x8000;
17855       table->header_row_alignment = align;
17856     }
17857   else
17858     {
17859       *error = 1;
17860       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17861     }
17862 }
17863 
17864 /** Returns _dwg_entity_TABLE::header_row_align, DXF 170.
17865     Might be ignored if bit of 0x8000 of table_flag_override DXF 93 is not set.
17866 \param[in]  table      dwg_ent_table *
17867 \param[out] error      set to 0 for ok, 1 on error
17868 \deprecated
17869 */
17870 BITCODE_BS
dwg_ent_table_get_header_row_alignment(const dwg_ent_table * restrict table,int * restrict error)17871 dwg_ent_table_get_header_row_alignment (const dwg_ent_table *restrict table,
17872                                         int *restrict error)
17873 {
17874   if (table)
17875     {
17876       *error = 0;
17877       return table->header_row_alignment;
17878     }
17879   else
17880     {
17881       *error = 1;
17882       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17883       return 0;
17884     }
17885 }
17886 
17887 /** Sets _dwg_entity_TABLE::data_row_align, DXF 170,
17888     and possibly table_flag_override 93.
17889 
17890     TODO: possible values?
17891 \param[in]  table      dwg_ent_table *
17892 \param[in]  alignment      short?
17893 \param[out] error      set to 0 for ok, 1 on error
17894 \deprecated
17895 */
17896 void
dwg_ent_table_set_data_row_alignment(dwg_ent_table * restrict table,const BITCODE_BS align,int * restrict error)17897 dwg_ent_table_set_data_row_alignment (dwg_ent_table *restrict table,
17898                                       const BITCODE_BS align,
17899                                       int *restrict error)
17900 {
17901   if (table)
17902     {
17903       *error = 0;
17904       if (align)
17905         table->table_flag_override |= 0x10000;
17906       table->data_row_alignment = align;
17907     }
17908   else
17909     {
17910       *error = 1;
17911       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17912     }
17913 }
17914 
17915 /** Returns _dwg_entity_TABLE::data_row_align, DXF 170.
17916     Might be ignored if bit of 0x10000 of table_flag_override, DXF 93 is not
17917 set. \param[in]  table      dwg_ent_table * \param[out] error      set to 0 for
17918 ok, 1 on error \deprecated
17919 */
17920 BITCODE_BS
dwg_ent_table_get_data_row_alignment(const dwg_ent_table * restrict table,int * restrict error)17921 dwg_ent_table_get_data_row_alignment (const dwg_ent_table *restrict table,
17922                                       int *restrict error)
17923 {
17924   if (table)
17925     {
17926       *error = 0;
17927       return table->data_row_alignment;
17928     }
17929   else
17930     {
17931       *error = 1;
17932       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17933       return 0;
17934     }
17935 }
17936 
17937 /** Sets _dwg_entity_TABLE::title_row_height, DXF 140.
17938     and en/disables the _dwg_entity_TABLE::table_flag_override
17939 \param[in]  table      dwg_ent_table *
17940 \param[out] error      set to 0 for ok, 1 on error
17941 \deprecated
17942 */
17943 void
dwg_ent_table_set_title_row_height(dwg_ent_table * restrict table,const double height,int * restrict error)17944 dwg_ent_table_set_title_row_height (dwg_ent_table *restrict table,
17945                                     const double height, int *restrict error)
17946 {
17947   if (table)
17948     {
17949       *error = 0;
17950       if (height > 0.0)
17951         table->table_flag_override |= 0x100000;
17952       else
17953         table->table_flag_override &= ~0x100000;
17954       table->title_row_height = height;
17955     }
17956   else
17957     {
17958       *error = 1;
17959       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17960     }
17961 }
17962 
17963 /** Returns _dwg_entity_TABLE::title_row_height, DXF 140.
17964 \param[in]  table      dwg_ent_table *
17965 \param[out] error      set to 0 for ok, 1 on error
17966 \deprecated
17967 */
17968 double
dwg_ent_table_get_title_row_height(const dwg_ent_table * restrict table,int * restrict error)17969 dwg_ent_table_get_title_row_height (const dwg_ent_table *restrict table,
17970                                     int *restrict error)
17971 {
17972   if (table)
17973     {
17974       *error = 0;
17975       return table->title_row_height;
17976     }
17977   else
17978     {
17979       *error = 1;
17980       LOG_ERROR ("%s: empty arg", __FUNCTION__)
17981       return bit_nan ();
17982     }
17983 }
17984 
17985 /** Sets _dwg_entity_TABLE::header_row_height, DXF 140.
17986     and en/disables the _dwg_entity_TABLE::table_flag_override.
17987 \param[in]  table      dwg_ent_table *
17988 \param[out] error      set to 0 for ok, 1 on error
17989 \deprecated
17990 */
17991 void
dwg_ent_table_set_header_row_height(dwg_ent_table * restrict table,const double height,int * restrict error)17992 dwg_ent_table_set_header_row_height (dwg_ent_table *restrict table,
17993                                      const double height, int *restrict error)
17994 {
17995   if (table)
17996     {
17997       *error = 0;
17998       if (height > 0.0)
17999         table->table_flag_override |= 0x200000;
18000       else
18001         table->table_flag_override &= ~0x200000;
18002       table->header_row_height = height;
18003     }
18004   else
18005     {
18006       *error = 1;
18007       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18008     }
18009 }
18010 
18011 /** Returns _dwg_entity_TABLE::header_row_height, DXF 140.
18012 \param[in]  table      dwg_ent_table *
18013 \param[out] error      set to 0 for ok, 1 on error
18014 \deprecated
18015 */
18016 double
dwg_ent_table_get_header_row_height(const dwg_ent_table * restrict table,int * restrict error)18017 dwg_ent_table_get_header_row_height (const dwg_ent_table *restrict table,
18018                                      int *restrict error)
18019 {
18020   if (table)
18021     {
18022       *error = 0;
18023       return table->header_row_height;
18024     }
18025   else
18026     {
18027       *error = 1;
18028       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18029       return bit_nan ();
18030     }
18031 }
18032 
18033 /** Sets _dwg_entity_TABLE::data_row_height, DXF 140.
18034     and en/disables the _dwg_entity_TABLE::table_flag_override.
18035 \param[in]  table      dwg_ent_table *
18036 \param[out] error      set to 0 for ok, 1 on error
18037 \deprecated
18038 */
18039 void
dwg_ent_table_set_data_row_height(dwg_ent_table * restrict table,const double height,int * restrict error)18040 dwg_ent_table_set_data_row_height (dwg_ent_table *restrict table,
18041                                    const double height, int *restrict error)
18042 {
18043   if (table)
18044     {
18045       *error = 0;
18046       if (height > 0.0)
18047         table->table_flag_override |= 0x400000;
18048       else
18049         table->table_flag_override &= ~0x400000;
18050       table->data_row_height = height;
18051     }
18052   else
18053     {
18054       *error = 1;
18055       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18056     }
18057 }
18058 
18059 /** Returns _dwg_entity_TABLE::data_row_height, DXF 140.
18060 \param[in]  table      dwg_ent_table *
18061 \param[out] error      set to 0 for ok, 1 on error
18062 \deprecated
18063 */
18064 double
dwg_ent_table_get_data_row_height(const dwg_ent_table * restrict table,int * restrict error)18065 dwg_ent_table_get_data_row_height (const dwg_ent_table *restrict table,
18066                                    int *restrict error)
18067 {
18068   if (table)
18069     {
18070       *error = 0;
18071       return table->data_row_height;
18072     }
18073   else
18074     {
18075       *error = 1;
18076       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18077       return bit_nan ();
18078     }
18079 }
18080 
18081 /** Returns _dwg_entity_TABLE::has_border_color_overrides, if DXF 94 > 0.
18082 \param[in]  table      dwg_ent_table *
18083 \param[out] error      set to 0 for ok, 1 on error
18084 \deprecated
18085 */
18086 unsigned char
dwg_ent_table_has_border_color_overrides(dwg_ent_table * restrict table,int * restrict error)18087 dwg_ent_table_has_border_color_overrides (dwg_ent_table *restrict table,
18088                                           int *restrict error)
18089 {
18090   if (table)
18091     {
18092       *error = 0;
18093       return table->has_border_color_overrides;
18094     }
18095   else
18096     {
18097       *error = 1;
18098       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18099       return '\0';
18100     }
18101 }
18102 
18103 /** Sets _dwg_entity_TABLE::border_color_overrides_flag, DXF 94.
18104     \sa dwg_ent_table_get_border_color_overrides_flag
18105 \param[in]  table      dwg_ent_table *
18106 \param[out] error      set to 0 for ok, 1 on error
18107 \deprecated
18108 */
18109 void
dwg_ent_table_set_border_color_overrides_flag(dwg_ent_table * restrict table,const BITCODE_BL overrides,int * restrict error)18110 dwg_ent_table_set_border_color_overrides_flag (dwg_ent_table *restrict table,
18111                                                const BITCODE_BL overrides,
18112                                                int *restrict error)
18113 {
18114   if (table != NULL && overrides <= 1)
18115     {
18116       *error = 0;
18117       table->border_color_overrides_flag = overrides;
18118     }
18119   else
18120     {
18121       *error = 1;
18122       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
18123     }
18124 }
18125 
18126 /** Returns _dwg_entity_TABLE::border_color_overrides_flag, DXF 94.
18127 
18128     Bitmask 1: has title_horiz_top_color
18129             2: has title_horiz_ins_color
18130             4: has title_horiz_bottom_color
18131             8: has title_vert_left_color
18132            10: has title_vert_ins_color
18133            20: has title_vert_right_color
18134            ...
18135 \param[in]  table      dwg_ent_table *
18136 \param[out] error      set to 0 for ok, 1 on error
18137  */
18138 BITCODE_BL
dwg_ent_table_get_border_color_overrides_flag(const dwg_ent_table * restrict table,int * restrict error)18139 dwg_ent_table_get_border_color_overrides_flag (
18140     const dwg_ent_table *restrict table, int *restrict error)
18141 {
18142   if (table)
18143     {
18144       *error = 0;
18145       return table->border_color_overrides_flag;
18146     }
18147   else
18148     {
18149       *error = 1;
18150       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18151       return 0L;
18152     }
18153 }
18154 
18155 /** Returns _dwg_entity_TABLE::has_border_lineweight_overrides, if DXF 95 > 0
18156 \param[in]  table      dwg_ent_table *
18157 \param[out] error      set to 0 for ok, 1 on error
18158 \deprecated
18159 */
18160 unsigned char
dwg_ent_table_has_border_lineweight_overrides(dwg_ent_table * restrict table,int * restrict error)18161 dwg_ent_table_has_border_lineweight_overrides (dwg_ent_table *restrict table,
18162                                                int *restrict error)
18163 {
18164   if (table)
18165     {
18166       *error = 0;
18167       return table->has_border_lineweight_overrides;
18168     }
18169   else
18170     {
18171       *error = 1;
18172       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18173       return '\0';
18174     }
18175 }
18176 
18177 /** Sets _dwg_entity_TABLE::border_lineweight_overrides_flag, DXF 95.
18178 \param[in]  table      dwg_ent_table *
18179 \param[in]  overrides  0 or 1
18180 \param[out] error      set to 0 for ok, 1 on error
18181 \deprecated
18182 */
18183 void
dwg_ent_table_set_border_lineweight_overrides_flag(dwg_ent_table * restrict table,const BITCODE_BL overrides,int * restrict error)18184 dwg_ent_table_set_border_lineweight_overrides_flag (
18185     dwg_ent_table *restrict table, const BITCODE_BL overrides,
18186     int *restrict error)
18187 {
18188   if (table != NULL && overrides <= 1)
18189     {
18190       *error = 0;
18191       table->border_lineweight_overrides_flag = overrides;
18192     }
18193   else
18194     {
18195       *error = 1;
18196       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
18197     }
18198 }
18199 
18200 /** Returns _dwg_entity_TABLE::border_lineweight_overrides_flag, DXF 95.
18201 \param[in]  table      dwg_ent_table *
18202 \param[out] error      set to 0 for ok, 1 on error
18203 \deprecated
18204 */
18205 BITCODE_BL
dwg_ent_table_get_border_lineweight_overrides_flag(const dwg_ent_table * restrict table,int * restrict error)18206 dwg_ent_table_get_border_lineweight_overrides_flag (
18207     const dwg_ent_table *restrict table, int *restrict error)
18208 {
18209   if (table)
18210     {
18211       *error = 0;
18212       return table->border_lineweight_overrides_flag;
18213     }
18214   else
18215     {
18216       *error = 1;
18217       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18218       return 0L;
18219     }
18220 }
18221 
18222 /** Sets _dwg_entity_TABLE::title_horiz_top_linewt
18223 \param[in]  table      dwg_ent_table *
18224 \param[in]  linewt     short
18225 \param[out] error      set to 0 for ok, 1 on error
18226 \deprecated
18227 */
18228 void
dwg_ent_table_set_title_horiz_top_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18229 dwg_ent_table_set_title_horiz_top_linewt (dwg_ent_table *restrict table,
18230                                           const BITCODE_BS linewt,
18231                                           int *restrict error)
18232 {
18233   if (table)
18234     {
18235       *error = 0;
18236       table->title_horiz_top_linewt = linewt;
18237     }
18238   else
18239     {
18240       *error = 1;
18241       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18242     }
18243 }
18244 
18245 /** Returns _dwg_entity_TABLE::title_horiz_top_linewt
18246 \param[in]  table      dwg_ent_table *
18247 \param[in]  linewt     short
18248 \param[out] error      set to 0 for ok, 1 on error
18249 \deprecated
18250 */
18251 BITCODE_BS
dwg_ent_table_get_title_horiz_top_linewt(const dwg_ent_table * restrict table,int * restrict error)18252 dwg_ent_table_get_title_horiz_top_linewt (const dwg_ent_table *restrict table,
18253                                           int *restrict error)
18254 {
18255   if (table)
18256     {
18257       *error = 0;
18258       return table->title_horiz_top_linewt;
18259     }
18260   else
18261     {
18262       *error = 1;
18263       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18264       return 0;
18265     }
18266 }
18267 
18268 /** Sets _dwg_entity_TABLE::title_horiz_ins_linewt
18269 \param[in]  table      dwg_ent_table *
18270 \param[in]  linewt     short
18271 \param[out] error      set to 0 for ok, 1 on error
18272 \deprecated
18273 */
18274 void
dwg_ent_table_set_title_horiz_ins_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18275 dwg_ent_table_set_title_horiz_ins_linewt (dwg_ent_table *restrict table,
18276                                           const BITCODE_BS linewt,
18277                                           int *restrict error)
18278 {
18279   if (table)
18280     {
18281       *error = 0;
18282       table->title_horiz_ins_linewt = linewt;
18283     }
18284   else
18285     {
18286       *error = 1;
18287       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18288     }
18289 }
18290 
18291 /** Returns _dwg_entity_TABLE::title_horiz_ins_linewt
18292 \param[in]  table      dwg_ent_table *
18293 \param[in]  linewt     short
18294 \param[out] error      set to 0 for ok, 1 on error
18295 \deprecated
18296 */
18297 BITCODE_BS
dwg_ent_table_get_title_horiz_ins_linewt(const dwg_ent_table * restrict table,int * restrict error)18298 dwg_ent_table_get_title_horiz_ins_linewt (const dwg_ent_table *restrict table,
18299                                           int *restrict error)
18300 {
18301   if (table)
18302     {
18303       *error = 0;
18304       return table->title_horiz_ins_linewt;
18305     }
18306   else
18307     {
18308       *error = 1;
18309       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18310       return 0;
18311     }
18312 }
18313 
18314 /** Sets _dwg_entity_TABLE::title_horiz_bottom_linewt
18315 \param[in]  table      dwg_ent_table *
18316 \param[in]  linewt     short
18317 \param[out] error      set to 0 for ok, 1 on error
18318 \deprecated
18319 */
18320 void
dwg_ent_table_set_title_horiz_bottom_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18321 dwg_ent_table_set_title_horiz_bottom_linewt (dwg_ent_table *restrict table,
18322                                              const BITCODE_BS linewt,
18323                                              int *restrict error)
18324 {
18325   if (table)
18326     {
18327       *error = 0;
18328       table->title_horiz_bottom_linewt = linewt;
18329     }
18330   else
18331     {
18332       *error = 1;
18333       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18334     }
18335 }
18336 
18337 /** Returns _dwg_entity_TABLE::title_horiz_bottom_linewt
18338 \param[in]  table      dwg_ent_table *
18339 \param[in]  linewt     short
18340 \param[out] error      set to 0 for ok, 1 on error
18341 \deprecated
18342 */
18343 BITCODE_BS
dwg_ent_table_get_title_horiz_bottom_linewt(const dwg_ent_table * restrict table,int * restrict error)18344 dwg_ent_table_get_title_horiz_bottom_linewt (
18345     const dwg_ent_table *restrict table, int *restrict error)
18346 {
18347   if (table)
18348     {
18349       *error = 0;
18350       return table->title_horiz_bottom_linewt;
18351     }
18352   else
18353     {
18354       *error = 1;
18355       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18356       return 0;
18357     }
18358 }
18359 
18360 /** Sets _dwg_entity_TABLE::title_vert_left_linewt
18361 \param[in]  table      dwg_ent_table *
18362 \param[in]  linewt     short
18363 \param[out] error      set to 0 for ok, 1 on error
18364 \deprecated
18365 */
18366 void
dwg_ent_table_set_title_vert_left_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18367 dwg_ent_table_set_title_vert_left_linewt (dwg_ent_table *restrict table,
18368                                           const BITCODE_BS linewt,
18369                                           int *restrict error)
18370 {
18371   if (table)
18372     {
18373       *error = 0;
18374       table->title_vert_left_linewt = linewt;
18375     }
18376   else
18377     {
18378       *error = 1;
18379       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18380     }
18381 }
18382 
18383 /** Returns _dwg_entity_TABLE::title_vert_left_linewt
18384 \param[in]  table      dwg_ent_table *
18385 \param[in]  linewt     short
18386 \param[out] error      set to 0 for ok, 1 on error
18387 \deprecated
18388 */
18389 BITCODE_BS
dwg_ent_table_get_title_vert_left_linewt(const dwg_ent_table * restrict table,int * restrict error)18390 dwg_ent_table_get_title_vert_left_linewt (const dwg_ent_table *restrict table,
18391                                           int *restrict error)
18392 {
18393   if (table)
18394     {
18395       *error = 0;
18396       return table->title_vert_left_linewt;
18397     }
18398   else
18399     {
18400       *error = 1;
18401       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18402       return 0;
18403     }
18404 }
18405 
18406 /** Sets _dwg_entity_TABLE::title_vert_ins_linewt
18407 \param[in]  table      dwg_ent_table *
18408 \param[in]  linewt     short
18409 \param[out] error      set to 0 for ok, 1 on error
18410 \deprecated
18411 */
18412 void
dwg_ent_table_set_title_vert_ins_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18413 dwg_ent_table_set_title_vert_ins_linewt (dwg_ent_table *restrict table,
18414                                          const BITCODE_BS linewt,
18415                                          int *restrict error)
18416 {
18417   if (table)
18418     {
18419       *error = 0;
18420       table->title_vert_ins_linewt = linewt;
18421     }
18422   else
18423     {
18424       *error = 1;
18425       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18426     }
18427 }
18428 
18429 /** Returns _dwg_entity_TABLE::title_vert_ins_linewt
18430 \param[in]  table      dwg_ent_table *
18431 \param[in]  linewt     short
18432 \param[out] error      set to 0 for ok, 1 on error
18433 \deprecated
18434 */
18435 BITCODE_BS
dwg_ent_table_get_title_vert_ins_linewt(const dwg_ent_table * restrict table,int * restrict error)18436 dwg_ent_table_get_title_vert_ins_linewt (const dwg_ent_table *restrict table,
18437                                          int *restrict error)
18438 {
18439   if (table)
18440     {
18441       *error = 0;
18442       return table->title_vert_ins_linewt;
18443     }
18444   else
18445     {
18446       *error = 1;
18447       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18448       return 0;
18449     }
18450 }
18451 
18452 /** Sets _dwg_entity_TABLE::title_vert_right_linewt
18453 \param[in]  table      dwg_ent_table *
18454 \param[in]  linewt     short
18455 \param[out] error      set to 0 for ok, 1 on error
18456 \deprecated
18457 */
18458 void
dwg_ent_table_set_title_vert_right_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18459 dwg_ent_table_set_title_vert_right_linewt (dwg_ent_table *restrict table,
18460                                            const BITCODE_BS linewt,
18461                                            int *restrict error)
18462 {
18463   if (table)
18464     {
18465       *error = 0;
18466       table->title_vert_right_linewt = linewt;
18467     }
18468   else
18469     {
18470       *error = 1;
18471       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18472     }
18473 }
18474 
18475 /** Returns _dwg_entity_TABLE::title_vert_right_linewt
18476 \param[in]  table      dwg_ent_table *
18477 \param[in]  linewt     short
18478 \param[out] error      set to 0 for ok, 1 on error
18479 \deprecated
18480 */
18481 BITCODE_BS
dwg_ent_table_get_title_vert_right_linewt(const dwg_ent_table * restrict table,int * restrict error)18482 dwg_ent_table_get_title_vert_right_linewt (const dwg_ent_table *restrict table,
18483                                            int *restrict error)
18484 {
18485   if (table)
18486     {
18487       *error = 0;
18488       return table->title_vert_right_linewt;
18489     }
18490   else
18491     {
18492       *error = 1;
18493       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18494       return 0;
18495     }
18496 }
18497 
18498 /** Sets _dwg_entity_TABLE::header_horiz_top_linewt
18499 \param[in]  table      dwg_ent_table *
18500 \param[in]  linewt     short
18501 \param[out] error      set to 0 for ok, 1 on error
18502 \deprecated
18503 */
18504 void
dwg_ent_table_set_header_horiz_top_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18505 dwg_ent_table_set_header_horiz_top_linewt (dwg_ent_table *restrict table,
18506                                            const BITCODE_BS linewt,
18507                                            int *restrict error)
18508 {
18509   if (table)
18510     {
18511       *error = 0;
18512       table->header_horiz_top_linewt = linewt;
18513     }
18514   else
18515     {
18516       *error = 1;
18517       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18518     }
18519 }
18520 
18521 /** Returns _dwg_entity_TABLE::header_horiz_top_linewt
18522 \param[in]  table      dwg_ent_table *
18523 \param[in]  linewt     short
18524 \param[out] error      set to 0 for ok, 1 on error
18525 \deprecated
18526 */
18527 BITCODE_BS
dwg_ent_table_get_header_horiz_top_linewt(const dwg_ent_table * restrict table,int * restrict error)18528 dwg_ent_table_get_header_horiz_top_linewt (const dwg_ent_table *restrict table,
18529                                            int *restrict error)
18530 {
18531   if (table)
18532     {
18533       *error = 0;
18534       return table->header_horiz_top_linewt;
18535     }
18536   else
18537     {
18538       *error = 1;
18539       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18540       return 0;
18541     }
18542 }
18543 
18544 /** Sets _dwg_entity_TABLE::header_horiz_ins_linewt
18545 \param[in]  table      dwg_ent_table *
18546 \param[in]  linewt     short
18547 \param[out] error      set to 0 for ok, 1 on error
18548 \deprecated
18549 */
18550 void
dwg_ent_table_set_header_horiz_ins_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18551 dwg_ent_table_set_header_horiz_ins_linewt (dwg_ent_table *restrict table,
18552                                            const BITCODE_BS linewt,
18553                                            int *restrict error)
18554 {
18555   if (table)
18556     {
18557       *error = 0;
18558       table->header_horiz_ins_linewt = linewt;
18559     }
18560   else
18561     {
18562       *error = 1;
18563       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18564     }
18565 }
18566 
18567 /** Returns _dwg_entity_TABLE::header_horiz_ins_linewt
18568 \param[in]  table      dwg_ent_table *
18569 \param[in]  linewt     short
18570 \param[out] error      set to 0 for ok, 1 on error
18571 \deprecated
18572 */
18573 BITCODE_BS
dwg_ent_table_get_header_horiz_ins_linewt(const dwg_ent_table * restrict table,int * restrict error)18574 dwg_ent_table_get_header_horiz_ins_linewt (const dwg_ent_table *restrict table,
18575                                            int *restrict error)
18576 {
18577   if (table)
18578     {
18579       *error = 0;
18580       return table->header_horiz_ins_linewt;
18581     }
18582   else
18583     {
18584       *error = 1;
18585       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18586       return 0;
18587     }
18588 }
18589 
18590 /** Sets _dwg_entity_TABLE::header_horiz_bottom_linewt
18591 \param[in]  table      dwg_ent_table *
18592 \param[in]  linewt     short
18593 \param[out] error      set to 0 for ok, 1 on error
18594 \deprecated
18595 */
18596 void
dwg_ent_table_set_header_horiz_bottom_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18597 dwg_ent_table_set_header_horiz_bottom_linewt (dwg_ent_table *restrict table,
18598                                               const BITCODE_BS linewt,
18599                                               int *restrict error)
18600 {
18601   if (table)
18602     {
18603       *error = 0;
18604       table->header_horiz_bottom_linewt = linewt;
18605     }
18606   else
18607     {
18608       *error = 1;
18609       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18610     }
18611 }
18612 
18613 /** Returns _dwg_entity_TABLE::header_horiz_bottom_linewt
18614 \param[in]  table      dwg_ent_table *
18615 \param[in]  linewt     short
18616 \param[out] error      set to 0 for ok, 1 on error
18617 \deprecated
18618 */
18619 BITCODE_BS
dwg_ent_table_get_header_horiz_bottom_linewt(const dwg_ent_table * restrict table,int * restrict error)18620 dwg_ent_table_get_header_horiz_bottom_linewt (
18621     const dwg_ent_table *restrict table, int *restrict error)
18622 {
18623   if (table)
18624     {
18625       *error = 0;
18626       return table->header_horiz_bottom_linewt;
18627     }
18628   else
18629     {
18630       *error = 1;
18631       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18632       return 0;
18633     }
18634 }
18635 
18636 /** Sets _dwg_entity_TABLE::header_vert_left_linewt
18637 \param[in]  table      dwg_ent_table *
18638 \param[in]  linewt     short
18639 \param[out] error      set to 0 for ok, 1 on error
18640 \deprecated
18641 */
18642 void
dwg_ent_table_set_header_vert_left_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18643 dwg_ent_table_set_header_vert_left_linewt (dwg_ent_table *restrict table,
18644                                            const BITCODE_BS linewt,
18645                                            int *restrict error)
18646 {
18647   if (table)
18648     {
18649       *error = 0;
18650       table->header_vert_left_linewt = linewt;
18651     }
18652   else
18653     {
18654       *error = 1;
18655       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18656     }
18657 }
18658 
18659 /** Returns _dwg_entity_TABLE::header_vert_left_linewt
18660 \param[in]  table      dwg_ent_table *
18661 \param[in]  linewt     short
18662 \param[out] error      set to 0 for ok, 1 on error
18663 \deprecated
18664 */
18665 BITCODE_BS
dwg_ent_table_get_header_vert_left_linewt(const dwg_ent_table * restrict table,int * restrict error)18666 dwg_ent_table_get_header_vert_left_linewt (const dwg_ent_table *restrict table,
18667                                            int *restrict error)
18668 {
18669   if (table)
18670     {
18671       *error = 0;
18672       return table->header_vert_left_linewt;
18673     }
18674   else
18675     {
18676       *error = 1;
18677       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18678       return 0;
18679     }
18680 }
18681 
18682 /** Sets _dwg_entity_TABLE::header_vert_ins_linewt
18683 \param[in]  table      dwg_ent_table *
18684 \param[in]  linewt     short
18685 \param[out] error      set to 0 for ok, 1 on error
18686 \deprecated
18687 */
18688 void
dwg_ent_table_set_header_vert_ins_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18689 dwg_ent_table_set_header_vert_ins_linewt (dwg_ent_table *restrict table,
18690                                           const BITCODE_BS linewt,
18691                                           int *restrict error)
18692 {
18693   if (table)
18694     {
18695       *error = 0;
18696       table->header_vert_ins_linewt = linewt;
18697     }
18698   else
18699     {
18700       *error = 1;
18701       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18702     }
18703 }
18704 
18705 /** Returns _dwg_entity_TABLE::header_vert_ins_linewt
18706 \param[in]  table      dwg_ent_table *
18707 \param[out] error      set to 0 for ok, 1 on error
18708 \deprecated
18709 */
18710 BITCODE_BS
dwg_ent_table_get_header_vert_ins_linewt(const dwg_ent_table * restrict table,int * restrict error)18711 dwg_ent_table_get_header_vert_ins_linewt (const dwg_ent_table *restrict table,
18712                                           int *restrict error)
18713 {
18714   if (table)
18715     {
18716       *error = 0;
18717       return table->header_vert_ins_linewt;
18718     }
18719   else
18720     {
18721       *error = 1;
18722       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18723       return 0;
18724     }
18725 }
18726 
18727 /** Sets _dwg_entity_TABLE::header_vert_right_linewt
18728 \param[in]  table      dwg_ent_table *
18729 \param[in]  linewt     short
18730 \param[out] error      set to 0 for ok, 1 on error
18731 \deprecated
18732 */
18733 void
dwg_ent_table_set_header_vert_right_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18734 dwg_ent_table_set_header_vert_right_linewt (dwg_ent_table *restrict table,
18735                                             const BITCODE_BS linewt,
18736                                             int *restrict error)
18737 {
18738   if (table)
18739     {
18740       *error = 0;
18741       table->header_vert_right_linewt = linewt;
18742     }
18743   else
18744     {
18745       *error = 1;
18746       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18747     }
18748 }
18749 
18750 /** Returns _dwg_entity_TABLE::header_vert_right_linewt
18751 \param[in]  table      dwg_ent_table *
18752 \param[out] error      set to 0 for ok, 1 on error
18753 \deprecated
18754 */
18755 BITCODE_BS
dwg_ent_table_get_header_vert_right_linewt(const dwg_ent_table * restrict table,int * restrict error)18756 dwg_ent_table_get_header_vert_right_linewt (
18757     const dwg_ent_table *restrict table, int *restrict error)
18758 {
18759   if (table)
18760     {
18761       *error = 0;
18762       return table->header_vert_right_linewt;
18763     }
18764   else
18765     {
18766       *error = 1;
18767       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18768       return 0;
18769     }
18770 }
18771 
18772 /** Sets _dwg_entity_TABLE::data_horiz_top_linewt, DXF ?.
18773 \param[in]  table      dwg_ent_table *
18774 \param[in]  linewt     short
18775 \param[out] error      set to 0 for ok, 1 on error
18776 \deprecated
18777 */
18778 void
dwg_ent_table_set_data_horiz_top_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18779 dwg_ent_table_set_data_horiz_top_linewt (dwg_ent_table *restrict table,
18780                                          const BITCODE_BS linewt,
18781                                          int *restrict error)
18782 {
18783   if (table)
18784     {
18785       *error = 0;
18786       table->data_horiz_top_linewt = linewt;
18787     }
18788   else
18789     {
18790       *error = 1;
18791       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18792     }
18793 }
18794 
18795 /** Returns _dwg_entity_TABLE::data_horiz_top_linewt, DXF ?.
18796 \param[in]  table      dwg_ent_table *
18797 \param[in]  linewt     short
18798 \param[out] error      set to 0 for ok, 1 on error
18799 \deprecated
18800 */
18801 BITCODE_BS
dwg_ent_table_get_data_horiz_top_linewt(const dwg_ent_table * restrict table,int * restrict error)18802 dwg_ent_table_get_data_horiz_top_linewt (const dwg_ent_table *restrict table,
18803                                          int *restrict error)
18804 {
18805   if (table)
18806     {
18807       *error = 0;
18808       return table->data_horiz_top_linewt;
18809     }
18810   else
18811     {
18812       *error = 1;
18813       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18814       return 0;
18815     }
18816 }
18817 
18818 /** Sets _dwg_entity_TABLE::data_horiz_ins_linewt, DXF ?.
18819 \param[in]  table      dwg_ent_table *
18820 \param[in]  linewt     short
18821 \param[out] error      set to 0 for ok, 1 on error
18822 \deprecated
18823 */
18824 void
dwg_ent_table_set_data_horiz_ins_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18825 dwg_ent_table_set_data_horiz_ins_linewt (dwg_ent_table *restrict table,
18826                                          const BITCODE_BS linewt,
18827                                          int *restrict error)
18828 {
18829   if (table)
18830     {
18831       *error = 0;
18832       table->data_horiz_ins_linewt = linewt;
18833     }
18834   else
18835     {
18836       *error = 1;
18837       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18838     }
18839 }
18840 
18841 /** Returns _dwg_entity_TABLE::data_horiz_ins_linewt, DXF ?.
18842 \param[in]  table      dwg_ent_table *
18843 \param[in]  linewt     short
18844 \param[out] error      set to 0 for ok, 1 on error
18845 \deprecated
18846 */
18847 BITCODE_BS
dwg_ent_table_get_data_horiz_ins_linewt(const dwg_ent_table * restrict table,int * restrict error)18848 dwg_ent_table_get_data_horiz_ins_linewt (const dwg_ent_table *restrict table,
18849                                          int *restrict error)
18850 {
18851   if (table)
18852     {
18853       *error = 0;
18854       return table->data_horiz_ins_linewt;
18855     }
18856   else
18857     {
18858       *error = 1;
18859       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18860       return 0;
18861     }
18862 }
18863 
18864 /** Sets _dwg_entity_TABLE::data_horiz_bottom_linewt
18865 \param[in]  table      dwg_ent_table *
18866 \param[in]  linewt     short
18867 \param[out] error      set to 0 for ok, 1 on error
18868 \deprecated
18869 */
18870 void
dwg_ent_table_set_data_horiz_bottom_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18871 dwg_ent_table_set_data_horiz_bottom_linewt (dwg_ent_table *restrict table,
18872                                             const BITCODE_BS linewt,
18873                                             int *restrict error)
18874 {
18875   if (table)
18876     {
18877       *error = 0;
18878       table->data_horiz_bottom_linewt = linewt;
18879     }
18880   else
18881     {
18882       *error = 1;
18883       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18884     }
18885 }
18886 
18887 /** Returns _dwg_entity_TABLE::data_horiz_bottom_linewt
18888 \param[in]  table      dwg_ent_table *
18889 \param[out] error      set to 0 for ok, 1 on error
18890 \deprecated
18891 */
18892 BITCODE_BS
dwg_ent_table_get_data_horiz_bottom_linewt(const dwg_ent_table * restrict table,int * restrict error)18893 dwg_ent_table_get_data_horiz_bottom_linewt (
18894     const dwg_ent_table *restrict table, int *restrict error)
18895 {
18896   if (table)
18897     {
18898       *error = 0;
18899       return table->data_horiz_bottom_linewt;
18900     }
18901   else
18902     {
18903       *error = 1;
18904       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18905       return 0;
18906     }
18907 }
18908 
18909 /** Sets _dwg_entity_TABLE::data_vert_ins_linewt
18910 \param[in]  table      dwg_ent_table *
18911 \param[in]  linewt     short
18912 \param[out] error      set to 0 for ok, 1 on error
18913 \deprecated
18914 */
18915 void
dwg_ent_table_set_data_vert_ins_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18916 dwg_ent_table_set_data_vert_ins_linewt (dwg_ent_table *restrict table,
18917                                         const BITCODE_BS linewt,
18918                                         int *restrict error)
18919 {
18920   if (table)
18921     {
18922       *error = 0;
18923       table->data_vert_ins_linewt = linewt;
18924     }
18925   else
18926     {
18927       *error = 1;
18928       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18929     }
18930 }
18931 
18932 /** Returns _dwg_entity_TABLE::data_vert_ins_linewt
18933 \param[in]  table      dwg_ent_table *
18934 \param[out] error      set to 0 for ok, 1 on error
18935 \deprecated
18936 */
18937 BITCODE_BS
dwg_ent_table_get_data_vert_ins_linewt(const dwg_ent_table * restrict table,int * restrict error)18938 dwg_ent_table_get_data_vert_ins_linewt (const dwg_ent_table *restrict table,
18939                                         int *restrict error)
18940 {
18941   if (table)
18942     {
18943       *error = 0;
18944       return table->data_vert_ins_linewt;
18945     }
18946   else
18947     {
18948       *error = 1;
18949       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18950       return 0;
18951     }
18952 }
18953 
18954 /** Sets _dwg_entity_TABLE::data_vert_right_linewt
18955 \param[in]  table      dwg_ent_table *
18956 \param[in]  linewt     short
18957 \param[out] error      set to 0 for ok, 1 on error
18958 \deprecated
18959 */
18960 void
dwg_ent_table_set_data_vert_right_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)18961 dwg_ent_table_set_data_vert_right_linewt (dwg_ent_table *restrict table,
18962                                           const BITCODE_BS linewt,
18963                                           int *restrict error)
18964 {
18965   if (table)
18966     {
18967       *error = 0;
18968       table->data_vert_right_linewt = linewt;
18969     }
18970   else
18971     {
18972       *error = 1;
18973       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18974     }
18975 }
18976 
18977 /** Returns _dwg_entity_TABLE::data_vert_right_linewt
18978 \param[in]  table      dwg_ent_table *
18979 \param[out] error      set to 0 for ok, 1 on error
18980 \deprecated
18981 */
18982 BITCODE_BS
dwg_ent_table_get_data_vert_right_linewt(const dwg_ent_table * restrict table,int * restrict error)18983 dwg_ent_table_get_data_vert_right_linewt (const dwg_ent_table *restrict table,
18984                                           int *restrict error)
18985 {
18986   if (table)
18987     {
18988       *error = 0;
18989       return table->data_vert_right_linewt;
18990     }
18991   else
18992     {
18993       *error = 1;
18994       LOG_ERROR ("%s: empty arg", __FUNCTION__)
18995       return 0;
18996     }
18997 }
18998 
18999 /** Sets _dwg_entity_TABLE::data_vert_left_linewt
19000 \param[in]  table      dwg_ent_table *
19001 \param[in]  linewt     short
19002 \param[out] error      set to 0 for ok, 1 on error
19003 \deprecated
19004 */
19005 void
dwg_ent_table_set_data_vert_left_linewt(dwg_ent_table * restrict table,const BITCODE_BS linewt,int * restrict error)19006 dwg_ent_table_set_data_vert_left_linewt (dwg_ent_table *restrict table,
19007                                          const BITCODE_BS linewt,
19008                                          int *restrict error)
19009 {
19010   if (table)
19011     {
19012       *error = 0;
19013       table->data_vert_left_linewt = linewt;
19014     }
19015   else
19016     {
19017       *error = 1;
19018       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19019     }
19020 }
19021 
19022 /** Returns _dwg_entity_TABLE::data_vert_left_linewt
19023 \param[in]  table      dwg_ent_table *
19024 \param[out] error      set to 0 for ok, 1 on error
19025 \deprecated
19026 */
19027 BITCODE_BS
dwg_ent_table_get_data_vert_left_linewt(const dwg_ent_table * restrict table,int * restrict error)19028 dwg_ent_table_get_data_vert_left_linewt (const dwg_ent_table *restrict table,
19029                                          int *restrict error)
19030 {
19031   if (table)
19032     {
19033       *error = 0;
19034       return table->data_vert_left_linewt;
19035     }
19036   else
19037     {
19038       *error = 1;
19039       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19040       return 0;
19041     }
19042 }
19043 
19044 /** Returns _dwg_entity_TABLE::has_border_visibility_overrides
19045 \param[in]  table      dwg_ent_table *
19046 \param[out] error      set to 0 for ok, 1 on error
19047 \deprecated
19048 */
19049 unsigned char
dwg_ent_table_has_border_visibility_overrides(dwg_ent_table * restrict table,int * restrict error)19050 dwg_ent_table_has_border_visibility_overrides (dwg_ent_table *restrict table,
19051                                                int *restrict error)
19052 {
19053   if (table)
19054     {
19055       *error = 0;
19056       return table->has_border_visibility_overrides;
19057     }
19058   else
19059     {
19060       *error = 1;
19061       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19062       return '\0';
19063     }
19064 }
19065 
19066 /** Sets _dwg_entity_TABLE::border_visibility_overrides_flag, DXF 96.
19067 \param[in]  table      dwg_ent_table *
19068 \param[in]  overrides  0 or 1
19069 \param[out] error      set to 0 for ok, 1 on error
19070 \deprecated
19071 */
19072 void
dwg_ent_table_set_border_visibility_overrides_flag(dwg_ent_table * restrict table,const BITCODE_BL overrides,int * restrict error)19073 dwg_ent_table_set_border_visibility_overrides_flag (
19074     dwg_ent_table *restrict table, const BITCODE_BL overrides,
19075     int *restrict error)
19076 {
19077   if (table != NULL && overrides <= 1)
19078     {
19079       *error = 0;
19080       table->border_visibility_overrides_flag = overrides;
19081     }
19082   else
19083     {
19084       *error = 1;
19085       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19086     }
19087 }
19088 
19089 /** Returns _dwg_entity_TABLE::border_visibility_overrides_flag, DXF 96.
19090 \param[in]  table      dwg_ent_table *
19091 \param[out] error      set to 0 for ok, 1 on error
19092 \deprecated
19093 */
19094 BITCODE_BL
dwg_ent_table_get_border_visibility_overrides_flag(const dwg_ent_table * restrict table,int * restrict error)19095 dwg_ent_table_get_border_visibility_overrides_flag (
19096     const dwg_ent_table *restrict table, int *restrict error)
19097 {
19098   if (table)
19099     {
19100       *error = 0;
19101       return table->border_visibility_overrides_flag;
19102     }
19103   else
19104     {
19105       *error = 1;
19106       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19107       return 0L;
19108     }
19109 }
19110 
19111 /** Sets _dwg_entity_TABLE::title_horiz_top_visibility, DXF ??.
19112 \param[in]  table      dwg_ent_table *
19113 \param[in]  visibility 0 or 1
19114 \param[out] error      set to 0 for ok, 1 on error
19115 \deprecated
19116 */
19117 void
dwg_ent_table_set_title_horiz_top_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19118 dwg_ent_table_set_title_horiz_top_visibility (dwg_ent_table *restrict table,
19119                                               const BITCODE_BS visibility,
19120                                               int *restrict error)
19121 {
19122   if (table != NULL && visibility <= 1)
19123     {
19124       *error = 0;
19125       if (visibility)
19126         table->border_visibility_overrides_flag |= 0x1;
19127       table->title_horiz_top_visibility = visibility;
19128     }
19129   else
19130     {
19131       *error = 1;
19132       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19133     }
19134 }
19135 
19136 /** Returns _dwg_entity_TABLE::title_horiz_top_visibility, DXF ??.
19137 \param[in]  table      dwg_ent_table *
19138 \param[out] error      set to 0 for ok, 1 on error
19139 \deprecated
19140 */
19141 BITCODE_BS
dwg_ent_table_get_title_horiz_top_visibility(const dwg_ent_table * restrict table,int * restrict error)19142 dwg_ent_table_get_title_horiz_top_visibility (
19143     const dwg_ent_table *restrict table, int *restrict error)
19144 {
19145   if (table)
19146     {
19147       *error = 0;
19148       return table->title_horiz_top_visibility;
19149     }
19150   else
19151     {
19152       *error = 1;
19153       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19154       return 0;
19155     }
19156 }
19157 
19158 /** Sets _dwg_entity_TABLE::title_horiz_ins_visibility, DXF ??.
19159 \param[in]  table      dwg_ent_table *
19160 \param[in]  visibility 0 or 1
19161 \param[out] error      set to 0 for ok, 1 on error
19162 \deprecated
19163 */
19164 void
dwg_ent_table_set_title_horiz_ins_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19165 dwg_ent_table_set_title_horiz_ins_visibility (dwg_ent_table *restrict table,
19166                                               const BITCODE_BS visibility,
19167                                               int *restrict error)
19168 {
19169   if (table != NULL && visibility <= 1)
19170     {
19171       *error = 0;
19172       if (visibility)
19173         table->border_visibility_overrides_flag |= 0x2;
19174       table->title_horiz_ins_visibility = visibility;
19175     }
19176   else
19177     {
19178       *error = 1;
19179       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19180     }
19181 }
19182 
19183 /** Returns _dwg_entity_TABLE::title_horiz_ins_visibility, DXF ??.
19184 \param[in]  table      dwg_ent_table *
19185 \param[out] error      set to 0 for ok, 1 on error
19186 \deprecated
19187 */
19188 BITCODE_BS
dwg_ent_table_get_title_horiz_ins_visibility(const dwg_ent_table * restrict table,int * restrict error)19189 dwg_ent_table_get_title_horiz_ins_visibility (
19190     const dwg_ent_table *restrict table, int *restrict error)
19191 {
19192   if (table)
19193     {
19194       *error = 0;
19195       return table->title_horiz_ins_visibility;
19196     }
19197   else
19198     {
19199       *error = 1;
19200       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19201       return 0;
19202     }
19203 }
19204 
19205 /** Sets _dwg_entity_TABLE::title_horiz_bottom_visibility, DXF ??.
19206 \param[in]  table      dwg_ent_table *
19207 \param[in]  visibility 0 or 1
19208 \param[out] error      set to 0 for ok, 1 on error
19209 \deprecated
19210 */
19211 void
dwg_ent_table_set_title_horiz_bottom_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19212 dwg_ent_table_set_title_horiz_bottom_visibility (dwg_ent_table *restrict table,
19213                                                  const BITCODE_BS visibility,
19214                                                  int *restrict error)
19215 {
19216   if (table != NULL && visibility <= 1)
19217     {
19218       *error = 0;
19219       if (visibility)
19220         table->border_visibility_overrides_flag |= 0x4;
19221       table->title_horiz_bottom_visibility = visibility;
19222     }
19223   else
19224     {
19225       *error = 1;
19226       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19227     }
19228 }
19229 
19230 /** Returns _dwg_entity_TABLE::title_horiz_bottom_visibility, DXF ??.
19231 \param[in]  table      dwg_ent_table *
19232 \param[out] error      set to 0 for ok, 1 on error
19233 \deprecated
19234 */
19235 BITCODE_BS
dwg_ent_table_get_title_horiz_bottom_visibility(const dwg_ent_table * restrict table,int * restrict error)19236 dwg_ent_table_get_title_horiz_bottom_visibility (
19237     const dwg_ent_table *restrict table, int *restrict error)
19238 {
19239   if (table)
19240     {
19241       *error = 0;
19242       return table->title_horiz_bottom_visibility;
19243     }
19244   else
19245     {
19246       *error = 1;
19247       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19248       return 0;
19249     }
19250 }
19251 
19252 /** Sets _dwg_entity_TABLE::title_vert_left_visibility, DXF ??.
19253 \param[in]  table      dwg_ent_table *
19254 \param[in]  visibility 0 or 1
19255 \param[out] error      set to 0 for ok, 1 on error
19256 \deprecated
19257 */
19258 void
dwg_ent_table_set_title_vert_left_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19259 dwg_ent_table_set_title_vert_left_visibility (dwg_ent_table *restrict table,
19260                                               const BITCODE_BS visibility,
19261                                               int *restrict error)
19262 {
19263   if (table != NULL && visibility <= 1)
19264     {
19265       *error = 0;
19266       if (visibility)
19267         table->border_visibility_overrides_flag |= 0x8;
19268       table->title_vert_left_visibility = visibility;
19269     }
19270   else
19271     {
19272       *error = 1;
19273       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19274     }
19275 }
19276 
19277 /** Returns _dwg_entity_TABLE::title_vert_left_visibility, DXF ??.
19278 \param[in]  table      dwg_ent_table *
19279 \param[out] error      set to 0 for ok, 1 on error
19280 \deprecated
19281 */
19282 BITCODE_BS
dwg_ent_table_get_title_vert_left_visibility(const dwg_ent_table * restrict table,int * restrict error)19283 dwg_ent_table_get_title_vert_left_visibility (
19284     const dwg_ent_table *restrict table, int *restrict error)
19285 {
19286   if (table)
19287     {
19288       *error = 0;
19289       return table->title_vert_left_visibility;
19290     }
19291   else
19292     {
19293       *error = 1;
19294       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19295       return 0;
19296     }
19297 }
19298 
19299 /** Sets _dwg_entity_TABLE::title_vert_ins_visibility, DXF ??.
19300 \param[in]  table      dwg_ent_table *
19301 \param[in]  visibility 0 or 1
19302 \param[out] error      set to 0 for ok, 1 on error
19303 \deprecated
19304 */
19305 void
dwg_ent_table_set_title_vert_ins_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19306 dwg_ent_table_set_title_vert_ins_visibility (dwg_ent_table *restrict table,
19307                                              const BITCODE_BS visibility,
19308                                              int *restrict error)
19309 {
19310   if (table != NULL && visibility <= 1)
19311     {
19312       *error = 0;
19313       if (visibility)
19314         table->border_visibility_overrides_flag |= 0x10;
19315       table->title_vert_ins_visibility = visibility;
19316     }
19317   else
19318     {
19319       *error = 1;
19320       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19321     }
19322 }
19323 
19324 /** Returns _dwg_entity_TABLE::title_vert_ins_visibility, DXF ??.
19325 \param[in]  table      dwg_ent_table *
19326 \param[out] error      set to 0 for ok, 1 on error
19327 \deprecated
19328 */
19329 BITCODE_BS
dwg_ent_table_get_title_vert_ins_visibility(const dwg_ent_table * restrict table,int * restrict error)19330 dwg_ent_table_get_title_vert_ins_visibility (
19331     const dwg_ent_table *restrict table, int *restrict error)
19332 {
19333   if (table)
19334     {
19335       *error = 0;
19336       return table->title_vert_ins_visibility;
19337     }
19338   else
19339     {
19340       *error = 1;
19341       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19342       return 0;
19343     }
19344 }
19345 
19346 /** Sets _dwg_entity_TABLE::title_vert_right_visibility, DXF ??.
19347 \param[in]  table      dwg_ent_table *
19348 \param[in]  visibility 0 or 1
19349 \param[out] error      set to 0 for ok, 1 on error
19350 \deprecated
19351 */
19352 void
dwg_ent_table_set_title_vert_right_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19353 dwg_ent_table_set_title_vert_right_visibility (dwg_ent_table *restrict table,
19354                                                const BITCODE_BS visibility,
19355                                                int *restrict error)
19356 {
19357   if (table != NULL && visibility <= 1)
19358     {
19359       *error = 0;
19360       if (visibility)
19361         table->border_visibility_overrides_flag |= 0x20;
19362       table->title_vert_right_visibility = visibility;
19363     }
19364   else
19365     {
19366       *error = 1;
19367       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19368     }
19369 }
19370 
19371 /** Returns _dwg_entity_TABLE::title_vert_right_visibility, DXF ??.
19372 \param[in]  table      dwg_ent_table *
19373 \param[out] error      set to 0 for ok, 1 on error
19374 \deprecated
19375 */
19376 BITCODE_BS
dwg_ent_table_get_title_vert_right_visibility(const dwg_ent_table * restrict table,int * restrict error)19377 dwg_ent_table_get_title_vert_right_visibility (
19378     const dwg_ent_table *restrict table, int *restrict error)
19379 {
19380   if (table)
19381     {
19382       *error = 0;
19383       return table->title_vert_right_visibility;
19384     }
19385   else
19386     {
19387       *error = 1;
19388       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19389       return 0;
19390     }
19391 }
19392 
19393 /** Sets _dwg_entity_TABLE::header_horiz_top_visibility, DXF ??.
19394 \param[in]  table      dwg_ent_table *
19395 \param[in]  visibility 0 or 1
19396 \param[out] error      set to 0 for ok, 1 on error
19397 \deprecated
19398 */
19399 void
dwg_ent_table_set_header_horiz_top_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19400 dwg_ent_table_set_header_horiz_top_visibility (dwg_ent_table *restrict table,
19401                                                const BITCODE_BS visibility,
19402                                                int *restrict error)
19403 {
19404   if (table != NULL && visibility <= 1)
19405     {
19406       *error = 0;
19407       if (visibility)
19408         table->border_visibility_overrides_flag |= 0x40;
19409       table->header_horiz_top_visibility = visibility;
19410     }
19411   else
19412     {
19413       *error = 1;
19414       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19415     }
19416 }
19417 
19418 /** Returns _dwg_entity_TABLE::header_horiz_top_visibility, DXF ??.
19419 \param[in]  table      dwg_ent_table *
19420 \param[out] error      set to 0 for ok, 1 on error
19421 \deprecated
19422 */
19423 BITCODE_BS
dwg_ent_table_get_header_horiz_top_visibility(const dwg_ent_table * restrict table,int * restrict error)19424 dwg_ent_table_get_header_horiz_top_visibility (
19425     const dwg_ent_table *restrict table, int *restrict error)
19426 {
19427   if (table)
19428     {
19429       *error = 0;
19430       return table->header_horiz_top_visibility;
19431     }
19432   else
19433     {
19434       *error = 1;
19435       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19436       return 0;
19437     }
19438 }
19439 
19440 /** Sets _dwg_entity_TABLE::header_horiz_ins_visibility, DXF ??.
19441 \param[in]  table      dwg_ent_table *
19442 \param[in]  visibility 0 or 1
19443 \param[out] error      set to 0 for ok, 1 on error
19444 \deprecated
19445 */
19446 void
dwg_ent_table_set_header_horiz_ins_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19447 dwg_ent_table_set_header_horiz_ins_visibility (dwg_ent_table *restrict table,
19448                                                const BITCODE_BS visibility,
19449                                                int *restrict error)
19450 {
19451   if (table != NULL && visibility <= 1)
19452     {
19453       *error = 0;
19454       if (visibility)
19455         table->border_visibility_overrides_flag |= 0x80;
19456       table->header_horiz_ins_visibility = visibility;
19457     }
19458   else
19459     {
19460       *error = 1;
19461       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19462     }
19463 }
19464 
19465 /** Returns _dwg_entity_TABLE::header_horiz_ins_visibility, DXF ??.
19466 \param[in]  table      dwg_ent_table *
19467 \param[out] error      set to 0 for ok, 1 on error
19468 \deprecated
19469 */
19470 BITCODE_BS
dwg_ent_table_get_header_horiz_ins_visibility(const dwg_ent_table * restrict table,int * restrict error)19471 dwg_ent_table_get_header_horiz_ins_visibility (
19472     const dwg_ent_table *restrict table, int *restrict error)
19473 {
19474   if (table)
19475     {
19476       *error = 0;
19477       return table->header_horiz_ins_visibility;
19478     }
19479   else
19480     {
19481       *error = 1;
19482       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19483       return 0;
19484     }
19485 }
19486 
19487 /** Sets _dwg_entity_TABLE::header_horiz_bottom_visibility, DXF ??.
19488 \param[in]  table      dwg_ent_table *
19489 \param[in]  visibility 0 or 1
19490 \param[out] error      set to 0 for ok, 1 on error
19491 \deprecated
19492 */
19493 void
dwg_ent_table_set_header_horiz_bottom_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19494 dwg_ent_table_set_header_horiz_bottom_visibility (
19495     dwg_ent_table *restrict table, const BITCODE_BS visibility,
19496     int *restrict error)
19497 {
19498   if (table != NULL && visibility <= 1)
19499     {
19500       *error = 0;
19501       if (visibility)
19502         table->border_visibility_overrides_flag |= 0x100;
19503       table->header_horiz_bottom_visibility = visibility;
19504     }
19505   else
19506     {
19507       *error = 1;
19508       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19509     }
19510 }
19511 
19512 /** Returns _dwg_entity_TABLE::header_horiz_bottom_visibility, DXF ??.
19513 \param[in]  table      dwg_ent_table *
19514 \param[out] error      set to 0 for ok, 1 on error
19515 \deprecated
19516 */
19517 BITCODE_BS
dwg_ent_table_get_header_horiz_bottom_visibility(const dwg_ent_table * restrict table,int * restrict error)19518 dwg_ent_table_get_header_horiz_bottom_visibility (
19519     const dwg_ent_table *restrict table, int *restrict error)
19520 {
19521   if (table)
19522     {
19523       *error = 0;
19524       return table->header_horiz_bottom_visibility;
19525     }
19526   else
19527     {
19528       *error = 1;
19529       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19530       return 0;
19531     }
19532 }
19533 
19534 /** Sets _dwg_entity_TABLE::header_vert_left_visibility, DXF ??.
19535 \param[in]  table      dwg_ent_table *
19536 \param[in]  visibility 0 or 1
19537 \param[out] error      set to 0 for ok, 1 on error
19538 \deprecated
19539 */
19540 void
dwg_ent_table_set_header_vert_left_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19541 dwg_ent_table_set_header_vert_left_visibility (dwg_ent_table *restrict table,
19542                                                const BITCODE_BS visibility,
19543                                                int *restrict error)
19544 {
19545   if (table != NULL && visibility <= 1)
19546     {
19547       *error = 0;
19548       if (visibility)
19549         table->border_visibility_overrides_flag |= 0x200;
19550       table->header_vert_left_visibility = visibility;
19551     }
19552   else
19553     {
19554       *error = 1;
19555       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19556     }
19557 }
19558 
19559 /** Returns _dwg_entity_TABLE::header_vert_left_visibility, DXF ??.
19560 \param[in]  table      dwg_ent_table *
19561 \param[out] error      set to 0 for ok, 1 on error
19562 \deprecated
19563 */
19564 BITCODE_BS
dwg_ent_table_get_header_vert_left_visibility(const dwg_ent_table * restrict table,int * restrict error)19565 dwg_ent_table_get_header_vert_left_visibility (
19566     const dwg_ent_table *restrict table, int *restrict error)
19567 {
19568   if (table)
19569     {
19570       *error = 0;
19571       return table->header_vert_left_visibility;
19572     }
19573   else
19574     {
19575       *error = 1;
19576       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19577       return 0;
19578     }
19579 }
19580 
19581 /** Sets _dwg_entity_TABLE::header_vert_ins_visibility, DXF ??.
19582 \param[in]  table      dwg_ent_table *
19583 \param[in]  visibility 0 or 1
19584 \param[out] error      set to 0 for ok, 1 on error
19585 \deprecated
19586 */
19587 void
dwg_ent_table_set_header_vert_ins_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19588 dwg_ent_table_set_header_vert_ins_visibility (dwg_ent_table *restrict table,
19589                                               const BITCODE_BS visibility,
19590                                               int *restrict error)
19591 {
19592   if (table != NULL && visibility <= 1)
19593     {
19594       *error = 0;
19595       if (visibility)
19596         table->border_visibility_overrides_flag |= 0x400;
19597       table->header_vert_ins_visibility = visibility;
19598     }
19599   else
19600     {
19601       *error = 1;
19602       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19603     }
19604 }
19605 
19606 /** Returns _dwg_entity_TABLE::header_vert_ins_visibility, DXF ??.
19607 \param[in]  table      dwg_ent_table *
19608 \param[out] error      set to 0 for ok, 1 on error
19609 \deprecated
19610 */
19611 BITCODE_BS
dwg_ent_table_get_header_vert_ins_visibility(const dwg_ent_table * restrict table,int * restrict error)19612 dwg_ent_table_get_header_vert_ins_visibility (
19613     const dwg_ent_table *restrict table, int *restrict error)
19614 {
19615   if (table)
19616     {
19617       *error = 0;
19618       return table->header_vert_ins_visibility;
19619     }
19620   else
19621     {
19622       *error = 1;
19623       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19624       return 0;
19625     }
19626 }
19627 
19628 /** Sets data header vert right visibility
19629 \param[in]  table      dwg_ent_table *
19630 \param[in]  visibility 0 or 1
19631 \param[out] error      set to 0 for ok, 1 on error
19632 \deprecated
19633 */
19634 void
dwg_ent_table_set_header_vert_right_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19635 dwg_ent_table_set_header_vert_right_visibility (dwg_ent_table *restrict table,
19636                                                 const BITCODE_BS visibility,
19637                                                 int *restrict error)
19638 {
19639   if (table != NULL && visibility <= 1)
19640     {
19641       *error = 0;
19642       if (visibility)
19643         table->border_visibility_overrides_flag |= 0x800;
19644       table->header_vert_right_visibility = visibility;
19645     }
19646   else
19647     {
19648       *error = 1;
19649       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19650     }
19651 }
19652 
19653 /** Returns _dwg_entity_TABLE::header_vert_right_visibility, DXF ??.
19654 \param[in]  table      dwg_ent_table *
19655 \param[out] error      set to 0 for ok, 1 on error
19656 \deprecated
19657 */
19658 BITCODE_BS
dwg_ent_table_get_header_vert_right_visibility(const dwg_ent_table * restrict table,int * restrict error)19659 dwg_ent_table_get_header_vert_right_visibility (
19660     const dwg_ent_table *restrict table, int *restrict error)
19661 {
19662   if (table)
19663     {
19664       *error = 0;
19665       return table->header_vert_right_visibility;
19666     }
19667   else
19668     {
19669       *error = 1;
19670       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19671       return 0;
19672     }
19673 }
19674 
19675 /** Sets _dwg_entity_TABLE::data_horiz_top_visibility, DXF ??.
19676 \param[in]  table      dwg_ent_table *
19677 \param[in]  visibility 0 or 1
19678 \param[out] error      set to 0 for ok, 1 on error
19679 \deprecated
19680 */
19681 void
dwg_ent_table_set_data_horiz_top_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19682 dwg_ent_table_set_data_horiz_top_visibility (dwg_ent_table *restrict table,
19683                                              const BITCODE_BS visibility,
19684                                              int *restrict error)
19685 {
19686   if (table != NULL && visibility <= 1)
19687     {
19688       *error = 0;
19689       if (visibility)
19690         table->border_visibility_overrides_flag |= 0x1000;
19691       table->data_horiz_top_visibility = visibility;
19692     }
19693   else
19694     {
19695       *error = 1;
19696       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19697     }
19698 }
19699 
19700 /** Returns _dwg_entity_TABLE::data_horiz_top_visibility, DXF ??.
19701 \param[in]  table      dwg_ent_table *
19702 \param[out] error      set to 0 for ok, 1 on error
19703 \deprecated
19704 */
19705 BITCODE_BS
dwg_ent_table_get_data_horiz_top_visibility(const dwg_ent_table * restrict table,int * restrict error)19706 dwg_ent_table_get_data_horiz_top_visibility (
19707     const dwg_ent_table *restrict table, int *restrict error)
19708 {
19709   if (table)
19710     {
19711       *error = 0;
19712       return table->data_horiz_top_visibility;
19713     }
19714   else
19715     {
19716       *error = 1;
19717       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19718       return 0;
19719     }
19720 }
19721 
19722 /** Sets _dwg_entity_TABLE::data_horiz_ins_visibility, DXF ?
19723 \param[in]  table      dwg_ent_table *
19724 \param[in]  visibility 0 or 1
19725 \param[out] error      set to 0 for ok, 1 on error
19726 \deprecated
19727 */
19728 void
dwg_ent_table_set_data_horiz_ins_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19729 dwg_ent_table_set_data_horiz_ins_visibility (dwg_ent_table *restrict table,
19730                                              const BITCODE_BS visibility,
19731                                              int *restrict error)
19732 {
19733   if (table != NULL && visibility <= 1)
19734     {
19735       *error = 0;
19736       if (visibility)
19737         table->border_visibility_overrides_flag |= 0x2000;
19738       table->data_horiz_ins_visibility = visibility;
19739     }
19740   else
19741     {
19742       *error = 1;
19743       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19744     }
19745 }
19746 
19747 /** Returns _dwg_entity_TABLE::data_horiz_ins_visibility, DXF ?
19748 \param[in]  table      dwg_ent_table *
19749 \param[out] error      set to 0 for ok, 1 on error
19750 \deprecated
19751 */
19752 BITCODE_BS
dwg_ent_table_get_data_horiz_ins_visibility(const dwg_ent_table * restrict table,int * restrict error)19753 dwg_ent_table_get_data_horiz_ins_visibility (
19754     const dwg_ent_table *restrict table, int *restrict error)
19755 {
19756   if (table)
19757     {
19758       *error = 0;
19759       return table->data_horiz_ins_visibility;
19760     }
19761   else
19762     {
19763       *error = 1;
19764       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19765       return 0;
19766     }
19767 }
19768 
19769 /** Sets _dwg_entity_TABLE::data_horiz_bottom_visibility, DXF ?.
19770 \param[in]  table      dwg_ent_table *
19771 \param[in]  visibility 0 or 1
19772 \param[out] error      set to 0 for ok, 1 on error
19773 \deprecated
19774 */
19775 void
dwg_ent_table_set_data_horiz_bottom_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19776 dwg_ent_table_set_data_horiz_bottom_visibility (dwg_ent_table *restrict table,
19777                                                 const BITCODE_BS visibility,
19778                                                 int *restrict error)
19779 {
19780   if (table != NULL && visibility <= 1)
19781     {
19782       *error = 0;
19783       if (visibility)
19784         table->border_visibility_overrides_flag |= 0x4000;
19785       table->data_horiz_bottom_visibility = visibility;
19786     }
19787   else
19788     {
19789       *error = 1;
19790       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19791     }
19792 }
19793 
19794 /** Returns _dwg_entity_TABLE::data_horiz_bottom_visibility, DXF ?.
19795 \param[in]  table      dwg_ent_table *
19796 \param[out] error      set to 0 for ok, 1 on error
19797 \deprecated
19798 */
19799 BITCODE_BS
dwg_ent_table_get_data_horiz_bottom_visibility(const dwg_ent_table * restrict table,int * restrict error)19800 dwg_ent_table_get_data_horiz_bottom_visibility (
19801     const dwg_ent_table *restrict table, int *restrict error)
19802 {
19803   if (table)
19804     {
19805       *error = 0;
19806       return table->data_horiz_bottom_visibility;
19807     }
19808   else
19809     {
19810       *error = 1;
19811       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19812       return 0;
19813     }
19814 }
19815 
19816 /** Sets _dwg_entity_TABLE::data_vert_left_visibility, DXF ?.
19817 \param[in]  table      dwg_ent_table *
19818 \param[in]  visibility 0 or 1
19819 \param[out] error      set to 0 for ok, 1 on error
19820 \deprecated
19821 */
19822 void
dwg_ent_table_set_data_vert_left_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19823 dwg_ent_table_set_data_vert_left_visibility (dwg_ent_table *restrict table,
19824                                              const BITCODE_BS visibility,
19825                                              int *restrict error)
19826 {
19827   if (table != NULL && visibility <= 1)
19828     {
19829       *error = 0;
19830       if (visibility)
19831         table->border_visibility_overrides_flag |= 0x8000;
19832       table->data_vert_left_visibility = visibility;
19833     }
19834   else
19835     {
19836       *error = 1;
19837       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19838     }
19839 }
19840 
19841 /** Returns _dwg_entity_TABLE::data_vert_left_visibility, DXF ?.
19842 \param[in]  table  dwg_ent_table *
19843 \param[out] error  set to 0 for ok, 1 on error
19844 \deprecated
19845 */
19846 BITCODE_BS
dwg_ent_table_get_data_vert_left_visibility(const dwg_ent_table * restrict table,int * restrict error)19847 dwg_ent_table_get_data_vert_left_visibility (
19848     const dwg_ent_table *restrict table, int *restrict error)
19849 {
19850   if (table)
19851     {
19852       *error = 0;
19853       return table->data_vert_left_visibility;
19854     }
19855   else
19856     {
19857       *error = 1;
19858       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19859       return 0;
19860     }
19861 }
19862 
19863 /** Sets _dwg_entity_TABLE::data_vert_ins_visibility, DXF ?.
19864 \param[in]  table      dwg_ent_table *
19865 \param[in]  visibility 0 or 1
19866 \param[out] error      set to 0 for ok, 1 on error
19867 \deprecated
19868 */
19869 void
dwg_ent_table_set_data_vert_ins_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19870 dwg_ent_table_set_data_vert_ins_visibility (dwg_ent_table *restrict table,
19871                                             const BITCODE_BS visibility,
19872                                             int *restrict error)
19873 {
19874   if (table != NULL && visibility <= 1)
19875     {
19876       *error = 0;
19877       if (visibility)
19878         table->border_visibility_overrides_flag |= 0x10000;
19879       table->data_vert_ins_visibility = visibility;
19880     }
19881   else
19882     {
19883       *error = 1;
19884       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19885     }
19886 }
19887 
19888 /** Returns _dwg_entity_TABLE::data_vert_ins_visibility, DXF ?.
19889 \param[in]  table  dwg_ent_table *
19890 \param[out] error  set to 0 for ok, 1 on error
19891 \deprecated
19892 */
19893 BITCODE_BS
dwg_ent_table_get_data_vert_ins_visibility(const dwg_ent_table * restrict table,int * restrict error)19894 dwg_ent_table_get_data_vert_ins_visibility (
19895     const dwg_ent_table *restrict table, int *restrict error)
19896 {
19897   if (table)
19898     {
19899       *error = 0;
19900       return table->data_vert_ins_visibility;
19901     }
19902   else
19903     {
19904       *error = 1;
19905       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19906       return 0;
19907     }
19908 }
19909 
19910 /** Sets the table data vert right visibility.
19911     Bit 0x20000 of border_visibility override flag, DXF 96
19912 \param[in]  table      dwg_ent_table *
19913 \param[in]  visibility short: 0 = visible, 1 = invisible
19914 \param[out] error      set to 0 for ok, 1 on error
19915 \deprecated
19916 */
19917 void
dwg_ent_table_set_data_vert_right_visibility(dwg_ent_table * restrict table,const BITCODE_BS visibility,int * restrict error)19918 dwg_ent_table_set_data_vert_right_visibility (dwg_ent_table *restrict table,
19919                                               const BITCODE_BS visibility,
19920                                               int *restrict error)
19921 {
19922   if (table != NULL && visibility <= 1)
19923     {
19924       *error = 0;
19925       if (visibility)
19926         table->border_visibility_overrides_flag |= 0x20000;
19927       table->data_vert_right_visibility = visibility;
19928     }
19929   else
19930     {
19931       *error = 1;
19932       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
19933     }
19934 }
19935 
19936 /** Returns _dwg_entity_TABLE::data vert right visibility, DXF ?.
19937     Bit 0x20000 of border_visibility override flag, DXF 96
19938 \param[in]  table  dwg_ent_table *
19939 \param[out] error  set to 0 for ok, 1 on error
19940 \deprecated
19941 */
19942 BITCODE_BS
dwg_ent_table_get_data_vert_right_visibility(const dwg_ent_table * restrict table,int * restrict error)19943 dwg_ent_table_get_data_vert_right_visibility (
19944     const dwg_ent_table *restrict table, int *restrict error)
19945 {
19946   if (table)
19947     {
19948       *error = 0;
19949       return table->data_vert_right_visibility;
19950     }
19951   else
19952     {
19953       *error = 1;
19954       LOG_ERROR ("%s: empty arg", __FUNCTION__)
19955       return 0;
19956     }
19957 }
19958 
19959 #endif /* USE_DEPRECATED_API */
19960 
19961 #endif /* __AFL_COMPILER ************************************************ */
19962 
19963 /** Returns number of vertices
19964  */
19965 BITCODE_BL
dwg_object_polyline_2d_get_numpoints(const dwg_object * restrict obj,int * restrict error)19966 dwg_object_polyline_2d_get_numpoints (const dwg_object *restrict obj,
19967                                       int *restrict error)
19968 {
19969   if (obj && obj->type == DWG_TYPE_POLYLINE_2D)
19970     {
19971       BITCODE_BL num_points = 0;
19972       Dwg_Data *dwg = obj->parent;
19973       Dwg_Entity_POLYLINE_2D *_obj = obj->tio.entity->tio.POLYLINE_2D;
19974       Dwg_Entity_VERTEX_2D *vertex;
19975       *error = 0;
19976 
19977       if (dwg->header.version >= R_2004)
19978         return obj->tio.entity->tio.POLYLINE_2D->num_owned;
19979       // iterate over first_vertex - last_vertex
19980       else if (dwg->header.version >= R_13)
19981         {
19982           Dwg_Object *vobj = dwg_ref_object (dwg, _obj->first_vertex);
19983           Dwg_Object *vlast = dwg_ref_object (dwg, _obj->last_vertex);
19984           if (!vobj)
19985             *error = 1;
19986           else
19987             {
19988               do
19989                 {
19990                   if ((vertex = dwg_object_to_VERTEX_2D (vobj)))
19991                     {
19992                       num_points++;
19993                     }
19994                   else
19995                     {
19996                       *error = 1; // return not all vertices, but some
19997                     }
19998                 }
19999               while ((vobj = dwg_next_object (vobj)) && vobj != vlast);
20000             }
20001         }
20002       else // <r13: iterate over vertices until seqend
20003         {
20004           Dwg_Object *vobj;
20005           while ((vobj = dwg_next_object (obj))
20006                  && vobj->type != DWG_TYPE_SEQEND)
20007             {
20008               if ((vertex = dwg_object_to_VERTEX_2D (vobj)))
20009                 num_points++;
20010               else
20011                 *error = 1; // return not all vertices, but some
20012             }
20013         }
20014       return num_points;
20015     }
20016   else
20017     {
20018       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
20019       *error = 1;
20020       return 0L;
20021     }
20022 }
20023 
20024 /** Returns a copy of the points
20025  */
20026 dwg_point_2d *
dwg_object_polyline_2d_get_points(const dwg_object * restrict obj,int * restrict error)20027 dwg_object_polyline_2d_get_points (const dwg_object *restrict obj,
20028                                    int *restrict error)
20029 {
20030   *error = 0;
20031   if (obj && obj->type == DWG_TYPE_POLYLINE_2D)
20032     {
20033       BITCODE_BL i;
20034       Dwg_Data *dwg = obj->parent;
20035       Dwg_Entity_POLYLINE_2D *_obj = obj->tio.entity->tio.POLYLINE_2D;
20036       BITCODE_BL num_points
20037           = dwg_object_polyline_2d_get_numpoints (obj, error);
20038       Dwg_Entity_VERTEX_2D *vertex = NULL;
20039       dwg_point_2d *ptx;
20040 
20041       if (!num_points || *error)
20042         return NULL;
20043       ptx = (dwg_point_2d *)calloc (num_points, sizeof (dwg_point_2d));
20044       if (!ptx)
20045         {
20046           LOG_ERROR ("%s: Out of memory", __FUNCTION__);
20047           *error = 1;
20048           return NULL;
20049         }
20050       if (dwg->header.version >= R_2004)
20051         for (i = 0; i < num_points; i++)
20052           {
20053             Dwg_Object *vobj = dwg_ref_object (dwg, _obj->vertex[i]);
20054             if (vobj && (vertex = dwg_object_to_VERTEX_2D (vobj)))
20055               {
20056                 ptx[i].x = vertex->point.x;
20057                 ptx[i].y = vertex->point.y;
20058               }
20059             else
20060               {
20061                 *error = 1; // return not all vertices, but some
20062               }
20063           }
20064       // iterate over first_vertex - last_vertex
20065       else if (dwg->header.version >= R_13)
20066         {
20067           Dwg_Object *vobj = dwg_ref_object (dwg, _obj->first_vertex);
20068           Dwg_Object *vlast = dwg_ref_object (dwg, _obj->last_vertex);
20069           if (!vobj)
20070             *error = 1;
20071           else
20072             {
20073               i = 0;
20074               do
20075                 {
20076                   if ((vertex = dwg_object_to_VERTEX_2D (vobj)))
20077                     {
20078                       ptx[i].x = vertex->point.x;
20079                       ptx[i].y = vertex->point.y;
20080                       i++;
20081                       if (i > num_points)
20082                         {
20083                           *error = 1;
20084                           break;
20085                         }
20086                     }
20087                   else
20088                     {
20089                       *error = 1; // return not all vertices, but some
20090                     }
20091                 }
20092               while ((vobj = dwg_next_object (vobj)) && vobj != vlast);
20093             }
20094         }
20095       else // <r13: iterate over vertices until seqend
20096         {
20097           Dwg_Object *vobj;
20098           i = 0;
20099           while ((vobj = dwg_next_object (obj))
20100                  && vobj->type != DWG_TYPE_SEQEND)
20101             {
20102               if ((vertex = dwg_object_to_VERTEX_2D (vobj)))
20103                 {
20104                   ptx[i].x = vertex->point.x;
20105                   ptx[i].y = vertex->point.y;
20106                   i++;
20107                   if (i > num_points)
20108                     {
20109                       *error = 1;
20110                       break;
20111                     }
20112                 }
20113               else
20114                 {
20115                   *error = 1; // return not all vertices, but some
20116                 }
20117             }
20118         }
20119       return ptx;
20120     }
20121   else
20122     {
20123       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20124       *error = 1;
20125       return NULL;
20126     }
20127 }
20128 
20129 /** Returns the number of _dwg_object:: POLYLINE_3D vertices,
20130     the list of associated _dwg_object_VERTEX_3D:: points.
20131 */
20132 BITCODE_BL
dwg_object_polyline_3d_get_numpoints(const dwg_object * restrict obj,int * restrict error)20133 dwg_object_polyline_3d_get_numpoints (const dwg_object *restrict obj,
20134                                       int *restrict error)
20135 {
20136   if (obj && obj->type == DWG_TYPE_POLYLINE_3D)
20137     {
20138       BITCODE_BL num_points = 0;
20139       Dwg_Data *dwg = obj->parent;
20140       Dwg_Entity_POLYLINE_3D *_obj = obj->tio.entity->tio.POLYLINE_3D;
20141       Dwg_Entity_VERTEX_3D *vertex;
20142       *error = 0;
20143 
20144       if (dwg->header.version >= R_2004)
20145         return obj->tio.entity->tio.POLYLINE_3D->num_owned;
20146       else if (dwg->header.version
20147                >= R_13) // iterate over first_vertex - last_vertex
20148         {
20149           Dwg_Object *vobj = dwg_ref_object (dwg, _obj->first_vertex);
20150           Dwg_Object *vlast = dwg_ref_object (dwg, _obj->last_vertex);
20151           if (!vobj)
20152             *error = 1;
20153           else
20154             {
20155               do
20156                 {
20157                   if ((vertex = dwg_object_to_VERTEX_3D (vobj)))
20158                     {
20159                       num_points++;
20160                     }
20161                   else
20162                     {
20163                       *error = 1; // return not all vertices, but some
20164                     }
20165                 }
20166               while ((vobj = dwg_next_object (vobj)) && vobj != vlast);
20167             }
20168         }
20169       else // <r13: iterate over vertices until seqend
20170         {
20171           Dwg_Object *vobj;
20172           while ((vobj = dwg_next_object (obj))
20173                  && vobj->type != DWG_TYPE_SEQEND)
20174             {
20175               if ((vertex = dwg_object_to_VERTEX_3D (vobj)))
20176                 num_points++;
20177               else
20178                 *error = 1; // return not all vertices, but some
20179             }
20180         }
20181       return num_points;
20182     }
20183   else
20184     {
20185       LOG_ERROR ("%s: empty or wrong arg", __FUNCTION__)
20186       *error = 1;
20187       return 0L;
20188     }
20189 }
20190 
20191 /** Returns the _dwg_object:: POLYLINE_3D vertices,
20192     the list of associated _dwg_object_VERTEX_3D:: points.
20193 */
20194 EXPORT dwg_point_3d *
dwg_object_polyline_3d_get_points(const dwg_object * restrict obj,int * restrict error)20195 dwg_object_polyline_3d_get_points (const dwg_object *restrict obj,
20196                                    int *restrict error)
20197 {
20198   *error = 0;
20199   if (obj && obj->type == DWG_TYPE_POLYLINE_3D)
20200     {
20201       BITCODE_BL i;
20202       Dwg_Data *dwg = obj->parent;
20203       Dwg_Entity_POLYLINE_3D *_obj = obj->tio.entity->tio.POLYLINE_3D;
20204       const BITCODE_BL num_points
20205           = dwg_object_polyline_3d_get_numpoints (obj, error);
20206       Dwg_Entity_VERTEX_3D *vertex = NULL;
20207       dwg_point_3d *ptx;
20208 
20209       if (!num_points || *error)
20210         return NULL;
20211       ptx = (dwg_point_3d *)calloc (num_points, sizeof (dwg_point_3d));
20212       if (!ptx)
20213         {
20214           LOG_ERROR ("%s: Out of memory", __FUNCTION__);
20215           *error = 1;
20216           return NULL;
20217         }
20218       vertex = NULL;
20219       if (dwg->header.version >= R_2004)
20220         for (i = 0; i < num_points; i++)
20221           {
20222             Dwg_Object *vobj = dwg_ref_object (dwg, _obj->vertex[i]);
20223             if (vobj && (vertex = dwg_object_to_VERTEX_3D (vobj)))
20224               {
20225                 ptx[i].x = vertex->point.x;
20226                 ptx[i].y = vertex->point.y;
20227                 ptx[i].z = vertex->point.z;
20228               }
20229             else
20230               {
20231                 *error = 1; // return not all vertices, but some
20232               }
20233           }
20234       else if (dwg->header.version
20235                >= R_13) // iterate over first_vertex - last_vertex
20236         {
20237           Dwg_Object *vobj = dwg_ref_object (dwg, _obj->first_vertex);
20238           Dwg_Object *vlast = dwg_ref_object (dwg, _obj->last_vertex);
20239           if (!vobj)
20240             *error = 1;
20241           else
20242             {
20243               i = 0;
20244               do
20245                 {
20246                   if ((vertex = dwg_object_to_VERTEX_3D (vobj)))
20247                     {
20248                       ptx[i].x = vertex->point.x;
20249                       ptx[i].y = vertex->point.y;
20250                       ptx[i].z = vertex->point.z;
20251                       i++;
20252                       if (i > num_points)
20253                         {
20254                           *error = 1;
20255                           break;
20256                         }
20257                     }
20258                   else
20259                     {
20260                       *error = 1; // return not all vertices, but some
20261                     }
20262                 }
20263               while ((vobj = dwg_next_object (vobj)) && vobj != vlast);
20264             }
20265         }
20266       else // <r13: iterate over vertices until seqend
20267         {
20268           Dwg_Object *vobj;
20269           i = 0;
20270           while ((vobj = dwg_next_object (obj))
20271                  && vobj->type != DWG_TYPE_SEQEND)
20272             {
20273               if ((vertex = dwg_object_to_VERTEX_3D (vobj)))
20274                 {
20275                   ptx[i].x = vertex->point.x;
20276                   ptx[i].y = vertex->point.y;
20277                   ptx[i].z = vertex->point.z;
20278                   i++;
20279                   if (i > num_points)
20280                     {
20281                       *error = 1;
20282                       break;
20283                     }
20284                 }
20285               else
20286                 {
20287                   *error = 1; // return not all vertices, but some
20288                 }
20289             }
20290         }
20291       return ptx;
20292     }
20293   else
20294     {
20295       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20296       *error = 1;
20297       return NULL;
20298     }
20299 }
20300 
20301 /** Returns lwpline bulges
20302  */
20303 EXPORT double *
dwg_ent_lwpline_get_bulges(const dwg_ent_lwpline * restrict lwpline,int * restrict error)20304 dwg_ent_lwpline_get_bulges (const dwg_ent_lwpline *restrict lwpline,
20305                             int *restrict error)
20306 {
20307   BITCODE_BD *ptx
20308       = (BITCODE_BD *)malloc (sizeof (BITCODE_BD) * lwpline->num_bulges);
20309   if (ptx)
20310     {
20311       BITCODE_BL i;
20312       *error = 0;
20313       for (i = 0; i < lwpline->num_bulges; i++)
20314         {
20315           ptx[i] = lwpline->bulges[i];
20316         }
20317       return ptx;
20318     }
20319   else
20320     {
20321       *error = 1;
20322       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
20323       return NULL;
20324     }
20325 }
20326 
20327 /** Returns lwpline point count
20328  */
20329 EXPORT BITCODE_BL
dwg_ent_lwpline_get_numpoints(const dwg_ent_lwpline * restrict lwpline,int * restrict error)20330 dwg_ent_lwpline_get_numpoints (const dwg_ent_lwpline *restrict lwpline,
20331                                int *restrict error)
20332 {
20333   if (lwpline)
20334     {
20335       *error = 0;
20336       return lwpline->num_points;
20337     }
20338   else
20339     {
20340       *error = 1;
20341       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20342       return 0L;
20343     }
20344 }
20345 
20346 /** Returns lwpline points
20347  */
20348 EXPORT dwg_point_2d *
dwg_ent_lwpline_get_points(const dwg_ent_lwpline * restrict lwpline,int * restrict error)20349 dwg_ent_lwpline_get_points (const dwg_ent_lwpline *restrict lwpline,
20350                             int *restrict error)
20351 {
20352   dwg_point_2d *ptx
20353       = (dwg_point_2d *)malloc (sizeof (dwg_point_2d) * lwpline->num_points);
20354   if (ptx)
20355     {
20356       BITCODE_BL i;
20357       *error = 0;
20358       for (i = 0; i < lwpline->num_points; i++)
20359         {
20360           ptx[i].x = lwpline->points[i].x;
20361           ptx[i].y = lwpline->points[i].y;
20362         }
20363       return ptx;
20364     }
20365   else
20366     {
20367       *error = 1;
20368       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
20369       return NULL;
20370     }
20371 }
20372 
20373 EXPORT int
dwg_ent_lwpline_set_points(dwg_ent_lwpline * restrict lwpline,const BITCODE_BL num_pts2d,const dwg_point_2d * restrict pts2d)20374 dwg_ent_lwpline_set_points (dwg_ent_lwpline *restrict lwpline,
20375                             const BITCODE_BL num_pts2d,
20376                             const dwg_point_2d *restrict pts2d)
20377 {
20378   lwpline->points = (BITCODE_2RD *)malloc (sizeof (dwg_point_2d) * num_pts2d);
20379   if (lwpline->points)
20380     {
20381       lwpline->num_points = num_pts2d;
20382       for (BITCODE_BL i = 0; i < num_pts2d; i++)
20383         {
20384           const dwg_point_2d pt = pts2d[i];
20385           if (bit_isnan(pt.x) || bit_isnan(pt.y))
20386             goto isnan;
20387           lwpline->points[i].x = pt.x;
20388           lwpline->points[i].y = pt.y;
20389         }
20390       return 0;
20391     }
20392   else
20393     {
20394       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
20395       return 1;
20396     }
20397  isnan:
20398   LOG_ERROR ("%s: Invalid vertex nan", __FUNCTION__);
20399   return 2;
20400 }
20401 
20402 /** Returns lwpline widths
20403  */
20404 EXPORT dwg_lwpline_widths *
dwg_ent_lwpline_get_widths(const dwg_ent_lwpline * restrict lwpline,int * restrict error)20405 dwg_ent_lwpline_get_widths (const dwg_ent_lwpline *restrict lwpline,
20406                             int *restrict error)
20407 {
20408   dwg_lwpline_widths *ptx = (dwg_lwpline_widths *)malloc (
20409       sizeof (dwg_lwpline_widths) * lwpline->num_widths);
20410   if (ptx)
20411     {
20412       BITCODE_BL i;
20413       *error = 0;
20414       for (i = 0; i < lwpline->num_widths; i++)
20415         {
20416           ptx[i].start = lwpline->widths[i].start;
20417           ptx[i].end = lwpline->widths[i].end;
20418         }
20419       return ptx;
20420     }
20421   else
20422     {
20423       *error = 1;
20424       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
20425       return NULL;
20426     }
20427 }
20428 
20429 /*******************************************************************
20430  *                    FUNCTIONS FOR TABLES                          *
20431  *        First the special tables: BLOCKS and LAYER                *
20432  ********************************************************************/
20433 
20434 /*******************************************************************
20435  *               FUNCTIONS FOR BLOCK_CONTROL OBJECT                  *
20436  ********************************************************************/
20437 
20438 /** Returns the block control object from the block header
20439 \code Usage: dwg_obj_block_control *blk =
20440 dwg_block_header_get_block_control(hdr, &error); \endcode \param[in]
20441 block_header \param[out] error  set to 0 for ok, >0 if not found.
20442 */
20443 dwg_obj_block_control *
dwg_block_header_get_block_control(const dwg_obj_block_header * block_header,int * restrict error)20444 dwg_block_header_get_block_control (const dwg_obj_block_header *block_header,
20445                                     int *restrict error)
20446 {
20447   if (block_header && block_header->parent && block_header->parent->ownerhandle
20448       && block_header->parent->ownerhandle->obj
20449       && block_header->parent->ownerhandle->obj->type == DWG_TYPE_BLOCK_CONTROL
20450       && block_header->parent->ownerhandle->obj->tio.object)
20451     {
20452       *error = 0;
20453       return block_header->parent->ownerhandle->obj->tio.object->tio
20454           .BLOCK_CONTROL;
20455     }
20456   else
20457     {
20458       *error = 1;
20459       LOG_ERROR ("%s: empty or invalid arg", __FUNCTION__)
20460       return NULL;
20461     }
20462 }
20463 
20464 /** Extracts and returns all block headers as references
20465 \param[in]  ctrl
20466 \param[out] error  set to 0 for ok, >0 if not found.
20467 */
20468 dwg_object_ref **
dwg_obj_block_control_get_block_headers(const dwg_obj_block_control * restrict ctrl,int * restrict error)20469 dwg_obj_block_control_get_block_headers (
20470     const dwg_obj_block_control *restrict ctrl, int *restrict error)
20471 {
20472   dwg_object_ref **ptx;
20473 
20474   if (!ctrl || (ctrl->num_entries && !ctrl->entries))
20475     {
20476       *error = 1;
20477       LOG_ERROR ("%s: null block_headers", __FUNCTION__);
20478       return NULL;
20479     }
20480 
20481   ptx = (dwg_object_ref **)malloc (ctrl->num_entries
20482                                    * sizeof (Dwg_Object_Ref *));
20483   if (ptx)
20484     {
20485       BITCODE_BS i;
20486       *error = 0;
20487       for (i = 0; i < ctrl->num_entries; i++)
20488         {
20489           ptx[i] = ctrl->entries[i];
20490         }
20491       return ptx;
20492     }
20493   else
20494     {
20495       *error = 1;
20496       LOG_ERROR ("%s: Out of memory", __FUNCTION__)
20497       return NULL;
20498     }
20499 }
20500 
20501 /** Returns number of blocks
20502 \param[in]  ctrl
20503 \param[out] error  set to 0 for ok, >0 if not found.
20504 */
20505 BITCODE_BL
dwg_obj_block_control_get_num_entries(const dwg_obj_block_control * restrict ctrl,int * restrict error)20506 dwg_obj_block_control_get_num_entries (
20507     const dwg_obj_block_control *restrict ctrl, int *restrict error)
20508 {
20509   if (ctrl)
20510     {
20511       *error = 0;
20512       return ctrl->num_entries;
20513     }
20514   else
20515     {
20516       *error = 1;
20517       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20518       return 0L;
20519     }
20520 }
20521 
20522 /** Returns reference to model space block
20523 \param[in]  ctrl
20524 \param[out] error  set to 0 for ok, >0 if not found.
20525 */
20526 dwg_object_ref *
dwg_obj_block_control_get_model_space(const dwg_obj_block_control * restrict ctrl,int * restrict error)20527 dwg_obj_block_control_get_model_space (
20528     const dwg_obj_block_control *restrict ctrl, int *restrict error)
20529 {
20530   if (ctrl)
20531     {
20532       *error = 0;
20533       return ctrl->model_space;
20534     }
20535   else
20536     {
20537       *error = 1;
20538       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20539       return NULL;
20540     }
20541 }
20542 
20543 /** Returns reference to paper space block
20544 \param[in]  ctrl
20545 \param[out] error  set to 0 for ok, >0 if not found.
20546 */
20547 dwg_object_ref *
dwg_obj_block_control_get_paper_space(const dwg_obj_block_control * restrict ctrl,int * restrict error)20548 dwg_obj_block_control_get_paper_space (
20549     const dwg_obj_block_control *restrict ctrl, int *restrict error)
20550 {
20551   if (ctrl)
20552     {
20553       *error = 0;
20554       return ctrl->paper_space;
20555     }
20556   else
20557     {
20558       *error = 1;
20559       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20560       return NULL;
20561     }
20562 }
20563 
20564 /*******************************************************************
20565  *                FUNCTIONS FOR BLOCK_HEADER OBJECT                  *
20566  ********************************************************************/
20567 
20568 /** Get name of the block header (utf-8 encoded)
20569 \code Usage: char* block_name = dwg_obj_block_header_get_name(hdr, &error);
20570 \endcode
20571 \param[in]  hdr
20572 \param[out] error  set to 0 for ok, >0 if not found.
20573 */
20574 char *
dwg_obj_block_header_get_name(const dwg_obj_block_header * restrict hdr,int * restrict error)20575 dwg_obj_block_header_get_name (const dwg_obj_block_header *restrict hdr,
20576                                int *restrict error)
20577 {
20578   if (hdr)
20579     {
20580       *error = 0;
20581       if (dwg_version >= R_2007)
20582         return bit_convert_TU ((BITCODE_TU)hdr->name);
20583       else
20584         return hdr->name;
20585     }
20586   else
20587     {
20588       *error = 1;
20589       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20590       return NULL;
20591     }
20592 }
20593 
20594 /** Returns 1st block header present in the dwg file.
20595     Usually the model space block.
20596 \code Usage: dwg_obj_block_header = dwg_get_block_header(dwg, &error);
20597 \endcode
20598 \param[in]  dwg
20599 \param[out] error  set to 0 for ok, >0 if not found.
20600 */
20601 dwg_obj_block_header *
dwg_get_block_header(dwg_data * restrict dwg,int * restrict error)20602 dwg_get_block_header (dwg_data *restrict dwg, int *restrict error)
20603 {
20604   Dwg_Object *obj;
20605   Dwg_Object_BLOCK_HEADER *blk;
20606 
20607   *error = 0;
20608   if (!dwg || dwg->num_classes > 1000 || dwg->num_objects > 0xfffffff)
20609     {
20610       *error = 1;
20611       return NULL;
20612     }
20613   if (dwg_version == R_INVALID)
20614     dwg_version = (Dwg_Version_Type)dwg->header.version;
20615 
20616   obj = &dwg->object[0];
20617   while (obj && obj->type != DWG_TYPE_BLOCK_HEADER)
20618     {
20619       if (obj->size > 0xffff)
20620         {
20621           *error = 2;
20622           return NULL;
20623         }
20624       obj = dwg_next_object (obj);
20625     }
20626   if (obj && DWG_TYPE_BLOCK_HEADER == obj->type)
20627     {
20628       if (obj->size > 0xffff)
20629         {
20630           *error = 2;
20631           return NULL;
20632         }
20633       blk = obj->tio.object->tio.BLOCK_HEADER;
20634       if (blk->name && strEQc (blk->name, "*Paper_Space"))
20635         dwg->pspace_block = obj;
20636       else if (blk->name && strEQc (blk->name, "*Model_Space"))
20637         dwg->mspace_block = obj;
20638       return blk;
20639     }
20640   else
20641     {
20642       *error = 3;
20643       LOG_ERROR ("%s: BLOCK_HEADER not found", __FUNCTION__)
20644       return NULL;
20645     }
20646 }
20647 
20648 /*******************************************************************
20649  *                    FUNCTIONS FOR LAYER OBJECT                     *
20650  ********************************************************************/
20651 
20652 /** Get name of the layer (utf-8 encoded)
20653 \code Usage: char* layer_name = dwg_obj_layer_get_name(layer, &error);
20654 \endcode
20655 \param[in]  layer
20656 \param[out] error  set to 0 for ok, >0 if not found.
20657 */
20658 char *
dwg_obj_layer_get_name(const dwg_obj_layer * restrict layer,int * restrict error)20659 dwg_obj_layer_get_name (const dwg_obj_layer *restrict layer,
20660                         int *restrict error)
20661 {
20662   if (layer)
20663     {
20664       const Dwg_Object *obj = dwg_obj_generic_to_object (layer, error);
20665       if (*error || obj->fixedtype != DWG_TYPE_LAYER)
20666         {
20667           *error = 1;
20668           LOG_ERROR ("%s: arg not a LAYER", __FUNCTION__)
20669           return NULL;
20670         }
20671       *error = 0;
20672       if (dwg_version >= R_2007)
20673         return bit_convert_TU ((BITCODE_TU)layer->name);
20674       else
20675         return layer->name;
20676     }
20677   else
20678     {
20679       *error = 1;
20680       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20681       return NULL;
20682     }
20683 }
20684 
20685 /** Change name of the layer (utf-8 encoded).
20686     The result is freshly allocated from the input, so it can be safely
20687     free'd/deleted.
20688 \code Usage: error = dwg_obj_layer_set_name(layer, name);
20689 \endcode
20690 \param[in]  layer
20691 \param[in]  name, utf-8 encoded
20692 \param[out] error  set to 0 for ok, >0 if not found.
20693 */
20694 void
dwg_obj_layer_set_name(dwg_obj_layer * restrict layer,const char * restrict name,int * restrict error)20695 dwg_obj_layer_set_name (dwg_obj_layer *restrict layer,
20696                         const char *restrict name, int *restrict error)
20697 {
20698   if (layer)
20699     {
20700       const Dwg_Object *obj = dwg_obj_generic_to_object (layer, error);
20701       if (*error || obj->fixedtype != DWG_TYPE_LAYER)
20702         {
20703           LOG_ERROR ("%s: arg not a LAYER", __FUNCTION__)
20704           *error = 1;
20705           return;
20706         }
20707       *error = 0;
20708       if (dwg_version >= R_2007)
20709         layer->name = bit_convert_TU ((BITCODE_TU)layer->name);
20710       else
20711         layer->name = strdup (name);
20712       return;
20713     }
20714   else
20715     {
20716       LOG_ERROR ("%s: empty arg", __FUNCTION__)
20717       *error = 1;
20718       return;
20719     }
20720 }
20721 
20722 /*******************************************************************
20723  *           GENERIC FUNCTIONS FOR OTHER TABLE OBJECTS              *
20724  ********************************************************************/
20725 
20726 /** Get number of table entries from the generic table control object.
20727 \code Usage: char* name = dwg_object_tablectrl_get_num_entries(obj, &error);
20728 \endcode
20729 \param[in]  obj    a TABLE_CONTROL dwg_object*
20730 \param[out] error  set to 0 for ok, >0 if not found.
20731 */
20732 BITCODE_BL
dwg_object_tablectrl_get_num_entries(const dwg_object * restrict obj,int * restrict error)20733 dwg_object_tablectrl_get_num_entries (const dwg_object *restrict obj,
20734                                       int *restrict error)
20735 {
20736   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20737       && dwg_obj_is_control (obj))
20738     {
20739       // HACK: we can guarantee that num_entries is always the first field.
20740       Dwg_Object_STYLE_CONTROL *ctrl = obj->tio.object->tio.STYLE_CONTROL;
20741       *error = 0;
20742       return ctrl->num_entries;
20743     }
20744   else
20745     {
20746       *error = 1;
20747       LOG_ERROR ("%s: empty or invalid table control arg %p, type: 0x%x",
20748                  __FUNCTION__, obj, obj ? obj->type : 0)
20749       return 0;
20750     }
20751 }
20752 
20753 /** Get all table entries from the generic table control object.
20754 \code Usage: dwg_object_ref **refs = dwg_object_tablectrl_get_entries(obj,
20755 &error); \endcode \param[in]  obj    a TABLE_CONTROL dwg_object* \param[out]
20756 error  set to 0 for ok, >0 if not found.
20757 */
20758 dwg_object_ref **
dwg_object_tablectrl_get_entries(const dwg_object * restrict obj,int * restrict error)20759 dwg_object_tablectrl_get_entries (const dwg_object *restrict obj,
20760                                   int *restrict error)
20761 {
20762   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20763       && dwg_obj_is_control (obj))
20764     {
20765       // HACK: we can guarantee a common layout of the common fields
20766       Dwg_Object_STYLE_CONTROL *ctrl = obj->tio.object->tio.STYLE_CONTROL;
20767       return ctrl->entries;
20768     }
20769   else
20770     {
20771       *error = 1;
20772       LOG_ERROR ("%s: empty or invalid table control arg %p, type: 0x%x",
20773                  __FUNCTION__, obj, obj ? obj->type : 0)
20774       return NULL;
20775     }
20776 }
20777 
20778 /** Get the nth table entry from the generic table control object.
20779 \code Usage: dwg_object_ref *ref = dwg_object_tablectrl_get_entry(obj, 0,
20780 &error); \endcode \param[in]  obj    a TABLE_CONTROL dwg_object* \param[in] idx
20781 BITCODE_BS \param[out] error  set to 0 for ok, >0 if not found.
20782 */
20783 dwg_object_ref *
dwg_object_tablectrl_get_entry(const dwg_object * restrict obj,const BITCODE_BS idx,int * restrict error)20784 dwg_object_tablectrl_get_entry (const dwg_object *restrict obj,
20785                                 const BITCODE_BS idx, int *restrict error)
20786 {
20787   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20788       && dwg_obj_is_control (obj))
20789     {
20790       // HACK: we can guarantee a common layout of the common fields
20791       Dwg_Object_STYLE_CONTROL *ctrl = obj->tio.object->tio.STYLE_CONTROL;
20792       const BITCODE_BS count = ctrl->num_entries;
20793       if (idx < count)
20794         {
20795           *error = 0;
20796           return ctrl->entries[idx];
20797         }
20798       else
20799         {
20800           *error = 2;
20801           LOG_ERROR ("%s: idx %d out of bounds %d", __FUNCTION__, idx, count);
20802           return NULL;
20803         }
20804     }
20805   else
20806     {
20807       *error = 1;
20808       LOG_ERROR ("%s: empty or invalid table control arg %p, type: 0x%x",
20809                  __FUNCTION__, obj, obj ? obj->type : 0)
20810       return NULL;
20811     }
20812 }
20813 
20814 /** Get the null_handle from the generic table control object.
20815 \code Usage: dwg_object_ref *ref = dwg_object_tablectrl_get_null_handle(obj,
20816 &error); \endcode \param[in]  obj    a TABLE_CONTROL dwg_object* \param[out]
20817 error  set to 0 for ok, >0 if not found.
20818 */
20819 dwg_object_ref *
dwg_object_tablectrl_get_ownerhandle(const dwg_object * restrict obj,int * restrict error)20820 dwg_object_tablectrl_get_ownerhandle (const dwg_object *restrict obj,
20821                                       int *restrict error)
20822 {
20823   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20824       && dwg_obj_is_control (obj))
20825     {
20826       return obj->tio.object->ownerhandle;
20827     }
20828   else
20829     {
20830       *error = 1;
20831       LOG_ERROR ("%s: empty or invalid table control arg %p, type: 0x%x",
20832                  __FUNCTION__, obj, obj ? obj->type : 0)
20833       return NULL;
20834     }
20835 }
20836 
20837 /** Get the xdicobjhandle from the generic table control object.
20838 \code Usage: dwg_object_ref *ref = dwg_object_tablectrl_get_xdicobjhandle(obj,
20839 &error); \endcode \param[in]  obj    a TABLE_CONTROL dwg_object* \param[out]
20840 error  set to 0 for ok, >0 if not found.
20841 */
20842 dwg_object_ref *
dwg_object_tablectrl_get_xdicobjhandle(const dwg_object * restrict obj,int * restrict error)20843 dwg_object_tablectrl_get_xdicobjhandle (const dwg_object *restrict obj,
20844                                         int *restrict error)
20845 {
20846   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20847       && dwg_obj_is_control (obj))
20848     {
20849       return obj->tio.object->xdicobjhandle;
20850     }
20851   else
20852     {
20853       *error = 1;
20854       LOG_ERROR ("%s: empty or invalid table control arg %p, type: 0x%x",
20855                  __FUNCTION__, obj, obj ? obj->type : 0)
20856       return NULL;
20857     }
20858 }
20859 
20860 /** Get the objid from the generic table control object.
20861 \code Usage: objid = dwg_object_tablectrl_get_objid(obj, &error);
20862 \endcode
20863 \param[in]  obj    a TABLE_CONTROL dwg_object*
20864 \param[out] error  set to 0 for ok, >0 if not found.
20865 */
20866 BITCODE_BL
dwg_object_tablectrl_get_objid(const dwg_object * restrict obj,int * restrict error)20867 dwg_object_tablectrl_get_objid (const dwg_object *restrict obj,
20868                                 int *restrict error)
20869 {
20870   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20871       && dwg_obj_is_control (obj))
20872     {
20873       return obj->tio.object->objid;
20874     }
20875   else
20876     {
20877       *error = 1;
20878       LOG_ERROR ("%s: empty or invalid table control arg %p, type: 0x%x",
20879                  __FUNCTION__, obj, obj ? obj->type : 0)
20880       return 0;
20881     }
20882 }
20883 
20884 /** Returns name of the referenced table entry (as UTF-8). Defaults to ByLayer
20885     Since r2007 it returns a malloc'd copy, before the direct reference to the
20886     dwg field or the constant "ByLayer".
20887 \code Usage: char* name = dwg_ref_get_table_name(ref, &error);
20888 \endcode
20889 \param[in]  ref     dwg_obj_ref*   A handle
20890 \param[out] error   int*, is set to 0 for ok, 1 on error
20891 */
20892 char *
dwg_ref_get_table_name(const dwg_object_ref * restrict ref,int * restrict error)20893 dwg_ref_get_table_name (const dwg_object_ref *restrict ref,
20894                         int *restrict error)
20895 {
20896   char *name = NULL;
20897   if (ref && ref->obj)
20898     name = dwg_obj_table_get_name (ref->obj, error);
20899   if (!name)
20900     name = (char *)"ByLayer";
20901   return name;
20902 }
20903 
20904 // TODO: the same for the dwg_tbl_generic obj
20905 
20906 /** Get name of the table object entry (utf-8 encoded)
20907     Since r2007 it returns a malloc'd copy, before the direct reference to the
20908     dwg field.
20909     Should not be used for a BLOCK, rather use dwg_handle_name() then.
20910 \code Usage: char* name = dwg_obj_table_get_name(obj, &error);
20911 \endcode
20912 \param[in]  obj    a TABLE dwg_object*
20913 \param[out] error  set to 0 for ok, >0 if not found.
20914 */
20915 char *
dwg_obj_table_get_name(const dwg_object * restrict obj,int * restrict error)20916 dwg_obj_table_get_name (const dwg_object *restrict obj, int *restrict error)
20917 {
20918   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT
20919       && (dwg_obj_is_table (obj) /* || obj->type == DWG_TYPE_DICTIONARY */))
20920     {
20921       // HACK: we can guarantee that the table name is always the first field,
20922       // by using COMMON_TABLE_FLAGS.
20923       // TODO: Dictionary also?
20924       const Dwg_Data *dwg = obj->parent;
20925       Dwg_Object_STYLE *table = obj->tio.object->tio.STYLE;
20926       *error = 0;
20927       // importers are still a hack and don't store TU
20928       if (IS_FROM_TU_DWG (dwg))
20929         return bit_convert_TU ((BITCODE_TU)table->name); // creates a copy
20930       else
20931         return table->name;
20932     }
20933   else
20934     {
20935       *error = 1;
20936       LOG_ERROR ("%s: empty or invalid table arg %p, type: 0x%x", __FUNCTION__,
20937                  obj, obj ? obj->type : 0)
20938       return NULL;
20939     }
20940 }
20941 
20942 /*******************************************************************
20943  *                    FUNCTIONS FOR GENERIC ENTITY                  *
20944  ********************************************************************/
20945 
20946 /** Returns the entity layer name (as UTF-8), or "0"
20947     Since r2007 it returns a malloc'd copy, before the direct reference
20948     to the dwg field or the constant "0".
20949 \code Usage: char* layer = dwg_ent_get_layer_name(ent, &error);
20950 \endcode
20951 \param[in]  ent     dwg_obj_ent*
20952 \param[out] error   int*, is set to 0 for ok, 1 on error
20953 */
20954 char *
dwg_ent_get_layer_name(const dwg_obj_ent * restrict ent,int * restrict error)20955 dwg_ent_get_layer_name (const dwg_obj_ent *restrict ent, int *restrict error)
20956 {
20957   char *name = NULL;
20958   Dwg_Object *layer = ent->layer ? ent->layer->obj : NULL;
20959 
20960   if (layer)
20961     name = dwg_obj_table_get_name (layer, error);
20962   if (!name)
20963     name = (char *)"0";
20964   return name;
20965 }
20966 
20967 /** Returns the entity linetype name (as UTF-8), or "ByLayer"
20968     Since r2007 it returns a malloc'd copy, before the direct reference
20969     to the dwg field or the constant "ByLayer".
20970 \code Usage: char* ltype = dwg_ent_get_ltype_name(ent, &error);
20971 \endcode
20972 \param[in]  ent     dwg_obj_ent*
20973 \param[out] error   int*, is set to 0 for ok, 1 on error
20974 */
20975 char *
dwg_ent_get_ltype_name(const dwg_obj_ent * restrict ent,int * restrict error)20976 dwg_ent_get_ltype_name (const dwg_obj_ent *restrict ent, int *restrict error)
20977 {
20978   char *name = NULL;
20979   Dwg_Object *ltype = ent->ltype ? ent->ltype->obj : NULL;
20980 
20981   if (ltype)
20982     name = dwg_obj_table_get_name (ltype, error);
20983   if (!name)
20984     name = (char *)"ByLayer";
20985   return name;
20986 }
20987 
20988 #ifndef __AFL_COMPILER
20989 
20990 /** Returns the entity bitsize
20991 \code Usage: bitsize = dwg_ent_get_bitsize(ent, &error);
20992 \endcode
20993 \param[in]  ent     dwg_obj_ent*
20994 \param[out] error   int*, is set to 0 for ok, 1 on error
20995 */
20996 BITCODE_RL
dwg_ent_get_bitsize(const dwg_obj_ent * restrict ent,int * restrict error)20997 dwg_ent_get_bitsize (const dwg_obj_ent *restrict ent, int *restrict error)
20998 {
20999   Dwg_Object *obj = dwg_ent_to_object (ent, error);
21000   if (obj && !*error)
21001     {
21002       return obj->bitsize;
21003     }
21004   else
21005     {
21006       return 0;
21007     }
21008 }
21009 
21010 /** Returns the number of entity EED structures
21011 See dwg_object_to_entity how to get the ent.
21012 \code Usage: int num_eed = dwg_ent_get_num_eed(ent,&error);
21013 \endcode
21014 \param[in]  ent     dwg_obj_ent*
21015 \param[out] error   int*, is set to 0 for ok, 1 on error
21016 */
21017 BITCODE_BL
dwg_ent_get_num_eed(const dwg_obj_ent * restrict ent,int * restrict error)21018 dwg_ent_get_num_eed (const dwg_obj_ent *restrict ent, int *restrict error)
21019 {
21020   if (!ent)
21021     {
21022       *error = 1;
21023       return 0;
21024     }
21025   *error = 0;
21026   return ent->num_eed;
21027 }
21028 /** Returns the nth EED structure.
21029 \code Usage: dwg_entity_eed *eed = dwg_ent_get_eed(ent,0,&error);
21030 \endcode
21031 \param[in]  ent    dwg_obj_ent*
21032 \param[in]  idx  [0 - num_eed-1]
21033 \param[out] error  set to 0 for ok, 1 if ent == NULL or 2 if idx out of bounds.
21034 */
21035 dwg_entity_eed *
dwg_ent_get_eed(const dwg_obj_ent * restrict ent,const BITCODE_BL idx,int * restrict error)21036 dwg_ent_get_eed (const dwg_obj_ent *restrict ent, const BITCODE_BL idx,
21037                  int *restrict error)
21038 {
21039   if (!ent)
21040     {
21041       *error = 1;
21042       LOG_ERROR ("%s: empty or invalid ent", __FUNCTION__)
21043       return NULL;
21044     }
21045   else if (idx >= ent->num_eed)
21046     {
21047       *error = 2;
21048       return NULL;
21049     }
21050   else
21051     {
21052       *error = 0;
21053       return &ent->eed[idx];
21054     }
21055 }
21056 
21057 /** Returns the data union of the nth EED structure.
21058 \code Usage: dwg_entity_eed_data *eed = dwg_ent_get_eed_data(ent,0,&error);
21059 \endcode
21060 \param[in]  ent    dwg_obj_ent*
21061 \param[in]  idx  [0 - num_eed-1]
21062 \param[out] error  set to 0 for ok, 1 if ent == NULL or 2 if idx out of bounds.
21063 */
21064 dwg_entity_eed_data *
dwg_ent_get_eed_data(const dwg_obj_ent * restrict ent,const BITCODE_BL idx,int * restrict error)21065 dwg_ent_get_eed_data (const dwg_obj_ent *restrict ent, const BITCODE_BL idx,
21066                       int *restrict error)
21067 {
21068   if (!ent)
21069     {
21070       *error = 1;
21071       LOG_ERROR ("%s: empty or invalid ent", __FUNCTION__)
21072       return NULL;
21073     }
21074   else if (idx >= ent->num_eed)
21075     {
21076       *error = 2;
21077       return NULL;
21078     }
21079   else
21080     {
21081       *error = 0;
21082       return ent->eed[idx].data;
21083     }
21084 }
21085 
21086 #endif /* __AFL_COMPILER */
21087 
21088 #define _BODY_FIELD(ent, field)                                               \
21089   if (!ent)                                                                   \
21090     {                                                                         \
21091       *error = 1;                                                             \
21092       return 0;                                                               \
21093     }                                                                         \
21094   *error = 0;                                                                 \
21095   return ent->field
21096 
21097 #ifndef __AFL_COMPILER
21098 
21099 EXPORT const Dwg_Color *
dwg_ent_get_color(const dwg_obj_ent * restrict ent,int * restrict error)21100 dwg_ent_get_color (const dwg_obj_ent *restrict ent, int *restrict error)
21101 {
21102   if (!ent)
21103     {
21104       *error = 1;
21105       return NULL;
21106     }
21107   *error = 0;
21108   return &(ent->color);
21109 }
21110 
21111 EXPORT BITCODE_B
dwg_ent_get_picture_exists(const dwg_obj_ent * restrict ent,int * restrict error)21112 dwg_ent_get_picture_exists (const dwg_obj_ent *restrict ent,
21113                             int *restrict error)
21114 {
21115   _BODY_FIELD (ent, preview_exists);
21116 }
21117 
21118 EXPORT BITCODE_BLL
dwg_ent_get_picture_size(const dwg_obj_ent * restrict ent,int * restrict error)21119 dwg_ent_get_picture_size (const dwg_obj_ent *restrict ent,
21120                           int *restrict error) // before r2007 only RL
21121 {
21122   _BODY_FIELD (ent, preview_size);
21123 }
21124 
21125 EXPORT BITCODE_TF
dwg_ent_get_picture(const dwg_obj_ent * restrict ent,int * restrict error)21126 dwg_ent_get_picture (const dwg_obj_ent *restrict ent, int *restrict error)
21127 {
21128   _BODY_FIELD (ent, preview);
21129 }
21130 
21131 EXPORT BITCODE_BB
dwg_ent_get_entmode(const dwg_obj_ent * restrict ent,int * restrict error)21132 dwg_ent_get_entmode (const dwg_obj_ent *restrict ent, int *restrict error)
21133 {
21134   _BODY_FIELD (ent, entmode);
21135 }
21136 
21137 EXPORT BITCODE_BL
dwg_ent_get_num_reactors(const dwg_obj_ent * restrict ent,int * restrict error)21138 dwg_ent_get_num_reactors (const dwg_obj_ent *restrict ent, int *restrict error)
21139 {
21140   _BODY_FIELD (ent, num_reactors);
21141 }
21142 
21143 EXPORT BITCODE_B
dwg_ent_get_is_xdic_missing(const dwg_obj_ent * restrict ent,int * restrict error)21144 dwg_ent_get_is_xdic_missing (const dwg_obj_ent *restrict ent,
21145                                int *restrict error) // r2004+
21146 {
21147   _BODY_FIELD (ent, is_xdic_missing);
21148 }
21149 
21150 EXPORT BITCODE_B
dwg_ent_get_isbylayerlt(const dwg_obj_ent * restrict ent,int * restrict error)21151 dwg_ent_get_isbylayerlt (const dwg_obj_ent *restrict ent,
21152                          int *restrict error) // r13-r14 only
21153 {
21154   _BODY_FIELD (ent, isbylayerlt);
21155 }
21156 
21157 EXPORT BITCODE_B
dwg_ent_get_nolinks(const dwg_obj_ent * restrict ent,int * restrict error)21158 dwg_ent_get_nolinks (const dwg_obj_ent *restrict ent, int *restrict error)
21159 {
21160   _BODY_FIELD (ent, nolinks);
21161 }
21162 
21163 EXPORT double
dwg_ent_get_linetype_scale(const dwg_obj_ent * restrict ent,int * restrict error)21164 dwg_ent_get_linetype_scale (const dwg_obj_ent *restrict ent,
21165                             int *restrict error)
21166 {
21167   _BODY_FIELD (ent, ltype_scale);
21168 }
21169 
21170 EXPORT BITCODE_BB
dwg_ent_get_linetype_flags(const dwg_obj_ent * restrict ent,int * restrict error)21171 dwg_ent_get_linetype_flags (const dwg_obj_ent *restrict ent,
21172                             int *restrict error) // r2000+
21173 {
21174   _BODY_FIELD (ent, ltype_flags);
21175 }
21176 
21177 EXPORT BITCODE_BB
dwg_ent_get_plotstyle_flags(const dwg_obj_ent * restrict ent,int * restrict error)21178 dwg_ent_get_plotstyle_flags (const dwg_obj_ent *restrict ent,
21179                              int *restrict error) // r2000+
21180 {
21181   _BODY_FIELD (ent, plotstyle_flags);
21182 }
21183 
21184 EXPORT BITCODE_BB
dwg_ent_get_material_flags(const dwg_obj_ent * restrict ent,int * restrict error)21185 dwg_ent_get_material_flags (const dwg_obj_ent *restrict ent,
21186                             int *restrict error) // r2007+
21187 {
21188   _BODY_FIELD (ent, material_flags);
21189 }
21190 
21191 EXPORT BITCODE_RC
dwg_ent_get_shadow_flags(const dwg_obj_ent * restrict ent,int * restrict error)21192 dwg_ent_get_shadow_flags (const dwg_obj_ent *restrict ent,
21193                           int *restrict error) // r2007+
21194 {
21195   _BODY_FIELD (ent, shadow_flags);
21196 }
21197 
21198 EXPORT BITCODE_B
dwg_ent_has_full_visualstyle(dwg_obj_ent * restrict ent,int * restrict error)21199 dwg_ent_has_full_visualstyle (dwg_obj_ent *restrict ent,
21200                               int *restrict error) // r2010+
21201 {
21202   _BODY_FIELD (ent, has_full_visualstyle);
21203 }
21204 
21205 EXPORT BITCODE_B
dwg_ent_has_face_visualstyle(dwg_obj_ent * restrict ent,int * restrict error)21206 dwg_ent_has_face_visualstyle (dwg_obj_ent *restrict ent,
21207                               int *restrict error) // r2010+
21208 {
21209   _BODY_FIELD (ent, has_face_visualstyle);
21210 }
21211 
21212 EXPORT BITCODE_B
dwg_ent_has_edge_visualstyle(dwg_obj_ent * restrict ent,int * restrict error)21213 dwg_ent_has_edge_visualstyle (dwg_obj_ent *restrict ent,
21214                               int *restrict error) // r2010+
21215 {
21216   _BODY_FIELD (ent, has_edge_visualstyle);
21217 }
21218 
21219 EXPORT BITCODE_BS
dwg_ent_get_invisible(const dwg_obj_ent * restrict ent,int * restrict error)21220 dwg_ent_get_invisible (const dwg_obj_ent *restrict ent, int *restrict error)
21221 {
21222   _BODY_FIELD (ent, invisible);
21223 }
21224 
21225 EXPORT BITCODE_RC
dwg_ent_get_linewt(const dwg_obj_ent * restrict ent,int * restrict error)21226 dwg_ent_get_linewt (const dwg_obj_ent *restrict ent,
21227                     int *restrict error) // r2000+
21228 {
21229   _BODY_FIELD (ent, linewt);
21230 }
21231 
21232 // TODO: dwg_object_ref* or dwg_handle*, not handle
21233 EXPORT dwg_object_ref *
dwg_ent_get_ownerhandle(const dwg_obj_ent * restrict ent,int * restrict error)21234 dwg_ent_get_ownerhandle (const dwg_obj_ent *restrict ent, int *restrict error)
21235 {
21236   _BODY_FIELD (ent, ownerhandle);
21237 }
21238 
21239 EXPORT dwg_object_ref **
dwg_ent_get_reactors(const dwg_obj_ent * restrict ent,int * restrict error)21240 dwg_ent_get_reactors (const dwg_obj_ent *restrict ent, int *restrict error)
21241 {
21242   _BODY_FIELD (ent, reactors);
21243 }
21244 
21245 EXPORT dwg_object_ref *
dwg_ent_get_xdicobjhandle(const dwg_obj_ent * restrict ent,int * restrict error)21246 dwg_ent_get_xdicobjhandle (const dwg_obj_ent *restrict ent,
21247                            int *restrict error)
21248 {
21249   _BODY_FIELD (ent, xdicobjhandle);
21250 }
21251 
21252 EXPORT dwg_object_ref *
dwg_ent_get_prev_entity(const dwg_obj_ent * restrict ent,int * restrict error)21253 dwg_ent_get_prev_entity (const dwg_obj_ent *restrict ent,
21254                          int *restrict error) // r13-r2000
21255 {
21256   _BODY_FIELD (ent, prev_entity);
21257 }
21258 
21259 EXPORT dwg_object_ref *
dwg_ent_get_next_entity(const dwg_obj_ent * restrict ent,int * restrict error)21260 dwg_ent_get_next_entity (const dwg_obj_ent *restrict ent,
21261                          int *restrict error) // r13-r2000
21262 {
21263   _BODY_FIELD (ent, next_entity);
21264 }
21265 
21266 EXPORT dwg_object_ref *
dwg_ent_get_layer(const dwg_obj_ent * restrict ent,int * restrict error)21267 dwg_ent_get_layer (const dwg_obj_ent *restrict ent, int *restrict error)
21268 {
21269   _BODY_FIELD (ent, layer);
21270 }
21271 
21272 EXPORT dwg_object_ref *
dwg_ent_get_ltype(const dwg_obj_ent * restrict ent,int * restrict error)21273 dwg_ent_get_ltype (const dwg_obj_ent *restrict ent, int *restrict error)
21274 {
21275   _BODY_FIELD (ent, ltype);
21276 }
21277 
21278 EXPORT dwg_object_ref *
dwg_ent_get_material(const dwg_obj_ent * restrict ent,int * restrict error)21279 dwg_ent_get_material (const dwg_obj_ent *restrict ent,
21280                       int *restrict error) // r2007+
21281 {
21282   _BODY_FIELD (ent, material);
21283 }
21284 
21285 EXPORT dwg_object_ref *
dwg_ent_get_plotstyle(const dwg_obj_ent * restrict ent,int * restrict error)21286 dwg_ent_get_plotstyle (const dwg_obj_ent *restrict ent,
21287                        int *restrict error) // r2000+
21288 {
21289   _BODY_FIELD (ent, plotstyle);
21290 }
21291 
21292 EXPORT dwg_object_ref *
dwg_ent_get_full_visualstyle(const dwg_obj_ent * restrict ent,int * restrict error)21293 dwg_ent_get_full_visualstyle (const dwg_obj_ent *restrict ent,
21294                               int *restrict error) // r2010+
21295 {
21296   _BODY_FIELD (ent, full_visualstyle);
21297 }
21298 
21299 EXPORT dwg_object_ref *
dwg_ent_get_face_visualstyle(const dwg_obj_ent * restrict ent,int * restrict error)21300 dwg_ent_get_face_visualstyle (const dwg_obj_ent *restrict ent,
21301                               int *restrict error) // r2010+
21302 {
21303   _BODY_FIELD (ent, face_visualstyle);
21304 }
21305 
21306 EXPORT dwg_object_ref *
dwg_ent_get_edge_visualstyle(const dwg_obj_ent * restrict ent,int * restrict error)21307 dwg_ent_get_edge_visualstyle (const dwg_obj_ent *restrict ent,
21308                               int *restrict error) // r2010+
21309 {
21310   _BODY_FIELD (ent, edge_visualstyle);
21311 }
21312 
21313 #endif /* __AFL_COMPILER */
21314 
21315 /** Returns dwg_object* from dwg_obj_ent*
21316 \code Usage: dwg_object* obj = dwg_obj_ent_to_object(ent, &error);
21317 \endcode
21318 \param[in]  obj     dwg_obj_ent*
21319 \param[out] error   int*, is set to 0 for ok, 1 on error
21320 */
21321 dwg_object *
dwg_ent_to_object(const dwg_obj_ent * restrict obj,int * restrict error)21322 dwg_ent_to_object (const dwg_obj_ent *restrict obj, int *restrict error)
21323 {
21324   dwg_data *dwg;
21325   dwg_object *retval;
21326   if (!obj)
21327     {
21328       *error = 1;
21329       LOG_ERROR ("%s: Empty or invalid obj", __FUNCTION__);
21330       return NULL;
21331     }
21332   dwg = obj->dwg;
21333   if (dwg_version == R_INVALID)
21334     dwg_version = (Dwg_Version_Type)dwg->header.version;
21335   if (obj->objid >= dwg->num_objects)
21336     {
21337       *error = 1;
21338       return NULL;
21339     }
21340   retval = &dwg->object[obj->objid];
21341   if (retval->supertype == DWG_SUPERTYPE_ENTITY)
21342     {
21343       *error = 0;
21344       return retval;
21345     }
21346   else
21347     {
21348       *error = 1;
21349       return NULL;
21350     }
21351 }
21352 
21353 /** Returns dwg_object* from any dwg_ent_*, the parent of the parent.
21354 \code Usage: dwg_object* obj = dwg_ent_generic_to_object(_obj, &error);
21355 \endcode
21356 \param[in]  obj     dwg_ent_generic* (line, circle, ...)
21357 \param[out] error   int*, is set to 0 for ok, 1 on error
21358 */
21359 dwg_object *
dwg_ent_generic_to_object(const void * restrict _obj,int * restrict error)21360 dwg_ent_generic_to_object (const void *restrict _obj,
21361                            int *restrict error)
21362 {
21363   return dwg_obj_generic_to_object (_obj, error);
21364 }
21365 
21366 Dwg_Data *
dwg_obj_generic_dwg(const void * restrict _obj,int * restrict error)21367 dwg_obj_generic_dwg (const void *restrict _obj,
21368                         int *restrict error)
21369 {
21370   dwg_obj_generic *o = (dwg_obj_generic *)_obj;
21371   return (o && o->parent && o->parent->dwg)
21372     ? o->parent->dwg : NULL;
21373 }
21374 
21375 /** Returns dwg_obj_ent* from any dwg_ent_* entity
21376 \code Usage: dwg_obj_ent* ent = dwg_ent_generic_parent(_ent, &error);
21377 \endcode
21378 \param[in]  ent     dwg_ent_generic* (line, circle, ...)
21379 \param[out] error   int*, is set to 0 for ok, 1 on error
21380 */
21381 dwg_obj_ent *
dwg_ent_generic_parent(const void * restrict ent,int * restrict error)21382 dwg_ent_generic_parent (const void *restrict ent,
21383                         int *restrict error)
21384 {
21385   const dwg_ent_generic *xent = (const dwg_ent_generic *)ent;
21386   if (xent && xent->parent)
21387     {
21388       dwg_obj_ent *retval = xent->parent;
21389       *error = 0;
21390       return retval;
21391     }
21392   else
21393     {
21394       *error = 1;
21395       LOG_ERROR ("%s: Empty or invalid obj", __FUNCTION__)
21396       return NULL;
21397     }
21398 }
21399 
21400 /** Returns dwg_obj_ent* from dwg object
21401 \code Usage : dwg_obj_ent* ent = dwg_object_to_entity(obj, &error);
21402 \endcode
21403 \param obj   dwg_object*
21404 \param error
21405 */
21406 dwg_obj_ent *
dwg_object_to_entity(dwg_object * restrict obj,int * restrict error)21407 dwg_object_to_entity (dwg_object *restrict obj, int *restrict error)
21408 {
21409   if (obj && obj->supertype == DWG_SUPERTYPE_ENTITY)
21410     {
21411       *error = 0;
21412       if (dwg_version == R_INVALID)
21413         dwg_version = (Dwg_Version_Type)obj->parent->header.version;
21414       return obj->tio.entity;
21415     }
21416   else
21417     {
21418       *error = 1;
21419       LOG_ERROR ("%s: Empty or invalid obj", __FUNCTION__)
21420       return NULL;
21421     }
21422 }
21423 
21424 /*******************************************************************
21425  *                    FUNCTIONS FOR DWG                             *
21426  ********************************************************************/
21427 
21428 /** Returns the number of classes or 0
21429 \code Usage: unsigned num_classes = dwg_get_num_classes(dwg);
21430 \endcode
21431 \param[in]  dwg   dwg_data*
21432 */
21433 unsigned int
dwg_get_num_classes(const dwg_data * dwg)21434 dwg_get_num_classes (const dwg_data *dwg)
21435 {
21436   if (!dwg)
21437     return 0;
21438   if (dwg_version == R_INVALID)
21439     dwg_version = (Dwg_Version_Type)dwg->header.version;
21440   return dwg->num_classes;
21441 }
21442 
21443 /** Returns the nth class or NULL
21444 \code Usage: dwg_object* obj = dwg_get_object(dwg, 0);
21445 \endcode
21446 \param[in]  dwg   dwg_data*
21447 \param[in]  idx
21448 */
21449 dwg_class *
dwg_get_class(const dwg_data * dwg,unsigned int idx)21450 dwg_get_class (const dwg_data *dwg, unsigned int idx)
21451 {
21452   if (!dwg)
21453     return NULL;
21454   if (dwg_version == R_INVALID)
21455     dwg_version = (Dwg_Version_Type)dwg->header.version;
21456   return (idx < dwg->num_classes) ? &dwg->dwg_class[idx] : NULL;
21457 }
21458 
21459 /** Returns the nth object or NULL
21460 \code Usage: dwg_object* obj = dwg_get_object(dwg, 0);
21461 \endcode
21462 \param[in]  dwg   dwg_data*
21463 \param[in]  idx
21464 */
21465 dwg_object *
dwg_get_object(dwg_data * dwg,const BITCODE_BL idx)21466 dwg_get_object (dwg_data *dwg, const BITCODE_BL idx)
21467 {
21468   if (!dwg)
21469     return NULL;
21470   if (dwg_version == R_INVALID)
21471     dwg_version = (Dwg_Version_Type)dwg->header.version;
21472   return (idx < dwg->num_objects) ? &dwg->object[idx] : NULL;
21473 }
21474 
21475 /** Returns object from absolute reference or NULL
21476 \code Usage: dwg_object* obj = dwg_absref_get_object(dwg, absref);
21477 \endcode
21478 \param[in]  dwg
21479 \param[in]  absref
21480 */
21481 dwg_object *
dwg_absref_get_object(const dwg_data * dwg,const BITCODE_BL absref)21482 dwg_absref_get_object (const dwg_data *dwg, const BITCODE_BL absref)
21483 {
21484   if (absref)
21485     return dwg_resolve_handle (dwg, absref);
21486   else
21487     return NULL;
21488 }
21489 
21490 /*******************************************************************
21491  *                    FUNCTIONS FOR DWG OBJECT                       *
21492  ********************************************************************/
21493 
21494 /** Returns the object bitsize or 0
21495 \code Usage: bitsize = dwg_object_get_bitsize(obj);
21496 \endcode
21497 \param[in]  obj   dwg_object*
21498 */
21499 BITCODE_RL
dwg_object_get_bitsize(const dwg_object * obj)21500 dwg_object_get_bitsize (const dwg_object *obj)
21501 {
21502   return obj ? obj->bitsize : 0;
21503 }
21504 
21505 /** Returns the global idx/objid in the list of all objects.
21506     This is the same as a dwg_handle absolute_ref value.
21507     \sa dwg_obj_get_objid
21508 
21509 \code Usage: int idx = dwg_object_get_index(obj, &error);
21510 \endcode
21511 \param[in]  obj     dwg_object*
21512 \param[out] error   int*, is set to 0 for ok, 1 on error
21513 */
21514 BITCODE_BL
dwg_object_get_index(const dwg_object * restrict obj,int * restrict error)21515 dwg_object_get_index (const dwg_object *restrict obj, int *restrict error)
21516 {
21517   if (obj)
21518     {
21519       *error = 0;
21520       if (dwg_version == R_INVALID)
21521         dwg_version = (Dwg_Version_Type)obj->parent->header.version;
21522       return obj->index;
21523     }
21524   else
21525     {
21526       *error = 1;
21527       LOG_ERROR ("%s: empty obj", __FUNCTION__)
21528       return 0;
21529     }
21530 }
21531 
21532 /** Returns dwg_handle* from dwg_object*
21533 \code Usage: dwg_handle* handle = dwg_object_get_handle(obj, &error);
21534 \endcode
21535 \param[in]  obj     dwg_object*
21536 \param[out] error   int*, is set to 0 for ok, 1 on error
21537 */
21538 dwg_handle *
dwg_object_get_handle(dwg_object * restrict obj,int * restrict error)21539 dwg_object_get_handle (dwg_object *restrict obj, int *restrict error)
21540 {
21541   if (obj)
21542     {
21543       *error = 0;
21544       if (dwg_version == R_INVALID)
21545         dwg_version = (Dwg_Version_Type)obj->parent->header.version;
21546       return &(obj->handle);
21547     }
21548   else
21549     {
21550       *error = 1;
21551       LOG_ERROR ("%s: empty obj", __FUNCTION__)
21552       return NULL;
21553     }
21554 }
21555 
21556 /** Returns the dwg object type, see \ref DWG_OBJECT_TYPE "enum
21557 DWG_OBJECT_TYPE". With types > 500 you need to check the dxfname instead, or
21558 check fixedtype. \sa dwg_object_get_dxfname \sa dwg_get_fixedtype \code Usage:
21559   int type = dwg_object_get_type(obj);
21560   if (type > 500) dxfname = dwg_object_get_dxfname(obj);
21561 \endcode
21562 \param[in]  obj   dwg_object*
21563 */
21564 int
dwg_object_get_type(const dwg_object * obj)21565 dwg_object_get_type (const dwg_object *obj)
21566 {
21567   if (obj)
21568     {
21569       return obj->type;
21570     }
21571   else
21572     {
21573       LOG_ERROR ("%s: empty ref", __FUNCTION__)
21574       return -1;
21575     }
21576 }
21577 
21578 /** Returns the fixed dwg object type, see \ref DWG_OBJECT_TYPE "enum
21579 DWG_OBJECT_TYPE". \sa dwg_object_get_type \code Usage: int type =
21580 dwg_object_get_type(obj); if (type > 500) dxfname =
21581 dwg_object_get_fixedtype(obj); \endcode \param[in]  obj   dwg_object*
21582 */
21583 int
dwg_object_get_fixedtype(const dwg_object * obj)21584 dwg_object_get_fixedtype (const dwg_object *obj)
21585 {
21586   if (obj)
21587     {
21588       return obj->fixedtype;
21589     }
21590   else
21591     {
21592       LOG_ERROR ("%s: empty ref", __FUNCTION__)
21593       return -1;
21594     }
21595 }
21596 
21597 /** Returns the object dxfname as ASCII string. Since r2007 utf8 encoded, but
21598     we haven't seen unicode names for the dxfname yet.
21599 \code Usage: const char* name = dwg_object_get_dxfname(obj);
21600 \endcode
21601 \param obj dwg_object*
21602 */
21603 char *
dwg_object_get_dxfname(const dwg_object * obj)21604 dwg_object_get_dxfname (const dwg_object *obj)
21605 {
21606   if (obj)
21607     {
21608       if (dwg_version == R_INVALID)
21609         dwg_version = (Dwg_Version_Type)obj->parent->header.version;
21610       return obj->dxfname;
21611     }
21612   else
21613     {
21614       LOG_ERROR ("%s: empty ref", __FUNCTION__)
21615       return NULL;
21616     }
21617 }
21618 
21619 /*******************************************************************
21620  *                    FUNCTIONS FOR DWG OBJECT SUBCLASSES           *
21621  ********************************************************************/
21622 
21623 /** This is the same as \sa dwg_object_get_index */
21624 EXPORT BITCODE_BL
dwg_obj_get_objid(const dwg_obj_obj * restrict obj,int * restrict error)21625 dwg_obj_get_objid (const dwg_obj_obj *restrict obj, int *restrict error)
21626 {
21627   _BODY_FIELD (obj, objid);
21628 }
21629 
21630 /** Returns the number of object EED structures.
21631 \code Usage: int num_eed = dwg_obj_get_num_eed(ent, &error);
21632 \endcode
21633 \param[in]  obj     dwg_obj_obj*
21634 \param[out] error   int*, is set to 0 for ok, 1 on error
21635 */
21636 BITCODE_BL
dwg_obj_get_num_eed(const dwg_obj_obj * restrict obj,int * restrict error)21637 dwg_obj_get_num_eed (const dwg_obj_obj *restrict obj, int *restrict error)
21638 {
21639   if (!obj)
21640     {
21641       *error = 1;
21642       return 0;
21643     }
21644   *error = 0;
21645   return obj->num_eed;
21646 }
21647 /** Returns the nth EED structure.
21648 \code Usage: dwg_entity_eed *eed = dwg_obj_get_eed(obj,0,&error);
21649 \endcode
21650 \param[in]  obj    dwg_obj_obj*
21651 \param[in]  idx  [0 - num_eed-1]
21652 \param[out] error  set to 0 for ok, 1 if obj == NULL or 2 if index out of
21653 bounds.
21654 */
21655 dwg_entity_eed *
dwg_obj_get_eed(const dwg_obj_obj * restrict obj,const BITCODE_BL idx,int * restrict error)21656 dwg_obj_get_eed (const dwg_obj_obj *restrict obj, const BITCODE_BL idx,
21657                  int *restrict error)
21658 {
21659   if (!obj)
21660     {
21661       *error = 1;
21662       LOG_ERROR ("%s: empty or invalid obj", __FUNCTION__)
21663       return NULL;
21664     }
21665   else if (idx >= obj->num_eed)
21666     {
21667       *error = 2;
21668       return NULL;
21669     }
21670   else
21671     {
21672       *error = 0;
21673       return &obj->eed[idx];
21674     }
21675 }
21676 
21677 /** Returns the data union of the nth EED structure.
21678 \code Usage: dwg_entity_eed_data *eed = dwg_obj_get_eed_data(obj,0,&error);
21679 \endcode
21680 \param[in]  obj    dwg_obj_obj*
21681 \param[in]  idx  [0 - num_eed-1]
21682 \param[out] error  set to 0 for ok, 1 if obj == NULL or 2 if index out of
21683 bounds.
21684 */
21685 dwg_entity_eed_data *
dwg_obj_get_eed_data(const dwg_obj_obj * restrict obj,const BITCODE_BL idx,int * restrict error)21686 dwg_obj_get_eed_data (const dwg_obj_obj *restrict obj, const BITCODE_BL idx,
21687                       int *restrict error)
21688 {
21689   if (!obj)
21690     {
21691       *error = 1;
21692       LOG_ERROR ("%s: empty or invalid obj", __FUNCTION__)
21693       return NULL;
21694     }
21695   else if (idx >= obj->num_eed)
21696     {
21697       *error = 2;
21698       return NULL;
21699     }
21700   else
21701     {
21702       *error = 0;
21703       return obj->eed[idx].data;
21704     }
21705 }
21706 
21707 EXPORT BITCODE_H
dwg_obj_get_ownerhandle(const dwg_obj_obj * restrict obj,int * restrict error)21708 dwg_obj_get_ownerhandle (const dwg_obj_obj *restrict obj, int *restrict error)
21709 {
21710   _BODY_FIELD (obj, ownerhandle);
21711 }
21712 EXPORT BITCODE_BL
dwg_obj_get_num_reactors(const dwg_obj_obj * restrict obj,int * restrict error)21713 dwg_obj_get_num_reactors (const dwg_obj_obj *restrict obj, int *restrict error)
21714 {
21715   _BODY_FIELD (obj, num_reactors);
21716 }
21717 EXPORT BITCODE_H *
dwg_obj_get_reactors(const dwg_obj_obj * restrict obj,int * restrict error)21718 dwg_obj_get_reactors (const dwg_obj_obj *restrict obj, int *restrict error)
21719 {
21720   _BODY_FIELD (obj, reactors);
21721 }
21722 EXPORT BITCODE_H
dwg_obj_get_xdicobjhandle(const dwg_obj_obj * restrict obj,int * restrict error)21723 dwg_obj_get_xdicobjhandle (const dwg_obj_obj *restrict obj,
21724                            int *restrict error)
21725 {
21726   _BODY_FIELD (obj, xdicobjhandle);
21727 }
21728 /* r2004+ */
21729 EXPORT BITCODE_B
dwg_obj_get_is_xdic_missing(const dwg_obj_obj * restrict obj,int * restrict error)21730 dwg_obj_get_is_xdic_missing (const dwg_obj_obj *restrict obj,
21731                                int *restrict error)
21732 {
21733   _BODY_FIELD (obj, is_xdic_missing);
21734 }
21735 /* r2013+ */
21736 EXPORT BITCODE_B
dwg_obj_get_has_ds_binary_data(const dwg_obj_obj * restrict obj,int * restrict error)21737 dwg_obj_get_has_ds_binary_data (const dwg_obj_obj *restrict obj,
21738                                 int *restrict error)
21739 {
21740   _BODY_FIELD (obj, has_ds_data);
21741 }
21742 EXPORT Dwg_Handle *
dwg_obj_get_handleref(const dwg_obj_obj * restrict obj,int * restrict error)21743 dwg_obj_get_handleref (const dwg_obj_obj *restrict obj, int *restrict error)
21744 {
21745   _BODY_FIELD (obj, handleref);
21746 }
21747 
21748 /** Returns dwg_obj_obj* from dwg_object*
21749 \code Usage: dwg_obj_obj ent = dwg_object_to_object(obj, &error);
21750 \endcode
21751 \param[in]  obj   dwg_object*
21752 \param[out] error   int*, is set to 0 for ok, 1 on error
21753 */
21754 dwg_obj_obj *
dwg_object_to_object(dwg_object * restrict obj,int * restrict error)21755 dwg_object_to_object (dwg_object *restrict obj, int *restrict error)
21756 {
21757   if (obj && obj->supertype == DWG_SUPERTYPE_OBJECT)
21758     {
21759       *error = 0;
21760       if ((dwg_version == R_INVALID)
21761           && (obj->parent != NULL))
21762         dwg_version = (Dwg_Version_Type)obj->parent->header.version;
21763       return obj->tio.object;
21764     }
21765   else
21766     {
21767       *error = 1;
21768       LOG_ERROR ("%s: Empty or invalid obj", __FUNCTION__)
21769       return NULL;
21770     }
21771 }
21772 
21773 /** Returns dwg_object* from dwg_obj_obj*
21774 \code Usage: dwg_object* obj = dwg_obj_obj_to_object(_obj, &error);
21775 \endcode
21776 \param[in]  obj     dwg_obj_obj*
21777 \param[out] error   int*, is set to 0 for ok, 1 on error
21778 */
21779 dwg_object *
dwg_obj_obj_to_object(const dwg_obj_obj * restrict obj,int * restrict error)21780 dwg_obj_obj_to_object (const dwg_obj_obj *restrict obj, int *restrict error)
21781 {
21782   dwg_data *dwg;
21783   dwg_object *retval;
21784 
21785   if (!obj)
21786     {
21787       *error = 1;
21788       // LOG_ERROR("%s: Empty or invalid obj", __FUNCTION__)
21789       return NULL;
21790     }
21791   dwg = obj->dwg;
21792   if (!dwg)
21793     {
21794       *error = 1;
21795       return NULL;
21796     }
21797   if (dwg_version == R_INVALID)
21798     dwg_version = (Dwg_Version_Type)dwg->header.version;
21799   if (obj->objid >= dwg->num_objects)
21800     {
21801       *error = 1;
21802       return NULL;
21803     }
21804   retval = &dwg->object[obj->objid];
21805   if (retval->supertype == DWG_SUPERTYPE_OBJECT)
21806     {
21807       *error = 0;
21808       return retval;
21809     }
21810   else
21811     {
21812       *error = 1;
21813       return NULL;
21814     }
21815 }
21816 
21817 /** Returns dwg_object* from any dwg_obj_*
21818 \code Usage: dwg_object* obj = dwg_obj_generic_to_object(_obj, &error);
21819 \endcode
21820 \param[in]  obj     dwg_obj_generic* (layer, block_header, xrecord, ...)
21821 \param[out] error   int*, is set to 0 for ok, 1 on error
21822 */
21823 dwg_object *
dwg_obj_generic_to_object(const void * restrict _vobj,int * restrict error)21824 dwg_obj_generic_to_object (const void *restrict _vobj,
21825                            int *restrict error)
21826 {
21827   const dwg_obj_generic *_obj = (const dwg_obj_generic *)_vobj;
21828   if (_obj && _obj->parent)
21829     {
21830       dwg_data *dwg = _obj->parent->dwg;
21831       dwg_object *retval = dwg ? &dwg->object[_obj->parent->objid] : NULL;
21832       if (!dwg
21833           || _obj->parent->objid > dwg->num_objects
21834           || dwg->header.version > R_AFTER)
21835         {
21836           *error = 1;
21837           LOG_ERROR ("%s: Invalid obj", __FUNCTION__)
21838           return NULL;
21839         }
21840       *error = 0;
21841       loglevel = dwg->opts & DWG_OPTS_LOGLEVEL;
21842       if (dwg && dwg_version == R_INVALID)
21843         dwg_version = (Dwg_Version_Type)dwg->header.version;
21844       return retval;
21845     }
21846   else
21847     {
21848       *error = 1;
21849       // LOG_ERROR("%s: Empty or invalid obj", __FUNCTION__)
21850       return NULL;
21851     }
21852 }
21853 
21854 /** Returns the handle value for any dwg_obj_*
21855 \code Usage: handle = dwg_obj_generic_handlevalue(_obj);
21856 \endcode
21857 \return The handle value or 0;
21858 \param[in]  obj   dwg_obj_generic* (layer, block_header, xrecord, ...) as void * to avoid casts.
21859 */
21860 unsigned long
dwg_obj_generic_handlevalue(void * _obj)21861 dwg_obj_generic_handlevalue (void *_obj)
21862 {
21863   int error;
21864   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
21865   if (obj && !error)
21866     return obj->handle.value;
21867   else
21868     return 0UL;
21869 }
21870 
21871 /** Returns dwg_obj_obj* from any dwg_obj_*
21872 \code Usage: dwg_obj_obj* obj = dwg_obj_generic_parent(_obj, &error);
21873 \endcode
21874 \param[in]  obj     dwg_obj_generic* (layer, block_header, xrecord, ...)
21875 \param[out] error   int*, is set to 0 for ok, 1 on error
21876 */
21877 dwg_obj_obj *
dwg_obj_generic_parent(const void * restrict _vobj,int * restrict error)21878 dwg_obj_generic_parent (const void *restrict _vobj,
21879                         int *restrict error)
21880 {
21881   const dwg_obj_generic *_obj = (const dwg_obj_generic *)_vobj;
21882   if (_obj && _obj->parent)
21883     {
21884       dwg_obj_obj *retval = _obj->parent;
21885       *error = 0;
21886       return retval;
21887     }
21888   else
21889     {
21890       *error = 1;
21891       LOG_ERROR ("%s: Empty or invalid obj", __FUNCTION__)
21892       return NULL;
21893     }
21894 }
21895 
21896 /*******************************************************************
21897  *                    FUNCTIONS FOR DWG OBJECT REF                  *
21898  ********************************************************************/
21899 
21900 /** Returns object from reference or NULL
21901 \code Usage: dwg_object obj = dwg_ref_get_object(ref, &error);
21902 \endcode
21903 \param[in]  ref     dwg_object_ref*
21904 \param[out] error   int*, is set to 0 for ok, 1 or 2 on error
21905 */
21906 dwg_object *
dwg_ref_get_object(const dwg_object_ref * restrict ref,int * restrict error)21907 dwg_ref_get_object (const dwg_object_ref *restrict ref, int *restrict error)
21908 {
21909   if (ref)
21910     {
21911       if (!ref->obj)
21912         {
21913           /* It is not possible to get the dwg from the ref only, only from an
21914              obj. The caller has to call the code below: */
21915           /* Dwg_Data *dwg = ;
21916           ref->obj = dwg_resolve_handle (dwg, ref->absolute_ref);
21917           if (!ref->obj) {
21918           */
21919           *error = 2;
21920           LOG_ERROR ("%s: empty ref", __FUNCTION__)
21921           //}
21922         }
21923       *error = 0;
21924       return ref->obj;
21925     }
21926   else
21927     {
21928       *error = 1;
21929       LOG_ERROR ("%s: empty ref", __FUNCTION__)
21930       return NULL;
21931     }
21932 }
21933 
21934 /* Returns the absolute handle reference, to be looked up
21935    in dwg->object_refs[]
21936 \code Usage: BITCODE_BL ref = dwg_ref_get_absref(obj, &error);
21937 \endcode
21938 \param[in]  ref   dwg_object_ref*
21939 \param[out] error   int*, is set to 0 for ok, 1 on error
21940 */
21941 BITCODE_BL
dwg_ref_get_absref(const dwg_object_ref * restrict ref,int * restrict error)21942 dwg_ref_get_absref (const dwg_object_ref *restrict ref, int *restrict error)
21943 {
21944   if (ref)
21945     {
21946       *error = 0;
21947       return ref->absolute_ref;
21948     }
21949   else
21950     {
21951       LOG_ERROR ("%s: empty ref", __FUNCTION__)
21952       *error = 1;
21953       return (BITCODE_BL)-1;
21954     }
21955 }
21956 
21957 /********************************************************************
21958  *                    FUNCTIONS FOR ADDING OBJECTS                  *
21959  ********************************************************************/
21960 
21961 #ifdef USE_WRITE
21962 
21963 /* internally used only by dwg_add_Attribute only */
21964 Dwg_Entity_ATTRIB*
21965 dwg_add_ATTRIB (Dwg_Entity_INSERT *restrict insert,
21966                 const double height,
21967                 const int flags,
21968                 const dwg_point_3d *restrict ins_pt,
21969                 const char *restrict tag,
21970                 const char *restrict text_value) __nonnull_all;
21971 /* internally used only by dwg_add_ATTRIB only */
21972 Dwg_Entity_ATTDEF*
21973 dwg_add_ATTDEF (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
21974                 const double height,
21975                 const int mode,
21976                 const char *restrict prompt,
21977                 const dwg_point_3d *restrict ins_pt,
21978                 const char *restrict tag,
21979                 const char *restrict default_value) __nonnull_all;
21980 
21981 /* internally used only by dwg_add_POLYLINE* only */
21982 // fixme: Dwg_Entity_POLYLINE_2D* as 1st owner arg
21983 Dwg_Entity_VERTEX_2D*
21984 dwg_add_VERTEX_2D (Dwg_Entity_POLYLINE_2D *restrict pline,
21985                    const dwg_point_2d *restrict point) __nonnull_all;
21986 Dwg_Entity_VERTEX_3D*
21987 dwg_add_VERTEX_3D (Dwg_Entity_POLYLINE_3D *restrict pline,
21988                    const dwg_point_3d *restrict point) __nonnull_all;
21989 Dwg_Entity_VERTEX_MESH*
21990 dwg_add_VERTEX_MESH (Dwg_Entity_POLYLINE_MESH *restrict pline,
21991                       const dwg_point_3d *restrict point) __nonnull_all;
21992 Dwg_Entity_VERTEX_PFACE*
21993 dwg_add_VERTEX_PFACE (Dwg_Entity_POLYLINE_PFACE *restrict pline,
21994                       const dwg_point_3d *restrict point) __nonnull_all;
21995 Dwg_Entity_VERTEX_PFACE_FACE*
21996 dwg_add_VERTEX_PFACE_FACE (Dwg_Entity_POLYLINE_PFACE *restrict pline,
21997                            const dwg_face vertind) __nonnull_all;
21998 Dwg_Entity_SEQEND *
21999 dwg_add_SEQEND (dwg_ent_generic *restrict owner) __nonnull_all;
22000 
22001 // imported from in_dxf.c
22002 void in_postprocess_handles (Dwg_Object *restrict obj);
22003 void in_postprocess_SEQEND (Dwg_Object *restrict obj, BITCODE_BL num_owned,
22004                             BITCODE_H *owned);
22005 int dwg_fixup_BLOCKS_entities (Dwg_Data *restrict dwg);
22006 
22007 #define NEW_OBJECT(dwg, obj)                                                  \
22008   {                                                                           \
22009     BITCODE_BL idx = dwg->num_objects;                                        \
22010     if (dwg_add_object (dwg) < 0)                                             \
22011       dwg_resolve_objectrefs_silent (dwg);                                    \
22012     obj = &dwg->object[idx];                                                  \
22013     obj->supertype = DWG_SUPERTYPE_OBJECT;                                    \
22014     obj->tio.object                                                           \
22015         = (Dwg_Object_Object *)calloc (1, sizeof (Dwg_Object_Object));        \
22016     obj->tio.object->objid = obj->index;                                      \
22017     obj->tio.object->dwg = dwg;                                               \
22018   }
22019 
22020 // returns BLOCK_HEADER owner for generic entity from ent->ownerhandle.
22021 EXPORT Dwg_Object_BLOCK_HEADER*
dwg_entity_owner(const void * _ent)22022 dwg_entity_owner (const void* _ent)
22023 {
22024   int error;
22025   Dwg_Object *ent = dwg_ent_generic_to_object (_ent, &error);
22026   Dwg_Object_Ref *owner;
22027   Dwg_Object *hdr;
22028   Dwg_Data *dwg = ent->parent;
22029   int iter = 0;
22030 
22031   if (error || !ent || ent->supertype != DWG_SUPERTYPE_ENTITY)
22032     return NULL;
22033   dwg = ent->parent;
22034   owner = ent->tio.entity->ownerhandle;
22035   hdr = dwg_ref_object (dwg, owner);
22036  hdr_again:
22037   if (!hdr || hdr->fixedtype != DWG_TYPE_BLOCK_HEADER)
22038     {
22039       if (iter)
22040         return NULL;
22041       if (ent->tio.entity->entmode == 2)
22042         {
22043           iter++;
22044           hdr = dwg_ref_object (dwg, dwg->header_vars.BLOCK_RECORD_MSPACE);
22045           goto hdr_again;
22046         }
22047       else if (ent->tio.entity->entmode == 1)
22048         {
22049           iter++;
22050           hdr = dwg_ref_object (dwg, dwg->header_vars.BLOCK_RECORD_PSPACE);
22051           goto hdr_again;
22052         }
22053       return NULL;
22054     }
22055   else
22056     return hdr->tio.object->tio.BLOCK_HEADER;
22057 }
22058 
add_ent_reactor(Dwg_Object_Entity * obj,unsigned long absolute_ref)22059 static void add_ent_reactor (Dwg_Object_Entity *obj, unsigned long absolute_ref)
22060 {
22061   if (obj->num_reactors)
22062     {
22063       obj->num_reactors++;
22064       obj->reactors = realloc (obj->reactors, obj->num_reactors * sizeof (BITCODE_H));
22065     }
22066   else
22067     {
22068       obj->num_reactors = 1;
22069       obj->reactors = calloc (1, sizeof (BITCODE_H));
22070     }
22071   obj->reactors[obj->num_reactors - 1] = dwg_add_handleref (obj->dwg, 4, absolute_ref, NULL);
22072 }
22073 
add_obj_reactor(Dwg_Object_Object * obj,unsigned long absolute_ref)22074 static void add_obj_reactor (Dwg_Object_Object *obj, unsigned long absolute_ref)
22075 {
22076   if (obj->num_reactors)
22077     {
22078       obj->num_reactors++;
22079       obj->reactors = realloc (obj->reactors, obj->num_reactors * sizeof (BITCODE_H));
22080     }
22081   else
22082     {
22083       obj->num_reactors = 1;
22084       obj->reactors = calloc (1, sizeof (BITCODE_H));
22085     }
22086   obj->reactors[obj->num_reactors - 1] = dwg_add_handleref (obj->dwg, 4, absolute_ref, NULL);
22087 }
22088 
22089 // check if radian or degree, need to normalize.
22090 // max observed angle: 10.307697 in some ELLIPSE.end_angle
22091 #define ADD_CHECK_ANGLE(angle)              \
22092   if (isnan (angle))                        \
22093     {                                       \
22094       LOG_ERROR ("Invalid %s: NaN", #angle) \
22095       return NULL;                          \
22096     }                                       \
22097   if (fabs (angle) > 12.0)                  \
22098     {                                       \
22099       LOG_ERROR ("Invalid %s: %f needs to " \
22100                  "be radian (%f)", #angle,  \
22101                  angle, deg2rad (angle))    \
22102       return NULL;                          \
22103     }                                       \
22104   if (fabs (angle) > M_PI)                  \
22105     {                                       \
22106       const double old = angle;             \
22107       while (angle > M_PI)                  \
22108         angle -= (M_PI * 2.0);              \
22109       while (angle < -M_PI)                 \
22110         angle += (M_PI * 2.0);              \
22111       LOG_WARN ("Bad angle %s: %f normalized "\
22112                 "to %f", #angle, old, angle) \
22113     }
22114 
22115 #define ADD_CHECK_3DPOINT(pt)                \
22116   if (isnan (pt->x) || isnan (pt->y) || isnan (pt->z)) \
22117     {                                       \
22118       LOG_ERROR ("Invalid %s: NaN", #pt)    \
22119       return NULL;                          \
22120     }
22121 #define ADD_CHECK_2DPOINT(pt)               \
22122   if (isnan (pt->x) || isnan (pt->y))       \
22123     {                                       \
22124       LOG_ERROR ("Invalid %s: NaN", #pt)    \
22125       return NULL;                          \
22126     }
22127 #define ADD_CHECK_DOUBLE(dbl)               \
22128  if (isnan (dbl))                           \
22129     {                                       \
22130       LOG_ERROR ("Invalid %s: NaN", #dbl)   \
22131       return NULL;                          \
22132     }                                       \
22133 
22134 /* Convert UTF-8 strings to BITCODE_T fields */
22135 EXPORT BITCODE_T
dwg_add_u8_input(Dwg_Data * restrict dwg,const char * restrict u8str)22136 dwg_add_u8_input (Dwg_Data *restrict dwg, const char *restrict u8str)
22137 {
22138   if (IS_FROM_TU_DWG (dwg))
22139     {
22140       return (BITCODE_T)bit_utf8_to_TU ((char *restrict)u8str, 0);
22141     }
22142   else
22143     {
22144       // TODO Encode unicode to \U+... bit_utf8_to_TV
22145 #if 0
22146       int size = 1024;
22147       char *dest = malloc (size);
22148       char *tgt = bit_utf8_to_TV (dest, u8str, size, strlen(u8str), 0);
22149       if (!dest)
22150         {
22151           LOG_ERROR ("Out of memory");
22152           return NULL;
22153         }
22154       while (!tgt)
22155         {
22156           size *= 2;
22157           if (size >= 1>>32)
22158             {
22159               LOG_ERROR ("Out of memory");
22160               return NULL;
22161             }
22162           dest = realloc (dest, size);
22163           tgt = bit_utf8_to_TV (dest, u8str, size, strlen(u8str), 0);
22164         }
22165       return tgt;
22166 #endif
22167       return strdup (u8str);
22168     }
22169 }
22170 
22171 /* Should be similar to the public VBA interface */
22172 
22173 /* Initialize a new dwg. Which template, imperial or metric */
22174 EXPORT Dwg_Data*
dwg_add_Document(const Dwg_Version_Type version,const int imperial,const int lglevel)22175 dwg_add_Document (const Dwg_Version_Type version, const int imperial, const int lglevel)
22176 {
22177   Dwg_Data *dwg = calloc (1, sizeof (Dwg_Data));
22178   int error;
22179   Dwg_Object_BLOCK_CONTROL *block_control;
22180   Dwg_Object_BLOCK_HEADER *mspace, *pspace;
22181   Dwg_Object_STYLE *style;
22182   Dwg_Object_LAYER *layer;
22183   Dwg_Object_LTYPE *ltype;
22184   Dwg_Object_LTYPE_CONTROL *ltype_ctrl;
22185   Dwg_Object_DICTIONARY *nod, *dict, *layoutdict;
22186   Dwg_Object_MLINESTYLE *mlstyle;
22187   Dwg_Object_LAYOUT *layout;
22188   Dwg_Object_VPORT *vport_active;
22189   Dwg_Entity_VIEWPORT *pviewport;
22190   dwg_point_3d pt0 = { 0.0, 1.0, 0.0 };
22191   Dwg_Object *obj, *ctrl, *mspaceobj;
22192   time_t now;
22193   const char *canonical_media_name;
22194 
22195   loglevel = lglevel & DWG_OPTS_LOGLEVEL;
22196   /* Set the import flag, so we don't encode to TU, just TV */
22197   dwg->opts = loglevel | DWG_OPTS_IN;
22198   dwg->dirty_refs = 0;
22199 
22200   //dwg->object_map = hash_new (200);
22201 
22202   dwg->header.version = version;
22203   dwg->header.from_version = version;
22204   //dwg->header.is_maint = 0xf;
22205   //dwg->header.zero_one_or_three = 1;
22206   //dwg->header.dwg_version = 0x17; // prefer encode if dwg_version is 0
22207   //dwg->header.maint_version = 29;
22208   dwg->header.codepage = 30; // FIXME: local codepage if <r2007
22209   //dwg->header.num_sections = 5;
22210   //dwg->header.section = (Dwg_Section *)calloc (
22211   //    dwg->header.num_sections, sizeof (Dwg_Section));
22212 
22213   dwg->header_vars.unknown_0 = 412148564080.0; // unit1_ration
22214   dwg->header_vars.unknown_1 = 1.0;
22215   dwg->header_vars.unknown_2 = 1.0;
22216   dwg->header_vars.unknown_3 = 1.0;
22217   dwg->header_vars.unknown_text1 = dwg_add_u8_input (dwg, "m"); // also meter sometimes. unit1_text
22218   dwg->header_vars.DIMASO = 1;
22219   dwg->header_vars.DIMSHO = 1; // Obsolete
22220   dwg->header_vars.REGENMODE = 1;
22221   dwg->header_vars.FILLMODE = 1;
22222   dwg->header_vars.PSLTSCALE = 1;
22223   dwg->header_vars.BLIPMODE = 1;
22224   dwg->header_vars.USRTIMER = 1;
22225   //dwg->header_vars.SKPOLY = 0;
22226   dwg->header_vars.TILEMODE = 1;
22227   dwg->header_vars.VISRETAIN = 1;
22228   dwg->header_vars.ATTREQ = 1;
22229   dwg->header_vars.MIRRTEXT = 1;
22230   dwg->header_vars.WORLDVIEW = 1;
22231   dwg->header_vars.TILEMODE = 1;
22232   dwg->header_vars.DELOBJ = 1;
22233   dwg->header_vars.PROXYGRAPHICS = 1;
22234   dwg->header_vars.DRAGMODE = 2;
22235   dwg->header_vars.TREEDEPTH = 3020;
22236   dwg->header_vars.LUNITS = 2;
22237   dwg->header_vars.LUPREC = 4;
22238   dwg->header_vars.ATTMODE = 1;
22239   dwg->header_vars.COORDS = 1;
22240   dwg->header_vars.PICKSTYLE = 1;
22241   dwg->header_vars.SPLINESEGS = 8;
22242   dwg->header_vars.SURFU = 6;
22243   dwg->header_vars.SURFV = 6;
22244   dwg->header_vars.SURFTYPE = 6;
22245   dwg->header_vars.SURFTAB1 = 6;
22246   dwg->header_vars.SURFTAB2 = 6;
22247   dwg->header_vars.SPLINETYPE = 6;
22248   dwg->header_vars.SHADEDGE = 3;
22249   dwg->header_vars.SHADEDIF = 70;
22250   dwg->header_vars.MAXACTVP = 48;
22251   dwg->header_vars.ISOLINES = 4;
22252   dwg->header_vars.TEXTQLTY = 50;
22253   dwg->header_vars.LTSCALE = 1.0;
22254   dwg->header_vars.TEXTSIZE = 0.2;
22255   dwg->header_vars.TRACEWID = 0.05;
22256   dwg->header_vars.SKETCHINC = 0.1;
22257   dwg->header_vars.FACETRES = 0.5;
22258   dwg->header_vars.CMLSCALE = imperial ? 1.0 : 20.0;
22259   dwg->header_vars.CELTSCALE = 1.0;
22260   dwg->header_vars.INSUNITS = imperial ? 1 : 4;
22261   dwg->header_vars.MENU = dwg_add_u8_input (dwg, "acad");
22262 
22263   dwg->header_vars.FLAGS = 0x2a1d; // or 0x281d
22264   dwg->header_vars.CELWEIGHT = -1; // => FLAGS & 0x1f + lweight lookup
22265   now = time(NULL);
22266   dwg->header_vars.TDCREATE = (BITCODE_TIMEBLL){ now / 3600, now / 86400 };
22267   // CECOLOR.index: 256 [CMC.BS 62]
22268   dwg->header_vars.CECOLOR = (BITCODE_CMC){ 256, 0 }; // ByLayer
22269   // HANDSEED: 0.1.49 [H 0] // FIXME needs to be updated on encode
22270   dwg->header_vars.HANDSEED = dwg_add_handleref (dwg, 0, 0x25, NULL);
22271   dwg->header_vars.PEXTMIN
22272       = (BITCODE_3BD){ 100000000000000000000.0, 100000000000000000000.0,
22273                        100000000000000000000.0 };
22274   dwg->header_vars.PEXTMAX
22275       = (BITCODE_3BD){ -100000000000000000000.0, -100000000000000000000.0,
22276                        -100000000000000000000.0 };
22277   // dwg->header_vars.PUCSORG = { 0.0, 0.0, 0.0 };
22278   dwg->header_vars.PUCSXDIR = (BITCODE_3BD){ 1.0, 0.0, 0.0 };
22279   dwg->header_vars.PUCSYDIR = (BITCODE_3BD){ 0.0, 1.0, 0.0 };
22280   // PUCSNAME: (5.0.0) abs:0 [H 2]
22281   dwg->header_vars.EXTMIN
22282       = (BITCODE_3BD){ 100000000000000000000.0, 100000000000000000000.0,
22283                        100000000000000000000.0 };
22284   dwg->header_vars.EXTMAX
22285       = (BITCODE_3BD){ -100000000000000000000.0, -100000000000000000000.0,
22286                        -100000000000000000000.0 };
22287   if (imperial)
22288     {
22289       dwg->header_vars.PLIMMAX = (BITCODE_2DPOINT){ 12.0, 9.0 };
22290       dwg->header_vars.LIMMAX = (BITCODE_2DPOINT){ 12.0, 9.0 };
22291     }
22292   else
22293     {
22294       dwg->header_vars.PLIMMAX = (BITCODE_2DPOINT){ 420.0, 297.0 };
22295       dwg->header_vars.LIMMAX = (BITCODE_2DPOINT){ 420.0, 297.0 };
22296     }
22297   // UCSORG: (0.0, 0.0, 0.0) [3BD 10]
22298   // UCSXDIR: (1.0, 0.0, 0.0) [3BD 10]
22299   // UCSYDIR: (0.0, 1.0, 0.0) [3BD 10]
22300   dwg->header_vars.UCSXDIR = (BITCODE_3BD){ 1.0, 0.0, 0.0 };
22301   dwg->header_vars.UCSYDIR = (BITCODE_3BD){ 0.0, 1.0, 0.0 };
22302   // UCSNAME: (5.0.0) abs:0 [H 2]
22303   dwg->header_vars.DIMTIH = 1;
22304   dwg->header_vars.DIMTOH = 1;
22305   dwg->header_vars.DIMALTD = 2;
22306   dwg->header_vars.DIMTOLJ = 1;
22307   dwg->header_vars.DIMFIT = 3;
22308   dwg->header_vars.DIMUNIT = 2;
22309   dwg->header_vars.DIMDEC = 4;
22310   dwg->header_vars.DIMTDEC = 4;
22311   dwg->header_vars.DIMALTU = 2;
22312   dwg->header_vars.DIMALTTD = 2;
22313   dwg->header_vars.DIMSCALE = 1.0;
22314   dwg->header_vars.DIMASZ = 0.18;
22315   dwg->header_vars.DIMEXO = 0.0625;
22316   dwg->header_vars.DIMDLI = 0.38;
22317   dwg->header_vars.DIMEXE = 0.18;
22318   dwg->header_vars.DIMTXT = 0.18;
22319   dwg->header_vars.DIMCEN = 0.09;
22320   dwg->header_vars.DIMALTF = 25.4;
22321   dwg->header_vars.DIMLFAC = 1.0;
22322   dwg->header_vars.DIMTFAC = 1.0;
22323   dwg->header_vars.DIMGAP = 0.09;
22324   //dwg->header_vars.DIMPOST = dwg_add_u8_input (dwg, "");
22325   //dwg->header_vars.DIMAPOST = dwg_add_u8_input (dwg, "");
22326   //dwg->header_vars.DIMBLK_T = dwg_add_u8_input (dwg, "");
22327   //dwg->header_vars.DIMBLK1_T = dwg_add_u8_input (dwg, "");
22328   //dwg->header_vars.DIMBLK2_T = dwg_add_u8_input (dwg, "");
22329 
22330   dwg->header_vars.DIMCLRD = (BITCODE_CMC){ 0 };
22331   dwg->header_vars.DIMCLRE = (BITCODE_CMC){ 0 };
22332   dwg->header_vars.DIMCLRT = (BITCODE_CMC){ 0 };
22333 
22334   dwg->header_vars.MEASUREMENT = imperial ? 0 : 256;
22335   canonical_media_name = imperial ? "ANSI_A_(8.50_x_11.00_Inches)"
22336                                   : "ISO_A1_(841.00_x_594.00_MM)";
22337 
22338   // BLOCK_CONTROL_OBJECT: (3.1.1) abs:1 [H 0]
22339   block_control = dwg_add_BLOCK_CONTROL (dwg, 0x1F, 0x20);
22340   // LAYER_CONTROL_OBJECT: (3.1.2) abs:2 [H 0]
22341   dwg_add_LAYER (dwg, NULL);
22342   // STYLE_CONTROL_OBJECT: (3.1.3) abs:3 [H 0]
22343   dwg_add_STYLE (dwg, NULL);
22344   // hole at 4
22345   dwg_set_next_hdl (dwg, 0x5);
22346   // LTYPE_CONTROL_OBJECT: (3.1.5) abs:5 [H 0]
22347   dwg_add_LTYPE (dwg, NULL);
22348   // VIEW_CONTROL_OBJECT: (3.1.6) abs:6 [H 0]
22349   dwg_add_VIEW (dwg, NULL);
22350   //dwg->view_control = *dwg->object[4].tio.object->tio.VIEW_CONTROL;
22351   // UCS_CONTROL_OBJECT: (3.1.7) abs:7 [H 0]
22352   dwg_add_UCS (dwg, &pt0, NULL, NULL, NULL);
22353   //dwg->ucs_control = *dwg->object[5].tio.object->tio.UCS_CONTROL;
22354   // VPORT_CONTROL_OBJECT: (3.1.8) abs:8 [H 0]
22355   dwg_add_VPORT (dwg, NULL);
22356   //dwg->vport_control = *dwg->object[6].tio.object->tio.VPORT_CONTROL;
22357   // APPID_CONTROL_OBJECT: (3.1.9) abs:9 [H 0]
22358   dwg_add_APPID (dwg, NULL);
22359   // DIMSTYLE_CONTROL_OBJECT: (3.1.A) abs:A [H 0]
22360   // We don't create DIMSTYLE Standard upfront, only on demand.
22361   dwg_add_DIMSTYLE (dwg, NULL);
22362   // VX_CONTROL_OBJECT: (3.1.B) abs:B [H 0]
22363   dwg_add_VX (dwg, NULL); // TODO only <r2000
22364   // DICTIONARY_NAMED_OBJECT: (3.1.C) abs:C [H 0]
22365   nod = dwg_add_DICTIONARY (dwg, NULL, (const BITCODE_T) "NAMED_OBJECT", 0UL);
22366   dwg->header_vars.DICTIONARY_NAMED_OBJECT
22367       = dwg_add_handleref (dwg, 3, 0xC, NULL);
22368   // DICTIONARY_ACAD_GROUP: (5.1.D) abs:D [H 0]
22369   dwg_add_DICTIONARY (dwg, (const BITCODE_T) "ACAD_GROUP", NULL, 0UL);
22370   dwg->header_vars.DICTIONARY_ACAD_GROUP = dwg_add_handleref (dwg, 5, 0xD, NULL);
22371   dwg_add_DICTIONARY_item (nod, (const BITCODE_T) "ACAD_GROUP", 0xD);
22372   if (version >= R_2000)
22373     {
22374       Dwg_Object_PLACEHOLDER *plh;
22375       // DICTIONARY (5.1.E) //FIXME
22376       dwg_add_DICTIONARYWDFLT (dwg, (const BITCODE_T) "ACAD_PLOTSTYLENAME",
22377                                (const BITCODE_T) "Normal", 0xF);
22378       dwg->header_vars.DICTIONARY_PLOTSTYLENAME
22379           = dwg_add_handleref (dwg, 5, 0xE, NULL);
22380       // PLOTSTYLE (2.1.F)
22381       plh = dwg_add_PLACEHOLDER (dwg); // PLOTSTYLE
22382       obj = dwg_obj_generic_to_object (plh, &error);
22383       obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, 0xE, obj);
22384       add_obj_reactor (obj->tio.object, 0xE);
22385     }
22386   else
22387     {
22388       dwg_set_next_hdl (dwg, 0x10);
22389     }
22390   // LAYER: (0.1.10)
22391   layer = dwg_add_LAYER (dwg, (const BITCODE_T) "0");
22392   layer->color = (BITCODE_CMC){ 7 };
22393   layer->ltype = dwg_add_handleref (dwg, 5, 0x16, NULL); // Continuous
22394   layer->plotstyle = dwg_add_handleref (dwg, 5, 0xF, NULL);
22395   // CLAYER: (5.1.F) abs:F [H 8]
22396   dwg->header_vars.CLAYER = dwg_add_handleref (dwg, 5, 0x10, NULL);
22397   //dwg->layer_control = *dwg->object[1].tio.object->tio.LAYER_CONTROL;
22398   // STYLE: (0.1.11)
22399   style = dwg_add_STYLE (dwg, "Standard");
22400   style->font_file = dwg_add_u8_input (dwg, "txt");
22401   style->last_height = 0.2;
22402   // TEXTSTYLE: (5.1.11) [H 7]
22403   dwg->header_vars.TEXTSTYLE = dwg_add_handleref (dwg, 5, 0x11, NULL);
22404   dwg->header_vars.DIMTXSTY = dwg->header_vars.TEXTSTYLE;
22405   //dwg->style_control = *dwg->object[2].tio.object->tio.STYLE_CONTROL;
22406   // APPID "ACAD": (0.1.12)
22407   dwg_add_APPID (dwg, "ACAD");
22408   //dwg->appid_control = *dwg->object[7].tio.object->tio.APPID_CONTROL;
22409   // hole at 13. already in r13
22410   dwg_set_next_hdl (dwg, 0x14);
22411   ltype_ctrl = dwg->object[3].tio.object->tio.LTYPE_CONTROL;
22412   // LTYPE->byblock: (3.1.14)
22413   ltype = dwg_add_LTYPE (dwg, "BYBLOCK");
22414   ltype_ctrl->num_entries--;
22415   ltype_ctrl->byblock = dwg_add_handleref (dwg, 3, 0x14, NULL);
22416   dwg->header_vars.LTYPE_BYBLOCK = dwg_add_handleref (dwg, 5, 0x14, NULL);
22417   // LTYPE->bylayer: (3.1.15)
22418   dwg_add_LTYPE (dwg, "BYLAYER");
22419   ltype_ctrl->num_entries--;
22420   ltype_ctrl->bylayer = dwg_add_handleref (dwg, 3, 0x15, NULL);
22421   dwg->header_vars.LTYPE_BYLAYER = dwg_add_handleref (dwg, 5, 0x15, NULL);
22422   // CELTYPE: (5.1.14) abs:14 [H 6]
22423   dwg->header_vars.CELTYPE = dwg_add_handleref (dwg, 5, 0x15, NULL);
22424   // LTYPE_CONTINUOUS: (5.1.16)
22425   ltype = dwg_add_LTYPE (dwg, "CONTINUOUS");
22426   ltype->description = dwg_add_u8_input (dwg, "Solid line");
22427   dwg->header_vars.LTYPE_CONTINUOUS = dwg_add_handleref (dwg, 5, 0x16, NULL);
22428 
22429   // DICTIONARY ACAD_MLINESTYLE: (5.1.17) abs:E [H 0]
22430   dwg_add_DICTIONARY (dwg, "ACAD_MLINESTYLE", "Standard", 0x18);
22431   dwg->header_vars.DICTIONARY_ACAD_MLINESTYLE
22432       = dwg_add_handleref (dwg, 5, 0x17, NULL);
22433   // MLINESTYLE: (0.1.18)
22434   mlstyle = dwg_add_MLINESTYLE (dwg, "Standard");
22435   obj = dwg_obj_generic_to_object (mlstyle, &error);
22436   dwg->header_vars.CMLSTYLE
22437       = dwg_add_handleref (dwg, 5, obj->handle.value, NULL);
22438 
22439   // DICTIONARY ACAD_PLOTSETTINGS: (5.1.19)
22440   dwg_add_DICTIONARY (dwg, "ACAD_PLOTSETTINGS", NULL, 0);
22441   dwg->header_vars.DICTIONARY_PLOTSETTINGS
22442       = dwg_add_handleref (dwg, 5, 0x19, NULL);
22443 
22444   if (version >= R_2000)
22445     {
22446       // DICTIONARY_LAYOUT: (5.1.1A)
22447       layoutdict = dwg_add_DICTIONARY (dwg, "ACAD_LAYOUT", NULL, 0);
22448       obj = dwg_obj_generic_to_object (layoutdict, &error);
22449       dwg->header_vars.DICTIONARY_LAYOUT
22450           = dwg_add_handleref (dwg, 5, obj->handle.value, NULL);
22451     }
22452   // DIMSTYLE: (5.1.1D) abs:1D [H 2]
22453 
22454   // hole until 1F
22455   dwg_set_next_hdl (dwg, 0x1F);
22456   // BLOCK_RECORD_MSPACE: (5.1.1F)
22457   mspace = dwg_add_BLOCK_HEADER (dwg, "*MODEL_SPACE");
22458   mspaceobj = dwg_obj_generic_to_object (mspace, &error);
22459   block_control->num_entries--;
22460   dwg->header_vars.BLOCK_RECORD_MSPACE
22461       = dwg_add_handleref (dwg, 5, mspaceobj->handle.value, NULL);
22462   dwg->header_vars.BLOCK_RECORD_MSPACE->obj = mspaceobj;
22463   block_control->model_space
22464       = dwg_add_handleref (dwg, 3, mspaceobj->handle.value, NULL);
22465   // BLOCK_RECORD_PSPACE: (5.1.20)
22466   pspace = dwg_add_BLOCK_HEADER (dwg, "*PAPER_SPACE");
22467   obj = dwg_obj_generic_to_object (pspace, &error);
22468   block_control->num_entries--;
22469   if (!block_control->num_entries)
22470     {
22471       free (block_control->entries);
22472       block_control->entries = NULL;
22473     }
22474   dwg->header_vars.BLOCK_RECORD_PSPACE
22475       = dwg_add_handleref (dwg, 5, obj->handle.value, NULL);
22476   dwg->header_vars.BLOCK_RECORD_PSPACE->obj = obj;
22477   block_control->paper_space
22478       = dwg_add_handleref (dwg, 3, obj->handle.value, NULL);
22479   dwg->block_control = *block_control;
22480   // BLOCK: (5.1.21)
22481   dwg_add_BLOCK (pspace, "*PAPER_SPACE");
22482   // ENDBLK: (5.1.22)
22483   dwg_add_ENDBLK (pspace);
22484   // LAYOUT (0.1.23)
22485   //layout = dwg_add_LAYOUT (layoutdict);
22486   //pspace->layout = dwg_add_handleref (dwg, 5, 0x23, NULL);
22487 
22488   // BLOCK: (5.1.24)
22489   dwg_add_BLOCK (mspace, "*MODEL_SPACE");
22490   // ENDBLK: (5.1.25)
22491   dwg_add_ENDBLK (mspace);
22492   if (dwg->header.version >= R_2000)
22493     {
22494 #ifdef NEED_VPORT_FOR_MODEL_LAYOUT
22495       // VPORT (0.1.26)
22496       vport_active = dwg_add_VPORT (dwg, "*Active");
22497       // LAYOUT (0.1.27)
22498       obj = dwg_obj_generic_to_object (vport_active, &error);
22499       layout = dwg_add_LAYOUT (obj, "Model", canonical_media_name);
22500 #  else
22501       layout = dwg_add_LAYOUT (mspaceobj, "Model", canonical_media_name);
22502 #  endif
22503       obj = dwg_obj_generic_to_object (layout, &error);
22504       mspace->layout = dwg_add_handleref (dwg, 5, obj->handle.value, NULL);
22505 
22506 #ifdef NEED_VPORT_FOR_MODEL_LAYOUT
22507       // VIEWPORT (0.1.28)
22508       pviewport = dwg_add_VIEWPORT (pspace, "");
22509       // LAYOUT (0.1.29)
22510       obj = dwg_obj_generic_to_object (pviewport, &error);
22511 #else
22512       obj = dwg_obj_generic_to_object (pspace, &error);
22513 #endif
22514       layout = dwg_add_LAYOUT (obj, "Layout1", canonical_media_name);
22515       obj = dwg_obj_generic_to_object (layout, &error);
22516       pspace->layout = dwg_add_handleref (dwg, 5, obj->handle.value, NULL);
22517     }
22518 
22519   // a non-invasive variant of resolve_objectref_vector()
22520   for (unsigned i = 0; i < dwg->num_object_refs; i++)
22521     {
22522       Dwg_Object_Ref *ref = dwg->object_ref[i];
22523       // possibly update the obj if realloced
22524       if ((obj = dwg_resolve_handle (dwg, ref->absolute_ref)))
22525         ref->obj = obj;
22526     }
22527   dwg->dirty_refs = 0;
22528   return dwg;
22529 }
22530 
22531 /* Returns <0 on error, the new 50x klass id on success..
22532    -1 out of memory.
22533    Takes UTF-8 names only */
22534 EXPORT int
dwg_add_class(Dwg_Data * restrict dwg,const char * const restrict dxfname,const char * const restrict cppname,const char * const restrict appname,const bool is_entity)22535 dwg_add_class (Dwg_Data *restrict dwg, const char *const restrict dxfname,
22536                const char *const restrict cppname,
22537                const char *const restrict appname, const bool is_entity)
22538 {
22539   /* calc. new number, no proxy, no is_zombie */
22540   BITCODE_BS i = dwg->num_classes;
22541   Dwg_Class *klass;
22542   if (i == 0)
22543     dwg->dwg_class = (Dwg_Class *)malloc (sizeof (Dwg_Class));
22544   else
22545     dwg->dwg_class = (Dwg_Class *)realloc (dwg->dwg_class,
22546                                            (i + 1) * sizeof (Dwg_Class));
22547   if (!dwg->dwg_class)
22548     {
22549       LOG_ERROR ("Out of memory");
22550       return -1;
22551     }
22552   klass = &dwg->dwg_class[i];
22553   memset (klass, 0, sizeof (Dwg_Class));
22554   klass->number = i + 500;
22555   klass->dxfname = strdup (dxfname);
22556   if (dwg->header.version >= R_2007)
22557     klass->dxfname_u = bit_utf8_to_TU ((char *restrict)dxfname, 0);
22558   klass->appname = dwg_add_u8_input (dwg, appname);
22559   klass->cppname = dwg_add_u8_input (dwg, cppname);
22560   klass->item_class_id = is_entity ? 0x1f2: 0x1f3;
22561   dwg->num_classes++;
22562   return klass->number;
22563 }
22564 
22565 /* Now implemented in dxfclasses.c as gperf lookup */
22566 #define REQUIRE_CLASS(name) dwg_require_class (dwg, name, sizeof(name)-1)
22567 
22568 #define NEW_ENTITY(dwg, obj)                                                  \
22569   {                                                                           \
22570     BITCODE_BL idx = dwg->num_objects;                                        \
22571     if (dwg_add_object (dwg) < 0)                                             \
22572       {                                                                       \
22573         dwg_resolve_objectrefs_silent (dwg);                                  \
22574         blkobj = dwg_obj_generic_to_object (blkhdr, &error);                  \
22575       }                                                                       \
22576     obj = &dwg->object[idx];                                                  \
22577     obj->supertype = DWG_SUPERTYPE_ENTITY;                                    \
22578     obj->tio.entity                                                           \
22579         = (Dwg_Object_Entity *)calloc (1, sizeof (Dwg_Object_Entity));        \
22580     obj->tio.entity->objid = obj->index;                                      \
22581     obj->tio.entity->dwg = dwg;                                               \
22582   }
22583 
22584 /* globals: dwg, obj, _obj, dxfname */
22585 #define ADD_ENTITY(token)                                                     \
22586   obj->type = obj->fixedtype = DWG_TYPE_##token;                              \
22587   obj->dxfname = (char*)dwg_type_dxfname (DWG_TYPE_##token);                  \
22588   if (memBEGINc (#token, "_3D"))                                              \
22589     obj->name = (char *)&#token[1];                                           \
22590   else                                                                        \
22591     obj->name = (char *)#token;                                               \
22592   if (!obj->dxfname)                                                          \
22593     {                                                                         \
22594       LOG_TRACE ("Unknown dxfname for %s\n", obj->name)                       \
22595       obj->dxfname = obj->name;                                               \
22596     }                                                                         \
22597   if (dwg->opts & DWG_OPTS_IN)                                                \
22598     obj->dxfname = strdup (obj->dxfname);                                     \
22599   if (dwg->opts & DWG_OPTS_INJSON)                                            \
22600     obj->name = strdup (obj->name);                                           \
22601   if (obj->type >= DWG_TYPE_GROUP)                                            \
22602     (void)dwg_encode_get_class (obj->parent, obj);                            \
22603   LOG_TRACE ("  ADD_ENTITY %s [%d]\n", obj->name, obj->index)                 \
22604   _obj = calloc (1, sizeof (Dwg_Entity_##token));                             \
22605   obj->tio.entity->tio.token = (Dwg_Entity_##token *)_obj;                    \
22606   obj->tio.entity->tio.token->parent = obj->tio.entity;                       \
22607   obj->tio.entity->objid = obj->index;                                        \
22608   dwg_add_entity_defaults (dwg, obj->tio.entity);                             \
22609   if (strEQc (#token, "SEQEND") || memBEGINc (#token, "VERTEX"))              \
22610     obj->tio.entity->linewt = 0x1c
22611 
22612 /* globals: dxfname, blkhdr=owner */
22613 #define API_ADD_ENTITY(token)                                                 \
22614   int error;                                                                  \
22615   Dwg_Object *obj;                                                            \
22616   Dwg_Entity_##token *_obj;                                                   \
22617   Dwg_Object *blkobj = dwg_obj_generic_to_object (blkhdr, &error);            \
22618   Dwg_Data *dwg = blkobj && !error ? blkobj->parent : NULL;                   \
22619   if (!dwg || !blkobj ||                                                      \
22620       !(blkobj->fixedtype == DWG_TYPE_BLOCK_HEADER ||                         \
22621         dwg_obj_has_subentity (blkobj)))                                      \
22622     {                                                                         \
22623       LOG_ERROR ("Entity %s can not be added to %s",                          \
22624                  #token, blkobj ? dwg_type_name (blkobj->fixedtype) : "NULL");\
22625       return NULL;                                                            \
22626     }                                                                         \
22627   NEW_ENTITY (dwg, obj);                                                      \
22628   ADD_ENTITY (token);                                                         \
22629   obj->tio.entity->ownerhandle = dwg_add_handleref (dwg,                      \
22630                                    5, blkobj->handle.value, obj);             \
22631   dwg_set_next_objhandle (obj);                                               \
22632   LOG_TRACE ("  handle " FORMAT_H "\n", ARGS_H (obj->handle));                \
22633   in_postprocess_handles (obj);                                               \
22634   dwg_insert_entity ((Dwg_Object_BLOCK_HEADER *)blkhdr, obj)
22635 
22636 #define ADD_OBJECT(token)                                                     \
22637   obj->type = obj->fixedtype = DWG_TYPE_##token;                              \
22638   obj->name = (char *)#token;                                                 \
22639   obj->dxfname = (char*)dwg_type_dxfname (DWG_TYPE_##token);                  \
22640   if (!obj->dxfname)                                                          \
22641     {                                                                         \
22642       LOG_TRACE ("Unknown dxfname for %s\n", obj->name)                       \
22643       obj->dxfname = obj->name;                                               \
22644     }                                                                         \
22645   if (dwg->opts & DWG_OPTS_IN)                                                \
22646     obj->dxfname = strdup (obj->dxfname);                                     \
22647   if (dwg->opts & DWG_OPTS_INJSON)                                            \
22648     obj->name = strdup (obj->name);                                           \
22649   if (obj->type >= DWG_TYPE_GROUP)                                            \
22650     (void)dwg_encode_get_class (obj->parent, obj);                            \
22651   LOG_TRACE ("  ADD_OBJECT %s [%d]\n", obj->name, obj->index)                 \
22652   _obj = calloc (1, sizeof (Dwg_Object_##token));                             \
22653   obj->tio.object->tio.token = (Dwg_Object_##token *)_obj;                    \
22654   obj->tio.object->tio.token->parent = obj->tio.object;                       \
22655   obj->tio.object->objid = obj->index
22656 
22657 /* globals: dwg */
22658 #define API_ADD_OBJECT(token)                                  \
22659   int error;                                                   \
22660   Dwg_Object *obj;                                             \
22661   Dwg_Object_##token *_obj;                                    \
22662   NEW_OBJECT (dwg, obj);                                       \
22663   ADD_OBJECT (token);                                          \
22664   dwg_set_next_objhandle (obj);                                \
22665   LOG_TRACE ("  handle " FORMAT_H "\n", ARGS_H(obj->handle));  \
22666   in_postprocess_handles (obj)
22667 
22668 EXPORT int
dwg_add_entity_defaults(Dwg_Data * restrict dwg,Dwg_Object_Entity * restrict ent)22669 dwg_add_entity_defaults (Dwg_Data *restrict dwg,
22670                          Dwg_Object_Entity *restrict ent)
22671 {
22672   int error;
22673   Dwg_Object *obj = dwg_ent_to_object (ent, &error);
22674   //const Dwg_Version_Type version = dwg->header.version;
22675   ent->is_xdic_missing = 1;
22676   ent->color.index = 256; /* ByLayer */
22677   // ltype either Bylayer or Continuous. if it has an ltype field, assume Cont
22678   if (!error && !dwg_dynapi_entity_field (obj->name, "ltype"))
22679     ent->isbylayerlt = 1;
22680   ent->ltype_scale = 1.0;
22681   // ltype_flags = 0; ByLayer
22682   // plotstyle_flags  = 0; ByLayer
22683   if (!error & (strEQc (obj->name, "SEQEND") || memBEGINc (obj->name, "VERTEX")))
22684     ent->linewt = 0x1c;
22685   else
22686     ent->linewt = 0x1d;
22687   if (dwg->header_vars.CLAYER)
22688     ent->layer = dwg_add_handleref (
22689         dwg, 5, dwg->header_vars.CLAYER->absolute_ref, NULL);
22690   // we cannot yet write >r2000, so no material, visualstyle, yet ...
22691 
22692   if (dwg->header_vars.THICKNESS != 0.0
22693       && !error && dwg_dynapi_entity_field (obj->name, "thickness"))
22694     {
22695       BITCODE_BD thickness = dwg->header_vars.THICKNESS;
22696       dwg_dynapi_entity_set_value (obj, obj->name, "thickness", &thickness, 0);
22697     }
22698   if (!error && dwg_dynapi_entity_field (obj->name, "extrusion"))
22699     {
22700       BITCODE_BE extrusion = (BITCODE_BE){0.0, 0.0, 1.0};
22701       dwg_dynapi_entity_set_value (ent->tio.POINT, obj->name, "extrusion", &extrusion, 0);
22702     }
22703   return 0;
22704 }
22705 
22706 /* Insert new entity into the block.
22707    We have two entity chains, one in the BLOCK_HEADER (not relative, obj always NULL)
22708    and the 2nd in the entities itself, these are always relative, so different ref.
22709    _owner may be BLOCK_HEADER or POLYLINE_*
22710  */
22711 EXPORT int
dwg_insert_entity(Dwg_Object_BLOCK_HEADER * restrict _owner,Dwg_Object * restrict obj)22712 dwg_insert_entity (Dwg_Object_BLOCK_HEADER *restrict _owner,
22713                    Dwg_Object *restrict obj)
22714 {
22715   int error;
22716   Dwg_Data *dwg = obj->parent;
22717   const Dwg_Version_Type version = dwg->header.version;
22718   Dwg_Object *owner = dwg_obj_generic_to_object (_owner, &error);
22719   const Dwg_Object_Ref *mspace =  dwg_model_space_ref (dwg);
22720   const Dwg_Object_Ref *pspace =  dwg_paper_space_ref (dwg);
22721   Dwg_Object_Entity *ent = obj->tio.entity;
22722 
22723   assert (mspace);
22724   // set entmode and ownerhandle
22725   if (owner->fixedtype == DWG_TYPE_BLOCK_HEADER &&
22726       owner->handle.value == mspace->absolute_ref)
22727     ent->entmode = 2;
22728   else
22729   if (owner->fixedtype == DWG_TYPE_BLOCK_HEADER &&
22730       pspace && owner->handle.value == pspace->absolute_ref)
22731     ent->entmode = 1;
22732   else
22733     obj->tio.entity->ownerhandle = dwg_add_handleref (dwg, 4, owner->handle.value, obj);
22734   if (!obj->tio.entity->ownerhandle &&
22735       (obj->fixedtype == DWG_TYPE_BLOCK ||
22736        obj->fixedtype == DWG_TYPE_ENDBLK ||
22737        obj->fixedtype == DWG_TYPE_SEQEND))
22738     // BLOCK,ENDBLK,SEQEND always have the ownerhandle set.
22739     ent->ownerhandle = dwg_add_handleref (dwg, 4, owner->handle.value, obj);
22740 
22741   // TODO 2004+
22742   if (1)
22743     {
22744       if (owner->fixedtype == DWG_TYPE_BLOCK_HEADER && obj->fixedtype == DWG_TYPE_BLOCK)
22745         {
22746           _owner->block_entity
22747               = dwg_add_handleref (dwg, 3, obj->handle.value, NULL);
22748           LOG_TRACE ("%s.block_entity = " FORMAT_REF "\n", owner->name,
22749                      ARGS_REF (_owner->block_entity));
22750         }
22751       else if (owner->fixedtype == DWG_TYPE_BLOCK_HEADER && obj->fixedtype == DWG_TYPE_ENDBLK)
22752         {
22753           _owner->endblk_entity
22754               = dwg_add_handleref (dwg, 3, obj->handle.value, NULL);
22755           LOG_TRACE ("%s.endblk_entity = " FORMAT_REF "\n", owner->name,
22756                      ARGS_REF (_owner->endblk_entity));
22757         }
22758       else if (obj->fixedtype == DWG_TYPE_SEQEND)
22759         {
22760           ent->prev_entity = ent->next_entity
22761             = dwg_add_handleref (dwg, 4, 0, NULL);
22762         }
22763       else if (owner->fixedtype == DWG_TYPE_BLOCK_HEADER &&
22764                !_owner->first_entity &&
22765                !_owner->num_owned &&
22766                !dwg_obj_is_subentity (obj))
22767         {
22768           BITCODE_H ref;
22769           _owner->first_entity = _owner->last_entity
22770             = dwg_add_handleref (dwg, 4, obj->handle.value, NULL);
22771           LOG_TRACE ("%s.{first,last}_entity = " FORMAT_REF "\n", owner->name,
22772                      ARGS_REF (_owner->first_entity));
22773           ref = dwg_add_handleref (dwg, 3, obj->handle.value, NULL);
22774           LOG_TRACE ("%s.entities[%d] = " FORMAT_REF "\n",
22775                      owner->name, _owner->num_owned, ARGS_REF (ref));
22776           PUSH_HV (_owner, num_owned, entities, ref)
22777           //ent->nolinks = 1;
22778           LOG_TRACE ("%s.num_owned = %u\n", owner->name, _owner->num_owned);
22779         }
22780       else
22781         {
22782           Dwg_Object *prev = NULL;
22783           if (dwg_obj_is_subentity (obj) && obj->index)
22784             {
22785               prev = &dwg->object[obj->index - 1];
22786               if (!dwg_obj_is_subentity (prev))
22787                 prev = NULL;
22788             }
22789           else if (owner->fixedtype == DWG_TYPE_BLOCK_HEADER)
22790             {
22791               BITCODE_H ref = _owner->last_entity;
22792               prev = ref ? dwg_ref_object (dwg, ref) : NULL; // may fail!
22793               _owner->last_entity = dwg_add_handleref (dwg, 4, obj->handle.value, NULL);
22794               LOG_TRACE ("%s.last_entity = " FORMAT_REF "\n",
22795                          owner->name, ARGS_REF (_owner->last_entity));
22796               ref = dwg_add_handleref (dwg, 3, obj->handle.value, NULL);
22797               LOG_TRACE ("%s.entities[%d] = " FORMAT_REF "\n",
22798                          owner->name, _owner->num_owned, ARGS_REF (ref));
22799               PUSH_HV (_owner, num_owned, entities, ref)
22800               LOG_TRACE ("%s.num_owned = %u\n", owner->name, _owner->num_owned);
22801             }
22802           // link prev. last to curr last
22803           if (prev && prev->supertype == DWG_SUPERTYPE_ENTITY)
22804             {
22805               if (prev->index + 1 == obj->index && // immediate next
22806                   prev->tio.entity->prev_entity && // and pref exist
22807                   prev->tio.entity->prev_entity->absolute_ref)
22808                 {
22809                   // is next and is not first
22810                   prev->tio.entity->nolinks = 1;
22811                 }
22812               else
22813                 {
22814                   prev->tio.entity->next_entity
22815                     = dwg_add_handleref (dwg, 4, obj->handle.value, prev);
22816                   LOG_TRACE ("prev.next_entity = " FORMAT_REF "\n",
22817                              ARGS_REF (prev->tio.entity->next_entity));
22818                   ent->prev_entity = dwg_add_handleref (dwg, 4, prev->handle.value, obj);
22819                   LOG_TRACE ("%s.prev_entity = " FORMAT_REF "\n", obj->name,
22820                              ARGS_REF (ent->prev_entity));
22821                   prev->tio.entity->nolinks = 0;
22822                 }
22823             }
22824           else
22825             ent->prev_entity = dwg_add_handleref (dwg, 4, 0, NULL);
22826         }
22827     }
22828   in_postprocess_handles (obj);
22829   return 0;
22830 }
22831 
22832 /* -- For now only the entities needed for SolveSpace -- */
22833 
22834 EXPORT Dwg_Entity_TEXT*
dwg_add_TEXT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict text_value,const dwg_point_3d * restrict ins_pt,const double height)22835 dwg_add_TEXT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
22836               const char *restrict text_value,
22837               const dwg_point_3d *restrict ins_pt,
22838               const double height)
22839 {
22840   API_ADD_ENTITY (TEXT);
22841   ADD_CHECK_3DPOINT (ins_pt);
22842   ADD_CHECK_DOUBLE (height);
22843   _obj->text_value = dwg_add_u8_input (dwg, text_value);
22844   _obj->ins_pt.x   = ins_pt->x;
22845   _obj->ins_pt.y   = ins_pt->y;
22846   _obj->elevation  = ins_pt->z;
22847   _obj->height     = height;
22848   if (dwg->header_vars.TEXTSTYLE)
22849     _obj->style = dwg_add_handleref (
22850         dwg, 5, dwg->header_vars.TEXTSTYLE->absolute_ref, NULL);
22851   return _obj;
22852 }
22853 
22854 /* This adds the ATTRIB and ENDBLK to the insert,
22855    and the ATTDEF and ENDBLK to the block. */
22856 EXPORT Dwg_Entity_ATTRIB*
dwg_add_Attribute(Dwg_Entity_INSERT * restrict insert,const double height,const int flags,const char * restrict prompt,const dwg_point_3d * restrict ins_pt,const char * restrict tag,const char * restrict text_value)22857 dwg_add_Attribute (Dwg_Entity_INSERT *restrict insert,
22858                    const double height,
22859                    const int flags,
22860                    const char *restrict prompt,
22861                    const dwg_point_3d *restrict ins_pt,
22862                    const char *restrict tag,
22863                    const char *restrict text_value)
22864 {
22865   Dwg_Object *hdr, *attobj, *insobj;
22866   Dwg_Object_BLOCK_HEADER *restrict blkhdr;
22867   Dwg_Entity_ENDBLK *endblk;
22868   Dwg_Entity_ATTDEF *attdef;
22869   Dwg_Entity_ATTRIB *attrib;
22870   int err;
22871 
22872   ADD_CHECK_3DPOINT (ins_pt);
22873   ADD_CHECK_DOUBLE (height);
22874   insobj = dwg_obj_generic_to_object (insert, &err);
22875   if (!insobj || err)
22876     {
22877       LOG_ERROR ("add_Attribute: No INSERT found");
22878       return NULL;
22879     }
22880   hdr = dwg_ref_object (insobj->parent, insert->block_header);
22881   if (!hdr)
22882     {
22883       LOG_ERROR ("add_Attribute: No INSERT.block_header found");
22884       return NULL;
22885     }
22886   blkhdr = hdr->tio.object->tio.BLOCK_HEADER;
22887 
22888   // TODO check if this ATTDEF already exists.
22889   attdef = dwg_add_ATTDEF (blkhdr, height, flags, prompt,
22890                            ins_pt, tag, text_value);
22891   if (!attdef)
22892     LOG_WARN ("No ATTDEF %s added", tag)
22893   // ENDBLK must exist already though
22894   attrib = dwg_add_ATTRIB (insert, height, flags, ins_pt, tag, text_value);
22895   attobj = dwg_obj_generic_to_object (attrib, &err);
22896   if (!attobj || err)
22897     {
22898       LOG_ERROR ("No ATTRIB %s added", tag);
22899       return NULL;
22900     }
22901   //dwg->header_vars.AFLAGS = flags; FIXME
22902   if (!insert->has_attribs) // no ATTRIB and SEQEND yet
22903     {
22904       API_ADD_ENTITY (SEQEND);
22905       insert->has_attribs = 1;
22906       insert->num_owned = 1;
22907       insert->first_attrib = dwg_add_handleref (dwg, 4, attobj->handle.value, insobj);
22908       insert->last_attrib = insert->first_attrib;
22909       insert->seqend = dwg_add_handleref (dwg, 3, obj->handle.value, insobj);
22910       insert->attribs = malloc (sizeof (BITCODE_H));
22911       insert->attribs[0] = insert->last_attrib;
22912       in_postprocess_SEQEND (obj, insert->num_owned, insert->attribs);
22913     }
22914   else
22915     {
22916       Dwg_Data *dwg = insobj->parent;
22917       Dwg_Object *seqend;
22918       Dwg_Object *lastobj = dwg_ref_object (dwg, insert->last_attrib); // prev attrib
22919       insert->last_attrib = dwg_add_handleref (attobj->parent, 4, attobj->handle.value, insobj);
22920       attobj->tio.entity->prev_entity = insert->last_attrib;
22921       insert->num_owned++;
22922       insert->attribs = realloc (insert->attribs, insert->num_owned * sizeof (BITCODE_H));
22923       lastobj->tio.entity->next_entity = dwg_add_handleref (dwg, 3, attobj->handle.value, insobj);
22924       insert->attribs[insert->num_owned - 1] = insert->last_attrib
22925           = dwg_add_handleref (dwg, 4, attobj->handle.value, insobj);
22926       seqend = dwg_ref_object (dwg, insert->seqend);
22927       in_postprocess_SEQEND (seqend, insert->num_owned, insert->attribs);
22928     }
22929   return attrib;
22930 }
22931 
22932 /* internally used only by dwg_add_Attribute only */
22933 Dwg_Entity_ATTRIB*
dwg_add_ATTRIB(Dwg_Entity_INSERT * restrict insert,const double height,const int flags,const dwg_point_3d * restrict ins_pt,const char * restrict tag,const char * restrict text_value)22934 dwg_add_ATTRIB (Dwg_Entity_INSERT *restrict insert,
22935                 const double height,
22936                 const int flags,
22937                 const dwg_point_3d *restrict ins_pt,
22938                 const char *restrict tag,
22939                 const char *restrict text_value)
22940 {
22941   Dwg_Object_BLOCK_HEADER *restrict blkhdr = dwg_entity_owner ((dwg_ent_generic*)insert);
22942   API_ADD_ENTITY (ATTRIB);
22943   ADD_CHECK_3DPOINT (ins_pt);
22944   ADD_CHECK_DOUBLE (height);
22945   _obj->tag        = dwg_add_u8_input (dwg, tag);
22946   _obj->text_value = dwg_add_u8_input (dwg, text_value);
22947   _obj->ins_pt.x   = ins_pt->x;
22948   _obj->ins_pt.y   = ins_pt->y;
22949   _obj->elevation  = ins_pt->z;
22950   _obj->height     = height;
22951   // block handles
22952   if (dwg->header_vars.TEXTSTYLE)
22953     _obj->style = dwg_add_handleref (
22954         dwg, 5, dwg->header_vars.TEXTSTYLE->absolute_ref, NULL);
22955   //blkhdr->hasattrs = 1;
22956   return _obj;
22957 }
22958 
22959 /* internally used only by dwg_add_Attribute only */
22960 Dwg_Entity_ATTDEF*
dwg_add_ATTDEF(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const double height,const int flags,const char * restrict prompt,const dwg_point_3d * restrict ins_pt,const char * restrict tag,const char * restrict default_value)22961 dwg_add_ATTDEF (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
22962                 const double height,
22963                 const int flags,
22964                 const char *restrict prompt,
22965                 const dwg_point_3d *restrict ins_pt,
22966                 const char *restrict tag,
22967                 const char *restrict default_value)
22968 {
22969   API_ADD_ENTITY (ATTDEF);
22970   ADD_CHECK_3DPOINT (ins_pt);
22971   ADD_CHECK_DOUBLE (height);
22972   _obj->prompt     = dwg_add_u8_input (dwg, prompt);
22973   _obj->tag        = dwg_add_u8_input (dwg, tag);
22974   _obj->default_value = dwg_add_u8_input (dwg, default_value);
22975   _obj->ins_pt.x   = ins_pt->x;
22976   _obj->ins_pt.y   = ins_pt->y;
22977   _obj->elevation  = ins_pt->z;
22978   _obj->height     = height;
22979   // block handles
22980   if (dwg->header_vars.TEXTSTYLE)
22981     _obj->style = dwg_add_handleref (
22982         dwg, 5, dwg->header_vars.TEXTSTYLE->absolute_ref, NULL);
22983   return _obj;
22984 }
22985 
22986 EXPORT Dwg_Entity_BLOCK*
dwg_add_BLOCK(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict name)22987 dwg_add_BLOCK (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
22988                const char *restrict name)
22989 {
22990   API_ADD_ENTITY (BLOCK);
22991   _obj->name = dwg_add_u8_input (dwg, name);
22992   return _obj;
22993 }
22994 
22995 EXPORT Dwg_Entity_ENDBLK*
dwg_add_ENDBLK(Dwg_Object_BLOCK_HEADER * restrict blkhdr)22996 dwg_add_ENDBLK (Dwg_Object_BLOCK_HEADER *restrict blkhdr)
22997 {
22998   API_ADD_ENTITY (ENDBLK);
22999   dwg_fixup_BLOCKS_entities (dwg);
23000   return _obj;
23001 }
23002 
23003 // owned by POLYLINE or INSERT
23004 Dwg_Entity_SEQEND*
dwg_add_SEQEND(dwg_ent_generic * restrict blkhdr)23005 dwg_add_SEQEND (dwg_ent_generic *restrict blkhdr)
23006 {
23007   API_ADD_ENTITY (SEQEND);
23008   return _obj;
23009 }
23010 
23011 EXPORT Dwg_Entity_INSERT*
dwg_add_INSERT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict ins_pt,const char * restrict name,const double xscale,const double yscale,const double zscale,const double rotation)23012 dwg_add_INSERT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23013                 const dwg_point_3d *restrict ins_pt,
23014                 const char *restrict name,
23015                 const double xscale,
23016                 const double yscale,
23017                 const double zscale,
23018                 const double rotation)
23019 {
23020   BITCODE_H hdrref;
23021   API_ADD_ENTITY (INSERT);
23022   ADD_CHECK_3DPOINT (ins_pt);
23023   ADD_CHECK_DOUBLE (xscale);
23024   ADD_CHECK_DOUBLE (yscale);
23025   ADD_CHECK_DOUBLE (zscale);
23026   _obj->ins_pt.x     = ins_pt->x;
23027   _obj->ins_pt.y     = ins_pt->y;
23028   _obj->ins_pt.z     = ins_pt->z;
23029   _obj->scale.x      = xscale;
23030   _obj->scale.y      = yscale;
23031   _obj->scale.z      = zscale;
23032   //TODO scale_flag
23033   _obj->rotation     = rotation;
23034   ADD_CHECK_ANGLE (_obj->rotation);
23035   hdrref = dwg_find_tablehandle (dwg, name, "BLOCK");
23036   if (hdrref)
23037     {
23038       Dwg_Object *hdr = dwg_ref_object (dwg, hdrref);
23039       if (!hdr)
23040         return _obj;
23041       _obj->block_header = dwg_add_handleref (dwg, 5, hdr->handle.value, NULL);
23042       blkhdr = hdr->tio.object->tio.BLOCK_HEADER;
23043       blkhdr->used = 1;
23044       blkhdr->is_xref_ref = 1;
23045       blkhdr->num_inserts++;
23046       if (!blkhdr->inserts)
23047         blkhdr->inserts = calloc (1, sizeof (BITCODE_H));
23048       else
23049         blkhdr->inserts = realloc (blkhdr->inserts,
23050                                    blkhdr->num_inserts * sizeof (BITCODE_H));
23051       blkhdr->inserts[blkhdr->num_inserts - 1]
23052           = dwg_add_handleref (dwg, 4, obj->handle.value, NULL);
23053     }
23054   return _obj;
23055 }
23056 
23057 EXPORT Dwg_Entity_MINSERT*
dwg_add_MINSERT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict ins_pt,const char * restrict name,const double xscale,const double yscale,const double zscale,const double rotation,const int num_rows,const int num_cols,const double row_spacing,const double col_spacing)23058 dwg_add_MINSERT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23059                  const dwg_point_3d *restrict ins_pt,
23060                  const char *restrict name,
23061                  const double xscale,
23062                  const double yscale,
23063                  const double zscale,
23064                  const double rotation,
23065                  const int num_rows,
23066                  const int num_cols,
23067                  const double row_spacing,
23068                  const double col_spacing)
23069 {
23070   BITCODE_H hdrref;
23071   API_ADD_ENTITY (MINSERT);
23072   ADD_CHECK_3DPOINT (ins_pt);
23073   ADD_CHECK_DOUBLE (xscale);
23074   ADD_CHECK_DOUBLE (yscale);
23075   ADD_CHECK_DOUBLE (zscale);
23076   _obj->ins_pt.x     = ins_pt->x;
23077   _obj->ins_pt.y     = ins_pt->y;
23078   _obj->ins_pt.z     = ins_pt->z;
23079   _obj->scale.x      = xscale;
23080   _obj->scale.y      = yscale;
23081   _obj->scale.z      = zscale;
23082   //TODO scale_flag
23083   _obj->rotation     = rotation;
23084   ADD_CHECK_ANGLE (_obj->rotation);
23085   _obj->num_rows     = (BITCODE_BS)num_rows;
23086   _obj->num_cols     = (BITCODE_BS)num_cols;
23087   _obj->row_spacing  = row_spacing;
23088   _obj->col_spacing  = col_spacing;
23089   hdrref = dwg_find_tablehandle (dwg, name, "BLOCK");
23090   if (hdrref)
23091     {
23092       Dwg_Object *hdr = dwg_ref_object (dwg, hdrref);
23093       if (!hdr)
23094         return _obj;
23095       _obj->block_header = dwg_add_handleref (dwg, 5, hdr->handle.value, NULL);
23096       blkhdr = hdr->tio.object->tio.BLOCK_HEADER;
23097       blkhdr->used = 1;
23098       blkhdr->is_xref_ref = 1;
23099       blkhdr->num_inserts++;
23100       if (!blkhdr->inserts)
23101         blkhdr->inserts = calloc (1, sizeof (BITCODE_H));
23102       else
23103         blkhdr->inserts = realloc (blkhdr->inserts,
23104                                    blkhdr->num_inserts * sizeof (BITCODE_H));
23105       blkhdr->inserts[blkhdr->num_inserts - 1]
23106           = dwg_add_handleref (dwg, 4, obj->handle.value, NULL);
23107     }
23108   return _obj;
23109 }
23110 
23111 // TODO blkhdr => pline owner
23112 Dwg_Entity_VERTEX_2D*
dwg_add_VERTEX_2D(Dwg_Entity_POLYLINE_2D * restrict pline,const dwg_point_2d * restrict point)23113 dwg_add_VERTEX_2D (Dwg_Entity_POLYLINE_2D *restrict pline,
23114                    const dwg_point_2d *restrict point)
23115 {
23116   Dwg_Object_BLOCK_HEADER *restrict blkhdr = dwg_entity_owner ((dwg_ent_generic*)pline);
23117   API_ADD_ENTITY (VERTEX_2D);
23118   obj->tio.entity->entmode = 0;
23119   obj->tio.entity->ownerhandle = dwg_add_handleref (dwg, 4, dwg_obj_generic_handlevalue (pline), obj);
23120   ADD_CHECK_2DPOINT (point);
23121   _obj->point.x = point->x;
23122   _obj->point.y = point->y;
23123   _obj->flag = 0x20;
23124   return _obj;
23125 }
23126 
23127 Dwg_Entity_VERTEX_3D*
dwg_add_VERTEX_3D(Dwg_Entity_POLYLINE_3D * restrict pline,const dwg_point_3d * restrict point)23128 dwg_add_VERTEX_3D (Dwg_Entity_POLYLINE_3D *restrict pline,
23129                    const dwg_point_3d *restrict point)
23130 {
23131   Dwg_Object_BLOCK_HEADER *restrict blkhdr = dwg_entity_owner ((dwg_ent_generic*)pline);
23132   API_ADD_ENTITY (VERTEX_3D);
23133   obj->tio.entity->entmode = 0;
23134   obj->tio.entity->ownerhandle = dwg_add_handleref (dwg, 4, dwg_obj_generic_handlevalue (pline), obj);
23135   ADD_CHECK_3DPOINT (point);
23136   _obj->point.x = point->x;
23137   _obj->point.y = point->y;
23138   _obj->point.z = point->z;
23139   _obj->flag = 0x20;
23140   return _obj;
23141 }
23142 
23143 EXPORT Dwg_Entity_POLYLINE_2D*
dwg_add_POLYLINE_2D(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const int num_pts,const dwg_point_2d * restrict pts)23144 dwg_add_POLYLINE_2D (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23145                     const int num_pts,
23146                     const dwg_point_2d *restrict pts)
23147 {
23148   Dwg_Object *pl, *vtx = NULL;
23149   Dwg_Entity_POLYLINE_2D *_pl;
23150   Dwg_Entity_VERTEX_2D *_vtx;
23151   Dwg_Entity_SEQEND *_seq;
23152 
23153   API_ADD_ENTITY (POLYLINE_2D);
23154   pl = obj;
23155   _pl = _obj;
23156   _pl->vertex = malloc (num_pts * sizeof (BITCODE_H));
23157   if (!_pl->vertex)
23158     return NULL;
23159   if (num_pts)
23160     _pl->has_vertex = 1;
23161   for (int i = 0; i < num_pts; i++)
23162     {
23163       _vtx = dwg_add_VERTEX_2D (_pl, &pts[i]);
23164       if (!_vtx)
23165         {
23166         vtx_2d_err:
23167           LOG_ERROR ("No VERTEX_2D[%d] added", i);
23168           return NULL;
23169         }
23170       vtx = dwg_obj_generic_to_object (_vtx, &error);
23171       if (!vtx)
23172         goto vtx_2d_err;
23173       _pl->vertex[i] = dwg_add_handleref (dwg, 3, vtx->handle.value, pl);
23174       if (i == 0)
23175         _pl->first_vertex  = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23176       if (i == num_pts - 1)
23177         {
23178           vtx->tio.entity->prev_entity = dwg_add_handleref (dwg, 4, vtx->handle.value - 1, vtx);
23179           _pl->last_vertex  = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23180         }
23181     }
23182   _seq = dwg_add_SEQEND ((dwg_ent_generic *)_pl);
23183   if (!_seq)
23184     {
23185       LOG_ERROR ("No SEQEND added");
23186       return NULL;
23187     }
23188   _pl->seqend = dwg_add_handleref (
23189       dwg, 3, dwg_obj_generic_handlevalue (_seq), pl);
23190   pl->tio.entity->next_entity = NULL;
23191 
23192   _pl->num_owned = num_pts;
23193   in_postprocess_SEQEND (obj, _pl->num_owned, _pl->vertex);
23194   return _pl;
23195 }
23196 
23197 EXPORT Dwg_Entity_POLYLINE_3D*
dwg_add_POLYLINE_3D(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const int num_pts,const dwg_point_3d * restrict pts)23198 dwg_add_POLYLINE_3D (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23199                     const int num_pts,
23200                     const dwg_point_3d *restrict pts)
23201 {
23202   Dwg_Object *pl, *vtx = NULL;
23203   Dwg_Entity_POLYLINE_3D *_pl;
23204   Dwg_Entity_VERTEX_3D *_vtx;
23205   Dwg_Entity_SEQEND *_seq;
23206 
23207   API_ADD_ENTITY (POLYLINE_3D);
23208   pl = obj;
23209   _pl = _obj;
23210   _pl->vertex = malloc (num_pts * sizeof (BITCODE_H));
23211   if (!_pl->vertex)
23212     return NULL;
23213   if (num_pts)
23214     _pl->has_vertex = 1;
23215   for (int i = 0; i < num_pts; i++)
23216     {
23217       _vtx = dwg_add_VERTEX_3D (_pl, &pts[i]);
23218       if (!_vtx)
23219         {
23220         vtx_3d_err:
23221           LOG_ERROR ("No VERTEX_3D[%d] added", i);
23222           return NULL;
23223         }
23224       vtx = dwg_obj_generic_to_object (_vtx, &error);
23225       if (!vtx)
23226         goto vtx_3d_err;
23227       _pl->vertex[i] = dwg_add_handleref (dwg, 3, vtx->handle.value, pl);
23228       if (i == 0)
23229         _pl->first_vertex = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23230       if (i == num_pts - 1)
23231         {
23232           vtx->tio.entity->prev_entity = dwg_add_handleref (dwg, 4, vtx->handle.value - 1, vtx);
23233           _pl->last_vertex = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23234         }
23235     }
23236   _seq = dwg_add_SEQEND ((dwg_ent_generic *)_pl);
23237   if (!_seq)
23238     {
23239       LOG_ERROR ("No SEQEND added");
23240       return NULL;
23241     }
23242   _pl->seqend  = dwg_add_handleref (dwg, 3, dwg_obj_generic_handlevalue (_seq), pl);
23243   pl->tio.entity->next_entity = NULL;
23244 
23245   _pl->num_owned = num_pts;
23246   in_postprocess_SEQEND (obj, _pl->num_owned, _pl->vertex);
23247   return _pl;
23248 }
23249 
23250 Dwg_Entity_VERTEX_PFACE*
dwg_add_VERTEX_PFACE(Dwg_Entity_POLYLINE_PFACE * restrict pline,const dwg_point_3d * restrict point)23251 dwg_add_VERTEX_PFACE (Dwg_Entity_POLYLINE_PFACE *restrict pline,
23252                       const dwg_point_3d *restrict point)
23253 {
23254   Dwg_Object_BLOCK_HEADER *restrict blkhdr = dwg_entity_owner ((dwg_ent_generic*)pline);
23255   API_ADD_ENTITY (VERTEX_PFACE);
23256   obj->tio.entity->entmode = 0;
23257   obj->tio.entity->ownerhandle = dwg_add_handleref (dwg, 4, dwg_obj_generic_handlevalue (pline), obj);
23258   ADD_CHECK_3DPOINT (point);
23259   _obj->point.x = point->x;
23260   _obj->point.y = point->y;
23261   _obj->point.z = point->z;
23262   _obj->flag = 0xc0;
23263   return _obj;
23264 }
23265 
23266 Dwg_Entity_VERTEX_PFACE_FACE*
dwg_add_VERTEX_PFACE_FACE(Dwg_Entity_POLYLINE_PFACE * restrict pline,const dwg_face vertind)23267 dwg_add_VERTEX_PFACE_FACE (Dwg_Entity_POLYLINE_PFACE *restrict pline,
23268                            const dwg_face vertind)
23269 {
23270   Dwg_Object_BLOCK_HEADER *restrict blkhdr = dwg_entity_owner ((dwg_ent_generic*)pline);
23271   API_ADD_ENTITY (VERTEX_PFACE_FACE);
23272   obj->tio.entity->entmode = 0;
23273   obj->tio.entity->ownerhandle = dwg_add_handleref (dwg, 4, dwg_obj_generic_handlevalue (pline), obj);
23274   _obj->flag = 70;
23275   _obj->vertind[0] = vertind[0];
23276   _obj->vertind[1] = vertind[1];
23277   _obj->vertind[2] = vertind[2];
23278   _obj->vertind[3] = vertind[3];
23279   return _obj;
23280 }
23281 
23282 // Polyface Mesh
23283 EXPORT Dwg_Entity_POLYLINE_PFACE*
dwg_add_POLYLINE_PFACE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const unsigned numverts,const unsigned numfaces,const dwg_point_3d * restrict verts,const dwg_face * restrict faces)23284 dwg_add_POLYLINE_PFACE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23285                         const unsigned numverts,
23286                         const unsigned numfaces,
23287                         const dwg_point_3d *restrict verts,
23288                         const dwg_face *restrict faces)
23289 {
23290   Dwg_Object *pl, *vtx;
23291   Dwg_Entity_POLYLINE_PFACE *_pl;
23292   Dwg_Entity_VERTEX_PFACE *_vtx;
23293   Dwg_Entity_VERTEX_PFACE_FACE *_vtxf;
23294   Dwg_Entity_SEQEND *_seq;
23295 
23296   API_ADD_ENTITY (POLYLINE_PFACE);
23297   pl = obj;
23298   _pl = _obj;
23299   _pl->vertex = malloc ((numverts + numfaces) * sizeof (BITCODE_H));
23300   if (!_pl->vertex)
23301     return NULL;
23302   _pl->has_vertex = 1;
23303   _pl->numverts = numverts;
23304   _pl->numfaces = numfaces;
23305   _pl->num_owned = numverts + numfaces;
23306   for (unsigned i = 0; i < numverts; i++)
23307     {
23308       _vtx = dwg_add_VERTEX_PFACE (_pl, &verts[i]);
23309       if (!_vtx)
23310         {
23311         vtx_pface_err:
23312           LOG_ERROR ("No VERTEX_PFACE[%d] added", i);
23313           return NULL;
23314         }
23315       vtx = dwg_obj_generic_to_object (_vtx, &error);
23316       if (!vtx)
23317         goto vtx_pface_err;
23318       _pl->vertex[i] = dwg_add_handleref (dwg, 3, vtx->handle.value, pl);
23319       if (i == 0)
23320         _pl->first_vertex = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23321     }
23322   for (unsigned j = 0; j < numfaces; j++)
23323     {
23324       _vtxf = dwg_add_VERTEX_PFACE_FACE (_pl, faces[j]);
23325       if (!_vtxf)
23326         {
23327         vtx_pface_face_err:
23328           LOG_ERROR ("No VERTEX_PFACE_FACE[%d] added", j);
23329           return NULL;
23330         }
23331       vtx = dwg_obj_generic_to_object (_vtxf, &error);
23332       if (!vtx)
23333         goto vtx_pface_face_err;
23334       _pl->vertex[numverts + j] = dwg_add_handleref (dwg, 3, vtx->handle.value, pl);
23335       if (j == numfaces - 1)
23336         {
23337           // FIXME
23338           vtx->tio.entity->prev_entity = dwg_add_handleref (dwg, 4, vtx->handle.value - 1, vtx);
23339           _pl->last_vertex  = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23340         }
23341     }
23342   _seq = dwg_add_SEQEND ((dwg_ent_generic *)_pl);
23343   if (!_seq)
23344     {
23345       LOG_ERROR ("No SEQEND added");
23346       return NULL;
23347     }
23348   _pl->seqend  = dwg_add_handleref (dwg, 3, dwg_obj_generic_handlevalue (_seq), pl);
23349   in_postprocess_SEQEND (obj, _pl->num_owned, _pl->vertex);
23350   pl->tio.entity->next_entity = NULL; // fixup
23351   return _pl;
23352 }
23353 
23354 Dwg_Entity_VERTEX_MESH*
dwg_add_VERTEX_MESH(Dwg_Entity_POLYLINE_MESH * restrict pline,const dwg_point_3d * restrict point)23355 dwg_add_VERTEX_MESH (Dwg_Entity_POLYLINE_MESH *restrict pline,
23356                      const dwg_point_3d *restrict point)
23357 {
23358   Dwg_Object_BLOCK_HEADER *restrict blkhdr = dwg_entity_owner ((dwg_ent_generic*)pline);
23359   API_ADD_ENTITY (VERTEX_MESH);
23360   obj->tio.entity->entmode = 0;
23361   obj->tio.entity->ownerhandle = dwg_add_handleref (dwg, 4, dwg_obj_generic_handlevalue (pline), obj);
23362   ADD_CHECK_3DPOINT (point);
23363   _obj->point.x = point->x;
23364   _obj->point.y = point->y;
23365   _obj->point.z = point->z;
23366   _obj->flag = 0x40;
23367   return _obj;
23368 }
23369 
23370 EXPORT Dwg_Entity_POLYLINE_MESH*
dwg_add_POLYLINE_MESH(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const unsigned num_m_verts,const unsigned num_n_verts,const dwg_point_3d * restrict verts)23371 dwg_add_POLYLINE_MESH (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23372                        const unsigned num_m_verts,
23373                        const unsigned num_n_verts,
23374                        const dwg_point_3d *restrict verts)
23375 {
23376   Dwg_Object *pl, *vtx;
23377   Dwg_Entity_POLYLINE_MESH *_pl;
23378   Dwg_Entity_VERTEX_MESH *_vtx;
23379   Dwg_Entity_SEQEND *_seq;
23380 
23381   API_ADD_ENTITY (POLYLINE_MESH);
23382   pl = obj;
23383   _pl = _obj;
23384   _pl->vertex = malloc (num_m_verts * num_n_verts * sizeof (BITCODE_H));
23385   if (!_pl->vertex)
23386     return NULL;
23387   _pl->flag = 16;
23388   _pl->num_m_verts = num_m_verts;
23389   _pl->num_n_verts = num_n_verts;
23390   _pl->num_owned = num_m_verts * num_n_verts;
23391   if (_pl->num_owned)
23392     _pl->has_vertex = 1;
23393   for (unsigned i = 0; i < _pl->num_owned; i++)
23394     {
23395       _vtx = dwg_add_VERTEX_MESH (_pl, &verts[i]);
23396       if (!_vtx)
23397         {
23398         vtx_mesh_err:
23399           LOG_ERROR ("No VERTEX_MESH[%d] added", i);
23400           return NULL;
23401         }
23402       vtx = dwg_obj_generic_to_object (_vtx, &error);
23403       if (!vtx)
23404         goto vtx_mesh_err;
23405       _pl->vertex[i] = dwg_add_handleref (dwg, 3, vtx->handle.value, pl);
23406       if (i == 0)
23407         _pl->first_vertex  = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23408       if (i == _pl->num_owned - 1)
23409         {
23410           vtx->tio.entity->prev_entity = dwg_add_handleref (dwg, 4, vtx->handle.value - 1, vtx);
23411           _pl->last_vertex  = dwg_add_handleref (dwg, 4, vtx->handle.value, NULL);
23412         }
23413     }
23414   _seq = dwg_add_SEQEND ((dwg_ent_generic *)_pl);
23415   if (!_seq)
23416     {
23417       LOG_ERROR ("No SEQEND added");
23418       return NULL;
23419     }
23420   _pl->seqend  = dwg_add_handleref (dwg, 3, dwg_obj_generic_handlevalue (_seq), pl);
23421   pl->tio.entity->next_entity = NULL;
23422   in_postprocess_SEQEND (obj, _pl->num_owned, _pl->vertex);
23423   return _pl;
23424 }
23425 
23426 EXPORT Dwg_Entity_ARC*
dwg_add_ARC(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center,const double radius,const double start_angle,const double end_angle)23427 dwg_add_ARC (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23428              const dwg_point_3d *restrict center,
23429              const double radius,
23430              const double start_angle,
23431              const double end_angle)
23432 {
23433   API_ADD_ENTITY (ARC);
23434   ADD_CHECK_3DPOINT (center);
23435   _obj->center.x    = center->x;
23436   _obj->center.y    = center->y;
23437   _obj->center.z    = center->z;
23438   _obj->radius      = radius;
23439   _obj->start_angle = start_angle;
23440   _obj->end_angle   = end_angle;
23441   ADD_CHECK_ANGLE (_obj->start_angle);
23442   ADD_CHECK_ANGLE (_obj->end_angle);
23443   return _obj;
23444 }
23445 
23446 EXPORT Dwg_Entity_CIRCLE*
dwg_add_CIRCLE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center,const double radius)23447 dwg_add_CIRCLE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23448                 const dwg_point_3d *restrict center,
23449                 const double radius)
23450 {
23451   API_ADD_ENTITY (CIRCLE);
23452   ADD_CHECK_3DPOINT (center);
23453   _obj->center.x    = center->x;
23454   _obj->center.y    = center->y;
23455   _obj->center.z    = center->z;
23456   _obj->radius      = radius;
23457   return _obj;
23458 }
23459 
23460 EXPORT Dwg_Entity_LINE*
dwg_add_LINE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict start_pt,const dwg_point_3d * restrict end_pt)23461 dwg_add_LINE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23462               const dwg_point_3d *restrict start_pt,
23463               const dwg_point_3d *restrict end_pt)
23464 {
23465   API_ADD_ENTITY (LINE);
23466   ADD_CHECK_3DPOINT (start_pt);
23467   ADD_CHECK_3DPOINT (end_pt);
23468   _obj->start.x = start_pt->x;
23469   _obj->start.y = start_pt->y;
23470   _obj->start.z = start_pt->z;
23471   _obj->end.x   = end_pt->x;
23472   _obj->end.y   = end_pt->y;
23473   _obj->end.z   = end_pt->z;
23474   return _obj;
23475 }
23476 
23477 static void
dwg_require_DIMSTYLE_Standard(Dwg_Data * restrict dwg)23478 dwg_require_DIMSTYLE_Standard (Dwg_Data *restrict dwg)
23479 {
23480   if (!(dwg_find_tablehandle_silent (dwg, "Standard", "DIMSTYLE")))
23481     {
23482       Dwg_Object_DIMSTYLE *std = dwg_add_DIMSTYLE (dwg, "Standard");
23483       if (std)
23484         dwg->header_vars.DIMSTYLE = dwg_add_handleref (
23485             dwg, 5, dwg_obj_generic_handlevalue (std), NULL);
23486     }
23487 }
23488 
23489 #define DIMENSION_DEFAULTS                                                    \
23490     _obj->extrusion.z = 1.0;                                                  \
23491     dwg_require_DIMSTYLE_Standard (dwg);                                      \
23492     if (dwg->header_vars.DIMSTYLE)                                            \
23493     _obj->dimstyle = dwg_add_handleref (                                      \
23494         dwg, 5, dwg->header_vars.DIMSTYLE->absolute_ref, NULL)
23495 
23496 EXPORT Dwg_Entity_DIMENSION_ALIGNED*
dwg_add_DIMENSION_ALIGNED(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict xline1_pt,const dwg_point_3d * restrict xline2_pt,const dwg_point_3d * restrict text_midpt)23497 dwg_add_DIMENSION_ALIGNED (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23498                            const dwg_point_3d *restrict xline1_pt,
23499                            const dwg_point_3d *restrict xline2_pt,
23500                            const dwg_point_3d *restrict text_midpt)
23501 {
23502   API_ADD_ENTITY (DIMENSION_ALIGNED);
23503   DIMENSION_DEFAULTS;
23504   ADD_CHECK_3DPOINT (xline1_pt);
23505   ADD_CHECK_3DPOINT (xline2_pt);
23506   ADD_CHECK_3DPOINT (text_midpt);
23507   _obj->text_midpt.x= text_midpt->x;
23508   _obj->text_midpt.y= text_midpt->y;
23509   //_obj->text_midpt.z= text_midpt->z;
23510   _obj->xline1_pt.x = xline1_pt->x;
23511   _obj->xline1_pt.y = xline1_pt->y;
23512   _obj->xline1_pt.z = xline1_pt->z;
23513   _obj->xline2_pt.x = xline2_pt->x;
23514   _obj->xline2_pt.y = xline2_pt->y;
23515   _obj->xline2_pt.z = xline2_pt->z;
23516   // TODO calc oblique_angle
23517   return _obj;
23518 }
23519 
23520 EXPORT Dwg_Entity_DIMENSION_ANG2LN* /* DimAngular */
dwg_add_DIMENSION_ANG2LN(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center_pt,const dwg_point_3d * restrict xline1end_pt,const dwg_point_3d * restrict xline2end_pt,const dwg_point_3d * restrict text_midpt)23521 dwg_add_DIMENSION_ANG2LN (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23522                           const dwg_point_3d *restrict center_pt,
23523                           const dwg_point_3d *restrict xline1end_pt,
23524                           const dwg_point_3d *restrict xline2end_pt,
23525                           const dwg_point_3d *restrict text_midpt)
23526 {
23527   API_ADD_ENTITY (DIMENSION_ANG2LN);
23528   DIMENSION_DEFAULTS;
23529   ADD_CHECK_3DPOINT (center_pt);
23530   ADD_CHECK_3DPOINT (xline1end_pt);
23531   ADD_CHECK_3DPOINT (xline2end_pt);
23532   ADD_CHECK_3DPOINT (text_midpt);
23533   _obj->def_pt.x     = center_pt->x;
23534   _obj->def_pt.y     = center_pt->y;
23535   _obj->def_pt.z     = center_pt->z;
23536   _obj->text_midpt.x = text_midpt->x;
23537   _obj->text_midpt.y = text_midpt->y;
23538   //_obj->text_midpt.z= text_midpt->z;
23539   // TODO calc xline1start_pt, xline2start_pt
23540   _obj->xline1end_pt.x = xline1end_pt->x;
23541   _obj->xline1end_pt.y = xline1end_pt->y;
23542   _obj->xline1end_pt.z = xline1end_pt->z;
23543   _obj->xline2end_pt.x = xline2end_pt->x;
23544   _obj->xline2end_pt.y = xline2end_pt->y;
23545   _obj->xline2end_pt.z = xline2end_pt->z;
23546   return _obj;
23547 }
23548 
23549 EXPORT Dwg_Entity_DIMENSION_ANG3PT*
dwg_add_DIMENSION_ANG3PT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center_pt,const dwg_point_3d * restrict xline1_pt,const dwg_point_3d * restrict xline2_pt,const dwg_point_3d * restrict text_midpt)23550 dwg_add_DIMENSION_ANG3PT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23551                           const dwg_point_3d *restrict center_pt,
23552                           const dwg_point_3d *restrict xline1_pt,
23553                           const dwg_point_3d *restrict xline2_pt,
23554                           const dwg_point_3d *restrict text_midpt)
23555 {
23556   API_ADD_ENTITY (DIMENSION_ANG3PT);
23557   DIMENSION_DEFAULTS;
23558   ADD_CHECK_3DPOINT (center_pt);
23559   ADD_CHECK_3DPOINT (xline1_pt);
23560   ADD_CHECK_3DPOINT (xline2_pt);
23561   ADD_CHECK_3DPOINT (text_midpt);
23562   _obj->center_pt.x  = center_pt->x;
23563   _obj->center_pt.y  = center_pt->y;
23564   _obj->center_pt.z  = center_pt->z;
23565   _obj->text_midpt.x = text_midpt->x;
23566   _obj->text_midpt.y = text_midpt->y;
23567   //_obj->text_midpt.z = text_midpt->z;
23568   _obj->xline1_pt.x  = xline1_pt->x;
23569   _obj->xline1_pt.y  = xline1_pt->y;
23570   _obj->xline1_pt.z  = xline1_pt->z;
23571   _obj->xline2_pt.x  = xline2_pt->x;
23572   _obj->xline2_pt.y  = xline2_pt->y;
23573   _obj->xline2_pt.z  = xline2_pt->z;
23574   return _obj;
23575 }
23576 
23577 EXPORT Dwg_Entity_DIMENSION_DIAMETER*
dwg_add_DIMENSION_DIAMETER(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict chord_pt,const dwg_point_3d * restrict far_chord_pt,const double leader_len)23578 dwg_add_DIMENSION_DIAMETER (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23579                             const dwg_point_3d *restrict chord_pt,
23580                             const dwg_point_3d *restrict far_chord_pt,
23581                             const double leader_len)
23582 {
23583   API_ADD_ENTITY (DIMENSION_DIAMETER);
23584   DIMENSION_DEFAULTS;
23585   ADD_CHECK_3DPOINT (chord_pt);
23586   ADD_CHECK_3DPOINT (far_chord_pt);
23587   ADD_CHECK_DOUBLE (leader_len);
23588   _obj->def_pt.x       = far_chord_pt->x;
23589   _obj->def_pt.y       = far_chord_pt->y;
23590   _obj->def_pt.z       = far_chord_pt->z;
23591   _obj->first_arc_pt.x = chord_pt->x;
23592   _obj->first_arc_pt.y = chord_pt->y;
23593   _obj->first_arc_pt.z = chord_pt->z;
23594   _obj->leader_len     = leader_len;
23595   return _obj;
23596 }
23597 
23598 EXPORT Dwg_Entity_DIMENSION_ORDINATE*
dwg_add_DIMENSION_ORDINATE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict feature_location_pt,const dwg_point_3d * restrict leader_endpt,const bool use_x_axis)23599 dwg_add_DIMENSION_ORDINATE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23600                             const dwg_point_3d *restrict feature_location_pt,
23601                             const dwg_point_3d *restrict leader_endpt,
23602                             const bool use_x_axis)
23603 {
23604   API_ADD_ENTITY (DIMENSION_ORDINATE);
23605   DIMENSION_DEFAULTS;
23606   ADD_CHECK_3DPOINT (feature_location_pt);
23607   ADD_CHECK_3DPOINT (leader_endpt);
23608   _obj->feature_location_pt.x = feature_location_pt->x;
23609   _obj->feature_location_pt.y = feature_location_pt->y;
23610   _obj->feature_location_pt.z = feature_location_pt->z;
23611   _obj->leader_endpt.x = leader_endpt->x;
23612   _obj->leader_endpt.y = leader_endpt->y;
23613   _obj->leader_endpt.z = leader_endpt->z;
23614   _obj->flag2          = (BITCODE_RC)use_x_axis;
23615   return _obj;
23616 }
23617 
23618 EXPORT Dwg_Entity_DIMENSION_RADIUS*
dwg_add_DIMENSION_RADIUS(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center_pt,const dwg_point_3d * restrict chord_pt,const double leader_len)23619 dwg_add_DIMENSION_RADIUS (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23620                           const dwg_point_3d *restrict center_pt,
23621                           const dwg_point_3d *restrict chord_pt,
23622                           const double leader_len)
23623 {
23624   API_ADD_ENTITY (DIMENSION_RADIUS);
23625   DIMENSION_DEFAULTS;
23626   ADD_CHECK_3DPOINT (center_pt);
23627   ADD_CHECK_3DPOINT (chord_pt);
23628   ADD_CHECK_DOUBLE (leader_len);
23629   _obj->def_pt.x       = center_pt->x;
23630   _obj->def_pt.y       = center_pt->y;
23631   _obj->def_pt.z       = center_pt->z;
23632   _obj->first_arc_pt.x = chord_pt->x;
23633   _obj->first_arc_pt.y = chord_pt->y;
23634   _obj->first_arc_pt.z = chord_pt->z;
23635   _obj->leader_len     = leader_len;
23636   return _obj;
23637 }
23638 
23639 EXPORT Dwg_Entity_DIMENSION_LINEAR* /* Rotated */
dwg_add_DIMENSION_LINEAR(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict xline1_pt,const dwg_point_3d * restrict xline2_pt,const dwg_point_3d * restrict def_pt,const double rotation_angle)23640 dwg_add_DIMENSION_LINEAR (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23641                           const dwg_point_3d *restrict xline1_pt,
23642                           const dwg_point_3d *restrict xline2_pt,
23643                           const dwg_point_3d *restrict def_pt,
23644                           const double rotation_angle)
23645 {
23646   API_ADD_ENTITY (DIMENSION_LINEAR);
23647   DIMENSION_DEFAULTS;
23648   ADD_CHECK_3DPOINT (xline1_pt);
23649   ADD_CHECK_3DPOINT (xline2_pt);
23650   ADD_CHECK_3DPOINT (def_pt);
23651   _obj->def_pt.x    = def_pt->x; // dimline_pt
23652   _obj->def_pt.y    = def_pt->y;
23653   _obj->def_pt.z    = def_pt->z;
23654   _obj->xline1_pt.x = xline1_pt->x;
23655   _obj->xline1_pt.y = xline1_pt->y;
23656   _obj->xline1_pt.z = xline1_pt->z;
23657   _obj->xline2_pt.x = xline2_pt->x;
23658   _obj->xline2_pt.y = xline2_pt->y;
23659   _obj->xline2_pt.z = xline2_pt->z;
23660   _obj->dim_rotation= rotation_angle;
23661   ADD_CHECK_ANGLE (_obj->dim_rotation);
23662   // TODO calc oblique_angle
23663   return _obj;
23664 }
23665 
23666 EXPORT Dwg_Entity_POINT*
dwg_add_POINT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict pt)23667 dwg_add_POINT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23668                const dwg_point_3d *restrict pt)
23669 {
23670   API_ADD_ENTITY (POINT);
23671   ADD_CHECK_3DPOINT (pt);
23672   _obj->x = pt->x;
23673   _obj->y = pt->y;
23674   _obj->z = pt->z;
23675   return _obj;
23676 }
23677 
23678 EXPORT Dwg_Entity__3DFACE*
dwg_add_3DFACE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict pt1,const dwg_point_3d * restrict pt2,const dwg_point_3d * restrict pt3,const dwg_point_3d * restrict pt4)23679 dwg_add_3DFACE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23680                 const dwg_point_3d *restrict pt1,
23681                 const dwg_point_3d *restrict pt2,
23682                 const dwg_point_3d *restrict pt3,
23683                 const dwg_point_3d *restrict pt4 /* may be NULL */)
23684 {
23685   API_ADD_ENTITY (_3DFACE);
23686   ADD_CHECK_3DPOINT (pt1);
23687   ADD_CHECK_3DPOINT (pt2);
23688   ADD_CHECK_3DPOINT (pt3);
23689   _obj->corner1.x = pt1->x;
23690   _obj->corner1.y = pt1->y;
23691   _obj->corner1.z = pt1->z;
23692   _obj->corner2.x = pt2->x;
23693   _obj->corner2.y = pt2->y;
23694   _obj->corner2.z = pt2->z;
23695   _obj->corner3.x = pt3->x;
23696   _obj->corner3.y = pt3->y;
23697   _obj->corner3.z = pt3->z;
23698   if (pt4)
23699     {
23700       ADD_CHECK_3DPOINT (pt4);
23701       _obj->corner4.x = pt4->x;
23702       _obj->corner4.y = pt4->y;
23703       _obj->corner4.z = pt4->z;
23704     }
23705   else
23706     {
23707       _obj->corner4.x = pt3->x;
23708       _obj->corner4.y = pt3->y;
23709       _obj->corner4.z = pt3->z;
23710     }
23711   if (pt1->z == 0.0 && pt2->z == 0.0 && pt3->z == 0.0 && (!pt4 || pt4->z == 0.0))
23712     _obj->z_is_zero = 1;
23713   _obj->has_no_flags = 1; // set invis_flags extra
23714   return _obj;
23715 }
23716 
23717 EXPORT Dwg_Entity_SOLID*
dwg_add_SOLID(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict pt1,const dwg_point_2d * restrict pt2,const dwg_point_2d * restrict pt3,const dwg_point_2d * restrict pt4)23718 dwg_add_SOLID (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23719                const dwg_point_3d *restrict pt1,
23720                const dwg_point_2d *restrict pt2,
23721                const dwg_point_2d *restrict pt3,
23722                const dwg_point_2d *restrict pt4)
23723 {
23724   API_ADD_ENTITY (SOLID);
23725   ADD_CHECK_3DPOINT (pt1);
23726   ADD_CHECK_2DPOINT (pt2);
23727   ADD_CHECK_2DPOINT (pt3);
23728   ADD_CHECK_2DPOINT (pt4);
23729   _obj->corner1.x = pt1->x;
23730   _obj->corner1.y = pt1->y;
23731   _obj->elevation = pt1->z;
23732   _obj->corner2.x = pt2->x;
23733   _obj->corner2.y = pt2->y;
23734   _obj->corner3.x = pt3->x;
23735   _obj->corner3.y = pt3->y;
23736   _obj->corner4.x = pt4->x;
23737   _obj->corner4.y = pt4->y;
23738   return _obj;
23739 }
23740 
23741 EXPORT Dwg_Entity_TRACE*
dwg_add_TRACE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict pt1,const dwg_point_2d * restrict pt2,const dwg_point_2d * restrict pt3,const dwg_point_2d * restrict pt4)23742 dwg_add_TRACE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23743                const dwg_point_3d *restrict pt1,
23744                const dwg_point_2d *restrict pt2,
23745                const dwg_point_2d *restrict pt3,
23746                const dwg_point_2d *restrict pt4)
23747 {
23748   API_ADD_ENTITY (TRACE);
23749   ADD_CHECK_3DPOINT (pt1);
23750   ADD_CHECK_2DPOINT (pt2);
23751   ADD_CHECK_2DPOINT (pt3);
23752   ADD_CHECK_2DPOINT (pt4);
23753   _obj->corner1.x = pt1->x;
23754   _obj->corner1.y = pt1->y;
23755   _obj->elevation = pt1->z;
23756   _obj->corner2.x = pt2->x;
23757   _obj->corner2.y = pt2->y;
23758   _obj->corner3.x = pt3->x;
23759   _obj->corner3.y = pt3->y;
23760   _obj->corner4.x = pt4->x;
23761   _obj->corner4.y = pt4->y;
23762   return _obj;
23763 }
23764 
23765 EXPORT Dwg_Entity_SHAPE*
dwg_add_SHAPE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict name,const dwg_point_3d * restrict ins_pt,const double scale,const double oblique_angle)23766 dwg_add_SHAPE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23767                const char *restrict name,
23768                const dwg_point_3d *restrict ins_pt,
23769                const double scale,
23770                const double oblique_angle)
23771 {
23772   API_ADD_ENTITY (SHAPE);
23773   ADD_CHECK_3DPOINT (ins_pt);
23774   ADD_CHECK_DOUBLE (scale);
23775   _obj->ins_pt.x      = ins_pt->x;
23776   _obj->ins_pt.y      = ins_pt->y;
23777   _obj->ins_pt.z      = ins_pt->z;
23778   _obj->scale         = scale;
23779   _obj->oblique_angle = oblique_angle;
23780   ADD_CHECK_ANGLE (_obj->oblique_angle);
23781   _obj->width_factor  = 1.0;
23782   if (dwg->header_vars.TEXTSTYLE && dwg->header_vars.TEXTSTYLE->absolute_ref)
23783     {
23784       _obj->style = dwg_add_handleref (dwg, 5, dwg->header_vars.TEXTSTYLE->absolute_ref, NULL);
23785       _obj->style_id = 1; // TODO STYLE_CONTROL index + 1
23786     }
23787   else
23788     _obj->style_id = 1; // Standard
23789   return _obj;
23790 }
23791 
23792 EXPORT Dwg_Entity_VIEWPORT*
dwg_add_VIEWPORT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict name)23793 dwg_add_VIEWPORT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23794                   const char *restrict name)
23795 {
23796   API_ADD_ENTITY (VIEWPORT);
23797   // TODO get defaults from name
23798   _obj->lens_length = 50.0;
23799   _obj->VIEWDIR.z = 1.0;
23800   _obj->center.x = _obj->VIEWCTR.x = 133.349991;
23801   _obj->center.y = _obj->VIEWCTR.y = 101.599997;
23802   _obj->width = 428.291613;
23803   _obj->height = _obj->VIEWSIZE = 228.422194;
23804   _obj->circle_zoom = 1000;
23805   _obj->status_flag = 32800;
23806   _obj->GRIDUNIT.x = 10.0;
23807   _obj->GRIDUNIT.y = 10.0;
23808   _obj->SNAPUNIT.x = 10.0;
23809   _obj->SNAPUNIT.y = 10.0;
23810   _obj->UCSVP = 1;
23811   _obj->ucsxdir.x = 1.0;
23812   _obj->ucsydir.y = 1.0;
23813   return _obj;
23814 }
23815 
23816 EXPORT Dwg_Entity_ELLIPSE*
dwg_add_ELLIPSE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center,const double major_axis,const double axis_ratio)23817 dwg_add_ELLIPSE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23818                const dwg_point_3d *restrict center,
23819                const double major_axis,
23820                const double axis_ratio)
23821 {
23822   API_ADD_ENTITY (ELLIPSE);
23823   ADD_CHECK_3DPOINT (center);
23824   ADD_CHECK_DOUBLE (major_axis);
23825   ADD_CHECK_DOUBLE (axis_ratio); // Only (0 - 1], ie. RadiusRatio
23826   _obj->center.x     = center->x;
23827   _obj->center.y     = center->y;
23828   _obj->center.z     = center->z;
23829   _obj->sm_axis.x    = major_axis;
23830   _obj->sm_axis.y    = major_axis;
23831   _obj->sm_axis.z    = center->z; // Error 150 (eGeneralModelingFailure) when not co-planar
23832   _obj->axis_ratio   = axis_ratio;
23833   if (axis_ratio > 1.0 || axis_ratio <= 0.0)
23834     {
23835       LOG_ERROR ("Illegal ELLIPSE.axis_ratio %f. Set to 1.0", axis_ratio);
23836       _obj->axis_ratio = 1.0;
23837     }
23838   if (major_axis == 0.0)
23839     {
23840       LOG_ERROR ("Illegal ELLIPSE.major_axis 0.0, needs to be != 0");
23841       return NULL;
23842     }
23843   _obj->end_angle    = M_PI * 2.0;
23844   return _obj;
23845 }
23846 
23847 EXPORT Dwg_Entity_SPLINE*
dwg_add_SPLINE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const int num_fit_pts,const dwg_point_3d * restrict fit_pts,const dwg_point_3d * restrict beg_tan_vec,const dwg_point_3d * restrict end_tan_vec)23848 dwg_add_SPLINE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23849                 const int num_fit_pts,
23850                 const dwg_point_3d *restrict fit_pts,
23851                 const dwg_point_3d *restrict beg_tan_vec,
23852                 const dwg_point_3d *restrict end_tan_vec)
23853 {
23854   API_ADD_ENTITY (SPLINE);
23855   ADD_CHECK_3DPOINT (beg_tan_vec);
23856   ADD_CHECK_3DPOINT (end_tan_vec);
23857   _obj->beg_tan_vec.x = beg_tan_vec->x;
23858   _obj->beg_tan_vec.y = beg_tan_vec->y;
23859   _obj->beg_tan_vec.z = beg_tan_vec->z;
23860   _obj->end_tan_vec.x = end_tan_vec->x;
23861   _obj->end_tan_vec.y = end_tan_vec->y;
23862   _obj->end_tan_vec.z = end_tan_vec->z;
23863   _obj->num_fit_pts = (BITCODE_BL)num_fit_pts;
23864   assert (sizeof (BITCODE_3BD) == sizeof (dwg_point_3d));
23865   _obj->fit_pts = malloc (num_fit_pts * sizeof(BITCODE_3BD));
23866   memcpy (_obj->fit_pts, fit_pts, num_fit_pts * sizeof(BITCODE_3BD));
23867   return _obj;
23868 }
23869 
23870 EXPORT Dwg_Entity_REGION*
dwg_add_REGION(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * acis_data)23871 dwg_add_REGION (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23872                 const char *acis_data)
23873 {
23874   const int len = strlen (acis_data);
23875   unsigned j;
23876   int acis_data_idx = 0;
23877   API_ADD_ENTITY (REGION);
23878   _obj->num_blocks = (int)(len / 4096);
23879   if (len % 4096)
23880     _obj->num_blocks++;
23881   j = _obj->num_blocks;
23882   _obj->acis_data = (BITCODE_RC*)strdup (acis_data);
23883   _obj->block_size = calloc (j + 1, sizeof (BITCODE_BL));
23884   _obj->encr_sat_data = calloc (j + 1, sizeof (char*));
23885   _obj->version = 1;
23886   _obj->unknown = 1;
23887   for (unsigned i = 0; i < _obj->num_blocks; i++)
23888     {
23889       if (i == j - 1)
23890         _obj->block_size[i] = len % 4096;
23891       else
23892         _obj->block_size[i] = 4096;
23893       _obj->encr_sat_data[i] = dwg_encrypt_SAT1 (
23894           _obj->block_size[i], &_obj->acis_data[acis_data_idx], &acis_data_idx);
23895     }
23896   return _obj;
23897 }
23898 
23899 EXPORT Dwg_Entity__3DSOLID*
dwg_add_3DSOLID(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * acis_data)23900 dwg_add_3DSOLID (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23901                 const char *acis_data)
23902 {
23903   const int len = strlen (acis_data);
23904   unsigned j;
23905   int acis_data_idx = 0;
23906   API_ADD_ENTITY (_3DSOLID);
23907   _obj->num_blocks = (int)(len / 4096);
23908   if (len % 4096)
23909     _obj->num_blocks++;
23910   j = _obj->num_blocks;
23911   _obj->acis_data = (BITCODE_RC*)strdup (acis_data);
23912   _obj->block_size = calloc (j + 1, sizeof (BITCODE_BL));
23913   _obj->encr_sat_data = calloc (j + 1, sizeof (char*));
23914   _obj->version = 1;
23915   _obj->unknown = 1;
23916   for (unsigned i = 0; i < j; i++)
23917     {
23918       if (i == j - 1)
23919         _obj->block_size[i] = len % 4096;
23920       else
23921         _obj->block_size[i] = 4096;
23922       _obj->encr_sat_data[i] = dwg_encrypt_SAT1 (
23923           _obj->block_size[i], &_obj->acis_data[acis_data_idx], &acis_data_idx);
23924     }
23925   //_obj->encr_sat_data[j] = NULL;
23926   //_obj->block_size[j] = 0;
23927   return _obj;
23928 }
23929 
23930 EXPORT Dwg_Entity_BODY*
dwg_add_BODY(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * acis_data)23931 dwg_add_BODY (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23932               const char *acis_data)
23933 {
23934   const int len = strlen (acis_data);
23935   unsigned j;
23936   int acis_data_idx = 0;
23937   API_ADD_ENTITY (BODY);
23938   _obj->num_blocks = (int)(len / 4096);
23939   if (len % 4096)
23940     _obj->num_blocks++;
23941   j = _obj->num_blocks;
23942   _obj->acis_data = (BITCODE_RC*)strdup (acis_data);
23943   _obj->block_size = calloc (j + 1, sizeof (BITCODE_BL));
23944   _obj->encr_sat_data = calloc (j + 1, sizeof (char*));
23945   _obj->version = 1;
23946   _obj->unknown = 1;
23947   for (unsigned i = 0; i < _obj->num_blocks; i++)
23948     {
23949       if (i == j - 1)
23950         _obj->block_size[i] = len % 4096;
23951       else
23952         _obj->block_size[i] = 4096;
23953       _obj->encr_sat_data[i] = dwg_encrypt_SAT1 (
23954           _obj->block_size[i], &_obj->acis_data[acis_data_idx], &acis_data_idx);
23955     }
23956   return _obj;
23957 }
23958 
23959 EXPORT Dwg_Entity_RAY*
dwg_add_RAY(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict point,const dwg_point_3d * restrict vector)23960 dwg_add_RAY (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23961              const dwg_point_3d *restrict point,
23962              const dwg_point_3d *restrict vector) /* different to VBA */
23963 {
23964   API_ADD_ENTITY (RAY);
23965   ADD_CHECK_3DPOINT (point);
23966   ADD_CHECK_3DPOINT (vector);
23967   _obj->point.x  = point->x;
23968   _obj->point.y  = point->y;
23969   _obj->point.z  = point->z;
23970   dwg_geom_normalize ((dwg_point_3d*)&_obj->vector, *vector);
23971   return _obj;
23972 }
23973 
23974 EXPORT Dwg_Entity_XLINE*
dwg_add_XLINE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict point,const dwg_point_3d * restrict vector)23975 dwg_add_XLINE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
23976              const dwg_point_3d *restrict point,
23977              const dwg_point_3d *restrict vector) /* different to VBA */
23978 {
23979   API_ADD_ENTITY (XLINE);
23980   ADD_CHECK_3DPOINT (point);
23981   ADD_CHECK_3DPOINT (vector);
23982   _obj->point.x  = point->x;
23983   _obj->point.y  = point->y;
23984   _obj->point.z  = point->z;
23985   dwg_geom_normalize ((dwg_point_3d*)&_obj->vector, *vector);
23986   return _obj;
23987 }
23988 
23989 /* The name is the NOD entry. On NULL this is the NOD 0.1.C ("Named Object Dictionary") */
23990 EXPORT Dwg_Object_DICTIONARY*
dwg_add_DICTIONARY(Dwg_Data * restrict dwg,const char * restrict name,const char * restrict key,const unsigned long absolute_ref)23991 dwg_add_DICTIONARY (Dwg_Data *restrict dwg,
23992                     const char *restrict name, /* the NOD entry */
23993                     const char *restrict key,  /* maybe NULL */
23994                     const unsigned long absolute_ref)
23995 {
23996   Dwg_Object* nod;
23997   API_ADD_OBJECT (DICTIONARY);
23998   if (key)
23999     {
24000       _obj->numitems = 1;
24001       _obj->texts = (BITCODE_T*)calloc (1, sizeof (BITCODE_T));
24002       _obj->itemhandles = (BITCODE_H*)calloc (1, sizeof (BITCODE_H));
24003       _obj->texts[0] = dwg_add_u8_input (dwg, key);
24004       _obj->itemhandles[0] = dwg_add_handleref (dwg, 2, absolute_ref, NULL);
24005     }
24006   if (name)
24007     {
24008       nod = dwg_get_first_object (dwg, DWG_TYPE_DICTIONARY);
24009       if (nod)
24010         {
24011           dwg_add_DICTIONARY_item (nod->tio.object->tio.DICTIONARY, name, obj->handle.value);
24012           /* owner is relative, reactor absolute */
24013           obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, nod->handle.value, obj);
24014           if (!obj->tio.object->num_reactors)
24015             add_obj_reactor (obj->tio.object, nod->handle.value);
24016         }
24017     }
24018   else /* not a direct NOD item */
24019     {
24020       obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, 0, NULL);
24021       _obj->cloning = 1;
24022     }
24023   return _obj;
24024 }
24025 
24026 EXPORT Dwg_Object_DICTIONARY*
dwg_add_DICTIONARY_item(Dwg_Object_DICTIONARY * _obj,const char * restrict key,const unsigned long absolute_ref)24027 dwg_add_DICTIONARY_item (Dwg_Object_DICTIONARY* _obj,
24028                          const char *restrict key,
24029                          const unsigned long absolute_ref)
24030 {
24031   int error;
24032   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
24033   Dwg_Data *dwg = (obj && !error) ? obj->parent : NULL;
24034   if (!dwg)
24035     {
24036       LOG_ERROR ("dwg_add_DICTIONARY_item: no obj from DICTIONARY");
24037       return NULL;
24038     }
24039   if (!_obj->numitems)
24040     {
24041       _obj->texts = (char **)calloc (1, sizeof (BITCODE_T));
24042       _obj->itemhandles = (BITCODE_H *)calloc (1, sizeof (BITCODE_H));
24043     }
24044   else
24045     {
24046       // check if text already exists, and if so just replace handle.
24047       for (unsigned i = 0; i < _obj->numitems; i++)
24048         {
24049           char **texts = _obj->texts;
24050           BITCODE_H *hdlv = _obj->itemhandles;
24051           if (!hdlv || !texts || !texts[i])
24052             continue;
24053           if (IS_FROM_TU_DWG (dwg))
24054             {
24055               if (bit_eq_TU (key, (BITCODE_TU)texts[i]))
24056                 {
24057                   _obj->itemhandles[i] = dwg_add_handleref (dwg, 2, absolute_ref, NULL);
24058                   LOG_TRACE ("replace DICTIONARY_item %s=> " FORMAT_REF "\n",
24059                              key, ARGS_REF (_obj->itemhandles[i]));
24060                   return _obj;
24061                 }
24062             }
24063           else
24064             {
24065               if (strEQ (key, texts[i]))
24066                 {
24067                   _obj->itemhandles[i] = dwg_add_handleref (dwg, 2, absolute_ref, NULL);
24068                   LOG_TRACE ("replace DICTIONARY_item %s => " FORMAT_REF "\n",
24069                              key, ARGS_REF (_obj->itemhandles[i]));
24070                   return _obj;
24071                 }
24072             }
24073         }
24074       // not found:
24075       _obj->texts = (char **)realloc (
24076           _obj->texts, (_obj->numitems + 1) * sizeof (BITCODE_T));
24077       _obj->itemhandles = (BITCODE_H *)realloc (
24078           _obj->itemhandles, (_obj->numitems + 1) * sizeof (BITCODE_H));
24079     }
24080 
24081   _obj->texts[_obj->numitems] = dwg_add_u8_input (dwg, key);
24082   _obj->itemhandles[_obj->numitems] = dwg_add_handleref (dwg, 2, absolute_ref, NULL);
24083   LOG_TRACE ("add DICTIONARY_item %s => " FORMAT_REF "\n", key,
24084              ARGS_REF (_obj->itemhandles[_obj->numitems]));
24085   _obj->numitems++;
24086   return _obj;
24087 }
24088 
24089 //dwg_add_DICTIONARYWDFLT (dwg, "Normal", handle (0xF));
24090 EXPORT Dwg_Object_DICTIONARYWDFLT*
dwg_add_DICTIONARYWDFLT(Dwg_Data * restrict dwg,const char * restrict name,const char * restrict key,const unsigned long absolute_ref)24091 dwg_add_DICTIONARYWDFLT (Dwg_Data *restrict dwg,
24092                          const char *restrict name, /* the NOD entry */
24093                          const char *restrict key, /* maybe NULL */
24094                          const unsigned long absolute_ref)
24095 {
24096   Dwg_Object* nod;
24097   {
24098     REQUIRE_CLASS ("ACDBDICTIONARYWDFLT");
24099   }
24100   {
24101     API_ADD_OBJECT (DICTIONARYWDFLT);
24102     if (key)
24103       {
24104         _obj->numitems = 1;
24105         _obj->texts = (BITCODE_T*)calloc (1, sizeof (BITCODE_T));
24106         _obj->itemhandles = (BITCODE_H*)calloc (1, sizeof (BITCODE_H));
24107         _obj->texts[0] = dwg_add_u8_input (dwg, key);
24108         _obj->itemhandles[0] = dwg_add_handleref (dwg, 2, absolute_ref, NULL);
24109       }
24110     if (absolute_ref)
24111       {
24112         _obj->cloning = 1;
24113         _obj->defaultid = dwg_add_handleref (dwg, 5, absolute_ref, obj);
24114       }
24115 
24116     if (name)
24117       {
24118         nod = dwg_get_first_object (dwg, DWG_TYPE_DICTIONARY);
24119         if (nod)
24120           {
24121             dwg_add_DICTIONARY_item (nod->tio.object->tio.DICTIONARY, name, obj->handle.value);
24122             /* owner is relative, reactor absolute */
24123             obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, nod->handle.value, obj);
24124             if (!obj->tio.object->num_reactors)
24125               add_obj_reactor (obj->tio.object, nod->handle.value);
24126           }
24127       }
24128     else /* not a direct NOD item */
24129       {
24130         obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, 0, NULL);
24131         _obj->cloning = 1;
24132       }
24133 
24134     return _obj;
24135   }
24136 }
24137 
24138 EXPORT Dwg_Entity_OLE2FRAME*
dwg_add_OLE2FRAME(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict pt1,const dwg_point_3d * restrict pt2)24139 dwg_add_OLE2FRAME (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24140                    const dwg_point_3d *restrict pt1,
24141                    const dwg_point_3d *restrict pt2)
24142 {
24143   //const Dwg_Object_Ref *pspace =  dwg_paper_space_ref (dwg);
24144   API_ADD_ENTITY (OLE2FRAME);
24145   _obj->pt1.x   = pt1->x;
24146   _obj->pt1.y   = pt1->y;
24147   _obj->pt1.z   = pt1->z;
24148   _obj->pt2.x   = pt2->x;
24149   _obj->pt2.y   = pt2->y;
24150   _obj->pt2.z   = pt2->z;
24151   _obj->oleversion = 2;
24152   if (strEQ (blkhdr->name, "*PAPER_SPACE"))
24153     _obj->mode = 1;
24154   return _obj;
24155 }
24156 
24157 EXPORT Dwg_Entity_MTEXT*
dwg_add_MTEXT(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict ins_pt,const double rect_width,const char * restrict text)24158 dwg_add_MTEXT (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24159                const dwg_point_3d *restrict ins_pt,
24160                const double rect_width,
24161                const char *restrict text)
24162 {
24163   API_ADD_ENTITY (MTEXT);
24164   _obj->text       = dwg_add_u8_input (dwg, text);
24165   ADD_CHECK_3DPOINT (ins_pt);
24166   ADD_CHECK_DOUBLE (rect_width);
24167   _obj->ins_pt.x   = ins_pt->x;
24168   _obj->ins_pt.y   = ins_pt->y;
24169   _obj->ins_pt.z   = ins_pt->z;
24170   _obj->rect_width = rect_width;
24171   // defaults:
24172   _obj->x_axis_dir.x = 1.0;
24173   _obj->linespace_style = 1;
24174   _obj->linespace_factor = 1.0;
24175   _obj->text_height = dwg->header_vars.TEXTSIZE;
24176   _obj->extents_height = dwg->header_vars.TEXTSIZE;
24177   _obj->extents_width = _obj->rect_width;
24178   _obj->attachment = 1;
24179   _obj->flow_dir = 1;
24180   if (dwg->header_vars.TEXTSTYLE)
24181     _obj->style = dwg_add_handleref (
24182         dwg, 5, dwg->header_vars.TEXTSTYLE->absolute_ref, NULL);
24183   return _obj;
24184 }
24185 
24186 EXPORT Dwg_Entity_LEADER*
dwg_add_LEADER(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const unsigned num_points,const dwg_point_3d * restrict points,const Dwg_Entity_MTEXT * restrict associated_annotation,const unsigned type)24187 dwg_add_LEADER (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24188                 const unsigned num_points,
24189                 const dwg_point_3d *restrict points,
24190                 const Dwg_Entity_MTEXT *restrict associated_annotation, /* maybe NULL */
24191                 const unsigned type)
24192 {
24193   API_ADD_ENTITY (LEADER);
24194   if (!num_points)
24195     return NULL;
24196   _obj->points = calloc (num_points, sizeof (BITCODE_3BD));
24197   _obj->num_points = num_points;
24198   for (unsigned i = 0; i < num_points; i++)
24199     {
24200       ADD_CHECK_DOUBLE (points[i].x);
24201       ADD_CHECK_DOUBLE (points[i].y);
24202       ADD_CHECK_DOUBLE (points[i].z);
24203       _obj->points[i].x = points[i].x;
24204       _obj->points[i].y = points[i].y;
24205       _obj->points[i].z = points[i].z;
24206     }
24207   _obj->origin.x = points[0].x;
24208   _obj->origin.y = points[0].y;
24209   _obj->origin.z = points[0].z;
24210   // TODO type => path_type + annot_type + arrowhead_on
24211   // TODO check more valid types
24212   if (associated_annotation)
24213     {
24214       BITCODE_H annotative;
24215       Dwg_Object *o = dwg_obj_generic_to_object (associated_annotation, &error);
24216       if (error || !o || o->fixedtype != DWG_TYPE_MTEXT)
24217         {
24218           LOG_ERROR ("Invalid associated_annotation object");
24219           return NULL;
24220         }
24221       _obj->annot_type = 1;
24222       _obj->associated_annotation =
24223         dwg_add_handleref (dwg, 5, dwg_obj_generic_handlevalue ((void*)associated_annotation), obj);
24224       add_obj_reactor (o->tio.object, obj->handle.value);
24225       // use DIMSTYLE "Annotative"
24226       annotative = dwg_find_tablehandle (dwg, "Annotative", "DIMSTYLE");
24227       if (annotative)
24228         _obj->dimstyle
24229             = dwg_add_handleref (dwg, 5, annotative->absolute_ref, NULL);
24230       else
24231         { // create it
24232           Dwg_Object_DIMSTYLE *annot
24233               = dwg_add_DIMSTYLE (dwg, (const BITCODE_T) "Annotative");
24234           if (annot)
24235             _obj->dimstyle = dwg_add_handleref (
24236                 dwg, 5, dwg_obj_generic_handlevalue (annot), NULL);
24237         }
24238     }
24239   // defaults:
24240   _obj->x_direction.x = 1.0;
24241   if (!_obj->dimstyle && dwg->header_vars.DIMSTYLE)
24242     _obj->dimstyle = dwg_add_handleref (
24243         dwg, 5, dwg->header_vars.DIMSTYLE->absolute_ref, NULL);
24244   _obj->dimgap = dwg->header_vars.DIMGAP;
24245   _obj->box_height = dwg->header_vars.DIMTXT;
24246   _obj->endptproj.y = -(_obj->box_height / 2.0);
24247   // TODO more calcs ...
24248   _obj->box_width = 0.82;
24249   _obj->arrowhead_type = 8;
24250   return _obj;
24251 }
24252 
24253 EXPORT Dwg_Entity_TOLERANCE*
dwg_add_TOLERANCE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict text_value,const dwg_point_3d * restrict ins_pt,const dwg_point_3d * restrict x_direction)24254 dwg_add_TOLERANCE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24255                    const char *restrict text_value,
24256                    const dwg_point_3d *restrict ins_pt,
24257                    const dwg_point_3d *restrict x_direction /* maybe NULL */)
24258 {
24259   API_ADD_ENTITY (TOLERANCE);
24260   _obj->text_value = dwg_add_u8_input (dwg, text_value);
24261   ADD_CHECK_3DPOINT (ins_pt);
24262   _obj->ins_pt.x   = ins_pt->x;
24263   _obj->ins_pt.y   = ins_pt->y;
24264   _obj->ins_pt.z   = ins_pt->z;
24265   if (x_direction)
24266     {
24267       ADD_CHECK_3DPOINT (x_direction);
24268       dwg_geom_normalize ((dwg_point_3d*)&_obj->x_direction, *x_direction);
24269     }
24270   else
24271     _obj->x_direction.x = 1.0;
24272   // defaults:
24273   if (dwg->header_vars.DIMSTYLE)
24274     _obj->dimstyle = dwg_add_handleref (
24275         dwg, 5, dwg->header_vars.DIMSTYLE->absolute_ref, NULL);
24276   _obj->dimgap = dwg->header_vars.DIMGAP;
24277   return _obj;
24278 }
24279 
24280 EXPORT Dwg_Entity_MLINE*
dwg_add_MLINE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const unsigned num_verts,const dwg_point_3d * restrict verts)24281 dwg_add_MLINE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24282                const unsigned num_verts,
24283                const dwg_point_3d *restrict verts)
24284 {
24285   BITCODE_H mlstyref;
24286   Dwg_Object_MLINESTYLE *mlstyle = NULL;
24287   API_ADD_ENTITY (MLINE);
24288   if (!num_verts)
24289     return NULL;
24290   _obj->verts = calloc (num_verts, sizeof (Dwg_MLINE_vertex));
24291   _obj->num_verts = num_verts;
24292   _obj->base_point.x = verts[0].x;
24293   _obj->base_point.y = verts[0].y;
24294   _obj->base_point.z = verts[0].z;
24295   // defaults:
24296   _obj->scale = dwg->header_vars.CMLSCALE;
24297   _obj->extrusion.z = 1.0;
24298   // flags?
24299   // set current mlinestyle
24300   mlstyref = dwg->header_vars.CMLSTYLE;
24301   _obj->mlinestyle = dwg_add_handleref (dwg, 5, mlstyref->absolute_ref, NULL);
24302   obj = dwg_ref_object (dwg, mlstyref);
24303   if (obj)
24304     {
24305       mlstyle = obj->tio.object->tio.MLINESTYLE;
24306       _obj->num_lines = mlstyle->num_lines;
24307     }
24308   for (unsigned i = 0; i < num_verts; i++)
24309     {
24310       //dwg_point_3d pt, ext;
24311       BITCODE_3BD dir;
24312       unsigned next = i + 1;
24313       unsigned prev = i ? i - 1 : num_verts - 1;
24314       if (next == num_verts)
24315         next = 0;
24316       _obj->verts[i].parent = _obj;
24317       _obj->verts[i].vertex.x = verts[i].x;
24318       _obj->verts[i].vertex.y = verts[i].y;
24319       _obj->verts[i].vertex.z = verts[i].z;
24320       // calc vertex_direction
24321       dwg_geom_normalize ((dwg_point_3d *)&dir,
24322                               (dwg_point_3d){ verts[next].x - verts[i].x,
24323                                               verts[next].y - verts[i].y,
24324                                               verts[next].z - verts[i].z });
24325       _obj->verts[i].vertex_direction = dir;
24326       // FIXME miter_direction = seems to be the extrusion (=normal) of the vertex_direction
24327       // to calculate the rotation matrix, starting with the start_angle.
24328       if (i == 0)
24329         {
24330 #if defined(HAVE_SINCOS) && !defined(__clang__)
24331           double cosa, sina;
24332           sincos (mlstyle->start_angle, &sina, &cosa);
24333 #else
24334           const double cosa = cos (mlstyle->start_angle);
24335           const double sina = sin (mlstyle->start_angle);
24336 #endif
24337           dir = _obj->verts[i].vertex_direction;
24338           // rotate by the mlstyle->start_angle
24339           dir.x = (dir.x * cosa) - (dir.y * sina);
24340           dir.y = (dir.x * sina) + (dir.y * cosa);
24341           //dwg_geom_normalize ((dwg_point_3d *)&_obj->verts[i].miter_direction, dir);
24342           _obj->verts[i].miter_direction = dir; // already normalized
24343         }
24344       else
24345         {
24346           // TODO v[prev]->vert_dir, v[i]->vert_dir, extrusion, v[0]->miter_dir
24347           dwg_point_3d ax, ay, az;
24348           memcpy (&az, &dir, sizeof (dwg_point_3d));
24349           if ((fabs (az.x) < 1 / 64.0) && (fabs (az.y) < 1 / 64.0))
24350             {
24351               dwg_point_3d tmp = { 0.0, 1.0, 0.0 };
24352               dwg_geom_cross (&tmp, tmp, az);
24353               dwg_geom_normalize (&ax, tmp);
24354             }
24355           else
24356             {
24357               dwg_point_3d tmp = { 0.0, 0.0, 1.0 };
24358               dwg_geom_cross (&tmp, tmp, az);
24359               dwg_geom_normalize (&ax, tmp);
24360             }
24361           dwg_geom_cross (&ay, az, ax);
24362           dwg_geom_normalize (&ay, ay);
24363           memcpy (&dir, &ay, sizeof (dwg_point_3d));
24364           _obj->verts[i].miter_direction = dir;
24365         }
24366       _obj->verts[i].lines = calloc (_obj->num_lines, sizeof (Dwg_MLINE_line));
24367       for (unsigned j = 0; j < _obj->num_lines; j++)
24368         {
24369           _obj->verts[i].lines[j].parent = _obj->verts;
24370           _obj->verts[i].lines[j].num_segparms = 2;
24371           _obj->verts[i].lines[j].segparms = calloc (_obj->verts[i].lines[j].num_segparms, 8);
24372           for (unsigned k = 0; k < _obj->verts[i].lines[j].num_segparms; k++)
24373             { // TODO
24374               _obj->verts[i].lines[j].segparms[k] = 0.0;
24375             }
24376         }
24377     }
24378   return _obj;
24379 }
24380 
24381 // Tables:
24382 
24383 /* This is a singleton and must be at 1. Must only be called from dwg_add_document() */
24384 Dwg_Object_BLOCK_CONTROL*
dwg_add_BLOCK_CONTROL(Dwg_Data * restrict dwg,const int ms,const int ps)24385 dwg_add_BLOCK_CONTROL (Dwg_Data *restrict dwg, const int ms, const int ps)
24386 {
24387   API_ADD_OBJECT (BLOCK_CONTROL);
24388   //obj->handle.value = 1;
24389   //obj->handle.size = 1;
24390   //dwg->block_control = _obj; // but will be realloc'ed soon
24391   dwg->header_vars.BLOCK_CONTROL_OBJECT = dwg_add_handleref (dwg, 3, 1, obj);
24392   dwg->header_vars.BLOCK_CONTROL_OBJECT->obj = obj;
24393   if (ms)
24394     {
24395       // Usually this does not exist yet.
24396       _obj->model_space = dwg_add_handleref (dwg, 3, ms, obj);
24397        dwg->header_vars.BLOCK_RECORD_MSPACE = _obj->model_space;
24398        LOG_TRACE ("blkctrl.model_space = " FORMAT_REF "\n",
24399                   ARGS_REF (_obj->model_space));
24400     }
24401   if (ps)
24402     {
24403       // This neither
24404       _obj->paper_space = dwg_add_handleref (dwg, 3, ps, obj);
24405        dwg->header_vars.BLOCK_RECORD_PSPACE = _obj->paper_space;
24406        LOG_TRACE ("blkctrl.paper_space = " FORMAT_REF "\n",
24407                   ARGS_REF (_obj->paper_space));
24408     }
24409   dwg->block_control = *_obj;
24410   return _obj;
24411 }
24412 
24413 #  define API_ADD_TABLE(record, control, ...)                                 \
24414     Dwg_Object_##record *_record = NULL;                                      \
24415     /* first check TABLE_CONTROL */                                           \
24416     Dwg_Object *ctrl = dwg_get_first_object (dwg, DWG_TYPE_##control);        \
24417     Dwg_Object_##control *_ctrl;                                              \
24418     unsigned long ctrlhdl;                                                    \
24419     if (!ctrl || !ctrl->tio.object || !ctrl->tio.object->tio.control)         \
24420       {                                                                       \
24421         API_ADD_OBJECT (control);                                             \
24422         dwg->header_vars.control##_OBJECT                                     \
24423             = dwg_add_handleref (dwg, 3, obj->handle.value, obj);             \
24424         LOG_TRACE (#control "_OBJECT = " FORMAT_REF "\n",                     \
24425                    ARGS_REF (dwg->header_vars.control##_OBJECT));             \
24426         dwg->header_vars.control##_OBJECT->obj = obj;                         \
24427         ctrl = obj;                                                           \
24428         _ctrl = _obj;                                                         \
24429       }                                                                       \
24430     else                                                                      \
24431       {                                                                       \
24432         _ctrl = ctrl->tio.object->tio.control;                                \
24433       }                                                                       \
24434     ctrlhdl = ctrl->handle.value;                                             \
24435     if (name || strEQc (#record, "BLOCK_HEADER"))                             \
24436       {                                                                       \
24437         API_ADD_OBJECT (record);                                              \
24438         _record = _obj;                                                       \
24439         _obj->name = dwg_add_u8_input (dwg, name);                            \
24440         LOG_TRACE (#record ".name = %s\n", name);                             \
24441         __VA_ARGS__                                                           \
24442         if (_ctrl->entries)                                                   \
24443           _ctrl->entries = realloc (                                          \
24444               _ctrl->entries, (_ctrl->num_entries + 1) * sizeof (BITCODE_H)); \
24445         else                                                                  \
24446           _ctrl->entries                                                      \
24447               = calloc (_ctrl->num_entries + 1, sizeof (BITCODE_H));          \
24448         _ctrl->entries[_ctrl->num_entries]                                    \
24449             = dwg_add_handleref (dwg, 2, obj->handle.value, NULL);            \
24450         LOG_TRACE (#control ".entries[%d] = " FORMAT_REF "\n",                \
24451                    _ctrl->num_entries,                                        \
24452                    ARGS_REF (_ctrl->entries[_ctrl->num_entries]));            \
24453         _ctrl->num_entries++;                                                 \
24454         obj->tio.object->ownerhandle                                          \
24455             = dwg_add_handleref (dwg, 4, ctrlhdl, obj);                       \
24456         _obj->is_xref_ref = 1;                                                \
24457         return _obj;                                                          \
24458       }                                                                       \
24459     else                                                                      \
24460       return NULL
24461 
24462 EXPORT Dwg_Object_BLOCK_HEADER *
dwg_add_BLOCK_HEADER(Dwg_Data * restrict dwg,const char * restrict name)24463 dwg_add_BLOCK_HEADER (Dwg_Data *restrict dwg, const char *restrict name)
24464 {
24465   API_ADD_TABLE (BLOCK_HEADER, BLOCK_CONTROL);
24466   dwg->block_control = *_ctrl;
24467 }
24468 
24469 EXPORT Dwg_Object_LAYER *
dwg_add_LAYER(Dwg_Data * restrict dwg,const char * restrict name)24470 dwg_add_LAYER (Dwg_Data *restrict dwg, const char *restrict name)
24471 {
24472   //Dwg_Object_Ref *plotstyle = dwg_ctrl_table (dwg, "PLOTSTYLE"); // PLOTSTYLE dict
24473   API_ADD_TABLE (LAYER, LAYER_CONTROL,
24474                  {
24475                    _obj->plotstyle = dwg_add_handleref (dwg, 5, 0xF, NULL);
24476                  });
24477 }
24478 
24479 EXPORT Dwg_Object_STYLE *
dwg_add_STYLE(Dwg_Data * restrict dwg,const char * restrict name)24480 dwg_add_STYLE (Dwg_Data *restrict dwg, const char *restrict name)
24481 {
24482   API_ADD_TABLE (STYLE, STYLE_CONTROL, { _obj->width_factor = 1.0; });
24483 }
24484 
24485 EXPORT Dwg_Object_LTYPE *
dwg_add_LTYPE(Dwg_Data * restrict dwg,const char * restrict name)24486 dwg_add_LTYPE (Dwg_Data *restrict dwg, const char *restrict name)
24487 {
24488   API_ADD_TABLE (LTYPE, LTYPE_CONTROL, { _obj->alignment = 0x41; });
24489 }
24490 
24491 EXPORT Dwg_Object_VIEW *
dwg_add_VIEW(Dwg_Data * restrict dwg,const char * restrict name)24492 dwg_add_VIEW (Dwg_Data *restrict dwg, const char *restrict name)
24493 {
24494   API_ADD_TABLE (VIEW, VIEW_CONTROL, {
24495     _obj->lens_length = 50.0;
24496     _obj->VIEWDIR.z = 1.0;
24497     _obj->VIEWMODE = 1;
24498     _obj->VIEWSIZE = 13314.951254;
24499     _obj->view_width = 19003.498504;
24500     _obj->VIEWCTR.x = 5771.997570;
24501     _obj->VIEWCTR.y = 789.325613;
24502     _obj->ucsxdir.x = 1.0;
24503     _obj->ucsydir.y = 1.0;
24504   });
24505 }
24506 
24507 EXPORT Dwg_Object_VPORT *
dwg_add_VPORT(Dwg_Data * restrict dwg,const char * restrict name)24508 dwg_add_VPORT (Dwg_Data *restrict dwg, const char *restrict name)
24509 {
24510   API_ADD_TABLE (VPORT, VPORT_CONTROL, {
24511     _obj->lens_length = 50.0;
24512     _obj->VIEWDIR.z = 1.0;
24513     _obj->VIEWMODE = 1;
24514     _obj->VIEWSIZE = 13314.951254;
24515     _obj->view_width = 19003.498504;
24516     _obj->VIEWCTR.x = 5771.997570;
24517     _obj->VIEWCTR.y = 789.325613;
24518     _obj->upper_right.x = 1.0;
24519     _obj->upper_right.y = 1.0;
24520     _obj->circle_zoom = 1000;
24521     _obj->FASTZOOM = 1;
24522     _obj->UCSICON = 3;
24523     _obj->GRIDUNIT.x = 10.0;
24524     _obj->GRIDUNIT.y = 10.0;
24525     _obj->SNAPUNIT.x = 10.0;
24526     _obj->SNAPUNIT.y = 10.0;
24527     _obj->UCSVP = 1;
24528     _obj->ucsxdir.x = 1.0;
24529     _obj->ucsydir.y = 1.0;
24530   });
24531 }
24532 
24533 // This is normally called automatically, not needed to set by the user.
24534 EXPORT Dwg_Object_APPID *
dwg_add_APPID(Dwg_Data * restrict dwg,const char * restrict name)24535 dwg_add_APPID (Dwg_Data *restrict dwg, const char *restrict name)
24536 {
24537   API_ADD_TABLE (APPID, APPID_CONTROL);
24538 }
24539 
24540 EXPORT Dwg_Object_DIMSTYLE *
dwg_add_DIMSTYLE(Dwg_Data * restrict dwg,const char * restrict name)24541 dwg_add_DIMSTYLE (Dwg_Data *restrict dwg, const char *restrict name)
24542 {
24543   if (name && strNE (name, "Standard"))
24544     dwg_require_DIMSTYLE_Standard (dwg);
24545   {
24546     API_ADD_TABLE (DIMSTYLE, DIMSTYLE_CONTROL, {
24547       _obj->DIMTIH = 1;
24548       _obj->DIMTOH = 1;
24549       _obj->DIMALTD = 2;
24550       _obj->DIMTOLJ = 1;
24551       _obj->DIMFIT = 3;
24552       _obj->DIMUNIT = 2;
24553       _obj->DIMDEC = 4;
24554       _obj->DIMTDEC = 4;
24555       _obj->DIMALTU = 2;
24556       _obj->DIMALTTD = 2;
24557       _obj->DIMLUNIT = 2;
24558       _obj->DIMATFIT = 3;
24559       _obj->DIMLWD = -2;
24560       _obj->DIMLWE = -2;
24561       _obj->DIMSCALE = strEQc (name, "Annotative") ? 0.0 : 1.0;
24562       _obj->DIMASZ = 0.18;
24563       _obj->DIMEXO = 0.0625;
24564       _obj->DIMDLI = 0.38;
24565       _obj->DIMEXE = 0.18;
24566       _obj->DIMTXT = 0.18;
24567       _obj->DIMCEN = 0.09;
24568       _obj->DIMALTF = 25.4;
24569       _obj->DIMLFAC = 1.0;
24570       _obj->DIMTFAC = 1.0;
24571       _obj->DIMGAP = 0.09;
24572       _obj->DIMCLRD = (BITCODE_CMC){ 0 };
24573       _obj->DIMCLRE = (BITCODE_CMC){ 0 };
24574       _obj->DIMCLRT = (BITCODE_CMC){ 0 };
24575       _obj->DIMTXSTY = dwg->header_vars.TEXTSTYLE;
24576     });
24577   }
24578 }
24579 
24580 EXPORT Dwg_Object_UCS *
dwg_add_UCS(Dwg_Data * restrict dwg,const dwg_point_3d * restrict origin,const dwg_point_3d * restrict x_axis,const dwg_point_3d * restrict y_axis,const char * restrict name)24581 dwg_add_UCS (Dwg_Data *restrict dwg,
24582              const dwg_point_3d *restrict origin,
24583              const dwg_point_3d *restrict x_axis,
24584              const dwg_point_3d *restrict y_axis,
24585              const char *restrict name)
24586 {
24587   API_ADD_TABLE (UCS, UCS_CONTROL, {
24588     _obj->ucsorg.x = origin->x;
24589     _obj->ucsorg.y = origin->y;
24590     _obj->ucsorg.z = origin->z;
24591     _obj->ucsxdir.x = x_axis->x;
24592     _obj->ucsxdir.y = x_axis->y;
24593     _obj->ucsxdir.z = x_axis->z;
24594     _obj->ucsydir.x = y_axis->x;
24595     _obj->ucsydir.y = y_axis->y;
24596     _obj->ucsydir.z = y_axis->z;
24597   });
24598 }
24599 
24600 // VX_CONTROL
24601 // VX_TABLE_RECORD
24602 // only until r14
24603 EXPORT Dwg_Object_VX_TABLE_RECORD *
dwg_add_VX(Dwg_Data * restrict dwg,const char * restrict name)24604 dwg_add_VX (Dwg_Data *restrict dwg, const char* restrict name)
24605 {
24606   API_ADD_TABLE (VX_TABLE_RECORD, VX_CONTROL);
24607 }
24608 
24609 EXPORT Dwg_Object_GROUP *
dwg_add_GROUP(Dwg_Data * restrict dwg,const char * restrict name)24610 dwg_add_GROUP (Dwg_Data *restrict dwg, const char *restrict name /* maybe NULL */)
24611 {
24612   Dwg_Object_DICTIONARY *dict = NULL;
24613   Dwg_Object *dictobj;
24614   Dwg_Object_Ref *groupdict;
24615   Dwg_Object *nod = dwg_get_first_object (dwg, DWG_TYPE_DICTIONARY);
24616   API_ADD_OBJECT (GROUP);
24617   // find nod dict
24618   groupdict = dwg_ctrl_table (dwg, "GROUP");
24619   if (!groupdict)
24620     {
24621       dict = dwg_add_DICTIONARY (
24622           dwg, (const BITCODE_T) "ACAD_GROUP", name, obj->handle.value);
24623     }
24624   else
24625     {
24626       Dwg_Object *group = dwg_ref_object (dwg, groupdict);
24627       if (group)
24628         dict = dwg_add_DICTIONARY_item (obj->tio.object->tio.DICTIONARY, (const BITCODE_T) "ACAD_GROUP",
24629                                         group->handle.value);
24630     }
24631   if (dict)
24632     {
24633       dictobj = dwg_obj_generic_to_object (dict, &error);
24634       obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, dictobj->handle.value, NULL);
24635       add_obj_reactor (obj->tio.object, dictobj->handle.value);
24636     }
24637 
24638    _obj->selectable = 1;
24639   if (name)
24640     _obj->name = dwg_add_u8_input (dwg, name);
24641   else
24642     _obj->unnamed = 1;
24643   return _obj;
24644 }
24645 
24646 EXPORT Dwg_Object_MLINESTYLE *
dwg_add_MLINESTYLE(Dwg_Data * restrict dwg,const char * restrict name)24647 dwg_add_MLINESTYLE (Dwg_Data *restrict dwg, const char *restrict name)
24648 {
24649   Dwg_Object_DICTIONARY *dict;
24650   Dwg_Object_Ref *dictref;
24651   API_ADD_OBJECT (MLINESTYLE);
24652   // find nod dict
24653   dictref = dwg_find_dictionary (dwg, "ACAD_MLINESTYLE");
24654   if (!dictref)
24655     {
24656       dict = dwg_add_DICTIONARY (dwg, (const BITCODE_T) "ACAD_MLINESTYLE", name,
24657                                  obj->handle.value);
24658       if (dict)
24659         {
24660           obj->tio.object->ownerhandle = dwg_add_handleref (
24661               dwg, 4, dwg_obj_generic_handlevalue (dict), obj);
24662           if (!obj->tio.object->num_reactors)
24663             add_obj_reactor (obj->tio.object, dwg_obj_generic_handlevalue (dict));
24664         }
24665     }
24666   else
24667     {
24668       Dwg_Object *dictobj = dwg_ref_object (dwg, dictref);
24669       if (dictobj)
24670         {
24671           dwg_add_DICTIONARY_item (dictobj->tio.object->tio.DICTIONARY, name,
24672                                    obj->handle.value);
24673           obj->tio.object->ownerhandle = dwg_add_handleref (
24674               dwg, 4, dictobj->handle.value, obj);
24675           if (!obj->tio.object->num_reactors)
24676             add_obj_reactor (obj->tio.object, dictobj->handle.value);
24677         }
24678     }
24679 
24680   _obj->name = strEQc (name, "Standard") ? dwg_add_u8_input (dwg, "STANDARD")
24681                                          : dwg_add_u8_input (dwg, name);
24682   _obj->fill_color = (BITCODE_CMC){ 256, 0 };
24683   if (strEQc (name, "Standard") || strEQc (name, "STANDARD"))
24684     {
24685       _obj->start_angle = _obj->end_angle = deg2rad (90.0);
24686       _obj->num_lines = 2;
24687       _obj->lines = calloc (2, sizeof (Dwg_MLINESTYLE_line));
24688       _obj->lines[0].parent = _obj;
24689       _obj->lines[0].offset = 0.5;
24690       _obj->lines[0].color = (BITCODE_CMC){ 256, 0 };
24691       _obj->lines[0].lt_index = 32767;
24692       _obj->lines[0].parent = _obj;
24693       _obj->lines[1].offset = -0.5;
24694       _obj->lines[1].color = (BITCODE_CMC){ 256, 0 };
24695       _obj->lines[1].lt_index = 32767;
24696     }
24697   return _obj;
24698 }
24699 
24700   // OLE2FRAME
24701   // DUMMY
24702   // LONG_TRANSACTION
24703 
24704 EXPORT Dwg_Entity_LWPOLYLINE *
dwg_add_LWPOLYLINE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const int num_pts2d,const dwg_point_2d * restrict pts2d)24705 dwg_add_LWPOLYLINE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24706                     const int num_pts2d, const dwg_point_2d *restrict pts2d)
24707 {
24708   {
24709     int err;
24710     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
24711     Dwg_Data *dwg = hdr ? hdr->parent : NULL;
24712     if (dwg && dwg->header.version < R_2000)
24713       REQUIRE_CLASS ("LWPOLYLINE");
24714   }
24715   {
24716     API_ADD_ENTITY (LWPOLYLINE);
24717     error = dwg_ent_lwpline_set_points (_obj, num_pts2d, pts2d);
24718     return _obj;
24719   }
24720 }
24721 
24722 //GCC33_DIAG_IGNORE (-Wswitch-enum)
24723 EXPORT Dwg_Entity_HATCH *
dwg_add_HATCH(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const int pattern_type,const char * restrict name,const bool is_associative,const unsigned num_paths,const Dwg_Object ** pathobjs)24724 dwg_add_HATCH (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
24725                const int pattern_type, const char *restrict name,
24726                const bool is_associative, const unsigned num_paths,
24727                // Line, Polyline, Circle, Arc, Ellipse, Spline or Region
24728                const Dwg_Object **pathobjs)
24729 {
24730   {
24731     int err;
24732     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
24733     Dwg_Data *dwg = hdr ? hdr->parent : NULL;
24734     if (dwg && dwg->header.version < R_2000)
24735       REQUIRE_CLASS ("HATCH");
24736   }
24737   {
24738     API_ADD_ENTITY (HATCH);
24739     if (strEQc (name, "SPHERICAL") || strEQc (name, "HEMISPHERICAL")
24740         || strEQc (name, "CURVED") || strEQc (name, "LINEAR")
24741         || strEQc (name, "CYLINDER"))
24742       {
24743         _obj->is_gradient_fill = 1;
24744         _obj->gradient_name = dwg_add_u8_input (dwg, name);
24745       }
24746     else
24747       {
24748         _obj->name = dwg_add_u8_input (dwg, name);
24749         // predefined (acad.pat), user-defined (ltype), custom (some.pat file)
24750         _obj->pattern_type = pattern_type;
24751       }
24752     if (strEQc (_obj->name, "SOLID"))
24753       _obj->is_solid_fill = 1;
24754     _obj->is_associative = is_associative;
24755     _obj->scale_spacing = 1.0;
24756     //_obj->x_dir.z = 1.0;
24757     _obj->num_paths = num_paths;
24758     //_obj->num_boundary_handles = num_paths;
24759     //_obj->boundary_handles = calloc (1, sizeof (BITCODE_H));
24760     _obj->paths = calloc (num_paths, sizeof (Dwg_HATCH_Path));
24761     for (unsigned i = 0; i < num_paths; i++)
24762       {
24763         Dwg_Object_Type type = pathobjs[i]->fixedtype;
24764         if (type != DWG_TYPE_LINE &&
24765             type != DWG_TYPE_ARC &&
24766             type != DWG_TYPE_CIRCLE &&
24767             type != DWG_TYPE_ELLIPSE &&
24768             type != DWG_TYPE_POLYLINE_2D &&
24769             type != DWG_TYPE_LWPOLYLINE &&
24770             type != DWG_TYPE_SPLINE &&
24771             type != DWG_TYPE_REGION)
24772           {
24773             LOG_ERROR ("Invalid HATCH.path[%d] object type %s. Only accept "
24774                        "Line, Polyline, Circle, Arc, Ellipse, Spline or Region",
24775                        i, dwg_type_name (type));
24776             return NULL;
24777           }
24778         _obj->paths[i].parent = _obj;
24779         // one path per object only here
24780         _obj->paths[i].num_boundary_handles = 1;
24781         _obj->paths[i].boundary_handles = calloc (1, sizeof (BITCODE_H));
24782         _obj->paths[i].boundary_handles[0]
24783             = dwg_add_handleref (dwg, 4, pathobjs[i]->handle.value, NULL);
24784         if (is_associative)
24785           add_ent_reactor (pathobjs[i]->tio.entity, obj->handle.value);
24786         // Split geometry into paths per pathobject
24787         switch (type)
24788           {
24789           case DWG_TYPE_LINE:
24790             {
24791               Dwg_Entity_LINE *line = pathobjs[i]->tio.entity->tio.LINE;
24792               _obj->paths[i].flag = 1 + (is_associative ? 0x200 : 0);
24793               _obj->paths[i].num_segs_or_paths = 1;
24794               _obj->paths[i].segs = calloc (1, sizeof (Dwg_HATCH_PathSeg));
24795               _obj->paths[i].segs[0].parent = &_obj->paths[i];
24796               _obj->paths[i].segs[0].curve_type = 1;
24797               _obj->paths[i].segs[0].first_endpoint.x = line->start.x;
24798               _obj->paths[i].segs[0].first_endpoint.y = line->start.y;
24799               _obj->paths[i].segs[0].second_endpoint.x = line->end.x;
24800               _obj->paths[i].segs[0].second_endpoint.y = line->end.y;
24801               break;
24802             }
24803           case DWG_TYPE_ARC:
24804             {
24805               Dwg_Entity_ARC *arc = pathobjs[i]->tio.entity->tio.ARC;
24806               _obj->paths[i].flag = 0x21 + (is_associative ? 0x200 : 0); // is_open
24807               _obj->paths[i].num_segs_or_paths = 1;
24808               _obj->paths[i].segs = calloc (1, sizeof (Dwg_HATCH_PathSeg));
24809               _obj->paths[i].segs[0].parent = &_obj->paths[i];
24810               _obj->paths[i].segs[0].curve_type = 2;
24811               _obj->paths[i].segs[0].center.x = arc->center.x;
24812               _obj->paths[i].segs[0].center.y = arc->center.y;
24813               _obj->paths[i].segs[0].radius = arc->radius;
24814               _obj->paths[i].segs[0].start_angle = arc->start_angle;
24815               _obj->paths[i].segs[0].end_angle = arc->end_angle;
24816               _obj->paths[i].segs[0].is_ccw = 1;
24817               break;
24818             }
24819           case DWG_TYPE_CIRCLE:
24820             {
24821               Dwg_Entity_CIRCLE *arc = pathobjs[i]->tio.entity->tio.CIRCLE;
24822               _obj->paths[i].flag = 1 + (is_associative ? 0x200 : 0);
24823               _obj->paths[i].num_segs_or_paths = 1;
24824               _obj->paths[i].segs = calloc (1, sizeof (Dwg_HATCH_PathSeg));
24825               _obj->paths[i].segs[0].parent = &_obj->paths[i];
24826               _obj->paths[i].segs[0].curve_type = 2;
24827               _obj->paths[i].segs[0].center.x = arc->center.x;
24828               _obj->paths[i].segs[0].center.y = arc->center.y;
24829               _obj->paths[i].segs[0].radius = arc->radius;
24830               _obj->paths[i].segs[0].start_angle = 0;
24831               _obj->paths[i].segs[0].end_angle = M_PI * 2;
24832               _obj->paths[i].segs[0].is_ccw = 1; //?
24833               break;
24834             }
24835           case DWG_TYPE_ELLIPSE:
24836             {
24837               Dwg_Entity_ELLIPSE *ell = pathobjs[i]->tio.entity->tio.ELLIPSE;
24838               _obj->paths[i].flag = 1 + (is_associative ? 0x200 : 0);
24839               _obj->paths[i].num_segs_or_paths = 1;
24840               _obj->paths[i].segs = calloc (1, sizeof (Dwg_HATCH_PathSeg));
24841               _obj->paths[i].segs[0].parent = &_obj->paths[i];
24842               _obj->paths[i].segs[0].curve_type = 3;
24843               _obj->paths[i].segs[0].center.x = ell->center.x;
24844               _obj->paths[i].segs[0].center.y = ell->center.y;
24845               _obj->paths[i].segs[0].endpoint.x = ell->sm_axis.x;
24846               _obj->paths[i].segs[0].endpoint.y = ell->sm_axis.y;
24847               _obj->paths[i].segs[0].minor_major_ratio = ell->axis_ratio;
24848               _obj->paths[i].segs[0].start_angle = ell->start_angle;
24849               _obj->paths[i].segs[0].end_angle = ell->end_angle;
24850               _obj->paths[i].segs[0].is_ccw = 1; //?
24851               break;
24852             }
24853           case DWG_TYPE_SPLINE:
24854           case DWG_TYPE_REGION:
24855             LOG_WARN ("Path segment extraction for HATCH from %s not yet implemented",
24856                       dwg_type_name (type));
24857             break;
24858           case DWG_TYPE_LWPOLYLINE:
24859             {
24860               bool has_bulges = false;
24861               Dwg_Entity_LWPOLYLINE *pline = pathobjs[i]->tio.entity->tio.LWPOLYLINE;
24862               // If no bulges just use flag 1 as with LINE?? (but flag 2 would be much more compact)
24863               // I have seen LWPOLYLINE's without bulges being HATCHed to segments.
24864               if (pline->num_bulges && pline->flag & 16)
24865                 {
24866                   for (unsigned j=0; j < pline->num_bulges; j++)
24867                     {
24868                       if (pline->bulges[j] != 0.0)
24869                         {
24870                           has_bulges = true;
24871                           break;
24872                         }
24873                     }
24874                 }
24875               if (!has_bulges) // use the segment path
24876                 {
24877                   unsigned num;
24878                   _obj->paths[i].flag = 1 + (is_associative ? 0x200 : 0);
24879                   if (pline->flag & 512) // closed
24880                     num = pline->num_points;
24881                   else
24882                     {
24883                       _obj->paths[i].flag += 0x20;
24884                       num = pline->num_points - 1;
24885                     }
24886                   _obj->paths[i].num_segs_or_paths = num;
24887                   _obj->paths[i].segs = calloc (num, sizeof (Dwg_HATCH_PathSeg));
24888                   for (unsigned j=0; j < num; j++)
24889                     {
24890                       unsigned k = j + 1;
24891                       if (k == pline->num_points)
24892                         k = 0;
24893                       _obj->paths[i].segs[j].parent = &_obj->paths[i];
24894                       _obj->paths[i].segs[j].curve_type = 1;
24895                       _obj->paths[i].segs[j].first_endpoint.x = pline->points[j].x;
24896                       _obj->paths[i].segs[j].first_endpoint.y = pline->points[j].y;
24897                       _obj->paths[i].segs[j].second_endpoint.x = pline->points[k].x;
24898                       _obj->paths[i].segs[j].second_endpoint.y = pline->points[k].y;
24899                     }
24900                 }
24901               else
24902                 {
24903                   _obj->paths[i].flag = 2 + (is_associative ? 0x200 : 0);
24904                   _obj->paths[i].bulges_present = 1;
24905                   _obj->paths[i].closed = pline->flag & 512 ? 1 : 0;
24906                   _obj->paths[i].num_segs_or_paths = pline->num_points;
24907                   _obj->paths[i].polyline_paths = calloc (
24908                       pline->num_points, sizeof (Dwg_HATCH_PolylinePath));
24909                   for (unsigned j = 0; j < pline->num_points; j++)
24910                     {
24911                       _obj->paths[i].polyline_paths[j].parent = &_obj->paths[i];
24912                       _obj->paths[i].polyline_paths[j].point.x = pline->points[j].x;
24913                       _obj->paths[i].polyline_paths[j].point.y = pline->points[j].y;
24914                       if (_obj->paths[i].bulges_present)
24915                         _obj->paths[i].polyline_paths[j].bulge = pline->bulges[j];
24916                     }
24917                 }
24918             }
24919             break;
24920           case DWG_TYPE_POLYLINE_2D:
24921             {
24922               Dwg_Entity_POLYLINE_2D *pline = pathobjs[i]->tio.entity->tio.POLYLINE_2D;
24923               dwg_point_2d *pts;
24924               _obj->paths[i].flag = 2 + (is_associative ? 0x200 : 0);
24925               _obj->paths[i].closed = pline->flag & 1 ? 1 : 0;
24926               _obj->paths[i].num_segs_or_paths = pline->num_owned;
24927               _obj->paths[i].polyline_paths
24928                   = calloc (pline->num_owned, sizeof (Dwg_HATCH_PolylinePath));
24929               pts = dwg_object_polyline_2d_get_points (pathobjs[i], &error);
24930               if (error)
24931                 return NULL;
24932               for (unsigned j=0; j < pline->num_owned; j++)
24933                 {
24934                   _obj->paths[i].polyline_paths[j].parent = &_obj->paths[i];
24935                   _obj->paths[i].polyline_paths[j].point.x = pts[j].x;
24936                   _obj->paths[i].polyline_paths[j].point.y = pts[j].y;
24937                 }
24938               // TODO bulges, curve_type
24939               free (pts);
24940             }
24941             break;
24942           default:
24943             LOG_ERROR ("Invalid HATCH.path[%d] object type %s. Only accept "
24944                        "Line, Polyline, Circle, Arc, Ellipse, Spline or Region",
24945                        i, dwg_type_name (type));
24946             return NULL;
24947           }
24948       }
24949     return _obj;
24950   }
24951 }
24952 
24953 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD(Dwg_Object_DICTIONARY * restrict dict,const char * restrict key)24954 dwg_add_XRECORD (Dwg_Object_DICTIONARY *restrict dict,
24955                  const char *restrict key)
24956 {
24957   int err;
24958   Dwg_Object *dictobj = dwg_obj_generic_to_object (dict, &err);
24959   Dwg_Data *dwg = dictobj->parent;
24960   if (dictobj->fixedtype != DWG_TYPE_DICTIONARY) // allow WDFLT? not seen in the wild
24961     {
24962       LOG_ERROR ("Object XRECORD must be added to a DICTIONARY, not %s",
24963                  dwg_type_name (dictobj->fixedtype));
24964       return NULL;
24965     }
24966   {
24967     if (dwg->header.version < R_2000)
24968       REQUIRE_CLASS ("XRECORD");
24969   }
24970   {
24971     API_ADD_OBJECT (XRECORD);
24972     _obj->cloning = dict->cloning;
24973     // find the key in the dict, and set the handle. or add it
24974     dwg_add_DICTIONARY_item (dict, key, obj->handle.value);
24975     return _obj;
24976   }
24977 }
24978 
rbuf_last(Dwg_Resbuf * rbuf)24979 static Dwg_Resbuf *rbuf_last (Dwg_Resbuf *rbuf)
24980 {
24981   Dwg_Resbuf *prev = rbuf;
24982   while (rbuf)
24983     {
24984       prev = rbuf;
24985       rbuf = rbuf->nextrb;
24986     }
24987   return prev;
24988 }
24989 
rbuf_add(Dwg_Resbuf * rbuf)24990 static Dwg_Resbuf *rbuf_add (Dwg_Resbuf *rbuf)
24991 {
24992   rbuf = rbuf_last (rbuf);
24993   if (!rbuf)
24994     {
24995       return (Dwg_Resbuf *)calloc (1, sizeof (Dwg_Resbuf));
24996     }
24997   else
24998     {
24999       rbuf->nextrb = (Dwg_Resbuf *)calloc (1, sizeof (Dwg_Resbuf));
25000       return rbuf->nextrb;
25001     }
25002 }
25003 
25004 #define CHECK_XRECORD                                                   \
25005   int error;                                                            \
25006   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);           \
25007   if (!obj || obj->fixedtype != DWG_TYPE_XRECORD)                       \
25008     {                                                                   \
25009       LOG_ERROR ("Not a XRECORD, but %s", obj ? dwg_type_name (obj->fixedtype) : "NULL"); \
25010       return NULL;                                                      \
25011     }
25012 
25013 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_bool(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_B value)25014 dwg_add_XRECORD_bool (Dwg_Object_XRECORD *restrict _obj,
25015                       const short dxf, const BITCODE_B value)
25016 {
25017   Dwg_Resbuf *rbuf;
25018   CHECK_XRECORD;
25019   rbuf = rbuf_add (_obj->xdata);
25020   if (!_obj->xdata)
25021     _obj->xdata = rbuf;
25022   _obj->num_xdata++;
25023   rbuf->type = dxf;
25024   rbuf->value.i8 = value;
25025   _obj->xdata_size += 3;
25026   return _obj;
25027 }
25028 
25029 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_int8(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_RC value)25030 dwg_add_XRECORD_int8 (Dwg_Object_XRECORD *restrict _obj,
25031                        const short dxf, const BITCODE_RC value)
25032 {
25033   int error;
25034   Dwg_Resbuf *rbuf;
25035   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
25036   if (obj->fixedtype != DWG_TYPE_XRECORD)
25037     {
25038       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25039       return NULL;
25040     }
25041   rbuf = rbuf_add (_obj->xdata);
25042   if (!_obj->xdata)
25043     _obj->xdata = rbuf;
25044   _obj->num_xdata++;
25045   rbuf->type = dxf;
25046   rbuf->value.i8 = value;
25047   _obj->xdata_size += 3; // 2 + 1
25048   return _obj;
25049 }
25050 
25051 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_int16(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_BS value)25052 dwg_add_XRECORD_int16 (Dwg_Object_XRECORD *restrict _obj,
25053                        const short dxf, const BITCODE_BS value)
25054 {
25055   int error;
25056   Dwg_Resbuf *rbuf;
25057   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
25058   if (obj->fixedtype != DWG_TYPE_XRECORD)
25059     {
25060       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25061       return NULL;
25062     }
25063   rbuf = rbuf_add (_obj->xdata);
25064   if (!_obj->xdata)
25065     _obj->xdata = rbuf;
25066   _obj->num_xdata++;
25067   rbuf->type = dxf;
25068   rbuf->value.i16 = value;
25069   _obj->xdata_size += 4; // 2 + 2
25070   return _obj;
25071 }
25072 
25073 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_int32(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_BL value)25074 dwg_add_XRECORD_int32 (Dwg_Object_XRECORD *restrict _obj,
25075                        const short dxf, const BITCODE_BL value)
25076 {
25077   int error;
25078   Dwg_Resbuf *rbuf;
25079   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
25080   if (!obj || obj->fixedtype != DWG_TYPE_XRECORD)
25081     {
25082       LOG_ERROR ("Not a XRECORD, but %s", obj ? dwg_type_name (obj->fixedtype) : "NULL");
25083       return NULL;
25084     }
25085   rbuf = rbuf_add (_obj->xdata);
25086   if (!_obj->xdata)
25087     _obj->xdata = rbuf;
25088   _obj->num_xdata++;
25089   rbuf->type = dxf;
25090   rbuf->value.i32 = value;
25091   _obj->xdata_size += 6; // 2 + 4
25092   return _obj;
25093 }
25094 
25095 
25096 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_int64(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_BLL value)25097 dwg_add_XRECORD_int64 (Dwg_Object_XRECORD *restrict _obj,
25098                        const short dxf, const BITCODE_BLL value)
25099 {
25100   int err;
25101   Dwg_Resbuf *rbuf;
25102   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &err);
25103   if (obj->fixedtype != DWG_TYPE_XRECORD)
25104     {
25105       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25106       return NULL;
25107     }
25108   rbuf = rbuf_add (_obj->xdata);
25109   if (!_obj->xdata)
25110     _obj->xdata = rbuf;
25111   _obj->num_xdata++;
25112   rbuf->type = dxf;
25113   rbuf->value.i64 = value;
25114   _obj->xdata_size += 10; // 2 + 8
25115   return _obj;
25116 }
25117 
25118 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_real(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_BD value)25119 dwg_add_XRECORD_real (Dwg_Object_XRECORD *restrict _obj,
25120                       const short dxf, const BITCODE_BD value)
25121 {
25122   int err;
25123   Dwg_Resbuf *rbuf;
25124   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &err);
25125   if (obj->fixedtype != DWG_TYPE_XRECORD)
25126     {
25127       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25128       return NULL;
25129     }
25130   rbuf = rbuf_add (_obj->xdata);
25131   if (!_obj->xdata)
25132     _obj->xdata = rbuf;
25133   _obj->num_xdata++;
25134   rbuf->type = dxf;
25135   rbuf->value.dbl = value;
25136   _obj->xdata_size += 10; // 2 + 8
25137   return _obj;
25138 }
25139 
25140 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_pointd3d(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_3DPOINT * pt)25141 dwg_add_XRECORD_pointd3d (Dwg_Object_XRECORD *restrict _obj,
25142                           const short dxf, const BITCODE_3DPOINT *pt)
25143 {
25144   int err;
25145   Dwg_Resbuf *rbuf;
25146   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &err);
25147   if (obj->fixedtype != DWG_TYPE_XRECORD)
25148     {
25149       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25150       return NULL;
25151     }
25152   rbuf = rbuf_add (_obj->xdata);
25153   if (!_obj->xdata)
25154     _obj->xdata = rbuf;
25155   _obj->num_xdata++;
25156   rbuf->type = dxf;
25157   rbuf->value.pt[0] = pt->x;
25158   rbuf->value.pt[1] = pt->y;
25159   rbuf->value.pt[2] = pt->z;
25160   _obj->xdata_size += 26; // 2 + 3*8
25161   return _obj;
25162 }
25163 
25164 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_binary(Dwg_Object_XRECORD * restrict _obj,const short dxf,const int size,const BITCODE_RC * data)25165 dwg_add_XRECORD_binary (Dwg_Object_XRECORD *restrict _obj,
25166                         const short dxf,
25167                         const int size, const BITCODE_RC* data)
25168 {
25169   int error;
25170   Dwg_Resbuf *rbuf;
25171   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
25172   Dwg_Data *dwg = obj ? obj->parent : NULL;
25173   if (obj->fixedtype != DWG_TYPE_XRECORD)
25174     {
25175       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25176       return NULL;
25177     }
25178   rbuf = rbuf_add (_obj->xdata);
25179   if (!_obj->xdata)
25180     _obj->xdata = rbuf;
25181   _obj->num_xdata++;
25182   rbuf->type = dxf;
25183   rbuf->value.str.size = size;
25184   rbuf->value.str.is_tu = 0;
25185   rbuf->value.str.u.data = malloc (size);
25186   memcpy (rbuf->value.str.u.data, data, size);
25187   _obj->xdata_size += 3 + size; // 2 + 1 + len
25188   return _obj;
25189 }
25190 
25191 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_string(Dwg_Object_XRECORD * restrict _obj,const short dxf,const BITCODE_BS len,const char * str)25192 dwg_add_XRECORD_string (Dwg_Object_XRECORD *restrict _obj,
25193                         const short dxf,
25194                         const BITCODE_BS len,
25195                         const char *str) // utf8
25196 {
25197   int error;
25198   Dwg_Resbuf *rbuf;
25199   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
25200   Dwg_Data *dwg = obj ? obj->parent : NULL;
25201   if (obj->fixedtype != DWG_TYPE_XRECORD)
25202     {
25203       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25204       return NULL;
25205     }
25206   rbuf = rbuf_add (_obj->xdata);
25207   if (!_obj->xdata)
25208     _obj->xdata = rbuf;
25209   _obj->num_xdata++;
25210   rbuf->type = dxf;
25211   rbuf->value.str.codepage
25212       = (dwg && dwg->header.version < R_2007) ? dwg->header.codepage : 30;
25213   rbuf->value.str.is_tu = 0;
25214   rbuf->value.str.size = len;
25215   rbuf->value.str.u.data = malloc (len);
25216   memcpy (rbuf->value.str.u.data, str, len); // utf-8 or single-byte
25217   _obj->xdata_size += 4 + len;
25218   return _obj;
25219 }
25220 
25221 EXPORT Dwg_Object_XRECORD *
dwg_add_XRECORD_handle(Dwg_Object_XRECORD * restrict _obj,const short dxf,const Dwg_Handle hdl)25222 dwg_add_XRECORD_handle (Dwg_Object_XRECORD *restrict _obj,
25223                         const short dxf, const Dwg_Handle hdl)
25224 {
25225   int error;
25226   Dwg_Resbuf *rbuf;
25227   Dwg_Object *obj = dwg_obj_generic_to_object (_obj, &error);
25228   Dwg_Data *dwg = obj ? obj->parent : NULL;
25229   if (obj->fixedtype != DWG_TYPE_XRECORD)
25230     {
25231       LOG_ERROR ("Not a XRECORD, but %s", dwg_type_name (obj->fixedtype));
25232       return NULL;
25233     }
25234   rbuf = rbuf_add (_obj->xdata);
25235   if (!_obj->xdata)
25236     _obj->xdata = rbuf;
25237   _obj->num_xdata++;
25238   rbuf->type = dxf;
25239   memcpy (rbuf->value.hdl, &hdl, sizeof (Dwg_Handle));
25240   _obj->xdata_size += 10; // 2 + 8
25241   return _obj;
25242 }
25243 
25244 EXPORT Dwg_Object_PLACEHOLDER *
dwg_add_PLACEHOLDER(Dwg_Data * restrict dwg)25245 dwg_add_PLACEHOLDER (Dwg_Data *restrict dwg)
25246 {
25247   {
25248     REQUIRE_CLASS ("ACDBPLACEHOLDER");
25249   }
25250   {
25251     API_ADD_OBJECT (PLACEHOLDER);
25252     return _obj;
25253   }
25254 }
25255 
25256 EXPORT Dwg_Object_VBA_PROJECT *
dwg_add_VBA_PROJECT(Dwg_Data * restrict dwg,const BITCODE_BL size,const BITCODE_RC * data)25257 dwg_add_VBA_PROJECT (Dwg_Data *restrict dwg, const BITCODE_BL size,
25258                      const BITCODE_RC *data)
25259 {
25260   if (dwg->header.version < R_2000)
25261     return NULL;
25262   {
25263     REQUIRE_CLASS ("VBA_PROJECT");
25264   }
25265   {
25266     API_ADD_OBJECT (VBA_PROJECT);
25267     _obj->data_size = size;
25268     // add the data to dwg->vbaproject, the SECTION_VBAPROJECT
25269     dwg->vbaproject.size = size;
25270     dwg->vbaproject.unknown_bits = malloc (size);
25271     //memcpy (_obj->data, data, size);
25272     memcpy (dwg->vbaproject.unknown_bits, data, size);
25273     // header.vbaproj_address is set in encode
25274     return _obj;
25275   }
25276 }
25277 
25278 /* either added to the VIEWPORT entity in pspace, or VPORT object in mspace. */
25279 EXPORT Dwg_Object_LAYOUT *
dwg_add_LAYOUT(Dwg_Object * restrict vp,const char * restrict name,const char * restrict canonical_media_name)25280 dwg_add_LAYOUT (Dwg_Object *restrict vp,
25281                 const char *restrict name,
25282                 const char *restrict canonical_media_name)
25283 {
25284   int err;
25285   Dwg_Data *dwg = vp->parent;
25286 #ifdef NEED_VPORT_FOR_MODEL_LAYOUT
25287   if (vp->fixedtype != DWG_TYPE_VPORT && vp->fixedtype != DWG_TYPE_VIEWPORT)
25288     {
25289       LOG_ERROR ("LAYOUT can only be added to VPORT (in mspace) or VIEWPORT (in pspace)");
25290       return NULL;
25291     }
25292 #endif
25293   {
25294     // TODL skip if <r2000
25295     REQUIRE_CLASS ("LAYOUT");
25296   }
25297   {
25298     Dwg_Object_DICTIONARY *dict = NULL;
25299     Dwg_Object *dictobj;
25300     Dwg_Object_Ref *dictref;
25301     Dwg_Object *nod;
25302     unsigned long ownerhandle;
25303 
25304     API_ADD_OBJECT (LAYOUT);
25305 
25306     _obj->layout_name = dwg_add_u8_input (dwg, name);
25307     _obj->layout_flags = 1;
25308     _obj->plotsettings.canonical_media_name = dwg_add_u8_input (dwg, canonical_media_name);
25309     _obj->UCSXDIR.x = 1.0;
25310     _obj->UCSYDIR.y = 1.0;
25311     if (vp->fixedtype == DWG_TYPE_VIEWPORT) {
25312       _obj->LIMMAX = dwg->header_vars.PLIMMAX;
25313       _obj->EXTMIN = dwg->header_vars.PEXTMIN;
25314       _obj->EXTMAX = dwg->header_vars.PEXTMAX;
25315       _obj->UCSXDIR = dwg->header_vars.PUCSXDIR;
25316       _obj->UCSYDIR = dwg->header_vars.PUCSYDIR;
25317     } else {
25318       _obj->LIMMAX = dwg->header_vars.LIMMAX;
25319       _obj->EXTMIN = dwg->header_vars.EXTMIN;
25320       _obj->EXTMAX = dwg->header_vars.EXTMAX;
25321       _obj->UCSXDIR = dwg->header_vars.UCSXDIR;
25322       _obj->UCSYDIR = dwg->header_vars.UCSYDIR;
25323     }
25324 
25325     // either VIEWPORT or VPORT
25326     if (vp->fixedtype == DWG_TYPE_BLOCK_HEADER) {
25327       ownerhandle = vp->handle.value;
25328       _obj->active_viewport = dwg_add_handleref (dwg, 4, 0, NULL);
25329     }
25330     else if (vp->fixedtype == DWG_TYPE_VPORT) {
25331       ownerhandle = vp->tio.object->ownerhandle->absolute_ref;
25332       _obj->active_viewport = dwg_add_handleref (dwg, 4, vp->handle.value, NULL);
25333     }
25334     else {
25335       ownerhandle = vp->tio.entity->ownerhandle->absolute_ref;
25336       _obj->active_viewport = dwg_add_handleref (dwg, 4, vp->handle.value, NULL);
25337     }
25338 
25339     _obj->block_header = dwg_add_handleref (dwg, 4, ownerhandle, NULL);
25340     // TODO copy the plotsettings and viewport settings as default
25341 
25342     dictref = dwg_find_dictionary (dwg, "ACAD_LAYOUT");
25343     if (dictref)
25344       {
25345         dictobj = dwg_ref_object (dwg, dictref);
25346         if (dictobj)
25347           dict = dwg_add_DICTIONARY_item (dictobj->tio.object->tio.DICTIONARY,
25348                                           name, obj->handle.value);
25349       }
25350     if (dict)
25351       {
25352         dictobj = dwg_obj_generic_to_object (dict, &error);
25353         obj->tio.object->ownerhandle
25354             = dwg_add_handleref (dwg, 4, dictobj->handle.value, obj);
25355         add_obj_reactor (obj->tio.object, dictobj->handle.value);
25356         if (!dwg->header_vars.DICTIONARY_LAYOUT || !dwg->header_vars.DICTIONARY_LAYOUT->absolute_ref)
25357           dwg->header_vars.DICTIONARY_LAYOUT
25358               = dwg_add_handleref (dwg, 5, dictobj->handle.value, NULL);
25359       }
25360     {
25361       // Attach to block_header also if empty. Only to *Paper_Space or *Model_Space.
25362       Dwg_Object_Ref *blkref = _obj->block_header;
25363       Dwg_Object *blk = dwg_ref_object (dwg, blkref);
25364       if (!blk)
25365         return _obj;
25366       if (!blk->tio.object->tio.BLOCK_HEADER->layout
25367           || !blk->tio.object->tio.BLOCK_HEADER->layout->absolute_ref)
25368         blk->tio.object->tio.BLOCK_HEADER->layout
25369             = dwg_add_handleref (dwg, 5, obj->handle.value, NULL);
25370     }
25371     return _obj;
25372   }
25373 }
25374 
25375 EXPORT Dwg_Entity_PROXY_ENTITY *
dwg_add_PROXY_ENTITY(Dwg_Object_BLOCK_HEADER * restrict blkhdr)25376 dwg_add_PROXY_ENTITY (Dwg_Object_BLOCK_HEADER *restrict blkhdr /* ... */)
25377 {
25378   {
25379     int err;
25380     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
25381     Dwg_Data *dwg = hdr ? hdr->parent : NULL;
25382     if (dwg && dwg->header.version < R_2000)
25383       REQUIRE_CLASS ("ACAD_PROXY_ENTITY_WRAPPER");
25384   }
25385   {
25386     API_ADD_ENTITY (PROXY_ENTITY);
25387     return _obj;
25388   }
25389 }
25390 
25391 // owned by a DICT: name: nod key, e.g. HOST_DOC_SETTINGS, key: e.g. NCDOCPARAMETERS
25392 EXPORT Dwg_Object_PROXY_OBJECT *
dwg_add_PROXY_OBJECT(Dwg_Data * restrict dwg,char * name,char * key)25393 dwg_add_PROXY_OBJECT (Dwg_Data *restrict dwg, char *name, char *key
25394                       /*, size, data */)
25395 {
25396   Dwg_Object_DICTIONARY *dict;
25397   Dwg_Object *nod, *dictobj;
25398   {
25399     int error;
25400     REQUIRE_CLASS ("ACAD_PROXY_OBJECT_WRAPPER");
25401 
25402     // add name to NOD
25403     dict = dwg_add_DICTIONARY (dwg, name, key, 0);
25404     nod = dwg_get_first_object (dwg, DWG_TYPE_DICTIONARY);
25405     dictobj = dwg_obj_generic_to_object (dict, &error);
25406   }
25407 
25408   {
25409     API_ADD_OBJECT (PROXY_OBJECT);
25410     dwg_add_DICTIONARY_item (nod->tio.object->tio.DICTIONARY, key, obj->handle.value);
25411     obj->tio.object->ownerhandle = dwg_add_handleref (dwg, 4, dictobj->handle.value, NULL);
25412     add_obj_reactor (obj->tio.object, dictobj->handle.value);
25413     _obj->class_id = 499;
25414     return _obj;
25415   }
25416 }
25417 
25418 // ACDSRECORD
25419 // ACDSSCHEMA
25420 // ACMECOMMANDHISTORY
25421 // ACMESCOPE
25422 // ACMESTATEMGR
25423 
25424 // ACSH_BOOLEAN_CLASS
25425 // Performs a Boolean operation (0 union, 1 intersect, or 2 subtract) between the
25426 // object and another 3DSolid or Region object
25427 
25428 Dwg_Object_EVALUATION_GRAPH *
dwg_add_EVALUATION_GRAPH(Dwg_Data * restrict dwg,const int has_graph,const int e_nodeid,const unsigned num_nodes,const BITCODE_H * restrict evalexpr)25429 dwg_add_EVALUATION_GRAPH (Dwg_Data *restrict dwg, const int has_graph,
25430                           const int e_nodeid, const unsigned num_nodes,
25431                           const BITCODE_H *restrict evalexpr)
25432 {
25433   API_ADD_OBJECT (EVALUATION_GRAPH);
25434   obj->tio.object->ownerhandle
25435       = dwg_add_handleref (dwg, 4, obj->handle.value + 1, obj);
25436   _obj->major = 27;
25437   _obj->minor = 52;
25438   _obj->has_graph = has_graph;
25439   _obj->first_nodeid = e_nodeid;
25440   _obj->first_nodeid_copy = e_nodeid;
25441   _obj->num_nodes = num_nodes;
25442   _obj->nodes = calloc (_obj->num_nodes, sizeof (Dwg_EVAL_Node));
25443   for (unsigned i = 0; i < num_nodes; i++)
25444     {
25445       _obj->nodes[i].parent = _obj;
25446       _obj->nodes[i].id = i;
25447       _obj->nodes[i].edge_flags = 32;
25448       _obj->nodes[i].nextid = i + 1;
25449       _obj->nodes[i].evalexpr = evalexpr[i];
25450       _obj->nodes[i].node[0] = -1;
25451       _obj->nodes[i].node[1] = -1;
25452       _obj->nodes[i].node[2] = -1;
25453       _obj->nodes[i].node[3] = -1;
25454     }
25455   _obj->edges = calloc (_obj->num_edges, sizeof (Dwg_EVAL_Edge));
25456   for (unsigned i = 0; i < _obj->num_edges; i++)
25457     {
25458       _obj->edges[i].parent = _obj;
25459       _obj->edges[i].id = i;
25460       _obj->edges[i].nextid = -1;
25461       _obj->edges[i].e1 = -1; // incoming edges
25462       _obj->edges[i].e2 = -1;
25463       _obj->edges[i].e3 = -1;
25464       _obj->edges[i].out_edge[0] = -1;
25465       _obj->edges[i].out_edge[1] = -1;
25466       _obj->edges[i].out_edge[2] = -1;
25467       _obj->edges[i].out_edge[3] = -1;
25468       _obj->edges[i].out_edge[4] = -1;
25469     }
25470   return _obj;
25471 }
25472 
25473 Dwg_Object_ACSH_HISTORY_CLASS*
dwg_add_ACSH_HISTORY_CLASS(Dwg_Entity_3DSOLID * restrict region,const int h_nodeid)25474 dwg_add_ACSH_HISTORY_CLASS (Dwg_Entity_3DSOLID *restrict region,
25475                             const int h_nodeid)
25476 {
25477   int err;
25478   Dwg_Object *hdr = dwg_obj_generic_to_object (region, &err);
25479   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
25480   if (!dwg)
25481     return NULL;
25482   {
25483     API_ADD_OBJECT (ACSH_HISTORY_CLASS);
25484     obj->tio.object->ownerhandle = dwg_add_handleref (
25485         dwg, 4, dwg_obj_generic_handlevalue (region), obj);
25486     _obj->major = 27;
25487     _obj->minor = 52;
25488     _obj->h_nodeid = h_nodeid;
25489     _obj->record_history = 1;
25490     return _obj;
25491   }
25492 }
25493 
25494 /* Some geometric helpers */
25495 
25496 double
dwg_geom_angle_normalize(double angle)25497 dwg_geom_angle_normalize (double angle)
25498 {
25499   if (fabs (angle) > M_PI)
25500     {
25501       while (angle > M_PI)
25502         angle -= (M_PI * 2.0);
25503       while (angle < -M_PI)
25504         angle += (M_PI * 2.0);
25505     }
25506   return angle;
25507 }
25508 
25509 dwg_point_3d *
dwg_geom_normalize(dwg_point_3d * out,const dwg_point_3d pt)25510 dwg_geom_normalize (dwg_point_3d *out, const dwg_point_3d pt)
25511 {
25512   double l = sqrt ((pt.x * pt.x) + (pt.y * pt.y) + (pt.z * pt.z));
25513   *out = pt;
25514   if (l != 1.0 && l != 0.0)
25515     {
25516       out->x = pt.x / l;
25517       out->y = pt.y / l;
25518       out->z = pt.z / l;
25519     }
25520   return out;
25521 }
25522 
25523 dwg_point_3d *
dwg_geom_cross(dwg_point_3d * out,const dwg_point_3d pt1,const dwg_point_3d pt2)25524 dwg_geom_cross (dwg_point_3d *out, const dwg_point_3d pt1, const dwg_point_3d pt2)
25525 {
25526   out->x = pt1.y * pt2.z - pt1.z * pt2.y;
25527   out->y = pt1.z * pt2.x - pt1.x * pt2.z;
25528   out->z = pt1.x * pt2.y - pt1.y * pt2.x;
25529   return out;
25530 }
25531 
25532 // Transform a 3D point via its OCS (extrusion or normal)
25533 EXPORT dwg_point_3d *
dwg_geom_transform_OCS(dwg_point_3d * out,const dwg_point_3d pt,const dwg_point_3d ext)25534 dwg_geom_transform_OCS (dwg_point_3d *out,
25535                         const dwg_point_3d pt,
25536                         const dwg_point_3d ext)
25537 {
25538   if (ext.x == 0.0 && ext.y == 0.0 && ext.z == 1.0)
25539     {
25540       *out = pt;
25541     }
25542   else if (ext.x == 0.0 && ext.y == 0.0 && ext.z == -1.0)
25543     {
25544       *out = pt;
25545       out->x = - out->x;
25546     }
25547   else
25548     {
25549       /* This is called the "Arbitrary Axis Algorithm" to calculate
25550          the OCS x-axis from the extrusion z-vector */
25551       dwg_point_3d ax, ay, az, be;
25552       be = ext;
25553       dwg_geom_normalize (&az, be);
25554       if ((fabs (az.x) < 1 / 64.0) && (fabs (az.y) < 1 / 64.0))
25555         {
25556           dwg_point_3d tmp = { 0.0, 1.0, 0.0 };
25557           dwg_geom_cross (&tmp, tmp, az);
25558           dwg_geom_normalize (&ax, tmp);
25559         }
25560       else
25561         {
25562           dwg_point_3d tmp = { 0.0, 0.0, 1.0 };
25563           dwg_geom_cross (&tmp, tmp, az);
25564           dwg_geom_normalize (&ax, tmp);
25565         }
25566       dwg_geom_cross (&ay, az, ax);
25567       dwg_geom_normalize (&ay, ay);
25568       out->x = pt.x * ax.x + pt.y * ax.y + pt.z * ax.z;
25569       out->y = pt.x * ay.x + pt.y * ay.y + pt.z * ay.z;
25570       out->z = pt.x * az.x + pt.y * az.y + pt.z * az.z;
25571     }
25572   return out;
25573 }
25574 
25575 // A limited rotation matrix, defining the 3 3d-axis rotations.
25576 // Geometry uses a double[16] transformation matrix with the
25577 // origin/offset on the right side columns.
25578 // and the scale vector as last row.
25579 typedef double dwg_matrix9[9];
25580 
25581 // Via the arbitray axis algorithm we can define the 3 rotations (dwg_matrix9)
25582 // as a single normal. This helper function creates the rotation matrix from the
25583 // normal vector.
25584 static void
dwg_geom_normal_to_matrix9(const dwg_point_3d * restrict normal,dwg_matrix9 * matrix)25585 dwg_geom_normal_to_matrix9 (const dwg_point_3d *restrict normal, dwg_matrix9 *matrix)
25586 {
25587   // TODO for now we keep the unrotated defaults
25588 #if 0
25589   if (normal.x == 0.0 && normal.y == 0.0 && normal.z == 1.0)
25590     {
25591       dwg_matrix9 def_matrix = {
25592         1.0, 0.0, 0.0,
25593         0.0, 1.0, 0.0,
25594         0.0, 0.0, 1.0 };
25595       memcpy (&matrix, &def_matrix, sizeof (dwg_point_3d));
25596       return;
25597     }
25598   else
25599     {
25600       dwg_point_3d ax, ay, az;
25601       memcpy (&az, &normal, sizeof (dwg_point_3d));
25602       if ((fabs (az.x) < 1 / 64.0) && (fabs (az.y) < 1 / 64.0))
25603         {
25604           dwg_point_3d tmp = { 0.0, 1.0, 0.0 };
25605           dwg_geom_cross (&tmp, tmp, az);
25606           dwg_geom_normalize (&ax, tmp);
25607         }
25608       else
25609         {
25610           dwg_point_3d tmp = { 0.0, 0.0, 1.0 };
25611           dwg_geom_cross (&tmp, tmp, az);
25612           dwg_geom_normalize (&ax, tmp);
25613         }
25614       dwg_geom_cross (&ay, az, ax);
25615       dwg_geom_normalize (&ay, ay);
25616       //??
25617       memcpy (&matrix, &ay, sizeof (dwg_point_3d));
25618     }
25619 #endif
25620   ;
25621 }
25622 
25623 static void
dwg_init_ACSH_CLASS(Dwg_Data * restrict dwg,Dwg_Object * restrict obj,void * restrict acsh,Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal)25624 dwg_init_ACSH_CLASS (Dwg_Data *restrict dwg, Dwg_Object *restrict obj,
25625                      void *restrict acsh, Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
25626                      const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal)
25627 {
25628   Dwg_Object_ACSH_BOX_CLASS* _obj = (Dwg_Object_ACSH_BOX_CLASS*)acsh;
25629   dwg_matrix9 matrix = {
25630     1.0, 0.0, 0.0,
25631     0.0, 1.0, 0.0,
25632     0.0, 0.0, 1.0 };
25633 
25634   obj->tio.object->ownerhandle = dwg_add_handleref (
25635       dwg, 5, dwg_obj_generic_handlevalue (evalgraph), obj);
25636   _obj->evalexpr.parentid = -1;
25637   _obj->evalexpr.major = 27;
25638   _obj->evalexpr.minor = 52;
25639   _obj->evalexpr.value_code = -9999;
25640   _obj->evalexpr.nodeid = nodeid;
25641   _obj->history_node.major = 27;
25642   _obj->history_node.minor = 52;
25643   _obj->history_node.color.index = 256;
25644   _obj->history_node.color.rgb = 0xc3000001;
25645   _obj->history_node.color.method = 0xc3;
25646   _obj->history_node.color.flag = 0x0;
25647   _obj->history_node.step_id = 97; //?
25648   _obj->history_node.material = NULL; // => MATERIAL of LAYER "0"
25649   dwg_geom_normal_to_matrix9 (normal, &matrix);
25650   _obj->history_node.trans = calloc (16, 8);
25651   _obj->history_node.trans[0] = matrix[0];
25652   _obj->history_node.trans[1] = matrix[1];
25653   _obj->history_node.trans[2] = matrix[2];
25654   _obj->history_node.trans[3] = origin_pt->x;
25655   _obj->history_node.trans[4] = matrix[3];
25656   _obj->history_node.trans[5] = matrix[4];
25657   _obj->history_node.trans[6] = matrix[5];
25658   _obj->history_node.trans[7] = origin_pt->y;
25659   _obj->history_node.trans[8] = matrix[6];
25660   _obj->history_node.trans[9] = matrix[7];
25661   _obj->history_node.trans[10] = matrix[8];
25662   _obj->history_node.trans[11] = origin_pt->z;
25663   // no scale, keep it at 0.0 from calloc
25664   _obj->history_node.trans[15] = 1.0;
25665   _obj->major = 27;
25666   _obj->minor = 52;
25667 }
25668 
dwg_acis_date(char * date,size_t size)25669 static size_t dwg_acis_date (char *date, size_t size)
25670 {
25671   time_t rawtime;
25672   struct tm *tm;
25673 
25674   time (&rawtime);
25675   tm = localtime (&rawtime);
25676   // "Thu Mar 26 22:02:42 2009"
25677   return strftime (date, size, "%a %b %d %H:%M:%S %Y", tm);
25678 }
25679 
25680 Dwg_Object_ACSH_BOX_CLASS*
dwg_add_ACSH_BOX_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double length,const double width,const double height)25681 dwg_add_ACSH_BOX_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
25682                         const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
25683                         const double length, const double width,
25684                         const double height)
25685 {
25686   int err;
25687   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
25688   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
25689   if (!dwg)
25690     return NULL;
25691   {
25692     API_ADD_OBJECT (ACSH_BOX_CLASS);
25693     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
25694     _obj->length = length;
25695     _obj->width = width;
25696     _obj->height = height;
25697     return _obj;
25698   }
25699 }
25700 
25701 static void
ACSH_init_evalgraph(Dwg_Data * restrict dwg,void * restrict _acsh,Dwg_Entity_3DSOLID * restrict solid)25702 ACSH_init_evalgraph (Dwg_Data *restrict dwg, void *restrict _acsh,
25703                      Dwg_Entity_3DSOLID *restrict solid)
25704 {
25705   int error;
25706   Dwg_Object_ACSH_HISTORY_CLASS *hist;
25707   Dwg_Object_EVALUATION_GRAPH *eval;
25708   Dwg_Object *solidobj, *histobj, *evalobj, *acsh;
25709   BITCODE_H *evalexpr = calloc (1, sizeof (BITCODE_H));
25710 
25711   acsh = dwg_obj_generic_to_object (_acsh, &error);
25712   solidobj = dwg_obj_generic_to_object (solid, &error);
25713 
25714   evalexpr[0] = dwg_add_handleref (dwg, 3, acsh->handle.value, NULL);
25715   eval = dwg_add_EVALUATION_GRAPH (dwg, 0, nodeid++, 1, evalexpr);
25716   evalobj = dwg_obj_generic_to_object (eval, &error);
25717   acsh->tio.object->ownerhandle
25718       = dwg_add_handleref (dwg, 4, evalobj->handle.value, acsh);
25719 
25720   hist = dwg_add_ACSH_HISTORY_CLASS (solid, 1);
25721   hist->owner = dwg_add_handleref (dwg, 3, evalobj->handle.value, NULL);
25722   histobj = dwg_obj_generic_to_object (hist, &error);
25723   solid->history_id
25724       = dwg_add_handleref (dwg, 5, histobj->handle.value, solidobj);
25725   evalobj->tio.object->ownerhandle
25726       = dwg_add_handleref (dwg, 4, histobj->handle.value, evalobj);
25727 }
25728 
25729 EXPORT Dwg_Entity_3DSOLID*
dwg_add_BOX(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double length,const double width,const double height)25730 dwg_add_BOX (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
25731              const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
25732              const double length, const double width,
25733              const double height)
25734 {
25735   int err;
25736   Dwg_Data *dwg;
25737   {
25738     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
25739     dwg = hdr ? hdr->parent : NULL;
25740     if (dwg)
25741       {
25742         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
25743         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
25744         REQUIRE_CLASS ("ACSH_BOX_CLASS");
25745       }
25746     else
25747       return NULL;
25748   }
25749   {
25750     Dwg_Entity_3DSOLID *solid;
25751     Dwg_Object_ACSH_BOX_CLASS *_obj;
25752     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
25753     dwg_matrix9 matrix = {
25754       1.0, 0.0, 0.0,
25755       0.0, 1.0, 0.0,
25756       0.0, 0.0, 1.0 };
25757     #define ACIS_BOX_SIZE 7500
25758     char acis_data[ACIS_BOX_SIZE];
25759     char date[48];
25760     unsigned date_size = dwg_acis_date (date, 48);
25761     // origin: 7.791946762401224191 11.02220663951163004 1.271660108551718515
25762     // length: 4.416106 [BD 40]
25763     // width: 2.044413 [BD 41]
25764     // height: 2.543320 [BD 42]
25765     const double l2 = length / 2.0; // 2.208053237598775809
25766     const double w2 = width / 2.0;  // 1.022206639511630044
25767     const double h2 = height / 2.0; // 1.271660108551718515
25768     const char box_acis_format[] =  /* len = 890 => 957 */
25769         // version num_records num_entities has_history
25770         "700 104 1 0 \n"
25771         // product acis_version date
25772         "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
25773         // num_mm_units resabs resnor
25774         "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
25775         "body $-1 -1 $-1 $1 $-1 $2 #\n"
25776         "lump $-1 -1 $-1 $-1 $3 $0 #\n"
25777         "transform $-1 -1 ""%g %g %g ""%g %g %g ""%g %g %g ""%g %g %g ""1 no_rotate no_reflect no_shear #\n"
25778         "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
25779         "face $5 -1 $-1 $-1 $-1 $3 $-1 $6 forward single #\n"
25780         "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
25781         "face $9 -1 $-1 $10 $11 $3 $-1 $12 reversed single #\n"
25782         "loop $-1 -1 $-1 $-1 $13 $4 #\n"
25783       // h2
25784         "plane-surface $-1 -1 $-1 0 0 %f 0 0 1 -1 0 0 reverse_v I I I I #\n"
25785         "color-adesk-attrib $-1 -1 $-1 $-1 $6 256 #\n"
25786         "face $14 -1 $-1 $15 $16 $3 $-1 $17 reversed single #\n"
25787         "loop $-1 -1 $-1 $-1 $18 $6 #\n"
25788       // -h2
25789         "plane-surface $-1 -1 $-1 0 0 %f 0 0 1 -1 0 0 reverse_v I I I I #\n"
25790         "coedge $-1 -1 $-1 $19 $20 $21 $22 reversed $7 $-1 #\n"
25791         "color-adesk-attrib $-1 -1 $-1 $-1 $10 256 #\n"
25792         "face $23 -1 $-1 $24 $25 $3 $-1 $26 reversed single #\n"
25793         "loop $-1 -1 $-1 $-1 $27 $10 #\n"
25794       // -w2
25795         "plane-surface $-1 -1 $-1 0 %f 0 0 1 0 0 0 1 reverse_v I I I I #\n"
25796         "coedge $-1 -1 $-1 $28 $29 $30 $31 reversed $11 $-1 #\n"
25797         "coedge $-1 -1 $-1 $32 $13 $33 $34 reversed $7 $-1 #\n"
25798         "coedge $-1 -1 $-1 $13 $32 $35 $36 reversed $7 $-1 #\n"
25799         "coedge $-1 -1 $-1 $37 $38 $13 $22 forward $39 $-1 #\n"
25800       // -w2, w2
25801         "edge $40 -1 $-1 $41 %f $42 %f $21 $43 forward @7 unknown #\n"
25802         "color-adesk-attrib $-1 -1 $-1 $-1 $15 256 #\n"
25803         "face $44 -1 $-1 $45 $46 $3 $-1 $47 reversed single #\n"
25804         "loop $-1 -1 $-1 $-1 $48 $15 #\n"
25805         // l2
25806         "plane-surface $-1 -1 $-1 %f 0 0 -1 0 0 0 0 -1 reverse_v I I I I #\n"
25807         "coedge $-1 -1 $-1 $33 $49 $50 $51 reversed $16 $-1 #\n"
25808         "coedge $-1 -1 $-1 $52 $18 $53 $54 reversed $11 $-1 #\n"
25809         "coedge $-1 -1 $-1 $18 $52 $49 $55 reversed $11 $-1 #\n"
25810         "coedge $-1 -1 $-1 $38 $37 $18 $31 forward $39 $-1 #\n"
25811       // -w2, w2
25812         "edge $56 -1 $-1 $57 %f $58 %f $30 $59 forward @7 unknown #\n"
25813         "coedge $-1 -1 $-1 $20 $19 $60 $61 reversed $7 $-1 #\n"
25814         "coedge $-1 -1 $-1 $62 $27 $19 $34 forward $16 $-1 #\n"
25815         // -l2, l2
25816         "edge $63 -1 $-1 $64 %f $41 %f $33 $65 forward @7 unknown #\n"
25817         "coedge $-1 -1 $-1 $66 $67 $20 $36 forward $46 $-1 #\n"
25818         // -l2, l2
25819         "edge $68 -1 $-1 $42 %f $69 %f $35 $70 forward @7 unknown #\n"
25820         "coedge $-1 -1 $-1 $30 $21 $67 $71 forward $39 $-1 #\n"
25821         "coedge $-1 -1 $-1 $21 $30 $62 $72 reversed $39 $-1 #\n"
25822         "loop $-1 -1 $-1 $-1 $38 $45 #\n"
25823         "color-adesk-attrib $-1 -1 $-1 $-1 $22 256 #\n"
25824         "vertex $-1 -1 $-1 $22 $73 #\n"
25825         "vertex $-1 -1 $-1 $22 $74 #\n"
25826         // -l2, h2
25827         "straight-curve $-1 -1 $-1 %f 0 %f 0 1 0 I I #\n"
25828         "color-adesk-attrib $-1 -1 $-1 $-1 $24 256 #\n"
25829         "face $75 -1 $-1 $-1 $39 $3 $-1 $76 reversed single #\n"
25830         "loop $-1 -1 $-1 $-1 $67 $24 #\n"
25831       // w2
25832         "plane-surface $-1 -1 $-1 0 %f 0 0 -1 0 0 0 -1 reverse_v I I I I #\n"
25833         "coedge $-1 -1 $-1 $60 $77 $66 $78 reversed $25 $-1 #\n"
25834         "coedge $-1 -1 $-1 $27 $62 $29 $55 forward $16 $-1 #\n"
25835         "coedge $-1 -1 $-1 $77 $60 $27 $51 forward $25 $-1 #\n"
25836       // -h2, h2
25837         "edge $79 -1 $-1 $64 %f $80 %f $50 $81 forward @7 unknown #\n"
25838         "coedge $-1 -1 $-1 $29 $28 $77 $82 reversed $11 $-1 #\n"
25839         "coedge $-1 -1 $-1 $67 $66 $28 $54 forward $46 $-1 #\n"
25840         // -l2, l2
25841         "edge $83 -1 $-1 $84 %f $57 %f $53 $85 forward @7 unknown #\n"
25842         // -l2, l2
25843         "edge $86 -1 $-1 $58 %f $80 %f $49 $87 forward @7 unknown #\n"
25844         "color-adesk-attrib $-1 -1 $-1 $-1 $31 256 #\n"
25845         "vertex $-1 -1 $-1 $31 $88 #\n"
25846         "vertex $-1 -1 $-1 $72 $89 #\n"
25847         // -l2, -h2
25848         "straight-curve $-1 -1 $-1 %f 0 %f 0 -1 0 I I #\n"
25849         "coedge $-1 -1 $-1 $50 $48 $32 $61 forward $25 $-1 #\n"
25850       // -w2, w2
25851         "edge $90 -1 $-1 $69 %f $64 %f $60 $91 forward @7 unknown #\n"
25852         "coedge $-1 -1 $-1 $49 $33 $38 $72 forward $16 $-1 #\n"
25853         "color-adesk-attrib $-1 -1 $-1 $-1 $34 256 #\n"
25854         "vertex $-1 -1 $-1 $61 $92 #\n"
25855       // -w2, h2
25856         "straight-curve $-1 -1 $-1 0 %f %f -1 0 0 I I #\n"
25857         "coedge $-1 -1 $-1 $53 $35 $48 $78 forward $46 $-1 #\n"
25858         "coedge $-1 -1 $-1 $35 $53 $37 $71 reversed $46 $-1 #\n"
25859         "color-adesk-attrib $-1 -1 $-1 $-1 $36 256 #\n"
25860         "vertex $-1 -1 $-1 $36 $93 #\n"
25861       // w2, h2
25862         "straight-curve $-1 -1 $-1 0 %f %f 1 0 0 I I #\n"
25863       // -h2, h2
25864         "edge $94 -1 $-1 $42 %f $57 %f $37 $95 forward @7 unknown #\n"
25865       // -h2, h2
25866         "edge $96 -1 $-1 $41 %f $58 %f $38 $97 forward @7 unknown #\n"
25867       // -l2 -w2 h2
25868         "point $-1 -1 $-1 %f %f %f #\n"
25869       // -l2 w2 h2
25870         "point $-1 -1 $-1 %f %f %f #\n"
25871         "color-adesk-attrib $-1 -1 $-1 $-1 $45 256 #\n"
25872       // -l2
25873         "plane-surface $-1 -1 $-1 %f 0 0 1 0 0 0 0 1 reverse_v I I I I #\n"
25874         "coedge $-1 -1 $-1 $48 $50 $52 $82 forward $25 $-1 #\n"
25875       // -h2, h2
25876         "edge $98 -1 $-1 $69 %f $84 %f $66 $99 forward @7 unknown #\n"
25877         "color-adesk-attrib $-1 -1 $-1 $-1 $51 256 #\n"
25878         "vertex $-1 -1 $-1 $82 $100 #\n"
25879       // l2 -w2
25880         "straight-curve $-1 -1 $-1 %f %f 0 0 0 -1 I I #\n"
25881       // -w2 w2
25882         "edge $101 -1 $-1 $80 %f $84 %f $77 $102 forward @7 unknown #\n"
25883         "color-adesk-attrib $-1 -1 $-1 $-1 $54 256 #\n"
25884         "vertex $-1 -1 $-1 $54 $103 #\n"
25885       // w2 -h2
25886         "straight-curve $-1 -1 $-1 0 %f %f -1 0 0 I I #\n"
25887         "color-adesk-attrib $-1 -1 $-1 $-1 $55 256 #\n"
25888       // -w2 -h2
25889         "straight-curve $-1 -1 $-1 0 %f %f 1 0 0 I I #\n"
25890       // -l2 w2 -h2
25891         "point $-1 -1 $-1 %f %f %f #\n"
25892       // -l2 -w2 -h2
25893         "point $-1 -1 $-1 %f %f %f #\n"
25894         "color-adesk-attrib $-1 -1 $-1 $-1 $61 256 #\n"
25895       // l2, h2
25896         "straight-curve $-1 -1 $-1 %f 0 %f 0 -1 0 I I #\n"
25897       // l2 -w2 h2
25898         "point $-1 -1 $-1 %f %f %f #\n"
25899       // l2 w2 h2
25900         "point $-1 -1 $-1 %f %f %f #\n"
25901         "color-adesk-attrib $-1 -1 $-1 $-1 $71 256 #\n"
25902       // -l2 w2
25903         "straight-curve $-1 -1 $-1 %f %f 0 0 0 -1 I I #\n"
25904         "color-adesk-attrib $-1 -1 $-1 $-1 $72 256 #\n"
25905       // -l2 -w2
25906         "straight-curve $-1 -1 $-1 %f %f 0 0 0 -1 I I #\n"
25907         "color-adesk-attrib $-1 -1 $-1 $-1 $78 256 #\n"
25908       // l2, w2
25909         "straight-curve $-1 -1 $-1 %f %f 0 0 0 -1 I I #\n"
25910       // l2 -w2 -h2
25911         "point $-1 -1 $-1 %f %f %f #\n"
25912         "color-adesk-attrib $-1 -1 $-1 $-1 $82 256 #\n"
25913       // l2, -h2
25914         "straight-curve $-1 -1 $-1 %f 0 %f 0 1 0 I I #\n"
25915       // l2 w2 -h2
25916         "point $-1 -1 $-1 %f %f %f #\n"
25917         "End-of-ACIS-data\n";
25918     dwg_geom_normal_to_matrix9 (normal, &matrix);
25919     snprintf (acis_data, ACIS_BOX_SIZE, box_acis_format, date_size, date,
25920               matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5],
25921               matrix[6], matrix[7], matrix[8],
25922               // clang-format off
25923               origin_pt->x, origin_pt->y, origin_pt->z,
25924               h2,
25925               -h2,
25926               -w2,
25927               -w2, w2,
25928               l2,
25929               -w2, w2,
25930               -l2, l2,
25931               -l2, l2,
25932               -l2, h2,
25933               w2,
25934               -h2, h2,
25935               -l2, l2,
25936               -l2, l2,
25937               -l2, -h2,
25938               -w2, w2,
25939               -w2, h2,
25940               w2, h2,
25941               -h2, h2,
25942               -h2, h2,
25943               -l2, -w2, h2,
25944               -l2, w2, h2,
25945               -l2,
25946               -h2, h2,
25947               l2, -w2,
25948               -w2, w2,
25949               w2, -h2,
25950               -w2, -h2,
25951               -l2, w2, -h2,
25952               -l2, -w2, -h2,
25953               l2, h2,
25954               l2, -w2, h2,
25955               l2, w2, h2,
25956               -l2, w2,
25957               -l2, -w2,
25958               l2, w2,
25959               l2, -w2, -h2,
25960               l2, -h2,
25961               l2, w2, -h2
25962               );
25963     // clang-format on
25964     solid = dwg_add_3DSOLID (blkhdr, acis_data);
25965     solid->wireframe_data_present = 1;
25966     solid->point_present = 1;
25967     solid->point.x = origin_pt->x;
25968     solid->point.y = origin_pt->y;
25969     solid->point.z = origin_pt->z;
25970     solid->acis_empty_bit = 1;
25971 
25972     _obj = dwg_add_ACSH_BOX_CLASS ((void*)solid, origin_pt, normal ? normal : &defnormal,
25973                                    length, width, height);
25974     ACSH_init_evalgraph (dwg, _obj, solid);
25975     return solid;
25976   }
25977 }
25978 
25979 // ACSH_BREP_CLASS
25980 
25981 Dwg_Object_ACSH_CHAMFER_CLASS*
dwg_add_ACSH_CHAMFER_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const int bl92,const double base_dist,const double other_dist,const int num_edges,const int32_t * edges,const int bl95)25982 dwg_add_ACSH_CHAMFER_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
25983                             const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
25984                             const int bl92, const double base_dist,
25985                             const double other_dist, const int num_edges,
25986                             const int32_t* edges, const int bl95)
25987 {
25988   int err;
25989   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
25990   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
25991   if (!dwg)
25992     return NULL;
25993   {
25994     API_ADD_OBJECT (ACSH_CHAMFER_CLASS);
25995     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
25996     _obj->bl92 = bl92;
25997     _obj->base_dist = base_dist;
25998     _obj->other_dist = other_dist;
25999     _obj->num_edges = num_edges;
26000     if (num_edges)
26001       {
26002         _obj->edges = calloc (num_edges, 4);
26003         memcpy (_obj->edges, edges, num_edges * 4);
26004       }
26005     _obj->bl95 = bl95;
26006     return _obj;
26007   }
26008 }
26009 
26010 #if 0
26011 EXPORT Dwg_Entity_3DSOLID*
26012 dwg_add_CHAMFER (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26013                  const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26014                  const int bl92, const double base_dist,
26015                  const double other_dist, const int num_edges,
26016                  const int32_t* edges, const int bl95)
26017 {
26018   int err;
26019   Dwg_Data *dwg;
26020   {
26021     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26022     dwg = hdr ? hdr->parent : NULL;
26023     if (dwg)
26024       {
26025         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26026         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26027         REQUIRE_CLASS ("ACSH_CHAMFER_CLASS");
26028       }
26029     else
26030       return NULL;
26031   }
26032   {
26033     Dwg_Entity_3DSOLID *solid;
26034     Dwg_Object_ACSH_CHAMFER_CLASS *_obj;
26035     Dwg_Object_ACSH_HISTORY_CLASS *hist;
26036     Dwg_Object_EVALUATION_GRAPH *eval;
26037     Dwg_Object *solidobj, *histobj, *evalobj, *acsh;
26038     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26039     dwg_matrix9 matrix = {
26040       1.0, 0.0, 0.0,
26041       0.0, 1.0, 0.0,
26042       0.0, 0.0, 1.0 };
26043     char acis_data[1048];
26044     char date[48];
26045     unsigned date_size = dwg_acis_date (date, 48);
26046     // acis version 106 (r14) would be nicer
26047     const char base_acis_format[] = /* len = 890 => 957 */
26048       // version num_records num_entities has_history
26049       "400 6 1 0 \n"
26050       // product acis_version date
26051       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26052       // num_mm_units resabs resnor
26053       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26054       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26055       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26056       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26057       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26058       "face $5 -1 $-1 $-1 $-1 $3 $-1 $6 forward single #\n"
26059       "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
26060       "End-of-ACIS-data\n";
26061     //FIXME
26062     dwg_geom_normal_to_matrix9 (normal, &matrix);
26063     snprintf (acis_data, 1048, base_acis_format,
26064               date_size, date,
26065               matrix[0], matrix[1], matrix[2],
26066               matrix[3], matrix[4], matrix[5],
26067               matrix[6], matrix[7], matrix[8],
26068               origin_pt->x, origin_pt->y, origin_pt->z);
26069     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26070     solidobj = dwg_obj_generic_to_object (solid, &err);
26071     solid->wireframe_data_present = 1;
26072     solid->point_present = 1;
26073     solid->point.x = origin_pt->x;
26074     solid->point.y = origin_pt->y;
26075     solid->point.z = origin_pt->z;
26076     solid->acis_empty_bit = 1;
26077 
26078     _obj = dwg_add_ACSH_CHAMFER_CLASS (
26079         (void *)solid, origin_pt, normal ? normal : &defnormal, bl92,
26080         base_dist, other_dist, num_edges, edges, bl95);
26081     ACSH_init_evalgraph (dwg, _obj, solid);
26082     return solid;
26083   }
26084 }
26085 #endif
26086 
26087 Dwg_Object_ACSH_CONE_CLASS*
dwg_add_ACSH_CONE_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double height,const double major_radius,const double minor_radius,const double x_radius)26088 dwg_add_ACSH_CONE_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
26089                          const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26090                          const double height, const double major_radius,
26091                          const double minor_radius, const double x_radius)
26092 {
26093   int err;
26094   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
26095   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
26096   if (!dwg)
26097     return NULL;
26098   {
26099     API_ADD_OBJECT (ACSH_CONE_CLASS);
26100     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
26101     _obj->height = height;
26102     _obj->major_radius = major_radius;
26103     _obj->minor_radius = minor_radius;
26104     _obj->x_radius = x_radius;
26105     return _obj;
26106   }
26107 }
26108 
26109 // same as CYLINDER
26110 EXPORT Dwg_Entity_3DSOLID*
dwg_add_CONE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double height,const double major_radius,const double minor_radius,const double x_radius)26111 dwg_add_CONE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26112               const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26113               const double height, const double major_radius,
26114               const double minor_radius, const double x_radius)
26115 {
26116   int err;
26117   Dwg_Data *dwg;
26118   {
26119     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26120     dwg = hdr ? hdr->parent : NULL;
26121     if (dwg)
26122       {
26123         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26124         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26125         REQUIRE_CLASS ("ACSH_CONE_CLASS");
26126       }
26127     else
26128       return NULL;
26129   }
26130   {
26131     Dwg_Entity_3DSOLID *solid;
26132     Dwg_Object_ACSH_CONE_CLASS *_obj;
26133     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26134     dwg_matrix9 matrix = {
26135       1.0, 0.0, 0.0,
26136       0.0, 1.0, 0.0,
26137       0.0, 0.0, 1.0 };
26138     double h2 = height / 2.0;
26139     double majr2 = major_radius / 2.0;
26140     double minr2 = minor_radius / 2.0;
26141     double x2 = x_radius / 2.0;
26142     double dbl_pi = 2.0 * M_PI; // i.e. 360
26143     char acis_data[1600];
26144     char date[48];
26145     unsigned date_size = dwg_acis_date (date, 48);
26146     const char cone_acis_format[] = /* len = 1200? => 1338 */
26147       // version num_records num_entities has_history
26148       "400 27 1 0 \n"
26149       // product acis_version date
26150       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26151       // num_mm_units resabs resnor
26152       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26153       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26154       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26155       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26156       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26157       "face $5 -1 $-1 $6 $7 $3 $-1 $8 forward single #\n"
26158       "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
26159       "face $9 -1 $-1 $-1 $10 $3 $-1 $11 forward single #\n"
26160       "loop $-1 -1 $-1 $12 $13 $4 #\n"
26161       "cone-surface $-1 -1 $-1 0 0 0 0 0 1 %f 0 0 1 I I %f %f %f forward I I I I #\n" // 2.5, -0.3162277660168379412 0.948683298050513768 2.5
26162       "color-adesk-attrib $-1 -1 $-1 $-1 $6 256 #\n"
26163       "loop $-1 -1 $-1 $-1 $14 $6 #\n"
26164       "plane-surface $-1 -1 $-1 0 0 %f 0 0 -1 -1 0 0 forward_v I I I I #\n" // -7.5
26165       "loop $-1 -1 $-1 $-1 $15 $4 #\n"
26166       "coedge $-1 -1 $-1 $13 $13 $14 $16 reversed $7 $-1 #\n"
26167       "coedge $-1 -1 $-1 $14 $14 $13 $16 forward $10 $-1 #\n"
26168       "coedge $-1 -1 $-1 $15 $15 $-1 $17 reversed $12 $-1 #\n"
26169       "edge $18 -1 $-1 $19 0 $19 %f $14 $20 forward @7 unknown #\n" // 2*pi
26170       "edge $21 -1 $-1 $22 1 $22 0 $15 $-1 forward @7 unknown #\n"
26171       "color-adesk-attrib $-1 -1 $-1 $-1 $16 256 #\n"
26172       "vertex $-1 -1 $-1 $16 $23 #\n"
26173       "ellipse-curve $-1 -1 $-1 0 0 %f 0 0 -1 %f 0 0 1 I I #\n" // -7.5, 5
26174       "color-adesk-attrib $-1 -1 $-1 $-1 $17 256 #\n"
26175       "vertex $-1 -1 $-1 $17 $24 #\n"
26176       "point $-1 -1 $-1 %f 0 %f #\n"   // 5, -7.5
26177       "point $-1 -1 $-1 %f 0 %f #\n"  // 0, 7.5
26178       "End-of-ACIS-data\n";
26179     // pt: 10, 10, 7.5
26180     //height: 15.000000 [BD 40]
26181     //major_radius: 5.000000 [BD 41]
26182     //minor_radius: 5.000000 [BD 42]
26183     //x_radius: 0.000000 [BD 43]
26184     dwg_geom_normal_to_matrix9 (normal, &matrix);
26185     snprintf (acis_data, 1600, cone_acis_format,
26186               date_size, date,
26187               matrix[0], matrix[1], matrix[2],
26188               matrix[3], matrix[4], matrix[5],
26189               matrix[6], matrix[7], matrix[8],
26190               origin_pt->x, origin_pt->y, origin_pt->z,
26191               majr2, -0.3162277660168379412, 0.948683298050513768, minr2, //?
26192               -majr2, dbl_pi,
26193               -majr2, major_radius,
26194               minor_radius, -h2,
26195               x_radius, h2);
26196     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26197     solid->wireframe_data_present = 1;
26198     solid->point_present = 1;
26199     solid->point.x = origin_pt->x;
26200     solid->point.y = origin_pt->y;
26201     solid->point.z = origin_pt->z;
26202     solid->acis_empty_bit = 1;
26203 
26204     _obj = dwg_add_ACSH_CONE_CLASS (
26205         (void *)solid, origin_pt, normal ? normal : &defnormal, height,
26206         major_radius, minor_radius, x_radius);
26207     ACSH_init_evalgraph (dwg, _obj, solid);
26208     return solid;
26209   }
26210 }
26211 
26212 Dwg_Object_ACSH_CYLINDER_CLASS*
dwg_add_ACSH_CYLINDER_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double height,const double major_radius,const double minor_radius,const double x_radius)26213 dwg_add_ACSH_CYLINDER_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
26214                              const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26215                              const double height, const double major_radius,
26216                              const double minor_radius, const double x_radius)
26217 {
26218   int err;
26219   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
26220   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
26221   if (!dwg)
26222     return NULL;
26223   {
26224     API_ADD_OBJECT (ACSH_CYLINDER_CLASS);
26225     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
26226     _obj->height = height;
26227     _obj->major_radius = major_radius;
26228     _obj->minor_radius = minor_radius;
26229     _obj->x_radius = x_radius;
26230     return _obj;
26231   }
26232 }
26233 
26234 // TODO compare to a cone, it's the same
26235 EXPORT Dwg_Entity_3DSOLID*
dwg_add_CYLINDER(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double height,const double major_radius,const double minor_radius,const double x_radius)26236 dwg_add_CYLINDER (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26237                   const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26238                   const double height, const double major_radius,
26239                   const double minor_radius, const double x_radius)
26240 {
26241   int err;
26242   Dwg_Data *dwg;
26243   {
26244     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26245     dwg = hdr ? hdr->parent : NULL;
26246     if (dwg)
26247       {
26248         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26249         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26250         REQUIRE_CLASS ("ACSH_CYLINDER_CLASS");
26251       }
26252     else
26253       return NULL;
26254   }
26255   {
26256     Dwg_Entity_3DSOLID *solid;
26257     Dwg_Object_ACSH_CYLINDER_CLASS *_obj;
26258     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26259     dwg_matrix9 matrix = {
26260       1.0, 0.0, 0.0,
26261       0.0, 1.0, 0.0,
26262       0.0, 0.0, 1.0 };
26263     double h2 = height / 2.0;
26264     double dbl_pi = 2.0 * M_PI; // i.e. 360
26265     char acis_data[2000];
26266     char date[48];
26267     unsigned date_size = dwg_acis_date (date, 48);
26268     // acis version 106 (r14) would be nicer
26269     const char cylinder_acis_format[] = /* len = 890 => 1609 */
26270       // version num_records num_entities has_history
26271       "400 30 1 0 \n"
26272       // product acis_version date
26273       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26274       // num_mm_units resabs resnor
26275       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26276       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26277       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26278       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26279       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26280       "face $5 -1 $-1 $6 $7 $3 $-1 $8 forward single #\n"
26281       "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
26282       "face $9 -1 $-1 $10 $11 $3 $-1 $12 forward single #\n"
26283       "loop $-1 -1 $-1 $13 $14 $4 #\n"
26284       "cone-surface $-1 -1 $-1 0 0 0 0 0 1 %g 0 0 1 I I 0 1 %g forward I I I I #\n"
26285       "color-adesk-attrib $-1 -1 $-1 $-1 $6 256 #\n"
26286       "face $15 -1 $-1 $-1 $16 $3 $-1 $17 forward single #\n"
26287       "loop $-1 -1 $-1 $-1 $18 $6 #\n"
26288       "plane-surface $-1 -1 $-1 0 0 %g 0 0 -1 -1 0 0 forward_v I I I I #\n" // -height/2
26289       "loop $-1 -1 $-1 $-1 $19 $4 #\n"
26290       "coedge $-1 -1 $-1 $14 $14 $18 $20 reversed $7 $-1 #\n"
26291       "color-adesk-attrib $-1 -1 $-1 $-1 $10 256 #\n"
26292       "loop $-1 -1 $-1 $-1 $21 $10 #\n"
26293       "plane-surface $-1 -1 $-1 0 0 %g 0 0 1 1 0 0 forward_v I I I I #\n" // height/2
26294       "coedge $-1 -1 $-1 $18 $18 $14 $20 forward $11 $-1 #\n"
26295       "coedge $-1 -1 $-1 $19 $19 $21 $22 reversed $13 $-1 #\n"
26296       "edge $23 -1 $-1 $24 0 $24 %g $18 $25 forward @7 unknown #\n" // 2*pi
26297       "coedge $-1 -1 $-1 $21 $21 $19 $22 forward $16 $-1 #\n"
26298       "edge $26 -1 $-1 $27 0 $27 %g $21 $28 forward @7 unknown #\n" // 2*pi
26299       "color-adesk-attrib $-1 -1 $-1 $-1 $20 256 #\n"
26300       "vertex $-1 -1 $-1 $20 $29 #\n"
26301       "ellipse-curve $-1 -1 $-1 0 0 %g 0 0 -1 %g 0 0 1 I I #\n" // -height/2, major_radius
26302       "color-adesk-attrib $-1 -1 $-1 $-1 $22 256 #\n"
26303       "vertex $-1 -1 $-1 $22 $30 #\n"
26304       "ellipse-curve $-1 -1 $-1 0 0 %g 0 0 1 %g 0 0 1 I I #\n"   // -height/2, minor_radius
26305       "point $-1 -1 $-1 %g 0 %g #\n"  // major_radius, -height/2,
26306       "point $-1 -1 $-1 %g 0 %g #\n" // major_radius, height/2,
26307       "End-of-ACIS-data\n";
26308     dwg_geom_normal_to_matrix9 (normal, &matrix);
26309     snprintf (acis_data, 2000, cylinder_acis_format,
26310               date_size, date,
26311               matrix[0], matrix[1], matrix[2],
26312               matrix[3], matrix[4], matrix[5],
26313               matrix[6], matrix[7], matrix[8],
26314               origin_pt->x, origin_pt->y, origin_pt->z,
26315               major_radius, minor_radius,
26316               -h2, h2, dbl_pi, dbl_pi,
26317               -h2, major_radius, -h2, major_radius,
26318               major_radius, -h2, major_radius, h2);
26319     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26320     solid->wireframe_data_present = 1;
26321     solid->point_present = 1;
26322     solid->point.x = origin_pt->x;
26323     solid->point.y = origin_pt->y;
26324     solid->point.z = origin_pt->z;
26325     solid->acis_empty_bit = 1;
26326 
26327     _obj = dwg_add_ACSH_CYLINDER_CLASS ((void*)solid, origin_pt, normal ? normal : &defnormal,
26328                                         height, major_radius, minor_radius, x_radius);
26329     ACSH_init_evalgraph (dwg, _obj, solid);
26330     return solid;
26331   }
26332 }
26333 
26334 Dwg_Object_ACSH_PYRAMID_CLASS*
dwg_add_ACSH_PYRAMID_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double height,const int sides,const double radius,const double topradius)26335 dwg_add_ACSH_PYRAMID_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
26336                             const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26337                             const double height, const int sides,
26338                             const double radius, const double topradius)
26339 {
26340   int err;
26341   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
26342   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
26343   if (!dwg)
26344     return NULL;
26345   {
26346     API_ADD_OBJECT (ACSH_PYRAMID_CLASS);
26347     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
26348     _obj->height = height;
26349     _obj->sides = sides;
26350     _obj->radius = radius;
26351     _obj->topradius = topradius;
26352     return _obj;
26353   }
26354 }
26355 
26356 // not yet implemented
26357 EXPORT Dwg_Entity_3DSOLID*
dwg_add_PYRAMID(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double height,const int sides,const double radius,const double topradius)26358 dwg_add_PYRAMID (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26359                  const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26360                  const double height, const int sides,
26361                  const double radius, const double topradius)
26362 {
26363   int err;
26364   Dwg_Data *dwg;
26365   {
26366     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26367     dwg = hdr ? hdr->parent : NULL;
26368     if (dwg)
26369       {
26370         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26371         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26372         REQUIRE_CLASS ("ACSH_PYRAMID_CLASS");
26373       }
26374     else
26375       return NULL;
26376   }
26377   {
26378     Dwg_Entity_3DSOLID *solid;
26379     Dwg_Object_ACSH_PYRAMID_CLASS *_obj;
26380     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26381     dwg_matrix9 matrix = {
26382       1.0, 0.0, 0.0,
26383       0.0, 1.0, 0.0,
26384       0.0, 0.0, 1.0 };
26385     char acis_data[1048];
26386     char date[48];
26387     unsigned date_size = dwg_acis_date (date, 48);
26388     // acis version 106 (r14) would be nicer
26389     const char base_acis_format[] = /* len = 890 => 957 */
26390       // version num_records num_entities has_history
26391       "400 6 1 0 \n"
26392       // product acis_version date
26393       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26394       // num_mm_units resabs resnor
26395       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26396       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26397       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26398       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26399       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26400       "face $5 -1 $-1 $-1 $-1 $3 $-1 $6 forward single #\n"
26401       "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
26402       "End-of-ACIS-data\n";
26403     // TODO
26404     dwg_geom_normal_to_matrix9 (normal, &matrix);
26405     snprintf (acis_data, 1048, base_acis_format,
26406               date_size, date,
26407               matrix[0], matrix[1], matrix[2],
26408               matrix[3], matrix[4], matrix[5],
26409               matrix[6], matrix[7], matrix[8],
26410               origin_pt->x, origin_pt->y, origin_pt->z);
26411     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26412     solid->wireframe_data_present = 1;
26413     solid->point_present = 1;
26414     solid->point.x = origin_pt->x;
26415     solid->point.y = origin_pt->y;
26416     solid->point.z = origin_pt->z;
26417     solid->acis_empty_bit = 1;
26418 
26419     _obj = dwg_add_ACSH_PYRAMID_CLASS ((void*)solid, origin_pt, normal ? normal : &defnormal,
26420                                        height, sides, radius, topradius);
26421     ACSH_init_evalgraph (dwg, _obj, solid);
26422     return solid;
26423   }
26424 }
26425 
26426 //EXPORT Dwg_Entity_3DSOLID*
26427 //dwg_add_ELLIPTICAL_CONE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26428 //                         const dwg_point_3d *restrict origin_pt,
26429 //                         const dwg_point_3d *restrict normal, /* maybe NULL */
26430 //                         const double major_radius,
26431 //                         const double minor_radius,
26432 //                         const double height)
26433 //{
26434 //  LOG_ERROR ("%s not yet implemented", __FUNCTION__)
26435 //  return NULL;
26436 //}
26437 //
26438 //EXPORT Dwg_Entity_3DSOLID*
26439 //dwg_add_ELLIPTICAL_CYLINDER (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26440 //                             const dwg_point_3d *restrict origin_pt,
26441 //                             const dwg_point_3d *restrict normal, /* maybe NULL */
26442 //                             const double major_radius,
26443 //                             const double minor_radius,
26444 //                             const double height)
26445 //{
26446 //  LOG_ERROR ("%s not yet implemented", __FUNCTION__)
26447 //  return NULL;
26448 //}
26449 
26450 EXPORT Dwg_Entity_3DSOLID*
dwg_add_EXTRUDED_SOLID(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const Dwg_Object * restrict profile,const double height,const double taper_angle)26451 dwg_add_EXTRUDED_SOLID (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26452                         const Dwg_Object *restrict profile,
26453                         const double height,
26454                         const double taper_angle)
26455 {
26456   LOG_ERROR ("%s not yet implemented", __FUNCTION__)
26457   return NULL;
26458 }
26459 EXPORT Dwg_Entity_3DSOLID*
dwg_add_EXTRUDED_PATH(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const Dwg_Object * restrict profile,const double height,const double taper_angle)26460 dwg_add_EXTRUDED_PATH (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26461                        const Dwg_Object *restrict profile,
26462                        const double height,
26463                        const double taper_angle)
26464 {
26465   LOG_ERROR ("%s not yet implemented", __FUNCTION__)
26466   return NULL;
26467 }
26468 
26469 EXPORT Dwg_Entity_3DSOLID*
dwg_add_REVOLVED_SOLID(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const Dwg_Object * restrict profile,const dwg_point_3d * restrict axis_pt,const dwg_point_3d * restrict axis_dir,const double angle)26470 dwg_add_REVOLVED_SOLID (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26471                         const Dwg_Object *restrict profile,
26472                         const dwg_point_3d *restrict axis_pt,
26473                         const dwg_point_3d *restrict axis_dir,
26474                         const double angle)
26475 {
26476   LOG_ERROR ("%s not yet implemented", __FUNCTION__)
26477   return NULL;
26478 }
26479 
26480 // ACSH_EXTRUSION_CLASS (needed)
26481 // ACSH_FILLET_CLASS
26482 // ACSH_LOFT_CLASS
26483 // ACSH_REVOLVE_CLASS (needed)
26484 
26485 Dwg_Object_ACSH_SPHERE_CLASS*
dwg_add_ACSH_SPHERE_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double radius)26486 dwg_add_ACSH_SPHERE_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
26487                            const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26488                            const double radius)
26489 {
26490   int err;
26491   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
26492   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
26493   if (!dwg)
26494     return NULL;
26495   {
26496     API_ADD_OBJECT (ACSH_SPHERE_CLASS);
26497     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
26498     _obj->radius = radius;
26499     return _obj;
26500   }
26501 }
26502 
26503 EXPORT Dwg_Entity_3DSOLID*
dwg_add_SPHERE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double radius)26504 dwg_add_SPHERE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26505                 const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26506                 const double radius)
26507 {
26508   int err;
26509   Dwg_Data *dwg;
26510   {
26511     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26512     dwg = hdr ? hdr->parent : NULL;
26513     if (dwg)
26514       {
26515         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26516         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26517         REQUIRE_CLASS ("ACSH_SPHERE_CLASS");
26518       }
26519     else
26520       return NULL;
26521   }
26522   {
26523     Dwg_Entity_3DSOLID *solid;
26524     Dwg_Object_ACSH_SPHERE_CLASS *_obj;
26525     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26526     dwg_matrix9 matrix = {
26527       1.0, 0.0, 0.0,
26528       0.0, 1.0, 0.0,
26529       0.0, 0.0, 1.0 };
26530     char acis_data[650];
26531     char date[48];
26532     unsigned date_size = dwg_acis_date (date, 48);
26533     const char sphere_acis_format[] = /* len = 524 => 552 */
26534       // version num_records num_entities has_history
26535       "400 7 1 0 \n"
26536       // product acis_version date
26537       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26538       // num_mm_units resabs resnor
26539       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26540       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26541       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26542       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26543       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26544       "face $5 -1 $-1 $-1 $-1 $3 $-1 $6 forward single #\n"
26545       "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
26546       "sphere-surface $-1 -1 $-1 0 0 0 %g 1 0 0 0 0 1 forward_v I I I I #\n"
26547       "End-of-ACIS-data\n";
26548     dwg_geom_normal_to_matrix9 (normal, &matrix);
26549     snprintf (acis_data, 650, sphere_acis_format,
26550               date_size, date,
26551               matrix[0], matrix[1], matrix[2],
26552               matrix[3], matrix[4], matrix[5],
26553               matrix[6], matrix[7], matrix[8],
26554               origin_pt->x, origin_pt->y, origin_pt->z,
26555               radius);
26556     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26557     solid->wireframe_data_present = 1;
26558     solid->point_present = 1;
26559     solid->point.x = origin_pt->x;
26560     solid->point.y = origin_pt->y;
26561     solid->point.z = origin_pt->z;
26562     solid->acis_empty_bit = 1;
26563 
26564     _obj = dwg_add_ACSH_SPHERE_CLASS ((void *)solid, origin_pt,
26565                                       normal ? normal : &defnormal, radius);
26566     ACSH_init_evalgraph (dwg, _obj, solid);
26567     return solid;
26568   }
26569 }
26570 
26571 // ACSH_SWEEP_CLASS
26572 
26573 Dwg_Object_ACSH_TORUS_CLASS*
dwg_add_ACSH_TORUS_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double major_radius,const double minor_radius)26574 dwg_add_ACSH_TORUS_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
26575                           const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26576                           const double major_radius, const double minor_radius)
26577 {
26578   int err;
26579   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
26580   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
26581   if (!dwg)
26582     return NULL;
26583   {
26584     API_ADD_OBJECT (ACSH_TORUS_CLASS);
26585     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
26586     _obj->major_radius = major_radius;
26587     _obj->minor_radius = minor_radius;
26588     return _obj;
26589   }
26590 }
26591 
26592 EXPORT Dwg_Entity_3DSOLID*
dwg_add_TORUS(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double major_radius,const double minor_radius)26593 dwg_add_TORUS (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26594                const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26595                const double major_radius, const double minor_radius)
26596 {
26597   int err;
26598   Dwg_Data *dwg;
26599   {
26600     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26601     dwg = hdr ? hdr->parent : NULL;
26602     if (dwg)
26603       {
26604         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26605         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26606         REQUIRE_CLASS ("ACSH_TORUS_CLASS");
26607       }
26608     else
26609       return NULL;
26610   }
26611   {
26612     Dwg_Entity_3DSOLID *solid;
26613     Dwg_Object_ACSH_TORUS_CLASS *_obj;
26614     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26615     dwg_matrix9 matrix = {
26616       1.0, 0.0, 0.0,
26617       0.0, 1.0, 0.0,
26618       0.0, 0.0, 1.0 };
26619     char acis_data[1048];
26620     char date[48];
26621     unsigned date_size = dwg_acis_date (date, 48);
26622     // acis version 106 (r14) would be nicer
26623     const char torus_acis_format[] = /* len = 890 => 957 */
26624       // version num_records num_entities has_history
26625       "400 19 1 0 \n"
26626       // product acis_version date
26627       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26628       // num_mm_units resabs resnor
26629       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26630       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26631       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26632       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26633       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26634       "face $5 -1 $-1 $-1 $6 $3 $-1 $7 forward single #\n"
26635       "color-adesk-attrib $-1 -1 $-1 $-1 $4 256 #\n"
26636       "loop $-1 -1 $-1 $8 $9 $4 #\n"
26637       "torus-surface $-1 -1 $-1 0 0 0 0 0 1 %g %g 1 0 0 forward_v I I I I #\n"
26638       "loop $-1 -1 $-1 $-1 $10 $4 #\n"
26639       "coedge $-1 -1 $-1 $9 $9 $-1 $11 reversed $6 $-1 #\n"
26640       "coedge $-1 -1 $-1 $10 $10 $-1 $12 reversed $8 $-1 #\n"
26641       "edge $13 -1 $-1 $14 1 $14 0 $9 $-1 forward @7 unknown #\n"
26642       "edge $15 -1 $-1 $16 1 $16 0 $10 $-1 forward @7 unknown #\n"
26643       "color-adesk-attrib $-1 -1 $-1 $-1 $11 256 #\n"
26644       "vertex $-1 -1 $-1 $11 $17 #\n"
26645       "color-adesk-attrib $-1 -1 $-1 $-1 $12 256 #\n"
26646       "vertex $-1 -1 $-1 $12 $18 #\n"
26647       "point $-1 -1 $-1 0 0 %g #\n"
26648       "point $-1 -1 $-1 0 0 %g #\n"
26649       "End-of-ACIS-data\n";
26650     dwg_geom_normal_to_matrix9 (normal, &matrix);
26651     snprintf (acis_data, 1048, torus_acis_format,
26652               date_size, date,
26653               matrix[0], matrix[1], matrix[2],
26654               matrix[3], matrix[4], matrix[5],
26655               matrix[6], matrix[7], matrix[8],
26656               origin_pt->x, origin_pt->y, origin_pt->z,
26657               major_radius, minor_radius,
26658               major_radius, -major_radius);
26659     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26660     solid->wireframe_data_present = 1;
26661     solid->point_present = 1;
26662     solid->point.x = origin_pt->x;
26663     solid->point.y = origin_pt->y;
26664     solid->point.z = origin_pt->z;
26665     solid->acis_empty_bit = 1;
26666 
26667     _obj = dwg_add_ACSH_TORUS_CLASS ((void*)solid, origin_pt,
26668                                      normal ? normal : &defnormal,
26669                                      major_radius, minor_radius);
26670     ACSH_init_evalgraph (dwg, _obj, solid);
26671     return solid;
26672   }
26673 }
26674 
26675 Dwg_Object_ACSH_WEDGE_CLASS*
dwg_add_ACSH_WEDGE_CLASS(Dwg_Object_EVALUATION_GRAPH * restrict evalgraph,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double length,const double width,const double height)26676 dwg_add_ACSH_WEDGE_CLASS (Dwg_Object_EVALUATION_GRAPH *restrict evalgraph,
26677                           const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26678                           const double length, const double width,
26679                           const double height)
26680 {
26681   int err;
26682   Dwg_Object *hdr = dwg_obj_generic_to_object (evalgraph, &err);
26683   Dwg_Data *dwg = hdr ? hdr->parent : NULL;
26684   if (!dwg)
26685     return NULL;
26686   {
26687     API_ADD_OBJECT (ACSH_WEDGE_CLASS);
26688     dwg_init_ACSH_CLASS (dwg, obj, _obj, evalgraph, origin_pt, normal);
26689     _obj->length = length;
26690     _obj->width = width;
26691     _obj->height = height;
26692     return _obj;
26693   }
26694 }
26695 
26696 EXPORT Dwg_Entity_3DSOLID*
dwg_add_WEDGE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict origin_pt,const dwg_point_3d * restrict normal,const double length,const double width,const double height)26697 dwg_add_WEDGE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
26698                const dwg_point_3d *restrict origin_pt, const dwg_point_3d *restrict normal,
26699                const double length, const double width, const double height)
26700 {
26701   int err;
26702   Dwg_Data *dwg;
26703   {
26704     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
26705     dwg = hdr ? hdr->parent : NULL;
26706     if (dwg)
26707       {
26708         REQUIRE_CLASS ("ACAD_EVALUATION_GRAPH");
26709         REQUIRE_CLASS ("ACSH_HISTORY_CLASS");
26710         REQUIRE_CLASS ("ACSH_WEDGE_CLASS");
26711       }
26712     else
26713       return NULL;
26714   }
26715   {
26716     Dwg_Entity_3DSOLID *solid;
26717     Dwg_Object_ACSH_WEDGE_CLASS *_obj;
26718     dwg_point_3d defnormal = { 0.0, 0.0, 1.0 };
26719     dwg_matrix9 matrix = {
26720       1.0, 0.0, 0.0,
26721       0.0, 1.0, 0.0,
26722       0.0, 0.0, 1.0 };
26723     #define WEDGE_ACIS_SIZE 6500
26724     char acis_data[WEDGE_ACIS_SIZE];
26725     char date[48];
26726     unsigned date_size = dwg_acis_date (date, 48);
26727     // the center is in the middle
26728     const double l2 = length / 2; // 1.674079
26729     const double w2 = width / 2;  // 1.244932
26730     const double h2 = height / 2; // 2.4430318
26731     const double c1 = 0.8249088118009861859; // ??
26732     const double c2 = 0.5652658243809589589; // ??
26733     // acis version 106 (r14) would be nicer
26734     const char wedge_acis_format[] = /* len => 4332 - 5300 */
26735       // version num_records num_entities has_history
26736       "400 87 1 0 \n"
26737       // product acis_version date
26738       "8 LibreDWG 19 ASM 223.0.1.1930 NT %u %s \n"
26739       // num_mm_units resabs resnor
26740       "25.39999999999999858 9.999999999999999547e-07 1.000000000000000036e-10\n"
26741       "body $-1 -1 $-1 $1 $-1 $2 #\n"
26742       "lump $-1 -1 $-1 $-1 $3 $0 #\n"
26743       "transform $-1 -1 " "%g %g %g " "%g %g %g " "%g %g %g " "%g %g %g " "1 no_rotate no_reflect no_shear #\n"
26744       "shell $-1 -1 $-1 $-1 $-1 $4 $-1 $1 #\n"
26745       "face $5 -1 $-1 $-1 $-1 $3 $-1 $6 forward single #\n"
26746       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $4 1 1 1 0 #\n"
26747       "face $9 $10 $11 $3 $-1 $12 forward single #\n"
26748       "loop $-1 $-1 $13 $4 #\n"
26749       // -l2 w2 -h2, -c1 0 c2, -c2 -0 -c1
26750       "plane-surface $-1 " "%f %f %f " "%f %d %f " "%f %d %f " "forward_v I I I I #\n"
26751       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $6 1 1 5 0 #\n"
26752       "face $14 $15 $16 $3 $-1 $17 forward single #\n"
26753       "loop $-1 $-1 $18 $6 #\n"
26754       // l2 w2 h2
26755       "plane-surface $-1 " "%f %f %f " "1 0 0 " "0 0 1 " "forward_v I I I I #\n"
26756       "coedge $-1 $19 $20 $21 $22 forward $7 $-1 #\n"
26757       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $10 1 1 9 0 #\n"
26758       "face $23 $24 $25 $3 $-1 $26 reversed single #\n"
26759       "loop $-1 $-1 $27 $10 #\n"
26760       // l2 w2 -h2
26761       "plane-surface $-1 " "%f %f %f " "0 0 -1 " "1 0 0 " "forward_v I I I I #\n"
26762       "coedge $-1 $28 $29 $30 $31 forward $11 $-1 #\n"
26763       "coedge $-1 $32 $13 $29 $33 reversed $7 $-1 #\n"
26764       "coedge $-1 $13 $32 $34 $35 forward $7 $-1 #\n"
26765       "coedge $-1 $36 $30 $13 $22 reversed $25 $-1 #\n"
26766       "edge $37 $38 $39 $13 $40 forward #\n"
26767       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $15 1 1 13 0 #\n"
26768       "face $41 $-1 $42 $3 $-1 $43 forward single #\n"
26769       "loop $-1 $-1 $21 $15 #\n"
26770       // 0 -w2 0
26771       "plane-surface $-1 " "%d %f %d " "0 1 0 " "0 0 -1 " "forward_v I I I I #\n"
26772       "coedge $-1 $34 $44 $36 $45 forward $16 $-1 #\n"
26773       "coedge $-1 $46 $18 $44 $47 reversed $11 $-1 #\n"
26774       "coedge $-1 $18 $46 $19 $33 forward $11 $-1 #\n"
26775       "coedge $-1 $21 $36 $18 $31 reversed $25 $-1 #\n"
26776       "edge $48 $39 $49 $18 $50 forward #\n"
26777       "coedge $-1 $20 $19 $51 $52 reversed $7 $-1 #\n"
26778       "edge $53 $54 $39 $29 $55 forward #\n"
26779       "coedge $-1 $56 $27 $20 $35 reversed $16 $-1 #\n"
26780       "edge $57 $58 $38 $20 $59 forward #\n"
26781       "coedge $-1 $30 $21 $27 $45 reversed $25 $-1 #\n"
26782       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $22 1 1 2 0 #\n"
26783       "vertex $60 $35 $61 #\n"
26784       "vertex $62 $33 $63 #\n"
26785       // -l2 -w2 -h2 c2 0 c1
26786       "straight-curve $-1 " "%f %f %f " "%f %d %f " " I I #\n"
26787       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $24 1 1 14 0 #\n"
26788       "loop $-1 $-1 $64 $24 #\n"
26789       // 0 w2 0
26790       "plane-surface $-1 " "%d %f %d " "0 1 0 " "0 0 -1 " "forward_v I I I I #\n"
26791       "coedge $-1 $27 $56 $28 $47 forward $16 $-1 #\n"
26792       "edge $65 $49 $38 $27 $66 forward #\n"
26793       "coedge $-1 $29 $28 $67 $68 reversed $11 $-1 #\n"
26794       "edge $69 $70 $49 $44 $71 forward #\n"
26795       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $31 1 1 6 0 #\n"
26796       "vertex $72 $47 $73 #\n"
26797       // l2 -w2 h2
26798       "straight-curve $-1 " "%f %f %f " "0 0 -1 ""I I #\n"
26799       "coedge $-1 $67 $64 $32 $52 forward $42 $-1 #\n"
26800       "edge $74 $58 $54 $51 $75 forward #\n"
26801       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $33 1 1 7 0 #\n"
26802       "vertex $76 $52 $77 #\n"
26803       // l2 w2 h2
26804       "straight-curve $-1 " "%f %f %f " "0 -1 0 ""I I #\n"
26805       "coedge $-1 $44 $34 $64 $78 reversed $16 $-1 #\n"
26806       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $35 1 1 3 0 #\n"
26807       "vertex $79 $78 $80 #\n"
26808       // -l2 w2 -h2
26809       "straight-curve $-1 " "%f %f %f " "0 -1 0 ""I I #\n"
26810       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $38 1 1 4 0 #\n"
26811       // -l2 -w2 -h2
26812       "point $-1 %f %f %f #\n"
26813       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $39 1 1 8 0 #\n"
26814       // l2 -w2 h2
26815       "point $-1 %f %f %f #\n"
26816       "coedge $-1 $51 $67 $56 $78 forward $42 $-1 #\n"
26817       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $45 1 1 10 0 #\n"
26818       // l2 -w2 -h2
26819       "straight-curve $-1 %f %f %f -1 0 0 I I #\n"
26820       "coedge $-1 $64 $51 $46 $68 forward $42 $-1 #\n"
26821       "edge $81 $54 $70 $67 $82 forward #\n"
26822       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $47 1 1 11 0 #\n"
26823       "vertex $83 $78 $84 #\n"
26824       // l2 w2 -h2
26825       "straight-curve $-1 %f %f %f 0 -1 0 I I #\n"
26826       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $49 1 1 12 0 #\n"
26827       // l2 -w2 -h2
26828       "point $-1 %f %f %f #\n"
26829       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $52 1 1 18 0 #\n"
26830       // -l2 w2 -h2 c2 0 c1
26831       "straight-curve $-1 %f %f %f %f %d %f I I #\n"
26832       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $54 1 1 19 0 #\n"
26833       // l2 w2 h2
26834       "point $-1 %f %f %f #\n"
26835       "edge $85 $70 $58 $64 $86 forward #\n"
26836       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $58 1 1 17 0 #\n"
26837       // -l2 w2 -h2
26838       "point $-1 %f %f %f #\n"
26839       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $68 1 1 20 0 #\n"
26840       // l2 w2 h2
26841       "straight-curve $-1 %f %f %f 0 0 -1 I I #\n"
26842       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $70 1 1 16 0 #\n"
26843       // l2 w2 -h2
26844       "point $-1 %f %f %f #\n"
26845       "persubent-acadSolidHistory-attrib $-1 $-1 $-1 $78 1 1 15 0 #\n"
26846       // l2 w2 -h2
26847       "straight-curve $-1 %f %f %f -1 0 0 I I #\n"
26848       "End-of-ACIS-data\n";
26849     // origin: 8.325921, 8.755068, 2.443032
26850     // matrix -1 0 0, 0 -1 0, 0 0 1
26851     // length: 3.348158
26852     // width: 2.489864
26853     // height: 4.886064
26854     dwg_geom_normal_to_matrix9 (normal, &matrix);
26855     snprintf (acis_data, WEDGE_ACIS_SIZE, wedge_acis_format,
26856               date_size, date,
26857               matrix[0], matrix[1], matrix[2],
26858               matrix[3], matrix[4], matrix[5],
26859               matrix[6], matrix[7], matrix[8],
26860               origin_pt->x, origin_pt->y, origin_pt->z,
26861               // clang-format off
26862               -l2, w2, -h2, -c1, 0, c2, -c2, -0, -c1,
26863               l2, w2, h2,
26864               l2, w2, -h2,
26865               0, -w2, 0,
26866               -l2, -w2, -h2, c2, 0, c1,
26867               0, w2, 0,
26868               l2, -w2, h2,
26869               l2, w2, h2,
26870               -l2, w2, -h2,
26871               -l2, -w2, -h2,
26872               l2, -w2, h2,
26873               l2, -w2, -h2,
26874               l2, w2, -h2,
26875               l2, -w2, -h2,
26876               -l2, w2, -h2, c2, 0, c1,
26877               l2, w2, h2,
26878               -l2, w2, -h2,
26879               l2, w2, h2,
26880               l2, w2, -h2,
26881               l2, w2, -h2
26882               // clang-format on
26883               );
26884     solid = dwg_add_3DSOLID (blkhdr, acis_data);
26885     solid->wireframe_data_present = 1;
26886     solid->point_present = 1;
26887     ADD_CHECK_3DPOINT (origin_pt);
26888     solid->point.x = origin_pt->x;
26889     solid->point.y = origin_pt->y;
26890     solid->point.z = origin_pt->z;
26891     solid->acis_empty_bit = 1;
26892 
26893     _obj = dwg_add_ACSH_WEDGE_CLASS ((void *)solid, origin_pt,
26894                                      normal ? normal : &defnormal, length,
26895                                      width, height);
26896     ACSH_init_evalgraph (dwg, _obj, solid);
26897     return solid;
26898   }
26899 }
26900 
26901 // ALDIMOBJECTCONTEXTDATA
26902 // ALIGNMENTPARAMETERENTITY
26903 // ANGDIMOBJECTCONTEXTDATA
26904 // ANNOTSCALEOBJECTCONTEXTDATA
26905 // ARC_DIMENSION  (needed)
26906 // ARCALIGNEDTEXT
26907 // ASSOC2DCONSTRAINTGROUP
26908 // ASSOC3POINTANGULARDIMACTIONBODY
26909 // ASSOCACTION
26910 // ASSOCACTIONPARAM
26911 // ASSOCALIGNEDDIMACTIONBODY
26912 // ASSOCARRAYACTIONBODY
26913 // ASSOCARRAYMODIFYACTIONBODY
26914 // ASSOCARRAYMODIFYPARAMETERS
26915 // ASSOCARRAYPATHPARAMETERS
26916 // ASSOCARRAYPOLARPARAMETERS
26917 // ASSOCARRAYRECTANGULARPARAMETERS
26918 // ASSOCASMBODYACTIONPARAM
26919 // ASSOCBLENDSURFACEACTIONBODY
26920 // ASSOCCOMPOUNDACTIONPARAM
26921 // ASSOCDEPENDENCY
26922 // ASSOCDIMDEPENDENCYBODY
26923 // ASSOCEDGEACTIONPARAM
26924 // ASSOCEDGECHAMFERACTIONBODY
26925 // ASSOCEDGEFILLETACTIONBODY
26926 // ASSOCEXTENDSURFACEACTIONBODY
26927 // ASSOCEXTRUDEDSURFACEACTIONBODY
26928 // ASSOCFACEACTIONPARAM
26929 // ASSOCFILLETSURFACEACTIONBODY
26930 // ASSOCGEOMDEPENDENCY
26931 // ASSOCLOFTEDSURFACEACTIONBODY
26932 // ASSOCMLEADERACTIONBODY
26933 // ASSOCNETWORK
26934 // ASSOCNETWORKSURFACEACTIONBODY
26935 // ASSOCOBJECTACTIONPARAM
26936 // ASSOCOFFSETSURFACEACTIONBODY
26937 // ASSOCORDINATEDIMACTIONBODY
26938 // ASSOCOSNAPPOINTREFACTIONPARAM
26939 // ASSOCPATCHSURFACEACTIONBODY
26940 // ASSOCPATHACTIONPARAM
26941 // ASSOCPERSSUBENTMANAGER
26942 // ASSOCPLANESURFACEACTIONBODY
26943 // ASSOCPOINTREFACTIONPARAM
26944 // ASSOCRESTOREENTITYSTATEACTIONBODY
26945 // ASSOCREVOLVEDSURFACEACTIONBODY
26946 // ASSOCROTATEDDIMACTIONBODY
26947 // ASSOCSWEPTSURFACEACTIONBODY
26948 // ASSOCTRIMSURFACEACTIONBODY
26949 // ASSOCVALUEDEPENDENCY
26950 // ASSOCVARIABLE
26951 // ASSOCVERTEXACTIONPARAM
26952 // BACKGROUND
26953 // BASEPOINTPARAMETERENTITY
26954 // BLKREFOBJECTCONTEXTDATA
26955 // BLOCKALIGNEDCONSTRAINTPARAMETER
26956 // BLOCKALIGNMENTGRIP
26957 // BLOCKALIGNMENTPARAMETER
26958 // BLOCKANGULARCONSTRAINTPARAMETER
26959 // BLOCKARRAYACTION
26960 // BLOCKBASEPOINTPARAMETER
26961 // BLOCKDIAMETRICCONSTRAINTPARAMETER
26962 // BLOCKFLIPACTION
26963 // BLOCKFLIPGRIP
26964 // BLOCKFLIPPARAMETER
26965 // BLOCKGRIPLOCATIONCOMPONENT
26966 // BLOCKHORIZONTALCONSTRAINTPARAMETER
26967 // BLOCKLINEARCONSTRAINTPARAMETER
26968 // BLOCKLINEARGRIP
26969 // BLOCKLINEARPARAMETER
26970 // BLOCKLOOKUPACTION
26971 // BLOCKLOOKUPGRIP
26972 // BLOCKLOOKUPPARAMETER
26973 // BLOCKMOVEACTION
26974 // BLOCKPARAMDEPENDENCYBODY
26975 // BLOCKPOINTPARAMETER
26976 // BLOCKPOLARGRIP
26977 // BLOCKPOLARPARAMETER
26978 // BLOCKPOLARSTRETCHACTION
26979 // BLOCKPROPERTIESTABLE
26980 // BLOCKPROPERTIESTABLEGRIP
26981 // BLOCKRADIALCONSTRAINTPARAMETER
26982 // BLOCKREPRESENTATION
26983 // BLOCKROTATEACTION
26984 // BLOCKROTATIONGRIP
26985 // BLOCKROTATIONPARAMETER
26986 // BLOCKSCALEACTION
26987 // BLOCKSTRETCHACTION
26988 // BLOCKUSERPARAMETER
26989 // BLOCKVERTICALCONSTRAINTPARAMETER
26990 // BLOCKVISIBILITYGRIP
26991 // BLOCKVISIBILITYPARAMETER
26992 // BLOCKXYGRIP
26993 // BLOCKXYPARAMETER
26994 // CAMERA
26995 // CELLSTYLEMAP
26996 // CONTEXTDATAMANAGER
26997 // CSACDOCUMENTOPTIONS
26998 // CURVEPATH
26999 // DATALINK
27000 // DATATABLE
27001 // DBCOLOR
27002 // DETAILVIEWSTYLE
27003 // DICTIONARYVAR
27004 // DIMASSOC
27005 // DMDIMOBJECTCONTEXTDATA
27006 // DYNAMICBLOCKPROXYNODE
27007 // DYNAMICBLOCKPURGEPREVENTER
27008 // EXTRUDEDSURFACE
27009 // FCFOBJECTCONTEXTDATA
27010 // FIELD
27011 // FIELDLIST
27012 // FLIPPARAMETERENTITY
27013 // GEODATA
27014 // GEOMAPIMAGE
27015 // GEOPOSITIONMARKER
27016 // HELIX
27017 // IDBUFFER
27018 
27019 // Called Raster in VBA
27020 EXPORT Dwg_Entity_IMAGE *
dwg_add_IMAGE(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict file_path,const dwg_point_3d * restrict ins_pt,const double scale_factor,const double rotation_angle)27021 dwg_add_IMAGE (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
27022                const char *restrict file_path,
27023                const dwg_point_3d *restrict ins_pt, const double scale_factor,
27024                const double rotation_angle)
27025 {
27026   Dwg_Object *img;
27027   Dwg_Entity_IMAGE *_img;
27028   Dwg_Object *imgdef;
27029   {
27030     int err;
27031     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
27032     Dwg_Data *dwg = hdr ? hdr->parent : NULL;
27033     if (dwg)
27034       {
27035         REQUIRE_CLASS ("IMAGEDEF");
27036         REQUIRE_CLASS ("IMAGEDEF_REACTOR");
27037         REQUIRE_CLASS ("IMAGE");
27038       }
27039   }
27040   {
27041     API_ADD_ENTITY (IMAGE);
27042     img = obj;
27043     if (!img)
27044       return NULL;
27045     _img = _obj;
27046     ADD_CHECK_3DPOINT (ins_pt);
27047     _obj->pt0.x = ins_pt->x;
27048     _obj->pt0.y = ins_pt->y;
27049     _obj->pt0.z = ins_pt->z;
27050     ADD_CHECK_DOUBLE (scale_factor);
27051     // TODO rotation cos()
27052     //ADD_CHECK_ANGLE (_obj->rotation);
27053     _obj->uvec.x = scale_factor;
27054     _obj->uvec.y = scale_factor;
27055     _obj->uvec.z = 1.0;
27056     _obj->vvec.x = scale_factor;
27057     _obj->vvec.y = scale_factor;
27058     _obj->vvec.z = 1.0;
27059     _obj->brightness = 0x32;
27060     _obj->contrast = 0x32;
27061   }
27062   // TODO normally a DICTIONARY owns an IMAGEDEF
27063   {
27064     Dwg_Data *dwg = img->parent;
27065     API_ADD_OBJECT (IMAGEDEF);
27066     imgdef = obj;
27067     //_obj->class_version = 0;
27068     _obj->file_path = dwg_add_u8_input (dwg, file_path);
27069     // TODO: get pixel props from the image. is_loaded, pixel_size, ...
27070     // needs -lpng -ljpeg ... load dynamically?
27071     _img->imagedef = dwg_add_handleref (dwg, 4, obj->handle.value, img);
27072   }
27073   {
27074     Dwg_Data *dwg = img->parent;
27075     API_ADD_OBJECT (IMAGEDEF_REACTOR);
27076     obj->tio.object->ownerhandle
27077         = dwg_add_handleref (dwg, 5, img->handle.value, obj);
27078     _obj->class_version = 2;
27079     _img->imagedefreactor = dwg_add_handleref (dwg, 3, obj->handle.value, img);
27080   }
27081   return _img;
27082 }
27083 
27084 // Not in VBA
27085 // Searches all PDFDEFINITION's for filename, if not found create a new one.
27086 EXPORT Dwg_Entity_PDFUNDERLAY *
dwg_add_PDFUNDERLAY(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const char * restrict filename,const dwg_point_3d * restrict ins_pt,const double scale_factor,const double rotation_angle)27087 dwg_add_PDFUNDERLAY (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
27088                      const char *restrict filename,
27089                      const dwg_point_3d *restrict ins_pt, const double scale_factor,
27090                      const double rotation_angle)
27091 {
27092   Dwg_Object *und, *dict = NULL, *def = NULL;
27093   Dwg_Object_DICTIONARY *_dict;
27094   Dwg_Data *_dwg;
27095   char name[80], *base, *ext;
27096   unsigned int i;
27097   {
27098     int err;
27099     Dwg_Object *hdr = dwg_obj_generic_to_object (blkhdr, &err);
27100     Dwg_Data *dwg = _dwg = hdr ? hdr->parent : NULL;
27101     char base_1[80];
27102     Dwg_Object *defs;
27103     Dwg_Object_DICTIONARY *_defs;
27104     BITCODE_H defsref;
27105 
27106     if (!dwg || err)
27107       return NULL;
27108     i = 1;
27109     REQUIRE_CLASS ("PDFDEFINITION");
27110     REQUIRE_CLASS ("PDFUNDERLAY");
27111     // name = "dxf - 1";
27112     // search/register in NOD
27113     base = split_filepath (filename, &ext);
27114     snprintf (name, 80, "%d", i);
27115     snprintf (base_1, 80, "%s - %d", base, i);
27116     defsref = dwg_find_dictionary (dwg, "ACAD_PDFDEFINITIONS");
27117     if (!defsref) // no nod entry yet, create
27118       _dict = dwg_add_DICTIONARY (dwg, "ACAD_PDFDEFINITIONS", base_1, 0);
27119     else
27120       {
27121         // PDFDEFINITIONS dict exists
27122         dict = dwg_ref_object (dwg, defsref);
27123         _dict = dict->tio.object->tio.DICTIONARY;
27124         // check if a PDFDEFINITION for this filename already exists.
27125         // if same path: re-use it. if same base: inc i and name.
27126         for (unsigned j=0; j < _dict->numitems; j++)
27127           {
27128             BITCODE_T text = _dict->texts[j];
27129             Dwg_Object_Ref *ref = _dict->itemhandles[j];
27130             Dwg_Object *o = dwg_ref_object (dwg, ref);
27131             if (o && o->fixedtype == DWG_TYPE_PDFDEFINITION)
27132               {
27133                 Bit_Chain dat = {0};
27134                 Dwg_Object_PDFDEFINITION *_def = o->tio.object->tio.PDFDEFINITION;
27135                 char text1[80];
27136                 int i1;
27137                 // for IS_FROM_TU in bit_eq_T: don't convert with DXF
27138                 dat.from_version = dwg->header.from_version;
27139                 dat.opts = dwg->opts;
27140                 if (bit_eq_T (&dat, _def->filename, filename))
27141                   {
27142                     // same filename: re-use
27143                     def = o;
27144                     break;
27145                   }
27146                 // same base: i++ and inc name
27147                 sscanf (text, "%s - %d", text1, &i1);
27148                 if (strEQ (text1, base))
27149                   {
27150                     i++;
27151                     snprintf (name, 80, "%d", i);
27152                     snprintf (base_1, 80, "%s - %d", base, i);
27153                     break;
27154                   }
27155               }
27156           }
27157         if (!def) // matching def + dict not found, add entry
27158           dwg_add_DICTIONARY_item (_dict, base_1, 0);
27159       }
27160     if (!def)
27161       {
27162         API_ADD_OBJECT (PDFDEFINITION);
27163         if (!_obj)
27164           return NULL;
27165         def = obj;
27166         _dict->itemhandles[_dict->numitems-1] = dwg_add_handleref (dwg, 2, obj->handle.value, NULL);
27167         _obj->filename = dwg_add_u8_input (dwg, filename);
27168         _obj->name = strdup (name);
27169         if (!dict)
27170           dict = dwg_obj_generic_to_object (_dict, &error);
27171         if (dict)
27172           {
27173             obj->tio.object->ownerhandle
27174               = dwg_add_handleref (dwg, 4, dict->handle.value, obj);
27175             add_obj_reactor (obj->tio.object, dict->handle.value);
27176           }
27177       }
27178   }
27179   {
27180     API_ADD_ENTITY (PDFUNDERLAY);
27181     if (!_obj)
27182       return NULL;
27183     _obj->definition_id = dwg_add_handleref (dwg, 5, def->handle.value, obj);
27184     ADD_CHECK_3DPOINT (ins_pt);
27185     _obj->ins_pt.x = ins_pt->x;
27186     _obj->ins_pt.y = ins_pt->y;
27187     _obj->ins_pt.z = ins_pt->z;
27188     _obj->angle = rotation_angle;
27189     ADD_CHECK_ANGLE (_obj->angle);
27190     ADD_CHECK_DOUBLE (scale_factor);
27191     _obj->scale.x = scale_factor;
27192     _obj->scale.y = scale_factor;
27193     _obj->scale.z = 1.0;
27194     _obj->contrast = 100;
27195     return _obj;
27196   }
27197 }
27198 
27199 // INDEX
27200 
27201 EXPORT Dwg_Entity_LARGE_RADIAL_DIMENSION *
dwg_add_LARGE_RADIAL_DIMENSION(Dwg_Object_BLOCK_HEADER * restrict blkhdr,const dwg_point_3d * restrict center_pt,const dwg_point_3d * restrict first_arc_pt,const dwg_point_3d * restrict ovr_center,const dwg_point_3d * restrict jog_point,const double leader_len)27202 dwg_add_LARGE_RADIAL_DIMENSION (Dwg_Object_BLOCK_HEADER *restrict blkhdr,
27203                                 const dwg_point_3d *restrict center_pt,
27204                                 const dwg_point_3d *restrict first_arc_pt,
27205                                 const dwg_point_3d *restrict ovr_center,
27206                                 const dwg_point_3d *restrict jog_point,
27207                                 const double leader_len)
27208 {
27209   API_ADD_ENTITY (LARGE_RADIAL_DIMENSION);
27210   _obj->def_pt.x = center_pt->x;
27211   _obj->def_pt.y = center_pt->y;
27212   _obj->def_pt.z = center_pt->z;
27213   _obj->first_arc_pt.x = first_arc_pt->x;
27214   _obj->first_arc_pt.y = first_arc_pt->y;
27215   _obj->first_arc_pt.z = first_arc_pt->z;
27216   _obj->ovr_center.x = ovr_center->x;
27217   _obj->ovr_center.y = ovr_center->y;
27218   _obj->ovr_center.z = ovr_center->z;
27219   _obj->jog_point.x = jog_point->x;
27220   _obj->jog_point.y = jog_point->y;
27221   _obj->jog_point.z = jog_point->z;
27222   _obj->leader_len = leader_len;
27223   return _obj;
27224 }
27225 
27226 // TODO, no coverage
27227 // LAYER_CONTROL->owner DICTIONARY with ACAD_LAYERFILTERS => DICTIONARY,
27228 // which is xdicobjhandle of LAYER_CONTROL
27229 EXPORT Dwg_Object_LAYERFILTER *
dwg_add_LAYERFILTER(Dwg_Data * restrict dwg)27230 dwg_add_LAYERFILTER (Dwg_Data *restrict dwg /* ... */)
27231 {
27232   API_ADD_OBJECT (LAYERFILTER);
27233   return _obj;
27234 }
27235 
27236 // no coverage
27237 EXPORT Dwg_Object_LAYER_INDEX *
dwg_add_LAYER_INDEX(Dwg_Data * restrict dwg)27238 dwg_add_LAYER_INDEX (Dwg_Data *restrict dwg /* ... */)
27239 {
27240   {
27241     REQUIRE_CLASS ("LAYER_INDEX");
27242   }
27243   {
27244     API_ADD_OBJECT (LAYER_INDEX);
27245     return _obj;
27246   }
27247 }
27248 
27249 // Untested, experimental.
27250 // INSERT.xdicobjhandle ->
27251 //   DICT_item "ACAD_FILTER" ->
27252 //   DICT_item "SPATIAL" -> obj
27253 EXPORT Dwg_Object_SPATIAL_FILTER *
dwg_add_SPATIAL_FILTER(Dwg_Entity_INSERT * restrict insert)27254 dwg_add_SPATIAL_FILTER (Dwg_Entity_INSERT *restrict insert /*, clip_verts... */)
27255 {
27256   int err;
27257   Dwg_Object *ins;
27258   Dwg_Object_DICTIONARY *_filter, *_spatial;
27259   Dwg_Object *filter, *spatial;
27260   Dwg_Data *dwg;
27261 
27262   ins = dwg_ent_generic_to_object (insert, &err);
27263   dwg = ins ? ins->parent : NULL;
27264   if (!dwg || err)
27265     return NULL;
27266   {
27267     REQUIRE_CLASS ("SPATIAL_FILTER");
27268 
27269     _filter = dwg_add_DICTIONARY (dwg, NULL, "ACAD_FILTER", 0);
27270     filter = dwg_obj_generic_to_object (_filter, &err);
27271     filter->tio.object->ownerhandle
27272         = dwg_add_handleref (dwg, 5, ins->handle.value, filter);
27273     _filter->is_hardowner = 1;
27274 
27275     ins->tio.entity->xdicobjhandle
27276         = dwg_add_handleref (dwg, 3, filter->handle.value, ins);
27277 
27278     _spatial = dwg_add_DICTIONARY (dwg, NULL, "SPATIAL", 0);
27279     _spatial->is_hardowner = 1;
27280     spatial = dwg_obj_generic_to_object (_spatial, &err);
27281     _filter->itemhandles[0]
27282         = dwg_add_handleref (dwg, 2, spatial->handle.value, filter);
27283     spatial->tio.object->ownerhandle
27284         = dwg_add_handleref (dwg, 5, filter->handle.value, spatial);
27285     add_obj_reactor (spatial->tio.object, filter->handle.value);
27286   }
27287   {
27288     API_ADD_OBJECT (SPATIAL_FILTER);
27289     _spatial->itemhandles[0]
27290         = dwg_add_handleref (dwg, 2, obj->handle.value, filter);
27291     obj->tio.object->ownerhandle
27292         = dwg_add_handleref (dwg, 5, spatial->handle.value, obj);
27293     add_obj_reactor (obj->tio.object, spatial->handle.value);
27294     // TODO normal -> matrix
27295     _obj->transform[0] = 1.0;
27296     _obj->transform[5] = 1.0;
27297     _obj->transform[10] = 1.0;
27298     return _obj;
27299   }
27300 }
27301 
27302 // no coverage
27303 EXPORT Dwg_Object_SPATIAL_INDEX *
dwg_add_SPATIAL_INDEX(Dwg_Data * restrict dwg)27304 dwg_add_SPATIAL_INDEX (Dwg_Data *restrict dwg /* ... */)
27305 {
27306   {
27307     REQUIRE_CLASS ("SPATIAL_INDEX");
27308   }
27309   {
27310     API_ADD_OBJECT (SPATIAL_INDEX);
27311     return _obj;
27312   }
27313 }
27314 
27315 // LAYOUTPRINTCONFIG
27316 // LEADEROBJECTCONTEXTDATA
27317 // LIGHT
27318 // LIGHTLIST
27319 // LINEARPARAMETERENTITY
27320 // LOFTEDSURFACE
27321 // MATERIAL
27322 // MENTALRAYRENDERSETTINGS
27323 // MESH (needed)
27324 // MLEADEROBJECTCONTEXTDATA
27325 // MLEADERSTYLE
27326 // MOTIONPATH
27327 // MPOLYGON
27328 // MTEXTATTRIBUTEOBJECTCONTEXTDATA
27329 // MTEXTOBJECTCONTEXTDATA
27330 // MULTILEADER (needed)
27331 // NAVISWORKSMODEL
27332 // NAVISWORKSMODELDEF
27333 // NPOCOLLECTION
27334 // NURBSURFACE
27335 // OBJECT_PTR
27336 // ORDDIMOBJECTCONTEXTDATA
27337 // PERSUBENTMGR
27338 // PLANESURFACE
27339 // PLOTSETTINGS
27340 // POINTCLOUD
27341 // POINTCLOUDEX
27342 // POINTCLOUDDEF
27343 // POINTCLOUDDEFEX
27344 // POINTCLOUDDEF_REACTOR
27345 // POINTCLOUDDEF_REACTOR_EX
27346 // POINTCLOUDCOLORMAP
27347 // POINTPARAMETERENTITY
27348 // POINTPATH
27349 // RADIMLGOBJECTCONTEXTDATA
27350 // RADIMOBJECTCONTEXTDATA
27351 // RAPIDRTRENDERSETTINGS
27352 // RASTERVARIABLES
27353 // RENDERENTRY
27354 // RENDERENVIRONMENT
27355 // RENDERGLOBAL
27356 // RENDERSETTINGS
27357 // REVOLVEDSURFACE
27358 // ROTATIONPARAMETERENTITY
27359 // RTEXT
27360 // SCALE (needed)
27361 // SECTIONOBJECT (needed)
27362 // SECTIONVIEWSTYLE
27363 // SECTION_MANAGER
27364 // SECTION_SETTINGS
27365 // SORTENTSTABLE
27366 // SUN
27367 // SUNSTUDY
27368 // SWEPTSURFACE
27369 // TABLE (needed)
27370 // TABLECONTENT
27371 // TABLEGEOMETRY
27372 // TABLESTYLE (needed)
27373 // TEXTOBJECTCONTEXTDATA
27374 // TVDEVICEPROPERTIES
27375 // VISIBILITYGRIPENTITY
27376 // VISIBILITYPARAMETERENTITY
27377 // VISUALSTYLE
27378 // WIPEOUT
27379 
27380 // just for testing dwg_type_dxfname()
27381 EXPORT Dwg_Object_WIPEOUTVARIABLES*
dwg_add_WIPEOUTVARIABLES(Dwg_Data * dwg)27382 dwg_add_WIPEOUTVARIABLES (Dwg_Data *dwg /* ... */)
27383 {
27384   {
27385     REQUIRE_CLASS ("WIPEOUTVARIABLES");
27386   }
27387   {
27388     API_ADD_OBJECT (WIPEOUTVARIABLES);
27389     return _obj;
27390   }
27391 }
27392 
27393 // XREFPANELOBJECT
27394 // XYPARAMETERENTITY
27395 
27396 #endif /* USE_WRITE */
27397