Skip to content

Commit 2272763

Browse files
committed
test
1 parent 2267bd8 commit 2272763

File tree

2 files changed

+94
-11
lines changed

2 files changed

+94
-11
lines changed

src/Mod/Fem/App/FemPostFilter.cpp

+88-10
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,33 @@ FemPostFilter::FilterPipeline& FemPostFilter::getFilterPipeline(std::string name
6868
void FemPostFilter::setActiveFilterPipeline(std::string name)
6969
{
7070
if (m_activePipeline != name && isValid()) {
71-
71+
printf("aca3 %s\n", name.c_str());
7272
// disable all inputs of current pipeline
7373
if (m_activePipeline != "" and m_pipelines.find(m_activePipeline) != m_pipelines.end()) {
7474
m_pipelines[m_activePipeline].source->RemoveAllInputConnections(0);
75+
printf("aca4 %s\n", name.c_str());
7576
}
7677

7778
// handle the transform
7879
if (m_use_transform) {
7980
m_transform_filter->RemoveAllInputConnections(0);
8081
if (m_transform_location == TransformLocation::output) {
82+
printf("aca5 %s\n", name.c_str());
8183
m_transform_filter->SetInputConnection(m_pipelines[name].target->GetOutputPort(0));
84+
printf("aca6 %s\n", name.c_str());
8285
}
8386
else {
87+
printf("aca7 %s\n", name.c_str());
8488
m_pipelines[name].source->SetInputConnection(m_transform_filter->GetOutputPort(0));
89+
printf("aca8 %s\n", name.c_str());
8590
}
8691
}
8792

8893
// set the new pipeline active
8994
m_activePipeline = name;
95+
printf("aca9 %s\n", name.c_str());
9096
pipelineChanged();
97+
printf("aca10 %s\n", name.c_str());
9198
}
9299
}
93100

@@ -170,19 +177,34 @@ DocumentObjectExecReturn* FemPostFilter::execute()
170177

171178
// the pipelines are setup correctly, all we need to do is to update and take out the data.
172179
if (!m_pipelines.empty() && !m_activePipeline.empty()) {
173-
auto output = getFilterOutput();
174180

175-
if (output->GetNumberOfInputConnections(0) == 0) {
181+
printf("filter execute -1\n");
182+
auto output = getFilterOutput();
183+
printf("filter execute 0 hasexecutive %d\n", output->HasExecutive());
184+
if (output->GetNumberOfInputConnections(0) == 0 || !output->HasExecutive()) {
176185
return StdReturn;
177186
}
178187

188+
printf("filter execute 1\n");
179189
if (Frame.getValue() > 0) {
190+
printf("filter execute 2\n");
180191
output->UpdateTimeStep(Frame.getValue());
192+
printf("filter execute 3\n");
181193
}
182194
else {
195+
printf("filter execute 4\n");
196+
auto o = output->GetOutputDataObject(0);
197+
int puntos = o->GetNumberOfElements(vtkDataObject::POINT);
198+
int celdas = o->GetNumberOfElements(vtkDataObject::CELL);
199+
printf("%s\tPUNTOS: %d\tCELLS: %d\n", m_activePipeline.c_str(), puntos, celdas);
200+
// if (puntos > 0) {
183201
output->Update();
202+
printf("filter execute 5\n");
203+
// }
184204
}
205+
printf("filter execute 6\n");
185206
Data.setValue(output->GetOutputDataObject(0));
207+
printf("filter execute 7\n");
186208
}
187209

188210
return StdReturn;
@@ -198,8 +220,13 @@ vtkSmartPointer<vtkDataSet> FemPostFilter::getInputData()
198220

199221
vtkAlgorithmOutput* output = active.source->GetInputConnection(0, 0);
200222
vtkAlgorithm* algo = output->GetProducer();
223+
printf("getInputData: %s\n", this->getNameInDocument());
224+
auto o = algo->GetOutputDataObject(0);
225+
int puntos = o->GetNumberOfElements(vtkDataObject::POINT);
226+
// if (puntos > 0) {
201227
algo->Update();
202-
228+
//}
229+
printf("getInputData2 PUNTOS: %d\n", puntos);
203230
return vtkDataSet::SafeDownCast(algo->GetOutputDataObject(0));
204231
}
205232

@@ -722,27 +749,35 @@ FemPostSmoothFilterExtension::FemPostSmoothFilterExtension()
722749

723750
void FemPostSmoothFilterExtension::extensionOnChanged(const App::Property* prop)
724751
{
752+
printf("reco1\n");
725753
if (prop == &EnableSmoothing || prop == &Iterations) {
726754
// if disabled, set iterations to zero to do nothing
727755
m_smooth->SetNumberOfIterations(EnableSmoothing.getValue() ? Iterations.getValue() : 0);
756+
printf("reco2\n");
728757
}
729758
else if (prop == &BoundarySmoothing) {
730759
m_smooth->SetBoundarySmoothing(static_cast<const App::PropertyBool*>(prop)->getValue());
760+
printf("reco3\n");
731761
}
732762
else if (prop == &EdgeAngle) {
733763
m_smooth->SetEdgeAngle(static_cast<const App::PropertyAngle*>(prop)->getValue());
764+
printf("reco4\n");
734765
}
735766
else if (prop == &FeatureAngle) {
736767
m_smooth->SetFeatureAngle(static_cast<const App::PropertyAngle*>(prop)->getValue());
768+
printf("reco5\n");
737769
}
738770
else if (prop == &EdgeSmoothing) {
739771
m_smooth->SetFeatureEdgeSmoothing(static_cast<const App::PropertyBool*>(prop)->getValue());
772+
printf("reco6\n");
740773
}
741774
else if (prop == &RelaxationFactor) {
742775
m_smooth->SetRelaxationFactor(static_cast<const App::PropertyFloat*>(prop)->getValue());
776+
printf("reco7\n");
743777
}
744778
else {
745779
DocumentObjectExtension::extensionOnChanged(prop);
780+
printf("reco8\n");
746781
}
747782
}
748783

@@ -771,53 +806,66 @@ FemPostContoursFilter::FemPostContoursFilter()
771806
m_contourConstraints.StepSize = 1;
772807
NumberOfContours.setConstraints(&m_contourConstraints);
773808

809+
smoothExtension.initExtension(this);
810+
774811
FilterPipeline contours;
775812
m_contours = vtkSmartPointer<vtkContourFilter>::New();
776813
m_contours->ComputeScalarsOn();
777814
smoothExtension.getFilter()->SetInputConnection(m_contours->GetOutputPort());
778815
contours.source = m_contours;
779816
contours.target = smoothExtension.getFilter();
780817
addFilterPipeline(contours, "contours");
818+
printf("Aca\n");
781819
setActiveFilterPipeline("contours");
782-
783-
smoothExtension.initExtension(this);
820+
printf("Aca2\n");
784821
}
785822

786823
FemPostContoursFilter::~FemPostContoursFilter() = default;
787824

788825
DocumentObjectExecReturn* FemPostContoursFilter::execute()
789826
{
827+
printf("execute1\n");
790828
// update list of available fields and their vectors
791829
if (!m_blockPropertyChanges) {
830+
printf("execute2\n");
792831
refreshFields();
832+
printf("execute3\n");
793833
refreshVectors();
834+
printf("execute4\n");
794835
}
795836

796837
// recalculate the filter
797838
auto returnObject = Fem::FemPostFilter::execute();
798839

799840
// delete contour field
800841
vtkDataSet* dset = getInputData();
842+
printf("execute5\n");
801843
if (!dset) {
844+
printf("execute6\n");
802845
return returnObject;
803846
}
804847
dset->GetPointData()->RemoveArray(contourFieldName.c_str());
805848
// refresh fields to reflect the deletion
806849
if (!m_blockPropertyChanges) {
850+
printf("execute7\n");
807851
refreshFields();
852+
printf("execute8\n");
808853
}
809854

810855
return returnObject;
811856
}
812857

813858
void FemPostContoursFilter::onChanged(const Property* prop)
814859
{
860+
printf("cont1\n");
815861
if (m_blockPropertyChanges) {
816862
return;
817863
}
818864

819865
if (prop == &Field && (Field.getValue() >= 0)) {
866+
printf("cont2\n");
820867
refreshVectors();
868+
printf("cont3\n");
821869
}
822870

823871
// note that we need to calculate also in case of a Data change
@@ -828,23 +876,30 @@ void FemPostContoursFilter::onChanged(const Property* prop)
828876
double p[2];
829877

830878
// get the field and its data
879+
printf("cont4\n");
831880
vtkDataSet* dset = getInputData();
832881
if (!dset) {
833882
return;
834883
}
884+
printf("throw2\n");
835885
vtkDataArray* pdata = dset->GetPointData()->GetArray(Field.getValueAsString());
886+
printf("throw2\n");
836887
if (!pdata) {
837888
return;
838889
}
839890
if (pdata->GetNumberOfComponents() == 1) {
840891
// if we have a scalar, we can directly use the array
892+
printf("cont5\n");
893+
printf("throw3\n");
841894
m_contours->SetInputArrayToProcess(0,
842895
0,
843896
0,
844897
vtkDataObject::FIELD_ASSOCIATION_POINTS,
845898
Field.getValueAsString());
899+
printf("throw3\n");
846900
pdata->GetRange(p);
847901
recalculateContours(p[0], p[1]);
902+
printf("cont5\n");
848903
}
849904
else {
850905
// The contour filter handles vectors by taking always its first component.
@@ -862,11 +917,13 @@ void FemPostContoursFilter::onChanged(const Property* prop)
862917
component = 2;
863918
}
864919
// extract the component to a new array
920+
printf("cont6\n");
865921
vtkSmartPointer<vtkDoubleArray> componentArray = vtkSmartPointer<vtkDoubleArray>::New();
866922
componentArray->SetNumberOfComponents(1);
867923
vtkIdType numTuples = pdata->GetNumberOfTuples();
868924
componentArray->SetNumberOfTuples(numTuples);
869925

926+
printf("cont7\n");
870927
if (component >= 0) {
871928
for (vtkIdType tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx) {
872929
componentArray->SetComponent(tupleIdx,
@@ -886,9 +943,11 @@ void FemPostContoursFilter::onChanged(const Property* prop)
886943
}
887944
}
888945
// name the array
946+
printf("cont8\n");
889947
contourFieldName = std::string(Field.getValueAsString()) + "_contour";
890948
componentArray->SetName(contourFieldName.c_str());
891949

950+
printf("cont9\n");
892951
// add the array as new field and use it for the contour filter
893952
dset->GetPointData()->AddArray(componentArray);
894953
m_contours->SetInputArrayToProcess(0,
@@ -897,27 +956,33 @@ void FemPostContoursFilter::onChanged(const Property* prop)
897956
vtkDataObject::FIELD_ASSOCIATION_POINTS,
898957
contourFieldName.c_str());
899958
componentArray->GetRange(p);
959+
printf("cont10\n");
900960
recalculateContours(p[0], p[1]);
901961
if (prop == &Data) {
902962
// we must recalculate to pass the new created contours field
903963
// to ViewProviderFemPostObject
904964
m_blockPropertyChanges = true;
905965
execute();
906966
m_blockPropertyChanges = false;
967+
printf("cont11\n");
907968
}
908969
}
909970
}
971+
printf("cont12\n");
910972

911973
Fem::FemPostFilter::onChanged(prop);
912974
}
913975

914976
short int FemPostContoursFilter::mustExecute() const
915977
{
978+
printf("mustExtex1\n");
916979
if (Field.isTouched() || VectorMode.isTouched() || NumberOfContours.isTouched()
917980
|| Data.isTouched()) {
981+
printf("mustExtex2\n");
918982
return 1;
919983
}
920984
else {
985+
printf("mustExtex3\n");
921986
return App::DocumentObject::mustExecute();
922987
}
923988
}
@@ -934,6 +999,7 @@ void FemPostContoursFilter::recalculateContours(double min, double max)
934999
void FemPostContoursFilter::refreshFields()
9351000
{
9361001
m_blockPropertyChanges = true;
1002+
printf("refresh1\n");
9371003

9381004
std::string fieldName;
9391005
if (Field.getValue() >= 0) {
@@ -957,26 +1023,32 @@ void FemPostContoursFilter::refreshFields()
9571023
App::Enumeration empty;
9581024
Field.setValue(empty);
9591025
m_fields.setEnums(FieldsArray);
1026+
printf("throw5\n");
9601027
Field.setValue(m_fields);
1028+
printf("throw5\n");
9611029

9621030
// search if the current field is in the available ones and set it
9631031
std::vector<std::string>::iterator it =
9641032
std::find(FieldsArray.begin(), FieldsArray.end(), fieldName);
9651033
if (!fieldName.empty() && it != FieldsArray.end()) {
9661034
Field.setValue(fieldName.c_str());
9671035
}
968-
else {
1036+
else if (Field.isValid()) {
1037+
// select the first field if exist
9691038
m_blockPropertyChanges = false;
970-
// select the first field
1039+
printf("throw4\n");
9711040
Field.setValue(long(0));
1041+
printf("throw4\n");
9721042
fieldName = Field.getValueAsString();
9731043
}
9741044

1045+
printf("refresh2\n");
9751046
m_blockPropertyChanges = false;
9761047
}
9771048

9781049
void FemPostContoursFilter::refreshVectors()
9791050
{
1051+
printf("refreshvec1\n");
9801052
// refreshes the list of available vectors for the current Field
9811053
m_blockPropertyChanges = true;
9821054

@@ -985,16 +1057,21 @@ void FemPostContoursFilter::refreshVectors()
9851057
m_blockPropertyChanges = false;
9861058
return;
9871059
}
988-
vtkDataArray* fieldArray = dset->GetPointData()->GetArray(Field.getValueAsString());
989-
if (!fieldArray) {
1060+
vtkDataArray* fieldArray = nullptr;
1061+
if (Field.isValid()) {
1062+
fieldArray = dset->GetPointData()->GetArray(Field.getValueAsString());
1063+
}
1064+
else {
9901065
m_blockPropertyChanges = false;
9911066
return;
9921067
}
9931068

9941069
// store name if already set
9951070
std::string vectorName;
9961071
if (VectorMode.hasEnums() && VectorMode.getValue() >= 0) {
1072+
printf("throw1\n");
9971073
vectorName = VectorMode.getValueAsString();
1074+
printf("throw1\n");
9981075
}
9991076

10001077
std::vector<std::string> vectorArray;
@@ -1022,6 +1099,7 @@ void FemPostContoursFilter::refreshVectors()
10221099
VectorMode.setValue(vectorName.c_str());
10231100
}
10241101

1102+
printf("refreshvec2\n");
10251103
m_blockPropertyChanges = false;
10261104
}
10271105

src/Mod/Fem/femtest/app/test_object.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1123,13 +1123,16 @@ def create_all_fem_objects_doc(doc):
11231123
vres = analysis.addObject(ObjectsFem.makePostVtkResult(doc, [res]))[0]
11241124
ObjectsFem.makePostVtkFilterClipRegion(doc, vres)
11251125
ObjectsFem.makePostVtkFilterClipScalar(doc, vres)
1126-
ObjectsFem.makePostVtkFilterContours(doc, vres)
1126+
print("TEST1")
1127+
# ObjectsFem.makePostVtkFilterContours(doc, vres)
11271128
ObjectsFem.makePostVtkFilterCutFunction(doc, vres)
11281129
ObjectsFem.makePostVtkFilterWarp(doc, vres)
1130+
print("TEST2")
11291131

11301132
analysis.addObject(ObjectsFem.makeSolverCalculiXCcxTools(doc))
11311133
analysis.addObject(ObjectsFem.makeSolverCalculix(doc))
11321134
sol = analysis.addObject(ObjectsFem.makeSolverElmer(doc))[0]
1135+
print("TEST3")
11331136
analysis.addObject(ObjectsFem.makeSolverMystran(doc))
11341137
analysis.addObject(ObjectsFem.makeSolverZ88(doc))
11351138

@@ -1144,6 +1147,8 @@ def create_all_fem_objects_doc(doc):
11441147
ObjectsFem.makeEquationMagnetodynamic(doc, sol)
11451148
ObjectsFem.makeEquationStaticCurrent(doc, sol)
11461149

1150+
print("TEST4")
11471151
doc.recompute()
1152+
print("TEST5")
11481153

11491154
return doc

0 commit comments

Comments
 (0)