廖井涛
2024-03-04 eae17d27ec56a6b7887f5597335e38ca40273ef4
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
73
74
75
76
77
78
79
80
81
82
83
84
package ng.Algorithm.Layouts;
 
public class Rect {
    private Piece source;
    private int width;
    private int length;
    private double area;
    public int x,y;    
    public int Row,Col;
    public boolean isHeng=false;
    private Piece.LayoutMode mode;
    private Rect(){
        
    }
    
    public boolean canHeng(){
        return mode==Piece.LayoutMode.Both || mode== Piece.LayoutMode.Heng;
    }
    
    
    public boolean canZhong(){
        return mode==Piece.LayoutMode.Both || mode== Piece.LayoutMode.Zhong;
    }
    
    
    
    public Rect(Piece source){
        this.width=source.width<=source.height?source.width:source.height;
        this.length=source.width>=source.height?source.width:source.height;
        this.area=this.width*this.length;
        this.mode=source.Mode;
        this.source=source;
        
    }
    
    
    public int getWidth(){
        return  this.width;
    }
    
    public int getLength(){
        return this.length;
    }
    
 
    
    public double getArea(){
        return this.area;
    }
    
    
    public int getXSize(){
        return isHeng?this.length:this.width;
    }
    
    public int getYSize(){
        return isHeng?this.width:this.length;
    }
 
    
    public Piece getSource(){
        return source;
    }
    
    protected void CopyTo(Rect r){
        r.source=this.source;
        r.width=this.width;
        r.length=this.length;
        r.mode=this.mode;
        r.isHeng=this.isHeng;
        r.area=this.area;
        r.Row=this.Row;
        r.Col=this.Col;
        r.x=this.x;
        r.y=this.y;
    }
    
    
    public Rect CloneRect(){
        Rect r=new Rect();
        CopyTo(r);
        return r;
    }
}