Skip to content

Commit

Permalink
encode: skip MATERIAL (and its NOD)
Browse files Browse the repository at this point in the history
and its common handle link.
  • Loading branch information
rurban committed Nov 23, 2023
1 parent a95f174 commit 7bc82e9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/classes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
UNSTABLE_CLASS (ACTION, WIPEOUT) /* ent, stable but causes acad redraw to crash (GH #244) */
UNSTABLE_CLASS (ACTION, LARGE_RADIAL_DIMENSION) /* ent */
UNSTABLE_CLASS (ACTION, LIGHTLIST)
UNSTABLE_CLASS (ACTION, MATERIAL)
UNSTABLE_CLASS (ACTION, MATERIAL) // encode fails ODA
UNSTABLE_CLASS (ACTION, MENTALRAYRENDERSETTINGS) // not exported by Teigha
UNSTABLE_CLASS (ACTION, OBJECT_PTR)
UNSTABLE_CLASS_CPP (ACTION, OBJECT_PTR, CAseDLPNTableRecord)
Expand Down
11 changes: 10 additions & 1 deletion src/common_entity_data.spec
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,18 @@
}
SINCE (R_2007)
{
#ifndef DEBUG_CLASSES
#ifdef IS_ENCODER
if (FIELD_VALUE (material_flags) == 3)
{
LOG_WARN ("Disabling MATERIAL handle\n")
FIELD_VALUE (material_flags) = 0;
}
#endif
#endif
FIELD_BB (material_flags, 0); //if not BYLAYER 00: 347 material handle
DXF {
if (FIELD_VALUE (material_flags))
if (FIELD_VALUE (material_flags)) // TODO BYBLOCK also?
FIELD_HANDLE (material, 0, 347)
}
FIELD_RC0 (shadow_flags, 284); /* r2007+: 0 both, 1 receives, 2 casts, 3 no */
Expand Down
21 changes: 16 additions & 5 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ fixup_NOD (Dwg_Data *restrict dwg,
remove_NOD_item (_obj, i, "ACAD_" #name); \
}

#ifndef DEBUG_CLASSES
for (BITCODE_BL i = 0; i < _obj->numitems; i++)
{
DISABLE_NODSTYLE (ASSOCPERSSUBENTMANAGER)
Expand All @@ -1672,6 +1673,7 @@ fixup_NOD (Dwg_Data *restrict dwg,
else DISABLE_NODSTYLE (TABLESTYLE)
else DISABLE_NODSTYLE (VISUALSTYLE)
}
#endif
#undef DISABLE_NODSTYLE
}

Expand Down Expand Up @@ -2441,6 +2443,7 @@ encode_r13_thumbnail (Dwg_Data *restrict dwg, Bit_Chain *restrict dat,
* TODO: 2007 maps.
* 2010+ uses the 2004 format.
* Returns a summary bitmask of all errors.
* Skip all MATERIAL objects, DICTS and common properties
*/
AFL_GCC_TOOBIG
EXPORT int
Expand Down Expand Up @@ -2514,10 +2517,14 @@ dwg_encode (Dwg_Data *restrict dwg, Bit_Chain *restrict dat)
Dwg_Object *obj = &dwg->object[i];
if (obj->fixedtype == DWG_TYPE_UNKNOWN_OBJ
|| obj->fixedtype == DWG_TYPE_UNKNOWN_ENT
// WIPEOUT causes hang, TABLEGEOMETRY crash
|| (dwg->opts & DWG_OPTS_IN
&& (obj->fixedtype == DWG_TYPE_WIPEOUT
|| obj->fixedtype == DWG_TYPE_TABLEGEOMETRY)))
// WIPEOUT causes hang, TABLEGEOMETRY crash, MATERIAL causes ODA errors
#ifndef DEBUG_CLASSES
|| (dwg->opts & DWG_OPTS_IN
&& (obj->fixedtype == DWG_TYPE_WIPEOUT
|| obj->fixedtype == DWG_TYPE_TABLEGEOMETRY
|| obj->fixedtype == DWG_TYPE_MATERIAL))
#endif
)
{
fixup++;
break;
Expand Down Expand Up @@ -2546,9 +2553,13 @@ dwg_encode (Dwg_Data *restrict dwg, Bit_Chain *restrict dat)
Dwg_Object *obj = &dwg->object[i];
if (obj->fixedtype == DWG_TYPE_UNKNOWN_OBJ
|| obj->fixedtype == DWG_TYPE_UNKNOWN_ENT
#ifndef DEBUG_CLASSES
|| (dwg->opts & DWG_OPTS_IN
&& (obj->fixedtype == DWG_TYPE_WIPEOUT
|| obj->fixedtype == DWG_TYPE_TABLEGEOMETRY)))
|| obj->fixedtype == DWG_TYPE_TABLEGEOMETRY
|| obj->fixedtype == DWG_TYPE_MATERIAL))
#endif
)
{
fixup++;
// replace entities with points, objects with
Expand Down

0 comments on commit 7bc82e9

Please sign in to comment.