Skip to content

Commit 7fd32f5

Browse files
committed
Fix: Make proxy layer compatible with empty functional model
1 parent b90869b commit 7fd32f5

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

src/layer/intermediate/Reshape.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,22 @@ function Reshape( config ) {
6161
this.actualHeight = undefined;
6262
this.actualDepth = undefined;
6363

64+
this.depth = undefined;
65+
6466
this.layerDimension = undefined;
6567
this.openFmCenters = undefined;
6668

69+
this.lastLayer = undefined;
70+
71+
if ( config !== undefined &&
72+
( config.targetShape !== undefined || config.shape !== undefined ) ) {
73+
74+
this.setReshapeType();
75+
this.createActualLayer();
76+
this.updateLayerMetric();
77+
78+
}
79+
6780
}
6881

6982
Reshape.prototype = {
@@ -114,10 +127,14 @@ Reshape.prototype = {
114127
this.actualHeight = this.actualLayer.actualHeight;
115128
this.actualDepth = this.actualLayer.actualDepth;
116129

130+
this.depth = this.actualLayer.depth;
131+
117132
this.layerDimension = this.actualLayer.layerDimension;
118133

119134
this.openFmCenters = this.actualLayer.openFmCenters;
120135

136+
this.lastLayer = this.actualLayer.lastLayer;
137+
121138
},
122139

123140
/**
@@ -166,6 +183,13 @@ Reshape.prototype = {
166183

167184
setEnvironment: function( context, model ) {
168185

186+
if ( this.actualLayer === undefined ) {
187+
188+
this.createActualLayer();
189+
this.updateLayerMetric();
190+
191+
}
192+
169193
this.actualLayer.setEnvironment( context, model );
170194

171195
},
@@ -212,6 +236,20 @@ Reshape.prototype = {
212236

213237
},
214238

239+
translateLayer: function( targetCenter, translateTime ) {
240+
241+
this.actualLayer.translateLayer( targetCenter, translateTime );
242+
243+
},
244+
245+
apply: function( lastLayer ) {
246+
247+
this.actualLayer.apply( lastLayer );
248+
249+
this.updateLayerMetric();
250+
251+
},
252+
215253
setShape: function( shape ) {
216254

217255
// Based on shape dimension, update proxy states.
@@ -246,6 +284,15 @@ Reshape.prototype = {
246284

247285
assemble: function() {
248286

287+
this.setReshapeType();
288+
289+
this.actualLayer.assemble();
290+
this.updateLayerMetric();
291+
292+
},
293+
294+
setReshapeType: function() {
295+
249296
// If "setShape" has been called before, there is no need to check "shape" attribute or "targetShape" attribute in config.
250297

251298
if ( this.reshapeType === undefined ) {
@@ -308,9 +355,6 @@ Reshape.prototype = {
308355

309356
}
310357

311-
this.actualLayer.assemble();
312-
this.updateLayerMetric();
313-
314358
}
315359

316360
};

src/merge/proxy/MergeProxy.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function MergeProxy( operatorType, layerList, config ) {
4545
this.actualHeight = undefined;
4646
this.actualDepth = undefined;
4747

48+
this.depth = undefined;
49+
4850
this.layerDimension = undefined;
4951

5052
this.openFmCenters = undefined;
@@ -89,6 +91,8 @@ MergeProxy.prototype = {
8991
this.actualHeight = this.actualLayer.actualHeight;
9092
this.actualDepth = this.actualLayer.actualDepth;
9193

94+
this.depth = this.actualLayer.depth;
95+
9296
this.layerDimension = this.actualLayer.layerDimension;
9397

9498
this.openFmCenters = this.actualLayer.openFmCenters;
@@ -136,6 +140,14 @@ MergeProxy.prototype = {
136140

137141
setEnvironment: function( context, model ) {
138142

143+
if ( this.actualLayer === undefined ) {
144+
145+
MergeValidator.validateDimension( this.layerList );
146+
this.createActualLayer();
147+
this.updateLayerMetric();
148+
149+
}
150+
139151
this.actualLayer.setEnvironment( context, model );
140152

141153
},
@@ -188,6 +200,12 @@ MergeProxy.prototype = {
188200

189201
},
190202

203+
translateLayer: function( targetCenter, translateTime ) {
204+
205+
this.actualLayer.translateLayer( targetCenter, translateTime );
206+
207+
},
208+
191209
setShape: function( shape ) {
192210

193211
// make sure the input elements have the same dimension.

0 commit comments

Comments
 (0)