|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef PLASTICSKELETON_H
|
|
Toshihiro Shimizu |
890ddd |
#define PLASTICSKELETON_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
262a92 |
#include <memory></memory>
|
|
Shinya Kitaoka |
262a92 |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tsmartpointer.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpersist.h"
|
|
shun_iwasawa |
0cae24 |
#include "tmeshimage.h" // add imported template
|
|
shun_iwasawa |
0cae24 |
// instance tcg::Vertex<tpointd> (for Windows dll)</tpointd>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzExt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "plastichandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Boost includes
|
|
Toshihiro Shimizu |
890ddd |
#include <boost config.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qstring></qstring>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if (defined TNZEXT_EXPORTS && !defined INCLUDE_HPP)
|
|
Toshihiro Shimizu |
890ddd |
#define REMOVE_INCLUDE_HPP
|
|
Shinya Kitaoka |
120a6e |
#define INCLUDE_HPP // Exporting templates needs full instantiation
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcg_wrap.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcg/tcg_vertex.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcg/tcg_edge.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcg/tcg_face.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcg/tcg_mesh.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef REMOVE_INCLUDE_HPP
|
|
Toshihiro Shimizu |
890ddd |
#undef INCLUDE_HPP
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZEXT_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PlasticSkeletonDeformation;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==========================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// PlasticSkeletonVertex declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! PlasticSkeletonVertex is the vertex of a plastic skeleton object.
|
|
Shinya Kitaoka |
d1f6c4 |
struct DVAPI PlasticSkeletonVertex final : public tcg::Vertex<tpointd>,</tpointd>
|
|
Shinya Kitaoka |
d1f6c4 |
public TPersist {
|
|
Shinya Kitaoka |
120a6e |
PERSIST_DECLARATION(PlasticSkeletonVertex)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
friend class PlasticSkeleton;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString m_name; //!< Vertex name
|
|
Shinya Kitaoka |
120a6e |
int m_number; //!< Vertex \a number - assigned persistently upon addition
|
|
Shinya Kitaoka |
120a6e |
//!< in a skeleton
|
|
Shinya Kitaoka |
120a6e |
int m_parent; //!< Index of the parent vertex in the skeleton
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
// Tool data
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double m_minAngle, m_maxAngle; //!< Minimum and maximum accepted angles when
|
|
Shinya Kitaoka |
38fd86 |
//! updating the vertex
|
|
Shinya Kitaoka |
38fd86 |
//!< position with the mouse. In degrees.
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
// Handle data
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_interpolate; //!< Whether the vertex needs to be interpolated (see
|
|
Shinya Kitaoka |
38fd86 |
//! plasticdeformer.h)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PlasticSkeletonVertex();
|
|
Shinya Kitaoka |
120a6e |
explicit PlasticSkeletonVertex(const TPointD &pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
operator PlasticHandle() const;
|
|
Shinya Kitaoka |
120a6e |
operator TPointD() const { return P(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const QString &name() const { return m_name; }
|
|
Shinya Kitaoka |
120a6e |
int number() const { return m_number; } // Should be removed
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int parent() const { return m_parent; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void saveData(TOStream &os) override;
|
|
Shinya Kitaoka |
473e70 |
void loadData(TIStream &is) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// PlasticSkeleton declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI PlasticSkeleton final
|
|
Shinya Kitaoka |
120a6e |
: public TSmartObject,
|
|
Shinya Kitaoka |
120a6e |
public tcg::Mesh<plasticskeletonvertex, tcg::edge,="" tcg::facen<3="">>,</plasticskeletonvertex,>
|
|
Shinya Kitaoka |
120a6e |
public TPersist {
|
|
Shinya Kitaoka |
120a6e |
DECLARE_CLASS_CODE
|
|
Shinya Kitaoka |
120a6e |
PERSIST_DECLARATION(PlasticSkeleton)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
class Imp;
|
|
Shinya Kitaoka |
120a6e |
std::unique_ptr<imp> m_imp;</imp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef tcg::Mesh<plasticskeletonvertex, tcg::edge,="" tcg::facen<3="">> mesh_type;</plasticskeletonvertex,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PlasticSkeleton();
|
|
Shinya Kitaoka |
120a6e |
PlasticSkeleton(const PlasticSkeleton &other);
|
|
Shinya Kitaoka |
120a6e |
~PlasticSkeleton();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
PlasticSkeleton &operator=(const PlasticSkeleton &other);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int parentVertex(int v) { return vertex(v).m_parent; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void moveVertex(int v, const TPointD &pos); //!< Moves a vertex to the
|
|
Shinya Kitaoka |
38fd86 |
//! specified position, informing
|
|
Shinya Kitaoka |
38fd86 |
//! associated deformers
|
|
Shinya Kitaoka |
120a6e |
int addVertex(const PlasticSkeletonVertex &vx,
|
|
Shinya Kitaoka |
120a6e |
int parent); //!< Adds a vertex to the skeleton
|
|
Shinya Kitaoka |
120a6e |
int insertVertex(const PlasticSkeletonVertex &vx,
|
|
Shinya Kitaoka |
120a6e |
int e); //!< Inserts a vertex splitting an existing edge
|
|
Shinya Kitaoka |
120a6e |
//!< \note Inserted Vertex will connect to parent first
|
|
Shinya Kitaoka |
120a6e |
int insertVertex(
|
|
Shinya Kitaoka |
120a6e |
const PlasticSkeletonVertex &vx,
|
|
Shinya Kitaoka |
120a6e |
int parent, //!< Generalization of vertex addition/insertion,
|
|
Shinya Kitaoka |
120a6e |
const std::vector<int></int>
|
|
Shinya Kitaoka |
120a6e |
&children); //!< it is useful as inverse of vertex removal.
|
|
Shinya Kitaoka |
120a6e |
void removeVertex(
|
|
Shinya Kitaoka |
120a6e |
int v); //!< Removes a vertex, reattaching all its children to parent
|
|
Shinya Kitaoka |
120a6e |
void clear();
|
|
Shinya Kitaoka |
120a6e |
void squeeze();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool setVertexName(int v, const QString &name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void saveData(TOStream &os) override;
|
|
Shinya Kitaoka |
473e70 |
void loadData(TIStream &is) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Utility functions
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int closestVertex(const TPointD &pos, double *distance = 0) const;
|
|
Shinya Kitaoka |
120a6e |
int closestEdge(const TPointD &pos, double *distance = 0) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<plastichandle> verticesToHandles() const;</plastichandle>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
// RValues-related functions
|
|
Shinya Kitaoka |
120a6e |
PlasticSkeleton(PlasticSkeleton &&other);
|
|
Shinya Kitaoka |
120a6e |
PlasticSkeleton &operator=(PlasticSkeleton &&other);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
friend class PlasticSkeletonDeformation; // Skeleton deformations can
|
|
Shinya Kitaoka |
120a6e |
// register to be notified
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void addListener(PlasticSkeletonDeformation *deformation);
|
|
Shinya Kitaoka |
120a6e |
void removeListener(PlasticSkeletonDeformation *deformation);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
|
e280ae |
#ifndef TFX_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<plasticskeleton>;</plasticskeleton>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
|
e280ae |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef TSmartPointerT<plasticskeleton> PlasticSkeletonP;</plasticskeleton>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // PLASTICSKELETON_H
|