Esempio n. 1
0
 def set_radius(self,radius) :
   ''' Change the trigon sphere radius. '''
   
   if not isinstance(radius,int) and not isinstance(radius,float) :
     raise TypeError(int,float)
   elif radius < 0.0 :
     raise ValueError("Value of radius must be greater than 0.0") 
   
   self.radius=radius
   self.trigons=generate_trigon_sphere(self.basis,radius)[0]
   self.ls=Localview()
Esempio n. 2
0
  def set_basis(self,basis) :
    ''' Change the trigon sphere basis. '''
    
    if not isinstance(basis,int) :
      raise TypeError(int)

    if basis < 6 or basis % 2 :
      print "the basis for the sphere must be greater as 5 and basis % 2 == 0 "
      quit()
    
    self.basis=basis
    self.trigons=generate_trigon_sphere(basis,self.radius)[0]
    self.ls=Localview()
Esempio n. 3
0
  def __init__(self,radius,basis,display_mode="lined",lines_color=False,faces_color=False,lines_width=1,display_ls=False) :
    ''' generate an trigon sphere object with the given radius and polygone basis.
    
        basis        = Integer taken as basis for the sphere generating.  
        radius       = Radius of the sphere. 
        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.
        line_width   = an integer representing the lines width.
    '''
    
    if not isinstance(radius,int) and not isinstance(radius,float) :
      raise TypeError(int,float)
    elif radius <= 0.0 :
      raise ValueError("Value of radius must be greater than 0.0") 
    
    if not isinstance(basis,int) :
      raise TypeError(int)

    if basis < 6 or basis % 4 :
      print "the basis for the sphere must be greater as 5 and basis % 4 == 0 "
      quit()
    
    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) : 
        raise TypeError("Argument faces_color",Color)
      
      
         	
    
    if not isinstance(lines_width,int) :
      raise TypeError(lines_width,int)
    elif lines_width < 1 :
      raise ValueError("Lines width value too little.") 
    
    if isinstance(lines_color,Color) :
      if type(lines_color.a) == bool :
        lines_color.a=0
    
    if not type(faces_color) == bool :
      if type(faces_color.a) == bool :
	faces_color.a=0
    
    if isinstance(display_ls,bool) :
      self.display_ls=display_ls
    
    self.lines_color=lines_color
    self.faces_color=faces_color
    self.lines_width=lines_width
    self.basis=basis
    self.radius=radius
    self.trigons=generate_trigon_sphere(basis,radius)[0]
    self.ls=Localview()
    
    self.center=Vertex(0.0,0.0,0.0)