AGX Dynamics  2.35.0.1
AddedMassDb.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXMODEL_ADDEDMASSDB_H
18 #define AGXMODEL_ADDEDMASSDB_H
19 
20 #include <agxModel/export.h>
22 
23 #include <agx/Vec6.h>
24 
25 #include <agxCollide/Mesh.h>
26 
29 #include <agxStream/InputArchive.h>
30 
31 namespace agxModel
32 {
33  class WindAndWaterParameters;
34 
39  {
40  public:
45 
46  public:
52 
57 
58  public:
63  {
64  Report( agx::Bool validIn, agx::Real executionTimeIn ) : valid( validIn ), executionTime( executionTimeIn ) {}
67  };
68 
69  public:
73  agxModel::AddedMassStorage::Report create( const agxCollide::Mesh* mesh, const agx::Vec3& localCenterOfMassPosition );
74 
79 
84 
88  agx::Bool equals( const agxModel::AddedMassStorage* other, agx::Real threshold = agx::Real( 0 ) ) const;
89 
94 
99 
104 
105  protected:
106  friend class AddedMassDb;
111 
115  virtual ~AddedMassStorage();
116 
120  void allocate( agx::UInt numElements );
121 
122  private:
123  PhiContainer m_phi;
124  NormalTangentContainer m_normalsTangents;
125  Identifier m_id;
126  };
127 
129 
134  {
135  public:
146 
147  public:
152 
158 
167 
173 
178  agx::Bool save( agxModel::AddedMassStorage* storage, const agx::String& filename );
179 
183  virtual void store( agxStream::OutputArchive& out ) const;
184 
189 
190  protected:
192 
193  protected:
197  virtual ~AddedMassDb();
198 
199  private:
200  AddedMassStorageContainer m_storage;
201  };
202 
204 
206 }
207 
208 #endif // AGXMODEL_ADDEDMASSDB_H
#define AGXMODEL_EXPORT
Class for more intuitive access to the Mesh's mesh data.
Definition: Mesh.h:79
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Definition: Mesh.h:70
Holder/manager of added mass storages.
Definition: AddedMassDb.h:134
agxModel::AddedMassStorage * load(const agx::String &filename)
Reloads a file and updates the storage identifier if it exist.
virtual void store(agxStream::OutputArchive &out) const
Internal method.
AddedMassDb()
Default constructor.
agxModel::AddedMassStorage * getOrCreateStorage(const agx::String &filename, const agxModel::WindAndWaterParameters *parameters)
Returns already loaded storage or loads existing file.
const agxModel::AddedMassStorage * getStorage(agxModel::AddedMassStorage::Identifier id) const
virtual ~AddedMassDb()
Reference counted object, protected destructor.
agx::HashVector< AddedMassStorage::Identifier, AddedMassStorageRef > AddedMassStorageContainer
Definition: AddedMassDb.h:191
virtual void restore(agxStream::InputArchive &in)
Internal method.
static agxModel::AddedMassStorageRef createStorage(const agxModel::WindAndWaterParameters *parameters, agxModel::AddedMassStorage::Identifier identifier)
Creates new storage given shape.
agx::Bool save(agxModel::AddedMassStorage *storage, const agx::String &filename)
Saves storage to file.
Storage that holds data needed for added mass calculations.
Definition: AddedMassDb.h:39
static agx::Bool isValid(agxModel::AddedMassStorage::Identifier id)
const agxModel::AddedMassStorage::PhiContainer & getFlowData() const
virtual ~AddedMassStorage()
Reference counted object, protected destructor.
agx::VectorPOD< agx::Vec6 > NormalTangentContainer
Definition: AddedMassDb.h:43
static agxModel::AddedMassStorage::Identifier createIdentifier(const agx::String &name)
Creates an identifier given name (normally path + filename) used to identify added mass storages.
AddedMassStorage(agxModel::AddedMassStorage::Identifier identifier)
Construct given identifier.
const agxModel::AddedMassStorage::NormalTangentContainer & getNormalTangentData() const
agx::Bool equals(const agxModel::AddedMassStorage *other, agx::Real threshold=agx::Real(0)) const
Mostly for debug purposes.
agxModel::AddedMassStorage::Identifier getIdentifier() const
agxModel::AddedMassStorage::Report restore(agxStream::StorageStream &str)
Restore data from stream.
agxModel::AddedMassStorage::Report create(const agxCollide::Mesh *mesh, const agx::Vec3 &localCenterOfMassPosition)
Create/calculate data given mesh and center of mass position given in mesh coordinate frame.
agxModel::dense::Vector Phi
Definition: AddedMassDb.h:41
agxModel::AddedMassStorage::Report store(agxStream::StorageStream &str) const
Store data to stream.
agx::Vector< Phi > PhiContainer
Definition: AddedMassDb.h:42
void allocate(agx::UInt numElements)
Allocate internal structure given the number of elements (triangles).
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
Base class providing referencing counted objects.
Definition: Referenced.h:114
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
agx::ref_ptr< AddedMassDb > AddedMassDbRef
Definition: AddedMassDb.h:203
agx::ref_ptr< AddedMassStorage > AddedMassStorageRef
Definition: AddedMassDb.h:128
AGXMODEL_EXPORT agx::Vec3 getCenter(const agxCollide::Mesh::Triangle &triangle)
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
uint32_t UInt32
Definition: Integer.h:40
bool Bool
Definition: Integer.h:48
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
Report from creation, store and restore.
Definition: AddedMassDb.h:63
Report(agx::Bool validIn, agx::Real executionTimeIn)
Definition: AddedMassDb.h:64