Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree structure in Backends #19

Closed
fryguybob opened this issue Aug 4, 2012 · 8 comments
Closed

Tree structure in Backends #19

fryguybob opened this issue Aug 4, 2012 · 8 comments

Comments

@fryguybob
Copy link
Member

(Imported from http://code.google.com/p/diagrams/issues/detail?id=73. Original issue from tillk.v...@gmail.com on March 11, 2012, 05:14:51 PM UTC)

Hi,
All of the Backends that I have seen so far flatten the UD-tree to produce output. Using a program like Inkscape to further edit an SVG image, it would be better to preserve this structure.

I also need to have such a structure to make a 3d-Backend. At first I aimed at WebGL using SceneJS, for which I need a SceneGraph (a tree structure). It seems easier to first make a Backend with lambdacubeengine (I roughly understand how the scenegraph works there) and then involve the other people here on the mailing list for the right structures for 3d.

The announcement for diagrams-0.5 mentions a new SVG-Backend. Is it preserving the structure? If yes, I would like to see the code.
Documentation about UD-trees would also help a lot.

@fryguybob
Copy link
Member Author

(Imported. Original comment by byor...@gmail.com on March 11, 2012, 07:07:12 PM UTC)

In fact I have been working on this very thing for the past day or so! I will send a message to the mailing list with some issues for discussion and feedback soon.

@byorgey
Copy link
Member

byorgey commented Aug 17, 2013

@jeffreyrosenbluth
Copy link
Member

Next Steps to enhancing performance by passing a tree to the backends:

  1. Test Compile.hs code in branch backend-tree by writing a version of prims for DTree.

https://github.com/diagrams/diagrams-core/blob/backend-tree/src/Diagrams/Core/Compile.hs

  1. Reimplement SVG backend to take a DTree instead of a list of Prims
  2. Implement optimization passes for Dtrees.

@jeffreyrosenbluth
Copy link
Member

Status Report:
byorgey has implemented a version of dual-tree that allows access to internal d nodes in foldDUAL.

https://github.com/diagrams/dual-tree/blob/internal-d/src/Data/Tree/DUAL/Internal.hs

This is used in the toTree function in the module Compile.hs to translate a QDiagram to a simpler tree DTree that dispenses with the u annotations. I have written another function fromDTree which creates an RTree from the DTree. The difference being that an RTree separates out the frozen and unfrozen transformations so that the frozen transformations get their own nodes and the unfrozen transformations accumulate until frozen or reach a primitive. An RTree should be easy to handle in the backends.

https://github.com/diagrams/diagrams-core/blob/backend-tree/src/Diagrams/Core/Compile.hs#L64

I have implemented this for the SVG backend except for handling clipping.

https://github.com/diagrams/diagrams-svg/blob/optimize/src/Diagrams/Backend/SVG.hs#L165

@byorgey
Copy link
Member

byorgey commented Nov 7, 2013

This is now all implemented and merged. Both the SVG backend and the cairo backend make use of the new exposed tree structure.

@byorgey byorgey closed this as completed Nov 7, 2013
@jeffreyrosenbluth
Copy link
Member

Nice !!!

@byorgey
Copy link
Member

byorgey commented Nov 8, 2013

Thanks for your work on this. I'm really happy with where we ended up. From here I think there are a lot more incremental improvements we can make, both in optimizing the output of toRTree and in the SVG backend in particular.

@jeffreyrosenbluth
Copy link
Member

Your welcome,
I'm really happy with the end result as well.
I look forward to discussing further improvements.

On Thu, Nov 7, 2013 at 10:45 PM, Brent Yorgey notifications@github.comwrote:

Thanks for your work on this. I'm really happy with where we ended up.
From here I think there are a lot more incremental improvements we can
make, both in optimizing the output of toRTree and in the SVG backend in
particular.


Reply to this email directly or view it on GitHubhttps://github.com//issues/19#issuecomment-28032472
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants