2019-12-31 14:36:56 +08:00
|
|
|
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
2018-10-08 04:52:23 +08:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2016-11-30 06:18:03 +08:00
|
|
|
|
2016-02-17 05:24:01 +08:00
|
|
|
from spack import *
|
2016-11-30 06:18:03 +08:00
|
|
|
import glob
|
2016-02-17 05:24:01 +08:00
|
|
|
|
2016-06-01 09:25:37 +08:00
|
|
|
|
2016-02-17 05:24:01 +08:00
|
|
|
class Tetgen(Package):
|
2016-06-01 09:25:37 +08:00
|
|
|
"""TetGen is a program and library that can be used to generate
|
|
|
|
tetrahedral meshes for given 3D polyhedral domains. TetGen
|
|
|
|
generates exact constrained Delaunay tetrahedralizations,
|
|
|
|
boundary conforming Delaunay meshes, and Voronoi paritions.
|
|
|
|
"""
|
2016-02-17 05:24:01 +08:00
|
|
|
|
2017-04-04 06:34:16 +08:00
|
|
|
homepage = "http://wias-berlin.de/software/tetgen/"
|
2016-02-17 05:24:01 +08:00
|
|
|
|
2019-10-11 13:44:41 +08:00
|
|
|
version('1.5.0', sha256='4d114861d5ef2063afd06ef38885ec46822e90e7b4ea38c864f76493451f9cf3', url='http://www.tetgen.org/1.5/src/tetgen1.5.0.tar.gz')
|
|
|
|
version('1.4.3', sha256='952711bb06b7f64fd855eb24c33f08e3faf40bdd54764de10bbe5ed5b0dce034', url='http://www.tetgen.org/files/tetgen1.4.3.tar.gz')
|
2016-11-30 06:18:03 +08:00
|
|
|
|
|
|
|
variant('debug', default=False, description='Builds the library in debug mode.')
|
|
|
|
variant('except', default=False, description='Replaces asserts with exceptions for better C++ compatibility.')
|
|
|
|
|
|
|
|
patch('tetgen-1.5.0-free.patch', when='@1.5.0')
|
|
|
|
|
|
|
|
def patch(self):
|
|
|
|
cflags = '-g -O0' if '+debug' in self.spec else '-g0 -O3'
|
|
|
|
|
|
|
|
mff = FileFilter('makefile')
|
|
|
|
mff.filter(r'^(C(XX)?FLAGS\s*=)(.*)$', r'\1 {0}'.format(cflags))
|
|
|
|
|
|
|
|
if '+except' in self.spec:
|
|
|
|
hff = FileFilter('tetgen.h')
|
|
|
|
hff.filter(r'(\b)(throw)(\b)(.*);', r'\1assert_throw(false);')
|
|
|
|
hff.filter(r'^(#define\s*tetgenH\s*)$', r'\1{0}'.format("""\n
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
inline void assert_throw(bool assertion)
|
|
|
|
{
|
|
|
|
if(!assertion)
|
|
|
|
throw std::runtime_error("Tetgen encountered a problem (assert failed)!");
|
|
|
|
}\n"""))
|
2016-02-17 05:24:01 +08:00
|
|
|
|
2016-11-30 06:18:03 +08:00
|
|
|
sff = FileFilter(*(glob.glob('*.cxx')))
|
|
|
|
sff.filter(r'(\b)(assert)(\b)', r'\1assert_throw\3')
|
2016-02-17 05:24:01 +08:00
|
|
|
|
|
|
|
def install(self, spec, prefix):
|
|
|
|
make('tetgen', 'tetlib')
|
|
|
|
|
|
|
|
mkdirp(prefix.bin)
|
|
|
|
install('tetgen', prefix.bin)
|
|
|
|
|
|
|
|
mkdirp(prefix.include)
|
|
|
|
install('tetgen.h', prefix.include)
|
|
|
|
|
|
|
|
mkdirp(prefix.lib)
|
|
|
|
install('libtet.a', prefix.lib)
|