root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FPolygon3D.java @ 38563
History | View | Annotate | Download (3.17 KB)
1 | 1100 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 262 | fjp | package com.iver.cit.gvsig.fmap.core; |
42 | |||
43 | 35335 | fpenarrubia | import java.awt.geom.PathIterator; |
44 | |||
45 | import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
||
46 | |||
47 | 262 | fjp | /**
|
48 | * Polilinea 3D.
|
||
49 | *
|
||
50 | * @author Vicente Caballero Navarro
|
||
51 | */
|
||
52 | 2196 | vcaballero | public class FPolygon3D extends FPolygon2D implements FShape3D { |
53 | 1005 | vcaballero | double[] pZ = null; |
54 | 262 | fjp | |
55 | 1005 | vcaballero | /**
|
56 | * Crea un nuevo Polyline3D.
|
||
57 | *
|
||
58 | * @param gpx GeneralPathX.
|
||
59 | * @param pZ vector con las Z.
|
||
60 | */
|
||
61 | public FPolygon3D(GeneralPathX gpx, double[] pZ) { |
||
62 | super(gpx);
|
||
63 | this.pZ = pZ;
|
||
64 | } |
||
65 | |||
66 | /**
|
||
67 | * Clona FPolygon3D.
|
||
68 | *
|
||
69 | * @return FShape clonado.
|
||
70 | */
|
||
71 | 711 | fjp | public FShape cloneFShape() {
|
72 | 2196 | vcaballero | return new FPolygon3D((GeneralPathX) gp.clone(), (double[]) pZ.clone()); |
73 | 711 | fjp | } |
74 | 2196 | vcaballero | |
75 | /**
|
||
76 | * Devuelve un array con los valores de todas las Z.
|
||
77 | *
|
||
78 | * @return Array de Zs.
|
||
79 | */
|
||
80 | public double[] getZs() { |
||
81 | return pZ;
|
||
82 | } |
||
83 | |||
84 | /**
|
||
85 | * @see com.iver.cit.gvsig.fmap.core.FShape#getShapeType()
|
||
86 | */
|
||
87 | public int getShapeType() { |
||
88 | 3181 | jmorell | return FShape.POLYGON | FShape.Z;
|
89 | 2196 | vcaballero | } |
90 | 35335 | fpenarrubia | |
91 | public String toText() { |
||
92 | //TODO: its not writing rings or multielements properly
|
||
93 | StringBuffer str = new StringBuffer(); |
||
94 | str.append("MULTIPOLYGON");
|
||
95 | str.append(" ((");
|
||
96 | int theType;
|
||
97 | double[] theData = new double[6]; |
||
98 | |||
99 | PathIterator theIterator = getPathIterator(null, FConverter.FLATNESS); |
||
100 | int i = 0; |
||
101 | |||
102 | while (!theIterator.isDone()) {
|
||
103 | //while not done
|
||
104 | theType = theIterator.currentSegment(theData); |
||
105 | |||
106 | double z = 0.0; |
||
107 | if (i < pZ.length){
|
||
108 | z = pZ[i]; |
||
109 | } |
||
110 | |||
111 | switch (theType) {
|
||
112 | case PathIterator.SEG_MOVETO: |
||
113 | str.append(theData[0] + " " + theData[1] + " " + z + ","); |
||
114 | break;
|
||
115 | |||
116 | case PathIterator.SEG_LINETO: |
||
117 | str.append(theData[0] + " " + theData[1] + " " + z + ","); |
||
118 | |||
119 | break;
|
||
120 | |||
121 | case PathIterator.SEG_QUADTO: |
||
122 | System.out.println("Not supported here"); |
||
123 | |||
124 | break;
|
||
125 | |||
126 | case PathIterator.SEG_CUBICTO: |
||
127 | System.out.println("Not supported here"); |
||
128 | |||
129 | break;
|
||
130 | |||
131 | case PathIterator.SEG_CLOSE: |
||
132 | break;
|
||
133 | } //end switch
|
||
134 | |||
135 | theIterator.next(); |
||
136 | i++; |
||
137 | } //end while loop
|
||
138 | return str.delete(str.length()-1, str.length()) + "))"; |
||
139 | |||
140 | } |
||
141 | 262 | fjp | } |