[774] | 1 | #ifndef NAUTILUS_ADJPRIMS_INCLUDED // -*- C++ -*-
|
---|
| 2 | #define NAUTILUS_ADJPRIMS_INCLUDED
|
---|
| 3 |
|
---|
| 4 | /************************************************************************
|
---|
| 5 |
|
---|
| 6 | Primitive entities for adjacency models (AdjModel).
|
---|
| 7 | $Id: AdjPrims.h,v 1.4 1997/03/18 18:39:34 garland Exp $
|
---|
| 8 |
|
---|
| 9 | Adapted from:
|
---|
| 10 | mlab: (Id: primitives.h,v 1.7 1997/02/06 16:30:14 garland Exp)
|
---|
| 11 | via
|
---|
[1025] | 12 | simplif: (Id: primitives.h,v 1.3 1997/02/18 21:11:29 garland Exp)
|
---|
[774] | 13 |
|
---|
| 14 | ************************************************************************/
|
---|
| 15 |
|
---|
| 16 | //#include "Nautilus.h"
|
---|
| 17 | #include "NPrim.h"
|
---|
| 18 | #include <gfx/tools/Buffer.h>
|
---|
| 19 | #include <gfx/math/Vec3.h>
|
---|
| 20 | #include <gfx/math/Vec2.h>
|
---|
| 21 | #include <gfx/geom/3D.h>
|
---|
| 22 |
|
---|
[1025] | 23 | namespace simplif
|
---|
[774] | 24 | {
|
---|
| 25 | class Vertex;
|
---|
| 26 | class Edge;
|
---|
| 27 | class Face;
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | typedef buffer<Vertex *> vert_buffer;
|
---|
| 31 | typedef buffer<Edge *> edge_buffer;
|
---|
| 32 | typedef buffer<Face *> face_buffer;
|
---|
| 33 | typedef buffer<Vec3> vec3_buffer;
|
---|
| 34 | typedef buffer<Vec2> vec2_buffer;
|
---|
| 35 |
|
---|
| 36 | extern void untagFaceLoop(Vertex *v);
|
---|
| 37 | extern void collectFaceLoop(Vertex *v, face_buffer& faces);
|
---|
| 38 |
|
---|
| 39 | #define EDGE_BOGUS 0
|
---|
| 40 | #define EDGE_BORDER 1
|
---|
| 41 | #define EDGE_MANIFOLD 2
|
---|
| 42 | #define EDGE_NONMANIFOLD 3
|
---|
| 43 | extern int classifyEdge(Edge *);
|
---|
| 44 |
|
---|
| 45 | #define VERTEX_INTERIOR 0
|
---|
| 46 | #define VERTEX_BORDER 1
|
---|
| 47 | #define VERTEX_BORDER_ONLY 2
|
---|
| 48 | extern int classifyVertex(Vertex *);
|
---|
| 49 |
|
---|
| 50 | ////////////////////////////////////////////////////////////////////////
|
---|
| 51 | //
|
---|
| 52 | // The actual class definitions
|
---|
| 53 | //
|
---|
| 54 |
|
---|
| 55 | class VProp
|
---|
| 56 | {
|
---|
| 57 | public:
|
---|
| 58 | Vec3 color;
|
---|
| 59 | };
|
---|
| 60 |
|
---|
| 61 | class FProp
|
---|
| 62 | {
|
---|
| 63 | public:
|
---|
| 64 | Vec3 color;
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | class Vertex : public Vec3, public NTaggedPrim
|
---|
| 68 | {
|
---|
| 69 | edge_buffer edge_uses;
|
---|
| 70 |
|
---|
| 71 | public:
|
---|
| 72 | #ifdef SUPPORT_VCOLOR
|
---|
| 73 | VProp *props;
|
---|
| 74 | #endif
|
---|
| 75 |
|
---|
| 76 | Vertex(real x, real y, real z) : Vec3(x, y, z), edge_uses(6) {
|
---|
| 77 | #ifdef SUPPORT_VCOLOR
|
---|
| 78 | props = NULL;
|
---|
| 79 | #endif
|
---|
| 80 | }
|
---|
| 81 | //
|
---|
| 82 | // Standard methods for all objects
|
---|
| 83 | //
|
---|
| 84 | void kill();
|
---|
| 85 | edge_buffer& edgeUses() { return edge_uses; }
|
---|
| 86 |
|
---|
| 87 | //
|
---|
| 88 | // Basic primitives for manipulating model topology
|
---|
| 89 | //
|
---|
| 90 | void linkEdge(Edge *);
|
---|
| 91 | void unlinkEdge(Edge *);
|
---|
| 92 | void remapTo(Vertex *v);
|
---|
| 93 |
|
---|
| 94 | unsigned int vID;
|
---|
| 95 | };
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | class Edge : public NPrim
|
---|
| 99 | {
|
---|
| 100 | private:
|
---|
| 101 |
|
---|
| 102 | Vertex *v1;
|
---|
| 103 |
|
---|
| 104 | face_buffer *face_uses;
|
---|
| 105 | Edge *twin;
|
---|
| 106 |
|
---|
| 107 | Edge(Edge *twin, Vertex *org); // the twin constructor
|
---|
| 108 |
|
---|
| 109 | public:
|
---|
| 110 | Edge(Vertex *, Vertex *);
|
---|
| 111 | ~Edge();
|
---|
| 112 |
|
---|
| 113 | //
|
---|
| 114 | // Fundamental Edge accessors
|
---|
| 115 | //
|
---|
| 116 | Vertex *org() { return v1; }
|
---|
| 117 | Vertex *dest() { return twin->v1; }
|
---|
| 118 | Edge *sym() { return twin; }
|
---|
| 119 |
|
---|
| 120 | //
|
---|
| 121 | // Standard methods for all objects
|
---|
| 122 | //
|
---|
| 123 | void kill();
|
---|
| 124 | face_buffer& faceUses() { return *face_uses; }
|
---|
| 125 |
|
---|
| 126 | //
|
---|
| 127 | // Basic primitives for manipulating model topology
|
---|
| 128 | //
|
---|
| 129 | void linkFace(Face *);
|
---|
| 130 | void unlinkFace(Face *);
|
---|
| 131 | void remapEndpoint(Vertex *from, Vertex *to);
|
---|
| 132 | void remapTo(Edge *);
|
---|
| 133 | };
|
---|
| 134 |
|
---|
| 135 | class Face : public Face3, public NTaggedPrim
|
---|
| 136 | {
|
---|
| 137 | Edge *edges[3];
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | public:
|
---|
| 141 | #ifdef SUPPORT_FCOLOR
|
---|
| 142 | FProp *props;
|
---|
| 143 | #endif
|
---|
| 144 |
|
---|
| 145 | Face(Edge *, Edge *, Edge *);
|
---|
| 146 |
|
---|
| 147 | //
|
---|
| 148 | // Basic Face accessors
|
---|
| 149 | //
|
---|
| 150 | const Vec3& vertexPos(int i) const { return *edges[i]->org(); }
|
---|
| 151 | void vertexPos(int, const Vec3&) {
|
---|
| 152 | fatal_error("Face: can't directly set vertex position.");
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | Vertex *vertex(int i) { return edges[i]->org(); }
|
---|
| 156 | const Vertex *vertex(int i) const { return edges[i]->org(); }
|
---|
| 157 | Edge *edge(int i) { return edges[i]; }
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | //
|
---|
| 161 | // Standard methods for all objects
|
---|
| 162 | //
|
---|
| 163 | void kill();
|
---|
| 164 |
|
---|
| 165 | void remapEdge(Edge *from, Edge *to);
|
---|
| 166 |
|
---|
| 167 | int igeo; // SUS
|
---|
| 168 | Vec3 vertex_normals[3]; // SUS
|
---|
| 169 | Vec2 vertex_texts[3]; //Carlos
|
---|
| 170 | int normals[3];
|
---|
| 171 | int texcoords[3];
|
---|
| 172 | };
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 | // NAUTILUS_ADJPRIMS_INCLUDED
|
---|
| 177 | #endif
|
---|