cisst-saw
Loading...
Searching...
No Matches
msh3DirPDTreeBase.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3// ****************************************************************************
4//
5// Copyright (c) 2014, Seth Billings, Russell Taylor, Johns Hopkins University
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// 1. Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14//
15// 2. Redistributions in binary form must reproduce the above copyright
16// notice, this list of conditions and the following disclaimer in the
17// documentation and/or other materials provided with the distribution.
18//
19// 3. Neither the name of the copyright holder nor the names of its
20// contributors may be used to endorse or promote products derived from
21// this software without specific prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34//
35// ****************************************************************************
36
37#ifndef _msh3DirPDTreeBase_h
38#define _msh3DirPDTreeBase_h
39
40#include <limits>
41
42#include <stdio.h>
43#include <assert.h>
44
48
49//#define DebugDirPDTree
50
51// Always include last!
52#include <cisstMesh/mshExport.h>
53
55{
56 //
57 // This is the base class for a directional PD tree
58 // (i.e. for oriented data).
59 // This class defines the entry point for performing
60 // a search. The type of datum (i.e. triangle, point, etc.)
61 // is unknown to this class and must be defined within a
62 // derived class, making this class abstract.
63 // This class stores a pointer to an pAlgorithm object
64 // which implements the key search routines.
65 //
66
67 friend class msh3DirPDTreeNode;
68
69 //--- Variables ---//
70
71 public:
72
73 // reference to pAlgorithm must exist here so that all nodes
74 // may access it
76
77 protected:
78
79#ifdef DebugDirPDTree
80 FILE *debugFile;
81 FILE *debugFile2;
82#endif
83
87
88 //--- Methods ---//
89
90 public:
91
92 // constructors
94 pAlgorithm(NULL),
95 NData(0), NNodes(0), treeDepth(0),
96 DataIndices(NULL), Top(NULL)
97 {
98#ifdef DebugDirPDTree
99 debugFile = fopen("../ICP_TestData/LastRun/debugDirPDTree.txt","w");
100 debugFile2 = fopen("../ICP_TestData/LastRun/debugDirPDTree2.txt","w");
101#endif
102 };
103
104 // destructor
106
107 int FastInitializeProximalDatum(const vct3 &v, const vct3 &n, vct3 &proxPoint, vct3 &proxNorm);
108
110 {
111 pAlgorithm = pAlg;
112 }
113
114 // Return the index for the datum in the tree that has lowest match error for
115 // the given point and set the closest point values
116 int FindClosestDatum(const vct3 &v, const vct3 &n,
117 vct3 &closestPoint, vct3 &closestPointNorm,
118 int prevDatum,
119 double &matchError,
120 unsigned int &numNodesSearched,
121 double currentMatchError = std::numeric_limits<double>::max());
122
123 // Compute the match error for a given datum
124 double ComputeDatumMatchError(const vct3 &v, const vct3 &n, int datum);
125
126 int NumData() const { return NData; };
127 int NumNodes() const { return NNodes; };
128 int TreeDepth() const { return treeDepth; };
129
130 // debug routines
131 int ValidateClosestDatum(const vct3 &v, const vct3 &n,
132 vct3 &closestPoint, vct3 &closestPointNorm);
133 int FindTerminalNode(int datum, msh3DirPDTreeNode **termNode);
134 void PrintTerminalNodes(std::ofstream &fs);
135
136
137 //--- Virtual Methods ---//
138 //
139 // These methods require a known datum type
140 //
141 virtual vct3 DatumSortPoint(int datum) = 0; // reference point for assigning datum to a node
142 virtual vct3 DatumNorm(int datum) = 0; // datum orientation (normal vector)
143 virtual void EnlargeBounds(const vctFrm3& F, int datum, msh3BoundingBox& BB) const = 0;
144
145};
146
147#endif
Definition msh3AlgDirPDTree.h:47
virtual void EnlargeBounds(const vctFrm3 &F, int datum, msh3BoundingBox &BB) const =0
int FindClosestDatum(const vct3 &v, const vct3 &n, vct3 &closestPoint, vct3 &closestPointNorm, int prevDatum, double &matchError, unsigned int &numNodesSearched, double currentMatchError=std::numeric_limits< double >::max())
int NumNodes() const
Definition msh3DirPDTreeBase.h:127
int TreeDepth() const
Definition msh3DirPDTreeBase.h:128
int NNodes
Definition msh3DirPDTreeBase.h:84
int FastInitializeProximalDatum(const vct3 &v, const vct3 &n, vct3 &proxPoint, vct3 &proxNorm)
msh3DirPDTreeBase()
Definition msh3DirPDTreeBase.h:93
double ComputeDatumMatchError(const vct3 &v, const vct3 &n, int datum)
int ValidateClosestDatum(const vct3 &v, const vct3 &n, vct3 &closestPoint, vct3 &closestPointNorm)
void SetSearchAlgorithm(msh3AlgDirPDTree *pAlg)
Definition msh3DirPDTreeBase.h:109
int * DataIndices
Definition msh3DirPDTreeBase.h:85
int NumData() const
Definition msh3DirPDTreeBase.h:126
msh3AlgDirPDTree * pAlgorithm
Definition msh3DirPDTreeBase.h:75
virtual ~msh3DirPDTreeBase()
Definition msh3DirPDTreeBase.h:105
virtual vct3 DatumSortPoint(int datum)=0
friend class msh3DirPDTreeNode
Definition msh3DirPDTreeBase.h:67
int NData
Definition msh3DirPDTreeBase.h:84
virtual vct3 DatumNorm(int datum)=0
void PrintTerminalNodes(std::ofstream &fs)
msh3DirPDTreeNode * Top
Definition msh3DirPDTreeBase.h:86
int treeDepth
Definition msh3DirPDTreeBase.h:84
int FindTerminalNode(int datum, msh3DirPDTreeNode **termNode)
#define CISST_EXPORT
Definition cmnExportMacros.h:50
vctBoundingBox3 msh3BoundingBox
Definition msh3BoundingBox.h:42
Macros to export the symbols of cisstMesh (in a Dll).
vctFixedSizeVector< double, 3 > vct3
Definition vctFixedSizeVectorTypes.h:46
vctFrameBase< vctRot3 > vctFrm3
Definition vctTransformationTypes.h:137