def generate(self): g.cloud(self.an,name='scene',color='r',dice=6,R=1,access='new') try : ll=np.shape(self.bn)[1] for i in range (ll): g.cloud(self.bn[i,:],display=False,name='scene',color='g',dice=6,access='append') except : g.cloud(self.bn,display=False,name='scene',color='g',dice=6,access='append')
def generate(self): g.cloud(self.an, name='scene', color='r', dice=6, R=1, access='new') try: ll = np.shape(self.bn)[1] for i in range(ll): g.cloud(self.bn[i, :], display=False, name='scene', color='g', dice=6, access='append') except: g.cloud(self.bn, display=False, name='scene', color='g', dice=6, access='append')
def show3(self): """ display constraint on Geomview The filename is boxes{Id}.list Id is the Id of the current constraint """ if self.runable: fname = 'boxes' + str(self.id) filename = basename + "/geom/" + fname + ".list" fd = open(filename, "w") fd.write("LIST\n") # # Display scene # if self.parmsh['scene']: fd.write("{<scene.list}\n") # # Display boxes # # if self.parmsh['mode']=='Full': # H_Id=self.history[-1].Id+1 # # # # Display all boxes # # # for k in range(len(self.history)): # cons = self.history[k] # constraint k # lb = cons.lbox # lb.parmsh['display']=False # filename2=lb.show3(Id=cons.Id) # fd.write("{<"+filename2+"}\n") elif self.parmsh['mode'] == 'Current': # # Display current box # color = ['m', 'g', 'c', 'y', 'm', 'b', 'r', 'm', 'g', 'c', 'y', 'orange', 'skyblue'] #color = ['skyblue','skyblue','orange'] if self.parmsh['boxes']: lb = self.lbox lb.parmsh['display'] = False filename2 = lb.show3(Id=[self.id], col='m') # )color[self.Id]) fd.write("{<" + filename2 + "}\n") # # Display Spherical Constraint # if self.parmsh['quadric']: if self.type == 'TOA': c1 = str(self.range + self.vcw * self.sstd) c2 = str(max(0, self.range - self.vcw * self.sstd)) try: c3 = str(self.p[0]) + " " + str(self.p[1]) + " " + \ str(self.p[2]) except: c3 = str(self.p[0]) + " " + str(self.p[ 1]) + " " + str(0) fd.write("{appearance {-edge patchdice 10 10 material {alpha 0.2}} {SPHERE " + c1 + " " + c3 + " }}\n") fd.write("{appearance {-edge patchdice 10 10 material {alpha 0.2}} {SPHERE " + c2 + " " + c3 + " }}\n") fd.close() # # Display points # if self.parmsh['point']: if self.type != 'Fusion': g.cloud(self.p, name=fname, color='g', dice=6, access='append') if self.evaluated: if self.parmsh['estimated']: g.cloud(self.pe, name=fname, color='b', dice=6, access='append') if self.parmsh['estimated_LS']: g.cloud(self.p_LS, name=fname, color='r', dice=6, access='append') if self.parmsh['grid']: if self.evaluated: g.cloud(self.g.p, name=fname, color='k', dice=2, R=0.1, access='append') if self.parmsh['display']: print filename chaine = "geomview -nopanel -b 1 1 1 " + \ filename + " 2>/dev/null &" os.system(chaine) else: return(fname) else: print 'constraint is not runnable. It can not be displayed'
def show3(self): """ display constraint on Geomview The filename is boxes{Id}.list Id is the Id of the current constraint """ if self.runable: fname = "boxes" + str(self.id) filename = basename + "/geom/" + fname + ".list" fd = open(filename, "w") fd.write("LIST\n") # # Display scene # if self.parmsh["scene"]: fd.write("{<scene.list}\n") # # Display boxes # # if self.parmsh['mode']=='Full': # H_Id=self.history[-1].Id+1 # # # # Display all boxes # # # for k in range(len(self.history)): # cons = self.history[k] # constraint k # lb = cons.lbox # lb.parmsh['display']=False # filename2=lb.show3(Id=cons.Id) # fd.write("{<"+filename2+"}\n") elif self.parmsh["mode"] == "Current": # # Display current box # color = ["m", "g", "c", "y", "m", "b", "r", "m", "g", "c", "y", "orange", "skyblue"] # color = ['skyblue','skyblue','orange'] if self.parmsh["boxes"]: lb = self.lbox lb.parmsh["display"] = False filename2 = lb.show3(Id=[self.id], col="m") # )color[self.Id]) fd.write("{<" + filename2 + "}\n") # # Display Spherical Constraint # if self.parmsh["quadric"]: if self.type == "TOA": c1 = str(self.range + self.vcw * self.sstd) c2 = str(max(0, self.range - self.vcw * self.sstd)) try: c3 = str(self.p[0]) + " " + str(self.p[1]) + " " + str(self.p[2]) except: c3 = str(self.p[0]) + " " + str(self.p[1]) + " " + str(0) fd.write( "{appearance {-edge patchdice 10 10 material {alpha 0.2}} {SPHERE " + c1 + " " + c3 + " }}\n" ) fd.write( "{appearance {-edge patchdice 10 10 material {alpha 0.2}} {SPHERE " + c2 + " " + c3 + " }}\n" ) fd.close() # # Display points # if self.parmsh["point"]: if self.type != "Fusion": g.cloud(self.p, name=fname, color="g", dice=6, access="append") if self.evaluated: if self.parmsh["estimated"]: g.cloud(self.pe, name=fname, color="b", dice=6, access="append") if self.parmsh["estimated_LS"]: g.cloud(self.p_LS, name=fname, color="r", dice=6, access="append") if self.parmsh["grid"]: if self.evaluated: g.cloud(self.g.p, name=fname, color="k", dice=2, R=0.1, access="append") if self.parmsh["display"]: print filename chaine = "geomview -nopanel -b 1 1 1 " + filename + " 2>/dev/null &" os.system(chaine) else: return fname else: print "constraint is not runnable. It can not be displayed"
def show3(self, l=-1, amb=False, sc='all'): """ Display constraints and theirs boxes through geomview. geomview parameters are the following self.parmsh['display']=False # launch geomview interactively self.parmsh['scene']=True # display whole scene self.parmsh['boxes']=True # display constraint box self.parmsh['constr_boxes']=False # display constraint box self.parmsh['estimated']=True # display estimated point ... .. todo: create a .ini file for geomview parameters :Parameters: l : layer number to observe. If -1 estimation is made on the highest available layer. default = -1 amb : display ambiguous boxes. default = false sc : display all constraint or give a list with the constrinat number to observe ex: [0,1,3]. default 'all' :Returns: Nothing but calls a geomview instance """ Nc = self.Nc filename = basename + "/geom/cla.list" fd = open(filename, "w") fd.write("LIST\n") par = self.parmsh if par['constr_boxes']: if l == -1: if sc == 'all': for c in self.c: if c.runable: c.parmsh['display'] = False c.parmsh['scene'] = False fname = c.show3() fd.write("{<" + fname + ".list}\n") else: try: for vsc in sc: if self.c[vsc].runable: self.c[vsc].parmsh['display'] = False self.c[vsc].parmsh['scene'] = False fname = self.c[vsc].show3() fd.write("{<" + fname + ".list}\n") except: if self.c[sc].runable: self.c[sc].parmsh['display'] = False self.c[sc].parmsh['scene'] = False fname = self.c[sc].show3() fd.write("{<" + fname + ".list}\n") else: if c[l].runable: self.c[l].parmsh['dispay'] = False self.c[l].parmsh['scene'] = False fname = self.c[l].show3() fd.write("{<" + fname + ".list}\n") col = ['r', 'b', 'g', 'm', 'y', 'b', 'r'] if par['scene']: an = np.zeros(len(self.bn)) for c in self.c: if c.runable: an = np.vstack((an, c.p)) S = Scene(an=an, bn=self.bn) sce = S.generate() if par['estimated']: try: sce = g.cloud(self.pe, display=False, name='scene', color='k', dice=6, access='append') fd.write("{<" + sce + "}\n") except: pass if par['boxes']: for l in self.dlayer.keys(): self.dlayer[l][0].parmsh['display'] = False self.dlayer[l][1].parmsh['display'] = False try: fname = self.dlayer[l][0].show3(col=col[Nc - l + 1], Id=l) fd.write("{<" + fname + "}\n") except: pass if amb: coco = ['r', 'v', 'b', 'y'] fname = self.dlayer[l][1].show3(col=col[Nc - l], Id=l + 1) # fname = self.dlayer[l][1].show3(col=coco,Id=l+1) fd.write("{<" + fname + "}\n") fd.close() chaine = "geomview -nopanel -b 1 1 1 " + filename + " 2>/dev/null &" os.system(chaine)