Statistics
| Revision:

root / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgSpline.java @ 10820

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

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

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

    
281
        }
282

    
283
}