예제 #1
0
 def set_side_length(self,side_length) :
   if not isinstance(side_length,int) and not isinstance(side_length,float) :
     raise TypeError("Argument side_length",int,float)
   elif side_length < 0.0 :
     raise ValueError("Value of argument side_length must be greater than 0.0") 
   
   self.side_length=side_length
   self.polyhedron=generate_cube(side_length)
   self.ls=Localview()
예제 #2
0
  def __init__(self,side_length,display_mode="lined",lines_color=False,faces_color=False,lines_width=1,display_ls=False) :
    ''' Generate an cube object with the given side length settings.
        
        display_mode = "lined" -> Only the lines will be displayed.
        display_mode = "faced" -> Only the faces will be displayed.
        display_mode = "twice" -> The lines and the faces will be displayed.
        lines_color  = An objet <type 'Color'> representing the lines color.
        faces_color  = An objet <type 'Color'> representing the faces color.
                       An 6-items-list from object <type 'Color'>.
                       One item per cube face. 
        lines_width  = An integer representing the lines width.
        display_ls   = Define if the localview should be display.
    '''
    
    if not isinstance(side_length,int) and not isinstance(side_length,float) :
      raise TypeError("Argument side_length",int,float)
    elif side_length <= 0.0 :
      raise ValueError("Value of argument side_length must be greater than 0.0") 
    
    if display_mode == "lined" or display_mode == "faced" or display_mode == "twice" :
      self.display_mode=display_mode
    else :
      raise ValueError("Argument display_mode","lined","faced","twice")
    
    if lines_color :
      if not isinstance(lines_color,Color) :
        raise TypeError("Argument lines_color",Color)
    
    if faces_color :
      if not isinstance(faces_color,Color) and not isinstance(faces_color,list) :
        raise TypeError(faces_color,Color,list)
      elif isinstance(faces_color,list) and len(faces_color) != 6 :
	print "Error faces_color argument:\nYou must give an list from 6 Color objects.\nOne Color object per face."
	quit()
      elif isinstance(faces_color,list) and len(faces_color) == 6 :
        tmp=[]
        faces_color_index=0
        while faces_color_index < 6 :
	  if type(faces_color[faces_color_index].a) == bool :
	    faces_color[faces_color_index].a=0
	  faces_color_index += 1
      
         	
    
    if not isinstance(lines_width,int) :
      raise TypeError("Argument lines_width",int)
    elif lines_width < 1 :
      raise ValueError(lines_width,"Lines width value too little.") 
    
    if isinstance(lines_color,Color) :
      if type(lines_color.a) == bool :
        lines_color.a=0
    
    if isinstance(faces_color,Color) :
      if type(faces_color.a) == bool :
	faces_color.a=0
    
    if isinstance(display_ls,bool) :
      self.display_ls=display_ls
    
    self.side_length=side_length
    self.lines_color=lines_color
    self.faces_color=faces_color
    self.lines_width=lines_width
    self.polyhedron=generate_cube(side_length)
    self.ls=Localview()
    
    self.center=Vertex(0.0,0.0,0.0)