Example #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.triangles,self.pentagons=generate_polyhedron_32_faces(side_length)
   self.ls=Localview()
Example #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.triangles, self.pentagons = generate_polyhedron_32_faces(
            side_length)
        self.ls = Localview()
Example #3
0
    def __init__(self,
                 side_length,
                 display_mode="lined",
                 lines_color=False,
                 pentagons_color=False,
                 triangles_color=False,
                 lines_width=1,
                 display_ls=False):
        ''' generate an 36 faces polyhedron 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.  
        triangles_color = an objet <type 'Color'> representing the triangles 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 20 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 triangles_color:
            if not isinstance(triangles_color, Color) and not isinstance(
                    triangles_color, list):
                raise TypeError(triangles_color, Color, list)
            elif isinstance(triangles_color,
                            list) and len(triangles_color) != 20:
                print "Error triangles_color argument:\nYou must give an list from 20 Color objects.\nOne Color object per face."
                quit()
            elif isinstance(triangles_color,
                            list) and len(triangles_color) == 20:
                tmp = []
                triangles_color_index = 0
                while triangles_color_index < 20:
                    if type(triangles_color[triangles_color_index].a) == bool:
                        triangles_color[triangles_color_index].a = 0
                    triangles_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(triangles_color, Color):
            if type(triangles_color.a) == bool:
                triangles_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.triangles_color = triangles_color
        self.lines_width = lines_width
        self.triangles, self.pentagons = generate_polyhedron_32_faces(
            side_length)
        self.ls = Localview()

        self.center = Vertex(0.0, 0.0, 0.0)
Example #4
0
  def __init__(self,side_length,display_mode="lined",lines_color=False,pentagons_color=False,triangles_color=False,lines_width=1,display_ls=False) :
    ''' generate an 36 faces polyhedron 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.  
        triangles_color = an objet <type 'Color'> representing the triangles 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 20 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 triangles_color :
      if not isinstance(triangles_color,Color) and not isinstance(triangles_color,list) :
        raise TypeError(triangles_color,Color,list)
      elif isinstance(triangles_color,list) and len(triangles_color) != 20 :
	print "Error triangles_color argument:\nYou must give an list from 20 Color objects.\nOne Color object per face."
	quit()
      elif isinstance(triangles_color,list) and len(triangles_color) == 20 :
        tmp=[]
        triangles_color_index=0
        while triangles_color_index < 20 :
	  if type(triangles_color[triangles_color_index].a) == bool :
	    triangles_color[triangles_color_index].a=0
	  triangles_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(triangles_color,Color) :
      if type(triangles_color.a) == bool :
	triangles_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.triangles_color=triangles_color
    self.lines_width=lines_width
    self.triangles,self.pentagons=generate_polyhedron_32_faces(side_length)
    self.ls=Localview()
    
    self.center=Vertex(0.0,0.0,0.0)