chrono::cascade::ChCascadeDoc Class Reference

Description

Class that contains an OCAF document (a tree hierarchy of shapes in the OpenCascade framework).

Most often this is populated by loading a STEP file from disk.

#include <ChCascadeDoc.h>

Public Member Functions

bool Load_STEP (const char *filename)
 Populate the document with all shapes that are contained in the STEP file, saved from some CAD. More...
 
void Dump (ChStreamOutAscii &mstream)
 Show shape hierarchy, writing on mstream (mstream could be GetLog() to print in default console log)
 
bool GetRootShape (TopoDS_Shape &mshape, const int num=1)
 Get the root shape. More...
 
bool GetNamedShape (TopoDS_Shape &mshape, char *name, bool set_location_to_root=true, bool get_multiple=false)
 Get a sub-shape with a given name, returned in 'mshape'. More...
 
void ScanCascadeShapes (callback_CascadeDoc &mcallback)
 Execute a callback on all contained shapes, with user-defined callback inherited from callback_CascadeDoc. More...
 

Static Public Member Functions

static bool GetVolumeProperties (const TopoDS_Shape &mshape, const double density, ChVector<> &center_position, ChVector<> &inertiaXX, ChVector<> &inertiaXY, double &volume, double &mass)
 Get the volume properties (center of mass, inertia moments, volume) of a given shape. More...
 
static void FromCascadeToChrono (const TopLoc_Location &from_coord, ChFrame<> &to_coord)
 Convert OpenCascade coordinates into Chrono coordinates.
 
static void FromChronoToCascade (const ChFrame<> &from_coord, TopLoc_Location &to_coord)
 Convert Chrono coordinates into OpenCascade coordinates.
 
static std::shared_ptr< ChBodyAuxRefCreateBodyFromShape (const TopoDS_Shape &mshape, const double density, const bool collide=false, const bool visual_asset=true)
 Create a ChBodyAuxRef with assets for the given TopoDS_Shape. More...
 

Member Function Documentation

◆ CreateBodyFromShape()

std::shared_ptr< ChBodyAuxRef > ChCascadeDoc::CreateBodyFromShape ( const TopoDS_Shape &  mshape,
const double  density,
const bool  collide = false,
const bool  visual_asset = true 
)
static

Create a ChBodyAuxRef with assets for the given TopoDS_Shape.

Parameters
mshapepass the shape here
densitypass the density here
collideif true, add a collision shape that uses the triangulation of shape
visual_assetif true, uses a triangulated shape for visualization

◆ GetNamedShape()

bool ChCascadeDoc::GetNamedShape ( TopoDS_Shape &  mshape,
char *  name,
bool  set_location_to_root = true,
bool  get_multiple = false 
)

Get a sub-shape with a given name, returned in 'mshape'.

Since the document can contain assembles, subassemblies etc, the name can use a 'directory type' syntax, using the / slash such as in "assembly/subassebmly/subsubassembly/mypart" It is possible to use # and ? wildcards as in Unix. If there are multiple parts (or assemblies) with the same name, only the first instance is returned in 'mshape'; otherwise, one can use the # wildcard to get the n-th object, for example "MyAssembly/bolt#3", "Car/Wheel#2/hub", etc. If the 'set_location_to_root' parameter is true (default), the location of the shape is changed so that it represents its position respect to the root, that is the shape .Location() function will give the absolute position, otherwise if false it will give its position relative to the assembly where it is a sub-shape. If the 'get_multiple' = true, if there are multiple parts satisfying the search string, they are all returned in a single shape of compound type (with null location).

◆ GetRootShape()

bool ChCascadeDoc::GetRootShape ( TopoDS_Shape &  mshape,
const int  num = 1 
)

Get the root shape.

Note that there could be more than one root, if so, use 'num' to select the one that you need.

◆ GetVolumeProperties()

bool ChCascadeDoc::GetVolumeProperties ( const TopoDS_Shape &  mshape,
const double  density,
ChVector<> &  center_position,
ChVector<> &  inertiaXX,
ChVector<> &  inertiaXY,
double &  volume,
double &  mass 
)
static

Get the volume properties (center of mass, inertia moments, volume) of a given shape.

Parameters
mshapepass the shape here
densitypass the density here
center_positionget the COG position center, respect to shape pos.
inertiaXXget the inertia diagonal terms
inertiaXYget the inertia extradiagonal terms
volumeget the volume
massget the mass

◆ Load_STEP()

bool ChCascadeDoc::Load_STEP ( const char *  filename)

Populate the document with all shapes that are contained in the STEP file, saved from some CAD.

If load was ok, return true.

◆ ScanCascadeShapes()

void ChCascadeDoc::ScanCascadeShapes ( callback_CascadeDoc &  mcallback)

Execute a callback on all contained shapes, with user-defined callback inherited from callback_CascadeDoc.

Btw. If the callback_CascadeDoc::ForShape callback returns false, subshapes are not processed.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_cascade/ChCascadeDoc.h
  • /builds/uwsbel/chrono/src/chrono_cascade/ChCascadeDoc.cpp