-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScaleInfo.java
More file actions
53 lines (39 loc) · 1.46 KB
/
ScaleInfo.java
File metadata and controls
53 lines (39 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.nio.ByteBuffer;
/**
* Created by C. Andrews on 6/5/17.
*/
public class ScaleInfo {
public ScaleInfo(ByteBuffer buffer){
int bufferSize = buffer.limit();
int numSegments = buffer.getInt();
System.out.println(numSegments);
System.out.println(buffer.limit());
for (int i = 0; i < numSegments; i++) {
String name = readString(buffer);
float x = buffer.getFloat();
float y = buffer.getFloat();
float z = buffer.getFloat();
System.out.println(String.format("\t%s (%f, %f, %f)", name, x, y, z));
}
int numPoints = buffer.getInt();
for (int i = 0; i < numPoints; i++){
short segId = buffer.getShort();
short pointId = buffer.getShort();
String name = readString(buffer);
int characteristics = buffer.getInt();
float x = buffer.getFloat();
float y = buffer.getFloat();
float z = buffer.getFloat();
System.out.println(String.format("\t%d %d %s %02X (%f, %f, %f)", segId, pointId, name, characteristics, x, y, z));
}
}
private String readString(ByteBuffer buffer){
StringBuffer stringBuffer = new StringBuffer();
char c;
int stringLength = buffer.getInt();
for (int i = 0; i < stringLength; i++){
stringBuffer.append((char)buffer.get());
}
return stringBuffer.toString();
}
}