[vtk-developers] pointer to a member method

Dean Inglis dean.inglis at camris.ca
Fri Jun 4 10:52:04 EDT 2004


Sorry, cut'n'paste err but I think you'll get the point...

///////////////////////////////////////////////////////
class GeomTest
{
  bool (__closure *PointInclusionTest)(const Vec3D&);

  void SetUpInclusionTest(int type);

  Sphere   s;
  Cylinder c;
  Prism    p;
}

void GeomTest::SetUpInclusionTest(int type)
{
  switch(type)
    {
    case 0:  PointInclusionTest = &s.PointInSphere;
    case 1:  PointInclusionTest = &c.PointInCylinder;
    case 2:  PointInclusionTest = &p.PointInPrism;
    }
}

class Sphere
{
  bool PointInSphere(const Vec3D&) const;
  double  RadiusSqr;
  Vec3D   Center;
}

bool Sphere::PointInSphere(const Vec3D& aPoint) const
{
  Vec3D Temp = aPoint - Center;
  return (Temp.SqrLength() <= RadiusSqr);
}
///////////////////////////////////////////////////////

Of course, it's not vtk friendly since closure is a Borland specific
key word...

Dean




Hi All,

I've got a class which uses this method in vtkOBBTree:

int vtkOBBTree::IntersectWithOBBTree ( vtkOBBTree *, vtkMatrix4x4 *,
int(*)(vtkOBBNode *, vtkOBBNode *, vtkMatrix4x4 *, void *), 
void *)

My code looks like:

static int ComputeCollisions(vtkOBBNode *, vtkOBBNode *, vtkMatrix4x4 *,
void *);
  {
  ...
  }

vtkCollisionDetectionFilter::Execute()
  {
  ...
  Obbtree1->IntersectWithOBBTree ( Obbtree2, matrix, ComputeCollisions,
this);
  ...
  }

This works fine. Now I'd like to make ComputeCollisions a class member
method but my compiler (bcc55) has other ideas. I get:

Error E2034 vtkCollisionDetectionFilter.cxx 364: Cannot convert 'int (*
(_closure )(vtkOBBNode *,vtkOBBNode *,vtkMatrix4x4 *,void *))(vtkOBBNode
*,vtkOBBNode *,vtkMatrix4x4 *,void *)' to 'int (*)(vtkOBBNode
*,vtkOBBNode *,vtkMatrix4x4 *,void *)' in function
vtkCollisionDetectionFilter::Execute()

Error E2342 vtkCollisionDetectionFilter.cxx 364: Type mismatch in
parameter 'function' (wanted 'int (*)(vtkOBBNode *,vtkOBBNode
*,vtkMatrix4x4 *,void *)', got 'void') in function
vtkCollisionDetectionFilter::Execute()

So I try:

Obbtree1->IntersectWithOBBTree ( Obbtree2, matrix, (int
(*))ComputeCollisions, this);

And I get:

Error E2235 vtkCollisionDetectionFilter.cxx 364: Member function must be
called or its address taken in function
vtkCollisionDetectionFilter::Execute()

The source code for the class is here:
http://www.bioengineering-research.com/vtk/vtkCollisionDetectionFilter.h
tm


Any help would be much appreciated.
TIA,

Goodwin


_______________________________________________
vtk-developers mailing list
vtk-developers at vtk.org
http://www.vtk.org/mailman/listinfo/vtk-developers

_______________________________________________
vtk-developers mailing list
vtk-developers at vtk.org
http://www.vtk.org/mailman/listinfo/vtk-developers




More information about the vtk-developers mailing list