Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////
- // experimentOrientVertices.cpp
- // (modifying square.cpp)
- //
- // Sumanta Guha.
- ///////////////////////////////////
- #ifdef __APPLE__
- # include <GL/glew.h>
- # include <GL/freeglut.h>
- # include <OpenGL/glext.h>
- #else
- # include <GL/glew.h>
- # include <GL/freeglut.h>
- # include <GL/glext.h>
- #pragma comment(lib, "glew32.lib")
- #endif
- // Drawing routine.
- void drawScene(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.0, 0.0, 0.0);
- // Draw a polygon with specified vertices.
- glPolygonMode(GL_FRONT, GL_LINE);
- glPolygonMode(GL_BACK, GL_FILL);
- glBegin(GL_POLYGON);
- glVertex3f(20.0, 20.0, 0.0);
- glVertex3f(80.0, 20.0, 0.0);
- glVertex3f(80.0, 80.0, 0.0);
- glVertex3f(20.0, 80.0, 0.0);
- glEnd();
- /*
- glPolygonMode(GL_FRONT, GL_LINE);
- glPolygonMode(GL_BACK, GL_FILL);
- glBegin(GL_POLYGON);
- glVertex3f(20.0, 80.0, 0.0);
- glVertex3f(20.0, 20.0, 0.0);
- glVertex3f(80.0, 20.0, 0.0);
- glVertex3f(80.0, 80.0, 0.0);
- glEnd();
- */
- /*
- glPolygonMode(GL_FRONT, GL_LINE);
- glPolygonMode(GL_BACK, GL_FILL);
- glBegin(GL_POLYGON);
- glVertex3f(80.0, 80.0, 0.0);
- glVertex3f(80.0, 20.0, 0.0);
- glVertex3f(20.0, 20.0, 0.0);
- glVertex3f(20.0, 80.0, 0.0);
- glEnd();
- */
- glFlush();
- }
- // Initialization routine.
- void setup(void)
- {
- glClearColor(1.0, 1.0, 1.0, 0.0);
- }
- // OpenGL window reshape routine.
- void resize(int w, int h)
- {
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- // Keyboard input processing routine.
- void keyInput(unsigned char key, int x, int y)
- {
- switch(key)
- {
- case 27:
- exit(0);
- break;
- default:
- break;
- }
- }
- // Main routine.
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitContextVersion(4, 3);
- glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
- glutInitWindowSize(500, 500);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("experimentOrientVertices.cpp");
- glutDisplayFunc(drawScene);
- glutReshapeFunc(resize);
- glutKeyboardFunc(keyInput);
- glewExperimental = GL_TRUE;
- glewInit();
- setup();
- glutMainLoop();
- }
- [['21=>59']]
- [['63=>65']]
- [['69=>76']]
- [['80=>89'], ['82=>88']]
- [['93=>113']]
- [['21=>59']]
- [['63=>65'], ['65=>63']]
- [['69=>76'], ['76=>69']]
- [['80=>89'], ['82=>88'], ['88=>82'], ['89=>80']]
- [['93=>113'], ['113=>93']]
- from sys import argv
- token = {
- '{': 0
- }
- level = ["" for i in range(10)]
- funcStartStop = [] #list to store each function start and stop brackets value
- def functionCount(filename):
- inFile = open(filename, 'r')
- currLine = 0
- mbracketopenline = [] #list to store the currLine value if a { is found
- mbracketcloseline = [] #list to store the currLine value if a } is found
- first = True
- for line in inFile:
- currLine += 1
- if "{" in line:
- token["{"] += 1
- if first:
- first = False
- mbracketopenline.append(currLine)
- if "}" in line:
- token["{"] -= 1
- mbracketcloseline.append(currLine)
- if not first and token["{"] == 0:
- first = True
- tmpfuncStartStop = []
- for i in range(mgraffeopenline.__len__()):
- tmpfuncStartStop.append([str(str(mbracketopenline[i])+"=>"+str(mbracketcloseline[-i-1]))]) #store opening and
- #closing brackets in a list of list, so at the end of the cycle
- #should be something like: [['1=>10'],['3=>8']]
- funcStartStop.append(tmpfuncStartStop)
- mbracketcloseline = mbracketopenline = []
- if __name__ == '__main__':
- functionCount(argv[1])
- for i in funcStartStop:
- print(i)
Add Comment
Please, Sign In to add comment