#include "vtkTensorsVisu.h"
#include "vtkProperty.h"
+#include "vtkFloatArray.h"
+
//------------------------------------------------------------------------
vtkTensorsVisu::vtkTensorsVisu() : vtkVectorsTensorsVisuBase()
superquadratic->SetThetaResolution(20);
superquadratic->SetPhiResolution(20);
tg->SetSource(superquadratic->GetOutput());
+superquadratic->Print( std::cout );
+
} else if(GetTypeForm()==1) { // source sphere
tg->SetSource(ss->GetOutput());
+ss->Print( std::cout );
} else { // source cube
tg->SetSource(cs->GetOutput());
+cs->Print( std::cout );
}
+//GetDataObject()->Print( std::cout );
+
+
tg->SetInput( GetDataObject() );
// tg->ScalingOn();
// tg->SetScaling(25);
//if(isfromcal)
tg->SetScaleFactor( GetScaleFactor() );
- tg->ScalingOn( );
+//EED04
+// tg->ScalingOn( );
+
//else
// //tg->SetScaleFactor(2);
// tg->SetScaleFactor(scale_factor);
//=====================================
_pdm->SetInput( pdn->GetOutput() );
- _pdm->ImmediateModeRenderingOn();
- _pdm->ScalarVisibilityOn();
- _pdm->SetScalarModeToUsePointFieldData();
+//EED04
+// _pdm->ImmediateModeRenderingOn();
+// _pdm->ScalarVisibilityOn();
+// _pdm->SetScalarModeToUsePointFieldData();
+
+
+
+// _pdm->SetScalarModeToUseFieldData();
+// _pdm->SetScalarModeToUseCellFieldData();
+// _pdm->SetScalarModeToUsePointFieldData();
+// _pdm->SetScalarModeToUseCellData();
+// _pdm->SetScalarModeToUsePointData();
+// _pdm->SetScalarModeToDefault();
+
//EED _pdm->Update();
_actor->SetMapper( _pdm );
_actor->GetProperty()->SetOpacity( GetOpacity() );
- tg->ColorGlyphsOn();
+//EED04.1
+// tg->ColorGlyphsOff();
+// tg->Update();
+// vtkDataArray* s = tg->GetOutput()->GetPointData()->GetScalars();
+// if (s) _pdm->SetScalarRange( s->GetRange() );
+
+
+//EED04.2
+// tg->ExtractEigenvaluesOff();
+// tg->Update();
+// vtkDataArray* s = tg->GetOutput()->GetPointData()->GetScalars();
+// if (s) _pdm->SetScalarRange( s->GetRange() );
+
+//EED04.3
+// tg->SetColorModeToEigenvalues();
+// tg->ThreeGlyphsOn();
+// tg->Update();
+// vtkDataArray* s = tg->GetOutput()->GetPointData()->GetScalars();
+// if (s) _pdm->SetScalarRange( s->GetRange() );
+
+//EED04.4
+ tg->SetColorModeToEigenvalues();
+// tg->SetColorModeToScalars();
+// tg->ThreeGlyphsOn();
+// tg->SymmetricOn();
+ tg->Update();
+// vtkDataArray* s = tg->GetOutput()->GetPointData()->GetScalars();
+// if (s) _pdm->SetScalarRange( s->GetRange() );
+
+
+//EED03
+// tg->ColorGlyphsOn();
// tg->ExtractEigenvaluesOn();
- tg->SetColorModeToEigenvalues();
+// tg->SetColorModeToEigenvalues();
+
- _pdm->SetLookupTable( _LutEED );
- _pdm->SelectColorArray( "Normals" );
+//EED02
+// tg->ColorGlyphsOff();
+// tg->ThreeGlyphsOff();
+// tg->ExtractEigenvaluesOff();
+// tg->Update();
+
+//EED01
+// _pdm->SetLookupTable( _LutEED );
+// _pdm->SelectColorArray( "Normals" );
//int tcg = tg->GetColorGlyphs();
//EED1 pd->Print( std::cout );
- tg->Update();
- vtkPolyData *pd = pdn->GetOutput();
- vtkPointData *pointdata = pd->GetPointData();
+ tg->Update();
+ vtkPolyData *pd_pdn = pdn->GetOutput();
+ vtkPointData *pointdata_pdn = pd_pdn->GetPointData();
+
+ vtkPolyData *pd_tg = tg->GetOutput();
+ vtkPointData *pointdata_tg = pd_tg->GetPointData();
+
+ vtkPolyData *pd_do = (vtkPolyData*)GetDataObject();
+ vtkPointData *pointdata_do = pd_do->GetPointData();
//EED1 printf("EED vtkTensorsVisu::Process XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx\n");
//EED1 pointdata->Print( std::cout );
+/*
+ int aa = pd_tg->GetNumberOfPieces ();
+ int bb = pd_tg->GetNumberOfVerts ();
+ int cc = pd_tg->GetNumberOfLines ();
+ int dd = pd_tg->GetNumberOfPolys ();
+ int ee = pd_tg->GetNumberOfStrips ();
+ int ff = pd_tg->GetNumberOfCells();
+
+ printf("EED vtkTensorsVisu::Process pd_tg %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
- int aa = pd->GetNumberOfPieces ();
- int bb = pd->GetNumberOfVerts ();
- int cc = pd->GetNumberOfLines ();
- int dd = pd->GetNumberOfPolys ();
- int ee = pd->GetNumberOfStrips ();
- int ff = pd->GetNumberOfCells();
- printf("EED vtkTensorsVisu::Process %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
+ aa = pd_pdn->GetNumberOfPieces ();
+ bb = pd_pdn->GetNumberOfVerts ();
+ cc = pd_pdn->GetNumberOfLines ();
+ dd = pd_pdn->GetNumberOfPolys ();
+ ee = pd_pdn->GetNumberOfStrips ();
+ ff = pd_pdn->GetNumberOfCells();
+
+// printf("EED vtkTensorsVisu::Process pd_pdn %d %d %d %d %d %d \n", aa,bb,cc,dd,ee,ff);
+*/
vtkPolyData *ttt = (vtkPolyData *)GetDataObject();
int numPnts = ttt->GetNumberOfPoints();
- printf("EED vtkTensorsVisu::Process numPnts %d \n", numPnts );
-
+// printf("EED vtkTensorsVisu::Process numPnts %d \n", numPnts );
vtkIdType numSourcePts, numSourceCells;
vtkPoints *sourcePts;
sourcePts = tg->GetSource()->GetPoints();
numSourcePts = sourcePts->GetNumberOfPoints();
numSourceCells = tg->GetSource()->GetNumberOfCells();
- printf("EED vtkTensorsVisu::Process numSourcePts %d numSourceCells %d\n", numSourcePts, numSourceCells);
+// printf("EED vtkTensorsVisu::Process numSourcePts %d numSourceCells %d\n", numSourcePts, numSourceCells);
+
+ vtkDataArray *tensorsArray = pointdata_do->GetArray("tensors");
+ if (tensorsArray)
+ {
+ vtkFloatArray *newScalarArray = vtkFloatArray::New();
+ newScalarArray->SetName( "NormalsEED" );
+ newScalarArray->SetNumberOfComponents(3);
+ int iNumPts,iNumSourcePts;
+ int iNormalsEED=0;
+ double *normalValue;
+ double sumEigenvalue,sumEigenvalue1,sumEigenvalue2,sumEigenvalue3;
+ double dirx,diry,dirz;
+ int idEigen;
+ for (iNumPts=0;iNumPts<numPnts;iNumPts++)
+ {
+ normalValue = tensorsArray->GetTuple9(iNumPts);
+ sumEigenvalue1 = sqrt (normalValue[0]*normalValue[0] + normalValue[1]*normalValue[1] + normalValue[2]*normalValue[2]);
+ sumEigenvalue2 = sqrt (normalValue[3]*normalValue[3] + normalValue[4]*normalValue[4] + normalValue[5]*normalValue[5]);
+ sumEigenvalue3 = sqrt (normalValue[6]*normalValue[6] + normalValue[7]*normalValue[7] + normalValue[8]*normalValue[8]);
+
+ if ((sumEigenvalue1>=sumEigenvalue2) && (sumEigenvalue1>=sumEigenvalue3))
+ {
+ sumEigenvalue=sumEigenvalue1;
+ idEigen=0;
+ }
+ if ((sumEigenvalue2>sumEigenvalue1) && (sumEigenvalue2>=sumEigenvalue3))
+ {
+ sumEigenvalue=sumEigenvalue2;
+ idEigen=3;
+ }
+ if ((sumEigenvalue3>=sumEigenvalue1) && (sumEigenvalue3>=sumEigenvalue2))
+ {
+ sumEigenvalue=sumEigenvalue3;
+ idEigen=6;
+ }
+
+ dirx = fabs(normalValue[idEigen+0]/sumEigenvalue);
+ diry = fabs(normalValue[idEigen+1]/sumEigenvalue);
+ dirz = fabs(normalValue[idEigen+2]/sumEigenvalue);
+//printf("%f %f %f\n",dirx, diry,dirz );
+//printf("%f %f %f\n",sumEigenvalue1, sumEigenvalue2, sumEigenvalue3 );
+//printf("%f %f %f\n", normalValue[0], normalValue[1], normalValue[2] );
+
+
+ for (iNumSourcePts=0;iNumSourcePts<numSourcePts;iNumSourcePts++)
+ {
+ newScalarArray->InsertTuple3( iNormalsEED, dirx,diry,dirz );
+ iNormalsEED++;
+ } // for iNumSourcePts
+
+ }
+ pointdata_tg->RemoveArray( "NormalsEED" );
+ pointdata_tg->AddArray( newScalarArray );
+ pointdata_pdn->Update();
+ tg->Update();
+ }
+
+ _LutEED->SetVectorModeToRGBColors();
+ _pdm->SetLookupTable( _LutEED );
+ _pdm->SelectColorArray( "NormalsEED" );
- int i,sizeDa = pointdata->GetNumberOfArrays();
+
+
+_pdm->ScalarVisibilityOn();
+_pdm->SetColorModeToMapScalars();
+// _pdm->SetColorModeToDirectScalars(); // NOT compile
+_pdm->SetScalarModeToUsePointFieldData();
+_pdm->ImmediateModeRenderingOn();
+
+/*
+ int i,sizeDa = pointdata_tg->GetNumberOfArrays();
printf("EED vtkTensorsVisu::Process sizeDa %d \n", sizeDa );
for (i=0;i<sizeDa;i++)
{
- int faces = pointdata->GetArray(i)->GetSize() / numPnts;
- printf("EED vtkTensorsVisu::Process-name %d, %s, size=%d %d \n", i, pointdata->GetArrayName(i) , pointdata->GetArray(i)->GetSize(), faces );
+ int faces = pointdata_tg->GetArray(i)->GetSize() / numPnts;
+//pointdata_pdn->GetArray(i)->Print( std::cout );
+ printf("EED vtkTensorsVisu::Process-name %d, %s, size=%d %d \n", i, pointdata_tg->GetArrayName(i) , pointdata_tg->GetArray(i)->GetSize(), faces );
+
}
+*/