Package schrodinger :: Package graphics3d :: Module polyhedron :: Class Polyhedron
[hide private]
[frames] | no frames]

Class Polyhedron

      object --+    
               |    
common.Primitive --+
                   |
                  Polyhedron
Known Subclasses:

Class to draw a 3D polyhedron with OpenGL using the current context in whatever is the current drawable (which could be Maestro).

Instance Methods [hide private]
 
__init__(self, vertices, faces, mode, color='red', opacity=1.0, style=1)
x.__init__(...) initializes x; see help(type(x)) for signature
 
_setNormals(self)
Private method to set the normals based on the self.faces value.
 
_draw(self)
Private method to draw the polyhedron with the current settings.
 
_calculateBoundingBox(self, mat)
Calculate a bounding box for the polyhedron.
 
update(self, vertices, faces)
Update the polyhedron's shape.
 
setStyle(self, style)
Sets the polyhedron's drawing style.

Inherited from common.Primitive: __del__, groupHidden, groupShown, hide, isGroupShown, isShown, setEntryID, setGlowColor, setIsGlowing, setRightClickOnGObject, show

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
_glSetup()
Private method to set up the GL state for polyhedra
 
_glReset()
Private method to reset the GL state for polyhedra
Class Variables [hide private]
  _blend = None
hash(x)
  _smooth_point = None
hash(x)
  _cull = None
hash(x)
  _lighting = None
hash(x)
  _lighting_model = None
hash(x)
  _shading_model = None
hash(x)
  _polygon_mode = None
hash(x)
Instance Variables [hide private]
  vertices
A list of each vertex of the polyhedron.
  faces
A list containing lists of vertices that define a face of the polyhedron.
  normals
The normals for the faces passed in.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, vertices, faces, mode, color='red', opacity=1.0, style=1)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • vertices (list of lists) - List of vertices. Each member of list should be a list of 3 coords, [x,y,z]
  • faces (list of lists) - List of faces comprising the polyhedron. Each face should be a list of at least 3 vertices.
  • color (Mixed. Either 1) Color object, 2) Color name (string), or 3) a tuple of (R, G, B) (each 0.0-1.0).) - The color of the polyhedron
  • opacity (float From 0.0 (invisible) to 1.0 (opaque). Default: 1.0 (opaque)) - The opacity of the polyhedron
  • style (Choice, FILL or LINE) - Whether to fill the polyhedron in or to leave it as lines connecting vertices.
Overrides: object.__init__

See Also: graphics3d.common.Group documentation

_setNormals(self)

 

Private method to set the normals based on the self.faces value. A normal is created for each face in self.faces. This method will clear all normals and re-calculate them.

_draw(self)

 

Private method to draw the polyhedron with the current settings. This should only be called by PolyhedronGroup instances.

_calculateBoundingBox(self, mat)

 

Calculate a bounding box for the polyhedron. This is used when resizing the molecule in the workspace.

Returns two lists of coordinates, each of 6 elements. The first three elements of the first list are the minimum values of the rotated object, the second three elements are the minimum values of the unrotated object. The second list has the corresponding maximum values.

update(self, vertices, faces)

 

Update the polyhedron's shape.

Parameters:
  • vertices (list of lists) - List of vertices. Each member of list should be a list of 3 coords, [x,y,z]
  • faces (list of lists) - List of faces comprising the polyhedron. Each face should be a list of at least 3 vertices.

See Also: Tetrahedron.updateVertices for an example of usage

setStyle(self, style)

 

Sets the polyhedron's drawing style.

Parameters:
  • style (Choice, FILL or LINE) - Whether to fill the polyhedron in or to leave it as lines connecting vertices.

Instance Variable Details [hide private]

vertices

A list of each vertex of the polyhedron. These are set during the Polyhedron.update method and taken from the constructor argument, vertices.

See Also: Polyhedron.update

faces

A list containing lists of vertices that define a face of the polyhedron. These are set during the Polyhedron.update method and taken from constructor argument, faces.

See Also: Polyhedron.update

normals

The normals for the faces passed in. These are calculated and set during the Polyhedron.update method.