00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: GEOWorkVertexBuffer.h ( GEO Library, C++) 00014 * 00015 * COMMENTS: A work-buffer of temporary vertices. These are allocated on 00016 * demand and free'd when the class is destructed. They are 00017 * intended to be used as temporary stack storage, and shouldn't 00018 * be persistent. 00019 * 00020 * Each vertex is indexed by a unique integer (like an array). 00021 * Accessing a vertex which hasn't been accessed already will 00022 * cause the vertex to be created. 00023 * 00024 * Each vertex will also have a point allocated for it, and the 00025 * point associated with the vertex should NOT be changed. 00026 */ 00027 00028 #ifndef __GEO_WorkVertexBuffer__ 00029 #define __GEO_WorkVertexBuffer__ 00030 00031 #include "GEO_API.h" 00032 #include <UT/UT_PtrArray.h> 00033 #include <GB/GB_Defines.h> 00034 00035 class GEO_Detail; 00036 class GEO_Point; 00037 class GEO_Vertex; 00038 00039 #define GEO_WORK_VERTEX_ARRAY_SIZE 128 00040 00041 class GEO_API GEO_WorkVertexBuffer { 00042 public: 00043 GEO_WorkVertexBuffer(GEO_Detail *gdp, int initial_size=0, 00044 int matrix_size=GB_MAXORDER); 00045 ~GEO_WorkVertexBuffer(); 00046 00047 // If the vertex isn't already allocated at the index passed in, it will be 00048 // created. 00049 GEO_Vertex *getVertex(int idx, GEO_Point *pt=0); 00050 GEO_Vertex *appendVertex(GEO_Point *pt=0); 00051 00052 GEO_Vertex *getBasisVertex(int r, int c, GEO_Point *pt=0) 00053 { return getVertex(r*myMatrixSize + c, pt); } 00054 00055 int getMatrixSize() const { return myMatrixSize; } 00056 00057 private: 00058 UT_PtrArray<GEO_Vertex *> myVertices; 00059 GEO_Detail *myDetail; 00060 int myMatrixSize; 00061 }; 00062 00063 class GEO_API GEO_WorkVertexArray { 00064 public: 00065 // Many of the curve/surface methods require an array of vertices. Rather 00066 // than worrying about allocating/deleting dynamic arrays, the 00067 // work-vertex-array can be used. 00068 // 00069 // Vertices are allocated using the work-vertex-buffer, so it must remain 00070 // in scope as long as the array. 00071 // 00072 GEO_WorkVertexArray(GEO_WorkVertexBuffer &buffer, int size); 00073 ~GEO_WorkVertexArray(); 00074 00075 GEO_Vertex **getVertices() { return myVertices; } 00076 private: 00077 GEO_WorkVertexBuffer &myBuffer; 00078 GEO_Vertex **myVertices; 00079 GEO_Vertex *mySmallBuf[GEO_WORK_VERTEX_ARRAY_SIZE]; 00080 int mySize; 00081 }; 00082 00083 #endif
1.5.9