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 2 commits into
base: master
Choose a base branch
from

Conversation

michal-josef-spacek
Copy link
Contributor

No description provided.

@rurban
Copy link
Contributor

rurban commented Oct 14, 2024

As smoke/dimassoc-pr1029

@rurban
Copy link
Contributor

rurban commented Oct 14, 2024

test make && make -C test/unit-testing/ dimassoc && (cd test/unit-testing && ./dimassoc; cd -) in smoke/dimassoc-pr1029. osnap_pt is wrong.

unknowns see DIMASSOC.zip

Copy link
Contributor

@rurban rurban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt parse. see the unit-tests and the pi logs

include/dwg.h Outdated Show resolved Hide resolved
@michal-josef-spacek
Copy link
Contributor Author

I am trying to test, but I was blocked by #1032

@michal-josef-spacek
Copy link
Contributor Author

Ad make && make -C test/unit-testing/ dimassoc && (cd test/unit-testing && ./dimassoc; cd -):
Yes, all >AC1018 are bad, condition with minimal length of item (35 bytes) to end of block is not working.

test/test-data/example_2018.dwg:

...
trans_space_flag: 0 [B 70]
rotated_type: 0x0 [RC 71]
dimensionobj: (4.2.399) abs:921 [H 330]
DIMASSOC_Ref.rcount1: 0
ref[rcount1].classname: "AcDbOsnapPointRef" [TU 1]
ref[0].osnap_type: 0xd [RC 72]
ref[0].num_xrefs: 1 [BL 0]
ref[rcount1].xrefs[vcount]: (4.2.398) abs:920 [H 331]
ref[0].main_subent_type: 2 [BL 73]
ref[0].main_gsmarker: 0 [BL 91]
ref[0].num_xrefpaths: 0 [BL 0]
ref[0].osnap_dist: 4.13129 [BD 40]
ref[0].osnap_pt: (0, 0, 2e+50) [3BD 10]
ref[0].has_lastpt_ref: 0 [B 75]
DIMASSOC_Ref.rcount1: 1
ref[rcount1].classname: "AcDbOsnapPointRef" [TU 1]
ref[1].osnap_type: 0x1 [RC 72]
ref[1].num_xrefs: 1 [BL 0]
ref[rcount1].xrefs[vcount]: (4.2.398) abs:920 [H 331]
ref[1].main_subent_type: 2 [BL 73]
ref[1].main_gsmarker: 0 [BL 91]
ref[1].num_xrefpaths: 0 [BL 0]
ref[1].osnap_dist: 7.44845 [BD 40]
ref[1].osnap_pt: (0, 0, 2e+50) [3BD 10]
ref[1].has_lastpt_ref: 0 [B 75]
DIMASSOC_Ref.rcount1: 2
ref[rcount1].classname: "AcDbOsnapPointRef" [TU 1]
ref[2].osnap_type: 0x3 [RC 72]
ref[2].num_xrefs: 1 [BL 0]
ref[rcount1].xrefs[vcount]: (4.2.398) abs:920 [H 331]
ref[2].main_subent_type: 2 [BL 73]
ref[2].main_gsmarker: 0 [BL 91]
ref[2].num_xrefpaths: 0 [BL 0]
ref[2].osnap_dist: 4.13129 [BD 40]
ref[2].osnap_pt: (0, 0, 0) [3BD 10]
ref[2].has_lastpt_ref: 0 [B 75]
DIMASSOC_Ref.rcount1: 3
ERROR: bit_read_TU buffer overflow at 170.6 + 112 > 172
ref[rcount1].classname: "" [TU 1]
ref[3].osnap_type: 0x44 [RC 72]
ref[3].num_xrefs: 65 [BL 0]
ERROR: Invalid xrefs size 65. Need min. 520 bits, have 3 for DIMASSOC. Set _size to 0
 object_map{3B4} = 261
 padding: 80/0 (6 bits)
crc: 3461 [RSx]
 check_CRC 121033-121226 = 193: 3461 == 3461

It need to end before last block.

@rurban rurban linked an issue Dec 12, 2024 that may be closed by this pull request
3 tasks
@rurban
Copy link
Contributor

rurban commented Dec 12, 2024

I fixed the unit-test now. branch work/dimassoc-pr1029

@michal-josef-spacek
Copy link
Contributor Author

@rurban

I fixed the unit-test now. branch work/dimassoc-pr1029

First, in this branch, the commit 3b55ce3 is wrong. There is 3BD, not 2BD. Or do you have some information that I don't have?

Second. The main problem with the activity to fix DIMASSOC is how to count AcDbOsnapPointRef classes. I don't see any count for a number of classes. The question is how to detect the start and end of this section. One possibility is to check the first string AcDbOsnapPointRef. Or I don't know. When we brainstormed this issue, I could finish the DIMASSOC object and test it.

@rurban
Copy link
Contributor

rurban commented Dec 13, 2024

@rurban

I fixed the unit-test now. branch work/dimassoc-pr1029

First, in this branch, the commit 3b55ce3 is wrong. There is 3BD, not 2BD. Or do you have some information that I don't have?

Second. The main problem with the activity to fix DIMASSOC is how to count AcDbOsnapPointRef classes. I don't see any count for a number of classes. The question is how to detect the start and end of this section. One possibility is to check the first string AcDbOsnapPointRef. Or I don't know. When we brainstormed this issue, I could finish the DIMASSOC object and test it.

As you in see in the current code, the count is computed from a number of bits

@michal-josef-spacek
Copy link
Contributor Author

@rurban
If you mean this code:

  // 6 = maximum of items
  REPEAT_CN (6, ref, Dwg_DIMASSOC_Ref) // i.e. AcDbOsnapPointRef
  REPEAT_BLOCK
      // 35 is minimal size of item
      if (dat->byte + 35 > dat->size)
        {
#ifdef IS_JSON 
          ENDHASH;
#endif
          break;
        }

I wrote it.
This is not working in every use case.
I am blocked on this detection.

@rurban
Copy link
Contributor

rurban commented Dec 15, 2024

@rurban If you mean this code:

  // 6 = maximum of items
  REPEAT_CN (6, ref, Dwg_DIMASSOC_Ref) // i.e. AcDbOsnapPointRef
  REPEAT_BLOCK
      // 35 is minimal size of item
      if (dat->byte + 35 > dat->size)
        {
#ifdef IS_JSON 
          ENDHASH;
#endif
          break;
        }

I wrote it. This is not working in every use case. I am blocked on this detection.

Yes, this wrong. See my current code which loops on the bits

@michal-josef-spacek
Copy link
Contributor Author

Ach, I rewrited your code to my, because I had issues with it. Ok, maybe it isn't wrong.

@michal-josef-spacek
Copy link
Contributor Author

michal-josef-spacek commented Dec 16, 2024

I have examples:
File #1 (AC1018 DXF):
associativity: 15, number of AcDbOsnapPointRef: 4
associativity: 7, number of AcDbOsnapPointRef: 3
associativity: 3, number of AcDbOsnapPointRef: 2
associativity: 2, number of AcDbOsnapPointRef: 1

File #2 (AC1018 DXF):
associativity: 3, number of AcDbOsnapPointRef: 3
associativity: 3, number of AcDbOsnapPointRef: 2
associativity: 2, number of AcDbOsnapPointRef: 2
associativity: 2, number of AcDbOsnapPointRef: 1
associativity: 1, number of AcDbOsnapPointRef: 1

@rurban
Copy link
Contributor

rurban commented Dec 16, 2024

I have examples: File #1 (AC1018 DXF): associativity: 15, number of AcDbOsnapPointRef: 4 associativity: 7, number of AcDbOsnapPointRef: 3 associativity: 3, number of AcDbOsnapPointRef: 2 associativity: 2, number of AcDbOsnapPointRef: 1

Here the popcounts do match

File #2 (AC1018 DXF): associativity: 3, number of AcDbOsnapPointRef: 3 associativity: 3, number of AcDbOsnapPointRef: 2 associativity: 2, number of AcDbOsnapPointRef: 2 associativity: 2, number of AcDbOsnapPointRef: 1 associativity: 1, number of AcDbOsnapPointRef: 1

Here only 3 of 5 match, hmm

@michal-josef-spacek
Copy link
Contributor Author

@rurban This is definitely #1031 (comment)

@michal-josef-spacek
Copy link
Contributor Author

@rurban I improved PR.

Nice example output from this PR code (index 0, 1, 4, 5, 6):

--common_size: 76
unknown_bits [1578 (76,1416,0) 198 TF]: 40C008920B1A23127B9B730B82837B4B73A2932B300042028151E8E9DCBCBBC3DA7F5512416344624F736E6170506F696E745265660000A1C2C7DE4B4431150481E089F982FCF34088920B1
A23127B9B730B82837B4B73A2932B300042028151E8E9DCBCBBC3DA7F5512416344624F736E6170506F696E74526566000840502A3D1D3B9797787B4FEAA2482C688C49EE6DCC2E0A0DED2DCE8A4CACC000143858FBC9688622A0903C113F30
5F9E6812010D8C1C4CC10D8C1C490D8C1BB50D8C1BBD0D8C1BB703

associativity: 0x3 [BLx 90]
trans_space_flag: 0 [B 70]
rotated_type: 0x0 [RC 71]
dimensionobj: (4.3.630712) abs:6489874 [H 330]
DIMASSOC_Ref.rcount1: 0
ref[rcount1].classname: "AcDbOsnapPointRef" [T 1]
ref[0].osnap_type: 0x8 [RC 72]
ref[0].num_xrefs: 1 [BL 0]
ref[rcount1].xrefs[vcount]: (4.3.6306ED) abs:6489837 [H 331]
ref[0].main_subent_type: 2 [BL 73]
ref[0].main_gsmarker: 0 [BL 91]
ref[0].num_xrefpaths: 0 [BL 0]
ref[0].osnap_dist: 0.93376 [BD 40]
ref[0].osnap_pt: (0, 0, 0) [3BD 10]
ref[0].has_lastpt_ref: 1 [B 75]
DIMASSOC_Ref.rcount1: 1
ref[rcount1].classname: "AcDbOsnapPointRef" [T 1]
ref[1].osnap_type: 0x0 [RC 72]
ref[1].num_xrefs: 0 [BL 0]
ref[1].osnap_dist: 0 [BD 40]
ref[1].osnap_pt: (2.75908e+06, 81864.2, 0) [3BD 10]
ref[1].has_lastpt_ref: 0 [B 75]
DIMASSOC_Ref.rcount1: 4
ref[4].classname: "AcDbOsnapPointRef" [T 1]
ref[4].osnap_type: 0x8 [RC 72]
ref[4].num_xrefs: 1 [BL 0]
ref[4].xrefs[vcount]: (4.3.6306EF) abs:6489839 [H 331]
ref[4].main_subent_type: 2 [BL 73]
ref[4].main_gsmarker: 0 [BL 91]
ref[4].num_xrefpaths: 0 [BL 0]
ref[4].osnap_dist: 0.93376 [BD 40]
ref[4].osnap_pt: (0, 0, 0) [3BD 10]
ref[4].has_lastpt_ref: 1 [B 75]
DIMASSOC_Ref.rcount1: 5
ref[5].classname: "AcDbOsnapPointRef" [T 1]
ref[5].osnap_type: 0x8 [RC 72]
ref[5].num_xrefs: 1 [BL 0]
ref[5].xrefs[vcount]: (4.3.6306ED) abs:6489837 [H 331]
ref[5].main_subent_type: 2 [BL 73]
ref[5].main_gsmarker: 0 [BL 91]
ref[5].num_xrefpaths: 0 [BL 0]
ref[5].osnap_dist: 0.93376 [BD 40]
ref[5].osnap_pt: (0, 0, 0) [3BD 10]
ref[5].has_lastpt_ref: 1 [B 75]
DIMASSOC_Ref.rcount1: 6
ref[6].classname: "AcDbOsnapPointRef" [T 1]
ref[6].osnap_type: 0x0 [RC 72]
ref[6].num_xrefs: 0 [BL 0]
ref[6].osnap_dist: 0 [BD 40]
ref[6].osnap_pt: (2.75908e+06, 81864.2, 0) [3BD 10]
ref[6].has_lastpt_ref: 0 [B 75]
 padding: +4
 object_map{630714} = 17672
 padding: DF/F (4 bits)
crc: 506D [RSx]
 check_CRC 7452086-7452297 = 211: 506D == 506D

@michal-josef-spacek
Copy link
Contributor Author

@rurban In the case of your code:

...
one_more = SUB_FIELD_VALUE(ref[rcount1], has_lastpt_ref);
...

This is not working.
one_more could be set from any first four has_lastpt_ref
Example:

--common_size: 76
unknown_bits [986 (76,856,0) 124 TF]: 40C008920B1A23127B9B730B82837B4B73A2932B300042028150E6B84AB50D97DE7F5512416344624F736E6170506F696E745265660000A131B0CDAD64D00904909281CA02B9DAC088920B1A2
3127B9B730B82837B4B73A2932B30000A02815344D323F62870DB0A52010C2681BCC10C2681B90C267B750C26772F03

associativity: 0x3 [BLx 90]
trans_space_flag: 0 [B 70]
rotated_type: 0x0 [RC 71]
dimensionobj: (4.3.9A06E) abs:630894 [H 330]
DIMASSOC_Ref.rcount1: 0
ref[rcount1].classname: "AcDbOsnapPointRef" [T 1]
ref[0].osnap_type: 0x8 [RC 72]
ref[0].num_xrefs: 1 [BL 0]
ref[rcount1].xrefs[vcount]: (4.3.99EDD) abs:630493 [H 331]
ref[0].main_subent_type: 2 [BL 73]
ref[0].main_gsmarker: 0 [BL 91]
ref[0].num_xrefpaths: 0 [BL 0]
ref[0].osnap_dist: 0.993594 [BD 40]
ref[0].osnap_pt: (0, 0, 0) [3BD 10]
ref[0].has_lastpt_ref: 1 [B 75]
DIMASSOC_Ref.rcount1: 1
ref[rcount1].classname: "AcDbOsnapPointRef" [T 1]
ref[1].osnap_type: 0x0 [RC 72]
ref[1].num_xrefs: 0 [BL 0]
ref[1].osnap_dist: 0 [BD 40]
ref[1].osnap_pt: (149131, -27364, 0) [3BD 10]
ref[1].has_lastpt_ref: 0 [B 75]
DIMASSOC_Ref.rcount1: 4
ref[4].classname: "AcDbOsnapPointRef" [T 1]
ref[4].osnap_type: 0x1 [RC 72]
ref[4].num_xrefs: 1 [BL 0]
ref[4].xrefs[vcount]: (4.3.99DCB) abs:630219 [H 331]
ref[4].main_subent_type: 2 [BL 73]
ref[4].main_gsmarker: 0 [BL 91]
ref[4].num_xrefpaths: 0 [BL 0]
ref[4].osnap_dist: 1 [BD 40]
ref[4].osnap_pt: (0, 0, 2e+50) [3BD 10]
ref[4].has_lastpt_ref: 0 [B 75]
 padding: +4
 object_map{9A070} = 19484
 padding: BF/F (4 bits)
crc: 9031 [RSx]
 check_CRC 2397786-2397923 = 137: 9031 == 9031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix DIMASSOC object
2 participants