Skip to content

Commit 562a185

Browse files
committed
refactor(cell): refactor constructor to call setters
refactor constructor to call setters
1 parent afb7f86 commit 562a185

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Sources/Common/DataModel/Cell/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,30 @@ function vtkCell(publicAPI, model) {
122122
// Object factory
123123
// ----------------------------------------------------------------------------
124124

125-
const DEFAULT_VALUES = {
126-
bounds: [-1, -1, -1, -1, -1, -1],
127-
pointsIds: [],
128-
};
125+
function defaultValues(initialValues) {
126+
return {
127+
points: vtkPoints.newInstance(),
128+
bounds: [-1, -1, -1, -1, -1, -1],
129+
pointsIds: [],
130+
...initialValues,
131+
};
132+
}
129133

130134
// ----------------------------------------------------------------------------
131135

132136
export function extend(publicAPI, model, initialValues = {}) {
133-
Object.assign(model, DEFAULT_VALUES, initialValues);
137+
Object.assign(initialValues, defaultValues(initialValues));
134138

135139
macro.obj(publicAPI, model);
136140

137-
if (!model.points) {
138-
model.points = vtkPoints.newInstance({ values: [] });
139-
}
140-
141141
macro.get(publicAPI, model, ['points', 'pointsIds']);
142142

143143
vtkCell(publicAPI, model);
144144
}
145145

146146
// ----------------------------------------------------------------------------
147147

148-
export const newInstance = macro.newInstance(extend, 'vtkCell');
148+
export const newInstance = macro.newInstance(extend, 'vtkCell', true);
149149

150150
// ----------------------------------------------------------------------------
151151

0 commit comments

Comments
 (0)