cisst-saw
Loading...
Searching...
No Matches
msh3DirPDTreeNode.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 _msh3DirPDTreeNode_h
38#define _msh3DirPDTreeNode_h
39
40#include <stdio.h>
41#include <assert.h>
42
45
48
49// Always include last!
50#include <cisstMesh/mshExport.h>
51
53{
54 //
55 // This class implements a node of a directed PD tree;
56 // there are no derived versions of this class.
57 //
58
59 //--- Variables ---//
60
61 public:
62
65 msh3DirPDTreeNode *pLEq, *pMore; // child nodes
66
68 int NData;
70
71 vctFrm3 F; // transforms world -> local node coords
72 msh3BoundingBox Bounds; // bounding box for this node
73
74 vct3 Navg; // avg orientation of the datum in this node
75 double dThetaMax; // max deviation (in radians) from the avg orientation
76
77 //--- Methods ---//
78
79 public:
80
81 // constructor
82 msh3DirPDTreeNode(int *pDataIndexArray, int numIndexes,
84
85 // debug constructor
87 pMyTree(NULL),
88 pParent(NULL),
89 pLEq(NULL),
90 pMore(NULL),
91 pDataIndices(NULL),
92 NData(0)
93 {};
94
95 // destructor
97
99
100 // Check if a datum in this node has a lower match error than the error bound
101 // If a lower match error is found, set the new closest point, update error
102 // bound, and return the global datum index of the closest datum.
103 // Otherwise, return -1.
104 int FindClosestDatum(const vct3 &v, const vct3 &n,
105 vct3 &closestPoint, vct3 &closestPointNorm,
106 double &ErrorBound,
107 unsigned int &numNodesVisited,
108 unsigned int &numNodesSearched);
109
110 int NumData() const { return NData; };
111 int IsTerminalNode() const { return pLEq == NULL; };
112
114 vctFrm3 ComputeCovFrame(int i0, int i1);
115 int ConstructSubtree(int CountThresh, double DiagThresh);
116
117 void AccumulateCentroid(int datum, vct3 &sum) const;
118 void AccumulateVariances(int datum, const vct3 &mean, vctDouble3x3 &C) const;
119
120 // Return the global datum index of the ith datum in this node
121 inline int Datum(int i) const
122 {
123 assert(i >= 0 && i < NData);
124 return pDataIndices[i];
125 };
126
127 inline int& Datum(int i)
128 {
129 assert(i >= 0 && i < NData);
130 return pDataIndices[i];
131 };
132
133 protected:
134
135 // computes orientation parameters for this node and
136 // returns the running sum of orientations in the node
137 // (return value is for speedup when computing parent node params)
139
140 public:
141
142 // debug routines
143 int FindTerminalNode(int datum, msh3DirPDTreeNode **termNode);
144 void PrintTerminalNodes(std::ofstream &fs);
145 inline bool NodeContainsDatum(int datum)
146 {
147 for (int i = 0; i < NData; i++)
148 {
149 if (datum == pDataIndices[i]) return true;
150 }
151 return false;
152 }
153
154 //void RecomputeBoundingBoxesUsingExistingCovFrames();
155 //void ReSortUsingExistingCovFrames();
156 //void RecomputeCovFrames();
157
158 //virtual void Print(FILE* chan, int indent);
159
160};
161
162#endif
163
172//int FindClosestDatum( const vct3 &v, const vct3 &n,
173// vct3 &closestPoint, vct3 &closestPointNorm,
174// double posWeight, double normWeight,
175// double &ErrorBound,
176// unsigned int &numNodesVisited,
177// unsigned int &numNodesSearched,
178// double geomDistBound );
Definition msh3DirPDTreeBase.h:55
vctFrm3 ComputeCovFrame(int i0, int i1)
vct3 Navg
Definition msh3DirPDTreeNode.h:74
bool NodeContainsDatum(int datum)
Definition msh3DirPDTreeNode.h:145
int NumData() const
Definition msh3DirPDTreeNode.h:110
int FindTerminalNode(int datum, msh3DirPDTreeNode **termNode)
int NData
Definition msh3DirPDTreeNode.h:68
int myDepth
Definition msh3DirPDTreeNode.h:69
msh3DirPDTreeNode * pMore
Definition msh3DirPDTreeNode.h:65
int FindClosestDatum(const vct3 &v, const vct3 &n, vct3 &closestPoint, vct3 &closestPointNorm, double &ErrorBound, unsigned int &numNodesVisited, unsigned int &numNodesSearched)
msh3DirPDTreeBase * pMyTree
Definition msh3DirPDTreeNode.h:63
msh3DirPDTreeNode * GetChildSplitNode(const vct3 &datumPos)
int * pDataIndices
Definition msh3DirPDTreeNode.h:67
msh3DirPDTreeNode * pParent
Definition msh3DirPDTreeNode.h:64
vct3 ComputeOrientationParams()
void PrintTerminalNodes(std::ofstream &fs)
int & Datum(int i)
Definition msh3DirPDTreeNode.h:127
void AccumulateVariances(int datum, const vct3 &mean, vctDouble3x3 &C) const
void AccumulateCentroid(int datum, vct3 &sum) const
msh3DirPDTreeNode(double)
Definition msh3DirPDTreeNode.h:86
msh3DirPDTreeNode(int *pDataIndexArray, int numIndexes, msh3DirPDTreeBase *pTree, msh3DirPDTreeNode *pParent)
int ConstructSubtree(int CountThresh, double DiagThresh)
msh3BoundingBox Bounds
Definition msh3DirPDTreeNode.h:72
int IsTerminalNode() const
Definition msh3DirPDTreeNode.h:111
vctFrm3 F
Definition msh3DirPDTreeNode.h:71
int Datum(int i) const
Definition msh3DirPDTreeNode.h:121
msh3DirPDTreeNode * pLEq
Definition msh3DirPDTreeNode.h:65
double dThetaMax
Definition msh3DirPDTreeNode.h:75
#define CISST_EXPORT
Definition cmnExportMacros.h:50
vctBoundingBox3 msh3BoundingBox
Definition msh3BoundingBox.h:42
Macros to export the symbols of cisstMesh (in a Dll).
Forward declarations and #define for cisstMesh.
vctFixedSizeMatrix< double, 3, 3 > vctDouble3x3
Definition vctFixedSizeMatrixTypes.h:58
Typedef for fixed size vectors.
vctFixedSizeVector< double, 3 > vct3
Definition vctFixedSizeVectorTypes.h:46
Typedef for different transformations.
vctFrameBase< vctRot3 > vctFrm3
Definition vctTransformationTypes.h:137