PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
Environment.h
Go to the documentation of this file.
1
11
12#ifndef PBAT_SIM_CONTACT_ENVIRONMENT_H
13#define PBAT_SIM_CONTACT_ENVIRONMENT_H
14
15#include "MultibodyTetrahedralMeshSystem.h"
16#include "pbat/Aliases.h"
18#include "pbat/geometry/sdf/Forest.h"
19#include "pbat/io/Archive.h"
20
21#include <Eigen/Core>
22
23namespace pbat::sim::contact {
24
29template <common::CFloatingPoint TScalar = Scalar>
31{
32 public:
33 using ScalarType = TScalar;
35
39 Environment() = default;
45 Environment(SdfType sdf, Eigen::Index nPrimitives = 0);
50 void SetSdf(SdfType sdf);
55 void Reserve(Eigen::Index nPrimitives);
60 template <common::CIndex TIndex = Index>
66 Eigen::Index NumContactCandidates() const { return nCandidates; }
72 bool IsContactCandidate(Eigen::Index i) const { return mIsCandidate[i]; }
77 auto ContactCandidates() const { return mCandidates.head(nCandidates); }
82 void Serialize(io::Archive& archive) const;
87 void Deserialize(io::Archive const& archive);
88
89 Eigen::Vector<bool, Eigen::Dynamic>
91 Eigen::Vector<Eigen::Index, Eigen::Dynamic>
93 Eigen::Index nCandidates;
94 Eigen::Vector<ScalarType, Eigen::Dynamic>
97 Eigen::Matrix<ScalarType, 3, Eigen::Dynamic>
100 Eigen::Matrix<ScalarType, 3 * 3, Eigen::Dynamic>
106};
107
108} // namespace pbat::sim::contact
109
110#endif // PBAT_SIM_CONTACT_ENVIRONMENT_H
(De)serializer
Archive class for reading and writing data to HDF5 files.
Definition Archive.h:29
void SetSdf(SdfType sdf)
Set the signed distance field representing the environment.
void Serialize(io::Archive &archive) const
Serialize the environment to an archive.
bool IsContactCandidate(Eigen::Index i) const
Check if a primitive is a contact candidate.
Definition Environment.h:72
Eigen::Vector< bool, Eigen::Dynamic > mIsCandidate
|# primitives| whether each point is in contact
Definition Environment.h:90
Eigen::Vector< ScalarType, Eigen::Dynamic > mPhi
Definition Environment.h:95
Environment()=default
Construct a new Environment object.
Eigen::Index NumContactCandidates() const
Get the number of contact candidates.
Definition Environment.h:66
void DetectContactCandidates(MultibodyTetrahedralMeshSystem< TIndex, ScalarType > const &meshes)
Eigen::Index nCandidates
Number of active primitives.
Definition Environment.h:93
pbat::geometry::sdf::Forest< ScalarType > mSdf
Signed distance field representing the environment.
Definition Environment.h:105
TScalar ScalarType
Scalar type.
Definition Environment.h:33
Eigen::Vector< Eigen::Index, Eigen::Dynamic > mCandidates
|# primitives| indices of active primitives in [0, nCandidates)
Definition Environment.h:92
Eigen::Matrix< ScalarType, 3, Eigen::Dynamic > mPoint
Definition Environment.h:98
auto ContactCandidates() const
Get the contact candidates.
Definition Environment.h:77
void Reserve(Eigen::Index nPrimitives)
Reserve space for contact primitives.
Environment(SdfType sdf, Eigen::Index nPrimitives=0)
Construct a new Environment object.
void Deserialize(io::Archive const &archive)
Deserialize the environment from an archive.
Eigen::Matrix< ScalarType, 3 *3, Eigen::Dynamic > mBasis
Definition Environment.h:101
Concepts for common types.
Namespace for contact detection algorithms.
Definition Constraints.cpp:3
CPU storage for a forest (of SDFs).
Definition Forest.h:22
Multibody Tetrahedral Mesh System.
Definition MultibodyTetrahedralMeshSystem.h:26