def test_fileDontExists(self): loader = ConfigFile('ConfigFileTest_test_fileDontExists.pyc') try: loadedConfig = loader.load() self.fail() except IOError: pass
def test_pickle(self): config = DayConfig() dayConfig = config.di dayConfig.startTime = time(5,0,0) pumpConfig = dayConfig.pumpPeriod pumpConfig.period = timedelta(minutes = 15) pumpConfig.duration = timedelta(minutes = 5) nigthConfig = config.noct nigthConfig.startTime = time(17,0,0) pumpConfig = nigthConfig.pumpPeriod pumpConfig.period = timedelta(minutes = 60) pumpConfig.duration = timedelta(minutes = 1) saver = ConfigFile('ConfigFileTest_test_pickle.pyc') saver.save(config) # TODO assert file exists loader = ConfigFile('ConfigFileTest_test_pickle.pyc') loadedConfig = loader.load() os.unlink('ConfigFileTest_test_pickle.pyc') loadedDayConfig = loadedConfig.di self.assertEqual(loadedDayConfig.startTime, time(5,0,0)) loadedPumpConfig = loadedDayConfig.pumpPeriod self.assertEqual(loadedPumpConfig.period, timedelta(minutes = 15)) self.assertEqual(loadedPumpConfig.duration, timedelta(minutes = 5))
assert A.shape[0] == b.shape[0] assert b.shape[1] == 3 LU = sparse.linalg.splu((A.T @ A).tocsc()) x = LU.solve(A.T @ b) vertices = x result = meshlib.Mesh(vertices=vertices[:len(self.target.vertices)], faces=self.target.faces) return result if __name__ == "__main__": import render.plot_result as plt_res import render.plot as plt # cfg = ConfigFile.load(ConfigFile.Paths.highpoly.horse_camel) cfg = ConfigFile.load(ConfigFile.Paths.lowpoly.catdog) # cfg = ConfigFile.load(ConfigFile.Paths.highpoly.cat_lion) corr_markers = cfg.markers # List of vertex-tuples (source, target) identity = False if identity: corr_markers = np.ascontiguousarray(np.array((corr_markers[:, 0], corr_markers[:, 0]), dtype=np.int).T) ######################################################### # Load meshes original_source = meshlib.Mesh.load(cfg.source.reference) original_pose = meshlib.Mesh.load(cfg.source.poses[0]) original_target = meshlib.Mesh.load(cfg.target.reference) if identity: original_target = meshlib.Mesh.load(cfg.source.reference)
source_rotated, text=[ f"<b>Vertex:</b> {n}" for n in range(len(source_rotated.vertices)) ], name="Source", **mesh_kwargs, ), row=1, col=1) fig.add_trace(BrowserVisualizer.make_mesh( target_rotated, text=[ f"<b>Vertex:</b> {n}" for n in range(len(target_rotated.vertices)) ], name="Target", **mesh_kwargs, ), row=1, col=2) return fig if __name__ == "__main__": cfg = ConfigFile.load(ConfigFile.Paths.highpoly.horse_camel) source = Mesh.load(cfg.source.reference) target = Mesh.load(cfg.target.reference) markers = cfg.markers plot(source, target).show(renderer="browser")
]) for p in results ]) camera = dict(up=dict(x=0, y=1, z=0)) scene = dict(aspectmode='data', xaxis_title='X', yaxis_title='Z', zaxis_title='Y', camera=camera, dragmode='turntable') fig.update_layout( scene=scene, scene2=scene, yaxis=dict(scaleanchor="x", scaleratio=1), yaxis2=dict(scaleanchor="x", scaleratio=1), margin=dict(l=0, r=0), # scene_camera=camera ) return fig def animate(transf: Transformation, poses: Sequence[meshlib.Mesh]): fig = make_animation(transf, poses) fig.show(renderer="browser") if __name__ == "__main__": # cfg = ConfigFile.load(ConfigFile.Paths.highpoly.horse_camel) cfg = ConfigFile.load("models/lowpoly/markers-cat-voxel.yml") # cfg = ConfigFile.load(ConfigFile.Paths.highpoly.cat_lion) animate_cfg(cfg)