80 vtkInformationVector **inputVector,
81 vtkInformationVector *outputVector) {
83 std::string
const associationNames[3] = {
"point",
"cell",
"field"};
86 auto target = vtkDataObject::GetData(inputVector[0], 0);
87 auto output = vtkDataObject::GetData(outputVector, 0);
88 output->ShallowCopy(target);
93 switch(this->EditorMode) {
95 this->
printMsg(
"Input string: '" + this->DataString +
"'",
99 if(this->DataString.length() > 0) {
102 int const targetAssociation
103 = this->TargetAssociation < 0 ? 2 : this->TargetAssociation;
104 auto outputAtt = output->GetAttributesAsFieldData(targetAssociation);
106 this->
printErr(
"Target does not have requested attribute type.");
111 this->
printMsg(
"Adding parsed arrays from string to "
112 + associationNames[targetAssociation] +
" data",
115 std::string finalExpressionString;
117 std::string errorMsg;
119 output->GetFieldData(),
120 finalExpressionString, errorMsg)) {
121 std::stringstream
const msg;
129 std::stringstream ss(finalExpressionString);
131 while(getline(ss, line,
'\n')) {
136 if(this->ReplaceExistingArrays
137 || !outputAtt->HasArray(array->GetName()))
138 outputAtt->AddArray(array);
142 this->
printMsg(
"Adding parsed arrays from string to "
143 + associationNames[targetAssociation] +
" data",
152 const std::string modeS
153 = isAddMode ?
"Adding point/cell/field arrays from source"
154 :
"Filter point/cell/field arrays from source";
157 auto source = vtkDataObject::GetData(inputVector[1], 0);
159 this->
printErr(
"Unable to retrieve source vtkDataObject.");
163 for(
int association = 0;
164 association < vtkDataObject::NUMBER_OF_ASSOCIATIONS; ++association) {
165 if(association == vtkDataObject::FIELD_ASSOCIATION_POINTS_THEN_CELLS)
169 auto sourceFD = source->GetAttributesAsFieldData(association);
171 if(!sourceFD || !selection)
175 int const targetAssociation
176 = this->TargetAssociation < 0 ? association : this->TargetAssociation;
177 auto outputAtt = output->GetAttributesAsFieldData(targetAssociation);
183 for(
int i = 0; i < sourceFD->GetNumberOfArrays(); i++) {
184 auto array = sourceFD->GetAbstractArray(i);
187 if(selection->ArrayIsEnabled(array->GetName()))
188 outputAtt->AddArray(array);
190 if(!selection->ArrayIsEnabled(array->GetName()))
191 outputAtt->RemoveArray(array->GetName());
202 auto targetArray = this->GetInputArrayToProcess(0, inputVector);
204 return !this->
printErr(
"Unable to retrieve input array.");
206 int const targetArrayAssociation
207 = this->GetInputArrayAssociation(0, inputVector);
209 this->
printMsg(
"Editing '" + std::string(targetArray->GetName()) +
"' "
210 + associationNames[targetArrayAssociation]
216 if(this->TargetArrayType >= 0 || this->TargetArrayIndexation[0] >= 0
217 || this->TargetArrayIndexation[1] >= 0) {
220 this->TargetArrayType < 0 ? targetArray->GetDataType()
221 : this->TargetArrayType));
223 size_t const nComponents = this->TargetArrayIndexation[1] >= 0
224 ? this->TargetArrayIndexation[1]
225 : this->TargetArrayIndexation[0] >= 0
226 ? targetArray->GetNumberOfValues()
227 / this->TargetArrayIndexation[0]
228 : targetArray->GetNumberOfComponents();
230 size_t const nTuples = this->TargetArrayIndexation[0] >= 0
231 ? this->TargetArrayIndexation[0]
232 : this->TargetArrayIndexation[1] >= 0
233 ? targetArray->GetNumberOfValues()
234 / this->TargetArrayIndexation[1]
235 : targetArray->GetNumberOfTuples();
236 copy->Allocate(nTuples * nComponents);
237 copy->SetNumberOfComponents(nComponents);
238 copy->SetNumberOfTuples(nTuples);
240 switch(vtkTemplate2PackMacro(
241 targetArray->GetDataType(), copy->GetDataType())) {
242 vtkTemplate2Macro((copyArrayData<VTK_T1, VTK_T2>(targetArray, copy)));
246 copy->ShallowCopy(targetArray);
248 copy->SetName(this->TargetArrayName.compare(
"") == 0
249 ? targetArray->GetName()
250 : this->TargetArrayName.data());
253 int const targetAssociation = this->TargetAssociation < 0
254 ? targetArrayAssociation
255 : this->TargetAssociation;
256 auto outputAtt = output->GetAttributesAsFieldData(targetAssociation);
258 this->
printErr(
"Target does not have requested attribute type.");
261 outputAtt->AddArray(copy);
263 this->
printMsg(
"Editing '" + std::string(targetArray->GetName()) +
"' "
264 + associationNames[targetArrayAssociation]