[Gmsh] gmsh export to png/gif?

Christophe Geuzaine cgeuzaine at ulg.ac.be
Wed Oct 14 21:11:24 CEST 2009


Bryan Bishop wrote:
> Hey Christophe,
> 
> I was browsing some OpenCASCADE code today and found that
> src/OpenGl/gl2ps.cxx was written by you. To be honest, when I was
> reading that file this morning, I didn't realize who you were; then,
> later, I was playing around with gmsh as a way to open up STL files
> and export to PNG, and I looked around at the source and realized that
> you are one and the same person. So, anyway, nice to see you.. I've
> been using gmsh for at least a year now, and it has proven useful in a
> variety of situations (CFD, CAD, etc.).
> 
> That said, I was wondering if you could give me a few protips.
> Yesterday I wrote some tools in python called iges2png, iges2stl,
> stl2pov, and pov2png, using pythonOCC, the python bindings to the
> OpenCASCADE library. The problem is that iges2stl is terribly slow, so
> generating an image of an IGES file takes absolutely forever.
> 
> I was wondering if you could point me to where in gmsh's code base I
> could find the means to do this with a simple C++ program I could
> write. I was wondering how I can go about loading up an IGES file with
> the gmsh codebase, and then export an image. Ideally without
> converting to STL in the mean time .. that would be absolutely
> awesome, and save 30 to 60 seconds on all of the images I generate in
> the future. (Right now OpenCASCADE takes 30 to 60 seconds to convert
> from IGES to STL.)
> 
> Is this doable?
> 

Hi Bryan - sure, and you don't need to write a C++ program: assuming 
that you have a file called "test.iges" in your current directory, just 
save the follwing little script in a text file and load it with Gmsh


// display stl mesh of CAD surfaces
Geometry.Surfaces = 1;
Geometry.SurfaceType = 2;

// display curves as 3D cylinders
Geometry.LineType = 2;

// specify model rotation using Euler angles
General.Trackball = 0;
General.RotationX = 45;
General.RotationY = 30;
General.RotationZ = -20;

// merge CAD file
Merge "test.iges";

// print image
Print "test.png";


Christophe

-- 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine