|
@@ -0,0 +1,1614 @@
|
|
|
+#include "vtkvisuncontour.h"
|
|
|
+#include <vtkCellDataToPointData.h>
|
|
|
+
|
|
|
+
|
|
|
+vtkStandardNewMacro(vtkVISUnContour)
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: the constructor
|
|
|
+ * @param:
|
|
|
+ * @ret:
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+vtkVISUnContour::vtkVISUnContour()
|
|
|
+{
|
|
|
+ contourLookupTable_ = NULL;
|
|
|
+ scalarBarWidget_ = NULL;
|
|
|
+ contourScalarIndex_ = 0;
|
|
|
+ vectorIndex_ = 0;
|
|
|
+ contourLevel_ = 10;
|
|
|
+
|
|
|
+ csdVectorWarp_ = NULL;
|
|
|
+
|
|
|
+ contourType_ = 0;
|
|
|
+ deformation_ = 0;
|
|
|
+ scaleFactor_ = 10.0;
|
|
|
+
|
|
|
+ conFilter_ = NULL;
|
|
|
+
|
|
|
+ scalarRange_[0] = 0;
|
|
|
+ scalarRange_[1] = 0;
|
|
|
+
|
|
|
+ representFlag_ = 1;
|
|
|
+
|
|
|
+ barEnable_ = 1;
|
|
|
+ scalarIndex_ = -1;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: the destructor
|
|
|
+ * @param:
|
|
|
+ * @ret:
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+vtkVISUnContour::~vtkVISUnContour()
|
|
|
+{
|
|
|
+ ErrorInfo(0, "destructure func 0");
|
|
|
+ if(scalarBarWidget_ != NULL)
|
|
|
+ {
|
|
|
+ scalarBarWidget_->Delete();
|
|
|
+ scalarBarWidget_ = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ ErrorInfo(0, "destructure func 2");
|
|
|
+ if(csdVectorWarp_ != NULL)
|
|
|
+ {
|
|
|
+ csdVectorWarp_->Delete();
|
|
|
+ csdVectorWarp_ = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(conFilter_ != NULL)
|
|
|
+ {
|
|
|
+ conFilter_->Delete();
|
|
|
+ conFilter_ = NULL;
|
|
|
+ }
|
|
|
+ //delete [] _vtkObjects;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: create contour display(创建等高线显示)
|
|
|
+ * @param: scalar
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::CreateContourDisplay(char* scalarName)
|
|
|
+{
|
|
|
+ deformation_ = 0;
|
|
|
+ bool pointOrCell = true;
|
|
|
+
|
|
|
+ int scalarIndex = _source->GetScalarIndex(scalarName);
|
|
|
+
|
|
|
+ if (scalarIndex == -1)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Scalar not exists, can't create contour.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (_source->scalarSource[scalarIndex] == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "This Scalar Source is not exists, Please Load it First!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ scalarIndex_ = scalarIndex;
|
|
|
+ scalarRange_[0] = _source->scalarRange[scalarIndex][0];
|
|
|
+ scalarRange_[1] = _source->scalarRange[scalarIndex][1];
|
|
|
+
|
|
|
+ vtkUnstructuredGrid *unGrid = vtkUnstructuredGrid::New();
|
|
|
+ unGrid->DeepCopy(_source->unstruGrid);
|
|
|
+ if (_source->scalarSource[scalarIndex]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ pointOrCell = true;
|
|
|
+ (unGrid->GetPointData())->SetScalars(_source->scalarSource[scalarIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pointOrCell = false;
|
|
|
+ (unGrid->GetCellData())->SetScalars(_source->cellScalarSource_[scalarIndex]);
|
|
|
+ }
|
|
|
+ unGrid->Modified();
|
|
|
+
|
|
|
+ vtkCellDataToPointData* ctop = vtkCellDataToPointData::New();
|
|
|
+ if (!pointOrCell)
|
|
|
+ {
|
|
|
+
|
|
|
+ ctop->SetInputData(unGrid);
|
|
|
+ ctop->PassCellDataOn();
|
|
|
+ ctop->Update();
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkGeometryFilter *geoFilter = vtkGeometryFilter::New();
|
|
|
+ if(pointOrCell)
|
|
|
+ {
|
|
|
+ geoFilter->SetInputData(unGrid);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ geoFilter->SetInputData(ctop->GetOutput());
|
|
|
+ }
|
|
|
+ //geoFilter->SetInputData(unGrid);
|
|
|
+
|
|
|
+ geoFilter->Modified();
|
|
|
+ geoFilter->Update();
|
|
|
+
|
|
|
+ vtkWarpVector* warp = vtkWarpVector::New();
|
|
|
+ warp->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ warp->SetScaleFactor(scaleFactor_);
|
|
|
+ warp->Modified();
|
|
|
+
|
|
|
+ vtkContourFilter *conFilter = vtkContourFilter::New();
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ conFilter->SetInputData(geoFilter->GetOutput());
|
|
|
+ }
|
|
|
+ else if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ conFilter->SetInputData(warp->GetOutput());
|
|
|
+ }
|
|
|
+ conFilter->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+
|
|
|
+ vtkBandedPolyDataContourFilter *bConFilter = vtkBandedPolyDataContourFilter::New();
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ //cout<<"test no deformation: "<<(geoFilter->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+ geoFilter->Modified();
|
|
|
+
|
|
|
+ bConFilter->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ bConFilter->SetInputData(warp->GetOutput());
|
|
|
+ }
|
|
|
+ bConFilter->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ bConFilter->ClippingOff();
|
|
|
+ bConFilter->Modified();
|
|
|
+ bConFilter->Update();
|
|
|
+
|
|
|
+ //cout<<"test contourFilter:; "<<(bConFilter->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ if(_source->scalarRange[scalarIndex][0] == _source->scalarRange[scalarIndex][1])
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(conFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(bConFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(warp->GetOutputPort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+ mapper->SetScalarRange(_source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ vtkLookupTable *lut = (vtkLookupTable*)(mapper->GetLookupTable());
|
|
|
+ lut->GetHueRange(range);
|
|
|
+ lut->SetHueRange(range[1], range[0]);
|
|
|
+ lut->SetRange(_source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ if(contourType_ == 1)
|
|
|
+ {
|
|
|
+ lut->SetNumberOfColors(256);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lut->SetNumberOfColors(contourLevel_);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (actor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (actor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (actor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ contourScalarIndex_ = scalarIndex;
|
|
|
+ contourLookupTable_ = lut;
|
|
|
+
|
|
|
+ conFilter_ = bConFilter;
|
|
|
+ _unActor = actor;
|
|
|
+
|
|
|
+ _vtkObjectsNum = 6;
|
|
|
+ _vtkObjects = new vtkObject*[_vtkObjectsNum];
|
|
|
+ _vtkObjects[0] = unGrid;
|
|
|
+ _vtkObjects[1] = geoFilter;
|
|
|
+ _vtkObjects[2] = conFilter;
|
|
|
+ _vtkObjects[3] = lut;
|
|
|
+ _vtkObjects[4] = mapper;
|
|
|
+ _vtkObjects[5] = warp;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: create contour display(创建等高线显示)
|
|
|
+ * @param: scalar,vector
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::CreateContourDisplay(char* scalarName,char* vectorName)
|
|
|
+{
|
|
|
+ int scalarIndex = _source->GetScalarIndex(scalarName);
|
|
|
+ int vectorIndex = -1;
|
|
|
+
|
|
|
+ if (! string(vectorName).empty ())
|
|
|
+ {
|
|
|
+ vectorIndex = _source->GetVectorIndex(vectorName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (scalarIndex == -1)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Scalar not exists, can't create contour.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_source->scalarSource[scalarIndex] == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "This Scalar Source is not exists, Please Load it First!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ scalarIndex_ = scalarIndex;
|
|
|
+ scalarRange_[0] = _source->scalarRange[scalarIndex][0];
|
|
|
+ scalarRange_[1] = _source->scalarRange[scalarIndex][1];
|
|
|
+
|
|
|
+ int num = _source->scalarSource[scalarIndex]->GetDataSize();
|
|
|
+
|
|
|
+ vtkUnstructuredGrid *unGrid = vtkUnstructuredGrid::New();
|
|
|
+ unGrid->DeepCopy(_source->unstruGrid);
|
|
|
+
|
|
|
+ if (num != 0)
|
|
|
+ {
|
|
|
+ (unGrid->GetPointData())->SetScalars(_source->scalarSource[scalarIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (unGrid->GetCellData())->SetScalars(_source->cellScalarSource_[scalarIndex]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vectorIndex != -1)
|
|
|
+ {
|
|
|
+ if( _source->vectorSource[vectorIndex]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (unGrid->GetPointData())->SetVectors(_source->vectorSource[vectorIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (unGrid->GetCellData())->SetVectors(_source->cellVectorSource_[vectorIndex]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unGrid->Modified();
|
|
|
+
|
|
|
+ vtkCellDataToPointData* ctop = vtkCellDataToPointData::New();
|
|
|
+ if (num == 0)
|
|
|
+ {
|
|
|
+ ctop->SetInputData(unGrid);
|
|
|
+ ctop->PassCellDataOn();
|
|
|
+ ctop->Update();
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkGeometryFilter *geoFilter = vtkGeometryFilter::New();
|
|
|
+ if(num != 0)
|
|
|
+ {
|
|
|
+ geoFilter->SetInputData(unGrid);
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ geoFilter->SetInputData(ctop->GetOutput());
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkWarpVector* warp = vtkWarpVector::New();
|
|
|
+ warp->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ warp->SetScaleFactor(scaleFactor_);
|
|
|
+ warp->Update();
|
|
|
+
|
|
|
+
|
|
|
+ vtkContourFilter *conFilter = vtkContourFilter::New();
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ conFilter->SetInputData(geoFilter->GetOutput());
|
|
|
+ }
|
|
|
+ else if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ conFilter->SetInputData(warp->GetOutput());
|
|
|
+ }
|
|
|
+ conFilter->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ conFilter->Modified();
|
|
|
+
|
|
|
+ vtkBandedPolyDataContourFilter *bConFilter = vtkBandedPolyDataContourFilter::New();
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ bConFilter->SetInputData(geoFilter->GetOutput());
|
|
|
+ }
|
|
|
+ else if (deformation_ == 1)
|
|
|
+ {
|
|
|
+
|
|
|
+ bConFilter->SetInputData(warp->GetOutput());
|
|
|
+ }
|
|
|
+ bConFilter->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ bConFilter->ClippingOn();
|
|
|
+ bConFilter->Modified();
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ if(_source->scalarRange[scalarIndex][0] == _source->scalarRange[scalarIndex][1])
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(conFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(bConFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(warp->GetOutputPort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+ mapper->SetScalarRange(_source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ vtkLookupTable *lut = (vtkLookupTable*)(mapper->GetLookupTable());
|
|
|
+ lut->GetHueRange(range);
|
|
|
+ lut->SetHueRange(range[1], range[0]);
|
|
|
+ lut->SetRange(_source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ if(contourType_ == 1)
|
|
|
+ {
|
|
|
+ lut->SetNumberOfColors(256);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lut->SetNumberOfColors(contourLevel_);
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (actor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (actor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (actor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ contourScalarIndex_ = scalarIndex;
|
|
|
+ vectorIndex_ = vectorIndex;
|
|
|
+ contourLookupTable_ = lut;
|
|
|
+
|
|
|
+ conFilter_ = bConFilter;
|
|
|
+ _unActor = actor;
|
|
|
+
|
|
|
+ _vtkObjectsNum = 6;
|
|
|
+ _vtkObjects = new vtkObject*[_vtkObjectsNum];
|
|
|
+ _vtkObjects[0] = unGrid;
|
|
|
+ _vtkObjects[1] = geoFilter;
|
|
|
+ _vtkObjects[2] = conFilter;
|
|
|
+ _vtkObjects[3] = lut;
|
|
|
+ _vtkObjects[4] = mapper;
|
|
|
+ _vtkObjects[5] = warp;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify contour display type(修改轮廓显示类型)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyContourDisplayType()
|
|
|
+{
|
|
|
+ if (_vtkObjects == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Contour Display Not Created.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->Modified();
|
|
|
+ ((vtkGeometryFilter*)_vtkObjects[1])->Modified();
|
|
|
+
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->GenerateValues(contourLevel_, _source->scalarRange[contourScalarIndex_][0], _source->scalarRange[contourScalarIndex_][1]);
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Modified();
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkContourFilter*)_vtkObjects[2])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ conFilter_->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ conFilter_->Modified();
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(conFilter_->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(contourType_ == 1)
|
|
|
+ {
|
|
|
+ ((vtkLookupTable*)_vtkObjects[3])->SetNumberOfColors(256);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkLookupTable*)_vtkObjects[3])->SetNumberOfColors(contourLevel_);
|
|
|
+ }
|
|
|
+ ((vtkLookupTable*)_vtkObjects[3])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+ _unActor->Modified();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify contour display(修改轮廓显示)
|
|
|
+ * @param: scalar
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyContourDisplay(char* scalarName)
|
|
|
+{
|
|
|
+ DeleteObjects();
|
|
|
+ CreateContourDisplay(scalarName);
|
|
|
+ /*char* vectorName = NULL;
|
|
|
+ int vectorIndex = -1;
|
|
|
+
|
|
|
+ if (_vtkObjects != NULL)
|
|
|
+ {
|
|
|
+ int scalarIndex = _source->GetScalarIndex(scalarName);
|
|
|
+// if (! string(vectorName).empty ())
|
|
|
+// {
|
|
|
+// vectorIndex = _source->GetVectorIndex(vectorName);
|
|
|
+// }
|
|
|
+ if (scalarIndex == -1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ contourScalarIndex_ = scalarIndex;
|
|
|
+ vectorIndex_ = -1;
|
|
|
+
|
|
|
+ if (_source->scalarSource[scalarIndex] == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "This Scalar Source is not exists, Please Load it First!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int num = _source->scalarSource[scalarIndex]->GetDataSize();
|
|
|
+
|
|
|
+ if (num != 0)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetPointData()->SetScalars(_source->scalarSource[scalarIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetCellData()->SetScalars(_source->cellScalarSource_[scalarIndex]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vectorIndex != -1)
|
|
|
+ {
|
|
|
+ if(num != 0)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetPointData()->SetVectors(_source->vectorSource[vectorIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetCellData()->SetVectors(_source->cellVectorSource_[vectorIndex]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scalarRange_[0] = _source->scalarRange[scalarIndex][0];
|
|
|
+ scalarRange_[1] = _source->scalarRange[scalarIndex][1];
|
|
|
+
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->Modified();
|
|
|
+ ((vtkGeometryFilter*)_vtkObjects[1])->Modified();
|
|
|
+ if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetScaleFactor(scaleFactor_);
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->Modified ();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputData(((vtkWarpVector*)_vtkObjects[5])->GetOutput());
|
|
|
+ }
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Modified();
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Update();
|
|
|
+
|
|
|
+ if(_source->scalarRange[scalarIndex][0]==_source->scalarRange[scalarIndex][1])
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkContourFilter*)_vtkObjects[2])->GetOutputPort());
|
|
|
+ }
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ conFilter_->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ conFilter_->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ conFilter_->Modified();
|
|
|
+
|
|
|
+ if(_source->scalarRange[scalarIndex][0]==_source->scalarRange[scalarIndex][1])
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(conFilter_->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarModeToUsePointData();
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarRange(_source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+
|
|
|
+ string temp = scalarName;
|
|
|
+ int length = temp.length();
|
|
|
+ string::size_type loc = temp.find( " ", 0 );
|
|
|
+ if( loc != string::npos ) {
|
|
|
+ temp.insert (loc,"\n");
|
|
|
+ }
|
|
|
+ string::size_type loc1 = temp.find_last_of( "-", length );
|
|
|
+ if( loc1 != string::npos ) {
|
|
|
+ temp.insert (loc1+1,"\n");
|
|
|
+ }
|
|
|
+ string::size_type loc2 = temp.find_last_of( "*", length );
|
|
|
+ if( loc2 != string::npos ) {
|
|
|
+ temp.insert (loc2+1,"\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (scalarBarWidget_ != NULL)
|
|
|
+ {
|
|
|
+ for (int s = temp.size(); s < 10; ++s) temp.append(" "); //add space to reduce font
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->SetTitle(temp.c_str ());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Contour Display Not Created.");
|
|
|
+ return;
|
|
|
+ }*/
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify ontour display(修改等高线显示)
|
|
|
+ * @param: scalar vector
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyContourDisplay(char* scalarName,char* vectorName)
|
|
|
+{
|
|
|
+ int vectorIndex = -1;
|
|
|
+
|
|
|
+ if (_vtkObjects != NULL)
|
|
|
+ {
|
|
|
+ int scalarIndex = _source->GetScalarIndex(scalarName);
|
|
|
+
|
|
|
+ if (! string(vectorName).empty ())
|
|
|
+ {
|
|
|
+ vectorIndex = _source->GetVectorIndex(vectorName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (scalarIndex == -1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ contourScalarIndex_ = scalarIndex;
|
|
|
+
|
|
|
+ scalarRange_[0] = _source->scalarRange[scalarIndex][0];
|
|
|
+ scalarRange_[1] = _source->scalarRange[scalarIndex][1];
|
|
|
+
|
|
|
+ int num = _source->scalarSource[scalarIndex]->GetDataSize();
|
|
|
+
|
|
|
+ if (_source->scalarSource[scalarIndex] == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "This Scalar Source is not exists, Please Load it First!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (num != 0)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetPointData()->SetScalars(_source->scalarSource[scalarIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetCellData()->SetScalars(_source->cellScalarSource_[scalarIndex]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vectorIndex != -1)
|
|
|
+ {
|
|
|
+ vectorIndex_ = vectorIndex;
|
|
|
+
|
|
|
+ if(_source->vectorSource[vectorIndex]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetPointData()->SetVectors(_source->vectorSource[vectorIndex]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->GetCellData()->SetVectors(_source->cellVectorSource_[vectorIndex]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->Modified();
|
|
|
+ ((vtkGeometryFilter*)_vtkObjects[1])->Modified();
|
|
|
+
|
|
|
+
|
|
|
+ if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetScaleFactor(scaleFactor_);
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->Modified ();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputData(((vtkWarpVector*)_vtkObjects[5])->GetOutput());
|
|
|
+ }
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Modified();
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Update();
|
|
|
+
|
|
|
+ if(_source->scalarRange[scalarIndex][0]==_source->scalarRange[scalarIndex][1])
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkContourFilter*)_vtkObjects[2])->GetOutputPort());
|
|
|
+ }
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ conFilter_->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ conFilter_->GenerateValues(contourLevel_, _source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ conFilter_->Modified();
|
|
|
+
|
|
|
+ if(_source->scalarRange[scalarIndex][0]==_source->scalarRange[scalarIndex][1])
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(conFilter_->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarModeToUsePointData();
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarRange(_source->scalarRange[scalarIndex][0], _source->scalarRange[scalarIndex][1]);
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+
|
|
|
+ string temp = scalarName;
|
|
|
+ int length = temp.length();
|
|
|
+ string::size_type loc = temp.find( " ", 0 );
|
|
|
+ if( loc != string::npos )
|
|
|
+ {
|
|
|
+ temp.insert (loc,"\n");
|
|
|
+ }
|
|
|
+ string::size_type loc1 = temp.find_last_of( "-", length );
|
|
|
+ if( loc1 != string::npos )
|
|
|
+ {
|
|
|
+ temp.insert (loc1+1,"\n");
|
|
|
+ }
|
|
|
+ string::size_type loc2 = temp.find_last_of( "*", length );
|
|
|
+ if( loc2 != string::npos )
|
|
|
+ {
|
|
|
+ temp.insert (loc2+1,"\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (scalarBarWidget_ != NULL)
|
|
|
+ {
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->SetTitle(temp.c_str());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Contour Display Not Created.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: create scalar bar(创建缩放栏)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::CreateScalarBar()
|
|
|
+{
|
|
|
+ string temp = _source->GetScalarName(contourScalarIndex_);
|
|
|
+ int length = temp.length();
|
|
|
+ string::size_type loc = temp.find( " ", 0 );
|
|
|
+ if( loc != string::npos ) {
|
|
|
+ temp.insert (loc,"\n");
|
|
|
+ }
|
|
|
+ string::size_type loc1 = temp.find_last_of( "-", length );
|
|
|
+ if( loc1 != string::npos ) {
|
|
|
+ temp.insert (loc1+1,"\n");
|
|
|
+ }
|
|
|
+ string::size_type loc2 = temp.find_last_of( "*", length );
|
|
|
+ if( loc2 != string::npos ) {
|
|
|
+ temp.insert (loc2+1,"\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkScalarBarActor *barActor = vtkScalarBarActor::New();
|
|
|
+ if(contourLevel_<10)
|
|
|
+ {
|
|
|
+ barActor->SetNumberOfLabels(contourLevel_);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ barActor->SetNumberOfLabels(10);
|
|
|
+ }
|
|
|
+ barActor->SetOrientationToVertical();
|
|
|
+ for (int s = temp.size(); s < 10; ++s) temp.append(" "); //add space to reduce font
|
|
|
+ barActor->SetTitle(temp.c_str());
|
|
|
+ barActor->SetLabelFormat("%1.2E");
|
|
|
+
|
|
|
+ barActor->GetTitleTextProperty()->SetFontFamilyToArial();
|
|
|
+ barActor->GetTitleTextProperty()->SetFontSize(6);
|
|
|
+ barActor->GetTitleTextProperty()->SetColor(0, 0, 0);
|
|
|
+ barActor->GetTitleTextProperty()->ItalicOff();
|
|
|
+
|
|
|
+ barActor->GetLabelTextProperty()->SetFontFamilyToArial();
|
|
|
+ barActor->GetLabelTextProperty()->SetFontSize(5);
|
|
|
+ barActor->GetLabelTextProperty()->SetColor(0, 0, 0);
|
|
|
+ barActor->GetLabelTextProperty()->ItalicOff();
|
|
|
+ barActor->SetLookupTable((vtkScalarsToColors*)contourLookupTable_);
|
|
|
+
|
|
|
+ vtkScalarBarRepresentation* rep = vtkScalarBarRepresentation::New();
|
|
|
+ rep->SetPosition(0.8, 0.1);
|
|
|
+ rep->SetPosition2(0.08, 0.8);
|
|
|
+ //rep->SetMaximumSize(10, 50);
|
|
|
+ rep->ProportionalResizeOff();
|
|
|
+ rep->SetScalarBarActor(barActor);
|
|
|
+
|
|
|
+ vtkScalarBarWidget *barWidget = vtkScalarBarWidget::New();
|
|
|
+ _renWin = _renderer->GetRenderWindow();
|
|
|
+ barWidget->SetInteractor(_renWin->GetInteractor());
|
|
|
+ barWidget->SetRepresentation(rep);
|
|
|
+ if(barEnable_ == 1)
|
|
|
+ {
|
|
|
+ barWidget->EnabledOn();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ barWidget->EnabledOff();
|
|
|
+ }
|
|
|
+
|
|
|
+ scalarBarWidget_ = barWidget;
|
|
|
+ scalarBarWidget_->On();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: show on scalar bar(显示缩放栏)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ShowOnScalarBar()
|
|
|
+{
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ barEnable_ = 1;
|
|
|
+
|
|
|
+ scalarBarWidget_->EnabledOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: show off scalar bar(关闭缩放栏)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ShowOffScalarBar()
|
|
|
+{
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ barEnable_ = 0;
|
|
|
+
|
|
|
+ scalarBarWidget_->EnabledOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: update scalar bar(更新缩放栏)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::UpdataScalarBar()
|
|
|
+{
|
|
|
+ if (scalarBarWidget_==NULL)
|
|
|
+ {
|
|
|
+ CreateScalarBar();
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ vtkScalarBarActor *barActor=scalarBarWidget_->GetScalarBarActor();
|
|
|
+ barActor->SetLookupTable((vtkScalarsToColors*)contourLookupTable_);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify scalar bar font(修改缩放栏字体)
|
|
|
+ * @param: font
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyScalarBarFont(char* fontName)
|
|
|
+{
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ vtkScalarBarActor *barActor=scalarBarWidget_->GetScalarBarActor();
|
|
|
+
|
|
|
+ if (strcmp(fontName,"Arial")==0)
|
|
|
+ {
|
|
|
+ barActor->GetTitleTextProperty()->SetFontFamilyToArial();
|
|
|
+ barActor->GetLabelTextProperty()->SetFontFamilyToArial();
|
|
|
+ }
|
|
|
+ else if (strcmp(fontName,"Courier")==0)
|
|
|
+ {
|
|
|
+ barActor->GetTitleTextProperty()->SetFontFamilyToCourier();
|
|
|
+ barActor->GetLabelTextProperty()->SetFontFamilyToCourier();
|
|
|
+ }
|
|
|
+ else if (strcmp(fontName,"Times")==0)
|
|
|
+ {
|
|
|
+ barActor->GetTitleTextProperty()->SetFontFamilyToTimes();
|
|
|
+ barActor->GetLabelTextProperty()->SetFontFamilyToTimes();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify scalar bar color(修改缩放栏字体颜色)
|
|
|
+ * @param: rgb
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyScalarBarFontColor(double r, double g, double b)
|
|
|
+{
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ vtkScalarBarActor *barActor=scalarBarWidget_->GetScalarBarActor();
|
|
|
+ barActor->GetTitleTextProperty()->SetColor(r, g, b);
|
|
|
+ barActor->GetLabelTextProperty()->SetColor(r, g, b);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify scalar bar title(修改缩放栏标题)
|
|
|
+ * @param: title
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyScalarBarTitle(char *title)
|
|
|
+{
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->SetTitle(title);
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->GetTitleTextProperty()->SetFontSize(6);
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->GetTitleTextProperty()->ItalicOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: delete scalar bar(删除缩放栏)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::DeleteScalarBar()
|
|
|
+{
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ scalarBarWidget_->Delete();
|
|
|
+ scalarBarWidget_=NULL;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: modify contour level (修改等高线标高)
|
|
|
+ * @param: level
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyContourLevel(int level)
|
|
|
+{
|
|
|
+ if (level < 2)
|
|
|
+ {
|
|
|
+ ErrorInfo(0, "Contour Level must be within range: 2 to 50!, Using the Min Level 2 insteading!");
|
|
|
+
|
|
|
+ level = 2;
|
|
|
+ }
|
|
|
+ if(level>MAXLEVEL)
|
|
|
+ {
|
|
|
+ ErrorInfo(0, "Contour Level must be within range: 2 to 50!, Using the Max Level 50 insteading!");
|
|
|
+
|
|
|
+ level = MAXLEVEL;
|
|
|
+ }
|
|
|
+
|
|
|
+ contourLevel_ = level;
|
|
|
+
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->GenerateValues(contourLevel_, scalarRange_[0], scalarRange_[1]);
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Modified();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ conFilter_->GenerateValues(contourLevel_, scalarRange_[0], scalarRange_[1]);
|
|
|
+ conFilter_->Modified();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (contourLookupTable_ != NULL)
|
|
|
+ {
|
|
|
+ if(contourType_ == 1)
|
|
|
+ {
|
|
|
+ contourLookupTable_->SetNumberOfColors(256);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ contourLookupTable_->SetNumberOfColors(level);
|
|
|
+ }
|
|
|
+ contourLookupTable_->Modified();
|
|
|
+ }
|
|
|
+ if (scalarBarWidget_!=NULL)
|
|
|
+ {
|
|
|
+ if(level<10)
|
|
|
+ {
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->SetNumberOfLabels(level);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ scalarBarWidget_->GetScalarBarActor()->SetNumberOfLabels(10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: set contour type (修改等高线类型)
|
|
|
+ * @param: type
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::SetContourType(int type)
|
|
|
+{
|
|
|
+ this->contourType_ = type;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: set deformation (设置变形)
|
|
|
+ * @param: flag
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::SetDeformation(int flag)
|
|
|
+{
|
|
|
+ this->deformation_ = flag;
|
|
|
+
|
|
|
+ //cout<<"test flag::" << deformation_<<endl;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Modify Scale Factor (修改缩放因子)
|
|
|
+ * @param: value
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyScaleFactor(double value)
|
|
|
+{
|
|
|
+ if ( _vtkObjects[5] != NULL )
|
|
|
+ {
|
|
|
+ scaleFactor_ = value;
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetScaleFactor(scaleFactor_);
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->Modified();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Modify Contour Representation (修改轮廓表示)
|
|
|
+ * @param: flag
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyContourRepresentation(int flag)
|
|
|
+{
|
|
|
+ if ( _unActor != NULL )
|
|
|
+ {
|
|
|
+ if (flag == 0)
|
|
|
+ {
|
|
|
+ representFlag_ = 0;
|
|
|
+
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (flag == 1)
|
|
|
+ {
|
|
|
+ representFlag_ = 1;
|
|
|
+
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (flag == 2)
|
|
|
+ {
|
|
|
+ representFlag_ = 2;
|
|
|
+
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Wrong Flag!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "The Actor is not Created");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Get Warp Scale Factor (获取扭曲比例因子)
|
|
|
+ * @param: vector
|
|
|
+ * @ret: factor
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+double vtkVISUnContour::GetWarpScaleFactor(char* vectorName)
|
|
|
+{
|
|
|
+ if(_source == NULL)
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ double *b = _source->GetSourceBounds();
|
|
|
+
|
|
|
+ double l = sqrt((b[1]-b[0])*(b[1]-b[0]) + (b[3]-b[2])*(b[3]-b[2]) + (b[5]-b[4])*(b[5]-b[4]));
|
|
|
+
|
|
|
+ int vectorIndex = -1;
|
|
|
+ if (!string(vectorName).empty ())
|
|
|
+ {
|
|
|
+ vectorIndex = _source->GetVectorIndex(vectorName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(vectorIndex == -1)
|
|
|
+ {
|
|
|
+ vectorIndex = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ double *r;
|
|
|
+ if(_source->vectorSource[vectorIndex]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ r = (_source->vectorSource[vectorIndex])->GetRange(-1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ r = (_source->cellVectorSource_[vectorIndex])->GetRange(-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ scaleFactor_ = l/(r[1]-r[0])/10;
|
|
|
+
|
|
|
+ return scaleFactor_;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Set Contour Level (设置等高线标高)
|
|
|
+ * @param: level
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::SetContourLevel(int level)
|
|
|
+{
|
|
|
+ this->contourLevel_ = level;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Clipping On Contour Display (打开轮廓显示上的剪裁)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ClippingOnContourDisplay()
|
|
|
+{
|
|
|
+ if (_vtkObjects != NULL)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->Modified();
|
|
|
+ ((vtkGeometryFilter*)_vtkObjects[1])->Modified();
|
|
|
+
|
|
|
+ if(conFilter_ != NULL)
|
|
|
+ {
|
|
|
+ conFilter_->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ conFilter_->GenerateValues(contourLevel_,scalarRange_[0], scalarRange_[1]);
|
|
|
+ conFilter_->ClippingOn();
|
|
|
+ conFilter_->Modified();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(conFilter_->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarRange(scalarRange_[0], scalarRange_[1]);
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Clipping Off Contour Display (关闭轮廓显示上的剪裁)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ClippingOffContourDisplay()
|
|
|
+{
|
|
|
+ if (_vtkObjects != NULL)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->Modified();
|
|
|
+ ((vtkGeometryFilter*)_vtkObjects[1])->Modified();
|
|
|
+
|
|
|
+ if(conFilter_ != NULL)
|
|
|
+ {
|
|
|
+ conFilter_->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ conFilter_->GenerateValues(contourLevel_,scalarRange_[0], scalarRange_[1]);
|
|
|
+ conFilter_->ClippingOff();
|
|
|
+ conFilter_->Modified();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(conFilter_->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarRange(scalarRange_[0], scalarRange_[1]);
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Modify Display Scalar Range (修改显示标量范围)
|
|
|
+ * @param: min and max range
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ModifyDisplayScalarRange(double min, double max)
|
|
|
+{
|
|
|
+ if (_vtkObjects != NULL)
|
|
|
+ {
|
|
|
+ ((vtkUnstructuredGrid*)_vtkObjects[0])->Modified();
|
|
|
+ ((vtkGeometryFilter*)_vtkObjects[1])->Modified();
|
|
|
+
|
|
|
+ if (deformation_ == 1)
|
|
|
+ {
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetInputConnection(((vtkGeometryFilter*)_vtkObjects[1])->GetOutputPort());
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->SetScaleFactor(scaleFactor_);
|
|
|
+ ((vtkWarpVector*)_vtkObjects[5])->Modified ();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(contourType_ == 2)
|
|
|
+ {
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->SetInputData(((vtkWarpVector*)_vtkObjects[5])->GetOutput());
|
|
|
+ }
|
|
|
+
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->GenerateValues(contourLevel_, min, max);
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Modified();
|
|
|
+ ((vtkContourFilter*)_vtkObjects[2])->Update();
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkContourFilter*)_vtkObjects[2])->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ conFilter_->SetInputData(((vtkGeometryFilter*)_vtkObjects[1])->GetOutput());
|
|
|
+ conFilter_->GenerateValues(contourLevel_, min, max);
|
|
|
+ conFilter_->Modified();
|
|
|
+
|
|
|
+ if (deformation_ == 0)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(conFilter_->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetInputConnection(((vtkWarpVector*)_vtkObjects[5])->GetOutputPort());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->SetScalarRange(min, max);
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Set Contour Representation Flag (设置轮廓表示标志)
|
|
|
+ * @param: flag
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::SetContourRepresentationFlag(int flag)
|
|
|
+{
|
|
|
+ if(flag == 0 || flag == 1 || flag==2)
|
|
|
+ {
|
|
|
+ this->representFlag_ = flag;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ErrorInfo(1, "Wrong Flag!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Set Scalar Bar Enable(设置标量栏启用)
|
|
|
+ * @param: bool
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::SetScalarBarEnable(bool enable)
|
|
|
+{
|
|
|
+ this->barEnable_ = enable;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Set Warp Scale Factor(设置扭曲比例因子)
|
|
|
+ * @param: value
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::SetWarpScaleFactor(double value)
|
|
|
+{
|
|
|
+ this->scaleFactor_ = value;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: DeleteObjects(删除对象)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::DeleteObjects()
|
|
|
+{
|
|
|
+ if (_unActor != 0)
|
|
|
+ {
|
|
|
+ if(_renderer != 0)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(_unActor);
|
|
|
+ }
|
|
|
+ _unActor->Delete();
|
|
|
+ _unActor = 0;
|
|
|
+ }
|
|
|
+ if (_vtkObjects != 0)
|
|
|
+ {
|
|
|
+ if (_vtkObjects[0] != 0)
|
|
|
+ {
|
|
|
+ _vtkObjects[0]->Delete();
|
|
|
+ _vtkObjects[0] = 0;
|
|
|
+ }
|
|
|
+ if (_vtkObjects[2] != 0)
|
|
|
+ {
|
|
|
+ _vtkObjects[2]->Delete();
|
|
|
+ _vtkObjects[2] = 0;
|
|
|
+ }
|
|
|
+ if (_vtkObjects[4] != 0)
|
|
|
+ {
|
|
|
+ _vtkObjects[4]->Delete();
|
|
|
+ _vtkObjects[4] = 0;
|
|
|
+ }
|
|
|
+ if (_vtkObjects[5] != 0)
|
|
|
+ {
|
|
|
+ _vtkObjects[5]->Delete();
|
|
|
+ _vtkObjects[5] = 0;
|
|
|
+ }
|
|
|
+ //_vtkObjects[1] _vtkObjects[3] needn't be delete explicitly.
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: get scalar range(获取标量范围)
|
|
|
+ * @param: range and scalar
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::GetScalarRange(double *range, char*ScalarName)
|
|
|
+{
|
|
|
+ if (ScalarName == NULL)
|
|
|
+ {
|
|
|
+ range[0] = scalarRange_[0];
|
|
|
+ range[1] = scalarRange_[1];
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ range[0] = _source->GetScalarRange(ScalarName)[0];
|
|
|
+ range[1] = _source->GetScalarRange(ScalarName)[1];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Scalar Off Display(关闭标量显示)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ScalarOffDisplay()
|
|
|
+{
|
|
|
+ if (_vtkObjects[4] != NULL)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->ScalarVisibilityOff();
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ (_unActor->GetProperty())->SetColor(0,0,1);
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+ }
|
|
|
+ ShowOffScalarBar();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Scalar On Display(打开标量显示)
|
|
|
+ * @param: void
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+void vtkVISUnContour::ScalarOnDisplay()
|
|
|
+{
|
|
|
+ if (_vtkObjects[4] != NULL)
|
|
|
+ {
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->ScalarVisibilityOn();
|
|
|
+ ((vtkDataSetMapper*)_vtkObjects[4])->Modified();
|
|
|
+
|
|
|
+ if(representFlag_ == 0)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToPoints();
|
|
|
+ }
|
|
|
+ else if(representFlag_ == 1)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToSurface();
|
|
|
+ }
|
|
|
+ else if (representFlag_ == 2)
|
|
|
+ {
|
|
|
+ (_unActor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+ }
|
|
|
+
|
|
|
+ _unActor->Modified();
|
|
|
+ }
|
|
|
+ ShowOnScalarBar();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Get Scalar Index(获取标量数值)
|
|
|
+ * @param: void
|
|
|
+ * @ret: index
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+int vtkVISUnContour::GetScalarIndex()
|
|
|
+{
|
|
|
+ return scalarIndex_;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Get Scalar name(获取标量名)
|
|
|
+ * @param: void
|
|
|
+ * @ret: name
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+string vtkVISUnContour::GetScalarName()
|
|
|
+{
|
|
|
+ const char* str = _source->GetScalarName(scalarIndex_);
|
|
|
+ string name = (char*)str;
|
|
|
+ return name;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Get Dat Source(获取数据源)
|
|
|
+ * @param: void
|
|
|
+ * @ret: source
|
|
|
+ * @birth: created by czm in 20230410
|
|
|
+ */
|
|
|
+vtkVISUnstructuredGridSource* vtkVISUnContour::GetDatSource()
|
|
|
+{
|
|
|
+ if (_source != NULL)
|
|
|
+ {
|
|
|
+ return _source;
|
|
|
+ }
|
|
|
+}
|