DataNetwork.C 4.65 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
#include <DataNetwork.h>

hrchilds's avatar
hrchilds committed
3
#include <avtActor.h>
hrchilds's avatar
hrchilds committed
4 5
#include <avtPlot.h>
#include <DebugStream.h>
hrchilds's avatar
hrchilds committed
6
#include <ImproperUseException.h>
hrchilds's avatar
hrchilds committed
7
#include <WindowAttributes.h>
hrchilds's avatar
hrchilds committed
8 9 10 11 12 13 14 15 16 17 18

using std::string;
using std::vector;
using std::deque;

// ****************************************************************************
//  Constructor:  DataNetwork::DataNetwork
//
//  Programmer:  Jeremy Meredith
//  Creation:    November  9, 2001
//
hrchilds's avatar
hrchilds committed
19 20 21 22
//  Modifications:
//
//    Mark C. Miller, Thu May 27 11:05:15 PDT 2004
//    Added missing initialization for plotActor data member
hrchilds's avatar
hrchilds committed
23 24 25
//
//    Mark C. Miller, Tue Jan  4 10:23:19 PST 2005
//    Added window id (wid)
hrchilds's avatar
hrchilds committed
26 27 28
// ****************************************************************************
DataNetwork::DataNetwork(void)
{
hrchilds's avatar
hrchilds committed
29 30
    nid = -1;
    wid = -1;
hrchilds's avatar
hrchilds committed
31 32 33
    pspec = NULL;
    dspec = NULL;
    writer = NULL;
hrchilds's avatar
hrchilds committed
34
    plotActor = NULL;
hrchilds's avatar
hrchilds committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48
}

// ****************************************************************************
//  Constructor:  DataNetwork::DataNetwork
//
//  Programmer:  Jeremy Meredith
//  Creation:    November  9, 2001
//
//  Modifications:
//
//    Hank Childs, Tue Jul 23 11:04:30 PDT 2002
//    Reflect that the terminal node has already been deleted by the time we
//    get here.
//
hrchilds's avatar
hrchilds committed
49 50 51 52
//    Hank Childs, Sun Mar  7 16:03:33 PST 2004
//    Do not clear the nodes before releasing the data -- we would then not
//    release the data in those nodes.
//
hrchilds's avatar
hrchilds committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
// ****************************************************************************
DataNetwork::~DataNetwork(void)
{
    // The terminal node has already been freed by this point.
    terminalNode = NULL;

    ReleaseData();
}

// ****************************************************************************
//  Method:  DataNetwork::GetWriter
//
//  Purpose: Cache data object writer for network output
//
//  Programmer:  Mark C. Miller
//  Creation:    May 5, 2003 
//
// ****************************************************************************
avtDataObjectWriter_p
DataNetwork::GetWriter(avtDataObject_p dob, avtPipelineSpecification_p pspec,
                          WindowAttributes *atts)
{

   if (*writer != NULL)
   {
      return writer;
   }
   else
   {
hrchilds's avatar
hrchilds committed
82 83 84 85
      avtDataObjectWriter_p tmpWriter = GetPlot()->Execute(dob, pspec, atts);
      if (GetPlot()->CanCacheWriterExternally())
         writer = tmpWriter;
      return tmpWriter;
hrchilds's avatar
hrchilds committed
86 87 88
   }
}

hrchilds's avatar
hrchilds committed
89 90 91 92 93 94 95 96
// ****************************************************************************
//  Method:  DataNetwork::GetActor
//
//  Purpose: Cache data actor for plot
//
//  Programmer:  Mark C. Miller
//  Creation:    December 5, 2003 
//
hrchilds's avatar
hrchilds committed
97 98 99 100 101
//  Modifications:
//
//     Mark C. Miller, Thu May 27 11:05:15 PDT 2004
//     Removed window attributes argument and dependencies
//
hrchilds's avatar
hrchilds committed
102 103 104 105
//     Kathleen Bonnell,  Thu Oct 21 15:55:46 PDT 2004
//     Allow dob arg to be NULL, but test for it and throw Exception when
//     necessary. 
//
hrchilds's avatar
hrchilds committed
106 107
// ****************************************************************************
avtActor_p
hrchilds's avatar
hrchilds committed
108
DataNetwork::GetActor(avtDataObject_p dob)
hrchilds's avatar
hrchilds committed
109
{
hrchilds's avatar
hrchilds committed
110
    if (*plotActor == NULL) 
hrchilds's avatar
hrchilds committed
111
    {
hrchilds's avatar
hrchilds committed
112 113 114 115 116 117 118 119 120 121 122 123
        if (*dob != NULL)
        {
            // do the part of the execute we'd do in the viewer
            plotActor = GetPlot()->Execute(NULL, dob);
        }
        else 
        {
            debug1 << "Attempting to retrieve a plot's actor with "
                   << "no input." << endl;
            EXCEPTION0(ImproperUseException);
        }
    }
hrchilds's avatar
hrchilds committed
124

hrchilds's avatar
hrchilds committed
125
   return plotActor;
hrchilds's avatar
hrchilds committed
126 127 128
}


hrchilds's avatar
hrchilds committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
// ****************************************************************************
//  Method:  DataNetwork::ReleaseData
//
//  Purpose:
//    Releases unused data.
//
//  Programmer:  Jeremy Meredith
//  Creation:    November 19, 2001
//
//  Modifications:
//      Sean Ahern, Mon May 20 16:28:39 PDT 2002
//      Retrofitted.
//
//      Sean Ahern, Wed May 22 14:51:34 PDT 2002
//      Added a check to see if the database should be cleaned.
//
//      Hank Childs, Tue Jul 23 11:04:30 PDT 2002
//      Make sure terminalNode is not NULL before calling a method on it.
//
//      Mark C. Miller, 30Apr03 
//      Make sure plot is not NULL before calling a method on it.
//
hrchilds's avatar
hrchilds committed
151 152 153
//      Mark C. Miller, Tue Jan  4 10:23:19 PST 2005
//      Changed id to nid 
//
hrchilds's avatar
hrchilds committed
154 155 156 157
// ****************************************************************************
void
DataNetwork::ReleaseData(void)
{
hrchilds's avatar
hrchilds committed
158
    debug1 << "Releasing all data associated with network " << nid << endl;
hrchilds's avatar
hrchilds committed
159 160 161 162 163 164 165 166 167
    int nNodes = nodeList.size();
    for (int i = 0 ; i < nNodes ; i++)
    {
        nodeList[i]->ReleaseData();
    }
    if (terminalNode != NULL)
    {
        terminalNode->ReleaseData();
    }
hrchilds's avatar
hrchilds committed
168 169
    if (*plotActor != NULL)
       plotActor = (avtActor *) 0;
hrchilds's avatar
hrchilds committed
170 171 172 173
    if (*plot != NULL)
    {
        plot->ReleaseData();
    }
hrchilds's avatar
hrchilds committed
174 175 176 177
    if (*writer)
    {
       writer->GetInput()->ReleaseData();
    }
hrchilds's avatar
hrchilds committed
178
}