Skip to content

Commit

Permalink
Minor corrections to colorization functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc0 committed Feb 22, 2022
1 parent af35408 commit 87b7bf8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ void UniqueIDColor::print_compact(){
cout << id;
}

bool UniqueIDColor::colorize_all_simplices(SimpComp* G, int level)
bool UniqueIDColor::colorize_simplices_at_level(SimpComp* G, int level)
{
bool colorization_successful = false, already_has_unique_id;

for (auto simplex : G->elements[level]) {
already_has_unique_id = false;
for (auto cl : simplex->colors)
if (cl->type == TYPE_UNIQUE_ID)
if (cl->type == TYPE_UNIQUE_ID) {
already_has_unique_id = true;
break;
}

if (!already_has_unique_id) {
simplex->colors.push_back(new UniqueIDColor());
Expand All @@ -54,7 +56,7 @@ bool UniqueIDColor::colorize_entire_complex(SimpComp* G)
{
bool colorization_successful = false, current_colorization_successful = false;
for (int level = 0; level <= G->D; level++) {
current_colorization_successful = UniqueIDColor::colorize_all_simplices(G, level);
current_colorization_successful = UniqueIDColor::colorize_simplices_at_level(G, level);
if (!colorization_successful)
colorization_successful = current_colorization_successful;
}
Expand Down
2 changes: 1 addition & 1 deletion color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class UniqueIDColor : public Color{
void print(string space = "");
void print_compact();

static bool colorize_all_simplices(SimpComp* G, int level);
static bool colorize_simplices_at_level(SimpComp* G, int level);
static bool colorize_entire_complex(SimpComp* G);

static unsigned long next_free_uid_number;
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main(){
tetrahedron->print_compact();

cout << endl << "Tetrahedron example, coloring level 0:" << endl << endl;
UniqueIDColor::colorize_all_simplices(tetrahedron, 0);
UniqueIDColor::colorize_simplices_at_level(tetrahedron, 0);
tetrahedron->print_compact();

cout << endl << "Tetrahedron example, coloring everyithing:" << endl << endl;
Expand Down

0 comments on commit 87b7bf8

Please sign in to comment.