NDEVR
API Documentation
GeometrySurfacing.h
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/SelectionArea.h>
42#include <NDEVR/GenericOption.h>
43#include <NDEVR/JSONNode.h>
44#include <NDEVR/INIInterface.h>
45namespace NDEVR
46{
47 template<uint01 t_dims, class t_type>
48 class SelectionArea;
50 class DesignSelection;
54 class NDEVR_SURFACING_API SurfacingDescription : public GenericOptionGroup, public INIInterface
55 {
56 public:
61 SurfacingDescription(const TranslatedString& filter_name, const StringView& filter_id);
65 virtual void getINI(INIFactory& factory) override;
66 uint04 use_counts = 0;
67 uint04 priority = 0;
68 };
72 struct SurfacePostProcessingOptions
73 {
74 fltp08 combine_vertex_epsilon = 0.0;
75 bool combine_vertices = false;
76 };
80 struct GenerateMaterialInformation
81 {
82 Material::UVMode mode = Material::UVMode::e_background;
83 RGBColor constant_color = Constant<RGBColor>::Invalid;
84 };
85 class NormalFlipper;
89 struct NDEVR_SURFACING_API GeometrySurfacingParameters : public GenericOptionGroup, public GeometryVertices
90 {
92 GeometrySurfacingParameters();
96 GeometrySurfacingParameters(const SurfacingDescription& description);
98 void flipPositionElevations();
102 [[nodiscard]] uint04 surfacePrimitiveSize() const;
107 [[nodiscard]] bool hasSameOptions(const GeometrySurfacingParameters& params) const;
108 GenerateMaterialInformation material_info;
109 const void* lock = nullptr;
110 LogPtr log = nullptr;
111 NormalFlipper* normal_flipper = nullptr;
112 DesignObjectLookup* lookup = nullptr;
113 Buffer<Vertex<3, fltp04>> surface_positions;
114 Buffer<Ray<3, fltp04>> surface_normals;
115 Buffer<RGBColor> surface_colors;
116 Buffer<Vector<3, uint04>> surface_triangles;
117 Buffer<Buffer<uint04>> surface_polygons;
118 fltp08 linework_surface_delta = 0.01;
119 fltp08 mesh_surface_delta = 0.01;
120 bool surface_linework = false;
121 bool surface_meshes = false;
122 bool include_colors = false;
123 bool simplify_meshes = false;
124 SurfacePostProcessingOptions post_processing_options;
125 Model target_surface_location;
126 UUID normal_cache_id;
127 };
133 class NormalFlipper : public SoftwareService
134 {
135 public:
142 virtual bool shouldFlipNormal(uint04 idx, GeometrySurfacingParameters& parameters, const Ray<3, fltp04>& normal) = 0;
143 };
149 class NDEVR_SURFACING_API GeometrySurfacing : public SoftwareServiceManager
150 {
151 protected:
156 explicit GeometrySurfacing(const TranslatedString& name, const StringView& id);
157 public:
158 GeometrySurfacing(const GeometrySurfacing& filter) = delete;
159 GeometrySurfacing(const GeometrySurfacing&& filter) = delete;
160 virtual ~GeometrySurfacing() = default;
165 virtual bool runSurfacing(GeometrySurfacingParameters& parameters) = 0;
169 [[nodiscard]] virtual bool canRunSurfacing(const GeometrySurfacingParameters&) { return true; }
173 [[nodiscard]] virtual Buffer<SurfacingDescription> defaultSurfacingArguments();
177 [[nodiscard]] const TranslatedString& surfacingName() const { return m_name; }
181 [[nodiscard]] const String& surfacingID() const { return m_id; }
182 public:
186 static void SetupDefaultSurfaceObject(GeometrySurfacingParameters& params);
190 static void SetupDefaultSurfaceMaterial(GeometrySurfacingParameters& params);
194 static const Dictionary<String, GeometrySurfacing*>& AvailableSurfacing();
198 static void AddAvailableSurfacingEngine(GeometrySurfacing* filter);
203 static void ExecuteSurfacing(GeometrySurfacingParameters& params, const DesignSelection& selection_to_surface);
208 static void ExecuteSurfacing(GeometrySurfacingParameters& params, const Buffer<Model>& models_to_surface);
213 static void ExecuteSurfacing(GeometrySurfacingParameters& params, const Buffer<SelectionArea<3, fltp08>>& boundary_areas);
217 [[nodiscard]] static Buffer<SurfacingDescription> GetAvailableDescriptions();
221 [[nodiscard]] static uint04 AvailableSurfacingDescriptionCount();
226 [[nodiscard]] static String ToCommandString(const SurfacingDescription& descriptions);
228 static void ClearCache();
233 [[nodiscard]] static String CreateDescription(GeometrySurfacingParameters& params);
238 static void FindSurfaceColors(GeometrySurfacingParameters& params, fltp04 max_distance = Constant<fltp04>::Max);
239 protected:
246 static void PrepareForSurfacing(const Matrix<fltp08>& transform, const Model& model, const Geometry& geo, GeometrySurfacingParameters& params);
252 static void ClearAllSurfacing(Geometry& geo, InfoPipe* log, const void* lock);
257 static void FinishSurfacing(GeometrySurfacingParameters& params, const Buffer<SelectionArea<3, fltp08>>& boundary_areas);
263 static void FilterSurface(const Matrix<fltp08>& transform, GeometrySurfacingParameters& params, const Buffer<SelectionArea<3, fltp08>>& boundary_areas);
267 static void FilterVertices(GeometrySurfacingParameters& params);
272 static void SetupGeometry(Geometry& geo, const GeometrySurfacingParameters& params);
273 protected:
274 static Dictionary<String, GeometrySurfacing*> s_global_available_surfacing_engines;
275 protected:
276 TranslatedString m_name;
277 String m_id;
278 };
283 class GeometrySurfacingCommand : public DesignCommand
284 {
285 public:
290 NDEVR_SURFACING_API GeometrySurfacingCommand(const GeometrySurfacingParameters& params, const UUID& output_id = Constant<UUID>::Invalid);
297 NDEVR_SURFACING_API GeometrySurfacingCommand(const SurfacingDescription& description, bool include_colors, bool include_lines, const UUID& output_id = Constant<UUID>::Invalid);
298 virtual ~GeometrySurfacingCommand() {};
302 NDEVR_SURFACING_API virtual void execute(DesignObjectLookup* lookup) override;
306 virtual bool isAsyncExecution() const override { return true; }
310 NDEVR_SURFACING_API StringView icon() const override;
314 NDEVR_SURFACING_API TranslatedString name() const override;
319 virtual bool addTarget(UUID target_id) override { targets.add(target_id); return true; }
320 public:
321 Buffer<UUID> targets;
322 protected:
323 GeometrySurfacingParameters m_params;
324 UUID m_output_id = Constant<UUID>::Invalid;
325 UUID m_generated_id = Constant<UUID>::Invalid;
326 };
327}
328#endif
Forward declaration of the central design object registry.
A core class where all Design Objects including models, materials, and geometries are stored.
A simple structure for storing a collection of data.
Stores a groups of GenericOptions that can be used to group them.
Contains methods for easily reading and writing to an INI file including efficient casting,...
An area of N-dimensional space that is considered selected.
Software Service Managers take a Software service to modify the behavior of the software.
Base interface for services that extend or modify software behavior through modules.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
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.
A container for storing vertex data associated with geometry, including positions,...