resetting manifest requested domain to floor
[platform/upstream/libbullet.git] / Extras / ConvexDecomposition / vlookup.h
1 #ifndef VLOOKUP_H
2
3 #define VLOOKUP_H
4
5
6 /*----------------------------------------------------------------------
7                 Copyright (c) 2004 Open Dynamics Framework Group
8                                         www.physicstools.org
9                 All rights reserved.
10
11                 Redistribution and use in source and binary forms, with or without modification, are permitted provided
12                 that the following conditions are met:
13
14                 Redistributions of source code must retain the above copyright notice, this list of conditions
15                 and the following disclaimer.
16
17                 Redistributions in binary form must reproduce the above copyright notice,
18                 this list of conditions and the following disclaimer in the documentation
19                 and/or other materials provided with the distribution.
20
21                 Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
22                 be used to endorse or promote products derived from this software without specific prior written permission.
23
24                 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25                 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26                 DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27                 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28                 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29                 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30                 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 -----------------------------------------------------------------------*/
32
33 // http://codesuppository.blogspot.com
34 //
35 // mailto: jratcliff@infiniplex.net
36 //
37 // http://www.amillionpixels.us
38 //
39
40
41 // CodeSnippet provided by John W. Ratcliff
42 // on March 23, 2006.
43 //
44 // mailto: jratcliff@infiniplex.net
45 //
46 // Personal website: http://jratcliffscarab.blogspot.com
47 // Coding Website:   http://codesuppository.blogspot.com
48 // FundRaising Blog: http://amillionpixels.blogspot.com
49 // Fundraising site: http://www.amillionpixels.us
50 // New Temple Site:  http://newtemple.blogspot.com
51 //
52 // This snippet shows how to 'hide' the complexity of
53 // the STL by wrapping some useful piece of functionality
54 // around a handful of discrete API calls.
55 //
56 // This API allows you to create an indexed triangle list
57 // from a collection of raw input triangles.  Internally
58 // it uses an STL set to build the lookup table very rapidly.
59 //
60 // Here is how you would use it to build an indexed triangle
61 // list from a raw list of triangles.
62 //
63 // (1) create a 'VertexLookup' interface by calling
64 //
65 //     VertexLook vl = Vl_createVertexLookup();
66 //
67 // (2) For each vertice in each triangle call:
68 //
69 //     unsigned int i1 = Vl_getIndex(vl,p1);
70 //     unsigned int i2 = Vl_getIndex(vl,p2);
71 //     unsigned int i3 = Vl_getIndex(vl,p3);
72 //
73 //     save the 3 indices into your triangle list array.
74 //
75 // (3) Get the vertex array by calling:
76 //
77 //     const float *vertices = Vl_getVertices(vl);
78 //
79 // (4) Get the number of vertices so you can copy them into
80 //     your own buffer.
81 //     unsigned int vcount = Vl_getVcount(vl);
82 //
83 // (5) Release the VertexLookup interface when you are done with it.
84 //     Vl_releaseVertexLookup(vl);
85 //
86 // Teaches the following lessons:
87 //
88 //    How to wrap the complexity of STL and C++ classes around a
89 //    simple API interface.
90 //
91 //    How to use an STL set and custom comparator operator for
92 //    a complex data type.
93 //
94 //    How to create a template class.
95 //
96 //    How to achieve significant performance improvements by
97 //    taking advantage of built in STL containers in just
98 //    a few lines of code.
99 //
100 //    You could easily modify this code to support other vertex
101 //    formats with any number of interpolants.
102 //
103 //    Hide C++ classes from the rest of your application by
104 //    keeping them in the CPP and wrapping them in a namespace
105 // Uses an STL set to create an index table for a bunch of vertex positions
106 // used typically to re-index a collection of raw triangle data.
107
108
109 typedef void * VertexLookup;
110
111 VertexLookup  Vl_createVertexLookup(void);
112 void          Vl_releaseVertexLookup(VertexLookup vlook);
113
114 unsigned int  Vl_getIndex(VertexLookup vlook,const float *pos);  // get index.
115 const float * Vl_getVertices(VertexLookup vlook);
116 unsigned int  Vl_getVcount(VertexLookup vlook);
117
118
119 #endif