//------------------------------------------------------------------------------ public override void BalanceOctree(ref int NodeCount) { // test if this //create the first cells for this branch for (int i = 0; i < (OctreeNode._OCT); i++) { if (_chld[i] != null) { if (_chld[i].IsBranch) { _chld[i].BalanceOctree(ref NodeCount); } else { // we have a leaf if (_chld[i].Depth != _CUROCTDEPTH) { double r = _chld[i].R; OctreeLeaf l = (OctreeLeaf)_chld[i]; OctreeBranch b = new OctreeBranch(r, l, this, _chld[i].ePos); int j = _chld[i].Depth; b.Create(ref j, ref NodeCount); _chld[i] = b; i--; } } } } }
//------------------------------------------------------------------------------ public double fit(OctreeLeaf l) { double ret = 0; Vectors p = l.Sigma; ret = 0.5 * (1 - Angle(p, l.Norm) + 0.5 * Math.Abs(Dist(p))) / ModelBase._POSERROR; return(ret); }
//------------------------------------------------------------------------------ private void ChooseFirstBestCandidate(ref OctreeLeaf candidate, List <OctreeLeaf> leafs) { foreach (OctreeLeaf l in leafs) { if (l.Bulge < OctreeNode._SURFCRIT) { candidate = l; break; } } }
// public OctreeBranch(double r, OctreeLeaf l, OctreeBranch parent, eOctPos p) : base(l.ID, l.Depth, l.vMin, l.vMax, r, parent, p) { _pts = new List <int>(l.PtsIdx); _chld = new List <OctreeNode>(OctreeNode._OCT);// the oct part _DispLstCentreNorm = -1; // we dont need to do PCA for Branches they come from leaves // which Are already calculated _vnorm = l.Norm; _eigenvec2 = l.EigenVec2; _eigenvec3 = l.EigenVec3; _rg = l.RadiiGyration; _sigma = l.Sigma; }
//------------------------------------------------------------------------------ public void Create(ref int currDepth, ref int NodeCount) { currDepth++; if (currDepth > _CUROCTDEPTH) { _CUROCTDEPTH++; } int i = 0; double r = R / 2.0d; // Depth; List <bool> used = new List <bool>(_pts.Count); // avoid testing points for (int k = 0; k < used.Capacity; k++) { used.Add(false); } OctreeLeaf l = null; //create the first cells for this branch for (i = 0; i < (OctreeNode._OCT); i++) { Vectors lmin, lmax; CalculateNewBBCoord(i, out lmin, out lmax); OctreeNode n = null; try { l = new OctreeLeaf(NodeCount, currDepth, lmin, lmax, ref used, r, this, (eOctPos)i); n = l; NodeCount++; if (l.Split()) { OctreeBranch b = new OctreeBranch(l.R, l, this, l.ePos); b.Create(ref currDepth, ref NodeCount); n = b; } } catch (Exception s) { n = null; Debug.WriteLine(s.Message.ToString()); } AddChild(n, i); } currDepth--; }
//------------------------------------------------------------------------------ private void inAdjplane(OctreeLeaf l, ref Surface s, ref List <int> used) { for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { for (int z = -1; z < 2; z++) { OctreeNode n = l.getAdjacentNOde(x, y, z); if (testFLatNess(n)) { if ((l.inplane(n) == true) && (!used.Contains(n.ID))) { used.Add(n.ID); s.add(n.ID, (OctreeLeaf)n); inAdjplane((OctreeLeaf)n, ref s, ref used); } } } // for z -1,0,1 } // for y -1,0,1 } // for x -1,0,1 }
//------------------------------------------------------------------------------ public bool testLeaf(OctreeLeaf l) { return(testPtN(l.Sigma, l.Norm)); }