Skip to content

Commit

Permalink
Label intersection chains.
Browse files Browse the repository at this point in the history
  • Loading branch information
oehmke committed Dec 12, 2023
1 parent 6367a09 commit 0b16873
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Infrastructure/Mesh/include/ESMCI_Pgon.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ using namespace ESMCI;

enum PGON_INTERLABEL {
PGON_INTERLABEL_ERROR=0,
PGON_INTERLABEL_NONE,
PGON_INTERLABEL_CROSSING,
PGON_INTERLABEL_BOUNCING,
PGON_INTERLABEL_LEFT_ON,
PGON_INTERLABEL_RIGHT_ON,
PGON_INTERLABEL_ON_ON,
PGON_INTERLABEL_ON_LEFT,
PGON_INTERLABEL_ON_RIGHT,
PGON_INTERLABEL_DELAYED_CROSSING,
PGON_INTERLABEL_DELAYED_BOUNCING,
PGON_INTERLABEL_NUM
};

Expand All @@ -71,7 +74,8 @@ class Vert {

// Base constructor
// Inits everything except points which are handled below
Vert( ): t(-1.0), orig(false), inter(false), next(NULL), prev(NULL) {}
Vert( ): t(-1.0), orig(false), inter(false), interlabel(PGON_INTERLABEL_NONE),
nbr(NULL), next(NULL), prev(NULL) {}

Vert(double x, double y);

Expand Down
36 changes: 33 additions & 3 deletions src/Infrastructure/Mesh/src/ESMCI_Pgon_Set_Oper.C
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,47 @@ void _label_intersections(Pgon<GEOM> &pg) {
// Spread labels down chains
for (Vert<GEOM> *v : pg.get_VertIter(PGON_VERTITERTYPE_INTER)) {

// Start of a
// If we're starting a chain
if ((v->interlabel == PGON_INTERLABEL_LEFT_ON) || (v->interlabel == PGON_INTERLABEL_RIGHT_ON)) {

// Save start vertex
Vert<GEOM> *chain_start = v;

// Move to end of chain, setting to NONE along chain
do {
v->interlabel=PGON_INTERLABEL_NONE; // TODO: SHOULD WE HAVE A SPECIAL LABEL FOR THIS???
v=v->next;
} while (v->interlabel == PGON_INTERLABEL_ON_ON);

// Decide label of whole chain by comparing start and end
PGON_INTERLABEL chain_label;
if ((chain_start->interlabel == PGON_INTERLABEL_LEFT_ON) && (v->interlabel == PGON_INTERLABEL_ON_LEFT)) {
chain_label=PGON_INTERLABEL_DELAYED_BOUNCING;
} else if ((chain_start->interlabel == PGON_INTERLABEL_RIGHT_ON) && (v->interlabel == PGON_INTERLABEL_ON_RIGHT)) {
chain_label=PGON_INTERLABEL_DELAYED_BOUNCING;
} else if ((chain_start->interlabel == PGON_INTERLABEL_LEFT_ON) && (v->interlabel == PGON_INTERLABEL_ON_RIGHT)) {
chain_label=PGON_INTERLABEL_DELAYED_CROSSING;
} else if ((chain_start->interlabel == PGON_INTERLABEL_RIGHT_ON) && (v->interlabel == PGON_INTERLABEL_ON_LEFT)) {
chain_label=PGON_INTERLABEL_DELAYED_CROSSING;
} else {
Throw() << "Unexpected crossing situation.";
}

// STOPPED HERE

// Mark both ends with chain label
chain_start->interlabel = chain_label; // chain start
v->interlabel = chain_label; // chain end
}
}


// Copy labels from pg to other polygons it's intersected with
for (Vert<GEOM> *v : pg.get_VertIter(PGON_VERTITERTYPE_INTER)) {
v->nbr->interlabel = v->interlabel;
}





}

Expand Down

0 comments on commit 0b16873

Please sign in to comment.