Exemplo n.º 1
0
void
avtLineScanQuery::WalkChain1(vtkPolyData *pd, int ptId, int cellId,
                             vtkIntArray *lineids, int lineid, 
                             int &newPtId, int &newCellId)
{
    static vtkIdList *list = vtkIdList::New();
    list->Reset();
    pd->GetCellPoints(cellId, list);
    if (list->GetNumberOfIds() != 2)
    {
        EXCEPTION0(ImproperUseException);
    }

    int id1 = list->GetId(0);
    int id2 = list->GetId(1);
    newPtId = (id1 == ptId ? id2 : id1);
    int seg1, seg2;
    int numMatches = GetCellsForPoint(newPtId, pd, lineids, lineid, seg1, seg2);
    if (numMatches <= 1)
        newCellId = -1;
    else if (numMatches > 2)
    {
        EXCEPTION0(ImproperUseException);
    }
    else
    {
        newCellId = (seg1 == cellId ? seg2 : seg1);
    }
}
void
avtOpacityMap::SetTable(RGBA *arr, int te, double attenuation)
{
    if (attenuation < 0. || attenuation > 1.)
    {
        debug1 << "Bad attenuation value " << attenuation << std::endl;
        EXCEPTION0(ImproperUseException);
    }

    if (table != NULL)
    {
        delete [] table;
    }

    tableEntries = te;
    table = new RGBA[tableEntries];
    for (int i = 0 ; i < tableEntries ; i++)
    {
        table[i].R = arr[i].R;
        table[i].G = arr[i].G;
        table[i].B = arr[i].B;
        table[i].A = arr[i].A * attenuation;
        if (table[i].A < 0. || table[i].A > 1.)
        {
            debug1 << "Bad value " << table[i].A << std::endl;
            EXCEPTION0(ImproperUseException);
        }
    }

    //
    // We need to set the intermediate vars again since the table size has
    // potentially changed.
    //
    SetIntermediateVars();
}
avtDataTree_p
avtCurveCMFEExpression::ExecuteTree(avtDataTree_p tree1, avtDataTree_p tree2,
                                   const std::string &invar,
                                   const std::string &outvar)
{
   if (tree1->GetNumberOfLeaves() == 0)
        return tree1;
    else if (tree1->GetNumberOfLeaves() != 1)
        EXCEPTION0(ImproperUseException);

    if (tree2->GetNumberOfLeaves() == 0)
        return tree1;
    else if (tree2->GetNumberOfLeaves() != 1)
        EXCEPTION0(ImproperUseException);

    //
    // We know that there is only one leaf node.  It is the curve.
    //
    vtkRectilinearGrid *curve1 = 
        vtkRectilinearGrid::SafeDownCast(tree1->GetSingleLeaf());
    if (curve1 == NULL)
        EXCEPTION0(ImproperUseException);

    vtkRectilinearGrid *curve2 = 
        vtkRectilinearGrid::SafeDownCast(tree2->GetSingleLeaf());
    if (curve2 == NULL)
        EXCEPTION0(ImproperUseException);

    vtkRectilinearGrid *rg = 
        MergeCurvesToSameXIntervals(curve1, curve2, outvar);
    avtDataTree_p output = new avtDataTree(rg, 1);
    rg->Delete();
    return output;
}
Exemplo n.º 4
0
avtDataObject_p
avtDataObjectReader::GetOutput(void)
{
    if (!haveInput)
    {
        EXCEPTION0(NoInputException);
    }

    if      (InputIsDataset())  return datasetReader->GetOutput();
    else if (InputIsImage())    return imageReader->GetOutput();
    else if (InputIsNullData()) return nullDataReader->GetOutput();
    else                       EXCEPTION0(NoInputException);
}
// ****************************************************************************
//  Method:  SocketBridge::StartNewBridge
//
//  Purpose:
//    Start a new bridge by accepting a new incoming connection and making
//    a new outbound connection.  This assumes there is already an incoming
//    connection attempt pending.
//
//  Programmer:  Jeremy Meredith
//  Creation:    May 24, 2007
//
//  Modifications:
//    Gunther H. Weber, Thu Jan 14 11:38:27 PST 2010
//    Added ability to connect bridge to other host than localhost.
//
// ****************************************************************************
void
SocketBridge::StartNewBridge()
{
    int ofd = Accept(listen_fd, listen_sock);
    if (ofd == -1)
        EXCEPTION0(CouldNotConnectException);
    originating_fd[num_bridges] = ofd;

    int tfd = Connect(to_host, to_port);
    if (tfd == -1)
        EXCEPTION0(CouldNotConnectException);
    terminating_fd[num_bridges] = tfd;

    num_bridges++;
}
Exemplo n.º 6
0
void
avtExtents::CopyTo(double *exts)
{
    if (exts == NULL)
    {
        //
        // How can we copy into a NULL array?
        //
        EXCEPTION0(ImproperUseException);
    }

    if (extents == NULL)
    {
        //
        // We don't have extents, so copy in the biggest bounds possible.
        //
        for (int i = 0 ; i < dimension ; i++)
        {
            exts[2*i]   = +DBL_MAX;
            exts[2*i+1] = -DBL_MAX;
        }
    }
    else
    {
        //
        // The most common case -- copy our extents over.
        //
        for (int i = 0 ; i < 2*dimension ; i++)
        {
            exts[i] = extents[i];
        }
    }
}
Exemplo n.º 7
0
const GetFileListRPC::FileList *
GetFileListRPC::operator()(const std::string &f, bool grouping,
    bool smartGrouping)
{
    debug3 << "Executing GetFileList(" << f.c_str()
           << (grouping?"true":"false") << ", "
           << (smartGrouping?"true":"false") << ", "
           << ") RPC\n";

    // Store the arguments.
    filter = f;
    automaticFileGrouping = grouping;
    smartFileGrouping = smartGrouping;

    // Try to execute the RPC.
    Execute();

    // If the RPC returned an error, throw an exception.
    if(GetReply()->GetStatus() == error)
    {
        EXCEPTION0(GetFileListException);
    }

    return &fileList;
}
void
avtOpacityMap::SetTable(unsigned char *arr, int te, double attenuation)
{
    if (attenuation < 0. || attenuation > 1.)
    {
        debug1 << "Bad attenuation value " << attenuation << endl;
        EXCEPTION0(ImproperUseException);
    }

    if (table != NULL)
    {
        delete [] table;
    }

    tableEntries = te;
    table = new RGBA[tableEntries];
    for (int i = 0 ; i < tableEntries ; i++)
    {
        table[i].R = arr[i*4];
        table[i].G = arr[i*4+1];
        table[i].B = arr[i*4+2];
        table[i].A = ((float) arr[i*4+3] / 255.) * attenuation;
    }

    //
    // We need to set the intermediate vars again since the table size has
    // potentially changed.
    //
    SetIntermediateVars();
}
Exemplo n.º 9
0
void
avtVMetricVolume::MetricForWholeMesh(vtkDataSet *ds, vtkDataArray *rv)
{
    if (ds->GetDataObjectType() != VTK_RECTILINEAR_GRID)
        EXCEPTION0(ImproperUseException);

    vtkRectilinearGrid *rg = (vtkRectilinearGrid *) ds;
    vtkDataArray *X = rg->GetXCoordinates();
    vtkDataArray *Y = rg->GetYCoordinates();
    vtkDataArray *Z = rg->GetZCoordinates();
    int dims[3];
    rg->GetDimensions(dims);
    double *Xdist = new double[dims[0]-1];
    for (int i = 0 ; i < dims[0]-1 ; i++)
        Xdist[i] = X->GetTuple1(i+1) - X->GetTuple1(i);
    double *Ydist = new double[dims[1]-1];
    for (int i = 0 ; i < dims[1]-1 ; i++)
        Ydist[i] = Y->GetTuple1(i+1) - Y->GetTuple1(i);
    double *Zdist = new double[dims[2]-1];
    for (int i = 0 ; i < dims[2]-1 ; i++)
        Zdist[i] = Z->GetTuple1(i+1) - Z->GetTuple1(i);

    for (int k = 0 ; k < dims[2]-1 ; k++)
        for (int j = 0 ; j < dims[1]-1 ; j++)
            for (int i = 0 ; i < dims[0]-1 ; i++)
            {
                int idx = k*(dims[1]-1)*(dims[0]-1) + j*(dims[0]-1) + i;
                double vol = Xdist[i]*Ydist[j]*Zdist[k];
                rv->SetTuple1(idx, vol);
            }

    delete [] Xdist;
    delete [] Ydist;
    delete [] Zdist;
}
// ****************************************************************************
//  Method: avtOpacityMap::SetTableFloat
//
//  Purpose:
//      Allows the table to be set from some outside array in the predefined
//      RGBA format. Matches the SLIVR renderer.
//
//  Arguments:
//      arr             The new table in RGBA format.
//      te              The number of entries in arr.
//      attenuation     The attenuation parameter specified
//      over            Reducing based on the number of slices
//
//  Programmer: Pascal Grosset
//  Creation:   June 6, 2013
//
// ****************************************************************************
void
avtOpacityMap::SetTableFloat(unsigned char *arr, int te, double attenuation, float over)
{
    if (attenuation < -1. || attenuation > 1.)
    {
        debug1 << "Bad attenuation value " << attenuation << std::endl;
        EXCEPTION0(ImproperUseException);
    }

    if (transferFn1D != NULL)
    {
        delete [] transferFn1D;
    }

    tableEntries = te;
    transferFn1D = new _RGBA[tableEntries]();
    for (int i = 0 ; i < tableEntries ; i++)
    {
        double bp = tan(1.570796327 * (0.5 - attenuation*0.49999));
        double alpha = pow((float) arr[i*4+3] / 255.f, (float)bp);
        alpha = 1.0 - pow((1.0 - alpha), 1.0/over);

        transferFn1D[i].R = (float)arr[i*4]/255.  *alpha;
        transferFn1D[i].G = (float)arr[i*4+1]/255.*alpha;
        transferFn1D[i].B = (float)arr[i*4+2]/255.*alpha;
        transferFn1D[i].A = alpha;
    }

    //
    // We need to set the intermediate vars again since the table size has
    // potentially changed.
    //
    SetIntermediateVars();
}
Exemplo n.º 11
0
void
avtGeometryDrawable::Remove(vtkRenderer *ren)
{
    if (ren != renderer)
    {
        EXCEPTION0(ImproperUseException);
    }

    for (int i = 0 ; i < nActors ; i++)
    {
        if (actors[i] != NULL)
        {
            //
            // This is supposed to approximate the RemoveActor call of
            // vtkRenderer.  That call also tells the actor to release its
            // graphics resources, which does not work well for us, since
            // we remove the actors every time we add new plots (the viewer
            // does a ClearPlots) and also when the vis window re-orders the
            // actors.
            //
            // THIS IS A MAINTENANCE ISSUE.  This routine should be the same
            // as vtkRenderer::RemoveActor, but does not call
            // ReleaseGraphicsResources (which is actually called indirectly
            // through vtkViewport::RemoveProp).
            //
            //ren->RemoveActor(actors[i]);
            //
            ren->GetActors()->RemoveItem(actors[i]);
            actors[i]->RemoveConsumer(ren);
            ren->GetViewProps()->RemoveItem(actors[i]);
        }
    }
    renderer = NULL;
}
unsigned char *
avtImageRepresentation::GetImageString(int &length, bool compress)
{
    if (asChar == NULL)
    {
        if (asVTK == NULL)
        {
            EXCEPTION0(NoInputException);
        }

        CreateStringFromInput(asVTK, zbuffer, asChar, asCharLength);
        asCharRef = new int(1);
    }

    if (compress)
    {
        int asCharLengthNew = 0;
        unsigned char *asCharNew = 0;

        if (CCompressDataString(asChar, asCharLength,
                                &asCharNew, &asCharLengthNew,
                                &timeToCompress, &compressionRatio))
        {
            delete [] asChar;
            asChar = asCharNew;
            asCharLength = asCharLengthNew;
        }
    }

    length = asCharLength;
    return asChar;
}
void
EngineMethods::GetProcInfo(ProcessAttributes &retAtts)
{
    state->procInfoRPC();

    // Get the reply and update the progress bar
    while (state->procInfoRPC.GetStatus() == VisItRPC::incomplete ||
           state->procInfoRPC.GetStatus() == VisItRPC::warning)
    {
        state->procInfoRPC.RecvReply();
    }

    // Check for abort
    if (state->procInfoRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }

    // Check for an error
    if (state->procInfoRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->procInfoRPC.GetExceptionType(),
                               state->procInfoRPC.Message());
    }

    retAtts = state->procInfoRPC.GetReturnAtts();

}
EngineProperties
EngineMethods::GetEngineProperties()
{
    state->enginePropertiesRPC();

    // Get the reply and update the progress bar
    while (state->enginePropertiesRPC.GetStatus() == VisItRPC::incomplete ||
           state->enginePropertiesRPC.GetStatus() == VisItRPC::warning)
    {
        state->enginePropertiesRPC.RecvReply();
    }

    // Check for abort
    if (state->enginePropertiesRPC.GetStatus() == VisItRPC::abort)
    {
        ClearStatus();
        EXCEPTION0(AbortException);
    }

    // Check for an error
    if (state->enginePropertiesRPC.GetStatus() == VisItRPC::error)
    {
        RECONSTITUTE_EXCEPTION(state->enginePropertiesRPC.GetExceptionType(),
                               state->enginePropertiesRPC.Message());
    }

    EngineProperties props(state->enginePropertiesRPC.GetReturnAtts());
    if(numNodes > props.GetNumNodes())
        props.SetNumNodes(numNodes);

    return props;
}
void 
avtHexahedron20Extractor::QuadraticHexExtract(const avtHexahedron20 &hex)
{
    cerr << "avtHexahedron20Extractor::QuadraticHexExtract not implemented yet"
         << endl;
    EXCEPTION0(ImproperUseException);
}
void
DBOptionsAttributes::SetEnumStrings(const std::string &name,
                                    const std::vector<std::string> &values)
{
    int eIndex = FindIndex(name);
    if (eIndex < 0)
        EXCEPTION0(BadDeclareFormatString);

    int numEnums = (int)optEnums.size();
    std::vector<std::string> newList;
    int idx = 0;
    for (int i = 0 ; i < numEnums ; i++)
    {
        if (i == eIndex)
        {
            for (size_t j = 0 ; j < values.size() ; j++)
                newList.push_back(values[j]);
        }
        else
        {
            for (int j = 0 ; j < enumStringsSizes[i] ; j++)
                newList.push_back(enumStrings[idx+j]);
        }
        idx += enumStringsSizes[i];
    }
    enumStrings = newList;
    enumStringsSizes[eIndex] = values.size();
}
Exemplo n.º 17
0
void
avtZoneDumpFilter::SaveOutput(const std::string &fname, std::vector<ZoneInfo> &zones)
{
    // loop index
    int i;

    // get # of found zones
    int nzones = zones.size();

    // open output file
    ofstream outs(fname.c_str());
    if(outs.fail())
        EXCEPTION0(ImproperUseException);

    // write general header info
    outs << "# VisIt Zone Dump  " << endl;
    outs << "# Number of Zones: " << nzones << endl;
    outs << "# Fields:" <<endl;
    outs << "block\tdomain\tzone\ti\tj\tk\t"
         << atts.GetVariable() << endl;

    // dump each found zone
    for(i = 0; i < nzones; i++)
        zones[i].Print(outs,"\t");

    // close the output file
    outs.close();
}
float *
avtImageRepresentation::GetZBuffer(void)
{
    //
    // Not all images have z-buffers.  If we have a VTK image and no z-buffer
    // then there is no z-buffer.  If we don't have the VTK image, we should
    // parse out the image and potentially the z-buffer from the marshall
    // string.
    //
    if (asVTK == NULL)
    {
        if (asChar == NULL)
        {
            EXCEPTION0(NoInputException);
        }

        GetImageFromString(asChar, asCharLength, asVTK, zbuffer);
        if (zbuffer != NULL)
        {
            zbufferRef = new int(1);
        }
    }

    return zbuffer;
}
void
avtImageRepresentation::GetSize(int *_rowSize, int *_colSize)
{
   // What do we do if the image hasn't been parsed out of the string
   // when this function is called? In the other query functions of this
   // class, we automatically call GetImageFromString on the caller's
   // behalf. However, all those calls ultimately need that to occur
   // to return the object a caller is looking for; a vtkImageData object
   // or a z-buffer. Here, we only want to return two ints representing
   // the size. So, we wind up doing problem sized work to satisfy
   // the query. Nonetheless, its a good assumption the client actually
   // wants some that data sometime in the future anyway.

    if (asVTK == NULL)
    {
        if (asChar == NULL)
        {
            EXCEPTION0(NoInputException);
        }

        GetImageFromString(asChar, asCharLength, asVTK, zbuffer);
    }

    int *imageDims = asVTK->GetDimensions();
    *_rowSize = imageDims[1]; // #rows is y-size
    *_colSize = imageDims[0]; // #cols is x-size
}
Exemplo n.º 20
0
int 
avtLineScanQuery::WalkChain(vtkPolyData *pd, int ptId, int cellId, 
                            std::vector<bool> &usedPoint,
                            vtkIntArray *lineids, int lineid)
{
    static vtkIdList *list = vtkIdList::New();

    bool haventFoundEnd = true;
    int  curCell = cellId;
    int  curPt   = ptId;

    int  endOfChain = -1;
    int  counter = 0;
    while (haventFoundEnd)
    {
        list->Reset();
        pd->GetCellPoints(curCell, list);
        if (list->GetNumberOfIds() != 2)
        {
            EXCEPTION0(ImproperUseException);
        }

        int id1 = list->GetId(0);
        int id2 = list->GetId(1);
        int newId = (id1 == curPt ? id2 : id1);
        usedPoint[newId] = true;

        int seg1, seg2;
        int numMatches = 
                      GetCellsForPoint(newId, pd, lineids, lineid, seg1, seg2);
        if (numMatches <= 1)
        {
            haventFoundEnd = false;
            endOfChain = newId;
        }
        else if (numMatches > 2)
        {
            // This is an error condition.  It is believed to occur when
            // a line coincides with an edge.  Empirically, it is believed
            // to happen about one time when you cast 100K lines over 90M
            // zones.  So: it doesn't happen often, but it happens enough.
            // In this case, just ignoring the line won't affect statistics.
            haventFoundEnd = false;
            endOfChain = -1;
        }
        else
        {
            curPt = newId;
            curCell = (seg1 == curCell ? seg2 : seg1);
        }
        if (counter++ > 1000000)
        {
            haventFoundEnd = false;
            endOfChain = -1;
        }
    }

    return endOfChain;
}
vtkDataSet *
avtUniformBinningScheme::CreateGrid(void) const
{
    int  i, j;

    if (ntuples > 3)
    {
        EXCEPTION0(ImproperUseException);
    }

    vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
    int dims[3] = { 1, 1, 1 };

    for (i = 0 ; i < 3 ; i++)
    {
        vtkFloatArray *arr = vtkFloatArray::New();
        if (i < ntuples)
        {
            if (ntuples == 1) // curve ... set up for point data
            {
                arr->SetNumberOfTuples(nvals[i]);
                float start = ranges[2*i];
                float stop  = ranges[2*i+1];
                float step  = (stop - start) / (nvals[i]);
                for (j = 0 ; j < nvals[i] ; j++)
                {
                    arr->SetValue(j, start + j*step + step/2.0);
                }
            }
            else // 2D or 3D ... set up for cell data
            {
                arr->SetNumberOfTuples(nvals[i]+1);
                float start = ranges[2*i];
                float stop  = ranges[2*i+1];
                float step  = (stop - start) / (nvals[i]);
                for (j = 0 ; j < nvals[i]+1 ; j++)
                {
                    arr->SetValue(j, start + j*step);
                }
            }
        }
        else
        {
            arr->SetNumberOfTuples(1);
            arr->SetValue(0, 0.);
        }
        dims[i] = arr->GetNumberOfTuples();
        if (i == 0)
            rgrid->SetXCoordinates(arr);
        else if (i == 1)
            rgrid->SetYCoordinates(arr);
        else if (i == 2)
            rgrid->SetZCoordinates(arr);
        arr->Delete();
    }

    rgrid->SetDimensions(dims);
    return rgrid;
}
bool
DBOptionsAttributes::GetBool(const std::string &name) const
{
    int bIndex = FindIndex(name);
    if (bIndex < 0)
        EXCEPTION0(BadDeclareFormatString);
    return optBools[bIndex] != 0;
}
DBOptionsAttributes::OptionType
DBOptionsAttributes::GetType(int index) const
{
    if (index < 0 || index >= types.size())
        EXCEPTION0(BadDeclareFormatString);

    return (DBOptionsAttributes::OptionType) types[index];
}
int
DBOptionsAttributes::GetEnum(const std::string &name) const
{
    int bIndex = FindIndex(name);
    if (bIndex < 0)
        EXCEPTION0(BadDeclareFormatString);
    return optEnums[bIndex];
}
float
DBOptionsAttributes::GetFloat(const std::string &name) const
{
    int bIndex = FindIndex(name);
    if (bIndex < 0)
        EXCEPTION0(BadDeclareFormatString);
    return (float) optFloats[bIndex];
}
Exemplo n.º 26
0
void
avtDataObject::CompatibleTypes(avtDataObject *dob)
{
    if (strcmp(GetType(), dob->GetType()) != 0)
    {
        EXCEPTION0(ImproperUseException);
    }
}
bool
avtFileWriter::IsImageFormat(void)
{
    if (format < 0)
    {
        EXCEPTION0(ImproperUseException);
    }
    return isImage;
}
Exemplo n.º 28
0
avtOriginatingSource *
avtDataObject::GetOriginatingSource(void)
{
    if (source == NULL)
    {
        EXCEPTION0(NoInputException);
    }

    return source->GetOriginatingSource();
}
Exemplo n.º 29
0
avtQueryableSource *
avtDataObject::GetQueryableSource(void)
{
    if (source == NULL)
    {
        EXCEPTION0(NoInputException);
    }

    return source->GetQueryableSource();
}
avtDataTree_p
avtDatasetSink::GetInputDataTree()
{
    if (*input == NULL)
    {
        EXCEPTION0(NoInputException);
    }

    return input->GetDataTree();
}