Advertisement
biochem_fan

Patch to optimize map rendering in Coot

Apr 9th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.24 KB | None | 0 0
  1. Patch to optimize map rendering in Coot
  2. http://code.google.com/p/coot/
  3.  
  4. Coot is licensed under GPL3, so is this patch.
  5.  
  6. Add the following to density-contour/CIsosurface.h
  7.  
  8. std::vector <float> m_vertices;
  9. std::vector <TRIANGLE> m_triangleIndices;
  10.  
  11. Apply this to density-contour/CIsosurface.cpp
  12.  
  13. 393,398d392
  14. < POINT3DID vertices[12];
  15. < m_vertices.clear();
  16. < m_triangleIndices.clear();
  17. <
  18. < int nVertices = 0;
  19. <
  20. 427,429c421,423
  21. < vertices[3] = CalculateIntersection(x, y, z, 3);
  22. < // unsigned int id = GetEdgeID(x, y, z, 3);
  23. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  24. ---
  25. > POINT3DID pt = CalculateIntersection(x, y, z, 3);
  26. > unsigned int id = GetEdgeID(x, y, z, 3);
  27. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  28. 432,434c426,428
  29. < vertices[0] = CalculateIntersection(x, y, z, 0);
  30. < // unsigned int id = GetEdgeID(x, y, z, 0);
  31. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  32. ---
  33. > POINT3DID pt = CalculateIntersection(x, y, z, 0);
  34. > unsigned int id = GetEdgeID(x, y, z, 0);
  35. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  36. 437,439c431,433
  37. < vertices[8] = CalculateIntersection(x, y, z, 8);
  38. < // unsigned int id = GetEdgeID(x, y, z, 8);
  39. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  40. ---
  41. > POINT3DID pt = CalculateIntersection(x, y, z, 8);
  42. > unsigned int id = GetEdgeID(x, y, z, 8);
  43. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  44. 442,482c436,446
  45. < // if (x == m_nCellsX - 1) {
  46. < if (m_edgeTable[tableIndex] & 4) {
  47. < vertices[2] = CalculateIntersection(x, y, z, 2);
  48. < // unsigned int id = GetEdgeID(x, y, z, 2);
  49. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  50. < }
  51. < if (m_edgeTable[tableIndex] & 2048) {
  52. < vertices[11] = CalculateIntersection(x, y, z, 11);
  53. < // unsigned int id = GetEdgeID(x, y, z, 11);
  54. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  55. < }
  56. < // }
  57. < // if (y == m_nCellsY - 1) {
  58. < if (m_edgeTable[tableIndex] & 2) {
  59. < vertices[1] = CalculateIntersection(x, y, z, 1);
  60. < // unsigned int id = GetEdgeID(x, y, z, 1);
  61. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  62. < }
  63. < if (m_edgeTable[tableIndex] & 512) {
  64. < vertices[9] = CalculateIntersection(x, y, z, 9);
  65. < // unsigned int id = GetEdgeID(x, y, z, 9);
  66. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  67. < }
  68. < // }
  69. < // if (z == m_nCellsZ - 1) {
  70. < if (m_edgeTable[tableIndex] & 16) {
  71. < vertices[4] = CalculateIntersection(x, y, z, 4);
  72. < // unsigned int id = GetEdgeID(x, y, z, 4);
  73. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  74. < }
  75. < if (m_edgeTable[tableIndex] & 128) {
  76. < vertices[7] = CalculateIntersection(x, y, z, 7);
  77. < // unsigned int id = GetEdgeID(x, y, z, 7);
  78. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  79. < }
  80. < // }
  81. < // if ((x==m_nCellsX - 1) && (y==m_nCellsY - 1))
  82. < if (m_edgeTable[tableIndex] & 1024) {
  83. < vertices[10] = CalculateIntersection(x, y, z, 10);
  84. < // unsigned int id = GetEdgeID(x, y, z, 10);
  85. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  86. ---
  87. > if (x == m_nCellsX - 1) {
  88. > if (m_edgeTable[tableIndex] & 4) {
  89. > POINT3DID pt = CalculateIntersection(x, y, z, 2);
  90. > unsigned int id = GetEdgeID(x, y, z, 2);
  91. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  92. > }
  93. > if (m_edgeTable[tableIndex] & 2048) {
  94. > POINT3DID pt = CalculateIntersection(x, y, z, 11);
  95. > unsigned int id = GetEdgeID(x, y, z, 11);
  96. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  97. > }
  98. 484,489c448,458
  99. < // }
  100. < // if ((x==m_nCellsX - 1) && (z==m_nCellsZ - 1))
  101. < if (m_edgeTable[tableIndex] & 64) {
  102. < vertices[6] = CalculateIntersection(x, y, z, 6);
  103. < // unsigned int id = GetEdgeID(x, y, z, 6);
  104. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  105. ---
  106. > if (y == m_nCellsY - 1) {
  107. > if (m_edgeTable[tableIndex] & 2) {
  108. > POINT3DID pt = CalculateIntersection(x, y, z, 1);
  109. > unsigned int id = GetEdgeID(x, y, z, 1);
  110. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  111. > }
  112. > if (m_edgeTable[tableIndex] & 512) {
  113. > POINT3DID pt = CalculateIntersection(x, y, z, 9);
  114. > unsigned int id = GetEdgeID(x, y, z, 9);
  115. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  116. > }
  117. 491,495c460,470
  118. < // if ((y==m_nCellsY - 1) && (z==m_nCellsZ - 1))
  119. < if (m_edgeTable[tableIndex] & 32) {
  120. < vertices[5] = CalculateIntersection(x, y, z, 5);
  121. < // unsigned int id = GetEdgeID(x, y, z, 5);
  122. < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  123. ---
  124. > if (z == m_nCellsZ - 1) {
  125. > if (m_edgeTable[tableIndex] & 16) {
  126. > POINT3DID pt = CalculateIntersection(x, y, z, 4);
  127. > unsigned int id = GetEdgeID(x, y, z, 4);
  128. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  129. > }
  130. > if (m_edgeTable[tableIndex] & 128) {
  131. > POINT3DID pt = CalculateIntersection(x, y, z, 7);
  132. > unsigned int id = GetEdgeID(x, y, z, 7);
  133. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  134. > }
  135. 496a472,489
  136. > if ((x==m_nCellsX - 1) && (y==m_nCellsY - 1))
  137. > if (m_edgeTable[tableIndex] & 1024) {
  138. > POINT3DID pt = CalculateIntersection(x, y, z, 10);
  139. > unsigned int id = GetEdgeID(x, y, z, 10);
  140. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  141. > }
  142. > if ((x==m_nCellsX - 1) && (z==m_nCellsZ - 1))
  143. > if (m_edgeTable[tableIndex] & 64) {
  144. > POINT3DID pt = CalculateIntersection(x, y, z, 6);
  145. > unsigned int id = GetEdgeID(x, y, z, 6);
  146. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  147. > }
  148. > if ((y==m_nCellsY - 1) && (z==m_nCellsZ - 1))
  149. > if (m_edgeTable[tableIndex] & 32) {
  150. > POINT3DID pt = CalculateIntersection(x, y, z, 5);
  151. > unsigned int id = GetEdgeID(x, y, z, 5);
  152. > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
  153. > }
  154. 501,522c494,500
  155. < pointID0 = m_triTable[tableIndex][i];
  156. < pointID1 = m_triTable[tableIndex][i+1];
  157. < pointID2 = m_triTable[tableIndex][i+2];
  158. <
  159. < // POINT3D v0 = {vertices[pointID0].x, vertices[pointID0].y, vertices[pointID0].z};
  160. < // POINT3D v1 = {vertices[pointID1].x, vertices[pointID1].y, vertices[pointID1].z};
  161. < // POINT3D v2 = {vertices[pointID2].x, vertices[pointID2].y, vertices[pointID2].z};
  162. < /*m_vertices.push_back(v0);
  163. < m_vertices.push_back(v1);
  164. < m_vertices.push_back(v2);*/
  165. < m_vertices.push_back(vertices[pointID0].x);
  166. < m_vertices.push_back(vertices[pointID0].y);
  167. < m_vertices.push_back(vertices[pointID0].z);
  168. < m_vertices.push_back(vertices[pointID1].x);
  169. < m_vertices.push_back(vertices[pointID1].y);
  170. < m_vertices.push_back(vertices[pointID1].z);
  171. < m_vertices.push_back(vertices[pointID2].x);
  172. < m_vertices.push_back(vertices[pointID2].y);
  173. < m_vertices.push_back(vertices[pointID2].z);
  174. < m_triangleIndices.push_back(nVertices++);
  175. < m_triangleIndices.push_back(nVertices++);
  176. < m_triangleIndices.push_back(nVertices++);
  177. ---
  178. > pointID0 = GetEdgeID(x, y, z, m_triTable[tableIndex][i]);
  179. > pointID1 = GetEdgeID(x, y, z, m_triTable[tableIndex][i+1]);
  180. > pointID2 = GetEdgeID(x, y, z, m_triTable[tableIndex][i+2]);
  181. > triangle.pointID[0] = pointID0;
  182. > triangle.pointID[1] = pointID1;
  183. > triangle.pointID[2] = pointID2;
  184. > m_trivecTriangles.push_back(triangle);
  185. 642a621
  186. >
  187. 1077a1057
  188. > interpolation.newID = 0;
  189. 1090c1070
  190. < /* unsigned int nextID = 0;
  191. ---
  192. > unsigned int nextID = 0;
  193. 1109c1089
  194. < } */
  195. ---
  196. > }
  197. 1114,1121c1094,1097
  198. < // mapIterator = m_i2pt3idVertices.begin();
  199. < m_nVertices = m_vertices.size() / 3; //m_i2pt3idVertices.size();
  200. < m_ppt3dVertices = new POINT3D[m_nVertices];//reinterpret_cast<POINT3D*> (&(m_vertices[0])); //
  201. < for (int i = 0, j = 0; i < m_nVertices; i++) {
  202. < m_ppt3dVertices[i][0] = m_vertices[j++];
  203. < m_ppt3dVertices[i][1] = m_vertices[j++];
  204. < m_ppt3dVertices[i][2] = m_vertices[j++];
  205. < }
  206. ---
  207. > mapIterator = m_i2pt3idVertices.begin();
  208. > m_nVertices = m_i2pt3idVertices.size();
  209. > m_ppt3dVertices = new POINT3D[m_nVertices];
  210. >
  211. 1126c1102
  212. < /* for (unsigned int i = 0; i < m_nVertices; i++, mapIterator++) {
  213. ---
  214. > for (unsigned int i = 0; i < m_nVertices; i++, mapIterator++) {
  215. 1144c1120
  216. < }*/
  217. ---
  218. > }
  219. 1152,1156c1128,1131
  220. < // vecIterator = m_trivecTriangles.begin();
  221. < m_nTriangles = m_triangleIndices.size() / 3; // trivecTriangles.size();
  222. < m_piTriangleIndices = new unsigned int[m_nTriangles * 3];// &m_triangleIndices[0]; //new unsigned int[m_nTriangles*3];
  223. < std::copy(m_triangleIndices.begin(), m_triangleIndices.end(), m_piTriangleIndices);
  224. < /* for (unsigned int i = 0; i < m_nTriangles; i++, vecIterator++) {
  225. ---
  226. > vecIterator = m_trivecTriangles.begin();
  227. > m_nTriangles = m_trivecTriangles.size();
  228. > m_piTriangleIndices = new unsigned int[m_nTriangles*3];
  229. > for (unsigned int i = 0; i < m_nTriangles; i++, vecIterator++) {
  230. 1160c1135
  231. < }*/
  232. ---
  233. > }
  234. 1606,1607d1580
  235. < long T0 = glutGet(GLUT_ELAPSED_TIME);
  236. <
  237. 1627,1628c1600
  238. < unsigned int j, jp, jp2, done_count = 0;
  239. < bool d1_2 = true, d2_3 = true, d1_3 = true;
  240. ---
  241. > unsigned int j, jp, jp2, done_count = 0, d1_2, d2_3, d1_3;
  242. 1644,1646c1616,1618
  243. < // d1_2 = do_line(done_line_list, j, jp);
  244. < // d1_3 = do_line(done_line_list, j, jp2);
  245. < // d2_3 = do_line(done_line_list, jp, jp2);
  246. ---
  247. > d1_2 = do_line(done_line_list, j, jp);
  248. > d1_3 = do_line(done_line_list, j, jp2);
  249. > d2_3 = do_line(done_line_list, jp, jp2);
  250. 1711,1713d1682
  251. <
  252. < long T1 = glutGet(GLUT_ELAPSED_TIME);
  253. < std::cout << "INFO:: " << float(T1-T0)/1000.0 << " seconds in returnTriangles\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement