def populate(self): """ Function that creates the dataset samples. :return: """ s = time() renderer = Renderer(mode=0) lightmanager = LightManager() cameramanager = CameraManager() for i in range(self.size): lightmanager.make() building = self.factory.produce() building.make() if use_materials: _monomaterial = np.random.random() < MATERIAL_PROB mat = self.material_factory.produce() for v in building.volumes: if not _monomaterial: mat = self.material_factory.produce() v.apply(mat) v.add_modules() self.json.add(building, '{}.png'.format(i), '{}.obj'.format(i)) cameramanager.make_main() renderer.render(filename='building_{}'.format(i)) if RENDER_VIEWS > 1: for view in range(1, RENDER_VIEWS): cameramanager.make() lightmanager.make() if RANDOMIZE_TEXTURES: if use_materials: _monomaterial = np.random.random() < MATERIAL_PROB mat = self.material_factory.produce() for v in building.volumes: if not _monomaterial: mat = self.material_factory.produce() v.apply(mat) renderer.render(filename='building_{}_{}'.format(i, view)) building.save(i) building.save(i, ext='ply') building.demolish() cloud = PointCloud() cloud.make(i) print('Whole process took: {}'.format(time() - s))
def populate(self): for i in range(self.size): building = self.factory.produce() building.make() if use_materials: _monomaterial = np.random.random() < MATERIAL_PROB mat = self.material_factory.produce() print(mat.name) for v in building.volumes: if not _monomaterial: mat = self.material_factory.produce() v.apply(mat) for module_name in MODULES: for side in range(2): mod = GridApplier( ModuleFactory().mapping[module_name]) module = ModuleFactory().produce(module_name) module.connect(v, side) step = (np.random.randint(ceil(module.scale[0]), 6), np.random.randint(ceil(module.scale[0]), 6)) mod.apply(module, step=step, offset=(2.0, 2.0, 2.0, 1.0)) self.json.add(building, '{}.png'.format(i), '{}.obj'.format(i)) # building.save(filename=str(i)) renderer = Renderer(mode=0) renderer.render(filename='building_{}'.format(i)) building.save(i) building.save(i, ext='ply') building.demolish() cloud = PointCloud() cloud.make(i)
for j, v in enumerate(collection.collection): mod = GridApplier(Window) w = Window() w.connect(v, 1) step = (np.random.randint(1, 6), np.random.randint(1, 6)) if j == 0: mod.apply(w, step=step, offset=(2.0, 2.0, 2.0, 1.0)) else: mod.apply(w, step=step) w = Window() w.connect(v, 0, 0) step = (np.random.randint(1, 6), np.random.randint(1, 6)) if j == 0: mod.apply(w, step=step, offset=(2.0, 2.0, 2.0, 1.0)) else: mod.apply(w, step=step) renderer = Renderer(mode=0) renderer.render(filename='building_{}'.format(image)) building.save(image) building.save(image, ext='ply') building.demolish() cloud = PointCloud() cloud.make(image) # cloud = PyntCloud.from_file("Models/{}.obj".format(image)) # cloud.to_file("{}.ply".format(image)) # cloud.to_file("{}.npz".format(image))