diff --git a/src/Infrastructure/Mesh/include/ESMCI_Pgon.h b/src/Infrastructure/Mesh/include/ESMCI_Pgon.h index 4742006030..4d82db6692 100644 --- a/src/Infrastructure/Mesh/include/ESMCI_Pgon.h +++ b/src/Infrastructure/Mesh/include/ESMCI_Pgon.h @@ -45,6 +45,7 @@ using namespace ESMCI; enum PGON_INTERLABEL { PGON_INTERLABEL_ERROR=0, + PGON_INTERLABEL_NONE, PGON_INTERLABEL_CROSSING, PGON_INTERLABEL_BOUNCING, PGON_INTERLABEL_LEFT_ON, @@ -52,6 +53,8 @@ enum PGON_INTERLABEL { PGON_INTERLABEL_ON_ON, PGON_INTERLABEL_ON_LEFT, PGON_INTERLABEL_ON_RIGHT, + PGON_INTERLABEL_DELAYED_CROSSING, + PGON_INTERLABEL_DELAYED_BOUNCING, PGON_INTERLABEL_NUM }; @@ -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); diff --git a/src/Infrastructure/Mesh/src/ESMCI_Pgon_Set_Oper.C b/src/Infrastructure/Mesh/src/ESMCI_Pgon_Set_Oper.C index 569dec8fb0..406b45ee7c 100644 --- a/src/Infrastructure/Mesh/src/ESMCI_Pgon_Set_Oper.C +++ b/src/Infrastructure/Mesh/src/ESMCI_Pgon_Set_Oper.C @@ -286,17 +286,47 @@ void _label_intersections(Pgon &pg) { // Spread labels down chains for (Vert *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 *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 *v : pg.get_VertIter(PGON_VERTITERTYPE_INTER)) { v->nbr->interlabel = v->interlabel; } + + + }