3D data structure visualization

I have a 3D data structure in C code that I want to visualize as boxes and dots in 3D space. So I have a bunch of coordinates, some for points and some for boxes, and I want to build them in 3D to visualize the data structure. Does anyone have something like this? I started using paraview. My plan is to create a paraview state file (an xml file type) and then just open it with paraview. The problem is that state files are massive and complex. To try to figure out the structure of the xml, I created Boxes and Point objects in Paraview, and then looked at the state files it created. It looks awful.

I just want to say that you can display a window with these coordinates and a point with these coordinates in a minimalistic way. Does anyone have any ideas? Itโ€™s not necessary to be in C or paraview, as I can display the coordinates and enter everything that is needed to create the final product. Python + Matlab will work just as well if it works.

+4
source share
3 answers

So, I realized a good compromise. I started with git code as described here:

http://www.shocksolution.com/microfluidics-and-biotechnology/visualization/python-vtk-paraview/

This is just one python file. The bottom line is code that allows you to specify the x, y, z positions and radius for points and output an XML file that is in VTK format. Therefore, to make particles, I just pass them the positions x, y, z, and then the radius constant for all particles. Then I just do a spherical glyph on the datasets.

For boxes I use the same code. For each box, x, y, z coordinates are still displayed, where x, y, z are the coordinates of the center of the field. Then, for the radius parameter, I use the length of the cube edge. This works because again in paraview I just glyph the dates for the boxes. I use a window glyph and scale the scalar where the scalar is the radius. If you do not orient the glyphs and set the scalar coefficient equal to 1, you will get the desired result. Here is a simple example with everything uniform:

Simple uniform tree

So, I just output the coordinates in my C-datastructure to CSV files, and then in python I inserted the files and used the code by reference and opened the result using paraview. This is how I used the code from the link:

from vtktools import VTK_XML_Serial_Unstructured import sys if len(sys.argv) > 2: treeFile = sys.argv[1] bodyFile = sys.argv[2] else: print 'No input files' exit(4) x = [] y = [] z = [] r = [] f = open(treeFile, 'r') for line in f: v = line.split(',') x.append(float(v[0].strip())) y.append(float(v[1].strip())) z.append(float(v[2].strip())) r.append(float(v[3].strip())) f.close() temp = treeFile.split('/') if (len(temp) == 1): temp = temp[0] else: temp = temp[-1] tree_writer = VTK_XML_Serial_Unstructured() tree_writer.snapshot(temp.split('.',1)[0] + '.vtu', x, y, z, [], [], [], [], [], [], r) tree_writer.writePVD("octree.pvd") x = [] y = [] z = [] r = [] f = open(bodyFile, 'r') for line in f: v = line.split(',') x.append(float(v[0].strip())) y.append(float(v[1].strip())) z.append(float(v[2].strip())) r.append(float(v[3].strip())) f.close() temp = bodyFile.split('/') if (len(temp) == 1): temp = temp[0] else: temp = temp[-1] body_writer = VTK_XML_Serial_Unstructured() body_writer.snapshot(temp.split('.',1)[0] + '.vtu', x, y, z, [], [], [], [], [], [], r) body_writer.writePVD("distribution.pvd") 
+3
source

Since your data doesn't seem complicated ... Why don't you export it to a CSV file?

You can open it from ParaView , MATLAB , etc. Moreover, it is a really simple implementation.

I would choose this if your data is not more complex than that.

Happy coding!

+2
source

If your algorithm is pure C and it creates static or canned animated data, you may like to export to XML format or your own format, which will open up many options.

Collada is an XML format designed to represent 3D objects in a programmatic agnostic style and certainly deserves attention. Then you can open the application in many applications for viewing, even Max and Maya, which means that encoding is not required to view it. Engines are also available that will read these exported materials initially.

As for other specific visualization methods, this may be a completely open answer, so depending on how many elements you are trying to visualize and how much interaction you need here, these are a few suggestions, but I know that this is just an iceberg tip.

Matlab seems very good at building mathematical graphics, but my rather dated memory of it was very slow and cumbersome to manipulate.

If this is a simple gouraud shaded textured material, and you want full control just go to your native OpenGL program, because these days it's okay there. It also means that you will get the C code. The downside is that it takes longer, especially if you need to handle camera controls or โ€œpixel qualityโ€. That is, if you are looking for shadows, animations, shader effects, etc., please read ...

If this requires some user interaction, a stand-alone application, more complex rendering, and the data set is not extensive or you can compile it as C # (i.e. do not use pointers), you can take a look at Unity. This makes 3D rendering easy for you by an order of magnitude, and you just need to write C # to create the mesh / particles you want to display and cut out some simple camera controls (or import your collada file). A difficult bit, if you are new to this, it will take a day or two to become familiar with creating your own grids for your purpose.

Alternatively, you can encode it in WebGL via HTML5, or better yet, use another WebGL system to do this for you!

There are a few points worth a look if you choose this route. My favorite is PlayCanvas, and I believe that it will also take your collada files if you just need to create them.

There is also SceneJS.org, which is more raw and has not personally checked, but showing that this should also be liked.

0
source

Source: https://habr.com/ru/post/1434936/


All Articles