[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 | {
|
---|
[1526] | 24 | protected:
|
---|
| 25 |
|
---|
| 26 | vert_buffer vertices;
|
---|
| 27 | edge_buffer edges;
|
---|
| 28 | face_buffer faces;
|
---|
| 29 | vec3_buffer normals; // SUS
|
---|
| 30 | vec2_buffer texcoords;
|
---|
[774] | 31 |
|
---|
[1526] | 32 | private:
|
---|
[774] | 33 |
|
---|
[1526] | 34 | void maybeFixFace(Face *);
|
---|
[774] | 35 |
|
---|
[1526] | 36 | public:
|
---|
| 37 |
|
---|
| 38 | Model()
|
---|
| 39 | {
|
---|
| 40 | validVertCount = 0;
|
---|
| 41 | validEdgeCount = 0;
|
---|
| 42 | validFaceCount = 0;
|
---|
| 43 | }
|
---|
[774] | 44 |
|
---|
[1526] | 45 | ~Model()
|
---|
| 46 | {
|
---|
| 47 | for (int i=0; i<vertices.length(); i++)
|
---|
| 48 | {
|
---|
| 49 | delete vertices[i];
|
---|
| 50 | }
|
---|
[774] | 51 |
|
---|
[1526] | 52 | for (int i=0; i<edges.length(); i++)
|
---|
| 53 | {
|
---|
| 54 | delete edges[i];
|
---|
| 55 | }
|
---|
[774] | 56 |
|
---|
[1526] | 57 | for (int i=0; i<faces.length(); i++)
|
---|
| 58 | {
|
---|
| 59 | delete faces[i];
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
[774] | 62 |
|
---|
[1526] | 63 | Bounds bounds;
|
---|
[774] | 64 |
|
---|
[1526] | 65 | int validVertCount;
|
---|
| 66 | int validEdgeCount;
|
---|
| 67 | int validFaceCount;
|
---|
[774] | 68 |
|
---|
[1526] | 69 | //
|
---|
| 70 | // Basic model accessor functions
|
---|
| 71 | //
|
---|
| 72 | simplif::Vertex *vertex(int i) { return vertices(i); }
|
---|
| 73 | simplif::Vec3 & normal(int i){ return normals(i); }
|
---|
| 74 | simplif::Vec2 & texcoord(int i){ return texcoords(i); }
|
---|
| 75 | simplif::Edge *edge(int i) { return edges(i); }
|
---|
| 76 | simplif::Face *face(int i) { return faces(i); }
|
---|
[774] | 77 |
|
---|
[1526] | 78 | int vertCount() { return vertices.length(); }
|
---|
| 79 | int normCount() { return normals.length(); }
|
---|
| 80 | int texcoordCount() { return texcoords.length(); }
|
---|
| 81 | int edgeCount() { return edges.length(); }
|
---|
| 82 | int faceCount() { return faces.length(); }
|
---|
[774] | 83 |
|
---|
[1526] | 84 | vert_buffer& allVertices() { return vertices; }
|
---|
| 85 | edge_buffer& allEdges() { return edges; }
|
---|
| 86 | face_buffer& allFaces() { return faces; }
|
---|
[774] | 87 |
|
---|
[1526] | 88 | //
|
---|
| 89 | // Simplification primitives
|
---|
| 90 | //
|
---|
| 91 | Vertex *newVertex(real x=0.0, real y=0.0, real z=0.0);
|
---|
| 92 | Edge *newEdge(Vertex *,Vertex *);
|
---|
| 93 | Face *newFace(Vertex *, Vertex *, Vertex *);
|
---|
[774] | 94 |
|
---|
[1526] | 95 | void killVertex(Vertex *);
|
---|
| 96 | void killEdge(Edge *);
|
---|
| 97 | void killFace(Face *);
|
---|
[774] | 98 |
|
---|
[1526] | 99 | void reshapeVertex(Vertex *, real, real, real);
|
---|
| 100 | void remapVertex(Vertex *from, Vertex *to);
|
---|
[774] | 101 |
|
---|
[1526] | 102 | void contract(Vertex *v1, Vertex *v2, const Vec3& to,
|
---|
| 103 | face_buffer& changed);
|
---|
[774] | 104 |
|
---|
[1526] | 105 | void contract(Vertex *v1,
|
---|
| 106 | const vert_buffer& others,
|
---|
| 107 | const Vec3& to,
|
---|
| 108 | face_buffer& changed);
|
---|
[774] | 109 |
|
---|
[1526] | 110 | //
|
---|
| 111 | // Simplification convenience procedures
|
---|
| 112 | //
|
---|
| 113 | void removeDegeneracy(face_buffer& changed);
|
---|
| 114 | void contractionRegion(Vertex *v1, Vertex *v2, face_buffer& changed);
|
---|
| 115 | void contractionRegion(Vertex *v1,
|
---|
| 116 | const vert_buffer& vertices,
|
---|
| 117 | face_buffer& changed);
|
---|
[774] | 118 |
|
---|
[1526] | 119 | //
|
---|
| 120 | // SMF reader functions
|
---|
| 121 | //
|
---|
| 122 | int in_Vertex(const Vec3&);
|
---|
| 123 | int in_Normal(const Vec3&);
|
---|
| 124 | int in_TexCoord(const Vec2&);
|
---|
| 125 |
|
---|
| 126 | int in_Face(int v1, int v2, int v3,
|
---|
| 127 | int n1, int n2, int n3,
|
---|
| 128 | int t1, int t2, int t3);
|
---|
| 129 |
|
---|
| 130 | int miin_Face(int v1, int v2, int v3);
|
---|
| 131 |
|
---|
| 132 | /* #ifdef SUPPORT_VCOLOR
|
---|
| 133 | int in_VColor(const Vec3&);
|
---|
| 134 | #endif
|
---|
| 135 | #ifdef SUPPORT_FCOLOR
|
---|
| 136 | int in_FColor(const Vec3&);
|
---|
| 137 | #endif
|
---|
[774] | 138 | */
|
---|
[1526] | 139 | //
|
---|
| 140 | // Some random functions that are mostly temporary
|
---|
| 141 | //
|
---|
[774] | 142 |
|
---|
[1526] | 143 | Vec3 synthesizeNormal(Vertex *);
|
---|
[774] | 144 | };
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | // NAUTILUS_ADJMODEL_INCLUDED
|
---|
| 148 | #endif
|
---|
[1526] | 149 |
|
---|