@@ -34,30 +34,30 @@ public void returnsNonNullMesh() {
3434 Mesh3D mesh = new CubeCreator ().create ();
3535 assertNotNull (modifier .modify (mesh , new ArrayList <Face3D >()));
3636 }
37-
37+
3838 @ Test
3939 public void nullMeshThrowsException () {
4040 assertThrows (IllegalArgumentException .class , () -> {
4141 modifier .modify (null , new ArrayList <Face3D >());
4242 });
4343 }
44-
44+
4545 @ Test
4646 public void nullCollcetionThrowsException () {
4747 ArrayList <Face3D > faces = null ;
4848 assertThrows (IllegalArgumentException .class , () -> {
4949 modifier .modify (new Mesh3D (), faces );
5050 });
5151 }
52-
52+
5353 @ Test
5454 public void testFaceCountModifyAllCubeFaces () {
5555 Mesh3D cube = new CubeCreator ().create ();
5656 ArrayList <Face3D > faces = new ArrayList <Face3D >(cube .getFaces ());
5757 modifier .modify (cube , faces );
5858 assertEquals (24 , cube .getFaceCount ());
5959 }
60-
60+
6161 @ Test
6262 public void testFaceCountModifyTwoCubeFaces () {
6363 Mesh3D cube = new CubeCreator ().create ();
@@ -67,15 +67,15 @@ public void testFaceCountModifyTwoCubeFaces() {
6767 modifier .modify (cube , faces );
6868 assertEquals (12 , cube .getFaceCount ());
6969 }
70-
70+
7171 @ Test
7272 public void testVertexCountModifyAllCubeFaces () {
7373 Mesh3D cube = new CubeCreator ().create ();
7474 ArrayList <Face3D > faces = new ArrayList <Face3D >(cube .getFaces ());
7575 modifier .modify (cube , faces );
7676 assertEquals (32 , cube .getVertexCount ());
7777 }
78-
78+
7979 @ Test
8080 public void testVertexCountModifyTwoCubeFaces () {
8181 Mesh3D cube = new CubeCreator ().create ();
@@ -85,207 +85,149 @@ public void testVertexCountModifyTwoCubeFaces() {
8585 modifier .modify (cube , faces );
8686 assertEquals (16 , cube .getVertexCount ());
8787 }
88-
89- @ ParameterizedTest
90- @ ValueSource (longs = {
91- 0 ,
92- 4432 ,
93- 245 ,
94- -14332 ,
95- -13423293 ,
96- 4324243 ,
97- Long .MAX_VALUE ,
98- Long .MIN_VALUE
99- })
100- public void testFacesWithDifferentSeeds (long seed ) {
101- int [][] expected = new int [][] {
102- {3 ,0 ,9 ,8 },
103- {0 ,1 ,10 ,9 },
104- {1 ,2 ,11 ,10 },
105- {2 ,3 ,8 ,11 },
106- {6 ,5 ,13 ,12 },
107- {5 ,4 ,14 ,13 },
108- {4 ,7 ,15 ,14 },
109- {7 ,6 ,12 ,15 },
110- {1 ,0 ,17 ,16 },
111- {0 ,4 ,18 ,17 },
112- {4 ,5 ,19 ,18 },
113- {5 ,1 ,16 ,19 },
114- {1 ,5 ,21 ,20 },
115- {5 ,6 ,22 ,21 },
116- {6 ,2 ,23 ,22 },
117- {2 ,1 ,20 ,23 },
118- {6 ,7 ,25 ,24 },
119- {7 ,3 ,26 ,25 },
120- {3 ,2 ,27 ,26 },
121- {2 ,6 ,24 ,27 },
122- {3 ,7 ,29 ,28 },
123- {7 ,4 ,30 ,29 },
124- {4 ,0 ,31 ,30 },
125- {0 ,3 ,28 ,31 }
126- };
88+
89+ @ ParameterizedTest
90+ @ ValueSource (longs = { 0 , 4432 , 245 , -14332 , -13423293 , 4324243 ,
91+ Long .MAX_VALUE , Long .MIN_VALUE })
92+ public void testFacesWithDifferentSeeds (long seed ) {
93+ int [][] expected = new int [][] { { 3 , 0 , 9 , 8 }, { 0 , 1 , 10 , 9 },
94+ { 1 , 2 , 11 , 10 }, { 2 , 3 , 8 , 11 }, { 6 , 5 , 13 , 12 }, { 5 , 4 , 14 , 13 },
95+ { 4 , 7 , 15 , 14 }, { 7 , 6 , 12 , 15 }, { 1 , 0 , 17 , 16 }, { 0 , 4 , 18 , 17 },
96+ { 4 , 5 , 19 , 18 }, { 5 , 1 , 16 , 19 }, { 1 , 5 , 21 , 20 }, { 5 , 6 , 22 , 21 },
97+ { 6 , 2 , 23 , 22 }, { 2 , 1 , 20 , 23 }, { 6 , 7 , 25 , 24 }, { 7 , 3 , 26 , 25 },
98+ { 3 , 2 , 27 , 26 }, { 2 , 6 , 24 , 27 }, { 3 , 7 , 29 , 28 }, { 7 , 4 , 30 , 29 },
99+ { 4 , 0 , 31 , 30 }, { 0 , 3 , 28 , 31 } };
127100 Mesh3D mesh = new CubeCreator ().create ();
128101 modifier .setSeed (seed );
129102 modifier .modify (mesh , mesh .getFaces ());
130103 for (int i = 0 ; i < expected .length ; i ++) {
131104 int [] actual = mesh .getFaceAt (i ).indices ;
132105 assertArrayEquals (expected [i ], actual );
133106 }
134- }
135-
107+ }
108+
136109 @ Test
137110 public void testPlaneVerticesWithZeroSeeed () {
138- Vector3f [] expected = {
139- new Vector3f (1.0f , 0.0f , -1.0f ),
140- new Vector3f (1.0f , 0.0f , 1.0f ),
141- new Vector3f (-1.0f , 0.0f , 1.0f ),
142- new Vector3f (-1.0f , 0.0f , -1.0f ),
143- new Vector3f (0.6847742f , 0.0f , -0.6847742f ),
144- new Vector3f (0.6847742f , 0.0f , 0.6847742f ),
145- new Vector3f (-0.6847742f , 0.0f , 0.6847742f ),
146- new Vector3f (-0.6847742f , 0.0f , -0.6847742f )
147- };
111+ Vector3f [] expected = { new Vector3f (1.0f , 0.0f , -1.0f ),
112+ new Vector3f (1.0f , 0.0f , 1.0f ), new Vector3f (-1.0f , 0.0f , 1.0f ),
113+ new Vector3f (-1.0f , 0.0f , -1.0f ),
114+ new Vector3f (0.6847742f , 0.0f , -0.6847742f ),
115+ new Vector3f (0.6847742f , 0.0f , 0.6847742f ),
116+ new Vector3f (-0.6847742f , 0.0f , 0.6847742f ),
117+ new Vector3f (-0.6847742f , 0.0f , -0.6847742f ) };
148118 ArrayList <Face3D > faces = new ArrayList <Face3D >();
149119 Mesh3D plane = new PlaneCreator ().create ();
150120 faces .add (plane .getFaceAt (0 ));
151121 modifier .modify (plane , faces );
152122 assertArrayEquals (expected , plane .vertices .toArray ());
153123 }
154-
124+
155125 @ Test
156126 public void testPlaneVerticesWithPositiveSeeed () {
157- Vector3f [] expected = {
158- new Vector3f (1.0f , 0.0f , -1.0f ),
159- new Vector3f (1.0f , 0.0f , 1.0f ),
160- new Vector3f (-1.0f , 0.0f , 1.0f ),
161- new Vector3f (-1.0f , 0.0f , -1.0f ),
162- new Vector3f (0.31211585f , 0.0f , -0.31211585f ),
163- new Vector3f (0.31211585f , 0.0f , 0.31211585f ),
164- new Vector3f (-0.31211585f , 0.0f , 0.31211585f ),
165- new Vector3f (-0.31211585f , 0.0f , -0.31211585f ),
166- };
127+ Vector3f [] expected = { new Vector3f (1.0f , 0.0f , -1.0f ),
128+ new Vector3f (1.0f , 0.0f , 1.0f ), new Vector3f (-1.0f , 0.0f , 1.0f ),
129+ new Vector3f (-1.0f , 0.0f , -1.0f ),
130+ new Vector3f (0.31211585f , 0.0f , -0.31211585f ),
131+ new Vector3f (0.31211585f , 0.0f , 0.31211585f ),
132+ new Vector3f (-0.31211585f , 0.0f , 0.31211585f ),
133+ new Vector3f (-0.31211585f , 0.0f , -0.31211585f ), };
167134 ArrayList <Face3D > faces = new ArrayList <Face3D >();
168135 Mesh3D plane = new PlaneCreator ().create ();
169136 faces .add (plane .getFaceAt (0 ));
170137 modifier .setSeed (13424 );
171138 modifier .modify (plane , faces );
172139 assertArrayEquals (expected , plane .vertices .toArray ());
173140 }
174-
141+
175142 @ Test
176143 public void testPlaneVerticesWithNegativeSeeed () {
177- Vector3f [] expected = {
178- new Vector3f (1.0f , 0.0f , -1.0f ),
179- new Vector3f (1.0f , 0.0f , 1.0f ),
180- new Vector3f (-1.0f , 0.0f , 1.0f ),
181- new Vector3f (-1.0f , 0.0f , -1.0f ),
182- new Vector3f (0.2969781f , 0.0f , -0.2969781f ),
183- new Vector3f (0.2969781f , 0.0f , 0.2969781f ),
184- new Vector3f (-0.2969781f , 0.0f , 0.2969781f ),
185- new Vector3f (-0.2969781f , 0.0f , -0.2969781f ),
186- };
144+ Vector3f [] expected = { new Vector3f (1.0f , 0.0f , -1.0f ),
145+ new Vector3f (1.0f , 0.0f , 1.0f ), new Vector3f (-1.0f , 0.0f , 1.0f ),
146+ new Vector3f (-1.0f , 0.0f , -1.0f ),
147+ new Vector3f (0.2969781f , 0.0f , -0.2969781f ),
148+ new Vector3f (0.2969781f , 0.0f , 0.2969781f ),
149+ new Vector3f (-0.2969781f , 0.0f , 0.2969781f ),
150+ new Vector3f (-0.2969781f , 0.0f , -0.2969781f ), };
187151 ArrayList <Face3D > faces = new ArrayList <Face3D >();
188152 Mesh3D plane = new PlaneCreator ().create ();
189153 faces .add (plane .getFaceAt (0 ));
190154 modifier .setSeed (-3244324 );
191155 modifier .modify (plane , faces );
192156 assertArrayEquals (expected , plane .vertices .toArray ());
193157 }
194-
158+
195159 @ Test
196160 public void testPlaneVerticesWithSeedMaxLong () {
197- Vector3f [] expected = {
198- new Vector3f (1.0f , 0.0f , -1.0f ),
199- new Vector3f (1.0f , 0.0f , 1.0f ),
200- new Vector3f (-1.0f , 0.0f , 1.0f ),
201- new Vector3f (-1.0f , 0.0f , -1.0f ),
202- new Vector3f (0.31515408f , 0.0f , -0.31515408f ),
203- new Vector3f (0.31515408f , 0.0f , 0.31515408f ),
204- new Vector3f (-0.31515408f , 0.0f , 0.31515408f ),
205- new Vector3f (-0.31515408f , 0.0f , -0.31515408f ),
206- };
161+ Vector3f [] expected = { new Vector3f (1.0f , 0.0f , -1.0f ),
162+ new Vector3f (1.0f , 0.0f , 1.0f ), new Vector3f (-1.0f , 0.0f , 1.0f ),
163+ new Vector3f (-1.0f , 0.0f , -1.0f ),
164+ new Vector3f (0.31515408f , 0.0f , -0.31515408f ),
165+ new Vector3f (0.31515408f , 0.0f , 0.31515408f ),
166+ new Vector3f (-0.31515408f , 0.0f , 0.31515408f ),
167+ new Vector3f (-0.31515408f , 0.0f , -0.31515408f ), };
207168 ArrayList <Face3D > faces = new ArrayList <Face3D >();
208169 Mesh3D plane = new PlaneCreator ().create ();
209170 faces .add (plane .getFaceAt (0 ));
210171 modifier .setSeed (Long .MAX_VALUE );
211172 modifier .modify (plane , faces );
212173 assertArrayEquals (expected , plane .vertices .toArray ());
213174 }
214-
175+
215176 @ Test
216177 public void testPlaneVerticesWithSeedMinLong () {
217- Vector3f [] expected = {
218- new Vector3f (1.0f , 0.0f , -1.0f ),
219- new Vector3f (1.0f , 0.0f , 1.0f ),
220- new Vector3f (-1.0f , 0.0f , 1.0f ),
221- new Vector3f (-1.0f , 0.0f , -1.0f ),
222- new Vector3f (0.6847742f , 0.0f , -0.6847742f ),
223- new Vector3f (0.6847742f , 0.0f , 0.6847742f ),
224- new Vector3f (-0.6847742f , 0.0f , 0.6847742f ),
225- new Vector3f (-0.6847742f , 0.0f , -0.6847742f ),
226- };
178+ Vector3f [] expected = { new Vector3f (1.0f , 0.0f , -1.0f ),
179+ new Vector3f (1.0f , 0.0f , 1.0f ), new Vector3f (-1.0f , 0.0f , 1.0f ),
180+ new Vector3f (-1.0f , 0.0f , -1.0f ),
181+ new Vector3f (0.6847742f , 0.0f , -0.6847742f ),
182+ new Vector3f (0.6847742f , 0.0f , 0.6847742f ),
183+ new Vector3f (-0.6847742f , 0.0f , 0.6847742f ),
184+ new Vector3f (-0.6847742f , 0.0f , -0.6847742f ), };
227185 ArrayList <Face3D > faces = new ArrayList <Face3D >();
228186 Mesh3D plane = new PlaneCreator ().create ();
229187 faces .add (plane .getFaceAt (0 ));
230188 modifier .setSeed (Long .MIN_VALUE );
231189 modifier .modify (plane , faces );
232190 assertArrayEquals (expected , plane .vertices .toArray ());
233191 }
234-
235- @ Test
236- public void tesCubeVerticesWithPositiveSeed () {
237- Vector3f [] expected = new Vector3f [] {
238- new Vector3f (1.0f , -1.0f , -1.0f ),
239- new Vector3f (1.0f , -1.0f , 1.0f ),
240- new Vector3f (-1.0f , -1.0f , 1.0f ),
241- new Vector3f (-1.0f , -1.0f , -1.0f ),
242- new Vector3f (1.0f , 1.0f , -1.0f ),
243- new Vector3f (1.0f , 1.0f , 1.0f ),
244- new Vector3f (-1.0f , 1.0f , 1.0f ),
245- new Vector3f (-1.0f , 1.0f , -1.0f ),
246- new Vector3f (-1.0f , 0.2517369f , 0.2517369f ),
247- new Vector3f (-1.0f , 0.2517369f , -0.2517369f ),
248- new Vector3f (-1.0f , -0.2517369f , -0.2517369f ),
249- new Vector3f (-1.0f , -0.2517369f , 0.2517369f ),
250- };
192+
193+ @ Test
194+ public void tesCubeVerticesWithPositiveSeed () {
195+ Vector3f [] expected = new Vector3f [] { new Vector3f (1.0f , -1.0f , -1.0f ),
196+ new Vector3f (1.0f , -1.0f , 1.0f ), new Vector3f (-1.0f , -1.0f , 1.0f ),
197+ new Vector3f (-1.0f , -1.0f , -1.0f ), new Vector3f (1.0f , 1.0f , -1.0f ),
198+ new Vector3f (1.0f , 1.0f , 1.0f ), new Vector3f (-1.0f , 1.0f , 1.0f ),
199+ new Vector3f (-1.0f , 1.0f , -1.0f ),
200+ new Vector3f (-1.0f , 0.2517369f , 0.2517369f ),
201+ new Vector3f (-1.0f , 0.2517369f , -0.2517369f ),
202+ new Vector3f (-1.0f , -0.2517369f , -0.2517369f ),
203+ new Vector3f (-1.0f , -0.2517369f , 0.2517369f ), };
251204 Mesh3D mesh = new CubeCreator ().create ();
252205 ArrayList <Face3D > faces = new ArrayList <Face3D >();
253206 faces .add (mesh .getFaceAt (4 ));
207+ modifier = new RandomHolesModifier (0.1f , 0.3f );
254208 modifier .setSeed (234453 );
255- modifier .setMinAmount (0.1f );
256- modifier .setMaxAmount (0.3f );
257209 modifier .modify (mesh , faces );
258210 assertArrayEquals (expected , mesh .vertices .toArray ());
259- }
260-
261- @ ParameterizedTest
262- @ ValueSource (floats = {
263- 0.1f ,
264- 0.322f ,
265- 0.123f ,
266- 0.022f ,
267- 0.245f ,
268- 0.751f ,
269- 0.965f ,
270- Float .MIN_VALUE ,
271- Float .MAX_VALUE ,
272- })
273- public void testMinMaxAmountPositiveValuesAndSeed (float amount ) {
274- Mesh3D expected = new PlaneCreator ().create ();
275- ExtrudeModifier extrudeModifier = new ExtrudeModifier ();
276- extrudeModifier .setRemoveFaces (true );
277- extrudeModifier .setScale (amount );
278- extrudeModifier .setAmount (0 );
279- expected .apply (extrudeModifier );
280-
281- Mesh3D actual = new PlaneCreator ().create ();
282- ArrayList <Face3D > faces = new ArrayList <Face3D >();
283- faces .add (actual .getFaceAt (0 ));
284- modifier .setMinAmount (amount );
285- modifier .setMaxAmount (amount );
286- modifier .setSeed (234 );
287- modifier .modify (actual , faces );
211+ }
212+
213+ @ ParameterizedTest
214+ @ ValueSource (floats = { 0.1f , 0.322f , 0.123f , 0.022f , 0.245f , 0.751f ,
215+ 0.965f })
216+ public void testMinMaxAmountPositiveValuesAndSeed (float amount ) {
217+ Mesh3D expected = new PlaneCreator ().create ();
218+ ExtrudeModifier extrudeModifier = new ExtrudeModifier ();
219+ extrudeModifier .setRemoveFaces (true );
220+ extrudeModifier .setScale (amount );
221+ extrudeModifier .setAmount (0 );
222+ expected .apply (extrudeModifier );
223+
224+ Mesh3D actual = new PlaneCreator ().create ();
225+ ArrayList <Face3D > faces = new ArrayList <Face3D >();
226+ faces .add (actual .getFaceAt (0 ));
227+ modifier = new RandomHolesModifier (amount , amount );
228+ modifier .setSeed (234 );
229+ modifier .modify (actual , faces );
288230 assertArrayEquals (expected .vertices .toArray (), actual .vertices .toArray ());
289- }
290-
231+ }
232+
291233}
0 commit comments