Blender V4.5
BLI_convexhull_2d_test.cc File Reference
#include "testing/testing.h"
#include "BLI_array.hh"
#include "BLI_convexhull_2d.h"
#include "BLI_math_angle_types.hh"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_rotation.h"
#include "BLI_math_rotation.hh"
#include "BLI_math_vector.h"
#include "BLI_math_vector.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_rand.hh"

Go to the source code of this file.

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 blender::Array< float2convexhull_points_from_map (blender::Span< float2 > points, blender::Span< int > points_map)
static blender::Array< float2convexhull_2d_as_array (blender::Span< float2 > points)
Wrap Public API's
static float convexhull_2d_aabb_fit_points_2d (blender::Span< float2 > points)
Tests
 TEST (convexhull_2d, IsConvex)
 TEST (convexhull_2d, IsCCW)
 TEST (convexhull_2d, NOP)
 TEST (convexhull_2d, Lines_AxisAligned)
 TEST (convexhull_2d, Lines_Diagonal)
 TEST (convexhull_2d, Simple)
 TEST (convexhull_2d, Octagon)
 TEST (convexhull_2d, OctagonAxisAligned)
 TEST (convexhull_2d, Complex)

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 TEST(), TEST(), TEST(), TEST(), TEST(), and 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 TEST(), TEST(), and TEST().

◆ DEFAULT_TEST_RANDOM_SEED

#define DEFAULT_TEST_RANDOM_SEED   123

Definition at line 42 of file BLI_convexhull_2d_test.cc.

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

◆ 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 TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

Function Documentation

◆ convexhull_2d_aabb_fit_points_2d()

◆ convexhull_2d_as_array()

◆ convexhull_points_from_map()

blender::Array< float2 > convexhull_points_from_map ( blender::Span< float2 > points,
blender::Span< int > points_map )
static

◆ TEST() [1/9]

TEST ( convexhull_2d ,
Complex  )

◆ TEST() [2/9]

◆ TEST() [3/9]

◆ TEST() [4/9]

◆ TEST() [5/9]

TEST ( convexhull_2d ,
Lines_Diagonal  )

◆ TEST() [6/9]

TEST ( convexhull_2d ,
NOP  )

◆ TEST() [7/9]

◆ TEST() [8/9]

◆ TEST() [9/9]