33#include <NDEVR/Geometry.h>
34#include <NDEVR/Plane.h>
94 uint04 width_segments = 128;
95 for (
uint04 x = 0; x <= width_segments; x++)
100 geo_line.
add(position);
140 for (
uint04 i = 0; i < polylines.size(); i++)
142 polylines[i].simplify();
147 if (bounds[X] * bounds[X] + bounds[Y] * bounds[Y] > bounds[Z] * bounds[Z])
148 poly_normal = { 0.0, 0.0, 1.0 };
149 else if (bounds[X] * bounds[X] > bounds[Y] * bounds[Y])
150 poly_normal = { 0.0, 1.0, 0.0 };
152 poly_normal = { 1.0, 0.0, 0.0 };
154 Extrude(indices, vertices, geo_line, polylines[i], poly_normal, is_closed, poly_transform);
165 if (solid_vertex_size < vertices.size())
167 linework.
addVertices(solid_vertex_offset, vertices.size() - solid_vertex_size);
171 for (
uint04 i = 0; i < vertices.size(); i++)
178 for (
uint04 i = 0; i < indices.size(); i++)
218 template<
class t_type>
224 ,
bool is_path_closed
238 bool greater_than_90_turn =
false;
242 Ray<3, t_type> original_dir;
243 if (is_path_closed && (i == 0 || i == extrude_path.
segmentCount()))
247 original_dir = extrude_path.
segment(extrude_path.
segmentCount() - 1).ray().template normalized<t_type>();
249 dir = (dir_2 + original_dir).
template normalized<t_type>();
250 greater_than_90_turn =
dot(dir_2, original_dir) < 0;
252 else if (last.size() == 0)
255 original_dir = extrude_path.
segment(i).ray().template normalized<t_type>();
262 original_dir = extrude_path.
segment(i - 1).ray().template normalized<t_type>();
268 original_dir = extrude_path.
segment(i - 1).ray().template normalized<t_type>();
270 dir = (dir_2 + original_dir).
template normalized<t_type>();
271 greater_than_90_turn =
dot(dir_2, original_dir) < 0;
276 if (dir.template magnitude<fltp08>() == 0.0 ||
IsInvalid(dir))
301 const Ray<3, fltp08> up =
cross(dir, right).template normalized<fltp08>();
305 const t_type p_off_original =
cast<t_type>(1.0) -
dot(dir, original_dir) *
dot(dir, original_dir);
307 t_type extra_distance =
sqrt(4 * p_off_original * p_off_original + 1.0);
308 if (greater_than_90_turn)
309 extra_distance = 2.0 / extra_distance;
312 for (
const auto& vertex : shape_to_extrude)
314 Ray<3, t_type> projection;
315 projection += vertex[X] * right;
316 projection += vertex[Y] * up;
317 projection += vertex[Z] * dir;
318 projection = projection.template normalized<fltp08>();
319 projection = (
transform * projection) * vertex.template magnitude<fltp08>();
320 current.
add((extra_distance * projection) + offset);
325 for (
uint04 n = 0; n < shape_to_extrude.vertexCount() - 1; n++)
331 vertices.add(last[n]);
332 vertices.add(current[n]);
333 vertices.add(current[n + 1]);
334 vertices.add(last[n + 1]);
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
The equivelent of std::vector but with a bit more control.
void add(t_type &&object)
Adds object to the end of the buffer.
constexpr decltype(auto) get(t_property_type property) const
Retrieves a property value from the database, cast to the requested type.
Provides static functions to extrude 2D/3D shapes along polyline paths, generating triangulated solid...
static void ExtrudeRealThickness(Geometry &linework, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
Extrudes a flat or circular cross-section along a linework geometry based on its real thickness prope...
static void ExtrudePolylineAlongGeo(Geometry &linework, const Polyline< 3, fltp08 > &geo_line, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
Extrudes a given polyline cross-section along a linework geometry, producing a triangulated solid sto...
static void Extrude(Buffer< Vector< 3, uint04 > > &indices, Buffer< Vertex< 3, t_type > > &vertices, const Polyline< 3, t_type > &shape_to_extrude, const Polyline< 3, t_type > &extrude_path, const Vector< 3, t_type > &plane_normal, bool is_path_closed, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
Extrudes a cross-section polyline along an extrusion path, generating triangle indices and vertices f...
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Retrieves all polylines from the geometry.
ThicknessMode thicknessMode() const
Retrieves the current thickness mode.
void updateVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Notifies the system that all vertex columns have been modified.
void setSolidVertexCountValue(uint04 count)
Sets the solid vertex count value in the database.
void setSolidVertexReservedValue(uint04 count)
Sets the solid vertex reserved count value in the database.
void updateSolidVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Notifies the system that all solid vertex columns have been modified.
uint04 solidVertexReservedCount() const
Returns the reserved capacity for solid vertices.
void updateModifiedTime(Time time=Time::SystemTime())
Updates the modified timestamp for this geometry.
void updatePrimitiveColumns(bool remove_tree=true)
Notifies the system that all primitive columns have been modified.
uint04 solidVertexOffset() const
Returns the offset of solid (thickness-expanded) vertices in the vertex table.
@ e_none
No thickness applied.
@ e_pixel
Thickness in screen pixels.
@ e_flat_single
Flat thickness, single value for all vertices.
@ e_circle_per_vertex
Circular cross-section thickness, per-vertex value.
@ e_flat_per_vertex
Flat thickness, per-vertex value.
@ e_circle
Circular cross-section thickness, single value.
void setPrimitiveMode(PrimitiveProperty property, PrimitiveMode mode)
Sets the primitive mode for a given property.
void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
Sets a single primitive index value.
uint04 primitiveCount(PrimitiveProperty property) const
Returns the number of primitives for a specific property.
uint04 addVertices(uint04 size)
Adds multiple vertices to the geometry.
void setSolidVertexOffsetValue(uint04 count)
Sets the solid vertex offset value in the database.
PrimitiveMode mode(PrimitiveProperty property) const
Retrieves the primitive mode for a given primitive property.
uint04 indexOffset() const
Returns the base index offset for this geometry within the shared index column.
uint04 vertexCount() const
Returns the number of vertices in this geometry.
uint04 primitiveIndexCount() const
Returns the total number of primitive indices across all properties.
void setVertex(VertexProperty property, uint04 index, const t_type &vector)
Sets a standard vertex property value at the given index.
void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count)
Sets the start offset and count for a primitive property range.
GeometryType getGeometryType() const
Retrieves the geometry type identifier.
Templated logic for doing matrix multiplication.
A sequence of connected line segments defined by ordered vertices along a path.
uint04 vertexCount() const
LineSegment< t_dims, t_type, t_vertex > segment(uint04 index) const
const t_vertex & vertex(uint04 index) const
uint04 segmentCount() const
void add(const t_vertex &vertex)
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
@ Position
XYZ position of the vertex.
@ e_triangle
Each triplet of indices defines a triangle.
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ e_linework
Lines or polylines.
double fltp08
Defines an alias representing an 8 byte floating-point number.
@ DEGREES
Angle measured in degrees (0 to 360 for a full circle).
constexpr Vector< 1, t_type > cross(const Vector< 1, t_type > &, const Vector< 1, t_type > &)
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
@ transform
A 4x4 transform matrix that maps local coordinates into global space.
t_type sqrt(const t_type &value)
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type sin(const Angle< t_type > &angle)
Performs optimized sine operation on the given angle using pre-computed lookup table for optimal spee...
@ Outline
Line-based outline rendering of primitives.
@ Solid
Solid filled rendering of primitives.
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type cos(const Angle< t_type > &angle)
Performs optimized cosine operation on the given angle using pre-computed lookup table for optimal sp...
@ has_closed_primitive
Whether primitives are closed, enabling volume calculations.
@ thickness
The thickness value applied to geometry rendering.
@ plane_normal
The normal ray of the surface plane.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...