Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libDwg / src / com / iver / cit / jdwglib / dwg / objects / DwgPolyline3D.java @ 2896

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 java.util.Vector;
38

    
39
import com.iver.cit.jdwglib.dwg.DwgObject;
40
import com.iver.cit.jdwglib.dwg.DwgUtil;
41

    
42
/**
43
 * The DwgPolyline3D class represents a DWG Polyline3D
44
 * 
45
 * @author jmorell
46
 */
47
public class DwgPolyline3D extends DwgObject {
48
        private int splineFlags;
49
        private int closedFlags;
50
        private int firstVertexHandle;
51
        private int lastVertexHandle;
52
        private int seqendHandle;
53
        private double[][] pts;
54
        private double[] bulges;
55
        
56
        /**
57
         * Read a Polyline3D in the DWG format Version 15
58
         * 
59
         * @param data Array of unsigned bytes obtained from the DWG binary file
60
         * @param offset The current bit offset where the value begins
61
         * @throws Exception If an unexpected bit value is found in the DWG file. Occurs
62
         *                    when we are looking for LwPolylines.
63
         */
64
        public void readDwgPolyline3DV15(int[] data, int offset) throws Exception {
65
                int bitPos = offset;
66
                bitPos = readObjectHeaderV15(data, bitPos);
67
                Vector v = DwgUtil.getRawChar(data, bitPos);
68
                bitPos = ((Integer)v.get(0)).intValue();
69
                int sflags = ((Integer)v.get(1)).intValue();
70
                splineFlags = sflags;
71
                v = DwgUtil.getRawChar(data, bitPos);
72
                bitPos = ((Integer)v.get(0)).intValue();
73
                int cflags = ((Integer)v.get(1)).intValue();
74
                closedFlags = cflags;
75
                bitPos = readObjectTailV15(data, bitPos);
76
                v = DwgUtil.getHandle(data, bitPos);
77
                bitPos = ((Integer)v.get(0)).intValue();
78
                int[] handle = new int[v.size()-1];
79
            for (int i=1;i<v.size();i++) {
80
                    handle[i-1] = ((Integer)v.get(i)).intValue();
81
            }
82
            Vector handleVect = new Vector();
83
            for (int i=0;i<handle.length;i++) {
84
                    handleVect.add(new Integer(handle[i]));
85
            }
86
            firstVertexHandle = DwgUtil.handleBinToHandleInt(handleVect);
87
                v = DwgUtil.getHandle(data, bitPos);
88
                bitPos = ((Integer)v.get(0)).intValue();
89
                handle = new int[v.size()-1];
90
            for (int i=1;i<v.size();i++) {
91
                    handle[i-1] = ((Integer)v.get(i)).intValue();
92
            }
93
            handleVect = new Vector();
94
            for (int i=0;i<handle.length;i++) {
95
                    handleVect.add(new Integer(handle[i]));
96
            }
97
            lastVertexHandle = DwgUtil.handleBinToHandleInt(handleVect);
98
                v = DwgUtil.getHandle(data, bitPos);
99
                bitPos = ((Integer)v.get(0)).intValue();
100
                handle = new int[v.size()-1];
101
            for (int i=1;i<v.size();i++) {
102
                    handle[i-1] = ((Integer)v.get(i)).intValue();
103
            }
104
            handleVect = new Vector();
105
            for (int i=0;i<handle.length;i++) {
106
                    handleVect.add(new Integer(handle[i]));
107
            }
108
            seqendHandle = DwgUtil.handleBinToHandleInt(handleVect);
109
        }
110
        /**
111
         * @return Returns the closedFlags.
112
         */
113
        public int getClosedFlags() {
114
                return closedFlags;
115
        }
116
        /**
117
         * @param closedFlags The closedFlags to set.
118
         */
119
        public void setClosedFlags(int closedFlags) {
120
                this.closedFlags = closedFlags;
121
        }
122
        /**
123
         * @return Returns the firstVertexHandle.
124
         */
125
        public int getFirstVertexHandle() {
126
                return firstVertexHandle;
127
        }
128
        /**
129
         * @param firstVertexHandle The firstVertexHandle to set.
130
         */
131
        public void setFirstVertexHandle(int firstVertexHandle) {
132
                this.firstVertexHandle = firstVertexHandle;
133
        }
134
        /**
135
         * @return Returns the lastVertexHandle.
136
         */
137
        public int getLastVertexHandle() {
138
                return lastVertexHandle;
139
        }
140
        /**
141
         * @param lastVertexHandle The lastVertexHandle to set.
142
         */
143
        public void setLastVertexHandle(int lastVertexHandle) {
144
                this.lastVertexHandle = lastVertexHandle;
145
        }
146
        /**
147
         * @return Returns the pts.
148
         */
149
        public double[][] getPts() {
150
                return pts;
151
        }
152
        /**
153
         * @param pts The pts to set.
154
         */
155
        public void setPts(double[][] pts) {
156
                this.pts = pts;
157
        }
158
        /**
159
         * @return Returns the bulges.
160
         */
161
        public double[] getBulges() {
162
                return bulges;
163
        }
164
        /**
165
         * @param bulges The bulges to set.
166
         */
167
        public void setBulges(double[] bulges) {
168
                this.bulges = bulges;
169
        }
170
        /* (non-Javadoc)
171
         * @see java.lang.Object#clone()
172
         */
173
        public Object clone() {
174
                DwgPolyline3D dwgPolyline3D = new DwgPolyline3D();
175
                dwgPolyline3D.setType(type);
176
                dwgPolyline3D.setHandle(handle);
177
                dwgPolyline3D.setVersion(version);
178
                dwgPolyline3D.setMode(mode);
179
                dwgPolyline3D.setLayerHandle(layerHandle);
180
                dwgPolyline3D.setColor(color);
181
                dwgPolyline3D.setNumReactors(numReactors);
182
                dwgPolyline3D.setNoLinks(noLinks);
183
                dwgPolyline3D.setLinetypeFlags(linetypeFlags);
184
                dwgPolyline3D.setPlotstyleFlags(plotstyleFlags);
185
                dwgPolyline3D.setSizeInBits(sizeInBits);
186
                dwgPolyline3D.setExtendedData(extendedData);
187
                dwgPolyline3D.setGraphicData(graphicData);
188
                //dwgPolyline3D.setInsideBlock(insideBlock);
189
                dwgPolyline3D.setSplineFlags(splineFlags);
190
                dwgPolyline3D.setClosedFlags(closedFlags);
191
                dwgPolyline3D.setFirstVertexHandle(firstVertexHandle);
192
                dwgPolyline3D.setLastVertexHandle(lastVertexHandle);
193
                dwgPolyline3D.setSeqendHandle(seqendHandle);
194
                dwgPolyline3D.setPts(pts);
195
                dwgPolyline3D.setBulges(bulges);
196
                return dwgPolyline3D;
197
        }
198
        /**
199
         * @return Returns the seqendHandle.
200
         */
201
        public int getSeqendHandle() {
202
                return seqendHandle;
203
        }
204
        /**
205
         * @param seqendHandle The seqendHandle to set.
206
         */
207
        public void setSeqendHandle(int seqendHandle) {
208
                this.seqendHandle = seqendHandle;
209
        }
210
        /**
211
         * @return Returns the splineFlags.
212
         */
213
        public int getSplineFlags() {
214
                return splineFlags;
215
        }
216
        /**
217
         * @param splineFlags The splineFlags to set.
218
         */
219
        public void setSplineFlags(int splineFlags) {
220
                this.splineFlags = splineFlags;
221
        }
222
}