def display(self) : if self.display_mode == "lined" : # Configuration of polygons lines displaying. glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) for polygon in self.hexagons : # Loop over every hexagon from the polyhedron. # For only lines displaying. glBegin(GL_POLYGON) for lines in polygon : for v in lines : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() elif self.display_mode == "faced" : # Configuration of polygons faces displaying. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.pentagons_color and isinstance(self.pentagons_color,Color) : # Case one same color for the faces displaying. glColor4ubv(self.pentagons_color.get_ubyte_v()) pentagons_color_index=0 # Iterator, case there are more than one color for the faces displaying. if self.pentagons_color and isinstance(self.pentagons_color,Color) : # Case one same color for the faces displaying. glColor4ubv(self.pentagons_color.get_ubyte_v()) for polygon in self.pentagons : # Loop over every pentagon from the polyhedron. if self.pentagons_color and isinstance(self.pentagons_color,list) : # Case there are more than one color for the faces displaying. glColor4ubv(self.pentagons_color[pentagons_color_index].get_ubyte_v()) glBegin(GL_POLYGON) for lines in polygon : for v in lines : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() pentagons_color_index += 1 if self.hexagons_color and isinstance(self.hexagons_color,Color) : # Case one same color for the faces displaying. glColor4ubv(self.hexagons_color.get_ubyte_v()) hexagons_color_index=0 # Iterator, case there are more than one color for the faces displaying. for polygon in self.hexagons : # Loop over every hexagon from the polyhedron. if self.hexagons_color and isinstance(self.hexagons_color,list) : # Case there are more than one color for the faces displaying. glColor4ubv(self.hexagons_color[hexagons_color_index].get_ubyte_v()) glBegin(GL_POLYGON) for lines in polygon : for v in lines : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() hexagons_color_index += 1 elif self.display_mode == "twice" : # Configuration of polygons faces displaying. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.pentagons_color and isinstance(self.pentagons_color,Color) : # Case one same color for the faces displaying. glColor4ubv(self.pentagons_color.get_ubyte_v()) pentagons_color_index=0 for polygon in self.pentagons : # Loop over every pentagon from the polyhedron. if self.pentagons_color and isinstance(self.pentagons_color,list) : # Case there are more than one color for the faces displaying. glColor4ubv(self.pentagons_color[pentagons_color_index].get_ubyte_v()) glBegin(GL_POLYGON) for lines in polygon : for v in lines : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() pentagons_color_index += 1 if self.hexagons_color and isinstance(self.hexagons_color,Color) : # Case one same color for the faces displaying. glColor4ubv(self.hexagons_color.get_ubyte_v()) hexagons_color_index=0 # Iterator, case there are more than one color for the faces displaying. for polygon in self.hexagons : # Loop over every hexagon from the polyhedron. if self.hexagons_color and isinstance(self.hexagons_color,list) : # Case there are more than one color for the faces displaying. glColor4ubv(self.hexagons_color[hexagons_color_index].get_ubyte_v()) glBegin(GL_POLYGON) for lines in polygon : for v in lines : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() hexagons_color_index += 1 # Configuration of polygons lines displaying. glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) for polygon in self.hexagons : # Loop over every hexagon from the polyhedron. # For only lines displaying. glBegin(GL_POLYGON) for lines in polygon : for v in lines : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() if self.display_ls : # Displaying the Localview. self.ls.display(self.side_length*4.0/10.0)
def display(self): if self.display_mode == "lined": # Configuration of polygons lines displaying. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) if self.lines_color: # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) for polygon in self.quads: # Loop over every quad from the polyhedron. # For only lines displaying. glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() elif self.display_mode == "faced": # Configuration of polygons faces displaying. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) if self.quads_color and isinstance(self.quads_color, Color): # Case one same color for the faces displaying. glColor4ubv(self.quads_color.get_ubyte_v()) quads_color_index = 0 # Iterator, case there are more than one color for the faces displaying. if self.quads_color and isinstance(self.quads_color, Color): # Case one same color for the faces displaying. glColor4ubv(self.quads_color.get_ubyte_v()) for polygon in self.quads: # Loop over every quad from the polyhedron. if self.quads_color and isinstance(self.quads_color, list): # Case there are more than one color for the faces displaying. glColor4ubv( self.quads_color[quads_color_index].get_ubyte_v()) glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() quads_color_index += 1 if self.triangles_color and isinstance(self.triangles_color, Color): # Case one same color for the faces displaying. glColor4ubv(self.triangles_color.get_ubyte_v()) triangles_color_index = 0 # Iterator, case there are more than one color for the faces displaying. for polygon in self.triangles: # Loop over every triangle from the polyhedron. if self.triangles_color and isinstance(self.triangles_color, list): # Case there are more than one color for the faces displaying. glColor4ubv(self.triangles_color[triangles_color_index]. get_ubyte_v()) glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() triangles_color_index += 1 elif self.display_mode == "twice": # Configuration of polygons faces displaying. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) if self.quads_color and isinstance(self.quads_color, Color): # Case one same color for the faces displaying. glColor4ubv(self.quads_color.get_ubyte_v()) quads_color_index = 0 # Iterator, case there are more than one color for the faces displaying. if self.quads_color and isinstance(self.quads_color, Color): # Case one same color for the faces displaying. glColor4ubv(self.quads_color.get_ubyte_v()) for polygon in self.quads: # Loop over every quad from the polyhedron. if self.quads_color and isinstance(self.quads_color, list): glColor4ubv( self.quads_color[quads_color_index].get_ubyte_v()) glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() quads_color_index += 1 if self.triangles_color and isinstance(self.triangles_color, Color): # Case one same color for the faces displaying. glColor4ubv(self.triangles_color.get_ubyte_v()) triangles_color_index = 0 # Iterator, case there are more than one color for the faces displaying. for polygon in self.triangles: # Loop over every triangle from the polyhedron. if self.triangles_color and isinstance(self.triangles_color, list): # Case there are more than one color for the faces displaying. glColor4ubv(self.triangles_color[triangles_color_index]. get_ubyte_v()) glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() triangles_color_index += 1 # Configuration of polygons lines displaying. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) if self.lines_color: # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) for polygon in self.quads: # Loop over every quad from the polyhedron. # For only lines displaying. glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() if self.display_ls: # Displaying the Localview. self.ls.display(self.side_length * 2.0 / 10.0)
def display(self): ''' Icosahedron displaying method towards the settings. ''' faces_color_index = 0 # Iterator, case there are more than one color for the faces displaying. if self.display_mode == "lined" or self.display_mode == "faced": if self.display_mode == "lined" and self.lines_color: # Configuration of polygons lines displaying. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) if self.lines_color: # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) elif self.display_mode == "faced": # Configuration of polygons faces displaying. glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) if self.faces_color and isinstance(self.faces_color, Color): # Faces colorizing configuration. glColor4ubv(self.faces_color.get_ubyte_v()) for polygon in self.polyhedron: # We loop over the polyhedron polygons container. if self.faces_color and isinstance( self.faces_color, list) and self.display_mode == "faced": # Faces multi-colorizing configuration. glColor4ubv( self.faces_color[faces_color_index].get_ubyte_v()) # Displaying one polygon: glBegin(GL_POLYGON) for v in polygon: # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() faces_color_index += 1 elif self.display_mode == "twice": glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) if self.faces_color and isinstance(self.faces_color, Color): glColor4ubv(self.faces_color.get_ubyte_v()) for faces in self.polyhedron: # We loop over the polyhedron polygons container. if self.faces_color and isinstance(self.faces_color, list): # Faces multi-colorizing configuration. glColor4ubv( self.faces_color[faces_color_index].get_ubyte_v()) # Displaying one polygon face: glBegin(GL_POLYGON) for v in faces: # We loop over the every vertice from the face. glVertex3fv(v.get_vertex()) glEnd() faces_color_index += 1 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) if self.lines_color: # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Displaying one polygon face edges: for faces in self.polyhedron: glBegin(GL_POLYGON) for v in faces: # We loop over the every vertice from the face. glVertex3fv(v.get_vertex()) glEnd() if self.display_ls: # Displaying the Localview. self.ls.display(self.side_length * 2.0 / 10.0)
def display(self) : ''' Icosahedron displaying method towards the settings. ''' faces_color_index=0 # Iterator, case there are more than one color for the faces displaying. if self.display_mode == "lined" or self.display_mode == "faced" : if self.display_mode == "lined" and self.lines_color : # Configuration of polygons lines displaying. glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) elif self.display_mode == "faced" : # Configuration of polygons faces displaying. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.faces_color and isinstance(self.faces_color,Color) : # Faces colorizing configuration. glColor4ubv(self.faces_color.get_ubyte_v()) for polygon in self.polyhedron : # We loop over the polyhedron polygons container. if self.faces_color and isinstance(self.faces_color,list) and self.display_mode == "faced" : # Faces multi-colorizing configuration. glColor4ubv(self.faces_color[faces_color_index].get_ubyte_v()) # Displaying one polygon: glBegin(GL_POLYGON) for v in polygon : # We loop over the every vertice from the polygon. glVertex3fv(v.get_vertex()) glEnd() faces_color_index += 1 elif self.display_mode == "twice" : glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.faces_color and isinstance(self.faces_color,Color) : glColor4ubv(self.faces_color.get_ubyte_v()) for faces in self.polyhedron : # We loop over the polyhedron polygons container. if self.faces_color and isinstance(self.faces_color,list) : # Faces multi-colorizing configuration. glColor4ubv(self.faces_color[faces_color_index].get_ubyte_v()) # Displaying one polygon face: glBegin(GL_POLYGON) for v in faces : # We loop over the every vertice from the face. glVertex3fv(v.get_vertex()) glEnd() faces_color_index += 1 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Displaying one polygon face edges: for faces in self.polyhedron : glBegin(GL_POLYGON) for v in faces : # We loop over the every vertice from the face. glVertex3fv(v.get_vertex()) glEnd() if self.display_ls : # Displaying the Localview. self.ls.display(self.side_length*2.0/10.0)
def display(self) : if self.display_mode == "lined" : if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Setting the line width given as argument. i=-1 boolean=False while i < len(self.trigons)-1 : # Loop to display the triangles from our sphere. # Throught iterating over the polygons on the XZ surface. ii=-1 while ii < len(self.trigons[i])-1 : glBegin(GL_LINE_LOOP) if boolean : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii].get_vertex()) else : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii+1].get_vertex()) glEnd() ii += 1 if boolean : boolean=False else : boolean=True i += 1 elif self.display_mode == "faced" : if self.faces_color : # Faces color configuration. glColor4ubv(self.faces_color.get_ubyte_v()) i=-1 boolean=False while i < len(self.trigons)-1 : # Loop to display the triangles from our sphere. # Throught iterating over the polygons on the XZ surface. ii=-1 while ii < len(self.trigons[i])-1 : glBegin(GL_TRIANGLES) if boolean : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii].get_vertex()) else : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii+1].get_vertex()) glEnd() ii += 1 if boolean : boolean=False else : boolean=True i += 1 if self.display_mode == "twice" : glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.faces_color : # Faces color configuration. glColor4ubv(self.faces_color.get_ubyte_v()) i=-1 boolean=False while i < len(self.trigons)-1 : # Loop to display the triangles from our sphere. # Throught iterating over the polygons on the XZ surface. ii=-1 while ii < len(self.trigons[i])-1 : glBegin(GL_TRIANGLES) if boolean : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii].get_vertex()) else : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii+1].get_vertex()) glEnd() ii += 1 if boolean : boolean=False else : boolean=True i += 1 if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Setting the line width given as argument. i=-1 boolean=False while i < len(self.trigons)-1 : # Loop to display the triangles from our sphere. # Throught iterating over the polygons on the XZ surface. ii=-1 while ii < len(self.trigons[i])-1 : glBegin(GL_LINE_LOOP) if boolean : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii].get_vertex()) else : glVertex3fv(self.trigons[i][ii].get_vertex()) glVertex3fv(self.trigons[i][ii+1].get_vertex()) glVertex3fv(self.trigons[i+1][ii+1].get_vertex()) glEnd() ii += 1 if boolean : boolean=False else : boolean=True i += 1 if self.display_ls : # Displaying the Localview. self.ls.display(self.radius*2.0/10.0)
def display(self) : if self.display_mode == "lined" : if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Setting the line width given as argument. i=0 while i < len(self.polygons) : # Loop displaying the lines of the polygons on an surface of the sphere. # We process by crossing the line displaying. ii=0 glBegin(GL_LINE_LOOP) while ii < len(self.polygons[i]) : glVertex3fv(self.polygons[i][ii].get_vertex()) ii += 1 glEnd() i += 1 i=0 while i < len(self.polygons) : # Loop displaying the lines of the polygons on an surface of the sphere. # We process by crossing the line displaying. ii=0 glBegin(GL_LINE_LOOP) while ii < len(self.polygons[i]) : glVertex3fv(self.polygons[ii][i].get_vertex()) ii += 1 glEnd() i += 1 elif self.display_mode == "faced" : glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.faces_color : # Faces color configuration. glColor4ubv(self.faces_color.get_ubyte_v()) i=0 while i < len(self.polygons) : # Iteration over the polygon container variable to compute the quads. ii=0 while ii < self.basis-1 : # We compute the quads: for spheres quads displaying. glBegin(GL_QUADS) if not i == self.basis-1 : glVertex3fv(self.polygons[i][ii].get_vertex()) glVertex3fv(self.polygons[i+1][ii].get_vertex()) glVertex3fv(self.polygons[i+1][ii+1].get_vertex()) glVertex3fv(self.polygons[i][ii+1].get_vertex()) else : glVertex3fv(self.polygons[i][ii].get_vertex()) glVertex3fv(self.polygons[0][ii].get_vertex()) glVertex3fv(self.polygons[0][ii+1].get_vertex()) glVertex3fv(self.polygons[i][ii+1].get_vertex()) glEnd() ii += 1 i += 1 elif self.display_mode == "twice" : glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) if self.faces_color : glColor4ubv(self.faces_color.get_ubyte_v()) i=0 while i < len(self.polygons) : # Iteration over the polygon container variable to compute the quads. ii=0 while ii < self.basis-1 : # We compute the quads: for spheres quads displaying. glBegin(GL_QUADS) if not i == self.basis-1 : glVertex3fv(self.polygons[i][ii].get_vertex()) glVertex3fv(self.polygons[i+1][ii].get_vertex()) glVertex3fv(self.polygons[i+1][ii+1].get_vertex()) glVertex3fv(self.polygons[i][ii+1].get_vertex()) else : glVertex3fv(self.polygons[i][ii].get_vertex()) glVertex3fv(self.polygons[0][ii].get_vertex()) glVertex3fv(self.polygons[0][ii+1].get_vertex()) glVertex3fv(self.polygons[i][ii+1].get_vertex()) glEnd() ii += 1 i += 1 if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Setting the line width given as argument. i=0 while i < len(self.polygons) : # Loop displaying the lines of the polygons on an surface of the sphere. # We process by crossing the line displaying. ii=0 glBegin(GL_LINE_LOOP) while ii < len(self.polygons[i]) : glVertex3fv(self.polygons[i][ii].get_vertex()) ii += 1 glEnd() i += 1 i=0 while i < len(self.polygons) : # Loop displaying the lines of the polygons on an surface of the sphere. # We process by crossing the line displaying. ii=0 glBegin(GL_LINE_LOOP) while ii < len(self.polygons[i]) : glVertex3fv(self.polygons[ii][i].get_vertex()) ii += 1 glEnd() i += 1 if self.display_ls : # Displaying the Localview. self.ls.display(self.radius*2.0/10.0)
def display(self) : if self.display_mode == "lined" : if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Setting the line width given as argument. i=0 while i < len(self.toros) : glBegin(GL_LINE_LOOP) for v in self.toros[i] : glVertex3fv(v.get_vertex()) glEnd() i += 1 i=-1 while i < len(self.toros)-1 : ii=0 while ii < len(self.toros[i]) : glBegin(GL_LINES) glVertex3fv(self.toros[i][ii].get_vertex()) glVertex3fv(self.toros[i+1][ii].get_vertex()) glEnd() ii += 1 i += 1 elif self.display_mode == "faced" : if self.faces_color : # Faces color configuration. glColor4ubv(self.faces_color.get_ubyte_v()) i=-1 while i < len(self.toros)-1 : ii=-1 while ii < len(self.toros[i])-1 : glBegin(GL_QUADS) glVertex3fv(self.toros[i][ii].get_vertex()) glVertex3fv(self.toros[i+1][ii].get_vertex()) glVertex3fv(self.toros[i+1][ii+1].get_vertex()) glVertex3fv(self.toros[i][ii+1].get_vertex()) glEnd() ii += 1 i += 1 elif self.display_mode == "twice" : if self.faces_color : glColor4ubv(self.faces_color.get_ubyte_v()) i=-1 while i < len(self.toros)-1 : ii=-1 while ii < len(self.toros[i])-1 : glBegin(GL_QUADS) glVertex3fv(self.toros[i][ii].get_vertex()) glVertex3fv(self.toros[i+1][ii].get_vertex()) glVertex3fv(self.toros[i+1][ii+1].get_vertex()) glVertex3fv(self.toros[i][ii+1].get_vertex()) glEnd() ii += 1 i += 1 if self.lines_color : # Lines color configuration. glColor4ubv(self.lines_color.get_ubyte_v()) glLineWidth(self.lines_width) # Setting the line width given as argument. i=0 while i < len(self.toros) : glBegin(GL_LINE_LOOP) for v in self.toros[i] : glVertex3fv(v.get_vertex()) glEnd() i += 1 i=-1 while i < len(self.toros)-1 : ii=0 while ii < len(self.toros[i]) : glBegin(GL_LINES) glVertex3fv(self.toros[i][ii].get_vertex()) glVertex3fv(self.toros[i+1][ii].get_vertex()) glEnd() ii += 1 i += 1 if self.display_ls : # Displaying the Localview. self.ls.display(self.base_radius*2.0/10.0)