API Documentation
Loading...
Searching...
No Matches
GeometrySurfacing.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: GeometrySurfacing
28File: GeometrySurfacing
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#if NDEVR_SURFACING
35#include <NDEVR/SoftwareService.h>
36#include <NDEVR/GeometryVertices.h>
37#include <NDEVR/Model.h>
38#include <NDEVR/Material.h>
39#include <NDEVR/DesignCommand.h>
40#include <NDEVR/Buffer.h>
41#include <NDEVR/GenericOption.h>
42#include <NDEVR/JSONNode.h>
43#include <NDEVR/INIInterface.h>
44namespace NDEVR
45{
46 template<uint01 t_dims, class t_type>
47 class SelectionArea;
48 class DesignObjectLookup;
49 class DesignSelection;
50 /**--------------------------------------------------------------------------------------------------
51 \brief Contains options to describe a SurfacingEngine process
52 **/
53 class NDEVR_SURFACING_API SurfacingDescription : public GenericOptionGroup, public INIInterface
54 {
55 public:
56 SurfacingDescription(const TranslatedString& filter_name, const String& filter_id);
57 virtual void getINI(INIFactory& factory) override;
58 uint04 use_counts = 0;
59 uint04 priority = 0;
60 };
61 /**--------------------------------------------------------------------------------------------------
62 \brief Options for post-processing a surface.
63 **/
64 struct SurfacePostProcessingOptions
65 {
66 fltp08 combine_vertex_epsilon = 0.0;
67 bool combine_vertices = false;
68 };
69 /**--------------------------------------------------------------------------------------------------
70 \brief Contains options for generating surface materials used with GeometrySurfacing
71 **/
72 struct GenerateMaterialInformation
73 {
74 Material::UVMode mode = Material::UVMode::e_background;
75 RGBColor constant_color = Constant<RGBColor>::Invalid;
76 };
77 class NormalFlipper;
78 /**--------------------------------------------------------------------------------------------------
79 \brief Parameters used in the GeometrySurfacing process
80 **/
81 struct NDEVR_SURFACING_API GeometrySurfacingParameters : public GenericOptionGroup, public GeometryVertices
82 {
83 GeometrySurfacingParameters();
84 GeometrySurfacingParameters(const SurfacingDescription& description);
85 void flipPositionElevations();
86 [[nodiscard]] uint04 surfacePrimitiveSize() const;
87 [[nodiscard]] bool hasSameOptions(const GeometrySurfacingParameters& params) const;
88 GenerateMaterialInformation material_info;
89 const void* lock = nullptr;
90 ProgressInfo* log = nullptr;
91 NormalFlipper* normal_flipper = nullptr;
92 DesignObjectLookup* lookup = nullptr;
93 Buffer<Vertex<3, fltp04>> surface_positions;
94 Buffer<Ray<3, fltp04>> surface_normals;
95 Buffer<RGBColor> surface_colors;
96 Buffer<Vector<3, uint04>> surface_triangles;
97 Buffer<Buffer<uint04>> surface_polygons;
98 fltp08 linework_surface_delta = 0.01;
99 fltp08 mesh_surface_delta = 0.01;
100 bool surface_linework = false;
101 bool surface_meshes = false;
102 bool include_colors = false;
103 SurfacePostProcessingOptions post_processing_options;
104 Model target_surface_location;
105 UUID normal_cache_id;
106 };
107 /**--------------------------------------------------------------------------------------------------
108 \brief A class that flips a surface generated normals from point clouds or lines given some parameters
109 or logic.
110 **/
111 class NormalFlipper : public SoftwareService
112 {
113 public:
114 virtual bool shouldFlipNormal(uint04 idx, GeometrySurfacingParameters& parameters, const Ray<3, fltp04>& normal) = 0;
115 };
116 /**--------------------------------------------------------------------------------------------------
117 \brief Allows Surfacing engines to register and be used to create surfaces from points or groups
118 of linework.
119 **/
120 class NDEVR_SURFACING_API GeometrySurfacing : public SoftwareServiceManager
121 {
122 protected:
123 explicit GeometrySurfacing(const TranslatedString& name, const String& id);
124 public:
125 GeometrySurfacing(const GeometrySurfacing& filter) = delete;
126 GeometrySurfacing(const GeometrySurfacing&& filter) = delete;
127 virtual ~GeometrySurfacing() = default;
128 virtual bool runSurfacing(GeometrySurfacingParameters& parameters) = 0;
129 //Returns whether or not the filter can be applied given the target parameters. Default true
130 [[nodiscard]] virtual bool canRunSurfacing(const GeometrySurfacingParameters&) { return true; }
131 [[nodiscard]] virtual Buffer<SurfacingDescription> defaultSurfacingArguments();
132 [[nodiscard]] const TranslatedString& surfacingName() const { return m_name; }
133 [[nodiscard]] const String& surfacingID() const { return m_id; }
134 public:
135 static void SetupDefaultSurfaceObject(GeometrySurfacingParameters& params);
136 static void SetupDefaultSurfaceMaterial(GeometrySurfacingParameters& params);
137 static const Dictionary<String, GeometrySurfacing*>& AvailableSurfacing();
138 static void AddAvailableSurfacingEngine(GeometrySurfacing* filter);
139 static void ExecuteSurfacing(GeometrySurfacingParameters& params, const DesignSelection& selection_to_surface);
140 static void ExecuteSurfacing(GeometrySurfacingParameters& params, const Buffer<Model>& models_to_surface);
141 static void ExecuteSurfacing(GeometrySurfacingParameters& params, const Buffer<SelectionArea<3, fltp08>, uint04, ObjectAllocator<false>>& boundary_areas);
142 [[nodiscard]] static Buffer<SurfacingDescription> GetAvailableDescriptions();
143 [[nodiscard]] static uint04 AvailableSurfacingDescriptionCount();
144 [[nodiscard]] static String ToCommandString(const SurfacingDescription& descriptions);
145 static void ClearCache();
146 [[nodiscard]] static String CreateDescription(GeometrySurfacingParameters& params);
147 static void FindSurfaceColors(GeometrySurfacingParameters& params, fltp04 max_distance = Constant<fltp04>::Max);
148 protected:
149 static void PrepareForSurfacing(const Matrix<fltp08>& transform, const Model& model, const Geometry& geo, GeometrySurfacingParameters& params);
150 static void ClearAllSurfacing(Geometry& geo, ProgressInfo* log, const void* lock);
151 static void FinishSurfacing(GeometrySurfacingParameters& params, const Buffer<SelectionArea<3, fltp08>, uint04, ObjectAllocator<false>>& boundary_areas);
152 static void FinishSurfacing(const Matrix<fltp08>& transform, Geometry& geo, const GeometrySurfacingParameters& params, const Buffer<SelectionArea<3, fltp08>, uint04, ObjectAllocator<false>>& boundary_areas);
153 protected:
154 static Dictionary<String, GeometrySurfacing*> s_global_available_surfacing_engines;
155 static Dictionary<UUID, GeometrySurfacingParameters> s_cached_geometry_cloud;
156 static Dictionary<UUID, Buffer<GeometrySurfacingParameters>> s_cached_geometry_params;
157 protected:
158 TranslatedString m_name;
159 String m_id;
160 };
161 /**--------------------------------------------------------------------------------------------------
162 \brief A command that can be executed in the command queue that will perform a surfacing task.
163 **/
164 class NDEVR_SURFACING_API GeometrySurfacingCommand : public DesignCommand
165 {
166 public:
167 GeometrySurfacingCommand(const GeometrySurfacingParameters& params, const UUID& output_id = Constant<UUID>::Invalid);
168 GeometrySurfacingCommand(const SurfacingDescription& description, bool include_colors, bool include_lines, const UUID& output_id = Constant<UUID>::Invalid);
169 virtual void execute(DesignObjectLookup* lookup) override;
170 virtual bool isAsyncExecution() const override { return true; }
171 String icon() const override;
172 TranslatedString name() const override;
173 protected:
174 GeometrySurfacingParameters m_params;
175 UUID m_output_id = Constant<UUID>::Invalid;
176 UUID m_generated_id = Constant<UUID>::Invalid;
177 };
178}
179#endif
#define NDEVR_SURFACING_API
Definition DLLInfo.h:56
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149