|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
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 |
|
|
Shinya Kitaoka |
d1f6c4 |
struct RigidPoint final : public TPointD {
|
|
Shinya Kitaoka |
120a6e |
double rigidity;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RigidPoint() : TPointD(), rigidity(1.0) {}
|
|
Shinya Kitaoka |
120a6e |
explicit RigidPoint(double x, double y, double rigidity_ = 1.0)
|
|
Shinya Kitaoka |
120a6e |
: TPointD(x, y), rigidity(rigidity_) {}
|
|
Shinya Kitaoka |
120a6e |
explicit RigidPoint(const TPointD &point, double rigidity_ = 1.0)
|
|
Shinya Kitaoka |
120a6e |
: TPointD(point), rigidity(rigidity_) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
RigidPoint &operator=(const TPointD &p) {
|
|
Shinya Kitaoka |
120a6e |
TPointD::operator=(p);
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RigidPoint operator+(const RigidPoint &other) const {
|
|
Shinya Kitaoka |
120a6e |
return RigidPoint(x + other.x, y + other.y, rigidity + other.rigidity);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
RigidPoint &operator+=(const RigidPoint &other) {
|
|
Shinya Kitaoka |
120a6e |
x += other.x, y += other.y, rigidity += other.rigidity;
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
RigidPoint operator-(const RigidPoint &other) const {
|
|
Shinya Kitaoka |
120a6e |
return RigidPoint(x - other.x, y - other.y, rigidity - other.rigidity);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
RigidPoint &operator-=(const RigidPoint &other) {
|
|
Shinya Kitaoka |
120a6e |
x -= other.x, y -= other.y, rigidity -= other.rigidity;
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
friend RigidPoint operator*(double a, const RigidPoint &b) {
|
|
Shinya Kitaoka |
120a6e |
return RigidPoint(a * b.x, a * b.y, a * b.rigidity);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
friend RigidPoint operator*(const RigidPoint &a, double b) {
|
|
Shinya Kitaoka |
120a6e |
return RigidPoint(a.x * b, a.y * b, a.rigidity * b);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
RigidPoint &operator*=(double a) {
|
|
Shinya Kitaoka |
120a6e |
x *= a, y *= a, rigidity *= a;
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
friend RigidPoint operator*(const TAffine &aff, const RigidPoint &p) {
|
|
Shinya Kitaoka |
120a6e |
return RigidPoint(aff.operator*(p), p.rigidity);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace tcg {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Toshihiro Shimizu |
890ddd |
struct point_traits<rigidpoint> {</rigidpoint>
|
|
Shinya Kitaoka |
120a6e |
typedef RigidPoint point_type;
|
|
Shinya Kitaoka |
120a6e |
typedef double value_type;
|
|
Shinya Kitaoka |
120a6e |
typedef double float_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
inline static value_type x(const point_type &p) { return p.x; }
|
|
Shinya Kitaoka |
120a6e |
inline static value_type y(const point_type &p) { return p.y; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
2fc36c |
//-----------------------------------------------------------------------------
|
|
|
2fc36c |
|
|
|
2fc36c |
template class DVAPI tcg::Vertex<tpointd>;</tpointd>
|
|
|
2fc36c |
template class DVAPI tcg::Vertex<rigidpoint>;</rigidpoint>
|
|
|
2fc36c |
|
|
|
2fc36c |
typedef tcg::Vertex<rigidpoint> TTextureVertex;</rigidpoint>
|
|
|
2fc36c |
|
|
|
2fc36c |
template class DVAPI tcg::Mesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">>;</ttexturevertex,>
|
|
|
2fc36c |
template class DVAPI tcg::TriMesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">>;</ttexturevertex,>
|
|
|
2fc36c |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TTextureMesh (Textured Mesh Type) declaration
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI TTextureMesh final
|
|
Shinya Kitaoka |
120a6e |
: public tcg::TriMesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">>,</ttexturevertex,>
|
|
Shinya Kitaoka |
120a6e |
public TSmartObject,
|
|
Shinya Kitaoka |
120a6e |
public TPersist {
|
|
Shinya Kitaoka |
120a6e |
PERSIST_DECLARATION(TTextureMesh)
|
|
Shinya Kitaoka |
120a6e |
DECLARE_CLASS_CODE
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TTextureMesh();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TTextureMesh(const TTextureMesh &);
|
|
Shinya Kitaoka |
120a6e |
TTextureMesh &operator=(const TTextureMesh &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int faceContaining(const TPointD &p) const;
|
|
Shinya Kitaoka |
120a6e |
bool faceContains(int f, const TPointD &p) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TRectD getBBox() const;
|
|
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 |
|
|
Shinya Kitaoka |
9f5a1b |
#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 |
|
|
Shinya Kitaoka |
120a6e |
namespace boost {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
d1f6c4 |
struct graph_traits<ttexturemesh> final</ttexturemesh>
|
|
Shinya Kitaoka |
120a6e |
: public graph_traits<
|
|
Shinya Kitaoka |
120a6e |
tcg::Mesh
|
|
Shinya Kitaoka |
120a6e |
TTextureMesh::face_type>> {};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace boost
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TMeshImage (Textured Mesh Image) declaration
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI TMeshImage final : public TImage {
|
|
Shinya Kitaoka |
120a6e |
class Imp;
|
|
Shinya Kitaoka |
120a6e |
std::shared_ptr<imp> m_imp;</imp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef std::vector<ttexturemeshp> meshes_container;</ttexturemeshp>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TMeshImage();
|
|
Shinya Kitaoka |
120a6e |
TMeshImage(std::shared_ptr<imp> imp);</imp>
|
|
Shinya Kitaoka |
120a6e |
~TMeshImage();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TMeshImage(const TMeshImage &other);
|
|
Shinya Kitaoka |
120a6e |
TMeshImage &operator=(TMeshImage other);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
TImage::Type getType() const override { return TImage::MESH; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
TRectD getBBox() const override;
|
|
Shinya Kitaoka |
473e70 |
TImage *cloneImage() const override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getDpi(double &dpix, double &dpiy) const;
|
|
Shinya Kitaoka |
120a6e |
void setDpi(double dpix, double dpiy);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const meshes_container &meshes() const;
|
|
Shinya Kitaoka |
120a6e |
meshes_container &meshes();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
friend void swap(TMeshImage &a, TMeshImage &b) {
|
|
Shinya Kitaoka |
120a6e |
std::swap(a.m_imp, b.m_imp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#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 |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI TMeshImageP final
|
|
Shinya Kitaoka |
d1f6c4 |
: public TDerivedSmartPointerT<tmeshimage, timage=""> {</tmeshimage,>
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TMeshImageP() {}
|
|
Shinya Kitaoka |
120a6e |
TMeshImageP(TMeshImage *image) : DerivedSmartPointer(image) {}
|
|
Shinya Kitaoka |
120a6e |
TMeshImageP(TImageP image) : DerivedSmartPointer(image) {}
|
|
Shinya Kitaoka |
9f5a1b |
#if !defined(_WIN32)
|
|
Shinya Kitaoka |
120a6e |
TMeshImageP(TImage *image) : DerivedSmartPointer(TImageP(image)) {}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
operator TImageP() { return TImageP(m_pointer); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TMESHIMAGE_INCLUDED
|