Skip to content

Commit d077ffe

Browse files
committed
Jan Eriks changes to server side code
1 parent 50891bb commit d077ffe

3 files changed

Lines changed: 70 additions & 27 deletions

File tree

ServerPlugin/EmfSerializerFactory.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ public void initSerializers() {
125125
enabled.add(upperCase);
126126
}
127127
}
128-
register(new ResultType("JSON_MODEL_FORMAT_2", "JSON Model Formal 2.0", "js", "appliction/collada", UseInCheckout.USE_NOT_IN_CHECKOUT, UserType.USER_TYPE, Type.MULTIPLE, DefaultSelected.FALSE, enabled.contains("JSON_MODEL_FORMAT_2")), new EmfSerializerCreator() {
129-
@Override
130-
public EmfSerializer create(Project project, User user, IfcModel model, String fileName) throws SerializerException {
131-
JSONModelFormat2Serializer jsonModelFormat2Serializer = new JSONModelFormat2Serializer();
132-
jsonModelFormat2Serializer.init(project, user, fileName, model, fieldIgnoreMap, schemaDefinition, ifcEngineFactory);
133-
return jsonModelFormat2Serializer;
134-
}
135-
});
136128
register(new ResultType("IFC", "IFC2x3", "ifc", "application/ifc", UseInCheckout.USE_IN_CHECKOUT, UserType.USER_TYPE, Type.MULTIPLE, DefaultSelected.TRUE, enabled.contains("IFC")), new EmfSerializerCreator(){
137129
@Override
138130
public EmfSerializer create(Project project, User user, IfcModel model, String fileName) {
@@ -189,6 +181,15 @@ public EmfSerializer create(Project project, User user, IfcModel model, String f
189181
return o3dJsonSerializer;
190182
}
191183
});
184+
register(new ResultType("THREEJS", "Three.js viewer", "js", "application/json", UseInCheckout.USE_NOT_IN_CHECKOUT, UserType.USER_TYPE, Type.MULTIPLE, DefaultSelected.FALSE, enabled.contains("THREEJS")), new EmfSerializerCreator() {
185+
@Override
186+
public EmfSerializer create(Project project, User user, IfcModel model, String fileName) throws SerializerException {
187+
//fileName = "wall.js";
188+
JSONModelFormat2Serializer JsonModelFormat2Serializer = new JSONModelFormat2Serializer();
189+
JsonModelFormat2Serializer.init(project, user, fileName, model, fieldIgnoreMap, schemaDefinition, ifcEngineFactory);
190+
return JsonModelFormat2Serializer;
191+
}
192+
});
192193
register(new ResultType("OBJECT_INFO", "Object Info", "html", "text/html", UseInCheckout.USE_NOT_IN_CHECKOUT, UserType.USER_TYPE, Type.SINGLE, DefaultSelected.FALSE, enabled.contains("OBJECT_INFO")), new EmfSerializerCreator() {
193194
@Override
194195
public EmfSerializer create(Project project, User user, IfcModel model, String fileName) {

ServerPlugin/JSONModelFormat2Serializer.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ public boolean write(OutputStream outputStream) throws SerializerException {
8181
PrintWriter out = new PrintWriter(outputStream);
8282
out.println("var model = [");
8383

84-
for(SetGeometryResult geometry : geometries) {
85-
out.println("{");
84+
for(int i=0; i<geometries.size(); i++) {
85+
SetGeometryResult geometry = geometries.get(i);
86+
out.println(i == 0 ? "{": ",{");
8687
writeGeometry(out, geometry);
87-
out.println("},");
88+
out.println("}");
8889
}
8990

9091
out.println("");
@@ -103,14 +104,10 @@ public boolean write(OutputStream outputStream) throws SerializerException {
103104

104105
private void writeGeometry(PrintWriter out, SetGeometryResult geometry) {
105106
out.println("id : '" + geometry.getGuid() + "', ");
107+
out.println("type : '" + geometry.getEntityType() + "', ");
106108
out.println("geometry : {");
107109
out.println(" 'version' : 2, ");
108-
out.println(" 'materials': [ {" +
109-
"\"DbgColor\" : 0xeeeeee," +
110-
"\"DbgIndex\" : 0," +
111-
"\"DbgName\" : \"dummy\"," +
112-
"\"colorDiffuse\" : [ 1, 0, 0 ]" +
113-
"} ],");
110+
out.println(" 'materials': [],");
114111
out.print(" 'vertices': [ ");
115112

116113
List<Float> vertices = geometry.getBinaryVertexBuffer().getVertices();
@@ -213,19 +210,14 @@ private List<SetGeometryResult> getGeometries() {
213210
List<SetGeometryResult> geometryList = new ArrayList<SetGeometryResult>();
214211
//Class[] eClasses = new Class[] { IfcSlab.class, IfcRoof.class, IfcWall.class, IfcWallStandardCase.class, IfcWindow.class, IfcDoor.class, IfcColumn.class, IfcRamp.class,
215212
// IfcStair.class, IfcStairFlight.class, IfcRailing.class };
216-
Class[] eClasses = new Class[] { IfcWallStandardCase.class, IfcWall.class, IfcWindow.class, IfcDoor.class };
213+
Class[] eClasses = new Class[] { IfcWallStandardCase.class, IfcWall.class, IfcWindow.class, IfcDoor.class, IfcSlab.class, IfcColumn.class };
217214

218215
try {
219216
for (Class<? extends EObject> eClass : eClasses) {
220-
int i=0;
221217
for (Object object : model.getAll(eClass)) {
222-
i++;
223-
// if (i < 2) { continue; }
224218
IfcRoot ifcRoot = (IfcRoot) object;
225219
SetGeometryResult geometry = getGeometry(ifcRoot);
226-
if (geometry != null) { geometryList.add(geometry); }
227-
// if (i == 13) { break; }
228-
220+
if (geometry != null) { geometryList.add(geometry); }
229221
}
230222
}
231223
} catch (SerializerException e) {
@@ -269,8 +261,9 @@ private SetGeometryResult getGeometry(IdEObject ifcRootObject) throws Serializer
269261
binaryVertexBuffer.addNormal(geometry.getNormal(i + 1));
270262
binaryVertexBuffer.addNormal(geometry.getNormal(i + 2));
271263
}
272-
String guid = Long.toString(ifcRootObject.getOid()); // TODO
273-
return new SetGeometryResult(guid, nrIndices * 3, geometry.getNrVertices(), binaryIndexBuffer, binaryVertexBuffer);
264+
String guid = ((IfcRoot)ifcRootObject).getGlobalId().getWrappedValue(); // "TODO" + Long.toString(ifcRootObject.getOid()); // TODO
265+
String entityType = ifcRootObject.eClass().getName().toUpperCase();
266+
return new SetGeometryResult(entityType, guid, nrIndices * 3, geometry.getNrVertices(), binaryIndexBuffer, binaryVertexBuffer);
274267
}
275268
} finally {
276269
model.close();
@@ -279,4 +272,4 @@ private SetGeometryResult getGeometry(IdEObject ifcRootObject) throws Serializer
279272
}
280273

281274

282-
}
275+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package ServerPlugin;
2+
3+
public class SetGeometryResult {
4+
private final int addedIndices;
5+
private final int addedVertices;
6+
private final BinaryIndexBuffer binaryIndexBuffer;
7+
private final BinaryVertexBuffer binaryVertexBuffer;
8+
private final String guid;
9+
private final String entityType;
10+
11+
12+
public SetGeometryResult(String entityType, String guid, int addedIndices, int addedVertices, BinaryIndexBuffer binaryIndexBuffer, BinaryVertexBuffer binaryVertexBuffer) {
13+
this.entityType = entityType;
14+
this.guid = guid;
15+
this.addedIndices = addedIndices;
16+
this.addedVertices = addedVertices;
17+
this.binaryIndexBuffer = binaryIndexBuffer;
18+
this.binaryVertexBuffer = binaryVertexBuffer;
19+
}
20+
21+
public SetGeometryResult(int addedIndices, int addedVertices, BinaryIndexBuffer binaryIndexBuffer, BinaryVertexBuffer binaryVertexBuffer) {
22+
this(null, null, addedIndices, addedVertices, binaryIndexBuffer, binaryVertexBuffer);
23+
}
24+
25+
public int getAddedIndices() {
26+
return addedIndices;
27+
}
28+
29+
public int getAddedVertices() {
30+
return addedVertices;
31+
}
32+
33+
public BinaryIndexBuffer getBinaryIndexBuffer() {
34+
return binaryIndexBuffer;
35+
}
36+
37+
public BinaryVertexBuffer getBinaryVertexBuffer() {
38+
return binaryVertexBuffer;
39+
}
40+
41+
public String getGuid() {
42+
return guid;
43+
}
44+
45+
public String getEntityType() {
46+
return entityType;
47+
}
48+
49+
}

0 commit comments

Comments
 (0)