Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SetFreeWorktop(presets,objects,spaces,form)
- {
- var workTop = GetWorktopInPresets(presets);
- var idealFreeWorkTop = workTop * 0.5;
- var allPossibleHighCombinations = HighMUEsTreeCreator(presets.length,[]);
- allPossibleHighCombinations.splice(0, 0, []);
- var numberOfPossibleHighCombinations = allPossibleHighCombinations.length;
- var freeWorkTopSpaces = [];
- for(var iCombination = 0 ; iCombination < numberOfPossibleHighCombinations ; iCombination++ )
- {
- var freeWorkTopSpace = 0;
- //console.log(allPossibleHighCombinations[iCombination]);
- for(var iPreset = 0 ; iPreset < presets.length ; iPreset++)
- {
- var isIn = false;
- for(var iResolution = 0 ; iResolution < allPossibleHighCombinations[iCombination].length ; iResolution++)
- if(iPreset == allPossibleHighCombinations[iCombination][iResolution]-1) isIn = true;
- if(isIn) freeWorkTopSpace += GetFreeWorktopInPresetIfLow(presets[iPreset].preset);
- else freeWorkTopSpace += GetFreeWorktopInPreset(presets[iPreset].preset);
- }
- freeWorkTopSpaces.push(freeWorkTopSpace);
- }
- var differences = [];
- for(var iFreeWorkTopSpace = 0 ; iFreeWorkTopSpace < freeWorkTopSpaces.length ; iFreeWorkTopSpace++)
- differences.push(Math.abs(idealFreeWorkTop - freeWorkTopSpaces[iFreeWorkTopSpace]));
- var min = 9999;
- var index = 0;
- for(var iDifference = 0 ; iDifference < differences.length ; iDifference++)
- {
- if(differences[iDifference] < min)
- {
- min = differences[iDifference];
- index = iDifference;
- }
- }
- for(var iResolution = 0 ; iResolution < allPossibleHighCombinations[index].length ; iResolution++)
- {
- var presetNum = allPossibleHighCombinations[index][iResolution]-1;
- DeleteInternalLATsInPreset(presets[presetNum]);
- var numElements = presets[presetNum].preset.length;
- presets[presetNum].preset = RelocateFRIandHOR(presets[presetNum].preset,spaces[presetNum]);
- var possible_positions = [];
- for(iElement = 0; iElement < numElements ; iElement++)
- {
- if(presets[presetNum].preset[iElement].type == "STO_COL_L" || presets[presetNum].preset[iElement].type == "STO_COL")
- presets[presetNum].preset[iElement] = objects[presets[presetNum].preset[iElement].low_object];
- }
- AddInternatLATsInPreset(presets[presetNum],objects['LAT'],spaces[presetNum]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement