Skip to content

Instantly share code, notes, and snippets.

@ziglee
Created October 22, 2017 00:50
Show Gist options
  • Save ziglee/91e9129757a57439090e4e8fbcbfa660 to your computer and use it in GitHub Desktop.
Save ziglee/91e9129757a57439090e4e8fbcbfa660 to your computer and use it in GitHub Desktop.
package br.com.celg.pd318
class StudsUtil {
static enum SeqPosition {
START,
MIDDLE,
END
}
static Set<String> studs(Assembly assembly, SeqPosition seqPosition) {
def estruturas = assembly.tipoAt1
Set<String> studs = new LinkedHashSet<String>()
if (estruturas && estruturas.size() == 1) {
double horizontalAngle = assembly.angDeflexao ?: 0d
ParamEstr paramEstr = estruturas.iterator().next()
addStuds(studs, seqPosition, paramEstr, horizontalAngle, assembly.posicaoPoste)
}
return studs
}
static void addStuds(Set<String> studs, SeqPosition seqPosition, ParamEstr paramEstr, double horizontalAngle, PosicaoPosteType posicaoPosteType) {
horizontalAngle = Math.abs(horizontalAngle)
if (horizontalAngle > 180) {
horizontalAngle = 360 - horizontalAngle
}
if (seqPosition.equals(SeqPosition.START)) {
if (['ND-N1','ND-N2','ND-N4','UD-U1','UD-U2','UD-U4','UD-T','N2-3','U2-3']
.contains(paramEstr.estrutura)) {
studs.add('1,0')
studs.add('1,2')
}
} else if (seqPosition.equals(SeqPosition.END)) {
if (['N3','U3','N2-3','U2-3'].contains(paramEstr.estrutura)) {
studs.add('1,0')
studs.add('1,2')
}
} else {
if (['N1','U1'].contains(paramEstr.estrutura)) {
if (horizontalAngle != 0) {
studs.add('0,1')
}
studs.add('0,2')
} else if (['N2','U2'].contains(paramEstr.estrutura)) {
if (horizontalAngle != 0) {
studs.add('0,1')
}
if (horizontalAngle >= 0 && horizontalAngle < 5) {
studs.add('0,2')
}
studs.add('2,0')
} else if (['N4','U4'].contains(paramEstr.estrutura)) {
if (horizontalAngle >= 0 && horizontalAngle < 60) {
studs.add('2,0')
}
if (horizontalAngle >= 5 && horizontalAngle < 60) {
studs.add('2,1')
studs.add('2,2')
}
if (horizontalAngle >= 0 && horizontalAngle < 5) {
studs.add('2,2')
}
} else if (['TE'].contains(paramEstr.estrutura)) {
if (horizontalAngle >= 5 && horizontalAngle < 60) {
studs.add('2,1')
studs.add('2,2')
}
if (horizontalAngle >= 0 && horizontalAngle < 5) {
studs.add('2,2')
}
} else if (['HT'].contains(paramEstr.estrutura)) {
if (horizontalAngle >= 0 && horizontalAngle < 5) {
studs.add('4,2')
}
if (horizontalAngle >= 5 && horizontalAngle < 60) {
studs.add('4,2')
studs.add('4,3')
studs.add('4,4')
}
} else if (['N3-N3','U3-U3'].contains(paramEstr.estrutura)) {
if (horizontalAngle < 60) {
if (posicaoPosteType.equals(PosicaoPosteType.NORMAL)) {
studs.add('1,1')
studs.add('1,2')
studs.add('2,2')
} else {
studs.add('1,1')
studs.add('2,1')
studs.add('2,2')
}
}
} else if (paramEstr.estrutura.equals('HTE')) {
if (horizontalAngle < 60) {
studs.add('6,2')
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment