Beispiel #1
0
        void remove_triangle(int triangle_id, ref Vector2d a, ref Vector2d b, ref Vector2d c, bool threadsafe = true)
        {
            bool lockTaken = false;

            while (threadsafe == true && lockTaken == false)
            {
                spinlock.Enter(ref lockTaken);
            }

            AxisAlignedBox2d bounds = BoundsUtil.Bounds(ref a, ref b, ref c);
            Vector2i         imin   = indexer.ToGrid(bounds.Min);
            Vector2i         imax   = indexer.ToGrid(bounds.Max);

            for (int yi = imin.y; yi <= imax.y; ++yi)
            {
                for (int xi = imin.x; xi <= imax.x; ++xi)
                {
                    int bin_i = yi * bins_x + xi;
                    bins_list.Remove(bin_i, triangle_id);
                }
            }

            if (lockTaken)
            {
                spinlock.Exit();
            }
        }
Beispiel #2
0
        void insert_triangle(int triangle_id, ref Vector2d a, ref Vector2d b, ref Vector2d c, bool threadsafe = true)
        {
            bool lockTaken = false;

            while (threadsafe == true && lockTaken == false)
            {
                spinlock.Enter(ref lockTaken);
            }

            // [TODO] actually want to conservatively rasterize triangles here, not just
            // store in every cell in bbox!

            AxisAlignedBox2d bounds = BoundsUtil.Bounds(ref a, ref b, ref c);
            Vector2i         imin   = indexer.ToGrid(bounds.Min);
            Vector2i         imax   = indexer.ToGrid(bounds.Max);

            for (int yi = imin.y; yi <= imax.y; ++yi)
            {
                for (int xi = imin.x; xi <= imax.x; ++xi)
                {
                    // check if triangle overlaps this grid cell...

                    int bin_i = yi * bins_x + xi;
                    bins_list.Insert(bin_i, triangle_id);
                }
            }

            if (lockTaken)
            {
                spinlock.Exit();
            }
        }
Beispiel #3
0
        public static void WriteDebugMeshAndMarkers(IMesh mesh, List <Vector3d> Markers, string sPath = @"..\..\test_output\debug.obj")
        {
            WriteOptions options = WriteOptions.Defaults;

            options.bWriteGroups = true;
            List <WriteMesh> meshes = new List <WriteMesh>()
            {
                new WriteMesh(mesh)
            };
            double size = BoundsUtil.Bounds(mesh).Diagonal.Length * 0.01f;

            foreach (Vector3d v in Markers)
            {
                TrivialBox3Generator boxgen = new TrivialBox3Generator();
                boxgen.Box = new Box3d(v, size * Vector3d.One);
                boxgen.Generate();
                DMesh3 m = new DMesh3();
                boxgen.MakeMesh(m);
                meshes.Add(new WriteMesh(m));
            }

            StandardMeshWriter.WriteFile(sPath, meshes, options);
        }