Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Patch to optimize map rendering in Coot
- http://code.google.com/p/coot/
- Coot is licensed under GPL3, so is this patch.
- Add the following to density-contour/CIsosurface.h
- std::vector <float> m_vertices;
- std::vector <TRIANGLE> m_triangleIndices;
- Apply this to density-contour/CIsosurface.cpp
- 393,398d392
- < POINT3DID vertices[12];
- < m_vertices.clear();
- < m_triangleIndices.clear();
- <
- < int nVertices = 0;
- <
- 427,429c421,423
- < vertices[3] = CalculateIntersection(x, y, z, 3);
- < // unsigned int id = GetEdgeID(x, y, z, 3);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- ---
- > POINT3DID pt = CalculateIntersection(x, y, z, 3);
- > unsigned int id = GetEdgeID(x, y, z, 3);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- 432,434c426,428
- < vertices[0] = CalculateIntersection(x, y, z, 0);
- < // unsigned int id = GetEdgeID(x, y, z, 0);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- ---
- > POINT3DID pt = CalculateIntersection(x, y, z, 0);
- > unsigned int id = GetEdgeID(x, y, z, 0);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- 437,439c431,433
- < vertices[8] = CalculateIntersection(x, y, z, 8);
- < // unsigned int id = GetEdgeID(x, y, z, 8);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- ---
- > POINT3DID pt = CalculateIntersection(x, y, z, 8);
- > unsigned int id = GetEdgeID(x, y, z, 8);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- 442,482c436,446
- < // if (x == m_nCellsX - 1) {
- < if (m_edgeTable[tableIndex] & 4) {
- < vertices[2] = CalculateIntersection(x, y, z, 2);
- < // unsigned int id = GetEdgeID(x, y, z, 2);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- < }
- < if (m_edgeTable[tableIndex] & 2048) {
- < vertices[11] = CalculateIntersection(x, y, z, 11);
- < // unsigned int id = GetEdgeID(x, y, z, 11);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- < }
- < // }
- < // if (y == m_nCellsY - 1) {
- < if (m_edgeTable[tableIndex] & 2) {
- < vertices[1] = CalculateIntersection(x, y, z, 1);
- < // unsigned int id = GetEdgeID(x, y, z, 1);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- < }
- < if (m_edgeTable[tableIndex] & 512) {
- < vertices[9] = CalculateIntersection(x, y, z, 9);
- < // unsigned int id = GetEdgeID(x, y, z, 9);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- < }
- < // }
- < // if (z == m_nCellsZ - 1) {
- < if (m_edgeTable[tableIndex] & 16) {
- < vertices[4] = CalculateIntersection(x, y, z, 4);
- < // unsigned int id = GetEdgeID(x, y, z, 4);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- < }
- < if (m_edgeTable[tableIndex] & 128) {
- < vertices[7] = CalculateIntersection(x, y, z, 7);
- < // unsigned int id = GetEdgeID(x, y, z, 7);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- < }
- < // }
- < // if ((x==m_nCellsX - 1) && (y==m_nCellsY - 1))
- < if (m_edgeTable[tableIndex] & 1024) {
- < vertices[10] = CalculateIntersection(x, y, z, 10);
- < // unsigned int id = GetEdgeID(x, y, z, 10);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- ---
- > if (x == m_nCellsX - 1) {
- > if (m_edgeTable[tableIndex] & 4) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 2);
- > unsigned int id = GetEdgeID(x, y, z, 2);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- > if (m_edgeTable[tableIndex] & 2048) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 11);
- > unsigned int id = GetEdgeID(x, y, z, 11);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- 484,489c448,458
- < // }
- < // if ((x==m_nCellsX - 1) && (z==m_nCellsZ - 1))
- < if (m_edgeTable[tableIndex] & 64) {
- < vertices[6] = CalculateIntersection(x, y, z, 6);
- < // unsigned int id = GetEdgeID(x, y, z, 6);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- ---
- > if (y == m_nCellsY - 1) {
- > if (m_edgeTable[tableIndex] & 2) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 1);
- > unsigned int id = GetEdgeID(x, y, z, 1);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- > if (m_edgeTable[tableIndex] & 512) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 9);
- > unsigned int id = GetEdgeID(x, y, z, 9);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- 491,495c460,470
- < // if ((y==m_nCellsY - 1) && (z==m_nCellsZ - 1))
- < if (m_edgeTable[tableIndex] & 32) {
- < vertices[5] = CalculateIntersection(x, y, z, 5);
- < // unsigned int id = GetEdgeID(x, y, z, 5);
- < // m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- ---
- > if (z == m_nCellsZ - 1) {
- > if (m_edgeTable[tableIndex] & 16) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 4);
- > unsigned int id = GetEdgeID(x, y, z, 4);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- > if (m_edgeTable[tableIndex] & 128) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 7);
- > unsigned int id = GetEdgeID(x, y, z, 7);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- 496a472,489
- > if ((x==m_nCellsX - 1) && (y==m_nCellsY - 1))
- > if (m_edgeTable[tableIndex] & 1024) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 10);
- > unsigned int id = GetEdgeID(x, y, z, 10);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- > if ((x==m_nCellsX - 1) && (z==m_nCellsZ - 1))
- > if (m_edgeTable[tableIndex] & 64) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 6);
- > unsigned int id = GetEdgeID(x, y, z, 6);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- > if ((y==m_nCellsY - 1) && (z==m_nCellsZ - 1))
- > if (m_edgeTable[tableIndex] & 32) {
- > POINT3DID pt = CalculateIntersection(x, y, z, 5);
- > unsigned int id = GetEdgeID(x, y, z, 5);
- > m_i2pt3idVertices.insert(ID2POINT3DID::value_type(id, pt));
- > }
- 501,522c494,500
- < pointID0 = m_triTable[tableIndex][i];
- < pointID1 = m_triTable[tableIndex][i+1];
- < pointID2 = m_triTable[tableIndex][i+2];
- <
- < // POINT3D v0 = {vertices[pointID0].x, vertices[pointID0].y, vertices[pointID0].z};
- < // POINT3D v1 = {vertices[pointID1].x, vertices[pointID1].y, vertices[pointID1].z};
- < // POINT3D v2 = {vertices[pointID2].x, vertices[pointID2].y, vertices[pointID2].z};
- < /*m_vertices.push_back(v0);
- < m_vertices.push_back(v1);
- < m_vertices.push_back(v2);*/
- < m_vertices.push_back(vertices[pointID0].x);
- < m_vertices.push_back(vertices[pointID0].y);
- < m_vertices.push_back(vertices[pointID0].z);
- < m_vertices.push_back(vertices[pointID1].x);
- < m_vertices.push_back(vertices[pointID1].y);
- < m_vertices.push_back(vertices[pointID1].z);
- < m_vertices.push_back(vertices[pointID2].x);
- < m_vertices.push_back(vertices[pointID2].y);
- < m_vertices.push_back(vertices[pointID2].z);
- < m_triangleIndices.push_back(nVertices++);
- < m_triangleIndices.push_back(nVertices++);
- < m_triangleIndices.push_back(nVertices++);
- ---
- > pointID0 = GetEdgeID(x, y, z, m_triTable[tableIndex][i]);
- > pointID1 = GetEdgeID(x, y, z, m_triTable[tableIndex][i+1]);
- > pointID2 = GetEdgeID(x, y, z, m_triTable[tableIndex][i+2]);
- > triangle.pointID[0] = pointID0;
- > triangle.pointID[1] = pointID1;
- > triangle.pointID[2] = pointID2;
- > m_trivecTriangles.push_back(triangle);
- 642a621
- >
- 1077a1057
- > interpolation.newID = 0;
- 1090c1070
- < /* unsigned int nextID = 0;
- ---
- > unsigned int nextID = 0;
- 1109c1089
- < } */
- ---
- > }
- 1114,1121c1094,1097
- < // mapIterator = m_i2pt3idVertices.begin();
- < m_nVertices = m_vertices.size() / 3; //m_i2pt3idVertices.size();
- < m_ppt3dVertices = new POINT3D[m_nVertices];//reinterpret_cast<POINT3D*> (&(m_vertices[0])); //
- < for (int i = 0, j = 0; i < m_nVertices; i++) {
- < m_ppt3dVertices[i][0] = m_vertices[j++];
- < m_ppt3dVertices[i][1] = m_vertices[j++];
- < m_ppt3dVertices[i][2] = m_vertices[j++];
- < }
- ---
- > mapIterator = m_i2pt3idVertices.begin();
- > m_nVertices = m_i2pt3idVertices.size();
- > m_ppt3dVertices = new POINT3D[m_nVertices];
- >
- 1126c1102
- < /* for (unsigned int i = 0; i < m_nVertices; i++, mapIterator++) {
- ---
- > for (unsigned int i = 0; i < m_nVertices; i++, mapIterator++) {
- 1144c1120
- < }*/
- ---
- > }
- 1152,1156c1128,1131
- < // vecIterator = m_trivecTriangles.begin();
- < m_nTriangles = m_triangleIndices.size() / 3; // trivecTriangles.size();
- < m_piTriangleIndices = new unsigned int[m_nTriangles * 3];// &m_triangleIndices[0]; //new unsigned int[m_nTriangles*3];
- < std::copy(m_triangleIndices.begin(), m_triangleIndices.end(), m_piTriangleIndices);
- < /* for (unsigned int i = 0; i < m_nTriangles; i++, vecIterator++) {
- ---
- > vecIterator = m_trivecTriangles.begin();
- > m_nTriangles = m_trivecTriangles.size();
- > m_piTriangleIndices = new unsigned int[m_nTriangles*3];
- > for (unsigned int i = 0; i < m_nTriangles; i++, vecIterator++) {
- 1160c1135
- < }*/
- ---
- > }
- 1606,1607d1580
- < long T0 = glutGet(GLUT_ELAPSED_TIME);
- <
- 1627,1628c1600
- < unsigned int j, jp, jp2, done_count = 0;
- < bool d1_2 = true, d2_3 = true, d1_3 = true;
- ---
- > unsigned int j, jp, jp2, done_count = 0, d1_2, d2_3, d1_3;
- 1644,1646c1616,1618
- < // d1_2 = do_line(done_line_list, j, jp);
- < // d1_3 = do_line(done_line_list, j, jp2);
- < // d2_3 = do_line(done_line_list, jp, jp2);
- ---
- > d1_2 = do_line(done_line_list, j, jp);
- > d1_3 = do_line(done_line_list, j, jp2);
- > d2_3 = do_line(done_line_list, jp, jp2);
- 1711,1713d1682
- <
- < long T1 = glutGet(GLUT_ELAPSED_TIME);
- < std::cout << "INFO:: " << float(T1-T0)/1000.0 << " seconds in returnTriangles\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement