Commit 83991c81 authored by camc's avatar camc

Fix SLIVR, introduce Raycasting: SLIVR, more coherent renderer dialog, add...

Fix SLIVR, introduce Raycasting: SLIVR, more coherent renderer dialog, add support for trilinear interpolation in raycasters.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21927 18c085ea-50e0-402c-830e-de6fd14e8384
parent b539179e
......@@ -83,6 +83,7 @@ avtGhostZoneFilter.C
avtICAlgorithm.C
avtImageCommunicator.C
avtImageCompositer.C
avtImgCommunicator.C
avtLinearTransformFilter.C
avtLineoutFilter.C
avtLineScanFilter.C
......
This diff is collapsed.
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtImgCommunicator.h //
// ************************************************************************* //
#ifndef AVT_IMG_COMMUNICATOR_H
#define AVT_IMG_COMMUNICATOR_H
#include <filters_exports.h>
#include <pipeline_exports.h>
#include <avtSamplePointExtractor.h>
#include <algorithm>
#include <string>
#ifdef PARALLEL
# include <mpi.h>
#endif
#define MSG_DATA 100
#define MSG_RESULT 101
const int SEND = 1;
const int RECEIVE = 2;
struct imageBuffer{
float *image;
float depth;
};
struct code{
float count; // should be int but float makes it easier to send with MPI!
float color[4];
};
// ****************************************************************************
// Class: avtRayTracer
//
// Purpose:
// Does the composition for Ray casting: SLIVR
//
// Programmer: Pascal Grosset
// Creation: Spetember 20, 2013
//
// ****************************************************************************
class avtImgCommunicator
{
int totalPatches;
int numPatchesToCompose;
int *processorPatchesCount;
float *imgBuffer;
iotaMeta *allRecvIotaMeta;
std::set<float> all_avgZ_proc0;
std::vector<std::vector<float> > boundsPerBlockVec;
int *patchesToSendArray, *patchesToRecvArray;
int *numPatchesToSendArray, *numPatchesToRecvArray;
int *recvDisplacementForProcs, *sendDisplacementForProcs;
int *numPatchesToSendRecvArray;
float *boundsPerBlockArray;
int *blockDisplacementForProcs;
int *numBlocksPerProc;
int* patchesToCompositeLocallyArray;
int* numPatchesToCompositeLocally;
int* compositeDisplacementForProcs;
int *compressedSizePerDiv; //size of each division
unsigned char background[3];
int num_procs;
int my_id;
imgMetaData setImg(int _inUse, int _procId, int _patchNumber, float dim_x, float dim_y, float screen_ll_x, float screen_ll_y, float screen_ur_x, float screen_ur_y, float _avg_z);
iotaMeta setIota(int _procId, int _patchNumber, int dim_x, int dim_y, int screen_ll_x, int screen_ll_y, float _avg_z);
int getDataPatchID(int procID, int patchID);
public:
avtImgCommunicator();
~avtImgCommunicator();
virtual const char *GetType(void)
{ return "avtImgCommunicator"; };
virtual const char *GetDescription(void)
{ return "Doing compositing for ray casting SLIVR";};
void init();
void gatherNumPatches(int numPatches);
void gatherIotaMetaData(int arraySize, float *allIotaMetadata);
void patchAllocationLogic(); // decides which processor should get which patches and tell each processor how many patches it will receive
void scatterNumDataToCompose(int& totalSendData, int& totalRecvData, int& numDivisions, int& totalPatchesToCompositeLocally);
void scatterDataToCompose( int& totalSendData, int* informationToSendArray,
int& totalRecvData, int* informationToRecvArray,
int& numDivisions, float* blocksPerProc,
int& totalPatchesToCompositeLocally, int* patchesToCompositeLocally);
void sendPointToPoint(imgMetaData toSendMetaData, imgData toSendImgData, int tag); // Send out the patches and receive them
void recvPointToPoint(imgMetaData &recvMetaData, imgData &recvImgData);
void recvPointToPointMetaData(imgMetaData &recvMetaData, int tag);
void recvPointToPointImgData(imgMetaData recvMetaData, imgData &recvImgData, int tag);
void gatherEncodingSizes(int *sizeEncoding, int numDivisions);
void gatherAndAssembleEncodedImages(int sizex, int sizey, int sizeSending, float *image, int numDivisions); // do the compositing of the subpatches
void getcompositedImage(int imgBufferWidth, int imgBufferHeight, unsigned char *wholeImage); // get the final composited image
int rleEncodeAll(int dimsX, int dimsY, int numDivs, float *imgArray, float *& encoding, int *& sizeOfEncoding);
void rleDecode(int encSize, float *encoding, int offset, float *& img);
void syncAllProcs();
int GetNumProcs(){ return num_procs;};
int GetMyId(){ return my_id;};
float clamp(float x);
void setBackground(unsigned char _background[3]){ for (int i=0; i<3; i++) background[i] = _background[i]; }
#ifdef PARALLEL
MPI_Status status;
MPI_Datatype _img_mpi;
MPI_Datatype createMetaDataType();
#endif
};
#endif
This diff is collapsed.
......@@ -48,9 +48,15 @@
#include <avtExtractor.h>
#include <avtViewInfo.h>
#include <avtOpacityMap.h>
class vtkRectilinearGrid;
class vtkMatrix4x4;
#include <vtkMatrix3x3.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm> // std::max
// ****************************************************************************
// Class: avtMassVoxelExtractor
......@@ -106,6 +112,21 @@ class AVTFILTERS_API avtMassVoxelExtractor : public avtExtractor
const double *);
void SetVariableInformation(std::vector<std::string> &names,
std::vector<int> varsize);
void SetRayCastingSLIVR(bool s) {rayCastingSLIVR = s; };
void SetTrilinear(bool t) {trilinearInterpolation = t; };
void SetLighting(bool l) {lighting = l; };
void SetLightDirection(double _lightDir[3]) { for (int i=0;i<3;i++) lightDirection[i]=_lightDir[i]; }
void SetLightPosition(double _lightPos[4]) { for (int i=0;i<4;i++) lightPosition[i]=_lightPos[i]; }
void SetMatProperties(double _matProp[4]) { for (int i=0;i<4;i++) materialProperties[i]=_matProp[i]; }
void SetTransferFn(avtOpacityMap *_transferFn1D) { transferFn1D = _transferFn1D; };
void SetModelViewMatrix(double _modelViewMatrix[16]) { for (int i=0;i<16;i++) modelViewMatrix[i]=_modelViewMatrix[i]; }
void SetViewDirection(double *vd){ for (int i=0; i<3; i++) view_direction[i] = vd[i]; }
void SetViewUp(double *vu){ for (int i=0; i<3; i++) view_up[i] = vu[i]; }
// Getting the image
void getImageDimensions(int &inUse, int dims[2], int screen_ll[2], int screen_ur[2], float &avg_z);
void getComputedImage(float *image);
void setProcIdPatchID(int _proc, int _patch){ proc = _proc; patch = _patch; }
protected:
bool gridsAreInWorldSpace;
......@@ -114,6 +135,8 @@ class AVTFILTERS_API avtMassVoxelExtractor : public avtExtractor
double aspect;
double cur_clip_range[2];
vtkMatrix4x4 *view_to_world_transform;
vtkMatrix4x4 *world_to_view_transform;
double modelViewMatrix[16];
double *X;
double *Y;
......@@ -134,6 +157,8 @@ class AVTFILTERS_API avtMassVoxelExtractor : public avtExtractor
double *prop_buffer;
int *ind_buffer;
bool *valid_sample;
bool trilinearInterpolation;
bool rayCastingSLIVR;
// We repeatedly divide by the term (X[i+1]-X[i]). In the interest of
// performance, cache the term 1./(X[i+1]-X[i]) and use that for faster
......@@ -142,27 +167,66 @@ class AVTFILTERS_API avtMassVoxelExtractor : public avtExtractor
double *divisors_Y;
double *divisors_Z;
bool lighting;
double lightPosition[4];
float lightDirection[3];
double materialProperties[4];
avtOpacityMap *transferFn1D;
float gradient[3];
double view_direction[3];
double view_up[3];
int debugOn;
int countt;
// Patch details for one image
int patchDrawn; // whether the patch is drawn or not
int imgWidth, imgHeight;
int imgDims[2]; // size of the patch
int imgLowerLeft[2]; // coordinates in the whole image
int imgUpperRight[2]; //
float imgDepth; // from the depth buffer
float *imgArray; // the image data
int proc; // id of the processor
int patch; // id of the patch
int fullImgWidth, fullImgHeight;
int xMin, xMax, yMin, yMax;
void ExtractImageSpaceGrid(vtkRectilinearGrid *,
std::vector<std::string> &varnames,
std::vector<int> &varsize);
void ExtractWorldSpaceGrid(vtkRectilinearGrid *,
std::vector<std::string> &varnames,
std::vector<int> &varsize);
void simpleExtractWorldSpaceGrid(vtkRectilinearGrid *, // added for raycasting slivr
std::vector<std::string> &varnames,
std::vector<int> &varsize);
void RegisterGrid(vtkRectilinearGrid*,
std::vector<std::string>&,std::vector<int>&);
void SampleAlongSegment(const double *, const double*, int, int);
void SampleVariable(int, int, int, int);
bool FrustumIntersectsGrid(int, int, int, int) const;
bool FrustumIntersectsGridSLIVR(int, int, int, int) const;
void GetSegment(int, int, double *, double *) const;
static void FindPlaneNormal(const double *, const double *,
const double *, double *);
bool GridOnPlusSideOfPlane(const double *, const double *) const;
bool FindSegmentIntersections(const double *, const double *,
int &, int &);
};
void computePixelColor(double source_rgb[4], double dest_rgb[4]);
double trilinearInterpolate(double vals[8], float distRight, float distTop, float distBack);
void computeIndices(int dims[3], int indices[6], int returnIndices[8]);
void computeIndicesVert(int dims[3], int indices[6], int returnIndices[8]);
void getIndexandDistFromCenter(float dist, int index, int &index_before, int &index_after, float &dist_before, float &dist_after);
#endif
};
#endif
This diff is collapsed.
......@@ -47,11 +47,13 @@
#include <avtDatasetToImageFilter.h>
#include <avtViewInfo.h>
#include <avtOpacityMap.h>
#include <map>
#include <avtImgCommunicator.h>
class avtRayFunction;
class vtkMatrix4x4;
// ****************************************************************************
// Class: avtRayTracer
//
......@@ -92,6 +94,9 @@ class vtkMatrix4x4;
// Hank Childs, Wed Dec 24 14:17:03 PST 2008
// Add method TightenClippingPlanes.
//
// Pascal Grosset, Fri Sep 20 2013
// Added ray casting slivr & trilinear interpolation
//
// ****************************************************************************
class AVTFILTERS_API avtRayTracer : public avtDatasetToImageFilter
......@@ -123,18 +128,45 @@ class AVTFILTERS_API avtRayTracer : public avtDatasetToImageFilter
void SetKernelBasedSampling(bool v)
{ kernelBasedSampling = v; };
void SetLighting(bool l) {lighting = l; };
void SetLightPosition(double _lightPos[4]) { for (int i=0;i<4;i++) lightPosition[i]=_lightPos[i]; }
void SetLightDirection(double _lightDir[3]) { for (int i=0;i<3;i++) lightDirection[i]=_lightDir[i]; }
void SetMatProperties(double _matProp[4]) { for (int i=0;i<4;i++) materialProperties[i]=_matProp[i]; }
void SetModelViewMatrix(double _modelViewMatrix[16]) { for (int i=0;i<16;i++) modelViewMatrix[i]=_modelViewMatrix[i]; }
void SetViewDirection(double *vd){ for (int i=0; i<3; i++) view_direction[i] = vd[i]; }
void SetViewUp(double *vu){ for (int i=0; i<3; i++) view_up[i] = vu[i]; }
void SetTransferFn(avtOpacityMap *_transferFn1D) {transferFn1D = _transferFn1D; };
void SetTrilinear(bool t) {trilinearInterpolation = t; };
void SetRayCastingSLIVR(bool _rayCastingSLIVR){ rayCastingSLIVR = _rayCastingSLIVR; };
protected:
avtImgCommunicator imgComm;
avtViewInfo view;
int screen[2];
int samplesPerRay;
bool kernelBasedSampling;
bool trilinearInterpolation;
int backgroundMode;
unsigned char background[3];
double gradBG1[3];
double gradBG2[3];
avtRayFunction *rayfoo;
bool lighting;
double lightPosition[4];
double lightDirection[3];
double view_direction[3];
double view_up[3];
double modelViewMatrix[16];
double materialProperties[4];
avtOpacityMap *transferFn1D;
bool rayCastingSLIVR;
avtImage_p opaqueImage;
virtual void Execute(void);
......
......@@ -50,6 +50,9 @@
#include <vtkPointData.h>
#include <vtkRectilinearGrid.h>
#include <avtCallback.h>
#include <avtDatabase.h>
#include <avtDatabaseMetaData.h>
#include <avtDatasetExaminer.h>
#include <avtExtents.h>
#include <avtImagePartition.h>
......@@ -105,6 +108,7 @@ avtResampleFilter::avtResampleFilter(const AttributeGroup *a)
primaryVariable = NULL;
selID = -1;
cellCenteredOutput = false;
rayCasting = false;
}
......@@ -165,107 +169,9 @@ avtResampleFilter::Create(const AttributeGroup *atts)
void
avtResampleFilter::Execute(void)
{
if (InputNeedsNoResampling())
{
debug5 << "Bypassing resample" << endl;
BypassResample();
}
else
{
debug5 << "Resampling input" << endl;
ResampleInput();
}
}
// ****************************************************************************
// Method: avtResampleFilter::InputNeedsNoResampling
//
// Purpose:
// Determines if it is worthwhile to resample the input. It is only
// worthwhile if, (1) the input is truly a rectilinear grid, (2) its
// coordinates are evenly spaced in all dimensions, and (3) the number
// of nodes it has are somewhat near the desired number of nodes.
//
// Programmer: Hank Childs
// Creation: April 6, 2001
//
// Modifications:
//
// Kathleen Bonnell, Tue Apr 10 10:49:10 PDT 2001
// Reflect changes in avtDataSet, that data is stored as single
// avtDataTree, instead of multiple avtDomainTrees. Treat 'domains'
// as first level children in input tree. avtDomain now called
// avtDataRepresentation.
//
// Hank Childs, Mon Nov 19 14:47:10 PST 2001
// Hooked back up resample bypass.
//
// Kathleen Bonnell, Tue Nov 20 08:09:45 PST 2001
// Use vtkDataArray in place of vtkScalars for rgrid coordinates,
// to match VTK 4.0 API.
//
// Mark C. Miller, Tue Sep 13 20:09:49 PDT 2005
// Permitted poly data to pass through
//
// Hank Childs, Thu Oct 6 10:53:17 PDT 2005
// Do not allow rectilinear grids to bypass resampling. Only for poly
// data now. ['6676]
//
// ****************************************************************************
bool
avtResampleFilter::InputNeedsNoResampling(void)
{
avtDataTree_p inDT = GetInputDataTree();
//
// permit VTK_POLY_DATA to pass through unchanged
//
#if 0
int n = 0;
vtkDataSet **in_dss = inDT->GetAllLeaves(n);
if (n && in_dss && in_dss[0] && in_dss[0]->GetDataObjectType() == VTK_POLY_DATA)
{
// Free the memory from the GetAllLeaves function call.
delete [] in_dss;
return true;
}
// Free the memory from the GetAllLeaves function call.
delete [] in_dss;
#endif
return false;
}
// ****************************************************************************
// Method: avtResampleFilter::BypassResample
//
// Purpose:
// Bypasses the resampling. This will assign the output to be the same
// as the input.
//
// Programmer: Hank Childs
// Creation: April 6, 2001
//
// Modifications:
//
// Kathleen Bonnell, Tue Apr 10 10:49:10 PDT 2001
// Reflect that input and output stored as single avtDataTree instead
// of multiple avtDomainTrees.
//
// ****************************************************************************
void
avtResampleFilter::BypassResample(void)
{
SetOutputDataTree(GetInputDataTree());
ResampleInput();
}
// ****************************************************************************
// Method: avtResampleFilter::ResampleInput
//
......@@ -741,7 +647,6 @@ avtResampleFilter::ResampleInput(void)
delete [] vars;
}
// ****************************************************************************
// Method: avtResampleFilter::GetDimensions
//
......@@ -871,10 +776,11 @@ avtResampleFilter::GetDimensions(int &width, int &height, int &depth,
}
else
{
width = atts.GetWidth();
height = atts.GetHeight();
depth = atts.GetDepth();
width = atts.GetWidth();
height = atts.GetHeight();
depth = atts.GetDepth();
}
if (width <= 0 || height <= 0 || depth < 0)
{
EXCEPTION1(VisItException, "The grid to resample on is degenerate."
......
......@@ -101,21 +101,25 @@ class AVTFILTERS_API avtResampleFilter : public avtDatasetToDatasetFilter
void MakeOutputCellCentered(bool doIt)
{ cellCenteredOutput = doIt; };
void SetRayCasting(bool _rayCasting)
{ rayCasting = _rayCasting; }
protected:
InternalResampleAttributes atts;
char *primaryVariable;
int selID;
bool cellCenteredOutput;
bool rayCasting;
virtual void Execute(void);
virtual void UpdateDataObjectInfo(void);
void GetDimensions(int &, int &, int &, const double *,
bool);
bool GetBounds(double[6]);
bool InputNeedsNoResampling(void);
void ResampleInput(void);
void BypassResample(void);
virtual int AdditionalPipelineFilters(void) { return 2; };
......
......@@ -78,6 +78,8 @@
#include <InvalidCellTypeException.h>
#include <TimingsManager.h>
#include <Utility.h>
#include <DebugStream.h>
// ****************************************************************************
// Method: avtSamplePointExtractor constructor
......@@ -160,10 +162,19 @@ avtSamplePointExtractor::avtSamplePointExtractor(int w, int h, int d)
modeIs3D = true;
SetKernelBasedSampling(false);
SetTrilinear(false);
shouldSetUpArbitrator = false;
arbitratorPrefersMinimum = false;
arbitrator = NULL;
patchCount = 0;
totalAssignedPatches = 0;
rayCastingSLIVR = false;
lighting = false;
lightPosition[0] = lightPosition[1] = lightPosition[2] = 0.0; lightPosition[3] = 1.0;
materialProperties[0] = 0.4; materialProperties[1] = 0.75; materialProperties[3] = 0.0; materialProperties[3] = 15.0;
}
......@@ -231,6 +242,8 @@ avtSamplePointExtractor::~avtSamplePointExtractor()
delete arbitrator;
arbitrator = NULL;
}
delImgPatches();
}
......@@ -444,6 +457,9 @@ avtSamplePointExtractor::SetUpExtractors(void)
pointExtractor = new avtPointExtractor(width, height, depth, volume, cl);
pyramidExtractor = new avtPyramidExtractor(width, height, depth,volume,cl);