@@ -68,26 +68,33 @@ FemPostFilter::FilterPipeline& FemPostFilter::getFilterPipeline(std::string name
68
68
void FemPostFilter::setActiveFilterPipeline (std::string name)
69
69
{
70
70
if (m_activePipeline != name && isValid ()) {
71
-
71
+ printf ( " aca3 %s \n " , name. c_str ());
72
72
// disable all inputs of current pipeline
73
73
if (m_activePipeline != " " and m_pipelines.find (m_activePipeline) != m_pipelines.end ()) {
74
74
m_pipelines[m_activePipeline].source ->RemoveAllInputConnections (0 );
75
+ printf (" aca4 %s\n " , name.c_str ());
75
76
}
76
77
77
78
// handle the transform
78
79
if (m_use_transform) {
79
80
m_transform_filter->RemoveAllInputConnections (0 );
80
81
if (m_transform_location == TransformLocation::output) {
82
+ printf (" aca5 %s\n " , name.c_str ());
81
83
m_transform_filter->SetInputConnection (m_pipelines[name].target ->GetOutputPort (0 ));
84
+ printf (" aca6 %s\n " , name.c_str ());
82
85
}
83
86
else {
87
+ printf (" aca7 %s\n " , name.c_str ());
84
88
m_pipelines[name].source ->SetInputConnection (m_transform_filter->GetOutputPort (0 ));
89
+ printf (" aca8 %s\n " , name.c_str ());
85
90
}
86
91
}
87
92
88
93
// set the new pipeline active
89
94
m_activePipeline = name;
95
+ printf (" aca9 %s\n " , name.c_str ());
90
96
pipelineChanged ();
97
+ printf (" aca10 %s\n " , name.c_str ());
91
98
}
92
99
}
93
100
@@ -170,19 +177,34 @@ DocumentObjectExecReturn* FemPostFilter::execute()
170
177
171
178
// the pipelines are setup correctly, all we need to do is to update and take out the data.
172
179
if (!m_pipelines.empty () && !m_activePipeline.empty ()) {
173
- auto output = getFilterOutput ();
174
180
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 ()) {
176
185
return StdReturn;
177
186
}
178
187
188
+ printf (" filter execute 1\n " );
179
189
if (Frame.getValue () > 0 ) {
190
+ printf (" filter execute 2\n " );
180
191
output->UpdateTimeStep (Frame.getValue ());
192
+ printf (" filter execute 3\n " );
181
193
}
182
194
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\t PUNTOS: %d\t CELLS: %d\n " , m_activePipeline.c_str (), puntos, celdas);
200
+ // if (puntos > 0) {
183
201
output->Update ();
202
+ printf (" filter execute 5\n " );
203
+ // }
184
204
}
205
+ printf (" filter execute 6\n " );
185
206
Data.setValue (output->GetOutputDataObject (0 ));
207
+ printf (" filter execute 7\n " );
186
208
}
187
209
188
210
return StdReturn;
@@ -198,8 +220,13 @@ vtkSmartPointer<vtkDataSet> FemPostFilter::getInputData()
198
220
199
221
vtkAlgorithmOutput* output = active.source ->GetInputConnection (0 , 0 );
200
222
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) {
201
227
algo->Update ();
202
-
228
+ // }
229
+ printf (" getInputData2 PUNTOS: %d\n " , puntos);
203
230
return vtkDataSet::SafeDownCast (algo->GetOutputDataObject (0 ));
204
231
}
205
232
@@ -722,27 +749,35 @@ FemPostSmoothFilterExtension::FemPostSmoothFilterExtension()
722
749
723
750
void FemPostSmoothFilterExtension::extensionOnChanged (const App::Property* prop)
724
751
{
752
+ printf (" reco1\n " );
725
753
if (prop == &EnableSmoothing || prop == &Iterations) {
726
754
// if disabled, set iterations to zero to do nothing
727
755
m_smooth->SetNumberOfIterations (EnableSmoothing.getValue () ? Iterations.getValue () : 0 );
756
+ printf (" reco2\n " );
728
757
}
729
758
else if (prop == &BoundarySmoothing) {
730
759
m_smooth->SetBoundarySmoothing (static_cast <const App::PropertyBool*>(prop)->getValue ());
760
+ printf (" reco3\n " );
731
761
}
732
762
else if (prop == &EdgeAngle) {
733
763
m_smooth->SetEdgeAngle (static_cast <const App::PropertyAngle*>(prop)->getValue ());
764
+ printf (" reco4\n " );
734
765
}
735
766
else if (prop == &FeatureAngle) {
736
767
m_smooth->SetFeatureAngle (static_cast <const App::PropertyAngle*>(prop)->getValue ());
768
+ printf (" reco5\n " );
737
769
}
738
770
else if (prop == &EdgeSmoothing) {
739
771
m_smooth->SetFeatureEdgeSmoothing (static_cast <const App::PropertyBool*>(prop)->getValue ());
772
+ printf (" reco6\n " );
740
773
}
741
774
else if (prop == &RelaxationFactor) {
742
775
m_smooth->SetRelaxationFactor (static_cast <const App::PropertyFloat*>(prop)->getValue ());
776
+ printf (" reco7\n " );
743
777
}
744
778
else {
745
779
DocumentObjectExtension::extensionOnChanged (prop);
780
+ printf (" reco8\n " );
746
781
}
747
782
}
748
783
@@ -771,53 +806,66 @@ FemPostContoursFilter::FemPostContoursFilter()
771
806
m_contourConstraints.StepSize = 1 ;
772
807
NumberOfContours.setConstraints (&m_contourConstraints);
773
808
809
+ smoothExtension.initExtension (this );
810
+
774
811
FilterPipeline contours;
775
812
m_contours = vtkSmartPointer<vtkContourFilter>::New ();
776
813
m_contours->ComputeScalarsOn ();
777
814
smoothExtension.getFilter ()->SetInputConnection (m_contours->GetOutputPort ());
778
815
contours.source = m_contours;
779
816
contours.target = smoothExtension.getFilter ();
780
817
addFilterPipeline (contours, " contours" );
818
+ printf (" Aca\n " );
781
819
setActiveFilterPipeline (" contours" );
782
-
783
- smoothExtension.initExtension (this );
820
+ printf (" Aca2\n " );
784
821
}
785
822
786
823
FemPostContoursFilter::~FemPostContoursFilter () = default ;
787
824
788
825
DocumentObjectExecReturn* FemPostContoursFilter::execute ()
789
826
{
827
+ printf (" execute1\n " );
790
828
// update list of available fields and their vectors
791
829
if (!m_blockPropertyChanges) {
830
+ printf (" execute2\n " );
792
831
refreshFields ();
832
+ printf (" execute3\n " );
793
833
refreshVectors ();
834
+ printf (" execute4\n " );
794
835
}
795
836
796
837
// recalculate the filter
797
838
auto returnObject = Fem::FemPostFilter::execute ();
798
839
799
840
// delete contour field
800
841
vtkDataSet* dset = getInputData ();
842
+ printf (" execute5\n " );
801
843
if (!dset) {
844
+ printf (" execute6\n " );
802
845
return returnObject;
803
846
}
804
847
dset->GetPointData ()->RemoveArray (contourFieldName.c_str ());
805
848
// refresh fields to reflect the deletion
806
849
if (!m_blockPropertyChanges) {
850
+ printf (" execute7\n " );
807
851
refreshFields ();
852
+ printf (" execute8\n " );
808
853
}
809
854
810
855
return returnObject;
811
856
}
812
857
813
858
void FemPostContoursFilter::onChanged (const Property* prop)
814
859
{
860
+ printf (" cont1\n " );
815
861
if (m_blockPropertyChanges) {
816
862
return ;
817
863
}
818
864
819
865
if (prop == &Field && (Field.getValue () >= 0 )) {
866
+ printf (" cont2\n " );
820
867
refreshVectors ();
868
+ printf (" cont3\n " );
821
869
}
822
870
823
871
// note that we need to calculate also in case of a Data change
@@ -828,23 +876,30 @@ void FemPostContoursFilter::onChanged(const Property* prop)
828
876
double p[2 ];
829
877
830
878
// get the field and its data
879
+ printf (" cont4\n " );
831
880
vtkDataSet* dset = getInputData ();
832
881
if (!dset) {
833
882
return ;
834
883
}
884
+ printf (" throw2\n " );
835
885
vtkDataArray* pdata = dset->GetPointData ()->GetArray (Field.getValueAsString ());
886
+ printf (" throw2\n " );
836
887
if (!pdata) {
837
888
return ;
838
889
}
839
890
if (pdata->GetNumberOfComponents () == 1 ) {
840
891
// if we have a scalar, we can directly use the array
892
+ printf (" cont5\n " );
893
+ printf (" throw3\n " );
841
894
m_contours->SetInputArrayToProcess (0 ,
842
895
0 ,
843
896
0 ,
844
897
vtkDataObject::FIELD_ASSOCIATION_POINTS,
845
898
Field.getValueAsString ());
899
+ printf (" throw3\n " );
846
900
pdata->GetRange (p);
847
901
recalculateContours (p[0 ], p[1 ]);
902
+ printf (" cont5\n " );
848
903
}
849
904
else {
850
905
// The contour filter handles vectors by taking always its first component.
@@ -862,11 +917,13 @@ void FemPostContoursFilter::onChanged(const Property* prop)
862
917
component = 2 ;
863
918
}
864
919
// extract the component to a new array
920
+ printf (" cont6\n " );
865
921
vtkSmartPointer<vtkDoubleArray> componentArray = vtkSmartPointer<vtkDoubleArray>::New ();
866
922
componentArray->SetNumberOfComponents (1 );
867
923
vtkIdType numTuples = pdata->GetNumberOfTuples ();
868
924
componentArray->SetNumberOfTuples (numTuples);
869
925
926
+ printf (" cont7\n " );
870
927
if (component >= 0 ) {
871
928
for (vtkIdType tupleIdx = 0 ; tupleIdx < numTuples; ++tupleIdx) {
872
929
componentArray->SetComponent (tupleIdx,
@@ -886,9 +943,11 @@ void FemPostContoursFilter::onChanged(const Property* prop)
886
943
}
887
944
}
888
945
// name the array
946
+ printf (" cont8\n " );
889
947
contourFieldName = std::string (Field.getValueAsString ()) + " _contour" ;
890
948
componentArray->SetName (contourFieldName.c_str ());
891
949
950
+ printf (" cont9\n " );
892
951
// add the array as new field and use it for the contour filter
893
952
dset->GetPointData ()->AddArray (componentArray);
894
953
m_contours->SetInputArrayToProcess (0 ,
@@ -897,27 +956,33 @@ void FemPostContoursFilter::onChanged(const Property* prop)
897
956
vtkDataObject::FIELD_ASSOCIATION_POINTS,
898
957
contourFieldName.c_str ());
899
958
componentArray->GetRange (p);
959
+ printf (" cont10\n " );
900
960
recalculateContours (p[0 ], p[1 ]);
901
961
if (prop == &Data) {
902
962
// we must recalculate to pass the new created contours field
903
963
// to ViewProviderFemPostObject
904
964
m_blockPropertyChanges = true ;
905
965
execute ();
906
966
m_blockPropertyChanges = false ;
967
+ printf (" cont11\n " );
907
968
}
908
969
}
909
970
}
971
+ printf (" cont12\n " );
910
972
911
973
Fem::FemPostFilter::onChanged (prop);
912
974
}
913
975
914
976
short int FemPostContoursFilter::mustExecute () const
915
977
{
978
+ printf (" mustExtex1\n " );
916
979
if (Field.isTouched () || VectorMode.isTouched () || NumberOfContours.isTouched ()
917
980
|| Data.isTouched ()) {
981
+ printf (" mustExtex2\n " );
918
982
return 1 ;
919
983
}
920
984
else {
985
+ printf (" mustExtex3\n " );
921
986
return App::DocumentObject::mustExecute ();
922
987
}
923
988
}
@@ -934,6 +999,7 @@ void FemPostContoursFilter::recalculateContours(double min, double max)
934
999
void FemPostContoursFilter::refreshFields ()
935
1000
{
936
1001
m_blockPropertyChanges = true ;
1002
+ printf (" refresh1\n " );
937
1003
938
1004
std::string fieldName;
939
1005
if (Field.getValue () >= 0 ) {
@@ -957,26 +1023,32 @@ void FemPostContoursFilter::refreshFields()
957
1023
App::Enumeration empty;
958
1024
Field.setValue (empty);
959
1025
m_fields.setEnums (FieldsArray);
1026
+ printf (" throw5\n " );
960
1027
Field.setValue (m_fields);
1028
+ printf (" throw5\n " );
961
1029
962
1030
// search if the current field is in the available ones and set it
963
1031
std::vector<std::string>::iterator it =
964
1032
std::find (FieldsArray.begin (), FieldsArray.end (), fieldName);
965
1033
if (!fieldName.empty () && it != FieldsArray.end ()) {
966
1034
Field.setValue (fieldName.c_str ());
967
1035
}
968
- else {
1036
+ else if (Field.isValid ()) {
1037
+ // select the first field if exist
969
1038
m_blockPropertyChanges = false ;
970
- // select the first field
1039
+ printf ( " throw4 \n " );
971
1040
Field.setValue (long (0 ));
1041
+ printf (" throw4\n " );
972
1042
fieldName = Field.getValueAsString ();
973
1043
}
974
1044
1045
+ printf (" refresh2\n " );
975
1046
m_blockPropertyChanges = false ;
976
1047
}
977
1048
978
1049
void FemPostContoursFilter::refreshVectors ()
979
1050
{
1051
+ printf (" refreshvec1\n " );
980
1052
// refreshes the list of available vectors for the current Field
981
1053
m_blockPropertyChanges = true ;
982
1054
@@ -985,16 +1057,21 @@ void FemPostContoursFilter::refreshVectors()
985
1057
m_blockPropertyChanges = false ;
986
1058
return ;
987
1059
}
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 {
990
1065
m_blockPropertyChanges = false ;
991
1066
return ;
992
1067
}
993
1068
994
1069
// store name if already set
995
1070
std::string vectorName;
996
1071
if (VectorMode.hasEnums () && VectorMode.getValue () >= 0 ) {
1072
+ printf (" throw1\n " );
997
1073
vectorName = VectorMode.getValueAsString ();
1074
+ printf (" throw1\n " );
998
1075
}
999
1076
1000
1077
std::vector<std::string> vectorArray;
@@ -1022,6 +1099,7 @@ void FemPostContoursFilter::refreshVectors()
1022
1099
VectorMode.setValue (vectorName.c_str ());
1023
1100
}
1024
1101
1102
+ printf (" refreshvec2\n " );
1025
1103
m_blockPropertyChanges = false ;
1026
1104
}
1027
1105
0 commit comments