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>
52 Buffer<Model> old_model_pool;
53 Buffer<Model> new_models_added;
54 Matrix<fltp08> source_transform = Matrix<fltp08>(1.0);
55 Matrix<fltp08> model_to_tile_transform = Matrix<fltp08>(1.0);
56 LineSegment<3, fltp08> placement_segment;
57 bool use_heading =
true;
58 bool use_inclination =
true;
60 static Model RootChild(TileOptions& options)
63 if (options.old_model_pool.size() > 0)
65 root_child = options.old_model_pool.last();
66 options.old_model_pool.removeLast();
70 root_child = options.parent.createChild();
71 root_child.copyFrom(options.model_to_tile, options.model_to_tile.getScene().uuid() != options.parent.getScene().uuid());
72 options.new_models_added.add(root_child);
76 static Model IndexChild(uint04 index,
const Model& root_child, TileOptions& options)
83 else if (options.old_model_pool.size() > 0)
85 child = options.old_model_pool.last();
86 options.old_model_pool.removeLast();
90 child = options.parent.createChild();
91 child.copyFrom(root_child,
false);
92 options.new_models_added.add(child);
96 static void TileAlongGeo(
const Geometry& linework, TileOptions& options)
98 if (linework.getGeometryType() == GeometryType::e_linework)
101 Buffer<Polyline<3, fltp08>> polylines = linework.polylines<3,
fltp08>(PrimitiveProperty::Outline, VertexProperty::Position);
103 for (uint04 i = 0; i < polylines.size(); i++)
105 polylines[i].simplify();
106 TileModelAlongLine(polylines[i], options);
125 else if (linework.getGeometryType() == GeometryType::e_points)
127 Buffer<Vertex<3, fltp08>> vertices = linework.vertices<Vertex<3, fltp08>>(VertexProperty::Position);
128 Model root_child = RootChild(options);
129 const Matrix<fltp08> dest_transform = options.model_to_tile_transform * options.model_to_tile.getCompleteTransform();
130 const Matrix<fltp08> parent_transform = options.parent.getCompleteTransform().invert();
131 for (uint04 i = 0; i < vertices.size(); i++)
133 if (
isNaN(vertices[i]))
135 Model child = IndexChild(i, root_child, options);
136 Matrix<fltp08> mat = Matrix<fltp08>::OffsetMatrix(options.source_transform * vertices[i]);
137 mat = parent_transform * mat * dest_transform;
138 child.setTransform(mat);
142 static void TileModelAlongLine(
const Polyline<3, fltp08>& extrude_path, TileOptions& options)
145 Polyline<3, fltp08> broken_poly = options.source_transform * extrude_path;
146 broken_poly = broken_poly.breakIntoSegmentsByDistance(distance);
147 if (broken_poly.segmentCount() == 0)
149 Model root_child = RootChild(options);
153 const Matrix<fltp08> dest_transform = options.model_to_tile_transform * options.model_to_tile.getCompleteTransform();
154 const Matrix<fltp08> parent_transform = options.parent.getCompleteTransform().invert();
155 for (uint04 i = 0; i < broken_poly.vertexCount(); i++)
157 Model child = IndexChild(i, root_child, options);
158 Matrix<fltp08> mat = Matrix<fltp08>::OffsetMatrix(broken_poly.vertex(i));
159 uint04 segment_index =
getMin(broken_poly.segmentCount() - 1, i);
160 if(options.use_heading)
161 mat = mat.rotate(AngleDefinitions::Heading<sint04>(broken_poly.segment(segment_index).ray()), Vector<3, fltp08>(0, 0, 1));
162 if(options.use_inclination)
163 mat = mat.rotate(-AngleDefinitions::Inclination<sint04>(broken_poly.segment(segment_index).ray()), Vector<3, fltp08>(0, 1, 0));
164 mat = parent_transform * mat * dest_transform;
165 child.setTransform(mat);
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:250
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
@ X
Definition BaseValues.hpp:200
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator.
Definition BaseFunctions.hpp:67