Skip to content

Commit

Permalink
Fix BLOCKSTRETCHACTION situation after handles
Browse files Browse the repository at this point in the history
Last fix was wrong. Each handle could have zero, one or more indexes.

Fixes GH#1053
  • Loading branch information
michal-josef-spacek committed Dec 6, 2024
1 parent b8fd725 commit ea93bca
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
10 changes: 5 additions & 5 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -13814,10 +13814,10 @@ BL, DXF 94
struct _dwg_object_BLOCKSTRETCHACTION*
@item hdl
H, DXF 331
@item bs74
@item num_indexes
BS, DXF 74
@item bl94
BL, DXF 94
@item indexes
BL*

@end vtable
@end indentedblock
Expand Down Expand Up @@ -14559,9 +14559,9 @@ BL, DXF 97
@item fitpts
2RD*
@item start_tangent
2RD
2RD, DXF 12
@item end_tangent
2RD
2RD, DXF 13

@end vtable
@end indentedblock
Expand Down
8 changes: 4 additions & 4 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -7799,9 +7799,9 @@ typedef struct _dwg_object_BLOCKSCALEACTION

typedef struct _dwg_BLOCKSTRETCHACTION_handles {
struct _dwg_object_BLOCKSTRETCHACTION *parent;
BITCODE_H hdl; // 331
BITCODE_BS bs74; // 74
BITCODE_BL bl94; // 94
BITCODE_H hdl; // 331
BITCODE_BS num_indexes; // 74
BITCODE_BL *indexes; // 94
} Dwg_BLOCKSTRETCHACTION_handles;

typedef struct _dwg_BLOCKSTRETCHACTION_codes {
Expand All @@ -7819,7 +7819,7 @@ typedef struct _dwg_object_BLOCKSTRETCHACTION
BITCODE_BL num_pts; // 72
BITCODE_2RD *pts; // 10
BITCODE_BL num_hdls; // 72
Dwg_BLOCKSTRETCHACTION_handles *hdls; /*!< DXF 331, 74, 94, 94 */
Dwg_BLOCKSTRETCHACTION_handles *hdls; /*!< DXF 331, 74, 94 */
BITCODE_BL num_codes; // 75
Dwg_BLOCKSTRETCHACTION_codes *codes; /*!< DXF 95, 76, 94 */
BLOCKACTION_doubles_fields;
Expand Down
5 changes: 3 additions & 2 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12427,8 +12427,9 @@ DWG_OBJECT (BLOCKSTRETCHACTION)
REPEAT (num_hdls, hdls, Dwg_BLOCKSTRETCHACTION_handles)
REPEAT_BLOCK
SUB_FIELD_HANDLE (hdls[rcount1], hdl, 0, 331);
SUB_FIELD_BS (hdls[rcount1], bs74, 74);
SUB_FIELD_BL (hdls[rcount1], bl94, 94);
SUB_FIELD_BS (hdls[rcount1], num_indexes, 74);
SUB_FIELD_VALUE (hdls[rcount1], indexes) = (BITCODE_BL *)calloc (_obj->hdls[rcount1].num_indexes, sizeof (BITCODE_BL));
SUB_FIELD_VECTOR_INL (hdls[rcount1], indexes, BL, _obj->hdls[rcount1].num_indexes, 94);
SET_PARENT_OBJ (hdls[rcount1]);
END_REPEAT_BLOCK
END_REPEAT (hdls)
Expand Down
10 changes: 5 additions & 5 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11254,10 +11254,10 @@ static const Dwg_DYNAPI_field _dwg_BLOCKSTRETCHACTION_handles_fields[] = {
1,1,0, 0 },
{ "hdl", "H", sizeof (BITCODE_H), OFF (struct _dwg_BLOCKSTRETCHACTION_handles, hdl),
1,0,0, 331 },
{ "bs74", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_BLOCKSTRETCHACTION_handles, bs74),
{ "num_indexes", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_BLOCKSTRETCHACTION_handles, num_indexes),
0,0,0, 74 },
{ "bl94", "BL", sizeof (BITCODE_BL), OFF (struct _dwg_BLOCKSTRETCHACTION_handles, bl94),
0,0,0, 94 },
{ "indexes", "BL*", sizeof (BITCODE_BL*), OFF (struct _dwg_BLOCKSTRETCHACTION_handles, indexes),
1,1,0, 0 },
{NULL, NULL, 0, 0, 0,0,0, 0},
};
/* from typedef struct _dwg_BLOCKVISIBILITYPARAMETER_state: (sorted by offset) */
Expand Down Expand Up @@ -11819,9 +11819,9 @@ static const Dwg_DYNAPI_field _dwg_HATCH_PathSeg_fields[] = {
{ "fitpts", "2RD*", sizeof (BITCODE_2RD*), OFF (struct _dwg_HATCH_PathSeg, fitpts),
1,1,0, 0 },
{ "start_tangent", "2RD", sizeof (BITCODE_2RD), OFF (struct _dwg_HATCH_PathSeg, start_tangent),
1,0,0, 0 },
1,0,0, 12 },
{ "end_tangent", "2RD", sizeof (BITCODE_2RD), OFF (struct _dwg_HATCH_PathSeg, end_tangent),
1,0,0, 0 },
1,0,0, 13 },
{NULL, NULL, 0, 0, 0,0,0, 0},
};
/* from typedef struct _dwg_HATCH_PolylinePath: (sorted by offset) */
Expand Down
27 changes: 17 additions & 10 deletions src/in_dxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7867,18 +7867,25 @@ add_AcDbBlockStretchAction (Dwg_Object *restrict obj, Bit_Chain *restrict dat)
dxf_free_pair (pair);

pair = dxf_read_pair (dat);
EXPECT_DXF (obj->name, o->hdls[i].bs74, 74);
o->hdls[i].bs74 = pair->value.i;
LOG_TRACE ("%s.hdls[%d].bs74 = %u [BS 74]\n", obj->name, i,
(unsigned)o->hdls[i].bs74);
EXPECT_DXF (obj->name, o->hdls[i].num_indexes, 74);
o->hdls[i].num_indexes = pair->value.i;
LOG_TRACE ("%s.hdls[%d].num_indexes = %u [BS 74]\n", obj->name, i,
(unsigned)o->hdls[i].num_indexes);
dxf_free_pair (pair);

pair = dxf_read_pair (dat);
EXPECT_DXF (obj->name, o->hdls[i].bl94, 94);
o->hdls[i].bl94 = pair->value.u;
LOG_TRACE ("%s.hdls[%d].bl94 = %u [BL 94]\n", obj->name, i,
(unsigned)o->hdls[i].bl94);
dxf_free_pair (pair);
if (o->hdls[i].num_indexes)
{
for (unsigned j = 0; j < o->hdls[i].num_indexes; j++)
{
pair = dxf_read_pair (dat);
EXPECT_DXF (obj->name, o->hdls[i].indexes[j], 94);
o->hdls[i].indexes[j] = pair->value.u;
LOG_TRACE ("%s.hdls[%d].indexes[%d] = %u [BL 94]\n", obj->name, i, j,
(unsigned)o->hdls[i].indexes[j]);
dxf_free_pair (pair);
}
}

}
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit-testing/blockstretchaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void
api_process (dwg_object *obj)
{
int error, isnew;
BITCODE_BL i;
BITCODE_BL i, j;
BLOCKACTION_fields;
BITCODE_BL num_pts;
BITCODE_2RD *pts;
Expand Down Expand Up @@ -40,8 +40,8 @@ api_process (dwg_object *obj)
for (i = 0; i < num_hdls; i++)
{
CHK_SUBCLASS_H (_obj->hdls[i], BLOCKSTRETCHACTION_handles, hdl);
CHK_SUBCLASS_TYPE (_obj->hdls[i], BLOCKSTRETCHACTION_handles, bs74, BS);
CHK_SUBCLASS_TYPE (_obj->hdls[i], BLOCKSTRETCHACTION_handles, bl94, BL);
CHK_SUBCLASS_TYPE (_obj->hdls[i], BLOCKSTRETCHACTION_handles, num_indexes, BS);
CHK_SUBCLASS_VECTOR_TYPE (_obj->hdls[i], BLOCKSTRETCHACTION_handles, indexes, _obj->hdls[i].num_indexes, BL);
}
CHK_ENTITY_TYPE (_obj, BLOCKSTRETCHACTION, num_codes, BL);
for (i = 0; i < num_codes; i++)
Expand Down

0 comments on commit ea93bca

Please sign in to comment.