Skip to content

Commit

Permalink
Implemented function UniqueIDColor::relabel_everything()
Browse files Browse the repository at this point in the history
  • Loading branch information
vvmarko committed Jun 25, 2023
1 parent d6a3b2c commit cbbe6fa
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 10 deletions.
1 change: 1 addition & 0 deletions library/include/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class UniqueIDColor : public Color{
static bool append_color_to_single_simplex(KSimplex* simp);
static bool append_color_to_simplices_at_level(SimpComp* G, int level);
static bool append_color_to_entire_complex(SimpComp* G);
static bool relabel_everything(void);

string get_color_value_as_str() const;
void set_color_value_from_str(const string& source) override;
Expand Down
19 changes: 19 additions & 0 deletions library/src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,25 @@ bool UniqueIDColor::append_color_to_entire_complex(SimpComp* G)
return outcome;
}

bool UniqueIDColor::relabel_everything( void )
{
bool outcome = true;
unsigned long N=1;
for (auto simpComp : triangulator_global::seededComplexes) {
for (auto scelem : simpComp->elements) {
for (auto ksimplex : scelem) {
for (auto col : ksimplex->colors) {
if (col->type == TYPE_UNIQUE_ID) {
static_cast<UniqueIDColor*>(col)->id = N;
N++;
}
}
}
}
}
UniqueIDColor::next_free_uid_number = N;
return outcome;
}

string UniqueIDColor::get_color_value_as_str() const
{
Expand Down
4 changes: 1 addition & 3 deletions library/src/seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,7 @@ SimpComp* seed_single_simplex(int D, string name){
SimpComp* seed_sphere(int D, string name){
SimpComp *simpComp = seed_single_simplex_or_sphere(D, 1, name);
triangulator_global::seededComplexes.push_back(simpComp);

cout << "Seed: " << triangulator_global::seededComplexes.size() << endl;

//cout << "Seed: " << triangulator_global::seededComplexes.size() << endl;
return simpComp;
}

Expand Down
64 changes: 57 additions & 7 deletions test/attach-simplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ int main(){
cout << "#######################################################" << endl << endl;


SimpComp* sc1 = seed_sphere_intuitively(2,"prvi");
UniqueIDColor::colorize_entire_complex(sc1);
SimpComp* sc2 = seed_single_simplex(3,"drugi");
UniqueIDColor::colorize_entire_complex(sc2);
SimpComp* sc3 = seed_sphere(4,"treci");
UniqueIDColor::colorize_entire_complex(sc3);
cout << "===========================" << endl;
sc1->print_compact();
cout << "===========================" << endl;
sc2->print_compact();
cout << "===========================" << endl;
sc3->print_compact();
cout << "===========================" << endl;
cout << "next free uid number = " << UniqueIDColor::next_free_uid_number << endl;
cout << "Number of complexes = " << triangulator_global::seededComplexes.size();

unseed_complex(sc2);

cout << endl << "Deleting complex 2..." << endl << endl;

cout << "===========================" << endl;
sc1->print_compact();
cout << "===========================" << endl;
sc3->print_compact();
cout << "===========================" << endl;
cout << "next free uid number = " << UniqueIDColor::next_free_uid_number << endl;
cout << "Number of complexes = " << triangulator_global::seededComplexes.size();

UniqueIDColor::relabel_everything();

cout << endl << "Relabeling UniqueID colors..." << endl << endl;

cout << "===========================" << endl;
sc1->print_compact();
cout << "===========================" << endl;
sc3->print_compact();
cout << "===========================" << endl;
cout << "next free uid number = " << UniqueIDColor::next_free_uid_number << endl;
cout << "Number of complexes = " << triangulator_global::seededComplexes.size();

unseed_everything();

/*
triangulator_global::logLevel=LOG_DEBUG;
triangulator_global::logFilename="logfile.html";
log_report(LOG_PANIC,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_ERROR,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_WARN,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_INFO,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_DEBUG,"Testing the log reporting facility, to see if it works and if it is readable...");
*/


/*
SimpComp *g = seed_single_simplex(4,"simpleks");
UniqueIDColor::colorize_entire_complex(g);
g->print_compact();
Expand All @@ -16,15 +71,10 @@ int main(){
UniqueIDColor::append_color_to_entire_complex(g);
g->print_compact();
unseed_complex(g);
*/

triangulator_global::logLevel=LOG_DEBUG;
triangulator_global::logFilename="logfile.html";

log_report(LOG_PANIC,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_ERROR,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_WARN,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_INFO,"Testing the log reporting facility, to see if it works and if it is readable...");
log_report(LOG_DEBUG,"Testing the log reporting facility, to see if it works and if it is readable...");



/*
Expand Down

0 comments on commit cbbe6fa

Please sign in to comment.