Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// tcg includes
Toshihiro Shimizu 890ddd
#include "tcg/tcg_misc.h"
Toshihiro Shimizu 890ddd
#include "tcg/tcg_iterator_ops.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define INCLUDE_HPP
Toshihiro Shimizu 890ddd
#include "tmeshimage.h"
Toshihiro Shimizu 890ddd
#undef INCLUDE_HPP
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
//    Explicit instantiations
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template class DV_EXPORT_API tcg::Vertex<tpointd>;</tpointd>
Toshihiro Shimizu 890ddd
template class DV_EXPORT_API tcg::Mesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">>;</ttexturevertex,>
Toshihiro Shimizu 890ddd
template class DV_EXPORT_API tcg::TriMesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">>;</ttexturevertex,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef tcg::TriMesh<ttexturevertex, tcg::edge,="" tcg::facen<3="">> TriMesh_base;</ttexturevertex,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
//    TTextureMesh  implementation
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DEFINE_CLASS_CODE(TTextureMesh, 120)
Toshihiro Shimizu 890ddd
PERSIST_IDENTIFIER(TTextureMesh, "mesh")
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
static TTextureMeshP cloneMesh_(const TTextureMeshP &other)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return TTextureMeshP(new TTextureMesh(*other));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void static_check()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	/* input iterator */
Toshihiro Shimizu 890ddd
	static_assert(std::is_same<std::iterator_traits<std::vector<ttexturemesh>::iterator>::iterator_category, std::random_access_iterator_tag>::value == true, "random");</std::iterator_traits<std::vector<ttexturemesh>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static_assert(std::is_base_of<std::input_iterator_tag, std::iterator_traits<std::vector<ttexturemesh="">::iterator>::iterator_category>::value == true, "input");</std::input_iterator_tag,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static_assert(std::is_base_of<std::forward_iterator_tag, std::iterator_traits<std::vector<ttexturemesh="">::iterator>::iterator_category>::value == true, "forward");</std::forward_iterator_tag,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static_assert(std::is_constructible
Toshihiro Shimizu 890ddd
										std::iterator_traits<std::vector<ttexturemeshp>::iterator>::reference>::value == true,</std::vector<ttexturemeshp>
Toshihiro Shimizu 890ddd
				  "akan");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/* converted iterator */
Toshihiro Shimizu 890ddd
	std::vector<ttexturemeshp> vec;</ttexturemeshp>
Toshihiro Shimizu 890ddd
	auto it = vec.end();
Toshihiro Shimizu 890ddd
	auto c = tcg::make_cast_it(it, cloneMesh_);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static_assert(std::is_same<std::iterator_traits<decltype(c)>::iterator_category, std::random_access_iterator_tag>::value == true, "random");</std::iterator_traits<decltype(c)>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static_assert(std::is_base_of<std::input_iterator_tag, std::iterator_traits<decltype(c)="">::iterator_category>::value == true, "input");</std::input_iterator_tag,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static_assert(std::is_base_of<std::forward_iterator_tag, std::iterator_traits<decltype(c)="">::iterator_category>::value == true, "forward");</std::forward_iterator_tag,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//TTextureMeshP p(std::iterator_traits< decltype(c) >::reference);
Toshihiro Shimizu 890ddd
	static_assert(std::is_constructible
Toshihiro Shimizu 890ddd
										std::iterator_traits<decltype(c)>::reference>::value == true,</decltype(c)>
Toshihiro Shimizu 890ddd
				  "akan");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TTextureMesh::TTextureMesh()
Toshihiro Shimizu 890ddd
	: TSmartObject(m_classCode)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TTextureMesh::TTextureMesh(const TTextureMesh &other)
Toshihiro Shimizu 890ddd
	: TriMesh_base(other), TSmartObject(m_classCode)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TTextureMesh &TTextureMesh::operator=(const TTextureMesh &other)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TriMesh_base::operator=(other);
Toshihiro Shimizu 890ddd
	return *this;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool TTextureMesh::faceContains(int f, const TPointD &p) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int v0, v1, v2;
Toshihiro Shimizu 890ddd
	this->faceVertices(f, v0, v1, v2);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const TPointD &p0 = vertex(v0).P();
Toshihiro Shimizu 890ddd
	const TPointD &p1 = vertex(v1).P();
Toshihiro Shimizu 890ddd
	const TPointD &p2 = vertex(v2).P();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool clockwise = (tcg::point_ops::cross(p2 - p0, p1 - p0) >= 0);
Toshihiro Shimizu 890ddd
	return ((tcg::point_ops::cross(p - p0, p1 - p0) >= 0) == clockwise) &&
Toshihiro Shimizu 890ddd
		   ((tcg::point_ops::cross(p - p1, p2 - p1) >= 0) == clockwise) &&
Toshihiro Shimizu 890ddd
		   ((tcg::point_ops::cross(p - p2, p0 - p2) >= 0) == clockwise);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int TTextureMesh::faceContaining(const TPointD &p) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int f, fCount = facesCount();
Toshihiro Shimizu 890ddd
	for (f = 0; f < fCount; ++f)
Toshihiro Shimizu 890ddd
		if (faceContains(f, p))
Toshihiro Shimizu 890ddd
			return f;
Toshihiro Shimizu 890ddd
	return -1;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TRectD TTextureMesh::getBBox() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	// TODO: Should be cached...
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const double max = (std::numeric_limits<double>::max)();</double>
Toshihiro Shimizu 890ddd
	TRectD result(max, max, -max, -max);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Iterate all meshes
Toshihiro Shimizu 890ddd
	assert(m_vertices.size() == m_vertices.nodesCount());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int v, vCount = int(m_vertices.size());
Toshihiro Shimizu 890ddd
	for (v = 0; v != vCount; ++v) {
Toshihiro Shimizu 890ddd
		const TTextureVertex &vx = m_vertices[v];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		result.x0 = tmin(result.x0, vx.P().x);
Toshihiro Shimizu 890ddd
		result.y0 = tmin(result.y0, vx.P().y);
Toshihiro Shimizu 890ddd
		result.x1 = tmax(result.x1, vx.P().x);
Toshihiro Shimizu 890ddd
		result.y1 = tmax(result.y1, vx.P().y);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return result;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TTextureMesh::saveData(TOStream &os)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	struct locals {
Toshihiro Shimizu 890ddd
		static inline bool hasNon1Rigidity(const TTextureMesh &mesh)
Toshihiro Shimizu 890ddd
		{
Toshihiro Shimizu 890ddd
			int v, vCount = int(mesh.verticesCount());
Toshihiro Shimizu 890ddd
			for (v = 0; v != vCount; ++v)
Toshihiro Shimizu 890ddd
				if (mesh.vertex(v).P().rigidity != 1.0)
Toshihiro Shimizu 890ddd
					return true;
Toshihiro Shimizu 890ddd
			return false;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// NOTE: Primitives saved by INDEX iteration is NOT COINCIDENTAL - since
Toshihiro Shimizu 890ddd
	// the lists' internal linking could have been altered to mismatch the
Toshihiro Shimizu 890ddd
	// natural indexing referred to by primitives' data.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (m_vertices.size() != m_vertices.nodesCount() ||
Toshihiro Shimizu 890ddd
		m_edges.size() != m_edges.nodesCount() ||
Toshihiro Shimizu 890ddd
		m_faces.size() != m_faces.nodesCount()) {
Toshihiro Shimizu 890ddd
		// Ensure the mesh is already squeezed - save a squeezed
Toshihiro Shimizu 890ddd
		// copy if necessary
Toshihiro Shimizu 890ddd
		TTextureMesh mesh(*this);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		mesh.squeeze();
Toshihiro Shimizu 890ddd
		mesh.saveData(os);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	assert(m_vertices.size() == m_vertices.nodesCount());
Toshihiro Shimizu 890ddd
	assert(m_edges.size() == m_edges.nodesCount());
Toshihiro Shimizu 890ddd
	assert(m_faces.size() == m_faces.nodesCount());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Store Vertices
Toshihiro Shimizu 890ddd
	os.openChild("V");
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		int vCount = int(m_vertices.size());
Toshihiro Shimizu 890ddd
		os << vCount;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		for (int v = 0; v != vCount; ++v) {
Toshihiro Shimizu 890ddd
			TTextureMesh::vertex_type &vx = m_vertices[v];
Toshihiro Shimizu 890ddd
			os << vx.P().x << vx.P().y;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	os.closeChild();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Store Edges
Toshihiro Shimizu 890ddd
	os.openChild("E");
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		int eCount = int(m_edges.size());
Toshihiro Shimizu 890ddd
		os << eCount;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		for (int e = 0; e != eCount; ++e) {
Toshihiro Shimizu 890ddd
			TTextureMesh::edge_type &ed = m_edges[e];
Toshihiro Shimizu 890ddd
			os << ed.vertex(0) << ed.vertex(1);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	os.closeChild();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Store Faces
Toshihiro Shimizu 890ddd
	os.openChild("F");
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		int fCount = int(m_faces.size());
Toshihiro Shimizu 890ddd
		os << fCount;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		for (int f = 0; f != fCount; ++f) {
Toshihiro Shimizu 890ddd
			TTextureMesh::face_type &fc = m_faces[f];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			int e, eCount = fc.edgesCount();
Toshihiro Shimizu 890ddd
			for (e = 0; e < eCount; ++e)
Toshihiro Shimizu 890ddd
				os << fc.edge(e);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	os.closeChild();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Store rigidities
Toshihiro Shimizu 890ddd
	if (locals::hasNon1Rigidity(*this)) {
Toshihiro Shimizu 890ddd
		os.openChild("rigidities");
Toshihiro Shimizu 890ddd
		{
Toshihiro Shimizu 890ddd
			int vCount = int(m_vertices.size());
Toshihiro Shimizu 890ddd
			os << vCount;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (int v = 0; v != vCount; ++v)
Toshihiro Shimizu 890ddd
				os << m_vertices[v].P().rigidity;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		os.closeChild();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TTextureMesh::loadData(TIStream &is)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	typedef tcg::Mesh<vertex_type, edge_type,="" face_type=""> mesh_type;</vertex_type,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::string str;
Toshihiro Shimizu 890ddd
	int i, size;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	while (is.openChild(str)) {
Toshihiro Shimizu 890ddd
		if (str == "V") {
Toshihiro Shimizu 890ddd
			is >> size;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			m_vertices.reserve(size);
Toshihiro Shimizu 890ddd
			TTextureMesh::vertex_type v;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (i = 0; i < size; ++i) {
Toshihiro Shimizu 890ddd
				is >> v.P().x >> v.P().y;
Toshihiro Shimizu 890ddd
				mesh_type::addVertex(v);
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			is.closeChild();
Toshihiro Shimizu 890ddd
		} else if (str == "E") {
Toshihiro Shimizu 890ddd
			is >> size;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			m_edges.reserve(size);
Toshihiro Shimizu 890ddd
			int v0, v1;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (i = 0; i < size; ++i) {
Toshihiro Shimizu 890ddd
				is >> v0 >> v1;
Toshihiro Shimizu 890ddd
				mesh_type::addEdge(TTextureMesh::edge_type(v0, v1));
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			is.closeChild();
Toshihiro Shimizu 890ddd
		} else if (str == "F") {
Toshihiro Shimizu 890ddd
			is >> size;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			m_faces.reserve(size);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			int e[3];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (i = 0; i < size; ++i) {
Toshihiro Shimizu 890ddd
				is >> e[0] >> e[1] >> e[2];
Toshihiro Shimizu 890ddd
				mesh_type::addFace(TTextureMesh::face_type(e));
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			is.closeChild();
Toshihiro Shimizu 890ddd
		} else if (str == "rigidities") {
Toshihiro Shimizu 890ddd
			is >> size;
Toshihiro Shimizu 890ddd
			size = tmin(size, this->verticesCount());
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			for (i = 0; i < size; ++i)
Toshihiro Shimizu 890ddd
				is >> m_vertices[i].P().rigidity;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			is.closeChild();
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			assert(false);
Toshihiro Shimizu 890ddd
			is.skipCurrentTag();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
//    TMeshImage::Imp  definition
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TMeshImage::Imp
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	std::vector<ttexturemeshp> m_meshes; //!< Mesh data</ttexturemeshp>
Toshihiro Shimizu 890ddd
	double m_dpiX, m_dpiY;				 //!< Meshes dpi
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Imp() : m_dpiX(), m_dpiY() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Imp(const Imp &other)
Toshihiro Shimizu 890ddd
		: m_meshes(tcg::make_cast_it(other.m_meshes.begin(), cloneMesh),
Toshihiro Shimizu 890ddd
				   tcg::make_cast_it(other.m_meshes.end(), cloneMesh)),
Toshihiro Shimizu 890ddd
		  m_dpiX(other.m_dpiX), m_dpiY(other.m_dpiY) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	static TTextureMeshP cloneMesh(const TTextureMeshP &other)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return TTextureMeshP(new TTextureMesh(*other));
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Not assignable
Toshihiro Shimizu 890ddd
	Imp &operator=(const Imp &other);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
//    TMeshImage  implementation
Toshihiro Shimizu 890ddd
//******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TMeshImage::TMeshImage()
Toshihiro Shimizu 890ddd
	: m_imp(new Imp)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TMeshImage::TMeshImage(Imp *imp)
Toshihiro Shimizu 890ddd
	: m_imp(imp)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TMeshImage::~TMeshImage()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	delete m_imp;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TMeshImage::TMeshImage(const TMeshImage &other)
Toshihiro Shimizu 890ddd
	: m_imp(new Imp(*other.m_imp))
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TMeshImage &TMeshImage::operator=(TMeshImage other)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	swap(*this, other);
Toshihiro Shimizu 890ddd
	return *this;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TRectD TMeshImage::getBBox() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	const double max = (std::numeric_limits<double>::max)();</double>
Toshihiro Shimizu 890ddd
	TRectD result(max, max, -max, -max);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Iterate all meshes
Toshihiro Shimizu 890ddd
	int m, mCount = int(m_imp->m_meshes.size());
Toshihiro Shimizu 890ddd
	for (m = 0; m < mCount; ++m)
Toshihiro Shimizu 890ddd
		result += m_imp->m_meshes[m]->getBBox();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	return result;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TImage *TMeshImage::cloneImage() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return new TMeshImage(*this);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TMeshImage::getDpi(double &dpix, double &dpiy) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	dpix = m_imp->m_dpiX, dpiy = m_imp->m_dpiY;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void TMeshImage::setDpi(double dpix, double dpiy)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_imp->m_dpiX = dpix, m_imp->m_dpiY = dpiy;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
const std::vector<ttexturemeshp> &TMeshImage::meshes() const</ttexturemeshp>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_imp->m_meshes;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
std::vector<ttexturemeshp> &TMeshImage::meshes()</ttexturemeshp>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_imp->m_meshes;
Toshihiro Shimizu 890ddd
}