예제 #1
0
void
OutputWarehouse::addOutput(MooseSharedPointer<Output> & output)
{
  _all_ptrs.push_back(output);

  // Add the object to the warehouse storage, Checkpoint placed at end so they are called last
  Checkpoint * cp = dynamic_cast<Checkpoint *>(output.get());
  if (cp != NULL)
    _all_objects.push_back(output.get());
  else
    _all_objects.insert(_all_objects.begin(), output.get());

  // Store the name and pointer
  _object_map[output->name()] = output.get();
  _object_names.insert(output->name());

  // If the output object is a FileOutput then store the output filename
  FileOutput * ptr = dynamic_cast<FileOutput *>(output.get());
  if (ptr != NULL)
    addOutputFilename(ptr->filename());

  // Insert object sync times to the global set
  if (output->parameters().isParamValid("sync_times"))
  {
    std::vector<Real> sync_times = output->parameters().get<std::vector<Real> >("sync_times");
    _sync_times.insert(sync_times.begin(), sync_times.end());
  }
}
예제 #2
0
std::map<std::string, unsigned int>
OutputWarehouse::getFileNumbers()
{

  std::map<std::string, unsigned int> output;
  for (std::vector<Output *>::const_iterator it = _all_objects.begin(); it != _all_objects.end(); ++it)
  {
    FileOutput * ptr = dynamic_cast<FileOutput *>(*it);
    if (ptr != NULL)
      output[ptr->name()] = ptr->getFileNumber();
  }
  return output;
}
예제 #3
0
std::map<std::string, unsigned int>
OutputWarehouse::getFileNumbers()
{

  std::map<std::string, unsigned int> output;
  for (const auto & obj : _all_objects)
  {
    FileOutput * ptr = dynamic_cast<FileOutput *>(obj);
    if (ptr != NULL)
      output[ptr->name()] = ptr->getFileNumber();
  }
  return output;
}
예제 #4
0
// store the HMM into a file
void HMMState::store(FileOutput &file) {
	
	// phonetic symbol
	char strPhone[MAX_PHONETIC_SYMBOL_LENGTH+1];
	memset(strPhone,0,MAX_PHONETIC_SYMBOL_LENGTH+1);
	strcpy(strPhone,m_phoneSet->getStrPhone(m_iPhone));	
	IOBase::writeBytes(file.getStream(),reinterpret_cast<char*>(strPhone),MAX_PHONETIC_SYMBOL_LENGTH+1);
	
	// state
	IOBase::write(file.getStream(),m_iState);
	
	// within word position (DEPRECATED)
	IOBase::write(file.getStream(),m_iPosition);

	// Gaussian components
	int iGaussianComponents = m_gaussianMixture->getNumberComponents();
	IOBase::write(file.getStream(),iGaussianComponents);
	for(int iGaussian = 0 ; iGaussian < iGaussianComponents ; ++iGaussian) {
		Gaussian *gaussian = (*m_gaussianMixture)(iGaussian); 
		IOBase::write(file.getStream(),gaussian->weight());
		gaussian->mean().writeData(file.getStream());
		if (m_iCovarianceModeling == COVARIANCE_MODELLING_TYPE_DIAGONAL) {
			gaussian->covarianceDiag().writeData(file.getStream());
		} else {
			gaussian->covarianceFull().writeData(file.getStream());
		}
	}
}
예제 #5
0
파일: main.cpp 프로젝트: PoiXP/CodeMonkey
int Run(int ArgCount, char** Args)
{
  po::positional_options_description positionOptions;
  positionOptions.add("command", 1);
  positionOptions.add("in_file", 1);
  positionOptions.add("prev_file", 1);

  po::options_description options("Allowed options");
  options.add_options()
    ("help", "print help message")
    ("command", po::value<std::string>(), "Command name {print, diff}. [Positional]")
    ("in_file", po::value<std::string>(), "A dependency file to analyze. [Positional]")
    ("prev_file", po::value<std::string>(), "A dependency file to diff with. [Positional]")
    ("solution", po::value<std::string>(), "Visual Studio 2010 solution file")
    ("out", po::value<std::string>(), "redirect output into the file");

  po::variables_map vm;
  try
  {
    po::store(po::command_line_parser(ArgCount, Args). options(options).positional(positionOptions).run(), vm);
    po::notify(vm);
  }
  catch(po::error& genericError)
  {
    LOG_ERROR("Exception: %s", genericError.what());
    return e_Error_InvalidParameters;
  }

  if (vm.count("command"))
  {
    if (vm.count("out"))
    {
      FileOutput* output = new FileOutput();
      if (output->Open(vm["out"].as<std::string>().c_str()))
      {
        g_Output = output;
      }
      else
      {
        delete output;
        LOG_ERROR("Can't open open file: %s", vm["out"].as<std::string>())
        return e_Error_InvalidParameters;
      }
    }
    else
    {
예제 #6
0
void
OutputWarehouse::setFileNumbers(std::map<std::string, unsigned int> input, unsigned int offset)
{
  for (std::vector<Output *>::const_iterator it = _all_objects.begin(); it != _all_objects.end(); ++it)
  {
    FileOutput * ptr = dynamic_cast<FileOutput *>(*it);
    if (ptr != NULL)
    {
      std::map<std::string, unsigned int>::const_iterator it = input.find(ptr->name());
      if (it != input.end())
      {
        int value = it->second + offset;
        if (value < 0)
          ptr->setFileNumber(0);
        else
          ptr->setFileNumber(it->second + offset);
      }
    }
  }
}
예제 #7
0
파일: patmake.cpp 프로젝트: cambDI/camb
void convertMolfile (char *path, char *filename, FileOutput &cpp_file)
{
   FileScanner molfile("%s\\%s", path, filename);
   MolfileLoader mf_loader(molfile);
   Molecule mol;
   QS_DEF(Array<int>, edges);

   printf("%s\n", filename);

   mf_loader.loadMolecule(mol, true);

   BiconnectedDecomposer bd(mol); 

   if (bd.decompose() != 1)
   {
      printf("Error: %s is not biconnected\n", filename);
      return;
   }

   int i, j;

   edges.clear_reserve(mol.edgeCount());

   for (i = mol.edgeBegin() ; i < mol.edgeEnd(); i = mol.edgeNext(i))
      edges.push(i);

   edges.qsort(edge_cmp, &mol);

   const Edge &edge = mol.getEdge(edges[edges.size() / 2]);

   Vec3f v1 = mol.getAtomPos(edge.beg);
   Vec3f v2 = mol.getAtomPos(edge.end);

   v1.z = 0.f;
   v2.z = 0.f;

   float scale = Vec3f::dist(v1, v2);

   if (scale < 0.0001f)
   {
      printf("Error: %s has zero bond\n", filename);
      return;
   }

   scale = 1.f / scale;

   int first_idx = mol.vertexBegin();
   Vec3f pos = mol.getAtomPos(first_idx);

   for (i = mol.vertexNext(first_idx); i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      if (mol.getAtomPos(i).y < pos.y)
      {
         pos = mol.getAtomPos(i);
         first_idx = i;
      }
   }


   for (i = mol.vertexBegin() ; i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      mol.getAtom2(i).pos.sub(pos);
      mol.getAtom2(i).pos.scale(scale);
   }

   char buf[1024];

   sprintf_s(buf, "BEGIN_PATTERN(\"%s\")", filename);
   cpp_file.writeStringCR(buf);   

   for (i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
   {
      sprintf_s(buf, "   ADD_ATOM(%d, %ff, %ff)", i, mol.getAtomPos(i).x, mol.getAtomPos(i).y);
      cpp_file.writeStringCR(buf);   
   }

   for (i = mol.edgeBegin(); i < mol.edgeEnd(); i = mol.edgeNext(i))
   {
      const Edge &edge = mol.getEdge(i);
      int type = mol.getBond(i).type;
      int qtype = mol.getQueryBond(i).type;

      sprintf_s(buf, "   ADD_BOND(%d, %d, %d)", edge.beg, edge.end, qtype != 0 ? qtype : type);
      cpp_file.writeStringCR(buf);   
   }

   Vec2f v, inter;
   Vec2f pos_i;
   int idx = mol.vertexCount();

   i = first_idx;

   float max_angle, cur_angle;
   float i_angle = 0;
   int next_nei = 0;
   int point_idx = 0;

   pos_i.set(mol.getAtomPos(i).x, mol.getAtomPos(i).y);

   while (true)
   {
      const Vertex &vert = mol.getVertex(i);

      if (i != first_idx)
      {
         v.set(pos_i.x, pos_i.y);
         pos_i.set(mol.getAtomPos(i).x, mol.getAtomPos(i).y);
         v.sub(pos_i);

         i_angle = v.tiltAngle2();
      } else if (point_idx > 0)
         break;

      sprintf_s(buf, "   OUTLINE_POINT(%d, %ff, %ff)", point_idx++, pos_i.x, pos_i.y);
      cpp_file.writeStringCR(buf);

      max_angle = 0.f;

      for (j = vert.neiBegin(); j < vert.neiEnd(); j = vert.neiNext(j))
      {
         const Vec3f &pos_nei = mol.getAtomPos(vert.neiVertex(j));

         v.set(pos_nei.x - pos_i.x, pos_nei.y - pos_i.y);

         cur_angle = v.tiltAngle2() - i_angle;

         if (cur_angle < 0.f)
            cur_angle += 2 * PI;

         if (max_angle < cur_angle)
         {
            max_angle = cur_angle;
            next_nei = j;
         }
      }
      
      i = vert.neiVertex(next_nei);

      float dist, min_dist = 0.f;
      int int_edge;
      Vec2f cur_v1 = pos_i;
      Vec2f cur_v2(mol.getAtomPos(i).x, mol.getAtomPos(i).y);

      while (min_dist < 10000.f)
      {
         min_dist = 10001.f;

         for (j = mol.edgeBegin(); j < mol.edgeEnd(); j = mol.edgeNext(j))
         {
            const Edge &edge = mol.getEdge(j);
            Vec2f cur_v3(mol.getAtomPos(edge.beg).x, mol.getAtomPos(edge.beg).y);
            Vec2f cur_v4(mol.getAtomPos(edge.end).x, mol.getAtomPos(edge.end).y);

            if (Vec2f::intersection(cur_v1, cur_v2, cur_v3, cur_v4, v))
               if ((dist = Vec2f::dist(cur_v1, v)) < min_dist)
               {
                  inter = v;
                  min_dist = dist;
                  int_edge = j;
               }
         }

         if (min_dist < 10000.f)
         {
            sprintf_s(buf, "   OUTLINE_POINT(%d, %ff, %ff)", point_idx++, v.x, v.y);
            cpp_file.writeStringCR(buf);   

            const Edge &edge = mol.getEdge(int_edge);
            Vec2f cur_v3(mol.getAtomPos(edge.beg).x, mol.getAtomPos(edge.beg).y);
            Vec2f cur_v4(mol.getAtomPos(edge.end).x, mol.getAtomPos(edge.end).y);

            Vec2f cur_v1v;
            Vec2f cur_v3v;
            Vec2f cur_v4v;

            cur_v1v.diff(cur_v1, inter);
            cur_v3v.diff(cur_v3, inter);
            cur_v4v.diff(cur_v4, inter);

            float angle1 = cur_v1v.tiltAngle2();
            float angle3 = cur_v3v.tiltAngle2() - angle1;
            float angle4 = cur_v4v.tiltAngle2() - angle1;

            if (angle3 < 0)
               angle3 += 2 * PI;
            if (angle4 < 0)
               angle4 += 2 * PI;

            cur_v1 = inter;

            if (angle3 > angle4)
            {
               cur_v2 = cur_v3;
               i = edge.beg;
            } else
            {
               cur_v2 = cur_v4;
               i = edge.end;
            }
         }
      }
   }

   cpp_file.writeStringCR("END_PATTERN()");   
}