Skip to content

Commit d4caf9a

Browse files
committed
Fixing a bug in the server code as well as making the client robust to
properties that may contain non serializable objects
1 parent 8234ada commit d4caf9a

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public CSG optimization(OptType type) {
803803
public CSG union(CSG csg) {
804804
if (this.polygons.size() > getMinPolygonsForOffloading() || csg.polygons.size() > getMinPolygonsForOffloading())
805805
if (CSGClient.isRunning()) {
806-
ArrayList<CSG> go = new ArrayList<CSG>(Arrays.asList(this));
806+
ArrayList<CSG> go = new ArrayList<CSG>(Arrays.asList(this,csg));
807807
try {
808808
return CSGClient.getClient().union(go).get(0);
809809
} catch (Exception e) {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ private ArrayList<CSG> performOperation(List<CSG> csgList, CSGRemoteOperation op
131131
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
132132
System.out.println("Running Operation on server: " + hostname + " " + operation);
133133
// Create and send request
134+
ArrayList<PropertyStorage> store =new ArrayList<PropertyStorage>();
135+
for(CSG c:csgList) {
136+
store.add(c.getStorage());
137+
// Do not attempt to send properties because they may contain lambda functions that can not serialize
138+
c.setStorage(new PropertyStorage());
139+
}
134140
CSGRequest request = new CSGRequest(csgList, operation);
135141
if (key != null)
136142
request.setAPIKEY(key);
@@ -145,6 +151,11 @@ private ArrayList<CSG> performOperation(List<CSG> csgList, CSGRemoteOperation op
145151
throw new RuntimeException(response.getMessage());
146152
// Return results as ArrayList
147153
back = new ArrayList<>(response.getCsgList());
154+
for(CSG c:back) {
155+
for(PropertyStorage s:store) {
156+
c.getStorage().syncProperties(s);// Keep the Lambdas in the memory space where they came from
157+
}
158+
}
148159
} catch (Throwable t) {
149160
socket.close();
150161
throw t;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ private CSGResponse processCSGRequest(CSGRequest request) {
100100
back.add(c.triangulate(true));
101101
break;
102102
case UNION:
103-
back.add(CSG.unionAll(request.getCsgList()));
103+
CSG d = request.getCsgList().remove(0);
104+
back.add(d.union(request.getCsgList()));
104105
break;
105106
case minkowskiHullShape:
106107
CSG m1 = request.getCsgList().remove(0);

0 commit comments

Comments
 (0)