Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
Extract big data.
3 files modified
125 ■■■■■ changed files
GroupEditor.java 3 ●●●● patch | view | raw | blame | history
ObjEditor.java 67 ●●●●● patch | view | raw | blame | history
Object3D.java 55 ●●●●● patch | view | raw | blame | history
GroupEditor.java
....@@ -3429,7 +3429,8 @@
34293429
34303430 int size = obj.MemorySize();
34313431
3432
- System.err.println((size/1024) + " KB is the size of " + obj);
3432
+ //System.err.println((size/1024) + " KB is the size of " + obj);
3433
+ System.err.println("the size of " + obj + " is " + size + " (" + (size/1024) + "KB)");
34333434 }
34343435 }
34353436 catch (Exception e)
ObjEditor.java
....@@ -3214,6 +3214,47 @@
32143214 objEditor.refreshContents();
32153215 }
32163216
3217
+ static public byte[] Compress(Object o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3224
+
3225
+ out.writeObject(o);
3226
+
3227
+ out.flush();
3228
+
3229
+ zstream.close();
3230
+ out.close();
3231
+
3232
+ return baos.toByteArray();
3233
+ } catch (Exception e)
3234
+ {
3235
+ System.err.println(e);
3236
+ return null;
3237
+ }
3238
+ }
3239
+
3240
+ static public Object Uncompress(byte[] bytes)
3241
+ {
3242
+ try
3243
+ {
3244
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3245
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3246
+ ObjectInputStream in = new ObjectInputStream(istream);
3247
+ Object obj = in.readObject();
3248
+ in.close();
3249
+
3250
+ return obj;
3251
+ } catch (Exception e)
3252
+ {
3253
+ System.err.println(e);
3254
+ return null;
3255
+ }
3256
+ }
3257
+
32173258 static public Object clone(Object o)
32183259 {
32193260 try
....@@ -3222,12 +3263,19 @@
32223263 ObjectOutputStream out = new ObjectOutputStream(baos);
32233264
32243265 out.writeObject(o);
3266
+
3267
+ out.flush();
3268
+ out.close();
3269
+
3270
+ byte[] bytes = baos.toByteArray();
3271
+
3272
+ System.out.println("clone = " + bytes.length);
32253273
3226
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3274
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
32273275 ObjectInputStream in = new ObjectInputStream(bais);
32283276 Object obj = in.readObject();
32293277 in.close();
3230
- out.close();
3278
+
32313279 return obj;
32323280 } catch (Exception e)
32333281 {
....@@ -3251,13 +3299,21 @@
32513299 return null;
32523300 }
32533301
3302
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3303
+
32543304 public void Save()
32553305 {
32563306 cRadio tab = GetCurrentTab();
32573307
3308
+ copy.ExtractBigData(hashtable);
3309
+
32583310 //EditorFrame.m_MainFrame.requestFocusInWindow();
32593311 tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
32603312
3313
+ copy.RestoreBigData(hashtable);
3314
+
3315
+ //assert(hashtable.isEmpty());
3316
+
32613317 for (int i = tab.undoindex; i < tab.graphs.length; i++)
32623318 {
32633319 tab.graphs[i] = null;
....@@ -3285,12 +3341,18 @@
32853341
32863342 void CopyChanged(Object3D obj)
32873343 {
3344
+ copy.ExtractBigData(hashtable);
3345
+
32883346 copy.clear();
32893347
32903348 for (int i=0; i<obj.Size(); i++)
32913349 {
32923350 copy.add(obj.get(i));
32933351 }
3352
+
3353
+ copy.RestoreBigData(hashtable);
3354
+
3355
+ //assert(hashtable.isEmpty());
32943356
32953357 copy.Touch();
32963358
....@@ -4295,6 +4357,7 @@
42954357
42964358 if (readobj != null)
42974359 {
4360
+ Save();
42984361 try
42994362 {
43004363 //readobj.deepCopySelf(copy);
Object3D.java
....@@ -163,6 +163,59 @@
163163 }
164164 }
165165
166
+void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
+{
168
+ if (hashtable.containsKey(GetUUID()))
169
+ return;
170
+
171
+ Object3D o = new Object3D();
172
+ o.bRep = this.bRep;
173
+ if (this.bRep != null)
174
+ {
175
+ o.transientrep = this.bRep.support;
176
+ o.bRep.support = null;
177
+ }
178
+
179
+// o.support = this.support;
180
+// o.fileparent = this.fileparent;
181
+// if (this.bRep != null)
182
+// o.bRep = this.bRep.support;
183
+
184
+ hashtable.put(GetUUID(), o);
185
+
186
+ this.bRep = null;
187
+// if (this.bRep != null)
188
+// this.bRep.support = null;
189
+// this.support = null;
190
+// this.fileparent = null;
191
+
192
+ for (int i=0; i<Size(); i++)
193
+ {
194
+ get(i).ExtractBigData(hashtable);
195
+ }
196
+}
197
+
198
+void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
199
+{
200
+ if (!hashtable.containsKey(GetUUID()))
201
+ return;
202
+
203
+ Object3D o = hashtable.get(GetUUID());
204
+
205
+ this.bRep = o.bRep;
206
+ if (this.bRep != null)
207
+ this.bRep.support = o.transientrep;
208
+// this.support = o.support;
209
+// this.fileparent = o.fileparent;
210
+
211
+ hashtable.remove(GetUUID());
212
+
213
+ for (int i=0; i<Size(); i++)
214
+ {
215
+ get(i).RestoreBigData(hashtable);
216
+ }
217
+}
218
+
166219 // MOCAP SUPPORT
167220 double tx,ty,tz,rx,ry,rz;
168221
....@@ -7567,7 +7620,7 @@
75677620 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75687621
75697622 Object3D /*Composite*/ parent;
7570
- Object3D /*Composite*/ fileparent;
7623
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75717624
75727625 double[][] toParent; // dynamic matrix
75737626 double[][] fromParent;