00001 /* 00002 * Copyright (c) 2006 00003 * Side Effects Software Inc. All rights reserved. 00004 * 00005 * Redistribution and use of Houdini Development Kit samples in source and 00006 * binary forms, with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. The name of Side Effects Software may not be used to endorse or 00011 * promote products derived from this software without specific prior 00012 * written permission. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 00015 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00017 * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00019 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00020 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00022 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00023 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 *---------------------------------------------------------------------------- 00026 * Defines the atomic objects defined in euclidean geometry, 00027 * the circle, the line, and the point 00028 */ 00029 00030 #ifndef __EUC_Object__ 00031 #define __EUC_Object__ 00032 00033 #include <UT/UT_Vector2.h> 00034 #include <UT/UT_PtrArray.h> 00035 00036 namespace HDK_Sample { 00037 00038 enum EUC_ObjType 00039 { 00040 EUC_PointType, 00041 EUC_LineType, 00042 EUC_CircleType 00043 }; 00044 00045 class EUC_Object 00046 { 00047 public: 00048 EUC_Object(); 00049 virtual ~EUC_Object(); 00050 00051 void setLook(bool visible, const UT_Vector3 &cd); 00052 bool getVisible() const { return myVisible; } 00053 UT_Vector3 getColor() const { return myCd; } 00054 00055 virtual EUC_ObjType getType() const = 0; 00056 protected: 00057 bool myVisible; 00058 UT_Vector3 myCd; 00059 }; 00060 00061 class EUC_Point : public EUC_Object 00062 { 00063 public: 00064 EUC_Point(); 00065 EUC_Point(const UT_Vector2 &pos); 00066 virtual ~EUC_Point(); 00067 00068 virtual EUC_ObjType getType() const { return EUC_PointType; } 00069 00070 const UT_Vector2 &getPos() const { return myPos; } 00071 void setPos(const UT_Vector2 &pos) { myPos = pos; } 00072 00073 protected: 00074 UT_Vector2 myPos; 00075 }; 00076 00077 class EUC_Line : public EUC_Object 00078 { 00079 public: 00080 EUC_Line(); 00081 virtual ~EUC_Line(); 00082 00083 virtual EUC_ObjType getType() const { return EUC_LineType; } 00084 00085 const UT_Vector2 &getPt(int idx) const { return myPts[idx]; } 00086 void setPt(int idx, const UT_Vector2 &pt) 00087 { myPts[idx] = pt; } 00088 protected: 00089 UT_Vector2 myPts[2]; 00090 }; 00091 00092 class EUC_Circle : public EUC_Line 00093 { 00094 public: 00095 EUC_Circle(); 00096 virtual ~EUC_Circle(); 00097 00098 virtual EUC_ObjType getType() const { return EUC_CircleType; } 00099 00100 // Circle specific methods 00101 const UT_Vector2 &getCenter() const { return myPts[0]; } 00102 void setCenter(const UT_Vector2 &pt) { myPts[0] = pt; } 00103 00104 float getRadius() const; 00105 }; 00106 00107 typedef UT_PtrArray<EUC_Object *> EUC_ObjectList; 00108 00109 } 00110 00111 #endif
1.5.9