⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 primitive.h

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 H
字号:
// Primitive.h: interface and implementation for the primitives of Ploutos.////////////////////////////////////////////////////////////////////////#if !defined(__PRIMITIVE_PLOUTOS__)#define __PRIMITIVE_PLOUTOS__#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000//#pragma warning(disable : 1125)#include "Vect4D.h"// RxPoint2D classtemplate <class Type>class RxPoint2D  {// Attributepublic:	Type x, y;public:	// Constructor	inline RxPoint2D();	inline RxPoint2D(const Type& tX, const Type& tY);	inline RxPoint2D(const CPoint& pt);	// Destructor	inline ~RxPoint2D();	inline RxPoint2D<Type> operator+(const RxPoint2D<Type>& pt);	inline RxPoint2D<Type> operator-(const RxPoint2D<Type>& pt);	inline RxPoint2D<Type> operator+=(const RxPoint2D<Type>& pt);	inline RxPoint2D<Type> operator-=(const RxPoint2D<Type>& pt);	inline RxPoint2D<Type> operator-();	inline BOOL operator==(const RxPoint2D<Type>& pt);	inline BOOL operator!=(const RxPoint2D<Type>& pt);	inline RxPoint2D<Type> operator=(const RxPoint2D<Type>& pt);	inline RxPoint2D<Type> operator=(const CPoint& pt);	inline RxPoint2D<Type> operator*(const Type& s);	inline RxPoint2D<Type> operator/(const Type& s);	inline RxPoint2D<Type> operator*=(const Type& s);	inline RxPoint2D<Type> operator/=(const Type& s);	// Type conversion operator	inline operator CPoint();	void Offset(const Type& xOffset, const Type& yOffset);	void Offset(const CSize& size);	void Offset(const RxPoint2D<Type>& pt);	double Magnitude();	// Friend function	template <class P> friend RxPoint2D<Type> operator*(const P& s, const RxPoint2D<Type>& pt);};// RxPoint3D classtemplate <class Type>class RxPoint3D {public:	Type x, y, z;public:	// Constructor	inline RxPoint3D(void);	inline RxPoint3D(const Type& tX, const Type& tY, const Type& tZ);	// Destructor	inline ~RxPoint3D(void);	inline RxPoint3D<Type> operator+(const RxPoint3D<Type>& pt);	inline RxPoint3D<Type> operator+(const RxVect4D& v);	inline RxPoint3D<Type> operator-(const RxPoint3D<Type>& pt);	inline RxPoint3D<Type> operator+=(const RxPoint3D<Type>& pt);	inline RxPoint3D<Type> operator-=(const RxPoint3D<Type>& pt);	inline RxPoint3D<Type> operator-();	inline BOOL operator==(const RxPoint3D<Type>& pt);	inline BOOL operator!=(const RxPoint3D<Type>& pt);	inline RxPoint3D<Type> operator=(const RxPoint3D<Type>& pt);	inline RxPoint3D<Type> operator*(const Type& s);	inline RxPoint3D<Type> operator/(const Type& s);	inline RxPoint3D<Type> operator*=(const Type& s);	inline RxPoint3D<Type> operator/=(const Type& s);	inline void Init (const Type& tX, const Type& tY, const Type& tZ);	inline Type operator^(const RxPoint3D& pt);				// inner-product, dot product	inline RxPoint3D<Type> operator*(const RxPoint3D& pt);	// outter-product, cross product	void Offset(const Type& xOffset, const Type& yOffset, const Type& zOffset);	void Offset(const RxPoint3D<Type>& pt);	double Magnitude();			// Get Magnitude	void Normalize();			// Make Unit Vector	// Friend function	template <class P> friend RxPoint3D<Type> operator*(const P& s, const RxPoint3D<Type>& pt);	friend RxPoint3D<Type> operator+(const RxVect4D& v, const RxPoint3D<Type>& pt);};//// 2D point implementation//template <class Type> inline RxPoint2D<Type>::RxPoint2D(){	x = (Type)0;	y = (Type)0;}template <class Type> inline RxPoint2D<Type>::RxPoint2D(const Type& tX, const Type& tY){	x = tX;	y = tY;}template <class Type> inline RxPoint2D<Type>::RxPoint2D(const CPoint& pt){	x = (Type)pt.x;	y = (Type)pt.y;}template <class Type> inline RxPoint2D<Type>::~RxPoint2D(){}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator +(const RxPoint2D<Type>& pt){	return RxPoint2D(x + pt.x, y + pt.y);}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator -(const RxPoint2D<Type>& pt){	return RxPoint2D(x - pt.x, y - pt.y);}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator +=(const RxPoint2D<Type>& pt){	x += pt.x;	y += pt.y;	return *this;}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator -=(const RxPoint2D<Type>& pt){	x -= pt.x;	y -= pt.y;	return *this;}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator -(){	return RxPoint2D(-x, -y);}template <class Type> BOOL inline RxPoint2D<Type>::operator ==(const RxPoint2D<Type>& pt){	return ( x == pt.x && y == pt.y ? TRUE : FALSE);}template <class Type> BOOL inline RxPoint2D<Type>::operator !=(const RxPoint2D<Type>& pt){	return ( x == pt.x && y == pt.y ? FALSE : TRUE);}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator =(const RxPoint2D<Type>& pt){	x = pt.x;	y = pt.y;	return *this;}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator =(const CPoint& pt){	x = (Type)pt.x;	y = (Type)pt.y;	return *this;}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator *(const Type& s){	return RxPoint2D(x * s, y * s);}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator /(const Type& s){	return RxPoint2D(x / s, y / s);}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator *=(const Type& s){	x *= s;	y *= s;	return *this;}template <class Type> inline RxPoint2D<Type> RxPoint2D<Type>::operator /=(const Type& s){	x /= s;	y /= s;	return *this;}template <class Type> inline RxPoint2D<Type>::operator CPoint(){	double xDiff, yDiff;	xDiff = (x >= 0) ? 0.5 : -0.5;	yDiff = (y >= 0) ? 0.5 : -0.5;	return CPoint(int(x + xDiff), int(y + yDiff));}template <class Type> void RxPoint2D<Type>::Offset(const Type& xOffset, const Type& yOffset){	x += xOffset;	y += yOffset;}template <class Type> void RxPoint2D<Type>::Offset(const CSize& size){	x += size.cx;	y += size.cy;}template <class Type> void RxPoint2D<Type>::Offset(const RxPoint2D<Type>& pt){	x += pt.x;	y += pt.y;}template <class Type> double RxPoint2D<Type>::Magnitude(){	return (sqrt(x * x + y * y));}template <class Type, class P> RxPoint2D<Type> operator*(const P& s, const RxPoint2D<Type>& pt){	return RxPoint2D(s * pt.x, s* pt.y);}//// 3D point & vector implementation//template <class Type> inline RxPoint3D<Type>::RxPoint3D(void){	x = (Type)0;	y = (Type)0;	z = (Type)0;}template <class Type> inline RxPoint3D<Type>::RxPoint3D(const Type& tX, const Type& tY, const Type& tZ){	x = tX;	y = tY;	z = tZ;}template <class Type> inline void RxPoint3D<Type>::Init (const Type& tX, const Type& tY, const Type& tZ){	x = tX;	y = tY;	z = tZ;}template <class Type> inline RxPoint3D<Type>::~RxPoint3D(void){}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator +(const RxPoint3D<Type>& pt){	return RxPoint3D(x + pt.x, y + pt.y, z + pt.z);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator +(const RxVect4D& v){	return RxPoint3D(x + (Type)v[0], y + (Type)v[1], z + (Type)v[2]);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator -(const RxPoint3D<Type>& pt){	return RxPoint3D(x - pt.x, y - pt.y, z - pt.z);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator +=(const RxPoint3D<Type>& pt){	x += pt.x;	y += pt.y;	z += pt.z;	return *this;}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator -=(const RxPoint3D<Type>& pt){	x -= pt.x;	y -= pt.y;	z -= pt.z;	return *this;}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator -(){	return RxPoint3D(-x, -y, -z);}template <class Type> inline BOOL RxPoint3D<Type>::operator ==(const RxPoint3D<Type>& pt){	return ( x == pt.x && y == pt.y && z == pt.z ? TRUE : FALSE);}template <class Type> inline BOOL RxPoint3D<Type>::operator !=(const RxPoint3D<Type>& pt){	return ( x == pt.x && y == pt.y && z == pt.z ? FALSE : TRUE);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator =(const RxPoint3D<Type>& pt){	x = pt.x;	y = pt.y;	z = pt.z;	return *this;}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator *(const Type& s){	return RxPoint3D(x * s, y * s, z * s);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator /(const Type& s){	return RxPoint3D(x / s, y / s, z / s);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator *=(const Type& s){	x *= s;	y *= s;	z *= s;	return *this;}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator /=(const Type& s){	x /= s;	y /= s;	z /= s;	return *this;}template <class Type> inline Type RxPoint3D<Type>::operator^(const RxPoint3D& pt){	return (x * pt.x + y * pt.y + z * pt.z);}template <class Type> inline RxPoint3D<Type> RxPoint3D<Type>::operator*(const RxPoint3D& pt){	return RxPoint3D(y * pt.z - z * pt.y, z * pt.x - x * pt.y, x * pt.y - y * pt.z);}template <class Type> void RxPoint3D<Type>::Offset(const Type& xOffset, const Type& yOffset, const Type& zOffset){	x += xOffset;	y += yOffset;	z += zOffset;}template <class Type> void RxPoint3D<Type>::Offset(const RxPoint3D<Type>& pt){	x += pt.x;	y += pt.y;	z += pt.z;}template <class Type> double RxPoint3D<Type>::Magnitude(){	return (sqrt(x * x + y * y + z * z));}// Type捞 int老 版快俊 狼固 绝澜template <class Type> void RxPoint3D<Type>::Normalize(){	double fMag = Magnitude();		x = (Type)(x / fMag);	y = (Type)(y / fMag);	z = (Type)(z / fMag);}template <class Type, class P> RxPoint3D<Type> operator*(const P& s, const RxPoint3D<Type>& pt){	return RxPoint3D(s * pt.x, s * pt.y, s * pt.z);}template <class Type> RxPoint3D<Type> operator+(const RxVect4D& v, const RxPoint3D<Type>& pt){	return RxPoint3D(v[0] + pt.x, v[1] + pt.y, v[2] + pt.z);}#endif // !defined(__PRIMITIVE_PLOUTOS__)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -