<s> from __future__ import print_function , division <EOL> from pyglet . gl import * <EOL> from plot_mode_base import PlotModeBase <EOL> from sympy . core import S <EOL> from sympy . core . compatibility import range <EOL> class PlotSurface ( PlotModeBase ) : <EOL> default_rot_preset = '<STR_LIT>' <EOL> def _on_calculate_verts ( self ) : <EOL> self . u_interval = self . intervals [ <NUM_LIT:0> ] <EOL> self . u_set = list ( self . u_interval . frange ( ) ) <EOL> self . v_interval = self . intervals [ <NUM_LIT:1> ] <EOL> self . v_set = list ( self . v_interval . frange ( ) ) <EOL> self . bounds = [ [ S . Infinity , - S . Infinity , <NUM_LIT:0> ] , <EOL> [ S . Infinity , - S . Infinity , <NUM_LIT:0> ] , <EOL> [ S . Infinity , - S . Infinity , <NUM_LIT:0> ] ] <EOL> evaluate = self . _get_evaluator ( ) <EOL> self . _calculating_verts_pos = <NUM_LIT:0.0> <EOL> self . _calculating_verts_len = float ( <EOL> self . u_interval . v_len * self . v_interval . v_len ) <EOL> verts = list ( ) <EOL> b = self . bounds <EOL> for u in self . u_set : <EOL> column = list ( ) <EOL> for v in self . v_set : <EOL> try : <EOL> _e = evaluate ( u , v ) <EOL> except ZeroDivisionError : <EOL> _e = None <EOL> if _e is not None : <EOL> for axis in range ( <NUM_LIT:3> ) : <EOL> b [ axis ] [ <NUM_LIT:0> ] = min ( [ b [ axis ] [ <NUM_LIT:0> ] , _e [ axis ] ] ) <EOL> b [ axis ] [ <NUM_LIT:1> ] = max ( [ b [ axis ] [ <NUM_LIT:1> ] , _e [ axis ] ] ) <EOL> column . append ( _e ) <EOL> self . _calculating_verts_pos += <NUM_LIT:1.0> <EOL> verts . append ( column ) <EOL> for axis in range ( <NUM_LIT:3> ) : <EOL> b [ axis ] [ <NUM_LIT:2> ] = b [ axis ] [ <NUM_LIT:1> ] - b [ axis ] [ <NUM_LIT:0> ] <EOL> if b [ axis ] [ <NUM_LIT:2> ] == <NUM_LIT:0.0> : <EOL> b [ axis ] [ <NUM_LIT:2> ] = <NUM_LIT:1.0> <EOL> self . verts = verts <EOL> self . push_wireframe ( self . draw_verts ( False , False ) ) <EOL> self . push_solid ( self . draw_verts ( False , True ) ) <EOL> def _on_calculate_cverts ( self ) : <EOL> if not self . verts or not self . color : <EOL> return <EOL> def set_work_len ( n ) : <EOL> self . _calculating_cverts_len = float ( n ) <EOL> def inc_work_pos ( ) : <EOL> self . _calculating_cverts_pos += <NUM_LIT:1.0> <EOL> set_work_len ( <NUM_LIT:1> ) <EOL> self . _calculating_cverts_pos = <NUM_LIT:0> <EOL> self . cverts = self . color . apply_to_surface ( self . verts , <EOL> self . u_set , <EOL> self . v_set , <EOL> set_len = set_work_len , <EOL> inc_pos = inc_work_pos ) <EOL> self . push_solid ( self . draw_verts ( True , True ) ) <EOL> def calculate_one_cvert ( self , u , v ) : <EOL> vert = self . verts [ u ] [ v ] <EOL> return self . color ( vert [ <NUM_LIT:0> ] , vert [ <NUM_LIT:1> ] , vert [ <NUM_LIT:2> ] , <EOL> self . u_set [ u ] , self . v_set [ v ] ) <EOL> def draw_verts ( self , use_cverts , use_solid_color ) : <EOL> def f ( ) : <EOL> for u in range ( <NUM_LIT:1> , len ( self . u_set ) ) : <EOL> glBegin ( GL_QUAD_STRIP ) <EOL> for v in range ( len ( self . v_set ) ) : <EOL> pa = self . verts [ u - <NUM_LIT:1> ] [ v ] <EOL> pb = self . verts [ u ] [ v ] <EOL> if pa is None or pb is None : <EOL> glEnd ( ) <EOL> glBegin ( GL_QUAD_STRIP ) <EOL> continue <EOL> if use_cverts : <EOL> ca = self . cverts [ u - <NUM_LIT:1> ] [ v ] <EOL> cb = self . cverts [ u ] [ v ] <EOL> if ca is None : <EOL> ca = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> if cb is None : <EOL> cb = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> else : <EOL> if use_solid_color : <EOL> ca = cb = self . default_solid_color <EOL> else : <EOL> ca = cb = self . default_wireframe_color <EOL> glColor3f ( * ca ) <EOL> glVertex3f ( * pa ) <EOL> glColor3f ( * cb ) <EOL> glVertex3f ( * pb ) <EOL> glEnd ( ) <EOL> return f </s>
