17 #include "Base/Math/MathTools.h"
18 #include "Base/Tools/DebugMemory.h"
22 TC3DNodeList* pC3DNodeList =
new TC3DNodeList();
23 int nNodes = (int) pGraph->
getNodes()->size();
25 for (
int i = 0; i < nNodes; i++)
28 Vec3d cartesian_point;
31 CC3DNode* pC3DNode =
new CC3DNode(cartesian_point);
32 pC3DNodeList->push_back(pC3DNode);
37 CCHGiftWrap giftWrapping = CCHGiftWrap(pC3DNodeList);
39 giftWrapping.generateConvexHull(pCopy);
44 for (
int e = 0 ; e < pEdges->size() ; e++)
46 pGraph->
addEdge(pEdges->at(e)->nIndex1, pEdges->at(e)->nIndex2);
55 int nNumberViews = (int) pGraph->
getNodes()->size();
68 for (
int e = 0 ; e < int(pDoubleGraph->
getEdges()->size()) ; e++)
70 pCurrentEdge = pDoubleGraph->
getEdges()->at(e);
71 nIndex1 = pCurrentEdge->
nIndex1;
72 nIndex2 = pCurrentEdge->
nIndex2;
95 if (nIndex1 >= nNumberViews)
97 nIndex1 %= nNumberViews;
100 if (nIndex2 >= nNumberViews)
102 nIndex2 %= nNumberViews;
106 if (nIndex1 != nIndex2)
109 pGraph->
addEdge(nIndex1, nIndex2);
120 int nNumberPoints = int(pNodes->size());
124 for (i = 0 ; i < nNumberPoints - 2 ; i++)
126 printf(
"Round %d / %d\n", i, nNumberPoints - 2);
128 for (j = i + 1 ; j < nNumberPoints - 1 ; j++)
132 for (k = j + 1; k < nNumberPoints; k++)
134 if (k != i && k != j)
140 for (l = 0; l < nNumberPoints ; l++)
143 if (l != i && l != j && l != k)
164 p_i = pNodes->at(i)->getPosition();
165 p_j = pNodes->at(j)->getPosition();
166 p_k = pNodes->at(k)->getPosition();
205 int nEdgeIndex = pGraph->
addEdge(
s, t, -1, -1);
209 while (nCurrentEdge <
int(pEdges->size()))
211 if (pEdges->at(nCurrentEdge)->nLeftFace == -1)
213 completeFacet(pGraph, nCurrentEdge, nFaces);
216 if (pEdges->at(nCurrentEdge)->nRightFace == -1)
218 completeFacet(pGraph, nCurrentEdge, nFaces);
225 void GraphTriangulation::completeFacet(
CSphericalGraph* pGraph,
int nEdgeIndex,
int nFaces)
232 if (pEdges->at(nEdgeIndex)->nLeftFace == -1)
234 s = pEdges->at(nEdgeIndex)->nIndex1;
235 t = pEdges->at(nEdgeIndex)->nIndex2;
237 else if (pEdges->at(nEdgeIndex)->nRightFace == -1)
239 s = pEdges->at(nEdgeIndex)->nIndex2;
240 t = pEdges->at(nEdgeIndex)->nIndex1;
250 for (u = 0; u < int(pNodes->size()); u++)
252 if (u ==
s || u == t)
270 if (nBestPoint <
int(pNodes->size()))
276 for (u = nBestPoint + 1; u < int(pNodes->size()); u++)
278 if (u ==
s || u == t)
301 if (nBestPoint <
int(pNodes->size()))
304 updateLeftFace(pGraph, nEdgeIndex,
s, t, nFaces);
310 if (nEdgeIndex == -1)
313 nEdgeIndex = pGraph->
addEdge(nBestPoint,
s, nFaces, -1);
318 updateLeftFace(pGraph, nEdgeIndex, nBestPoint,
s, nFaces);
324 if (nEdgeIndex == -1)
327 nEdgeIndex = pGraph->
addEdge(t, nBestPoint, nFaces, -1);
332 updateLeftFace(pGraph, nEdgeIndex, t, nBestPoint, nFaces);
337 updateLeftFace(pGraph, nEdgeIndex,
s, t, -2);
341 void GraphTriangulation::updateLeftFace(
CSphericalGraph* pGraph,
int nEdgeIndex,
int nIndex1,
int nIndex2,
int nFace)
344 vector<CSGEdge*>* pEdges = pGraph->
getEdges();
348 if ((pEdges->at(nEdgeIndex)->nIndex1 == nIndex1) && (pEdges->at(nEdgeIndex)->nIndex2 == nIndex2))
353 if ((pEdges->at(nEdgeIndex)->nIndex1 == nIndex2) && (pEdges->at(nEdgeIndex)->nIndex2 == nIndex1))
360 printf(
"updateLeftFace: adj. matrix and edge table mismatch\n");
363 if ((pEdges->at(nEdgeIndex)->nIndex1 == nIndex1) && (pEdges->at(nEdgeIndex)->nLeftFace == -1))
365 pEdges->at(nEdgeIndex)->nLeftFace = nFace;
367 else if ((pEdges->at(nEdgeIndex)->nIndex2 == nIndex1) && (pEdges->at(nEdgeIndex)->nRightFace == -1))
369 pEdges->at(nEdgeIndex)->nRightFace = nFace;
378 int nNumberSourceNodes = (int) pNodes->size();
381 vector<TSphereCoord> coordinates;
384 for (
int i = 0 ; i < nNumberSourceNodes ; i++)
386 coordinates.push_back(pNodes->at(i)->getPosition());
391 for (
int i = 0 ; i < nNumberSourceNodes ; i++)
393 shiftedCoord = pNodes->at(i)->getPosition();
394 shiftedCoord.
fTheta += 360.0f;
395 coordinates.push_back(shiftedCoord);
416 for (
int i = 0 ; i < 2 * nNumberSourceNodes ; i++)