[Insight-users] itk::kdtree and itk::hashtable

Luis Ibanez luis.ibanez at kitware.com
Wed Nov 25 18:17:27 EST 2009


Hi Motes,

You could create a new class that derives from the itk::Point and that
has a pointer to your own object type.

In this way you can use the PointLocator it is current form, and then
each time that you recover a point, you could look back at the object
to which it is pointing.

---

About your code, using a particular name for a template argument
is not a replacement for a typedef.  That is, the fact that you are
templating your class over "PointDimension" is not equivalent to
declaring "PointDimension" as a type or as a numeric constant.

What you should do is:



template <typename V, unsigned int Dimension=3>
class MyControlPoint
  {
  public:

      itkStaticConstMacro(PointDimension, unsigned int, Dimension);
      typedef V                                      ControlPointVectorType;
      typedef typename V::ValueType                  ValueType;

.....


Note that "itkStaticConstMacro()" is where "PointDimension"
will actually be declared.



     Regards,


           Luis


------------------------------
On Tue, Nov 24, 2009 at 7:02 AM, motes motes <mort.motes at gmail.com> wrote:
> But I need an implementation that returns a container of my own
> objects. In the seach method an InstanceIdentifierVectorType is
> returned:
>
> template <class TMesh>
> void
> PointLocator2<TMesh>
> ::Search(const PointType &query,
>         unsigned int numberOfNeighborsRequested,
>         InstanceIdentifierVectorType& result) const
> {
>  this->m_Tree->Search( query, numberOfNeighborsRequested, result );
> }
>
>
> corresponding to the neighbors. But as I understand thats still just
> an array of vectors and not user-specified objects containing the
> vectors.
>
>
>
>
> I have tried using the implementation with my own object:
>
>  const unsigned int Dimension = 3;
>  typedef itk::Vector<double, Dimension>
>                 VectorType;
>  typedef MyControlPoint<VectorType, Dimension>
>          ControlPointType;
>  typedef itk::PointLocator2<ControlPointType> PointLocatorType;
>  PointLocatorType pointLocator;
>
>
>
>
> But when I compile I get:
>
> error C2039: 'PointDimension' : is not a member of
> 'MyControlPoint<V,PointDimension>'
>
> corresponding to this line:
>
>  itkStaticConstMacro(PointDimension, unsigned int, TPointSet::PointDimension);
>
> in itkPointLocator2.h.
>
> But I have added the PointDimension to MyControlPoint:
>
>
>  template <typename V, unsigned int PointDimension=3>
>  class MyControlPoint
>  {
>  public:
>
>    typedef V                                      ControlPointVectorType;
>    typedef typename V::ValueType                  ValueType;
>
>
> But maybe I need to do something else?
>
>
> On Mon, Nov 23, 2009 at 2:58 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>> Hi Motes,
>>
>> You may find useful the class
>>
>>            itkPointLocator2
>>
>> in the NAMIC Sandbox:
>>
>>  NAMICSandBox/QuadEdgeMeshRigidRegistration/Source
>>
>> http://svn.na-mic.org/NAMICSandBox/trunk/QuadEdgeMeshRigidRegistration/Source/
>>
>>
>> It uses internally a KdTree in order to perform the type
>> of point search that you are describing.
>>
>>
>>    Regards,
>>
>>           Luis
>>
>>
>> -----------------------------------------
>> On Fri, Nov 20, 2009 at 5:59 AM, motes motes <mort.motes at gmail.com> wrote:
>>> Assume that I  have 100 points in 3D which I have used to build a
>>> kdTree.  For a given point P I can use the KdTree to find the
>>> k-nearest neighbors.
>>>
>>> But since each point acutally corresponds to the location of a unique
>>> object that contains additional that data I need, I would like to get
>>> these objects based on their location returned from the kd-tree.
>>>
>>> I would therefore like to store each object in a itk::hashtable based
>>> on its 3D location. When I get the set of neighbors from the kd-tree I
>>> can use each location as a key to retreive the object.
>>>
>>> I know how to use the itk::kdtree, but have not been able to find any
>>> examples using the itk::hashtable. Does anyone know if the above idea
>>> would work with the itk::hashtable or know of any examples  using the
>>> itk::hashtable?
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>


More information about the Insight-users mailing list