source: cpp/frams/_demos/geometry/geometrytestutils.h @ 854

Last change on this file since 854 was 286, checked in by Maciej Komosinski, 10 years ago

Updated headers

  • Property svn:eol-style set to native
File size: 5.2 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _GEOMETRYTESTUTILS_H_
6#define _GEOMETRYTESTUTILS_H_
7
8#include <frams/model/model.h>
9#include <frams/model/modelparts.h>
10#include <frams/util/3d.h>
11#include <frams/util/sstring.h>
12
13/**
14 * @brief Geometry module testing utilities.
15 * @details Contains functions frequently used by tests, such as loading or generating random Model,
16 *     or adding markers of points to a Model.
17 * @author Radosław Gołębiewski
18 */
19namespace GeometryTestUtils
20{
21        /**
22         * @brief Execution entry point for test based on specified input model.
23         * @details Parses call arguments and performs one of following tasks: printing usage message;
24         *     printing list of genotypes in specified file; creating Model from loaded genotype and
25         *     executing test; creating random Model and executing test.
26         * @param[in] header Header of usage message. This text should contain test description.
27         * @param[in] argc Number of call arguments.
28         * @param[in] argv Call arguments.
29         * @param[in] test Pointer to function implementing test.
30         * @returns Result code: 0 - no error, 1 - incorrect arguments (usage message printed),
31         *     2 - cannot open file, 3 - cannot find genotype, 4 - incorrect genotype.
32         */
33        int execute(const SString header, int argc, char *argv[], void (*test)(Model &));
34       
35        /**
36         * @brief Execution entry point for test based on specified input model and density.
37         * @details Parses call arguments and performs one of following tasks: printing usage message;
38         *     printing list of genotypes in specified file; creating Model from loaded genotype and
39         *     executing test using specified density; creating random Model and executing test using
40         *     specified density.
41         * @param[in] header Header of usage message. This text should contain test description.
42         * @param[in] argc Number of call arguments.
43         * @param[in] argv Call arguments.
44         * @param[in] test Pointer to function implementing test.
45         * @returns Result code: 0 - no error, 1 - incorrect arguments (usage message printed),
46         *     2 - cannot open file, 3 - cannot find genotype, 4 - incorrect genotype.
47         */
48        int execute(const SString header, int argc, char *argv[], void (*test)(Model &, const double));
49       
50        /**
51         * @brief Adds anchor to the specified Model.
52         * @details An anchor has two functions. First is to provide Model consistency. Some functions in
53         *     GeometryTestUtils namespace requires Model passed to them as an argument to contain at
54         *     least one Part. All new Parts are bonded to the rest of Model using Joint connecting them
55         *     with first Part of Model. Second is to provide reference which helps to understand Model
56         *     position, scale and orientation. Anchor is built from four Parts: small sphere placed in
57         *     global coordinate system origin and three cuboids visualising global coordinate system
58         *     axes.
59         * @see addAxesToModel.
60         * @param[in] model Owner of Parts to be created.
61         */
62        void addAnchorToModel(Model &model);
63       
64        /**
65         * @brief Adds point marker to Model.
66         * @details Marker of point is a small sphere (radius = 0.05).
67         * @param[in] point Location of marker.
68         * @param[in] model Owner of Part to be created, must contain at least one part.
69         */
70        void addPointToModel(const Pt3D &point, Model &model);
71       
72        /**
73         * @brief Adds axes markers to Model.
74         * @details Axes markers are three streched (one of scales = 0.5, others = 0.05) and colored
75         *     cuboids. Cuboid visualising OX axis is red, OY - green, and OZ - blue.
76         * @param[in] sizes Axes visual lengths.
77         * @param[in] axes Axes orientation, relatively to global coordinate system axes.
78         * @param[in] center Axes intersection point, relatively to global coordinate system origin.
79         * @param[in] model Owner of Parts to be created, must contain at least one part.
80         */
81        void addAxesToModel(const Pt3D &sizes, const Orient &axes, const Pt3D &center, Model &model);
82       
83        /**
84         * @brief Merges two Models.
85         * @details Moves all parts from source Model to target Model and - to provide Model
86         *     consistency - creates Joint between firsts Parts of each of them. Each model must contain
87         *     at least one Part.
88         * @param[in] target Target Model, must contain at least one part.
89         * @param[in] source Source Model, must contain at least one part.
90         */
91        void mergeModels(Model &target, Model &source);
92       
93        /**
94         * @brief Randomizes position, scale and rotations of Part.
95         * @details Sets coords of Part position to random values from range (1.5, 2.5), scales to
96         *     random values from range (0.1, 1.0), and rotations around each axis to random values from
97         *     range (0, M_PI).
98         * @param[in] part Part which position, scale and orient should be randomized.
99         */
100        void randomizePositionScaleAndOrient(Part *part);
101       
102        /**
103         * @brief Prints description of given Part to specified file.
104         * @details Prints shape ("shape"), position ("x", "y", "z"), scale ("sx", "sy", "sz") and
105         *     rotations ("rx", "ry", "rz") of given Part. Each value is printed in separate line using
106         *     following syntax: "# NAME=VALUE".
107         * @param[in] part Part to be described.
108         * @param[in] output Output file.
109         */
110        void describePart(const Part *part, FILE *output);
111}
112
113#endif
Note: See TracBrowser for help on using the repository browser.