/******************************************************************************
* AUTHOR        : Bharath A
* DATE          : 12-Jun-2008
* NAME			: convertFeatVecToTraceGroup
* DESCRIPTION	:
* ARGUMENTS		:
* RETURNS		:
* NOTES			:
* CHANGE HISTROY
* Author			Date				Description
******************************************************************************/
int NPenShapeFeatureExtractor::convertFeatVecToTraceGroup(
                                 const vector<LTKShapeFeaturePtr>& shapeFeature,
                                 LTKTraceGroup& outTraceGroup)
{
    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Entering " <<
        "NPenShapeFeatureExtractor::convertFeatVecToTraceGroup()" << endl;
    
	vector<LTKChannel> channels;				//	channels of a trace

	LTKChannel xChannel("X", DT_FLOAT, true);	//	x-coordinate channel of the trace
	LTKChannel yChannel("Y", DT_FLOAT, true);	//	y-coordinate channel of the trace

	//initializing the channels of the trace
	channels.push_back(xChannel);
	channels.push_back(yChannel);

	//	composing the trace format object
	LTKTraceFormat traceFormat(channels);

	vector<float> point;				//	a point of a trace

	LTKTrace trace(traceFormat);

	for(int count=0;count<(int)shapeFeature.size();count++)
	{
		float Xpoint, Ypoint;
		bool penUp;

		NPenShapeFeature* ptr = (NPenShapeFeature*)(shapeFeature[count].operator ->());
		Xpoint = ptr->getX();
		Ypoint = ptr->getY();
		penUp = ptr->isPenUp();



		point.push_back(Xpoint);
		point.push_back(Ypoint);

		trace.addPoint(point);
		point.clear();


		if(penUp == true)	// end of a trace, clearing the trace now
		{
			outTraceGroup.addTrace(trace);
			trace.emptyTrace();
			LTKTrace tempTrace(traceFormat);
			trace = tempTrace;
		}
	}

    LOG(LTKLogger::LTK_LOGLEVEL_DEBUG) << "Exiting " <<
        "NPenShapeFeatureExtractor::convertFeatVecToTraceGroup()" << endl;
	return SUCCESS;

}
	int NPenShapeFeature::getDistance(const LTKShapeFeaturePtr& shapeFeaturePtr, float& outDistance) const
	{ 
		outDistance = 0.0;
		
		NPenShapeFeature *inFeature = (NPenShapeFeature*)(shapeFeaturePtr.operator ->());
		
		outDistance += (m_x - inFeature->getX())*(m_x - inFeature->getX());
		outDistance += (m_y - inFeature->getY())*(m_y - inFeature->getY());
		outDistance += (m_cosAlpha - inFeature->getCosAlpha())*(m_cosAlpha - inFeature->getCosAlpha());
		outDistance += (m_sinAlpha - inFeature->getSinAlpha())*(m_sinAlpha - inFeature->getSinAlpha());
		outDistance += (m_cosBeta - inFeature->getCosBeta())*(m_cosBeta - inFeature->getCosBeta());
		outDistance += (m_sinBeta - inFeature->getSinBeta())*(m_sinBeta - inFeature->getSinBeta());
		outDistance += (m_aspect - inFeature->getAspect())*(m_aspect - inFeature->getAspect());
		outDistance += (m_curliness - inFeature->getCurliness())*(m_curliness - inFeature->getCurliness());
		outDistance += (m_linearity - inFeature->getLinearity())*(m_linearity - inFeature->getLinearity());
		outDistance += (m_slope - inFeature->getSlope())*(m_slope - inFeature->getSlope());
		

		return SUCCESS;

	}