@@ -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+ }
0 commit comments