def init_particles(this): # Initialize the particles on each node maxNp = np.max(this.nParticles) if this.display > 3: ms = [Mesh(v=this.scanMesh.v, f=this.scanMesh.f).set_vertex_colors('SeaGreen')] # Number of particles on each node n = np.zeros((this.nNodes)) k = 0 for p in range(int(maxNp)): Pw, r_abs, t, Zp, Zs = get_sample_from_model.get_sample(this.body, this.nB[this.torso], this.nB, this.nBshape[this.torso], add_global_rotation=this.init_with_global_rotation, init_torso_rotation=this.init_torso_rotation) this.body.r_abs = r_abs t = t + this.init_torso_location this.body.t = t for i in this.nodeIdx: this.body.Zs[i] = Zs this.body.Zp = Zp for i in this.nodeIdx: if n[i] < this.nParticles[i]: this.b[i]['x'][:,p] = particles.get_from_sbm_with_init_location_noise(this, this.body, i) n[i] = n[i]+1 if this.display > 4: partSet = this.body.partSet P = ba.get_sbm_points_per_part(this.body) for part in partSet: ms.append(Mesh(v=P[part], f=this.body.partFaces[part]).set_vertex_colors(this.body.colors[part])) if this.display > 4: mv = MeshViewer() mv.set_static_meshes(ms)
def show_all_particles(this, faustId, nParticles, s): """ @params: this, a dpmp object @params: faustId, ID of the faust scan, only used for the filename of the picture @params: nParticles, how many particles to show @params: step, only used for the filename of the picture """ ms = [ Mesh(v=this.scanMesh.v, f=this.scanMesh.f).set_vertex_colors('firebrick') ] for i in range(0, nParticles): for part in this.body.partSet: P = particles.particle_to_points(this, this.b[part]['x'][:, i], part) ms.append( Mesh(v=P, f=this.body.partFaces[part]).set_vertex_colors( this.body.colors[part])) mv = MeshViewer() #mv.set_background_color(np.array([1.0, 1.0, 1.0])) mv.set_static_meshes(ms) time.sleep(4) mv.save_snapshot('particles_' + faustId + '_' + str(s) + '.png', blocking=True)
def show_mesh(this, P, dbstop=False, mesh=None, scan=None, filename=None, Pwo=None): # P is a list of parts mv = MeshViewer() #mv.set_background_color(np.array([1.0, 1.0, 1.0])) ms = [Mesh(v=P[part], f=this.partFaces[part]).set_vertex_colors('light blue') for part in this.partSet] if mesh is not None: ms2 = [Mesh(v=mesh[part], f=this.partFaces[part]).set_vertex_colors('SeaGreen') for part in this.partSet] ms = ms + ms2 if scan is not None: s = [Mesh(v=scan.v, f=scan.f).set_vertex_colors('firebrick')] ms = ms + s if Pwo is not None: ms2 = [Mesh(v=Pwo[part], f=this.partFaces[part]).set_vertex_colors('turquoise3') for part in this.partSet] ms = ms + ms2 mv.set_static_meshes(ms) if filename is not None: time.sleep(1) mv.save_snapshot(filename, blocking=True) if dbstop: import pdb pdb.set_trace() else: time.sleep(4)
def show_all_particles(this, faustId, nParticles, s): """ @params: this, a dpmp object @params: faustId, ID of the faust scan, only used for the filename of the picture @params: nParticles, how many particles to show @params: step, only used for the filename of the picture """ ms = [Mesh(v=this.scanMesh.v, f=this.scanMesh.f).set_vertex_colors('firebrick')] for i in range(0, nParticles): for part in this.body.partSet: P = particles.particle_to_points(this, this.b[part]['x'][:,i], part) ms.append(Mesh(v=P, f=this.body.partFaces[part]).set_vertex_colors(this.body.colors[part])) mv = MeshViewer() #mv.set_background_color(np.array([1.0, 1.0, 1.0])) mv.set_static_meshes(ms) time.sleep(4) mv.save_snapshot('particles_'+faustId+'_'+str(s)+'.png', blocking=True)
def show_mesh(this, P, dbstop=False, mesh=None, scan=None, filename=None, Pwo=None): # P is a list of parts mv = MeshViewer() #mv.set_background_color(np.array([1.0, 1.0, 1.0])) ms = [ Mesh(v=P[part], f=this.partFaces[part]).set_vertex_colors('light blue') for part in this.partSet ] if mesh is not None: ms2 = [ Mesh(v=mesh[part], f=this.partFaces[part]).set_vertex_colors('SeaGreen') for part in this.partSet ] ms = ms + ms2 if scan is not None: s = [Mesh(v=scan.v, f=scan.f).set_vertex_colors('firebrick')] ms = ms + s if Pwo is not None: ms2 = [ Mesh(v=Pwo[part], f=this.partFaces[part]).set_vertex_colors('turquoise3') for part in this.partSet ] ms = ms + ms2 mv.set_static_meshes(ms) if filename is not None: time.sleep(1) mv.save_snapshot(filename, blocking=True) if dbstop: import pdb pdb.set_trace() else: time.sleep(4)