summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-04-16 07:44:05 +0000
committerglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-04-16 07:44:05 +0000
commit4a88c2b8532ab2ebeeccb76b488abeecd4a4a658 (patch)
tree6c61c4bb9e0db78d6434639ce20db1eba35e8b3f /src
parent351059be74b4f613d798ca4364a0e37202c3f378 (diff)
Less CRLF line endings.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1135 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 83328005a983668b00961f069672e97493e42a34
Diffstat (limited to 'src')
-rw-r--r--src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h314
-rw-r--r--src/Contraction/example/Garland_heckbert/Error_quadric.h364
-rw-r--r--src/GudhUI/gui/MenuEdgeContraction.ui236
-rw-r--r--src/GudhUI/gui/gudhui.cpp76
-rw-r--r--src/GudhUI/view/Viewer.h240
-rw-r--r--src/GudhUI/view/Viewer_instructor.h234
-rw-r--r--src/cmake/modules/FindTBB.cmake866
7 files changed, 1165 insertions, 1165 deletions
diff --git a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h
index 83921427..550e90b9 100644
--- a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h
+++ b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h
@@ -1,157 +1,157 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA Sophia-Saclay (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef DOC_GUDHI_CUBICAL_COMPLEX_COMPLEX_H_
-#define DOC_GUDHI_CUBICAL_COMPLEX_COMPLEX_H_
-
-namespace Gudhi {
-
-namespace Cubical_complex {
-
-/** \defgroup cubical_complex Cubical complex
- *
- * \author Pawel Dlotko
- *
- * @{
- *
-
- * Bitmap_cubical_complex is an example of a structured complex useful in computational mathematics (specially rigorous
- * numerics) and image analysis. The presented implementation of cubical complexes is based on the following
- * definition.
- *
- * An <em>elementary interval</em> is an interval of a form \f$ [n,n+1] \f$, or \f$[n,n]\f$, for \f$ n \in \mathcal{Z}
- * \f$. The first one is called <em>non-degenerate</em>, while the second one is \a degenerate interval. A
- * <em>boundary of a elementary interval</em> is a chain \f$\partial [n,n+1] = [n+1,n+1]-[n,n] \f$ in case of
- * non-degenerated elementary interval and \f$\partial [n,n] = 0 \f$ in case of degenerate elementary interval. An
- * <em>elementary cube</em> \f$ C \f$ is a product of elementary intervals, \f$C=I_1 \times \ldots \times I_n\f$.
- * <em>Embedding dimension</em> of a cube is n, the number of elementary intervals (degenerate or not) in the product.
- * A <em>dimension of a cube</em> \f$C=I_1 \times ... \times I_n\f$ is the number of non degenerate elementary
- * intervals in the product. A <em>boundary of a cube</em> \f$C=I_1 \times \ldots \times I_n\f$ is a chain obtained
- * in the following way:
- * \f[\partial C = (\partial I_1 \times \ldots \times I_n) + (I_1 \times \partial I_2 \times \ldots \times I_n) +
- * \ldots + (I_1 \times I_2 \times \ldots \times \partial I_n).\f]
- * A <em>cubical complex</em> \f$\mathcal{K}\f$ is a collection of cubes closed under operation of taking boundary
- * (i.e. boundary of every cube from the collection is in the collection). A cube \f$C\f$ in cubical complex
- * \f$\mathcal{K}\f$ is <em>maximal</em> if it is not in a boundary of any other cube in \f$\mathcal{K}\f$. A \a
- * support of a cube \f$C\f$ is the set in \f$\mathbb{R}^n\f$ occupied by \f$C\f$ (\f$n\f$ is the embedding dimension
- * of \f$C\f$).
- *
- * Cubes may be equipped with a filtration values in which case we have filtered cubical complex. All the cubical
- * complexes considered in this implementation are filtered cubical complexes (although, the range of a filtration may
- * be a set of two elements).
- *
- * For further details and theory of cubical complexes, please consult \cite kaczynski2004computational as well as the
- * following paper \cite peikert2012topological .
- *
- * \section datastructure Data structure.
- *
- * The implementation of Cubical complex provides a representation of complexes that occupy a rectangular region in
- * \f$\mathbb{R}^n\f$. This extra assumption allows for a memory efficient way of storing cubical complexes in a form
- * of so called bitmaps. Let \f$R = [b_1,e_1] \times \ldots \times [b_n,e_n]\f$, for \f$b_1,...b_n,e_1,...,e_n \in
- * \mathbb{Z}\f$, \f$b_i \leq d_i\f$ be the considered rectangular region and let \f$\mathcal{K}\f$ be a filtered
- * cubical complex having the rectangle \f$R\f$ as its support. Note that the structure of the coordinate system gives
- * a way a lexicographical ordering of cells of \f$\mathcal{K}\f$. This ordering is a base of the presented
- * bitmap-based implementation. In this implementation, the whole cubical complex is stored as a vector of the values
- * of filtration. This, together with dimension of \f$\mathcal{K}\f$ and the sizes of \f$\mathcal{K}\f$ in all
- * directions, allows to determine, dimension, neighborhood, boundary and coboundary of every cube \f$C \in
- * \mathcal{K}\f$.
- *
- * \image html "Cubical_complex_representation.png" Cubical complex.
- *
- * Note that the cubical complex in the figure above is, in a natural way, a product of one dimensional cubical
- * complexes in \f$\mathbb{R}\f$. The number of all cubes in each direction is equal \f$2n+1\f$, where \f$n\f$ is the
- * number of maximal cubes in the considered direction. Let us consider a cube at the position \f$k\f$ in the bitmap.
- * Knowing the sizes of the bitmap, by a series of modulo operation, we can determine which elementary intervals are
- * present in the product that gives the cube \f$C\f$. In a similar way, we can compute boundary and the coboundary of
- * each cube. Further details can be found in the literature.
- *
- * \section inputformat Input Format.
- *
- * In the current implantation, filtration is given at the maximal cubes, and it is then extended by the lower star
- * filtration to all cubes. There are a number of constructors that can be used to construct cubical complex by users
- * who want to use the code directly. They can be found in the \a Bitmap_cubical_complex class.
- * Currently one input from a text file is used. It uses a format used already in Perseus software
- * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda.
- * Below we are providing a description of the format. The first line contains a number d begin the dimension of the
- * bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3
- * in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8
- * 20 4 7 6 5 in the example below).
- *
- *
- * \image html "exampleBitmap.png" "Example of a input data."
- *
- * The input file for the following complex is:
- * \verbatim
-2
-3
-3
-1
-4
-6
-8
-20
-4
-7
-6
-5
-\endverbatim
-
- * \section PeriodicBoundaryConditions Periodic boundary conditions
- * Often one would like to impose periodic boundary conditions to the cubical complex. Let \f$ I_1\times ... \times
- * I_n \f$ be a box that is decomposed with a cubical complex \f$ \mathcal{K} \f$. Imposing periodic boundary
- * conditions in the direction i, means that the left and the right side of a complex \f$ \mathcal{K} \f$ are
- * considered the same. In particular, if for a bitmap \f$ \mathcal{K} \f$ periodic boundary conditions are imposed
- * in all directions, then complex \f$ \mathcal{K} \f$ became n-dimensional torus. One can use various constructors
- * from the file Bitmap_cubical_complex_periodic_boundary_conditions_base.h to construct cubical complex with periodic
- * boundary conditions. One can also use Perseus style input files. To indicate periodic boundary conditions in a
- * given direction, then number of top dimensional cells in this direction have to be multiplied by -1. For instance:
-
- *\verbatim
-2
--3
-3
-1
-4
-6
-8
-20
-4
-7
-6
-5
-\endverbatim
-
- * Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y.
-
- * \section BitmapExamples Examples
- * End user programs are available in example/Bitmap_cubical_complex folder.
- *
- * \copyright GNU General Public License v3.
- */
-/** @} */ // end defgroup cubical_complex
-
-} // namespace Cubical_complex
-
-} // namespace Gudhi
-
-#endif // DOC_GUDHI_CUBICAL_COMPLEX_COMPLEX_H_
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Pawel Dlotko
+ *
+ * Copyright (C) 2015 INRIA Sophia-Saclay (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef DOC_GUDHI_CUBICAL_COMPLEX_COMPLEX_H_
+#define DOC_GUDHI_CUBICAL_COMPLEX_COMPLEX_H_
+
+namespace Gudhi {
+
+namespace Cubical_complex {
+
+/** \defgroup cubical_complex Cubical complex
+ *
+ * \author Pawel Dlotko
+ *
+ * @{
+ *
+
+ * Bitmap_cubical_complex is an example of a structured complex useful in computational mathematics (specially rigorous
+ * numerics) and image analysis. The presented implementation of cubical complexes is based on the following
+ * definition.
+ *
+ * An <em>elementary interval</em> is an interval of a form \f$ [n,n+1] \f$, or \f$[n,n]\f$, for \f$ n \in \mathcal{Z}
+ * \f$. The first one is called <em>non-degenerate</em>, while the second one is \a degenerate interval. A
+ * <em>boundary of a elementary interval</em> is a chain \f$\partial [n,n+1] = [n+1,n+1]-[n,n] \f$ in case of
+ * non-degenerated elementary interval and \f$\partial [n,n] = 0 \f$ in case of degenerate elementary interval. An
+ * <em>elementary cube</em> \f$ C \f$ is a product of elementary intervals, \f$C=I_1 \times \ldots \times I_n\f$.
+ * <em>Embedding dimension</em> of a cube is n, the number of elementary intervals (degenerate or not) in the product.
+ * A <em>dimension of a cube</em> \f$C=I_1 \times ... \times I_n\f$ is the number of non degenerate elementary
+ * intervals in the product. A <em>boundary of a cube</em> \f$C=I_1 \times \ldots \times I_n\f$ is a chain obtained
+ * in the following way:
+ * \f[\partial C = (\partial I_1 \times \ldots \times I_n) + (I_1 \times \partial I_2 \times \ldots \times I_n) +
+ * \ldots + (I_1 \times I_2 \times \ldots \times \partial I_n).\f]
+ * A <em>cubical complex</em> \f$\mathcal{K}\f$ is a collection of cubes closed under operation of taking boundary
+ * (i.e. boundary of every cube from the collection is in the collection). A cube \f$C\f$ in cubical complex
+ * \f$\mathcal{K}\f$ is <em>maximal</em> if it is not in a boundary of any other cube in \f$\mathcal{K}\f$. A \a
+ * support of a cube \f$C\f$ is the set in \f$\mathbb{R}^n\f$ occupied by \f$C\f$ (\f$n\f$ is the embedding dimension
+ * of \f$C\f$).
+ *
+ * Cubes may be equipped with a filtration values in which case we have filtered cubical complex. All the cubical
+ * complexes considered in this implementation are filtered cubical complexes (although, the range of a filtration may
+ * be a set of two elements).
+ *
+ * For further details and theory of cubical complexes, please consult \cite kaczynski2004computational as well as the
+ * following paper \cite peikert2012topological .
+ *
+ * \section datastructure Data structure.
+ *
+ * The implementation of Cubical complex provides a representation of complexes that occupy a rectangular region in
+ * \f$\mathbb{R}^n\f$. This extra assumption allows for a memory efficient way of storing cubical complexes in a form
+ * of so called bitmaps. Let \f$R = [b_1,e_1] \times \ldots \times [b_n,e_n]\f$, for \f$b_1,...b_n,e_1,...,e_n \in
+ * \mathbb{Z}\f$, \f$b_i \leq d_i\f$ be the considered rectangular region and let \f$\mathcal{K}\f$ be a filtered
+ * cubical complex having the rectangle \f$R\f$ as its support. Note that the structure of the coordinate system gives
+ * a way a lexicographical ordering of cells of \f$\mathcal{K}\f$. This ordering is a base of the presented
+ * bitmap-based implementation. In this implementation, the whole cubical complex is stored as a vector of the values
+ * of filtration. This, together with dimension of \f$\mathcal{K}\f$ and the sizes of \f$\mathcal{K}\f$ in all
+ * directions, allows to determine, dimension, neighborhood, boundary and coboundary of every cube \f$C \in
+ * \mathcal{K}\f$.
+ *
+ * \image html "Cubical_complex_representation.png" Cubical complex.
+ *
+ * Note that the cubical complex in the figure above is, in a natural way, a product of one dimensional cubical
+ * complexes in \f$\mathbb{R}\f$. The number of all cubes in each direction is equal \f$2n+1\f$, where \f$n\f$ is the
+ * number of maximal cubes in the considered direction. Let us consider a cube at the position \f$k\f$ in the bitmap.
+ * Knowing the sizes of the bitmap, by a series of modulo operation, we can determine which elementary intervals are
+ * present in the product that gives the cube \f$C\f$. In a similar way, we can compute boundary and the coboundary of
+ * each cube. Further details can be found in the literature.
+ *
+ * \section inputformat Input Format.
+ *
+ * In the current implantation, filtration is given at the maximal cubes, and it is then extended by the lower star
+ * filtration to all cubes. There are a number of constructors that can be used to construct cubical complex by users
+ * who want to use the code directly. They can be found in the \a Bitmap_cubical_complex class.
+ * Currently one input from a text file is used. It uses a format used already in Perseus software
+ * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda.
+ * Below we are providing a description of the format. The first line contains a number d begin the dimension of the
+ * bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3
+ * in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8
+ * 20 4 7 6 5 in the example below).
+ *
+ *
+ * \image html "exampleBitmap.png" "Example of a input data."
+ *
+ * The input file for the following complex is:
+ * \verbatim
+2
+3
+3
+1
+4
+6
+8
+20
+4
+7
+6
+5
+\endverbatim
+
+ * \section PeriodicBoundaryConditions Periodic boundary conditions
+ * Often one would like to impose periodic boundary conditions to the cubical complex. Let \f$ I_1\times ... \times
+ * I_n \f$ be a box that is decomposed with a cubical complex \f$ \mathcal{K} \f$. Imposing periodic boundary
+ * conditions in the direction i, means that the left and the right side of a complex \f$ \mathcal{K} \f$ are
+ * considered the same. In particular, if for a bitmap \f$ \mathcal{K} \f$ periodic boundary conditions are imposed
+ * in all directions, then complex \f$ \mathcal{K} \f$ became n-dimensional torus. One can use various constructors
+ * from the file Bitmap_cubical_complex_periodic_boundary_conditions_base.h to construct cubical complex with periodic
+ * boundary conditions. One can also use Perseus style input files. To indicate periodic boundary conditions in a
+ * given direction, then number of top dimensional cells in this direction have to be multiplied by -1. For instance:
+
+ *\verbatim
+2
+-3
+3
+1
+4
+6
+8
+20
+4
+7
+6
+5
+\endverbatim
+
+ * Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y.
+
+ * \section BitmapExamples Examples
+ * End user programs are available in example/Bitmap_cubical_complex folder.
+ *
+ * \copyright GNU General Public License v3.
+ */
+/** @} */ // end defgroup cubical_complex
+
+} // namespace Cubical_complex
+
+} // namespace Gudhi
+
+#endif // DOC_GUDHI_CUBICAL_COMPLEX_COMPLEX_H_
diff --git a/src/Contraction/example/Garland_heckbert/Error_quadric.h b/src/Contraction/example/Garland_heckbert/Error_quadric.h
index a033aa00..076f1be0 100644
--- a/src/Contraction/example/Garland_heckbert/Error_quadric.h
+++ b/src/Contraction/example/Garland_heckbert/Error_quadric.h
@@ -1,182 +1,182 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-M�diterran�e (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ERROR_QUADRIC_H_
-#define ERROR_QUADRIC_H_
-
-#include <boost/optional/optional.hpp>
-
-#include <vector>
-#include <utility>
-
-template <typename Point> class Error_quadric {
- private:
- double coeff[10];
-
- public:
- Error_quadric() {
- clear();
- }
-
- /**
- * Quadric corresponding to the L2 distance to the plane.
- *
- * According to the notation of Garland Heckbert, they
- * denote a quadric symetric matrix as :
- * Q = [ q11 q12 q13 q14]
- * [ q12 q22 q23 q24]
- * [ q13 q23 q33 q34]
- * [ q14 q24 q34 q44]
- *
- * which is represented by a vector with 10 elts that
- * are denoted ci for clarity with :
- * Q = [ c0 c1 c2 c3 ]
- * [ c1 c4 c5 c6 ]
- * [ c2 c5 c7 c8 ]
- * [ c3 c6 c8 c9 ]
- *
- * The constructor return the quadrics that represents
- * the squared distance to the plane defined by triangle p0,p1,p2
- * times the area of triangle p0,p1,p2.
- */
- Error_quadric(const Point & p0, const Point & p1, const Point & p2) {
- Point normal(unit_normal(p0, p1, p2));
- double a = normal[0];
- double b = normal[1];
- double c = normal[2];
- double d = -a * p0[0] - b * p0[1] - c * p0[2];
- coeff[0] = a*a;
- coeff[1] = a*b;
- coeff[2] = a*c;
- coeff[3] = a*d;
- coeff[4] = b*b;
- coeff[5] = b*c;
- coeff[6] = b*d;
- coeff[7] = c*c;
- coeff[8] = c*d;
- coeff[9] = d*d;
-
- double area_p0p1p2 = std::sqrt(squared_area(p0, p1, p2));
- for (auto& x : coeff)
- x *= area_p0p1p2;
- }
-
- inline double squared_area(const Point& p0, const Point& p1, const Point& p2) {
- // if (x1,x2,x3) = p1-p0 and (y1,y2,y3) = p2-p0
- // then the squared area is = (u^2+v^2+w^2)/4
- // with: u = x2 * y3 - x3 * y2;
- // v = x3 * y1 - x1 * y3;
- // w = x1 * y2 - x2 * y1;
- Point p0p1(p1 - p0);
- Point p0p2(p2 - p0);
- double A = p0p1[1] * p0p2[2] - p0p1[2] * p0p2[1];
- double B = p0p1[2] * p0p2[0] - p0p1[0] * p0p2[2];
- double C = p0p1[0] * p0p2[1] - p0p1[1] * p0p2[0];
- return 1. / 4. * (A * A + B * B + C * C);
- }
-
- void clear() {
- for (auto& x : coeff)
- x = 0;
- }
-
- Error_quadric& operator+=(const Error_quadric& other) {
- if (this != &other) {
- for (int i = 0; i < 10; ++i)
- coeff[i] += other.coeff[i];
- }
- return *this;
- }
-
- /**
- * @return The quadric quost defined by the scalar product v^T Q v where Q is the quadratic form of Garland/Heckbert
- */
- inline double cost(const Point& point) const {
- double cost =
- coeff[0] * point.x() * point.x() + coeff[4] * point.y() * point.y() + coeff[7] * point.z() * point.z()
- + 2 * (coeff[1] * point.x() * point.y() + coeff[5] * point.y() * point.z() + coeff[2] * point.z() * point.x())
- + 2 * (coeff[3] * point.x() + coeff[6] * point.y() + coeff[8] * point.z())
- + coeff[9];
- if (cost < 0) {
- return 0;
- } else {
- return cost;
- }
- }
-
- inline double grad_determinant() const {
- return
- coeff[0] * coeff[4] * coeff[7]
- - coeff[0] * coeff[5] * coeff[5]
- - coeff[1] * coeff[1] * coeff[7]
- + 2 * coeff[1] * coeff[5] * coeff[2]
- - coeff[4] * coeff[2] * coeff[2];
- }
-
- /**
- * Return the point such that it minimizes the gradient of the quadric.
- * Det must be passed with the determinant value of the gradient (should be non zero).
- */
- inline Point solve_linear_gradient(double det) const {
- return Point({
- (-coeff[1] * coeff[5] * coeff[8] + coeff[1] * coeff[7] * coeff[6] + coeff[2] * coeff[8] * coeff[4] -
- coeff[2] * coeff[5] * coeff[6] - coeff[3] * coeff[4] * coeff[7] + coeff[3] * coeff[5] * coeff[5])
- / det,
- (coeff[0] * coeff[5] * coeff[8] - coeff[0] * coeff[7] * coeff[6] - coeff[5] * coeff[2] * coeff[3] -
- coeff[1] * coeff[2] * coeff[8] + coeff[6] * coeff[2] * coeff[2] + coeff[1] * coeff[3] * coeff[7])
- / det,
- (-coeff[8] * coeff[0] * coeff[4] + coeff[8] * coeff[1] * coeff[1] + coeff[2] * coeff[3] * coeff[4] +
- coeff[5] * coeff[0] * coeff[6] - coeff[5] * coeff[1] * coeff[3] - coeff[1] * coeff[2] * coeff[6])
- / det
- });
- }
-
- /**
- * returns the point that minimizes the quadric.
- * It inverses the quadric if its determinant is higher that a given threshold .
- * If the determinant is lower than this value the returned value is uninitialized.
- */
- boost::optional<Point> min_cost(double scale = 1) const {
- // const double min_determinant = 1e-4 * scale*scale;
- const double min_determinant = 1e-5;
- boost::optional<Point> pt_res;
- double det = grad_determinant();
- if (std::abs(det) > min_determinant)
- pt_res = solve_linear_gradient(det);
- return pt_res;
- }
-
- friend std::ostream& operator<<(std::ostream& stream, const Error_quadric& quadric) {
- stream << "\n[ " << quadric.coeff[0] << "," << quadric.coeff[1] << "," << quadric.coeff[2] << "," <<
- quadric.coeff[3] << ";\n";
- stream << " " << quadric.coeff[1] << "," << quadric.coeff[4] << "," << quadric.coeff[5] << "," <<
- quadric.coeff[6] << ";\n";
- stream << " " << quadric.coeff[2] << "," << quadric.coeff[5] << "," << quadric.coeff[7] << "," <<
- quadric.coeff[8] << ";\n";
- stream << " " << quadric.coeff[3] << "," << quadric.coeff[6] << "," << quadric.coeff[8] << "," <<
- quadric.coeff[9] << "]";
- return stream;
- }
-};
-
-#endif // ERROR_QUADRIC_H_
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-M�diterran�e (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef ERROR_QUADRIC_H_
+#define ERROR_QUADRIC_H_
+
+#include <boost/optional/optional.hpp>
+
+#include <vector>
+#include <utility>
+
+template <typename Point> class Error_quadric {
+ private:
+ double coeff[10];
+
+ public:
+ Error_quadric() {
+ clear();
+ }
+
+ /**
+ * Quadric corresponding to the L2 distance to the plane.
+ *
+ * According to the notation of Garland Heckbert, they
+ * denote a quadric symetric matrix as :
+ * Q = [ q11 q12 q13 q14]
+ * [ q12 q22 q23 q24]
+ * [ q13 q23 q33 q34]
+ * [ q14 q24 q34 q44]
+ *
+ * which is represented by a vector with 10 elts that
+ * are denoted ci for clarity with :
+ * Q = [ c0 c1 c2 c3 ]
+ * [ c1 c4 c5 c6 ]
+ * [ c2 c5 c7 c8 ]
+ * [ c3 c6 c8 c9 ]
+ *
+ * The constructor return the quadrics that represents
+ * the squared distance to the plane defined by triangle p0,p1,p2
+ * times the area of triangle p0,p1,p2.
+ */
+ Error_quadric(const Point & p0, const Point & p1, const Point & p2) {
+ Point normal(unit_normal(p0, p1, p2));
+ double a = normal[0];
+ double b = normal[1];
+ double c = normal[2];
+ double d = -a * p0[0] - b * p0[1] - c * p0[2];
+ coeff[0] = a*a;
+ coeff[1] = a*b;
+ coeff[2] = a*c;
+ coeff[3] = a*d;
+ coeff[4] = b*b;
+ coeff[5] = b*c;
+ coeff[6] = b*d;
+ coeff[7] = c*c;
+ coeff[8] = c*d;
+ coeff[9] = d*d;
+
+ double area_p0p1p2 = std::sqrt(squared_area(p0, p1, p2));
+ for (auto& x : coeff)
+ x *= area_p0p1p2;
+ }
+
+ inline double squared_area(const Point& p0, const Point& p1, const Point& p2) {
+ // if (x1,x2,x3) = p1-p0 and (y1,y2,y3) = p2-p0
+ // then the squared area is = (u^2+v^2+w^2)/4
+ // with: u = x2 * y3 - x3 * y2;
+ // v = x3 * y1 - x1 * y3;
+ // w = x1 * y2 - x2 * y1;
+ Point p0p1(p1 - p0);
+ Point p0p2(p2 - p0);
+ double A = p0p1[1] * p0p2[2] - p0p1[2] * p0p2[1];
+ double B = p0p1[2] * p0p2[0] - p0p1[0] * p0p2[2];
+ double C = p0p1[0] * p0p2[1] - p0p1[1] * p0p2[0];
+ return 1. / 4. * (A * A + B * B + C * C);
+ }
+
+ void clear() {
+ for (auto& x : coeff)
+ x = 0;
+ }
+
+ Error_quadric& operator+=(const Error_quadric& other) {
+ if (this != &other) {
+ for (int i = 0; i < 10; ++i)
+ coeff[i] += other.coeff[i];
+ }
+ return *this;
+ }
+
+ /**
+ * @return The quadric quost defined by the scalar product v^T Q v where Q is the quadratic form of Garland/Heckbert
+ */
+ inline double cost(const Point& point) const {
+ double cost =
+ coeff[0] * point.x() * point.x() + coeff[4] * point.y() * point.y() + coeff[7] * point.z() * point.z()
+ + 2 * (coeff[1] * point.x() * point.y() + coeff[5] * point.y() * point.z() + coeff[2] * point.z() * point.x())
+ + 2 * (coeff[3] * point.x() + coeff[6] * point.y() + coeff[8] * point.z())
+ + coeff[9];
+ if (cost < 0) {
+ return 0;
+ } else {
+ return cost;
+ }
+ }
+
+ inline double grad_determinant() const {
+ return
+ coeff[0] * coeff[4] * coeff[7]
+ - coeff[0] * coeff[5] * coeff[5]
+ - coeff[1] * coeff[1] * coeff[7]
+ + 2 * coeff[1] * coeff[5] * coeff[2]
+ - coeff[4] * coeff[2] * coeff[2];
+ }
+
+ /**
+ * Return the point such that it minimizes the gradient of the quadric.
+ * Det must be passed with the determinant value of the gradient (should be non zero).
+ */
+ inline Point solve_linear_gradient(double det) const {
+ return Point({
+ (-coeff[1] * coeff[5] * coeff[8] + coeff[1] * coeff[7] * coeff[6] + coeff[2] * coeff[8] * coeff[4] -
+ coeff[2] * coeff[5] * coeff[6] - coeff[3] * coeff[4] * coeff[7] + coeff[3] * coeff[5] * coeff[5])
+ / det,
+ (coeff[0] * coeff[5] * coeff[8] - coeff[0] * coeff[7] * coeff[6] - coeff[5] * coeff[2] * coeff[3] -
+ coeff[1] * coeff[2] * coeff[8] + coeff[6] * coeff[2] * coeff[2] + coeff[1] * coeff[3] * coeff[7])
+ / det,
+ (-coeff[8] * coeff[0] * coeff[4] + coeff[8] * coeff[1] * coeff[1] + coeff[2] * coeff[3] * coeff[4] +
+ coeff[5] * coeff[0] * coeff[6] - coeff[5] * coeff[1] * coeff[3] - coeff[1] * coeff[2] * coeff[6])
+ / det
+ });
+ }
+
+ /**
+ * returns the point that minimizes the quadric.
+ * It inverses the quadric if its determinant is higher that a given threshold .
+ * If the determinant is lower than this value the returned value is uninitialized.
+ */
+ boost::optional<Point> min_cost(double scale = 1) const {
+ // const double min_determinant = 1e-4 * scale*scale;
+ const double min_determinant = 1e-5;
+ boost::optional<Point> pt_res;
+ double det = grad_determinant();
+ if (std::abs(det) > min_determinant)
+ pt_res = solve_linear_gradient(det);
+ return pt_res;
+ }
+
+ friend std::ostream& operator<<(std::ostream& stream, const Error_quadric& quadric) {
+ stream << "\n[ " << quadric.coeff[0] << "," << quadric.coeff[1] << "," << quadric.coeff[2] << "," <<
+ quadric.coeff[3] << ";\n";
+ stream << " " << quadric.coeff[1] << "," << quadric.coeff[4] << "," << quadric.coeff[5] << "," <<
+ quadric.coeff[6] << ";\n";
+ stream << " " << quadric.coeff[2] << "," << quadric.coeff[5] << "," << quadric.coeff[7] << "," <<
+ quadric.coeff[8] << ";\n";
+ stream << " " << quadric.coeff[3] << "," << quadric.coeff[6] << "," << quadric.coeff[8] << "," <<
+ quadric.coeff[9] << "]";
+ return stream;
+ }
+};
+
+#endif // ERROR_QUADRIC_H_
diff --git a/src/GudhUI/gui/MenuEdgeContraction.ui b/src/GudhUI/gui/MenuEdgeContraction.ui
index da2e5c82..b1696431 100644
--- a/src/GudhUI/gui/MenuEdgeContraction.ui
+++ b/src/GudhUI/gui/MenuEdgeContraction.ui
@@ -1,118 +1,118 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MenuEdgeContraction</class>
- <widget class="QDialog" name="MenuEdgeContraction">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>362</width>
- <height>209</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Edge contraction</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="5" column="2">
- <widget class="QSpinBox" name="spinBox_nb_remaining_vertices">
- <property name="minimum">
- <number>1</number>
- </property>
- <property name="maximum">
- <number>999999999</number>
- </property>
- <property name="value">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item row="7" column="2">
- <widget class="QCheckBox" name="checkBox_link_condition">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Link condition</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="2" alignment="Qt::AlignRight">
- <widget class="QLabel" name="txt_nb_collapses">
- <property name="text">
- <string>1</string>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Policy</string>
- </property>
- </widget>
- </item>
- <item row="6" column="2">
- <widget class="QComboBox" name="m_simplificationMethod">
- <item>
- <property name="text">
- <string>Length_midpoint</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="2" column="2" alignment="Qt::AlignRight">
- <widget class="QLabel" name="txt_nb_vertices">
- <property name="text">
- <string>0</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Number of vertices</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Number of contractions</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0" colspan="2">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Number of vertices after </string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QSlider" name="horizontalSlider">
- <property name="minimum">
- <number>0</number>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="pushButton_collapse">
- <property name="text">
- <string>Perform collapse</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MenuEdgeContraction</class>
+ <widget class="QDialog" name="MenuEdgeContraction">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>362</width>
+ <height>209</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Edge contraction</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="5" column="2">
+ <widget class="QSpinBox" name="spinBox_nb_remaining_vertices">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>999999999</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="2">
+ <widget class="QCheckBox" name="checkBox_link_condition">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Link condition</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2" alignment="Qt::AlignRight">
+ <widget class="QLabel" name="txt_nb_collapses">
+ <property name="text">
+ <string>1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Policy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="2">
+ <widget class="QComboBox" name="m_simplificationMethod">
+ <item>
+ <property name="text">
+ <string>Length_midpoint</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="2" alignment="Qt::AlignRight">
+ <widget class="QLabel" name="txt_nb_vertices">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Number of vertices</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Number of contractions</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Number of vertices after </string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QSlider" name="horizontalSlider">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="pushButton_collapse">
+ <property name="text">
+ <string>Perform collapse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/GudhUI/gui/gudhui.cpp b/src/GudhUI/gui/gudhui.cpp
index 377cd2f2..276c4a5f 100644
--- a/src/GudhUI/gui/gudhui.cpp
+++ b/src/GudhUI/gui/gudhui.cpp
@@ -1,38 +1,38 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "MainWindow.h"
-#include <QApplication>
-#include <CGAL/Qt/resources.h>
-
-int main(int argc, char** argv) {
- QApplication application(argc, argv);
- application.setOrganizationDomain("inria.fr");
- application.setOrganizationName("INRIA");
- application.setApplicationName("GudhUI");
-
- MainWindow mw;
- application.setQuitOnLastWindowClosed(false);
- mw.show();
- return application.exec();
-}
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "MainWindow.h"
+#include <QApplication>
+#include <CGAL/Qt/resources.h>
+
+int main(int argc, char** argv) {
+ QApplication application(argc, argv);
+ application.setOrganizationDomain("inria.fr");
+ application.setOrganizationName("INRIA");
+ application.setApplicationName("GudhUI");
+
+ MainWindow mw;
+ application.setQuitOnLastWindowClosed(false);
+ mw.show();
+ return application.exec();
+}
diff --git a/src/GudhUI/view/Viewer.h b/src/GudhUI/view/Viewer.h
index 276ccd3c..319c8e04 100644
--- a/src/GudhUI/view/Viewer.h
+++ b/src/GudhUI/view/Viewer.h
@@ -1,120 +1,120 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef VIEW_VIEWER_H_
-#define VIEW_VIEWER_H_
-
-// Workaround for moc-qt4 not parsing boost headers
-#include <CGAL/config.h>
-
-#include <QGLViewer/qglviewer.h>
-
-#include <vector>
-
-#include "View_parameter.h"
-#include "model/Complex_typedefs.h"
-#include "Color.h"
-#include "Viewer_instructor.h"
-
-class Viewer_instructor;
-
-class Viewer : public QGLViewer {
- Q_OBJECT
-
- Viewer_instructor * instructor;
-
- /**
- * light angles
- */
- double theta, phi;
- typedef Complex::GT Gudhi_kernel;
- typedef Gudhi_kernel::Point_3 Point_3;
-
- public:
- Viewer(QWidget* parent);
-
- void set_instructor(Viewer_instructor* instructor_);
-
- void show_entire_scene();
-
- void draw();
-
- void set_bounding_box(const Point_3 & lower_left, const Point_3 & upper_right);
-
- void update_GL();
-
- void init_scene();
-
- void init_light();
-
- void set_light();
-
- void set_light_direction(double theta, double phi);
-
- /**
- * set the light in the direction of the observer
- */
- void set_light_direction();
-
- protected:
- virtual void postSelection(const QPoint& point);
-
- public:
- ////////////////////////
- // draw
- ////////////////////////
- void set_size_point(double size_points);
-
- void set_color(const Color& color);
-
- void draw_point(const Point_3& p, const Color& color, double size_points);
-
- void begin_draw_points(double size, bool light = false);
-
- void draw_points(const Point_3 & point);
-
- void end_draw_points();
-
- void draw_edge(const Point_3 &a, const Point_3 &b, const Color& color, double size);
-
- void begin_draw_edges(double size, bool light = false);
-
- void draw_edges(const Point_3 &a, const Point_3 &b);
-
- void end_draw_edges();
-
- void begin_draw_triangles(double size, bool light, bool transparent = false);
-
- void draw_triangles(const Point_3& p1, const Point_3& p2, const Point_3& p3);
-
- // todo remove
- void draw_triangles(const std::vector<Point_3*>& points);
-
- void end_draw_triangles();
-
-
- signals:
- void click(const Point_3& position);
-};
-
-#endif // VIEW_VIEWER_H_
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef VIEW_VIEWER_H_
+#define VIEW_VIEWER_H_
+
+// Workaround for moc-qt4 not parsing boost headers
+#include <CGAL/config.h>
+
+#include <QGLViewer/qglviewer.h>
+
+#include <vector>
+
+#include "View_parameter.h"
+#include "model/Complex_typedefs.h"
+#include "Color.h"
+#include "Viewer_instructor.h"
+
+class Viewer_instructor;
+
+class Viewer : public QGLViewer {
+ Q_OBJECT
+
+ Viewer_instructor * instructor;
+
+ /**
+ * light angles
+ */
+ double theta, phi;
+ typedef Complex::GT Gudhi_kernel;
+ typedef Gudhi_kernel::Point_3 Point_3;
+
+ public:
+ Viewer(QWidget* parent);
+
+ void set_instructor(Viewer_instructor* instructor_);
+
+ void show_entire_scene();
+
+ void draw();
+
+ void set_bounding_box(const Point_3 & lower_left, const Point_3 & upper_right);
+
+ void update_GL();
+
+ void init_scene();
+
+ void init_light();
+
+ void set_light();
+
+ void set_light_direction(double theta, double phi);
+
+ /**
+ * set the light in the direction of the observer
+ */
+ void set_light_direction();
+
+ protected:
+ virtual void postSelection(const QPoint& point);
+
+ public:
+ ////////////////////////
+ // draw
+ ////////////////////////
+ void set_size_point(double size_points);
+
+ void set_color(const Color& color);
+
+ void draw_point(const Point_3& p, const Color& color, double size_points);
+
+ void begin_draw_points(double size, bool light = false);
+
+ void draw_points(const Point_3 & point);
+
+ void end_draw_points();
+
+ void draw_edge(const Point_3 &a, const Point_3 &b, const Color& color, double size);
+
+ void begin_draw_edges(double size, bool light = false);
+
+ void draw_edges(const Point_3 &a, const Point_3 &b);
+
+ void end_draw_edges();
+
+ void begin_draw_triangles(double size, bool light, bool transparent = false);
+
+ void draw_triangles(const Point_3& p1, const Point_3& p2, const Point_3& p3);
+
+ // todo remove
+ void draw_triangles(const std::vector<Point_3*>& points);
+
+ void end_draw_triangles();
+
+
+ signals:
+ void click(const Point_3& position);
+};
+
+#endif // VIEW_VIEWER_H_
diff --git a/src/GudhUI/view/Viewer_instructor.h b/src/GudhUI/view/Viewer_instructor.h
index 82c8e346..1da28009 100644
--- a/src/GudhUI/view/Viewer_instructor.h
+++ b/src/GudhUI/view/Viewer_instructor.h
@@ -1,117 +1,117 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): David Salinas
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef VIEW_VIEWER_INSTRUCTOR_H_
-#define VIEW_VIEWER_INSTRUCTOR_H_
-
-// todo do a viewer instructor that have directely a pointer to a QGLviewer and buffer ot not triangles
-
-// Workaround for moc-qt4 not parsing boost headers
-#include <CGAL/config.h>
-
-#include <QFileDialog>
-#include <QKeyEvent>
-#include <QGLViewer/camera.h>
-
-#include <memory>
-#include <utility> // for pair<>
-
-#include "model/Complex_typedefs.h"
-
-#include "Projector3D.h"
-#include "View_parameter.h"
-#include "Viewer.h"
-
-class Viewer;
-class Viewer_parameter;
-
-class Viewer_instructor : public QWidget {
- Q_OBJECT
-
- typedef Geometry_trait::Point_3 Point_3;
- typedef Complex::Point Point;
- typedef Complex::Vertex_handle Vertex_handle;
- typedef Complex::Edge_handle Edge_handle;
- typedef Complex::Simplex Simplex;
-
- Viewer* viewer_;
- View_parameter view_params_;
- const Complex& mesh_;
- std::unique_ptr<Projector3D> projector_;
-
- public:
- Viewer_instructor(QWidget* parent, Viewer* viewer, const Complex& mesh);
-
- void initialize_bounding_box();
-
- std::pair<Point, Point> compute_bounding_box_corners();
-
- void show_entire_scene();
-
- const qglviewer::Camera* camera() const;
-
- int width() const;
- int height() const;
-
- /**
- * to change display parameters
- */
- View_parameter& view_params();
-
- public:
- /**
- * gives instructions to the viewer
- */
- void give_instructions();
-
- void draw_edges();
- void draw_triangles();
- void draw_points();
-
- void draw_edge(const Point&, const Point&);
-
- void draw_point(const Point&);
-
- /**
- * set the right color of vertex/edge/triangle considering the view_params choice
- */
- void set_color_vertex(Vertex_handle vh);
- void set_color_edge(Edge_handle eh);
-
- void set_color_triangle(const Simplex& triangle);
-
- private:
- /**
- * Projection to 3D needed for the viewer.
- */
- Point_3 proj(const Point& p) const;
-
- public slots:
- void sceneChanged();
- void change_draw_vertices();
- void change_draw_edges();
- void change_draw_triangles();
- void change_light();
-};
-
-#endif // VIEW_VIEWER_INSTRUCTOR_H_
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef VIEW_VIEWER_INSTRUCTOR_H_
+#define VIEW_VIEWER_INSTRUCTOR_H_
+
+// todo do a viewer instructor that have directely a pointer to a QGLviewer and buffer ot not triangles
+
+// Workaround for moc-qt4 not parsing boost headers
+#include <CGAL/config.h>
+
+#include <QFileDialog>
+#include <QKeyEvent>
+#include <QGLViewer/camera.h>
+
+#include <memory>
+#include <utility> // for pair<>
+
+#include "model/Complex_typedefs.h"
+
+#include "Projector3D.h"
+#include "View_parameter.h"
+#include "Viewer.h"
+
+class Viewer;
+class Viewer_parameter;
+
+class Viewer_instructor : public QWidget {
+ Q_OBJECT
+
+ typedef Geometry_trait::Point_3 Point_3;
+ typedef Complex::Point Point;
+ typedef Complex::Vertex_handle Vertex_handle;
+ typedef Complex::Edge_handle Edge_handle;
+ typedef Complex::Simplex Simplex;
+
+ Viewer* viewer_;
+ View_parameter view_params_;
+ const Complex& mesh_;
+ std::unique_ptr<Projector3D> projector_;
+
+ public:
+ Viewer_instructor(QWidget* parent, Viewer* viewer, const Complex& mesh);
+
+ void initialize_bounding_box();
+
+ std::pair<Point, Point> compute_bounding_box_corners();
+
+ void show_entire_scene();
+
+ const qglviewer::Camera* camera() const;
+
+ int width() const;
+ int height() const;
+
+ /**
+ * to change display parameters
+ */
+ View_parameter& view_params();
+
+ public:
+ /**
+ * gives instructions to the viewer
+ */
+ void give_instructions();
+
+ void draw_edges();
+ void draw_triangles();
+ void draw_points();
+
+ void draw_edge(const Point&, const Point&);
+
+ void draw_point(const Point&);
+
+ /**
+ * set the right color of vertex/edge/triangle considering the view_params choice
+ */
+ void set_color_vertex(Vertex_handle vh);
+ void set_color_edge(Edge_handle eh);
+
+ void set_color_triangle(const Simplex& triangle);
+
+ private:
+ /**
+ * Projection to 3D needed for the viewer.
+ */
+ Point_3 proj(const Point& p) const;
+
+ public slots:
+ void sceneChanged();
+ void change_draw_vertices();
+ void change_draw_edges();
+ void change_draw_triangles();
+ void change_light();
+};
+
+#endif // VIEW_VIEWER_INSTRUCTOR_H_
diff --git a/src/cmake/modules/FindTBB.cmake b/src/cmake/modules/FindTBB.cmake
index 414a929b..a29c6d9c 100644
--- a/src/cmake/modules/FindTBB.cmake
+++ b/src/cmake/modules/FindTBB.cmake
@@ -1,433 +1,433 @@
-# Locate Intel Threading Building Blocks include paths and libraries
-# FindTBB.cmake can be found at https://code.google.com/p/findtbb/
-# Written by Hannes Hofmann <hannes.hofmann _at_ informatik.uni-erlangen.de>
-# Improvements by Gino van den Bergen <gino _at_ dtecta.com>,
-# Florian Uhlig <F.Uhlig _at_ gsi.de>,
-# Jiri Marsik <jiri.marsik89 _at_ gmail.com>
-
-# The MIT License
-#
-# Copyright (c) 2011 Hannes Hofmann
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-
-# GvdB: This module uses the environment variable TBB_ARCH_PLATFORM which defines architecture and compiler.
-# e.g. "ia32/vc8" or "em64t/cc4.1.0_libc2.4_kernel2.6.16.21"
-# TBB_ARCH_PLATFORM is set by the build script tbbvars[.bat|.sh|.csh], which can be found
-# in the TBB installation directory (TBB_INSTALL_DIR).
-#
-# GvdB: Mac OS X distribution places libraries directly in lib directory.
-#
-# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER.
-# TBB_ARCHITECTURE [ ia32 | em64t | itanium ]
-# which architecture to use
-# TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9
-# which compiler to use (detected automatically on Windows)
-
-# This module respects
-# TBB_INSTALL_DIR or $ENV{TBB21_INSTALL_DIR} or $ENV{TBB_INSTALL_DIR}
-
-# This module defines
-# TBB_INCLUDE_DIRS, where to find task_scheduler_init.h, etc.
-# TBB_LIBRARY_DIRS, where to find TBB libraries
-# TBB_INSTALL_DIR, the base TBB install directory.
-# TBB_LIBRARIES, all the following TBB libraries (both release and debug versions, using "optimized" and "debug" CMake keywords). Note that if the debug versions are not found, the release versions will be used instead for the debug mode.
-# TBB_RELEASE_LIBRARY, the TBB release library
-# TBB_MALLOC_RELEASE_LIBRARY, the TBB release malloc library
-# TBB_DEBUG_LIBRARY, the TBB debug library
-# TBB_MALLOC_DEBUG_LIBRARY, the TBB debug malloc library
-# TBB_FOUND, If false, don't try to use TBB.
-# TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h
-# TBB_MALLOCPROXY_DEBUG_LIBRARY, the TBB debug malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal)
-# TBB_MALLOCPROXY_RELEASE_LIBRARY, the TBB release malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal)
-
-include(CheckCXXSourceCompiles)
-
-# Usage:
-# try_TBB_with_pthread(<result_var_name> [additional linker args...])
-function(try_TBB_with_pthread result_var)
- set(TBB_try_ts_source "
- #include <tbb/enumerable_thread_specific.h>
- int main() {
- tbb::enumerable_thread_specific<
- bool*,
- tbb::cache_aligned_allocator<bool*>,
- tbb::ets_key_per_instance> grid;
- }
- ")
- set(CMAKE_REQUIRED_LIBRARIES ${ALL_TBB_LIBRARIES} ${ARGN})
- set(CMAKE_REQUIRED_INCLUDES ${TBB_INCLUDE_DIR})
- check_cxx_source_compiles("${TBB_try_ts_source}" ${result_var})
- set(${result_var} ${${result_var}} PARENT_SCOPE)
-endfunction(try_TBB_with_pthread)
-
-if (WIN32)
- # has em64t/vc8 em64t/vc9
- # has ia32/vc7.1 ia32/vc8 ia32/vc9
- set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
- set(_TBB_LIB_RELEASE_NAME "tbb")
- set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
- set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
- set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
- set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
- set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
- if (MSVC71)
- set (_TBB_COMPILER "vc7.1")
- endif(MSVC71)
- if (MSVC80)
- set(_TBB_COMPILER "vc8")
- endif(MSVC80)
- if (MSVC90)
- set(_TBB_COMPILER "vc9")
- endif(MSVC90)
- if(MSVC10)
- set(_TBB_COMPILER "vc10")
- endif(MSVC10)
- if(MSVC11)
- set(_TBB_COMPILER "vc11")
- endif(MSVC11)
- if(MSVC12)
- set(_TBB_COMPILER "vc12")
- endif(MSVC12)
- #note there was no MSVC13
- if(MSVC14)
- if(RUNNING_CGAL_AUTO_TEST)
- set (TBB_FOUND "NO")
- return()#binaries for TBB not publicly available when CGAL-4.7 is published
- endif(RUNNING_CGAL_AUTO_TEST)
- message(STATUS "[Warning] FindTBB.cmake: TBB 4.4 (latest available when CGAL-4.7 is published) does not provide support for MSVC 2015.")
- endif(MSVC14)
- # Todo: add other Windows compilers such as ICL.
- set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
-endif (WIN32)
-
-if (UNIX)
- if (APPLE)
- # MAC
- set(_TBB_DEFAULT_INSTALL_DIR "/Library/Frameworks/Intel_TBB.framework/Versions")
- # libs: libtbb.dylib, libtbbmalloc.dylib, *_debug
- set(_TBB_LIB_RELEASE_NAME "tbb")
- set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
- #set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
- set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
- set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
- #set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
- # default flavor on apple: ia32/cc4.0.1_os10.4.9
- # Jiri: There is no reason to presume there is only one flavor and
- # that user's setting of variables should be ignored.
- if(NOT TBB_COMPILER)
- set(_TBB_COMPILER "cc4.0.1_os10.4.9")
- elseif (NOT TBB_COMPILER)
- set(_TBB_COMPILER ${TBB_COMPILER})
- endif(NOT TBB_COMPILER)
- if(NOT TBB_ARCHITECTURE)
- set(_TBB_ARCHITECTURE "ia32")
- elseif(NOT TBB_ARCHITECTURE)
- set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
- endif(NOT TBB_ARCHITECTURE)
- else (APPLE)
- # LINUX
- set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include")
- set(_TBB_LIB_RELEASE_NAME "tbb")
- set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
- set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
- set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
- set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
- set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
- # has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21
- # has ia32/*
- # has itanium/*
- set(_TBB_COMPILER ${TBB_COMPILER})
- set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
- endif (APPLE)
-endif (UNIX)
-
-if (CMAKE_SYSTEM MATCHES "SunOS.*")
-# SUN
-# not yet supported
-# has em64t/cc3.4.3_kernel5.10
-# has ia32/*
-endif (CMAKE_SYSTEM MATCHES "SunOS.*")
-
-
-#-- Clear the public variables
-set (TBB_FOUND "NO")
-
-
-#-- Find TBB install dir and set ${_TBB_INSTALL_DIR} and cached ${TBB_INSTALL_DIR}
-# first: use CMake variable TBB_INSTALL_DIR
-if (TBB_INSTALL_DIR)
- set (_TBB_INSTALL_DIR ${TBB_INSTALL_DIR})
-endif (TBB_INSTALL_DIR)
-# second: use environment variable
-if (NOT _TBB_INSTALL_DIR)
- if (NOT "$ENV{TBBROOT}" STREQUAL "")
- set (_TBB_INSTALL_DIR $ENV{TBBROOT})
- endif (NOT "$ENV{TBBROOT}" STREQUAL "")
- if (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
- set (_TBB_INSTALL_DIR $ENV{TBB_INSTALL_DIR})
- endif (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
- # Intel recommends setting TBB21_INSTALL_DIR
- if (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
- set (_TBB_INSTALL_DIR $ENV{TBB21_INSTALL_DIR})
- endif (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
- if (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
- set (_TBB_INSTALL_DIR $ENV{TBB22_INSTALL_DIR})
- endif (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
- if (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
- set (_TBB_INSTALL_DIR $ENV{TBB30_INSTALL_DIR})
- endif (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
-endif (NOT _TBB_INSTALL_DIR)
-# third: try to find path automatically
-if (NOT _TBB_INSTALL_DIR)
- if (_TBB_DEFAULT_INSTALL_DIR)
- set (_TBB_INSTALL_DIR ${_TBB_DEFAULT_INSTALL_DIR})
- endif (_TBB_DEFAULT_INSTALL_DIR)
-endif (NOT _TBB_INSTALL_DIR)
-# sanity check
-if (NOT _TBB_INSTALL_DIR)
- message ("ERROR: Unable to find Intel TBB install directory. ${_TBB_INSTALL_DIR}")
-else (NOT _TBB_INSTALL_DIR)
-# finally: set the cached CMake variable TBB_INSTALL_DIR
-if (NOT TBB_INSTALL_DIR)
- set (TBB_INSTALL_DIR ${_TBB_INSTALL_DIR} CACHE PATH "Intel TBB install directory")
- mark_as_advanced(TBB_INSTALL_DIR)
-endif (NOT TBB_INSTALL_DIR)
-
-
-#-- A macro to rewrite the paths of the library. This is necessary, because
-# find_library() always found the em64t/vc9 version of the TBB libs
-macro(TBB_CORRECT_LIB_DIR var_name)
-# if (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
- string(REPLACE em64t "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
-# endif (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
- string(REPLACE ia32 "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
- string(REPLACE vc7.1 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
- string(REPLACE vc8 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
- string(REPLACE vc9 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
- string(REPLACE vc10 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
- string(REPLACE vc11 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
-endmacro(TBB_CORRECT_LIB_DIR var_content)
-
-
-#-- Look for include directory and set ${TBB_INCLUDE_DIR}
-set (TBB_INC_SEARCH_DIR ${_TBB_INSTALL_DIR}/include)
-# Jiri: tbbvars now sets the CPATH environment variable to the directory
-# containing the headers.
-# LR: search first with NO_DEFAULT_PATH...
-find_path(TBB_INCLUDE_DIR
- tbb/task_scheduler_init.h
- PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
- NO_DEFAULT_PATH
-)
-if(NOT TBB_INCLUDE_DIR)
-# LR: ... and then search again with NO_DEFAULT_PATH if nothing was found in
-# hinted paths
- find_path(TBB_INCLUDE_DIR
- tbb/task_scheduler_init.h
- PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
- )
-endif()
-mark_as_advanced(TBB_INCLUDE_DIR)
-
-
-#-- Look for libraries
-# GvdB: $ENV{TBB_ARCH_PLATFORM} is set by the build script tbbvars[.bat|.sh|.csh]
-if (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
- set (_TBB_LIBRARY_DIR
- ${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM}
- ${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib
- )
-endif (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
-# Jiri: This block isn't mutually exclusive with the previous one
-# (hence no else), instead I test if the user really specified
-# the variables in question.
-if ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
- # HH: deprecated
- message(STATUS "[Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set \$ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).")
- # Jiri: It doesn't hurt to look in more places, so I store the hints from
- # ENV{TBB_ARCH_PLATFORM} and the TBB_ARCHITECTURE and TBB_COMPILER
- # variables and search them both.
- set (_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}/lib" ${_TBB_LIBRARY_DIR})
-endif ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
-
-# GvdB: Mac OS X distribution places libraries directly in lib directory.
-list(APPEND _TBB_LIBRARY_DIR ${_TBB_INSTALL_DIR}/lib)
-
-# Jiri: No reason not to check the default paths. From recent versions,
-# tbbvars has started exporting the LIBRARY_PATH and LD_LIBRARY_PATH
-# variables, which now point to the directories of the lib files.
-# It all makes more sense to use the ${_TBB_LIBRARY_DIR} as a HINTS
-# argument instead of the implicit PATHS as it isn't hard-coded
-# but computed by system introspection. Searching the LIBRARY_PATH
-# and LD_LIBRARY_PATH environment variables is now even more important
-# that tbbvars doesn't export TBB_ARCH_PLATFORM and it facilitates
-# the use of TBB built from sources.
-# LR: search first with NO_DEFAULT_PATH...
-find_library(TBB_RELEASE_LIBRARY ${_TBB_LIB_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
-find_library(TBB_MALLOC_RELEASE_LIBRARY ${_TBB_LIB_MALLOC_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
-find_library(TBB_MALLOCPROXY_RELEASE_LIBRARY ${_TBB_LIB_MALLOCPROXY_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
-if(NOT TBB_RELEASE_LIBRARY OR NOT TBB_MALLOC_RELEASE_LIBRARY OR NOT TBB_MALLOCPROXY_RELEASE_LIBRARY)
-# LR: ... and then search again with NO_DEFAULT_PATH if nothing was found
-# in hinted paths
- find_library(TBB_RELEASE_LIBRARY ${_TBB_LIB_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
- find_library(TBB_MALLOC_RELEASE_LIBRARY ${_TBB_LIB_MALLOC_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
- find_library(TBB_MALLOCPROXY_RELEASE_LIBRARY ${_TBB_LIB_MALLOCPROXY_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
-endif()
-
-#Extract path from TBB_RELEASE_LIBRARY name
-get_filename_component(TBB_RELEASE_LIBRARY_DIR ${TBB_RELEASE_LIBRARY} PATH)
-
-#TBB_CORRECT_LIB_DIR(TBB_RELEASE_LIBRARY)
-#TBB_CORRECT_LIB_DIR(TBB_MALLOC_RELEASE_LIBRARY)
-#TBB_CORRECT_LIB_DIR(TBB_MALLOCPROXY_RELEASE_LIBRARY)
-mark_as_advanced(TBB_RELEASE_LIBRARY TBB_MALLOC_RELEASE_LIBRARY TBB_MALLOCPROXY_RELEASE_LIBRARY)
-
-#-- Look for debug libraries
-# Jiri: Changed the same way as for the release libraries.
-find_library(TBB_DEBUG_LIBRARY ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
-find_library(TBB_MALLOC_DEBUG_LIBRARY ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
-find_library(TBB_MALLOCPROXY_DEBUG_LIBRARY ${_TBB_LIB_MALLOCPROXY_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
-if(NOT TBB_DEBUG_LIBRARY OR NOT TBB_MALLOC_DEBUG_LIBRARY OR NOT TBB_MALLOCPROXY_DEBUG_LIBRARY)
- find_library(TBB_DEBUG_LIBRARY ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
- find_library(TBB_MALLOC_DEBUG_LIBRARY ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
- find_library(TBB_MALLOCPROXY_DEBUG_LIBRARY ${_TBB_LIB_MALLOCPROXY_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
- PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
-endif()
-
-# Jiri: Self-built TBB stores the debug libraries in a separate directory.
-# Extract path from TBB_DEBUG_LIBRARY name
-get_filename_component(TBB_DEBUG_LIBRARY_DIR ${TBB_DEBUG_LIBRARY} PATH)
-
-#TBB_CORRECT_LIB_DIR(TBB_DEBUG_LIBRARY)
-#TBB_CORRECT_LIB_DIR(TBB_MALLOC_DEBUG_LIBRARY)
-#TBB_CORRECT_LIB_DIR(TBB_MALLOCPROXY_DEBUG_LIBRARY)
-mark_as_advanced(TBB_DEBUG_LIBRARY TBB_MALLOC_DEBUG_LIBRARY TBB_MALLOCPROXY_DEBUG_LIBRARY)
-
-if (TBB_INCLUDE_DIR)
- if (TBB_RELEASE_LIBRARY)
- set (TBB_FOUND "YES")
-
- # NOTE: Removed because we don't want to link with the malloc_proxy by default
- #if (NOT "${TBB_MALLOCPROXY_RELEASE_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_RELEASE_LIBRARY-NOTFOUND")
- # mark_as_advanced(TBB_MALLOCPROXY_RELEASE_LIBRARY)
- # set (_TBB_MALLOCPROXY optimized ${TBB_MALLOCPROXY_RELEASE_LIBRARY})
- #endif (NOT "${TBB_MALLOCPROXY_RELEASE_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_RELEASE_LIBRARY-NOTFOUND")
- #if (NOT "${TBB_MALLOCPROXY_DEBUG_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND")
- # mark_as_advanced(TBB_MALLOCPROXY_DEBUG_LIBRARY)
- # set (_TBB_MALLOCPROXY ${_TBB_MALLOCPROXY} debug ${TBB_MALLOCPROXY_DEBUG_LIBRARY})
- #endif (NOT "${TBB_MALLOCPROXY_DEBUG_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND")
-
- # TBB release library
- set (ALL_TBB_LIBRARIES optimized ${TBB_RELEASE_LIBRARY})
-
- # TBB debug library found?
- if (TBB_DEBUG_LIBRARY)
- list(APPEND ALL_TBB_LIBRARIES debug ${TBB_DEBUG_LIBRARY})
- else (TBB_DEBUG_LIBRARY)
- # Otherwise, link with the release library even in debug mode
- list(APPEND ALL_TBB_LIBRARIES debug ${TBB_RELEASE_LIBRARY})
- endif (TBB_DEBUG_LIBRARY)
-
- # TBB malloc - release
- if (TBB_MALLOC_RELEASE_LIBRARY)
- list(APPEND ALL_TBB_LIBRARIES optimized ${TBB_MALLOC_RELEASE_LIBRARY})
-
- # TBB malloc - debug
- if (TBB_MALLOC_DEBUG_LIBRARY)
- list(APPEND ALL_TBB_LIBRARIES debug ${TBB_MALLOC_DEBUG_LIBRARY})
- else (TBB_MALLOC_DEBUG_LIBRARY)
- list(APPEND ALL_TBB_LIBRARIES debug ${TBB_MALLOC_RELEASE_LIBRARY})
- endif (TBB_MALLOC_DEBUG_LIBRARY)
- endif (TBB_MALLOC_RELEASE_LIBRARY)
-
- if(UNIX AND NOT APPLE)
- # On Fedora, code using TBB might need -pthread
-
- # First check without pthread
- try_TBB_with_pthread(TBB_without_pthread)
-
- if(NOT TBB_without_pthread)
- # Then check with -pthread
- try_TBB_with_pthread(TBB_with_pthread -pthread)
- if(TBB_with_pthread)
- list(APPEND ALL_TBB_LIBRARIES general -pthread)
- endif(TBB_with_pthread)
- endif(NOT TBB_without_pthread)
- endif(UNIX AND NOT APPLE)
-
- set (TBB_LIBRARIES ${ALL_TBB_LIBRARIES}
- CACHE PATH "TBB libraries" FORCE)
-
- # Include dirs
- set (TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE)
-
- # Library dirs
- if( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
- set (TBB_LIBRARY_DIRS
- ${TBB_RELEASE_LIBRARY_DIR}
- CACHE PATH "TBB library directories" FORCE)
- else( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
- set (TBB_LIBRARY_DIRS
- ${TBB_RELEASE_LIBRARY_DIR} ${TBB_DEBUG_LIBRARY_DIR}
- CACHE PATH "TBB library directories" FORCE)
- endif( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
-
- message(STATUS "Found Intel TBB")
- endif (TBB_RELEASE_LIBRARY)
-endif (TBB_INCLUDE_DIR)
-
-if (NOT TBB_FOUND)
- if(NOT TBB_FIND_QUIETLY)
- message("ERROR: Intel TBB NOT found! Please define the TBBROOT (or TBB_INSTALL_DIR) and/or TBB_ARCH_PLATFORM environment variables.")
- message(STATUS "Looked for Threading Building Blocks in ${_TBB_INSTALL_DIR}")
- endif(NOT TBB_FIND_QUIETLY)
- SET(TBB_INSTALL_DIR "TBB_INSTALL_DIR_NOT_FOUND" CACHE STRING "Intel TBB install directory")
- # do only throw fatal, if this pkg is REQUIRED
- if (TBB_FIND_REQUIRED)
- message(FATAL_ERROR "Could NOT find TBB library.")
- endif (TBB_FIND_REQUIRED)
-endif (NOT TBB_FOUND)
-
-endif (NOT _TBB_INSTALL_DIR)
-
-if (TBB_FOUND)
- set(TBB_INTERFACE_VERSION 0)
- FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS)
- STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}")
- set(TBB_INTERFACE_VERSION "${TBB_INTERFACE_VERSION}")
-endif (TBB_FOUND)
-
-set(TBB_USE_FILE "UseTBB")
-
-### ** Emacs settings **
-### Local Variables:
-### cmake-tab-width: 4
-### End:
+# Locate Intel Threading Building Blocks include paths and libraries
+# FindTBB.cmake can be found at https://code.google.com/p/findtbb/
+# Written by Hannes Hofmann <hannes.hofmann _at_ informatik.uni-erlangen.de>
+# Improvements by Gino van den Bergen <gino _at_ dtecta.com>,
+# Florian Uhlig <F.Uhlig _at_ gsi.de>,
+# Jiri Marsik <jiri.marsik89 _at_ gmail.com>
+
+# The MIT License
+#
+# Copyright (c) 2011 Hannes Hofmann
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+# GvdB: This module uses the environment variable TBB_ARCH_PLATFORM which defines architecture and compiler.
+# e.g. "ia32/vc8" or "em64t/cc4.1.0_libc2.4_kernel2.6.16.21"
+# TBB_ARCH_PLATFORM is set by the build script tbbvars[.bat|.sh|.csh], which can be found
+# in the TBB installation directory (TBB_INSTALL_DIR).
+#
+# GvdB: Mac OS X distribution places libraries directly in lib directory.
+#
+# For backwards compatibility, you may explicitely set the CMake variables TBB_ARCHITECTURE and TBB_COMPILER.
+# TBB_ARCHITECTURE [ ia32 | em64t | itanium ]
+# which architecture to use
+# TBB_COMPILER e.g. vc9 or cc3.2.3_libc2.3.2_kernel2.4.21 or cc4.0.1_os10.4.9
+# which compiler to use (detected automatically on Windows)
+
+# This module respects
+# TBB_INSTALL_DIR or $ENV{TBB21_INSTALL_DIR} or $ENV{TBB_INSTALL_DIR}
+
+# This module defines
+# TBB_INCLUDE_DIRS, where to find task_scheduler_init.h, etc.
+# TBB_LIBRARY_DIRS, where to find TBB libraries
+# TBB_INSTALL_DIR, the base TBB install directory.
+# TBB_LIBRARIES, all the following TBB libraries (both release and debug versions, using "optimized" and "debug" CMake keywords). Note that if the debug versions are not found, the release versions will be used instead for the debug mode.
+# TBB_RELEASE_LIBRARY, the TBB release library
+# TBB_MALLOC_RELEASE_LIBRARY, the TBB release malloc library
+# TBB_DEBUG_LIBRARY, the TBB debug library
+# TBB_MALLOC_DEBUG_LIBRARY, the TBB debug malloc library
+# TBB_FOUND, If false, don't try to use TBB.
+# TBB_INTERFACE_VERSION, as defined in tbb/tbb_stddef.h
+# TBB_MALLOCPROXY_DEBUG_LIBRARY, the TBB debug malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal)
+# TBB_MALLOCPROXY_RELEASE_LIBRARY, the TBB release malloc_proxy library (not included in TBB_LIBRARIES since it's optionnal)
+
+include(CheckCXXSourceCompiles)
+
+# Usage:
+# try_TBB_with_pthread(<result_var_name> [additional linker args...])
+function(try_TBB_with_pthread result_var)
+ set(TBB_try_ts_source "
+ #include <tbb/enumerable_thread_specific.h>
+ int main() {
+ tbb::enumerable_thread_specific<
+ bool*,
+ tbb::cache_aligned_allocator<bool*>,
+ tbb::ets_key_per_instance> grid;
+ }
+ ")
+ set(CMAKE_REQUIRED_LIBRARIES ${ALL_TBB_LIBRARIES} ${ARGN})
+ set(CMAKE_REQUIRED_INCLUDES ${TBB_INCLUDE_DIR})
+ check_cxx_source_compiles("${TBB_try_ts_source}" ${result_var})
+ set(${result_var} ${${result_var}} PARENT_SCOPE)
+endfunction(try_TBB_with_pthread)
+
+if (WIN32)
+ # has em64t/vc8 em64t/vc9
+ # has ia32/vc7.1 ia32/vc8 ia32/vc9
+ set(_TBB_DEFAULT_INSTALL_DIR "C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB")
+ set(_TBB_LIB_RELEASE_NAME "tbb")
+ set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
+ set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
+ set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
+ if (MSVC71)
+ set (_TBB_COMPILER "vc7.1")
+ endif(MSVC71)
+ if (MSVC80)
+ set(_TBB_COMPILER "vc8")
+ endif(MSVC80)
+ if (MSVC90)
+ set(_TBB_COMPILER "vc9")
+ endif(MSVC90)
+ if(MSVC10)
+ set(_TBB_COMPILER "vc10")
+ endif(MSVC10)
+ if(MSVC11)
+ set(_TBB_COMPILER "vc11")
+ endif(MSVC11)
+ if(MSVC12)
+ set(_TBB_COMPILER "vc12")
+ endif(MSVC12)
+ #note there was no MSVC13
+ if(MSVC14)
+ if(RUNNING_CGAL_AUTO_TEST)
+ set (TBB_FOUND "NO")
+ return()#binaries for TBB not publicly available when CGAL-4.7 is published
+ endif(RUNNING_CGAL_AUTO_TEST)
+ message(STATUS "[Warning] FindTBB.cmake: TBB 4.4 (latest available when CGAL-4.7 is published) does not provide support for MSVC 2015.")
+ endif(MSVC14)
+ # Todo: add other Windows compilers such as ICL.
+ set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
+endif (WIN32)
+
+if (UNIX)
+ if (APPLE)
+ # MAC
+ set(_TBB_DEFAULT_INSTALL_DIR "/Library/Frameworks/Intel_TBB.framework/Versions")
+ # libs: libtbb.dylib, libtbbmalloc.dylib, *_debug
+ set(_TBB_LIB_RELEASE_NAME "tbb")
+ set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
+ #set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
+ set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
+ #set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
+ # default flavor on apple: ia32/cc4.0.1_os10.4.9
+ # Jiri: There is no reason to presume there is only one flavor and
+ # that user's setting of variables should be ignored.
+ if(NOT TBB_COMPILER)
+ set(_TBB_COMPILER "cc4.0.1_os10.4.9")
+ elseif (NOT TBB_COMPILER)
+ set(_TBB_COMPILER ${TBB_COMPILER})
+ endif(NOT TBB_COMPILER)
+ if(NOT TBB_ARCHITECTURE)
+ set(_TBB_ARCHITECTURE "ia32")
+ elseif(NOT TBB_ARCHITECTURE)
+ set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
+ endif(NOT TBB_ARCHITECTURE)
+ else (APPLE)
+ # LINUX
+ set(_TBB_DEFAULT_INSTALL_DIR "/opt/intel/tbb" "/usr/local/include" "/usr/include")
+ set(_TBB_LIB_RELEASE_NAME "tbb")
+ set(_TBB_LIB_MALLOC_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc")
+ set(_TBB_LIB_MALLOCPROXY_RELEASE_NAME "${_TBB_LIB_RELEASE_NAME}malloc_proxy")
+ set(_TBB_LIB_DEBUG_NAME "${_TBB_LIB_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOC_DEBUG_NAME "${_TBB_LIB_MALLOC_RELEASE_NAME}_debug")
+ set(_TBB_LIB_MALLOCPROXY_DEBUG_NAME "${_TBB_LIB_MALLOCPROXY_RELEASE_NAME}_debug")
+ # has em64t/cc3.2.3_libc2.3.2_kernel2.4.21 em64t/cc3.3.3_libc2.3.3_kernel2.6.5 em64t/cc3.4.3_libc2.3.4_kernel2.6.9 em64t/cc4.1.0_libc2.4_kernel2.6.16.21
+ # has ia32/*
+ # has itanium/*
+ set(_TBB_COMPILER ${TBB_COMPILER})
+ set(_TBB_ARCHITECTURE ${TBB_ARCHITECTURE})
+ endif (APPLE)
+endif (UNIX)
+
+if (CMAKE_SYSTEM MATCHES "SunOS.*")
+# SUN
+# not yet supported
+# has em64t/cc3.4.3_kernel5.10
+# has ia32/*
+endif (CMAKE_SYSTEM MATCHES "SunOS.*")
+
+
+#-- Clear the public variables
+set (TBB_FOUND "NO")
+
+
+#-- Find TBB install dir and set ${_TBB_INSTALL_DIR} and cached ${TBB_INSTALL_DIR}
+# first: use CMake variable TBB_INSTALL_DIR
+if (TBB_INSTALL_DIR)
+ set (_TBB_INSTALL_DIR ${TBB_INSTALL_DIR})
+endif (TBB_INSTALL_DIR)
+# second: use environment variable
+if (NOT _TBB_INSTALL_DIR)
+ if (NOT "$ENV{TBBROOT}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBBROOT})
+ endif (NOT "$ENV{TBBROOT}" STREQUAL "")
+ if (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB_INSTALL_DIR})
+ endif (NOT "$ENV{TBB_INSTALL_DIR}" STREQUAL "")
+ # Intel recommends setting TBB21_INSTALL_DIR
+ if (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB21_INSTALL_DIR})
+ endif (NOT "$ENV{TBB21_INSTALL_DIR}" STREQUAL "")
+ if (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB22_INSTALL_DIR})
+ endif (NOT "$ENV{TBB22_INSTALL_DIR}" STREQUAL "")
+ if (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
+ set (_TBB_INSTALL_DIR $ENV{TBB30_INSTALL_DIR})
+ endif (NOT "$ENV{TBB30_INSTALL_DIR}" STREQUAL "")
+endif (NOT _TBB_INSTALL_DIR)
+# third: try to find path automatically
+if (NOT _TBB_INSTALL_DIR)
+ if (_TBB_DEFAULT_INSTALL_DIR)
+ set (_TBB_INSTALL_DIR ${_TBB_DEFAULT_INSTALL_DIR})
+ endif (_TBB_DEFAULT_INSTALL_DIR)
+endif (NOT _TBB_INSTALL_DIR)
+# sanity check
+if (NOT _TBB_INSTALL_DIR)
+ message ("ERROR: Unable to find Intel TBB install directory. ${_TBB_INSTALL_DIR}")
+else (NOT _TBB_INSTALL_DIR)
+# finally: set the cached CMake variable TBB_INSTALL_DIR
+if (NOT TBB_INSTALL_DIR)
+ set (TBB_INSTALL_DIR ${_TBB_INSTALL_DIR} CACHE PATH "Intel TBB install directory")
+ mark_as_advanced(TBB_INSTALL_DIR)
+endif (NOT TBB_INSTALL_DIR)
+
+
+#-- A macro to rewrite the paths of the library. This is necessary, because
+# find_library() always found the em64t/vc9 version of the TBB libs
+macro(TBB_CORRECT_LIB_DIR var_name)
+# if (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
+ string(REPLACE em64t "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
+# endif (NOT "${_TBB_ARCHITECTURE}" STREQUAL "em64t")
+ string(REPLACE ia32 "${_TBB_ARCHITECTURE}" ${var_name} ${${var_name}})
+ string(REPLACE vc7.1 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc8 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc9 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc10 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+ string(REPLACE vc11 "${_TBB_COMPILER}" ${var_name} ${${var_name}})
+endmacro(TBB_CORRECT_LIB_DIR var_content)
+
+
+#-- Look for include directory and set ${TBB_INCLUDE_DIR}
+set (TBB_INC_SEARCH_DIR ${_TBB_INSTALL_DIR}/include)
+# Jiri: tbbvars now sets the CPATH environment variable to the directory
+# containing the headers.
+# LR: search first with NO_DEFAULT_PATH...
+find_path(TBB_INCLUDE_DIR
+ tbb/task_scheduler_init.h
+ PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
+ NO_DEFAULT_PATH
+)
+if(NOT TBB_INCLUDE_DIR)
+# LR: ... and then search again with NO_DEFAULT_PATH if nothing was found in
+# hinted paths
+ find_path(TBB_INCLUDE_DIR
+ tbb/task_scheduler_init.h
+ PATHS ${TBB_INC_SEARCH_DIR} ENV CPATH
+ )
+endif()
+mark_as_advanced(TBB_INCLUDE_DIR)
+
+
+#-- Look for libraries
+# GvdB: $ENV{TBB_ARCH_PLATFORM} is set by the build script tbbvars[.bat|.sh|.csh]
+if (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
+ set (_TBB_LIBRARY_DIR
+ ${_TBB_INSTALL_DIR}/lib/$ENV{TBB_ARCH_PLATFORM}
+ ${_TBB_INSTALL_DIR}/$ENV{TBB_ARCH_PLATFORM}/lib
+ )
+endif (NOT $ENV{TBB_ARCH_PLATFORM} STREQUAL "")
+# Jiri: This block isn't mutually exclusive with the previous one
+# (hence no else), instead I test if the user really specified
+# the variables in question.
+if ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
+ # HH: deprecated
+ message(STATUS "[Warning] FindTBB.cmake: The use of TBB_ARCHITECTURE and TBB_COMPILER is deprecated and may not be supported in future versions. Please set \$ENV{TBB_ARCH_PLATFORM} (using tbbvars.[bat|csh|sh]).")
+ # Jiri: It doesn't hurt to look in more places, so I store the hints from
+ # ENV{TBB_ARCH_PLATFORM} and the TBB_ARCHITECTURE and TBB_COMPILER
+ # variables and search them both.
+ set (_TBB_LIBRARY_DIR "${_TBB_INSTALL_DIR}/${_TBB_ARCHITECTURE}/${_TBB_COMPILER}/lib" ${_TBB_LIBRARY_DIR})
+endif ((NOT ${TBB_ARCHITECTURE} STREQUAL "") AND (NOT ${TBB_COMPILER} STREQUAL ""))
+
+# GvdB: Mac OS X distribution places libraries directly in lib directory.
+list(APPEND _TBB_LIBRARY_DIR ${_TBB_INSTALL_DIR}/lib)
+
+# Jiri: No reason not to check the default paths. From recent versions,
+# tbbvars has started exporting the LIBRARY_PATH and LD_LIBRARY_PATH
+# variables, which now point to the directories of the lib files.
+# It all makes more sense to use the ${_TBB_LIBRARY_DIR} as a HINTS
+# argument instead of the implicit PATHS as it isn't hard-coded
+# but computed by system introspection. Searching the LIBRARY_PATH
+# and LD_LIBRARY_PATH environment variables is now even more important
+# that tbbvars doesn't export TBB_ARCH_PLATFORM and it facilitates
+# the use of TBB built from sources.
+# LR: search first with NO_DEFAULT_PATH...
+find_library(TBB_RELEASE_LIBRARY ${_TBB_LIB_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOC_RELEASE_LIBRARY ${_TBB_LIB_MALLOC_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOCPROXY_RELEASE_LIBRARY ${_TBB_LIB_MALLOCPROXY_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+if(NOT TBB_RELEASE_LIBRARY OR NOT TBB_MALLOC_RELEASE_LIBRARY OR NOT TBB_MALLOCPROXY_RELEASE_LIBRARY)
+# LR: ... and then search again with NO_DEFAULT_PATH if nothing was found
+# in hinted paths
+ find_library(TBB_RELEASE_LIBRARY ${_TBB_LIB_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOC_RELEASE_LIBRARY ${_TBB_LIB_MALLOC_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOCPROXY_RELEASE_LIBRARY ${_TBB_LIB_MALLOCPROXY_RELEASE_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+endif()
+
+#Extract path from TBB_RELEASE_LIBRARY name
+get_filename_component(TBB_RELEASE_LIBRARY_DIR ${TBB_RELEASE_LIBRARY} PATH)
+
+#TBB_CORRECT_LIB_DIR(TBB_RELEASE_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOC_RELEASE_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOCPROXY_RELEASE_LIBRARY)
+mark_as_advanced(TBB_RELEASE_LIBRARY TBB_MALLOC_RELEASE_LIBRARY TBB_MALLOCPROXY_RELEASE_LIBRARY)
+
+#-- Look for debug libraries
+# Jiri: Changed the same way as for the release libraries.
+find_library(TBB_DEBUG_LIBRARY ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOC_DEBUG_LIBRARY ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+find_library(TBB_MALLOCPROXY_DEBUG_LIBRARY ${_TBB_LIB_MALLOCPROXY_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
+if(NOT TBB_DEBUG_LIBRARY OR NOT TBB_MALLOC_DEBUG_LIBRARY OR NOT TBB_MALLOCPROXY_DEBUG_LIBRARY)
+ find_library(TBB_DEBUG_LIBRARY ${_TBB_LIB_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOC_DEBUG_LIBRARY ${_TBB_LIB_MALLOC_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+ find_library(TBB_MALLOCPROXY_DEBUG_LIBRARY ${_TBB_LIB_MALLOCPROXY_DEBUG_NAME} HINTS ${_TBB_LIBRARY_DIR}
+ PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH)
+endif()
+
+# Jiri: Self-built TBB stores the debug libraries in a separate directory.
+# Extract path from TBB_DEBUG_LIBRARY name
+get_filename_component(TBB_DEBUG_LIBRARY_DIR ${TBB_DEBUG_LIBRARY} PATH)
+
+#TBB_CORRECT_LIB_DIR(TBB_DEBUG_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOC_DEBUG_LIBRARY)
+#TBB_CORRECT_LIB_DIR(TBB_MALLOCPROXY_DEBUG_LIBRARY)
+mark_as_advanced(TBB_DEBUG_LIBRARY TBB_MALLOC_DEBUG_LIBRARY TBB_MALLOCPROXY_DEBUG_LIBRARY)
+
+if (TBB_INCLUDE_DIR)
+ if (TBB_RELEASE_LIBRARY)
+ set (TBB_FOUND "YES")
+
+ # NOTE: Removed because we don't want to link with the malloc_proxy by default
+ #if (NOT "${TBB_MALLOCPROXY_RELEASE_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_RELEASE_LIBRARY-NOTFOUND")
+ # mark_as_advanced(TBB_MALLOCPROXY_RELEASE_LIBRARY)
+ # set (_TBB_MALLOCPROXY optimized ${TBB_MALLOCPROXY_RELEASE_LIBRARY})
+ #endif (NOT "${TBB_MALLOCPROXY_RELEASE_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_RELEASE_LIBRARY-NOTFOUND")
+ #if (NOT "${TBB_MALLOCPROXY_DEBUG_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND")
+ # mark_as_advanced(TBB_MALLOCPROXY_DEBUG_LIBRARY)
+ # set (_TBB_MALLOCPROXY ${_TBB_MALLOCPROXY} debug ${TBB_MALLOCPROXY_DEBUG_LIBRARY})
+ #endif (NOT "${TBB_MALLOCPROXY_DEBUG_LIBRARY}" STREQUAL "TBB_MALLOCPROXY_DEBUG_LIBRARY-NOTFOUND")
+
+ # TBB release library
+ set (ALL_TBB_LIBRARIES optimized ${TBB_RELEASE_LIBRARY})
+
+ # TBB debug library found?
+ if (TBB_DEBUG_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_DEBUG_LIBRARY})
+ else (TBB_DEBUG_LIBRARY)
+ # Otherwise, link with the release library even in debug mode
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_RELEASE_LIBRARY})
+ endif (TBB_DEBUG_LIBRARY)
+
+ # TBB malloc - release
+ if (TBB_MALLOC_RELEASE_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES optimized ${TBB_MALLOC_RELEASE_LIBRARY})
+
+ # TBB malloc - debug
+ if (TBB_MALLOC_DEBUG_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_MALLOC_DEBUG_LIBRARY})
+ else (TBB_MALLOC_DEBUG_LIBRARY)
+ list(APPEND ALL_TBB_LIBRARIES debug ${TBB_MALLOC_RELEASE_LIBRARY})
+ endif (TBB_MALLOC_DEBUG_LIBRARY)
+ endif (TBB_MALLOC_RELEASE_LIBRARY)
+
+ if(UNIX AND NOT APPLE)
+ # On Fedora, code using TBB might need -pthread
+
+ # First check without pthread
+ try_TBB_with_pthread(TBB_without_pthread)
+
+ if(NOT TBB_without_pthread)
+ # Then check with -pthread
+ try_TBB_with_pthread(TBB_with_pthread -pthread)
+ if(TBB_with_pthread)
+ list(APPEND ALL_TBB_LIBRARIES general -pthread)
+ endif(TBB_with_pthread)
+ endif(NOT TBB_without_pthread)
+ endif(UNIX AND NOT APPLE)
+
+ set (TBB_LIBRARIES ${ALL_TBB_LIBRARIES}
+ CACHE PATH "TBB libraries" FORCE)
+
+ # Include dirs
+ set (TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR} CACHE PATH "TBB include directory" FORCE)
+
+ # Library dirs
+ if( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
+ set (TBB_LIBRARY_DIRS
+ ${TBB_RELEASE_LIBRARY_DIR}
+ CACHE PATH "TBB library directories" FORCE)
+ else( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
+ set (TBB_LIBRARY_DIRS
+ ${TBB_RELEASE_LIBRARY_DIR} ${TBB_DEBUG_LIBRARY_DIR}
+ CACHE PATH "TBB library directories" FORCE)
+ endif( "${TBB_DEBUG_LIBRARY_DIR}" STREQUAL "" OR "${TBB_RELEASE_LIBRARY_DIR}" STREQUAL "${TBB_DEBUG_LIBRARY_DIR}" )
+
+ message(STATUS "Found Intel TBB")
+ endif (TBB_RELEASE_LIBRARY)
+endif (TBB_INCLUDE_DIR)
+
+if (NOT TBB_FOUND)
+ if(NOT TBB_FIND_QUIETLY)
+ message("ERROR: Intel TBB NOT found! Please define the TBBROOT (or TBB_INSTALL_DIR) and/or TBB_ARCH_PLATFORM environment variables.")
+ message(STATUS "Looked for Threading Building Blocks in ${_TBB_INSTALL_DIR}")
+ endif(NOT TBB_FIND_QUIETLY)
+ SET(TBB_INSTALL_DIR "TBB_INSTALL_DIR_NOT_FOUND" CACHE STRING "Intel TBB install directory")
+ # do only throw fatal, if this pkg is REQUIRED
+ if (TBB_FIND_REQUIRED)
+ message(FATAL_ERROR "Could NOT find TBB library.")
+ endif (TBB_FIND_REQUIRED)
+endif (NOT TBB_FOUND)
+
+endif (NOT _TBB_INSTALL_DIR)
+
+if (TBB_FOUND)
+ set(TBB_INTERFACE_VERSION 0)
+ FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _TBB_VERSION_CONTENTS)
+ STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_TBB_VERSION_CONTENTS}")
+ set(TBB_INTERFACE_VERSION "${TBB_INTERFACE_VERSION}")
+endif (TBB_FOUND)
+
+set(TBB_USE_FILE "UseTBB")
+
+### ** Emacs settings **
+### Local Variables:
+### cmake-tab-width: 4
+### End: