#pragma once #include "StructureGraph.h" using namespace Structure; #include "RMF.h" extern int randomCount; extern int uniformTriCount; struct ParameterCoord{ float u, v; float theta, psi; float origOffset; Eigen::Vector3f origPoint; Eigen::Vector3f origNormal; Structure::Node * origNode; ParameterCoord(){ u = v = -1; theta = psi = 0; origOffset = 0; origNode = NULL; } ParameterCoord(float theta, float psi, float u, float v = 0, float offset = 0, Structure::Node * node = NULL){ this->u = u; this->v = v; this->theta = theta; this->psi = psi; this->origOffset = offset; this->origNode = node; } bool operator < (const ParameterCoord& other) const{ return (u < other.u); } }; static inline QDebug operator<<(QDebug dbg, const ParameterCoord &c){ dbg.nospace() << QString("[ %1, %2] - theta = %3 \tpsi = %4").arg(c.u).arg(c.v).arg(c.theta).arg(c.psi); return dbg.space(); } typedef QMap > SynthData; struct Synthesizer{ // Generate sample points in the parameter domain static QVector genPointCoordsCurve( Structure::Curve * curve, const std::vector & points, const std::vector & normals ); static QVector genPointCoordsSheet( Structure::Sheet * sheet, const std::vector & points, const std::vector & normals ); static QVector genFeatureCoords( Structure::Node * node ); static QVector genEdgeCoords( Structure::Node * node ); static QVector genRandomCoords( Structure::Node * node, int samples_count ); static QVector genUniformCoords( Structure::Node * node, float sampling_resolution = -1); static QVector genRemeshCoords( Structure::Node * node ); static QVector genUniformTrisCoords( Structure::Node * node ); static QVector genSampleCoordsCurve(Structure::Curve * curve, int samplingType = Features | Random); static QVector genSampleCoordsSheet(Structure::Sheet * sheet, int samplingType = Features | Random); // Compute the geometry on given samples in the parameter domain static void sampleGeometryCurve( QVector samples, Structure::Curve * curve, QVector &offsets, QVector &normals); static void sampleGeometrySheet( QVector samples, Structure::Sheet * sheet, QVector &offsets, QVector &normals ); // Preparation enum SamplingType{ Features = 1, Edges = 2, Random = 4, Uniform = 8, All = 16, AllNonUniform = 32, Remeshing = 64, TriUniform = 128 }; static void prepareSynthesizeCurve( Structure::Curve * curve1, Structure::Curve * curve2, int samplingType, SynthData & output ); static void prepareSynthesizeSheet( Structure::Sheet * sheet1, Structure::Sheet * sheet2, int samplingType, SynthData & output ); // Blend geometries static void blendGeometryCurves( Structure::Curve * curve, float alpha, const SynthData & data, QVector &points, QVector &normals, bool isApprox); static void blendGeometrySheets( Structure::Sheet * sheet, float alpha, const SynthData & data, QVector &points, QVector &normals, bool isApprox); // Reconstruction on given base skeleton static void reconstructGeometryCurve( Structure::Curve * base_curve, const QVector &in_samples, const QVector &in_offsets, const QVector &in_normals, QVector &out_points, QVector &out_normals, bool isApprox); static void reconstructGeometrySheet( Structure::Sheet * base_sheet, const QVector &in_samples, const QVector &in_offsets, const QVector &in_normals, QVector &out_points, QVector &out_normals, bool isApprox); // Blend skeleton bases static void blendCurveBases(Structure::Curve * curve1, Structure::Curve * curve2, float alpha); static void blendSheetBases(Structure::Sheet * sheet1, Structure::Sheet * sheet2, float alpha); // Helper functions static RMF consistentFrame( Structure::Curve * curve, Array1D_Vector4d & coords ); // IO static void saveSynthesisData(Structure::Node *node, QString prefix, SynthData & input); static int loadSynthesisData(Structure::Node *node, QString prefix, SynthData & output); static void writeXYZ( QString filename, std::vector points, std::vector normals ); }; Q_DECLARE_METATYPE(Eigen::Vector3f) Q_DECLARE_METATYPE(QVector) Q_DECLARE_METATYPE(QVector) Q_DECLARE_METATYPE(QVector) Q_DECLARE_METATYPE(QVector)