src/vertexmap.h

Sat, 08 Apr 2023 12:53:15 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sat, 08 Apr 2023 12:53:15 +0300
changeset 342
9fd7dcab6d76
parent 338
719b909a7d2b
permissions
-rw-r--r--

Fix line type 0 format regular expression

#ifndef VERTEXMAP_H
#define VERTEXMAP_H
#include <set>
#include "src/basics.h"
#include "src/model.h"

/**
 * @brief Collects a map of all vertices in a model to all objects that use the specified vertex.
 */
class VertexMap : public QObject
{
	Q_OBJECT
public:
	struct VertexInfo
	{
		glm::vec3 point;
		//std::set<ElementId> objects;
		bool transformSet = false;
		glm::mat4 transform;
	};
	using ApplyFunction = std::function<void(const glm::vec3&, const VertexInfo&)>;
	VertexMap(const QTextDocument *model);
	Q_SLOT void build();
	void apply(ApplyFunction fn) const;
Q_SIGNALS:
	Q_SIGNAL void verticesChanged();
private:
	const QTextDocument* const model;
	QSet<hash_t> vertexHashes;
	std::vector<glm::vec3> vertices;
	std::map<hash_t, VertexInfo> map;
};

#endif // VERTEXMAP_H

mercurial