AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
RaytraceOutputHandler.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16#pragma once
21
22#include <agx/HashTable.h>
23
24namespace agxSensor
25{
26 class RtNodeGroupHandler;
27
29
35 {
36 public:
38 {
39 RAYTRACING = 1 << 0,
40 FETCHING_DATA = 1 << 1,
41 RESTORED = 1 << 2
42 };
43
44 using RuntimeState = agx::AtomicState<RuntimeFlag>;
45
46 public:
51
60 bool add( size_t uniqueId, RtOutput* output );
61
68 template<typename T, RtOutput::Field... field>
69 RtOutput* add();
70
76 RtOutput* get( size_t uniqueId );
77
83 ISensorOutput* getBase( size_t uniqueId ) override;
84
90 template<typename T>
91 RtOutput* get();
92
99 template<typename T>
100 BinaryOutputView<T> view();
101
110 void setRaytraceDepth( size_t steps = 1 );
111
115 size_t getRaytraceDepth() const;
116
121 void setAmbientHitSeed( agx::UInt32 seed = 783u );
122
127
135 void setEnableRemoveRayMisses( bool enable );
136
142
148 bool add( RtOutputNoise* noise );
149
157 bool remove( RtOutputNoise* noise );
158
163 bool contains( const RtOutputNoise* noise ) const;
164
169
171
172 public:
173 using ISensorOutputHandler::view;
174
175 public:
176
180 RtSystemNodeProxy* getProxy( const RtOutputNoise* noise ) const;
181
186 virtual void onParentConnect( RtSystemNode& parent ) override;
187
191 virtual void execute( const CallbackData& data ) override;
192
196 virtual void complete() override;
197
199
206 virtual bool insertParent( SystemNode& parent ) override;
207
208 protected:
212 virtual RtNode* createNode() final override;
213
215
216 private:
217 struct OutputNoiseData
218 {
219 RtOutputNoiseRef noise;
220 RtSystemNodeRef proxy;
221 };
222
223 bool tryAssembleLocalRtOutputChain();
224
225 private:
226 using OutputTable = agx::HashTable<size_t, RtOutputRef>;
227 using OutputNoiseDataVector = std::vector<OutputNoiseData>;
228
229 private:
230 RtNodeGroupHandler* getExitNode() const;
231
232 private:
233 OutputTable m_outputs;
234 RuntimeState m_runtimeState;
235 RtNode* m_parentNode;
236 size_t m_raytraceDepth;
237 RtNode* m_raytraceNode;
238 RtNode* m_beamDivergenceNode;
239 agx::UInt32 m_ambientHitSeed;
240 RtNode* m_assemblyNode;
241 RtRemoveRayMissesRef m_removeRayMisses;
242 OutputNoiseDataVector m_outputNoises;
243 };
244
245 template<typename T, RtOutput::Field... field>
247 {
248 RtOutputRef output = new RtOutput();
249 output->build<field...>();
250
251 if ( !RtOutput::template verifySize<T>( output->getElementSize() ) )
252 return nullptr;
253
254 if ( !this->add( RtOutput::template getTypeHash<T>(), output ) )
255 return nullptr;
256
257 return output;
258 }
259
260 template<typename T>
262 {
263 return this->get( RtOutput::template getTypeHash<T>() );
264 }
265
266 template<typename T>
268 {
269 return this->view<T>( RtOutput::template getTypeHash<T>() );
270 }
271}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXSENSOR_EXPORT
View for reading sections of a binary packed buffer of the specified template parameter type.
Common interface for sensor output handlers.
Common interface for sensor output data.
Definition: SensorOutput.h:27
This node doesn't have a representation in the raytrace graph but manages adding and removal of child...
Raytrace result handler is resposible for when and how the raytracing starts and ends and collecting/...
RtOutputHandler()
Default constructor.
size_t getRaytraceDepth() const
bool contains(const RtOutputNoise *noise) const
void setAmbientHitSeed(agx::UInt32 seed=783u)
Set the seed used to configure the pseudo-random generation the ambient/atmospheric hits.
agx::UInt32 getAmbientHitSeed() const
BinaryOutputView< T > view()
Directly access an output view of the raytrace output instance using a hash of the type with which it...
RtOutputNoiseRefVector getOutputNoises() const
ISensorOutput * getBase(size_t uniqueId) override
Access result instance given the unique id used when it was added.
bool add(RtOutputNoise *noise)
Add output noise instance to the system tree.
void setRaytraceDepth(size_t steps=1)
Configure the number of maximum raytrace steps.
agx::AtomicState< RuntimeFlag > RuntimeState
bool getEnableRemoveRayMisses() const
bool remove(RtOutputNoise *noise)
Remove output noise instance from the system tree.
RtOutput * add()
Build matching result to a given data type T.
void setEnableRemoveRayMisses(bool enable)
Enable/disable pruning of data for rays that doesn't hit any target.
RtOutput * get(size_t uniqueId)
Access result instance given the unique id used when it was added.
bool add(size_t uniqueId, RtOutput *output)
Add raytrace result given unique id, e.g., RtOutput::getTypeHash<MyData>().
RtOutput * get()
Access added result instance for the given data type T.
Defines a noise that is applied to Lidar output data.
Raytrace output data where RtOutput::Field defines the data available.
Raytrace system node acting as a clone of model specific implementations.
A system node focused on raytracing.
System node is a separate step/operation in an execution tree representing a sensor (or such) in a se...
Definition: SystemNode.h:44
Inheritance with partial specialization due to bug with ref_ptr containers.
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
uint32_t UInt32
Definition: Integer.h:32
A node performs a single operation, e.g., raycast, gaussian blur, merging etc.