Geometrize  1.0
C++ library for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
model.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <functional>
5 #include <memory>
6 #include <vector>
7 
8 #include "core.h"
9 #include "shaperesult.h"
10 
11 namespace geometrize
12 {
13 class Bitmap;
14 class Shape;
15 }
16 
17 namespace geometrize
18 {
19 
24 class Model
25 {
26 public:
31  Model(const geometrize::Bitmap& target);
32 
39  Model(const geometrize::Bitmap& target, const geometrize::Bitmap& initial);
40  ~Model();
41  Model& operator=(const Model&) = delete;
42  Model(const Model&) = delete;
43 
48  void reset(geometrize::rgba backgroundColor);
49 
54  std::int32_t getWidth() const;
55 
60  std::int32_t getHeight() const;
61 
72  std::vector<geometrize::ShapeResult> step(
73  const std::function<std::shared_ptr<geometrize::Shape>(void)>& shapeCreator,
74  std::uint8_t alpha,
75  std::uint32_t shapeCount,
76  std::uint32_t maxShapeMutations,
77  std::uint32_t maxThreads,
78  const geometrize::core::EnergyFunction& energyFunction = nullptr);
79 
87  geometrize::ShapeResult drawShape(std::shared_ptr<geometrize::Shape> shape, geometrize::rgba color);
88 
94 
100 
105  const geometrize::Bitmap& getCurrent() const;
106 
111  const geometrize::Bitmap& getTarget() const;
112 
117  void setSeed(std::uint32_t seed);
118 
119 private:
120  class ModelImpl;
121  std::unique_ptr<Model::ModelImpl> d;
122 };
123 
124 }
geometrize::Bitmap & getTarget()
getTarget Gets the target bitmap.
Definition: model.cpp:241
void reset(geometrize::rgba backgroundColor)
reset Resets the model back to the state it was in when it was created.
Definition: model.cpp:210
std::int32_t getHeight() const
getHeight Gets the height of the target bitmap.
Definition: model.cpp:220
void setSeed(std::uint32_t seed)
setSeed Sets the seed that the random number generators of this model use. Note that the model also u...
Definition: model.cpp:261
Definition: model.cpp:25
Model & operator=(const Model &)=delete
The ShapeResult struct is a container for info about a shape added to the model.
Definition: shaperesult.h:19
geometrize::Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: model.cpp:246
std::vector< geometrize::ShapeResult > step(const std::function< std::shared_ptr< geometrize::Shape >(void)> &shapeCreator, std::uint8_t alpha, std::uint32_t shapeCount, std::uint32_t maxShapeMutations, std::uint32_t maxThreads, const geometrize::core::EnergyFunction &energyFunction=nullptr)
step Steps the primitive optimization/fitting algorithm.
Definition: model.cpp:225
std::unique_ptr< Model::ModelImpl > d
Definition: model.h:120
~Model()
Definition: model.cpp:207
geometrize::ShapeResult drawShape(std::shared_ptr< geometrize::Shape > shape, geometrize::rgba color)
drawShape Draws a shape on the model. Typically used when to manually add a shape to the image (e...
Definition: model.cpp:236
The Model class is the model for the core optimization/fitting algorithm.
Definition: model.h:24
std::int32_t getWidth() const
getWidth Gets the width of the target bitmap.
Definition: model.cpp:215
The Bitmap class is a helper class for working with bitmap data.
Definition: bitmap.h:15
The rgba struct is a helper for manipulating RGBA8888 color data.
Definition: rgba.h:12
Model(const geometrize::Bitmap &target)
Model Creates a model that will aim to replicate the target bitmap with shapes.
Definition: model.cpp:201
std::function< double(const std::vector< geometrize::Scanline > &lines, const std::uint32_t alpha, const geometrize::Bitmap &target, const geometrize::Bitmap &current, geometrize::Bitmap &buffer, double score)> EnergyFunction
EnergyFunction Type alias for a function that calculates a measure of the improvement adding the scan...
Definition: core.h:44