[774] | 1 | #ifndef NAUTILUS_ADJMODEL_INCLUDED // -*- C++ -*-
|
---|
| 2 | #define NAUTILUS_ADJMODEL_INCLUDED
|
---|
| 3 |
|
---|
| 4 | /************************************************************************
|
---|
| 5 |
|
---|
| 6 | Adjacency model representation.
|
---|
| 7 | $Id: AdjModel.h,v 1.7 1997/07/18 15:27:38 garland Exp $
|
---|
| 8 |
|
---|
| 9 | Adapted from:
|
---|
| 10 | mlab: (Id: polymodel.h,v 1.13 1997/02/06 16:30:11 garland Exp)
|
---|
| 11 | via
|
---|
[1025] | 12 | simplif: (Id: polymodel.h,v 1.1 1997/02/11 15:21:29 garland Exp)
|
---|
[774] | 13 |
|
---|
| 14 | ************************************************************************/
|
---|
| 15 |
|
---|
| 16 | #include "AdjPrims.h"
|
---|
| 17 | #include <gfx/SMF/smf.h>
|
---|
| 18 | #include <vector>
|
---|
| 19 |
|
---|
[1025] | 20 | namespace simplif
|
---|
[774] | 21 | {
|
---|
| 22 | class Model : public SMF_Model
|
---|
| 23 | {
|
---|
| 24 | protected:
|
---|
| 25 | vert_buffer vertices;
|
---|
| 26 | edge_buffer edges;
|
---|
| 27 | face_buffer faces;
|
---|
| 28 | vec3_buffer normals; // SUS
|
---|
| 29 | vec2_buffer texcoords;
|
---|
| 30 |
|
---|
| 31 | private:
|
---|
| 32 |
|
---|
| 33 | void maybeFixFace(Face *);
|
---|
| 34 |
|
---|
| 35 | public:
|
---|
| 36 | Model() {
|
---|
| 37 | validVertCount = 0;
|
---|
| 38 | validEdgeCount = 0;
|
---|
| 39 | validFaceCount = 0;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | ~Model(){
|
---|
| 43 | for (int i=0; i<vertices.length(); i++)
|
---|
| 44 | delete vertices[i];
|
---|
| 45 | for (int i=0; i<edges.length(); i++)
|
---|
| 46 | delete edges[i];
|
---|
| 47 | for (int i=0; i<faces.length(); i++)
|
---|
| 48 | delete faces[i];
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | Bounds bounds;
|
---|
| 52 |
|
---|
| 53 | int validVertCount;
|
---|
| 54 | int validEdgeCount;
|
---|
| 55 | int validFaceCount;
|
---|
| 56 |
|
---|
| 57 | //
|
---|
| 58 | // Basic model accessor functions
|
---|
| 59 | //
|
---|
[1025] | 60 | simplif::Vertex *vertex(int i) { return vertices(i); }
|
---|
| 61 | simplif::Vec3 & normal(int i){ return normals(i); }
|
---|
| 62 | simplif::Vec2 & texcoord(int i){ return texcoords(i); }
|
---|
| 63 | simplif::Edge *edge(int i) { return edges(i); }
|
---|
| 64 | simplif::Face *face(int i) { return faces(i); }
|
---|
[774] | 65 |
|
---|
| 66 | int vertCount() { return vertices.length(); }
|
---|
| 67 | int normCount() { return normals.length(); }
|
---|
| 68 | int texcoordCount() { return texcoords.length(); }
|
---|
| 69 | int edgeCount() { return edges.length(); }
|
---|
| 70 | int faceCount() { return faces.length(); }
|
---|
| 71 |
|
---|
| 72 | vert_buffer& allVertices() { return vertices; }
|
---|
| 73 | edge_buffer& allEdges() { return edges; }
|
---|
| 74 | face_buffer& allFaces() { return faces; }
|
---|
| 75 |
|
---|
| 76 | //
|
---|
| 77 | // Simplification primitives
|
---|
| 78 | //
|
---|
| 79 | Vertex *newVertex(real x=0.0, real y=0.0, real z=0.0);
|
---|
| 80 | Edge *newEdge(Vertex *,Vertex *);
|
---|
| 81 | Face *newFace(Vertex *, Vertex *, Vertex *);
|
---|
| 82 |
|
---|
| 83 | void killVertex(Vertex *);
|
---|
| 84 | void killEdge(Edge *);
|
---|
| 85 | void killFace(Face *);
|
---|
| 86 |
|
---|
| 87 | void reshapeVertex(Vertex *, real, real, real);
|
---|
| 88 | void remapVertex(Vertex *from, Vertex *to);
|
---|
| 89 |
|
---|
| 90 | void contract(Vertex *v1, Vertex *v2, const Vec3& to,
|
---|
| 91 | face_buffer& changed);
|
---|
| 92 |
|
---|
| 93 | void contract(Vertex *v1,
|
---|
| 94 | const vert_buffer& others,
|
---|
| 95 | const Vec3& to,
|
---|
| 96 | face_buffer& changed);
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | //
|
---|
| 100 | // Simplification convenience procedures
|
---|
| 101 | //
|
---|
| 102 | void removeDegeneracy(face_buffer& changed);
|
---|
| 103 | void contractionRegion(Vertex *v1, Vertex *v2, face_buffer& changed);
|
---|
| 104 | void contractionRegion(Vertex *v1,
|
---|
| 105 | const vert_buffer& vertices,
|
---|
| 106 | face_buffer& changed);
|
---|
| 107 |
|
---|
| 108 | //
|
---|
| 109 | // SMF reader functions
|
---|
| 110 | //
|
---|
| 111 | int in_Vertex(const Vec3&);
|
---|
| 112 | int in_Normal(const Vec3&);
|
---|
| 113 | int in_TexCoord(const Vec2&);
|
---|
| 114 | int in_Face(int v1, int v2, int v3, int n1, int n2, int n3, int t1, int t2, int t3);
|
---|
| 115 | int miin_Face(int v1, int v2, int v3);
|
---|
| 116 |
|
---|
| 117 | /* #ifdef SUPPORT_VCOLOR
|
---|
| 118 | int in_VColor(const Vec3&);
|
---|
| 119 | #endif
|
---|
| 120 | #ifdef SUPPORT_FCOLOR
|
---|
| 121 | int in_FColor(const Vec3&);
|
---|
| 122 | #endif
|
---|
| 123 | */
|
---|
| 124 | //
|
---|
| 125 | // Some random functions that are mostly temporary
|
---|
| 126 | //
|
---|
| 127 |
|
---|
| 128 | Vec3 synthesizeNormal(Vertex *);
|
---|
| 129 | };
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | // NAUTILUS_ADJMODEL_INCLUDED
|
---|
| 134 | #endif
|
---|