1
1
package joons ;
2
2
3
- import java . util .ArrayList ;
4
- import java . util .List ;
3
+ import org . sunflow . util .FloatArray ;
4
+ import org . sunflow . util .IntArray ;
5
5
6
6
public class JRFiller {
7
7
8
- private final List < Float > vertices ;
9
- private final List < Integer > triangleIndices ;
10
- private final List < Float > spheres ;
11
- private final List < Float > points ;
8
+ private final FloatArray vertices ;
9
+ private final IntArray triangleIndices ;
10
+ private final FloatArray spheres ;
11
+ private final FloatArray points ;
12
12
13
13
private final String fillType ;
14
14
public float [] p ; //array of parameters
15
15
public int np = 0 ; //number of parameters
16
16
17
17
public JRFiller (String fillType , float ... params ) {
18
- vertices = new ArrayList <> ();
19
- triangleIndices = new ArrayList <> ();
20
- spheres = new ArrayList <> ();
21
- points = new ArrayList <> ();
18
+ vertices = new FloatArray ();
19
+ triangleIndices = new IntArray ();
20
+ spheres = new FloatArray ();
21
+ points = new FloatArray ();
22
22
23
23
this .fillType = fillType ;
24
24
p = params ;
@@ -29,12 +29,12 @@ public String getType() {
29
29
return fillType ;
30
30
}
31
31
32
- public List < Float > getVertices () {
32
+ public FloatArray getVertices () {
33
33
return vertices ;
34
34
}
35
35
36
36
private void writeTriangleIndices () {
37
- for (int i = 0 ; i < (vertices .size () / 9 ); i ++) {
37
+ for (int i = 0 ; i < (vertices .getSize () / 9 ); i ++) {
38
38
//vertices/3 = number of 3d points
39
39
//vertices/9 = number of triangles
40
40
triangleIndices .add (i * 3 );
@@ -44,20 +44,12 @@ private void writeTriangleIndices() {
44
44
}
45
45
46
46
public float [] verticesToArray () {
47
- float [] v = new float [vertices .size ()];
48
- for (int i = 0 ; i < vertices .size (); i ++) {
49
- v [i ] = vertices .get (i );
50
- }
51
- return v ;
47
+ return vertices .trim ();
52
48
}
53
49
54
50
public int [] triangleIndicesToArray () {
55
51
writeTriangleIndices ();
56
- int [] t = new int [triangleIndices .size ()];
57
- for (int i = 0 ; i < triangleIndices .size (); i ++) {
58
- t [i ] = triangleIndices .get (i );
59
- }
60
- return t ;
52
+ return triangleIndices .trim ();
61
53
}
62
54
63
55
public void addSphere (float x , float y , float z , float r ) {
@@ -67,7 +59,7 @@ public void addSphere(float x, float y, float z, float r) {
67
59
spheres .add (r );
68
60
}
69
61
70
- public List < Float > getSpheres () {
62
+ public FloatArray getSpheres () {
71
63
return spheres ;
72
64
}
73
65
0 commit comments