Convert all CRLF files to LF

This commit is contained in:
Sébastien Loriot 2013-12-11 07:11:52 +01:00
parent 9b1c8ae9ca
commit e80216c757
7 changed files with 993 additions and 993 deletions

View File

@ -1,201 +1,201 @@
#include "config.h" #include "config.h"
#include "Scene_points_with_normal_item.h" #include "Scene_points_with_normal_item.h"
#include "Polyhedron_demo_plugin_helper.h" #include "Polyhedron_demo_plugin_helper.h"
#include "Polyhedron_demo_plugin_interface.h" #include "Polyhedron_demo_plugin_interface.h"
#include <CGAL/pca_estimate_normals.h> #include <CGAL/pca_estimate_normals.h>
#include <CGAL/jet_estimate_normals.h> #include <CGAL/jet_estimate_normals.h>
#include <CGAL/mst_orient_normals.h> #include <CGAL/mst_orient_normals.h>
#include <CGAL/Timer.h> #include <CGAL/Timer.h>
#include <CGAL/Memory_sizer.h> #include <CGAL/Memory_sizer.h>
#include <QObject> #include <QObject>
#include <QAction> #include <QAction>
#include <QMainWindow> #include <QMainWindow>
#include <QApplication> #include <QApplication>
#include <QtPlugin> #include <QtPlugin>
#include <QInputDialog> #include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
#include "ui_Polyhedron_demo_normal_estimation_plugin.h" #include "ui_Polyhedron_demo_normal_estimation_plugin.h"
class Polyhedron_demo_normal_estimation_plugin : class Polyhedron_demo_normal_estimation_plugin :
public QObject, public QObject,
public Polyhedron_demo_plugin_helper public Polyhedron_demo_plugin_helper
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(Polyhedron_demo_plugin_interface) Q_INTERFACES(Polyhedron_demo_plugin_interface)
QAction* actionNormalEstimation; QAction* actionNormalEstimation;
QAction* actionNormalInversion; QAction* actionNormalInversion;
public: public:
void init(QMainWindow* mainWindow, Scene_interface* scene_interface) { void init(QMainWindow* mainWindow, Scene_interface* scene_interface) {
actionNormalEstimation = new QAction(tr("Normal estimation of point set"), mainWindow); actionNormalEstimation = new QAction(tr("Normal estimation of point set"), mainWindow);
actionNormalEstimation->setObjectName("actionNormalEstimation"); actionNormalEstimation->setObjectName("actionNormalEstimation");
actionNormalInversion = new QAction(tr("Inverse normal orientation"), mainWindow); actionNormalInversion = new QAction(tr("Inverse normal orientation"), mainWindow);
actionNormalInversion->setObjectName("actionNormalInversion"); actionNormalInversion->setObjectName("actionNormalInversion");
Polyhedron_demo_plugin_helper::init(mainWindow, scene_interface); Polyhedron_demo_plugin_helper::init(mainWindow, scene_interface);
} }
QList<QAction*> actions() const { QList<QAction*> actions() const {
return QList<QAction*>() << actionNormalEstimation << actionNormalInversion; return QList<QAction*>() << actionNormalEstimation << actionNormalInversion;
} }
bool applicable() const { bool applicable() const {
return qobject_cast<Scene_points_with_normal_item*>(scene->item(scene->mainSelectionIndex())); return qobject_cast<Scene_points_with_normal_item*>(scene->item(scene->mainSelectionIndex()));
} }
public slots: public slots:
void on_actionNormalEstimation_triggered(); void on_actionNormalEstimation_triggered();
void on_actionNormalInversion_triggered(); void on_actionNormalInversion_triggered();
}; // end PS_demo_smoothing_plugin }; // end PS_demo_smoothing_plugin
class Point_set_demo_normal_estimation_dialog : public QDialog, private Ui::NormalEstimationDialog class Point_set_demo_normal_estimation_dialog : public QDialog, private Ui::NormalEstimationDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
Point_set_demo_normal_estimation_dialog(QWidget* /*parent*/ = 0) Point_set_demo_normal_estimation_dialog(QWidget* /*parent*/ = 0)
{ {
setupUi(this); setupUi(this);
} }
QString directionMethod() const { return m_inputDirection->currentText(); } QString directionMethod() const { return m_inputDirection->currentText(); }
int directionNbNeighbors() const { return m_inputNbNeighborsDirection->value(); } int directionNbNeighbors() const { return m_inputNbNeighborsDirection->value(); }
QString orientationMethod() const { return m_inputOrientation->currentText(); } QString orientationMethod() const { return m_inputOrientation->currentText(); }
int orientationNbNeighbors() const { return m_inputNbNeighborsOrientation->value(); } int orientationNbNeighbors() const { return m_inputNbNeighborsOrientation->value(); }
}; };
void Polyhedron_demo_normal_estimation_plugin::on_actionNormalInversion_triggered() void Polyhedron_demo_normal_estimation_plugin::on_actionNormalInversion_triggered()
{ {
const Scene_interface::Item_id index = scene->mainSelectionIndex(); const Scene_interface::Item_id index = scene->mainSelectionIndex();
Scene_points_with_normal_item* item = Scene_points_with_normal_item* item =
qobject_cast<Scene_points_with_normal_item*>(scene->item(index)); qobject_cast<Scene_points_with_normal_item*>(scene->item(index));
if(item) if(item)
{ {
// Gets point set // Gets point set
Point_set* points = item->point_set(); Point_set* points = item->point_set();
if(points == NULL) if(points == NULL)
return; return;
for(Point_set::iterator it = points->begin(); it != points->end(); ++it){ for(Point_set::iterator it = points->begin(); it != points->end(); ++it){
it->normal() = -1 * it->normal(); it->normal() = -1 * it->normal();
} }
} }
} }
void Polyhedron_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered() void Polyhedron_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered()
{ {
const Scene_interface::Item_id index = scene->mainSelectionIndex(); const Scene_interface::Item_id index = scene->mainSelectionIndex();
Scene_points_with_normal_item* item = Scene_points_with_normal_item* item =
qobject_cast<Scene_points_with_normal_item*>(scene->item(index)); qobject_cast<Scene_points_with_normal_item*>(scene->item(index));
if(item) if(item)
{ {
// Gets point set // Gets point set
Point_set* points = item->point_set(); Point_set* points = item->point_set();
if(points == NULL) if(points == NULL)
return; return;
// Gets options // Gets options
Point_set_demo_normal_estimation_dialog dialog; Point_set_demo_normal_estimation_dialog dialog;
if(!dialog.exec()) if(!dialog.exec())
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
// First point to delete // First point to delete
Point_set::iterator first_unoriented_point = points->end(); Point_set::iterator first_unoriented_point = points->end();
//*************************************** //***************************************
// normal estimation // normal estimation
//*************************************** //***************************************
if (dialog.directionMethod() == "plane") if (dialog.directionMethod() == "plane")
{ {
CGAL::Timer task_timer; task_timer.start(); CGAL::Timer task_timer; task_timer.start();
std::cerr << "Estimates normal direction by PCA (k=" << dialog.directionNbNeighbors() <<")...\n"; std::cerr << "Estimates normal direction by PCA (k=" << dialog.directionNbNeighbors() <<")...\n";
// Estimates normals direction. // Estimates normals direction.
CGAL::pca_estimate_normals(points->begin(), points->end(), CGAL::pca_estimate_normals(points->begin(), points->end(),
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()), CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
dialog.directionNbNeighbors()); dialog.directionNbNeighbors());
// Mark all normals as unoriented // Mark all normals as unoriented
first_unoriented_point = points->begin(); first_unoriented_point = points->begin();
std::size_t memory = CGAL::Memory_sizer().virtual_size(); std::size_t memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, " std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated" << (memory>>20) << " Mb allocated"
<< std::endl; << std::endl;
} }
else if (dialog.directionMethod() == "quadric") else if (dialog.directionMethod() == "quadric")
{ {
CGAL::Timer task_timer; task_timer.start(); CGAL::Timer task_timer; task_timer.start();
std::cerr << "Estimates normal direction by Jet Fitting (k=" << dialog.directionNbNeighbors() <<")...\n"; std::cerr << "Estimates normal direction by Jet Fitting (k=" << dialog.directionNbNeighbors() <<")...\n";
// Estimates normals direction. // Estimates normals direction.
CGAL::jet_estimate_normals(points->begin(), points->end(), CGAL::jet_estimate_normals(points->begin(), points->end(),
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()), CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
dialog.directionNbNeighbors()); dialog.directionNbNeighbors());
// Mark all normals as unoriented // Mark all normals as unoriented
first_unoriented_point = points->begin(); first_unoriented_point = points->begin();
std::size_t memory = CGAL::Memory_sizer().virtual_size(); std::size_t memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, " std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated" << (memory>>20) << " Mb allocated"
<< std::endl; << std::endl;
} }
//*************************************** //***************************************
// normal orientation // normal orientation
//*************************************** //***************************************
CGAL::Timer task_timer; task_timer.start(); CGAL::Timer task_timer; task_timer.start();
std::cerr << "Orient normals with a Minimum Spanning Tree (k=" << dialog.orientationNbNeighbors() << ")...\n"; std::cerr << "Orient normals with a Minimum Spanning Tree (k=" << dialog.orientationNbNeighbors() << ")...\n";
// Tries to orient normals // Tries to orient normals
first_unoriented_point = first_unoriented_point =
CGAL::mst_orient_normals(points->begin(), points->end(), CGAL::mst_orient_normals(points->begin(), points->end(),
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()), CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
dialog.orientationNbNeighbors()); dialog.orientationNbNeighbors());
std::size_t nb_unoriented_normals = std::distance(first_unoriented_point, points->end()); std::size_t nb_unoriented_normals = std::distance(first_unoriented_point, points->end());
std::size_t memory = CGAL::Memory_sizer().virtual_size(); std::size_t memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Orient normals: " << nb_unoriented_normals << " point(s) with an unoriented normal are selected (" std::cerr << "Orient normals: " << nb_unoriented_normals << " point(s) with an unoriented normal are selected ("
<< task_timer.time() << " seconds, " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated)" << (memory>>20) << " Mb allocated)"
<< std::endl; << std::endl;
// Selects points with an unoriented normal // Selects points with an unoriented normal
points->select(points->begin(), points->end(), false); points->select(points->begin(), points->end(), false);
points->select(first_unoriented_point, points->end(), true); points->select(first_unoriented_point, points->end(), true);
// Updates scene // Updates scene
scene->itemChanged(index); scene->itemChanged(index);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
// Warns user // Warns user
if (nb_unoriented_normals > 0) if (nb_unoriented_normals > 0)
{ {
QMessageBox::information(NULL, QMessageBox::information(NULL,
tr("Points with an unoriented normal"), tr("Points with an unoriented normal"),
tr("%1 point(s) with an unoriented normal are selected.\nPlease orient them or remove them before running Poisson reconstruction.") tr("%1 point(s) with an unoriented normal are selected.\nPlease orient them or remove them before running Poisson reconstruction.")
.arg(nb_unoriented_normals)); .arg(nb_unoriented_normals));
} }
} }
} }
Q_EXPORT_PLUGIN2(Polyhedron_demo_normal_estimation_plugin, Polyhedron_demo_normal_estimation_plugin) Q_EXPORT_PLUGIN2(Polyhedron_demo_normal_estimation_plugin, Polyhedron_demo_normal_estimation_plugin)
#include "Polyhedron_demo_normal_estimation_plugin.moc" #include "Polyhedron_demo_normal_estimation_plugin.moc"

View File

@ -1,188 +1,188 @@
#! /bin/sh #! /bin/sh
# #
# ============================================================================= # =============================================================================
# $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Scripts/developer_scripts/create_cgal_test $ # $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Scripts/developer_scripts/create_cgal_test $
# $Id: create_cgal_test 36975 2007-03-09 22:52:40Z spion $ # $Id: create_cgal_test 36975 2007-03-09 22:52:40Z spion $
# #
# author(s) : Wieger Wesselink, Geert-Jan Giezeman # author(s) : Wieger Wesselink, Geert-Jan Giezeman
# #
# coordinator : Utrecht University # coordinator : Utrecht University
# ============================================================================= # =============================================================================
# #
# This script creates a cgal_test_with_cmake script with entries for all .C and .cpp # This script creates a cgal_test_with_cmake script with entries for all .C and .cpp
# files in the current test directory. # files in the current test directory.
VERSION=1.1 VERSION=1.1
DO_RUN="y" DO_RUN="y"
usage() usage()
{ {
echo 'Usage : create_cgal_test [--no-run]' echo 'Usage : create_cgal_test [--no-run]'
echo echo
echo ' --help : prints this usage help' echo ' --help : prints this usage help'
echo ' --no-run : produces a cgal_test_with_cmake script that only does compilation, no execution' echo ' --no-run : produces a cgal_test_with_cmake script that only does compilation, no execution'
exit exit
} }
while [ $1 ]; do while [ $1 ]; do
case "$1" in case "$1" in
-h|-help|--h|--help) -h|-help|--h|--help)
usage; usage;
;; ;;
--no-run) --no-run)
DO_RUN="" DO_RUN=""
shift; continue shift; continue
;; ;;
*) *)
echo "Unknown option: $1" echo "Unknown option: $1"
usage usage
;; ;;
esac esac
done done
header() header()
{ {
echo "#---------------------------------------------------------------------#" echo "#---------------------------------------------------------------------#"
echo "# $1" echo "# $1"
echo "#---------------------------------------------------------------------#" echo "#---------------------------------------------------------------------#"
} }
create_script() create_script()
{ {
echo "#! /bin/sh" echo "#! /bin/sh"
echo echo
echo "# This is a script for the CGAL test suite. Such a script must obey" echo "# This is a script for the CGAL test suite. Such a script must obey"
echo "# the following rules:" echo "# the following rules:"
echo "#" echo "#"
echo "# - the name of the script is cgal_test_with_cmake" echo "# - the name of the script is cgal_test_with_cmake"
echo "# - for every target two one line messages are written to the file 'error.txt'" echo "# - for every target two one line messages are written to the file 'error.txt'"
echo "# the first one indicates if the compilation was successful" echo "# the first one indicates if the compilation was successful"
echo "# the second one indicates if the execution was successful" echo "# the second one indicates if the execution was successful"
echo "# if one of the two was not successful, the line should start with 'ERROR:'" echo "# if one of the two was not successful, the line should start with 'ERROR:'"
echo "# - running the script should not require any user interaction" echo "# - running the script should not require any user interaction"
echo "# - the script should clean up object files and executables" echo "# - the script should clean up object files and executables"
echo echo
cat << EOF cat << EOF
ERRORFILE=error.txt ERRORFILE=error.txt
DO_RUN=${DO_RUN} DO_RUN=${DO_RUN}
if [ -z "\${MAKE_CMD}" ]; then if [ -z "\${MAKE_CMD}" ]; then
MAKE_CMD=make MAKE_CMD=make
fi fi
NEED_CLEAN= NEED_CLEAN=
EOF EOF
header "configure" header "configure"
cat << EOF cat << EOF
configure() configure()
{ {
echo "Configuring... " echo "Configuring... "
if eval 'cmake "\$CMAKE_GENERATOR" -DRUNNING_CGAL_AUTO_TEST=TRUE \\ if eval 'cmake "\$CMAKE_GENERATOR" -DRUNNING_CGAL_AUTO_TEST=TRUE \\
-DCGAL_DIR="\$CGAL_DIR" \\ -DCGAL_DIR="\$CGAL_DIR" \\
.' ; then .' ; then
echo " successful configuration" >> \$ERRORFILE echo " successful configuration" >> \$ERRORFILE
else else
echo " ERROR: configuration" >> \$ERRORFILE echo " ERROR: configuration" >> \$ERRORFILE
fi fi
} }
EOF EOF
header "compile_and_run <target>" header "compile_and_run <target>"
cat << EOF cat << EOF
compile_and_run() compile_and_run()
{ {
echo "Compiling \$1 ... " echo "Compiling \$1 ... "
SUCCESS="y" SUCCESS="y"
if eval '\${MAKE_CMD} VERBOSE=ON -fMakefile \$1' ; then if eval '\${MAKE_CMD} VERBOSE=ON -fMakefile \$1' ; then
echo " successful compilation of \$1" >> \$ERRORFILE echo " successful compilation of \$1" >> \$ERRORFILE
else else
echo " ERROR: compilation of \$1" >> \$ERRORFILE echo " ERROR: compilation of \$1" >> \$ERRORFILE
SUCCESS="" SUCCESS=""
fi fi
if [ -n "\$DO_RUN" ] ; then if [ -n "\$DO_RUN" ] ; then
if [ -n "\${SUCCESS}" ] ; then if [ -n "\${SUCCESS}" ] ; then
OUTPUTFILE=ProgramOutput.\$1.\$PLATFORM OUTPUTFILE=ProgramOutput.\$1.\$PLATFORM
rm -f \$OUTPUTFILE rm -f \$OUTPUTFILE
COMMAND="./\$1" COMMAND="./\$1"
if [ -f \$1.cmd ] ; then if [ -f \$1.cmd ] ; then
COMMAND="\$COMMAND \`cat \$1.cmd\`" COMMAND="\$COMMAND \`cat \$1.cmd\`"
fi fi
if [ -f \$1.cin ] ; then if [ -f \$1.cin ] ; then
COMMAND="cat \$1.cin | \$COMMAND" COMMAND="cat \$1.cin | \$COMMAND"
fi fi
echo "Executing \$1 ... " echo "Executing \$1 ... "
echo echo
ulimit -t 3600 2> /dev/null ulimit -t 3600 2> /dev/null
if eval \$COMMAND > \$OUTPUTFILE 2>&1 ; then if eval \$COMMAND > \$OUTPUTFILE 2>&1 ; then
echo " successful execution of \$1" >> \$ERRORFILE echo " successful execution of \$1" >> \$ERRORFILE
else else
echo " ERROR: execution of \$1" >> \$ERRORFILE echo " ERROR: execution of \$1" >> \$ERRORFILE
fi fi
else else
echo " ERROR: not executed \$1" >> \$ERRORFILE echo " ERROR: not executed \$1" >> \$ERRORFILE
fi fi
fi fi
} }
EOF EOF
header "remove the previous error file" header "remove the previous error file"
cat << EOF cat << EOF
rm -f \$ERRORFILE rm -f \$ERRORFILE
touch \$ERRORFILE touch \$ERRORFILE
EOF EOF
header "configure, compile and run the tests" header "configure, compile and run the tests"
cat << EOF cat << EOF
configure configure
if [ \$# -ne 0 ] ; then if [ \$# -ne 0 ] ; then
for file in \$* ; do for file in \$* ; do
compile_and_run \$file compile_and_run \$file
done done
else else
echo "Run all tests." echo "Run all tests."
EOF EOF
for file in `ls *.C *.cpp 2>/dev/null | sort` ; do for file in `ls *.C *.cpp 2>/dev/null | sort` ; do
if [ -n "`grep '\<main\>' $file`" ] ; then if [ -n "`grep '\<main\>' $file`" ] ; then
tmp=`basename $file .C` tmp=`basename $file .C`
tmp=`basename $tmp .cpp` tmp=`basename $tmp .cpp`
cat <<EOF cat <<EOF
if grep -qE "^${tmp}:" Makefile; then if grep -qE "^${tmp}:" Makefile; then
compile_and_run $tmp compile_and_run $tmp
NEED_CLEAN=y NEED_CLEAN=y
fi fi
EOF EOF
fi fi
done done
cat << EOF cat << EOF
fi fi
# #
# The clean target generated by CMake under cygwin # The clean target generated by CMake under cygwin
# always fails for some reason # always fails for some reason
# #
if [ -n "\${NEED_CLEAN}" ]; then if [ -n "\${NEED_CLEAN}" ]; then
if ! ( uname | grep -q "CYGWIN" ) ; then if ! ( uname | grep -q "CYGWIN" ) ; then
\${MAKE_CMD} -fMakefile clean \${MAKE_CMD} -fMakefile clean
fi fi
fi fi
EOF EOF
} }
if [ -f cgal_test_with_cmake ] ; then if [ -f cgal_test_with_cmake ] ; then
echo "moving cgal_test_with_cmake to cgal_test_with_cmake.bak ..." echo "moving cgal_test_with_cmake to cgal_test_with_cmake.bak ..."
mv -f cgal_test_with_cmake cgal_test_with_cmake.bak mv -f cgal_test_with_cmake cgal_test_with_cmake.bak
fi fi
create_script > cgal_test_with_cmake create_script > cgal_test_with_cmake
chmod 755 cgal_test_with_cmake chmod 755 cgal_test_with_cmake
echo "created cgal_test_with_cmake, version $VERSION, in $PWD ..." echo "created cgal_test_with_cmake, version $VERSION, in $PWD ..."

View File

@ -1,252 +1,252 @@
// Copyright (c) 2012 INRIA Bordeaux Sud-Ouest (France), All rights reserved. // Copyright (c) 2012 INRIA Bordeaux Sud-Ouest (France), All rights reserved.
// //
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as // modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License, // published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version. // or (at your option) any later version.
// //
// Licensees holding a valid commercial license may use this file in // Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software. // accordance with the commercial license agreement provided with the software.
// //
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// //
// $URL$ // $URL$
// $Id$ // $Id$
// //
// Author(s) : Gael Guennebaud // Author(s) : Gael Guennebaud
#ifndef CGAL_EIGEN_MATRIX_H #ifndef CGAL_EIGEN_MATRIX_H
#define CGAL_EIGEN_MATRIX_H #define CGAL_EIGEN_MATRIX_H
#include <CGAL/basic.h> // include basic.h before testing #defines #include <CGAL/basic.h> // include basic.h before testing #defines
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
#include <Eigen/Sparse> #include <Eigen/Sparse>
namespace CGAL { namespace CGAL {
/// The class Eigen_sparse_matrix /// The class Eigen_sparse_matrix
/// is a C++ wrapper around Eigen' matrix type SparseMatrix<>. /// is a C++ wrapper around Eigen' matrix type SparseMatrix<>.
/// ///
/// This kind of matrix can be either symmetric or not. Symmetric /// This kind of matrix can be either symmetric or not. Symmetric
/// matrices store only the lower triangle. /// matrices store only the lower triangle.
/// ///
/// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d::Matrix concept. /// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d::Matrix concept.
/// ///
/// @heading Parameters: /// @heading Parameters:
/// @param T Number type. /// @param T Number type.
template<class T> template<class T>
struct Eigen_sparse_matrix struct Eigen_sparse_matrix
{ {
// Public types // Public types
public: public:
typedef Eigen::SparseMatrix<T> EigenType; typedef Eigen::SparseMatrix<T> EigenType;
typedef T NT; typedef T NT;
// Public operations // Public operations
public: public:
/// Create a square matrix initialized with zeros. /// Create a square matrix initialized with zeros.
Eigen_sparse_matrix(int dim, ///< Matrix dimension. Eigen_sparse_matrix(int dim, ///< Matrix dimension.
bool is_symmetric = false) ///< Symmetric/hermitian? bool is_symmetric = false) ///< Symmetric/hermitian?
: m_is_already_built(false), m_matrix(dim,dim) : m_is_already_built(false), m_matrix(dim,dim)
{ {
CGAL_precondition(dim > 0); CGAL_precondition(dim > 0);
m_is_symmetric = is_symmetric; m_is_symmetric = is_symmetric;
// reserve memory for a regular 3D grid // reserve memory for a regular 3D grid
m_triplets.reserve(dim); m_triplets.reserve(dim);
} }
/// Create a rectangular matrix initialized with zeros. /// Create a rectangular matrix initialized with zeros.
/// ///
/// @commentheading Precondition: rows == columns if is_symmetric is true. /// @commentheading Precondition: rows == columns if is_symmetric is true.
Eigen_sparse_matrix(int rows, ///< Number of rows. Eigen_sparse_matrix(int rows, ///< Number of rows.
int columns, ///< Number of columns. int columns, ///< Number of columns.
bool is_symmetric = false) ///< Symmetric/hermitian? bool is_symmetric = false) ///< Symmetric/hermitian?
: m_is_already_built(false), m_matrix(rows,columns) : m_is_already_built(false), m_matrix(rows,columns)
{ {
CGAL_precondition(rows > 0); CGAL_precondition(rows > 0);
CGAL_precondition(columns > 0); CGAL_precondition(columns > 0);
if (m_is_symmetric) { if (m_is_symmetric) {
CGAL_precondition(rows == columns); CGAL_precondition(rows == columns);
} }
m_is_symmetric = is_symmetric; m_is_symmetric = is_symmetric;
// reserve memory for a regular 3D grid // reserve memory for a regular 3D grid
m_triplets.reserve(rows); m_triplets.reserve(rows);
} }
/// Delete this object and the wrapped TAUCS matrix. /// Delete this object and the wrapped TAUCS matrix.
~Eigen_sparse_matrix() ~Eigen_sparse_matrix()
{ {
} }
/// Return the matrix number of rows /// Return the matrix number of rows
int row_dimension() const { return m_matrix.rows(); } int row_dimension() const { return m_matrix.rows(); }
/// Return the matrix number of columns /// Return the matrix number of columns
int column_dimension() const { return m_matrix.cols(); } int column_dimension() const { return m_matrix.cols(); }
/// Write access to a matrix coefficient: a_ij <- val. /// Write access to a matrix coefficient: a_ij <- val.
/// ///
/// Optimizations: /// Optimizations:
/// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle /// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle
/// set_coef() does nothing if (i, j) belongs to the upper triangle. /// set_coef() does nothing if (i, j) belongs to the upper triangle.
/// - Caller can optimize this call by setting 'new_coef' to true /// - Caller can optimize this call by setting 'new_coef' to true
/// if the coefficient does not already exist in the matrix. /// if the coefficient does not already exist in the matrix.
/// ///
/// @commentheading Preconditions: /// @commentheading Preconditions:
/// - 0 <= i < row_dimension(). /// - 0 <= i < row_dimension().
/// - 0 <= j < column_dimension(). /// - 0 <= j < column_dimension().
void set_coef(int i, int j, T val, bool new_coef = false) void set_coef(int i, int j, T val, bool new_coef = false)
{ {
CGAL_precondition(i < row_dimension()); CGAL_precondition(i < row_dimension());
CGAL_precondition(j < column_dimension()); CGAL_precondition(j < column_dimension());
if (m_is_symmetric && (j > i)) if (m_is_symmetric && (j > i))
return; return;
if (m_is_already_built) if (m_is_already_built)
m_matrix.coeffRef(i,j)=val; m_matrix.coeffRef(i,j)=val;
else else
{ {
if ( new_coef == false ) if ( new_coef == false )
{ {
assemble_matrix(); assemble_matrix();
m_matrix.coeffRef(i,j)=val; m_matrix.coeffRef(i,j)=val;
} }
else else
m_triplets.push_back(Triplet(i,j,val)); m_triplets.push_back(Triplet(i,j,val));
} }
} }
/// Write access to a matrix coefficient: a_ij <- a_ij+val. /// Write access to a matrix coefficient: a_ij <- a_ij+val.
/// ///
/// Optimizations: /// Optimizations:
/// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle /// - For symmetric matrices, Eigen_sparse_matrix stores only the lower triangle
/// add_coef() does nothing if (i, j) belongs to the upper triangle. /// add_coef() does nothing if (i, j) belongs to the upper triangle.
/// ///
/// @commentheading Preconditions: /// @commentheading Preconditions:
/// - 0 <= i < row_dimension(). /// - 0 <= i < row_dimension().
/// - 0 <= j < column_dimension(). /// - 0 <= j < column_dimension().
void add_coef(int i, int j, T val) void add_coef(int i, int j, T val)
{ {
CGAL_precondition(i < row_dimension()); CGAL_precondition(i < row_dimension());
CGAL_precondition(j < column_dimension()); CGAL_precondition(j < column_dimension());
if (m_is_symmetric && (j > i)) if (m_is_symmetric && (j > i))
return; return;
if (m_is_already_built) if (m_is_already_built)
m_matrix.coeffRef(i,j)+=val; m_matrix.coeffRef(i,j)+=val;
else else
m_triplets.push_back(Triplet(i,j,val)); m_triplets.push_back(Triplet(i,j,val));
} }
void assemble_matrix() const void assemble_matrix() const
{ {
m_matrix.setFromTriplets(m_triplets.begin(), m_triplets.end()); m_matrix.setFromTriplets(m_triplets.begin(), m_triplets.end());
m_is_already_built = true; m_is_already_built = true;
m_triplets.clear(); //the matrix is built and will not be rebuilt m_triplets.clear(); //the matrix is built and will not be rebuilt
} }
const EigenType& eigen_object() const const EigenType& eigen_object() const
{ {
if(!m_is_already_built) assemble_matrix(); if(!m_is_already_built) assemble_matrix();
// turns the matrix into compressed mode: // turns the matrix into compressed mode:
// -> release some memory // -> release some memory
// -> required for some external solvers // -> required for some external solvers
m_matrix.makeCompressed(); m_matrix.makeCompressed();
return m_matrix; return m_matrix;
} }
private: private:
/// Eigen_sparse_matrix cannot be copied (yet) /// Eigen_sparse_matrix cannot be copied (yet)
Eigen_sparse_matrix(const Eigen_sparse_matrix& rhs); Eigen_sparse_matrix(const Eigen_sparse_matrix& rhs);
Eigen_sparse_matrix& operator=(const Eigen_sparse_matrix& rhs); Eigen_sparse_matrix& operator=(const Eigen_sparse_matrix& rhs);
// Fields // Fields
private: private:
mutable bool m_is_already_built; mutable bool m_is_already_built;
typedef Eigen::Triplet<T,int> Triplet; typedef Eigen::Triplet<T,int> Triplet;
mutable std::vector<Triplet> m_triplets; mutable std::vector<Triplet> m_triplets;
mutable EigenType m_matrix; mutable EigenType m_matrix;
// Symmetric/hermitian? // Symmetric/hermitian?
bool m_is_symmetric; bool m_is_symmetric;
}; // Eigen_sparse_matrix }; // Eigen_sparse_matrix
/// The class Eigen_sparse_symmetric_matrix is a C++ wrapper /// The class Eigen_sparse_symmetric_matrix is a C++ wrapper
/// around a Eigen sparse matrix (type Eigen::SparseMatrix). /// around a Eigen sparse matrix (type Eigen::SparseMatrix).
/// ///
/// Symmetric matrices store only the lower triangle. /// Symmetric matrices store only the lower triangle.
/// ///
/// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d::Matrix concept. /// @heading Is Model for the Concepts: Model of the SparseLinearAlgebraTraits_d::Matrix concept.
/// ///
/// @heading Parameters: /// @heading Parameters:
/// @param T Number type. /// @param T Number type.
template<class T> template<class T>
struct Eigen_sparse_symmetric_matrix struct Eigen_sparse_symmetric_matrix
: public Eigen_sparse_matrix<T> : public Eigen_sparse_matrix<T>
{ {
// Public types // Public types
typedef T NT; typedef T NT;
// Public operations // Public operations
/// Create a square *symmetric* matrix initialized with zeros. /// Create a square *symmetric* matrix initialized with zeros.
Eigen_sparse_symmetric_matrix(int dim) ///< Matrix dimension. Eigen_sparse_symmetric_matrix(int dim) ///< Matrix dimension.
: Eigen_sparse_matrix<T>(dim, true /* symmetric */) : Eigen_sparse_matrix<T>(dim, true /* symmetric */)
{ {
} }
/// Create a square *symmetric* matrix initialized with zeros. /// Create a square *symmetric* matrix initialized with zeros.
/// ///
/// @commentheading Precondition: rows == columns. /// @commentheading Precondition: rows == columns.
Eigen_sparse_symmetric_matrix(int rows, ///< Number of rows. Eigen_sparse_symmetric_matrix(int rows, ///< Number of rows.
int columns) ///< Number of columns. int columns) ///< Number of columns.
: Eigen_sparse_matrix<T>(rows, columns, true /* symmetric */) : Eigen_sparse_matrix<T>(rows, columns, true /* symmetric */)
{ {
} }
}; };
template <class FT> template <class FT>
struct Eigen_matrix : public ::Eigen::Matrix<FT,::Eigen::Dynamic,::Eigen::Dynamic> struct Eigen_matrix : public ::Eigen::Matrix<FT,::Eigen::Dynamic,::Eigen::Dynamic>
{ {
typedef ::Eigen::Matrix<FT,::Eigen::Dynamic,::Eigen::Dynamic> EigenType; typedef ::Eigen::Matrix<FT,::Eigen::Dynamic,::Eigen::Dynamic> EigenType;
Eigen_matrix( std::size_t n1, std::size_t n2):EigenType(n1,n2){} Eigen_matrix( std::size_t n1, std::size_t n2):EigenType(n1,n2){}
std::size_t number_of_rows () const {return this->rows();} std::size_t number_of_rows () const {return this->rows();}
std::size_t number_of_columns () const {return this->cols();} std::size_t number_of_columns () const {return this->cols();}
FT operator()( std::size_t i , std::size_t j ) const {return this->operator()(i,j);} FT operator()( std::size_t i , std::size_t j ) const {return this->operator()(i,j);}
void set( std::size_t i, std::size_t j,FT value){ void set( std::size_t i, std::size_t j,FT value){
this->coeffRef(i,j)=value; this->coeffRef(i,j)=value;
} }
const EigenType& eigen_object() const{ const EigenType& eigen_object() const{
return static_cast<const EigenType&>(*this); return static_cast<const EigenType&>(*this);
} }
}; };
} //namespace CGAL } //namespace CGAL
#endif // CGAL_EIGEN_MATRIX_H #endif // CGAL_EIGEN_MATRIX_H

View File

@ -1,64 +1,64 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/Search_traits_3.h> #include <CGAL/Search_traits_3.h>
#include <CGAL/Search_traits_adapter.h> #include <CGAL/Search_traits_adapter.h>
#include <CGAL/point_generators_3.h> #include <CGAL/point_generators_3.h>
#include <CGAL/Orthogonal_k_neighbor_search.h> #include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/property_map.h> #include <CGAL/property_map.h>
#include <boost/iterator/zip_iterator.hpp> #include <boost/iterator/zip_iterator.hpp>
#include <utility> #include <utility>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3; typedef Kernel::Point_3 Point_3;
typedef boost::tuple<Point_3,int> Point_and_int; typedef boost::tuple<Point_3,int> Point_and_int;
typedef CGAL::Random_points_in_cube_3<Point_3> Random_points_iterator; typedef CGAL::Random_points_in_cube_3<Point_3> Random_points_iterator;
typedef CGAL::Search_traits_3<Kernel> Traits_base; typedef CGAL::Search_traits_3<Kernel> Traits_base;
typedef CGAL::Search_traits_adapter<Point_and_int, typedef CGAL::Search_traits_adapter<Point_and_int,
CGAL::Nth_of_tuple_property_map<0, Point_and_int>, CGAL::Nth_of_tuple_property_map<0, Point_and_int>,
Traits_base> Traits; Traits_base> Traits;
typedef CGAL::Orthogonal_k_neighbor_search<Traits> K_neighbor_search; typedef CGAL::Orthogonal_k_neighbor_search<Traits> K_neighbor_search;
typedef K_neighbor_search::Tree Tree; typedef K_neighbor_search::Tree Tree;
typedef K_neighbor_search::Distance Distance; typedef K_neighbor_search::Distance Distance;
int main() { int main() {
const unsigned int K = 5; const unsigned int K = 5;
// generator for random data points in the cube ( (-1,-1,-1), (1,1,1) ) // generator for random data points in the cube ( (-1,-1,-1), (1,1,1) )
Random_points_iterator rpit( 1.0); Random_points_iterator rpit( 1.0);
std::vector<Point_3> points; std::vector<Point_3> points;
std::vector<int> indices; std::vector<int> indices;
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
points.push_back(Point_3(*rpit++)); points.push_back(Point_3(*rpit++));
indices.push_back(0); indices.push_back(0);
indices.push_back(1); indices.push_back(1);
indices.push_back(2); indices.push_back(2);
indices.push_back(3); indices.push_back(3);
indices.push_back(4); indices.push_back(4);
indices.push_back(5); indices.push_back(5);
indices.push_back(6); indices.push_back(6);
// Insert number_of_data_points in the tree // Insert number_of_data_points in the tree
Tree tree( Tree tree(
boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )),
boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) )
); );
Point_3 query(0.0, 0.0, 0.0); Point_3 query(0.0, 0.0, 0.0);
Distance tr_dist; Distance tr_dist;
// search K nearest neighbours // search K nearest neighbours
K_neighbor_search search(tree, query, K); K_neighbor_search search(tree, query, K);
for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){
std::cout << " d(q, nearest neighbor)= " std::cout << " d(q, nearest neighbor)= "
<< tr_dist.inverse_of_transformed_distance(it->second) << " " << boost::get<0>(it->first)<< " " << boost::get<1>(it->first) << std::endl; << tr_dist.inverse_of_transformed_distance(it->second) << " " << boost::get<0>(it->first)<< " " << boost::get<1>(it->first) << std::endl;
} }
return 0; return 0;
} }

View File

@ -1,35 +1,35 @@
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/spatial_sort.h> #include <CGAL/spatial_sort.h>
#include <CGAL/Spatial_sort_traits_adapter_2.h> #include <CGAL/Spatial_sort_traits_adapter_2.h>
#include <CGAL/property_map.h> #include <CGAL/property_map.h>
#include <vector> #include <vector>
typedef CGAL::Simple_cartesian<double> Kernel; typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2; typedef Kernel::Point_2 Point_2;
typedef std::pair<Point_2,int> Point_with_info; typedef std::pair<Point_2,int> Point_with_info;
typedef std::vector< Point_with_info > Data_vector; typedef std::vector< Point_with_info > Data_vector;
typedef CGAL::Spatial_sort_traits_adapter_2<Kernel, typedef CGAL::Spatial_sort_traits_adapter_2<Kernel,
CGAL::First_of_pair_property_map<Point_with_info> CGAL::First_of_pair_property_map<Point_with_info>
> Search_traits_2; > Search_traits_2;
int main() int main()
{ {
Data_vector points; Data_vector points;
points.push_back(std::make_pair(Point_2(14,12) , 3)); points.push_back(std::make_pair(Point_2(14,12) , 3));
points.push_back(std::make_pair(Point_2(1,2) , 0)); points.push_back(std::make_pair(Point_2(1,2) , 0));
points.push_back(std::make_pair(Point_2(414,2) , 5)); points.push_back(std::make_pair(Point_2(414,2) , 5));
points.push_back(std::make_pair(Point_2(4,21) , 1)); points.push_back(std::make_pair(Point_2(4,21) , 1));
points.push_back(std::make_pair(Point_2(7,74) , 2)); points.push_back(std::make_pair(Point_2(7,74) , 2));
points.push_back(std::make_pair(Point_2(74,4) , 4)); points.push_back(std::make_pair(Point_2(74,4) , 4));
Search_traits_2 traits; Search_traits_2 traits;
CGAL::spatial_sort(points.begin(), points.end(), traits); CGAL::spatial_sort(points.begin(), points.end(), traits);
for (Data_vector::iterator it=points.begin();it!=points.end();++it) for (Data_vector::iterator it=points.begin();it!=points.end();++it)
std::cout << it->second << " "; std::cout << it->second << " ";
std::cout << "\n"; std::cout << "\n";
std::cout << "done" << std::endl; std::cout << "done" << std::endl;
return 0; return 0;
} }

View File

@ -1,215 +1,215 @@
#include "config.h" #include "config.h"
#include "Point_set_scene_item.h" #include "Point_set_scene_item.h"
#include "Polyhedron_demo_plugin_helper.h" #include "Polyhedron_demo_plugin_helper.h"
#include "Polyhedron_demo_plugin_interface.h" #include "Polyhedron_demo_plugin_interface.h"
#include <CGAL/pca_estimate_normals.h> #include <CGAL/pca_estimate_normals.h>
#include <CGAL/jet_estimate_normals.h> #include <CGAL/jet_estimate_normals.h>
#include <CGAL/mst_orient_normals.h> #include <CGAL/mst_orient_normals.h>
#include <CGAL/Timer.h> #include <CGAL/Timer.h>
#include <CGAL/Memory_sizer.h> #include <CGAL/Memory_sizer.h>
#include <QObject> #include <QObject>
#include <QAction> #include <QAction>
#include <QMainWindow> #include <QMainWindow>
#include <QApplication> #include <QApplication>
#include <QtPlugin> #include <QtPlugin>
#include <QInputDialog> #include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
#include "ui_PS_demo_normal_estimation_plugin.h" #include "ui_PS_demo_normal_estimation_plugin.h"
class PS_demo_normal_estimation_plugin : class PS_demo_normal_estimation_plugin :
public QObject, public QObject,
public Polyhedron_demo_plugin_helper public Polyhedron_demo_plugin_helper
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(Polyhedron_demo_plugin_interface) Q_INTERFACES(Polyhedron_demo_plugin_interface)
QAction* actionNormalEstimation; QAction* actionNormalEstimation;
QAction* actionNormalInversion; QAction* actionNormalInversion;
public: public:
void init(QMainWindow* mainWindow, Scene_interface* scene_interface) { void init(QMainWindow* mainWindow, Scene_interface* scene_interface) {
this->scene = scene_interface; this->scene = scene_interface;
this->mw = mainWindow; this->mw = mainWindow;
actionNormalEstimation = this->getActionFromMainWindow(mw, "actionNormalEstimation"); actionNormalEstimation = this->getActionFromMainWindow(mw, "actionNormalEstimation");
if(actionNormalEstimation) { if(actionNormalEstimation) {
connect(actionNormalEstimation, SIGNAL(triggered()), connect(actionNormalEstimation, SIGNAL(triggered()),
this, SLOT(on_actionNormalEstimation_triggered())); this, SLOT(on_actionNormalEstimation_triggered()));
} }
actionNormalInversion = this->getActionFromMainWindow(mw, "actionNormalInversion"); actionNormalInversion = this->getActionFromMainWindow(mw, "actionNormalInversion");
if(actionNormalInversion) { if(actionNormalInversion) {
connect(actionNormalInversion, SIGNAL(triggered()), connect(actionNormalInversion, SIGNAL(triggered()),
this, SLOT(on_actionNormalInversion_triggered())); this, SLOT(on_actionNormalInversion_triggered()));
} }
} }
QList<QAction*> actions() const { QList<QAction*> actions() const {
return QList<QAction*>() << actionNormalEstimation << actionNormalInversion; return QList<QAction*>() << actionNormalEstimation << actionNormalInversion;
} }
public slots: public slots:
void on_actionNormalEstimation_triggered(); void on_actionNormalEstimation_triggered();
void on_actionNormalInversion_triggered(); void on_actionNormalInversion_triggered();
}; // end PS_demo_smoothing_plugin }; // end PS_demo_smoothing_plugin
class Point_set_demo_normal_estimation_dialog : public QDialog, private Ui::NormalEstimationDialog class Point_set_demo_normal_estimation_dialog : public QDialog, private Ui::NormalEstimationDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
Point_set_demo_normal_estimation_dialog(QWidget* = 0) Point_set_demo_normal_estimation_dialog(QWidget* = 0)
{ {
setupUi(this); setupUi(this);
} }
QString directionMethod() const { return m_inputDirection->currentText(); } QString directionMethod() const { return m_inputDirection->currentText(); }
int directionNbNeighbors() const { return m_inputNbNeighborsDirection->value(); } int directionNbNeighbors() const { return m_inputNbNeighborsDirection->value(); }
QString orientationMethod() const { return m_inputOrientation->currentText(); } QString orientationMethod() const { return m_inputOrientation->currentText(); }
int orientationNbNeighbors() const { return m_inputNbNeighborsOrientation->value(); } int orientationNbNeighbors() const { return m_inputNbNeighborsOrientation->value(); }
}; };
void PS_demo_normal_estimation_plugin::on_actionNormalInversion_triggered() void PS_demo_normal_estimation_plugin::on_actionNormalInversion_triggered()
{ {
const Scene_interface::Item_id index = scene->mainSelectionIndex(); const Scene_interface::Item_id index = scene->mainSelectionIndex();
Point_set_scene_item* item = Point_set_scene_item* item =
qobject_cast<Point_set_scene_item*>(scene->item(index)); qobject_cast<Point_set_scene_item*>(scene->item(index));
if(item) if(item)
{ {
// Gets point set // Gets point set
Point_set* points = item->point_set(); Point_set* points = item->point_set();
if(points == NULL) if(points == NULL)
return; return;
for(Point_set::iterator it = points->begin(); it != points->end(); ++it){ for(Point_set::iterator it = points->begin(); it != points->end(); ++it){
it->normal() = -1 * it->normal(); it->normal() = -1 * it->normal();
} }
} }
} }
void PS_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered() void PS_demo_normal_estimation_plugin::on_actionNormalEstimation_triggered()
{ {
const Scene_interface::Item_id index = scene->mainSelectionIndex(); const Scene_interface::Item_id index = scene->mainSelectionIndex();
Point_set_scene_item* item = Point_set_scene_item* item =
qobject_cast<Point_set_scene_item*>(scene->item(index)); qobject_cast<Point_set_scene_item*>(scene->item(index));
if(item) if(item)
{ {
// Gets point set // Gets point set
Point_set* points = item->point_set(); Point_set* points = item->point_set();
if(points == NULL) if(points == NULL)
return; return;
// Gets options // Gets options
Point_set_demo_normal_estimation_dialog dialog; Point_set_demo_normal_estimation_dialog dialog;
if(!dialog.exec()) if(!dialog.exec())
return; return;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
// First point to delete // First point to delete
Point_set::iterator first_unoriented_point = points->end(); Point_set::iterator first_unoriented_point = points->end();
//*************************************** //***************************************
// normal estimation // normal estimation
//*************************************** //***************************************
if (dialog.directionMethod() == "plane") if (dialog.directionMethod() == "plane")
{ {
CGAL::Timer task_timer; task_timer.start(); CGAL::Timer task_timer; task_timer.start();
std::cerr << "Estimates normal direction by PCA (k=" << dialog.directionNbNeighbors() <<")...\n"; std::cerr << "Estimates normal direction by PCA (k=" << dialog.directionNbNeighbors() <<")...\n";
// Estimates normals direction. // Estimates normals direction.
CGAL::pca_estimate_normals(points->begin(), points->end(), CGAL::pca_estimate_normals(points->begin(), points->end(),
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 #ifdef CGAL_USE_PROPERTY_MAPS_API_V1
CGAL::make_normal_of_point_with_normal_pmap(points->begin()), CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
#else #else
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()), CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
#endif #endif
dialog.directionNbNeighbors()); dialog.directionNbNeighbors());
// Mark all normals as unoriented // Mark all normals as unoriented
first_unoriented_point = points->begin(); first_unoriented_point = points->begin();
long memory = CGAL::Memory_sizer().virtual_size(); long memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, " std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated" << (memory>>20) << " Mb allocated"
<< std::endl; << std::endl;
} }
else if (dialog.directionMethod() == "quadric") else if (dialog.directionMethod() == "quadric")
{ {
CGAL::Timer task_timer; task_timer.start(); CGAL::Timer task_timer; task_timer.start();
std::cerr << "Estimates normal direction by Jet Fitting (k=" << dialog.directionNbNeighbors() <<")...\n"; std::cerr << "Estimates normal direction by Jet Fitting (k=" << dialog.directionNbNeighbors() <<")...\n";
// Estimates normals direction. // Estimates normals direction.
CGAL::jet_estimate_normals(points->begin(), points->end(), CGAL::jet_estimate_normals(points->begin(), points->end(),
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 #ifdef CGAL_USE_PROPERTY_MAPS_API_V1
CGAL::make_normal_of_point_with_normal_pmap(points->begin()), CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
#else #else
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()), CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
#endif #endif
dialog.directionNbNeighbors()); dialog.directionNbNeighbors());
// Mark all normals as unoriented // Mark all normals as unoriented
first_unoriented_point = points->begin(); first_unoriented_point = points->begin();
long memory = CGAL::Memory_sizer().virtual_size(); long memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, " std::cerr << "Estimates normal direction: " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated" << (memory>>20) << " Mb allocated"
<< std::endl; << std::endl;
} }
//*************************************** //***************************************
// normal orientation // normal orientation
//*************************************** //***************************************
CGAL::Timer task_timer; task_timer.start(); CGAL::Timer task_timer; task_timer.start();
std::cerr << "Orient normals with a Minimum Spanning Tree (k=" << dialog.orientationNbNeighbors() << ")...\n"; std::cerr << "Orient normals with a Minimum Spanning Tree (k=" << dialog.orientationNbNeighbors() << ")...\n";
// Tries to orient normals // Tries to orient normals
first_unoriented_point = first_unoriented_point =
CGAL::mst_orient_normals(points->begin(), points->end(), CGAL::mst_orient_normals(points->begin(), points->end(),
#ifdef CGAL_USE_PROPERTY_MAPS_API_V1 #ifdef CGAL_USE_PROPERTY_MAPS_API_V1
CGAL::make_normal_of_point_with_normal_pmap(points->begin()), CGAL::make_normal_of_point_with_normal_pmap(points->begin()),
#else #else
CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()), CGAL::make_normal_of_point_with_normal_pmap(Point_set::value_type()),
#endif #endif
dialog.orientationNbNeighbors()); dialog.orientationNbNeighbors());
int nb_unoriented_normals = std::distance(first_unoriented_point, points->end()); int nb_unoriented_normals = std::distance(first_unoriented_point, points->end());
long memory = CGAL::Memory_sizer().virtual_size(); long memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "Orient normals: " << nb_unoriented_normals << " point(s) with an unoriented normal are selected (" std::cerr << "Orient normals: " << nb_unoriented_normals << " point(s) with an unoriented normal are selected ("
<< task_timer.time() << " seconds, " << task_timer.time() << " seconds, "
<< (memory>>20) << " Mb allocated)" << (memory>>20) << " Mb allocated)"
<< std::endl; << std::endl;
// Selects points with an unoriented normal // Selects points with an unoriented normal
points->select(points->begin(), points->end(), false); points->select(points->begin(), points->end(), false);
points->select(first_unoriented_point, points->end(), true); points->select(first_unoriented_point, points->end(), true);
// Updates scene // Updates scene
scene->itemChanged(index); scene->itemChanged(index);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
// Warns user // Warns user
if (nb_unoriented_normals > 0) if (nb_unoriented_normals > 0)
{ {
QMessageBox::information(NULL, QMessageBox::information(NULL,
tr("Points with an unoriented normal"), tr("Points with an unoriented normal"),
tr("%1 point(s) with an unoriented normal are selected.\nPlease orient them or remove them before running Poisson reconstruction.") tr("%1 point(s) with an unoriented normal are selected.\nPlease orient them or remove them before running Poisson reconstruction.")
.arg(nb_unoriented_normals)); .arg(nb_unoriented_normals));
} }
} }
} }
Q_EXPORT_PLUGIN2(PS_demo_normal_estimation_plugin, PS_demo_normal_estimation_plugin) Q_EXPORT_PLUGIN2(PS_demo_normal_estimation_plugin, PS_demo_normal_estimation_plugin)
#include "PS_demo_normal_estimation_plugin.moc" #include "PS_demo_normal_estimation_plugin.moc"

View File

@ -1,38 +1,38 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h> #include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h> #include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <vector> #include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, K> Vb; typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned, K> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds; typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
//Use the Fast_location tag. Default or Compact_location works too. //Use the Fast_location tag. Default or Compact_location works too.
typedef CGAL::Delaunay_triangulation_3<K, Tds, CGAL::Fast_location> Delaunay; typedef CGAL::Delaunay_triangulation_3<K, Tds, CGAL::Fast_location> Delaunay;
typedef Delaunay::Point Point; typedef Delaunay::Point Point;
int main() int main()
{ {
std::vector< std::pair<Point,unsigned> > points; std::vector< std::pair<Point,unsigned> > points;
points.push_back( std::make_pair(Point(0,0,0),0) ); points.push_back( std::make_pair(Point(0,0,0),0) );
points.push_back( std::make_pair(Point(1,0,0),1) ); points.push_back( std::make_pair(Point(1,0,0),1) );
points.push_back( std::make_pair(Point(0,1,0),2) ); points.push_back( std::make_pair(Point(0,1,0),2) );
points.push_back( std::make_pair(Point(0,0,1),3) ); points.push_back( std::make_pair(Point(0,0,1),3) );
points.push_back( std::make_pair(Point(2,2,2),4) ); points.push_back( std::make_pair(Point(2,2,2),4) );
points.push_back( std::make_pair(Point(-1,0,1),5) ); points.push_back( std::make_pair(Point(-1,0,1),5) );
Delaunay T( points.begin(),points.end() ); Delaunay T( points.begin(),points.end() );
CGAL_assertion( T.number_of_vertices() == 6 ); CGAL_assertion( T.number_of_vertices() == 6 );
// check that the info was correctly set. // check that the info was correctly set.
Delaunay::Finite_vertices_iterator vit; Delaunay::Finite_vertices_iterator vit;
for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
if( points[ vit->info() ].first != vit->point() ){ if( points[ vit->info() ].first != vit->point() ){
std::cerr << "Error different info" << std::endl; std::cerr << "Error different info" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
std::cout << "OK" << std::endl; std::cout << "OK" << std::endl;
return 0; return 0;
} }