Thanks Even.
After checking the code under dwg and dxf, I believe the relevant error code to
my original error report should be in
ogr/ogrsf_frmts/dxf/ogrdxf_polyline_smooth.cpp. The code in EmitArc() must
consider the case when ogrArcStartAngle > ogrArcEndAngle and bClockWise is true
before calling OGRGeometryFactory::approximateArcAngles() (around line 265).
Here I increase the value of ogrArcEndAngle by 360 degree as follows:
if( bClockwise && (ogrArcStartAngle > ogrArcEndAngle) )
ogrArcEndAngle += 360.0;
Then the reported error is corrected.
Similarly, there are error codes in both ogrdxf_hatch.cpp and ogrdwg_hatch.cpp
as you mentioned.
Line 286-294 in ogrdxf_hatch.cpp are quite suspicious:
if( bCounterClockwise )
{
double dfTemp = dfStartAngle;
dfStartAngle = dfEndAngle;
dfEndAngle = dfTemp;
}
if( dfStartAngle > dfEndAngle )
dfEndAngle += 360.0;
Can anyone explain to me why switching Start Angle and End Angle (this will
reverse the order of the line string!!). Also, if bCounterClockwise, you won't
want to increase dfEndAngle by 360..
I've fixed the above code with something like:
if( bCounterClockwise )
{
dfStartAngle *= -1;
dfEndAngle *= -1;
}
else if( dfStartAngle > dfEndAngle )
dfEndAngle += 360.0;
Similar fix-up is made in ogrdwg_hatch.cpp
Not sure if these are sufficient, yet at least work well with my couple of
sample dwg/dxf files.
I may want to submit a patch if you and other developers are okay with my
fix-up.
Best regards,
Xian
________________________________________
From: Even Rouault [[email protected]]
Sent: August 1, 2013 3:31
To: Xian Chen/陈羡
cc: [email protected]
Subject: Re: [gdal-dev] Reading error with dwg and dxf files
Selon Xian Chen <[email protected]>:
Hi Xian,
If you want to debug that, you can have a look at the revelant code in
ogr/ogrsf_frmts/dxf/ogrdxf_hatch.cpp around line 250 and below, and in
ogr/ogrsf_frmts/dwg/ogrdwg_hatch.cpp around line 190 and below.
Best regards,
Even
> Hi all,
>
> I encountered an error when reading the attached dwg file using OGR. The
> last part is supposed to be a clockwise big circle arc, but is translated
> into a counterclockwise circle arc.
>
> I then converted the file into dxf and still have the error. Can anyone
> please help me out?
>
>
> Best regards,
> Xian
> Curvelines.dwg
> <http://osgeo-org.1560.x6.nabble.com/file/n5069826/Curvelines.dwg>
>
>
>
> --
> View this message in context:
>
http://osgeo-org.1560.x6.nabble.com/gdal-dev-Reading-error-with-dwg-and-dxf-files-tp5069826.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev