33#include <NDEVR/Model.h>
34#if NDEVR_MODEL_TILE_CONTAINER
35#include <NDEVR/Geometry.h>
36#include <NDEVR/AngleDefinitions.h>
37#include <NDEVR/MatrixFunctions.h>
55 Buffer<Model> old_model_pool;
56 Buffer<Model> new_models_added;
57 Matrix<fltp08> source_transform = Matrix<fltp08>(1.0);
58 Matrix<fltp08> model_to_tile_transform = Matrix<fltp08>(1.0);
59 LineSegment<3, fltp08> placement_segment;
60 bool use_heading =
true;
61 bool use_inclination =
true;
63 static Model RootChild(TileOptions& options)
66 if (options.old_model_pool.size() > 0)
68 root_child = options.old_model_pool.last();
69 options.old_model_pool.removeLast();
73 root_child = options.parent.createChild();
74 root_child.copyFrom(options.model_to_tile, options.model_to_tile.getScene().uuid() != options.parent.getScene().uuid());
75 options.new_models_added.add(root_child);
79 static Model IndexChild(uint04 index,
const Model& root_child, TileOptions& options)
86 else if (options.old_model_pool.size() > 0)
88 child = options.old_model_pool.last();
89 options.old_model_pool.removeLast();
93 child = options.parent.createChild();
94 child.copyFrom(root_child,
false);
95 options.new_models_added.add(child);
99 static void TileAlongGeo(
const Geometry& linework, TileOptions& options)
101 if (linework.getGeometryType() == GeometryType::e_linework)
104 Buffer<Polyline<3, fltp08>> polylines = linework.polylines<3,
fltp08>(PrimitiveProperty::Outline, VertexProperty::Position);
106 for (uint04 i = 0; i < polylines.size(); i++)
108 polylines[i].simplify();
109 TileModelAlongLine(polylines[i], options);
128 else if (linework.getGeometryType() == GeometryType::e_points)
130 Buffer<Vertex<3, fltp08>> vertices = linework.vertices<Vertex<3, fltp08>>(VertexProperty::Position);
131 Model root_child = RootChild(options);
132 const Matrix<fltp08> dest_transform = options.model_to_tile_transform * options.model_to_tile.getCompleteTransform();
133 const Matrix<fltp08> parent_transform = options.parent.getCompleteTransform().invert();
134 for (uint04 i = 0; i < vertices.size(); i++)
138 Model child = IndexChild(i, root_child, options);
139 Matrix<fltp08> mat = Matrix<fltp08>::OffsetMatrix(options.source_transform * vertices[i]);
140 mat = parent_transform * mat * dest_transform;
141 child.setTransform(mat);
145 static void TileModelAlongLine(
const Polyline<3, fltp08>& extrude_path, TileOptions& options)
148 Polyline<3, fltp08> broken_poly = options.source_transform * extrude_path;
149 broken_poly = broken_poly.breakIntoSegmentsByDistance(distance);
150 if (broken_poly.segmentCount() == 0)
152 Model root_child = RootChild(options);
156 const Matrix<fltp08> dest_transform = options.model_to_tile_transform * options.model_to_tile.getCompleteTransform();
157 const Matrix<fltp08> parent_transform = options.parent.getCompleteTransform().invert();
158 for (uint04 i = 0; i < broken_poly.vertexCount(); i++)
160 Model child = IndexChild(i, root_child, options);
161 Matrix<fltp08> mat = Matrix<fltp08>::OffsetMatrix(broken_poly.vertex(i));
162 uint04 segment_index =
getMin(broken_poly.segmentCount() - 1, i);
163 if(options.use_heading)
164 mat = mat.rotate(AngleDefinitions::Heading<sint04>(broken_poly.segment(segment_index).ray()), Vector<3, fltp08>(0, 0, 1));
165 if(options.use_inclination)
166 mat = mat.rotate(-AngleDefinitions::Inclination<sint04>(broken_poly.segment(segment_index).ray()), Vector<3, fltp08>(0, 1, 0));
167 mat = parent_transform * mat * dest_transform;
168 child.setTransform(mat);
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:171
@ X
Definition BaseValues.hpp:167
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
Definition BaseFunctions.hpp:56