Ejemplo n.º 1
0
void CCoder::constructBlocks(Stream *in, Analyzer *analyzer)
{
  uint64_t total_in = 0;
  for (size_t p_idx = 0; p_idx < static_cast<size_t>(Detector::kProfileCount); ++p_idx) {
    auto profile = static_cast<Detector::Profile>(p_idx);
    uint64_t pos = 0;
    FileSegmentStream::FileSegments seg;
    seg.base_offset_ = 0;
    seg.stream_ = in;
    for (const auto &b : analyzer->getBlocks()) {
      const auto len = b.length();
      if (b.profile() == profile) {
        FileSegmentStream::SegmentRange range;
        range.offset_ = pos;
        range.length_ = len;
        seg.ranges_.push_back(range);
      }
      pos += len;
    }
    seg.calculateTotalSize();
    if (seg.total_size_ > 0) {
      auto *solid_block = new SolidBlock();
      solid_block->algorithm_ = Algorithm(options_, profile);
      solid_block->segments_.push_back(seg);
      solid_block->total_size_ = seg.total_size_;
      blocks_.blocks_.push_back(solid_block);
    }
  }
  std::sort(blocks_.blocks_.rbegin(), blocks_.blocks_.rend(), BlockSizeComparator());
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
void medOpSubdivide::OnEvent(mafEventBase *maf_event)
//----------------------------------------------------------------------------
{
  if (mafEvent *e = mafEvent::SafeDownCast(maf_event))
  {
    switch(e->GetId())
    {	
      case ID_PREVIEW:
        {
          mafEventMacro(mafEvent(this,CAMERA_UPDATE));
        }
      break;
      case ID_NUMBER_OF_SUBDIVISION:
        {
          if (m_NumberOfSubdivision >5)
          {
            if(m_TestMode == false)
              wxMessageBox("Warning! the number of subdivision is hight, it could require too many memory!");
          }
        }
        break;
      case ID_SUBDIVIDE:
        {
          Algorithm();
        }
        break;
      case wxOK:
        OpStop(OP_RUN_OK);        
      break;
      case wxCANCEL:
        OpStop(OP_RUN_CANCEL);        
      break;
    }
  }
}
TEST(GetAnswerToProblem, itShouldReturnTheCorrectAnswer) {
	Algorithm obj = Algorithm();
	int rangeStart = 1;
	int rangeStop = 20;
	int correctAnswer = 232792560;
	int result = obj.getSmallestMultipleOfRange(rangeStart, rangeStop);
	EXPECT_EQ(correctAnswer, result);
}
TEST(TestProblemSolved, itShouldReturnSmallestMultipleOfSpecifiedRange) {
	Algorithm obj = Algorithm();
	int rangeStart = 1;
	int rangeStop = 10;
	int correctAnswer = 2520;
	int result = obj.getSmallestMultipleOfRange(rangeStart, rangeStop);
	EXPECT_EQ(correctAnswer, result);
}
VGVariantsListElement NetBufferingAlgorithm::BufferingNet(HNet& net, bool isRealBuffering)
{
    if (!isInitialize)   Initialize();

    if (data->printNetInfo)
    {
        ALERT("\t%s\t%d\t", data->design.Nets.GetString<HNet::Name>(net).c_str(), 
            data->design.Nets.GetInt<HNet::PinsCount>(net));
    }
    if (data->typeBufferAddition != LEGAL_ADDITION)
        data->netVisit[::ToID(net)] = true;

    data->vGTree->updateVanGinnekenTree->UpdateTree<HSteinerPoint>(data->design.SteinerPoints[(net, data->design).Source()]);

    if ((data->plotSteinerPoint) || (data->plotNets))
    {
        data->design.Plotter->ShowNetSteinerTree(net, Color_Black, true, 
            HPlotter::WaitTime(data->plotterWaitTime));
    }

    if (data->plotVGTree)
    {
        data->design.Plotter->ShowVGTree(net, data->vGTree->GetSource(), 
            Color_Black, true, HPlotter::WaitTime(data->plotterWaitTime));
    }

    VGVariantsListElement best = Algorithm(data->vGTree);
    int bufCount = best.GetPositionCount();
    best.SortBufferPosition();
    if (bufCount > 0)
    {
        TemplateTypes<NewBuffer>::list newBuffer;
        for (TemplateTypes<BufferPositions>::list::iterator pos = best.GetBufferPosition()->begin(); 
            pos != best.GetBufferPosition()->end(); ++pos)
        {
            data->AddAreaBuffer(data->design[pos->GetBufferInfo()->Type()].SizeX() * data->design[pos->GetBufferInfo()->Type()].SizeY());
            if (data->plotBuffer)
            {
                data->design.Plotter->DrawFilledRectangle(pos->GetPosition()->x, pos->GetPosition()->y, data->design[pos->GetBufferInfo()->Type()].SizeX(), data->design[pos->GetBufferInfo()->Type()].SizeY(), Color_Red, false);
            }
        }
        if (isRealBuffering)
        {
            HNet* newNet = new HNet[bufCount + 1];
            additionNewElement->InsertsBuffer(newBuffer, &best);
            newBuffer.sort();
            additionNewElement->CreateNets(net, newBuffer, newNet, data->vGTree->GetSource()->GetLeft(), bufCount);
            delete [] newNet;
        }
    }

    if ((data->plotSteinerPoint) || (data->plotVGTree) || (data->plotNets))
    {
        data->design.Plotter->ShowPlacement();
    }

    return best;
}
Ejemplo n.º 6
0
void SpectrogramSettings::LoadPrefs()
{
   minFreq = gPrefs->Read(wxT("/Spectrum/MinFreq"), 0L);

   maxFreq = gPrefs->Read(wxT("/Spectrum/MaxFreq"), 8000L);

   range = gPrefs->Read(wxT("/Spectrum/Range"), 80L);
   gain = gPrefs->Read(wxT("/Spectrum/Gain"), 20L);
   frequencyGain = gPrefs->Read(wxT("/Spectrum/FrequencyGain"), 0L);

   windowSize = gPrefs->Read(wxT("/Spectrum/FFTSize"), 256);

#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
   zeroPaddingFactor = gPrefs->Read(wxT("/Spectrum/ZeroPaddingFactor"), 1);
#endif

   gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, eWinFuncHanning);

   isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);

   scaleType = ScaleType(gPrefs->Read(wxT("/Spectrum/ScaleType"), 0L));

#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
   spectralSelection = (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
#endif

   algorithm = Algorithm(gPrefs->Read(wxT("/Spectrum/Algorithm"), 0L));

#ifdef EXPERIMENTAL_FFT_Y_GRID
   fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
#endif //EXPERIMENTAL_FFT_Y_GRID

#ifdef EXPERIMENTAL_FIND_NOTES
   fftFindNotes = (gPrefs->Read(wxT("/Spectrum/FFTFindNotes"), 0L) != 0);
   findNotesMinA = gPrefs->Read(wxT("/Spectrum/FindNotesMinA"), -30.0);
   numberOfMaxima = gPrefs->Read(wxT("/Spectrum/FindNotesN"), 5L);
   findNotesQuantize = (gPrefs->Read(wxT("/Spectrum/FindNotesQuantize"), 0L) != 0);
#endif //EXPERIMENTAL_FIND_NOTES

   // Enforce legal values
   Validate(true);

   // These preferences are not written anywhere in the program as of now,
   // but I keep this legacy here.  Who knows, someone might edit prefs files
   // directly.  PRL
   logMinFreq = gPrefs->Read(wxT("/SpectrumLog/MinFreq"), -1);
   if (logMinFreq < 0)
      logMinFreq = minFreq;
   if (logMinFreq < 1)
      logMinFreq = 1;
   logMaxFreq = gPrefs->Read(wxT("/SpectrumLog/MaxFreq"), -1);
   if (logMaxFreq < 0)
      logMaxFreq = maxFreq;
   logMaxFreq =
      std::max(logMinFreq + 1, logMaxFreq);

   InvalidateCaches();
}
Ejemplo n.º 7
0
void
MaterialAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("MaterialAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("smoothing")) != 0)
        SetSmoothing(node->AsBool());
    if((node = searchNode->GetNode("forceMIR")) != 0)
        SetForceMIR(node->AsBool());
    if((node = searchNode->GetNode("cleanZonesOnly")) != 0)
        SetCleanZonesOnly(node->AsBool());
    if((node = searchNode->GetNode("needValidConnectivity")) != 0)
        SetNeedValidConnectivity(node->AsBool());
    if((node = searchNode->GetNode("algorithm")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 5)
                SetAlgorithm(Algorithm(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Algorithm value;
            if(Algorithm_FromString(node->AsString(), value))
                SetAlgorithm(value);
        }
    }
    if((node = searchNode->GetNode("iterationEnabled")) != 0)
        SetIterationEnabled(node->AsBool());
    if((node = searchNode->GetNode("numIterations")) != 0)
        SetNumIterations(node->AsInt());
    if((node = searchNode->GetNode("iterationDamping")) != 0)
        SetIterationDamping(node->AsFloat());
    if((node = searchNode->GetNode("simplifyHeavilyMixedZones")) != 0)
        SetSimplifyHeavilyMixedZones(node->AsBool());
    if((node = searchNode->GetNode("maxMaterialsPerZone")) != 0)
        SetMaxMaterialsPerZone(node->AsInt());
    if((node = searchNode->GetNode("isoVolumeFraction")) != 0)
        SetIsoVolumeFraction(node->AsFloat());
    if((node = searchNode->GetNode("annealingTime")) != 0)
        SetAnnealingTime(node->AsInt());
}
Ejemplo n.º 8
0
  PvlGroup LimitPolygonSeeder::PluginParameters(QString grpName) {
    PvlGroup pluginInfo(grpName);

    PvlKeyword name("Name", Algorithm());
    PvlKeyword minThickness("MinimumThickness", toString(MinimumThickness()));
    PvlKeyword minArea("MinimumArea", toString(MinimumArea()));
    PvlKeyword majAxis("MajorAxisPoints", toString(p_majorAxisPts));
    PvlKeyword minAxis("MinorAxisPoints", toString(p_minorAxisPts));

    pluginInfo.addKeyword(name);
    pluginInfo.addKeyword(minThickness);
    pluginInfo.addKeyword(minArea);
    pluginInfo.addKeyword(majAxis);
    pluginInfo.addKeyword(minAxis);

    return pluginInfo;
  }
Ejemplo n.º 9
0
void SpectrogramSettings::LoadPrefs()
{
   minFreq = gPrefs->Read(wxT("/Spectrum/MinFreq"), 0L);

   maxFreq = gPrefs->Read(wxT("/Spectrum/MaxFreq"), 8000L);

   range = gPrefs->Read(wxT("/Spectrum/Range"), 80L);
   gain = gPrefs->Read(wxT("/Spectrum/Gain"), 20L);
   frequencyGain = gPrefs->Read(wxT("/Spectrum/FrequencyGain"), 0L);

   windowSize = gPrefs->Read(wxT("/Spectrum/FFTSize"), 256);

#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
   zeroPaddingFactor = gPrefs->Read(wxT("/Spectrum/ZeroPaddingFactor"), 1);
#endif

   gPrefs->Read(wxT("/Spectrum/WindowType"), &windowType, eWinFuncHanning);

   isGrayscale = (gPrefs->Read(wxT("/Spectrum/Grayscale"), 0L) != 0);

   scaleType = ScaleType(gPrefs->Read(wxT("/Spectrum/ScaleType"), 0L));

#ifndef SPECTRAL_SELECTION_GLOBAL_SWITCH
   spectralSelection = (gPrefs->Read(wxT("/Spectrum/EnableSpectralSelection"), 0L) != 0);
#endif

   algorithm = Algorithm(gPrefs->Read(wxT("/Spectrum/Algorithm"), 0L));

#ifdef EXPERIMENTAL_FFT_Y_GRID
   fftYGrid = (gPrefs->Read(wxT("/Spectrum/FFTYGrid"), 0L) != 0);
#endif //EXPERIMENTAL_FFT_Y_GRID

#ifdef EXPERIMENTAL_FIND_NOTES
   fftFindNotes = (gPrefs->Read(wxT("/Spectrum/FFTFindNotes"), 0L) != 0);
   findNotesMinA = gPrefs->Read(wxT("/Spectrum/FindNotesMinA"), -30.0);
   numberOfMaxima = gPrefs->Read(wxT("/Spectrum/FindNotesN"), 5L);
   findNotesQuantize = (gPrefs->Read(wxT("/Spectrum/FindNotesQuantize"), 0L) != 0);
#endif //EXPERIMENTAL_FIND_NOTES

   // Enforce legal values
   Validate(true);

   InvalidateCaches();
}
		//----------
		RigidBodyFit::RigidBodyFit() :
		fit(Algorithm(nlopt::LN_NEWUOA, Algorithm::LocalGradientless)) {
			for(int i=0; i<6; i++) {
				this->parameters.push_back(shared_ptr<ofParameter<float>>(new ofParameter<float>()));
				this->parameters[i]->addListener(this, & RigidBodyFit::callbackTransformParameter);
			}
			
			this->parameterCallbackEnabled = false;

			this->parameters[0]->set("Translate X", 0.0, -20.0f, 20.0f);
			this->parameters[1]->set("Translate Y", 0.0, -20.0f, 20.0f);
			this->parameters[2]->set("Translate Z", 0.0, -20.0f, 20.0f);
			
			this->parameters[3]->set("Rotate X", 0.0, -180.0f, 180.0f);
			this->parameters[4]->set("Rotate Y", 0.0, -180.0f, 180.0f);
			this->parameters[5]->set("Rotate Z", 0.0, -180.0f, 180.0f);

			this->parameterCallbackEnabled = true;

			Model::Parameter modelParameters[6];
			std::fill(modelParameters, modelParameters + 6, 0.0);
			this->model.setParameters(modelParameters);
		}
Ejemplo n.º 11
0
MaterialAttributes::Algorithm
MaterialAttributes::GetAlgorithm() const
{
    return Algorithm(algorithm);
}
Ejemplo n.º 12
0
bool SpectrogramSettings::Validate(bool quiet)
{
   if (!quiet &&
      maxFreq < 100) {
      wxMessageBox(_("Maximum frequency must be 100 Hz or above"));
      return false;
   }
   else
      maxFreq = std::max(100, maxFreq);

   if (!quiet &&
      minFreq < 0) {
      wxMessageBox(_("Minimum frequency must be at least 0 Hz"));
      return false;
   }
   else
      minFreq = std::max(0, minFreq);

   if (!quiet &&
      maxFreq <= minFreq) {
      wxMessageBox(_("Minimum frequency must be less than maximum frequency"));
      return false;
   }
   else
      maxFreq = std::max(1 + minFreq, maxFreq);

   if (!quiet &&
      range <= 0) {
      wxMessageBox(_("The range must be at least 1 dB"));
      return false;
   }
   else
      range = std::max(1, range);

   if (!quiet &&
      frequencyGain < 0) {
      wxMessageBox(_("The frequency gain cannot be negative"));
      return false;
   }
   else if (!quiet &&
      frequencyGain > 60) {
      wxMessageBox(_("The frequency gain must be no more than 60 dB/dec"));
      return false;
   }
   else
      frequencyGain =
         std::max(0, std::min(60, frequencyGain));

   // The rest are controlled by drop-down menus so they can't go wrong
   // in the Preferences dialog, but we also come here after reading fom saved
   // preference files, which could be or from future versions.  Validate quietly.
   windowType =
      std::max(0, std::min(NumWindowFuncs() - 1, windowType));
   scaleType =
      ScaleType(std::max(0,
         std::min((int)(SpectrogramSettings::stNumScaleTypes) - 1,
            (int)(scaleType))));
   algorithm = Algorithm(
      std::max(0, std::min((int)(algNumAlgorithms) - 1, (int)(algorithm)))
   );
   ConvertToEnumeratedWindowSizes();
   ConvertToActualWindowSizes();

   return true;
}
TEST(TestTestsAreWorking, itShouldReturnString) {
	Algorithm obj = Algorithm();
	EXPECT_EQ("Test are working!", obj.getTestAreWorking());
}
FB::JSAPIPtr X509CertificateImpl::get_privateKey()
{
    // TODO fill in parameters
    return boost::shared_ptr<Key>(new Key(m_host, "private", false, Algorithm(m_host, "Boe", FB::VariantMap()), FB::VariantList()));
}