@@ -120,10 +120,9 @@ void EditMeshBoundingBox::setOutputParameters()
120120 state->setValue (OutputCenterX, widgetTranslation_.x ());
121121 state->setValue (OutputCenterY, widgetTranslation_.y ());
122122 state->setValue (OutputCenterZ, widgetTranslation_.z ());
123- auto vecs = widgetScale_.get_transformation_vectors ();
124- state->setValue (OutputSizeX, 2.0 *vecs[0 ].norm ());
125- state->setValue (OutputSizeY, 2.0 *vecs[1 ].norm ());
126- state->setValue (OutputSizeZ, 2.0 *vecs[2 ].norm ());
123+ state->setValue (OutputSizeX, size_[0 ]);
124+ state->setValue (OutputSizeY, size_[1 ]);
125+ state->setValue (OutputSizeZ, size_[2 ]);
127126}
128127
129128void EditMeshBoundingBox::clearVals ()
@@ -241,10 +240,11 @@ void EditMeshBoundingBox::resetToInputField()
241240 computeWidgetBox (outputField_->vmesh ()->get_bounding_box ());
242241
243242 ogPos_ = pos_;
243+ ogSize_ = size_;
244244 widgetTranslation_ = pos_;
245- auto trans = Transform (pos_, eigvecs_[ 0 ]*eigvals_[ 0 ], eigvecs_[ 1 ]*eigvals_[ 1 ], eigvecs_[ 2 ]*eigvals_[ 2 ]) ;
246- ogScale_ = 2.0 * Vector (eigvals_ [0 ], eigvals_ [1 ], eigvals_ [2 ]);
247- widgetScale_.pre_scale (Vector (eigvals_[ 0 ], eigvals_[ 1 ], eigvals_[ 2 ]) );
245+ auto eigvals = HALF_SCALE_ * size_ ;
246+ auto trans = Transform (pos_, eigvecs_[ 0 ]*eigvals [0 ], eigvecs_ [1 ]*eigvals[ 1 ], eigvecs_[ 2 ]*eigvals [2 ]);
247+ widgetScale_.pre_scale (eigvals );
248248
249249 inputFieldInverse_ = Transform (trans);
250250 inputFieldInverse_.invert ();
@@ -254,9 +254,9 @@ void EditMeshBoundingBox::resetToInputField()
254254 state->setValue (OutputCenterX, ogPos_.x ());
255255 state->setValue (OutputCenterY, ogPos_.y ());
256256 state->setValue (OutputCenterZ, ogPos_.z ());
257- state->setValue (OutputSizeX, ogScale_ .x ());
258- state->setValue (OutputSizeY, ogScale_ .y ());
259- state->setValue (OutputSizeZ, ogScale_ .z ());
257+ state->setValue (OutputSizeX, ogSize_ .x ());
258+ state->setValue (OutputSizeY, ogSize_ .y ());
259+ state->setValue (OutputSizeZ, ogSize_ .z ());
260260}
261261
262262// Sets the translation vector in the homogeneous matrices
@@ -266,8 +266,8 @@ void EditMeshBoundingBox::setOutputCenter()
266266 state->setTransientValue (SetOutputCenter, false );
267267
268268 widgetTranslation_ = Point (state->getValue (OutputCenterX).toDouble (),
269- state->getValue (OutputCenterY).toDouble (),
270- state->getValue (OutputCenterZ).toDouble ());
269+ state->getValue (OutputCenterY).toDouble (),
270+ state->getValue (OutputCenterZ).toDouble ());
271271
272272}
273273
@@ -286,23 +286,27 @@ void EditMeshBoundingBox::setOutputSize()
286286{
287287 auto state = get_state ();
288288 state->setTransientValue (SetOutputSize, false );
289+ size_ = Vector (state->getValue (OutputSizeX).toDouble (),
290+ state->getValue (OutputSizeY).toDouble (),
291+ state->getValue (OutputSizeZ).toDouble ());
292+ auto eigvals = HALF_SCALE_ * size_;
289293
290294 widgetScale_ = Transform ();
291- widgetScale_.post_scale (0.5 * Vector (state->getValue (OutputSizeX).toDouble (),
292- state->getValue (OutputSizeY).toDouble (),
293- state->getValue (OutputSizeZ).toDouble ()));
295+ widgetScale_.post_scale (eigvals);
294296}
295297
296298void EditMeshBoundingBox::resetOutputSize ()
297299{
298300 auto state = get_state ();
299301 state->setTransientValue (ResetSize, false );
302+ size_ = ogSize_;
303+ auto eigvals = HALF_SCALE_ * size_;
300304
301305 widgetScale_ = Transform ();
302- widgetScale_.pre_scale (0.5 * ogScale_ );
303- state->setValue (OutputSizeX, ogScale_ .x ());
304- state->setValue (OutputSizeY, ogScale_ .y ());
305- state->setValue (OutputSizeZ, ogScale_ .z ());
306+ widgetScale_.pre_scale (eigvals );
307+ state->setValue (OutputSizeX, size_ .x ());
308+ state->setValue (OutputSizeY, size_ .y ());
309+ state->setValue (OutputSizeZ, size_ .z ());
306310}
307311
308312std::string EditMeshBoundingBox::convertForLabel (double coord)
@@ -322,32 +326,28 @@ void EditMeshBoundingBox::computeWidgetBox(const BBox& box)
322326 }
323327
324328 // build a widget identical to the BBox
325- auto diag = bbox_.diagonal ();
329+ pos_ = bbox_.center ();
330+ size_ = bbox_.diagonal ();
326331 const auto SMALL = 1e-4 ;
327- if (fabs (diag.x ())<SMALL)
332+ const auto SMALL2 = 2 *SMALL;
333+ if (fabs (size_.x ())<SMALL)
328334 {
329- diag .x (2 * SMALL );
335+ size_ .x (SMALL2 );
330336 bbox_.extend (bbox_.get_min () - Vector (SMALL, 0.0 , 0.0 ));
331337 bbox_.extend (bbox_.get_max () + Vector (SMALL, 0.0 , 0.0 ));
332338 }
333- if (fabs (diag .y ())<SMALL)
339+ if (fabs (size_ .y ())<SMALL)
334340 {
335- diag .y (2 * SMALL );
341+ size_ .y (SMALL2 );
336342 bbox_.extend (bbox_.get_min () - Vector (0.0 , SMALL, 0.0 ));
337343 bbox_.extend (bbox_.get_max () + Vector (0.0 , SMALL, 0.0 ));
338344 }
339- if (fabs (diag .z ())<SMALL)
345+ if (fabs (size_ .z ())<SMALL)
340346 {
341- diag .z (2 * SMALL );
347+ size_ .z (SMALL2 );
342348 bbox_.extend (bbox_.get_min () - Vector (0.0 , 0.0 , SMALL));
343349 bbox_.extend (bbox_.get_max () + Vector (0.0 , 0.0 , SMALL));
344350 }
345-
346- eigvals_.resize (mDIMENSIONS );
347- pos_ = bbox_.center ();
348- eigvals_[0 ] = diag.x () * 0.5 ;
349- eigvals_[1 ] = diag.y () * 0.5 ;
350- eigvals_[2 ] = diag.z () * 0.5 ;
351351}
352352
353353void EditMeshBoundingBox::generateGeomsList ()
@@ -377,9 +377,9 @@ void EditMeshBoundingBox::updateInputFieldAttributes()
377377 state->setValue (InputCenterX, convertForLabel (ogPos_[0 ]));
378378 state->setValue (InputCenterY, convertForLabel (ogPos_[1 ]));
379379 state->setValue (InputCenterZ, convertForLabel (ogPos_[2 ]));
380- state->setValue (InputSizeX, convertForLabel (ogScale_ [0 ]));
381- state->setValue (InputSizeY, convertForLabel (ogScale_ [1 ]));
382- state->setValue (InputSizeZ, convertForLabel (ogScale_ [2 ]));
380+ state->setValue (InputSizeX, convertForLabel (ogSize_ [0 ]));
381+ state->setValue (InputSizeY, convertForLabel (ogSize_ [1 ]));
382+ state->setValue (InputSizeZ, convertForLabel (ogSize_ [2 ]));
383383}
384384
385385void EditMeshBoundingBox::saveToParameters ()
0 commit comments