Random object generators for automated software stress tests.
More...
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateCircle (int numPoints, double x, double y, double z, double radiusX, double radiusY, std::vector< Point2 > &vCirclePointsOut) |
| Generate points on a circle. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateRandomNumbers (size_t num, double min, double max, std::vector< double > &vRandomNumbersOut, unsigned int seed=0) |
| Generate (reproducible) random numbers. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateRandomPoints (size_t numRandomPoints, double min, double max, std::vector< Point2 > &vRandomPointsOut, unsigned int seed=0) |
| Generate (reproducible) random points. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateRandomPoints3D (size_t numRandomPoints, double min, double max, std::vector< Point2 > &vRandomPointsOut, unsigned int seed=0) |
| Generate (reproducible) random 3D points. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateRandomPolygon (size_t numSegments, double min, double max, std::vector< Segment2 > &vPolygonOut, unsigned int seed=0) |
| Generate a (reproducible) random polygon. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateRandomSegments (size_t numSegments, double min, double max, double maxLen, std::vector< Segment2 > &vSegmentsOut, unsigned int seed) |
| Generate (reproducible) random line segments. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateRandomSurfacePoints (size_t numX, size_t numY, size_t numCenters, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, std::vector< Point2 > &vSurfacePointsOut, unsigned int seed, bool bGrid=true) |
| Generate a (reproducible) random surface. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::generateSineSegments (int numSegments, int numPeriods, double xOffset, double yOffset, double xFactor, double yFactor, bool bSwapXY, std::vector< Segment2 > &vSineSegmentsOut) |
| Generate segments from a sine function. More...
|
|
CLASS_DECLSPEC void | GEOM_FADE25D::shear (std::vector< Point2 > &vPointsInOut, double shearX, double shearY) |
| Apply shear transformation to points. More...
|
|
Random objects (points, lines, polygons, polylines)
Theory, careful programming, and automated stress tests are essential. None of these can replace the others. Testing with random data helps to uncover unexpected bugs early. Fade provides random object generators to assist with automated stress tests, including:
- Random simple polygons
- Random segments
- Random point clouds
- Random numbers
- Polylines based on sine functions
These tools allow you to reproduce specific error conditions. The random object generators accept a seed value to initialize the random number generator. Using the same seed value will always generate the same sequence of objects. Only the seed value 0 will produce different sequences with each execution.
◆ generateCircle()
CLASS_DECLSPEC void GEOM_FADE25D::generateCircle |
( |
int |
numPoints, |
|
|
double |
x, |
|
|
double |
y, |
|
|
double |
z, |
|
|
double |
radiusX, |
|
|
double |
radiusY, |
|
|
std::vector< Point2 > & |
vCirclePointsOut |
|
) |
| |
This function generates points evenly distributed on the circumference of an ellipse or circle, centered at the specified coordinates.
- Parameters
-
numPoints | The number of points to generate along the circle's circumference. |
x | The x-coordinate of the circle's center. |
y | The y-coordinate of the circle's center. |
z | The z-coordinate of the circle's center. |
radiusX | The radius along the x-axis. |
radiusY | The radius along the y-axis. |
vCirclePointsOut | [out] A vector to store the generated points. |
- Note
- If
radiusX
equals radiusY
, the points will form a circle. For other values, the points form an ellipse.
◆ generateRandomNumbers()
CLASS_DECLSPEC void GEOM_FADE25D::generateRandomNumbers |
( |
size_t |
num, |
|
|
double |
min, |
|
|
double |
max, |
|
|
std::vector< double > & |
vRandomNumbersOut, |
|
|
unsigned int |
seed = 0 |
|
) |
| |
This function generates a specified number of random numbers within a given range and stores them in the output vector.
- Parameters
-
[in] | num | The number of random numbers to generate. |
[in] | min | The lower bound for the random numbers. |
[in] | max | The upper bound for the random numbers. |
[out] | vRandomNumbersOut | The output vector that will store the generated random numbers. |
[in] | seed | Initializes the random number generator (RNG).
0 (default): Uses a random seed, resulting in non-reproducible sequences.
- Otherwise: Uses the given value for reproducible sequences.
|
- Note
- Reproducible random numbers are useful for testing software with random geometric constructions. Providing a seed value other than
0
ensures the output sequence can be reproduced. Conversely, a seed value of 0
maps to random initialization, leading to a unique output sequence for each function call.
◆ generateRandomPoints()
CLASS_DECLSPEC void GEOM_FADE25D::generateRandomPoints |
( |
size_t |
numRandomPoints, |
|
|
double |
min, |
|
|
double |
max, |
|
|
std::vector< Point2 > & |
vRandomPointsOut, |
|
|
unsigned int |
seed = 0 |
|
) |
| |
This function generates a specified number of random points within a given range and stores them in the output vector.
- Parameters
-
| numRandomPoints | The number of random points to generate. |
| min | The lower bound for both x and y coordinates. |
| max | The upper bound for both x and y coordinates. |
[out] | vRandomPointsOut | The output vector to store the generated random points. |
| seed | Initializes the random number generator (RNG).
0 (default): Uses a random seed, resulting in non-reproducible sequences.
- Non-zero: Uses the given value for reproducible sequences.
|
- Note
- Reproducible random points are useful for testing applications involving random geometric constructions. Providing a seed value other than
0
ensures the output sequence can be reproduced. Conversely, a seed value of 0
maps to random initialization, leading to a unique output sequence for each function call.
Point generator
◆ generateRandomPoints3D()
CLASS_DECLSPEC void GEOM_FADE25D::generateRandomPoints3D |
( |
size_t |
numRandomPoints, |
|
|
double |
min, |
|
|
double |
max, |
|
|
std::vector< Point2 > & |
vRandomPointsOut, |
|
|
unsigned int |
seed = 0 |
|
) |
| |
- Parameters
-
| numRandomPoints | Number of points to be generated. |
| min | Lower bound (x, y, z) coordinates. |
| max | Upper bound (x, y, z) coordinates. |
[out] | vRandomPointsOut | The output vector to store the generated random points. |
| seed | Initializes the random number generator (RNG).
- Default:
0 (mapped to a random seed for unique sequences).
- Other values: Use for constant initialization and reproducible sequences.
|
◆ generateRandomPolygon()
CLASS_DECLSPEC void GEOM_FADE25D::generateRandomPolygon |
( |
size_t |
numSegments, |
|
|
double |
min, |
|
|
double |
max, |
|
|
std::vector< Segment2 > & |
vPolygonOut, |
|
|
unsigned int |
seed = 0 |
|
) |
| |
This function generates a random simple polygon.
- Parameters
-
| numSegments | The number of segments to be generated. |
| min | Lower bound for (x, y) coordinates. |
| max | Upper bound for (x, y) coordinates. |
[out] | vPolygonOut | The output vector that stores the generated polygon's segments. |
| seed | Initializes the random number generator (RNG).
- Default:
0 (mapped to a random seed for unique sequences).
- Other values: Use for constant initialization and reproducible sequences.
|
Polygon generator: Random simple polygon
◆ generateRandomSegments()
CLASS_DECLSPEC void GEOM_FADE25D::generateRandomSegments |
( |
size_t |
numSegments, |
|
|
double |
min, |
|
|
double |
max, |
|
|
double |
maxLen, |
|
|
std::vector< Segment2 > & |
vSegmentsOut, |
|
|
unsigned int |
seed |
|
) |
| |
- Parameters
-
| numSegments | The number of segments to be generated. |
| min | Lower bound for (x, y) coordinates. |
| max | Upper bound for (x, y) coordinates. |
| maxLen | The maximum length of each segment. |
[out] | vSegmentsOut | The output vector storing the generated segments. |
| seed | Initializes the random number generator (RNG):
- Default:
0 (mapped to a random seed for unique sequences).
- Other values: Use for constant initialization and reproducible sequences.
|
Segment generator: Random line segments
◆ generateRandomSurfacePoints()
CLASS_DECLSPEC void GEOM_FADE25D::generateRandomSurfacePoints |
( |
size_t |
numX, |
|
|
size_t |
numY, |
|
|
size_t |
numCenters, |
|
|
double |
xmin, |
|
|
double |
ymin, |
|
|
double |
zmin, |
|
|
double |
xmax, |
|
|
double |
ymax, |
|
|
double |
zmax, |
|
|
std::vector< Point2 > & |
vSurfacePointsOut, |
|
|
unsigned int |
seed, |
|
|
bool |
bGrid = true |
|
) |
| |
- Parameters
-
| numX,numY | Specifies the grid dimensions. Both must be >1, resulting in numX*numY points. |
| numCenters | The number of extreme points |
| xmin,ymin,zmin,xmax,ymax,zmax | Defines the geometric bounds for the surface. |
[out] | vSurfacePointsOut | The output vector storing the generated surface points. |
| seed | Initializes the random number generator:
- Default:
0 (mapped to a random seed for unique sequences).
- Other values: Use for constant initialization and reproducible sequences.
|
| bGrid | Specifies whether points are placed exactly on a grid or slightly randomized.
- Default:
true (grid-aligned points).
|
◆ generateSineSegments()
CLASS_DECLSPEC void GEOM_FADE25D::generateSineSegments |
( |
int |
numSegments, |
|
|
int |
numPeriods, |
|
|
double |
xOffset, |
|
|
double |
yOffset, |
|
|
double |
xFactor, |
|
|
double |
yFactor, |
|
|
bool |
bSwapXY, |
|
|
std::vector< Segment2 > & |
vSineSegmentsOut |
|
) |
| |
This function generates segments from a sine function.
- Parameters
-
| numSegments | Number of segments to be generated |
| numPeriods | Number of periods of the sine function |
| xOffset | Offset of the output x-coordinates |
| yOffset | Offset of the output y-coordinates |
| xFactor | Factor to scale the sine function in x direction |
| yFactor | Factor to scale the sine function in y direction |
| bSwapXY | Swap the x and y coordinate of the function |
[out] | vSineSegmentsOut | is the output vector |
Polyline generator: Polylines from sine functions
◆ shear()
CLASS_DECLSPEC void GEOM_FADE25D::shear |
( |
std::vector< Point2 > & |
vPointsInOut, |
|
|
double |
shearX, |
|
|
double |
shearY |
|
) |
| |
Applies a shear transformation to a set of points, modifying their coordinates based on the specified shear factors.
- Parameters
-
[in,out] | vPointsInOut | The input points to be sheared. These points are modified in place. |
[in] | shearX,shearY | The shear factors in x and y direction. |
- Note
- The shear transformation modifies the original points in place. The result will be stored in the same vector.