コード例 #1
0
ファイル: pyglutCube.py プロジェクト: mrcyberfighter/pyglut
 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.polyhedron=generate_cube(side_length)
   self.ls=Localview()
コード例 #2
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()
コード例 #3
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()
コード例 #4
0
ファイル: pyglutToros.py プロジェクト: mrcyberfighter/pyglut
 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()
コード例 #5
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()
コード例 #6
0
ファイル: pyglutToros.py プロジェクト: mrcyberfighter/pyglut
  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()
コード例 #7
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)
コード例 #8
0
    def __init__(self,
                 side_length,
                 display_mode="lined",
                 lines_color=False,
                 faces_color=False,
                 lines_width=1,
                 display_ls=False):
        ''' Generate an Icosahedron 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.
        faces_color  = An objet <type 'Color'> representing the faces color.
                       An 8-items-list from object <type 'Color'>.
                       One item per icosahedron face. 
        lines_width  = An integer representing the lines width.
        display_ls   = Define if the localview should be display.
    '''

        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")

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

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

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

        self.side_length = side_length
        self.lines_color = lines_color
        self.faces_color = faces_color
        self.lines_width = lines_width
        self.polyhedron = generate_icosahedron(side_length)[1]
        self.ls = Localview()

        self.center = Vertex(0.0, 0.0, 0.0)
コード例 #9
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)    
コード例 #10
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)
コード例 #11
0
ファイル: pyglutToros.py プロジェクト: mrcyberfighter/pyglut
  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)