Skip to content

Commit

Permalink
spec: DIMASSOC honor the last has_lastpt_ref
Browse files Browse the repository at this point in the history
There is only one error case missing, where there's an additional point.
But all other last has_lastpt_ref: 0 cases end there.

GH #1031
  • Loading branch information
rurban committed Jan 1, 2025
1 parent b60a6c1 commit 1d6dc2d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -9314,6 +9314,8 @@ BL, DXF 90
B, DXF 70
@item rotated_type
RC, DXF 71
@item has_lastpt_ref
B
@item ref
Dwg_DIMASSOC_Ref*

Expand Down
1 change: 1 addition & 0 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -5364,6 +5364,7 @@ typedef struct _dwg_object_DIMASSOC
BITCODE_BL associativity; /*!< DXF 90, bitmask 0-15 */
BITCODE_B trans_space_flag; /*!< DXF 70 boolean */
BITCODE_RC rotated_type; /*!< DXF 71 */
BITCODE_B has_lastpt_ref; // copy of last ref field
Dwg_DIMASSOC_Ref *ref; /* 1-4x, with possible holes,
depends on associativity bitmask */
} Dwg_Object_DIMASSOC;
Expand Down
8 changes: 4 additions & 4 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9935,7 +9935,7 @@ DWG_ENTITY_END
FIELD_B (dimension.flip_arrow1, 297)

// (varies) UNSTABLE
// 1-4 references, see associativity bits 1-8.
// 1-6 references, see associativity bits 1-8.
DWG_OBJECT (DIMASSOC)

HANDLE_UNKNOWN_BITS;
Expand All @@ -9944,12 +9944,11 @@ DWG_OBJECT (DIMASSOC)
FIELD_B (trans_space_flag, 70);
FIELD_RC (rotated_type, 71);
FIELD_HANDLE (dimensionobj, 4, 330);
// 6 = maximum of items
REPEAT_CN (6, ref, Dwg_DIMASSOC_Ref) // i.e. AcDbOsnapPointRef
REPEAT_BLOCK
// there could be more blocks, up to 5.
// there could be more blocks, up to 5 or 6.
// 0 1 2 3 => 1 2 4 8. skip unset bits
if (!(FIELD_VALUE (associativity) & (1 << rcount1)))
if (!(FIELD_VALUE (associativity) & (1 << rcount1)) && !FIELD_VALUE(has_lastpt_ref))
{
#ifdef IS_JSON
ENDHASH;
Expand Down Expand Up @@ -9986,6 +9985,7 @@ DWG_OBJECT (DIMASSOC)
FIELD_VECTOR_T (ref[rcount1].intersec_xrefpaths, T, ref[rcount1].num_intersec_xrefpaths, 302)
}
SUB_FIELD_B (ref[rcount1], has_lastpt_ref, 75);
FIELD_VALUE(has_lastpt_ref) = SUB_FIELD_VALUE(ref[rcount1], has_lastpt_ref);
SET_PARENT_OBJ (ref[rcount1]);
END_REPEAT_BLOCK
END_REPEAT (ref)
Expand Down
2 changes: 2 additions & 0 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -7777,6 +7777,8 @@ static const Dwg_DYNAPI_field _dwg_DIMASSOC_fields[] = {
0,0,0, 70 },
{ "rotated_type", "RC", sizeof (BITCODE_RC), OFF (struct _dwg_object_DIMASSOC, rotated_type),
0,0,0, 71 },
{ "has_lastpt_ref", "B", sizeof (BITCODE_B), OFF (struct _dwg_object_DIMASSOC, has_lastpt_ref),
0,0,0, 0 },
{ "ref", "Dwg_DIMASSOC_Ref*", sizeof (Dwg_DIMASSOC_Ref*), OFF (struct _dwg_object_DIMASSOC, ref),
1,1,0, 0 },
{NULL, NULL, 0, 0, 0,0,0, 0},
Expand Down
15 changes: 15 additions & 0 deletions test/unit-testing/dynapi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -46465,6 +46465,21 @@ static int test_DIMASSOC (const Dwg_Object *obj)
else
fail ("DIMASSOC.dimensionobj [H]");
}
{
BITCODE_B has_lastpt_ref;
if (dwg_dynapi_entity_value (dimassoc, "DIMASSOC", "has_lastpt_ref", &has_lastpt_ref, NULL)
&& has_lastpt_ref == dimassoc->has_lastpt_ref)
pass ();
else
fail ("DIMASSOC.has_lastpt_ref [B] " FORMAT_B " != " FORMAT_B "", dimassoc->has_lastpt_ref, has_lastpt_ref);
has_lastpt_ref++;
if (dwg_dynapi_entity_set_value (dimassoc, "DIMASSOC", "has_lastpt_ref", &has_lastpt_ref, 0)
&& has_lastpt_ref == dimassoc->has_lastpt_ref)
pass ();
else
fail ("DIMASSOC.has_lastpt_ref [B] set+1 " FORMAT_B " != " FORMAT_B "", dimassoc->has_lastpt_ref, has_lastpt_ref);
dimassoc->has_lastpt_ref--;
}
{
struct _dwg_object_object* parent;
if (dwg_dynapi_entity_value (dimassoc, "DIMASSOC", "parent", &parent, NULL)
Expand Down

0 comments on commit 1d6dc2d

Please sign in to comment.