vlookup.h
Go to the documentation of this file.
1 #ifndef VLOOKUP_H
2 
3 #define VLOOKUP_H
4 
60 // CodeSnippet provided by John W. Ratcliff
61 // on March 23, 2006.
62 //
63 // mailto: jratcliff@infiniplex.net
64 //
65 // Personal website: http://jratcliffscarab.blogspot.com
66 // Coding Website: http://codesuppository.blogspot.com
67 // FundRaising Blog: http://amillionpixels.blogspot.com
68 // Fundraising site: http://www.amillionpixels.us
69 // New Temple Site: http://newtemple.blogspot.com
70 //
71 // This snippet shows how to 'hide' the complexity of
72 // the STL by wrapping some useful piece of functionality
73 // around a handful of discrete API calls.
74 //
75 // This API allows you to create an indexed triangle list
76 // from a collection of raw input triangles. Internally
77 // it uses an STL set to build the lookup table very rapidly.
78 //
79 // Here is how you would use it to build an indexed triangle
80 // list from a raw list of triangles.
81 //
82 // (1) create a 'VertexLookup' interface by calling
83 //
84 // VertexLook vl = Vl_createVertexLookup();
85 //
86 // (2) For each vertice in each triangle call:
87 //
88 // unsigned int i1 = Vl_getIndex(vl,p1);
89 // unsigned int i2 = Vl_getIndex(vl,p2);
90 // unsigned int i3 = Vl_getIndex(vl,p3);
91 //
92 // save the 3 indices into your triangle list array.
93 //
94 // (3) Get the vertex array by calling:
95 //
96 // const double *vertices = Vl_getVertices(vl);
97 //
98 // (4) Get the number of vertices so you can copy them into
99 // your own buffer.
100 // unsigned int vcount = Vl_getVcount(vl);
101 //
102 // (5) Release the VertexLookup interface when you are done with it.
103 // Vl_releaseVertexLookup(vl);
104 //
105 // Teaches the following lessons:
106 //
107 // How to wrap the complexity of STL and C++ classes around a
108 // simple API interface.
109 //
110 // How to use an STL set and custom comparator operator for
111 // a complex data type.
112 //
113 // How to create a template class.
114 //
115 // How to achieve significant performance improvements by
116 // taking advantage of built in STL containers in just
117 // a few lines of code.
118 //
119 // You could easily modify this code to support other vertex
120 // formats with any number of interpolants.
121 //
122 // Hide C++ classes from the rest of your application by
123 // keeping them in the CPP and wrapping them in a namespace
124 // Uses an STL set to create an index table for a bunch of vertex positions
125 // used typically to re-index a collection of raw triangle data.
126 
127 namespace ConvexDecomposition
128 {
129 
130 typedef void * VertexLookup;
131 
134 
135 unsigned int Vl_getIndex(VertexLookup vlook,const double *pos); // get index.
136 const double * Vl_getVertices(VertexLookup vlook);
137 
138 unsigned int Vl_getVcount(VertexLookup vlook);
139 
140 };
141 
142 
143 #endif
ConvexDecomposition
Definition: bestfit.cpp:75
ConvexDecomposition::Vl_releaseVertexLookup
void Vl_releaseVertexLookup(VertexLookup vlook)
Definition: vlookup.cpp:314
ConvexDecomposition::Vl_createVertexLookup
VertexLookup Vl_createVertexLookup(void)
Definition: vlookup.cpp:308
ConvexDecomposition::Vl_getVertices
const double * Vl_getVertices(VertexLookup vlook)
Definition: vlookup.cpp:327
ConvexDecomposition::Vl_getIndex
unsigned int Vl_getIndex(VertexLookup vlook, const double *pos)
Definition: vlookup.cpp:320
ConvexDecomposition::VertexLookup
void * VertexLookup
Definition: vlookup.h:130
ConvexDecomposition::Vl_getVcount
unsigned int Vl_getVcount(VertexLookup vlook)
Definition: vlookup.cpp:334


convex_decomposition
Author(s): John W. Ratcliff
autogenerated on Wed Mar 2 2022 00:04:59