Exemplo n.º 1
0
def preprocess_space_parameters(x, y, z, max_x, max_y, max_z):
    """
    Covert ajax call parameters into numbers and validate them.

    :param x:  coordinate
    :param y:  coordinate
    :param z:  coordinate that will be reversed
    :param max_x: maximum x accepted value
    :param max_y: maximum y accepted value
    :param max_z: maximum z accepted value

    :return: (x, y, z) as integers, Z reversed
    """

    x, y, z = int(x), int(y), int(z)

    if not 0 <= x <= max_x or not 0 <= y <= max_y or not 0 <= z <= max_z:
        msg = "Coordinates out of boundaries: [x,y,z] = [{0}, {1}, {2}]".format(
            x, y, z)
        raise exceptions.ValidationException(msg)

    # Reverse Z
    z = max_z - z - 1

    return x, y, z
Exemplo n.º 2
0
    def validate(self):
        self.number_of_vertices = self.vertices.shape[0]
        self.number_of_triangles = self.triangles.shape[0]

        if self.triangles.max() >= self.number_of_vertices:
            raise exceptions.ValidationException("There are triangles that index nonexistent vertices.")

        validation_result = self.validate_topology_for_simulations()

        self.valid_for_simulations = len(validation_result.warnings) == 0

        return validation_result
Exemplo n.º 3
0
def preprocess_time_parameters(t1, t2, time_length):
    """
    Covert ajax call parameters into numbers and validate them.

    :param t1: start time
    :param t2: end time
    :param time_length: maximum time length in current TS

    :return: (t1, t2, t2-t1) as numbers
    """

    from_idx = int(t1)
    to_idx = int(t2)

    if not 0 <= from_idx < to_idx <= time_length:
        msg = "Time indexes out of boundaries: from {0} to {1}".format(
            from_idx, to_idx)
        raise exceptions.ValidationException(msg)

    current_time_line = max(to_idx - from_idx, 1)

    return from_idx, to_idx, current_time_line