https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 5d8f37f7c6b88e2716e164df6a0a5f43eacddb0e authored by renchao_lu on 05 March 2021, 15:10:39 UTC
[CL] move return statement forward.
Tip revision: 5d8f37f
TestDividedByPlane.cpp
/**
 * \file
 * \author Karsten Rink
 * \date   2014-02-26
 *
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 *
 */

#include <gtest/gtest.h>

#include "MathLib/GeometricBasics.h"
#include "MathLib/Point3d.h"

TEST(MathLib, TestDividedByPlane)
{
    // xy plane
    MathLib::Point3d a(std::array<double,3>{{0, 0, 0}});
    MathLib::Point3d b(std::array<double,3>{{1, 0, 0}});
    MathLib::Point3d c(std::array<double,3>{{0, 1, 0}});
    MathLib::Point3d d(std::array<double,3>{{1, 1, 0}});

    bool result = MathLib::dividedByPlane(a, d, b, c);
    ASSERT_TRUE(result);

    result = MathLib::dividedByPlane(b, c, a, d);
    ASSERT_TRUE(result);

    d = MathLib::Point3d(std::array<double,3>{{0.1, 0.1, 0}});
    result = MathLib::dividedByPlane(b, c, a, d);
    ASSERT_FALSE(result);

    // xz plane
    c = MathLib::Point3d(std::array<double,3>{{0, 0, 1}});
    d = MathLib::Point3d(std::array<double,3>{{1, 0, 1}});
    result = MathLib::dividedByPlane(a, d, b, c);
    ASSERT_TRUE(result);

    // yz plane
    b = MathLib::Point3d(std::array<double,3>{{0, 1, 0}});
    d = MathLib::Point3d(std::array<double,3>{{0, 1, 1}});
    result = MathLib::dividedByPlane(a, d, b, c);
    ASSERT_TRUE(result);
}
back to top