![]() |
IAIPoint.hGo to the documentation of this file.00001 /* 00002 * Name: IAIPoint.h 00003 * $Revision: 1 $ 00004 * Author: 00005 * 00006 * ADOBE SYSTEMS INCORPORATED 00007 * Copyright 2008 Adobe Systems Incorporated 00008 * All rights reserved. 00009 * 00010 * NOTICE: Adobe permits you to use, modify, and distribute this file 00011 * in accordance with the terms of the Adobe license agreement 00012 * accompanying it. If you have received this file from a source other 00013 * than Adobe, then your use, modification, or distribution of it 00014 * requires the prior written permission of Adobe. 00015 * 00016 */ 00017 00018 #ifndef __IAIPoint__ 00019 #define __IAIPoint__ 00020 00021 /* 00022 * Includes 00023 */ 00024 00025 #include "AITypes.h" 00026 #include <cmath> 00027 #include <cfloat> 00028 00029 namespace ai 00030 { 00031 namespace PointTraits 00032 { 00033 template<typename S> 00034 struct PointStruct_Traits 00035 { 00036 00037 }; 00038 template<> 00039 struct PointStruct_Traits <AIPoint> 00040 { 00041 //current implementation is compatible with ADMPoint, 00042 //but we plan to make is same for win and mac. 00043 #ifdef WIN_ENV 00044 typedef ai::int32 Coordinates_t; 00045 #endif 00046 #ifdef MAC_ENV 00047 typedef short Coordinates_t; 00048 #endif 00049 }; 00050 template<> 00051 struct PointStruct_Traits <AIRealPoint> 00052 { 00053 typedef AIReal Coordinates_t; 00054 }; 00055 } 00056 } 00057 /* 00058 * Wrapper Class 00059 */ 00060 //Class used to working with point 00061 template <typename S> 00062 class IAIPointImpl : public S 00063 { 00064 private: 00065 typedef typename ai::PointTraits::PointStruct_Traits<S>::Coordinates_t CoordinateType; 00066 public: 00067 IAIPointImpl() 00068 { 00069 this->h = 0; 00070 this->v = 0; 00071 } 00072 IAIPointImpl(const S& p) 00073 { 00074 this->h = p.h; 00075 this->v = p.v; 00076 } 00077 IAIPointImpl(CoordinateType h, CoordinateType v) 00078 { 00079 this->h = h; 00080 this->v = v; 00081 } 00082 IAIPointImpl &operator = (const S& p) 00083 {this->h = p.h; this->v =p.v; return *this;} 00084 IAIPointImpl &operator ++() 00085 { this->operator += (1); return *this;} 00086 IAIPointImpl &operator --() 00087 { this->operator += (-1); return *this;} 00088 00089 S operator + (const S& a) const 00090 { return IAIPointImpl(this->h+a.h,this->v+a.v);} 00091 S operator - (const S& a) const 00092 { return IAIPointImpl(this->h-a.h,this->v-a.v);} 00093 S operator + (const CoordinateType& a) const 00094 { return IAIPointImpl(this->h+a,this->v+a);} 00095 S operator - (const CoordinateType& a) const 00096 { return IAIPointImpl(this->h-a,this->v-a);} 00097 00098 AIBoolean operator == (const S& a) const 00099 { return (a.h == this->h && a.v == this->v);} 00100 AIBoolean operator != (const S& a) const 00101 { return !(*this == a);} 00102 S operator * (CoordinateType s) const 00103 { return IAIPointImpl(this->h * s, this->v * s);} 00104 S operator / (CoordinateType s) const 00105 { return IAIPointImpl(this->h / s, this->v / s);} 00106 void operator -() 00107 { this->h = -this->h; this->v = -this->v; return;} 00108 00109 IAIPointImpl &operator += (const S& p) 00110 { this->h+=p.h; this->v+=p.v; return *this;} 00111 IAIPointImpl &operator -= (const S& p) 00112 { this->h -= p.h; this->v -= p.v; return *this;} 00113 00114 IAIPointImpl &operator *= (CoordinateType s) 00115 { this->h*=s; this->v*=s; return *this;} 00116 IAIPointImpl &operator /= (CoordinateType s) 00117 { 00118 if(s){this->h/=s; this->v/=s;} 00119 else {this->h = 0; this->v = 0;} 00120 return *this; 00121 } 00122 }; 00123 00124 typedef IAIPointImpl<AIRealPoint> IAIRealPoint; 00125 typedef IAIPointImpl<AIPoint> IAIPoint; 00126 00127 #endif //__IAIPoint__ |
||||||
|
![]() |
|