25#ifndef _MODELS_VERTEX_SOLVER_TFMESHQUALITY_H_
26#define _MODELS_VERTEX_SOLVER_TFMESHQUALITY_H_
35#include <unordered_set>
39namespace TissueForge::models::vertex {
50 enum Flag :
unsigned int {
66 std::set<MeshQualityOperation*>
prev;
69 std::set<MeshQualityOperation*>
next;
120 virtual bool check() {
return !(flags & Flag::None); };
162 typedef bool (*OperationCheck)();
163 typedef void (*OperationPrep)();
164 typedef std::vector<int> (*OperationFunction)(std::vector<int>);
166 OperationCheck *opCheck;
167 OperationPrep *opPrep;
168 OperationFunction *opFunc;
176 flags = Flag::Active | Flag::Custom;
189 if(opCheck)
return (*opCheck)();
194 if(opPrep) (*opPrep)();
197 std::vector<int>
implement()
override {
return (*opFunc)(targets); }
212 FloatP_t vertexMergeDist;
219 FloatP_t surfaceDemoteArea;
226 FloatP_t bodyDemoteVolume;
231 FloatP_t edgeSplitDist;
241 std::unordered_set<unsigned int> excludedVertices;
243 std::unordered_set<unsigned int> excludedSurfaces;
245 std::unordered_set<unsigned int> excludedBodies;
250 const FloatP_t &vertexMergeDistCf=0.0001,
251 const FloatP_t &surfaceDemoteAreaCf=0.0001,
252 const FloatP_t &bodyDemoteVolumeCf=0.0001,
253 const FloatP_t &_edgeSplitDistCf=2.0
283 const bool working()
const {
return _working; }
Contains all Vertex, Surface and Body instances.
Definition tfMesh.h:52
An object that schedules topological operations on a mesh to maintain its quality.
Definition tfMeshQuality.h:205
HRESULT excludeBody(const unsigned int &id)
Exclude a body from quality operations.
HRESULT setBodyDemoteVolume(const FloatP_t &_val)
Set the volume below which a body is scheduled to become a vertex.
HRESULT excludeVertex(const unsigned int &id)
Exclude a vertex from quality operations.
static MeshQuality fromString(const std::string &s)
Create an instance from a JSON string representation.
const bool working() const
Test whether quality operations are being done.
Definition tfMeshQuality.h:283
FloatP_t getBodyDemoteVolume() const
Get the volume below which a body is scheduled to become a vertex.
Definition tfMeshQuality.h:312
HRESULT includeVertex(const unsigned int &id)
Include a vertex from quality operations.
std::unordered_set< unsigned int > getExcludedVertices() const
Get the current set of excluded vertices.
Definition tfMeshQuality.h:398
FloatP_t getEdgeSplitDist() const
Get the distance at which two vertices are seperated when a vertex is split.
Definition tfMeshQuality.h:324
std::unordered_set< unsigned int > getExcludedBodies() const
Get the current set of excluded bodies.
Definition tfMeshQuality.h:408
HRESULT setVertexMergeDistance(const FloatP_t &_val)
Set the distance below which two vertices are scheduled for merging.
HRESULT doQuality()
Perform quality operations work.
HRESULT excludeSurface(const unsigned int &id)
Exclude a surface from quality operations.
HRESULT includeSurface(const unsigned int &id)
Include a surface from quality operations.
std::unordered_set< unsigned int > getExcludedSurfaces() const
Get the current set of excluded surfaces.
Definition tfMeshQuality.h:403
FloatP_t getVertexMergeDistance() const
Get the distance below which two vertices are scheduled for merging.
Definition tfMeshQuality.h:288
HRESULT setCollision2D(const bool &_collision2D)
Set whether 2D collisions are implemented.
std::string toString()
Get a JSON string representation.
HRESULT setEdgeSplitDist(const FloatP_t &_val)
Set the distance at which two vertices are seperated when a vertex is split.
std::string str() const
Get a summary string.
FloatP_t getSurfaceDemoteArea() const
Get the area below which a surface is scheduled to become a vertex.
Definition tfMeshQuality.h:300
HRESULT setSurfaceDemoteArea(const FloatP_t &_val)
Set the area below which a surface is scheduled to become a vertex.
HRESULT includeBody(const unsigned int &id)
Include a body from quality operations.
bool getCollision2D() const
Get whether 2D collisions are implemented.
Definition tfMeshQuality.h:338
Custom mesh quality operation.
Definition tfMeshQuality.h:160
std::vector< int > implement() override
Implement this operation.
Definition tfMeshQuality.h:197
bool check() override
Check whether this operation is still valid.
Definition tfMeshQuality.h:188
void prep() override
Do all prep, checks and planning for this operation.
Definition tfMeshQuality.h:193
An operation that modifies the topology of a mesh to improve its quality.
Definition tfMeshQuality.h:48
std::set< MeshQualityOperation * > upstreams() const
Compute all upstream operations.
virtual void prep()
Do all prep, checks and planning for this operation.
Definition tfMeshQuality.h:125
std::set< MeshQualityOperation * > headOperations() const
Compute all upstream operations that have no dependencies.
virtual size_t numNewSurfaces() const
Returns how many surfaces will be created by this operation.
Definition tfMeshQuality.h:135
virtual HRESULT validate()
Validate this operation.
Definition tfMeshQuality.h:113
std::set< MeshQualityOperation * > next
Definition tfMeshQuality.h:69
virtual std::vector< int > implement()
Implement this operation.
Definition tfMeshQuality.h:147
std::mutex lock
Definition tfMeshQuality.h:72
virtual size_t numNewBodies() const
Returns how many bodies will be created by this operation.
Definition tfMeshQuality.h:140
virtual size_t numNewVertices() const
Returns how many vertices will be created by this operation.
Definition tfMeshQuality.h:130
virtual bool check()
Check whether this operation is still valid.
Definition tfMeshQuality.h:120
std::set< MeshQualityOperation * > prev
Definition tfMeshQuality.h:66
std::set< MeshQualityOperation * > downstreams() const
Compute all downstream operations.
HRESULT appendNext(MeshQualityOperation *_next)
Add an operation to the list of next operations.
HRESULT removeNext(MeshQualityOperation *_next)
Remove an operation to the list of next operations.
std::vector< int > targets
Target mesh objects.
Definition tfMeshQuality.h:63
int32_t HRESULT
Definition tf_port.h:255