6#include <nlohmann/json.hpp>
73 Mat3d inertia{{{0.05236, 0, 0}, {0, 0.05236, 0}, {0, 0, 0.05236}}};
167 virtual double GetSize()
const;
202 Vec4d const &quat)
const;
207 virtual double GetSkin()
const;
270 virtual void SetSize(
double d);
275 virtual void SetSkin(
double sk);
330 virtual void SaveAsVTK(std::string
const &filename);
336 virtual void SaveAsSTL(std::string
const &filename);
388 virtual void Print();
static constexpr double PI
Definition utils_math.hpp:15
Class for working with STL models.
Definition stl_model.hpp:17
This class represents different types of shapes and performs various calculations on them.
Definition shape.hpp:15
virtual STLModel GetSTLModel(int num_nodes=200)
Gets the STL model of the shape instance.
Definition shape.cpp:342
virtual void InitFromJson(nlohmann::json const &js)
Initializes the shape instance from a JSON object.
Definition shape.cpp:34
virtual Vec3d SupportPoint(Vec3d const &dir)
Gets the support point in a given direction for the shape instance.
Definition shape.cpp:358
virtual VecXT< Vec3d > SupportPoints(Vec3d const &dir)
Gets the set of support points in a given direction for the shape instance.
Definition shape.cpp:365
std::string shape_name
Name of the shape instance.
Definition shape.hpp:57
double volume
Volume of the shape instance.
Definition shape.hpp:68
virtual void UpdateSurfaceNodes()
Initializes the surface nodes of the shape instance.
Definition shape.cpp:214
int surface_node_num
Number of nodes used for the contact solver.
Definition shape.hpp:121
virtual void UpdateRenderMesh(int num_nodes=200)
Initializes the surface mesh for rendering.
Definition shape.cpp:219
Vec3d bound_aabb_max
Maximum bounds of the AABB used for broad-phase contact detection.
Definition shape.hpp:99
virtual void SaveAsSTL(std::string const &filename)
Saves the shape instance as an STL file.
Definition shape.cpp:353
virtual double GetSkinFactor() const
Return skin factor of the shape.
Definition shape.cpp:170
bool use_surface_nodes
Determines whether to use nodes for the contact solver.
Definition shape.hpp:116
bool CheckConvexity()
Return the convexity of the shape.
Definition shape.cpp:207
virtual double GetBoundSphereRadius() const
Return the inertia of the shape.
Definition shape.cpp:126
std::string label
Label of the shape instance.
Definition shape.hpp:47
virtual void UpdateShapeProperties()
Initializes the shape properties of the shape instance.
Definition shape.cpp:223
bool is_convex
Determines whether the shape instance is convex or not.
Definition shape.hpp:104
virtual void Translate(Vec3d const &pos)
Translates the shape instance to a new position.
Definition shape.cpp:209
virtual double GetSkin() const
Return skin size of the shape.
Definition shape.cpp:168
virtual void DisableSurfaceNodes()
Disable the use of surface nodes.
Definition shape.cpp:294
virtual bool CheckPrincipal() const
Determines whether the shape is in principal configuration.
Definition shape.cpp:393
virtual double GetSurfaceNodeSpacing() const
Return spacing of surface nodes.
Definition shape.cpp:180
virtual void SetSurfaceNodes(VecXT< Vec3d > const &nodes)
Set the surface nodes of the shape.
Definition shape.cpp:308
virtual void Print()
Prints the properties of the shape instance.
Definition shape.cpp:402
double surface_node_spacing
Spacing between nodes used for the contact solver.
Definition shape.hpp:126
double skin_factor
Factor used to adjust the skin thickness.
Definition shape.hpp:89
virtual void EnableSurfaceNodes()
Enable the use of surface nodes.
Definition shape.cpp:284
virtual bool IsSurfaceNodesEnabled()
Check if the use of surface nodes is enabled.
Definition shape.cpp:296
bool use_customized_solver
Determines whether to use a customized contact solver or not.
Definition shape.hpp:110
virtual void SetSize(double d)
Sets the size of the shape instance.
Definition shape.cpp:228
virtual Vec3d SurfacePoint(Vec3d const &pos)
Calculates the surface point corresponding to an intruding node.
Definition shape.cpp:382
virtual void SetSkinFactor(double sk_factor)
Set skin size factor (skin = size by skin size factor) of the shape.
Definition shape.cpp:279
virtual double GetVolume() const
Return the volume of the shape.
Definition shape.cpp:118
virtual ~Shape()
Destructor for the Shape class.
Definition shape.cpp:412
virtual void SaveAsVTK(std::string const &filename)
Saves the shape instance as a VTK file.
Definition shape.cpp:348
double bound_sphere_radius
Radius of the bounding sphere used for broad-phase contact detection.
Definition shape.hpp:79
virtual double SignedDistance(Vec3d const &pos) const
Calculates the signed distance between a point and the shape instance.
Definition shape.cpp:373
virtual Shape * Clone() const
Clones the shape instance.
Definition shape.cpp:340
virtual bool CheckEnclose(Vec3d const &pos) const
Determines whether a given point is enclosed within the shape instance.
Definition shape.cpp:389
virtual void SetSkin(double sk)
Set skin size of the shape.
Definition shape.cpp:274
virtual double GetSurfaceNodeNum() const
Return number of surface nodes of the shape.
Definition shape.cpp:172
Type
Enumeration for different types of shapes.
Definition shape.hpp:20
@ coded_netsdf
Definition shape.hpp:36
@ num_shapes
Definition shape.hpp:37
@ plane
Definition shape.hpp:30
@ sphere
Definition shape.hpp:23
@ poly_super_quadrics
Definition shape.hpp:33
@ triangle
Definition shape.hpp:29
@ trimesh
Definition shape.hpp:25
@ spherical_harmonics
Definition shape.hpp:24
@ trimesh_convex
Definition shape.hpp:26
@ point_sphere
Definition shape.hpp:22
@ level_set
Definition shape.hpp:34
@ netsdf
Definition shape.hpp:35
@ ellipsoid
Definition shape.hpp:27
@ cylinder
Definition shape.hpp:31
@ poly_super_ellipsoid
Definition shape.hpp:32
@ polybezier
Definition shape.hpp:28
@ none
Definition shape.hpp:21
virtual std::tuple< Vec3d, Vec3d > GetBoundAABB() const
Gets the boundary AABB of the shape instance.
Definition shape.cpp:128
virtual nlohmann::json PackJson()
Packs the data of the shape instance into a JSON object.
Definition shape.cpp:7
const STLModel & GetRenderMesh() const
Return the surface mesh for rendering.
Definition shape.cpp:205
Vec3d GetInertiaPrincipal() const
Return the principal inertia of the shape.
Definition shape.cpp:122
Mat3d inertia
Inertia tensor of the shape instance.
Definition shape.hpp:73
static MatNd< 8, 3 > VerticesOfAABB(Vec3d const &bmin, Vec3d const &bmax)
Gets the vertices of the boundary AABB of the shape instance.
Definition shape.cpp:414
virtual void SetSurfaceNodeNum(int num)
Set number of surface nodes of the shape.
Definition shape.cpp:298
double skin
Skin thickness used for broad-phase contact detection.
Definition shape.hpp:84
VecXT< Vec3d > surface_nodes
Surface nodes of the shape instance used for the contact solver.
Definition shape.hpp:131
virtual VecXT< double > const & GetSurfaceNodeAreas() const
Return surface area associated with each surface node.
Definition shape.cpp:197
STLModel render_mesh
Surface mesh for rendering.
Definition shape.hpp:142
Vec3d bound_aabb_min
Minimum bounds of the AABB used for broad-phase contact detection.
Definition shape.hpp:94
Type shape_type
Type of the shape instance.
Definition shape.hpp:52
virtual VecXT< Vec3d > const & GetSurfaceNodes() const
Return surface nodes of the shape.
Definition shape.cpp:189
virtual void InitFromJsonFile(std::string const &js_file)
Initializes the shape instance from a JSON file.
Definition shape.cpp:102
virtual double GetSize() const
Return shape size, which is defined as the diameter of equal-volume sphere.
Definition shape.cpp:116
VecXT< double > surface_node_areas
Area associated with each surface node.
Definition shape.hpp:136
double size
Size and volume of the shape instance.
Definition shape.hpp:63
virtual Mat3d const & GetInertia() const
Return the inertia of the shape.
Definition shape.cpp:120
Definition bond_entry.hpp:7
std::array< std::array< double, 3 >, 3 > Mat3d
Definition utils_macros.hpp:22
std::vector< T > VecXT
Definition utils_macros.hpp:31
pos
Definition json_serilization.hpp:19
std::array< double, 3 > Vec3d
Definition utils_macros.hpp:18
std::array< std::array< double, Nc >, Nr > MatNd
Definition utils_macros.hpp:27
std::array< double, 4 > Vec4d
Definition utils_macros.hpp:19