NetDEM v1.0
Loading...
Searching...
No Matches
netdem::Polybezier Class Reference

A class representing a polybezier with variable orders and patches. More...

#include <shape_polybezier.hpp>

Inheritance diagram for netdem::Polybezier:
netdem::Shape

Public Member Functions

 Polybezier ()
 Default constructor.
 
nlohmann::json PackJson () override
 Pack the Polybezier object into a JSON structure.
 
void InitFromJson (nlohmann::json const &js) override
 Initialize the Polybezier object from a JSON structure.
 
ShapeClone () const override
 Clone the Polybezier object.
 
void InitByRandom ()
 Initialize the Polybezier object randomly.
 
void InitFromKernelSTL (std::string const &file)
 Initialize the Polybezier object from a kernel STL model read from file.
 
void InitFromKernelSTL (STLModel const &stl_model)
 Initialize the Polybezier object from a kernel STL model.
 
void Init ()
 Initialize the Polybezier object.
 
void UpdateShapeProperties () override
 Update the shape properties of the Polybezier object.
 
void SetSize (double d) override
 Set the size of the Polybezier object.
 
STLModel GetSTLModel (int num_nodes=200) override
 Generate an STL model for the Polybezier object.
 
STLModel GetSTLModel_v2 (int num_nodes=200)
 Generate an alternate version of the STL model for the Polybezier object.
 
void SaveNormalPatchesSpherical (std::string const &file)
 Save normal patches as a spherical mesh.
 
void SaveNormalPatchesCubic (std::string const &file)
 Save normal patches as a cubic mesh.
 
Vec3d SupportPoint (Vec3d const &dir) override
 Compute the support point of the Polybezier object in a given direction.
 
VecXT< Vec3dSupportPoints (Vec3d const &dir) override
 Compute the support points of the Polybezier object in a given direction.
 
void Print () override
 Print information about the Polybezier object.
 
- Public Member Functions inherited from netdem::Shape
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, Vec3dGetBoundAABB () const
 Gets the boundary AABB of the shape instance.
 
virtual std::tuple< Vec3d, Vec3dGetBoundAABB (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 STLModelGetRenderMesh () 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 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 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 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 ~Shape ()
 Destructor for the Shape class.
 

Public Attributes

int num_patches {30}
 
int order {2}
 
VecXT< VecXT< Vec3d > > face_patch_knots_list
 
VecXT< VecXT< Vec3d > > face_patch_normals_list
 
VecXT< VecXT< Vec3d > > edge_patch_knots_list
 
VecXT< Vec3ilinked_edges_list
 
VecXT< VecXT< int > > linked_patches_list
 
int num_cells {4}
 
- Public Attributes inherited from netdem::Shape
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.
 

Additional Inherited Members

- Public Types inherited from netdem::Shape
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...
 
- Static Public Member Functions inherited from netdem::Shape
static MatNd< 8, 3 > VerticesOfAABB (Vec3d const &bmin, Vec3d const &bmax)
 Gets the vertices of the boundary AABB of the shape instance.
 
- Protected Attributes inherited from netdem::Shape
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< Vec3dsurface_nodes
 Surface nodes of the shape instance used for the contact solver.
 
VecXT< double > surface_node_areas
 Area associated with each surface node.
 

Detailed Description

A class representing a polybezier with variable orders and patches.

This class provides methods for initializing, updating, and generating the Polybezier object using various sources such as kernel STL models or random initialization. It also implements operations such as computing support points and surface properties. The polybezier is defined by its patches which are represented by knot vectors as well as edge patches and face patches.

Examples
01_random_generation.cpp, 04_demo_normal_patches.cpp, 05_ave_num_linked_patches.cpp, and 81_voronoi_packing.cpp.

Constructor & Destructor Documentation

◆ Polybezier()

Polybezier::Polybezier ( )

Default constructor.

Member Function Documentation

◆ Clone()

Shape * Polybezier::Clone ( ) const
overridevirtual

Clone the Polybezier object.

This method creates a copy of the Polybezier object.

Returns
A pointer to the cloned Polybezier object.

Reimplemented from netdem::Shape.

◆ GetSTLModel()

STLModel Polybezier::GetSTLModel ( int num_nodes = 200)
overridevirtual

Generate an STL model for the Polybezier object.

This method generates an STLModel object representing the Polybezier object with the specified number of nodes for each surface triangle.

Parameters
num_nodesThe number of nodes to use for each surface triangle (default: 200).
Returns
An STLModel object representing the Polybezier object.

Reimplemented from netdem::Shape.

Examples
01_random_generation.cpp, 04_demo_normal_patches.cpp, 05_ave_num_linked_patches.cpp, and 81_voronoi_packing.cpp.

◆ GetSTLModel_v2()

STLModel Polybezier::GetSTLModel_v2 ( int num_nodes = 200)

Generate an alternate version of the STL model for the Polybezier object.

This method generates an alternate version of the STLModel object representing the Polybezier object with the specified number of nodes for each surface triangle.

Parameters
num_nodesThe number of nodes to use for each surface triangle (default: 400).
Returns
An STLModel object representing the alternate version of the Polybezier object.

◆ Init()

void Polybezier::Init ( )

Initialize the Polybezier object.

This method initializes the Polybezier object by updating its nodes and shape properties.

◆ InitByRandom()

void Polybezier::InitByRandom ( )

Initialize the Polybezier object randomly.

This method initializes the Polybezier object randomly by updating its nodes and shape properties.

Examples
01_random_generation.cpp.

◆ InitFromJson()

void Polybezier::InitFromJson ( nlohmann::json const & js)
overridevirtual

Initialize the Polybezier object from a JSON structure.

This method initializes the Polybezier object from a JSON structure previously generated by PackJson().

Parameters
jsThe JSON structure to load.

Reimplemented from netdem::Shape.

◆ InitFromKernelSTL() [1/2]

void netdem::Polybezier::InitFromKernelSTL ( std::string const & file)

Initialize the Polybezier object from a kernel STL model read from file.

This method initializes the Polybezier object from a kernel STL model read from file by updating its nodes and shape properties.

Parameters
fileThe name of the kernel STL model file.
Examples
04_demo_normal_patches.cpp, 05_ave_num_linked_patches.cpp, and 81_voronoi_packing.cpp.

◆ InitFromKernelSTL() [2/2]

void Polybezier::InitFromKernelSTL ( STLModel const & stl_model)

Initialize the Polybezier object from a kernel STL model.

This method initializes the Polybezier object from a kernel STL model by updating its nodes and shape properties.

Parameters
stl_modelThe kernel STL model to use.

◆ PackJson()

nlohmann::json Polybezier::PackJson ( )
overridevirtual

Pack the Polybezier object into a JSON structure.

This method packs the Polybezier object into a JSON structure for serialization and storage.

Returns
The packed JSON structure.

Reimplemented from netdem::Shape.

◆ Print()

void Polybezier::Print ( )
overridevirtual

Print information about the Polybezier object.

This method prints basic information about the Polybezier object, including its position, rotation, size, volume, and surface area.

Reimplemented from netdem::Shape.

◆ SaveNormalPatchesCubic()

void Polybezier::SaveNormalPatchesCubic ( std::string const & file)

Save normal patches as a cubic mesh.

This method saves the normal patches of the Polybezier object as a cubic mesh in an OBJ file.

Parameters
fileThe name of the output OBJ file.
Examples
04_demo_normal_patches.cpp.

◆ SaveNormalPatchesSpherical()

void Polybezier::SaveNormalPatchesSpherical ( std::string const & file)

Save normal patches as a spherical mesh.

This method saves the normal patches of the Polybezier object as a spherical mesh in an OBJ file.

Parameters
fileThe name of the output OBJ file.

◆ SetSize()

void Polybezier::SetSize ( double d)
overridevirtual

Set the size of the Polybezier object.

This method sets the size of the Polybezier object by updating its order and knot vectors. The new size is a scalar value that applies to all axes.

Parameters
dThe new size for the Polybezier object.

Reimplemented from netdem::Shape.

Examples
81_voronoi_packing.cpp.

◆ SupportPoint()

Vec3d Polybezier::SupportPoint ( Vec3d const & dir)
overridevirtual

Compute the support point of the Polybezier object in a given direction.

This method computes the support point of the Polybezier object in a given direction, which is the point on the surface farthest in the specified direction.

Parameters
dirThe direction in which to compute the support point.
Returns
The support point of the Polybezier object in the specified direction.

Reimplemented from netdem::Shape.

◆ SupportPoints()

VecXT< Vec3d > Polybezier::SupportPoints ( Vec3d const & dir)
overridevirtual

Compute the support points of the Polybezier object in a given direction.

This method computes the support points of the Polybezier object in a given direction, which are two opposite points on the surface farthest along the specified direction.

Parameters
dirThe direction in which to compute the support points.
Returns
A vector containing the two support points of the Polybezier object in the specified direction.

Reimplemented from netdem::Shape.

◆ UpdateShapeProperties()

void Polybezier::UpdateShapeProperties ( )
overridevirtual

Update the shape properties of the Polybezier object.

This method updates the shape properties of the Polybezier object, such as its volume and surface area.

Reimplemented from netdem::Shape.

Member Data Documentation

◆ edge_patch_knots_list

VecXT<VecXT<Vec3d> > netdem::Polybezier::edge_patch_knots_list

◆ face_patch_knots_list

VecXT<VecXT<Vec3d> > netdem::Polybezier::face_patch_knots_list

◆ face_patch_normals_list

VecXT<VecXT<Vec3d> > netdem::Polybezier::face_patch_normals_list

◆ linked_edges_list

VecXT<Vec3i> netdem::Polybezier::linked_edges_list

◆ linked_patches_list

VecXT<VecXT<int> > netdem::Polybezier::linked_patches_list

◆ num_cells

int netdem::Polybezier::num_cells {4}

◆ num_patches

int netdem::Polybezier::num_patches {30}

◆ order

int netdem::Polybezier::order {2}

The documentation for this class was generated from the following files: