Skip to content

Commit

Permalink
Improve DIMASSOC object
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-josef-spacek committed Dec 30, 2024
1 parent dcfe2e0 commit 812ff03
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 51 deletions.
12 changes: 9 additions & 3 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -14116,12 +14116,18 @@ BL, DXF 91
BS
@item xrefpaths
TV*, DXF 301
@item num_intersec_xrefpaths
BS
@item intersec_xrefpaths
TV*
@item has_lastpt_ref
B, DXF 75
@item lastpt_ref
3BD
@item intersec_subent_type
BS, DXF 74
@item intersec_gsmarker
BL, DXF 92
@item num_intsectobj
BL, DXF 74
BL
@item intsectobj
H*, DXF 332

Expand Down
27 changes: 15 additions & 12 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -5338,20 +5338,23 @@ typedef struct _dwg_object_DATALINK
typedef struct _dwg_DIMASSOC_Ref
{
struct _dwg_object_DIMASSOC *parent;
BITCODE_T classname; /*!< DXF 1 constant */
BITCODE_RC osnap_type; /*!< DXF 72 */
BITCODE_BD osnap_dist; /*!< DXF 40 */
BITCODE_3BD osnap_pt; /*!< DXF 10-30 */
BITCODE_T classname; /*!< DXF 1 constant */
BITCODE_RC osnap_type; /*!< DXF 72 */
BITCODE_BD osnap_dist; /*!< DXF 40 */
BITCODE_3BD osnap_pt; /*!< DXF 10-30 */
BITCODE_BS num_xrefs;
BITCODE_H *xrefs; /*!< DXF 331 the geometry objects, 1 or 2 */
BITCODE_BS main_subent_type; /*!< DXF 73 */
BITCODE_BL main_gsmarker; /*!< DXF 91 */
BITCODE_H *xrefs; /*!< DXF 331 the geometry objects, 1 or 2 */
BITCODE_BS main_subent_type; /*!< DXF 73 */
BITCODE_BL main_gsmarker; /*!< DXF 91 */
BITCODE_BS num_xrefpaths;
BITCODE_T *xrefpaths; /*!< DXF 301 */
BITCODE_B has_lastpt_ref; /*!< DXF 75 */
BITCODE_3BD lastpt_ref; /*!< DXF ?? */
BITCODE_BL num_intsectobj; /*!< DXF 74 */
BITCODE_H* intsectobj; /*!< DXF 332 the intersection objects, 1 or 2 */
BITCODE_T *xrefpaths; /*!< DXF 301 */
BITCODE_BS num_intersec_xrefpaths;
BITCODE_T *intersec_xrefpaths; /*!< DXF 302 */
BITCODE_B has_lastpt_ref; /*!< DXF 75 */
BITCODE_BS intersec_subent_type; /*!< DXF 74 */
BITCODE_BL intersec_gsmarker; /*!< DXF 92 */
BITCODE_BL num_intsectobj;
BITCODE_H* intsectobj; /*!< DXF 332 the intersection objects, 1 or 2 */
} Dwg_DIMASSOC_Ref;

typedef struct _dwg_object_DIMASSOC
Expand Down
75 changes: 42 additions & 33 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9934,6 +9934,33 @@ DWG_ENTITY_END
FIELD_B (dimension.flip_arrow2, 296); \
FIELD_B (dimension.flip_arrow1, 297)

#define AcDbOsnapPointRef_fields(index) \
LOG_HANDLE ("DIMASSOC_Ref.rcount1: %d\n", index); \
SUB_FIELD_T (ref[index], classname, 1); /* "AcDbOsnapPointRef" */ \
SUB_FIELD_RC (ref[index], osnap_type, 72); /* 0-13 */ \
SUB_FIELD_BL (ref[index], num_xrefs, 0); \
SUB_HANDLE_VECTOR (ref[index], xrefs, num_xrefs, 4, 331); \
if (FIELD_VALUE (ref[index].osnap_type) != 0) \
{ \
SUB_FIELD_BL (ref[index], main_subent_type, 73); \
SUB_FIELD_BL (ref[index], main_gsmarker, 91); \
SUB_FIELD_BL (ref[index], num_xrefpaths, 0); \
FIELD_VECTOR_T (ref[index].xrefpaths, T, ref[4].num_xrefpaths, 301) \
} \
SUB_FIELD_BD (ref[index], osnap_dist, 40); \
SUB_FIELD_3BD (ref[index], osnap_pt, 10); \
if (FIELD_VALUE (ref[index].osnap_type) == 6 \
|| FIELD_VALUE (ref[index].osnap_type) == 11) \
{ \
SUB_FIELD_BL (ref[index], num_intsectobj, 0); \
SUB_HANDLE_VECTOR (ref[index], intsectobj, num_intsectobj, 5, 332); \
SUB_FIELD_BL (ref[index], intersec_subent_type, 74); \
SUB_FIELD_BL (ref[index], intersec_gsmarker, 92); \
SUB_FIELD_BL (ref[index], num_intersec_xrefpaths, 0); \
FIELD_VECTOR_T (ref[index].intersec_xrefpaths, T, ref[index].num_intersec_xrefpaths, 302) \
} \
SUB_FIELD_B (ref[index], has_lastpt_ref, 75);

// (varies) UNSTABLE
// 1-4 references, see associativity bits 1-8.
DWG_OBJECT (DIMASSOC)
Expand All @@ -9944,48 +9971,30 @@ DWG_OBJECT (DIMASSOC)
FIELD_B (trans_space_flag, 70);
FIELD_RC (rotated_type, 71);
FIELD_HANDLE (dimensionobj, 4, 330);
REPEAT_CN (4, ref, Dwg_DIMASSOC_Ref) // i.e. AcDbOsnapPointRef
REPEAT_CN (6, ref, Dwg_DIMASSOC_Ref) // i.e. AcDbOsnapPointRef
REPEAT_BLOCK
// TODO: there could be much more blocks, up to 5.
// 0 1 2 3 => 1 2 4 8. skip unset bits
if (!(FIELD_VALUE (associativity) & (1<<rcount1)))
// index 0 1 2 3 => bits 1 2 4 8. skip unset bits
if (!(FIELD_VALUE (associativity) & (1 << rcount1)))
{
#ifdef IS_JSON
ENDHASH;
#endif
continue;
}
LOG_HANDLE ("DIMASSOC_Ref.rcount1: %d\n", rcount1);
// DXF: 1, 72, 10, ??, 75
SUB_FIELD_T (ref[rcount1], classname, 1); // "AcDbOsnapPointRef"
SUB_FIELD_RC (ref[rcount1], osnap_type, 72); // 0-13
// idpaths:
SUB_FIELD_BL0 (ref[rcount1], num_intsectobj, 74);
SUB_HANDLE_VECTOR (ref[rcount1], intsectobj, num_intsectobj, 5, 332);

SUB_FIELD_BD (ref[rcount1], osnap_dist, 40);
SUB_FIELD_3BD (ref[rcount1], osnap_pt, 10);

// XrefFullSubentPath
SUB_FIELD_BL (ref[rcount1], num_xrefs, 0); // 1 or 2
SUB_VALUEOUTOFBOUNDS (ref[rcount1], num_xrefs, 100)
SUB_HANDLE_VECTOR (ref[rcount1], xrefs, num_xrefs, 4, 331);

// restrict only when writing, not when reading?
//if (FIELD_VALUE (ref[rcount1].osnap_type) == 6 || FIELD_VALUE (ref[rcount1].osnap_type) == 11)
// {
SUB_FIELD_BL0 (ref[rcount1], main_subent_type, 73);
SUB_FIELD_BL (ref[rcount1], main_gsmarker, 91);
SUB_FIELD_BL (ref[rcount1], num_xrefpaths, 0);
FIELD_VECTOR_T (ref[rcount1].xrefpaths, T, ref[rcount1].num_xrefpaths, 301)
// }
SUB_FIELD_B (ref[rcount1], has_lastpt_ref, 75);
if (FIELD_VALUE (ref[rcount1].has_lastpt_ref))
{
SUB_FIELD_3BD (ref[rcount1], lastpt_ref, 0);
}
AcDbOsnapPointRef_fields(rcount1)
SET_PARENT_OBJ (ref[rcount1]);
END_REPEAT_BLOCK
if (FIELD_VALUE (ref[0].has_lastpt_ref)
|| FIELD_VALUE (ref[1].has_lastpt_ref)
|| FIELD_VALUE (ref[2].has_lastpt_ref)
|| FIELD_VALUE (ref[3].has_lastpt_ref))
{
AcDbOsnapPointRef_fields(4)
}
if (FIELD_VALUE (ref[4].has_lastpt_ref))
{
AcDbOsnapPointRef_fields(5)
}
END_REPEAT (ref)

START_OBJECT_HANDLE_STREAM;
Expand Down
12 changes: 9 additions & 3 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11478,12 +11478,18 @@ static const Dwg_DYNAPI_field _dwg_DIMASSOC_Ref_fields[] = {
0,0,0, 0 },
{ "xrefpaths", "TV*", sizeof (BITCODE_TV*), OFF (struct _dwg_DIMASSOC_Ref, xrefpaths),
1,1,0, 301 },
{ "num_intersec_xrefpaths", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_DIMASSOC_Ref, num_intersec_xrefpaths),
0,0,0, 0 },
{ "intersec_xrefpaths", "TV*", sizeof (BITCODE_TV*), OFF (struct _dwg_DIMASSOC_Ref, intersec_xrefpaths),
1,1,0, 0 },
{ "has_lastpt_ref", "B", sizeof (BITCODE_B), OFF (struct _dwg_DIMASSOC_Ref, has_lastpt_ref),
0,0,0, 75 },
{ "lastpt_ref", "3BD", sizeof (BITCODE_3BD), OFF (struct _dwg_DIMASSOC_Ref, lastpt_ref),
1,0,0, 0 },
{ "num_intsectobj", "BL", sizeof (BITCODE_BL), OFF (struct _dwg_DIMASSOC_Ref, num_intsectobj),
{ "intersec_subent_type", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_DIMASSOC_Ref, intersec_subent_type),
0,0,0, 74 },
{ "intersec_gsmarker", "BL", sizeof (BITCODE_BL), OFF (struct _dwg_DIMASSOC_Ref, intersec_gsmarker),
0,0,0, 92 },
{ "num_intsectobj", "BL", sizeof (BITCODE_BL), OFF (struct _dwg_DIMASSOC_Ref, num_intsectobj),
0,0,0, 0 },
{ "intsectobj", "H*", sizeof (BITCODE_H*), OFF (struct _dwg_DIMASSOC_Ref, intsectobj),
1,1,0, 332 },
{NULL, NULL, 0, 0, 0,0,0, 0},
Expand Down

0 comments on commit 812ff03

Please sign in to comment.