CPPFLAGS+= $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+= $(VTK_LIBS) -lSalomeVTKFilter -lVisuConvertor \
- -L${KERNEL_ROOT_DIR}/lib/salome
+ -L${KERNEL_ROOT_DIR}/lib/salome
@CONCLUDE@
#include "VISU_VectorsPL.hxx"
#include "VISU_StreamLinesPL.hxx"
-typedef VISU_StreamLinesPL TPresent;
+typedef VISU_ScalarMapPL TPresent;
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
aPresent->SetInput(aDataSet);
aPresent->Build();
aPresent->Init();
+ aPresent->SetSourceRange();
//aPresent->SetPartDefault(0);
//aPresent->SetScalarMin(0.01);
//aPresent->SetScaling(VTK_SCALE_LOG10);
void VISU_CutLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
VISU_CutPlanesPL::ShallowCopy(thePipeLine);
if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
- SetPlaneOrientation(aPipeLine->GetPlaneOrientation(1),1);
+ SetOrientation(aPipeLine->GetPlaneOrientation(1),
+ aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
SetDisplacement(aPipeLine->GetDisplacement(1),1);
SetDefault();
if (!aPipeLine->IsDefault()) SetPosition(aPipeLine->GetPosition());
- SetRotateX(aPipeLine->GetRotateX(1),1);
- SetRotateY(aPipeLine->GetRotateY(1),1);
}
}
void VISU_CutPlanesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
VISU_ScalarMapPL::ShallowCopy(thePipeLine);
if(VISU_CutPlanesPL *aPipeLine = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine)){
- SetPlaneOrientation(aPipeLine->GetPlaneOrientation());
+ SetOrientation(aPipeLine->GetPlaneOrientation(),
+ aPipeLine->GetRotateX(),aPipeLine->GetRotateY());
SetDisplacement(aPipeLine->GetDisplacement());
SetNbParts(aPipeLine->GetNbParts());
for (int i = 0, iend = GetNbParts(); i < iend; i++)
if(!aPipeLine->IsPartDefault(i)) SetPartPosition(i, aPipeLine->GetPartPosition(i));
- SetRotateX(aPipeLine->GetRotateX());
- SetRotateY(aPipeLine->GetRotateY());
}
}
BoundPrj[2] = BoundPrj[1] - BoundPrj[0];
}
-void VISU_CutPlanesPL::SetRotateX(float theAng, int theNum){
+
+void VISU_CutPlanesPL::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient,
+ float theXAng, float theYAng, int theNum)
+{
+ myBasePlane[theNum] = theOrient;
+ switch(myBasePlane[theNum]){
+ case XY: myAng[theNum][0] = theXAng; break;
+ case YZ: myAng[theNum][1] = theXAng; break;
+ case ZX: myAng[theNum][2] = theXAng; break;
+ }
switch(myBasePlane[theNum]){
- case XY: myAng[theNum][0] = theAng; break;
- case YZ: myAng[theNum][1] = theAng; break;
- case ZX: myAng[theNum][2] = theAng; break;
+ case XY: myAng[theNum][1] = theYAng; break;
+ case YZ: myAng[theNum][2] = theYAng; break;
+ case ZX: myAng[theNum][0] = theYAng; break;
}
}
+
+const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL::GetPlaneOrientation(int theNum){
+ return myBasePlane[theNum];
+}
+
float VISU_CutPlanesPL::GetRotateX(int theNum){
switch(myBasePlane[theNum]){
case XY: return myAng[theNum][0];
}
}
-void VISU_CutPlanesPL::SetRotateY(float theAng, int theNum){
- switch(myBasePlane[theNum]){
- case XY: myAng[theNum][1] = theAng; break;
- case YZ: myAng[theNum][2] = theAng; break;
- case ZX: myAng[theNum][0] = theAng; break;
- }
-}
-
float VISU_CutPlanesPL::GetRotateY(int theNum){
switch(myBasePlane[theNum]){
case XY: return myAng[theNum][1];
virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
enum PlaneOrientation {XY, YZ, ZX};
- virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0) { return myBasePlane[theNum];}
- virtual void SetPlaneOrientation(const PlaneOrientation& theOrient, int theNum = 0) {
- myBasePlane[theNum] = theOrient;
- }
+ virtual void SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient,
+ float theXAng, float theYAng, int theNum = 0);
+ virtual const PlaneOrientation& GetPlaneOrientation(int theNum = 0);
+ virtual float GetRotateX(int theNum = 0);
+ virtual float GetRotateY(int theNum = 0);
+
virtual float GetDisplacement(int theNum = 0) { return myDisplacement[theNum];}
virtual void SetDisplacement(float theDisp, int theNum = 0) { myDisplacement[theNum] = theDisp;}
virtual void SetPartDefault(int thePartNumber);
virtual int IsPartDefault(int thePartNumber);
- virtual void SetRotateX(float theAngle, int theNum = 0);
- virtual float GetRotateX(int theNum = 0);
- virtual void SetRotateY(float theAngle, int theNum = 0);
- virtual float GetRotateY(int theNum = 0);
-
virtual void SetNbParts(int theNb);
virtual int GetNbParts(){ return myNbParts;}
VISU_DeformedShapePL::VISU_DeformedShapePL(){
myWarpVector = vtkWarpVector::New();
+ myCellDataToPointData = vtkCellDataToPointData::New();
}
VISU_DeformedShapePL::~VISU_DeformedShapePL(){
+ myWarpVector->UnRegisterAllOutputs();
myWarpVector->Delete();
+
+ myCellDataToPointData->UnRegisterAllOutputs();
+ myCellDataToPointData->Delete();
}
void VISU_DeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){
}
VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){
- VISU::CellDataToPoint(myWarpVector,myInput,myFieldTransform);
+ VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,myInput,myFieldTransform);
return myWarpVector->GetOutput();
}
#include "VISU_ScalarMapPL.hxx"
+class vtkCellDataToPointData;
class SALOME_Transform;
class vtkWarpVector;
protected:
virtual THook* DoHook();
- vtkWarpVector *myWarpVector;
float myScaleFactor;
+ vtkWarpVector *myWarpVector;
+ vtkCellDataToPointData* myCellDataToPointData;
};
// Module : VISU
#include "VISU_Extractor.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+#include <sstream>
#include <vtkObjectFactory.h>
#include <vtkUnstructuredGrid.h>
using namespace std;
-#ifdef DEBUG
+#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
myScalarMode = 0;
}
-VISU_Extractor::~VISU_Extractor() {}
+VISU_Extractor::~VISU_Extractor(){
+}
void VISU_Extractor::SetScalarMode(int theScalarMode){
if(myScalarMode != theScalarMode){
if ( !inVectors || theNbComp < 1 )
return;
vtkFloatArray *newScalars = vtkFloatArray::New();
- //newScalars->SetName(inVectors->GetName());
+ ostringstream aName;
+ aName<<inVectors->GetName(); aName<<", "; aName<<theScalarMode;
+ newScalars->SetName(aName.str().c_str());
newScalars->SetNumberOfComponents(1);
newScalars->SetNumberOfTuples(theNbComp);
for (int ptId = 0; ptId < theNbComp; ptId++) {
public:
vtkTypeMacro(VISU_Extractor,vtkPointSetToPointSetFilter);
static VISU_Extractor *New();
- ~VISU_Extractor();
virtual int GetScalarMode(){ return myScalarMode;}
virtual void SetScalarMode(int theScalarMode = 0);
protected:
VISU_Extractor();
VISU_Extractor(const VISU_Extractor&);
+ ~VISU_Extractor();
virtual void Execute();
myTransform = NULL;
}
-VISU_FieldTransform::~VISU_FieldTransform() {}
+VISU_FieldTransform::~VISU_FieldTransform() {
+ SetSpaceTransform(NULL);
+}
void VISU_FieldTransform::Update(){
SetScalarRange(aScalarRange);
}
+
template<typename TypeData> void
ExecVectors(VISU_FieldTransform::TTransformFun theFunction,
SALOME_Transform* theTransform,
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();
#include <vtkContourFilter.h>
-VISU_IsoSurfacesPL* VISU_IsoSurfacesPL::New(){
- vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_IsoSurfacesPL");
- if(ret) return (VISU_IsoSurfacesPL*)ret;
- return new VISU_IsoSurfacesPL;
-}
+vtkStandardNewMacro(VISU_IsoSurfacesPL);
VISU_IsoSurfacesPL::VISU_IsoSurfacesPL(){
myContourFilter = vtkContourFilter::New();
+ myCellDataToPointData = vtkCellDataToPointData::New();
}
VISU_IsoSurfacesPL::~VISU_IsoSurfacesPL(){
+ myContourFilter->UnRegisterAllOutputs();
myContourFilter->Delete();
+
+ myCellDataToPointData->UnRegisterAllOutputs();
+ myCellDataToPointData->Delete();
}
void VISU_IsoSurfacesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
void VISU_IsoSurfacesPL::Update(){
- VISU::CellDataToPoint(myContourFilter,myInput,myFieldTransform);
+ VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,myInput,myFieldTransform);
SetMapScale();
VISU_ScalarMapPL::Update();
#include "VISU_ScalarMapPL.hxx"
class vtkContourFilter;
+class vtkCellDataToPointData;
class VISU_IsoSurfacesPL : public VISU_ScalarMapPL{
protected:
protected:
int myNbParts;
float myRange[2];
+ vtkCellDataToPointData* myCellDataToPointData;
vtkContourFilter *myContourFilter;
};
#include "VISU_PipeLine.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+#include <limits.h>
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
+static int MYVTKDEBUG = 0;
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
VISU_PipeLine::VISU_PipeLine(){
myMapper = TMapper::New();
myInput = NULL;
+ SetDebug(MYVTKDEBUG);
}
VISU_PipeLine::~VISU_PipeLine(){
- myMapper->Delete();
+ if(MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<<myInput->GetReferenceCount());
SetInput(NULL);
+ myMapper->RemoveAllInputs();
+ myMapper->Delete();
}
void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
}
void VISU_PipeLine::SetInput(TInput* theInput){
- if (myInput != theInput){
+ if(myInput != theInput){
if (myInput != NULL) myInput->UnRegister(this);
myInput = theInput;
- if (myInput != NULL) {
+ if(myInput != NULL){
myInput->Register(this);
myInput->Update();
- }
+ }else
+ myMapper->SetInput(NULL);
Modified();
}
}
}
-size_t VISU_PipeLine::CheckAvailableMemory(const size_t& theSize){
+int VISU_PipeLine::CheckAvailableMemory(const float& theSize){
try{
- char *aCheck = new char[theSize];
+ if(theSize > ULONG_MAX) return 0;
+ size_t aSize = size_t(theSize);
+ char *aCheck = new char[aSize];
if(aCheck) delete [] aCheck;
if(MYDEBUG && aCheck == NULL)
- cout<<"VISU_PipeLine::CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!\n";
+ MESSAGE("CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!");
return aCheck != NULL;
//return theSize < 1000*1024*1024;
}catch(...){
if(MYDEBUG)
- cout<<"VISU_PipeLine::CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!\n";
+ MESSAGE("CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!");
}
return 0;
}
-size_t VISU_PipeLine::GetAvailableMemory(size_t theSize, size_t theMinSize){
+float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize){
while(!CheckAvailableMemory(theSize))
if(theSize > theMinSize)
theSize /= 2;
virtual void Init() = 0;
virtual void Update();
- static size_t CheckAvailableMemory(const size_t& theSize);
- static size_t GetAvailableMemory(size_t theSize = 16*1024*1024,
- size_t theMinSize = 1024*1024);
+ static int CheckAvailableMemory(const float& theSize);
+ static float GetAvailableMemory(float theSize = 16*1024*1024.0,
+ float theMinSize = 1024*1024.0);
protected:
virtual void Build() = 0;
#include <vtkMath.h>
+#ifndef MESSAGE
+#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"<<msg<<endl
+
+#undef EXCEPT
+#define EXCEPT(msg) QString(QString(__FILE__) + "[" + QString::number(__LINE__) + "]::" + msg)
+
+#undef EXCEPTION
+#define EXCEPTION(msg) EXCEPT(msg).latin1()
+
+#endif
+
namespace VISU{
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, vtkDataSet* theDataSet,
+ template<class TItem> void CellDataToPoint(TItem* theTItem,
+ vtkCellDataToPointData *theFilter,
+ vtkDataSet* theDataSet,
VISU_FieldTransform *theFieldTransform)
{
if(theDataSet->GetCellData()->GetNumberOfArrays()){
- vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
- aFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
- aFilter->PassCellDataOn();
- theTItem->SetInput(aFilter->GetUnstructuredGridOutput());
- aFilter->Register(theTItem);
- aFilter->Delete();
+ theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theFilter->PassCellDataOn();
+ theTItem->SetInput(theFilter->GetUnstructuredGridOutput());
}else
theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
}
- template<class TItem> void ToCellCenters(TItem* theTItem, vtkDataSet* theDataSet,
+ template<class TItem> void ToCellCenters(TItem* theTItem,
+ vtkCellCenters *theFilter,
+ vtkDataSet* theDataSet,
VISU_FieldTransform *theFieldTransform)
{
if(theDataSet->GetCellData()->GetNumberOfArrays()){
- vtkCellCenters *aCenters = vtkCellCenters::New(); // for vectors on cells
- aCenters->SetInput(theFieldTransform->GetUnstructuredGridOutput());
- aCenters->VertexCellsOn();
- theTItem->SetInput(aCenters->GetOutput());
- aCenters->Register(theTItem);
- aCenters->Delete();
+ theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theFilter->VertexCellsOn();
+ theTItem->SetInput(theFilter->GetOutput());
}else
theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
}
VISU_ScalarMapPL::VISU_ScalarMapPL(){
myFieldTransform = VISU_FieldTransform::New();
+ //myFieldTransform->DebugOn();
myMapperTable = VISU_LookupTable::New();
myMapperTable->SetScale(VTK_SCALE_LINEAR);
myBarTable->SetHueRange(0.667,0.0);
myExtractor = VISU_Extractor::New();
+ //myExtractor->DebugOn();
}
VISU_ScalarMapPL::~VISU_ScalarMapPL(){
+ myFieldTransform->UnRegisterAllOutputs();
myFieldTransform->Delete();
myMapperTable->Delete();;
myBarTable->Delete();
+ myExtractor->UnRegisterAllOutputs();
myExtractor->Delete();
}
myMapper->SetLookupTable(myMapperTable);
myMapper->SetScalarRange(aScalarRange);
- myFieldTransform->Update();
-
VISU_PipeLine::Update();
}
#include "VISU_UsedPointsFilter.hxx"
#include "SALOME_GeometryFilter.h"
+#include <algo.h>
+
+#include <vtkCell.h>
#include <vtkPointSet.h>
#include <vtkStreamLine.h>
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
-static float EPS = 1.0e-20;
-int VISU_StreamLinesPL::myMaxIncrementMemorySize = 64;
-
-void SetStreamerSource(vtkStreamer *theStreamer, vtkPointSet* theDataSet, float thePercents){
- theDataSet->Update();
- VISU_UsedPointsFilter* anUsedPointsFilter = VISU_UsedPointsFilter::New();
- anUsedPointsFilter->SetInput(theDataSet);
- anUsedPointsFilter->SetPercentsOfUsedPoints(thePercents);
- theStreamer->SetSource(anUsedPointsFilter->GetOutput());
- anUsedPointsFilter->Register(theStreamer);
- anUsedPointsFilter->Delete();
-}
+static float EPS = 1.0e-7;
+static float aMinNbOfSteps = 1.0E+2;
+static float aMaxNbOfSteps = 1.0E+3;
+static float aCoeffOfIntStep = 1.0E+1;
vtkStandardNewMacro(VISU_StreamLinesPL);
VISU_StreamLinesPL::VISU_StreamLinesPL(){
myStream = vtkStreamLine::New();
+ myCenters = vtkCellCenters::New();
myGeomFilter = SALOME_GeometryFilter::New();
+ myPointsFilter = VISU_UsedPointsFilter::New();
+ myPercents = 0.3;
mySource = NULL;
}
VISU_StreamLinesPL::~VISU_StreamLinesPL(){
- myStream->Delete();
+ myPointsFilter->UnRegisterAllOutputs();
+ myPointsFilter->Delete();
+
+ myCenters->UnRegisterAllOutputs();
+ myCenters->Delete();
+
+ myGeomFilter->UnRegisterAllOutputs();
myGeomFilter->Delete();
- SetSource(NULL);
+
+ myStream->UnRegisterAllOutputs();
+ myStream->Delete();
}
void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
VISU_DeformedShapePL::ShallowCopy(thePipeLine);
- if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine)){
+ if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine))
+ SetParams(aPipeLine->GetIntegrationStep(),
+ aPipeLine->GetPropagationTime(),
+ aPipeLine->GetStepLength(),
+ aPipeLine->GetSource(),
+ aPipeLine->GetUsedPoints(),
+ aPipeLine->GetDirection());
+}
+
- //Order of setting of the values are important
- SetUsedPoints(aPipeLine->GetUsedPoints());
- SetSource(aPipeLine->GetSource());
+float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength,
+ float thePropogationTime, float thePercents)
+{
+ static float aStreamPointSize = sizeof(float)*15 + sizeof(vtkIdType)*2;
+ static float aStreamArraySize = aStreamPointSize*1024; // == 69632
- SetDirection(aPipeLine->GetDirection());
+ float aNbCells = thePercents*theNbOfPoints*2.0;
+ float aNbPointsPerCell = thePropogationTime/theStepLength;
+ float aCellsSize = aNbCells*(1+aNbPointsPerCell);
+ float aPointsSize = aCellsSize*3.0*sizeof(float);
- //Order of setting of the values are important
- SetIntegrationStep(aPipeLine->GetIntegrationStep());
- SetPropagationTime(aPipeLine->GetPropagationTime());
- SetStepLength(aPipeLine->GetStepLength());
+ float aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+ float aTypesSize = aNbCells*sizeof(char);
+ float aLocationsSize = aNbCells*sizeof(int);
+ float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+ float aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize;
+
+ float anAssignedDataSize = aCellsSize*4.0*sizeof(float);
+ float anOutputDataSetSize = aMeshSize + anAssignedDataSize;
+
+ float aResult = aStreamArraySize*aNbCells + anOutputDataSetSize;
+ return aResult;
+}
+
+int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength,
+ float& thePropogationTime, float& thePercents)
+{
+ static float aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0;
+ vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
+ float aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+ int isPoss = CheckAvailableMemory(aSize);
+ if(!isPoss){
+ float aMaxStepLength = max(GetMaxStepLength(theDataSet),thePropogationTime);
+ float aMinStepLength = GetMinStepLength(theDataSet);
+ float aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
+ for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){
+ float aStepLength = theStepLength + aDeltaStepLength;
+ if(aStepLength < aMaxStepLength) theStepLength = aStepLength;
+ else if(aStepChanged){
+ aStepLength = aMaxStepLength;
+ aStepChanged = 0;
+ }
+ float aPercents = thePercents /= aPercentsDecrease;
+ if(aPercents*aNbOfPoints > 1) thePercents = aPercents;
+ else if(aPerecentsChanged) {
+ thePercents = 1.1 / aNbOfPoints;
+ aPerecentsChanged = 0;
+ }
+ aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+ if(CheckAvailableMemory(aSize)){
+ isPoss = i;
+ break;
+ }
+ }
}
+ if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<<aSize<<"; isPoss = "<<isPoss);
+ return isPoss;
}
-void VISU_StreamLinesPL::SetSource(vtkPointSet* theSource){
- if (mySource != NULL) mySource->UnRegister(this);
- mySource = theSource;
- if (mySource != NULL) mySource->Register(this);
- if(myInput && myInput->GetCellData()->GetNumberOfArrays()){
- vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
- aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
- aFilter->PassCellDataOn();
- myStream->SetInput(aFilter->GetOutput());
- aFilter->Register(myStream);
- aFilter->Delete();
- vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells
- centers->SetInput(myFieldTransform->GetUnstructuredGridOutput());
- centers->VertexCellsOn();
- mySource = mySource? mySource: centers->GetOutput();
- SetStreamerSource(myStream,mySource,myPercents);
- centers->Register(myStream);
- centers->Delete();
- }else{
- myStream->SetInput(myFieldTransform->GetUnstructuredGridOutput());
- mySource = mySource? mySource: myFieldTransform->GetUnstructuredGridOutput();
- SetStreamerSource(myStream,mySource,myPercents);
+
+int VISU_StreamLinesPL::SetParams(float theIntStep,
+ float thePropogationTime,
+ float theStepLength,
+ vtkPointSet* theSource,
+ float thePercents,
+ int theDirection,
+ int isOnlyTry)
+{
+ vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput();
+ aDataSet->Update();
+ vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints();
+ vtkPointSet* aPointSet = myExtractor->GetOutput();
+ if(thePercents*aNbOfPoints < 1) thePercents = 2.0/aNbOfPoints;
+ theIntStep = CorrectIntegrationStep(theIntStep,aPointSet,thePercents);
+ thePropogationTime = CorrectPropagationTime(thePropogationTime,aPointSet);
+ theStepLength = CorrectStepLength(theStepLength,aPointSet);
+ int isAccepted = FindPossibleParams(aPointSet,theStepLength,thePropogationTime,thePercents);
+ if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
+ mySource = theSource;
+ myPercents = thePercents;
+ if(myInput->GetCellData()->GetNumberOfArrays()){
+ myCenters->SetInput(aDataSet);
+ myCenters->VertexCellsOn();
+ aDataSet = myCenters->GetOutput();
+ }
+ myPointsFilter->SetInput(aDataSet);
+ myPointsFilter->SetPercentsOfUsedPoints(thePercents);
+ aDataSet = myPointsFilter->GetOutput();
+ myStream->SetSource(aDataSet);
+ myStream->SetIntegrationStepLength(theIntStep);
+ myStream->SetMaximumPropagationTime(thePropogationTime);
+ myStream->SetStepLength(theStepLength);
+ myStream->SetSavePointInterval(theIntStep*aMinNbOfSteps);
+ myStream->SetIntegrationDirection(theDirection);
+ myStream->Modified();
+ Modified();
}
- myStream->Modified();
- Modified();
+ return isAccepted;
}
-float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
- if(!theDataSet) return 0.0;
- theDataSet->Update();
- float* aBounds = theDataSet->GetBounds();
- float aMaxSizeY = aBounds[3] - aBounds[2];
- float aMaxSizeZ = aBounds[5] - aBounds[4];
- float aMinMax = aBounds[1] - aBounds[0];
- if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
- if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
- return aMinMax / 2.0;
-}
+vtkPointSet* VISU_StreamLinesPL::GetSource() {
+ return mySource;
+}
+
+float VISU_StreamLinesPL::GetUsedPoints() {
+ return myPercents;
+}
+
+vtkDataSet* VISU_StreamLinesPL::GetStreamerSource(){
+ return myStream->GetSource();
+}
+
+float VISU_StreamLinesPL::GetVelocityCoeff(){
+ return GetVelocityCoeff(myExtractor->GetOutput());
+}
+
+float VISU_StreamLinesPL::GetVelocityCoeff(vtkPointSet* theDataSet){
+ float* aScalarRange = theDataSet->GetScalarRange();
+ return (fabs(aScalarRange[1]) + fabs(aScalarRange[0]))/2.0;
+}
+
+
+int VISU_StreamLinesPL::IsPossible(vtkPointSet* theDataSet, float thePercents){
+ float aStepLength = GetBaseStepLength(theDataSet);
+ float aBasePropTime = GetBasePropagationTime(theDataSet);
+ VISU_UsedPointsFilter *aPointsFilter = VISU_UsedPointsFilter::New();
+ aPointsFilter->SetInput(theDataSet);
+ vtkPointSet* aDataSet = aPointsFilter->GetOutput();
+ aDataSet->Update();
+ int aRes = FindPossibleParams(aDataSet,aStepLength,aBasePropTime,thePercents);
+ aPointsFilter->UnRegisterAllOutputs();
+ aPointsFilter->Delete();
+ return aRes;
+}
+
-float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet) {
- if(!theDataSet) return 0.0;
+float VISU_StreamLinesPL::GetIntegrationStep(){
+ return myStream->GetIntegrationStepLength();
+}
+float VISU_StreamLinesPL::GetStepLength() {
+ return myStream->GetStepLength();
+}
+float VISU_StreamLinesPL::GetPropagationTime() {
+ return myStream->GetMaximumPropagationTime();
+}
+int VISU_StreamLinesPL::GetDirection(){
+ return myStream->GetIntegrationDirection();
+}
+
+
+float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents) {
+ if(!theDataSet) return -1.0;
float aVolume = 1.0, tmp;
int degree = 0;
theDataSet->Update();
}
}
if (degree < 1) return 0.0; // absolutely empty object
- unsigned long aSize = 1024*theDataSet->GetActualMemorySize();
- // we have to use no more, than myMaxIncrementMemorySize*aSize amount of memory
- unsigned long aRealSize = GetAvailableMemory(myMaxIncrementMemorySize*aSize);
- if(MYDEBUG) cout<<"GetMinIntegrationStep - GetActualMemorysize() = "<<aRealSize<<"; "<<aSize<<endl;
+ float anStepLength = GetMaxIntegrationStep(theDataSet)/aCoeffOfIntStep;
+ float aBasePropTime = GetBasePropagationTime(theDataSet)/GetVelocityCoeff(theDataSet);
+ thePercents = 1.0;
+ vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
+ float aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
+ float aRealSize = GetAvailableMemory(aSize);
float anAverageVolume = aVolume / aRealSize;
float aStep = pow(double(anAverageVolume), double(1.0/double(degree)));
return aStep;
}
+float VISU_StreamLinesPL::GetMinIntegrationStep(){
+ return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints());
+}
-float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet) {
- if(!theDataSet) return 0.0;
+
+float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
+ if(!theDataSet) return -1.0;
theDataSet->Update();
- float* aScalarRange = theDataSet->GetScalarRange();
- return theDataSet->GetLength()/fabs(aScalarRange[1] + aScalarRange[0])*2.0;
+ float aLength = theDataSet->GetLength();
+ float* aBounds = theDataSet->GetBounds();
+ float aMaxSizeY = (aBounds[3]-aBounds[2])/aLength;
+ float aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength;
+ float aMinMax = (aBounds[1] - aBounds[0])/aLength;
+ if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
+ if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
+ return aMinMax*aLength/2.0;
+}
+float VISU_StreamLinesPL::GetMaxIntegrationStep(){
+ return GetMaxIntegrationStep(myExtractor->GetOutput());
}
-
-int VISU_StreamLinesPL::GetDirection(){
- return myStream->GetIntegrationDirection();
+float VISU_StreamLinesPL::GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents){
+ theDataSet->Update();
+ float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+ float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+ float anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep;
+ float aMinMax = theDataSet->GetLength()/theDataSet->GetNumberOfPoints();
+ if(aMinMax > anIntegrationStep)
+ anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep;
+ if(aMinIntegrationStep > anIntegrationStep)
+ anIntegrationStep = aMinIntegrationStep;
+ return anIntegrationStep;
}
-void VISU_StreamLinesPL::SetDirection(int theDirection){
- myStream->SetIntegrationDirection(theDirection);
- Modified();
+
+float VISU_StreamLinesPL::CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents){
+ theDataSet->Update();
+ float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+ float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+ if(aMinIntegrationStep > theStep)
+ theStep = aMinIntegrationStep;
+ if(aMaxIntegrationStep < theStep)
+ theStep = aMaxIntegrationStep;
+ return theStep;
}
-float VISU_StreamLinesPL::GetPropagationTime() {
- return myStream->GetMaximumPropagationTime();
+float VISU_StreamLinesPL::GetMinPropagationTime(vtkPointSet* theDataSet){
+ if(!theDataSet) return -1.0;
+ return GetMinStepLength(theDataSet);
}
-void VISU_StreamLinesPL::SetPropagationTime(float theTime) {
- if(myStream->GetMaximumPropagationTime() == theTime) return;
- myStream->SetMaximumPropagationTime(theTime);
- Modified();
+float VISU_StreamLinesPL::GetMinPropagationTime(){
+ return GetMinPropagationTime(myExtractor->GetOutput());
}
+float VISU_StreamLinesPL::GetMaxPropagationTime(vtkPointSet* theDataSet){
+ if(!theDataSet) return -1.0;
+ return GetBasePropagationTime(theDataSet)*aMinNbOfSteps;
+}
+float VISU_StreamLinesPL::GetMaxPropagationTime(){
+ return GetMaxPropagationTime(myExtractor->GetOutput());
+}
-float VISU_StreamLinesPL::GetIntegrationStep(){
- return myStream->GetIntegrationStepLength();
+float VISU_StreamLinesPL::CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet){
+ float aMinPropagationTime = GetMinPropagationTime(theDataSet);
+ float aMaxPropagationTime = GetMaxPropagationTime(theDataSet);
+ if(aMinPropagationTime > thePropagationTime)
+ thePropagationTime = aMinPropagationTime;
+ if(aMaxPropagationTime < thePropagationTime)
+ thePropagationTime = aMaxPropagationTime;
+ return thePropagationTime;
}
-float VISU_StreamLinesPL::SetIntegrationStep(float theStep){
- if(myStream->GetIntegrationStepLength() == theStep) return theStep;
- myExtractor->Update();
- vtkPointSet* aDataSet = GetSource();
- aDataSet->Update();
- float anIntegrationStep = theStep;
- float aMinIntegrationStep = GetMinIntegrationStep(aDataSet);
- float aMaxIntegrationStep = GetMaxIntegrationStep(aDataSet);
- if(aMinIntegrationStep < anIntegrationStep && anIntegrationStep < aMaxIntegrationStep){
- myStream->SetIntegrationStepLength(theStep);
- Modified();
- }else{
- anIntegrationStep = aMaxIntegrationStep / 10.0;
- float aMinMax = aDataSet->GetLength()/myInput->GetNumberOfPoints();
- if(aMinMax > anIntegrationStep)
- anIntegrationStep = (anIntegrationStep*9.0+aMinMax)/10.0;
- if(aMinIntegrationStep > anIntegrationStep)
- anIntegrationStep = aMinIntegrationStep;
- }
- return anIntegrationStep;
+float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet){
+ if(!theDataSet) return -1.0;
+ theDataSet->Update();
+ float aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet);
+ return aPropagationTime;
+}
+float VISU_StreamLinesPL::GetBasePropagationTime(){
+ return GetBasePropagationTime(myExtractor->GetOutput());
}
-float VISU_StreamLinesPL::GetStepLength() {
- return myStream->GetStepLength();
+float VISU_StreamLinesPL::GetMinStepLength(vtkPointSet* theDataSet){
+ static float aNbOfStepsOfIntStep = 1.0E+1;
+ float anIntStep = GetMinIntegrationStep(theDataSet);
+ float aStepLength = anIntStep*aNbOfStepsOfIntStep/GetVelocityCoeff(theDataSet);
+ return aStepLength;
}
-float VISU_StreamLinesPL::GetMinStepLength(float theIntegrationStep){
- return theIntegrationStep*2.0;
+float VISU_StreamLinesPL::GetMinStepLength(){
+ return GetMinStepLength(myExtractor->GetOutput());
+}
+
+float VISU_StreamLinesPL::GetMaxStepLength(vtkPointSet* theDataSet){
+ float aStepLength = GetBasePropagationTime(theDataSet);
+ return aStepLength;
}
-float VISU_StreamLinesPL::GetMaxStepLength(float thePropagationTime){
- return thePropagationTime/100.0;
+float VISU_StreamLinesPL::GetMaxStepLength(){
+ return GetMaxStepLength(myExtractor->GetOutput());
}
-float VISU_StreamLinesPL::CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime){
- float aMinStep = GetMinStepLength(theIntegrationStep);
+
+float VISU_StreamLinesPL::CorrectStepLength(float theStep, vtkPointSet* theDataSet){
+ float aMinStep = GetMinStepLength(theDataSet);
if(theStep < aMinStep) theStep = aMinStep;
- float aMaxStep = GetMaxStepLength(thePropagationTime);
+ float aMaxStep = GetMaxStepLength(theDataSet);
if(theStep > aMaxStep) theStep = aMaxStep;
return theStep;
}
-float VISU_StreamLinesPL::SetStepLength(float theStep){
- if(myStream->GetStepLength() == theStep) return theStep;
- float aStepLength = CorrectStepLength(theStep,GetIntegrationStep(),GetPropagationTime());
- if(aStepLength == theStep){
- myStream->SetStepLength(theStep);
- Modified();
- }
+float VISU_StreamLinesPL::GetBaseStepLength(vtkPointSet* theDataSet){
+ static float anAvgNbOfSteps = 1.0E+2;
+ float aPropagationTime = GetBasePropagationTime(theDataSet);
+ float aStepLength = aPropagationTime/anAvgNbOfSteps;
+ aStepLength = CorrectStepLength(aStepLength,theDataSet);
return aStepLength;
}
void VISU_StreamLinesPL::Init(){
VISU_ScalarMapPL::Init();
-
- SetDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);
- vtkPointSet* aDataSet = myExtractor->GetOutput();
- //Order of setting of the values are important
- myPercents = 0.3;
- SetSource(NULL);
-
- SetIntegrationStep(SetIntegrationStep(GetMaxIntegrationStep(aDataSet)/10.0));
- SetPropagationTime(GetBasePropagationTime(aDataSet));
- SetStepLength(SetStepLength(GetPropagationTime()/20.));
+ vtkPointSet* aDataSet = myExtractor->GetOutput();
+ float anIntStep = GetBaseIntegrationStep(aDataSet);
+ float aPropagationTime = GetBasePropagationTime(aDataSet);
+ float aStepLength = GetBaseStepLength(aDataSet);
+ SetParams(anIntStep,aPropagationTime,aStepLength);
}
VISU_ScalarMapPL::THook* VISU_StreamLinesPL::DoHook(){
- SetSource(NULL);
myInput->Update();
+ VISU::CellDataToPoint(myStream,myCellDataToPointData,myInput,myFieldTransform);
float *aBounds = myInput->GetBounds();
myGeomFilter->SetExtent(aBounds);
myGeomFilter->ExtentClippingOn();
#include <vtkStreamLine.h>
class vtkPointSet;
+class vtkCellCenters;
class SALOME_GeometryFilter;
+class VISU_UsedPointsFilter;
class VISU_StreamLinesPL : public VISU_DeformedShapePL{
protected:
virtual ~VISU_StreamLinesPL();
virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
- virtual int GetDirection();
- virtual void SetDirection(int theDirection);
-
- virtual float GetStepLength();
- virtual float SetStepLength(float theStep);
-
+ virtual int SetParams(float theIntStep,
+ float thePropogationTime,
+ float theStepLength,
+ vtkPointSet* theSource = NULL,
+ float thePercents = 0.3,
+ int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS,
+ int isOnlyTry = false);
+ virtual vtkPointSet* GetSource();
+ virtual float GetUsedPoints();
+ virtual float GetIntegrationStep();
virtual float GetPropagationTime();
- virtual void SetPropagationTime(float theTime);
+ virtual float GetStepLength();
+ virtual int GetDirection();
- virtual float GetIntegrationStep();
- virtual float SetIntegrationStep(float theStep);
+ virtual vtkDataSet* GetStreamerSource();
+ virtual float GetVelocityCoeff();
- virtual void SetSource(vtkPointSet* theSource);
- virtual vtkPointSet* GetSource() {return mySource;}
+ virtual float GetMaxIntegrationStep();
+ virtual float GetMinIntegrationStep();
- virtual void SetUsedPoints(float thePercents) { myPercents = thePercents;}
- virtual float GetUsedPoints() { return myPercents;}
+ virtual float GetMinStepLength();
+ virtual float GetMaxStepLength();
- virtual float GetMaxIntegrationStep(){ return GetMaxIntegrationStep(GetSource());}
- virtual float GetMinIntegrationStep(){ return GetMinIntegrationStep(GetSource());}
- virtual float GetBasePropagationTime(){ return GetBasePropagationTime(GetSource());};
+ virtual float GetMinPropagationTime();
+ virtual float GetMaxPropagationTime();
+ virtual float GetBasePropagationTime();
public:
virtual THook* DoHook();
virtual void SetMapScale(float theMapScale = 1.0);
public:
- static int myMaxIncrementMemorySize;
-
- static float GetMinStepLength(float theIntegrationStep);
- static float GetMaxStepLength(float thePropagationTime);
- static float CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime);
-
static float GetMaxIntegrationStep(vtkPointSet* theDataSet);
- static float GetMinIntegrationStep(vtkPointSet* theDataSet);
+ static float GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents = 0.3);
+ static float GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents = 0.3);
+
+ static float GetMinPropagationTime(vtkPointSet* theDataSet);
+ static float GetMaxPropagationTime(vtkPointSet* theDataSet);
static float GetBasePropagationTime(vtkPointSet* theDataSet);
+ static float GetMinStepLength(vtkPointSet* theDataSet);
+ static float GetMaxStepLength(vtkPointSet* theDataSet);
+ static float GetBaseStepLength(vtkPointSet* theDataSet);
+
+ static float GetVelocityCoeff(vtkPointSet* theDataSet);
+
+ static int IsPossible(vtkPointSet* theDataSet, float thePercents = 0.3);
+
protected:
+ static float GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength,
+ float thePropogationTime, float thePercents = 0.3);
+ static int FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength,
+ float& thePropogationTime, float& thePercents);
+
+ static float CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents = 0.3);
+ static float CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet);
+ static float CorrectStepLength(float theStep, vtkPointSet* theDataSet);
+
vtkStreamLine* myStream;
vtkPointSet* mySource;
+ vtkCellCenters* myCenters;
SALOME_GeometryFilter *myGeomFilter;
+ VISU_UsedPointsFilter *myPointsFilter;
float myPercents;
};
#endif
+
vtkStandardNewMacro(VISU_UsedPointsFilter);
VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
- PercentsOfUsedPoints = 0.1;
+ PercentsOfUsedPoints = 1.0;
}
VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
anOutput->GetPointData()->CopyAllOff();
anOutput->GetCellData()->CopyAllOff();
+ anOutput->CopyStructure(anInput);
+
vtkPoints* aPoints = vtkPoints::New();
vtkIdType aCellSize = anInput->GetMaxCellSize();
vtkIdList *anIdList = vtkIdList::New();
if(anIdList->GetNumberOfIds() > 0)
aPoints->InsertNextPoint(anInput->GetPoint(i));
}
- static float EPS = 1E-5;
- if(PercentsOfUsedPoints < EPS){
- anOutput->SetPoints(aPoints);
- }else{
- vtkPoints* aNewPoints = vtkPoints::New();
- iEnd = aPoints->GetNumberOfPoints();
+ vtkPoints* aNewPoints = vtkPoints::New();
+ iEnd = aPoints->GetNumberOfPoints();
+ if (PercentsOfUsedPoints > 0){
vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
if(anOffset < 1) anOffset = 1;
for(vtkIdType i = 0; i < iEnd; i += anOffset)
aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
- anOutput->SetPoints(aNewPoints);
- aNewPoints->Delete();
}
+ anOutput->SetPoints(aNewPoints);
+ aNewPoints->Delete();
aPoints->Delete();
}
VISU_VectorsPL::VISU_VectorsPL(){
myGlyph = vtkGlyph3D::New();
+
+ myGlyphSource = vtkGlyphSource2D::New();
+ myConeSource = vtkConeSource::New();
+ myLineSource = vtkLineSource::New();
+
+ myCenters = vtkCellCenters::New();
myTransformFilter = SALOME_TransformFilter::New();
}
VISU_VectorsPL::~VISU_VectorsPL(){
+ myGlyph->UnRegisterAllOutputs();
myGlyph->Delete();
+
+ myCenters->UnRegisterAllOutputs();
+ myCenters->Delete();
+
+ myGlyphSource->UnRegisterAllOutputs();
+ myGlyphSource->Delete();
+
+ myConeSource->UnRegisterAllOutputs();
+ myConeSource->Delete();
+
+ myLineSource->UnRegisterAllOutputs();
+ myLineSource->Delete();
+
+ myTransformFilter->UnRegisterAllOutputs();
myTransformFilter->Delete();
}
VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){
- VISU::ToCellCenters(myTransformFilter,myInput,myFieldTransform);
+ VISU::ToCellCenters(myTransformFilter,myCenters,myInput,myFieldTransform);
myGlyph->SetInput(myTransformFilter->GetOutput());
myGlyph->SetVectorModeToUseVector();
myGlyph->SetScaleModeToScaleByVector();
void VISU_VectorsPL::Update(){
switch (myTypeGlyph) {
case ARROW: {
- vtkGlyphSource2D *aGlyphSource = vtkGlyphSource2D::New();
- aGlyphSource->SetGlyphTypeToArrow();
- aGlyphSource->SetFilled(0);
- if(myPosGlyph == TAIL)
- aGlyphSource->SetCenter(0.5, 0.0, 0.0);
- else if(myPosGlyph == HEAD)
- aGlyphSource->SetCenter(-0.5, 0.0, 0.0);
- myGlyph->SetSource(aGlyphSource->GetOutput());
- aGlyphSource->Register(myGlyph);
- aGlyphSource->Delete();
+ myGlyphSource->SetGlyphTypeToArrow();
+ myGlyphSource->SetFilled(0);
+ switch (myPosGlyph) {
+ case TAIL:
+ myGlyphSource->SetCenter(0.5, 0.0, 0.0);
+ break;
+ case HEAD:
+ myGlyphSource->SetCenter(-0.5, 0.0, 0.0);
+ break;
+ 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());
}
break;
case CONE2:
case CONE6: {
- vtkConeSource *aGlyphSource = vtkConeSource::New(); //by default
if (myTypeGlyph == CONE2)
- aGlyphSource->SetResolution(3);
+ myConeSource->SetResolution(3);
else
- aGlyphSource->SetResolution(7);
- aGlyphSource->SetHeight(1.0);
- aGlyphSource->SetRadius(.1);
-
- if(myPosGlyph == TAIL)
- aGlyphSource->SetCenter(0.5, 0.0, 0.0);
- else if(myPosGlyph == HEAD)
- aGlyphSource->SetCenter(-0.5, 0.0, 0.0);
+ myConeSource->SetResolution(7);
+ myConeSource->SetHeight(1.0);
+ myConeSource->SetRadius(.1);
- myGlyph->SetSource(aGlyphSource->GetOutput());
- aGlyphSource->Register(myGlyph);
- aGlyphSource->Delete();
+ switch (myPosGlyph) {
+ case TAIL:
+ myConeSource->SetCenter(0.5, 0.0, 0.0);
+ break;
+ case HEAD:
+ myConeSource->SetCenter(-0.5, 0.0, 0.0);
+ break;
+ 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());
}
break;
case NONE:
default: {
- vtkLineSource *aGlyphSource = vtkLineSource::New();
- myGlyph->SetSource(aGlyphSource->GetOutput());
- aGlyphSource->Register(myGlyph);
- aGlyphSource->Delete();
+ myGlyph->SetSource(myLineSource->GetOutput());
}
}
class SALOME_TransformFilter;
class SALOME_Transform;
+class vtkCellCenters;
+
+class vtkGlyphSource2D;
+class vtkConeSource;
+class vtkLineSource;
+
class vtkGlyph3D;
class VISU_VectorsPL : public VISU_DeformedShapePL{
GlyphType myTypeGlyph;
GlyphPos myPosGlyph;
vtkGlyph3D *myGlyph;
+
+ vtkGlyphSource2D *myGlyphSource;
+ vtkLineSource *myLineSource;
+ vtkConeSource *myConeSource;
+
+ vtkCellCenters* myCenters;
SALOME_TransformFilter *myTransformFilter;
};