示例#1
0
        public CurveLoopUV(CurveLoop curveLoop, Face face)
        {
            Loop3d  = curveLoop;
            _loop2d = new CurveLoop();

            var points3d = Loop3d.SelectMany(curve => curve.Tessellate().Skip(1));
            var pointsUv = points3d.Select(point3d => face.Project(point3d).UVPoint);
            var points2d = pointsUv.Select(pointUv => new XYZ(pointUv.U, pointUv.V, 0)).ToList();

            MinX = MinY = 1.0e100;
            MaxX = MaxY = -1.0e100;
            var nPoints = points2d.Count;

            for (var i = 0; i < nPoints; i++)
            {
                var p1 = points2d[i];
                var p2 = points2d[(i + 1) % nPoints];
                _loop2d.Append(Line.CreateBound(p1, p2));
                if (p1.X < MinX)
                {
                    MinX = p1.X;
                }
                if (p1.Y < MinY)
                {
                    MinY = p1.Y;
                }
                if (p1.X > MaxX)
                {
                    MaxX = p1.X;
                }
                if (p1.Y > MaxY)
                {
                    MaxY = p1.Y;
                }
            }
        }