lixiaojun
2024-10-17 c492a80c42564c7d6e62e1ddc4042b9b33b2a5f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace Yw.WinFrmUI.HydroL3d
{
    /// <summary>
    /// 
    /// </summary>
    [TypeConverter(typeof(PropertySorter))]
    public class BoundingBox3d
    {
        /// <summary>
        /// 
        /// </summary>
        public BoundingBox3d() { }
 
        /// <summary>
        /// 
        /// </summary>
        public BoundingBox3d(Point3d min, Point3d max)
        {
            this.Min = new Point3d(min);
            this.Max = new Point3d(max);
        }
 
        /// <summary>
        /// 
        /// </summary>
        [DisplayName("Min")]
        [PropertyOrder(1)]
        public Point3d Min { get; set; }
 
        /// <summary>
        /// 
        /// </summary>
        [DisplayName("Max")]
        [PropertyOrder(2)]
        public Point3d Max { get; set; }
 
        /// <summary>
        /// 获取中心
        /// </summary>
        public Point3d GetCenter()
        {
            return new Point3d()
            {
                X = (this.Max.X + this.Min.X) / 2f,
                Y = (this.Max.Y + this.Min.Y) / 2f,
                Z = (this.Max.Z + this.Min.Z) / 2f
            };
        }
 
        /// <summary>
        /// 是否包含
        /// </summary>
        public bool Contains(Point3d pt)
        {
            if (pt.X > this.Max.X || pt.X < this.Min.X)
            {
                return false;
            }
            if (pt.Y > this.Max.Y || pt.Y < this.Min.Y)
            {
                return false;
            }
            //if (pt.Z > this.Max.Z || pt.Z < this.Min.Z)
            //{
            //    return false;
            //}
 
            return true;
        }
 
    }
}