Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DIMASSOC object #1029

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -14060,12 +14060,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 @@ -5282,20 +5282,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
49 changes: 23 additions & 26 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9896,46 +9896,43 @@ 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
// 6 = maximum of items
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)))
// 35 is minimal size of item
if (dat->byte + 35 > dat->size)
{
#ifdef IS_JSON
ENDHASH;
#endif
continue;
break;
}
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_BL (ref[rcount1], num_xrefs, 0);
SUB_HANDLE_VECTOR (ref[rcount1], xrefs, num_xrefs, 4, 331);

if (FIELD_VALUE (ref[rcount1].osnap_type) != 0)
{
SUB_FIELD_BL (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_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))
if (FIELD_VALUE (ref[rcount1].osnap_type) == 6 || FIELD_VALUE (ref[rcount1].osnap_type) == 11)
{
SUB_FIELD_3BD (ref[rcount1], lastpt_ref, 0);
SUB_FIELD_BL (ref[rcount1], num_intsectobj, 0);
SUB_HANDLE_VECTOR (ref[rcount1], intsectobj, num_intsectobj, 5, 332);
SUB_FIELD_BL (ref[rcount1], intersec_subent_type, 74);
SUB_FIELD_BL (ref[rcount1], intersec_gsmarker, 92);
SUB_FIELD_BL (ref[rcount1], num_intersec_xrefpaths, 0);
FIELD_VECTOR_T (ref[rcount1].intersec_xrefpaths, T, ref[rcount1].num_intersec_xrefpaths, 302)
}
SUB_FIELD_B (ref[rcount1], has_lastpt_ref, 75);
SET_PARENT_OBJ (ref[rcount1]);
END_REPEAT_BLOCK
END_REPEAT (ref)
Expand Down
12 changes: 9 additions & 3 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11428,12 +11428,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
Loading