NetDEM v1.0
|
This class represents different types of shapes and performs various calculations on them. More...
#include <shape.hpp>
Public Types | |
enum | Type { none , point_sphere , sphere , spherical_harmonics , trimesh , trimesh_convex , ellipsoid , polybezier , triangle , plane , cylinder , poly_super_ellipsoid , poly_super_quadrics , level_set , netsdf , coded_netsdf , num_shapes } |
Enumeration for different types of shapes. More... | |
Public Member Functions | |
virtual nlohmann::json | PackJson () |
Packs the data of the shape instance into a JSON object. | |
virtual void | InitFromJson (nlohmann::json const &js) |
Initializes the shape instance from a JSON object. | |
virtual void | InitFromJsonFile (std::string const &js_file) |
Initializes the shape instance from a JSON file. | |
virtual double | GetSize () const |
Return shape size, which is defined as the diameter of equal-volume sphere. | |
virtual double | GetVolume () const |
Return the volume of the shape. | |
virtual Mat3d const & | GetInertia () const |
Return the inertia of the shape. | |
Vec3d | GetInertiaPrincipal () const |
Return the principal inertia of the shape. | |
virtual double | GetBoundSphereRadius () const |
Return the inertia of the shape. | |
virtual std::tuple< Vec3d, Vec3d > | GetBoundAABB () const |
Gets the boundary AABB of the shape instance. | |
virtual std::tuple< Vec3d, Vec3d > | GetBoundAABB (Vec3d const &pos, Vec4d const &quat) const |
Gets the boundary AABB of the shape instance. | |
virtual double | GetSkin () const |
Return skin size of the shape. | |
virtual double | GetSkinFactor () const |
Return skin factor of the shape. | |
virtual double | GetSurfaceNodeNum () const |
Return number of surface nodes of the shape. | |
virtual VecXT< Vec3d > const & | GetSurfaceNodes () const |
Return surface nodes of the shape. | |
virtual VecXT< double > const & | GetSurfaceNodeAreas () const |
Return surface area associated with each surface node. | |
virtual double | GetSurfaceNodeSpacing () const |
Return spacing of surface nodes. | |
const STLModel & | GetRenderMesh () const |
Return the surface mesh for rendering. | |
bool | CheckConvexity () |
Return the convexity of the shape. | |
virtual void | Translate (Vec3d const &pos) |
Translates the shape instance to a new position. | |
virtual void | UpdateSurfaceNodes () |
Initializes the surface nodes of the shape instance. | |
virtual void | UpdateRenderMesh (int num_nodes=200) |
Initializes the surface mesh for rendering. | |
virtual void | UpdateShapeProperties () |
Initializes the shape properties of the shape instance. | |
virtual void | SetSize (double d) |
Sets the size of the shape instance. | |
virtual void | SetSkin (double sk) |
Set skin size of the shape. | |
virtual void | SetSkinFactor (double sk_factor) |
Set skin size factor (skin = size by skin size factor) of the shape. | |
virtual void | EnableSurfaceNodes () |
Enable the use of surface nodes. | |
virtual void | DisableSurfaceNodes () |
Disable the use of surface nodes. | |
virtual bool | IsSurfaceNodesEnabled () |
Check if the use of surface nodes is enabled. | |
virtual void | SetSurfaceNodeNum (int num) |
Set number of surface nodes of the shape. | |
virtual void | SetSurfaceNodes (VecXT< Vec3d > const &nodes) |
Set the surface nodes of the shape. | |
virtual void | SetSurfaceNodes (STLModel const &surf_stl) |
Set the surface nodes of the shape. | |
virtual Shape * | Clone () const |
Clones the shape instance. | |
virtual STLModel | GetSTLModel (int num_nodes=200) |
Gets the STL model of the shape instance. | |
virtual void | SaveAsVTK (std::string const &filename) |
Saves the shape instance as a VTK file. | |
virtual void | SaveAsSTL (std::string const &filename) |
Saves the shape instance as an STL file. | |
virtual Vec3d | SupportPoint (Vec3d const &dir) |
Gets the support point in a given direction for the shape instance. | |
virtual VecXT< Vec3d > | SupportPoints (Vec3d const &dir) |
Gets the set of support points in a given direction for the shape instance. | |
virtual double | SignedDistance (Vec3d const &pos) const |
Calculates the signed distance between a point and the shape instance. | |
virtual Vec3d | SurfacePoint (Vec3d const &pos) |
Calculates the surface point corresponding to an intruding node. | |
virtual bool | CheckEnclose (Vec3d const &pos) const |
Determines whether a given point is enclosed within the shape instance. | |
virtual bool | CheckPrincipal () const |
Determines whether the shape is in principal configuration. | |
virtual void | Print () |
Prints the properties of the shape instance. | |
virtual | ~Shape () |
Destructor for the Shape class. | |
Static Public Member Functions | |
static MatNd< 8, 3 > | VerticesOfAABB (Vec3d const &bmin, Vec3d const &bmax) |
Gets the vertices of the boundary AABB of the shape instance. | |
Public Attributes | |
int | id {0} |
ID of the shape instance. | |
std::string | label {"default"} |
Label of the shape instance. | |
Type | shape_type {Type::none} |
Type of the shape instance. | |
std::string | shape_name {"shape"} |
Name of the shape instance. | |
bool | use_customized_solver {false} |
Determines whether to use a customized contact solver or not. | |
STLModel | render_mesh |
Surface mesh for rendering. | |
Protected Attributes | |
double | size {1.0} |
Size and volume of the shape instance. | |
double | volume {0.5236} |
Volume of the shape instance. | |
Mat3d | inertia {{{0.05236, 0, 0}, {0, 0.05236, 0}, {0, 0, 0.05236}}} |
Inertia tensor of the shape instance. | |
double | bound_sphere_radius {0.5} |
Radius of the bounding sphere used for broad-phase contact detection. | |
double | skin {0.025} |
Skin thickness used for broad-phase contact detection. | |
double | skin_factor {0.05} |
Factor used to adjust the skin thickness. | |
Vec3d | bound_aabb_min {-0.5, -0.5, -0.5} |
Minimum bounds of the AABB used for broad-phase contact detection. | |
Vec3d | bound_aabb_max {0.5, 0.5, 0.5} |
Maximum bounds of the AABB used for broad-phase contact detection. | |
bool | is_convex {true} |
Determines whether the shape instance is convex or not. | |
bool | use_surface_nodes {false} |
Determines whether to use nodes for the contact solver. | |
int | surface_node_num {1000} |
Number of nodes used for the contact solver. | |
double | surface_node_spacing {std::sqrt(Math::PI / 1000.0)} |
Spacing between nodes used for the contact solver. | |
VecXT< Vec3d > | surface_nodes |
Surface nodes of the shape instance used for the contact solver. | |
VecXT< double > | surface_node_areas |
Area associated with each surface node. | |
This class represents different types of shapes and performs various calculations on them.
enum netdem::Shape::Type |
|
virtual |
Destructor for the Shape class.
bool Shape::CheckConvexity | ( | ) |
Return the convexity of the shape.
|
virtual |
Determines whether a given point is enclosed within the shape instance.
pos | The point to test for enclosure. |
Reimplemented in netdem::Triangle.
|
virtual |
Determines whether the shape is in principal configuration.
|
virtual |
Clones the shape instance.
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
|
virtual |
Disable the use of surface nodes.
|
virtual |
Enable the use of surface nodes.
Gets the boundary AABB of the shape instance.
Reimplemented in netdem::Triangle.
Gets the boundary AABB of the shape instance.
pos | Position of the shape instance. |
quat | Quaternion orientation of the shape instance. |
Reimplemented in netdem::Plane, and netdem::Triangle.
|
virtual |
Return the inertia of the shape.
|
virtual |
Return the inertia of the shape.
Vec3d Shape::GetInertiaPrincipal | ( | ) | const |
Return the principal inertia of the shape.
STLModel const & Shape::GetRenderMesh | ( | ) | const |
Return the surface mesh for rendering.
|
virtual |
Return shape size, which is defined as the diameter of equal-volume sphere.
|
virtual |
Return skin size of the shape.
|
virtual |
Return skin factor of the shape.
|
virtual |
Gets the STL model of the shape instance.
num_nodes | Number of nodes to use for the STL model (default: 200). |
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
|
virtual |
Return surface area associated with each surface node.
|
virtual |
Return number of surface nodes of the shape.
Return surface nodes of the shape.
|
virtual |
Return spacing of surface nodes.
|
virtual |
Return the volume of the shape.
|
virtual |
Initializes the shape instance from a JSON object.
js | A JSON object containing the shape data. |
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
|
virtual |
Initializes the shape instance from a JSON file.
js_file | Path to the JSON file containing the shape data. |
|
virtual |
Check if the use of surface nodes is enabled.
|
virtual |
Packs the data of the shape instance into a JSON object.
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
|
virtual |
Prints the properties of the shape instance.
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, and netdem::TriMesh.
|
virtual |
Saves the shape instance as an STL file.
filename | Path to the STL file to save. |
|
virtual |
Saves the shape instance as a VTK file.
filename | Path to the VTK file to save. |
|
virtual |
Sets the size of the shape instance.
d | The new size of the shape instance. |
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::SphericalHarmonics, and netdem::TriMesh.
|
virtual |
Set skin size of the shape.
|
virtual |
Set skin size factor (skin = size by skin size factor) of the shape.
|
virtual |
Set number of surface nodes of the shape.
|
virtual |
Set the surface nodes of the shape.
Set the surface nodes of the shape.
|
virtual |
Calculates the signed distance between a point and the shape instance.
pos | The point to calculate the distance from. |
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
Gets the support point in a given direction for the shape instance.
dir | The direction in which to find the support point. |
Reimplemented in netdem::Cylinder, netdem::Ellipsoid, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::Triangle, and netdem::TriMesh.
Gets the set of support points in a given direction for the shape instance.
dir | The direction in which to find the support points. |
Reimplemented in netdem::Cylinder, netdem::Ellipsoid, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::Triangle, and netdem::TriMesh.
Calculates the surface point corresponding to an intruding node.
This method will be used to compute the contact point.
pos | The position of the intruding node. |
calculate the surface point corrsponding to a intruding node. It will be used to compute the contact point
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
|
virtual |
Translates the shape instance to a new position.
pos | The new position of the shape instance. |
Reimplemented in netdem::Triangle.
|
virtual |
Initializes the surface mesh for rendering.
num_nodes | Number of nodes to use for the STL model (default: 200). |
|
virtual |
Initializes the shape properties of the shape instance.
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::Polybezier, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
|
virtual |
Initializes the surface nodes of the shape instance.
Reimplemented in netdem::CodedNetSDF, netdem::Cylinder, netdem::Ellipsoid, netdem::LevelSet, netdem::NetSDF, netdem::Plane, netdem::PointSphere, netdem::PolySuperEllipsoid, netdem::PolySuperQuadrics, netdem::Sphere, netdem::SphericalHarmonics, netdem::Triangle, and netdem::TriMesh.
Gets the vertices of the boundary AABB of the shape instance.
|
protected |
Maximum bounds of the AABB used for broad-phase contact detection.
|
protected |
Minimum bounds of the AABB used for broad-phase contact detection.
|
protected |
Radius of the bounding sphere used for broad-phase contact detection.
int netdem::Shape::id {0} |
ID of the shape instance.
|
protected |
Inertia tensor of the shape instance.
|
protected |
Determines whether the shape instance is convex or not.
std::string netdem::Shape::label {"default"} |
Label of the shape instance.
STLModel netdem::Shape::render_mesh |
Surface mesh for rendering.
std::string netdem::Shape::shape_name {"shape"} |
Name of the shape instance.
Type netdem::Shape::shape_type {Type::none} |
Type of the shape instance.
|
protected |
Size and volume of the shape instance.
|
protected |
Skin thickness used for broad-phase contact detection.
|
protected |
Factor used to adjust the skin thickness.
|
protected |
Area associated with each surface node.
|
protected |
Number of nodes used for the contact solver.
|
protected |
Spacing between nodes used for the contact solver.
Surface nodes of the shape instance used for the contact solver.
bool netdem::Shape::use_customized_solver {false} |
Determines whether to use a customized contact solver or not.
|
protected |
Determines whether to use nodes for the contact solver.
|
protected |
Volume of the shape instance.