Revision 10539 branches/v10/libraries/libDwg/src/com/iver/cit/jdwglib/dwg/objects/DwgVertex2D.java
DwgVertex2D.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package com.iver.cit.jdwglib.dwg.objects; |
36 | 36 |
|
37 |
import java.util.ArrayList; |
|
38 |
|
|
39 | 37 |
import com.iver.cit.jdwglib.dwg.DwgObject; |
40 |
import com.iver.cit.jdwglib.dwg.DwgUtil; |
|
41 | 38 |
|
42 | 39 |
/** |
43 | 40 |
* The DwgVertex2D class represents a DWG Vertex2D |
... | ... | |
45 | 42 |
* @author jmorell |
46 | 43 |
*/ |
47 | 44 |
public class DwgVertex2D extends DwgObject { |
45 |
public DwgVertex2D(int index) { |
|
46 |
super(index); |
|
47 |
// TODO Auto-generated constructor stub |
|
48 |
} |
|
48 | 49 |
private int flags; |
49 | 50 |
private double[] point; |
50 | 51 |
private double initWidth; |
... | ... | |
52 | 53 |
private double bulge; |
53 | 54 |
private double tangentDir; |
54 | 55 |
|
56 |
|
|
55 | 57 |
/** |
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 |
ArrayList 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 | 58 |
* @return Returns the bulge. |
108 | 59 |
*/ |
109 | 60 |
public double getBulge() { |
... | ... | |
139 | 90 |
public void setPoint(double[] point) { |
140 | 91 |
this.point = point; |
141 | 92 |
} |
93 |
public double getEndWidth() { |
|
94 |
return endWidth; |
|
95 |
} |
|
96 |
public void setEndWidth(double endWidth) { |
|
97 |
this.endWidth = endWidth; |
|
98 |
} |
|
99 |
public double getInitWidth() { |
|
100 |
return initWidth; |
|
101 |
} |
|
102 |
public void setInitWidth(double initWidth) { |
|
103 |
this.initWidth = initWidth; |
|
104 |
} |
|
105 |
public double getTangentDir() { |
|
106 |
return tangentDir; |
|
107 |
} |
|
108 |
public void setTangentDir(double tangentDir) { |
|
109 |
this.tangentDir = tangentDir; |
|
110 |
} |
|
111 |
public Object clone(){ |
|
112 |
DwgVertex2D obj = new DwgVertex2D(index); |
|
113 |
this.fill(obj); |
|
114 |
return obj; |
|
115 |
} |
|
116 |
|
|
117 |
protected void fill(DwgObject obj){ |
|
118 |
super.fill(obj); |
|
119 |
DwgVertex2D myObj = (DwgVertex2D)obj; |
|
120 |
|
|
121 |
myObj.setBulge(bulge); |
|
122 |
myObj.setEndWidth(endWidth); |
|
123 |
myObj.setFlags(flags); |
|
124 |
myObj.setInitWidth(initWidth); |
|
125 |
myObj.setPoint(point); |
|
126 |
myObj.setTangentDir(tangentDir); |
|
127 |
} |
|
128 |
|
|
142 | 129 |
} |
Also available in: Unified diff