示例#1
0
文件: lines.cpp 项目: herbsolo/DynamO
void
SpLines::updateRenderData(magnet::CL::CLGLState& CLState) const
{
  if (!_renderObj.isValid())
    M_throw() << "Updating before the render object has been fetched";
  
  ///////////////////////POSITION DATA UPDATE
  //Divide by the maximum box length, to have a natural scale for the visualizer
  const double lengthRescale = 1 / Sim->primaryCellSize.maxElement();

  double diam = getIntPtr()->maxIntDist() * lengthRescale;

  std::vector<cl_float>& particleData 
    = _renderObj.as<LineParticleRenderer>()._particleData;
      
  size_t lineID(0);

  BOOST_FOREACH(unsigned long ID, *range)
    {
      //Position
      Vector pos = Sim->particleList[ID].getPosition();
      Sim->dynamics.BCs().applyBC(pos);
      for (size_t i(0); i < NDIM; ++i)
	particleData[3 * lineID + i] = pos[i] * lengthRescale;
      
      //Vector
      Vector orientation 
	= diam * Sim->dynamics.getLiouvillean()
	.getRotData(Sim->particleList[ID]).orientation;
      for (size_t i(0); i < NDIM; ++i)
	particleData[3 * (range->size() + lineID) + i] = orientation[i];

      ++lineID;
    }

  _coil->getInstance().getTaskQueue().queueTask(magnet::function::Task::makeTask(&LineParticleRenderer::sendRenderData, 
										 &(_renderObj.as<LineParticleRenderer>()), CLState));
}
    /**
       Update the enumeration.

       \param updateInstances If true (default) all instances will be updated.
                              Otherwise only the content of the enumeration will be updated.

    */
    void StaticPhysicalDiskEnumeration::Update(bool updateInstances/*=true*/)
    {
        for (EntityIterator iter=Begin(); iter!=End(); iter++)
        {
            SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = *iter;
            disk->m_online = false;
        }

#if defined(linux)
        // First detect optical devices so later we can just skip the mount points which we determined are optical disks.
        // Various projects may or may not require optical drive detection. We check if iso9660 file system is to be
        // ignored to determine if optical drives should be detected.
        std::vector<std::wstring> drives;
        if ( ! m_deps->FileSystemIgnored(L"iso9660") )
        {
            // Get CD-ROM and DVD drives directly from the kernel interface in /proc.
            SCXCoreLib::SCXHandle<std::wistream> cdStrm = m_deps->GetWIStream("/proc/sys/dev/cdrom/info");
            std::vector<std::wstring> cdStrmLines;
            SCXCoreLib::SCXStream::NLFs nlfs;
            // /proc/sys/dev/cdrom/info format:
            // CD-ROM information, Id: cdrom.c 3.20 2003/12/17
            //
            // drive name:             sr0      hdc
            // drive speed:            0        0
            // drive # of slots:       1        1
            // ...
            SCXCoreLib::SCXStream::ReadAllLines(*cdStrm, cdStrmLines, nlfs);
            std::wstring lineID(L"drive name:");
            size_t i;
            for (i = 0; i < cdStrmLines.size(); i++)
            {
                if (cdStrmLines[i].substr(0, lineID.size()) == lineID)
                {
                    std::wstring drivesLine = cdStrmLines[i].substr(lineID.size(), std::wstring::npos);
                    SCXCoreLib::StrTokenize(drivesLine, drives, L" \t");
                    size_t d;
                    for (d = 0; d < drives.size(); d++)
                    {
                        AddDiskInstance(L"/dev/" + drives[d], L"/dev/" + drives[d], true);
                    }                
                    break;
                }
            }
        }
#endif

        m_deps->RefreshMNTTab();
        for (std::vector<MntTabEntry>::const_iterator it = m_deps->GetMNTTab().begin(); 
             it != m_deps->GetMNTTab().end(); it++)
        {
#if defined(linux)
            // It this is an optical device just skip it. We already processed it.
            size_t d;
            bool found = false;
            for (d = 0; d < drives.size(); d++)
            {
                if ((L"/dev/" + drives[d]) == it->device)
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                continue;
            }
#endif
            if ( ! m_deps->FileSystemIgnored(it->fileSystem) &&
                 ! m_deps->DeviceIgnored(it->device) &&
                 m_deps->LinkToPhysicalExists(it->fileSystem, it->device, it->mountPoint) )
            {
                std::map<std::wstring, std::wstring> devices = m_deps->GetPhysicalDevices(it->device);
                if (devices.size() == 0)
                {
                    static SCXCoreLib::LogSuppressor suppressor(SCXCoreLib::eError, SCXCoreLib::eTrace);
                    std::wstringstream                  out;

                    out << L"Unable to locate physical devices for: " << it->device;
                    SCX_LOG(m_log, suppressor.GetSeverity(out.str()), out.str());
                    continue;
                }
                for (std::map<std::wstring, std::wstring>::const_iterator dev_it = devices.begin();
                     dev_it != devices.end(); dev_it++)
                {
                    SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = AddDiskInstance(dev_it->first, dev_it->second);
                }
            }
        }
#if defined(sun)
        this->UpdateSolarisHelper();
#endif

        if (updateInstances)
        {
            UpdateInstances();
        }
    }