AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Deformable1DGeometryFactory.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#ifndef AGXMODEL_DEFORMABLE1DGEOMETRYFACTORY_H
18#define AGXMODEL_DEFORMABLE1DGEOMETRYFACTORY_H
19
21
22#include <agxCollide/Sphere.h>
23
26
27namespace agxModel
28{
34
74
121
125 template< typename T >
127 {
128 public:
134
139
140 public:
147
151 virtual agx::Real getWidth(const agxModel::Deformable1DNode* node) const override;
152
156 virtual agx::Real getHeight(const agxModel::Deformable1DNode* node) const override;
157
158 void store( agxStream::OutputArchive& out ) const override;
159 void restore( agxStream::InputArchive& in ) override;
160
161 protected:
166
171
172 protected:
174 };
175
176#ifdef SWIG
177 %template(Deformable1DRadiusGeometryFactoryCapsule) agxModel::Deformable1DRadiusGeometryFactory<agxCollide::Capsule>;
178 %template(Deformable1DRadiusGeometryFactoryCylinder) agxModel::Deformable1DRadiusGeometryFactory<agxCollide::Cylinder>;
179 %template(Deformable1DRadiusGeometryFactorySphere) agxModel::Deformable1DRadiusGeometryFactory<agxCollide::Sphere>;
180#endif
181
213
239
271
272 template< typename T >
276
277 template< typename T >
282
283 template< typename T >
287
288 template< typename T >
290 {
291 return m_radius;
292 }
293
294 template< typename T >
296 {
297 return agx::Real( 2 ) * getRadius();
298 }
299
300 template< typename T >
302 {
303 return agx::Real( 2 ) * getRadius();
304 }
305
306 template<>
308 {
309 if ( node == nullptr )
310 return agxCollide::GeometryRef( nullptr );
311
312 // Maybe input?
313 const agx::Real offset = getRadius();
314
315 const agx::UInt numSpheres = std::max( agx::UInt( node->getLength() / offset + agx::Real( 0.5 ) ), agx::UInt( 1 ) );
316 const agx::Real dl = node->getLength() / agx::Real( numSpheres );
318 agx::Vec3 pos( 0, 0, 0 );
320 for ( agx::UInt i = 0; i < numSpheres; ++i ) {
321 geometry->add( new agxCollide::Sphere( getRadius() ), agx::AffineMatrix4x4::translate( pos ) );
322 pos += dl * dir;
323 }
324
325 return geometry;
326 }
327
328 template< typename T >
330 {
331 if ( node == nullptr )
332 return agxCollide::GeometryRef( nullptr );
333
334 agxCollide::GeometryRef geometry = new agxCollide::Geometry( new T( getRadius(), node->getLength() ) );
335 geometry->setLocalTransform( agx::AffineMatrix4x4::rotate( agx::Vec3::Y_AXIS(), agx::Vec3::Z_AXIS() ) *
337
338 return geometry;
339 }
340
341 template< typename T >
343 {
344 out << agxStream::out( "radius", m_radius );
345 }
346
347 template< typename T >
349 {
350 in >> agxStream::in( "radius", m_radius );
351 }
352}
353
354#endif // AGXMODEL_DEFORMABLE1DGEOMETRYFACTORY_H
#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...
#define AGXMODEL_EXPORT
The geometry representation used by the collision detection engine.
Definition Geometry.h:92
A sphere class for geometric intersection tests.
Definition Sphere.h:32
Geometry factor for boxes of given width and height.
virtual agx::Real getWidth(const agxModel::Deformable1DNode *node) const override
virtual agxCollide::GeometryRef createGeometry(const agxModel::Deformable1DNode *node) override
virtual ~Deformable1DBoxGeometryFactory()
Reference counted object, protected destructor.
virtual agx::Real getHeight(const agxModel::Deformable1DNode *node) const override
Deformable1DBoxGeometryFactory(agx::Real width, agx::Real height)
Construct given width and height.
Deformable1DBoxGeometryFactory()
Default constructor for serialization.
Geometry factory that creates Capsules with given radius.
Deformable1DCapsuleGeometryFactory(agx::Real radius)
Construct given radius.
Deformable1DCapsuleGeometryFactory()
Default constructor for serialization.
virtual ~Deformable1DCapsuleGeometryFactory()
Reference counted object, protected destructor.
virtual agx::Real getOverlappingDistance(const agxModel::Deformable1DNode *node) const override
Geometry factory that creates Cylinders with given radius.
Deformable1DCylinderGeometryFactory()
Default constructor for serialization.
Deformable1DCylinderGeometryFactory(agx::Real radius)
Construct given radius.
virtual ~Deformable1DCylinderGeometryFactory()
Reference counted object, protected destructor.
Geometry factory is an object that spawns geometries for a Deformable1D object.
virtual agxCollide::GeometryRef createGeometry(const agxModel::Deformable1DNode *node)=0
Create geometry for given node.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agxModel::Deformable1DGeometryFactory)
virtual agx::Real getHeight(const agxModel::Deformable1DNode *node) const =0
virtual ~Deformable1DGeometryFactory()
Reference counted object, protected destructor.
virtual agx::Real getWidth(const agxModel::Deformable1DNode *node) const =0
virtual agx::Real getOverlappingDistance(const agxModel::Deformable1DNode *) const
Characteristic overlapping distance, i.e., the distance the shape extends the shape definition.
Special node implementation of segments in e.g., a Deformable1D object.
agx::Real getLength() const
General geometry factory for shapes where width = height = radius.
virtual agxCollide::GeometryRef createGeometry(const agxModel::Deformable1DNode *node) override
Create a geometry with given shape for node.
Deformable1DRadiusGeometryFactory(agx::Real radius)
Constraint given radius = width = height.
virtual ~Deformable1DRadiusGeometryFactory()
Reference counted object, protected destructor.
virtual agx::Real getWidth(const agxModel::Deformable1DNode *node) const override
Deformable1DRadiusGeometryFactory()
Default constructor for serialization.
void store(agxStream::OutputArchive &out) const override
virtual agx::Real getHeight(const agxModel::Deformable1DNode *node) const override
void restore(agxStream::InputArchive &in) override
Geometry factory that creates Spheres with given radius.
virtual ~Deformable1DSphereGeometryFactory()
Reference counted object, protected destructor.
virtual agx::Real getOverlappingDistance(const agxModel::Deformable1DNode *node) const override
Deformable1DSphereGeometryFactory(agx::Real radius)
Construct given radius.
Deformable1DSphereGeometryFactory()
Default constructor for serialization.
Class for reading a binary stream of serialized data.
Class for writing serialized data in binary format to a stream.
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
static AffineMatrix4x4T< Real > rotate(const Vec3T< Real > &from, const Vec3T< Real > &to)
Return a matrix which rotate a vector from from to to.
static AffineMatrix4x4T< Real > translate(const Vec3T< Real > &dv)
Return a matrix which translates according to dv.
Base class providing referencing counted objects.
Definition Referenced.h:120
static Vec3T Y_AXIS()
static Vec3T Z_AXIS()
agx::ref_ptr< Geometry > GeometryRef
Definition Geometry.h:77
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition FlowUnit.h:37
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...
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.
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42