Compiling and running qslim on Mac OS x
Alec Jacobson
May 23, 2013
I recently successfully compiled and executed qslim on mac os x. It took a little tweaking but here's how I did it.
fltk
Before anything else, be sure to install fltk. I did this using macports:
sudo port install fltk
libgfx
Then, following the instructions in qslim-2.1/README.txt, I first compiled libgfx:
cd libgfx
./configure
The libpng support seems out of date and I don't really need it so in raster-png.cxx I replaced:
//#ifdef HAVE_LIBPNG
#if false
memcopy
was shoing up undefined so I added the following include to raster.cxx:
#include <cstring>
Similarly there was a missing include in time.cxx:
#elif defined(HAVE_TIMES)
#include <sys/times.h>
Know, while inside libgfx I issue:
make -C src
mixkit
First travel inside mixkit and configure:
cd ../mixkit
./configure
Trying to make I got a bunch of errors of the form:
MxDynBlock.h:44:33: Error: 'resize' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
MxDynBlock.h:44:33: Error: note: declarations in dependent base 'MxBlock<MxStdModel*>' are not found by unqualified lookup
MxDynBlock.h:44:33: Error: note: use 'this->resize' instead
There're at least two ways to fix this. You can add this->
everywhere gcc is tell you to: edit MxStack.h and MxDynBlock.h or you can add -fpermissive to the CXXFLAGS. This is awkwardly done not in mix-config but in ../libgfx/gfx-config. Where you can edit into something like:
CXXFLAGS = -g -O2 -I/Users/ajx/Downloads/qslim-2.1/libgfx/include -DHAVE_CONFIG_H $(WIN_FLAGS) -fpermissive
Alternatively you could have done this when configuring libgfx with:
cd ../libgfx
./configure CXXFLAGS='-fpermissive'
cd ../mixkit/
If you do it this way then you'll get warnings instead of errors.
Now you can build with:
make -C src
qslim and qvis
Travel to the qslim tools directory:
cd ../tools/qslim
Here I need to add libfltk_gl to the linker commands in Makefile:
$(CXX) -o qslim $(OBJS) $(LDFLAGS) $(LIBMIX) -lm -lfltk_gl
...
$(CXX) -o qvis $(QVIS_OBJS) $(LDFLAGS) $(LIBMIX) $(GUI_LIBS) -lm -lfltk_gl
Then build with:
make
(those fpermissive warnings may show up again, but no problem)
Finally I can run the command line program qslim or the gui qvis. For some reason the qui qvis.app immediately closes if I double click on it. But I can run it by issuing:
./qvis.app/Contents/MacOS/qvis
where I'm then prompted to load a .smf file.
or
./qvis.app/Contents/MacOS/qvis input.smf
You can call the command line program with:
./qslim -t 1000 -M smf -q 2>/dev/null
which spills the .smf file to stdout
It seems .smf format is the same as .obj, at least if there are only vertices and triangular faces. So, you can compose---a rather long---bash oneliner that simplifies an input.obj file to an output.obj file:
grep "^[vf] " input.obj | sed -e "s/^f *\([0-9][0-9]*\)\/[^ ]* *\([0-9][0-9]*\)\/[^ ]* *\([0-9][0-9]*\)\/.*/f \1 \2 \3/g" | ./qslim -t 1000 -M smf -q 2>/dev/null | grep "^[vf]" > output.obj
qslim/filters
I also built the "filters" (converters?) with:
cd ../filters
make
Note that ply2smf only acts on stdin and stdout so call it with:
cat input.ply | ./ply2smf >output.smf
Update: I found an easier way to setup the configure script and ensure that all macports libraries are found:
env CPPFLAGS="-I/opt/local/include -fpermissive" LDFLAGS="-L/opt/local/lib" ./configure