Rhino C++ API  7.22
Public Types | Public Member Functions | Public Attributes | List of all members
CRhinoPickContext Class Reference

#include <rhinoSdkPick.h>

Public Types

enum  { no_pick = 0, point_pick = 1, window_pick = 2, crossing_pick = 3 }
 three styles of picking More...
 
enum  { wireframe_pick = 1, shaded_pick = 2 }
 picking can happen in wireframe or shaded display mode More...
 

Public Member Functions

 CRhinoPickContext ()
 
bool IsAcceptableCandidate (const class CRhinoObject *object, bool bIgnoreSelectionState=false, bool bIgnoreLocking=false, bool bIgnoreVisibility=false) const
 
bool PickBezier (const ON_BezierCurve &bezier_curve, double *t, double *depth, double *dist) const
 
bool PickBox (const ON_BoundingBox &bbox, bool *bBoxInsidePickFrustum=0) const
 
bool PickLight (const ON_Light &light, ON_3dPoint &hit_point, double *depth, double *dist) const
 
bool PickLine (const ON_Line &line, double *t, double *depth, double *dist) const
 
bool PickMesh (const ON_Mesh *mesh, const struct CRhinoPickContext_MeshEdgeInfo *edge_info, int pick_style, ON_3dPoint *hit_point, ON_2dPoint *hit_srf_uv, ON_2dPoint *hit_tex_st, double *depth, double *dist, int *vef_flag, int *vef_index) const
 
bool PickMesh (const ON_Mesh *mesh, int pick_style, ON_3dPoint *hit_point, ON_2dPoint *hit_srf_uv, ON_2dPoint *hit_tex_st, double *depth, double *dist, int *vef_flag, int *vef_index) const
 
bool PickNurbsCurve (const ON_NurbsCurve &nurbs_curve, double *t, double *depth, double *dist) const
 
bool PickPoint (const ON_3dPoint &point, double *depth, double *dist) const
 
bool PickPointCloud (int point_count, const ON_3dPoint *points, int *point_index, double *depth, double *dist) const
 
bool PickSegment (const ON_3dPoint points[2], const ON_3dPoint clip_points[2], const unsigned int clip_flags[2], ON_PickPoint &pick_point) const
 
bool PickSegment (const ON_3dPoint points[2], const ON_4dPoint clip_points[2], const unsigned int clip_flags[2], ON_PickPoint &pick_point) const
 
unsigned int PickSubD (ON_SubDMeshFragmentIterator subd_frit, const class CRhinoSubDPickSettings &subd_pick_settings, ON_SimpleArray< ON_SubDComponentPoint > &component_points) const
 
unsigned int PickSubDControlNet (const class ON_SubDRef subd_ref, const class CRhinoSubDPickSettings &subd_pick_settings, ON_SimpleArray< ON_SubDComponentPoint > &component_points) const
 
unsigned int PickSubDMeshFragment (ON_SubDComponentLocation subd_appearance, const class ON_SubDMeshFragment &subd_surface_mesh_fragment, const class CRhinoSubDPickSettings &subd_pick_settings, ON_SubDComponentPoint component_points[9]) const
 
bool PickTriangle (const ON_3dPoint points[3], const ON_3dPoint clip_points[3], const unsigned int clip_flags[3], ON_PickPoint &pick_point) const
 
bool PickTriangle (const ON_3dPoint points[3], const ON_4dPoint clip_points[3], const unsigned int clip_flags[3], ON_PickPoint &pick_point) const
 
ON_PickType PickType () const
 
bool SubDEdgeIsInsideWindowPick (ON_SubDComponentLocation subd_appearance, const class ON_SubDEdge *edge, const class ON_SubDMeshFragment &subd_surface_mesh_fragment) const
 
bool SubDFaceIsInsideWindowPick (ON_SubDComponentLocation subd_appearance, bool bWireframePick, const class ON_SubDFace *face, const class ON_SubDMeshFragment &subd_surface_mesh_fragment) const
 
void UpdateClippingPlanes ()
 

Public Attributes

bool m_bModelXformIsIdentity = true
 True if the m_model_xform is the identity. More...
 
bool m_bPickGroups = false
 true if CRhinoGroupObjects should be added to pick list More...
 
bool m_bSetClippingPlanes = true
 
bool m_bSkipSelected = true
 these flags are used in pre and post pick More...
 
bool m_bSkipUnselected = false
 
bool m_bSubSelect = false
 true if the user activated subobject selection More...
 
const class CRhinoGetObjectm_go = nullptr
 in pre-pick, m_go is NULL More...
 
ON_Xform m_model_xform
 
double m_model_xform_det = 1.0
 determinant of m_model_xform More...
 
ON_Line m_pick_line
 pick chord starts on near clipping plane and ends on far clipping plane More...
 
enum CRhinoPickContext:: { ... }  m_pick_mode = wireframe_pick
 picking can happen in wireframe or shaded display mode More...
 
ON_ClippingRegion m_pick_region
 
enum CRhinoPickContext:: { ... }  m_pick_style = point_pick
 three styles of picking More...
 
class CRhinoViewm_view = nullptr
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

three styles of picking

Enumerator
no_pick 
point_pick 
window_pick 
crossing_pick 

◆ anonymous enum

anonymous enum

picking can happen in wireframe or shaded display mode

Enumerator
wireframe_pick 
shaded_pick 

Constructor & Destructor Documentation

◆ CRhinoPickContext()

CRhinoPickContext::CRhinoPickContext ( )

Member Function Documentation

◆ IsAcceptableCandidate()

bool CRhinoPickContext::IsAcceptableCandidate ( const class CRhinoObject object,
bool  bIgnoreSelectionState = false,
bool  bIgnoreLocking = false,
bool  bIgnoreVisibility = false 
) const

Description: Tests an object to see if it is an acceptable candidate for being selected. This test is fast and completely answers all status questions. If IsAcceptableCandidate() returns true, then the only thing left to test is intersecting the pick frustrum with the object. Parameters: object - [on] object to test bIgnoreSelectionState - [in] if true, current selection state is ignored. If false (default), then selected objects are NOT acceptable. bIgnoreLocking - [in] If true, locked objects and objects on locked layers are acceptable. If false (default), then locked objects and objects on locked layers are not acceptable. bIgnoreVisibility - [in] If true, hidden objects and objects on hidden layers are acceptable. If false (default), then hidden objects and objects on hidden layers are not acceptable.

Returns: Returns true if object is an acceptable candidate for being selected

◆ PickBezier()

bool CRhinoPickContext::PickBezier ( const ON_BezierCurve bezier_curve,
double *  t,
double *  depth,
double *  dist 
) const

Description: Utility for picking bezier curves Parameters: bezier_curve - [in] t - [out] line parameter returned here for point picks depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point Returns: true if there is a hit.

◆ PickBox()

bool CRhinoPickContext::PickBox ( const ON_BoundingBox bbox,
bool *  bBoxInsidePickFrustum = 0 
) const

Description: Fast test to check if a bounding box intersects a pick frustum. Parameters: bbox - [in] bounding box bBoxInsidePickFrustum - [out] if not NULL, then *bBoxInsidePickFrustum is set to true if the box is completely contained in the pick frustum.
When doing a window or crossing pick, you can immediately return a hit if the object's bounding box is completely inside of the pick frustum. Returns: False if bbox is invalid or box does not intersect the pick frustum

◆ PickLight()

bool CRhinoPickContext::PickLight ( const ON_Light light,
ON_3dPoint hit_point,
double *  depth,
double *  dist 
) const

Description: Utility for picking meshes Parameters: light - [in] hit_point - [out] location returned here for point picks depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point Returns: true if there is a hit.

◆ PickLine()

bool CRhinoPickContext::PickLine ( const ON_Line line,
double *  t,
double *  depth,
double *  dist 
) const

Description: Utility for picking 3d line Parameters: line - [in] t - [out] line parameter returned here for point picks depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point Returns: true if there is a hit.

◆ PickMesh() [1/2]

bool CRhinoPickContext::PickMesh ( const ON_Mesh mesh,
const struct CRhinoPickContext_MeshEdgeInfo edge_info,
int  pick_style,
ON_3dPoint hit_point,
ON_2dPoint hit_srf_uv,
ON_2dPoint hit_tex_st,
double *  depth,
double *  dist,
int *  vef_flag,
int *  vef_index 
) const

◆ PickMesh() [2/2]

bool CRhinoPickContext::PickMesh ( const ON_Mesh mesh,
int  pick_style,
ON_3dPoint hit_point,
ON_2dPoint hit_srf_uv,
ON_2dPoint hit_tex_st,
double *  depth,
double *  dist,
int *  vef_flag,
int *  vef_index 
) const

Description: Utility for picking meshes Parameters: mesh - [in] edge_info - [in] (can be null) If not null, edge_info for wireframe picking. This parameter is not used when pick_style != 0 pick_style - [in] 0 = wireframe picking (checks for vertex and edge hits) If the mesh edge list from ON_Mesh::GetMeshEdgeList() is available, then pass it in. 1 = shaded mode picking (checks for face hits) 2 = vertex only picking (returns false if no vertices are hit)

mesh_edge_count - [in] Number of edges in mesh_edge_list[]. mesh_edge_stride - [in] The mesh.m_V[] indices of the i-th mesh edge are vi0 = mesh_edge_list[i*mesh_edge_stride] and vi1 = mesh_edge_list[i*mesh_edge_stride+1] and mesh_edge_list - [in] optional list of mesh edges from ON_Mesh::GetEdgeList(). If this information is available, pass it in.

hit_point - [out] location returned here for point picks hit_srf_uv - [out] if not NULL and the mesh has surface parameters, hit_uv is set to the surface parameters of the hit point. hit_tex_st - [out] if not NULL and the mesh has texture coordinates, hit_st is set to the texture coordinate of the hit point. Note that the texture coodinates can be set in many different ways and this information is useless unless you know how the texture coordinates are set on this particular mesh.

depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point

vef_flag - [out] (for point picks) 0 = vertex hit, 1 = edge hit, 2 = face hit vef_index - [out] (for point picks) index of vertex/edge/face that was hit Returns: true if there is a hit.

◆ PickNurbsCurve()

bool CRhinoPickContext::PickNurbsCurve ( const ON_NurbsCurve nurbs_curve,
double *  t,
double *  depth,
double *  dist 
) const

Description: Utility for picking NURBS curves Parameters: nurbs_curve - [in] t - [out] line parameter returned here for point picks depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point Returns: true if there is a hit.

◆ PickPoint()

bool CRhinoPickContext::PickPoint ( const ON_3dPoint point,
double *  depth,
double *  dist 
) const

Description: Utility for picking 3d point Parameters: point - [in] depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point Returns: true if there is a hit.

◆ PickPointCloud()

bool CRhinoPickContext::PickPointCloud ( int  point_count,
const ON_3dPoint points,
int *  point_index,
double *  depth,
double *  dist 
) const

Description: Utility for picking 3d point clouds Parameters: point_count - [in] points - [in] point_index [out] zero based index returned here for point picks depth - [out] depth returned here for point picks LARGER values are NEARER to the camera. SMALLER values are FARTHER from the camera. dist - [out] planar distance returned here for point picks. SMALLER values are CLOSER to the pick point Returns: true if there is a hit.

◆ PickSegment() [1/2]

bool CRhinoPickContext::PickSegment ( const ON_3dPoint  points[2],
const ON_3dPoint  clip_points[2],
const unsigned int  clip_flags[2],
ON_PickPoint pick_point 
) const

Description: Pick a segment.

Parameters: points - [in] ends of the segment.

clip_points - [in] The clip_points[] and clipflags[] parameters can be nullptr, in which case the information will be locally calculated in the function. When a large number of segments that share end points are being tested, it is more efficient to calculate the clip_pionts[] and clip_flags[] informaton once per point location, provided storage and access is well managed. Use CRhinoPickContext.m_pick_region.TrasnformPoint() to calculate the correct values for clip_points[] and clip_flags[].

Both versions of PickSegment() return the same true/false result and calculate the same values for pick_point.m_point, pick_point.m_depth and pick_point.m_distance. If the pick projection is from a parallel (orthographic) view, then both versions calculate the same value for pick_point.m_t[0] parameter. If the pick projection is from a perspective view, then the version of the function that takes ON_4dPoints will calculated the pick_point.m_t[0] parameter more accurately, assuming the ON_4dPoints are properly calculated from the projection matrix.

clip_flags - [in] The clip_points[] and clipflags[] parameters can be nullptr, in which case the information will be locally calculated in the function. When a large number of segments that share end points are being tested, it is more efficient to calculate the clip_pionts[] and clip_flags[] informaton once per point location, provided storage and access is well managed. Use CRhinoPickContext.m_pick_region.TrasnformPoint() to calculate the correct values for clip_points[] and clip_flags[].

pick_point - [out] Returns: True if the triangle is hit.

◆ PickSegment() [2/2]

bool CRhinoPickContext::PickSegment ( const ON_3dPoint  points[2],
const ON_4dPoint  clip_points[2],
const unsigned int  clip_flags[2],
ON_PickPoint pick_point 
) const

◆ PickSubD()

unsigned int CRhinoPickContext::PickSubD ( ON_SubDMeshFragmentIterator  subd_frit,
const class CRhinoSubDPickSettings subd_pick_settings,
ON_SimpleArray< ON_SubDComponentPoint > &  component_points 
) const

Description: Find the best points for a subd selection. The value of subd_frit.SubDAppearance() determines if the surface or control net is inspected. Parameters: subd_frit - [in]
A subd mesh fragment interator. The value of subd_frit.SubDAppearance() determines if the surface or control net is inspected. subd_pick_settings - [in] component_points - [out] If bReturnSubObjects is false and a point pick is done, then the best pick (vertex, edge or face) is added to component_points[].

If bReturnSubObjects is false and a window or crossing pick is done, then nothing is added to component_points[].

If bReturnSubObjects is true, every subobject that qualifies is added to component_points[]. Returns: 0: nothing selected.

If bReturnSubObjects is false and something was selected, 1 is returned.

If bReturnSubObjects is true, the number of components added to component_points[] is returned.

◆ PickSubDControlNet()

unsigned int CRhinoPickContext::PickSubDControlNet ( const class ON_SubDRef  subd_ref,
const class CRhinoSubDPickSettings subd_pick_settings,
ON_SimpleArray< ON_SubDComponentPoint > &  component_points 
) const

Description: Find the best points for a subd control net selection. Up to 3 points can be returned, a face point, an edge point and a vertex point. The caller can apply various criteria to determing which point is the best one. Parameters: subd_limit_mesh - [in] level_index - [in] component_point - [out] component_point[0] A point on a vertex or ON_SubDComponentPoint::Unset. component_point[1] A point on an edge or ON_SubDComponentPoint::Unset. component_point[2] A point on a face or ON_SubDComponentPoint::Unset. Returns: true if at least one point is returned.

◆ PickSubDMeshFragment()

unsigned int CRhinoPickContext::PickSubDMeshFragment ( ON_SubDComponentLocation  subd_appearance,
const class ON_SubDMeshFragment subd_surface_mesh_fragment,
const class CRhinoSubDPickSettings subd_pick_settings,
ON_SubDComponentPoint  component_points[9] 
) const

Description: Pick a triangle. Parameters: subd_appearance - [in] surface or control net subd_surface_mesh_fragment - [in] A surface mesh fragment used to display some part of the face. component_points - [out] The array must have a capacity of 9 components. If component_points[].m_component_ptr.Direction() is not zero, then a window pick involving a partial fragment added an edge/face and additional testing is required to determine if the entire edge/face is inside the widow. Returns: Number of components that were hit. Information about these components is returned in the component_points[] array. If bReturnSubObjects is false and the pick sytle is a window or crossing, then 1 is returned if the pick hits the fragment and component_points[0] is set, but the contents are meaningless.

◆ PickTriangle() [1/2]

bool CRhinoPickContext::PickTriangle ( const ON_3dPoint  points[3],
const ON_3dPoint  clip_points[3],
const unsigned int  clip_flags[3],
ON_PickPoint pick_point 
) const

Description: Pick a triangle.

Parameters: points - [in] corners of the triangle.

clip_points - [in] The clip_points[] and clipflags[] parameters can be nullptr, in which case the information will be locally calculated in the function. When a large number of triangles that share corner points are being tested, it is more efficient to calculate the clip_pionts[] and clip_flags[] informaton once per point location, provided storage and access is well managed. Use CRhinoPickContext.m_pick_region.TrasnformPoint() to calculate the correct values for clip_points[] and clip_flags[].

Both versions of PickSegment() return the same true/false result and calculate the same values for pick_point.m_point, pick_point.m_depth and pick_point.m_distance. If the pick projection is from a parallel (orthographic) view, then both versions calculate the same value for pick_point.m_t[0] parameter. If the pick projection is from a perspective view, then the version of the function that takes ON_4dPoints will calculated the pick_point.m_t[0] parameter more accurately, assuming the ON_4dPoints are properly calculated from the projection matrix.

clip_flags - [in] The clip_points[] and clipflags[] parameters can be nullptr, in which case the information will be locally calculated in the function. When a large number of triangles that share corner points are being tested, it is more efficient to calculate the clip_pionts[] and clip_flags[] informaton once per point location, provided storage and access is well managed. Use CRhinoPickContext.m_pick_region.TrasnformPoint() to calculate the correct values for clip_points[] and clip_flags[].

pick_point - [out]

Returns: True if the triangle is hit. Remarks: The value of CRhinoPickContext.m_pick_mode is ignored. The hit point caluculation considers the entire triangle.

◆ PickTriangle() [2/2]

bool CRhinoPickContext::PickTriangle ( const ON_3dPoint  points[3],
const ON_4dPoint  clip_points[3],
const unsigned int  clip_flags[3],
ON_PickPoint pick_point 
) const

◆ PickType()

ON_PickType CRhinoPickContext::PickType ( ) const

Returns: m_pick_style as an ON_PickType.

◆ SubDEdgeIsInsideWindowPick()

bool CRhinoPickContext::SubDEdgeIsInsideWindowPick ( ON_SubDComponentLocation  subd_appearance,
const class ON_SubDEdge edge,
const class ON_SubDMeshFragment subd_surface_mesh_fragment 
) const

Description: Low level tool to determine perform additional checking to insure a SubD edge is inside a window pick. Parameters: edge - [in] SubD edge to test. subd_surface_mesh_fragment - [in] A surface mesh fragment used to display some part of the face. Returns: True when input information is valid and the entire subd face is inside the window pick. False otherwise.

◆ SubDFaceIsInsideWindowPick()

bool CRhinoPickContext::SubDFaceIsInsideWindowPick ( ON_SubDComponentLocation  subd_appearance,
bool  bWireframePick,
const class ON_SubDFace face,
const class ON_SubDMeshFragment subd_surface_mesh_fragment 
) const

Description: Low level tool to determine perform additional checking to insure a SubD face is inside a window pick. Parameters: subd_appearance - [in] surface or control net bWireframePick - [in] True for wireframe pick. False for shaded surface pick. face - [in] SubD face to test. subd_surface_mesh_fragment - [in] A surface mesh fragment used to display some part of the face. Returns: True when input information is valid and the entire subd face is inside the window pick. False otherwise.

◆ UpdateClippingPlanes()

void CRhinoPickContext::UpdateClippingPlanes ( )

Description: Updates the clipping plane information in m_pick_region. The m_bSetClippingPlanes and m_view fields must be before calling UpdateClippingPlanes().

Member Data Documentation

◆ m_bModelXformIsIdentity

bool CRhinoPickContext::m_bModelXformIsIdentity = true

True if the m_model_xform is the identity.

◆ m_bPickGroups

bool CRhinoPickContext::m_bPickGroups = false

true if CRhinoGroupObjects should be added to pick list

◆ m_bSetClippingPlanes

bool CRhinoPickContext::m_bSetClippingPlanes = true

If m_bSetClippingPlanes is true, then CRhPickContext will use lazy evaluation to automatically set m_pick_region.m_clip_planes[] when m_view is set. If m_bSetClippingPlanes is false, then you have to set m_pick_region.m_clip_planes[] if they are required.

◆ m_bSkipSelected

bool CRhinoPickContext::m_bSkipSelected = true

these flags are used in pre and post pick

◆ m_bSkipUnselected

bool CRhinoPickContext::m_bSkipUnselected = false

◆ m_bSubSelect

bool CRhinoPickContext::m_bSubSelect = false

true if the user activated subobject selection

◆ m_go

const class CRhinoGetObject* CRhinoPickContext::m_go = nullptr

in pre-pick, m_go is NULL

set if picking is in CRhinoGetObject::GetObject()

◆ m_model_xform

ON_Xform CRhinoPickContext::m_model_xform

Sometimes a component of m_pick_xform is due to a model transformation. For example, this happens when component geometry in an instance reference is being picked. The model transformation information is recoreded below. Most objects can ignore this information. However, objects like annotation where arrow heads and text sizes are independent of model transformations need this information.

◆ m_model_xform_det

double CRhinoPickContext::m_model_xform_det = 1.0

determinant of m_model_xform

◆ m_pick_line

ON_Line CRhinoPickContext::m_pick_line

pick chord starts on near clipping plane and ends on far clipping plane

◆ m_pick_mode

enum { ... } CRhinoPickContext::m_pick_mode

picking can happen in wireframe or shaded display mode

◆ m_pick_region

ON_ClippingRegion CRhinoPickContext::m_pick_region

m_pick_region.m_xform maps world 3d picking frustum into -1<=x,y,z<=+1 clipping coordinate box

◆ m_pick_style

enum { ... } CRhinoPickContext::m_pick_style

three styles of picking

◆ m_view

class CRhinoView* CRhinoPickContext::m_view = nullptr

This m_view can be a model view or a page view. When m_view is a page view, then you need to distingish between the viewports m_view->MainViewport() and m_view->ActiveViewport(). When m_view is a model view, both m_view->MainViewport() and
m_view->ActiveViewport() return the world view's viewport.