2019-12-14 13:28:14 +00:00
|
|
|
#ifndef DUST3D_RECOMBINER_H
|
|
|
|
#define DUST3D_RECOMBINER_H
|
2019-02-18 12:57:18 +00:00
|
|
|
#include <QVector3D>
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
|
|
|
#include <map>
|
2019-12-14 13:28:14 +00:00
|
|
|
#include "meshcombiner.h"
|
2019-02-18 12:57:18 +00:00
|
|
|
|
2019-12-14 13:28:14 +00:00
|
|
|
class MeshRecombiner
|
2019-02-18 12:57:18 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
void setVertices(const std::vector<QVector3D> *vertices,
|
2019-12-14 13:28:14 +00:00
|
|
|
const std::vector<std::pair<MeshCombiner::Source, size_t>> *verticesSourceIndices);
|
2019-02-18 12:57:18 +00:00
|
|
|
void setFaces(const std::vector<std::vector<size_t>> *faces);
|
|
|
|
const std::vector<QVector3D> ®eneratedVertices();
|
2019-12-14 13:28:14 +00:00
|
|
|
const std::vector<std::pair<MeshCombiner::Source, size_t>> ®eneratedVerticesSourceIndices();
|
2019-02-18 12:57:18 +00:00
|
|
|
const std::vector<std::vector<size_t>> ®eneratedFaces();
|
|
|
|
bool recombine();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::vector<QVector3D> *m_vertices = nullptr;
|
2019-12-14 13:28:14 +00:00
|
|
|
const std::vector<std::pair<MeshCombiner::Source, size_t>> *m_verticesSourceIndices = nullptr;
|
2019-02-18 12:57:18 +00:00
|
|
|
const std::vector<std::vector<size_t>> *m_faces = nullptr;
|
|
|
|
std::vector<QVector3D> m_regeneratedVertices;
|
2019-12-14 13:28:14 +00:00
|
|
|
std::vector<std::pair<MeshCombiner::Source, size_t>> m_regeneratedVerticesSourceIndices;
|
2019-02-18 12:57:18 +00:00
|
|
|
std::vector<std::vector<size_t>> m_regeneratedFaces;
|
|
|
|
std::map<std::pair<size_t, size_t>, size_t> m_halfEdgeToFaceMap;
|
|
|
|
std::map<size_t, size_t> m_facesInSeamArea;
|
|
|
|
std::set<size_t> m_goodSeams;
|
|
|
|
|
|
|
|
bool addFaceToHalfEdgeToFaceMap(size_t faceIndex,
|
|
|
|
std::map<std::pair<size_t, size_t>, size_t> &halfEdgeToFaceMap);
|
|
|
|
bool buildHalfEdgeToFaceMap(std::map<std::pair<size_t, size_t>, size_t> &halfEdgeToFaceMap);
|
|
|
|
bool convertHalfEdgesToEdgeLoops(const std::vector<std::pair<size_t, size_t>> &halfEdges,
|
|
|
|
std::vector<std::vector<size_t>> *edgeLoops);
|
|
|
|
size_t splitSeamVerticesToIslands(const std::map<size_t, std::vector<size_t>> &seamEdges,
|
|
|
|
std::map<size_t, size_t> *vertexToIslandMap);
|
|
|
|
void copyNonSeamFacesAsRegenerated();
|
|
|
|
size_t adjustTrianglesFromSeam(std::vector<size_t> &edgeLoop, size_t seamIndex);
|
|
|
|
size_t otherVertexOfTriangle(const std::vector<size_t> &face, const std::vector<size_t> &indices);
|
|
|
|
bool bridge(const std::vector<size_t> &first, const std::vector<size_t> &second);
|
|
|
|
size_t nearestIndex(const QVector3D &position, const std::vector<size_t> &edgeLoop);
|
|
|
|
void removeReluctantVertices();
|
|
|
|
void fillPairs(const std::vector<size_t> &small, const std::vector<size_t> &large);
|
2019-12-18 14:16:52 +00:00
|
|
|
void updateEdgeLoopNeighborVertices(const std::vector<size_t> &edgeLoop);
|
2019-02-18 12:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|