示例#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.hexagons,self.pentagons=generate_fulleren(side_length) 
   self.ls=Localview()
示例#2
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.hexagons, self.pentagons = generate_fulleren(side_length)
        self.ls = Localview()
示例#3
0
  def __init__(self,side_length,display_mode="lined",lines_color=False,pentagons_color=False,hexagons_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.
        pentagons_color = an objet <type 'Color'> representing the pentagons color.
                          an 12-items-list contains <type 'Color'> objects.  
        hexagons_color  = an objet <type 'Color'> representing the hexagons color.
                          an 20-items-list contains <type 'Color'> objects. 
        line_width      = an integer representing the lines width.
    '''
    
    if not isinstance(side_length,int) and not isinstance(side_length,float) :
      raise TypeError(int,float)
    elif side_length <= 0.0 :
      raise ValueError("Value of 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("lined","faced","twice")
    
    if lines_color :
      if not isinstance(lines_color,Color) :
        raise TypeError(lines_color,Color)
      
    
    if pentagons_color :
      if not isinstance(pentagons_color,Color) and not isinstance(pentagons_color,list) :
        raise TypeError(pentagons_color,Color,list)
      elif isinstance(pentagons_color,list) and len(pentagons_color) != 12 :
	print "Error pentagons_color argument:\nYou must give an list from 12 Color objects.\nOne Color object per face."
	quit()
      elif isinstance(pentagons_color,list) and len(pentagons_color) == 12 :
        tmp=[]
        pentagons_color_index=0
        while pentagons_color_index < 12 :
	  if type(pentagons_color[pentagons_color_index].a) == bool :
	    pentagons_color[pentagons_color_index].a=0
	  pentagons_color_index += 1
      
    if hexagons_color :
      if not isinstance(hexagons_color,Color) and not isinstance(hexagons_color,list) :
        raise TypeError(hexagons_color,Color,list)
      elif isinstance(hexagons_color,list) and len(hexagons_color) != 20 :
	print "Error hexagons_color argument:\nYou must give an list from 20 Color objects.\nOne Color object per face."
	quit()
      elif isinstance(hexagons_color,list) and len(hexagons_color) == 20 :
        tmp=[]
        hexagons_color_index=0
        while hexagons_color_index < 20 :
	  if type(hexagons_color[hexagons_color_index].a) == bool :
	    hexagons_color[hexagons_color_index].a=0
	  hexagons_color_index += 1    
        
    
    if not isinstance(lines_width,int) :
      raise TypeError(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(pentagons_color,Color) :
      if type(pentagons_color.a) == bool :
	pentagons_color.a=0
	
    if isinstance(hexagons_color,Color) :
      if type(hexagons_color.a) == bool :
	hexagons_color.a=0 	
    
    if isinstance(display_ls,bool) :
      self.display_ls=display_ls
    
    self.side_length=side_length
    self.lines_color=lines_color
    self.pentagons_color=pentagons_color
    self.hexagons_color=hexagons_color
    self.lines_width=lines_width
    self.hexagons,self.pentagons=generate_fulleren(side_length)
    self.ls=Localview()
    
    self.center=Vertex(0.0,0.0,0.0)    
示例#4
0
    def __init__(self,
                 side_length,
                 display_mode="lined",
                 lines_color=False,
                 pentagons_color=False,
                 hexagons_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.
        pentagons_color = an objet <type 'Color'> representing the pentagons color.
                          an 12-items-list contains <type 'Color'> objects.  
        hexagons_color  = an objet <type 'Color'> representing the hexagons color.
                          an 20-items-list contains <type 'Color'> objects. 
        line_width      = an integer representing the lines width.
    '''

        if not isinstance(side_length, int) and not isinstance(
                side_length, float):
            raise TypeError(int, float)
        elif side_length <= 0.0:
            raise ValueError("Value of 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("lined", "faced", "twice")

        if lines_color:
            if not isinstance(lines_color, Color):
                raise TypeError(lines_color, Color)

        if pentagons_color:
            if not isinstance(pentagons_color, Color) and not isinstance(
                    pentagons_color, list):
                raise TypeError(pentagons_color, Color, list)
            elif isinstance(pentagons_color,
                            list) and len(pentagons_color) != 12:
                print "Error pentagons_color argument:\nYou must give an list from 12 Color objects.\nOne Color object per face."
                quit()
            elif isinstance(pentagons_color,
                            list) and len(pentagons_color) == 12:
                tmp = []
                pentagons_color_index = 0
                while pentagons_color_index < 12:
                    if type(pentagons_color[pentagons_color_index].a) == bool:
                        pentagons_color[pentagons_color_index].a = 0
                    pentagons_color_index += 1

        if hexagons_color:
            if not isinstance(hexagons_color, Color) and not isinstance(
                    hexagons_color, list):
                raise TypeError(hexagons_color, Color, list)
            elif isinstance(hexagons_color,
                            list) and len(hexagons_color) != 20:
                print "Error hexagons_color argument:\nYou must give an list from 20 Color objects.\nOne Color object per face."
                quit()
            elif isinstance(hexagons_color,
                            list) and len(hexagons_color) == 20:
                tmp = []
                hexagons_color_index = 0
                while hexagons_color_index < 20:
                    if type(hexagons_color[hexagons_color_index].a) == bool:
                        hexagons_color[hexagons_color_index].a = 0
                    hexagons_color_index += 1

        if not isinstance(lines_width, int):
            raise TypeError(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(pentagons_color, Color):
            if type(pentagons_color.a) == bool:
                pentagons_color.a = 0

        if isinstance(hexagons_color, Color):
            if type(hexagons_color.a) == bool:
                hexagons_color.a = 0

        if isinstance(display_ls, bool):
            self.display_ls = display_ls

        self.side_length = side_length
        self.lines_color = lines_color
        self.pentagons_color = pentagons_color
        self.hexagons_color = hexagons_color
        self.lines_width = lines_width
        self.hexagons, self.pentagons = generate_fulleren(side_length)
        self.ls = Localview()

        self.center = Vertex(0.0, 0.0, 0.0)