THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/04/2011 at 01:50, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12.043
Platform: Windows ;
Language(s) : C++ ;
---------
hi !
I have a setup with around 100k ngons. When I try to build them by using the BuildNgon function of the ngonbase class (passing only the inner edges of tris and quads) my memory usage gets out of control. Any suggestions?
Here is the code. The given vector contains the indices of the polys which build the ngon.
Bool BuildNgon(std::vector<LONG> &nGon;)
{
NgonBase *ngonBase = m_pobj->GetNgonBase();
if(!ngonBase) {
m_pobj->GetAndBuildNgon();
ngonBase = m_pobj->GetNgonBase();
if(!ngonBase) return FALSE;
}
const CPolygon* vadr = m_pobj->GetPolygonR();
std::vector<LONG> innerEdges;
for (LONG iFace = 0; iFace < nGon.size(); ++iFace)
{
for (LONG iSide = 0; iSide < 4; iSide++)
{
if (iSide==2 && vadr[nGon[iFace]].c==vadr[nGon[iFace]].d) continue;
LONG a1 = 0, b1 = 0;
switch (iSide)
{
case 0: a1 = vadr[nGon[iFace]].a; b1 = vadr[nGon[iFace]].b; break;
case 1: a1 = vadr[nGon[iFace]].b; b1 = vadr[nGon[iFace]].c; break;
case 2: a1 = vadr[nGon[iFace]].c; b1 = vadr[nGon[iFace]].d; break;
case 3: a1 = vadr[nGon[iFace]].d; b1 = vadr[nGon[iFace]].a; break;
}
Bool neighborFound = FALSE;
for (LONG jFace = 0; jFace < nGon.size(); ++jFace)
{
if (iFace == jFace) continue;
if (neighborFound) break;
for (LONG jSide = 0; jSide < 4; jSide++)
{
if (jSide==2 && vadr[nGon[jFace]].c==vadr[nGon[jFace]].d) continue;
LONG a2 = 0, b2 = 0;
switch (jSide)
{
case 0: a2 = vadr[nGon[jFace]].a; b2 = vadr[nGon[jFace]].b; break;
case 1: a2 = vadr[nGon[jFace]].b; b2 = vadr[nGon[jFace]].c; break;
case 2: a2 = vadr[nGon[jFace]].c; b2 = vadr[nGon[jFace]].d; break;
case 3: a2 = vadr[nGon[jFace]].d; b2 = vadr[nGon[jFace]].a; break;
}
// nGon[iFace] and nGon[jFace] are neighbors
if ((a1 == a2 && b1 == b2) || (a1 == b2 && a2 == b1))
{
innerEdges.push_back(nGon[iFace] * 4 + iSide);
neighborFound = TRUE;
break;
}
}
}
}
}
if (!innerEdges.empty()) ngonBase->BuildNgon(&innerEdges;[0], NULL, (LONG)innerEdges.size(), 0, vadr, m_pobj->GetPointR());
return TRUE;
}