ML Reference
|
00001 // **InsertLicense** code 00002 //------------------------------------------------------------------------- 00011 //------------------------------------------------------------------------- 00012 #ifndef __mlSubImageBoxd_H 00013 #define __mlSubImageBoxd_H 00014 00015 #ifndef __mlInitSystemML_H 00016 #include "mlInitSystemML.h" 00017 #endif 00018 #ifndef __mlSubImageBox_H 00019 #include "mlSubImageBox.h" 00020 #endif 00021 #ifndef __mlLinearAlgebra_H 00022 #include "mlLinearAlgebra.h" 00023 #endif 00024 00025 ML_START_NAMESPACE 00026 00027 //------------------------------------------------------------------------- 00032 //------------------------------------------------------------------------- 00033 class SubImageBoxd 00034 { 00035 00036 public: 00037 00041 Vector6 v1; 00042 00044 Vector6 v2; 00045 00046 //------------------------------------------------------ 00048 00049 //------------------------------------------------------ 00051 inline SubImageBoxd() 00052 { 00053 ML_TRACE_IN( "SubImageBoxd::SubImageBoxd( )" ); 00054 00055 v1=Vector6(0); 00056 v2=Vector6(-1); 00057 } 00058 00061 inline SubImageBoxd(const Vector6& vector1, const Vector6& vector2) : v1(vector1), v2(vector2) 00062 { 00063 ML_TRACE_IN( "SubImageBoxd::SubImageBoxd( )" ); 00064 } 00065 00067 inline SubImageBoxd(const Vector6& extent) : v1(0), v2(extent) 00068 { 00069 ML_TRACE_IN( "SubImageBoxd::SubImageBoxd( )" ); 00070 } 00071 00075 MLEXPORT SubImageBoxd(const SubImageBox& box); 00077 00078 00079 00080 //------------------------------------------------------ 00082 00083 //------------------------------------------------------ 00085 inline bool operator==(const SubImageBoxd& box) const 00086 { 00087 ML_TRACE_IN( "SubImageBoxd::operator==()" ); 00088 00089 return (v1==box.v1) && (v2==box.v2); 00090 } 00091 00093 inline bool operator!=(const SubImageBoxd& box) const 00094 { 00095 ML_TRACE_IN( "SubImageBoxd::operator!=()" ); 00096 00097 return !operator==(box); 00098 } 00099 00102 inline bool isEmpty() const 00103 { 00104 ML_TRACE_IN( "SubImageBoxd::isEmpty( )" ); 00105 00106 return (v1[0]>v2[0]) || (v1[1]>v2[1]) || (v1[2]>v2[2]) || (v1[3]>v2[3]) || (v1[4]>v2[4]) || (v1[5]>v2[5]); 00107 } 00108 00110 inline Vector6 getExtent() const 00111 { 00112 ML_TRACE_IN( "SubImageBoxd::getExtent ( )" ); 00113 00114 if (isEmpty()) 00115 { 00116 return Vector6(0); 00117 } 00118 else 00119 { 00120 return v2-v1; 00121 } 00122 } 00123 00125 MLEXPORT void correct(); 00127 00128 //------------------------------------------------------ 00130 00131 //------------------------------------------------------ 00133 inline static SubImageBoxd intersect(const SubImageBoxd& box1, const SubImageBoxd& box2) 00134 { 00135 ML_TRACE_IN( "SubImageBoxd::intersect( )" ); 00136 00137 SubImageBoxd result; 00138 // If for any component result holds (result.v1[0]>result.v2[0] || 00139 // result.v1[1]>result.v1[1] || result.v1[2]>result.v1[2] ... ), the 00140 // intersection is interpreted as empty! This holds especially if 00141 // if loc1 or loc2 are already empty! 00142 result.v1 = compMax(box1.v1, box2.v1); 00143 result.v2 = compMin(box1.v2, box2.v2); 00144 return result; 00145 } 00146 00148 inline void makeEmpty() 00149 { 00150 ML_TRACE_IN( "SubImageBoxd::makeEmpty( )" ); 00151 00152 v1 = Vector6(0); 00153 v2 = Vector6(-1); 00154 } 00155 00157 inline SubImageBoxd intersect(const SubImageBoxd &box) 00158 { 00159 ML_TRACE_IN( "SubImageBoxd::SubImageBoxd ( )" ); 00160 00161 return SubImageBoxd::intersect(*this, box); 00162 } 00163 00166 inline Vector6 clamp(const Vector6& position) 00167 { 00168 ML_TRACE_IN( "SubImageBoxd::clamp( )" ); 00169 00170 return compMax(compMin(position, v2), v1); 00171 } 00172 00175 MLEXPORT static SubImageBoxd calcAATransformedBox(const SubImageBox& box, const Matrix4& matrix); 00177 00178 00179 #ifdef ML_DEPRECATED 00180 00182 00183 00184 public: 00185 00188 inline ML_DEPRECATED Vector6 getExt() const { return getExtent(); } 00189 00191 00192 #endif // ML_DEPRECATED 00193 00194 }; // end of SubImageBoxd 00195 00196 00197 #ifdef ML_DEPRECATED 00198 00199 00200 00201 00202 ML_DEPRECATED typedef SubImageBoxd SubImgBoxf; 00204 #endif // ML_DEPRECATED 00205 00206 00207 00208 ML_END_NAMESPACE 00209 00210 00211 //----------------------------------------------------------------------------------- 00212 // Stream output for std::ostream 00213 //----------------------------------------------------------------------------------- 00214 namespace std { 00215 00217 inline ostream& operator<<(ostream& s, const ML_NAMESPACE::SubImageBoxd &box) 00218 { 00219 return s << "(" << box.v1 << ")(" << box.v2 << ")"; 00220 } 00221 00222 } 00223 00224 #endif // __mlSubImageBoxd_H 00225 00226 00227 00228