Enzo
Loading...
Searching...
No Matches
SelectionComponent.h
1#pragma once
2#include "Engine/Core/Types.h"
3#include "Engine/Primitives/Primitive.h"
4#include "Engine/Selection/IndexSet.h"
5#include <memory>
6#include <string>
7
8namespace enzo {
9
20{
21 public:
25 static std::unique_ptr<SelectionComponent> fromString(std::string_view string);
29 static std::unique_ptr<SelectionComponent> fromGroup(std::string_view name);
30
31 virtual ~SelectionComponent() = default;
32
33 virtual bool containsPrim(const geo::Primitive& prim) const = 0;
34 // When `inverted` is true the answer is flipped, but only for the
35 // element type the component actually talks about.
36 //
37 // `index` is the compacted element number (counting only valid elements)
38 // and `offset` is the raw storage offset. Path components match against the
39 // compacted index, while group components read group bools keyed by offset.
40 virtual bool containsFace(
41 const geo::Primitive& prim,
42 Index index,
43 Offset offset,
44 bool inverted = false
45 ) const = 0;
46 virtual bool containsPoint(
47 const geo::Primitive& prim,
48 Index index,
49 Offset offset,
50 bool inverted = false
51 ) const = 0;
52 virtual bool containsVertex(
53 const geo::Primitive& prim,
54 Index index,
55 Offset offset,
56 bool inverted = false
57 ) const = 0;
65 virtual bool isWholePrim(const geo::Primitive& prim) const = 0;
66
67 protected:
68 SelectionComponent() = default;
69};
70
76{
77 public:
78 static std::unique_ptr<PathSelectionComponent> parse(std::string_view string);
79
80 bool containsPrim(const geo::Primitive& prim) const override;
81 bool containsFace(
82 const geo::Primitive& prim,
83 Index index,
84 Offset offset,
85 bool inverted = false
86 ) const override;
87 bool containsPoint(
88 const geo::Primitive& prim,
89 Index index,
90 Offset offset,
91 bool inverted = false
92 ) const override;
93 bool containsVertex(
94 const geo::Primitive& prim,
95 Index index,
96 Offset offset,
97 bool inverted = false
98 ) const override;
99 bool isWholePrim(const geo::Primitive& prim) const override;
100
101 private:
102 PathSelectionComponent() = default;
103 std::string primPath_;
104 std::shared_ptr<IndexSet> points_;
105 std::shared_ptr<IndexSet> faces_;
106 std::shared_ptr<IndexSet> vertices_;
107};
108
113{
114 public:
115 static std::unique_ptr<GroupSelectionComponent> create(std::string_view name);
116
117 bool containsPrim(const geo::Primitive& prim) const override;
118 bool containsFace(
119 const geo::Primitive& prim,
120 Index index,
121 Offset offset,
122 bool inverted = false
123 ) const override;
124 bool containsPoint(
125 const geo::Primitive& prim,
126 Index index,
127 Offset offset,
128 bool inverted = false
129 ) const override;
130 bool containsVertex(
131 const geo::Primitive& prim,
132 Index index,
133 Offset offset,
134 bool inverted = false
135 ) const override;
136 bool isWholePrim(const geo::Primitive& prim) const override;
137
138 private:
139 GroupSelectionComponent() = default;
140 std::string groupName_;
141};
142
143} // namespace enzo
Basic attribute, parameter, and node types for Enzo.
size_t Offset
enzo::Offset is the internal discontinuous index of an element in a given AttributeOwner.
Definition Types.h:100
size_t Index
enzo::Index is the continuous index of an element in a given AttributeOwner.
Definition Types.h:91
Selection component that resolves membership through a named group.
Definition SelectionComponent.h:113
bool isWholePrim(const geo::Primitive &prim) const override
Whether the component selects the prim as a whole.
Definition SelectionComponent.cpp:268
Selection component anchored to a primitive path plus optional per element index sets.
Definition SelectionComponent.h:76
bool isWholePrim(const geo::Primitive &prim) const override
Whether the component selects the prim as a whole.
Definition SelectionComponent.cpp:176
Abstract base for one piece of a Selection expression.
Definition SelectionComponent.h:20
static std::unique_ptr< SelectionComponent > fromString(std::string_view string)
Parses one component string and returns the appropriate subclass.
Definition SelectionComponent.cpp:43
virtual bool isWholePrim(const geo::Primitive &prim) const =0
Whether the component selects the prim as a whole.
static std::unique_ptr< SelectionComponent > fromGroup(std::string_view name)
Creates a group based component for the named group.
Definition SelectionComponent.cpp:64
Base class for all primitive types in the engine.