void buildKDTree(const GeDynamicArray<Vector> &points, KDNode **nodes, Random &rng) { Sorter sorter; Int32 *pnts = NewMemClear(Int32,points.GetCount()); Int32 numPoints = points.GetCount(); for(Int32 i=0;i<numPoints;i++){ pnts[i] = i; } *nodes = recursiveBuild(points,pnts,numPoints,rng,0,sorter); }
vector<vector<float> > Voxelify::objectPointsToPoints(GeDynamicArray<Vector> objectPoints){ vector<vector<float> > points(objectPoints.GetCount()); for (LONG i = 0; i < objectPoints.GetCount(); i++) { vector<float> p(3); p[0] = objectPoints[i].x; p[1] = objectPoints[i].y; p[2] = objectPoints[i].z; points[i] = p; } return points; }
void PaletteSubDialog::UpdatePopup(Int32 current) { BaseContainer bc; bc.SetString(ACTION_LOAD, "Load palette"); bc.SetString(ACTION_NEW, "New palette"); bc.SetString(ACTION_SAVE, "Save palette"); bc.InsData(0, String("")); if(m_showControls){ bc.SetString(ACTION_LABEL, "Show controls&c&"); }else{ bc.SetString(ACTION_LABEL, "Show controls"); } bc.InsData(0, String("")); GeDynamicArray<Palette> pals; Palette::GetPalettes(pals); for(Int32 i=0;i<pals.GetCount();i++){ String str; if(i==current){ str = "&c&"; } bc.SetString(ACTION_COUNT+i,pals[i].m_name+str); } SetPopup(m_actionPopup,bc); }
SplineObject* Voxelify::GetContour(BaseObject *op, BaseDocument *doc, Real lod, BaseThread *bt){ BaseContainer *data = op->GetDataInstance(); BaseObject* parent=(BaseObject*)data->GetLink(CTT_OBJECT_LINK,doc,Obase); if (!parent) return NULL; LONG startObject = data->GetLong(START_FRAME); LONG endObject = data->GetLong(END_FRAME); if (startObject >=endObject) return NULL; maxSeg = data->GetReal(CTTSPOBJECT_MAXSEG,30.); minSeg = data->GetReal(CTTSPOBJECT_MINSEG); LONG delta = data->GetLong(OBJECT_SKIP,1); delta = delta < 1 ? 1 : delta; GeDynamicArray<BaseObject*> children; GeDynamicArray<GeDynamicArray<Vector> > splineAtPoint; BaseObject* chld = NULL; LONG trck = 0; for (chld=parent->GetDownLast(); chld; chld=chld->GetPred()) { if (trck >= startObject && trck<= endObject && trck % delta == 0){ children.Push((BaseObject*)chld->GetClone(COPYFLAGS_NO_HIERARCHY|COPYFLAGS_NO_ANIMATION|COPYFLAGS_NO_BITS,NULL)); } trck++; } if (children.GetCount() < 2) { return NULL; } LONG splineInterpolation = data->GetLong(SPLINEOBJECT_INTERPOLATION); LONG longestPercent = data->GetLong(TAKE_LONGEST, 1); longestPercent = longestPercent > 100 ? 100: longestPercent; parentMatrix = parent->GetMl(); GeDynamicArray<GeDynamicArray<Vector> > objectPoints(children.GetCount()); StatusSetBar(0); StatusSetText("Collecting Points"); vector<vector<float> > points; std::vector<VGrid> grids; LONG gridSize = data->GetLong(GRID_SIZE, 1); if (!(gridSize > 0)) return NULL; for (int k= 0; k < children.GetCount(); k++){ Matrix ml; DoRecursion(op,children[k],objectPoints[k], ml); points = objectPointsToPoints(objectPoints[k]); GePrint(children[k]->GetName()); grids.push_back(vox.voxelify(points,gridSize, 12, 1.0)); if (k % 5 == 0){ LONG progress = 10 + (50*k)/children.GetCount(); StatusSetBar(progress); StatusSetText(LongToString(progress)+"%"); if (bt && bt->TestBreak()){ //break; //this break seems to be kicking in randomly killing the loop } } } StatusSetText("Building Splines"); SplineObject* parentSpline = ComputeSpline(bt, grids, longestPercent, splineAtPoint); ModelingCommandData mcd; mcd.doc = doc; mcd.op = parentSpline; if(!SendModelingCommand(MCOMMAND_JOIN, mcd)){ return NULL; } SplineObject* ret = ToSpline(mcd.result->GetIndex(0L)); ret->GetDataInstance()->SetLong(SPLINEOBJECT_INTERPOLATION, splineInterpolation); for (int k=0; k<children.GetCount(); k++){ if (children[k]){ BaseObject::Free(children[k]); } } return ret; Error: for (int i = 0; i < children.GetCount(); i++){ BaseObject::Free(children[i]); } return NULL; }