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

Method RequestData

Infovis/BoostGraphAlgorithms/vtkBoostLogWeighting.cxx:45–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45int vtkBoostLogWeighting::RequestData(
46 vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
47{
48 try
49 {
50 vtkArrayData* const input_data = vtkArrayData::GetData(inputVector[0]);
51 if (!input_data)
52 throw std::runtime_error("Missing input vtkArrayData on port 0.");
53 if (input_data->GetNumberOfArrays() != 1)
54 throw std::runtime_error("Input vtkArrayData must contain exactly one array.");
55 vtkTypedArray<double>* const input_array =
56 vtkTypedArray<double>::SafeDownCast(input_data->GetArray(0));
57 if (!input_array)
58 throw std::runtime_error("Unsupported input array type.");
59
60 vtkTypedArray<double>* const output_array =
61 vtkTypedArray<double>::SafeDownCast(input_array->DeepCopy());
62 vtkArrayData* const output = vtkArrayData::GetData(outputVector);
63 output->ClearArrays();
64 output->AddArray(output_array);
65 output_array->Delete();
66
67 const vtkIdType value_count = input_array->GetNonNullSize();
68 switch (this->Base)
69 {
70 case BASE_E:
71 {
72 if (this->EmitProgress)
73 {
74 for (vtkIdType i = 0; i != value_count; ++i)
75 {
76 output_array->SetValueN(i, boost::math::log1p(output_array->GetValueN(i)));
77
78 double progress = static_cast<double>(i) / static_cast<double>(value_count);
79 this->InvokeEvent(vtkCommand::ProgressEvent, &progress);
80 }
81 }
82 else
83 {
84 for (vtkIdType i = 0; i != value_count; ++i)
85 {
86 output_array->SetValueN(i, boost::math::log1p(output_array->GetValueN(i)));
87 }
88 }
89 break;
90 }
91 case BASE_2:
92 {
93 const double ln2 = log(2.0);
94 if (this->EmitProgress)
95 {
96 for (vtkIdType i = 0; i != value_count; ++i)
97 {
98 output_array->SetValueN(i, 1.0 + log(output_array->GetValueN(i)) / ln2);
99
100 double progress = static_cast<double>(i) / static_cast<double>(value_count);
101 this->InvokeEvent(vtkCommand::ProgressEvent, &progress);
102 }

Callers

nothing calls this directly

Calls 11

InvokeEventMethod · 0.80
DeleteMethod · 0.65
GetDataFunction · 0.50
log1pFunction · 0.50
logFunction · 0.50
GetNumberOfArraysMethod · 0.45
GetArrayMethod · 0.45
DeepCopyMethod · 0.45
ClearArraysMethod · 0.45
AddArrayMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected