Commit 8e882e86 authored by hrchilds's avatar hrchilds

Merge 1.12RC into trunk, picking up named selections infrastructure


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@6213 18c085ea-50e0-402c-830e-de6fd14e8384
parent 3ba090b8
......@@ -102,6 +102,9 @@
# Hank Childs, Tue Dec 2 13:41:08 PST 2008
# Add the avtStreamlinePolyDataFilter.
#
# Hank Childs, Mon Feb 2 16:42:03 PST 2009
# Added avtNamedSelectionFilter.
#
# Dave Pugmire, Tue Feb 3 10:56:45 EST 2009
# Add the streamline algorithm code.
#
......@@ -137,6 +140,7 @@ SRC=\
avtLineoutFilter.C \
avtMassVoxelExtractor.C \
avtMeshLogFilter.C \
avtNamedSelectionFilter.C \
avtPointToGlyphFilter.C \
avtRayCompositer.C \
avtRayTracer.C \
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400142
* 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.
*
*****************************************************************************/
// ************************************************************************* //
// File: avtNamedSelectionFilter.C
// ************************************************************************* //
#include <avtNamedSelectionFilter.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkThreshold.h>
#include <vtkUnstructuredGrid.h>
#include <avtNamedSelection.h>
#include <avtNamedSelectionManager.h>
#include <avtSILRestriction.h>
// ****************************************************************************
// Method: avtNamedSelectionFilter constructor
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtNamedSelectionFilter::avtNamedSelectionFilter()
{
}
// ****************************************************************************
// Method: avtNamedSelectionFilter destructor
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtNamedSelectionFilter::~avtNamedSelectionFilter()
{
}
// ****************************************************************************
// Method: avtNamedSelectionFilter::ExecuteData
//
// Purpose:
// Sends the specified input and output through the NamedSelection filter.
//
// Arguments:
// in_ds The input dataset.
// <unused> The domain number.
// <unused> The label.
//
// Returns: The output dataset.
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
vtkDataSet *
avtNamedSelectionFilter::ExecuteData(vtkDataSet *in_ds, int dom, std::string)
{
int i;
vtkDataArray *ocn=in_ds->GetCellData()->GetArray("avtOriginalCellNumbers");
if (ocn == NULL)
{
EXCEPTION0(ImproperUseException);
}
unsigned int *ptr = (unsigned int *) ocn->GetVoidPointer(0);
if (ptr == NULL)
{
EXCEPTION0(ImproperUseException);
}
avtNamedSelectionManager *nsm = avtNamedSelectionManager::GetInstance();
avtNamedSelection *ns = nsm->GetNamedSelection(selName);
if (ns == NULL || ns->GetType() != avtNamedSelection::ZONE_ID)
{
EXCEPTION0(ImproperUseException);
}
avtZoneIdNamedSelection *zins = (avtZoneIdNamedSelection *) ns;
vector<int> ids;
int ncells = in_ds->GetNumberOfCells();
zins->GetMatchingIds(ptr, ncells, ids);
if (ids.size() == 0)
return NULL;
vtkDataSet *ds = in_ds->NewInstance();
ds->ShallowCopy(in_ds);
vtkFloatArray *arr = vtkFloatArray::New();
arr->SetNumberOfTuples(ncells);
arr->SetName("_avt_thresh_var");
for (i = 0 ; i < ncells ; i++)
arr->SetValue(i, 0.);
for (i = 0 ; i < ids.size() ; i++)
arr->SetValue(ids[i], 1.);
ds->GetCellData()->AddArray(arr);
arr->Delete();
vtkThreshold *thres = vtkThreshold::New();
thres->SetInput(ds);
thres->ThresholdBetween(0.5, 1.5);
thres->SetInputArrayToProcess(0, 0, 0,
vtkDataObject::FIELD_ASSOCIATION_CELLS, "_avt_thresh_var");
vtkUnstructuredGrid *rv = thres->GetOutput();
rv->Update();
ManageMemory(rv);
thres->Delete();
return rv;
}
// ****************************************************************************
// Method: avtNamedSelectionFilter::ModifyContract
//
// Purpose:
// Turn on Zone numbers flag if needed, so that original cell array
// will be propagated throught the pipeline.
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtContract_p
avtNamedSelectionFilter::ModifyContract(avtContract_p contract)
{
avtContract_p rv = new avtContract(contract);
rv->GetDataRequest()->TurnZoneNumbersOn();
avtNamedSelectionManager *nsm = avtNamedSelectionManager::GetInstance();
avtNamedSelection *ns = nsm->GetNamedSelection(selName);
if (ns == NULL)
{
EXCEPTION1(VisItException, "The named selection was not valid");
}
vector<int> domains;
bool useList = ns->GetDomainList(domains);
if (useList)
{
rv->GetDataRequest()->GetRestriction()->RestrictDomains(domains);
}
return rv;
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400142
* 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.
*
*****************************************************************************/
// ************************************************************************* //
// File: avtNamedSelectionFilter.h
// ************************************************************************* //
#ifndef AVT_NamedSelection_FILTER_H
#define AVT_NamedSelection_FILTER_H
#include <filters_exports.h>
#include <avtDataTreeIterator.h>
class vtkDataSet;
// ****************************************************************************
// Class: avtNamedSelectionFilter
//
// Purpose:
// A filter that removes all identifiers that aren't part of the named
// selection.
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
class AVTFILTERS_API avtNamedSelectionFilter : public avtDataTreeIterator
{
public:
avtNamedSelectionFilter();
virtual ~avtNamedSelectionFilter();
virtual const char *GetType(void) { return "avtNamedSelectionFilter"; };
virtual const char *GetDescription(void)
{ return "Applying named selection"; };
void SetSelectionName(const std::string &s)
{ selName = s; };
protected:
std::string selName;
virtual vtkDataSet *ExecuteData(vtkDataSet *, int, std::string);
virtual avtContract_p ModifyContract(avtContract_p);
};
#endif
......@@ -101,15 +101,22 @@ avtDataObject::~avtDataObject()
// Propagates an Update up the pipeline.
//
// Arguments:
// spec The specification of what data the pipeline should execute.
// contract The contract of what data the pipeline should execute.
//
// Programmer: Hank Childs
// Creation: May 23, 2001
//
// Modifications:
//
// Hank Childs, Mon Feb 2 09:26:36 PST 2009
// Store off the contract if this is not a transient data object.
// (Chose to do this only for non-transients, because those are probably
// the only ones we'd want it for ... simply trying to save on space.)
//
// ****************************************************************************
bool
avtDataObject::Update(avtContract_p spec)
avtDataObject::Update(avtContract_p contract)
{
bool rv = false;
if (source == NULL)
......@@ -121,9 +128,11 @@ avtDataObject::Update(avtContract_p spec)
}
else
{
rv = source->Update(spec);
rv = source->Update(contract);
}
contractFromPrevExecution = contract;
return rv;
}
......
......@@ -87,6 +87,9 @@ class avtWebpage;
// Define private copy constructor and assignment operator to prevent
// accidental use of default, bitwise copy implementations.
//
// Hank Childs, Mon Feb 2 09:26:16 PST 2009
// Added data member for the contract from a previous execution.
//
// ****************************************************************************
class PIPELINE_API avtDataObject
......@@ -120,6 +123,8 @@ class PIPELINE_API avtDataObject
void SetTransientStatus(bool b)
{ transient = b; };
bool IsTransient(void) { return transient; };
avtContract_p GetContractFromPreviousExecution(void)
{ return contractFromPrevExecution; };
virtual void DebugDump(avtWebpage *, const char *);
......@@ -134,6 +139,8 @@ class PIPELINE_API avtDataObject
// because we need it for queries.
bool transient;
avtContract_p contractFromPrevExecution;
virtual void DerivedCopy(avtDataObject *);
virtual void DerivedMerge(avtDataObject *);
void CompatibleTypes(avtDataObject *);
......
......@@ -123,6 +123,9 @@ class avtWebpage;
// Hank Childs, Mon Jun 16 12:25:31 PDT 2008
// Add method CalculateSpatialIntervalTree.
//
// Hank Childs, Tue Feb 3 11:26:05 PST 2009
// Add friend status for avtNamedSelectionManager.
//
// ****************************************************************************
class PIPELINE_API avtDataset : public avtDataObject
......@@ -137,6 +140,7 @@ class PIPELINE_API avtDataset : public avtDataObject
friend class avtLineScanQuery;
friend class avtLineSurfaceFilter;
friend class avtExecuteThenTimeLoopFilter;
friend class avtNamedSelectionManager;
public:
avtDataset(avtDataObjectSource *);
......
......@@ -255,6 +255,9 @@
# Hank Childs and Jeremy Meredith, Tue Jan 27 11:00:31 PST 2009
# Added avtHistogramSpecification and avtIdentifierSelection.
#
# Hank Childs, Mon Feb 2 08:24:47 PST 2009
# Added named selections.
#
##############################################################################
@SET_MAKE@
......@@ -340,6 +343,8 @@ Pipeline_src= \
Pipeline/avtImageReader.C \
Pipeline/avtImageTiler.C \
Pipeline/avtImageWriter.C \
Pipeline/avtNamedSelection.C \
Pipeline/avtNamedSelectionManager.C \
Pipeline/avtNullDataReader.C \
Pipeline/avtNullDataWriter.C \
Pipeline/avtParallel.C \
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400142
* 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.
*
*****************************************************************************/
// ************************************************************************* //
// avtNamedSelection.C //
// ************************************************************************* //
#include <avtNamedSelection.h>
#include <visitstream.h>
#include <VisItException.h>
// ****************************************************************************
// Method: avtNamedSelection constructor
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtNamedSelection::avtNamedSelection(const std::string &n)
{
name = n;
}
// ****************************************************************************
// Method: avtNamedSelection destructor
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtNamedSelection::~avtNamedSelection()
{
}
// ****************************************************************************
// Method: avtZoneIdNamedSelection constructor
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtZoneIdNamedSelection::avtZoneIdNamedSelection(const std::string &n)
: avtNamedSelection(n)
{
}
// ****************************************************************************
// Method: avtZoneIdNamedSelection constructor
//
// Programmer: Hank Childs
// Creation: February 3, 2009
//
// ****************************************************************************
avtZoneIdNamedSelection::avtZoneIdNamedSelection(const std::string &n, int num,
const int *dom, const int *zon)
: avtNamedSelection(n)
{
domId.resize(num);
zoneId.resize(num);
for (int i = 0 ; i < num ; i++)
{
domId[i] = dom[i];
zoneId[i] = zon[i];
}
}
// ****************************************************************************
// Method: avtZoneIdNamedSelection destructor
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
avtZoneIdNamedSelection::~avtZoneIdNamedSelection()
{
}
// ****************************************************************************
// Method: avtZoneIdNamedSelection::Write
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
void
avtZoneIdNamedSelection::Write(const std::string &fname)
{
ofstream ofile(fname.c_str());
ofile << ZONE_ID << endl;
ofile << domId.size() << endl;
for (int i = 0 ; i < domId.size() ; i++)
{
ofile << domId[i] << " " << zoneId[i] << endl;
}
}
// ****************************************************************************
// Method: avtZoneIdNamedSelection::Read
//
// Programmer: Hank Childs
// Creation: February 2, 2009
//
// ****************************************************************************
void
avtZoneIdNamedSelection::Read(const std::string &fname)
{
ifstream ifile(fname.c_str());
if (ifile.fail())
{
EXCEPTION1(VisItException, "Cannot read named selection");
}
int nsType;
ifile >> nsType;
if (nsType != ZONE_ID)
{
EXCEPTION1(VisItException, "Internal error reading named selection");
}
int nvals;
ifile >> nvals;
if (nvals < 0)
{
EXCEPTION1(VisItException, "Invalid named selection");
}
domId.resize(nvals);
zoneId.resize(nvals);
for (int i = 0 ; i < nvals ; i++)
{
ifile >> domId[i];
ifile >> zoneId[i];
}
}
// ****************************************************************************
// Method: avtZoneIdNamedSelection::GetDomainList
//
// Purpose:
// Gets the list of domains from the identifiers in this selection.
//
// Programmer: Hank Childs
// Creation: February 3, 2009
//
// ****************************************************************************
bool
avtZoneIdNamedSelection::GetDomainList(std::vector<int> &domains)
{
int i;
int maxDomain = 0;
for (i = 0 ; i < domId.size() ; i++)
{
if (domId[i] > maxDomain)
maxDomain = domId[i];
}
std::vector<bool> useDomain(maxDomain+1, false);
int numDoms = 0;