| #pragma once |
| |
| #ifndef PLASTICSKELETON_H |
| #define PLASTICSKELETON_H |
| |
| #include <memory> |
| |
| |
| #include "tsmartpointer.h" |
| #include "tpersist.h" |
| #include "tmeshimage.h" // add imported template |
| |
| |
| |
| #include "plastichandle.h" |
| |
| |
| #include <boost/config.hpp> |
| |
| |
| #include <QString> |
| |
| #if (defined TNZEXT_EXPORTS && !defined INCLUDE_HPP) |
| #define REMOVE_INCLUDE_HPP |
| #define INCLUDE_HPP // Exporting templates needs full instantiation |
| #endif |
| |
| #include "tcg_wrap.h" |
| #include "tcg/tcg_vertex.h" |
| #include "tcg/tcg_edge.h" |
| #include "tcg/tcg_face.h" |
| #include "tcg/tcg_mesh.h" |
| |
| #ifdef REMOVE_INCLUDE_HPP |
| #undef INCLUDE_HPP |
| #endif |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TNZEXT_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| |
| |
| |
| class PlasticSkeletonDeformation; |
| |
| |
| |
| |
| |
| |
| |
| |
| struct DVAPI PlasticSkeletonVertex final : public tcg::Vertex<TPointD>, |
| public TPersist { |
| PERSIST_DECLARATION(PlasticSkeletonVertex) |
| |
| private: |
| friend class PlasticSkeleton; |
| |
| QString m_name; |
| int m_number; |
| |
| int m_parent; |
| |
| public: |
| |
| |
| double m_minAngle, m_maxAngle; |
| |
| |
| public: |
| |
| |
| bool m_interpolate; |
| |
| |
| public: |
| PlasticSkeletonVertex(); |
| explicit PlasticSkeletonVertex(const TPointD &pos); |
| |
| operator PlasticHandle() const; |
| operator TPointD() const { return P(); } |
| |
| const QString &name() const { return m_name; } |
| int number() const { return m_number; } |
| |
| int parent() const { return m_parent; } |
| |
| void saveData(TOStream &os) override; |
| void loadData(TIStream &is) override; |
| }; |
| |
| |
| |
| |
| |
| class DVAPI PlasticSkeleton final |
| : public TSmartObject, |
| public tcg::Mesh<PlasticSkeletonVertex, tcg::Edge, tcg::FaceN<3>>, |
| public TPersist { |
| DECLARE_CLASS_CODE |
| PERSIST_DECLARATION(PlasticSkeleton) |
| |
| private: |
| class Imp; |
| std::unique_ptr<Imp> m_imp; |
| |
| public: |
| typedef tcg::Mesh<PlasticSkeletonVertex, tcg::Edge, tcg::FaceN<3>> mesh_type; |
| |
| public: |
| PlasticSkeleton(); |
| PlasticSkeleton(const PlasticSkeleton &other); |
| ~PlasticSkeleton(); |
| |
| PlasticSkeleton &operator=(const PlasticSkeleton &other); |
| |
| int parentVertex(int v) { return vertex(v).m_parent; } |
| |
| void moveVertex(int v, const TPointD &pos); |
| |
| |
| int addVertex(const PlasticSkeletonVertex &vx, |
| int parent); |
| int insertVertex(const PlasticSkeletonVertex &vx, |
| int e); |
| |
| int insertVertex( |
| const PlasticSkeletonVertex &vx, |
| int parent, |
| const std::vector<int> |
| &children); |
| void removeVertex( |
| int v); |
| void clear(); |
| void squeeze(); |
| |
| bool setVertexName(int v, const QString &name); |
| |
| void saveData(TOStream &os) override; |
| void loadData(TIStream &is) override; |
| |
| |
| |
| int closestVertex(const TPointD &pos, double *distance = 0) const; |
| int closestEdge(const TPointD &pos, double *distance = 0) const; |
| |
| std::vector<PlasticHandle> verticesToHandles() const; |
| |
| public: |
| |
| PlasticSkeleton(PlasticSkeleton &&other); |
| PlasticSkeleton &operator=(PlasticSkeleton &&other); |
| |
| private: |
| friend class PlasticSkeletonDeformation; |
| |
| |
| void addListener(PlasticSkeletonDeformation *deformation); |
| void removeListener(PlasticSkeletonDeformation *deformation); |
| }; |
| |
| |
| |
| #ifdef _WIN32 |
| #ifndef TFX_EXPORTS |
| template class DVAPI TSmartPointerT<PlasticSkeleton>; |
| #endif |
| #endif |
| |
| typedef TSmartPointerT<PlasticSkeleton> PlasticSkeletonP; |
| |
| #endif // PLASTICSKELETON_H |