![]() Home Page Toolkit Overview Using GML User Input Services Finger Tracker Calibrator Frame Grabber Service protocol Obtaining GML Installing GML Licence Developer Documentation Tcl/Tk API The GML Canvas Image processing Tcl Scripts Library List of Classes List of Files C/C++ API List of Classes List of Files |
gml_Geometry.hGo to the documentation of this file.00001 /** 00002 * @file gml_Geometry.h 00003 * 00004 * Structures to represent 2D points and rectangles. 00005 * 00006 * Copyright (c) 2003 CLIPS-IMAG 00007 * 00008 * See the file "gml_LicenseTerms.txt" for information on usage and redistribution 00009 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 00010 * 00011 * Created on Sept. 20, 2003 (FB). 00012 */ 00013 #ifndef __GML_GEOMETRY__ 00014 #define __GML_GEOMETRY__ 00015 00016 #include <assert.h> 00017 00018 #include "gml/base/gml_Types.h" 00019 #include "gml/math/gml_Math.h" 00020 00021 00022 00023 00024 /** 00025 * gml_TRect -- 00026 * 00027 * 2D rectangles with integer coordinates. 00028 */ 00029 typedef struct 00030 { 00031 SInt32 fLeft; 00032 SInt32 fTop; 00033 SInt32 fRight; 00034 SInt32 fBottom; 00035 00036 } gml_TRect; 00037 00038 00039 00040 /** 00041 * gml_TPoint -- 00042 * 2D points with integer coordinates. 00043 */ 00044 typedef struct 00045 { 00046 SInt32 fX; 00047 SInt32 fY; 00048 00049 } gml_TPoint; 00050 00051 00052 00053 /** 00054 * gml_TRectFloat -- 00055 * 00056 * 2D rectangles with floating-point coordinates. 00057 */ 00058 typedef struct 00059 { 00060 Float32 fLeft; 00061 Float32 fTop; 00062 Float32 fRight; 00063 Float32 fBottom; 00064 00065 } gml_TRectFloat; 00066 00067 00068 00069 /** 00070 * gml_TPointFloat -- 00071 * 00072 * 2D points with floating-point coordinates. 00073 */ 00074 typedef struct 00075 { 00076 Float32 fX; 00077 Float32 fY; 00078 00079 } gml_TPointFloat; 00080 00081 00082 00083 /** 00084 * gml_Rect_Width -- 00085 * 00086 * Return the width of a gml_TRect. 00087 */ 00088 inline static 00089 SInt32 gml_Rect_Width (gml_TRect* rect) 00090 { 00091 return rect->fRight - rect->fLeft; 00092 } 00093 00094 00095 00096 /** 00097 * gml_Rect_Height -- 00098 * 00099 * Return the height of a gml_TRect. 00100 */ 00101 inline static 00102 SInt32 gml_Rect_Height (gml_TRect* rect) 00103 { 00104 return rect->fBottom - rect->fTop; 00105 } 00106 00107 00108 /** 00109 * gml_Rect_Equal -- 00110 * 00111 * Return true iff the two rectangles are identical. 00112 */ 00113 inline static 00114 gml_TBoolean gml_Rect_Equal (gml_TRect* rect0, gml_TRect* rect1) 00115 { 00116 return (rect0->fLeft == rect1->fLeft && 00117 rect0->fRight == rect1->fRight && 00118 rect0->fTop == rect1->fTop && 00119 rect0->fBottom == rect1->fBottom) ? gml_cTrue : gml_cFalse; 00120 } 00121 00122 00123 /** 00124 * gml_SetValidRect -- 00125 * 00126 * If <rectPtr> is NULL, set <validRect> to the (0, 0, w, h) rectangle. 00127 * Else set it to the intersection of that rectangle and the rectangle 00128 * pointed by <rectPtr>. 00129 */ 00130 inline static 00131 void gml_SetValidRect (SInt32 w, SInt32 h, gml_TRect* rectPtr, gml_TRect* validRect) 00132 { 00133 assert (validRect != NULL); 00134 00135 if (rectPtr == NULL) { 00136 validRect->fLeft = 0; 00137 validRect->fTop = 0; 00138 validRect->fRight = w; 00139 validRect->fBottom = h; 00140 } else { 00141 validRect->fLeft = Min (Max (rectPtr->fLeft, SInt32(0)), w); 00142 validRect->fRight = Max (Min (rectPtr->fRight, w), validRect->fLeft); 00143 validRect->fTop = Min (Max (rectPtr->fTop, SInt32(0)), h); 00144 validRect->fBottom = Max (Min (rectPtr->fBottom, h), validRect->fTop); 00145 } 00146 } 00147 00148 00149 #endif /* ifndef __GML_GEOMETRY__ */ 00150
Generated on Tue Jun 12 14:03:27 2007 for gml by
Doxygen 1.5.2.
|
Contact: julien (dot) letessier (at) gmail (dot) com.
Copyright (c) 2000-2007 CLIPS-IMAG Laboratory, Grenoble, France. All rights reserved. W3CXHTML 1.0 W3CCSS 2.0 |