Project Chrono: chrono::particlefactory::ChRandomShapeCreatorFromFamilies Class Reference

Public Types | Public Member Functions | List of all members
chrono::particlefactory::ChRandomShapeCreatorFromFamilies Class Reference

## Description

Class for generating spheres from different families, each with given probability.

It 'mixes' different ChRandomShapeGenerator sources (among these you can also put other ChRandomShapeCreatorFromFamilies to create tree-like families). This can be used to make bi-modal or multi-modal distributions, for example suppose that you need a mixture of 30% spheres, with their own size distribution, and 70% cubes, with their own distribution.

`#include <ChRandomShapeCreator.h>`

Inheritance diagram for chrono::particlefactory::ChRandomShapeCreatorFromFamilies:
[legend]
Collaboration diagram for chrono::particlefactory::ChRandomShapeCreatorFromFamilies:
[legend]

## Public Types
enum | eChFamilyProbabilityMode { PARTICLE_PROBABILITY , MASS_PROBABILITY }

## Public Member Functions
virtual std::shared_ptr< ChBody > | RandomGenerate (ChCoordsys<> mcoords) override
| Function that creates a random ChBody particle each time it is called.
void | Reset ()
| Call this BEFORE adding a set of samples via AddSample().
void | AddFamily (std::shared_ptr< ChRandomShapeCreator > family_generator, double mprobability)
| Call this multiple times to add a set of samples.
void | Setup ()
| Call this when you finished adding samples via AddSample().
void | SetProbabilityMode (eChFamilyProbabilityMode mymode)
| Choose how the probability of each family must be considered: either in terms of number of particles, as by default, or either in terms of mass.
eChFamilyProbabilityMode | GetProbabilityMode ()
| Report if the probability of each family is in terms of n.of particles or mass.
std::vector< double > & | GetObtainedPercentuals ()
| For debugging.
Public Member Functions inherited from chrono::particlefactory::ChRandomShapeCreator
virtual std::shared_ptr< ChBody > | RandomGenerateAndCallbacks (ChCoordsys<> mcoords)
| This function does RandomGenerate and also executes the the custom callback, if provided.
void | RegisterAddBodyCallback (std::shared_ptr< AddBodyCallback > callback)
| Set the callback function to execute at each each particle generation.
void | SetAddCollisionShape (bool addcoll)
| Set if the created particles must include the collision shape(s).
void | SetAddVisualizationAsset (bool addvisual)
| Set if the created particles must include the visualization asset(s).

## Additional Inherited Members
Protected Attributes inherited from chrono::particlefactory::ChRandomShapeCreator
std::shared_ptr< AddBodyCallback > | callback_post_creation
bool | add_collision_shape
bool | add_visualization_asset

## Member Function Documentation

## ◆ AddFamily()

void chrono::particlefactory::ChRandomShapeCreatorFromFamilies::AddFamily | ( | std::shared_ptr< ChRandomShapeCreator > | family_generator,
|  | double | mprobability )
| inline

Call this multiple times to add a set of samples.

Each sample is a body with a given probability. Finally, use Setup() after you used AddSample N times The sum of probabilities should be 1; otherwise will be normalized.

## ◆ GetObtainedPercentuals()

std::vector< double > & chrono::particlefactory::ChRandomShapeCreatorFromFamilies::GetObtainedPercentuals | ( |  | ) |
| inline

For debugging.

For various reasons (ex. very odd masses in generated particles), especially with a small number of particles, the desired percentuals of masses or n.of particles for the families are only approximated. Use this vector to get the actual percentuals obtained so far.

## ◆ RandomGenerate()

virtual std::shared_ptr< ChBody > chrono::particlefactory::ChRandomShapeCreatorFromFamilies::RandomGenerate | ( | ChCoordsys<> | mcoords | ) |
| inlineoverridevirtual

Function that creates a random ChBody particle each time it is called.

Implements chrono::particlefactory::ChRandomShapeCreator.

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

- D:/W/B/src/chrono-9.0.1/src/chrono/particlefactory/ChRandomShapeCreator.h