NDEVR
API Documentation
GeometryFilter.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/SoftwareService.h>
4#include <NDEVR/GeometryVertices.h>
5#include <NDEVR/DesignCommand.h>
6#include <NDEVR/Buffer.h>
7#include <NDEVR/UUID.h>
8#include <NDEVR/GenericOption.h>
9#include <NDEVR/Pointer.h>
10
11namespace NDEVR
12{
14 class Model;
15 class Geometry;
16
20 struct NDEVR_DESIGN_API FilterDescription : public GenericOptionGroup
21 {
27 FilterDescription(const TranslatedString& filter_name, const String& filter_id);
28 };
29
44
51 class NDEVR_DESIGN_API GeometryFilter : public SoftwareServiceManager, public SoftwareService
52 {
53 protected:
59 explicit GeometryFilter(const TranslatedString& name, const StringView& id);
60 public:
66
71 static void AddAvailableFilter(GeometryFilter* filter);
72
80 static void ExecuteFiltering(const JSONNode& active_filters, Model& model, LogPtr log, const void* lock);
81
90 static void ExecuteFiltering(const JSONNode& active_filters, const Matrix<fltp08>& transform, Geometry& geo, LogPtr log, const void* lock);
91
97
107
114
121 public:
122 GeometryFilter(const GeometryFilter& filter) = delete;
123 GeometryFilter(const GeometryFilter&& filter) = delete;
124 virtual ~GeometryFilter() = default;
125
131 virtual bool runFilter(GeometryFilterParameters& parameters) = 0;
132
138 virtual bool canRunFilter(const GeometryFilterParameters&) { return true; }
139
145
150 [[nodiscard]] const TranslatedString& filterName() const { return m_name; }
151
156 [[nodiscard]] const String& filterID() const { return m_id; }
157 protected:
160 protected:
167 static void PrepareForFiltering(const Matrix<fltp08>& transform, Geometry& geo, GeometryFilterParameters& params);
168
175 static void ClearAllFiltering(Geometry& geo, LogPtr log, const void* lock);
176
183 static void FinishFiltering(const Matrix<fltp08>& transform, Geometry& geo, const GeometryFilterParameters& params);
184 protected:
186 };
187}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
GenericOptionGroup()=default
Default constructor.
const String & filterID() const
Returns the internal string identifier of this filter.
String m_id
The internal unique string identifier for this filter.
virtual bool runFilter(GeometryFilterParameters &parameters)=0
Executes this filter on the given parameters, modifying the filtered flags.
static DynamicPointer< ManagedDesignCommand > AddFilterCommand(const FilterDescription &filter)
Creates a design command that adds a single filter to the active filter set.
static Buffer< FilterDescription > GetAvailableDescriptions()
Retrieves the default FilterDescription entries for all registered filters.
static void AddAvailableFilter(GeometryFilter *filter)
Registers a GeometryFilter instance in the global available filters dictionary.
static const Dictionary< String, GeometryFilter * > & AvailableFilters()
Returns the global dictionary of all registered GeometryFilter instances keyed by their ID.
virtual bool canRunFilter(const GeometryFilterParameters &)
Returns whether this filter can be applied given the target parameters.
static DynamicPointer< ManagedDesignCommand > SetFiltersCommand(const Buffer< FilterDescription > &filter)
Creates a design command that replaces the entire active filter set with the given filters.
static void ExecuteFiltering(const JSONNode &active_filters, const Matrix< fltp08 > &transform, Geometry &geo, LogPtr log, const void *lock)
Executes filtering on a single Geometry object using the filters described in the JSON node.
GeometryFilter(const GeometryFilter &&filter)=delete
Move constructor is deleted; filters are non-movable.
GeometryFilter(const TranslatedString &name, const StringView &id)
Constructs a GeometryFilter with the given display name and identifier.
static Dictionary< String, GeometryFilter * > s_global_available_filters
Global registry of all available filter instances, keyed by their string ID.
static void PrepareForFiltering(const Matrix< fltp08 > &transform, Geometry &geo, GeometryFilterParameters &params)
Prepares geometry data for filtering by populating the parameters with vertex data.
TranslatedString m_name
The user-facing translated display name for this filter.
virtual Buffer< FilterDescription > defaultFilterArguments()
Returns the default set of FilterDescription arguments for this filter.
static String ToCommandString(const Buffer< FilterDescription > &descriptions)
Serializes a set of filter descriptions into a command string representation.
virtual ~GeometryFilter()=default
Virtual destructor defaulted for proper polymorphic cleanup.
static void ExecuteFiltering(const JSONNode &active_filters, Model &model, LogPtr log, const void *lock)
Executes filtering on all geometry within a Model using the filters described in the JSON node.
GeometryFilter(const GeometryFilter &filter)=delete
Copy constructor is deleted; filters are non-copyable.
static void ClearAllFiltering(Geometry &geo, LogPtr log, const void *lock)
Clears all filtering results from the given geometry, restoring it to unfiltered state.
static void FinishFiltering(const Matrix< fltp08 > &transform, Geometry &geo, const GeometryFilterParameters &params)
Applies the filtering results back to the geometry after filter execution.
const TranslatedString & filterName() const
Returns the user-facing translated name of this filter.
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:149
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A DesignCommand subclass that dispatches common design operations based on a ManagedCommandType enum ...
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
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 core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
Describes special options/parameters for a GeometryFilter engine.
FilterDescription(const TranslatedString &filter_name, const String &filter_id)
Constructs a FilterDescription with the given display name and identifier.
Stores a groups of options for performing GeometryFilter operations.
const void * lock
An optional lock pointer used for thread synchronization during filtering.
Matrix< fltp08 > transform
The transformation matrix applied to geometry during filtering.
Dictionary< UUID, Bounds< 1, uint04 > > vertex_bounds
Maps geometry UUIDs to their vertex index ranges within the shared vertex buffer.
LogPtr log
An optional log for reporting filter progress or errors.
Buffer< bool > filtered
Per-vertex or per-element boolean flags indicating whether each element was filtered out.
GeometryFilterParameters()
Constructs default GeometryFilterParameters with identity transform and null lock/log.
A container for storing vertex data associated with geometry, including positions,...