[FEM] fix pipeline recompute bug
- on recomputing scalar or warp filters the information about the field was lost. This is because the validity of an array was tested before it is actually filled - also fix MSVC warning of using a C++ keyword as variable - also avoid an unnecessary recompute after Elmer solver was run
This commit is contained in:
@@ -26,9 +26,10 @@
|
||||
# include <vtkPointData.h>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
|
||||
#include "FemPostFilter.h"
|
||||
#include "FemPostPipeline.h"
|
||||
#include <App/Document.h>
|
||||
|
||||
|
||||
using namespace Fem;
|
||||
@@ -455,10 +456,10 @@ FemPostScalarClipFilter::~FemPostScalarClipFilter() {
|
||||
DocumentObjectExecReturn* FemPostScalarClipFilter::execute(void) {
|
||||
|
||||
std::string val;
|
||||
if (m_scalarFields.hasEnums() && Scalars.getValue() >= 0)
|
||||
if (Scalars.getValue() >= 0)
|
||||
val = Scalars.getValueAsString();
|
||||
|
||||
std::vector<std::string> array;
|
||||
std::vector<std::string> ScalarsArray;
|
||||
|
||||
vtkSmartPointer<vtkDataObject> data = getInputData();
|
||||
if (!data || !data->IsA("vtkDataSet"))
|
||||
@@ -467,18 +468,21 @@ DocumentObjectExecReturn* FemPostScalarClipFilter::execute(void) {
|
||||
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
|
||||
vtkPointData* pd = dset->GetPointData();
|
||||
|
||||
// get all scalar fields
|
||||
for (int i = 0; i < pd->GetNumberOfArrays(); ++i) {
|
||||
if (pd->GetArray(i)->GetNumberOfComponents() == 1)
|
||||
array.emplace_back(pd->GetArrayName(i));
|
||||
ScalarsArray.emplace_back(pd->GetArrayName(i));
|
||||
}
|
||||
|
||||
App::Enumeration empty;
|
||||
Scalars.setValue(empty);
|
||||
m_scalarFields.setEnums(array);
|
||||
m_scalarFields.setEnums(ScalarsArray);
|
||||
Scalars.setValue(m_scalarFields);
|
||||
|
||||
std::vector<std::string>::iterator it = std::find(array.begin(), array.end(), val);
|
||||
if (!val.empty() && it != array.end())
|
||||
// search if the current field is in the available ones and set it
|
||||
std::vector<std::string>::iterator it =
|
||||
std::find(ScalarsArray.begin(), ScalarsArray.end(), val);
|
||||
if (!val.empty() && it != ScalarsArray.end())
|
||||
Scalars.setValue(val.c_str());
|
||||
|
||||
//recalculate the filter
|
||||
@@ -506,11 +510,10 @@ short int FemPostScalarClipFilter::mustExecute(void) const {
|
||||
|
||||
if (Value.isTouched() ||
|
||||
InsideOut.isTouched() ||
|
||||
Scalars.isTouched()) {
|
||||
|
||||
Scalars.isTouched())
|
||||
return 1;
|
||||
}
|
||||
else return App::DocumentObject::mustExecute();
|
||||
else
|
||||
return App::DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
void FemPostScalarClipFilter::setConstraintForField() {
|
||||
@@ -558,10 +561,10 @@ FemPostWarpVectorFilter::~FemPostWarpVectorFilter() {
|
||||
DocumentObjectExecReturn* FemPostWarpVectorFilter::execute(void) {
|
||||
|
||||
std::string val;
|
||||
if (m_vectorFields.hasEnums() && Vector.getValue() >= 0)
|
||||
if (Vector.getValue() >= 0)
|
||||
val = Vector.getValueAsString();
|
||||
|
||||
std::vector<std::string> array;
|
||||
std::vector<std::string> VectorArray;
|
||||
|
||||
vtkSmartPointer<vtkDataObject> data = getInputData();
|
||||
if (!data || !data->IsA("vtkDataSet"))
|
||||
@@ -570,18 +573,21 @@ DocumentObjectExecReturn* FemPostWarpVectorFilter::execute(void) {
|
||||
vtkDataSet* dset = vtkDataSet::SafeDownCast(data);
|
||||
vtkPointData* pd = dset->GetPointData();
|
||||
|
||||
// get all vector fields
|
||||
for (int i = 0; i < pd->GetNumberOfArrays(); ++i) {
|
||||
if (pd->GetArray(i)->GetNumberOfComponents() == 3)
|
||||
array.emplace_back(pd->GetArrayName(i));
|
||||
VectorArray.emplace_back(pd->GetArrayName(i));
|
||||
}
|
||||
|
||||
App::Enumeration empty;
|
||||
Vector.setValue(empty);
|
||||
m_vectorFields.setEnums(array);
|
||||
m_vectorFields.setEnums(VectorArray);
|
||||
Vector.setValue(m_vectorFields);
|
||||
|
||||
std::vector<std::string>::iterator it = std::find(array.begin(), array.end(), val);
|
||||
if (!val.empty() && it != array.end())
|
||||
// search if the current field is in the available ones and set it
|
||||
std::vector<std::string>::iterator it =
|
||||
std::find(VectorArray.begin(), VectorArray.end(), val);
|
||||
if (!val.empty() && it != VectorArray.end())
|
||||
Vector.setValue(val.c_str());
|
||||
|
||||
//recalculate the filter
|
||||
@@ -590,13 +596,11 @@ DocumentObjectExecReturn* FemPostWarpVectorFilter::execute(void) {
|
||||
|
||||
void FemPostWarpVectorFilter::onChanged(const Property* prop) {
|
||||
|
||||
if (prop == &Factor) {
|
||||
if (prop == &Factor)
|
||||
m_warp->SetScaleFactor(Factor.getValue());
|
||||
}
|
||||
else if (prop == &Vector && (Vector.getValue() >= 0)) {
|
||||
else if (prop == &Vector && (Vector.getValue() >= 0))
|
||||
m_warp->SetInputArrayToProcess(0, 0, 0,
|
||||
vtkDataObject::FIELD_ASSOCIATION_POINTS, Vector.getValueAsString());
|
||||
}
|
||||
|
||||
Fem::FemPostFilter::onChanged(prop);
|
||||
}
|
||||
@@ -604,11 +608,10 @@ void FemPostWarpVectorFilter::onChanged(const Property* prop) {
|
||||
short int FemPostWarpVectorFilter::mustExecute(void) const {
|
||||
|
||||
if (Factor.isTouched() ||
|
||||
Vector.isTouched()) {
|
||||
|
||||
Vector.isTouched())
|
||||
return 1;
|
||||
}
|
||||
else return App::DocumentObject::mustExecute();
|
||||
else
|
||||
return App::DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -255,7 +255,6 @@ class Results(run.Results):
|
||||
# at the moment we scale the mesh back using Elmer
|
||||
# this might be changed in future, therefore leave this
|
||||
# self.solver.ElmerResult.scale(1000)
|
||||
self.solver.ElmerResult.getLastPostObject().touch()
|
||||
self.solver.ElmerResult.recomputeChildren()
|
||||
self.solver.Document.recompute()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user