Guest User

Untitled

a guest
May 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. ///////////////////////////////////
  2. // experimentOrientVertices.cpp
  3. // (modifying square.cpp)
  4. //
  5. // Sumanta Guha.
  6. ///////////////////////////////////
  7.  
  8. #ifdef __APPLE__
  9. # include <GL/glew.h>
  10. # include <GL/freeglut.h>
  11. # include <OpenGL/glext.h>
  12. #else
  13. # include <GL/glew.h>
  14. # include <GL/freeglut.h>
  15. # include <GL/glext.h>
  16. #pragma comment(lib, "glew32.lib")
  17. #endif
  18.  
  19. // Drawing routine.
  20. void drawScene(void)
  21. {
  22. glClear(GL_COLOR_BUFFER_BIT);
  23.  
  24. glColor3f(0.0, 0.0, 0.0);
  25.  
  26. // Draw a polygon with specified vertices.
  27. glPolygonMode(GL_FRONT, GL_LINE);
  28. glPolygonMode(GL_BACK, GL_FILL);
  29. glBegin(GL_POLYGON);
  30. glVertex3f(20.0, 20.0, 0.0);
  31. glVertex3f(80.0, 20.0, 0.0);
  32. glVertex3f(80.0, 80.0, 0.0);
  33. glVertex3f(20.0, 80.0, 0.0);
  34. glEnd();
  35.  
  36. /*
  37. glPolygonMode(GL_FRONT, GL_LINE);
  38. glPolygonMode(GL_BACK, GL_FILL);
  39. glBegin(GL_POLYGON);
  40. glVertex3f(20.0, 80.0, 0.0);
  41. glVertex3f(20.0, 20.0, 0.0);
  42. glVertex3f(80.0, 20.0, 0.0);
  43. glVertex3f(80.0, 80.0, 0.0);
  44. glEnd();
  45. */
  46.  
  47. /*
  48. glPolygonMode(GL_FRONT, GL_LINE);
  49. glPolygonMode(GL_BACK, GL_FILL);
  50. glBegin(GL_POLYGON);
  51. glVertex3f(80.0, 80.0, 0.0);
  52. glVertex3f(80.0, 20.0, 0.0);
  53. glVertex3f(20.0, 20.0, 0.0);
  54. glVertex3f(20.0, 80.0, 0.0);
  55. glEnd();
  56. */
  57.  
  58. glFlush();
  59. }
  60.  
  61. // Initialization routine.
  62. void setup(void)
  63. {
  64. glClearColor(1.0, 1.0, 1.0, 0.0);
  65. }
  66.  
  67. // OpenGL window reshape routine.
  68. void resize(int w, int h)
  69. {
  70. glViewport(0, 0, w, h);
  71. glMatrixMode(GL_PROJECTION);
  72. glLoadIdentity();
  73. glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
  74. glMatrixMode(GL_MODELVIEW);
  75. glLoadIdentity();
  76. }
  77.  
  78. // Keyboard input processing routine.
  79. void keyInput(unsigned char key, int x, int y)
  80. {
  81. switch(key)
  82. {
  83. case 27:
  84. exit(0);
  85. break;
  86. default:
  87. break;
  88. }
  89. }
  90.  
  91. // Main routine.
  92. int main(int argc, char **argv)
  93. {
  94. glutInit(&argc, argv);
  95.  
  96. glutInitContextVersion(4, 3);
  97. glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
  98.  
  99. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
  100. glutInitWindowSize(500, 500);
  101. glutInitWindowPosition(100, 100);
  102. glutCreateWindow("experimentOrientVertices.cpp");
  103. glutDisplayFunc(drawScene);
  104. glutReshapeFunc(resize);
  105. glutKeyboardFunc(keyInput);
  106.  
  107. glewExperimental = GL_TRUE;
  108. glewInit();
  109.  
  110. setup();
  111.  
  112. glutMainLoop();
  113. }
  114.  
  115. [['21=>59']]
  116. [['63=>65']]
  117. [['69=>76']]
  118. [['80=>89'], ['82=>88']]
  119. [['93=>113']]
  120.  
  121. [['21=>59']]
  122. [['63=>65'], ['65=>63']]
  123. [['69=>76'], ['76=>69']]
  124. [['80=>89'], ['82=>88'], ['88=>82'], ['89=>80']]
  125. [['93=>113'], ['113=>93']]
  126.  
  127. from sys import argv
  128.  
  129. token = {
  130. '{': 0
  131. }
  132. level = ["" for i in range(10)]
  133.  
  134. funcStartStop = [] #list to store each function start and stop brackets value
  135.  
  136. def functionCount(filename):
  137. inFile = open(filename, 'r')
  138. currLine = 0
  139. mbracketopenline = [] #list to store the currLine value if a { is found
  140. mbracketcloseline = [] #list to store the currLine value if a } is found
  141. first = True
  142. for line in inFile:
  143. currLine += 1
  144. if "{" in line:
  145. token["{"] += 1
  146. if first:
  147. first = False
  148. mbracketopenline.append(currLine)
  149. if "}" in line:
  150. token["{"] -= 1
  151. mbracketcloseline.append(currLine)
  152. if not first and token["{"] == 0:
  153. first = True
  154. tmpfuncStartStop = []
  155. for i in range(mgraffeopenline.__len__()):
  156. tmpfuncStartStop.append([str(str(mbracketopenline[i])+"=>"+str(mbracketcloseline[-i-1]))]) #store opening and
  157. #closing brackets in a list of list, so at the end of the cycle
  158. #should be something like: [['1=>10'],['3=>8']]
  159. funcStartStop.append(tmpfuncStartStop)
  160. mbracketcloseline = mbracketopenline = []
  161.  
  162. if __name__ == '__main__':
  163. functionCount(argv[1])
  164. for i in funcStartStop:
  165. print(i)
Add Comment
Please, Sign In to add comment