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

Part of GeometryTestUtils? functions moved to GeometryUtils?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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{
Note: See TracChangeset for help on using the changeset viewer.