00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "stdafx.h"
00012
00013 #include "ippdme/Command/ippScanOnCurveCommand.h"
00014 #include "ippdme/misc/ippStringBuilder.h"
00015 #include "ippdme/assert.h"
00016
00017 ippScanOnCurveCommand::ippScanOnCurveCommand(
00018 unsigned int tgNum,
00019 bool inClose,
00020 FormatType inType
00021 )
00022 : ippCommand(tgNum, CommandTag, ScanOnCurve)
00023 , _closed(inClose)
00024 , _type(inType)
00025 {
00026
00027 }
00028
00029 ippScanOnCurveCommand::~ippScanOnCurveCommand()
00030 {
00031 }
00032
00033 void ippScanOnCurveCommand::addPoint(
00034 double x,double y,double z,
00035 double i,double j,double k,
00036 int tag
00037 )
00038 {
00039
00040 _points.push_back(ippScanOnCurvePoint());
00041 ippScanOnCurvePoint& vector =_points.back();
00042 vector.push_back(x);
00043 vector.push_back(y);
00044 vector.push_back(z);
00045 vector.push_back(i);
00046 vector.push_back(j);
00047 vector.push_back(k);
00048 vector.push_back(tag);
00049 }
00050 void ippScanOnCurveCommand::addPoint(
00051 double x,double y,double z,
00052 double i,double j,double k,
00053 int tag,
00054 double pi,double pj,double pk
00055 )
00056 {
00057 addPoint(x,y,z,i,j,k,tag);
00058 ippScanOnCurvePoint& vector =_points.back();
00059 vector.push_back(pi);
00060 vector.push_back(pj);
00061 vector.push_back(pk);
00062 }
00063 void ippScanOnCurveCommand::addPoint(
00064 double x,double y,double z,
00065 double i,double j,double k,
00066 int tag,
00067 double pi,double pj,double pk,
00068 double si,double sj,double sk
00069 )
00070 {
00071 addPoint(x,y,z,i,j,k,tag,pi,pj,pk);
00072 ippScanOnCurvePoint& vector =_points.back();
00073 vector.push_back(si);
00074 vector.push_back(sj);
00075 vector.push_back(sk);
00076 }
00077
00078 const char* ippScanOnCurveCommand::getFormatString(
00079 ippScanOnCurveCommand::FormatType f
00080 )
00081 {
00082 switch(f)
00083 {
00084 case Type1:
00085 return "Format(X(),Y(),Z(),IJK(),tag)";
00086 break;
00087 case Type2:
00088 return "Format(X(),Y(),Z(),IJK(),tag,pi,pj,pk)";
00089 break;
00090 case Type3:
00091 return "Format(X(),Y(),Z(),IJK(),tag,pi,pj,pk,si,sj,sk)";
00092 break;
00093 default:
00094 IPP_ASSERT_FAIL("invalid value");
00095 }
00096 return "";
00097 }
00098
00099 std::string ippScanOnCurveCommand::getCommandString() const
00100 {
00101 ippStringBuilder builder(_tag);
00102 builder.StartFunc(getCommandName());
00103
00104
00105 builder.AppendFunc("Closed",getClosed());
00106
00107
00108 builder.Append(", ");
00109 builder.Append(getFormatString(_type));
00110
00111
00112 builder.StartFunc("Data");
00113 for (int i=0;i<getCount();i++) {
00114 const ippScanOnCurvePoint& vector = _points[i];
00115 IPP_ASSERT( ( _type == Type1 && vector.size() == 7)||
00116 ( _type == Type2 && vector.size() == 10)||
00117 ( _type == Type3 && vector.size() == 13));
00118 for (int j=0;j<vector.size();j++) {
00119 if ( j == 6 ) {
00120 builder.AppendParam((int)vector[j]);
00121 } else {
00122 builder.AppendParam((double)vector[j]);
00123 }
00124 }
00125 }
00126 builder.EndFunc();
00127
00128 builder.EndFunc();
00129 return builder.ToString();
00130 }