vagran / dxf-viewer

DXF 2D viewer written in JavaScript
Mozilla Public License 2.0
323 stars 98 forks source link

Problems with for ANSI31/SOLID pattern hatches #88

Open tth05 opened 1 year ago

tth05 commented 1 year ago

Hello,

thanks for making this library, it works really well. I'm just having two small issues, which you can see below (Note that I renamed the files, otherwise github won't let me upload them...):

The triangle is not rendered in your viewer image solid-hatch.dxf.txt

The 45° lines are not rendered in your viewer image ansi31-pattern.dxf.txt

I recognize that you're busy right now, so I'd be happy about any help on how to fix these two issues. I'm willing to invest time and make a PR if you could give me some advice. I already saw your comment about solid hatches, not sure yet why the other one doesn't work. Is there any way to know how things in a dxf file should be rendered properly? I can't find any information about it. Also, I have access to AutoCAD, although I have no idea how to use it, so I can probably give you more information or create samples.

tth05 commented 1 year ago

I noticed that second one doesn't render because the hatchStyle is 1 (outermost area only). I changed it to 2 while debugging which interestingly makes it renders exactly like in AutoCAD. Sadly, this doesn't work when the lines are vertical

image vertical-lines.dxf.txt

vagran commented 1 year ago

Hello, I will definitely take a look at all your samples once I have some free time (perhaps in a few days). Maybe it is time to implement solid hatching as well. Thanks for the samples!

tth05 commented 1 year ago

Thanks a lot for the response. Let me know if you want to fix/implement anything, then I won't bother trying. I'm currently working on MText frames which are completely undocumented and the size of the background box makes no sense...

Also, I can create infinitely more samples if you need any. Just ask.

vagran commented 1 year ago

Seems the problem with non-solid hatching caused by my complete misunderstanding of hatching styles due to a lack of documentation. I was under impression that outermost style means hatching between the hatch path and some outer entities (which is difficult to implement), however seems it is always defined inside hatch paths, according to this description which I missed somehow. This definitely should be fixed, I will try to do this. This depends on test samples, which should have several nested hatch islands (with and without intersections), with different hatch styles, some variants of marking paths with external and outermost flags mentioned in the description, and their "ground truth" rendering example. Any assistance with creating such test samples is very welcome.

tth05 commented 1 year ago

I put some random stuff together, let me know if you need more. image random-hatches.dxf.txt

On a side note: I found this project https://github.com/mattdesl/three-line-2d. Could possibly be used as an easy way to get variable line width

tth05 commented 10 months ago

@vagran I implemented quite a few MText related things as well as outer hatch style in my fork. https://github.com/tth05/dxf-viewer Would you up to review it if I make a PR? I wouldn't want it to sit around and become stale

vagran commented 10 months ago

I took a quick look at your fork, it seems to be very valuable work. Yes, make PR for sure. Feel free to add yourself to the CONTRIBUTORS file. Thanks!