Revision 41417 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.impl/src/main/java/org/gvsig/fmap/geom/primitive/impl/Envelope3D.java

View differences:

Envelope3D.java
37 37
 */
38 38
public class Envelope3D extends DefaultEnvelope implements Cloneable{
39 39
	public static final String PERSISTENCE_DEFINITION_NAME = "Envelope3Dimensions";
40
	
40
        private static final int DIMENSION = 3;
41
        private boolean isZInitilized =false;
42
        
41 43
	public Envelope3D() {
42 44
		super();		
43 45
	}
......
50 52
	 * @see org.gvsig.fmap.geom.primitive.Envelope#getDimension()
51 53
	 */
52 54
	public int getDimension() {
53
		return 3;
55
		return DIMENSION;
54 56
	}
55 57
	
56 58
	/*
......
79 81
	public Object clone() throws CloneNotSupportedException {
80 82
	    return super.clone();
81 83
	}
84
        
85
        
86
    private void createPoints() {
87
        this.min = new Point2DZ(0, 0, 0);
88
        this.max = new Point2DZ(0, 0, 0);
89
    }
90
    
91
    public void add(Envelope envelope) {
92
        int i;
93
        
94
        if( envelope==null && envelope.isEmpty() ) {
95
            return;
96
        }
97
       
98
        int maxDimension = DIMENSION; 
99

  
100
        if( envelope.getDimension()==2 ) {
101
            maxDimension = 2;
102
        }
103
        
104
        if( this.isZInitilized ) {
105
            for (i=0;i<maxDimension;i++){
106
                this.min.setCoordinateAt(i,
107
                    Math.min(this.min.getCoordinateAt(i), envelope.getMinimum(i)));
108
                this.max.setCoordinateAt(i,
109
                    Math.max(this.max.getCoordinateAt(i), envelope.getMaximum(i)));
110
            }
111
            return;
112
        }
113
        
114
        
115
        if (isEmpty){
116
            createPoints();
117
            if( maxDimension == 3 ) {
118
                this.isZInitilized = true;
119
            }
120
            for (i=0;i<maxDimension;i++){
121
                this.min.setCoordinateAt(i, envelope.getMinimum(i));
122
                this.max.setCoordinateAt(i, envelope.getMaximum(i));
123
            }
124
            isEmpty = false;
125
        } else {
126
            if( maxDimension==DIMENSION ) {
127
                this.min.setCoordinateAt(2, envelope.getMinimum(2));
128
                this.max.setCoordinateAt(2, envelope.getMaximum(2));
129
                this.isZInitilized = true;
130
            }
131
            for (i=0;i<maxDimension;i++){
132
                this.min.setCoordinateAt(i,
133
                    Math.min(this.min.getCoordinateAt(i), envelope.getMinimum(i)));
134
                this.max.setCoordinateAt(i,
135
                    Math.max(this.max.getCoordinateAt(i), envelope.getMaximum(i)));
136
            }
137
        }
138
    }
82 139
}
83 140

  

Also available in: Unified diff