1 /*****************************************************************************************
2 * Copyright (c) 2006 Hewlett-Packard Development Company, L.P.
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of
4 * this software and associated documentation files (the "Software"), to deal in
5 * the Software without restriction, including without limitation the rights to use,
6 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7 * Software, and to permit persons to whom the Software is furnished to do so,
8 * subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
17 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 *****************************************************************************************/
19 /************************************************************************
20  * SVN MACROS
21  *
22  * $LastChangedDate: 2009-07-01 20:12:22 +0530 (Wed, 01 Jul 2009) $
23  * $Revision: 784 $
24  * $Author: mnab $
25  *
26  ************************************************************************/
27 #include "LTKShapeSample.h"
28 
29 #include "LTKShapeFeature.h"
30 
31 #include "LTKRefCountedPtr.h"
32 
33 #include "LTKLoggerUtil.h"
34 
35 
36 /**********************************************************************************
37  * AUTHOR		: Saravanan R.
38  * DATE			: 22-Mar-2007
39  * NAME			: LTKShapeSample
40  * DESCRIPTION	: Default Constructor
41  * ARGUMENTS		:
42  * RETURNS		:
43  * NOTES			:
44  * CHANGE HISTROY
45  * Author			Date				Description of change
46  * ************************************************************************************/
47 
LTKShapeSample()48 LTKShapeSample::LTKShapeSample()
49 {
50     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
51         "Entering LTKShapeSample::LTKShapeSample()"  <<endl;
52     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
53         "Exiting LTKShapeSample::LTKShapeSample()"  <<endl;
54 
55 }
56 
57 /**********************************************************************************
58  * AUTHOR		: Saravanan R.
59  * DATE			: 22-Mar-2007
60  * NAME			: LTKShapeSample
61  * DESCRIPTION	: Copy Constructor
62  * ARGUMENTS		: sampleFeatures - LTKShapeSample to be copied
63  * RETURNS		:
64  * NOTES			:
65  * CHANGE HISTROY
66  * Author			Date				Description of change
67  * ************************************************************************************/
68 
LTKShapeSample(const LTKShapeSample & sampleFeatures)69 LTKShapeSample::LTKShapeSample(const LTKShapeSample& sampleFeatures)
70 {
71     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
72         "Entering LTKShapeSample::LTKShapeSample(const LTKShapeSample& )"  <<endl;
73 
74     m_featureVector = sampleFeatures.m_featureVector;
75     m_classId = sampleFeatures.m_classId;
76 
77     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
78         "Exiting LTKShapeSample::LTKShapeSample(const LTKShapeSample& )"  <<endl;
79 }
80 
81 /**********************************************************************************
82  * AUTHOR		: Saravanan R.
83  * DATE			: 22-Mar-2007
84  * NAME			: operator=
85  * DESCRIPTION	: Overloaded assignment operator
86  * ARGUMENTS		: sampleFeatures - LTKShapeSample to be assigned to
87  * RETURNS		:
88  * NOTES			:
89  * CHANGE HISTROY
90  * Author			Date				Description of change
91  * ************************************************************************************/
92 
operator =(const LTKShapeSample & sampleFeatures)93 LTKShapeSample& LTKShapeSample::operator=(const LTKShapeSample& sampleFeatures)
94 {
95     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
96         "Entering LTKShapeSample::operator=(const LTKShapeSample& )"  <<endl;
97 
98     if ( this != &sampleFeatures )
99     {
100         m_featureVector = sampleFeatures.m_featureVector;
101         m_classId = sampleFeatures.m_classId;
102     }
103 
104     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
105         "Entering LTKShapeSample::operator=(const LTKShapeSample& )"  <<endl;
106     return *this;
107 }
108 
109 /**********************************************************************************
110  * AUTHOR		: Saravanan R.
111  * DATE			: 22-Mar-2007
112  * NAME			: ~LTKShapeSample
113  * DESCRIPTION	: destructor
114  * ARGUMENTS		:
115  * RETURNS		:
116  * NOTES			:
117  * CHANGE HISTROY
118  * Author			Date				Description of change
119  * ************************************************************************************/
120 
~LTKShapeSample()121 LTKShapeSample::~LTKShapeSample()
122 {
123 }
124 
125 /**********************************************************************************
126  * AUTHOR		: Saravanan R.
127  * DATE			: 22-Mar-2007
128  * NAME			: setFeatureVector
129  * DESCRIPTION	:
130  * ARGUMENTS		:
131  * RETURNS		:
132  * NOTES			:
133  * CHANGE HISTROY
134  * Author			Date				Description of change
135  * ************************************************************************************/
setFeatureVector(const vector<LTKShapeFeaturePtr> & inFeatureVec)136 void LTKShapeSample::setFeatureVector(const vector<LTKShapeFeaturePtr>& inFeatureVec)
137 {
138     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
139         "Entering LTKShapeSample:setFeatureVector()"  <<endl;
140 
141     m_featureVector = inFeatureVec;
142 
143     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
144         "Exiting LTKShapeSample:setFeatureVector()"  <<endl;
145 }
146 
147 /**********************************************************************************
148  * AUTHOR		: Saravanan R.
149  * DATE			: 22-Mar-2007
150  * NAME			: setClassID
151  * DESCRIPTION	:
152  * ARGUMENTS		:
153  * RETURNS		:
154  * NOTES			:
155  * CHANGE HISTROY
156  * Author			Date				Description of change
157  * ************************************************************************************/
setClassID(int inClassId)158 void LTKShapeSample::setClassID(int inClassId)
159 {
160     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
161         "Entering LTKShapeSample:setClassID()"  <<endl;
162 
163     m_classId = inClassId;
164 
165     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
166         "Exiting LTKShapeSample:setClassID()"  <<endl;
167 }
168 
169 /**********************************************************************************
170  * AUTHOR		: Saravanan R.
171  * DATE			: 22-Mar-2007
172  * NAME			: getFeatureVector
173  * DESCRIPTION	:
174  * ARGUMENTS		:
175  * RETURNS		:
176  * NOTES			:
177  * CHANGE HISTROY
178  * Author			Date				Description of change
179  * ************************************************************************************/
getFeatureVector() const180 const vector<LTKShapeFeaturePtr>& LTKShapeSample::getFeatureVector() const
181 {
182     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
183         "Entering LTKShapeSample:getFeatureVector()"  <<endl;
184 
185     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
186         "Exiting LTKShapeSample:getFeatureVector()"  <<endl;
187 
188     return m_featureVector;
189 }
190 
191 /**********************************************************************************
192  * AUTHOR		: The Qt Company
193  * DATE			: 17-Mar-2015
194  * NAME			: getFeatureVectorRef
195  * DESCRIPTION	:
196  * ARGUMENTS		:
197  * RETURNS		:
198  * NOTES			:
199  * CHANGE HISTROY
200  * Author			Date				Description of change
201  * ************************************************************************************/
getFeatureVectorRef()202 vector<LTKShapeFeaturePtr>& LTKShapeSample::getFeatureVectorRef()
203 {
204     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
205         "Entering LTKShapeSample:getFeatureVectorRef()"  <<endl;
206 
207     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
208         "Exiting LTKShapeSample:getFeatureVectorRef()"  <<endl;
209 
210     return m_featureVector;
211 }
212 
213 /**********************************************************************************
214  * AUTHOR		: Saravanan R.
215  * DATE			: 22-Mar-2007
216  * NAME			: getClassID
217  * DESCRIPTION	:
218  * ARGUMENTS		:
219  * RETURNS		:
220  * NOTES			:
221  * CHANGE HISTROY
222  * Author			Date				Description of change
223  * ************************************************************************************/
getClassID() const224 int LTKShapeSample::getClassID() const
225 {
226     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
227         "Entering LTKShapeSample:getClassID()"  <<endl;
228 
229     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
230         "Exiting LTKShapeSample:getClassID()"  <<endl;
231 
232     return m_classId;
233 }
234 
235 /**************************************************************************
236  * AUTHOR		: Nidhi Sharma
237  * DATE			: 28-Nov-2007
238  * NAME			: clearShapeSampleFeatures
239  * DESCRIPTION	:
240  * ARGUMENTS		:
241  * RETURNS		:
242  * NOTES			:
243  * CHANGE HISTROY
244  * Author			Date				Description of change
245  * ****************************************************************************/
clearShapeSampleFeatures()246 void LTKShapeSample::clearShapeSampleFeatures()
247 {
248     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
249         "Entering LTKShapeSample:clearShapeSampleFeatures()"  <<endl;
250 
251     m_featureVector.clear();
252     m_classId = -1;
253 
254     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
255         "Exiting LTKShapeSample:clearShapeSampleFeatures()"  <<endl;
256 }
257 /**************************************************************************
258  * AUTHOR		: Balaji MNA
259  * DATE			: 30-June-2009
260  * NAME			: getCountStrokes
261  * DESCRIPTION	: get strokes count
262  * ARGUMENTS	: NONE
263  * RETURNS		: return number of strokes
264  * NOTES		:
265  * CHANGE HISTROY
266  * Author			Date				Description of change
267  * ****************************************************************************/
getCountStrokes() const268 int LTKShapeSample::getCountStrokes() const
269 {
270     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
271         "Entering LTKShapeSample::getCountStrokes()"  <<endl;
272 
273 	int countStrokes = 0;
274 
275 	vector<LTKShapeFeaturePtr>::const_iterator featureIter = m_featureVector.begin();
276 	vector<LTKShapeFeaturePtr>::const_iterator featureEnd = m_featureVector.end();
277 
278 	for(; featureIter != featureEnd; ++featureIter)
279 	{
280 		if ((*featureIter)->isPenUp())
281 			++countStrokes;
282 	}
283 
284     LOG( LTKLogger::LTK_LOGLEVEL_DEBUG)<<
285         "Exiting LTKShapeSample::getCountStrokes()"  <<endl;
286 
287 	return countStrokes;
288 }
289