Ejemplo n.º 1
0
        // Function to find out all of the possibly intersecting pairs of triangles, and also to find out which triangles are not possibly intersecting anything
        public static void CullIntersections(CSGModel a, CSGModel b, SparseBoolMatrix.PairCallback pairCallback, SafeTriangleCallback safeCallback)
        {
            ModelIntersectTree tree = new ModelIntersectTree(a, b);             // create the tree (operations are done automatically by the constructor

            // make lists of all the triangle indices in each of the input objects
            HashSet<long> aSafe = new HashSet<long>();
            HashSet<long> bSafe = new HashSet<long>();
            foreach (long i in tree.allItems[0])
                aSafe.Add(i);
            foreach (long j in tree.allItems[1])
                bSafe.Add(j);

            // iterate through all of the pairs
            tree.ForLeafLevelPairs(
                (i, j) =>
                {
                    aSafe.Remove(i);                                            // if an item is in a pair with another item, it isn't safe, so we remove it from the safe list
                    bSafe.Remove(j);

                    pairCallback(i, j);                                         // call the user-defined callback
                });

            foreach (long i in aSafe)                                           // let the user know which ones were determined to be 'safe'
                safeCallback(0, i);
            foreach (long j in bSafe)
                safeCallback(1, j);
        }
Ejemplo n.º 2
0
        // Function to find out all of the possibly intersecting pairs of triangles, and also to find out which triangles are not possibly intersecting anything
        public static void CullIntersections(CSGModel a, CSGModel b, SparseBoolMatrix.PairCallback pairCallback, SafeTriangleCallback safeCallback)
        {
            ModelIntersectTree tree = new ModelIntersectTree(a, b);             // create the tree (operations are done automatically by the constructor

            // make lists of all the triangle indices in each of the input objects
            HashSet <long> aSafe = new HashSet <long>();
            HashSet <long> bSafe = new HashSet <long>();

            foreach (long i in tree.allItems[0])
            {
                aSafe.Add(i);
            }
            foreach (long j in tree.allItems[1])
            {
                bSafe.Add(j);
            }

            // iterate through all of the pairs
            tree.ForLeafLevelPairs(
                (i, j) =>
            {
                aSafe.Remove(i);                                                // if an item is in a pair with another item, it isn't safe, so we remove it from the safe list
                bSafe.Remove(j);

                pairCallback(i, j);                                             // call the user-defined callback
            });

            foreach (long i in aSafe)                                           // let the user know which ones were determined to be 'safe'
            {
                safeCallback(0, i);
            }
            foreach (long j in bSafe)
            {
                safeCallback(1, j);
            }
        }