HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EUC_Object.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * Defines the atomic objects defined in euclidean geometry,
27  * the circle, the line, and the point
28  */
29 
30 #ifndef __EUC_Object__
31 #define __EUC_Object__
32 
33 #include <UT/UT_Vector2.h>
34 #include <UT/UT_ValArray.h>
35 
36 namespace HDK_Sample {
37 
39 {
43 };
44 
46 {
47 public:
48  EUC_Object();
49  virtual ~EUC_Object();
50 
51  void setLook(bool visible, const UT_Vector3 &cd);
52  bool getVisible() const { return myVisible; }
53  UT_Vector3 getColor() const { return myCd; }
54 
55  virtual EUC_ObjType getType() const = 0;
56 protected:
57  bool myVisible;
59 };
60 
61 class EUC_Point : public EUC_Object
62 {
63 public:
64  EUC_Point();
65  EUC_Point(const UT_Vector2 &pos);
66  ~EUC_Point() override;
67 
68  EUC_ObjType getType() const override { return EUC_PointType; }
69 
70  const UT_Vector2 &getPos() const { return myPos; }
71  void setPos(const UT_Vector2 &pos) { myPos = pos; }
72 
73 protected:
75 };
76 
77 class EUC_Line : public EUC_Object
78 {
79 public:
80  EUC_Line();
81  ~EUC_Line() override;
82 
83  EUC_ObjType getType() const override { return EUC_LineType; }
84 
85  const UT_Vector2 &getPt(int idx) const { return myPts[idx]; }
86  void setPt(int idx, const UT_Vector2 &pt)
87  { myPts[idx] = pt; }
88 protected:
90 };
91 
92 class EUC_Circle : public EUC_Line
93 {
94 public:
95  EUC_Circle();
96  ~EUC_Circle() override;
97 
98  EUC_ObjType getType() const override { return EUC_CircleType; }
99 
100  // Circle specific methods
101  const UT_Vector2 &getCenter() const { return myPts[0]; }
102  void setCenter(const UT_Vector2 &pt) { myPts[0] = pt; }
103 
104  float getRadius() const;
105 };
106 
108 
109 }
110 
111 #endif
const UT_Vector2 & getCenter() const
Definition: EUC_Object.h:101
void setPt(int idx, const UT_Vector2 &pt)
Definition: EUC_Object.h:86
UT_Vector2 myPts[2]
Definition: EUC_Object.h:89
float getRadius() const
Definition: EUC_Object.C:96
EUC_ObjType getType() const override
Definition: EUC_Object.h:98
void setPos(const UT_Vector2 &pos)
Definition: EUC_Object.h:71
UT_ValArray< EUC_Object * > EUC_ObjectList
Definition: EUC_Object.h:107
~EUC_Line() override
Definition: EUC_Object.C:80
~EUC_Point() override
Definition: EUC_Object.C:67
EUC_ObjType getType() const override
Definition: EUC_Object.h:68
virtual EUC_ObjType getType() const =0
const UT_Vector2 & getPos() const
Definition: EUC_Object.h:70
UT_Vector3 getColor() const
Definition: EUC_Object.h:53
EUC_ObjType getType() const override
Definition: EUC_Object.h:83
void setLook(bool visible, const UT_Vector3 &cd)
Definition: EUC_Object.C:48
void setCenter(const UT_Vector2 &pt)
Definition: EUC_Object.h:102
bool getVisible() const
Definition: EUC_Object.h:52
const UT_Vector2 & getPt(int idx) const
Definition: EUC_Object.h:85
~EUC_Circle() override
Definition: EUC_Object.C:91