// **************************************************************************** // Method: avtResampleFilter::GetBounds // // Purpose: // Obtains the bounds of the resampled volume. This could come from // attributes, or the existing spatial extents of the input. // // Arguments: // bounds Output array. Format is min/max X, then m/m Y, m/m Z. // // Returns: whether or not these specify 3-dimensional bounds. // // Programmer: Tom Fogal // Creation: June 23, 2009 // // Modifications: // // Hank Childs, Thu Aug 26 13:47:30 PDT 2010 // Change extents names. // // Hank Childs, Tue Nov 30 21:54:43 PST 2010 // Remove const qualification. // // **************************************************************************** bool avtResampleFilter::GetBounds(double bounds[6]) { bool is3D = true; if (atts.GetUseBounds()) { bounds[0] = atts.GetMinX(); bounds[1] = atts.GetMaxX(); bounds[2] = atts.GetMinY(); bounds[3] = atts.GetMaxY(); bounds[4] = atts.GetMinZ(); bounds[5] = atts.GetMaxZ(); } else { const avtDataAttributes &datts = GetInput()->GetInfo().GetAttributes(); avtExtents *exts = datts.GetDesiredSpatialExtents(); if (exts->HasExtents()) { exts->CopyTo(bounds); } else { GetSpatialExtents(bounds); } } if (fabs(bounds[4]) < 1e-100 && fabs(bounds[5]) < 1e-100) { is3D = false; bounds[5] += 0.1; } return is3D; }
void avtTubeFilter::PreExecute(void) { if (atts.GetScaleByVarFlag() == true) return; if (atts.GetTubeRadiusType() == TubeAttributes::Absolute) { scaleFactor = atts.GetRadiusAbsolute(); } else { int dim = GetInput()->GetInfo().GetAttributes().GetSpatialDimension(); double bbox[6]; avtIntervalTree *it = GetMetaData()->GetSpatialExtents(); if (it != NULL) it->GetExtents(bbox); else GetSpatialExtents(bbox); int numReal = 0; double volume = 1.0; for (int i = 0 ; i < dim ; i++) { if (bbox[2*i] != bbox[2*i+1]) { numReal++; volume *= (bbox[2*i+1]-bbox[2*i]); } } if (volume < 0) volume *= -1.; if (numReal > 0) scaleFactor = pow(volume, 1.0/numReal)*atts.GetRadiusFractionBBox(); else scaleFactor = 1*atts.GetRadiusFractionBBox(); } }
void avtDataBinningFilter::Execute(void) { ConstructDataBinningAttributes dba = atts.CreateConstructionAtts(); std::vector<double> bb = dba.GetBinBoundaries(); if (! atts.GetDim1SpecifyRange()) { if (atts.GetDim1BinBasedOn() == DataBinningAttributes::Variable) { std::string v1name = atts.GetDim1Var(); if (v1name == "default") v1name = pipelineVariable; double range[2]; GetDataExtents(range, v1name.c_str()); bb[0] = range[0]; bb[1] = range[1]; } else { int dim = (atts.GetDim1BinBasedOn()-DataBinningAttributes::X); double range[6]; GetSpatialExtents(range); bb[0] = range[2*dim]; bb[1] = range[2*dim+1]; } } if ((! atts.GetDim2SpecifyRange()) && (atts.GetNumDimensions() == DataBinningAttributes::Two || atts.GetNumDimensions() == DataBinningAttributes::Three)) { if (atts.GetDim2BinBasedOn() == DataBinningAttributes::Variable) { std::string v2name = atts.GetDim2Var(); if (v2name == "default") v2name = pipelineVariable; double range[2]; GetDataExtents(range, v2name.c_str()); bb[2] = range[0]; bb[3] = range[1]; } else { int dim = (atts.GetDim2BinBasedOn()-DataBinningAttributes::X); double range[6]; GetSpatialExtents(range); bb[2] = range[2*dim]; bb[3] = range[2*dim+1]; } } if ((! atts.GetDim3SpecifyRange()) && atts.GetNumDimensions() == DataBinningAttributes::Three) { if (atts.GetDim3BinBasedOn() == DataBinningAttributes::Variable) { std::string v3name = atts.GetDim3Var(); if (v3name == "default") v3name = pipelineVariable; double range[2]; GetDataExtents(range, v3name.c_str()); bb[4] = range[0]; bb[5] = range[1]; } else { int dim = (atts.GetDim3BinBasedOn()-DataBinningAttributes::X); double range[6]; GetSpatialExtents(range); bb[4] = range[2*dim]; bb[5] = range[2*dim+1]; } } dba.SetBinBoundaries(bb); avtDataBinningConstructor dbc; dbc.SetInput(GetInput()); avtDataBinning *d = dbc.ConstructDataBinning(&dba, lastContract, false); if (atts.GetOutputType() == DataBinningAttributes::OutputOnBins) { if (PAR_Rank() == 0) { vtkDataSet *ds = d->CreateGrid(); if (atts.GetNumDimensions() == DataBinningAttributes::One) ds->GetPointData()->GetScalars()->SetName(varname.c_str()); else ds->GetCellData()->GetScalars()->SetName(varname.c_str()); ds->GetCellData()->SetActiveScalars(varname.c_str()); SetOutputDataTree(new avtDataTree(ds, -1)); double range[2] = { FLT_MAX, -FLT_MAX }; GetDataRange(ds, range, varname.c_str(), false); avtDataAttributes &dataAtts = GetOutput()->GetInfo().GetAttributes(); dataAtts.GetThisProcsOriginalDataExtents(varname.c_str())->Set(range); dataAtts.GetThisProcsActualDataExtents(varname.c_str())->Set(range); ds->Delete(); } else SetOutputDataTree(new avtDataTree()); avtDataAttributes &dataAtts = GetOutput()->GetInfo().GetAttributes(); int dim = ( (atts.GetNumDimensions() == DataBinningAttributes::One) ? 1 : ((atts.GetNumDimensions() == DataBinningAttributes::Two) ? 2 : 3)); dataAtts.GetThisProcsOriginalSpatialExtents()->Set(&bb[0]); dataAtts.GetOriginalSpatialExtents()->Set(&bb[0]); } else if (atts.GetOutputType() == DataBinningAttributes::OutputOnInputMesh) { double range[2] = { FLT_MAX, -FLT_MAX }; bool hadError = false; avtDataTree_p tree = CreateArrayFromDataBinning(GetInputDataTree(), d, range, hadError); if (UnifyMaximumValue((int) hadError) > 0) { avtCallback::IssueWarning("The data binning could not be placed on the input " "mesh. This is typically because the data binning is over different " "centerings (zonal and nodal) and can not be meaningfully placed back " "on the input mesh. Try recentering one of the variables to remove " "this ambiguity."); SetOutputDataTree(new avtDataTree()); } else { SetOutputDataTree(tree); avtDataAttributes &dataAtts = GetOutput()->GetInfo().GetAttributes(); dataAtts.GetThisProcsOriginalDataExtents(varname.c_str())->Set(range); dataAtts.GetThisProcsActualDataExtents(varname.c_str())->Set(range); } } delete d; }
avtIntervalTree * avtMetaData::GetSpatialExtents(const char *var) { return GetSpatialExtents(-1, var); }