Input: An D-OPP . |
ββββThe number of dimensions. |
Output: A list containing the EVMs which describe the D components of . |
Procedure ConnectedComponentsLabeling(EVM , int ) |
βββ if() then |
βββββreturn ConnectedComponentsLabeling1D // Base case. |
βββ else |
βββββEVM hvlβββββ// Current couplet of p. |
βββββEVM , βββββ// Previous and next sections about hvl. |
βββββ = InitEVM( ) |
βββββList components β// The components of section . |
βββββList indexes βββ// A list of indexes. |
βββββList components ββ// The components of section . |
βββββList indexes ββ// A list of indexes. |
βββββList componentsPβ// The D components of input polytope p. |
βββββCoordType currCoord = getCoordNextHvl |
βββββhvl = ReadHvl |
βββββCoordType nextCoord = getCoordNextHvl |
βββββwhile(Not(EndEVM)) |
βββββββ = GetSection(, hvl) |
βββββββcomponents = ConnectedComponentsLabeling // Recursive call. |
βββββββfor(int , j < Size(components ), ) |
βββββββββEVM = components |
βββββββββboolean withoutComponent = true |
βββββββββfor(int , i < Size(components ), ) |
βββββββββββEVM = components |
βββββββββββEVM c = BooleanOperation(,, Intersection, ) |
βββββββββββif(Not(IsEmpty(c)) and (withoutComponent = true)) then |
βββββββββββββ// CASE 1 |
βββββββββββββwithoutComponent = false |
βββββββββββββList componentToUpdate = componentsP(indexes ) |
βββββββββββββAppend(componentToUpdate, , currCood, nextCoord}) |
βββββββββββββAppend(indexes , indexes ) |
βββββββββββelse if(Not(IsEmpty(c)) and (withoutComponent = false)) then |
βββββββββββββ// CASE 2 |
βββββββββββββif(indexes β indexes ) then |
βββββββββββββββList component1 = componentsP(indexes ) |
βββββββββββββββList component2 = componentsP(indexes ) |
βββββββββββββββfor(int , k < Size(component1), ) |
βββββββββββββββββAppend(component2, component1()) |
βββββββββββββββend-of-for |
βββββββββββββββUpdate(componentsP, indexes , NULL) |
βββββββββββββββfor(int , k < Size(indexes ), ) |
βββββββββββββββββif(indexes = indexes ) then |
βββββββββββββββββββUpdate(indexes , k, indexes ) |
βββββββββββββββββend-of-if |
βββββββββββββββend-of-for |
βββββββββββββββfor(int , k < Size(indexes ), ) |
βββββββββββββββββif(indexes = indexes ) then |
βββββββββββββββββββUpdate(indexes , k, indexes ) |
βββββββββββββββββend-of-if |
βββββββββββββββend-of-for |
βββββββββββββββUpdate(indexes , i, indexes ) |
βββββββββββββend-of-if |
βββββββββββend-of-if |
ββββββββββend-of-for |
ββββββββββif(withoutComponent = true) then |
ββββββββββββ// CASE 3 |
ββββββββββββList newComponent |
ββββββββββββAppend(newComponent, , currCoord, nextCoord}) |
ββββββββββββAppend(componentsP, newComponent) |
ββββββββββββAppend(indexes , Size(componentsP) - 1) |
ββββββββββend-of-if |
βββββββββend-of-for |
βββββββββ |
βββββββββcomponents = components |
βββββββββindexes = indexes |
βββββββββcurrCoord = GetCoordNextHvl |
βββββββββhvl = ReadHvl // Read next couplet. |
nextCoord = GetCoordNextHvl |
end-of-while |
// End of sectionsβ processing. |
int |
while(i < Size(componentsP)) |
ββif(componentsP(i) = NULL) then |
ββββRemove(componentsP, i) |
ββββ |
ββelse |
ββββList currentListOfSections = componentsP(i) |
ββββEVM evmComponent = getEVMforListOfSections(currentListOfSections, ) |
ββββUpdate(componentsP, , evmComponent) |
ββend-of-if |
ββ |
ββend-of-while |
ββreturn componentsP |
βend-of-if |
end-of-procedure |