Exemplo n.º 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.quads=generate_polyhedron_26_faces(side_length)
   self.ls=Localview()
Exemplo n.º 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.quads = generate_polyhedron_26_faces(side_length)
        self.ls = Localview()
Exemplo n.º 3
0
    def __init__(self,
                 side_length,
                 display_mode="lined",
                 lines_color=False,
                 quads_color=False,
                 triangles_color=False,
                 lines_width=1,
                 display_ls=False):
        ''' generate an 26 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.
        quads_color     = an objet <type 'Color'> representing the quads color.
                          an 18-items-list contains <type 'Color'> objects.  
        triangles_color = an objet <type 'Color'> representing the triangles color.
                          an 8-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 quads_color:
            if not isinstance(quads_color, Color) and not isinstance(
                    quads_color, list):
                raise TypeError(quads_color, Color, list)
            elif isinstance(quads_color, list) and len(quads_color) != 18:
                print "Error quads_color argument:\nYou must give an list from 18 Color objects.\nOne Color object per face."
                quit()
            elif isinstance(quads_color, list) and len(quads_color) == 18:
                tmp = []
                quads_color_index = 0
                while quads_color_index < 18:
                    if type(quads_color[quads_color_index].a) == bool:
                        quads_color[quads_color_index].a = 0
                    quads_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) != 8:
                print "Error triangles_color argument:\nYou must give an list from 8 Color objects.\nOne Color object per face."
                quit()
            elif isinstance(triangles_color,
                            list) and len(triangles_color) == 8:
                tmp = []
                triangles_color_index = 0
                while triangles_color_index < 8:
                    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(quads_color, Color):
            if type(quads_color.a) == bool:
                quads_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.quads_color = quads_color
        self.triangles_color = triangles_color
        self.lines_width = lines_width
        self.triangles, self.quads = generate_polyhedron_26_faces(side_length)
        self.ls = Localview()

        self.center = Vertex(0.0, 0.0, 0.0)
Exemplo n.º 4
0
  def __init__(self,side_length,display_mode="lined",lines_color=False,quads_color=False,triangles_color=False,lines_width=1,display_ls=False) :
    ''' generate an 26 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.
        quads_color     = an objet <type 'Color'> representing the quads color.
                          an 18-items-list contains <type 'Color'> objects.  
        triangles_color = an objet <type 'Color'> representing the triangles color.
                          an 8-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 quads_color :
      if not isinstance(quads_color,Color) and not isinstance(quads_color,list) :
        raise TypeError(quads_color,Color,list)
      elif isinstance(quads_color,list) and len(quads_color) != 18 :
	print "Error quads_color argument:\nYou must give an list from 18 Color objects.\nOne Color object per face."
	quit()
      elif isinstance(quads_color,list) and len(quads_color) == 18 :
        tmp=[]
        quads_color_index=0
        while quads_color_index < 18 :
	  if type(quads_color[quads_color_index].a) == bool :
	    quads_color[quads_color_index].a=0
	  quads_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) != 8 :
	print "Error triangles_color argument:\nYou must give an list from 8 Color objects.\nOne Color object per face."
	quit()
      elif isinstance(triangles_color,list) and len(triangles_color) == 8 :
        tmp=[]
        triangles_color_index=0
        while triangles_color_index < 8 :
	  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(quads_color,Color) :
      if type(quads_color.a) == bool :
	quads_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.quads_color=quads_color
    self.triangles_color=triangles_color
    self.lines_width=lines_width
    self.triangles,self.quads=generate_polyhedron_26_faces(side_length)
    self.ls=Localview()
    
    self.center=Vertex(0.0,0.0,0.0)