Opened 10 months ago

Closed 9 months ago

#6971 closed defect (fixed)

DXF: Cannot import hatches with boundaries that contain elliptical arcs

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

Description

The importation of hatch entities with elliptical arcs in their boundaries is completely broken:

  • The ratio of minor axis to major axis is incorrectly interpreted by OGR as a percentage between 0 and 100, where it is actually a ratio between 0 and 1.
  • In AutoCAD, "start angle" and "end angle" refer to circular angles. OGR is incorrectly interpreting these values as elliptical angles, or parameters.

Given the common code, it's possible that the DWG format also has these issues (although I haven't tested that).

The specification (http://images.autodesk.com/adsk/files/autocad_2014_pdf_dxf_reference_enu.pdf, PDF page 111, numbered 103 in document) is admittedly vague, but the problems are obvious when you export a DXF from AutoCAD and try reading it into OGR.

Attachments (3)

elliptical-arc-hatch.png (7.8 KB) - added by Alan Thomas 10 months ago.
Screenshot of the example DXF file
elliptical-arc-hatch.dxf (349.3 KB) - added by Alan Thomas 10 months ago.
Sample DXF file with elliptical arc on hatch boundary
OGR-DXF-hatch-fixesonly.diff (1.4 KB) - added by Alan Thomas 10 months ago.
Patch

Download all attachments as: .zip

Change History (6)

Changed 10 months ago by Alan Thomas

Attachment: elliptical-arc-hatch.png added

Screenshot of the example DXF file

Changed 10 months ago by Alan Thomas

Attachment: elliptical-arc-hatch.dxf added

Sample DXF file with elliptical arc on hatch boundary

Changed 10 months ago by Alan Thomas

Patch

comment:1 Changed 10 months ago by Even Rouault

@atlight What is the rationale for the "180.0 * floor ( ( dfStartAngle + 90 ) / 180 )" term in the formula that converts from circular to elliptical angles ?

comment:2 Changed 9 months ago by Alan Thomas

@Even: This part of the formula:

atan( ( 1.0 / dfRatio ) * tan( dfEndAngle * M_PI / 180 ) )

always returns an angle between -90 and 90 degrees. The term

180.0 * floor ( ( dfStartAngle + 90 ) / 180 )

returns a multiple of 180, which is added on in order to give the correct result.

If you know a clearer formula to convert circular to elliptical angles, please feel free to substitute that :)

comment:3 Changed 9 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 39826:

DXF: fix reading of hatches with boundaries that contain elliptical arcs (patch by atlight, fixes #6971)

Note: See TracTickets for help on using tickets.