AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Connector.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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
17#pragma once
18
19#include <agxModel/export.h>
20
24#include <agx/List.h>
25#include <agx/Vector.h>
26#include <agx/SetVector.h>
27#include <agxUtil/agxUtil.h>
29#include <agxPowerLine/Sides.h>
31#include <agx/LookupTables.h>
32
33namespace agxPowerLine
34{
35 class Unit;
36 class PowerLine;
37 class PhysicalDimensionMultiBodyConstraintImplementation;
38 class ElementaryPhysicalDimensionConstraint;
39
43
44 // Local typdef to avoid include loop.
47
53 {
54 public:
55
60
61 virtual void initConstraint();
62
63 virtual bool addNotification(agxSDK::Simulation* simulation) override;
64
68 virtual bool removeNotification(agxUtil::ConstraintHolder* holder, agxSDK::Simulation* simulation) override;
69
73 virtual bool connect(agxPowerLine::Unit* unit);
74
75 virtual bool connect(
76 agxPowerLine::Side mySide,
77 agxPowerLine::Side unitSide,
78 agxPowerLine::Unit* unit);
79
86 virtual bool disconnect(agxPowerLine::Unit* unit);
87
88 virtual bool disconnect();
89
90
91 virtual agxPowerLine::Side getSide(const agxPowerLine::Unit* unit) const;
92
93
95
97
102
107
109
111
116
117 // Get a hash vector with pointers to all units connected to this connector.
119 bool getInputUnits(UnitPtrSetVector& units, const bool startFromCleanUnitSet = true);
120 bool getOutputUnits(UnitPtrSetVector& units, const bool startFromCleanUnitSet = true);
121 bool getUnits(UnitPtrSetVector& units, agxPowerLine::Side side, const bool startFromCleanUnitSet = true);
122 bool getUnits(UnitPtrSetVector& units, const bool startFromCleanUnitSet = true);
123
124
125 // Get a hash vector with pointers to all units connected to this connector.
126 bool getInputUnits(UnitConstPtrSetVector& units, const bool startFromCleanUnitSet = true) const;
127 bool getOutputUnits(UnitConstPtrSetVector& units, const bool startFromCleanUnitSet = true) const;
128 bool getUnits(UnitConstPtrSetVector& units, agxPowerLine::Side side, const bool startFromCleanUnitSet = true) const;
129 bool getUnits(UnitConstPtrSetVector& units, const bool startFromCleanUnitSet = true) const;
130
131 static PhysicalDimension* getDimension(const ConnectionRefVector& connections, const PhysicalDimension::Type dimensionType);
134
139
144
149
154
155
159 int getNumConnections() const;
160
161 // All of these return -1 when the any number of connections is allowed.
166
170 bool hasFreeConnection() const;
171
176
181
182
187
192
197
202
206
207
211
216
221
226
231
233
241 agxPowerLine::ConnectionRefVector& getConnections(agxPowerLine::Side side);
243
248
254
259
264 agxPowerLine::ElementaryPhysicalDimensionConstraint* getElementaryConstraint() const;
265
269 virtual bool isOutput( Connection* connection ) const;
270
274 virtual bool isOutput(const agxPowerLine::PhysicalDimension* dimension ) const;
275
281 virtual bool isInput(const agxPowerLine::PhysicalDimension* dimension) const;
282
286 void setDamping(agx::Real damping);
287 agx::Real getDamping() const;
288
289
290 agx::Real getRatio() const;
291 agx::Real getRatioDerivative() const;
292
293 virtual agx::Real getRatio(agx::Real x) const;
294 virtual agx::Real getRatioDerivative(agx::Real x) const;
295
299 virtual agx::RegularizationParameters::VariableType calculateComplianceAndDamping(const agx::Real /*timeStep*/, agx::Real& /*compliance*/, agx::Real& /*damping*/);
300
301
305 virtual bool postStore( agxStream::StorageStream& str ) const;
306 virtual bool postRestore(agxStream::StorageStream& str);
307
311 virtual agx::Real getViolation() const;
312
313 void setPowerLine(agxPowerLine::PowerLine* powerLine);
314
315 agxPowerLine::PowerLine* getPowerLine() const;
316
317 bool connectDimensions(Unit* unit, agxPowerLine::Side mySide, agxPowerLine::Side unitSide);
318
323 bool connect(agxPowerLine::PhysicalDimension* dimension,
324 agxPowerLine::Side connectorSide,
325 agxPowerLine::Side dimensionSide);
326
327 virtual bool connect(agxPowerLine::PhysicalDimension* inputDimension,
328 agxPowerLine::Side inputSide,
329 agxPowerLine::Side outputSide,
330 agxPowerLine::PhysicalDimension* outputDimension);
331
332 bool disconnect(agxPowerLine::PhysicalDimension* dimension,
333 agxPowerLine::Side connectorSide,
334 agxPowerLine::Side dimensionSide);
335
336
337 bool isConstraintValid() const;
338
339 virtual bool vetoConnect(agxPowerLine::Unit* unit) const;
340
344 virtual bool store(agxStream::StorageStream& str) const override;
345
349 virtual bool restore(agxStream::StorageStream& str) override;
350
351 bool getIgnoreForStoreRestoreStream() const;
352 void setIgnoreForStoreRestoreStream(bool ignore);
353
355 virtual void store(agxStream::OutputArchive& out) const override;
356 virtual void restore(agxStream::InputArchive& in) override;
357
358 protected:
359
363 void setRatio(agx::Real ratio);
364 void setRatioDerivative(agx::Real ratioDerivative);
365
366 bool getUnits(UnitPtrSetVector& units, ConnectionRefVector& connections, const bool startFromCleanUnitSet = true);
367 bool getUnits(UnitConstPtrSetVector& units, const ConnectionRefVector& connections, const bool startFromCleanUnitSet = true) const;
368
369 bool hasNonValidInputConnection() const;
370 bool hasNonValidOutputConnection() const;
371
372// Swig tries to generate bindings to this protected connect member function
373// which leads to compiler errors since the function is protected.
374#ifndef SWIG
376 virtual bool connect(
377 agxPowerLine::Unit* inputUnit, agxPowerLine::Side inputUnitSide,
378 agxPowerLine::Side outputUnitSide, agxPowerLine::Unit* outputUnit);
379#endif
380
382 virtual ~Connector();
383
384 protected:
391
393
397
399 };
400
403
408
409}
410
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
#define AGXMODEL_EXPORT
Links two connections together.
Definition Connector.h:53
agxPowerLine::Connection * findConnection(const agxPowerLine::Unit *unit, agxPowerLine::Side side)
virtual bool connect(agxPowerLine::Unit *unit)
Connect a unit to this Connector.
bool hasInputConnection(Connection *connection)
Find out if the connection belongs to this connector.
int getNumOutputConnections() const
int getNumPossibleOutputConnections() const
bool getInputUnits(UnitPtrSetVector &units, const bool startFromCleanUnitSet=true)
const DimensionTypeVector & getInputTypes() const
const agxPowerLine::Connection * findOutputConnection(const agxPowerLine::Unit *unit) const
const DimensionTypeVector & getOutputTypes() const
void setNumPossibleOutputConnections(int num)
Define number of output dimensions the constraint should handle.
PhysicalDimensionMultiBodyConstraintImplementation * m_constraint
Definition Connector.h:396
bool getUnits(UnitConstPtrSetVector &units, const bool startFromCleanUnitSet=true) const
int getNumPossibleInputConnections() const
virtual bool connect(agxPowerLine::Side mySide, agxPowerLine::Side unitSide, agxPowerLine::Unit *unit)
DimensionTypeVector m_outputTypes
Definition Connector.h:390
ConnectionRefVector m_outputConnections
Definition Connector.h:388
bool hasFreeConnection() const
agxPowerLine::ConnectionRefVector & getInputConnections()
return vector to all input connections from this connector
bool compareWithInputTypes(PhysicalDimensionRefVector &dimensions) const
ConnectionRefVector m_inputConnections
Definition Connector.h:387
virtual bool addNotification(agxSDK::Simulation *simulation) override
const agxPowerLine::Connection * getInputConnection(size_t index) const
return a specific output connection
bool getUnits(UnitConstPtrSetVector &units, agxPowerLine::Side side, const bool startFromCleanUnitSet=true) const
const agxPowerLine::Connection * findInputConnection(const agxPowerLine::Unit *unit) const
bool hasOutputConnection(Connection *connection)
agx::Real getPowerOut() const
agx::Real m_ratioDerivative
Definition Connector.h:395
int getNumConnections(agxPowerLine::Side side) const
agxPowerLine::Connection * findOutputConnection(const agxPowerLine::Unit *unit)
agx::Real getPowerIn() const
bool hasFreeInputConnection() const
virtual bool disconnect(agxPowerLine::Unit *unit)
Disconnect the given unit from this Connector.
const agxPowerLine::ConnectionRefVector & getConnections(agxPowerLine::Side side) const
agxPowerLine::Connection * getInputConnection(size_t index)
return a specific input connection
bool getOutputUnits(UnitPtrSetVector &units, const bool startFromCleanUnitSet=true)
const DimensionTypeVector & getTypes(agxPowerLine::Side side) const
int getNumFreeConnections() const
virtual bool disconnect()
bool getUnits(UnitPtrSetVector &units, const bool startFromCleanUnitSet=true)
const agxPowerLine::Connection * findConnection(const agxPowerLine::Unit *unit, agxPowerLine::Side side) const
PhysicalDimension * getInputDimension(const PhysicalDimension::Type dimensionType) const
int getNumFreeConnections(agxPowerLine::Side side) const
virtual bool connect(agxPowerLine::Unit *inputUnit, agxPowerLine::Side inputUnitSide, agxPowerLine::Side outputUnitSide, agxPowerLine::Unit *outputUnit)
void setNumPossibleInputConnections(int num)
Define number of input dimensions the constraint should handle.
virtual void initConstraint()
PhysicalDimension * getOutputDimension(const PhysicalDimension::Type dimensionType) const
bool hasFreeConnection(agxPowerLine::Side side) const
bool getUnits(UnitPtrSetVector &units, agxPowerLine::Side side, const bool startFromCleanUnitSet=true)
virtual agx::Real calculateViolation() const
calculate violation for constraint
bool getInputUnits(UnitConstPtrSetVector &units, const bool startFromCleanUnitSet=true) const
agxPowerLine::ConnectionRefVector & getOutputConnections()
return vector to all output connections from this connector
int getNumFreeOutputConnections() const
int getNumConnections() const
virtual bool removeNotification(agxUtil::ConstraintHolder *holder, agxSDK::Simulation *simulation) override
remove connector and constraint from simulation
const agxPowerLine::Connection * getOutputConnection(size_t index) const
return a specific output connection
int getNumFreeInputConnections() const
Connector()
create a connector
DimensionTypeVector m_inputTypes
Definition Connector.h:389
bool hasFreeOutputConnection() const
bool getOutputUnits(UnitConstPtrSetVector &units, const bool startFromCleanUnitSet=true) const
bool compareWithOutputTypes(PhysicalDimensionRefVector &dimensions) const
const agxPowerLine::ConnectionRefVector & getInputConnections() const
return vector to all input connections from this connector
agx::Real calculateEfficiency() const
calculate simulated efficiency
int getNumInputConnections() const
agxPowerLine::Connection * findInputConnection(const agxPowerLine::Unit *unit)
virtual agxPowerLine::Side getSide(const agxPowerLine::Unit *unit) const
static PhysicalDimension * getDimension(const ConnectionRefVector &connections, const PhysicalDimension::Type dimensionType)
const agxPowerLine::ConnectionRefVector & getOutputConnections() const
return vector to all output connections from this connector
agxPowerLine::Connection * getOutputConnection(size_t index)
return a specific input connection
Constraint implementation for constraining a number of physical dimensions of the same type.
PowerLine is the base class for a system of power transfer integrated into the rigid body simulation.
Definition PowerLine.h:66
Pure virtual class.
Definition Unit.h:72
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Utility class to hold custom implementations of constraints.
Definition agxUtil.h:464
This class is a combined container which has the find complexity of a HashTable, deterministic iterat...
Definition SetVector.h:38
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
agxPowerLine contains a collection of connected components that transport power across a system.
Definition MotorUnit.h:24
agx::SetVector< Unit * > UnitPtrSetVector
Definition Connector.h:40
agx::SetVector< Connector * > ConnectorPtrSetVector
Definition Connector.h:402
agx::Vector< UnitRef > UnitRefVector
Definition Connector.h:46
agx::Vector< ConnectorObserver > ConnectorObserverVector
Definition Connector.h:407
agx::SetVector< const Unit * > UnitConstPtrSetVector
Definition Connector.h:41
agx::SetVector< ConnectorRef > ConnectorRefSet
Definition Connector.h:406
agx::Vector< ConnectorRef > ConnectorRefVector
Definition Connector.h:405
agx::ref_ptr< Unit > UnitRef
Definition Connector.h:45
agx::Vector< PhysicalDimension::Type > DimensionTypeVector
Definition Connector.h:42
agx::Vector< Connector * > ConnectorPtrVector
Definition Connector.h:401
agx::ref_ptr< Connector > ConnectorRef
Definition Connector.h:404
This namespace contain classes for streaming classes into archives, ASCII, binary for storage (serial...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition Real.h:42