33#include <NDEVR/Geometry.h>
34#include <NDEVR/Plane.h>
69 lib_assert(!
isNaN(thickness) && thickness > 0.0,
"Thickness must be > 0.0");
81 geo_line.
add({ -thickness / 2.0, 0, 0 });
82 geo_line.
add({ thickness / 2.0, 0, 0 });
87 uint04 width_segments = 128;
88 for (
uint04 x = 0; x <= width_segments; x++)
93 geo_line.
add(position);
132 for (
uint04 i = 0; i < polylines.size(); i++)
134 polylines[i].simplify();
136 if (
isNaN(poly_normal))
139 if (bounds[
X] * bounds[
X] + bounds[
Y] * bounds[
Y] > bounds[
Z] * bounds[
Z])
140 poly_normal = { 0.0, 0.0, 1.0 };
141 else if (bounds[
X] * bounds[
X] > bounds[
Y] * bounds[
Y])
142 poly_normal = { 0.0, 1.0, 0.0 };
144 poly_normal = { 1.0, 0.0, 0.0 };
146 Extrude(indices, vertices, geo_line, polylines[i], poly_normal, is_closed, poly_transform);
151 if (
isNaN(solid_vertex_offset))
157 if (solid_vertex_size < vertices.
size())
159 linework.
addVertices(solid_vertex_offset, vertices.
size() - solid_vertex_size);
170 for (
uint04 i = 0; i < indices.size(); i++)
204 template<
class t_type>
210 ,
bool is_path_closed
224 bool greater_than_90_turn =
false;
229 if (is_path_closed && (i == 0 || i == extrude_path.
segmentCount()))
233 original_dir = extrude_path.
segment(extrude_path.
segmentCount() - 1).ray().template normalized<t_type>();
235 dir = (dir_2 + original_dir).
template normalized<t_type>();
236 greater_than_90_turn =
dot(dir_2, original_dir) < 0;
238 else if (last.
size() == 0)
241 original_dir = extrude_path.
segment(i).ray().template normalized<t_type>();
248 original_dir = extrude_path.
segment(i - 1).ray().template normalized<t_type>();
254 original_dir = extrude_path.
segment(i - 1).ray().template normalized<t_type>();
256 dir = (dir_2 + original_dir).
template normalized<t_type>();
257 greater_than_90_turn =
dot(dir_2, original_dir) < 0;
262 if (dir.template magnitude<fltp08>() == 0.0 ||
isNaN(dir))
272 if (
isNaN(last_right))
291 const t_type p_off_original =
cast<t_type>(1.0) -
dot(dir, original_dir) *
dot(dir, original_dir);
293 t_type extra_distance =
sqrt(4 * p_off_original * p_off_original + 1.0);
294 if (greater_than_90_turn)
295 extra_distance = 2.0 / extra_distance;
298 for (
const auto& vertex : shape_to_extrude)
301 projection += vertex[
X] * right;
302 projection += vertex[
Y] * up;
303 projection += vertex[
Z] * dir;
304 projection = projection.template normalized<fltp08>();
305 projection = (transform * projection) * vertex.template magnitude<fltp08>();
306 current.
add((extra_distance * projection) + offset);
311 for (
uint04 n = 0; n < shape_to_extrude.vertexCount() - 1; n++)
317 vertices.add(last[n]);
318 vertices.add(current[n]);
319 vertices.add(current[n + 1]);
320 vertices.add(last[n + 1]);
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Stores an angle in an optimized format.
Definition StringStream.h:352
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void add(t_type &&object)
Definition Buffer.hpp:199
constexpr t_index_type size() const
Definition Buffer.hpp:1461
void clear()
Definition Buffer.hpp:572
Matrix< fltp08 > getTransform() const
Definition DesignObject.cpp:593
static void ExtrudeRealThickness(Geometry &linework, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
Definition Extruder.h:65
static void ExtrudePolylineAlongGeo(Geometry &linework, const Polyline< 3, fltp08 > &geo_line, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
Definition Extruder.h:117
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))
Definition Extruder.h:205
void setSolidVertexOffsetValue(uint04 count)
Definition Geometry.h:1335
void updateSolidVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Definition Geometry.cpp:2219
void updateModifiedTime(Time time=Time::SystemTime())
Definition Geometry.cpp:2008
void updateVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Definition Geometry.cpp:2206
void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
Definition Geometry.h:335
uint04 addVertices(uint04 size)
Definition Geometry.h:686
uint04 solidVertexOffset() const
Definition Geometry.h:717
uint04 vertexCount() const
Definition Geometry.h:713
GeometryType getGeometryType() const
Definition Geometry.cpp:1054
void setPrimitiveRange(PrimitiveProperty mode, uint04 start, uint04 primitive_count)
Definition Geometry.cpp:753
uint04 primitiveCount(PrimitiveProperty property) const
Definition Geometry.h:669
void setSolidVertexCountValue(uint04 count)
Definition Geometry.h:1327
void updatePrimitiveColumns(bool remove_tree=true)
Definition Geometry.cpp:1999
void setVertex(VertexProperty property, uint04 index, const t_type &vector)
Definition Geometry.h:871
@ e_flat_per_vertex
Definition Geometry.h:134
@ e_circle
Definition Geometry.h:135
@ e_none
Definition Geometry.h:131
@ e_flat_single
Definition Geometry.h:133
@ e_circle_per_vertex
Definition Geometry.h:136
@ e_pixel
Definition Geometry.h:132
ThicknessMode thicknessMode() const
Definition Geometry.cpp:498
t_type getGeometryProperty(GeometryProperty property) const
Definition Geometry.h:174
@ e_plane_normal
Definition Geometry.h:107
@ e_has_closed_primitive
Definition Geometry.h:106
@ e_thickness
Definition Geometry.h:101
Buffer< Polyline< t_dims, t_type > > polylines(PrimitiveProperty primitive_property, VertexProperty vertex_property) const
Definition Geometry.h:1170
void setPrimitiveMode(PrimitiveProperty property, PrimitiveMode mode)
Definition Geometry.cpp:1981
PrimitiveMode mode(PrimitiveProperty property) const
Definition Geometry.h:309
uint04 indexOffset() const
Definition Geometry.h:628
void setSolidVertexReservedValue(uint04 count)
Definition Geometry.h:1331
uint04 primitiveIndexCount() const
Definition Geometry.h:665
uint04 solidVertexReservedCount() const
Definition Geometry.h:721
Definition Matrix.hpp:173
Matrix< t_type, t_cols, t_rows > invert() const
Definition Matrix.hpp:649
A polyline which stores vertex information for many points along a given path.
Definition CoordinateProjectionManager.h:44
uint04 vertexCount() const
Definition PolyLine.hpp:209
uint04 segmentCount() const
Definition PolyLine.hpp:226
LineSegment< t_dims, t_type, t_vertex > segment(uint04 index) const
Definition PolyLine.hpp:175
void add(const t_vertex &vertex)
Definition PolyLine.hpp:265
const t_vertex & vertex(uint04 index) const
Definition PolyLine.hpp:155
Definition Vertex.hpp:341
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
A vertex.
Definition Vertex.hpp:54
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1096
@ DEGREES
Definition Angle.h:66
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type cos(const Angle< t_type > &angle)
Definition AngleFunctions.h:154
constexpr Vector< 1, t_type > cross(const Vector< 1, t_type > &, const Vector< 1, t_type > &)
Definition VectorFunctions.hpp:954
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1309
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type sin(const Angle< t_type > &angle)
Definition AngleFunctions.h:113
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition BaseValues.hpp:272