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
|
---|
12 | simplif: (Id: polymodel.h,v 1.1 1997/02/11 15:21:29 garland Exp)
|
---|
13 |
|
---|
14 | ************************************************************************/
|
---|
15 |
|
---|
16 | #include "AdjPrims.h"
|
---|
17 | #include <gfx/SMF/smf.h>
|
---|
18 | #include <vector>
|
---|
19 |
|
---|
20 | namespace simplif
|
---|
21 | {
|
---|
22 | class Model : public SMF_Model
|
---|
23 | {
|
---|
24 | protected:
|
---|
25 |
|
---|
26 | vert_buffer vertices;
|
---|
27 | edge_buffer edges;
|
---|
28 | face_buffer faces;
|
---|
29 | vec3_buffer normals; // SUS
|
---|
30 | vec2_buffer texcoords;
|
---|
31 |
|
---|
32 | private:
|
---|
33 |
|
---|
34 | void maybeFixFace(Face *);
|
---|
35 |
|
---|
36 | public:
|
---|
37 |
|
---|
38 | Model()
|
---|
39 | {
|
---|
40 | validVertCount = 0;
|
---|
41 | validEdgeCount = 0;
|
---|
42 | validFaceCount = 0;
|
---|
43 | }
|
---|
44 |
|
---|
45 | ~Model()
|
---|
46 | {
|
---|
47 | for (int i=0; i<vertices.length(); i++)
|
---|
48 | {
|
---|
49 | delete vertices[i];
|
---|
50 | }
|
---|
51 |
|
---|
52 | for (int i=0; i<edges.length(); i++)
|
---|
53 | {
|
---|
54 | delete edges[i];
|
---|
55 | }
|
---|
56 |
|
---|
57 | for (int i=0; i<faces.length(); i++)
|
---|
58 | {
|
---|
59 | delete faces[i];
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | Bounds bounds;
|
---|
64 |
|
---|
65 | int validVertCount;
|
---|
66 | int validEdgeCount;
|
---|
67 | int validFaceCount;
|
---|
68 |
|
---|
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);}
|
---|
77 |
|
---|
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();}
|
---|
83 |
|
---|
84 | vert_buffer& allVertices() {return vertices;}
|
---|
85 | edge_buffer& allEdges() {return edges;}
|
---|
86 | face_buffer& allFaces() {return faces;}
|
---|
87 |
|
---|
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 *);
|
---|
94 |
|
---|
95 | void killVertex(Vertex *);
|
---|
96 | void killEdge(Edge *);
|
---|
97 | void killFace(Face *);
|
---|
98 |
|
---|
99 | void reshapeVertex(Vertex *, real, real, real);
|
---|
100 | void remapVertex(Vertex *from, Vertex *to);
|
---|
101 |
|
---|
102 | void contract(Vertex *v1, Vertex *v2, const Vec3& to,
|
---|
103 | face_buffer& changed);
|
---|
104 |
|
---|
105 | void contract(Vertex *v1,
|
---|
106 | const vert_buffer& others,
|
---|
107 | const Vec3& to,
|
---|
108 | face_buffer& changed);
|
---|
109 |
|
---|
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);
|
---|
118 |
|
---|
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
|
---|
138 | */
|
---|
139 | //
|
---|
140 | // Some random functions that are mostly temporary
|
---|
141 | //
|
---|
142 |
|
---|
143 | Vec3 synthesizeNormal(Vertex *);
|
---|
144 | };
|
---|
145 | }
|
---|
146 |
|
---|
147 | // NAUTILUS_ADJMODEL_INCLUDED
|
---|
148 | #endif
|
---|
149 |
|
---|