NDEVR
API Documentation
ViewToPrimitiveObjects.h
1#pragma once
2#include <NDEVR/Font.h>
3#if NDEVR_VIEWPORT
4#include <NDEVR/Polygon.h>
5#include <NDEVR/UUID.h>
6#include <functional>
7namespace NDEVR
8{
10 class Text;
11 class Model;
12 class Geometry;
13 class Camera;
18 {
22 struct PrimitiveClipRegion
23 {
24 Polygon<fltp04> polygon;
29 bool operator==(const PrimitiveClipRegion& region) const
30 {
31 return region.polygon == polygon;
32 }
37 bool operator!=(const PrimitiveClipRegion& region) const
38 {
39 return region.polygon != polygon;
40 }
41 };
45 struct PrimitiveDrawObject
46 {
47 Buffer<PrimitiveClipRegion> clip_region;
48 fltp04 radius;
49 fltp04 distance;
50 RGBColor color;
51 bool is_filled;
52 };
56 struct PrimitiveDrawPoint : public PrimitiveDrawObject
57 {
58 Vector<2, fltp04> point;
59 };
63 struct PrimitiveDrawLine : public PrimitiveDrawObject
64 {
66 };
70 struct PrimitiveDrawPolygon : public PrimitiveDrawObject
71 {
72 Polygon<fltp04> polygon;
73 };
77 struct PrimitiveDrawImagePolygon : public PrimitiveDrawPolygon
78 {
79 String image_id;
80 Polygon<fltp04> image_polygon;
81 fltp04 opacity = 1.0f;
82 Matrix<fltp08> image_transform = Matrix<fltp08>(1.0);
83 };
87 struct PrimitiveDrawText : public PrimitiveDrawObject
88 {
89 String text;
90 Font font;
91 Matrix<fltp04, 3, 2> transform;
92 };
96 struct PrimitiveRenderOptions
97 {
98 Matrix<fltp08> complete_geo_transform;
99 Bounds<3, fltp04> bounds;
100 fltp04 px_scale;
101 bool draw_grid;
102 bool draw_border;
103 fltp04 dpi;
104 uint04 margins;
108 Buffer<PrimitiveDrawImagePolygon> image_polygons;
111 Matrix<fltp08> camera_transform;
112 };
113 public:
121 void setDrawGrid(bool draw_grid);
126 void setTitle(const String& title, const String& subject);
130 void setMargins(uint04 margins);
134 virtual void setdpi(fltp08 dpi);
138 void setDrawBorder(bool border);
145 virtual bool execute(const Camera& camera, const Buffer<UUID>& objects_to_render, PrimitiveRenderOptions& options);
146
147 protected:
151 void sortAndDraw(PrimitiveRenderOptions& draw_options);
157 Buffer<PrimitiveClipRegion> getClipping(const PrimitiveRenderOptions& primitive_options, const Model& model);
158 #if NDEVR_TEXT_MODEL
164 void writeTextToOptions(PrimitiveRenderOptions& primitive_options, const Matrix<fltp08>& tr, Text text);
165 #endif
172 void writeGeometryToOptions(PrimitiveRenderOptions& pdf_options, const Matrix<fltp08>& tr, const Model& model, const Geometry& geo);
173 protected:
174 std::function<void(const PrimitiveDrawImagePolygon& image_id, const PrimitiveRenderOptions& pdf_options)> m_draw_image;
175 std::function<void(const Font& font, const PrimitiveRenderOptions& pdf_options)> m_add_font;
176 std::function<void(const PrimitiveDrawPoint& point, const PrimitiveRenderOptions& pdf_options)> m_draw_point;
177 std::function<void(const PrimitiveDrawLine& line, const PrimitiveRenderOptions& pdf_options)> m_draw_line;
178 std::function<void(const PrimitiveDrawPolygon& poly, const PrimitiveRenderOptions& pdf_options)> m_draw_poly;
179 std::function<void(const PrimitiveDrawImagePolygon& image_poly, const PrimitiveRenderOptions& pdf_options)> m_draw_image_poly;
180 std::function<void(const PrimitiveDrawText& text, const PrimitiveRenderOptions& pdf_options)> m_draw_text;
181
189 };
190}
191#endif
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
A core class where all Design Objects including models, materials, and geometries are stored.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Information for how to display text data.
Definition Font.h:46
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Class: LineSegment.
Definition Line.hpp:52
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
An N-sided polygon.
Definition Polygon.hpp:55
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
The core String class for the NDEVR API.
Definition String.h:95
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
std::function< void(const Font &font, const PrimitiveRenderOptions &pdf_options)> m_add_font
Callback for registering a font with the output backend.
uint04 m_margins
The margin size in pixels.
fltp08 m_dpi
The output resolution in dots per inch.
void setTitle(const String &title, const String &subject)
Sets the title and subject metadata for the output.
String m_title
The document title metadata.
void writeGeometryToOptions(PrimitiveRenderOptions &pdf_options, const Matrix< fltp08 > &tr, const Model &model, const Geometry &geo)
Converts a Geometry object into primitive draw operations (lines, points, polygons).
std::function< void(const PrimitiveDrawLine &line, const PrimitiveRenderOptions &pdf_options)> m_draw_line
Callback for drawing a line primitive.
ViewToPrimitiveObjects(const DesignObjectLookup *lookup)
Constructs a ViewToPrimitiveObjects with the given design object lookup.
void sortAndDraw(PrimitiveRenderOptions &draw_options)
Sorts collected primitives by distance and invokes the draw callbacks in order.
String m_subject
The document subject metadata.
Buffer< PrimitiveClipRegion > getClipping(const PrimitiveRenderOptions &primitive_options, const Model &model)
Computes the clip regions for a given model within the render context.
void setMargins(uint04 margins)
Sets the margin size around the rendered content.
std::function< void(const PrimitiveDrawPolygon &poly, const PrimitiveRenderOptions &pdf_options)> m_draw_poly
Callback for drawing a polygon primitive.
bool m_draw_grid
Whether to draw a background grid.
std::function< void(const PrimitiveDrawImagePolygon &image_id, const PrimitiveRenderOptions &pdf_options)> m_draw_image
Callback for drawing an image (NOTE: parameter name 'image_id' may be misleading; receives a full Pri...
virtual void setdpi(fltp08 dpi)
Sets the output resolution in dots per inch.
void setDrawBorder(bool border)
Sets whether a border should be drawn around the output.
const DesignObjectLookup * m_lookup
Pointer to the design object lookup providing scene data access.
void setDrawGrid(bool draw_grid)
Sets whether a background grid should be drawn.
std::function< void(const PrimitiveDrawImagePolygon &image_poly, const PrimitiveRenderOptions &pdf_options)> m_draw_image_poly
Callback for drawing an image polygon primitive.
std::function< void(const PrimitiveDrawPoint &point, const PrimitiveRenderOptions &pdf_options)> m_draw_point
Callback for drawing a point primitive.
bool m_draw_border
Whether to draw a border around the output.
virtual bool execute(const Camera &camera, const Buffer< UUID > &objects_to_render, PrimitiveRenderOptions &options)
Executes the conversion of a camera view and set of objects into primitive draw operations.
std::function< void(const PrimitiveDrawText &text, const PrimitiveRenderOptions &pdf_options)> m_draw_text
Callback for drawing a text primitive.
The primary namespace for the NDEVR SDK.
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Inequality operator.
Definition Vector.hpp:673
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.