Porting Marco Attene's meshfix to mac os x

Alec Jacobson

November 14, 2012

weblog/

Short notes on porting meshfix to mac. Follow readme.txt placing downloaded OpenNL and JMeshLib directories in the mesh fix directory [same as meshfix.cpp] When compiling JMeshLib be sure in makeconf file to change the lines:

# On 64-bit machines you need to uncomment the following line
# -DIS64BITPLATFORM

MOREFLAGS = $(OPTM) $(STRICTALIAS)

to:

MOREFLAGS = $(OPTM) $(STRICTALIAS) -DIS64BITPLATFORM

When compiling JMeshExt I separated the predicates.cxx file from tetgen's source to make jrs_predicates.h and jrs_predicates.c. Placing them according to readme.txt. One note is that if jrs_predicates.c is to be a .c file rather than a .cpp file then you need to extern "C"{...} encapsulate the jrs_predicates.h header file or you will get Undefined symbol linker errors. Finally in JMeshExt and meshfix.cpp there are several casts of pointers to ints. This won't compile on 64-bit machines. This similar operation was fixed in JMeshLib by the -DIS64BITPLATFORM. Thus, I've fixed the following files to use the j_voidint typedef defined by IS64BITPLATFORM in j_mesh.h:

JMeshExt-1.0alpha_src/src/holeFilling.cpp
meshfix.cpp

I've zipped up my changes and organization: download package. Then you can just issue:

cd OpenNL3.2.1/
# # You might need to do:
# export CC=`which cc`
# export CXX=`which c++`
./configure.sh
make -C build/Darwin-Release/
cd ../JMeshLib-1.2/
make
cd ../JMeshExt-1.0alpha_src/
make
cd ..
make

I imagine a very similar port could be used for Linux.

Update: I started occasionally getting runtime errors:

OpenNL should not have reached this point: file:/Users/ajx/Downloads/MeshFix/OpenNL3.2.1/src/NL/nl_superlu.c, line:223
Abort trap: 6

Seems this comes from compiling OpenNL without SuperLU support. SuperLU is fairly straightforward to install and so is following the OpenNL instructions for compiling with OpenNL support.