Changeset 1045


Ignore:
Timestamp:
12/11/20 20:23:42 (3 years ago)
Author:
oriona
Message:

Part of GeometryTestUtils? functions moved to GeometryUtils?.

Location:
cpp/frams
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/Makefile-SDK-files

    r1044 r1045  
    3737NEURO_OBJS=frams/neuro/neuroimpl.o frams/neuro/neurofactory.o frams/neuro/impl/neuroimpl-simple.o frams/neuro/impl/neuroimpl-channels.o frams/neuro/impl/neuroimpl-fuzzy.o frams/neuro/impl/neuroimpl-fuzzy-f0.o
    3838
    39 SIMILARITY_OBJS=frams/_demos/geometry/geometrytestutils.o frams/model/similarity/measure-greedy.o frams/model/similarity/measure-hungarian.o frams/model/similarity/measure-distribution.o frams/model/similarity/measure-mds-based.o frams/model/similarity/simil-measure.o frams/model/similarity/hungarian/hungarian.o frams/model/similarity/SVD/lapack.o frams/model/similarity/SVD/matrix_tools.o frams/model/similarity/simil-match.o
     39SIMILARITY_OBJS=frams/model/similarity/measure-greedy.o frams/model/similarity/measure-hungarian.o frams/model/similarity/measure-distribution.o frams/model/similarity/measure-mds-based.o frams/model/similarity/simil-measure.o frams/model/similarity/hungarian/hungarian.o frams/model/similarity/SVD/lapack.o frams/model/similarity/SVD/matrix_tools.o frams/model/similarity/simil-match.o
    4040
    4141NN_LAYOUT_OBJS=frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o
  • cpp/frams/_demos/geometry/apices_test.cpp

    r534 r1045  
    1414        Model resultModel;
    1515        resultModel.open();
    16         GeometryTestUtils::addAnchorToModel(resultModel);
     16        GeometryUtils::addAnchorToModel(resultModel);
    1717       
    1818        // Creating instance of Iterator class (MeshBuilder::ModelApices in this case). Object is
     
    3131                // Processing points created by iterator. In this case, they are added to result model as
    3232                // small spheres.
    33                 GeometryTestUtils::addPointToModel(point, resultModel);
     33                GeometryUtils::addPointToModel(point, resultModel);
    3434        }
    3535       
  • cpp/frams/_demos/geometry/geometrytestutils.cpp

    r999 r1045  
    44
    55#include "geometrytestutils.h"
    6 
    76#include "../genotypeloader.h"
    87#include "frams/genetics/preconfigured.h"
    98#include <common/virtfile/stdiofile.h>
    109#include <common/loggers/loggertostdout.h>
     10#include <frams/model/geometry/geometryutils.h>
    1111#include <math.h>
    1212#include <stdio.h>
     
    9999
    100100        Part *part = model.addNewPart(Part::Shape(shape));
    101         GeometryTestUtils::randomizePositionScaleAndOrient(part);
     101        GeometryUtils::randomizePositionScaleAndOrient(part);
    102102
    103103        model.close();
     
    233233}
    234234
    235 void GeometryTestUtils::addAnchorToModel(Model &model)
    236 {
    237         Part *part = model.addNewPart(Part::SHAPE_ELLIPSOID);
    238 
    239         part->p = Pt3D(0);
    240         part->scale = Pt3D(0.1);
    241         part->vcolor = Pt3D(1.0, 0.0, 1.0);
    242 
    243         addAxesToModel(Pt3D(0.5), Orient(Orient_1), Pt3D(0.0), model);
    244 }
    245 
    246 void GeometryTestUtils::addPointToModel(const Pt3D &markerLocation, Model &model)
    247 {
    248         Part *anchor = model.getPart(0);
    249         Part *part = model.addNewPart(Part::SHAPE_ELLIPSOID);
    250 
    251         part->p = Pt3D(markerLocation);
    252         part->scale = Pt3D(0.05);
    253         part->vcolor = Pt3D(1.0, 1.0, 0.0);
    254 
    255         model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
    256 }
    257 
    258 void GeometryTestUtils::addAxesToModel(const Pt3D &sizes, const Orient &axes, const Pt3D &center,
    259         Model &model)
    260 {
    261         Part *anchor = model.getPart(0);
    262         Part *part;
    263 
    264         part = model.addNewPart(Part::SHAPE_CUBOID);
    265         part->scale = Pt3D(sizes.x, 0.05, 0.05);
    266         part->setOrient(axes);
    267         part->p = center;
    268         part->vcolor = Pt3D(1.0, 0.0, 0.0);
    269         model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
    270 
    271         part = model.addNewPart(Part::SHAPE_CUBOID);
    272         part->scale = Pt3D(0.05, sizes.y, 0.05);
    273         part->setOrient(axes);
    274         part->p = center;
    275         part->vcolor = Pt3D(0.0, 1.0, 0.0);
    276         model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
    277 
    278         part = model.addNewPart(Part::SHAPE_CUBOID);
    279         part->scale = Pt3D(0.05, 0.05, sizes.z);
    280         part->setOrient(axes);
    281         part->p = center;
    282         part->vcolor = Pt3D(0.0, 0.0, 1.0);
    283         model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
    284 }
    285 
    286 void GeometryTestUtils::mergeModels(Model &target, Model &source)
    287 {
    288         Part *targetAnchor = target.getPart(0);
    289         Part *sourceAnchor = source.getPart(0);
    290 
    291         target.moveElementsFrom(source);
    292 
    293         target.addNewJoint(targetAnchor, sourceAnchor, Joint::SHAPE_FIXED);
    294 }
    295 
    296 double frand(double from, double width)
    297 {
    298         return from + width * ((rand() % 10000) / 10000.0);
    299 }
    300 
    301 void GeometryTestUtils::randomizePositionScaleAndOrient(Part *part)
    302 {
    303         part->p = Pt3D(frand(1.5, 1.0), frand(1.5, 1.0), frand(1.5, 1.0));
    304         part->scale = Pt3D(frand(0.1, 0.9), frand(0.1, 0.9), frand(0.1, 0.9));
    305         part->setRot(Pt3D(frand(0.0, M_PI), frand(0.0, M_PI), frand(0.0, M_PI)));
    306 }
    307 
    308235void GeometryTestUtils::describePart(const Part *part, FILE *output)
    309236{
  • cpp/frams/_demos/geometry/geometrytestutils.h

    r286 r1045  
    4747         */
    4848        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        
     49
    10250        /**
    10351         * @brief Prints description of given Part to specified file.
  • cpp/frams/_demos/geometry/info_test.cpp

    r658 r1045  
    5151        Model resultModel;
    5252        resultModel.open();
    53         GeometryTestUtils::addAnchorToModel(resultModel);
     53        GeometryUtils::addAnchorToModel(resultModel);
    5454       
    5555        // Adding bounding markers of bounding box apices.
     
    6060                apex.y = Octants::isPositiveY(o) ? upperBoundary.y : lowerBoundary.y;
    6161                apex.z = Octants::isPositiveZ(o) ? upperBoundary.z : lowerBoundary.z;
    62                 GeometryTestUtils::addPointToModel(apex, resultModel);
     62                GeometryUtils::addPointToModel(apex, resultModel);
    6363        }
    6464       
    6565        // Adding markers of axes (intersection of axes is in the center of bounding box).
    6666        Pt3D intersection = (lowerBoundary + upperBoundary) * 0.5;
    67         GeometryTestUtils::addAxesToModel(sizes, axes, intersection, resultModel);
     67        GeometryUtils::addAxesToModel(sizes, axes, intersection, resultModel);
    6868       
    6969        // Merging with original model.
    70         GeometryTestUtils::mergeModels(resultModel, model);
     70        GeometryUtils::mergeModels(resultModel, model);
    7171       
    7272        // Finishing result Model and printing its genotype.
  • cpp/frams/_demos/geometry/surface_test.cpp

    r534 r1045  
    44
    55#include "geometrytestutils.h"
     6#include <frams/model/geometry/geometryutils.h>
    67#include <frams/model/geometry/meshbuilder.h>
    78#include <frams/model/model.h>
     
    1415        Model resultModel;
    1516        resultModel.open();
    16         GeometryTestUtils::addAnchorToModel(resultModel);
     17        GeometryUtils::addAnchorToModel(resultModel);
    1718       
    1819        // Creating instance of Iterator class (MeshBuilder::ModelSurface in this case). Object is
     
    3132                // Processing points created by iterator. In this case, they are added to result model as
    3233                // small spheres.
    33                 GeometryTestUtils::addPointToModel(point, resultModel);
     34                GeometryUtils::addPointToModel(point, resultModel);
    3435        }
    3536       
  • cpp/frams/_demos/geometry/volume_test.cpp

    r534 r1045  
    1414        Model resultModel;
    1515        resultModel.open();
    16         GeometryTestUtils::addAnchorToModel(resultModel);
     16        GeometryUtils::addAnchorToModel(resultModel);
    1717       
    1818        // Creating instance of Iterator class (MeshBuilder::ModelApices in this case). Object is
     
    3333                if (GeometryUtils::isPointInsideModel(point, model))
    3434                {
    35                         GeometryTestUtils::addPointToModel(point, resultModel);
     35                        GeometryUtils::addPointToModel(point, resultModel);
    3636                }
    3737        }
  • cpp/frams/model/geometry/geometryutils.cpp

    r1032 r1045  
    44
    55#include "geometryutils.h"
    6 
    76#include <math.h>
    87
     
    409408        return true;
    410409}
     410
     411void GeometryUtils::addAnchorToModel(Model &model)
     412{
     413    Part *part = model.addNewPart(Part::SHAPE_ELLIPSOID);
     414
     415    part->p = Pt3D(0);
     416    part->scale = Pt3D(0.1);
     417    part->vcolor = Pt3D(1.0, 0.0, 1.0);
     418
     419    addAxesToModel(Pt3D(0.5), Orient(Orient_1), Pt3D(0.0), model);
     420}
     421
     422void GeometryUtils::addPointToModel(const Pt3D &markerLocation, Model &model)
     423{
     424    Part *anchor = model.getPart(0);
     425    Part *part = model.addNewPart(Part::SHAPE_ELLIPSOID);
     426
     427    part->p = Pt3D(markerLocation);
     428    part->scale = Pt3D(0.05);
     429    part->vcolor = Pt3D(1.0, 1.0, 0.0);
     430
     431    model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
     432}
     433
     434void GeometryUtils::addAxesToModel(const Pt3D &sizes, const Orient &axes, const Pt3D &center,
     435                                   Model &model)
     436{
     437    Part *anchor = model.getPart(0);
     438    Part *part;
     439
     440    part = model.addNewPart(Part::SHAPE_CUBOID);
     441    part->scale = Pt3D(sizes.x, 0.05, 0.05);
     442    part->setOrient(axes);
     443    part->p = center;
     444    part->vcolor = Pt3D(1.0, 0.0, 0.0);
     445    model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
     446
     447    part = model.addNewPart(Part::SHAPE_CUBOID);
     448    part->scale = Pt3D(0.05, sizes.y, 0.05);
     449    part->setOrient(axes);
     450    part->p = center;
     451    part->vcolor = Pt3D(0.0, 1.0, 0.0);
     452    model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
     453
     454    part = model.addNewPart(Part::SHAPE_CUBOID);
     455    part->scale = Pt3D(0.05, 0.05, sizes.z);
     456    part->setOrient(axes);
     457    part->p = center;
     458    part->vcolor = Pt3D(0.0, 0.0, 1.0);
     459    model.addNewJoint(anchor, part, Joint::SHAPE_FIXED);
     460}
     461
     462void GeometryUtils::mergeModels(Model &target, Model &source)
     463{
     464    Part *targetAnchor = target.getPart(0);
     465    Part *sourceAnchor = source.getPart(0);
     466
     467    target.moveElementsFrom(source);
     468
     469    target.addNewJoint(targetAnchor, sourceAnchor, Joint::SHAPE_FIXED);
     470}
     471
     472double frand(double from, double width)
     473{
     474    return from + width * ((rand() % 10000) / 10000.0);
     475}
     476
     477void GeometryUtils::randomizePositionScaleAndOrient(Part *part)
     478{
     479    part->p = Pt3D(frand(1.5, 1.0), frand(1.5, 1.0), frand(1.5, 1.0));
     480    part->scale = Pt3D(frand(0.1, 0.9), frand(0.1, 0.9), frand(0.1, 0.9));
     481    part->setRot(Pt3D(frand(0.0, M_PI), frand(0.0, M_PI), frand(0.0, M_PI)));
     482}
  • cpp/frams/model/geometry/geometryutils.h

    r1032 r1045  
    180180        double calculateSolidVolume(Part *part);
    181181        bool isSolidPartScaleValid(const Part::Shape &partShape, const Pt3D &scale);
     182
     183    /**
     184    * @brief Adds anchor to the specified Model.
     185    * @details An anchor has two functions. First is to provide Model consistency. Some functions in
     186    *     GeometryTestUtils namespace requires Model passed to them as an argument to contain at
     187    *     least one Part. All new Parts are bonded to the rest of Model using Joint connecting them
     188    *     with first Part of Model. Second is to provide reference which helps to understand Model
     189    *     position, scale and orientation. Anchor is built from four Parts: small sphere placed in
     190    *     global coordinate system origin and three cuboids visualising global coordinate system
     191    *     axes.
     192    * @see addAxesToModel.
     193    * @param[in] model Owner of Parts to be created.
     194    */
     195    void addAnchorToModel(Model &model);
     196
     197    /**
     198     * @brief Adds point marker to Model.
     199     * @details Marker of point is a small sphere (radius = 0.05).
     200     * @param[in] point Location of marker.
     201     * @param[in] model Owner of Part to be created, must contain at least one part.
     202     */
     203    void addPointToModel(const Pt3D &point, Model &model);
     204
     205    /**
     206     * @brief Adds axes markers to Model.
     207     * @details Axes markers are three streched (one of scales = 0.5, others = 0.05) and colored
     208     *     cuboids. Cuboid visualising OX axis is red, OY - green, and OZ - blue.
     209     * @param[in] sizes Axes visual lengths.
     210     * @param[in] axes Axes orientation, relatively to global coordinate system axes.
     211     * @param[in] center Axes intersection point, relatively to global coordinate system origin.
     212     * @param[in] model Owner of Parts to be created, must contain at least one part.
     213     */
     214    void addAxesToModel(const Pt3D &sizes, const Orient &axes, const Pt3D &center, Model &model);
     215
     216    /**
     217     * @brief Merges two Models.
     218     * @details Moves all parts from source Model to target Model and - to provide Model
     219     *     consistency - creates Joint between firsts Parts of each of them. Each model must contain
     220     *     at least one Part.
     221     * @param[in] target Target Model, must contain at least one part.
     222     * @param[in] source Source Model, must contain at least one part.
     223     */
     224    void mergeModels(Model &target, Model &source);
     225
     226    /**
     227     * @brief Randomizes position, scale and rotations of Part.
     228     * @details Sets coords of Part position to random values from range (1.5, 2.5), scales to
     229     *     random values from range (0.1, 1.0), and rotations around each axis to random values from
     230     *     range (0, M_PI).
     231     * @param[in] part Part which position, scale and orient should be randomized.
     232     */
     233    void randomizePositionScaleAndOrient(Part *part);
    182234}
    183235
  • cpp/frams/model/similarity/simil-measure.cpp

    r1044 r1045  
    55#include "simil-measure.h"
    66#include <frams/vm/classes/genoobj.h>
     7#include <frams/model/geometry/geometryutils.h>
    78#include <frams/model/geometry/meshbuilder.h>
    8 #include <frams/_demos/geometry/geometrytestutils.h>
    99
    1010#define FIELDSTRUCT SimilMeasure
     
    8181    Model resultModel;
    8282    resultModel.open();
    83     GeometryTestUtils::addAnchorToModel(resultModel);
     83    GeometryUtils::addAnchorToModel(resultModel);
    8484
    8585    MeshBuilder::ModelSurface iterator(density);
     
    8989    while (iterator.tryGetNext(point))
    9090    {
    91         GeometryTestUtils::addPointToModel(point, resultModel);
     91        GeometryUtils::addPointToModel(point, resultModel);
    9292    }
    9393
Note: See TracChangeset for help on using the changeset viewer.