AGX Dynamics  2.37.2.0
BrickInterop.h
Go to the documentation of this file.
1 #pragma once
2 
3 
5 #include <agx/String.h>
6 #include <agx/Referenced.h>
7 #include <agxSDK/Simulation.h>
8 
9 namespace agxBrick {
10 
18  AGXBRICK_EXPORT bool init(const agx::String& brickRoot, const agx::String& logLevel = "info", bool initPythonnet = true);
19 
22 
29  AGXBRICK_EXPORT bool loadBrickFile(agxSDK::Simulation *target, const agx::String& filePath, const agx::String& model);
30 
38  agxSDK::Simulation* simulation,
39  const agx::String& filePath,
40  const agx::String& model);
41 
44 
46  AGXBRICK_EXPORT bool parseBrickModelLoadingDeclaration(const agx::String& declaration, agx::String& filepath, agx::String& modelname);
47 
48  // Interop of SWIG.Python and Brick.Pythonnet
52 
53  // Try and locate the Brick runtime resources
55 
58  public:
59  static BrickInterop* instance();
60 
61  public:
62  virtual bool init(const agx::String& agxBrickDistDir, const agx::String& logLevel, bool initPythonnet) = 0;
63  virtual void setLogLevel(const agx::String& logLevel) = 0;
64  virtual bool loadBrickFile(agxSDK::Simulation *target, const agx::String& filePath, const agx::String& model) = 0;
65  virtual bool loadBrickFile(agxSDK::Assembly* target,
66  agxSDK::Simulation* simulation,
67  const agx::String& filePath,
68  const agx::String& model) = 0;
69  virtual bool syncBrickInputs( agxSDK::Simulation* target ) = 0;
70  virtual bool syncBrickOutputs( agxSDK::Simulation* target ) = 0;
71 
72  // Allow sharing pythonnet instances
73  virtual bool registerAgxSimulation(agxSDK::Simulation *target, const agx::String& name) = 0;
74  virtual bool unregisterAgxSimulation(const agx::String& name) = 0;
76 
77  protected:
78  // virtual ~BrickInterop() override = 0;
79  virtual ~BrickInterop() override {};
80  };
81 
82  // Will be called from C# application when launching from dotnet directly, instead of the embedded dotnet runtime
84 
85 
86  // To be used by non-embedded C# runtime
88  public:
89  static agxSDK::Simulation* createSimulation();
90  private:
91  BrickInteropHost() = default;
92  };
93 
94  // Special struct to pass .NET implementation back to C++ during bootstraping
97  };
98 }
Interface to the Brick data and modelling format for simulation and engineering workflows.
AGXBRICK_EXPORT bool unregisterAgxSimulation(const agx::String &name)
AGXBRICK_EXPORT bool loadBrickFile(agxSDK::Simulation *target, const agx::String &filePath, const agx::String &model)
Load a Brick model from file into a target simulation.
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
virtual ~BrickInterop() override
Definition: BrickInterop.h:79
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGXBRICK_EXPORT bool registerAgxSimulation(agxSDK::Simulation *target, const agx::String &name)
AGXBRICK_EXPORT bool syncBrickOutputs(agxSDK::Simulation *target)
#define AGXBRICK_EXPORT
AGXBRICK_EXPORT bool parseBrickModelLoadingDeclaration(const agx::String &declaration, agx::String &filepath, agx::String &modelname)
Parsing of composite brick model path syntax, eg path/to/modelfile.yml:modelname
AGXBRICK_EXPORT bool syncBrickInputs(agxSDK::Simulation *target)
AGXBRICK_EXPORT bool init(const agx::String &brickRoot, const agx::String &logLevel="info", bool initPythonnet=true)
Initialize the embedded Brick .NET runtime.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
AGXBRICK_EXPORT bool isInitialized()
AGXBRICK_EXPORT agx::String locateBrickRootFromEnvironment()
AGXBRICK_EXPORT void setInteropInstance(BrickInterop *instance)
AGXBRICK_EXPORT agxSDK::Simulation * getRegisteredAgxSimulation(const agx::String &name)
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:66