1 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // Source code for "Creating Efficient Triangle Strips"
4 // (C) 2000, Pierre Terdiman (p.terdiman@wanadoo.fr)
5 //
6 // Version is 2.0.
7 //
8 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef __STRIPER_H__
11 #define __STRIPER_H__
12 
13 #include <stdint.h>
14 
15 #include "StripStdafx.h"
16 
17 //typedef uint32_t udword;   // DWORD = unsigned 32 bit value
18 //typedef uint16_t uword;    // WORD = unsigned 16 bit value
19 //typedef uint8_t ubyte;     // BYTE = unsigned 8 bit value
20 
21 //#define null nullptr
22 
23 //#include "Adjacency.h"
24 //#include "CustomArray.h"
25 
26 	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27 	//
28 	//																Class Striper
29 	//
30 	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 	struct STRIPERCREATE{
STRIPERCREATESTRIPERCREATE33 				STRIPERCREATE()
34 				{
35 					DFaces				= null;
36 					WFaces				= null;
37 					NbFaces				= 0;
38 					AskForWords			= true;
39 					OneSided			= true;
40 					SGIAlgorithm		= true;
41 					ConnectAllStrips	= false;
42 				}
43 				udword					NbFaces;			// #faces in source topo
44 				udword*					DFaces;				// list of faces (dwords) or null
45 				uword*					WFaces;				// list of faces (words) or null
46 				bool					AskForWords;		// true => results are in words (else dwords)
47 				bool					OneSided;			// true => create one-sided strips
48 				bool					SGIAlgorithm;		// true => use the SGI algorithm, pick least connected faces first
49 				bool					ConnectAllStrips;	// true => create a single strip with void faces
50 	};
51 
52 	struct STRIPERRESULT{
53 				udword					NbStrips;			// #strips created
54 				udword*					StripLengths;		// Lengths of the strips (NbStrips values)
55 				void*					StripRuns;			// The strips in words or dwords, depends on AskForWords
56 				bool					AskForWords;		// true => results are in words (else dwords)
57 	};
58 
59 	class Striper
60 	{
61 	private:
62 				Striper&				FreeUsedRam();
63 				udword					ComputeBestStrip(udword face);
64 				udword					TrackStrip(udword face, udword oldest, udword middle, udword* strip, udword* faces, bool* tags);
65 				bool					ConnectAllStrips(STRIPERRESULT& result);
66 
67 				Adjacencies*			mAdj;				// Adjacency structures
68 				bool*					mTags;				// Face markers
69 
70 				udword					mNbStrips;			// The number of strips created for the mesh
71 				CustomArray*			mStripLengths;		// Array to store strip lengths
72 				CustomArray*			mStripRuns;			// Array to store strip indices
73 
74 				udword					mTotalLength;		// The length of the single strip
75 				CustomArray*			mSingleStrip;		// Array to store the single strip
76 
77 				// Flags
78 				bool					mAskForWords;
79 				bool					mOneSided;
80 				bool					mSGIAlgorithm;
81 				bool					mConnectAllStrips;
82 
83 	public:
84 				Striper();
85 				~Striper();
86 
87 				bool					Init(STRIPERCREATE& create);
88 				bool					Compute(STRIPERRESULT& result);
89 	};
90 
91 #endif // __STRIPER_H__
92