source: cpp/frams/_demos/geometry/volume_test.cpp @ 196

Last change on this file since 196 was 193, checked in by Maciej Komosinski, 11 years ago

Set svn:eol-style native for all textual files

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#include "geometrytestutils.h"
6#include <frams/model/geometry/geometryutils.h>
7#include <frams/model/geometry/meshbuilder.h>
8#include <frams/model/model.h>
9#include <stdio.h>
10
11void test(Model &model, const double density)
12{
13        // Creating and preparing result Model object.
14        Model resultModel;
15        resultModel.open();
16        GeometryTestUtils::addAnchorToModel(resultModel);
17       
18        // Creating instance of Iterator class (MeshBuilder::ModelApices in this case). Object is
19        // placed in stack memory, thus there is no heap memory allocation and creation is fast.
20        MeshBuilder::BoundingBoxVolume iterator(density);
21       
22        // Once created, iterator can be used many times, but must be initialized before every time.
23        iterator.initialize(model);
24       
25        // Creating output variable.
26        Pt3D point;
27       
28        // Method tryGetNext checks if next point exists and optionally updates fields of Pt3D object.
29        while (iterator.tryGetNext(point))
30        {
31                // Processing points created by iterator. In this case, they are added to result model as
32                // small spheres only if they are placed inside or on surface of input model.
33                if (GeometryUtils::isPointInsideModel(point, model))
34                {
35                        GeometryTestUtils::addPointToModel(point, resultModel);
36                }
37        }
38       
39        // Finishing result Model and printing its genotype.
40        resultModel.close();
41        puts((const char*)resultModel.getF0Geno().toString());
42}
43
44int main(int argc, char *argv[])
45{
46        return GeometryTestUtils::execute(
47                "Creates new model built of small spheres filling volume of input model and prints its "
48                "genotype.", argc, argv, test);
49}
Note: See TracBrowser for help on using the repository browser.