#include <vtkPolyDataMapper.h>
#include <vtkPolyData.h>
-using namespace std;
-
-//=======================================================================
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_VectorsAct);
-VISU_VectorsAct::VISU_VectorsAct(){}
+//----------------------------------------------------------------------------
+VISU_VectorsAct
+::VISU_VectorsAct():
+ myVectorsPL(NULL)
+{}
-VISU_VectorsAct::~VISU_VectorsAct(){}
+//----------------------------------------------------------------------------
+VISU_VectorsAct
+::~VISU_VectorsAct()
+{}
-void VISU_VectorsAct::SetPipeLine(VISU_PipeLine* thePipeLine) {
- myPipeLine = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
- VISU_Actor::SetPipeLine(myPipeLine);
- myPipeLine->Delete();
+//----------------------------------------------------------------------------
+void
+VISU_VectorsAct
+::SetPipeLine(VISU_PipeLine* thePipeLine)
+{
+ myVectorsPL = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
+ VISU_Actor::SetPipeLine(myVectorsPL);
+ myVectorsPL->Delete();
}
-void VISU_VectorsAct::SetTransform(VTKViewer_Transform* theTransform){
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_VectorsAct
+::GetInput()
+{
+ return GetCurrentPL()->GetOutput();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_VectorsAct
+::SetTransform(VTKViewer_Transform* theTransform)
+{
Superclass::SetTransform(theTransform);
- myPipeLine->SetTransform(theTransform);
+ myVectorsPL->SetTransform(theTransform);
}
-void VISU_VectorsAct::SetMapper(vtkMapper* theMapper){
+//----------------------------------------------------------------------------
+void
+VISU_VectorsAct
+::SetMapper(vtkMapper* theMapper)
+{
if(theMapper){
myPassFilter[0]->SetInput(theMapper->GetInput());
-
+
myPassFilter[1]->SetInput(myPassFilter[0]->GetPolyDataOutput());
myPassFilter[2]->SetInput(myPassFilter[1]->GetPolyDataOutput());
void Mul(const float A[3], float b, float C[3]); // C = A * b
void Sub(const float A[3], const float B[3], float C[3]); // C = A - B
- template<class TItem> void CellDataToPoint(TItem* theTItem,
- vtkCellDataToPointData *theFilter,
- vtkDataSet* theDataSet,
- VISU_FieldTransform *theFieldTransform)
+ template<class TItem>
+ void
+ CellDataToPoint(TItem* theTItem,
+ vtkCellDataToPointData *theFilter,
+ vtkDataSet* theDataSet,
+ VISU_FieldTransform *theFieldTransform)
{
if(theDataSet->GetCellData()->GetNumberOfArrays()){
theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
}
- template<class TItem> void ToCellCenters(TItem* theTItem,
- vtkCellCenters *theFilter,
- vtkDataSet* theDataSet,
- VISU_FieldTransform *theFieldTransform)
+ template<class TItem>
+ void
+ ToCellCenters(TItem* theTItem,
+ vtkCellCenters *theFilter,
+ vtkDataSet* theDataSet,
+ VISU_FieldTransform *theFieldTransform)
{
if(theDataSet->GetCellData()->GetNumberOfArrays()){
theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
#include <vtkConeSource.h>
#include <vtkLineSource.h>
#include <vtkGlyphSource2D.h>
+#include <vtkPolyData.h>
vtkStandardNewMacro(VISU_VectorsPL);
-VISU_VectorsPL::VISU_VectorsPL(){
- myGlyph = vtkGlyph3D::New();
+VISU_VectorsPL
+::VISU_VectorsPL()
+{
+ myBaseGlyph = vtkGlyph3D::New();
+ myTransformedGlyph = vtkGlyph3D::New();
myGlyphSource = vtkGlyphSource2D::New();
myConeSource = vtkConeSource::New();
myIsShrinkable = false;
}
-VISU_VectorsPL::~VISU_VectorsPL(){
- myGlyph->UnRegisterAllOutputs();
- myGlyph->Delete();
+VISU_VectorsPL
+::~VISU_VectorsPL()
+{
+ myBaseGlyph->Delete();
+ myTransformedGlyph->Delete();
- myCenters->UnRegisterAllOutputs();
myCenters->Delete();
- myGlyphSource->UnRegisterAllOutputs();
myGlyphSource->Delete();
- myConeSource->UnRegisterAllOutputs();
myConeSource->Delete();
- myLineSource->UnRegisterAllOutputs();
myLineSource->Delete();
- myTransformFilter->UnRegisterAllOutputs();
myTransformFilter->Delete();
}
-void VISU_VectorsPL::ShallowCopy(VISU_PipeLine *thePipeLine){
+void
+VISU_VectorsPL
+::ShallowCopy(VISU_PipeLine *thePipeLine)
+{
if(VISU_VectorsPL *aPipeLine = dynamic_cast<VISU_VectorsPL*>(thePipeLine)){
SetGlyphType(aPipeLine->GetGlyphType());
SetGlyphPos(aPipeLine->GetGlyphPos());
}
- VISU_DeformedShapePL::ShallowCopy(thePipeLine);
+ Superclass::ShallowCopy(thePipeLine);
}
-void VISU_VectorsPL::SetTransform(VTKViewer_Transform* theTransform){
+void
+VISU_VectorsPL
+::SetTransform(VTKViewer_Transform* theTransform)
+{
myFieldTransform->SetSpaceTransform(theTransform);
myTransformFilter->SetTransform(theTransform);
myTransformFilter->Modified();
}
-VTKViewer_Transform* VISU_VectorsPL::GetTransform(){
+
+VTKViewer_Transform*
+VISU_VectorsPL
+::GetTransform()
+{
return myFieldTransform->GetSpaceTransform();
}
-void VISU_VectorsPL::SetScale(float theScale) {
- if(myScaleFactor == theScale) return;
+void
+VISU_VectorsPL
+::SetScale(float theScale)
+{
+ if(myScaleFactor == theScale)
+ return;
+
myScaleFactor = theScale;
- myGlyph->SetScaleFactor(myScaleFactor);
+
+ myBaseGlyph->SetScaleFactor(myScaleFactor);
+ myTransformedGlyph->SetScaleFactor(myScaleFactor);
+
Modified();
}
-float VISU_VectorsPL::GetScale() {
- return myGlyph->GetScaleFactor();
+
+float
+VISU_VectorsPL
+::GetScale()
+{
+ return myTransformedGlyph->GetScaleFactor();
}
-void VISU_VectorsPL::Init(){
- VISU_DeformedShapePL::Init();
+void
+VISU_VectorsPL
+::Init()
+{
+ Superclass::Init();
myTypeGlyph = ARROW;
myPosGlyph = TAIL;
}
-VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){
+vtkDataSet*
+VISU_VectorsPL
+::GetOutput()
+{
+ myBaseGlyph->Update();
+ return myBaseGlyph->GetOutput();
+}
+
+
+VISU_ScalarMapPL::THook*
+VISU_VectorsPL
+::DoHook()
+{
+ VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform);
+ myBaseGlyph->SetVectorModeToUseVector();
+ myBaseGlyph->SetScaleModeToScaleByVector();
+ myBaseGlyph->SetColorModeToColorByScalar();
+
VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform);
- myGlyph->SetInput(myTransformFilter->GetOutput());
- myGlyph->SetVectorModeToUseVector();
- myGlyph->SetScaleModeToScaleByVector();
- myGlyph->SetColorModeToColorByScalar();
- return myGlyph->GetOutput();
+ myTransformedGlyph->SetInput(myTransformFilter->GetOutput());
+ myTransformedGlyph->SetVectorModeToUseVector();
+ myTransformedGlyph->SetScaleModeToScaleByVector();
+ myTransformedGlyph->SetColorModeToColorByScalar();
+
+ return myTransformedGlyph->GetOutput();
}
-void VISU_VectorsPL::Update(){
+void
+VISU_VectorsPL
+::Update()
+{
switch (myTypeGlyph) {
case ARROW: {
myGlyphSource->SetGlyphTypeToArrow();
case CENTER:
myGlyphSource->SetCenter(0.0, 0.0, 0.0);
}
-// if(myPosGlyph == TAIL)
-// myGlyphSource->SetCenter(0.5, 0.0, 0.0);
-// else if(myPosGlyph == HEAD)
-// myGlyphSource->SetCenter(-0.5, 0.0, 0.0);
- myGlyph->SetSource(myGlyphSource->GetOutput());
+ myBaseGlyph->SetSource(myGlyphSource->GetOutput());
+ myTransformedGlyph->SetSource(myGlyphSource->GetOutput());
}
break;
case CONE2:
case CENTER:
myConeSource->SetCenter(0.0, 0.0, 0.0);
}
-// if(myPosGlyph == TAIL)
-// myConeSource->SetCenter(0.5, 0.0, 0.0);
-// else if(myPosGlyph == HEAD)
-// myConeSource->SetCenter(-0.5, 0.0, 0.0);
- myGlyph->SetSource(myConeSource->GetOutput());
+ myBaseGlyph->SetSource(myConeSource->GetOutput());
+ myTransformedGlyph->SetSource(myConeSource->GetOutput());
}
break;
case NONE:
default: {
- myGlyph->SetSource(myLineSource->GetOutput());
+ myBaseGlyph->SetSource(myLineSource->GetOutput());
+ myTransformedGlyph->SetSource(myLineSource->GetOutput());
}
}
- VISU_DeformedShapePL::Update();
+ Superclass::Update();
}
-void VISU_VectorsPL::SetMapScale(float theMapScale){
+void
+VISU_VectorsPL
+::SetMapScale(float theMapScale)
+{
VISU_ScalarMapPL::SetMapScale(theMapScale);
- myGlyph->SetScaleFactor(myScaleFactor*theMapScale);
- myGlyph->Modified();
+ myBaseGlyph->SetScaleFactor(myScaleFactor*theMapScale);
+ myTransformedGlyph->SetScaleFactor(myScaleFactor*theMapScale);
+
+ Modified();
}