Opened 7 years ago

Closed 7 years 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 7 years ago.
Screenshot of the example DXF file
elliptical-arc-hatch.dxf (349.3 KB ) - added by Alan Thomas 7 years ago.
Sample DXF file with elliptical arc on hatch boundary
OGR-DXF-hatch-fixesonly.diff (1.4 KB ) - added by Alan Thomas 7 years ago.
Patch

Download all attachments as: .zip

Change History (6)

by Alan Thomas, 7 years ago

Attachment: elliptical-arc-hatch.png added

Screenshot of the example DXF file

by Alan Thomas, 7 years ago

Attachment: elliptical-arc-hatch.dxf added

Sample DXF file with elliptical arc on hatch boundary

by Alan Thomas, 7 years ago

Patch

comment:1 by Even Rouault, 7 years ago

@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 by Alan Thomas, 7 years ago

@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 by Even Rouault, 7 years ago

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.