MCPcopy Create free account
hub / github.com/Kitware/VTK / RequestData

Method RequestData

Infovis/BoostGraphAlgorithms/vtkBoostRandomSparseArraySource.cxx:67–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65//------------------------------------------------------------------------------
66
67int vtkBoostRandomSparseArraySource::RequestData(
68 vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
69{
70 boost::mt19937 pattern_generator(static_cast<boost::uint32_t>(this->ElementProbabilitySeed));
71 boost::bernoulli_distribution<> pattern_distribution(this->ElementProbability);
72 boost::variate_generator<boost::mt19937&, boost::bernoulli_distribution<>> pattern(
73 pattern_generator, pattern_distribution);
74
75 boost::mt19937 value_generator(static_cast<boost::uint32_t>(this->ElementValueSeed));
76 boost::uniform_real<> value_distribution(this->MinValue, this->MaxValue);
77 boost::variate_generator<boost::mt19937&, boost::uniform_real<>> values(
78 value_generator, value_distribution);
79
80 vtkSparseArray<double>* const array = vtkSparseArray<double>::New();
81 array->Resize(this->Extents);
82
83 vtkArrayCoordinates coordinates;
84 for (vtkArray::SizeT n = 0; n != this->Extents.GetSize(); ++n)
85 {
86 this->Extents.GetRightToLeftCoordinatesN(n, coordinates);
87
88 // Although it seems wasteful, we calculate a value for every element in the array
89 // so the results stay consistent as the ElementProbability varies
90 const double value = values();
91 if (pattern())
92 {
93 array->AddValue(coordinates, value);
94 }
95 }
96
97 vtkArrayData* const output = vtkArrayData::GetData(outputVector);
98 output->ClearArrays();
99 output->AddArray(array);
100 array->Delete();
101
102 return 1;
103}
104VTK_ABI_NAMESPACE_END

Callers

nothing calls this directly

Calls 9

AddValueMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetDataFunction · 0.50
ResizeMethod · 0.45
GetSizeMethod · 0.45
ClearArraysMethod · 0.45
AddArrayMethod · 0.45

Tested by

no test coverage detected