Statistics
| Revision:

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

History | View | Annotate | Download (3.98 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 DwgVertex2D class represents a DWG Vertex2D
44
 * 
45
 * @author jmorell
46
 */
47
public class DwgVertex2D extends DwgObject {
48
        private int flags;
49
        private double[] point;
50
        private double initWidth;
51
        private double endWidth;
52
        private double bulge;
53
        private double tangentDir;
54
        
55
        /**
56
         * Read a Vertex2D in the DWG format Version 15
57
         * 
58
         * @param data Array of unsigned bytes obtained from the DWG binary file
59
         * @param offset The current bit offset where the value begins
60
         * @throws Exception If an unexpected bit value is found in the DWG file. Occurs
61
         *                    when we are looking for LwPolylines.
62
         */
63
        public void readDwgVertex2DV15(int[] data, int offset) throws Exception {
64
                //System.out.println("readDwgVertex2D executing ...");
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 flags = ((Integer)v.get(1)).intValue();
70
                this.flags = flags;
71
                v = DwgUtil.getBitDouble(data, bitPos);
72
                bitPos = ((Integer)v.get(0)).intValue();
73
                double x = ((Double)v.get(1)).doubleValue();
74
                v = DwgUtil.getBitDouble(data, bitPos);
75
                bitPos = ((Integer)v.get(0)).intValue();
76
                double y = ((Double)v.get(1)).doubleValue();
77
                v = DwgUtil.getBitDouble(data, bitPos);
78
                bitPos = ((Integer)v.get(0)).intValue();
79
                double z = ((Double)v.get(1)).doubleValue();
80
                double[] coord = new double[]{x, y, z};
81
                point = new double[]{x, y, z};
82
                v = DwgUtil.getBitDouble(data, bitPos);
83
                bitPos = ((Integer)v.get(0)).intValue();
84
                double sw = ((Double)v.get(1)).doubleValue();
85
                double ew = 0.0;
86
                if (sw<0.0) {
87
                        ew = Math.abs(sw);
88
                        sw = ew;
89
                } else {
90
                        v = DwgUtil.getBitDouble(data, bitPos);
91
                        bitPos = ((Integer)v.get(0)).intValue();
92
                        ew = ((Double)v.get(1)).doubleValue();
93
                }
94
                initWidth = sw;
95
                endWidth = ew;
96
                v = DwgUtil.getBitDouble(data, bitPos);
97
                bitPos = ((Integer)v.get(0)).intValue();
98
                double bulge = ((Double)v.get(1)).doubleValue();
99
                this.bulge = bulge;
100
                v = DwgUtil.getBitDouble(data, bitPos);
101
                bitPos = ((Integer)v.get(0)).intValue();
102
                double tandir = ((Double)v.get(1)).doubleValue();
103
                tangentDir = tandir;
104
                bitPos = readObjectTailV15(data, bitPos);
105
        }
106
        /**
107
         * @return Returns the bulge.
108
         */
109
        public double getBulge() {
110
                return bulge;
111
        }
112
        /**
113
         * @param bulge The bulge to set.
114
         */
115
        public void setBulge(double bulge) {
116
                this.bulge = bulge;
117
        }
118
        /**
119
         * @return Returns the flags.
120
         */
121
        public int getFlags() {
122
                return flags;
123
        }
124
        /**
125
         * @param flags The flags to set.
126
         */
127
        public void setFlags(int flags) {
128
                this.flags = flags;
129
        }
130
        /**
131
         * @return Returns the point.
132
         */
133
        public double[] getPoint() {
134
                return point;
135
        }
136
        /**
137
         * @param point The point to set.
138
         */
139
        public void setPoint(double[] point) {
140
                this.point = point;
141
        }
142
}