<commit_before>import math, time

from util import util3d
from util import profile

try:
	import OpenGL
	OpenGL.ERROR_CHECKING = False
	from OpenGL.GLU import *
	from OpenGL.GL import *
	hasOpenGLlibs = True
except:
	print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/"
	hasOpenGLlibs = False

def InitGL(window, view3D, zoom):
	# set viewing projection
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	size = window.GetSize()
	glViewport(0,0, size.GetWidth(), size.GetHeight())
	
	glLightfv(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0])
	glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0])

	glEnable(GL_NORMALIZE)
	glEnable(GL_LIGHTING)
	glEnable(GL_LIGHT0)
	glEnable(GL_DEPTH_TEST)
	glEnable(GL_CULL_FACE)
	glDisable(GL_BLEND)

	glClearColor(1.0, 1.0, 1.0, 1.0)
	glClearStencil(0)
	glClearDepth(1.0)

	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	aspect = float(size.GetWidth()) / float(size.GetHeight())
	if view3D:
		gluPerspective(45.0, aspect, 1.0, 1000.0)
	else:
		glOrtho(-aspect, aspect, -1, 1, -1000.0, 1000.0)

	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)

def DrawMachine(machineSize):
	glDisable(GL_LIGHTING)
	if False:
		glColor3f(0.7,0.7,0.7)
		glLineWidth(2)
		glBegin(GL_LINES)
		for i in xrange(0, int(machineSize.x), 10):
			glVertex3f(i, 0, 0)
			glVertex3f(i, machineSize.y, 0)
		for i in xrange(0, int(machineSize.y), 10):
			glVertex3f(0, i, 0)
			glVertex3f(machineSize.x, i, 0)
		glEnd()
	else:
		glDisable(GL_CULL_FACE)
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
		glColor4ub(5,171,231,127)
		glBegin(GL_QUADS)
		for x in xrange(0, int(machineSize.x), 20):
			for y in xrange(0, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		for x in xrange(10, int(machineSize.x), 20):
			for y in xrange(10, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		glEnd()
		glColor4ub(5,171,231,64)
		glBegin(GL_QUADS)
		for x in xrange(10, int(machineSize.x), 20):
			for y in xrange(0, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		for x in xrange(0, int(machineSize.x), 20):
			for y in xrange(10, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		glEnd()
		glEnable(GL_CULL_FACE)
		glDisable(GL_BLEND)
	
	glEnable(GL_LINE_SMOOTH)
	glEnable(GL_BLEND)
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
	glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);

	glColor3f(0.0,0.0,0.0)
	glLineWidth(4)
	glBegin(GL_LINE_LOOP)
	glVertex3f(0, 0, 0)
	glVertex3f(machineSize.x, 0, 0)
	glVertex3f(machineSize.x, machineSize.y, 0)
	glVertex3f(0, machineSize.y, 0)
	glEnd()
	
	glLineWidth(2)
	glBegin(GL_LINE_LOOP)
	glVertex3f(0, 0, machineSize.z)
	glVertex3f(machineSize.x, 0, machineSize.z)
	glVertex3f(machineSize.x, machineSize.y, machineSize.z)
	glVertex3f(0, machineSize.y, machineSize.z)
	glEnd()
	glBegin(GL_LINES)
	glVertex3f(0, 0, 0)
	glVertex3f(0, 0, machineSize.z)
	glVertex3f(machineSize.x, 0, 0)
	glVertex3f(machineSize.x, 0, machineSize.z)
	glVertex3f(machineSize.x, machineSize.y, 0)
	glVertex3f(machineSize.x, machineSize.y, machineSize.z)
	glVertex3f(0, machineSize.y, 0)
	glVertex3f(0, machineSize.y, machineSize.z)
	glEnd()

	glPushMatrix()
	glTranslate(-5,-5,0)
	glLineWidth(2)
	glColor3f(0.5,0,0)
	glBegin(GL_LINES)
	glVertex3f(0,0,0)
	glVertex3f(20,0,0)
	glEnd()
	glColor3f(0,0.5,0)
	glBegin(GL_LINES)
	glVertex3f(0,0,0)
	glVertex3f(0,20,0)
	glEnd()
	glColor3f(0,0,0.5)
	glBegin(GL_LINES)
	glVertex3f(0,0,0)
	glVertex3f(0,0,20)
	glEnd()

	glDisable(GL_DEPTH_TEST)
	#X<commit_msg>Update on the 3D preview, remove the boxed lines and make an "inside viewing" box.<commit_after>import math, time

from util import util3d
from util import profile

try:
	import OpenGL
	OpenGL.ERROR_CHECKING = False
	from OpenGL.GLU import *
	from OpenGL.GL import *
	hasOpenGLlibs = True
except:
	print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/"
	hasOpenGLlibs = False

def InitGL(window, view3D, zoom):
	# set viewing projection
	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	size = window.GetSize()
	glViewport(0,0, size.GetWidth(), size.GetHeight())
	
	glLightfv(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0])
	glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0])

	glEnable(GL_NORMALIZE)
	glEnable(GL_LIGHTING)
	glEnable(GL_LIGHT0)
	glEnable(GL_DEPTH_TEST)
	glEnable(GL_CULL_FACE)
	glDisable(GL_BLEND)

	glClearColor(1.0, 1.0, 1.0, 1.0)
	glClearStencil(0)
	glClearDepth(1.0)

	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	aspect = float(size.GetWidth()) / float(size.GetHeight())
	if view3D:
		gluPerspective(45.0, aspect, 1.0, 1000.0)
	else:
		glOrtho(-aspect, aspect, -1, 1, -1000.0, 1000.0)

	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity()
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)

def DrawMachine(machineSize):
	glDisable(GL_LIGHTING)
	if False:
		glColor3f(0.7,0.7,0.7)
		glLineWidth(2)
		glBegin(GL_LINES)
		for i in xrange(0, int(machineSize.x), 10):
			glVertex3f(i, 0, 0)
			glVertex3f(i, machineSize.y, 0)
		for i in xrange(0, int(machineSize.y), 10):
			glVertex3f(0, i, 0)
			glVertex3f(machineSize.x, i, 0)
		glEnd()
		
		glEnable(GL_LINE_SMOOTH)
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
		glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);

		glColor3f(0.0,0.0,0.0)
		glLineWidth(4)
		glBegin(GL_LINE_LOOP)
		glVertex3f(0, 0, 0)
		glVertex3f(machineSize.x, 0, 0)
		glVertex3f(machineSize.x, machineSize.y, 0)
		glVertex3f(0, machineSize.y, 0)
		glEnd()
		
		glLineWidth(2)
		glBegin(GL_LINE_LOOP)
		glVertex3f(0, 0, machineSize.z)
		glVertex3f(machineSize.x, 0, machineSize.z)
		glVertex3f(machineSize.x, machineSize.y, machineSize.z)
		glVertex3f(0, machineSize.y, machineSize.z)
		glEnd()
		glBegin(GL_LINES)
		glVertex3f(0, 0, 0)
		glVertex3f(0, 0, machineSize.z)
		glVertex3f(machineSize.x, 0, 0)
		glVertex3f(machineSize.x, 0, machineSize.z)
		glVertex3f(machineSize.x, machineSize.y, 0)
		glVertex3f(machineSize.x, machineSize.y, machineSize.z)
		glVertex3f(0, machineSize.y, 0)
		glVertex3f(0, machineSize.y, machineSize.z)
		glEnd()
	else:
		glDisable(GL_CULL_FACE)
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
		glColor4ub(5,171,231,127)
		glBegin(GL_QUADS)
		for x in xrange(0, int(machineSize.x), 20):
			for y in xrange(0, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		for x in xrange(10, int(machineSize.x), 20):
			for y in xrange(10, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		glEnd()
		glColor4ub(5,171,231,64)
		glBegin(GL_QUADS)
		for x in xrange(10, int(machineSize.x), 20):
			for y in xrange(0, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		for x in xrange(0, int(machineSize.x), 20):
			for y in xrange(10, int(machineSize.y), 20):
				glVertex3f(x, y, -0.01)
				glVertex3f(min(x+10, machineSize.x), y, -0.01)
				glVertex3f(min(x+10, machineSize.x), min(y+10, machineSize.y), -0.01)
				glVertex3f(x, min(y+10, machineSize.y), -0.01)
		glEnd()
		glEnable(GL_CULL_FACE)

		glColor4ub(5,171,231,128)
		glBegin(GL_QUADS)
		glVertex3f(0, 0, machineSize.z)
		glVertex3f(0, machineSize.y, machineSize.z)
		glVertex3f(machineSize.x, machineSize.y, machineSize.z)
		glVertex3f(machineSize.x, 0, machineSize.z)
		glEnd()
		
		glColor4ub(5,171,231,192)
		glBegin(GL_QUADS)
		glVertex3f(0, 0, 0)
		glVertex3f(0, 0, machineSize.z)
		glVertex3f(machineSize.x, 0, machineSize.z)
		glVertex3f(machineSize.x, 0, 0)

		glVertex3f(0, machineSize.y, machineSize.z)
		glVertex3f(0, machineSize.y, 0)
		glVertex3f(machineSize.x, machineSize.y, 0)
		glVertex3f(machineSize.x, machineSize.y, machineSize.z)
		glEnd()

		glColor4ub(5,171,231,255)
		glBegin(GL_QUADS)
		glVertex3f(0, 0, machineSize.z)
		glVertex3f(0, 0, 0)
		glVertex3f(0, machineSize.y, 0)
		glVertex3f(0, machineSize.y, machineSize.z)

		glVertex3f(machineSize.y, 0, 0)
		glVertex3f(machineSize.y, 0, machineSize.z)
		glVertex3f(machineSize.x, machineSize.y, machineSize.z)
		glVertex3f(machineSize.x, machineSize.y, 0)
		glEnd()

		glDisable(GL_BLEND)
	
	glPushMatrix()
	glTranslate(-5,-5,0)
	glLineWidth(2)
	glColor3f(0.5,0,0)
	glBegin(GL_LINES)
	glVertex3f(0,0,0)
	glVertex3f(20,0,0)
	glEnd()
	glColor3f(0,0.5,0)
	glBegin(GL_LINES)
	glVertex3f(0,0,0)
	glVertex3f(0,20,0)
	glEnd()
	glColor3f(0,0,0.5)
	glBegin(GL_LINES)
	glVertex3f(0,0,0)
	glVertex3f(0,0,20)
	glEnd()

	glDisable(GL_DEPTH_TEST)
	#X
{'fraction_non_alphanumeric': 0.15143303804064617, 'fraction_numerical': 0.0754559666492965, 'mean_word_length': 4.87630128597673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663668', 'n_tokens_mistral': 5020, 'n_tokens_neox': 4447, 'n_words': 752}