Files
LBPM/analysis/dcel.h

95 lines
2.3 KiB
C
Raw Normal View History

2020-06-26 15:53:23 -04:00
#ifndef DCEL_INC
#define DCEL_INC
2018-07-27 16:23:39 -04:00
#include <vector>
2018-09-09 23:51:52 -04:00
#include "analysis/pmmc.h"
2018-07-27 16:23:39 -04:00
2021-09-18 16:32:32 -04:00
/**
* \class Vertex
* @brief store vertex for DCEL data structure
2018-07-27 16:23:39 -04:00
*/
// Vertex structure
class Vertex {
2018-07-27 16:23:39 -04:00
public:
Vertex() { d_data.resize(12); }
~Vertex() = default;
Vertex(const Vertex &) = delete;
Vertex operator=(const Vertex &) = delete;
2018-09-28 16:20:50 -04:00
// Add/assign a point
inline void add(const Point &P) { d_data.push_back(P); }
inline void assign(int idx, const Point &P) { d_data[idx] = P; }
2018-09-28 16:20:50 -04:00
// Get a point
inline Point &coords(int idx) { return d_data[idx]; }
inline const Point &coords(int idx) const { return d_data[idx]; }
2018-09-28 16:20:50 -04:00
int IncidentEdge();
2018-09-28 16:20:50 -04:00
// Return the number of points
inline int size() const { return d_data.size(); }
2018-09-28 16:20:50 -04:00
2018-07-27 16:23:39 -04:00
private:
std::vector<Point> d_data;
2018-07-27 16:23:39 -04:00
};
2021-09-18 16:32:32 -04:00
/**
* \class Halfedge
* @brief store half edge for DCEL data structure
*/
class Halfedge {
2018-07-27 16:23:39 -04:00
public:
Halfedge() = default;
~Halfedge() = default;
Halfedge(const Halfedge &) = delete;
Halfedge operator=(const Halfedge &) = delete;
2018-09-28 16:20:50 -04:00
inline int v1(int edge) const { return d_data[edge][0]; }
inline int v2(int edge) const { return d_data[edge][1]; }
inline int face(int edge) const { return d_data[edge][2]; }
inline int twin(int edge) const { return d_data[edge][3]; }
inline int prev(int edge) const { return d_data[edge][4]; }
inline int next(int edge) const { return d_data[edge][5]; }
2018-09-28 16:20:50 -04:00
inline int size() const { return d_data.size(); }
inline void resize(int N) { d_data.resize(N); }
2018-09-28 16:20:50 -04:00
inline int &data(int i, int j) { return d_data[j][i]; }
inline const int &data(int i, int j) const { return d_data[j][i]; }
2018-09-28 16:20:50 -04:00
2018-07-27 16:23:39 -04:00
private:
std::vector<std::array<int, 6>> d_data;
2018-07-27 16:23:39 -04:00
};
2021-09-18 16:32:32 -04:00
/**
* \class DCEL
* @details doubly connected edge list data structure
*/
class DCEL {
2018-07-27 16:23:39 -04:00
public:
DCEL();
~DCEL();
int face();
Vertex vertex;
Halfedge halfedge;
void LocalIsosurface(const DoubleArray &A, double value, int i, int j,
int k);
void Write();
int Face(int index);
double origin(int edge);
double EdgeAngle(int edge);
Point TriNormal(int edge);
int TriangleCount;
int VertexCount;
2018-07-30 16:51:37 -04:00
2018-07-27 16:23:39 -04:00
private:
std::vector<int> FaceData;
2018-07-27 16:23:39 -04:00
};
2020-06-26 15:53:23 -04:00
void iso_surface(const Array<double> &Field, const double isovalue);
2020-06-26 15:53:23 -04:00
#endif