Rhino C++ API  9.0
Public Member Functions | Public Attributes | List of all members
ON_RayShooter Class Reference

#include <opennurbs_plus.h>

Public Member Functions

 ON_RayShooter ()
 
 ON_RayShooter (const ON_RayShooter &src)
 
void ConstructHelper ()
 
ON_RayShooteroperator= (const ON_RayShooter &src)
 
bool SetRayHelper (ON_3dPoint P, ON_3dPoint Q)
 
bool Shoot (const ON_3dPoint &P, const ON_3dVector &D, const class ON_BrepFace *face, ON_X_EVENT &hit)
 
bool Shoot (const ON_3dPoint &P, const ON_3dVector &D, const ON_SimpleArray< const class ON_BrepFace * > &face_list, ON_X_EVENT &hit)
 
bool Shoot (const ON_3dPoint &P, const ON_3dVector &D, const ON_SimpleArray< const ON_Surface * > &surface_list, ON_X_EVENT &hit)
 
bool Shoot (const ON_3dPoint &P, const ON_3dVector &D, const ON_SimpleArray< const ON_SurfaceTreeNode * > &snode_list, ON_X_EVENT &hit)
 
bool Shoot (const ON_3dPoint &P, const ON_3dVector &D, const ON_Surface *surface, ON_X_EVENT &hit)
 
bool Shoot (const ON_3dPoint &P, const ON_3dVector &D, const ON_SurfaceTreeNode *snode, ON_X_EVENT &hit)
 
bool Shoot (ON_3dPoint P, ON_3dVector D, int face_count, const class ON_BrepFace *const *face_list, ON_X_EVENT &hit)
 
bool Shoot (ON_3dPoint P, ON_3dVector D, int snode_count, const ON_SurfaceTreeNode *const *snode_list, ON_X_EVENT &hit)
 
bool ShootRayHelper (const ON_SurfaceTreeNode *stree, double mins, double maxs, ON_X_EVENT &hit)
 

Public Attributes

ON_CurveTree m_curve_tree
 Workspace for holding ray information. More...
 
const class ON_BrepFacem_hit_face
 
ON_RAY_HIT_FILTER m_hit_filter
 
void * m_hit_filter_context
 Passed to m_hit_filter as its "context" argument. More...
 
const ON_SurfaceTreeNodem_hit_snode_root
 
double m_min_travel_distance
 
ON_CurveTreeBezier m_tree_bez
 

Constructor & Destructor Documentation

◆ ON_RayShooter() [1/2]

ON_RayShooter::ON_RayShooter ( )

◆ ON_RayShooter() [2/2]

ON_RayShooter::ON_RayShooter ( const ON_RayShooter src)

Member Function Documentation

◆ ConstructHelper()

void ON_RayShooter::ConstructHelper ( )

For expert users ...

◆ operator=()

ON_RayShooter& ON_RayShooter::operator= ( const ON_RayShooter src)

◆ SetRayHelper()

bool ON_RayShooter::SetRayHelper ( ON_3dPoint  P,
ON_3dPoint  Q 
)

◆ Shoot() [1/8]

bool ON_RayShooter::Shoot ( const ON_3dPoint P,
const ON_3dVector D,
const class ON_BrepFace face,
ON_X_EVENT hit 
)

Description: Shoot a ray at a brep face or collection of brep faces. Unlike the ON_Surface and ON_SurfaceTreeNode flavors above, these honor trimming: a hit on the part of the underlying surface that the face's trimming loops throw away is skipped and the ray keeps going. Parameters: P - [in] start point D - [in] direction of infinite ray face - [in] face_list - [in] Faces with no surface tree are ignored. hit - [in/out] If hit.m_type = ON_X_EVENT::csx_point and 0.0 < hit.m_a[0], then a new hit will be returned only if it is closer to the start of the ray. Returns: True if the ray hits a face. When true, m_hit_face is the face that was hit. Remarks: These install their own m_hit_filter for the duration of the call. A filter set by the caller is applied in addition to the trimming test, not replaced by it. Rhino 8 and earlier ignored trimming. Pass the face's SurfaceTree() to one of the ON_SurfaceTreeNode flavors above to get the old behavior.

◆ Shoot() [2/8]

bool ON_RayShooter::Shoot ( const ON_3dPoint P,
const ON_3dVector D,
const ON_SimpleArray< const class ON_BrepFace * > &  face_list,
ON_X_EVENT hit 
)

◆ Shoot() [3/8]

bool ON_RayShooter::Shoot ( const ON_3dPoint P,
const ON_3dVector D,
const ON_SimpleArray< const ON_Surface * > &  surface_list,
ON_X_EVENT hit 
)

◆ Shoot() [4/8]

bool ON_RayShooter::Shoot ( const ON_3dPoint P,
const ON_3dVector D,
const ON_SimpleArray< const ON_SurfaceTreeNode * > &  snode_list,
ON_X_EVENT hit 
)

◆ Shoot() [5/8]

bool ON_RayShooter::Shoot ( const ON_3dPoint P,
const ON_3dVector D,
const ON_Surface surface,
ON_X_EVENT hit 
)

Description: Shoot a ray at a surface or collection of surfaces. Parameters: P - [in] start point D - [in] direction of infinite ray surface - [in] suface_list - [in] snode -[in] snode_list - [in] hit - [in/out] If hit.m_type = ON_X_EVENT::csx_point and 0.0 < hit.m_a[0], then a new hit will be returned only if it closer to the start of the ray. Example: Shoot a ray at a collection of "mirrors" and let it reflect.

  ON_3dPoint P = ...; ///< ray starting point
  ON_3dVector D = ...; ///< ray direction
  int max_reflection_count = 100; ///< number of reflections
  ON_SimpleArray<const ON_Surface*> surface_list = ...;

/ polyline = path of reflected ray ON_Polyline polyline(m_max_bounce_count+1); polyline.Append(P);

/ shoot ... ON_RayShooter ray; ON_X_EVENT hit; ON_3dPoint Q; ON_3dVector V[3], N, T, R; double d; R = D; for ( i = 0; i < max_reflection_count; i++ ) { memset(&hit,0,sizeof(hit)); T = R; if ( !T.Unitize() ) break; if ( !ray.Shoot(Q,T,surface_list,hit) ) break; Q = hit.m_A[0]; polyline.Append(Q); if ( !hit.m_snodeB[0] ) break; hit.m_snodeB[0]->Evaluate(hit.m_b[0],hit.m_b[1],1,3,&V[0].x); N = ON_CrossProduct(V[1],V[2]); if ( !N.Unitize() ) break; d = N*T; R = T + (-2.0*d)*N; ///< R = reflection direction }

Returns: True if the ray hits a surface.

◆ Shoot() [6/8]

bool ON_RayShooter::Shoot ( const ON_3dPoint P,
const ON_3dVector D,
const ON_SurfaceTreeNode snode,
ON_X_EVENT hit 
)

◆ Shoot() [7/8]

bool ON_RayShooter::Shoot ( ON_3dPoint  P,
ON_3dVector  D,
int  face_count,
const class ON_BrepFace *const *  face_list,
ON_X_EVENT hit 
)

◆ Shoot() [8/8]

bool ON_RayShooter::Shoot ( ON_3dPoint  P,
ON_3dVector  D,
int  snode_count,
const ON_SurfaceTreeNode *const *  snode_list,
ON_X_EVENT hit 
)

◆ ShootRayHelper()

bool ON_RayShooter::ShootRayHelper ( const ON_SurfaceTreeNode stree,
double  mins,
double  maxs,
ON_X_EVENT hit 
)

Parameters: mins - [in] minimum normalized line parameter maxs - [in] maximum normalized line parameter

Member Data Documentation

◆ m_curve_tree

ON_CurveTree ON_RayShooter::m_curve_tree

Workspace for holding ray information.

◆ m_hit_face

const class ON_BrepFace* ON_RayShooter::m_hit_face

Set by the ON_BrepFace flavors of Shoot() to the face that was hit, or to null when nothing was hit. The other flavors always set this to null.

◆ m_hit_filter

ON_RAY_HIT_FILTER ON_RayShooter::m_hit_filter

Optional filter used to accept or reject candidate hits. When m_hit_filter is null, which is the default, every hit on the underlying surface is accepted. A rejected hit does not end the search - the ray keeps going.

◆ m_hit_filter_context

void* ON_RayShooter::m_hit_filter_context

Passed to m_hit_filter as its "context" argument.

◆ m_hit_snode_root

const ON_SurfaceTreeNode* ON_RayShooter::m_hit_snode_root

Set by Shoot() to the element of its snode_list that was hit, or to null when nothing was hit. Saves callers from keeping a map of surface tree serial numbers to surfaces.

◆ m_min_travel_distance

double ON_RayShooter::m_min_travel_distance

Minimum 3d distance the ray must travel from "P" before an intersection is considered a "hit".
The default is zero.

◆ m_tree_bez

ON_CurveTreeBezier ON_RayShooter::m_tree_bez