ladybug-tools / bsdf-viewer

🎇 A web-based viewer for BSDF files
https://www.ladybug.tools/bsdf-viewer/
GNU General Public License v3.0
2 stars 3 forks source link

feat(tensor-tree): add incident patch drawing for TT #7

Closed mostaphaRoudsari closed 5 years ago

mostaphaRoudsari commented 5 years ago

This commit adds a new html file that shows how we can use d3.geoProjection to visualize tensor-tree patches. The implementation addresses both issues that are discussed here: (https://github.com/ladybug-tools/bsdf-viewer/issues/5).

The trick was to implement each patch as a d3-geo-shape which is mostly used for drawing maps! Because each patch is now a goJSON polygon it translates to a D3 native object. I attach an id to each patch to show how it is possible. Then once the patches are generated we can use d3.projection to visualize them. This makes interactions much easier as we can bind the data for each patch to the geometry.

With this approach we also keep the original orthogonal coordinates for each patch and use that for Boolean functions like merging them together. Running union calculation on the original grid of squares is quite fast. For testing I implemented it to the current interface and it works almost real time. Try to click on patches and the algorithm will join the ones that are next to each other together and draws a curve around them.

merge patches

This will be helpful for joining outgoing patches based on values. Basically we can group all the patches with similar values regardless of being neighbors or not and then use polygon-clipping library to join them together. Since the patches is implemented in geoJSON format we can take advantage of all the different libraries to interact with geoJSON files including polygon-clipping! :)

Next step is to figure out how to map data from BSDF file to these patches. Though the parser works I still have no idea how to match the values to these patches. @andyrew is it something that you can help me with or should I ask Greg?

I tried to figure it out based on your code but I get lost when you use Radiance to get the values. It is hard to imagine what is the result structure that is generated from Radiance. I wish I could have get TensorTree code working on my machine! That would have made everything easier. :/

resolves #5

andyrew commented 5 years ago

Mostapha, we basically need to query the BSDF with pairs of incident and outgoing vectors. The incident vector is selected by the user and the outgoing vectors are the center of each tensor tree patch. We'd need to determine the maximum resolution (tensor rank) we'll show in the viewer. In my previous version I used rank 6 as the maximum (4096 total patches).

I'll try to look into this sometime this week.

mostaphaRoudsari commented 5 years ago

Hi @andyrew, Thank you for the note. Not that I really understand what you said here about the outgoing vectors but "sounds good to me!"

Adjusting the resolution should be very straight forward. As far as I understand we can identify this based on the number of {s at the start of the data in BSDF file. And we will have full control on the output. After checking a number of files I feel we might not even need the joining process if we map the values correctly to patches. We should rewrite the method that returns the grid to return it based on tree branch and the resolution of each branch.

Two notes about merging the PRS (or basically how we do it):

  1. Once the reviewer reviews the PR and confirms the PR the one who has sent the PR is responsible for merging it in.

  2. In most cases we use rebase and merge instead of the normal merge so git doesn't create an extra commit for the merge itself. In some cases when there has been so many back and forth and the number of commits are too many we use squash and merge which puts all the commits in PR into a single commit. You can use git reset afterwards to reset your local fork and force push the changes. That will make your fork to be the same as the upstream master branch. I know I used so many git buzzwords here. Sorry and let me know if you have any questions.