Save a Mesh file under VTK - c++

I'm trying to generate a mesh from a 3d volume.
I processed on VTK, using Marching Cube (vtkMarchingCubes.h); but I still can't found how to save the result view, as vtk file!
any idea
I appreciate your help.

You can use vtkPolyDataWriter or vtkXMLPolyDataWriter to write the mesh data to files.
If you want the write the rendered output in a window you can use vtkWindowToImageFilter as a starting point
You can find some examples here
Mayavi is a very nice tool to visualize the files.

Related

Is there a way to save CGAL::Linear_cell_complex_for_combinatorial_map as .off or .obj format?

I have just implemented an algorithm that takes a surface mesh, tetrahedralizes it and saves the tetrahedralization data inside the CGAL data structure CGAL::Linear_cell_complex_for_combinatorial_map.
I'm new to using CGAL library and I would like to know if there is a way to write CGAL::Linear_cell_complex_for_combinatorial_map data structure in .obj, .off or some other formats.
There is an undocumented function write_off(lcc) (cf here).
In the off, when a face is shared by two volumes, the face is saved twice. Moreover, the output mesh is not a surface, and some tools (like meshlab) does not like such a mesh.
It is easy to modify the code of write_off to save only the surface of your volumic mesh. Contact me if you need such function.

Write texture mapped obj file to disk with VTK

I am using VTK to read an obj file, texture map the 3D model and transform it to another view (by applying rotateY/X/Z transforms to vtkActors) and writing it to file using vtkwindowtoImageFilter. Due to this pipeline, the rendered image is displayed on the screen before being written to file. Is there a way to do the same pipeline without the image being displayed on screen ?
If you are using VTK 5.10 or earlier, you can reander the geometry off screen.
I am not quite sure if this is what you are looking for. I am new to vtk and I found the above link looking for a way to convert a triangular surface to volume data, ie, to voxelize the surface. All profile I found on the internet is about using vtkwindowtoImageFilter to obtain a 2D section of the screen, have you worked out a way to access 3D data of the rendered window? Please tell me about that.

Rendering Wavefront OBJ and associated material MTL using OpenGL

I have these files: sample.obj, sample.mtl and a folder sample containing image jpg. Can somebody give me an example code of opengl texture mapping using above input.
Your problem is not just texture mapping. What you are asking for is loading an Wavefront OBJ model and its material library, then passing this data to OpenGL rendering commands. Depending on how many preexisting code you want (not) to use this takes different amounts of code. However there's no such thing like a simple OpenGL function that does it all in a black box.
Although this is a FAQ and Google brings you some results I didn't find a tutorial that really explains what's going on.
If you want it to be really simple, use a Wavefront loader and render library:
http://www.evl.uic.edu/pape/sw/libwave.html

Importing 3D objects and its animation to iphone openGL

I am trying to develop a 3D game in openGL and i need to create many 3D objects.. I am a begginner in openGL.. I have tried with many 3D softwares like Blender , MODO, Unity 3D and Cheetah.
I am easily able to create my objects with these and exporting as Wavefront .OBJ, and converting it to a header file using a perl script. This header file is added to my openGL project..
The 3D objects are seen, but its not perfect. The script i used is to convert the .OBJ to .h using TRIANGLES.. And the object is seen with triangles. Its not full.. No way when i used TRIANGLE STRIP,FAN..? Problems with the vertices..
Is the problem with my Script or is it the wrong way i have gone..?? Or is there any other best ways to directly import 3D objects to openGL..??
The below link is the best one which you can get for 3D objects to openGL.. i got the scripts from these..
http://www.heikobehrens.net/2009/08/27/obj2opengl/
please help..
You don't want to go that way. Direct drawing mode (using TRIANGLE and friends) is extremely slow in OpenGL.
Instead, you should pick a decent format and write a loader for it (or use one found on the web). Good formats would be 3ds, obj if gzipped, collada.
Here's an example tutorial on loading from Milkshape files.
Once you load your objects programatically, you can use Vertex Arrays, or even better VBO's to display them. This is waaay faster.
Google for a mesh loader for your favorite format, or write one yourself.
I have written a reader/renderer for AC3D files that works fine on the iPhone (OpenGL ES)
Feel free to have a look at it here.
There is also an obj loader by Jeff Lamarche at google code.
AC3D can reduce the triangle count pretty good and as an alternative I ported QVis to the mac. My reader/renderer also tries to build tri-strips.
About VBO's. I have not seen any gained performance when using them in the iPhone. I'm not the only one.

how could I load a bitmap file in a video feed?

I am using artoolkit to create an augmented reality based project.I can load vrml 3d objects in the video feed using openvrml.
Now I wanted to load a bitmap or any other image file like jpg,png etc file on the marker in the video feed.How do I go about achieving this?
The usual approach is using an overlay.
Just make a VRML 'model' consisting of a single quad with a texture corresponding to your image file. Your existing VRML machinery should take care of the rest.