Blender V5.3
BLI_convexhull_2d_test.cc File Reference
#include "testing/testing.h"
#include "BLI_array.hh"
#include "BLI_convexhull_2d.hh"
#include "BLI_math_angle_types.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_rotation.hh"
#include "BLI_math_rotation_c.hh"
#include "BLI_math_vector.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_rand.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define DEFAULT_TEST_ITER   8
#define DEFAULT_TEST_POLY_NUM   12
#define DEFAULT_TEST_RANDOM_SEED   123
#define ROTATION_EPS   1e-6

Functions

Internal Utilities
static Array< float2 > blender::convexhull_points_from_map (Span< float2 > points, Span< int > points_map)
static Array< float2 > blender::convexhull_2d_as_array (Span< float2 > points)
static float blender::mod_inline (float a, float b)
static float blender::convexhull_aabb_canonical_angle (float angle)
Tests
 blender::TEST (convexhull_2d, IsConvex)
 blender::TEST (convexhull_2d, IsCCW)
 blender::TEST (convexhull_2d, NOP)
 blender::TEST (convexhull_2d, Lines_AxisAligned)
 blender::TEST (convexhull_2d, Lines_Diagonal)
 blender::TEST (convexhull_2d, Simple)
 blender::TEST (convexhull_2d, Octagon)
 blender::TEST (convexhull_2d, OctagonAxisAligned)
 blender::TEST (convexhull_2d, OctagonNearDuplicates)
 blender::TEST (convexhull_2d, Complex)
 blender::TEST (convexhull_2d, NearCoLinear)
 blender::TEST (convexhull_2d, CoincidentTopmostX)

Detailed Description

Test that convex hull calculation and fitting convex hulls to a bounding box is working properly.

Note
Bounding box fitting checks compare against exact values. In this case there are multiple correct angles since both 45 degrees & -45 degrees will give the desired outcome. Keep using exact value matches so any changes to the return values are detected. If this becomes a problem for maintaining tests then values could be normalized for comparison.

Definition in file BLI_convexhull_2d_test.cc.

Macro Definition Documentation

◆ DEFAULT_TEST_ITER

#define DEFAULT_TEST_ITER   8

Increase to a large number (8k or so) to test many permutations, too slow for regular tests.

Definition at line 37 of file BLI_convexhull_2d_test.cc.

Referenced by blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), and blender::TEST().

◆ DEFAULT_TEST_POLY_NUM

#define DEFAULT_TEST_POLY_NUM   12

The size of a polygon when generating data.

Definition at line 40 of file BLI_convexhull_2d_test.cc.

Referenced by blender::TEST(), blender::TEST(), and blender::TEST().

◆ DEFAULT_TEST_RANDOM_SEED

#define DEFAULT_TEST_RANDOM_SEED   123

◆ ROTATION_EPS

#define ROTATION_EPS   1e-6

The epsilon to use when comparing floating point rotations (as radians).

Definition at line 45 of file BLI_convexhull_2d_test.cc.

Referenced by blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), and blender::TEST().