OpenGeoVis / PVGeo

🌍 Python package of VTK-based algorithms to analyze geoscientific data and models
https://pvgeo.org
BSD 3-Clause "New" or "Revised" License
213 stars 42 forks source link

UBC Octree Mesh Reader #3

Closed banesullivan closed 6 years ago

banesullivan commented 6 years ago

From @craigmillernz:

If you can implement a UBC octree mesh reader that would be great! There are quite a few tools that can read the Tensor mesh, but only UBC meshtools can read octree.

Reader Details Here

@craigmillernz, would you be willing to provide an example file with some screenshots (from UBC Meshtools) for me to work with?

craigmillernz commented 6 years ago

Just checking you received the example files I emailed?

grosenkj commented 6 years ago

@banesullivan I am more than happy to help with this feature. I contributed to writing IO functions for discritize that read and write UBCTreeMesh and write out vtu files of the model. I have wanted to implement a plugin for Paraview to do this directly so this would be a great learning opportunity for me. What branch are you doing this work?

banesullivan commented 6 years ago

@grosenkj, your help would be greatly appreciated! I was looking through discretize to try to figure this out... I have made the skeletons of how this reader will be implemented in the PVGP repo and it just needs some filling in to make a vtkUnstructuredGrid of the data read to pass on. Note that if you open an OcTree mesh file in ParaView (File->Open... with extensions .msh, .mesh, or .dat) and use the PVGP: UBC OcTree Mesh File Format reader, it will simply print out a statement that the reader is not implemented followed by the indexing arrays.

I just pushed these changes to the develop branch and you can find the skeletons for the backend of the OcTree reader in the PVGPpy module under: PVGPpy/read/ubc.py. Specifically in the function

def ubcOcTreeMesh(FileName, pdo=None):

I have mostly implemented the reading of the OcTree format there but this method still needs to generate the vtkUnstructuredGrid declared in the pdo object.

Could you construct the vtkUnstructuredGrid object in the ubcOcTreeMesh() method? Once that is implemented, the reader should work... my only concern/question is: does the OcTree format have an associated model file like the 2D/3D mesh formats? If so, I will have to add a few things to allow the user to select that model file and pass it on so it can be added to the vtkUnstructuredGrid.

I am working to make a complete guide on how to navigate the code repository to understand how everything works and how to develop in the repo. Let me know if you have any trouble and feel free to email me: chrsulli@mines.edu

grosenkj commented 6 years ago

@banesullivan Thanks for this, I will look at develop this weekend and implement the construction of vtkUnstructuredGrid to within the function.

As for your questions/concerns, the UBC OcTree format has an associated model file, just like the tensor mesh. Will keep this in mind and maybe implement some of that functionality, similar to the UBC Tensor mesh.

grosenkj commented 6 years ago

@banesullivan Just made a pull request from the fork I made. I finished the ubcOcTreeMesh function to the point of returning the vtkUnstructuredGrid. I also implemented placeModelOnOcTreeMesh function similar to the tensor grid. I did some minimal sanity testing on the function and it seems to work as expected.

banesullivan commented 6 years ago

I have finished the remainder of implementing the UBC OcTree reader with minor refactoring! Themaster branch is caught up and a release has been tagged so @craigmillernz, you can get started using the OcTree reader!

To use the plugin:

I could only find one mesh-model pair online to test against in this example on the GIFtoolsCookbook website. Everything appears to be working to the best of my understanding, but please test it out if you get a chance. Since I am unsure about using the model files, I made it an optional parameter for the plugin.

Check out this page on the Docs for a visualization of that example and check back for further details on this plugin's implementation.

craigmillernz commented 6 years ago

Thanks @banesullivan , i've updated and am able to read in the model. I also tried with a 3 column model (x,y,z vector) and it seems to load. In paraview how do you recommend is the best way to display the volume data? i.e. which representation to use?

banesullivan commented 6 years ago

This can depend on your graphics card and other computer specs. Overall for fluid and responsive rendering, I would recommend displaying as Wireframe, Surface, Surface with Edges, or Points and coloring by the attribute of interest. Try adding a clip filter to slice through the volume while changing the center of rotation in the render view.

For the model you sent me over email, I applied a Cell Data to Point Data filter, a Contour filter, clipped the result, and zoomed to that final pipeline object to get something like this.

From the GIFtoolsCookbook example I posted above there was an active_cells_topo model file containing 1s and 0s to extract the subsurface parts of the model. If you have something like this, you could add that as an attribute to your mesh then use a Threshold filter to remove unnecessary parts (the 0s) of the volume. Also, you could add a clip on the Z axis to hide parts of the model that are very deep. Then if you wanted to contour the model by some attribute you could use a Cell Data to Point Data filter and then a Contour filter and display as a Surface to get something like this.

Using Volume for the representation can be dangerous… I have a high-end NVIDIA graphics card in my MacBook Pro and the Volume Representation seems to work fairly fluidly/responsively in ParaView but it is not very useful to see all aspects of the model from what I can tell.

If we could get some sample data for a few models to put on a mesh, then we could implement an example on the Docs pages to narrow down some solid ways to visualize the OcTree data. I'm also thinking it might make sense to implement a macro to handle these series of operations for representing the OcTree data in the Render View.

craigmillernz commented 6 years ago

Thanks for that. I was trying to use volume, which is not ideal (i'm not a paraview expert yet!). I have trouble viewing the links to examples. Can you double check? They don't load for me.

banesullivan commented 6 years ago

That's strange; the links work for me in Safari, Chrome, and iOS/iPhone Safari.

Those links work by locally (in your browser) running javascript on a file publicly hosted in my Dropbox account. Would you mind sharing what you do see when you click those links? Is it just a gray window in the browser? If so, I wonder if these aren't working because you are not in the U.S. and the Dropbox server might be slow to respond (just a guess)?

Do any of the examples on the Demo Page work?

craigmillernz commented 6 years ago

When I go to "explore" the demos i get a URL like this http://gpvis.org/?fileURL=https://dl.dropbox.com/s/qybpnsn11lghnq9/OcTree.vtkjs?dl=0 which returns nothing. A blank page

The demo model on this page http://pvgp.io/ works ok, but not the ones on this page https://demo.pvgp.io/

banesullivan commented 6 years ago

@craigmillernz this is very strange and quite concerning for me as I thought these web renderings were stable and visible to everyone. I just spent some time using some online tools to ping all of these domains to make sure they are accessible in most of the world and everything checks out.

If the page is just blank/white with no message it is likely due to Javascript being disabled. You may just need to enable Javascript for http://gpvis.org). If this does not resolve you problems, lets continue debugging in the new issue #6

craigmillernz commented 6 years ago

Tried it on a different pc and works fine. Probably a local issue, i'll investigate. Those are cool renderings!