Exemple #1
0
std::shared_ptr<RenderObject> DisCOVERay::addObject(int sender, const std::string &senderPort,
                                 vistle::Object::const_ptr container,
                                 vistle::Object::const_ptr geometry,
                                 vistle::Object::const_ptr normals,
                                 vistle::Object::const_ptr texture) {

   std::shared_ptr<RayRenderObject> ro(new RayRenderObject(m_device, sender, senderPort, container, geometry, normals, texture));

   const int t = ro->timestep;
   if (t == -1) {
      static_geometry.push_back(ro);
   } else {
      if (anim_geometry.size() <= size_t(t))
         anim_geometry.resize(t+1);
      anim_geometry[t].push_back(ro);
   }

   auto rod = ro->data.get();
   if (rod->scene) {
      RTCGeometry geom_0 = rtcNewGeometry (m_device, RTC_GEOMETRY_TYPE_INSTANCE);
      rtcSetGeometryInstancedScene(geom_0,rod->scene);
      rtcSetGeometryTimeStepCount(geom_0,1);
      rod->instID = rtcAttachGeometry(m_scene,geom_0);
      rtcReleaseGeometry(geom_0);
      if (instances.size() <= rod->instID)
         instances.resize(rod->instID+1);
      vassert(!instances[rod->instID]);
      instances[rod->instID] = rod;

      float transform[16];
      auto geoTransform = geometry->getTransform();
      for (int i=0; i<16; ++i) {
          transform[i] = geoTransform(i%4, i/4);
      }
      auto inv = geoTransform.inverse().transpose();
      for (int c=0; c<3; ++c) {
          rod->normalTransform[c].x = inv(c,0);
          rod->normalTransform[c].y = inv(c,1);
          rod->normalTransform[c].z = inv(c,2);
      }
      rtcSetGeometryTransform(geom_0,0,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,transform);
      rtcCommitGeometry(geom_0);
      if (t == -1 || t == m_timestep) {
         rtcEnableGeometry(geom_0);
         m_renderManager.setModified();
      } else {
         rtcDisableGeometry(geom_0);
      }
      rtcCommitScene(m_scene);
   }

   m_renderManager.addObject(ro);

   return ro;
}
Exemple #2
0
bool IsoSurface::work(vistle::Object::const_ptr grid,
             vistle::Vec<vistle::Scalar>::const_ptr dataS,
             vistle::DataBase::const_ptr mapdata) {

   const int processorType = getIntParameter("processortype");
#ifdef CUTTINGSURFACE
   const Scalar isoValue = 0.0;
#else
   const Scalar isoValue = getFloatParameter("isovalue");
#endif

   Leveller l(isocontrol, grid, isoValue, processorType);
   l.setComputeNormals(m_computeNormals->getValue());

#ifndef CUTTINGSURFACE
   l.setIsoData(dataS);
#endif
   if(mapdata){
      l.addMappedData(mapdata);
   };
   l.process();

#ifndef CUTTINGSURFACE
   auto minmax = dataS->getMinMax();
   if (minmax.first[0] < m_min)
      m_min = minmax.first[0];
   if (minmax.second[0] > m_max)
      m_max = minmax.second[0];
#endif

   Object::ptr result = l.result();
   DataBase::ptr mapresult = l.mapresult();
   if (result && !result->isEmpty()) {
#ifndef CUTTINGSURFACE
      result->copyAttributes(dataS);
#endif
      result->updateInternals();
      result->copyAttributes(grid, false);
      result->setTransform(grid->getTransform());
      if (result->getTimestep() < 0) {
          result->setTimestep(grid->getTimestep());
          result->setNumTimesteps(grid->getNumTimesteps());
      }
      if (result->getBlock() < 0) {
          result->setBlock(grid->getBlock());
          result->setNumBlocks(grid->getNumBlocks());
      }
      if (mapdata && mapresult) {
         mapresult->updateInternals();
         mapresult->copyAttributes(mapdata);
         mapresult->setGrid(result);
         addObject(m_dataOut, mapresult);
      }
#ifndef CUTTINGSURFACE
      else {
          addObject(m_dataOut, result);
      }
#endif
   }
   return true;
}