Merge pull request #2594 from gdamiand/CMap-bugfixes-gdamiand

CMap bugfixes
This commit is contained in:
Laurent Rineau 2017-12-05 18:20:56 +01:00
commit 0b0b1503ef
16 changed files with 1432 additions and 1192 deletions

View File

@ -713,18 +713,18 @@ namespace CGAL
typename CMap::Dart_handle d1, d2;
typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle;
typename CMap::size_type mark = amap.get_new_mark();
typename CMap::size_type amark = amap.get_new_mark();
// First we store and mark all the darts of the 1-cell to contract.
std::deque<typename CMap::Dart_handle> to_erase;
for ( CGAL::CMap_dart_iterator_basic_of_cell<CMap,1> it(amap,adart,mark);
for ( CGAL::CMap_dart_iterator_basic_of_cell<CMap,1> it(amap,adart,amark);
it.cont(); ++it )
{
to_erase.push_back(it);
if ( dg1==amap.null_handle && !amap.template is_free<0>(it) &&
!amap.template is_free<1>(it) )
{ dg1=amap.template beta<0>(it); dg2=amap.template beta<1>(it); }
amap.mark(it, mark);
amap.mark(it, amark);
++res;
}
@ -757,7 +757,8 @@ namespace CGAL
if ( (*it)->beta(0)!=(*it)->beta(1) )*/
if ( amap.are_attributes_automatically_managed() && update_attributes )
{
modified_darts.push_back(amap.template beta<1>(*it));
if (!amap.is_marked(amap.template beta<1>(*it), amark))
{ modified_darts.push_back(amap.template beta<1>(*it)); }
}
amap.basic_link_beta_1(amap.template beta<0>(*it),
amap.template beta<1>(*it));
@ -767,7 +768,8 @@ namespace CGAL
{
if ( amap.are_attributes_automatically_managed() && update_attributes )
{
modified_darts2.push_back(amap.template beta<0>(*it));
if (!amap.is_marked(amap.template beta<0>(*it), amark))
{ modified_darts2.push_back(amap.template beta<0>(*it)); }
}
amap.template dart_unlink_beta<1>(amap.template beta<0>(*it));
}
@ -778,7 +780,8 @@ namespace CGAL
{
if ( amap.are_attributes_automatically_managed() && update_attributes )
{
modified_darts.push_back(amap.template beta<1>(*it));
if (!amap.is_marked(amap.template beta<1>(*it), amark))
{ modified_darts.push_back(amap.template beta<1>(*it)); }
}
amap.template dart_unlink_beta<0>(amap.template beta<1>(*it));
}
@ -789,8 +792,8 @@ namespace CGAL
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
{ amap.erase_dart(*it); }
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
amap.free_mark(mark);
CGAL_assertion( amap.is_whole_map_unmarked(amark) );
amap.free_mark(amark);
if ( amap.are_attributes_automatically_managed() && update_attributes )
{

View File

@ -30,6 +30,7 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Combinatorial_map_functors.h>
#include <algorithm>
#include <map>
@ -40,6 +41,8 @@
namespace CGAL {
typedef Exact_predicates_inexact_constructions_kernel::Point_2 RPoint_2;
typedef Exact_predicates_exact_constructions_kernel::Point_2 EPoint_2;
typedef Exact_predicates_inexact_constructions_kernel::Point_3 RPoint_3;
typedef Exact_predicates_exact_constructions_kernel::Point_3 EPoint_3;
@ -126,6 +129,20 @@ namespace CGAL {
const std::string& val)
{node.add("v",val);}
inline
void write_cmap_attribute_node(boost::property_tree::ptree & node,
const RPoint_2& val)
{
node.add("p.x",val.x());
node.add("p.y",val.y());
}
inline
void write_cmap_attribute_node(boost::property_tree::ptree & node,
const EPoint_2& val)
{
node.add("p.x",CGAL::to_double(val.x()));
node.add("p.y",CGAL::to_double(val.y()));
}
inline
void write_cmap_attribute_node(boost::property_tree::ptree & node,
const RPoint_3& val)
{
@ -167,7 +184,7 @@ namespace CGAL {
boost::property_tree::ptree& ndim = ptree.add("dimension", "");
ndim.put("<xmlattr>.index", i);
ndim.add("type", typeid(typename CMap::template Attribute_type<i>::type::Info).name());
ndim.add("type_point", typeid(RPoint_3).name());
ndim.add("type_point", typeid(typename CMap::Point).name());
// for every attribute of the dimension
for (; it_attrib!=itend_attrib; ++it_attrib)
@ -202,7 +219,7 @@ namespace CGAL {
boost::property_tree::ptree& ndim = ptree.add("dimension", "");
ndim.put("<xmlattr>.index", i);
ndim.add("type", "void");
ndim.add("type_point", typeid(RPoint_3).name());
ndim.add("type_point", typeid(typename CMap::Point).name());
// for every attribute of the dimension
for (; it_attrib!=itend_attrib; ++it_attrib)
@ -355,13 +372,26 @@ namespace CGAL {
return pt;
}
template < class CMap >
bool save_combinatorial_map(const CMap& amap, std::ostream & output)
struct EmptyFunctor
{
void operator() (boost::property_tree::ptree & /*node*/) const
{
// node.add("myinfo.myvalie",15);
}
};
template < class CMap, class Functor >
bool save_combinatorial_map(const CMap& amap, std::ostream & output,
const Functor& f)
{
using boost::property_tree::ptree;
ptree tree;
tree.put("data", "");
/** First we save general information of the map (by default nothing,
the fuction can be specialized by users). */
f(tree);
// map dart => number
std::map<typename CMap::Dart_const_handle, typename CMap::size_type> myDarts;
@ -379,12 +409,27 @@ namespace CGAL {
return true;
}
template < class CMap >
bool save_combinatorial_map(const CMap& amap, const char* filename)
template < class CMap, class Functor >
bool save_combinatorial_map(const CMap& amap, const char* filename,
const Functor& f)
{
std::ofstream output(filename);
if (!output) return false;
return save_combinatorial_map(amap, output);
return save_combinatorial_map(amap, output, f);
}
template < class CMap >
bool save_combinatorial_map(const CMap& amap, std::ostream & output)
{
EmptyFunctor f;
return save_combinatorial_map(amap, output, f);
}
template < class CMap >
bool save_combinatorial_map(const CMap& amap, const char* filename)
{
EmptyFunctor f;
return save_combinatorial_map(amap, filename, f);
}
// Here T is a Dart_handle so no need of &
@ -450,6 +495,14 @@ namespace CGAL {
{val=boost::lexical_cast< std::string >(v.second.data());}
template<> inline
void read_cmap_attribute_node
(const boost::property_tree::ptree::value_type &v,RPoint_2 &val)
{
double x=v.second.get<double>("x");
double y=v.second.get<double>("y");
val = RPoint_2(x,y);
}
template<> inline
void read_cmap_attribute_node
(const boost::property_tree::ptree::value_type &v,RPoint_3 &val)
{
double x=v.second.get<double>("x");
@ -771,26 +824,47 @@ namespace CGAL {
<My_functor_cmap_load_attrib<CMap> >::run(pt, amap, myDarts);
}
template < class CMap >
bool load_combinatorial_map(std::ifstream & input, CMap& amap)
template < class CMap, class Functor >
bool load_combinatorial_map(std::ifstream & input, CMap& amap,
Functor& f)
{
using boost::property_tree::ptree;
ptree pt;
read_xml(input, pt);
/** First we load general information of the map (by default nothing,
the fuction can be specialized by users). */
f(pt);
// Then we load darts and attributes.
std::vector<typename CMap::Dart_handle> myDarts;
cmap_load_darts(pt,amap,myDarts);
cmap_load_attributes(pt,amap,myDarts);
return true;
}
template < class CMap >
bool load_combinatorial_map(const char* filename, CMap& amap)
template < class CMap, class Functor >
bool load_combinatorial_map(const char* filename, CMap& amap,
Functor& f)
{
std::ifstream input(filename);
if (!input) return false;
return load_combinatorial_map(input, amap);
return load_combinatorial_map(input, amap, f);
}
template < class CMap >
bool load_combinatorial_map(std::ifstream & input, CMap& amap)
{
EmptyFunctor f;
return load_combinatorial_map(input, amap, f);
}
template < class CMap >
bool load_combinatorial_map(const char* filename, CMap& amap)
{
EmptyFunctor f;
return load_combinatorial_map(filename, amap, f);
}
} // namespace CGAL
#endif // CGAL_COMBINATORIAL_MAP_SAVE_LOAD_H //

View File

@ -347,7 +347,7 @@ namespace CGAL {
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle & dart(Dart_handle adart)
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=NULL );
CGAL_assertion( attribute<i>(adart)!=NULL );

View File

@ -340,7 +340,7 @@ namespace CGAL {
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle & dart(Dart_handle adart)
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=NULL );
CGAL_assertion( attribute<i>(adart)!=NULL );

View File

@ -154,7 +154,6 @@ void MainWindow::connectVolumeListHandlers()
void MainWindow::update_operations_entries(bool show)
{
actionImportOFF->setEnabled(show);
actionAddOFF->setEnabled(show);
actionImport3DTDS->setEnabled(show);
actionCompute_Voronoi_3D->setEnabled(show);
actionClear->setEnabled(show);
@ -247,7 +246,7 @@ void MainWindow::on_actionLoad_triggered ()
if (!fileName.isEmpty ())
{
load(fileName, true);
load(fileName, false);
}
}
@ -260,7 +259,7 @@ void MainWindow::on_actionImportOFF_triggered ()
if (!fileName.isEmpty ())
{
load_off (fileName, true);
load_off (fileName, false);
}
}
@ -273,7 +272,7 @@ void MainWindow::on_actionImportMoka_triggered()
if (!fileName.isEmpty ())
{
load_moka(fileName, true);
load_moka(fileName, false);
}
}
@ -286,25 +285,12 @@ void MainWindow::on_actionImport3DTDS_triggered ()
if (!fileName.isEmpty ())
{
load_3DTDS (fileName, true);
load_3DTDS (fileName, false);
statusBar ()->showMessage (QString ("Import 3DTDS file") + fileName,
DELAY_STATUSMSG);
}
}
void MainWindow::on_actionAddOFF_triggered()
{
QString fileName = QFileDialog::getOpenFileName (this,
tr ("Add OFF"),
"./off",
tr ("off files (*.off)"));
if (!fileName.isEmpty ())
{
load_off (fileName, false);
}
}
void MainWindow::load_depend_on_extension(const QString & fileName, bool clear)
{
QString ext = QFileInfo(fileName).suffix();
@ -468,7 +454,7 @@ void MainWindow::load_moka(const QString & fileName, bool clear)
#ifdef CGAL_PROFILE_LCC_DEMO
timer.stop();
std::cout<<"Time to load off "<<qPrintable(fileName)<<": "
std::cout<<"Time to load moka "<<qPrintable(fileName)<<": "
<<timer.time()<<" seconds."<<std::endl;
#endif
@ -479,10 +465,10 @@ void MainWindow::load_moka(const QString & fileName, bool clear)
QApplication::restoreOverrideCursor ();
if (clear)
statusBar ()->showMessage (QString ("Load off file") + fileName,
statusBar ()->showMessage (QString ("Load moka file") + fileName,
DELAY_STATUSMSG);
else
statusBar ()->showMessage (QString ("Add off file") + fileName,
statusBar ()->showMessage (QString ("Add moka file") + fileName,
DELAY_STATUSMSG);
Q_EMIT (sceneChanged ());
}

View File

@ -114,7 +114,6 @@ public Q_SLOTS:
void on_actionSave_triggered();
void on_actionLoad_triggered();
void on_actionImportOFF_triggered();
void on_actionAddOFF_triggered();
void on_actionImport3DTDS_triggered();
void on_actionImportMoka_triggered();
void on_actionCompute_Voronoi_3D_triggered();
@ -148,12 +147,12 @@ public Q_SLOTS:
void on_actionExtend_hidden_volumes_triggered();
// Other slots
void load_depend_on_extension(const QString& fileName, bool clear=true);
void load(const QString& fileName, bool clear=true);
void load_depend_on_extension(const QString& fileName, bool clear=false);
void load(const QString& fileName, bool clear=false);
void save(const QString& fileName);
void load_off(const QString& fileName, bool clear=true);
void load_3DTDS(const QString& fileName, bool clear=true);
void load_moka(const QString& fileName, bool clear=true);
void load_off(const QString& fileName, bool clear=false);
void load_3DTDS(const QString& fileName, bool clear=false);
void load_moka(const QString& fileName, bool clear=false);
void onSceneChanged();

View File

@ -44,7 +44,6 @@
<addaction name="actionSave"/>
<addaction name="separator"/>
<addaction name="actionImportOFF"/>
<addaction name="actionAddOFF"/>
<addaction name="actionImportMoka"/>
<addaction name="separator"/>
<addaction name="actionImport3DTDS"/>
@ -107,11 +106,6 @@
<string>&amp;Import OFF</string>
</property>
</action>
<action name="actionAddOFF">
<property name="text">
<string>Add &amp;OFF</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>&amp;Quit</string>

View File

@ -1,9 +1,9 @@
# This file must be included in your CMakeLists.txt to use cgal_map_viewer_qt.h.
# This file must be included in your CMakeLists.txt to use the basic viewer
# You need to link the libraries in your executable by using
# TARGET_LINK_LIBRARIES( myexec ${MAP_VIEWER_LIBRARIES})
# TARGET_LINK_LIBRARIES( myexec ${BASIC_VIEWER_LIBRARIES})
if ( NOT CGAL_FOUND OR NOT CGAL_Qt5_FOUND)
message(STATUS "NOTICE: Libraries for lcc_viewer not found "
message(STATUS "NOTICE: Libraries for basic viewer not found "
"(CGAL, Qt5, QGLViewer).")
endif( NOT CGAL_FOUND OR NOT CGAL_Qt5_FOUND)
@ -20,14 +20,14 @@ add_definitions(-DQT_NO_KEYWORDS)
include_directories( ${QGLVIEWER_INCLUDE_DIR} )
add_definitions(${QGLVIEWER_DEFINITIONS})
set (MAP_VIEWER_LIBRARIES ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES}
set (BASIC_VIEWER_LIBRARIES ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES}
${OPENGL_gl_LIBRARY}) # ${OPENGL_glu_LIBRARY}
set(MAP_VIEWER_MODULES Xml OpenGL)
set(BASIC_VIEWER_MODULES Xml OpenGL)
ADD_DEFINITIONS("-DCGAL_LCC_USE_VIEWER -DCGAL_LCC_USE_QT")
ADD_DEFINITIONS("-DCGAL_USE_BASIC_VIEWER")
message(STATUS "Libraries for lcc_viewer found. You need to link them "
"in your executable by using "
"TARGET_LINK_LIBRARIES( myexec \${MAP_VIEWER_LIBRARIES})")
"TARGET_LINK_LIBRARIES( myexec \${BASIC_VIEWER_LIBRARIES})")
set(LCC_VIEWER true)
set(USE_BASIC_VIEWER true)

View File

@ -13,7 +13,7 @@ endif()
# based on qt. Just uncomment the following two lines, plus the lines qt5_use_modules below
# find_package(CGAL COMPONENTS Qt5)
# include("CMakeLCCViewerQt.inc")
# include("CMakeBasicViewerQt.inc")
# If you don't want to visualize, use the following line (otherwise comment it)
find_package(CGAL QUIET)
@ -43,21 +43,27 @@ if ( CGAL_FOUND )
add_executable(voronoi_2 voronoi_2.cpp)
target_link_libraries(voronoi_2 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${MAP_VIEWER_LIBRARIES})
# qt5_use_modules(voronoi_2 ${MAP_VIEWER_MODULES})
${BASIC_VIEWER_LIBRARIES})
if (USE_BASIC_VIEWER)
qt5_use_modules(voronoi_2 ${BASIC_VIEWER_MODULES})
endif(USE_BASIC_VIEWER)
add_executable(voronoi_3 voronoi_3.cpp)
target_link_libraries(voronoi_3 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${MAP_VIEWER_LIBRARIES})
# qt5_use_modules(voronoi_3 ${MAP_VIEWER_MODULES})
${BASIC_VIEWER_LIBRARIES})
if (USE_BASIC_VIEWER)
qt5_use_modules(voronoi_3 ${BASIC_VIEWER_MODULES})
endif(USE_BASIC_VIEWER)
create_single_source_cgal_program( "gmap_linear_cell_complex_3.cpp" )
add_executable(linear_cell_complex_3_operations linear_cell_complex_3_operations.cpp)
target_link_libraries(linear_cell_complex_3_operations ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${MAP_VIEWER_LIBRARIES})
# qt5_use_modules(linear_cell_complex_3_operations ${MAP_VIEWER_MODULES})
${BASIC_VIEWER_LIBRARIES})
if (USE_BASIC_VIEWER)
qt5_use_modules(linear_cell_complex_3_operations ${BASIC_VIEWER_MODULES})
endif(USE_BASIC_VIEWER)
else()

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
#include <vector>
/* If you want to use a viewer, you can use qglviewer. */
#ifdef CGAL_LCC_USE_QT
#ifdef CGAL_USE_BASIC_VIEWER
#include "linear_cell_complex_3_viewer_qt.h"
#endif
@ -54,9 +54,9 @@ void run_test()
lcc.template sew<3>(lcc.template opposite<2>(lcc.next(dh1)),
lcc.other_orientation(lcc.template opposite<2>(lcc.previous(dh3))));
#ifdef CGAL_LCC_USE_VIEWER
#ifdef CGAL_USE_BASIC_VIEWER
display_lcc(lcc);
#endif // CGAL_LCC_USE_VIEWER
#endif // CGAL_USE_BASIC_VIEWER
lcc.insert_cell_1_in_cell_2(lcc.next(dh1),
Alpha1<LCC>::run(lcc, lcc.previous(dh1)));
@ -75,9 +75,9 @@ void run_test()
lcc.display_characteristics(std::cout) << ", valid="
<< lcc.is_valid() << std::endl;
#ifdef CGAL_LCC_USE_VIEWER
#ifdef CGAL_USE_BASIC_VIEWER
display_lcc(lcc);
#endif // CGAL_LCC_USE_VIEWER
#endif // CGAL_USE_BASIC_VIEWER
}

View File

@ -7,7 +7,7 @@
#include <fstream>
/* If you want to use a viewer, you can use qglviewer. */
#ifdef CGAL_LCC_USE_QT
#ifdef CGAL_USE_BASIC_VIEWER
#include "linear_cell_complex_3_viewer_qt.h"
#endif
@ -57,9 +57,9 @@ void display_voronoi(LCC_2& alcc, Dart_handle adart)
<< alcc.is_valid()
<< std::endl;
#ifdef CGAL_LCC_USE_VIEWER
#ifdef CGAL_USE_BASIC_VIEWER
display_lcc(alcc);
#endif // CGAL_LCC_USE_VIEWER
#endif // CGAL_USE_BASIC_VIEWER
}
template<typename LCC, typename TR>

View File

@ -6,7 +6,7 @@
#include <fstream>
/* If you want to use a viewer, you can use one qglviewer. */
#ifdef CGAL_LCC_USE_QT
#ifdef CGAL_USE_BASIC_VIEWER
#include "linear_cell_complex_3_viewer_qt.h"
#endif
@ -60,9 +60,9 @@ void display_voronoi(LCC_3& alcc, Dart_handle adart)
<< alcc.is_valid()
<< std::endl;
#ifdef CGAL_LCC_USE_VIEWER
#ifdef CGAL_USE_BASIC_VIEWER
display_lcc(alcc);
#endif // CGAL_LCC_USE_VIEWER
#endif // CGAL_USE_BASIC_VIEWER
}
template<typename LCC, typename TR>

View File

@ -367,7 +367,7 @@ namespace CGAL {
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle & dart(Dart_handle adart)
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=NULL );
CGAL_assertion( attribute<i>(adart)!=NULL );

View File

@ -359,7 +359,7 @@ namespace CGAL {
// Get the dart of the i-cell attribute associated with the given dart
template<unsigned int i>
Dart_handle & dart(Dart_handle adart)
Dart_handle dart(Dart_handle adart)
{
CGAL_assertion( adart!=NULL );
CGAL_assertion( attribute<i>(adart)!=NULL );