API Documentation
Loading...
Searching...
No Matches
ParameterSlicer.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/DesignParameter.h>
3#include <NDEVR/DesignCommand.h>
4#if NDEVR_CROSS_SECTION
5namespace NDEVR
6{
7 class Model;
8 class Geometry;
9 class PolylineValueSliceIterator;
10 class ProgressInfo;
11
12 /**--------------------------------------------------------------------------------------------------
13 \brief Arguments for a parameterSlicer command
14 *-----------------------------------------------------------------------------------------------**/
15 struct ParameterSlicerArgs
16 {
17 Model linework_root;
18 Buffer<Model> models_to_slice;
19 PolylineValueSliceIterator* slicer = nullptr;
20 DesignParameter parameter;
21 ProgressInfo* log = nullptr;
22 const void* lock = nullptr;
23 };
24
25 struct ValueSlicePlane
26 {
27 Buffer<Buffer<uint04>> segments;
28 Buffer<Vertex<3, fltp04>> polyline_vertices;
29 Dictionary<String, Buffer<fltp04>> properties;
30 fltp08 value;
31 String name;
32 String group;
33 };
34 class PolylineValueSliceIterator
35 {
36 public:
37 virtual Buffer<ValueSlicePlane> slicePlanes(const Matrix<fltp08>& transform, const DesignParameter& param) = 0;
38 virtual void cleanupSlicePlanes(const Matrix<fltp08>&, Buffer<ValueSlicePlane>&) { /*Do nothing*/ };
39 };
40 //Slices object into evenly spaced cross sections
41 class EvenSliceIterator : public PolylineValueSliceIterator
42 {
43 Buffer<ValueSlicePlane> slicePlanes(const Matrix<fltp08>& transform, const DesignParameter& param) override;
44 public:
45 Bounds<1, fltp08> bounds;
46 fltp08 spacing = 1.0;
47 };
48
49 struct PolylineValueSliceCache
50 {
51 Matrix<fltp08> slice_transform;
52 DesignParameter parameter;
53 Buffer<ValueSlicePlane> planes;
54 Buffer<Triangle<3, fltp08>> triangles;
55 Buffer<Vector<3, fltp08>> triangle_values;
56 PolylineValueSliceIterator* slice_plane;
57 ProgressInfo* log;
58 };
59 /**--------------------------------------------------------------------------------------------------
60 \brief Slices a geometery around certain parameter values. For example: meshes will be turned into
61 polylines along the border between values.
62 *-----------------------------------------------------------------------------------------------**/
63 class PolylineValueSlicer
64 {
65 public:
66 static void CreateActiveLinework(ParameterSlicerArgs& args);
67 static constexpr const char* SliceTypeName() { return "polyline_slice"; }
68 protected:
69 static void SliceIntoLineSegments(uint04 slice_index, PolylineValueSliceCache& args);
70 static void PrepareCache(const Matrix<fltp08>& transform, const Geometry& geo, PolylineValueSliceCache& params);
71 static void FinishSegmenting(const Matrix<fltp08>& transform, Model& model, uint04 slice_index, const PolylineValueSliceCache& params);
72 static void AddVertices(Geometry& geo, const ValueSlicePlane& plane, const Matrix<fltp08>& mat);
73 };
74 class NDEVR_DESIGN_API ParameterSlicerCommand : public DesignCommand
75 {
76 public:
77 ParameterSlicerCommand(const Bounds<1, fltp08>& bounds, fltp08 spacing, DesignParameter param);
78 virtual ~ParameterSlicerCommand() {};
79 virtual void execute(DesignObjectLookup* lookup) override;
80 virtual bool canCombineWith(const DynamicPointer<DesignCommand>&) override { return false; };
81
82 virtual bool isAsyncExecution() const override { return true; };
83 virtual String icon() const override;
84 virtual TranslatedString name() const override;
85 protected:
86 Bounds<1, fltp08> m_bounds;
87 fltp08 m_spacing;
88 DesignParameter m_param;
89 };
90}
91#endif
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146