コード例 #1
0
        public static List <Point3d> GetBoundaryLine2d(List <Int16Triple> regionPoints, bool smoothing, int iteration)
        {
            Box3Int  box = GetBox3(regionPoints);
            int      stx = 0, sty = 0;
            BitMap2d bmp_1 = GetMappedBitmap(regionPoints, box, ref stx, ref sty);
            // bmp_1.OutputBitMap("1.bmp");
            BitMap2d bmp_2 = GetSingleRegionBitmap(bmp_1);

            // bmp_2.OutputBitMap("2.bmp");
            bmp_1 = null;
            SquarSurface mc2      = new SquarSurface(bmp_2);
            PolyLine     polyline = mc2.GenerateLine();

            if (smoothing && iteration >= 1)
            {
                for (int i = 0; i < iteration; i++)
                {
                    SmoothingLine(polyline);
                }
            }
            // PlyManager.Output2(polyline.Points,polyline.Edges,"3.ply");
            List <FloatDouble> points = polyline.GetDrawablePointList();
            List <Point3d>     ret    = new List <Point3d>(points.Count);

            for (int i = 0; i < points.Count; i++)
            {
                ret.Add(new Point3d(points[i].X + stx, points[i].Y + sty, 0));
            }
            return(ret);
        }
コード例 #2
0
        private static Box3Int GetBox3(List <Int16Triple> regionPoints)
        {
            Box3Int box = new Box3Int();

            for (int i = 0; i < regionPoints.Count; i++)
            {
                box.UpdataRange(regionPoints[i].X, regionPoints[i].Y, regionPoints[i].Z);
            }
            return(box);
        }
コード例 #3
0
        private static BitMap2d GetMappedBitmap(List <Int16Triple> regionPoints, Box3Int box, ref int stx, ref int sty)
        {
            BitMap2d bmp = new BitMap2d(box.GetXLength() + 2, box.GetYLength() + 2, BitMap2d.BLACK);

            stx = box.Min3[0] - 1;
            sty = box.Min3[1] - 1;
            for (int i = 0; i < regionPoints.Count; i++)
            {
                bmp.SetPixel(regionPoints[i].X - stx, regionPoints[i].Y - sty, BitMap2d.WHITE);
            }
            return(bmp);
        }