bool sgCContour::BreakContour(sgCObject** objcts)
Description:
Takes the contour to component parts.
Arguments:
objcts - buffer to put the contour component parts. You should allocate the memory for an array of objects pointers beforehand. The number of the elements in this array must be equal to the contour child objects (returned by GetChildrenList->GetCount()).
Returned value:
Returns false if the function fails, otherwise true. The function argument is filled with the pointers to child objects.
Example:
/*Build contour*/
sgCObject* objcts[4];
objcts[0] = sgCreateLine(0.0, 0.0, 0.0, 2.0, 3.0, 5.0);
objcts[1] = sgCreateLine(2.0, 3.0, 5.0, 10.0, 0.0, 3.0);
objcts[2] = sgCreateLine(10.0, 0.0, 3.0, 6.0, 13.0, 15.0);
objcts[0] = sgCContour::CreateContour(&objcts[0],3);
objcts[1] = sgCreateLine(6.0, 13.0, 15.0, 20.0, 30.0, 75.0);
objcts[2] = sgCreateLine(20.0, 30.0, 75.0, 10.0, 6.0, -3.0);
objcts[3] = sgCreateLine(10.0, 6.0, -3.0, 0.0, 0.0, 0.0);
sgCContour* resCont = sgCContour::CreateContour(&objcts[0],4);
/*Break contour*/
const int ChildsCount = resCont->GetChildrenList()->GetCount();
sgCObject** allChilds = (sgCObject**)malloc(ChildsCount*sizeof(sgCObject*));
if (!resCont->BreakContour(allChilds))
{
assert(0);
}
const int sz = resCont->GetChildrenList()->GetCount();
assert(sz==0);
sgDeleteObject(resCont);
for (int i=0;i<ChCnt;i++)
{
sgGetScene()->AttachObject(allChilds[i]);
}
free(allChilds);
See also: