NDEVR
API Documentation
ParameterSlicer.h
1#pragma once
2#include <NDEVR/DesignParameter.h>
3#include <NDEVR/DesignCommand.h>
4#include <NDEVR/DesignObjectResourceCache.h>
5#if NDEVR_CROSS_SECTION
6namespace NDEVR
7{
8 class Model;
9 class Geometry;
10 class PolylineValueSliceIterator;
11 class InfoPipe;
12
16 struct ParameterSlicerArgs
17 {
18 Model linework_root;
19 Buffer<Model> models_to_slice;
20 PolylineValueSliceIterator* slicer = nullptr;
21 DesignParameter parameter;
22 LogPtr log;
23 DesignObjectResourceCache resource_cache;
24 const void* lock = nullptr;
25 };
26
31 struct ValueSlicePlane
32 {
33 Buffer<Buffer<uint04>> segments;
34 Buffer<Vertex<3, fltp04>> polyline_vertices;
35 Dictionary<String, Buffer<fltp04>> properties;
36 fltp08 value;
37 String name;
38 TranslatedString group;
39 };
40
45 class PolylineValueSliceIterator
46 {
47 public:
54 virtual Buffer<ValueSlicePlane> slicePlanes(const Matrix<fltp08>& transform, const DesignParameter& param) = 0;
55
61 virtual void cleanupSlicePlanes(const Matrix<fltp08>&, Buffer<ValueSlicePlane>&) { /*Do nothing*/ };
62 };
63
68 class EvenSliceIterator : public PolylineValueSliceIterator
69 {
76 Buffer<ValueSlicePlane> slicePlanes(const Matrix<fltp08>& transform, const DesignParameter& param) override;
77 public:
78 Bounds<1, fltp08> bounds;
79 fltp08 spacing = 1.0;
80 };
81
86 struct PolylineValueSliceCache
87 {
88 Matrix<fltp08> slice_transform;
89 DesignParameter parameter;
90 Buffer<ValueSlicePlane> planes;
91 Buffer<Triangle<3, fltp08>> triangles;
92 Buffer<Vector<3, fltp08>> triangle_values;
93 PolylineValueSliceIterator* slice_plane;
94 DesignObjectResourceCache resource_cache;
95 LogPtr log;
96 };
97
103 class PolylineValueSlicer
104 {
105 public:
110 static void CreateActiveLinework(ParameterSlicerArgs& args);
111
116 static constexpr StringView SliceTypeName() { return "polyline_slice"; }
117 protected:
123 static void SliceIntoLineSegments(uint04 slice_index, PolylineValueSliceCache& args);
124
131 static void PrepareCache(const Matrix<fltp08>& transform, const Geometry& geo, PolylineValueSliceCache& params);
132
140 static void FinishSegmenting(const Matrix<fltp08>& transform, Model& model, uint04 slice_index, PolylineValueSliceCache& params);
141
148 static void AddVertices(Geometry& geo, const ValueSlicePlane& plane, const Matrix<fltp08>& mat);
149 };
150
156 class ParameterSlicerCommand : public DesignCommand
157 {
158 public:
165 NDEVR_DESIGN_API ParameterSlicerCommand(const Bounds<1, fltp08>& bounds, fltp08 spacing, DesignParameter param);
166
170 virtual ~ParameterSlicerCommand() {};
171
176 NDEVR_DESIGN_API virtual void execute(DesignObjectLookup* lookup) override;
177
183 virtual bool canCombineWith(const DynamicPointer<DesignCommand>&) override { return false; };
184
189 virtual bool isAsyncExecution() const override { return true; };
190
195 NDEVR_DESIGN_API virtual StringView icon() const override;
196
201 NDEVR_DESIGN_API virtual TranslatedString name() const override;
202
208 virtual bool addTarget(UUID target_id) override { targets.add(target_id); return true; }
209 public:
210 Buffer<UUID> targets;
211 protected:
212 Bounds<1, fltp08> m_bounds;
213 fltp08 m_spacing;
214 DesignParameter m_param;
215 };
216}
217#endif
Forward declaration of the central design object registry.
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
A light-weight base class for Log that allows processes to update, without the need for additional in...
A core class that represents a node on model hierarchy.
Definition Model.h:292
The primary namespace for the NDEVR SDK.
double fltp08
Defines an alias representing an 8 byte floating-point number.
@ name
The display name of the object.
@ icon
Icon identifier for the object.