00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "hs.h"
00012
00013 using namespace std;
00014
00015 HS::HS(
00016 const Id& n,
00017 In<VYApixel>& Cin,
00018 In<VYAlineLength>& inLineLengthIn,
00019 In<VYAlineLength>& outLineLengthIn,
00020 Out<VYApixel>& Cout)
00021 :
00022 Process(n),
00023 CinP( id("CinP"), Cin),
00024 inLineLengthInP( id("inLineLengthInP"), inLineLengthIn),
00025 outLineLengthInP( id("outLineLengthInP"), outLineLengthIn),
00026 CoutP( id("CoutP"), Cout)
00027 {
00028 }
00029
00030 void HS::main()
00031 {
00032 while (true)
00033 {
00034 VYApixel pixel;
00035 VYAlineLength inLineLength;
00036 VYAlineLength outLineLength;
00037 double index;
00038 double scaleFactor;
00039
00040 read(inLineLengthInP, inLineLength);
00041 read(outLineLengthInP, outLineLength);
00042
00043 index = 0;
00044 scaleFactor = (double)outLineLength / (double)inLineLength;
00045
00046 if (scaleFactor <= 1)
00047 {
00048 for (unsigned int i=0; i<inLineLength; i++)
00049 {
00050 read(CinP, pixel);
00051 if (index <= i)
00052 {
00053 write(CoutP, pixel);
00054 index += 1/scaleFactor;
00055 }
00056 }
00057 }
00058 else
00059 {
00060 for (unsigned int i=0; i<outLineLength; i++)
00061 {
00062 if (index <= i)
00063 {
00064 read(CinP, pixel);
00065 index += scaleFactor;
00066 }
00067 write(CoutP, pixel);
00068 }
00069 }
00070 }
00071 }