JamesBremner / DXF_Viewer

A simple DXF File viewer
MIT License
22 stars 4 forks source link

Spline parser confused when zero points specified #28

Closed JamesBremner closed 3 months ago

JamesBremner commented 3 months ago

Reported in #23 by @asmwarrior

One thing I like to mention is that when I export dxf file from autocad or other tool, this library can not handle dxf files contains splines.

JamesBremner commented 3 months ago

@asmwarrior Please provide a small, simple example of a DXF file that fails.

There are 3 test files in the dxf folder that contain splines. Two of these work for me. How about for you?

asmwarrior commented 3 months ago

Hi, James, thanks for creating a new issue.

I see that you said:

Please open an issue for this and provide a small, simple example of a DXF file that fails. Ensure that you do NOT have SPLINE with fit AND control points.

My guess that my DXF file may belong to the "SPLINE with fit AND control points". I need to take some time to check the DXF files and the parser code to confirm this.

BTW: how hard is it to implement/support the "SPLINE with fit AND control points"?

Thanks.

JamesBremner commented 3 months ago

( Problem was some type drawing functions tried to use their own color, resulting in drawing black line on a black background. Now all types used the default color, white. )

All spline test files now produce reasonable looking displays. This includes spline_mixed.dxf which contains BOTH control and fit points.

JamesBremner commented 3 months ago

Please test with release v1.0.0

asmwarrior commented 3 months ago

Drawing2.zip

Hi, in the test folder, I see the spline related files can be loaded and drawn correctly.

I have uploaded a new dxf, which can't be read by this library(an exception will happen). I'm not sure this kinds of dxf can be handled. Thanks.

JamesBremner commented 3 months ago

Did you test with the v1.0.0 release?

When I try it here, it seems fine

image

JamesBremner commented 3 months ago

Note that Drawing2,dxf contains no splines. So it probably should not be in this issue.

asmwarrior commented 3 months ago

Note that Drawing2,dxf contains no splines. So it probably should not be in this issue.

Oh I'm sorry, I see I uploaded the wrong test dxf file.

I will create a new one when I got to the office.

asmwarrior commented 3 months ago

test-spline.zip

OK, this is the dxf file, which can't be parsed by this library.

It will report that: throw std::runtime_error("Spline has no points");

This file can be opened in the LibreCAD, see the image shot below:

image

Thanks.

JamesBremner commented 3 months ago

Cause: Your test file specifies the number of fit points to be zero. The parsing code assumes that, if there are zero fit points, then the code-value pair would be omitted. I will modify the code to check for a zero count specified, in which case it will behave as if the code-value pair had been omitted.

asmwarrior commented 3 months ago

Thanks, I see this issue happens several years ago. I believe it is in year 2020. And in that time, I see the DXF file converted from dwg files (using some autoCAD like tool) can't loaded by this library. The only way till now is that I need to convert all the spline lines in the dwg file to polygon lines, so that the converted dxf file does not contains any spline lines.

If you can solve the problem, it will be great!

JamesBremner commented 3 months ago

I see this issue happens several years ago. I believe it is in year 2020.

Did you report it at that time?

asmwarrior commented 3 months ago

I see this issue happens several years ago. I believe it is in year 2020.

Did you report it at that time?

Oh, I think I haven't reported this issue before.

Now, this the latest git head, I see the file can be loaded and shown, thanks, see below:

image

You see the inner red line is missing, Compared with the image I posted before in LiberCAD.

asmwarrior commented 3 months ago

It looks like there are some layer information in this DXF file, and DXF_Viewer's parser can't parse it.

See the LibreCAD screen shot.

image

image

So, you can see, the inner red lines belong to the second layer.

JamesBremner commented 3 months ago

I think I haven't reported this issue before.

Well then, you should not expect it to be fixed without a report

JamesBremner commented 3 months ago

there are some layer information in this DXF file

If so, then merge the layers.

asmwarrior commented 3 months ago

I think I haven't reported this issue before.

Well then, you should not expect it to be fixed without a report

OK.

there are some layer information in this DXF file

If so, then merge the layers.

Can the parser parse the layer information?

Such as when it see the layer start token or layer end token, it mark the objects in a specified layer. Even though a DXF has many layers, the parser can still skip the layer start or end token, so those objects can still be drawn.

JamesBremner commented 3 months ago

Did you try merging the layers so as to check if that is really the problem?

asmwarrior commented 3 months ago

Did you try merging the layers so as to check if that is really the problem?

LiberCAD can not merge the layers, I will try other tools tomorrow.

JamesBremner commented 3 months ago

I see the file can be loaded and shown, thanks,