FastQuadrics.h
1 /************************************************************
2 * (C) Voxel Farm Inc. 2015
3 */
4 
5 #pragma once
6 
7 #include "matrix.h"
8 
9 namespace VoxelFarm
10 {
12  struct FQ_Vertex
13  {
15  double x, y, z;
17  int type;
19  int faces;
21  bool deleted;
23  int external;
25  unsigned short flags;
27  double maxerror;
28  };
29 
32  typedef int FQ_Face[4];
33 
35  struct CFaceLink
36  {
38  int faceId;
40  int next;
41  };
42 
45  {
46  public:
50  FQ_Face* faces;
56  int faceCount;
60  bool fastBuild;
61  public:
62  CFastQuadrics(void);
63  ~CFastQuadrics(void);
64  public:
66  void allocate(
68  int vertCount,
70  int faceCount);
71 
73  void release();
74 
76  void resize();
77 
79  void swap(CFastQuadrics& mesh);
80 
82  void copy(CFastQuadrics& mesh);
83 
85  void append(CFastQuadrics& mesh);
86 
88  int addVertex(
90  double x,
92  double y,
94  double z,
96  int type,
98  double maxerror = 1000000.0,
100  int external = 0,
102  unsigned short flags = 0);
103 
105  void addFace(
107  int vid0,
109  int vid1,
111  int vid2,
113  int material);
114  private:
115  void addFaceToIndex(FQ_Vertex& v, int fid);
116  };
117 }
void addFace(int vid0, int vid1, int vid2, int material)
Adds a triangle to the mesh.
void swap(CFastQuadrics &mesh)
Swaps one CFastQuadrics with another.
bool deleted
Whether the vertex has been deleted.
Definition: FastQuadrics.h:21
int addVertex(double x, double y, double z, int type, double maxerror=1000000.0, int external=0, unsigned short flags=0)
Adds a vertex to the mesh.
Contains all classes and functions for the VoxelFarm engine.
FQ_Face * faces
Array of faces in the mesh.
Definition: FastQuadrics.h:50
void resize()
Allows one to resize the container to hold vertexCount verts and faceCount faces. ...
int faceCount
Number of faces in the mesh.
Definition: FastQuadrics.h:56
unsigned short flags
Contains contouring flags to differentiate border vertices and roaming vector vertices.
Definition: FastQuadrics.h:25
void append(CFastQuadrics &mesh)
Appends the mesh parameter to the mesh.
CFaceLink * faceIndex
Array of all nodes in adjancency lists.
Definition: FastQuadrics.h:52
int faces
Pointer to the mesh faces adjacent to the vertex.
Definition: FastQuadrics.h:19
Specifies a vertex in a polygonal mesh.
Definition: FastQuadrics.h:12
double x
3D coordinates of the vertex
Definition: FastQuadrics.h:15
int vertexCount
Number of vertices in the mesh.
Definition: FastQuadrics.h:54
int faceLinkCount
Number of adjancency links in the mesh.
Definition: FastQuadrics.h:58
int FQ_Face[4]
Definition: FastQuadrics.h:32
int external
An external piece of data that can be stored in the vertex.
Definition: FastQuadrics.h:23
double maxerror
Maximum error the vertex will tolerate during optimization.
Definition: FastQuadrics.h:27
An efficient mesh representation that features Quadratic Error function simplification using a Multip...
Definition: FastQuadrics.h:44
void release()
Releases memory held by this mesh.
FQ_Vertex * vertices
Array of vertices in the mesh.
Definition: FastQuadrics.h:48
int type
Vertex type. Only vertices of the same type can be collapsed during optimization. ...
Definition: FastQuadrics.h:17
bool fastBuild
Set to true to skip building adjancency lists.
Definition: FastQuadrics.h:60
void copy(CFastQuadrics &mesh)
Copies the mesh parameter to the mesh.
void allocate(int vertCount, int faceCount)
Allocates memory for the vertex and face arrays.