LBPM/analysis/dcel.h

111 lines
3.0 KiB
C
Raw Permalink Normal View History

2023-10-23 03:18:20 -05:00
/*
Copyright 2013--2018 James E. McClure, Virginia Polytechnic & State University
Copyright Equnior ASA
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
2020-06-26 14:53:23 -05:00
#ifndef DCEL_INC
#define DCEL_INC
2018-07-27 15:23:39 -05:00
#include <vector>
2018-09-09 22:51:52 -05:00
#include "analysis/pmmc.h"
2018-07-27 15:23:39 -05:00
2021-09-18 15:32:32 -05:00
/**
* \class Vertex
* @brief store vertex for DCEL data structure
2018-07-27 15:23:39 -05:00
*/
// Vertex structure
class Vertex {
2018-07-27 15:23:39 -05:00
public:
Vertex() { d_data.resize(12); }
~Vertex() = default;
Vertex(const Vertex &) = delete;
Vertex operator=(const Vertex &) = delete;
2018-09-28 15:20:50 -05: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 15:20:50 -05: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 15:20:50 -05:00
int IncidentEdge();
2018-09-28 15:20:50 -05:00
// Return the number of points
inline int size() const { return d_data.size(); }
2018-09-28 15:20:50 -05:00
2018-07-27 15:23:39 -05:00
private:
std::vector<Point> d_data;
2018-07-27 15:23:39 -05:00
};
2021-09-18 15:32:32 -05:00
/**
* \class Halfedge
* @brief store half edge for DCEL data structure
*/
class Halfedge {
2018-07-27 15:23:39 -05:00
public:
Halfedge() = default;
~Halfedge() = default;
Halfedge(const Halfedge &) = delete;
Halfedge operator=(const Halfedge &) = delete;
2018-09-28 15:20:50 -05: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 15:20:50 -05:00
inline int size() const { return d_data.size(); }
inline void resize(int N) { d_data.resize(N); }
2018-09-28 15:20:50 -05: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 15:20:50 -05:00
2018-07-27 15:23:39 -05:00
private:
std::vector<std::array<int, 6>> d_data;
2018-07-27 15:23:39 -05:00
};
2021-09-18 15:32:32 -05:00
/**
* \class DCEL
* @details doubly connected edge list data structure
*/
class DCEL {
2018-07-27 15:23:39 -05: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 15:51:37 -05:00
2018-07-27 15:23:39 -05:00
private:
std::vector<int> FaceData;
2018-07-27 15:23:39 -05:00
};
2020-06-26 14:53:23 -05:00
void iso_surface(const Array<double> &Field, const double isovalue);
2020-06-26 14:53:23 -05:00
#endif