Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgSpline.java @ 10539

History | View | Annotate | Download (6.31 KB)

1
/* jdwglib. Java Library for reading Dwg files.
2
 * 
3
 * Author: Jose Morell Rama (jose.morell@gmail.com).
4
 * Port from the Pythoncad Dwg library by Art Haas.
5
 *
6
 * Copyright (C) 2005 Jose Morell, IVER TI S.A. and Generalitat Valenciana
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 * Jose Morell (jose.morell@gmail.com)
25
 * 
26
 * or
27
 *
28
 * IVER TI S.A.
29
 *  C/Salamanca, 50
30
 *  46005 Valencia
31
 *  Spain
32
 *  +34 963163400
33
 *  dac@iver.es
34
 */
35
package com.iver.cit.jdwglib.dwg.objects;
36

    
37
import com.iver.cit.jdwglib.dwg.DwgObject;
38
import com.iver.cit.jdwglib.dwg.IDwg3DTestable;
39

    
40
/**
41
 * The DwgSpline class represents a DWG Spline
42
 * 
43
 * @author jmorell
44
 */
45
public class DwgSpline extends DwgObject implements IDwg3DTestable{
46
        public DwgSpline(int index) {
47
                super(index);
48
                // TODO Auto-generated constructor stub
49
        }
50
        private int scenario;
51
        private int degree;
52
        private double fitTolerance;
53
        private double[] beginTanVector;
54
        private double[] endTanVector;
55
        private boolean rational;
56
        private boolean closed;
57
        private boolean periodic;
58
        private double knotTolerance;
59
        private double controlTolerance;
60
        private double[] knotPoints;
61
        private double[][] controlPoints;
62
        private double[] weights;
63
        private double[][] fitPoints;
64
        
65
        /**
66
         * @return Returns the closed.
67
         */
68
        public boolean isClosed() {
69
                return closed;
70
        }
71
        /**
72
         * @param closed The closed to set.
73
         */
74
        public void setClosed(boolean closed) {
75
                this.closed = closed;
76
        }
77
        /**
78
         * @return Returns the controlPoints.
79
         */
80
        public double[][] getControlPoints() {
81
                return controlPoints;
82
        }
83
        /**
84
         * @param controlPoints The controlPoints to set.
85
         */
86
        public void setControlPoints(double[][] controlPoints) {
87
                this.controlPoints = controlPoints;
88
        }
89
        /**
90
         * @return Returns the fitPoints.
91
         */
92
        public double[][] getFitPoints() {
93
                return fitPoints;
94
        }
95
        /**
96
         * @param fitPoints The fitPoints to set.
97
         */
98
        public void setFitPoints(double[][] fitPoints) {
99
                this.fitPoints = fitPoints;
100
        }
101
        /**
102
         * @return Returns the knotPoints.
103
         */
104
        public double[] getKnotPoints() {
105
                return knotPoints;
106
        }
107
        /**
108
         * @param knotPoints The knotPoints to set.
109
         */
110
        public void setKnotPoints(double[] knotPoints) {
111
                this.knotPoints = knotPoints;
112
        }
113
        /**
114
         * @return Returns the scenario.
115
         */
116
        public int getScenario() {
117
                return scenario;
118
        }
119
        /**
120
         * @param scenario The scenario to set.
121
         */
122
        public void setScenario(int scenario) {
123
                this.scenario = scenario;
124
        }
125

    
126
        /**
127
         * @return Returns the beginTanVector.
128
         */
129
        public double[] getBeginTanVector() {
130
                return beginTanVector;
131
        }
132
        /**
133
         * @param beginTanVector The beginTanVector to set.
134
         */
135
        public void setBeginTanVector(double[] beginTanVector) {
136
                this.beginTanVector = beginTanVector;
137
        }
138
        /**
139
         * @return Returns the controlTolerance.
140
         */
141
        public double getControlTolerance() {
142
                return controlTolerance;
143
        }
144
        /**
145
         * @param controlTolerance The controlTolerance to set.
146
         */
147
        public void setControlTolerance(double controlTolerance) {
148
                this.controlTolerance = controlTolerance;
149
        }
150
        /**
151
         * @return Returns the degree.
152
         */
153
        public int getDegree() {
154
                return degree;
155
        }
156
        /**
157
         * @param degree The degree to set.
158
         */
159
        public void setDegree(int degree) {
160
                this.degree = degree;
161
        }
162
        /**
163
         * @return Returns the endTanVector.
164
         */
165
        public double[] getEndTanVector() {
166
                return endTanVector;
167
        }
168
        /**
169
         * @param endTanVector The endTanVector to set.
170
         */
171
        public void setEndTanVector(double[] endTanVector) {
172
                this.endTanVector = endTanVector;
173
        }
174
        /**
175
         * @return Returns the fitTolerance.
176
         */
177
        public double getFitTolerance() {
178
                return fitTolerance;
179
        }
180
        /**
181
         * @param fitTolerance The fitTolerance to set.
182
         */
183
        public void setFitTolerance(double fitTolerance) {
184
                this.fitTolerance = fitTolerance;
185
        }
186
        /**
187
         * @return Returns the knotTolerance.
188
         */
189
        public double getKnotTolerance() {
190
                return knotTolerance;
191
        }
192
        /**
193
         * @param knotTolerance The knotTolerance to set.
194
         */
195
        public void setKnotTolerance(double knotTolerance) {
196
                this.knotTolerance = knotTolerance;
197
        }
198
        /**
199
         * @return Returns the periodic.
200
         */
201
        public boolean isPeriodic() {
202
                return periodic;
203
        }
204
        /**
205
         * @param periodic The periodic to set.
206
         */
207
        public void setPeriodic(boolean periodic) {
208
                this.periodic = periodic;
209
        }
210
        /**
211
         * @return Returns the rational.
212
         */
213
        public boolean isRational() {
214
                return rational;
215
        }
216
        /**
217
         * @param rational The rational to set.
218
         */
219
        public void setRational(boolean rational) {
220
                this.rational = rational;
221
        }
222
        /**
223
         * @return Returns the weights.
224
         */
225
        public double[] getWeights() {
226
                return weights;
227
        }
228
        /**
229
         * @param weights The weights to set.
230
         */
231
        public void setWeights(double[] weights) {
232
                this.weights = weights;
233
        }
234
        /* (non-Javadoc)
235
         * @see com.iver.cit.jdwglib.dwg.IDwg3DTestable#has3DData()
236
         */
237
        public boolean has3DData() {
238
                double[][] pts = getControlPoints();   
239
                if(pts == null)
240
                        return false;
241
                double z = 0d;
242
                for (int j=0;j<pts.length;j++) {
243
                                z = pts[j][2];
244
                                if (z != 0.0) 
245
                                        return true;
246
                }//for
247
                return false;
248
        }
249
        public double getZ() {
250
                return 0d;
251
        }
252
        /* (non-Javadoc)
253
         * @see java.lang.Object#clone()
254
         */
255
        public Object clone(){
256
                DwgSpline obj = new DwgSpline(index);
257
                this.fill(obj);
258
                return obj;
259
        }
260
        
261
        protected void fill(DwgObject obj){
262
                super.fill(obj);
263
                DwgSpline myObj = (DwgSpline)obj;
264

    
265
                myObj.setBeginTanVector(beginTanVector);
266
                myObj.setClosed(closed);
267
                myObj.setControlPoints(controlPoints);
268
                myObj.setControlTolerance(controlTolerance);
269
                myObj.setDegree(degree);
270
                myObj.setEndTanVector(endTanVector);
271
                myObj.setFitPoints(fitPoints);
272
                myObj.setFitTolerance(fitTolerance);
273
                myObj.setKnotPoints(knotPoints);
274
                myObj.setKnotTolerance(knotTolerance);
275
                myObj.setPeriodic(periodic);
276
                myObj.setRational(rational);
277
                myObj.setScenario(scenario);
278
                myObj.setWeights(weights);
279

    
280
        }
281

    
282
}