<commit_before>// Virvo - Virtual Reality Volume Rendering
// Copyright (C) 1999-2003 University of Stuttgart, 2004-2005 Brown University
// Contact: <NAME>, <EMAIL>
//
// This file is part of Virvo.
//
// Virvo is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library (see license.txt); if not, write to the 
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#include <iostream>
using std::cerr;
using std::endl;

#ifdef _WIN32
#include <windows.h>
#elif __linux
#include <string.h>
#endif

#ifndef VV_REMOTE_RENDERING
#include "vvopengl.h"
#endif

#include <assert.h>
#include <math.h>
#include "vvcuda.h"
#include "vvdebugmsg.h"
#include "vvvecmath.h"
#include "vvsoftimg.h"
#include "vvsoftvr.h"
#include "vvstopwatch.h"
#include "vvimage.h"

//----------------------------------------------------------------------------
/// Constructor.
vvSoftVR::vvSoftVR(vvVolDesc* vd, vvRenderState rs) : vvRenderer(vd, rs)
{
   int i;

   vvDebugMsg::msg(1, "vvSoftVR::vvSoftVR()");

   // Initialize variables:
   xClipNormal.set(0.0f, 0.0f, 1.0f);
   xClipDist = 0.0f;
   numProc = vvToolshed::getNumProcessors();
   len[0] = len[1] = len[2] = 0;
   compression = false;
   multiprocessing = false;
   preIntegration = false;
   sliceInterpol = true;
   warpInterpol = true;
   sliceBuffer = true;
   bilinLookup = false;
   opCorr = false;
   earlyRayTermination = 0;
   _timing = false;
   _size = vd->getSize();

   //  setWarpMode(SOFTWARE);     // initialize warp mode
   setWarpMode(TEXTURE);

   // Create intermediate image:
   intImg = new vvSoftImg(0,0);

#ifdef HAVE_CUDA
   mappedImage = false;
#endif

   // Create output image size:
   outImg = NULL;
   vWidth = vHeight = -1;
   setOutputImageSize();

   // Generate x and y axis representations:
   for (i=0; i<3; ++i)
   {
      raw[i] = NULL;
      rle[i] = NULL;
      rleStart[i] = NULL;
   }
   findAxisRepresentations();
   //  encodeRLE();

   if (vd->getBPV() != 1)
   {
      cerr << "Shear-warp renderer can only display 8 bit scalar datasets." << endl;
   }

   // Generate color LUTs:
   updateTransferFunction();
}


//----------------------------------------------------------------------------
/// Destructor.
vvSoftVR::~vvSoftVR()
{
   int i;

   vvDebugMsg::msg(1, "vvSoftVR::~vvSoftVR()");

   delete outImg;
   delete intImg;
   for (i=0; i<3; ++i)
      delete[] raw[i];
}


//----------------------------------------------------------------------------
// See description in superclass.
void vvSoftVR::renderVolumeGL()
{
#ifndef VV_REMOTE_RENDERING
   GLint matrixMode;                              // current OpenGL matrix mode
   vvStopwatch* sw = NULL;                        // stop watch
                                                  // rendering times
   float preparation=0.0f, compositing=0.0f, warp=0.0f, total=0.0f;
   bool result;

   vvDebugMsg::msg(3, "vvSoftPer::renderVolumeGL()");

   if (vd->getBPV() != 1) return;                      // TODO: should work with all color depths

   if (_timing)
   {
      sw = new vvStopwatch();
      sw->start();
   }

   // Memorize current OpenGL matrix mode and modelview matrix
   // because prepareRendering modifies the modelview matrix:
   glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();

   result = prepareRendering();

   // Undo translation:
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();
   glMatrixMode(matrixMode);                      // restore matrix mode

   if (!result)
   {
      delete sw;
      return;
   }

   if (_timing)
   {
      preparation = sw->getTime();
   }

   compositeVolume();

   if (_timing)
   {
      compositing = sw->getTime() - preparation;
   }

   if (vvDebugMsg::isActive(3))
      compositeOutline();

   if (_renderState._boundaries)
                                                  // draw back boundaries
      drawBoundingBox(&_size, &vd->pos, _renderState._boundColor /*FIXME:, false*/);

   if (warpMode==SOFTWARE)
   {
      outImg->warp(&ivWarp, intImg);
      if (vvDebugMsg::isActive(3))
         outImg->overlay(intImg);
      outImg->draw();
   }
   else
      intImg->warpTex(&iwWarp);

   if (_renderState._boundaries)
                                                  // draw front boundaries
      drawBoundingBox(&_size, &vd->pos, _renderState._boundColor /*FIXME:, true*/);

   if (_timing)
   {
      total = sw->getTime();
      warp = total - compositing - preparation;
      cerr << "Times [ms]: prep=" << (preparation*1000.0f) <<
         ", comp=" << (compositing*1000.0f) << ", warp=" <<
         (warp * 1000.0f) << ", total=" << (total*1000.0f) << endl;
      delete sw;
   }

   vvRenderer::renderVolumeGL();                  // draw coordinate axes
#endif
}

<commit_msg>overlay intermediate image also for texture based warp<commit_after>// Virvo - Virtual Reality Volume Rendering
// Copyright (C) 1999-2003 University of Stuttgart, 2004-2005 Brown University
// Contact: <NAME>, <EMAIL>
//
// This file is part of Virvo.
//
// Virvo is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library (see license.txt); if not, write to the 
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#include <iostream>
using std::cerr;
using std::endl;

#ifdef _WIN32
#include <windows.h>
#elif __linux
#include <string.h>
#endif

#ifndef VV_REMOTE_RENDERING
#include "vvopengl.h"
#endif

#include <assert.h>
#include <math.h>
#include "vvcuda.h"
#include "vvdebugmsg.h"
#include "vvvecmath.h"
#include "vvsoftimg.h"
#include "vvsoftvr.h"
#include "vvstopwatch.h"
#include "vvimage.h"

//----------------------------------------------------------------------------
/// Constructor.
vvSoftVR::vvSoftVR(vvVolDesc* vd, vvRenderState rs) : vvRenderer(vd, rs)
{
   int i;

   vvDebugMsg::msg(1, "vvSoftVR::vvSoftVR()");

   // Initialize variables:
   xClipNormal.set(0.0f, 0.0f, 1.0f);
   xClipDist = 0.0f;
   numProc = vvToolshed::getNumProcessors();
   len[0] = len[1] = len[2] = 0;
   compression = false;
   multiprocessing = false;
   preIntegration = false;
   sliceInterpol = true;
   warpInterpol = true;
   sliceBuffer = true;
   bilinLookup = false;
   opCorr = false;
   earlyRayTermination = 0;
   _timing = false;
   _size = vd->getSize();

   //  setWarpMode(SOFTWARE);     // initialize warp mode
   setWarpMode(TEXTURE);

   // Create intermediate image:
   intImg = new vvSoftImg(0,0);

#ifdef HAVE_CUDA
   mappedImage = false;
#endif

   // Create output image size:
   outImg = NULL;
   vWidth = vHeight = -1;
   setOutputImageSize();

   // Generate x and y axis representations:
   for (i=0; i<3; ++i)
   {
      raw[i] = NULL;
      rle[i] = NULL;
      rleStart[i] = NULL;
   }
   findAxisRepresentations();
   //  encodeRLE();

   if (vd->getBPV() != 1)
   {
      cerr << "Shear-warp renderer can only display 8 bit scalar datasets." << endl;
   }

   // Generate color LUTs:
   updateTransferFunction();
}


//----------------------------------------------------------------------------
/// Destructor.
vvSoftVR::~vvSoftVR()
{
   int i;

   vvDebugMsg::msg(1, "vvSoftVR::~vvSoftVR()");

   delete outImg;
   delete intImg;
   for (i=0; i<3; ++i)
      delete[] raw[i];
}


//----------------------------------------------------------------------------
// See description in superclass.
void vvSoftVR::renderVolumeGL()
{
#ifndef VV_REMOTE_RENDERING
   GLint matrixMode;                              // current OpenGL matrix mode
   vvStopwatch* sw = NULL;                        // stop watch
                                                  // rendering times
   float preparation=0.0f, compositing=0.0f, warp=0.0f, total=0.0f;
   bool result;

   vvDebugMsg::msg(3, "vvSoftPer::renderVolumeGL()");

   if (vd->getBPV() != 1) return;                      // TODO: should work with all color depths

   if (_timing)
   {
      sw = new vvStopwatch();
      sw->start();
   }

   // Memorize current OpenGL matrix mode and modelview matrix
   // because prepareRendering modifies the modelview matrix:
   glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();

   result = prepareRendering();

   // Undo translation:
   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();
   glMatrixMode(matrixMode);                      // restore matrix mode

   if (!result)
   {
      delete sw;
      return;
   }

   if (_timing)
   {
      preparation = sw->getTime();
   }

   compositeVolume();

   if (_timing)
   {
      compositing = sw->getTime() - preparation;
   }

   if (vvDebugMsg::isActive(3))
      compositeOutline();

   if (_renderState._boundaries)
                                                  // draw back boundaries
      drawBoundingBox(&_size, &vd->pos, _renderState._boundColor /*FIXME:, false*/);

   if (warpMode==SOFTWARE)
   {
      outImg->warp(&ivWarp, intImg);
      if (vvDebugMsg::isActive(3))
         outImg->overlay(intImg);
      outImg->draw();
   }
   else
   {
      intImg->warpTex(&iwWarp);
      if (vvDebugMsg::isActive(3))
         intImg->draw();
   }

   if (_renderState._boundaries)
                                                  // draw front boundaries
      drawBoundingBox(&_size, &vd->pos, _renderState._boundColor /*FIXME:, true*/);

   if (_timing)
   {
      total = sw->getTime();
      warp = total - compositing - preparation;
      cerr << "Times [ms]: prep=" << (preparation*1000.0f) <<
         ", comp=" << (compositing*1000.0f) << ", warp=" <<
         (warp * 1000.0f) << ", total=" << (total*1000.0f) << endl;
      delete sw;
   }

   vvRenderer::renderVolumeGL();                  // draw coordinate axes
#endif
}


{'fraction_non_alphanumeric': 0.16631070665799982, 'fraction_numerical': 0.01680750301792181, 'mean_word_length': 2.1892212022505184, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1036354', 'n_tokens_mistral': 3507, 'n_tokens_neox': 3324, 'n_words': 918}