Updating new branch with modified and new files, in accordance with provided features

This commit is contained in:
Sylvain Brandel 2014-06-03 11:22:47 +02:00
parent 4d34b88770
commit ec61d7cdc0
10 changed files with 1944 additions and 121 deletions

View File

@ -1159,6 +1159,34 @@ namespace CGAL {
return valid;
}
/// validate the map
void validate_scene()
{
std::vector<int> marks(dimension+1);
for ( int i=0; i<=dimension; ++i)
marks[i] = -1;
Helper::template
Foreach_enabled_attributes<Reserve_mark_functor<Self> >::
run(this,&marks);
for ( typename Dart_range::iterator it(darts().begin()),
itend(darts().end()); it!=itend; ++it)
{
Helper::template Foreach_enabled_attributes
<internal::Validate_attribute_functor<Self> >::
run(this,it,&marks);
}
for ( int i=0; i<=dimension; ++i)
if ( marks[i]!=-1 )
{
CGAL_assertion( is_whole_map_marked(marks[i]) );
free_mark(marks[i]);
}
}
/// @return the number of darts.
size_type number_of_darts() const
{ return mdarts.size(); }

View File

@ -35,7 +35,8 @@ template<class CMap>
typename CMap::Dart_handle
insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle )
Attribute_handle<0>::type ah=CMap::null_handle,
bool update_attributes=true )
{
typename CMap::Dart_handle d1, d2;
int mark=amap.get_new_mark();
@ -70,13 +71,19 @@ insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
amap.basic_link_beta_1(*it, d1);
if (update_attributes)
{
// We copy all the attributes except for dim=0
CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 0>::
run(&amap,*it,d1);
}
if (ah != CMap::null_handle)
{
// We initialise the 0-atttrib to ah
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d1, ah);
}
amap.mark(*it, mark);
}
@ -92,8 +99,11 @@ insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
amap.free_mark(m);
amap.free_mark(mark);
if (update_attributes)
{
CGAL::internal::Degroup_attribute_functor_run<CMap, 1>::
run(&amap, adart, amap.template beta<1>(adart));
}
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( amap.is_valid() );
@ -112,7 +122,8 @@ template < class CMap >
typename CMap::Dart_handle
insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle )
Attribute_handle<0>::type ah=CMap::null_handle,
bool update_attributes=true )
{
CGAL_assertion(adart!=amap.null_dart_handle);
@ -162,9 +173,12 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
if ( prev!=amap.null_handle )
amap.template basic_link_beta_for_involution<2>(prev, n1);
if (update_attributes)
{
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, n1, ah);
}
}
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
{
@ -185,9 +199,12 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
nn2=amap.create_dart();
amap.link_beta_0(amap.beta(cur, dim), nn2);
amap.basic_link_beta_for_involution(n2, nn2, dim);
if (update_attributes)
{
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, nn2, ah);
}
}
else nn2=amap.null_handle;
if (nn1 != amap.null_handle && nn2 != amap.null_handle)
@ -265,7 +282,8 @@ typename CMap::Dart_handle
insert_dangling_cell_1_in_cell_2( CMap& amap,
typename CMap::Dart_handle adart1,
typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle )
Attribute_handle<0>::type ah=CMap::null_handle,
bool update_attributes=true )
{
int mark1 = amap.get_new_mark();
std::deque<typename CMap::Dart_handle> to_unmark;
@ -327,8 +345,11 @@ insert_dangling_cell_1_in_cell_2( CMap& amap,
(amap.beta(it1, dim, CGAL_BETAINV(s1), 2), d2, dim);
}
}
if (update_attributes)
{
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d1, ah);
}
amap.mark(it1, treated);
}
@ -384,7 +405,8 @@ template<class CMap>
typename CMap::Dart_handle
insert_cell_1_in_cell_2(CMap& amap,
typename CMap::Dart_handle adart1,
typename CMap::Dart_handle adart2)
typename CMap::Dart_handle adart2,
bool update_attributes=true)
{
if ( adart2==amap.null_handle ) return insert_dangling_cell_1_in_cell_2(amap,adart1);
@ -461,8 +483,10 @@ insert_cell_1_in_cell_2(CMap& amap,
amap.mark(it1,treated);
}
if (update_attributes)
{
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::run(&amap, d1, d2);
}
amap.negate_mark(m1);
amap.negate_mark(m2);
it1.rewind(); it2.rewind();
@ -551,7 +575,8 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap,
*/
template<class CMap, class InputIterator>
typename CMap::Dart_handle
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast,
bool update_attributes=true)
{
CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
@ -668,9 +693,12 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
if ( withBeta3 )
{ // Here we cannot use Degroup_attribute_functor_run as new darts do not
// have their 3-attribute
if (update_attributes)
{
CGAL::internal::Degroup_attribute_functor_run<CMap, 3>::
run(&amap, first, amap.template beta<3>(first));
}
}
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( amap.is_valid() );

View File

@ -87,7 +87,7 @@ namespace CGAL
template<class CMap, unsigned int i, unsigned int nmi>
struct Remove_cell_functor
{
static size_t run(CMap& amap, typename CMap::Dart_handle adart)
static size_t run(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes)
{
CGAL_static_assertion ( 1<=i && i<CMap::dimension );
CGAL_assertion( (is_removable<CMap,i>(amap, adart)) );
@ -115,10 +115,13 @@ namespace CGAL
++res;
}
if (update_attributes)
{
// We group the two (i+1)-cells incident if they exist.
if ( dg1!=amap.null_handle )
CGAL::internal::Group_attribute_functor_run<CMap, i+1>::
run(&amap, dg1, dg2);
}
// During the operation, we store in modified_darts the darts modified
// to test after the loop the non void attributes that are split.
@ -211,6 +214,8 @@ namespace CGAL
}
}
if (update_attributes)
{
// We test the split of all the incident cells for all the non
// void attributes.
if ( i==1 )
@ -222,6 +227,7 @@ namespace CGAL
CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Test_split_attribute_functor<CMap,i>, i>::
run(&amap, modified_darts, mark_modified_darts);
}
// We remove all the darts of the i-cell.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
@ -268,7 +274,7 @@ namespace CGAL
template<class CMap,unsigned int i>
struct Remove_cell_functor<CMap,i,0>
{
static size_t run(CMap& amap, typename CMap::Dart_handle adart)
static size_t run(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes)
{
int mark = amap.get_new_mark();
std::deque<typename CMap::Dart_handle> to_erase;
@ -298,11 +304,14 @@ namespace CGAL
}
}
if (update_attributes)
{
// We test the split of all the incident cells for all the non
// void attributes.
CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Test_split_attribute_functor<CMap,i>,
CMap::dimension>::run(&amap, modified_darts);
}
// We remove all the darts of the d-cell.
for ( it = to_erase.begin(); it != to_erase.end(); ++it )
@ -327,7 +336,7 @@ namespace CGAL
template<class CMap,unsigned int nmi>
struct Remove_cell_functor<CMap,0,nmi>
{
static size_t run(CMap& amap, typename CMap::Dart_handle adart)
static size_t run(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes)
{
CGAL_assertion( (is_removable<CMap,0>(amap,adart)) );
@ -351,10 +360,13 @@ namespace CGAL
++res;
}
if (update_attributes)
{
// We group the two edges incident if they exist.
if ( dg1!=amap.null_handle )
CGAL::internal::Group_attribute_functor_run<CMap, 1>::
run(&amap, dg1, dg2);
}
// During the operation, we store in modified_darts the darts modified
// by beta0 to test after the loop non void attributes that are split.
@ -410,11 +422,14 @@ namespace CGAL
}
}
if (update_attributes)
{
// We test the split of all the incident cells for all the non
// void attributes.
CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Test_split_attribute_functor<CMap,0>, 1>::
run(&amap,modified_darts, modified_darts2);
}
// We remove all the darts of the 0-cell.
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
@ -437,10 +452,10 @@ namespace CGAL
* @return the number of deleted darts.
*/
template < class CMap, unsigned int i >
size_t remove_cell(CMap& amap, typename CMap::Dart_handle adart)
size_t remove_cell(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes = true)
{
return
CGAL::Remove_cell_functor<CMap,i,CMap::dimension-i>::run(amap,adart);
CGAL::Remove_cell_functor<CMap,i,CMap::dimension-i>::run(amap,adart,update_attributes);
}
/** Test if an i-cell can be contracted.

View File

@ -262,6 +262,85 @@ struct Test_is_valid_attribute_functor
}
};
// ****************************************************************************
/// Functor used to validate an i-cell
template<typename CMap>
struct Validate_attribute_functor
{
template <unsigned int i>
static void run(CMap* amap,
typename CMap::Dart_handle adart,
std::vector<int>* marks)
{
// std::cout << "Validate_attribute_functor for " << i << "-cell" << std::endl;
CGAL_static_assertion_msg(CMap::Helper::template
Dimension_index<i>::value>=0,
"Validate_attribute_functor<i> but "
" i-attributes are disabled");
int amark = (*marks)[i];
if ( amap->is_marked(adart, amark) ) return; // dart already test.
typename CMap::template Attribute_handle<i>::type
a=amap->template attribute<i>(adart);
bool found_attrib = false;
if (a == amap->null_handle)
{
// we search if the i-cell has a valid i-attrib
for ( CGAL::CMap_dart_iterator_of_cell<CMap,i>
it(*amap, adart); !found_attrib && it.cont(); ++it )
{
if (amap->template attribute<i>(it) != amap->null_handle)
{
a = amap->template attribute<i>(it);
found_attrib = true;
}
}
}
else
{
found_attrib = true;
}
if (found_attrib)
{
// std::cout << i << "-attribute found" << std::endl;
bool found_dart = false;
for ( CGAL::CMap_dart_iterator_of_cell<CMap,i>
it(*amap, adart); it.cont(); ++it )
{
if (a != amap->template attribute<i>(it))
{
// If two different i-attributes, we could call on_split ?
amap->template set_dart_attribute<i>(it, a);
}
if (it==amap->template dart_of_attribute<i>(a))
{
found_dart = true;
}
amap->mark(it, amark);
}
if (!found_dart)
{
// the current i-attrib does not belong to the i-cell
// so we affect it to the first dart of the i-cell
amap->template set_dart_of_attribute<i>(a,adart);
}
}
else
{
for ( CGAL::CMap_dart_iterator_of_cell<CMap,i>
it(*amap, adart); it.cont(); ++it )
{
// we perform a traversal to mark all darts
amap->mark(it, amark);
}
}
}
};
// ****************************************************************************
/// Functor for counting i-cell
template<typename CMap>
struct Count_cell_functor

View File

@ -52,7 +52,7 @@ include_directories(${QGLVIEWER_INCLUDE_DIR})
include_directories(BEFORE . ../../include/)
# ui file, created wih Qt Designer
qt4_wrap_ui(uis MainWindow.ui CreateMesh.ui CreateMenger.ui)
qt4_wrap_ui(uis MainWindow.ui CreateMesh.ui CreateMenger.ui CreateSierpinskiCarpet.ui CreateSierpinskiTriangle.ui)
# qrc files (resources files, that contain icons, at least)
qt4_add_resources (RESOURCE_FILES ./Linear_cell_complex_3.qrc)

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>227</width>
<height>76</height>
<width>264</width>
<height>106</height>
</rect>
</property>
<property name="windowTitle">
@ -16,8 +16,8 @@
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>-142</x>
<y>40</y>
<x>-90</x>
<y>70</y>
<width>341</width>
<height>32</height>
</rect>
@ -67,6 +67,22 @@
<string>Menger Complexity</string>
</property>
</widget>
<widget class="QCheckBox" name="updateAttributes">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>241</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Update attributes during construction</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
<resources/>
<connections>

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,8 @@
#include "ui_MainWindow.h"
#include "ui_CreateMesh.h"
#include "ui_CreateMenger.h"
#include "ui_CreateSierpinskiCarpet.h"
#include "ui_CreateSierpinskiTriangle.h"
#include <CGAL/Qt/DemosMainWindow.h>
@ -61,6 +63,44 @@ public:
{ setupUi(this); }
};
class DialogSierpinskiCarpet : public QDialog, public Ui::createSierpinskiCarpet
{
Q_OBJECT
public:
DialogSierpinskiCarpet(QWidget* /*parent*/)
{ setupUi(this); }
};
class DialogSierpinskiTriangle : public QDialog, public Ui::createSierpinskiTriangle
{
Q_OBJECT
public:
DialogSierpinskiTriangle(QWidget* /*parent*/)
{ setupUi(this); }
};
template < class First, class Second, class Third > struct Triplet
{
First first;
Second second;
Third third;
Triplet(First first, Second second, Third third)
{
this->first = first;
this->second = second;
this->third = third;
}
Triplet()
{
}
};
class MainWindow : public CGAL::Qt::DemosMainWindow, private Ui::MainWindow
{
Q_OBJECT
@ -82,6 +122,8 @@ public slots:
void on_actionCreate2Volumes_triggered();
void on_actionCreate_mesh_triggered();
void on_actionCreate_Menger_Sponge_triggered();
void on_actionCreate_Sierpinski_Carpet_triggered();
void on_actionCreate_Sierpinski_Triangle_triggered();
// Operations menu
void on_actionSubdivide_triggered();
@ -115,6 +157,26 @@ public slots:
void onMengerChange(int);
void onMengerOk();
void onMengerCancel();
void onMengerUpdateAttributes(bool);
void onSierpinskiCarpetChangeLevel(int);
void onSierpinskiCarpetNeverUpdateAttributes(bool);
void onSierpinskiCarpetDuringConstructionUpdateAttributes(bool);
void onSierpinskiCarpetAfterConstructionUpdateAttributes(bool);
void onSierpinskiCarpetUpdateAttributesMethodStdMap(bool);
void onSierpinskiCarpetUpdateAttributesMethodTraversal(bool);
void onSierpinskiCarpetComputeGeometry(bool);
void onSierpinskiCarpetOk();
void onSierpinskiCarpetCancel();
void onSierpinskiCarpetInc();
void onSierpinskiCarpetDec();
void onSierpinskiTriangleChangeLevel(int);
void onSierpinskiTriangleUpdateAttributes(bool);
void onSierpinskiTriangleOk();
void onSierpinskiTriangleCancel();
void onSierpinskiTriangleInc();
void onSierpinskiTriangleDec();
signals:
void sceneChanged();
@ -151,16 +213,49 @@ protected:
std::vector<Dart_handle>& faces,
int markVols);
void sierpinski_carpet_copy_attributes_and_embed_vertex(Dart_handle dh, LCC::Point& p);
void sierpinski_carpet_update_geometry();
void sierpinski_carpet_compute_geometry();
void sierpinski_carpet_compute_4x4_geometry_matrix(LCC::Point p[4][4], LCC::Point& p00, LCC::Point& p03, LCC::Point& p33, LCC::Point& p30);
void sierpinski_carpet_split_edge_in_three(Dart_handle dh);
void sierpinski_carpet_split_face_in_three(Dart_handle dh, bool removecenter);
void sierpinski_carpet_split_face_in_nine(Dart_handle dh);
void sierpinski_triangle_split_edge_in_two(Dart_handle dh);
void sierpinski_triangle_split_face_in_four(Dart_handle dh, bool removecenter);
Scene scene;
unsigned int nbcube;
QLabel* statusMessage;
DialogMesh dialogmesh;
DialogMenger dialogmenger;
DialogSierpinskiCarpet dialogsierpinskicarpet;
DialogSierpinskiTriangle dialogsierpinskitriangle;
int mengerLevel;
bool mengerUpdateAttributes;
std::vector<Dart_handle> mengerVolumes;
int sierpinskiCarpetLevel;
unsigned int nbfacesinit;
bool neverUpdateAttributes;
bool duringConstructionUpdateAttributes;
bool afterConstructionUpdateAttributes;
bool updateAttributesMethodStdMap;
bool updateAttributesMethodTraversal;
bool computeGeometry;
bool isComputableGeometry;
std::vector<Dart_handle> sierpinskiCarpetSurfaces;
// utilisés seulement lorsque pas de mise à jour d'attributs
std::map<Dart_handle, LCC::Point> dart_map;
std::vector<Dart_handle> new_darts;
int sierpinskiTriangleLevel;
bool sierpinskiTriangleUpdateAttributes;
std::vector<Dart_handle> sierpinskiTriangleSurfaces;
std::vector< Triplet<Dart_handle, Dart_handle, Dart_handle> > removedTriangles;
QDockWidget* volumeListDock;
QTableWidget* volumeList;
};

View File

@ -33,7 +33,7 @@
<x>0</x>
<y>0</y>
<width>635</width>
<height>26</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -74,6 +74,9 @@
<addaction name="actionCreate2Volumes"/>
<addaction name="actionCreate_mesh"/>
<addaction name="actionCreate_Menger_Sponge"/>
<addaction name="separator"/>
<addaction name="actionCreate_Sierpinski_Carpet"/>
<addaction name="actionCreate_Sierpinski_Triangle"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
@ -208,6 +211,16 @@
<string>&amp;Merge volumes</string>
</property>
</action>
<action name="actionCreate_Sierpinski_Carpet">
<property name="text">
<string>Create Sierpinski Carpet</string>
</property>
</action>
<action name="actionCreate_Sierpinski_Triangle">
<property name="text">
<string>Create Sierpinski Triangle</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -348,6 +348,24 @@ namespace CGAL {
return valid;
}
/** validate the lcc
*/
void validate_scene()
{
Base::validate_scene();
// On vérifie que chaque brin a un 0-plongement
for (typename Dart_range::iterator it(this->darts().begin()),
itend(this->darts().end()); it != itend; ++it)
{
if ( vertex_attribute(it)==null_handle )
{
// sinon on crée un point à l'origine
set_vertex_attribute(it, create_vertex_attribute(CGAL::ORIGIN));
}
}
}
/** test if the two given facets have the same geometry
* @return true iff the two facets have the same geometry.
*/
@ -686,10 +704,11 @@ namespace CGAL {
* @param p the point to insert
* @return a dart handle to the new vertex containing p.
*/
Dart_handle insert_point_in_cell_1(Dart_handle dh, const Point& p)
Dart_handle insert_point_in_cell_1(Dart_handle dh, const Point& p, bool update_attribute)
{
return CGAL::insert_cell_0_in_cell_1(*this, dh,
create_vertex_attribute(p));
create_vertex_attribute(p),
update_attribute);
}
/** Insert a point in a given 2-cell.
@ -697,11 +716,11 @@ namespace CGAL {
* @param p the point to insert
* @return a dart handle to the new vertex containing p.
*/
Dart_handle insert_point_in_cell_2(Dart_handle dh, const Point& p)
Dart_handle insert_point_in_cell_2(Dart_handle dh, const Point& p, bool update_attribute)
{
Vertex_attribute_handle v = create_vertex_attribute(p);
Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh, v);
Dart_handle first = CGAL::insert_cell_0_in_cell_2(*this, dh, v, update_attribute);
if ( first==null_handle ) // If the triangulated facet was made of one dart
erase_vertex_attribute(v);
@ -719,11 +738,11 @@ namespace CGAL {
* @return a dart handle to the new vertex containing p.
*/
template <unsigned int i>
Dart_handle insert_point_in_cell(Dart_handle dh, const Point& p)
Dart_handle insert_point_in_cell(Dart_handle dh, const Point& p, bool update_attributes = true)
{
CGAL_static_assertion(1<=i && i<=2);
if (i==1) return insert_point_in_cell_1(dh, p);
return insert_point_in_cell_2(dh, p);
if (i==1) return insert_point_in_cell_1(dh, p, update_attributes);
return insert_point_in_cell_2(dh, p, update_attributes);
}
/** Insert a dangling edge in a given facet.