Ejemplo n.º 1
0
	def main(self):
		""" Data parsing/processing section"""
		# parse input data 
		strip=Parse(self.input)
		parsed_data=strip.getStripText()	# Parse input data
		need_compress_catagory=strip.getNeedCompreeCatagory()	# Check which catagories need group
		grouped_data=strip.getGroupedParsedData()	# Group data

		""" Cuboid construction section """
		#Create cuboid
		division_factor=3
		min_sup=len(grouped_data)/division_factor	# Iceberg condition
		cuboid=Cuboid(strip.getRowConuter(), min_sup)
		oneDimensionTable=cuboid.getOneDimensionTable()	# Conduct 1-D aggregate
		compressedBaseTable=cuboid.getCompressedBaseTable(grouped_data, need_compress_catagory)	# Construct compressed base table

		""" Star tree/table construction section"""
		#Construct star tree and star table
		s_t=Cubing(compressedBaseTable)
		root=s_t.starCubing()
		#s_t.constructStarTree()

		""" Test/Output section """
		# test results
		t=Test()
		t.testParsedData(parsed_data)	# Test if parsed data is correct
		t.testNeedCompressCatagory(need_compress_catagory) # Test which catagory needs compress
		t.testGroupedParsedData(grouped_data)	# Test grouped data
		t.testOneDimensionAggregatation(oneDimensionTable,need_compress_catagory, min_sup)	# Test 1-D aggregation
		t.testCompressedBaseTable(compressedBaseTable)	# Test node-ordered compressed base table
		t.testStarTree(root,0,s_t.count,'')
Ejemplo n.º 2
0
def load_map(map):
    y = 0
    for line in map:
        x = 0
        for tile in line:
            if tile == "#":
                objects.append(
                    Cuboid(TILE_SIZE * x, TILE_SIZE * y, 0, TILE_SIZE,
                           TILE_SIZE, TILE_SIZE * 2, (64, 100, 64)))
            x += 1
        y += 1
Ejemplo n.º 3
0
def importObjects(filePath: str):
    i = 0
    objects = []
    with open(os.path.join(__location__, filePath), "r") as inFile:
        lines = inFile.read().splitlines()
        for line in lines:
            if (len(line) > 0) and (line[0] != '#'):
                name, parameters = line.split('(', 1)
                name = name.strip()
                parameters = parameters.strip()[:-1]
                if (name == 'Cuboid'):
                    p = re.findall(r"\([ -]*\d+ *\,[ -]*\d+ *\,[ -]*\d+ *\)",
                                   parameters)
                    color = str(re.findall(r"[a-zA-Z]+", parameters)[0])
                    try:
                        position, dimension = p[0], p[1]
                        position = re.findall(r"-*\w+", position)
                        dimension = re.findall(r"-*\w+", dimension)
                        position = [float(x) for x in position]
                        dimension = [float(x) for x in dimension]
                        try:
                            objects.append(
                                Cuboid(
                                    Vector3(position[0], position[1],
                                            position[2]),
                                    Vector3(dimension[0],
                                            dimension[1], dimension[2]),
                                    Vector3(0, 0, 0), [color]))
                            i += 1
                        except:
                            raise Exception("Niepowodzenie utworzenia obiektu")
                    except Exception as err:
                        raise Exception(err)
                else:
                    raise Exception("Figura o podanej nazwie nie istnieje")
    return objects
Ejemplo n.º 4
0
from Sphere import Sphere
from Cuboid import Cuboid

spRadius = float(input())
spColor = str(input())

cuLength = float(input())
cuWidth = float(input())
cuHeight = float(input())
cuColor = str(input())

sp = Sphere(spRadius, spColor)
cu = Cuboid(cuLength, cuWidth, cuHeight, cuColor)

print(
    str(sp) + ":(%d),%.1f,%s" %
    (sp.getRadius(), sp.getVolume(), sp.getColor()))
print(
    str(cu) + ":(%d,%d,%d),%.1f,%s" %
    (cu.getLength(), cu.getWidth(), cu.getHeight(), cu.getVolume(),
     cu.getColor()))
from Sphere import Sphere
from Cuboid import Cuboid

radius = int(input())
scolor = str(input())
l = float(input())
w = float(input())
h = float(input())
ccolor = str(input())

sphere = Sphere(radius)
sphere.setColor(scolor)

cuboid = Cuboid(l, w, h)
cuboid.setColor(ccolor)

print("{}({}),{},{}".format(sphere.__str__(), sphere.getRadius(),
                            round(sphere.getVolume(), 1), sphere.getColor()))
print("{}({},{},{}),{},{}".format(cuboid.__str__(), int(cuboid.getLength()),
                                  int(cuboid.getWidth()),
                                  int(cuboid.getHeight()),
                                  round(cuboid.getVolume(), 1),
                                  cuboid.getColor()))
Ejemplo n.º 6
0
from Shape import Shape
from Cuboid import Cuboid
from Sphere import Sphere

#main

inp = []
for i in range(6):
    inp.append(input())

sphere = Sphere(int(inp[0]), inp[1])
cubiod = Cuboid(int(inp[2]), int(inp[3]), int(inp[4]), inp[5])

print("{}:({}),{},{}".format(str(sphere), sphere.getRadius(),
                             sphere.getVolume(), sphere.getColor()))
print("{}:({},{},{}),{},{}".format(str(cubiod), cubiod.getLength(),
                                   cubiod.getWidth(), cubiod.getHeight(),
                                   cubiod.getVolume(), cubiod.getColor()))
Ejemplo n.º 7
0
from Cuboid import Cuboid
from Sphere import Sphere

radius = int(input())
c1 = input()
length = float(input())
width = float(input())
height = float(input())
c2 = input()

sphere = Sphere(radius, c1)
cuboid = Cuboid(length, width, height, c2)

print("{}({}),{},{}".format(sphere.__str__(), sphere.getRadius(), sphere.getVolume(), sphere.getColor()))
print("{}({},{},{}),{},{}".format(cuboid.__str__(), int(cuboid.getLength()), int(cuboid.getWidth()), int(cuboid.getHeight()), cuboid.getVolume(), cuboid.getColor()))
Ejemplo n.º 8
0
from Shape import Shape
from Sphere import Sphere
from Cuboid import Cuboid
list = []
for i in range(6):
    list.append(input())
a = Sphere(int(list[0]))
b = Shape(list[1])
c = Cuboid(int(list[2]), int(list[3]), int(list[4]))
f = Shape(list[5])
print(str(a), ":(", a.getRadius(), "),", round(a.getVolume(), 1), ",",
      b.getColor())
print(str(c),
      ":(",
      c.getLength(),
      ",",
      c.getWidth(),
      ",",
      c.getHeight(),
      "),",
      c.getVolume(),
      ",",
      f.getColor(),
      sep='')