Opened 9 months ago

Closed 9 months ago

#7098 closed defect (fixed)

DXF: OCS fixes for HATCH and INSERT entities

Reported by: Alan Thomas Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords: dxf
Cc:

Description

The OCS transformation is correctly applied for HATCH entities, but because the elevations of these entities are ignored, the transformation is wrong for any HATCH not at zero elevation.

Additionally, in #7077 I added an OCS transformation for the insertion point of INSERTs. This is sufficient for simple OCS transformations like (0,0,-1), but it is not enough for an OCS like (0,1/sqrt(2),-1/sqrt(2)). In the latter case the entire block needs to be transformed from the OCS to the WCS. As usual the documentation is useless, so I used a process of trial-and-error, and comparison with AutoCAD's outputs, to arrive at the solution in the patch.

The patch:

  • adds support for the HATCH elevation field
  • performs additional OCS transformations for the geometry of blocks
  • promotes the geometry to 3D before performing the OCS transformation, to avoid losing the Z coordinates for entities that were initially 2D
  • includes a testcase that also tests OCS to WCS transformations for SOLID elements with nonzero Z coordinate as a follow-up to #7089

Attachments (3)

OGR-DXF-more-ocs-fixes.diff (31.8 KB) - added by Alan Thomas 9 months ago.
Patch
OGR-DXF-more-ocs-fixes-v2.diff (32.5 KB) - added by Alan Thomas 9 months ago.
Patch
OGR-DXF-more-ocs-fixes-v3.diff (34.5 KB) - added by Alan Thomas 9 months ago.
Patch

Download all attachments as: .zip

Change History (9)

Changed 9 months ago by Alan Thomas

Attachment: OGR-DXF-more-ocs-fixes.diff added

Patch

comment:1 Changed 9 months ago by Alan Thomas

This patch is experiencing similar test failures to the patch in #7089, with weird WKT outputs like POLYGON ((0 0 0,0 1 0,1 0 0,0 0 0)) (shouldn't it either miss out the zero Z values, or be POLYGON Z?)

comment:2 in reply to:  1 Changed 9 months ago by Even Rouault

Replying to atlight:

This patch is experiencing similar test failures to the patch in #7089, with weird WKT outputs like POLYGON ((0 0 0,0 1 0,1 0 0,0 0 0)) (shouldn't it either miss out the zero Z values, or be POLYGON Z?)

See my answer in #7089 regarding this

But I observe the following test failures with your patch (note: I have already applied #7089, in case that makes a difference)

  TEST: ogr_dxf_12 ... fail
    line 440: not keeping polygon 2D
  TEST: ogr_dxf_15 ... fail
    line 630: not keeping polygon 2D
  TEST: ogr_dxf_34 ... fail
    line 2399: did not get expected geometry back: got POLYGON ((0 0 0,0 1 0,1 0 0,0 0 0))

It seems that we promote to 3D more eagerly now than with the previous version of the code.

Changed 9 months ago by Alan Thomas

Patch

comment:3 Changed 9 months ago by Alan Thomas

That patch should address the test failures properly.

comment:4 Changed 9 months ago by Alan Thomas

Actually don't merge that yet, this code is still wrong for blocks on an OCS that have rotation/scaling. I will try to fix that as well.

Changed 9 months ago by Alan Thomas

Patch

comment:5 Changed 9 months ago by Alan Thomas

Third time lucky, I hope!

comment:6 Changed 9 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 40523:

DXF: OCS fixes for HATCH and INSERT entities (patch by atlight, fixes #7098)

Note: See TracTickets for help on using tickets.