I still dont follow, please include screenshot to explain what is missing
Sorry for the continued confusion
This is when I apply my new combined filter. You see in the Orientation Array dropdown below, it does not show the “Result” array from the Calculator part.
Whereas, if I don’t use my combined filter but instead use Calculator filter first and then glyph filter. I can see the “Result” array in the Orientation and Scale dropdowns:
This is expected, the domains are extracted from the input of the filter.
But you see that in both cases the pipeline is the same — (Import Cylinder, extract same surface, apply calculator and glyph filters)
So according to my understanding the input should be same, no?
GlyphFilter input is calculator output.
ForceFilter input is ExtractSelection output.
Not the same.
I see. I thought when I am passing calculators output i forceFilter to the glyph part I will be able to achieve the desired functionality.
this->GlyphFilter->SetInputData(dataset);
this->GlyphFilter->SetInputConnection(this->ArrayCalculator->GetOutputPort());
If not is there a way to somehow do that?
And thanks a lot for your help and patience!
VTK input and ParaView input is not the same.
If not is there a way to somehow do that?
You should not expose this setting and set it manually in your C++ code.
I will do that.
Thank you so much!
If I try to apply my ForceFilter (calculator + glyph) twice on two different surface it does not let me do that and the filter menu is greyed out (see the first figure).
I can achieve the same functionality if I apply calculator + glyph filter separately (see the second figure)
Press apply
How did I even miss that
I am applying multiple Force filter, then I group them using Group Datasets
filter. After that I am applying Resample with dataset to convert into my original mesh form.
But if I use my apply force filter (instead of calculator + glyph) filter I don’t see the force vector (actually the function in calculator) in Resample with dataset in some cases.
By force vector I mean:
0*iHat + 0*jHat + 4*kHat
This is the pipeline with my ApplyForce
filter. Here you can see that I cannot see any Force value. Btw this only happens if I have 0 in two directions and only one non zero value.
And if you see in ResampleWithDataset vtkValidPointMask are all 0 (not sure why)
But if I use Calculator + Glyph instead of ApplyForce then it works fine with any sort of vector, which is how it should be.
Here you can see that Force equation is present in the Group Dataset also:
Can you please help me with it.
My assumptions are that maybe in one case I am applying GroupDataset directly on calculator but in the other case I am applying GroupDataset to the ApplyForce filter so maybe something is wrong there. But then in both cases I have the same output of GroupDataset.
And in some cases I don’t have this issue if I change the Force vector equation to maybe have non zero in jHat and other 0s.
Thanks in advance for your help and patience.
if I use my apply force filter (instead of calculator + glyph) filter I don’t see the force vector
What is apply force filter ? Maybe the data is not computed. Check your filter.
Force filter is the combination of Calculator
filter and Glyph
Filter:
vtkStandardNewMacro(vtkMyForceFilter);
vtkMyForceFilter::vtkMyForceFilter()
{
this->ArrayCalculator = vtkSmartPointer<vtkPVArrayCalculator>::New();
this->GlyphFilter = vtkSmartPointer<vtkPVGlyphFilter>::New();
this->SetNumberOfInputPorts(2);
}
vtkMyForceFilter::~vtkMyForceFilter()
{
}
void vtkMyForceFilter::SetAttributeType(int value)
{
this->ArrayCalculator->SetAttributeType(value);
this->Modified();
}
void vtkMyForceFilter::SetCoordinateResults(int value)
{
this->ArrayCalculator->SetCoordinateResults(value);
this->Modified();
}
void vtkMyForceFilter::SetResultNormals(int value)
{
this->ArrayCalculator->SetResultNormals(value);
this->Modified();
}
void vtkMyForceFilter::SetResultTCoords(int value)
{
this->ArrayCalculator->SetResultTCoords(value);
this->Modified();
}
void vtkMyForceFilter::SetResultArrayName(std::string value)
{
this->ArrayCalculator->SetResultArrayName(value.c_str());
this->Modified();
}
void vtkMyForceFilter::SetFunction(std::string value)
{
this->ArrayCalculator->SetFunction(value.c_str());
this->Modified();
}
void vtkMyForceFilter::SetReplaceInvalidValues(int value)
{
this->ArrayCalculator->SetReplaceInvalidValues(value);
this->Modified();
}
void vtkMyForceFilter::SetReplacementValue(double value)
{
this->ArrayCalculator->SetReplacementValue(value);
this->Modified();
}
void vtkMyForceFilter::SetResultArrayType(int value)
{
this->ArrayCalculator->SetResultArrayType(value);
this->Modified();
}
void vtkMyForceFilter::SetFunctionParserTypeFromInt(int value)
{
this->ArrayCalculator->SetFunctionParserTypeFromInt(value);
this->Modified();
}
// Glyph Methods for XML
void vtkMyForceFilter::SetVectorScaleMode(int value)
{
this->GlyphFilter->SetVectorScaleMode(value);
this->Modified();
}
void vtkMyForceFilter::SetScaleFactor(double value)
{
this->GlyphFilter->SetScaleFactor(value);
this->Modified();
}
void vtkMyForceFilter::SetGlyphMode(int value)
{
this->GlyphFilter->SetGlyphMode(value);
this->Modified();
}
void vtkMyForceFilter::SetMaximumNumberOfSamplePoints(int value)
{
this->GlyphFilter->SetMaximumNumberOfSamplePoints(value);
this->Modified();
}
void vtkMyForceFilter::SetSeed(int value)
{
this->GlyphFilter->SetSeed(value);
this->Modified();
}
void vtkMyForceFilter::SetStride(int value)
{
this->GlyphFilter->SetStride(value);
this->Modified();
}
void vtkMyForceFilter::SetSourceTransform(vtkTransform* transform)
{
this->GlyphFilter->SetSourceTransform(transform);
this->Modified();
}
// Specify a source object at a specified table location.
void vtkMyForceFilter::SetSourceConnection(int id, vtkAlgorithmOutput* algOutput)
{
if (id < 0)
{
vtkErrorMacro("Bad index " << id << " for source.");
return;
}
int numConnections = this->GetNumberOfInputConnections(1);
if (id < numConnections)
{
this->SetNthInputConnection(1, id, algOutput);
}
else if (id == numConnections && algOutput)
{
this->AddInputConnection(1, algOutput);
}
else if (algOutput)
{
vtkWarningMacro("The source id provided is larger than the maximum "
"source id, using "
<< numConnections << " instead.");
this->AddInputConnection(1, algOutput);
}
}
int vtkMyForceFilter::FillInputPortInformation(int port, vtkInformation* info)
{
if (port == 0)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
// we can handle composite datasets.
info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkCompositeDataSet");
return 1;
}
else if (port == 1)
{
info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1);
info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1);
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
return 1;
}
return 0;
}
void vtkMyForceFilter::SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name)
{
this->GlyphFilter->SetInputArrayToProcess(idx, port, connection, fieldAssociation, name);
this->Modified();
}
int vtkMyForceFilter::RequestData(
vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
auto* arrayCalcInput = vtkDataObject::GetData(inputVector[0], 0);
vtkDataSet* output = vtkDataSet::GetData(outputVector);
this->ArrayCalculator->SetInputData(arrayCalcInput);
this->ArrayCalculator->Update();
vtkDataObject* arrayCalcOutput = this->ArrayCalculator->GetOutputDataObject(0);
vtkDataSet* dataset = vtkDataSet::SafeDownCast(arrayCalcOutput);
// Glyph Parts
vtkNew<vtkArrowSource> arrowSource;
this->GlyphFilter->SetSourceConnection(arrowSource->GetOutputPort());
this->GlyphFilter->SetInputData(dataset);
this->GlyphFilter->SetInputConnection(this->ArrayCalculator->GetOutputPort());
// // Set the vector array
this->GlyphFilter->SetInputArrayToProcess(1, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Force");
this->GlyphFilter->Update();
// Get the output data object of the GlyphFilter
// vtkDataObject* glyphOutput = this->GlyphFilter->GetOutputDataObject(0);
vtkDataObject* glyphOutput = this->GlyphFilter->GetOutput();
// Shallow copy the output of GlyphFilter to the output of vtkMyForceFilter
if (glyphOutput)
{
output->ShallowCopy(glyphOutput);
}
return 1;
}
And the issue is with certain vectors.
E.g. if I write 0iHat + 0jHat + 5*kHat then when i apply resample with data it can’t this equation. It actually mask those points to 0
So essentially if two dimensions are 0 then I have the issue and that’s when masking in resample with dataset happens, which is strange