Question about ON_Rtree

Can anyone give me an example of the following function:

bool ON_RTree::Search (ON_RTreeSphere *a_sphere, bool ON_CALLBACK_CDECL resultCallback(void *a_context, ON__INT_PTR a_id), void *a_context) const

Thank you very much :heart:

Hi @suc_kiet,

How about this?

static bool TestCallback(void* a_context, ON__INT_PTR a_id)
  if (nullptr == a_context)
    return false;

  CCommandTest* command = (CCommandTest*)a_context;
  if (nullptr == command)
    return false;

  // TODO...

  return true;

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
  ON_RTree rtree;

  // TODO...

  ON_RTreeSphere sphere;
  sphere.m_point[0] = 0.0;
  sphere.m_point[1] = 0.0;
  sphere.m_point[2] = 0.0;
  sphere.m_radius = 1.0;
  bool rc = rtree.Search(&sphere, TestCallback, (void*)this);

  // TODO...

– Dale

1 Like

Hi @dale ;
Thank you :smile: