def _applyAlignSettings(self):
     rot = vectorops.eulerToRotationMatrix3(self._alignSettings['euler_angles'])
     scale = self._alignSettings['scale']
     xScale = scale
     if self.isAlignMirror():
         xScale = -scale
     rotationScale = [
         rot[0][0]*xScale, rot[0][1]*xScale, rot[0][2]*xScale,
         rot[1][0]*scale,  rot[1][1]*scale,  rot[1][2]*scale,
         rot[2][0]*scale,  rot[2][1]*scale,  rot[2][2]*scale]
     fm = self._region.getFieldmodule()
     fm.beginChange()
     if self._modelTransformedCoordinateField is None:
         self._modelRotationScaleField = fm.createFieldConstant(rotationScale)
         # following works in 3-D only
         temp1 = fm.createFieldMatrixMultiply(3, self._modelRotationScaleField, self._modelCoordinateField)
         self._modelOffsetField = fm.createFieldConstant(self._alignSettings['offset'])
         self._modelTransformedCoordinateField = fm.createFieldAdd(temp1, self._modelOffsetField)
     else:
         cache = fm.createFieldcache()
         self._modelRotationScaleField.assignReal(cache, rotationScale)
         self._modelOffsetField.assignReal(cache, self._alignSettings['offset'])
     fm.endChange()
     if not self._modelTransformedCoordinateField.isValid():
         print("Can't create transformed model coordinate field. Is problem 2-D?")
     self._alignSettingsChangeCallback()
 def setStatePostAlign(self):
     if not self._isStateAlign:
         return
     self._isStateAlign = False
     rotationScale = vectorops.matrixconstantmult(vectorops.eulerToRotationMatrix3(self._alignSettings['euler_angles']), self._alignSettings['scale'])
     if self.isAlignMirror():
         rotationScale[0] = vectorops.mult(rotationScale[0], -1.0)
     zincutils.transformCoordinates(self._modelCoordinateField, rotationScale, self._alignSettings['offset'])
     zincutils.copyNodalParameters(self._modelCoordinateField, self._modelReferenceCoordinateField)
     self._setModelGraphicsCoordinateField(self._modelCoordinateField)
 def rotateModel(self, axis, angle):
     quat = vectorops.axisAngleToQuaternion(axis, angle)
     mat1 = vectorops.rotmx(quat)
     mat2 = vectorops.eulerToRotationMatrix3(self._alignSettings['euler_angles'])
     if self.isAlignMirror():
         mat2[0] = vectorops.mult(mat2[0], -1.0)
     newmat = vectorops.matrixmult(mat1, mat2)
     if self.isAlignMirror():
         newmat[0] = vectorops.mult(newmat[0], -1.0)
     self._alignSettings['euler_angles'] = vectorops.rotationMatrix3ToEuler(newmat)
     self._applyAlignSettings()
 def rotateModel(self, axis, angle):
     quat = vectorops.axisAngleToQuaternion(axis, angle)
     mat1 = vectorops.rotmx(quat)
     mat2 = vectorops.eulerToRotationMatrix3(
         self._alignSettings['euler_angles'])
     if self.isAlignMirror():
         mat2[0] = vectorops.mult(mat2[0], -1.0)
     newmat = vectorops.matrixmult(mat1, mat2)
     if self.isAlignMirror():
         newmat[0] = vectorops.mult(newmat[0], -1.0)
     self._alignSettings['euler_angles'] = vectorops.rotationMatrix3ToEuler(
         newmat)
     self._applyAlignSettings()
 def setStatePostAlign(self):
     if not self._isStateAlign:
         return
     self._isStateAlign = False
     rotationScale = vectorops.matrixconstantmult(
         vectorops.eulerToRotationMatrix3(
             self._alignSettings['euler_angles']),
         self._alignSettings['scale'])
     if self.isAlignMirror():
         rotationScale[0] = vectorops.mult(rotationScale[0], -1.0)
     zincutils.transformCoordinates(self._modelCoordinateField,
                                    rotationScale,
                                    self._alignSettings['offset'])
     zincutils.copyNodalParameters(self._modelCoordinateField,
                                   self._modelReferenceCoordinateField)
     self._setModelGraphicsCoordinateField(self._modelCoordinateField)
 def _applyAlignSettings(self):
     rot = vectorops.eulerToRotationMatrix3(
         self._alignSettings['euler_angles'])
     scale = self._alignSettings['scale']
     xScale = scale
     if self.isAlignMirror():
         xScale = -scale
     rotationScale = [
         rot[0][0] * xScale, rot[0][1] * xScale, rot[0][2] * xScale,
         rot[1][0] * scale, rot[1][1] * scale, rot[1][2] * scale,
         rot[2][0] * scale, rot[2][1] * scale, rot[2][2] * scale
     ]
     fm = self._region.getFieldmodule()
     fm.beginChange()
     if self._modelTransformedCoordinateField is None:
         self._modelRotationScaleField = fm.createFieldConstant(
             rotationScale)
         # following works in 3-D only
         temp1 = fm.createFieldMatrixMultiply(3,
                                              self._modelRotationScaleField,
                                              self._modelCoordinateField)
         self._modelOffsetField = fm.createFieldConstant(
             self._alignSettings['offset'])
         self._modelTransformedCoordinateField = fm.createFieldAdd(
             temp1, self._modelOffsetField)
     else:
         cache = fm.createFieldcache()
         self._modelRotationScaleField.assignReal(cache, rotationScale)
         self._modelOffsetField.assignReal(cache,
                                           self._alignSettings['offset'])
     fm.endChange()
     if not self._modelTransformedCoordinateField.isValid():
         print(
             "Can't create transformed model coordinate field. Is problem 2-D?"
         )
     self._alignSettingsChangeCallback()