Adobe.com
Contents Suites Classes Class Index Member Index

IAIPoint.h

Go 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 "AIBasicTypes.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     #ifdef LINUX_ENV
00050                 typedef short Coordinates_t;
00051     #endif
00052                 };
00053                 template<>
00054                 struct PointStruct_Traits <AIRealPoint>
00055                 {
00056                         typedef AIReal Coordinates_t;
00057                 };
00058         }
00059 }
00060 /*
00061 * Wrapper Class
00062 */
00063 //Class used to working with point
00064 template <typename S>
00065 class IAIPointImpl : public S
00066 {
00067 private:
00068         typedef typename ai::PointTraits::PointStruct_Traits<S>::Coordinates_t CoordinateType;
00069 public: 
00070         IAIPointImpl()
00071         {
00072                 this->h = 0;
00073                 this->v = 0;
00074         }
00075         IAIPointImpl(const S& p)
00076         {       
00077                 this->h = p.h;
00078                 this->v = p.v;
00079         }
00080         IAIPointImpl(CoordinateType h, CoordinateType v)
00081         {
00082                 this->h = h;
00083                 this->v = v;
00084         }
00085         IAIPointImpl &operator = (const S& p)
00086                 {this->h = p.h; this->v =p.v; return *this;}
00087         IAIPointImpl &operator ++()
00088                 { this->operator += (1); return *this;}
00089         IAIPointImpl &operator --()
00090                 { this->operator += (-1); return *this;}
00091 
00092         S operator + (const S& a) const
00093                 { return IAIPointImpl(this->h+a.h,this->v+a.v);}
00094         S operator - (const S& a) const
00095                 { return IAIPointImpl(this->h-a.h,this->v-a.v);}
00096         S operator + (const CoordinateType& a) const
00097         { return IAIPointImpl(this->h+a,this->v+a);}
00098         S operator - (const CoordinateType& a) const
00099         { return IAIPointImpl(this->h-a,this->v-a);}
00100 
00101         AIBoolean operator == (const S& a) const
00102                 { return (a.h == this->h && a.v == this->v);}
00103         AIBoolean operator != (const S& a) const
00104                 { return !(*this == a);}
00105         S operator * (CoordinateType s) const
00106                 { return IAIPointImpl(this->h * s, this->v * s);}       
00107         S operator / (CoordinateType s) const
00108                 { return IAIPointImpl(this->h / s, this->v / s);}
00109         void operator -()
00110                 { this->h = -this->h; this->v = -this->v; return;}
00111 
00112         IAIPointImpl &operator += (const S& p)
00113                 {       this->h+=p.h; this->v+=p.v; return *this;}
00114         IAIPointImpl &operator -= (const S& p)
00115                 {       this->h -= p.h; this->v -= p.v; return *this;}
00116 
00117         IAIPointImpl &operator *= (CoordinateType s)
00118                 {       this->h*=s; this->v*=s; return *this;}
00119         IAIPointImpl &operator /= (CoordinateType s)
00120         {       
00121                 if(s){this->h/=s; this->v/=s;}
00122                 else {this->h = 0; this->v = 0;}
00123                 return *this;
00124         }
00125 };
00126 
00127 typedef IAIPointImpl<AIRealPoint> IAIRealPoint;
00128 typedef IAIPointImpl<AIPoint> IAIPoint;
00129 
00130 #endif //__IAIPoint__


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2014 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks