本学期的高级计算机图像学作业的一部分, 实现halfedge结构。 我用obj结构和halfedge互相转化来完成这样一件事。
halfedge.h:
#ifndef HALFEDGE_VECTOR_H_
#define HALFEDGE_VECTOR_H_
#include <iostream>
using namespace std;
#include <vector>
typedef struct
{
float x;
float y;
float z;
int edge_index;
// whether a new point
bool isnew;
// the neighbour of a point
vector<int> beighbour;
} halfegde_point;
typedef struct
{
int one_edge_index;
} halfedge_face;
typedef struct
{
int original_point_index;
int face_index;
int twin_edge_index;
int next_edge_index;
int previous_edge_index;
// whether splited
bool issplited;
// splited point's index
int split_point_index;
} halfegde;
//默认逆时针
bool twins(vector<halfegde> e, halfegde a, halfegde b);
// index begin from 0;
// transform obj to halfedge
void obj2halfedge(float (*point)[3], int point_count, int (*face)[3], int face_count, vector<halfegde_point> &halfegde_p, vector<halfedge_face> &halfegde_f, vector<halfegde> &e);
// transform halfedge to obj
void halfedge2obj(vector<halfegde_point> halfegde_p, vector<halfedge_face> halfegde_f, vector<halfegde> e, float (*point)[3], int (*face)[3]);
// calculate points neighbour
void update_ne