// File : VISU_FieldTransform.cxx
// Module : VISU
-#include "VISU_FieldTransform.hxx"
-#include "SALOME_Transform.h"
+#include "VISU_FieldTransform.hxx"
+#include "VTKViewer_Transform.h"
#include <vtkObjectFactory.h>
#include <vtkFloatArray.h>
using namespace std;
-#ifdef DEBUG
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
vtkStandardNewMacro(VISU_FieldTransform);
-double VISU_FieldTransform::Ident(double theArg){
+double VISU_FieldTransform::Ident(double theArg){
return theArg;
}
-double VISU_FieldTransform::Log10(double theArg){
+double VISU_FieldTransform::Log10(double theArg){
if(theArg <= 0.0) return -VTK_LARGE_FLOAT;
return log10(theArg);
}
myTransform = NULL;
}
-VISU_FieldTransform::~VISU_FieldTransform() {}
+VISU_FieldTransform::~VISU_FieldTransform() {
+ SetSpaceTransform(NULL);
+}
void VISU_FieldTransform::Update(){
return vtkSource::GetMTime();
}
-void VISU_FieldTransform::SetScalarTransform(TTransformFun theFunction) {
+void VISU_FieldTransform::SetScalarTransform(TTransformFun theFunction) {
myFunction = theFunction;
if(myFunction == NULL) myFunction = &Ident;
Modified();
}
-void VISU_FieldTransform::SetSpaceTransform(SALOME_Transform* theTransform){
+void VISU_FieldTransform::SetSpaceTransform(VTKViewer_Transform* theTransform){
if(myTransform != theTransform){
if (myTransform != NULL) myTransform->UnRegister(this);
myTransform = theTransform;
}
-void VISU_FieldTransform::SetScalarRange(float theScalarRange[2]) {
+void VISU_FieldTransform::SetScalarRange(float theScalarRange[2]) {
myScalarRange[0] = theScalarRange[0];
myScalarRange[1] = theScalarRange[1];
Modified();
SetScalarRange(aScalarRange);
}
+
template<typename TypeData> void
-ExecVectors(VISU_FieldTransform::TTransformFun theFunction,
- SALOME_Transform* theTransform,
- float theScalarRange[2], int theNbComponent,
+ExecVectors(VISU_FieldTransform::TTransformFun theFunction,
+ VTKViewer_Transform* theTransform,
+ float theScalarRange[2], int theNbComponent,
TypeData* theInputData, TypeData* theOutputData)
{
vtkDataArray *inVectors = theInputData->GetVectors();
- if ( !inVectors || theNbComponent < 1 ) return;
+ if ( !inVectors || theNbComponent < 1 ) return;
vtkFloatArray *newVectors = vtkFloatArray::New();
newVectors->SetNumberOfComponents(3);
newVectors->SetNumberOfTuples(theNbComponent);
aScale[1] = theTransform->GetScale()[1];
aScale[2] = theTransform->GetScale()[2];
}
- for (int ptId = 0; ptId < theNbComponent; ptId++) {
- V = inVectors->GetTuple3(ptId);
- vMag = vtkMath::Norm(V);
- vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag;
- if(vMag <= 0.0) vMag = 0.0;
- v[0] = V[0]*vMag*aScale[0];
- v[1] = V[1]*vMag*aScale[1];
- v[2] = V[2]*vMag*aScale[2];
- newVectors->SetTuple3(ptId, v[0], v[1], v[2]);
+ if(theFunction == &(VISU_FieldTransform::Ident)){
+ for (int ptId = 0; ptId < theNbComponent; ptId++) {
+ V = inVectors->GetTuple3(ptId);
+ v[0] = V[0]*aScale[0];
+ v[1] = V[1]*aScale[1];
+ v[2] = V[2]*aScale[2];
+ newVectors->SetTuple3(ptId, v[0], v[1], v[2]);
+ }
+ }else{
+ for (int ptId = 0; ptId < theNbComponent; ptId++) {
+ V = inVectors->GetTuple3(ptId);
+ vMag = vtkMath::Norm(V);
+ vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag;
+ if(vMag <= 0.0) vMag = 0.0;
+ v[0] = V[0]*vMag*aScale[0];
+ v[1] = V[1]*vMag*aScale[1];
+ v[2] = V[2]*vMag*aScale[2];
+ newVectors->SetTuple3(ptId, v[0], v[1], v[2]);
+ }
}
theOutputData->SetVectors(newVectors);
newVectors->Delete();
int theNbComponent, TypeData* theInputData, TypeData* theOutputData)
{
vtkDataArray *inScalars = theInputData->GetScalars();
- if ( !inScalars || theNbComponent < 1 )
- return;
+ if ( !inScalars || theNbComponent < 1 )
+ return;
vtkFloatArray *newScalars = vtkFloatArray::New();
newScalars->SetNumberOfComponents(1);
newScalars->SetNumberOfTuples(theNbComponent);