コード例 #1
0
ファイル: networkbuilder.cpp プロジェクト: bhanu475/tesseract
// Builds a network with a network_spec in the network description
// language, to recognize a character set of num_outputs size.
// If append_index is non-negative, then *network must be non-null and the
// given network_spec will be appended to *network AFTER append_index, with
// the top of the input *network discarded.
// Note that network_spec is call by value to allow a non-const char* pointer
// into the string for BuildFromString.
// net_flags control network behavior according to the NetworkFlags enum.
// The resulting network is returned via **network.
// Returns false if something failed.
bool NetworkBuilder::InitNetwork(int num_outputs, STRING network_spec,
                                 int append_index, int net_flags,
                                 float weight_range, TRand* randomizer,
                                 Network** network) {
  NetworkBuilder builder(num_outputs);
  Series* bottom_series = NULL;
  StaticShape input_shape;
  if (append_index >= 0) {
    // Split the current network after the given append_index.
    ASSERT_HOST(*network != NULL && (*network)->type() == NT_SERIES);
    Series* series = reinterpret_cast<Series*>(*network);
    Series* top_series = NULL;
    series->SplitAt(append_index, &bottom_series, &top_series);
    if (bottom_series == NULL || top_series == NULL) {
      tprintf("Yikes! Splitting current network failed!!\n");
      return false;
    }
    input_shape = bottom_series->OutputShape(input_shape);
    delete top_series;
  }
  char* str_ptr = &network_spec[0];
  *network = builder.BuildFromString(input_shape, &str_ptr);
  if (*network == NULL) return false;
  (*network)->SetNetworkFlags(net_flags);
  (*network)->InitWeights(weight_range, randomizer);
  (*network)->SetupNeedsBackprop(false);
  if (bottom_series != NULL) {
    bottom_series->AppendSeries(*network);
    *network = bottom_series;
  }
  (*network)->CacheXScaleFactor((*network)->XScaleFactor());
  return true;
}
コード例 #2
0
ファイル: Test.cpp プロジェクト: ainur-giniyatov/wxPlot
bool TestPlotWithArea::DoTest()
{
    Plot *plot;
    plot = new Plot();

    Area *area = new Area2D();

    Box *box1, *box2;
    box1 = new Box(plot);

    box2 = new Box(plot);

    Series *series;
    series = new Series2D("Series");

    DataTyped<int> *xdata;
    xdata = new DataTyped<int>();

    series->SetData(xdata, AXIS_X);

    area->AddSeries(series);
    plot->AddArea(area);

    delete box1;


    delete plot;

    return true;
}
コード例 #3
0
ファイル: networkbuilder.cpp プロジェクト: bhanu475/tesseract
// Parses a network that begins with 'C'.
Network* NetworkBuilder::ParseC(const StaticShape& input_shape, char** str) {
  NetworkType type = NonLinearity((*str)[1]);
  if (type == NT_NONE) {
    tprintf("Invalid nonlinearity on C-spec!: %s\n", *str);
    return nullptr;
  }
  int y = 0, x = 0, d = 0;
  if ((y = strtol(*str + 2, str, 10)) <= 0 || **str != ',' ||
      (x = strtol(*str + 1, str, 10)) <= 0 || **str != ',' ||
      (d = strtol(*str + 1, str, 10)) <= 0) {
    tprintf("Invalid C spec!:%s\n", *str);
    return nullptr;
  }
  if (x == 1 && y == 1) {
    // No actual convolution. Just a FullyConnected on the current depth, to
    // be slid over all batch,y,x.
    return new FullyConnected("Conv1x1", input_shape.depth(), d, type);
  }
  Series* series = new Series("ConvSeries");
  Convolve* convolve =
      new Convolve("Convolve", input_shape.depth(), x / 2, y / 2);
  series->AddToStack(convolve);
  StaticShape fc_input = convolve->OutputShape(input_shape);
  series->AddToStack(new FullyConnected("ConvNL", fc_input.depth(), d, type));
  return series;
}
コード例 #4
0
ファイル: dtw.cpp プロジェクト: lbull/AA-T2-DTW
void readData()
{

    //percorrendo

    list<double>::iterator it;

    for(int i = 0; i < mySeries.size(); i++)
    {
        cout <<"serie " << i<<endl;
        for(it = mySeries[i].begin(); it != mySeries[i].end(); it++)
        {

            cout << *it << " ";
        }

        cout << endl;
    }

    for(int i = 0; i < templateSeries.size(); i++)
    {
        cout <<"serie " << i<<endl;
        for(it = templateSeries[i].begin(); it != templateSeries[i].end(); it++)
        {

            cout << *it << " ";
        }

        cout << endl;
    }

}
コード例 #5
0
ファイル: Talk.cpp プロジェクト: Amos-zq/marsyas
void
Talk::cmd_load(mrs_string fname, mrs_natural lineSize)
{
  cout << "cmd_load called" << endl;

  src_ = new SoundFileSource("src");
  src_->updControl("mrs_string/filename", fname);
  fname_ = fname;
  src_->updControl("mrs_natural/inSamples", lineSize);
  AbsMax* absmax = new AbsMax("absmax");

  Series *series = new Series("plot");
  series->addMarSystem(src_);
  series->addMarSystem(absmax);


  mrs_natural hops = src_->getctrl("mrs_natural/size")->to<mrs_natural>() * src_->getctrl("mrs_natural/nChannels")->to<mrs_natural>() / src_->getctrl("mrs_natural/inSamples")->to<mrs_natural>() + 1;


  Accumulator* acc = new Accumulator("acc");
  acc->updControl("mrs_natural/nTimes", hops);
  acc->addMarSystem(series);



  realvec in(acc->getctrl("mrs_natural/inObservations")->to<mrs_natural>(),
             acc->getctrl("mrs_natural/inSamples")->to<mrs_natural>());

  realvec out(acc->getctrl("mrs_natural/onObservations")->to<mrs_natural>(),
              acc->getctrl("mrs_natural/onSamples")->to<mrs_natural>());



  acc->process(in,out);

  out.send(communicator_);



//   Util util;
//   fname_ = fname;
//   src_ = util.sfopen(fname, MRS_SF_READ);
//   if (src_ == NULL)
//     cout << "src_ = NULL" << endl;

//   if (src_ != NULL)			// File exists
//     {
//       src_->initWindow(lineSize, lineSize, 0, 0);
//       PlotExtractor pextractor(src_, src_->winSize());
//       fvec res(src_->iterations());
//       pextractor.extract(0, src_->iterations(), res);
//       res.send(communicator_);
//     }
//   else
//     {
//       fvec res(0);
//       res.send(communicator_);
//     }
}
コード例 #6
0
ファイル: LocalService.cpp プロジェクト: JanKolomaznik/MedV4D
void
LocalService::CheckDataSet(
    DcmDataset *dataSet,
    SerieInfo &sInfo,
    TableRow &row,
    std::string path)
{
  // load data from dataSet
  GetTableRowFromDataSet( dataSet, &row);
  GetSeriesInfo( dataSet, &sInfo);

  // now check what is in database
  Patients::iterator patIt = m_patients.find( row.patientID);
  if( patIt == m_patients.end() )
  {
    // insert new patient
    // insert new study
    Serie serie(sInfo.id, sInfo.description, path);
    Series s;
    s.insert( Series::value_type( serie.id, serie) );
    Study stud(row.studyID, row.date, s);
    Studies buddStudies;
    buddStudies.insert( Studies::value_type( stud.id, stud));

    Patient buddPat( row.patientID, row.name, row.birthDate, row.sex, buddStudies);
    m_patients.insert( Patients::value_type( row.patientID, buddPat) );
  }
  else
  {
    // perform lookup level down
    Studies &studies = patIt->second.studies;
    Studies::iterator studItr = studies.find( row.studyID);
    if( studItr == studies.end() )
    {
      // insert new study
      Serie serie(sInfo.id, sInfo.description, path);
      Series s;
      s.insert( Series::value_type( serie.id, serie) );
      Study stud(row.studyID, row.date, s);
      patIt->second.studies.insert( Studies::value_type(
        stud.id, stud) );
    }
    else
    {
      // perform lookup level down
      Series &series = studItr->second.series;
      Series::iterator serItr = series.find( sInfo.id);
      if( serItr == series.end() )
      {
        // insert new serie
        Serie buddy(sInfo.id, sInfo.description, path);
        series.insert( Series::value_type( sInfo.id, buddy) );
      }
      // else do nothing
    }
  }
}
コード例 #7
0
DataDictionaryImpl::DataDictionaryImpl(const DataDictionaryImpl& other) :
	_loadedFieldDictionary(false),
	_loadedEnumTypeDef(false),
	_pDictionaryEntryList(0),
	_pEnumTypeTableList(0),
	_ownRsslDataDictionary(true),
	_pfieldNameToIdHash(0)
{
	_errorText.length = MAX_ERROR_TEXT_SIZE;
	_errorText.data = (char*)malloc(sizeof(char) * _errorText.length);

	if ( !_errorText.data )
	{
		throwMeeException("Failed to allocate memory in DataDictionaryImpl::DataDictionaryImpl()");
	}

	if ( _ownRsslDataDictionary )
	{
		try
		{
			_pRsslDataDictionary = new RsslDataDictionary();
		}
		catch (std::bad_alloc)
		{
			throwMeeException("Failed to allocate memory in DataDictionaryImpl::DataDictionaryImpl()");
		}

		rsslClearDataDictionary(_pRsslDataDictionary);
	}

	if (!other._loadedEnumTypeDef && !other._loadedFieldDictionary)
	{
		return;
	}

	Series series;

	if ( other._loadedFieldDictionary )
	{
		const_cast<DataDictionaryImpl&>(other).encodeFieldDictionary(series, DICTIONARY_VERBOSE);

		StaticDecoder::setData(&series, 0);

		decodeFieldDictionary(series, DICTIONARY_VERBOSE);

		series.clear();
	}

	if ( other._loadedEnumTypeDef )
	{
		const_cast<DataDictionaryImpl&>(other).encodeEnumTypeDictionary(series, DICTIONARY_VERBOSE);

		StaticDecoder::setData(&series, 0);

		decodeEnumTypeDictionary(series, DICTIONARY_VERBOSE);
	}
}
コード例 #8
0
void LineChartPane::SetOffset(ViewChannels &channels, int offset){
	for (size_t i = 0; i < channels.Count(); i++){
		ViewChannel &channel = channels[i];
		Series *series = m_lineChart->GetSeries(channel.ToString());
		if (NULL != series){
			series->SetOffset(offset);
		}
	}
	m_lineChart->Refresh();
}
コード例 #9
0
 void perform_test_trivial() {
   Series s;
   typedef ParserResultElement<Series> Parser;
   Parser p(s);
   {
     const std::string test = "09/y-i/A/xXyY1";
     OKLIB_TESTTRIVIAL_RETHROW(::OKlib::Parser::Test_ParsingString<Parser>(p, test, ::OKlib::Parser::match_full));
     if(s.name() != test)
       OKLIB_THROW("Resulting name is " + s.name() + ", and not " + test);
   }
 }
コード例 #10
0
    coarse_grain(Series const &series, Discretization discretization, ordered_inserter<Out> out)
    {
        typedef typename concepts::TimeSeries<Series const>::offset_type offset_type;

        BOOST_ASSERT(discretization > series.discretization());
        BOOST_ASSERT(discretization % series.discretization() == 0);

        offset_type factor = discretization / series.discretization();

        detail::coarse_grain_inserter<ordered_inserter<Out>, offset_type> o(out, factor);
        return range_run_storage::copy(series, o).out();
    }
コード例 #11
0
void LineChartPane::UpdateValueRange(ViewDataHistoryArray &historyArray, size_t fromIndex, size_t toIndex){

	for (size_t i = 0; i < historyArray.size(); i++){
		ViewDataHistory &history = historyArray[i];
		Series *series = m_lineChart->GetSeries(history.channel.ToString());
		if (NULL != series){
			for (size_t i = fromIndex; i < toIndex; i++){
				series->SetValueAt(i, history.values[i]);
			}
			m_lineChart->Refresh();
		}
	}
}
コード例 #12
0
ファイル: networkbuilder.cpp プロジェクト: bhanu475/tesseract
// Parses an Output spec.
Network* NetworkBuilder::ParseOutput(const StaticShape& input_shape,
                                     char** str) {
  char dims_ch = (*str)[1];
  if (dims_ch != '0' && dims_ch != '1' && dims_ch != '2') {
    tprintf("Invalid dims (2|1|0) in output spec!:%s\n", *str);
    return nullptr;
  }
  char type_ch = (*str)[2];
  if (type_ch != 'l' && type_ch != 's' && type_ch != 'c') {
    tprintf("Invalid output type (l|s|c) in output spec!:%s\n", *str);
    return nullptr;
  }
  int depth = strtol(*str + 3, str, 10);
  if (depth != num_softmax_outputs_) {
    tprintf("Warning: given outputs %d not equal to unicharset of %d.\n", depth,
            num_softmax_outputs_);
    depth = num_softmax_outputs_;
  }
  NetworkType type = NT_SOFTMAX;
  if (type_ch == 'l')
    type = NT_LOGISTIC;
  else if (type_ch == 's')
    type = NT_SOFTMAX_NO_CTC;
  if (dims_ch == '0') {
    // Same as standard fully connected.
    return BuildFullyConnected(input_shape, type, "Output", depth);
  } else if (dims_ch == '2') {
    // We don't care if x and/or y are variable.
    return new FullyConnected("Output2d", input_shape.depth(), depth, type);
  }
  // For 1-d y has to be fixed, and if not 1, moved to depth.
  if (input_shape.height() == 0) {
    tprintf("Fully connected requires fixed height!\n");
    return nullptr;
  }
  int input_size = input_shape.height();
  int input_depth = input_size * input_shape.depth();
  Network* fc = new FullyConnected("Output", input_depth, depth, type);
  if (input_size > 1) {
    Series* series = new Series("FCSeries");
    series->AddToStack(new Reconfig("FCReconfig", input_shape.depth(), 1,
                                    input_shape.height()));
    series->AddToStack(fc);
    fc = series;
  }
  return fc;
}
コード例 #13
0
ファイル: LocalService.cpp プロジェクト: JanKolomaznik/MedV4D
void
LocalService::FindStudyInfo( 
      SerieInfoVector &result,
      const std::string &patientID,
			const std::string &studyID)
{
  // just take informatoin from tree
  Series series = GetSeries( patientID, studyID);
  SerieInfo s;
  for( Series::iterator serie=series.begin(); 
    serie != series.end(); serie++)
  {
    s.id = serie->second.id;
    s.description = serie->second.desc;
    result.push_back( s);
  }
}
コード例 #14
0
ファイル: Test.cpp プロジェクト: ainur-giniyatov/wxPlot
bool TestSeries2DwithData::DoTest()
{
    Series *serie;
    serie = new Series2D("new series");

    DataNoType *xdata, *ydata;
    xdata = new DataTyped<double>(100, "x-data");
    ydata = new DataTyped<double>(100, "y-data");

    serie->SetData(xdata, AXIS_X);
    serie->SetData(ydata, AXIS_Y);

    //delete ydata;
    delete xdata;
    delete serie;
    return true;
}
コード例 #15
0
ファイル: main.cpp プロジェクト: sergerold/imdb-tv
int main()
{
	//threaded	 

	try
	{
		Series test ("/title/tt0436992/");
		test.getEpisodes();
		std::cout << test.getXML();
	}

	catch (const char* msg)
	{
    		 std::cerr << msg << std::endl;
   	}


}
コード例 #16
0
void LineChartPane::SetBufferSize(ViewChannels &channels, size_t size, int offset){

	ViewChannels enabledChannels;
	for (size_t i = 0; i < channels.Count(); i++){
		ViewChannel &channel = channels[i];
		Series *series = m_lineChart->GetSeries(channel.ToString());
		if (NULL != series){
			enabledChannels.Add(channel);
			series->SetBufferSize(size);
			series->SetOffset(offset);
		}
	}

	wxCommandEvent addEvent(REQUEST_DATALOG_DATA_EVENT, ID_REQUEST_DATALOG_DATA);
	RequestDatalogRangeParams *params = new RequestDatalogRangeParams(this, enabledChannels, 0, size - 1);
	addEvent.SetClientData(params);
	GetParent()->GetEventHandler()->AddPendingEvent(addEvent);
}
コード例 #17
0
ファイル: lineChart.cpp プロジェクト: BMWPower/RaceAnalyzer
void LineChart::DrawCurrentValues(wxMemoryDC &dc, size_t dataIndex, int x, int y){
	int currentOffset = 0;
	wxFont labelFont = GetFont();
	int labelWidth,labelHeight,descent,externalLeading;

	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		Series *series = it->second;
		double dataValue = series->GetValueAtOrNear(dataIndex);
		wxString numberFormat = "% 2." + wxString::Format("%df", series->GetPrecision());
		wxString valueString = (DatalogValue::NULL_VALUE == dataValue ? "---" : wxString::Format(numberFormat.ToAscii(), dataValue)) + " " + series->GetLabel();
		dc.SetTextForeground(series->GetColor());
		dc.GetTextExtent(valueString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);

		dc.DrawRotatedText(valueString, x + CURRENT_VALUES_RIGHT_OFFSET, y + currentOffset,0);
		currentOffset += labelWidth;
	}
}
コード例 #18
0
ファイル: Series.cpp プロジェクト: volchnik/stock_cpp
const Series operator/(const double &dividend, const Series &series) {
  Series returnSeries(series);
  for (auto &datetime_series : returnSeries.datetime_map_) {
    for (auto &sample : datetime_series.second.series_) {
      sample.value = dividend / sample.value;
    }
  }
  returnSeries.SetName("(" + std::to_string(dividend) + " / " + series.GetName() + ")");
  return returnSeries;
}
コード例 #19
0
ファイル: dtw.cpp プロジェクト: lbull/AA-T2-DTW
void DTW()
{
    int myBestClass;
    double myMinDbl, myDbl;
    int totalHits, correctClass;
    list<double>::iterator it;


    totalHits = 0;

    //uncoment do get graph data
    //cout << " Error at: \n Serie number | Class Estimated | Correct Class " << endl;

    //series a serem testadas
    for(int k = 0; k < mySeries.size()-1; k++)
    {
        myMinDbl = INFINITY;

        //series templates
        for(int i = 0; i < templateSeries.size() -1; i++)
        {
            myDbl = calcDTW(k, i);
            if(myDbl < myMinDbl)
            {
                it = templateSeries[i].begin();
                myBestClass = *it;
                myMinDbl = myDbl;
            }

        }
        it = mySeries[k].begin();
        correctClass = *it;

        if(myBestClass == correctClass)totalHits++;
        //   else cout << k << " " << myBestClass << " " << correctClass  << endl;

    }

    cout <<"Total de Séries: "<< mySeries.size() -1 <<"\nacertos: " << totalHits <<" -> "
        << std::setprecision(5)<< (totalHits * 100.0)/(mySeries.size() -1) << "%" <<endl;

}
コード例 #20
0
ファイル: networkbuilder.cpp プロジェクト: bhanu475/tesseract
// Helper builds a truly (0-d) fully connected layer of the given type.
static Network* BuildFullyConnected(const StaticShape& input_shape,
                                    NetworkType type, const STRING& name,
                                    int depth) {
  if (input_shape.height() == 0 || input_shape.width() == 0) {
    tprintf("Fully connected requires positive height and width, had %d,%d\n",
            input_shape.height(), input_shape.width());
    return nullptr;
  }
  int input_size = input_shape.height() * input_shape.width();
  int input_depth = input_size * input_shape.depth();
  Network* fc = new FullyConnected(name, input_depth, depth, type);
  if (input_size > 1) {
    Series* series = new Series("FCSeries");
    series->AddToStack(new Reconfig("FCReconfig", input_shape.depth(),
                                    input_shape.width(), input_shape.height()));
    series->AddToStack(fc);
    fc = series;
  }
  return fc;
}
コード例 #21
0
ファイル: Talk.cpp プロジェクト: Amos-zq/marsyas
void Talk::cmd_play(mrs_natural start, mrs_natural end, mrs_natural lineSize)
{
  communicator_->send_message("From Server: Play command received\n");



  src_->updControl("mrs_natural/pos", (mrs_natural)start * lineSize);
  src_->updControl("mrs_natural/inSamples", lineSize);



  Series *series = new Series("playbacknet");
  series->addMarSystem(src_);
  series->addMarSystem(dest_);


  series->updControl("AudioSink/dest/mrs_natural/nChannels",
                     series->getctrl("SoundFileSource/src/mrs_natural/nChannels")->to<mrs_natural>());
  for (int i=0; i < end-start; ++i)
  {
    series->tick();
    // communicator_->send_message("tick\n");
  }

}
コード例 #22
0
ファイル: networkbuilder.cpp プロジェクト: bhanu475/tesseract
// Parses a sequential series of networks, defined by [<net><net>...].
Network* NetworkBuilder::ParseSeries(const StaticShape& input_shape,
                                     Input* input_layer, char** str) {
  StaticShape shape = input_shape;
  Series* series = new Series("Series");
  ++*str;
  if (input_layer != nullptr) {
    series->AddToStack(input_layer);
    shape = input_layer->OutputShape(shape);
  }
  Network* network = NULL;
  while (**str != '\0' && **str != ']' &&
         (network = BuildFromString(shape, str)) != NULL) {
    shape = network->OutputShape(shape);
    series->AddToStack(network);
  }
  if (**str != ']') {
    tprintf("Missing ] at end of [Series]!\n");
    delete series;
    return NULL;
  }
  ++*str;
  return series;
}
コード例 #23
0
void DataDictionaryImpl::decodeEnumTypeDictionary(const Series& series, UInt32 verbosity)
{
	if (_ownRsslDataDictionary)
	{
		RsslBuffer rsslBuffer;
		rsslBuffer.data = (char *)series.getAsHex().c_buf();
		rsslBuffer.length = series.getAsHex().length();

		RsslDecodeIterator rsslDecodeIterator;
		rsslClearDecodeIterator(&rsslDecodeIterator);
		RsslRet ret;

		if ((ret = rsslSetDecodeIteratorBuffer(&rsslDecodeIterator, &rsslBuffer)) != RSSL_RET_SUCCESS)
		{
			throwIueException("Failed to set decode iterator buffer in DataDictionaryImpl::decodeEnumTypeDictionary()");
		}

		if ((ret = rsslSetDecodeIteratorRWFVersion(&rsslDecodeIterator, RSSL_RWF_MAJOR_VERSION, RSSL_RWF_MINOR_VERSION)) != RSSL_RET_SUCCESS)
		{
			throwIueException("Failed to set decode iterator RWF version in DataDictionaryImpl::decodeEnumTypeDictionary()");
		}

		if (rsslDecodeEnumTypeDictionary(&rsslDecodeIterator, _pRsslDataDictionary, (RDMDictionaryVerbosityValues)verbosity, &_errorText) < 0)
		{
			EmaString errorText("Failed to decode the enumerated types dictionary");
			errorText.append(CR).append("Reason='").append(_errorText.data).append("'");

			throwIueException(errorText);
		}

		_loadedEnumTypeDef = true;
	}
	else
	{
		throwIueForQueryOnly();
	}
}
コード例 #24
0
// plot a new curve, if a figure of the specified figure name already exists,
// the curve will be plot on that figure; if not, a new figure will be created.
void PlotManager::Plot(const string figure_name, const float *p, int count, int step,
					   int R, int G, int B)
{
	if (count < 1)
		return;

	if (step <= 0)
		step = 1;

	// copy data and create a series format.
	float *data_copy = new float[count];

	for (int i = 0; i < count; i++)
		*(data_copy + i) = *(p + step * i);

	Series s;
	s.SetData(count, data_copy);

	if ((R > 0) || (G > 0) || (B > 0))
		s.SetColor(R, G, B, false);

	// search the named window and create one if none was found
	active_figure = FindFigure(figure_name);
	if ( active_figure == NULL)
	{
		Figure new_figure(figure_name);
		figure_list.push_back(new_figure);
		active_figure = FindFigure(figure_name);
		if (active_figure == NULL)
			exit(-1);
	}

	active_series = active_figure->Add(s);
	active_figure->Show();

}
コード例 #25
0
void DataDictionaryImpl::encodeEnumTypeDictionary(Series& series, UInt32 verbosity)
{
	if (!_loadedEnumTypeDef)
	{
		throwIueException("The enumerated types dictionary was not loaded");
	}

	SeriesEncoder& seriesEncoder = static_cast<SeriesEncoder&>(const_cast<Encoder&>(series.getEncoder()));

	UInt32 enumTypeDictionarySize = _pRsslDataDictionary->enumTableCount > 0 ? (_pRsslDataDictionary->enumTableCount * DEFAULT_ENUM_TABLE_ENTRY_SIZE ) 
		: DEFAULT_ENCODE_ITERATOR_BUFFER_SIZE;

	EncodeIterator* pEncodeIterator;

	if (!seriesEncoder.hasEncIterator())
	{
		seriesEncoder.acquireEncIterator(enumTypeDictionarySize);
		pEncodeIterator = seriesEncoder._pEncodeIter;
	}
	else
	{
		pEncodeIterator = seriesEncoder._pEncodeIter;
		pEncodeIterator->clear(enumTypeDictionarySize);
	}

	RsslRet ret;

	while ((ret = rsslEncodeEnumTypeDictionary(&pEncodeIterator->_rsslEncIter, _pRsslDataDictionary,
		(RDMDictionaryVerbosityValues)verbosity, &_errorText)) == RSSL_RET_DICT_PART_ENCODED)
	{
		pEncodeIterator->reallocate(pEncodeIterator->_allocatedSize * 2);
	}

	if (ret != RSSL_RET_SUCCESS)
	{
		thomsonreuters::ema::access::EmaString errorText("Failed to encode the enumerated type definition");
		errorText.append(CR).append("Reason='").append(_errorText.data).append("'");

		throwIueException(errorText);
	}

	pEncodeIterator->setEncodedLength(rsslGetEncodedBufferLength(&(pEncodeIterator->_rsslEncIter)));

	seriesEncoder._containerComplete = true;
}
コード例 #26
0
ファイル: rotate_left.hpp プロジェクト: dailypips/time_series
    rotate_left(Series const &series, typename concepts::TimeSeries<Series const>::value_type const &value)
    {
        typedef typename concepts::TimeSeries<Series const>::value_type value_type;
        typedef typename concepts::TimeSeries<Series const>::discretization_type discretization_type;
        typedef typename concepts::TimeSeries<Series const>::offset_type offset_type;

        // The partial differences are held in a sparse array.
        sparse_series<value_type, discretization_type, offset_type> result(
            time_series::discretization = series.discretization()
        );

        time_series::rotate_left(
            series
          , value
          , time_series::make_ordered_inserter(result)
        ).commit();

        return result;
    }
コード例 #27
0
ファイル: period_sums.hpp プロジェクト: dailypips/time_series
    period_sums(Series const &series, Offset start, Length length)
    {
        typedef typename concepts::TimeSeries<Series const>::value_type value_type;
        typedef typename concepts::TimeSeries<Series const>::discretization_type discretization_type;

        // The periodic sums are held in a sparse array. The sums are
        // stored at the start of their associated periods.
        sparse_series<value_type, discretization_type, Offset> result(
            time_series::discretization = series.discretization()
        );

        time_series::period_sums(
            series
          , start
          , length
          , time_series::make_ordered_inserter(result)
        ).commit();

        return result;
    }
コード例 #28
0
Volume* VolumeBuilderFromCaptures::build()
{
    Q_ASSERT(m_parentStudy);
    Q_ASSERT(m_vtkImageAppend->GetNumberOfInputs());

    // Creem la nova sèrie
    Series *newSeries = new Series();

    // Omplim la informació de la sèrie a partir de la sèrie de referència

    // Assignem la modalitat segons el valor introduit. El valor per defecte és 'OT' (Other).
    newSeries->setModality(m_modality);
    newSeries->setSOPClassUID(QString(UID_SecondaryCaptureImageStorage));

    // Generem el SeriesInstanceUID a partir del generador de DCMTK. \TODO Utilitzar el nostre UID_ROOT?
    char seriesUid[100];
    dcmGenerateUniqueIdentifier(seriesUid, SITE_SERIES_UID_ROOT);
    newSeries->setInstanceUID(QString(seriesUid));
    // \TODO Quin criteri volem seguir per donar nous noms?
    newSeries->setSeriesNumber(QString("0000") + QString::number(m_parentStudy->getSeries().count()));
    newSeries->setDescription(this->getSeriesDescription());

    // Assignem la sèrie a l'estudi al qual partenyia l'inputVolume.
    newSeries->setParentStudy(m_parentStudy);
    m_parentStudy->addSeries(newSeries);

    // Obtenim el nou vtkImageData a partir de la sortida del vtkImageAppend.
    // Fem un flip horitzontal per tal utilitzar el mateix sistema de coordenades que DICOM.
    m_vtkImageAppend->Update();

    vtkSmartPointer<vtkImageData> newVtkData = vtkSmartPointer<vtkImageData>::New();
    newVtkData->ShallowCopy(m_vtkImageAppend->GetOutput());

    // Creem el nou volume
    Volume *newVolume = new Volume();
    newSeries->addVolume(newVolume);

    // Generem les noves imatges a partir del vtkData generat per vtkImageAppend
    int samplesPerPixel = newVtkData->GetNumberOfScalarComponents();
    int bitsAllocated;
    int bitsStored;
    int highBit;
    int pixelRepresentation;
    int rows;
    int columns;

    // \TODO Potser podriem ser mes precisos
    QString photometricInterpretation;
    if (samplesPerPixel == 1)
    {
        photometricInterpretation = QString("MONOCHROME2");
    }
    else if (samplesPerPixel == 3)
    {
        photometricInterpretation = QString("RGB");
    }

    int scalarType = newVtkData->GetScalarType();

    switch (scalarType)
    {
        //case VTK_CHAR:
        //break;
        case VTK_SIGNED_CHAR:
            bitsAllocated = 8;
            pixelRepresentation = 1;
            break;
        case VTK_UNSIGNED_CHAR:
            bitsAllocated = 8;
            pixelRepresentation = 0;
            break;
        case VTK_SHORT:
            bitsAllocated = 16;
            pixelRepresentation = 1;
            break;
        case VTK_UNSIGNED_SHORT:
            bitsAllocated = 16;
            pixelRepresentation = 0;
            break;
        case VTK_INT:
            bitsAllocated = 32;
            pixelRepresentation = 1;
            break;
        case VTK_UNSIGNED_INT:
            bitsAllocated = 32;
            pixelRepresentation = 0;
            break;
//        case VTK_FLOAT:
//            bitsAllocated = 32;
//            pixelRepresentation = 1; ?
//            break;
//        case VTK_DOUBLE:
//            bitsAllocated = 64;
//            pixelRepresentation = 1; ?
//            break;
        default:
            DEBUG_LOG(QString("Pixel Type no suportat: ") + newVtkData->GetScalarTypeAsString());

    }

    bitsStored = bitsAllocated;
    highBit = bitsStored - 1;

    int *dimensions = newVtkData->GetDimensions();
    double *spacing = newVtkData->GetSpacing();

    rows = dimensions[1];
    columns = dimensions[0];

    Image *currentImage;

    for (int i = 0; i < dimensions[2]; i++)
    {
        currentImage = new Image();

        // Generem el SOPInstanceUID a partir del generador de DCMTK. \TODO Utilitzar el nostre UID_ROOT?
        char instanceUid[100];
        dcmGenerateUniqueIdentifier(instanceUid, SITE_INSTANCE_UID_ROOT);
        currentImage->setSOPInstanceUID(QString(instanceUid));
        newSeries->addImage(currentImage);
        newVolume->addImage(currentImage);
        currentImage->setParentSeries(newSeries);
        currentImage->setOrderNumberInVolume(i);
        currentImage->setVolumeNumberInSeries(0);

        currentImage->setBitsAllocated(bitsAllocated);
        currentImage->setBitsStored(bitsStored);
        currentImage->setHighBit(highBit);
        currentImage->setColumns(columns);
        currentImage->setInstanceNumber(QString::number(i + 1));
        currentImage->setPhotometricInterpretation(photometricInterpretation);
        currentImage->setPixelRepresentation(pixelRepresentation);
        currentImage->setPixelSpacing(spacing[0], spacing[1]);
        currentImage->setRows(rows);
        currentImage->setSamplesPerPixel(samplesPerPixel);

    }

    // Es fa després d'haver inserit les imatges perquè el nou Volume activi el flag de dades carregades.
    newVolume->setData(newVtkData);

    newVolume->setNumberOfPhases(1);
    newVolume->setNumberOfSlicesPerPhase(newSeries->getImages().count());

    // Informació de DEBUG
    DEBUG_LOG(QString("\nNova sèrie generada:") +
     QString("\n  SeriesInstanceUID: ") + newSeries->getInstanceUID() +
     QString("\n  SeriesNumber: ") + newSeries->getSeriesNumber() +
     QString("\n  SeriesDescription: ") + newSeries->getDescription() +
     QString("\n  SOPClassUID: ") + newSeries->getSOPClassUID() +
     QString("\n  Modality: ") + newSeries->getModality() +
     QString("\n  SamplesPerPixel: ") + QString::number(samplesPerPixel) +
     QString("\n  PhotometricInterpretation: ") + photometricInterpretation +
     QString("\n  BitsAllocated: ") + QString::number(bitsAllocated) +
     QString("\n  BitsStored: ") + QString::number(bitsStored) +
     QString("\n  HighBit: ") + QString::number(highBit) +
     QString("\n  PixelRepresentation: ") + QString::number(pixelRepresentation) +
     QString("\n  PixelSpacing: ") + QString::number(spacing[0]) + QString(",") + QString::number(spacing[1]) +
     QString("\n  Num.Imatges: ") + QString::number(newSeries->getImages().count()));

    return newVolume;

}
コード例 #29
0
ファイル: lineChart.cpp プロジェクト: BMWPower/RaceAnalyzer
int LineChart::DrawScale(wxMemoryDC &dc){
	int leftOrientationEdge = 0;
	int rightOrientationEdge = _currentWidth - 1;

	int scaleOrientation = LineChart::ORIENTATION_LEFT;

	wxFont labelFont = GetFont();



	int tickLabelWidth = 0;
	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		int maxLabelWidth = 0;
		Series *series = it->second;
		Range * range = m_rangeArray[series->GetRangeId()];


		double minValue = range->GetMin();
		double maxValue = range->GetMax();
		double rangeSize = maxValue - minValue;
		double stepInterval = (maxValue - minValue) / 10;
		if (stepInterval == 0) stepInterval = 1;

		dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID));

		dc.SetTextForeground(series->GetColor());

		bool labelOn = false;
		int tickLabelHeight,tickDescent,tickExternalLeading;
		dc.DrawLine(leftOrientationEdge, 0, leftOrientationEdge, _currentHeight);

		for (double tick = minValue; tick <=maxValue; tick += stepInterval){

			int y = _currentHeight - (double)_currentHeight * ((tick - minValue) / rangeSize);
			int nextY = _currentHeight - (double)_currentHeight * ((tick + stepInterval - minValue) / rangeSize);

			if (labelOn){
				wxString numberFormat = "%." + wxString::Format("%df", range->GetPrecision());
				wxString tickLabel = wxString::Format(numberFormat, tick);
				dc.GetTextExtent(tickLabel, &tickLabelHeight, &tickLabelWidth, &tickDescent, &tickExternalLeading, &labelFont);
				if (tickLabelHeight > maxLabelWidth) maxLabelWidth = tickLabelHeight;

				if (tickLabelWidth < y - nextY ){
					switch (scaleOrientation){
						case LineChart::ORIENTATION_LEFT:
						{
							dc.DrawRotatedText(tickLabel, leftOrientationEdge, y, 0);
							break;
						}
						case LineChart::ORIENTATION_RIGHT:
						{
							dc.DrawRotatedText(tickLabel, rightOrientationEdge, y, 0);
							break;
						}
					}
				}
			}
			labelOn = !labelOn;
			dc.DrawLine(leftOrientationEdge, y, leftOrientationEdge + tickLabelWidth, y);
		}

		maxLabelWidth+=(tickLabelWidth / 2);
		switch (scaleOrientation){
			case LineChart::ORIENTATION_LEFT:
			{
				leftOrientationEdge += (maxLabelWidth);
				break;
			}
			case LineChart::ORIENTATION_RIGHT:
			{
				rightOrientationEdge -= (maxLabelWidth);
				break;
			}
		}
	}
	return leftOrientationEdge;
}
コード例 #30
0
ファイル: lineChart.cpp プロジェクト: BMWPower/RaceAnalyzer
void LineChart::OnPaint(wxPaintEvent &event){

	wxPaintDC old_dc(this);

	float zoomFactor = (float)_zoomPercentage / 100;

	int w,h ;
	GetClientSize(&w,&h);

	if (w != _currentWidth || h != _currentHeight){
		delete (_memBitmap);
		_currentWidth = w;
		_currentHeight = h;
		_memBitmap = new wxBitmap(_currentWidth, _currentHeight);
	}
	/////////////////
	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	wxColor backColor = GetBackgroundColour();
	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.Clear();
	DrawGrid(dc);

	if (m_showScale){
		m_leftEdge = DrawScale(dc);
	}
	else{
		m_leftEdge = 0;
	}

	size_t largestBufferSize = GetMaxSeriesBufferSize();
	double lastValue = 0;
	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		float currentX = (float)m_leftEdge;
		int lastX = (int)currentX;
		int lastY;

		Series *series = it->second;
		dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID));
		size_t bufSize = series->GetBufferSize();
		Range *range = m_rangeArray[series->GetRangeId()];
		if (bufSize > 0){

			double minValue = range->GetMin();
			double maxValue = range->GetMax();

			double loggedValue = series->GetValueAt(0);

			double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);
			lastY = h - (int)(((double)h) * percentageOfMax);

			size_t i = (size_t)(((double)largestBufferSize) * m_viewOffsetFactor);

			while (i < bufSize && currentX < _currentWidth ){
				if (i == m_markerIndex){
					wxPen pen = dc.GetPen();
					dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSOLID));
					dc.DrawLine(currentX, 0, currentX, _currentHeight);
					DrawCurrentValues(dc, i, currentX, CURRENT_VALUES_TOP_OFFSET);
					dc.SetPen(pen);
				}

				loggedValue = series->GetValueAt(i);

				if (DatalogValue::NULL_VALUE == loggedValue){
					loggedValue = lastValue;
				}
				else{
					lastValue = loggedValue;
				}

				double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);

				int y = h - (int)(((double)h) * percentageOfMax);

				dc.DrawLine(lastX, lastY, (int)currentX, y);
				lastX = (int)currentX;
				lastY = y;
				currentX += zoomFactor;
				i++;
			}
		}
	}
	if (m_showData) DrawMouseoverMarker(dc);
	//blit into the real DC
	old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0);

}