Example #1
0
 def set_toros_radius(self,toros_radius) :
   ''' Change the toros radius (without the base polygon radius). '''
   
   if not isinstance(toros_radius,int) and not isinstance(toros_radius,float) :
     raise TypeError("toros_radius argument",int,float)
   elif toros_radius <= 0.0 :
     raise ValueError("Value of toros_radius must be greater than 0.0") 
   
   self.toros_radius=toros_radius
   self.toros=generate_toros(self.base_polygon,self.base_radius,toros_radius)
   self.ls=Localview()
Example #2
0
  def set_base_polygon(self,base_polygon) :
    ''' Change the toros basis polygon. '''
    
    if not isinstance(base_polygon,int) :
      raise TypeError("base_polygon argument",int)

    if base_polygon <= 2 :
      print "the base polygon must be greater than 2 "
      quit()
    
    
    self.base_polygon=base_polygon
    self.toros=generate_toros(base_polygon,self.base_radius,self.toros_radius)
    self.ls=Localview()
Example #3
0
  def __init__(self,base_polygon,base_radius,toros_radius,display_mode="lined",lines_color=False,faces_color=False,lines_width=1,display_ls=False) :
    ''' Generate an toros object with the given radius and basis polygone settings.
    
        base_polygon = the toros basis polygon.
        base_radius  = the toros basis polygon radius.
        toros_radius = the toros radius (without the base polygon radius). 
        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(base_polygon,int) :
      raise TypeError("base_polygon argument",int)

    if base_polygon <= 2 :
      print "the base polygon must be greater than 2 "
      quit()
    
    
    if not isinstance(base_radius,int) and not isinstance(base_radius,float) :
      raise TypeError("base_radius argument",int,float)
    elif base_radius <= 0.0 :
      raise ValueError("Value of base_radius must be greater than 0.0") 
    
    
    if not isinstance(toros_radius,int) and not isinstance(toros_radius,float) :
      raise TypeError("toros_radius argument",int,float)
    elif toros_radius <= 0.0 :
      raise ValueError("Value of toros_radius 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) : 
        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 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.base_polygon=base_polygon
    self.base_radius=base_radius
    self.toros_radius=toros_radius
    self.lines_color=lines_color
    self.faces_color=faces_color
    self.lines_width=lines_width
    self.toros=generate_toros(base_polygon,base_radius,toros_radius)
    self.ls=Localview()
    self.center=Vertex(0.0,0.0,0.0)