11package joons ;
22
3- import java . util .ArrayList ;
4- import java . util .List ;
3+ import org . sunflow . util .FloatArray ;
4+ import org . sunflow . util .IntArray ;
55
66public class JRFiller {
77
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 ;
1212
1313 private final String fillType ;
1414 public float [] p ; //array of parameters
1515 public int np = 0 ; //number of parameters
1616
1717 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 ();
2222
2323 this .fillType = fillType ;
2424 p = params ;
@@ -29,12 +29,12 @@ public String getType() {
2929 return fillType ;
3030 }
3131
32- public List < Float > getVertices () {
32+ public FloatArray getVertices () {
3333 return vertices ;
3434 }
3535
3636 private void writeTriangleIndices () {
37- for (int i = 0 ; i < (vertices .size () / 9 ); i ++) {
37+ for (int i = 0 ; i < (vertices .getSize () / 9 ); i ++) {
3838 //vertices/3 = number of 3d points
3939 //vertices/9 = number of triangles
4040 triangleIndices .add (i * 3 );
@@ -44,20 +44,12 @@ private void writeTriangleIndices() {
4444 }
4545
4646 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 ();
5248 }
5349
5450 public int [] triangleIndicesToArray () {
5551 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 ();
6153 }
6254
6355 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) {
6759 spheres .add (r );
6860 }
6961
70- public List < Float > getSpheres () {
62+ public FloatArray getSpheres () {
7163 return spheres ;
7264 }
7365
0 commit comments