Listing the geometric data in three tables provides a convenient reference to the individual components of each object. Also, the object can be displayed efficiently be using data from the edge table to draw the component lines. Here I discuss about how to create those tables with the help of C++ code.
Vertex table consists of the array of vertices with the coordinate value of each vertex. In C++, a vertex table can be created by creating a class that has . For example
1 2 3 4 5 6 7 8 9 10 | class vertex { private: Point3D *points; public: vertex() { points = new Point3D(); } }; |
Edge table consists of pointers back into vertex to identify the edges for each polygon. For example,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | class edge { public: vertex *ver1; vertex *ver2; bool done; //1 if edge not to be drawn: //0 if edge to be drawn, avoids multiple drawing of the edges edge *adjsur; //pointer to adjacent surface's edge edge() { ver1 = new vertex(); ver2 = new vertex(); done = false; } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class surface { public: edge *edges; float A, B, C, D; int icolor; surface() { edges = new edge(); A = 0.0f; B = 0.0f; C = 0.0f; D = 0.0f; icolor = 0; } } |
Rules for creating Geometric table:
1. Every vertex is listed as an end point for at least two edges.
2. Every edge is part of at least one polygon
3. Each polygon has at least one shared edge.
4. Every surface is close.
Related Article
destination source:https://www.programming-techniques.com/?p=95