Пример #1
0
def RotateVtuField(vtu, fieldName, axis, angle):
    """
  Rotate a field in a vtu
  """

    field = vtu.GetField(fieldName)
    rank = VtuFieldRank(vtu, fieldName)
    if rank == 0:
        # Scalar field rotation (i.e., do nothing)
        pass
    elif rank == 1:
        # Vector field rotation
        newField = []
        for val in field:
            newField.append(calc.RotatedVector(val, angle, axis=axis))
        newField = numpy.array(newField)
        vtu.AddVectorField(fieldName, newField)
    elif rank == 2:
        # Tensor field rotation
        newField = []
        for val in field:
            newField.append(calc.RotatedTensor(val, angle, axis=axis))
        newField = numpy.array(newField)
        vtu.AddField(fieldName, newField)
    else:
        # Erm, erm ...
        raise Exception("Unexpected data shape: " +
                        str(VtuFieldShape(vtu, fieldName)))

    return
Пример #2
0
def RotateVtu(vtu, axis, angle):
    """
  Rotate a vtu
  """

    # Rotate the locations
    locations = vtu.GetLocations()
    newLocations = vtk.vtkPoints()
    for location in locations:
        newLocations.InsertNextPoint(
            calc.RotatedVector(location, angle, axis=axis))
    vtu.ugrid.SetPoints(newLocations)

    # Rotate the fields
    for fieldName in vtu.GetFieldNames():
        RotateVtuField(vtu, fieldName, axis, angle)

    return
Пример #3
0
 def Map(self, coord):
     return calc.RotatedVector(coord, self._angle, axis=self._axis)