32 std::shared_ptr<std::vector<std::shared_ptr<Node>>> m_builtNodes;
51 this->m_builtNodes =
nullptr;
58 virtual void setEntities(
const std::shared_ptr<std::vector<std::shared_ptr<T>>>& entities)
60 this->m_builder->setEntities(entities);
64 std::vector<std::shared_ptr<T>>
select(
int x,
int y,
int depth = 0)
67 this->m_producer->toPixel(x, y);
71 *nodes = *this->m_builtNodes;
72 std::vector<std::shared_ptr<T>> result;
74 std::function<void()> render;
75 render = [&]() ->
void {
76 this->m_producer->updatePassBatch();
77 auto image = this->m_producer->produce(nodes);
78 auto entityIndex = ((
unsigned int*)image->data())[0];
79 if (entityIndex != 0XFFFFFFFF)
81 result.push_back((*this->m_builder->entities())[entityIndex]);
83 auto& node = (*this->m_builtNodes)[entityIndex];
84 auto it = std::find(nodes->begin(), nodes->end(), node);
85 if (it != nodes->end())
90 if (!depth || count < depth)
100 std::vector<std::shared_ptr<T>>
multiSelect(
int x1,
int y1,
int x2,
int y2,
int depth = 0)
103 this->m_producer->toBox(x1, y1, x2, y2);
107 *nodes = *this->m_builtNodes;
108 std::vector<std::shared_ptr<T>> result;
110 std::function<void()> render;
111 render = [&]() ->
void {
112 this->m_producer->updatePassBatch();
113 auto image = this->m_producer->produce(nodes);
114 auto imageData = (
unsigned int*)image->data();
116 std::set<unsigned int> entityIndices;
117 auto length = image->width() * image->height();
118 for (
int i = 0; i < length; ++i)
120 entityIndices.insert(imageData[i]);
122 entityIndices.erase(0XFFFFFFFF);
124 if (entityIndices.size() != 0)
126 auto entities = *this->m_builder->entities();
127 for (
auto entityIndex : entityIndices)
129 result.push_back(entities[entityIndex]);
131 auto& node = (*this->m_builtNodes)[entityIndex];
132 auto it = std::find(nodes->begin(), nodes->end(), node);
133 if (it != nodes->end())
140 if (!depth || count < depth)
152 if (!this->m_builtNodes)
154 this->m_builtNodes = this->m_builder->build();
155 this->m_producer->updatePass();
160 template <
typename T>
167 this->m_builder = std::make_shared<FaceBuilder<T>>(options->entities, options->entity2node);
168 this->m_producer = std::make_shared<FaceProducer>(engine->renderer, engine->camera, engine->backgroundSize, engine->windowSize);
176 template <
typename T>
183 this->m_builder = std::make_shared<VertexBuilder<T>>(options->entities, options->entity2node);
184 this->m_producer = std::make_shared<VertexProducer>(engine->renderer, engine->camera, engine->backgroundSize, engine->windowSize);
192 template <
typename T>
199 this->m_builder = std::make_shared<EdgeBuilder<T>>(options->entities, options->entity2node);
200 this->m_producer = std::make_shared<EdgeProducer>(engine->renderer, engine->camera, engine->backgroundSize, engine->windowSize);
208 template <
typename T>
211 return std::make_shared<PassThroughFaceSelector<T>>(engine, options);
214 template <
typename T>
217 return std::make_shared<PassThroughVertexSelector<T>>(engine, options);
220 template <
typename T>
223 return std::make_shared<PassThroughEdgeSelector<T>>(engine, options);
Definition passthrough.h:194
PassThroughEdgeSelector(const std::shared_ptr< SelectorEngine > &engine, const std::shared_ptr< SelectorOptions< T > > &options)
Definition passthrough.h:196
virtual ~PassThroughEdgeSelector()
Definition passthrough.h:203
Definition passthrough.h:26
virtual ~PassThroughEntitySelector()
Definition passthrough.h:40
std::vector< std::shared_ptr< T > > multiSelect(int x1, int y1, int x2, int y2, int depth=0)
Definition passthrough.h:100
std::shared_ptr< EntityProducer > m_producer
Definition passthrough.h:29
PassThroughEntitySelector()
Definition passthrough.h:35
std::shared_ptr< EntityBuilder< T > > m_builder
Definition passthrough.h:28
virtual void setEntities(const std::shared_ptr< std::vector< std::shared_ptr< T > > > &entities)
Definition passthrough.h:58
std::vector< std::shared_ptr< T > > select(int x, int y, int depth=0)
Definition passthrough.h:64
virtual void update(SelectorUpdateMode mode)
Definition passthrough.h:44
Definition passthrough.h:162
virtual ~PassThroughFaceSelector()
Definition passthrough.h:171
PassThroughFaceSelector(const std::shared_ptr< SelectorEngine > &engine, const std::shared_ptr< SelectorOptions< T > > &options)
Definition passthrough.h:164
Definition passthrough.h:178
virtual ~PassThroughVertexSelector()
Definition passthrough.h:187
PassThroughVertexSelector(const std::shared_ptr< SelectorEngine > &engine, const std::shared_ptr< SelectorOptions< T > > &options)
Definition passthrough.h:180
SelectorUpdateMode
Definition selector.h:35
std::shared_ptr< PassThroughEdgeSelector< T > > _passThroughEdgeSelector(const std::shared_ptr< SelectorEngine > &engine, const std::shared_ptr< SelectorOptions< T > > &options)
Definition passthrough.h:221
std::shared_ptr< PassThroughVertexSelector< T > > _passThroughVertexSelector(const std::shared_ptr< SelectorEngine > &engine, const std::shared_ptr< SelectorOptions< T > > &options)
Definition passthrough.h:215
std::shared_ptr< std::vector< std::shared_ptr< Node > > > _nodes(const std::vector< std::shared_ptr< Node > > &nodes={})
std::shared_ptr< PassThroughFaceSelector< T > > _passThroughFaceSelector(const std::shared_ptr< SelectorEngine > &engine, const std::shared_ptr< SelectorOptions< T > > &options)
Definition passthrough.h:209