Commit 3920bc25 authored by brugger's avatar brugger

I extended the multi resolution data selection support to work in 3d.

This is still a work in progress but it is in a useable state. The
way things are currently working is that the reader gets an axis aligned
bounding box for the view frustum. I will see how this works and if it
isn't good enough I may change it to pass the view frustum volume and
the equations of the 6 planes that define the view frustum. I will also
soon check in an enhanced MRTest database reader that also provides 3d
data.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@22559 18c085ea-50e0-402c-830e-de6fd14e8384
parent 27eacfcf
......@@ -75,13 +75,19 @@
// Eric Brugger, Fri Dec 20 11:52:45 PST 2013
// Add support for doing multi resolution data selections.
//
// Eric Brugger, Thu Jan 2 15:16:28 PST 2014
// Add support for 3d multi resolution data selections.
//
// ****************************************************************************
avtMultiresFilter::avtMultiresFilter(double *frust, double size)
avtMultiresFilter::avtMultiresFilter(double *frust2D, double *frust3D,
double size)
{
nDims = 3;
for (int i = 0; i < 6; i++)
desiredFrustum[i] = frust[i];
desiredFrustum2D[i] = frust2D[i];
for (int i = 0; i < 6; i++)
desiredFrustum3D[i] = frust3D[i];
desiredCellSize = size;
selID = -1;
......@@ -176,16 +182,29 @@ avtMultiresFilter::Execute(void)
// Eric Brugger, Fri Dec 20 11:52:45 PST 2013
// Add support for doing multi resolution data selections.
//
// Eric Brugger, Thu Jan 2 15:16:28 PST 2014
// Add support for 3d multi resolution data selections.
//
// ****************************************************************************
avtContract_p avtMultiresFilter::ModifyContract(avtContract_p contract)
{
//
// Get the spatial extents for the mesh.
// Get the desired frustum and the spatial extents for the mesh.
//
avtMetaData *md = GetMetaData();
avtDataAttributes &dataAtts = GetInput()->GetInfo().GetAttributes();
nDims = dataAtts.GetSpatialDimension();
if (nDims == 2)
{
for (int i = 0; i < 6; i++)
desiredFrustum[i] = desiredFrustum2D[i];
}
else
{
for (int i = 0; i < 6; i++)
desiredFrustum[i] = desiredFrustum3D[i];
}
double extents[6];
dataAtts.GetOriginalSpatialExtents()->CopyTo(extents);
......@@ -198,12 +217,6 @@ avtContract_p avtMultiresFilter::ModifyContract(avtContract_p contract)
desiredFrustum[i] = extents[i];
}
//
// Currently we are only implemented for 2d, so return if not 2d.
//
if (nDims != 2)
return contract;
//
// If the format can do multires then add a multi resolution data
// selection to the contract and return.
......
......@@ -65,12 +65,15 @@ class avtMultiresSelection;
// Eric Brugger, Fri Dec 20 11:50:18 PST 2013
// Add support for doing multi resolution data selections.
//
// Eric Brugger, Thu Jan 2 15:15:54 PST 2014
// Add support for 3d multi resolution data selections.
//
// ****************************************************************************
class AVTFILTERS_API avtMultiresFilter : public avtDatasetToDatasetFilter
{
public:
avtMultiresFilter(double *, double);
avtMultiresFilter(double *, double *, double);
virtual ~avtMultiresFilter();
virtual const char *GetType(void) {return "avtMultiresFilter";};
......@@ -78,6 +81,8 @@ class AVTFILTERS_API avtMultiresFilter : public avtDatasetToDatasetFilter
protected:
int nDims;
double desiredFrustum2D[6];
double desiredFrustum3D[6];
double desiredFrustum[6];
double desiredCellSize;
double actualCellSize;
......
......@@ -47,10 +47,8 @@
#include <avtViewInfo.h>
#include <View3DAttributes.h>
//
// Local macros.
//
#define max(x,y) ((x) > (y) ? (x) : (y))
#include <vtkCamera.h>
#include <vtkMatrix4x4.h>
// ****************************************************************************
......@@ -380,7 +378,7 @@ avtView3D::SetViewInfoFromView(avtViewInfo &viewInfo) const
// number should be as large as possible. 10000 would probably also
// work, but 100000 would start showing z buffering artifacts.
//
viewInfo.nearPlane = max (nearPlane + distance, (farPlane - nearPlane) / 5000.);
viewInfo.nearPlane = std::max(nearPlane + distance, (farPlane - nearPlane) / 5000.);
viewInfo.farPlane = farPlane + distance;
//
......@@ -504,3 +502,98 @@ avtView3D::SetToView3DAttributes(View3DAttributes *view3DAtts) const
view3DAtts->SetAxis3DScales(axis3DScales);
view3DAtts->SetShear(shear);
}
// ****************************************************************************
// Method: avtView3D::GetFrustum
//
// Purpose:
// Returns the view frustum given the aspect ratio of the window width
// to height.
//
// Arguments:
// frustum : The returned frustum.
// aspect : The aspect ratio of the window width to height.
//
// Programmer: Eric Brugger
// Creation: Thu Jan 2 15:05:55 PST 2014
//
// ****************************************************************************
void
avtView3D::GetFrustum(double *frustum, double aspect) const
{
//
// Get the inverse of the composite projection transform matrix.
//
avtViewInfo viewInfo;
SetViewInfoFromView(viewInfo);
vtkCamera *vtkcam = vtkCamera::New();
viewInfo.SetCameraFromView(vtkcam);
double matrix[4][4];
vtkMatrix4x4::DeepCopy(
*matrix,
vtkcam->GetCompositeProjectionTransformMatrix(aspect, -1, +1));
vtkMatrix4x4::Invert(*matrix,*matrix);
//
// Transform the corners in normalized device coordinates to
// world coordinates.
//
double c[8][4];
c[0][0] = -1.; c[0][1] = -1.; c[0][2] = -1.; c[0][3] = 1.;
c[1][0] = +1.; c[1][1] = -1.; c[1][2] = -1.; c[1][3] = 1.;
c[2][0] = +1.; c[2][1] = +1.; c[2][2] = -1.; c[2][3] = 1.;
c[3][0] = -1.; c[3][1] = +1.; c[3][2] = -1.; c[3][3] = 1.;
c[4][0] = -1.; c[4][1] = -1.; c[4][2] = +1.; c[4][3] = 1.;
c[5][0] = +1.; c[5][1] = -1.; c[5][2] = +1.; c[5][3] = 1.;
c[6][0] = +1.; c[6][1] = +1.; c[6][2] = +1.; c[6][3] = 1.;
c[7][0] = -1.; c[7][1] = +1.; c[7][2] = +1.; c[7][3] = 1.;
for (int i = 0; i < 8; i++)
{
vtkMatrix4x4::MultiplyPoint(*matrix, c[i], c[i]);
c[i][0] /= c[i][3]; c[i][1] /= c[i][3]; c[i][2] /= c[i][3];
}
//
// Calculate the frustum (an AABB (axis aligned bounding box)) from
// the corners.
//
double xmin, xmax, ymin, ymax, zmin, zmax;
xmin = c[0][0]; xmax = c[0][0];
ymin = c[0][1]; ymax = c[0][1];
zmin = c[0][2]; zmax = c[0][2];
for (int i = 1; i < 8; i++)
{
xmin = std::min(xmin, c[i][0]);
xmax = std::max(xmax, c[i][0]);
ymin = std::min(ymin, c[i][1]);
ymax = std::max(ymax, c[i][1]);
zmin = std::min(zmin, c[i][2]);
zmax = std::max(zmax, c[i][2]);
}
frustum[0] = xmin;
frustum[1] = xmax;
frustum[2] = ymin;
frustum[3] = ymax;
frustum[4] = zmin;
frustum[5] = zmax;
#if 0
cerr << "frustum=" << frustum[0] << "," << frustum[1] << ","
<< frustum[2] << "," << frustum[3] << ","
<< frustum[4] << "," << frustum[5] << endl;
//
// Code that gets the plane equations of the 6 frustum planes.
// I'm leaving it here in case I decide I later want to use
// that instead of an AABB for the frustum.
avtViewInfo viewInfo;
SetViewInfoFromView(viewInfo);
vtkCamera *vtkcam = vtkCamera::New();
viewInfo.SetCameraFromView(vtkcam);
double planes[24];
vtkcam->GetFrustumPlanes(aspect, planes);
vtkcam->Delete();
#endif
}
......@@ -79,6 +79,10 @@ class View3DAttributes;
// Jeremy Meredith, Mon Aug 2 14:23:08 EDT 2010
// Add shear for oblique projection support.
//
// Eric Brugger, Thu Jan 2 15:04:00 PST 2014
// I added GetFrustum to add support for 3d multi resolution data
// selections.
//
// ****************************************************************************
struct AVTVIEW_API avtView3D
......@@ -109,6 +113,8 @@ struct AVTVIEW_API avtView3D
void SetFromView3DAttributes(const View3DAttributes *);
void SetToView3DAttributes(View3DAttributes *) const;
void GetFrustum(double *, double) const;
};
......
......@@ -114,8 +114,9 @@
#include <avtQueryFactory.h>
#include <avtMultiresFilter.h>
#include <CompactSILRestrictionAttributes.h>
#include <VisWindow.h>
#include <VisWinRendering.h> // for SetStereoEnabled
#include <VisWindow.h>
#include <VisWindowTypes.h>
#include <ParsingExprList.h>
#include <avtExprNode.h>
#include <DatabasePluginManager.h>
......@@ -1033,6 +1034,9 @@ NetworkManager::StartNetwork(const std::string &format,
// Brad Whitlock, Wed Jan 18 11:30:34 PST 2012
// I added missing data support.
//
// Eric Brugger, Thu Jan 2 15:18:21 PST 2014
// I added support for 3d multi resolution data selections.
//
// ****************************************************************************
void
......@@ -1127,25 +1131,38 @@ NetworkManager::StartNetwork(const std::string &format,
VisWindow *visWin = viswinMap[windowID].viswin;
if (visWin->GetMultiresolutionMode())
{
double frustum[6];
// Get the 2D frustum.
double frustum2D[6];
const avtView2D view2D = visWin->GetView2D();
if (!view2D.windowValid)
{
frustum[0] = DBL_MAX;
frustum[1] = -DBL_MAX;
frustum[2] = DBL_MAX;
frustum[3] = -DBL_MAX;
frustum2D[0] = DBL_MAX;
frustum2D[1] = -DBL_MAX;
frustum2D[2] = DBL_MAX;
frustum2D[3] = -DBL_MAX;
}
else
{
frustum[0] = view2D.window[0];
frustum[1] = view2D.window[1];
frustum[2] = view2D.window[2];
frustum[3] = view2D.window[3];
frustum2D[0] = view2D.window[0];
frustum2D[1] = view2D.window[1];
frustum2D[2] = view2D.window[2];
frustum2D[3] = view2D.window[3];
}
// Get the 3D frustum.
double frustum3D[6];
const avtView3D view3D = visWin->GetView3D();
int width, height;
visWin->GetSize(width, height);
double aspect = double(width) / double(height);
view3D.GetFrustum(frustum3D, aspect);
// Get the cell size.
double cellSize = visWin->GetMultiresolutionCellSize();
avtMultiresFilter *f2 = new avtMultiresFilter(frustum, cellSize);
// Add the multires filter.
avtMultiresFilter *f2 = new avtMultiresFilter(frustum2D, frustum3D,
cellSize);
filt = new NetnodeFilter(f2, "MultiresFilter");
filt->GetInputNodes().push_back(input);
workingNet->AddNode(filt);
......
......@@ -10029,6 +10029,8 @@ ViewerPlotList::PermitsLogViewScaling(WINDOW_MODE wm)
// Creation: Fri Oct 28 09:54:23 PDT 2011
//
// Modifications:
// Eric Brugger, Thu Jan 2 15:19:29 PST 2014
// I added support for 3d multi resolution data selections.
//
// ****************************************************************************
......@@ -10069,7 +10071,10 @@ ViewerPlotList::ShouldRefineData(double smallestCellSize) const
else if (window->GetWindowMode() == WINMODE_3D)
{
const avtView3D &view3D = window->GetView3D();
return false;
int width, height;
window->GetSize(width, height);
double aspect = double(width) / double(height);
view3D.GetFrustum(fustrum, aspect);
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment