Skip to content

Commit 76a6909

Browse files
committed
fixing the difference error
1 parent d07dbfa commit 76a6909

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/java/eu/mihosoft/vrl/v3d/CSG.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,9 @@ private CSG _unionNoOpt(CSG csg) {
11591159
*/
11601160
public CSG difference(List<CSG> csgs) {
11611161
if (CSGClient.isRunning()) {
1162-
ArrayList<CSG> go = new ArrayList<CSG>(csgs);
1162+
ArrayList<CSG> go = new ArrayList<CSG>();
1163+
go.add(this);
1164+
go.addAll(csgs);
11631165
try {
11641166
return CSGClient.getClient().difference(go).get(0);
11651167
} catch (Exception e) {

src/test/java/eu/mihosoft/vrl/v3d/ServerClientTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ public CSG prep(CSG incoming) {
5353
b.getBounds();
5454
CSG c = new Cube(10, 10, 10).toCSG();
5555
c.getBounds();
56+
CSG dif = new Cube(100, 100, 1).toCSG();
57+
dif.getBounds();
5658

5759
int apoly1 = a.getPolygons().size();
5860
int bpoly1 =b.getPolygons().size();
5961

6062
CSG u1 = a.union( b,c);
6163
CSG i1 = c.intersect(b);
62-
CSG d1 = a.difference(b);
64+
CSG d1 = a.difference(b,dif);
6365
CSG t1 = d1.clone().triangulate(true);
6466
ArrayList<CSG> m1 = a.minkowskiHullShape(b);
6567
CSG h1 = u1.hull();
@@ -77,7 +79,7 @@ public CSG prep(CSG incoming) {
7779
CSG i0 = c.intersect(b);
7880
if(testPoly(i1,i0))
7981
fail();
80-
CSG d = a.difference(b);
82+
CSG d = a.difference(b,dif);
8183
if(testPoly(d1,d))
8284
fail("Difference Step fail , expected "+d1.getPolygons().size()+" got "+d.getPolygons().size());
8385
CSG t = d.clone().triangulate(true);

0 commit comments

Comments
 (0)