|
Toshihiro Shimizu |
890ddd |
#ifndef TMESHIMAGE_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TMESHIMAGE_INCLUDED
|
|
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"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "timage.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// tcg includes
|
|
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 |
#include "tcg/tcg_mesh_bgl.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TVECTORIMAGE_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 |
//===========================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TTextureVertex (Textured Mesh Vertex Type) declaration
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct RigidPoint : public TPointD {
|
|
Toshihiro Shimizu |
890ddd |
double rigidity;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint() : TPointD(), rigidity(1.0) {}
|
|
Toshihiro Shimizu |
890ddd |
explicit RigidPoint(double x, double y, double rigidity_ = 1.0)
|
|
Toshihiro Shimizu |
890ddd |
: TPointD(x, y), rigidity(rigidity_) {}
|
|
Toshihiro Shimizu |
890ddd |
explicit RigidPoint(const TPointD &point, double rigidity_ = 1.0)
|
|
Toshihiro Shimizu |
890ddd |
: TPointD(point), rigidity(rigidity_) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint &operator=(const TPointD &p)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TPointD::operator=(p);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint operator+(const RigidPoint &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return RigidPoint(x + other.x, y + other.y, rigidity + other.rigidity);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint &operator+=(const RigidPoint &other)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
x += other.x, y += other.y, rigidity += other.rigidity;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint operator-(const RigidPoint &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return RigidPoint(x - other.x, y - other.y, rigidity - other.rigidity);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint &operator-=(const RigidPoint &other)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
x -= other.x, y -= other.y, rigidity -= other.rigidity;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
friend RigidPoint operator*(double a, const RigidPoint &b)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return RigidPoint(a * b.x, a * b.y, a * b.rigidity);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
friend RigidPoint operator*(const RigidPoint &a, double b)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return RigidPoint(a.x * b, a.y * b, a.rigidity * b);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RigidPoint &operator*=(double a)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
x *= a, y *= a, rigidity *= a;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
friend RigidPoint operator*(const TAffine &aff, const RigidPoint &p)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return RigidPoint(aff.operator*(p), p.rigidity);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef tcg::Vertex<rigidpoint> TTextureVertex;</rigidpoint>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct point_traits<rigidpoint> {</rigidpoint>
|
|
Toshihiro Shimizu |
890ddd |
typedef RigidPoint point_type;
|
|
Toshihiro Shimizu |
890ddd |
typedef double value_type;
|
|
Toshihiro Shimizu |
890ddd |
typedef double float_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline static value_type x(const point_type &p) { return p.x; }
|
|
Toshihiro Shimizu |
890ddd |
inline static value_type y(const point_type &p) { return p.y; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TTextureMesh (Textured Mesh Type) declaration
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TTextureMesh : public tcg::TriMesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">>, public TSmartObject, public TPersist</ttexturevertex,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PERSIST_DECLARATION(TTextureMesh)
|
|
Toshihiro Shimizu |
890ddd |
DECLARE_CLASS_CODE
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TTextureMesh();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TTextureMesh(const TTextureMesh &);
|
|
Toshihiro Shimizu |
890ddd |
TTextureMesh &operator=(const TTextureMesh &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int faceContaining(const TPointD &p) const;
|
|
Toshihiro Shimizu |
890ddd |
bool faceContains(int f, const TPointD &p) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD getBBox() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void saveData(TOStream &os);
|
|
Toshihiro Shimizu |
890ddd |
void loadData(TIStream &is);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<ttexturemesh>;</ttexturemesh>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef TSmartPointerT<ttexturemesh> TTextureMeshP;</ttexturemesh>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace boost
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct graph_traits<ttexturemesh></ttexturemesh>
|
|
Toshihiro Shimizu |
890ddd |
: public graph_traits
|
|
Toshihiro Shimizu |
890ddd |
TTextureMesh::edge_type,
|
|
Toshihiro Shimizu |
890ddd |
TTextureMesh::face_type>> {
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace boost
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TMeshImage (Textured Mesh Image) declaration
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TMeshImage : public TImage
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
class Imp;
|
|
Shinya Kitaoka |
262a92 |
std::shared_ptr<imp> m_imp;</imp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
typedef std::vector<ttexturemeshp> meshes_container;</ttexturemeshp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TMeshImage();
|
|
Shinya Kitaoka |
262a92 |
TMeshImage(std::shared_ptr<imp> imp);</imp>
|
|
Toshihiro Shimizu |
890ddd |
~TMeshImage();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TMeshImage(const TMeshImage &other);
|
|
Toshihiro Shimizu |
890ddd |
TMeshImage &operator=(TMeshImage other);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImage::Type getType() const { return TImage::MESH; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD getBBox() const;
|
|
Toshihiro Shimizu |
890ddd |
TImage *cloneImage() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void getDpi(double &dpix, double &dpiy) const;
|
|
Toshihiro Shimizu |
890ddd |
void setDpi(double dpix, double dpiy);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const meshes_container &meshes() const;
|
|
Toshihiro Shimizu |
890ddd |
meshes_container &meshes();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
friend void swap(TMeshImage &a, TMeshImage &b)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::swap(a.m_imp, b.m_imp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TSmartPointerT<tmeshimage>;</tmeshimage>
|
|
Toshihiro Shimizu |
890ddd |
template class DVAPI TDerivedSmartPointerT<tmeshimage, timage="">;</tmeshimage,>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TMeshImageP : public TDerivedSmartPointerT<tmeshimage, timage=""></tmeshimage,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TMeshImageP() {}
|
|
Toshihiro Shimizu |
890ddd |
TMeshImageP(TMeshImage *image) : DerivedSmartPointer(image) {}
|
|
Toshihiro Shimizu |
890ddd |
TMeshImageP(TImageP image) : DerivedSmartPointer(image) {}
|
|
Toshihiro Shimizu |
890ddd |
#if !defined(WIN32)
|
|
Toshihiro Shimizu |
890ddd |
TMeshImageP(TImage *image) : DerivedSmartPointer(TImageP(image))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
operator TImageP()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TImageP(m_pointer);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // TMESHIMAGE_INCLUDED
|