Wings 3D Development Forum
SVG plugin additions - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Design & Development (https://www.wings3d.com/forum/forumdisplay.php?fid=6)
+--- Thread: SVG plugin additions (/showthread.php?tid=3083)

Pages: 1 2 3 4


RE: SVG plugin additions [WIP] - edb - 05-07-2023

Hello,

I was able to replicate the problem, it is likely caused by there being repeat coordinates being generated for the <circle> tag.
[Image: iQLFfpRS_o.png]

Removing the repeat coordinates, at least in a isolated setup for debugging, seems to fix it:
[Image: QRQU7jtc_o.png]

However after trying to apply the fix to remove the extra points to the wpc_svg_path plugin and trying the test file again, it then cause a key_exists error and make the shape vanish. So in some conditions there might happen a key_exists error that I am trying to figure out.

In some cases I can cause the key_exists error to happen in isolated setup as well in some different scenarios. If I only remove some coordinates and not others, it will cause key_exists, which then works again if I put back in 2 repeating coordinates at the end of the path.


RE: SVG plugin additions [WIP] - micheus - 05-07-2023

Where in the code are you getting this key_exists error?


RE: SVG plugin additions [WIP] - edb - 05-07-2023

Hello micheus,

It happens somewhere when calling into wpc_ai and then into e3d__tri_quad.

I've attached a file with tkbd's test file and a .beam/.erl of that reproduces
the error, the setting "combine all paths" needs to be checked on:
svg_key_exists.zip

Code:
error: {key_exists,{120,103}}
stack trace: [{gb_trees,insert_1,4,[{file,"gb_trees.erl"},{line,319}]},
              {gb_trees,insert_1,4,[{file,"gb_trees.erl"},{line,281}]},
              {gb_trees,insert_1,4,[{file,"gb_trees.erl"},{line,281}]},
              {gb_trees,insert,3,[{file,"gb_trees.erl"},{line,278}]},
              {e3d__tri_quad,tridict1,2,
                             [{file,"e3d__tri_quad.erl"},{line,484}]},
              {lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
              {e3d__tri_quad,cdt,3,[{file,"e3d__tri_quad.erl"},{line,432}]},
              {e3d__tri_quad,quadrangulate_face_with_holes,3,
                             [{file,"e3d__tri_quad.erl"},{line,119}]},
              {wpc_ai,pa2object,1,[{file,"wpc_ai.erl"},{line,574}]},
              {lists,map,2,[{file,"lists.erl"},{line,1239}]},
              {wpc_ai,polyareas_to_faces,1,[{file,"wpc_ai.erl"},{line,301}]},
              {wpc_svg_path,'-process_islands/1-fun-0-',2,
                            [{file,"src/wpc_svg_path.erl"},{line,3671}]},
              {lists,foldr,3,[{file,"lists.erl"},{line,1276}]},
              {wpc_svg_path,try_import_svg_1,5,
                            [{file,"src/wpc_svg_path.erl"},{line,427}]},
              {wpc_svg_path,try_import_svg,9,
                            [{file,"src/wpc_svg_path.erl"},{line,386}]},
              {wpc_svg_path,make_svg,2,
                            [{file,"src/wpc_svg_path.erl"},{line,309}]},
              {wpa,do_import,3,[{file,"wpa.erl"},{line,142}]},
              {wpa,'-import/3-fun-0-',3,[{file,"wpa.erl"},{line,131}]},
              {wings_file,'-import_filename_1/2-fun-0-',3,
                          [{file,"wings_file.erl"},{line,67}]},
              {wings_develop,time_command,2,
                             [{file,"wings_develop.erl"},{line,87}]},
              {wings_plugin,command,3,[{file,"wings_plugin.erl"},{line,147}]},
              {wings,raw_command_1,3,[{file,"wings.erl"},{line,644}]},
              {wings,raw_command,4,[{file,"wings.erl"},{line,641}]},
              {wings_wm,handle_event,3,[{file,"wings_wm.erl"},{line,1030}]},
              {wings_wm,send_event,2,[{file,"wings_wm.erl"},{line,996}]}]

Also if it is useful, this is what i'm using to try to debug between the modules, I run it from erl command line and the vs and fs is drawn to a imagemagick vector file to make a png:
setup_fix_wpc_svg.zip


RE: SVG plugin additions [WIP] - edb - 05-08-2023

Hello micheus and tkbd,

I've found a fix for the <circle> in the svg plugin. There was still a point at the end of the generated path that was similar to the first point before the path closing command. It could be that key_exists might have been caused by that.

Here is the test file with the fix:
[Image: AAje4MpN_o.png]

Here is the newest .beam/.erl
wpc_svg_path.tar

I might try to make a change to the kind of path that is generated for <circle> and another bug I have noticed, before making a pull request.


RE: SVG plugin additions [WIP] - micheus - 05-08-2023

Nice.

Quote:There was still a point at the end of the generated path that was similar to the first point before the path closing command. It could be that key_exists might have been caused by that.
Yeah. Probably it was the cause.
I think I already face that before in a similar situation which I was trying to insert a coordinate twice in a gb_trees (I was using coordinate as index). In that case it was easy because the problem was happening in my code (not in Wings3D's module) and I just checked it before to insert. Smile


RE: SVG plugin additions [WIP] - tkbd - 05-09-2023

Thank you very much
It works fine


RE: SVG plugin additions [WIP] - edb - 05-09-2023

Thank you tkbd for confirming the fix works.

Latest .beam made for the pull request has some small changes (made <circle> more round, and a path tokenizer fix):
wpc_svg_path.tar


RE: SVG plugin additions [WIP] - edb - 05-12-2023

A new build with better handling of the transform attribute:
wpc_svg_path.tar


RE: SVG plugin additions [WIP] - edb - 05-28-2023

I've made a fix for SVG files that use X11 color names such as fill="blue". I thought it worked before but a change might have happened at some point so I fixed it.

Newest build:
wpc_svg_path.tar


RE: SVG plugin additions - edb - 10-19-2023

Just as an update, <style> css support is on my TODO for the SVG importer.