コード例 #1
0
 public SmallListSet(SmallListSet copy)
 {
     linked_store  = new DVector <int>(copy.linked_store);
     free_head_ptr = copy.free_head_ptr;
     list_heads    = new DVector <int>(copy.list_heads);
     block_store   = new DVector <int>(copy.block_store);
     free_blocks   = new DVector <int>(copy.free_blocks);
 }
コード例 #2
0
        /// <summary>
        /// "invalid" value will be returned by queries if no valid result is found (eg bounded-distance query)
        /// </summary>
        public TriangleBinsGrid2d(AxisAlignedBox2d bounds, int numCells)
        {
            this.bounds = bounds;
            double   cellsize = bounds.MaxDim / (double)numCells;
            Vector2d origin   = bounds.Min - cellsize * 0.5 * Vector2d.One;

            indexer = new ShiftGridIndexer2(origin, cellsize);

            bins_x      = (int)(bounds.Width / cellsize) + 2;
            bins_y      = (int)(bounds.Height / cellsize) + 2;
            grid_bounds = new AxisAlignedBox2i(0, 0, bins_x - 1, bins_y - 1);
            bins_list   = new SmallListSet();
            bins_list.Resize(bins_x * bins_y);
        }
コード例 #3
0
        /// <summary>
        /// Construct vertex correspondences between fill mesh boundary loop
        /// and input mesh boundary loop. In ideal case there is an easy 1-1
        /// correspondence. If that is not true, then do a brute-force search
        /// to find the best correspondences we can.
        ///
        /// Currently only returns unique correspondences. If any vertex
        /// matches with multiple input vertices it is not merged.
        /// [TODO] we could do better in many cases...
        ///
        /// Return value is list of indices into fillLoopV that were not merged
        /// </summary>
        List <int> build_merge_map(DMesh3 fillMesh, int[] fillLoopV,
                                   DMesh3 targetMesh, int[] targetLoopV,
                                   double tol, IndexMap mergeMapV)
        {
            if (fillLoopV.Length == targetLoopV.Length)
            {
                if (build_merge_map_simple(fillMesh, fillLoopV, targetMesh, targetLoopV, tol, mergeMapV))
                {
                    return(null);
                }
            }

            int NF = fillLoopV.Length, NT = targetLoopV.Length;

            bool[] doneF  = new bool[NF], doneT = new bool[NT];
            int[]  countF = new int[NF], countT = new int[NT];
            var    errorV = new List <int>();

            var matchF = new SmallListSet(); matchF.Resize(NF);

            // find correspondences
            double tol_sqr = tol * tol;

            for (int i = 0; i < NF; ++i)
            {
                if (fillMesh.IsVertex(fillLoopV[i]) == false)
                {
                    doneF[i] = true;
                    errorV.Add(i);
                    continue;
                }
                matchF.AllocateAt(i);
                Vector3d v = fillMesh.GetVertex(fillLoopV[i]);
                for (int j = 0; j < NT; ++j)
                {
                    Vector3d v2 = targetMesh.GetVertex(targetLoopV[j]);
                    if (v.DistanceSquared(ref v2) < tol_sqr)
                    {
                        matchF.Insert(i, j);
                    }
                }
            }

            for (int i = 0; i < NF; ++i)
            {
                if (doneF[i])
                {
                    continue;
                }

                if (matchF.Count(i) == 1)
                {
                    int j = matchF.First(i);
                    mergeMapV[fillLoopV[i]] = targetLoopV[j];
                    doneF[i] = true;
                }
            }

            for (int i = 0; i < NF; ++i)
            {
                if (doneF[i] == false)
                {
                    errorV.Add(i);
                }
            }

            return(errorV);
        }