|
@@ -19,5 +19,2594 @@ vtkStandardNewMacro(vtkVISUnSlice)
|
|
|
|
|
|
vtkVISUnSlice::vtkVISUnSlice()
|
|
|
{
|
|
|
+ sliceActors_ = new vtkActor*[6];
|
|
|
+ sliceTable_ = new vtkLookupTable*[6];
|
|
|
|
|
|
+ for (int i = 0; i<6;i++)
|
|
|
+ {
|
|
|
+ sliceActors_[i] = vtkActor::New();
|
|
|
+ sliceActors_[i] = NULL;
|
|
|
+
|
|
|
+ sliceTable_[i] = vtkLookupTable::New();
|
|
|
+ sliceTable_[i] = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ //sliceMapper_ = new vtkDataSetMapper*[6];
|
|
|
+ sliceMapper_ = vtkCollection::New();
|
|
|
+ sliceMapper_ = NULL;
|
|
|
+
|
|
|
+ contourLinesFilter_ = vtkContourFilter::New ();
|
|
|
+ contourLinesFilter_ = NULL;
|
|
|
+
|
|
|
+ contourLabelFilter_ = vtkContourFilter::New ();
|
|
|
+ contourLabelFilter_ = NULL;
|
|
|
+
|
|
|
+ sliceGlyph2D_ = vtkGlyphSource2D::New ();
|
|
|
+ sliceGlyph2D_ = NULL;
|
|
|
+
|
|
|
+ sliceGlyph3D_ = vtkGlyph3D::New();
|
|
|
+ sliceGlyph3D_ = NULL;
|
|
|
+
|
|
|
+ shadeColor_[0] = 1.0;
|
|
|
+ shadeColor_[1] = 0.0;
|
|
|
+ shadeColor_[2] = 0.0;
|
|
|
+
|
|
|
+ meshColor_[0] = 0.0;
|
|
|
+ meshColor_[1] = 1.0;
|
|
|
+ meshColor_[2] = 0.0;
|
|
|
+
|
|
|
+
|
|
|
+ planeNormal_[0] = 1.0;
|
|
|
+ planeNormal_[1] = 0.0;
|
|
|
+ planeNormal_[2] = 0.0;
|
|
|
+
|
|
|
+ conLevel_ = 5;
|
|
|
+ usedScalarIndex_ = -1;
|
|
|
+ usedVectorIndex_ = -1;
|
|
|
+
|
|
|
+ for (int i=0; i<3; i++)
|
|
|
+ {
|
|
|
+ planeOrigin_[i] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ cutSource_ = NULL;
|
|
|
+ cutActor_ = NULL;
|
|
|
+ gridSource_ = NULL;
|
|
|
+
|
|
|
+ //cutMapper_ = NULL;
|
|
|
+
|
|
|
+ slicePlane_ = NULL;
|
|
|
+ planeWidget_ = NULL;
|
|
|
+
|
|
|
+ scalarRange_[0] = 0;
|
|
|
+ scalarRange_[1] = 0;
|
|
|
+
|
|
|
+ bandedContourFilter_ = 0;
|
|
|
+ contourLinesFilter_ = 0;
|
|
|
+ contourLabelFilter_ = 0;
|
|
|
+ scalarSource_ = 0;
|
|
|
+}
|
|
|
+
|
|
|
+vtkVISUnSlice::~vtkVISUnSlice()
|
|
|
+{
|
|
|
+ ErrorInfo(0, "destructure func 0");
|
|
|
+ if (cutActor_ != NULL)
|
|
|
+ {
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(cutActor_);
|
|
|
+ }
|
|
|
+ cutActor_->Delete();
|
|
|
+ cutActor_ = NULL;
|
|
|
+ }
|
|
|
+ ErrorInfo(0, "destructure func 1");
|
|
|
+
|
|
|
+ if(planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ //if(_renWin != NULL)
|
|
|
+ //{
|
|
|
+ // planeWidget->SetInteractor(_renWin->GetInteractor());
|
|
|
+ //}
|
|
|
+ // planeWidget_->EnabledOff();
|
|
|
+ planeWidget_->Delete();
|
|
|
+ planeWidget_ = NULL;
|
|
|
+ }
|
|
|
+ ErrorInfo(0, "destructure func 2");
|
|
|
+
|
|
|
+ if (cutSource_ != NULL)
|
|
|
+ {
|
|
|
+ cutSource_->Delete();
|
|
|
+ cutSource_ = NULL;
|
|
|
+ }
|
|
|
+ ErrorInfo(0, "destructure func 3");
|
|
|
+ if (gridSource_ != NULL)
|
|
|
+ {
|
|
|
+ gridSource_->Delete();
|
|
|
+ gridSource_ = NULL;
|
|
|
+ }
|
|
|
+ ErrorInfo(0, "destructure func 4");
|
|
|
+
|
|
|
+ if(slicePlane_ != NULL)
|
|
|
+ {
|
|
|
+ slicePlane_->Delete();
|
|
|
+ slicePlane_ = NULL;
|
|
|
+ }
|
|
|
+ ErrorInfo(0, "destructure func 5");
|
|
|
+
|
|
|
+ /*if(cutMapper_ != NULL)
|
|
|
+ {
|
|
|
+ cutMapper_->Delete();
|
|
|
+ cutMapper_ = NULL;
|
|
|
+ }*/
|
|
|
+ for (int i=0;i<6;i++)
|
|
|
+ {
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ if (sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(sliceActors_[i]);
|
|
|
+ sliceActors_[i]->Delete();
|
|
|
+ sliceActors_[i] = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete [] sliceActors_;
|
|
|
+
|
|
|
+ for (int i=0;i<6;i++)
|
|
|
+ {
|
|
|
+ if (sliceTable_[i] != NULL)
|
|
|
+ {
|
|
|
+ sliceTable_[i]->Delete();
|
|
|
+ sliceTable_[i] = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete [] sliceTable_;
|
|
|
+
|
|
|
+ ErrorInfo(0, "destructure func 6");
|
|
|
+
|
|
|
+ if (sliceMapper_!= NULL)
|
|
|
+ {
|
|
|
+ sliceMapper_->Delete ();
|
|
|
+ sliceMapper_ = NULL;
|
|
|
+ }
|
|
|
+ if (contourLinesFilter_!= NULL)
|
|
|
+ {
|
|
|
+ contourLinesFilter_->Delete();
|
|
|
+ contourLinesFilter_ = NULL;
|
|
|
+ }
|
|
|
+ if (contourLabelFilter_!= NULL)
|
|
|
+ {
|
|
|
+ contourLabelFilter_->Delete();
|
|
|
+ contourLabelFilter_ = NULL;
|
|
|
+ }
|
|
|
+ if (sliceGlyph2D_!= NULL)
|
|
|
+ {
|
|
|
+ sliceGlyph2D_->Delete();
|
|
|
+ sliceGlyph2D_ = NULL;
|
|
|
+ }
|
|
|
+ if (sliceGlyph3D_!= NULL)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->Delete();
|
|
|
+ sliceGlyph3D_ = NULL;
|
|
|
+ }
|
|
|
+ if (scalarSource_ != 0)
|
|
|
+ {
|
|
|
+ scalarSource_->Delete();
|
|
|
+ scalarSource_ = 0;
|
|
|
+ }
|
|
|
+ ErrorInfo(0, "destructure func 7 end.");
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * @brief: Set the slice scalar/vector data source(设置切片标量/矢量数据源)
|
|
|
+ * @param: vector data and scalar data
|
|
|
+ * @ret: void
|
|
|
+ * @birth: created by czm in 20230326
|
|
|
+ */
|
|
|
+void vtkVISUnSlice::SetSliceSource(char* scalar, char* vector)
|
|
|
+{
|
|
|
+ int index1 = -1;
|
|
|
+ int index2 = -1;
|
|
|
+
|
|
|
+ if(scalar != NULL)
|
|
|
+ {
|
|
|
+ index1 = _source->GetScalarIndex(scalar);
|
|
|
+ }
|
|
|
+ if(vector != NULL)
|
|
|
+ {
|
|
|
+ index2 = _source->GetVectorIndex(vector);
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkUnstructuredGrid *unGrid = vtkUnstructuredGrid::New();
|
|
|
+ unGrid->DeepCopy(_source->unstruGrid);
|
|
|
+
|
|
|
+ cout << "point num: " <<unGrid->GetNumberOfPoints() << ", cell num: " << unGrid->GetNumberOfCells() <<endl;
|
|
|
+ if (index1 != -1)
|
|
|
+ {
|
|
|
+ usedScalarIndex_ = index1;
|
|
|
+
|
|
|
+ if(_source->scalarSource[index1]->GetDataSize() != 0)
|
|
|
+ {cout << "scalar size : " <<_source->scalarSource[index1]->GetDataSize() << endl;
|
|
|
+ (unGrid->GetPointData())->SetScalars(_source->scalarSource[index1]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (unGrid->GetCellData())->SetScalars(_source->cellScalarSource_[index1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (index2 != -1)
|
|
|
+ {
|
|
|
+ usedVectorIndex_ = index2;
|
|
|
+
|
|
|
+ if(_source->vectorSource[index2]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (unGrid->GetPointData())->SetVectors(_source->vectorSource[index2]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (unGrid->GetCellData())->SetVectors(_source->cellVectorSource_[index2]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unGrid->Modified();
|
|
|
+
|
|
|
+ vtkPlane *plane = vtkPlane::New();
|
|
|
+ plane->SetNormal(planeNormal_[0], planeNormal_[1], planeNormal_[2]);
|
|
|
+
|
|
|
+ vtkCutter *cutter = vtkCutter::New();
|
|
|
+ cutter->SetInputData(unGrid);
|
|
|
+ cutter->SetCutFunction(plane);
|
|
|
+ cutter->GenerateCutScalarsOff();
|
|
|
+ cutter->SetSortByToSortByCell();
|
|
|
+ cutter->Update();
|
|
|
+
|
|
|
+ //cout<<"test here 1111"<<(cutter->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+ gridSource_ = unGrid;
|
|
|
+ cutSource_ = cutter;
|
|
|
+ slicePlane_ = plane;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Write point,scalar and vector data to file.(将点、标量和矢量数据写入文件)
|
|
|
+* @param: filename
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::WriteScalarVectorData(const char* FileName)
|
|
|
+{
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ vtkFloatArray* cutScalar = vtkFloatArray::New();
|
|
|
+ cutScalar->SetNumberOfComponents(1);
|
|
|
+
|
|
|
+ if(usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if(_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ cutScalar->DeepCopy((cutSource_->GetOutput())->GetPointData()->GetScalars());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cutScalar->DeepCopy((cutSource_->GetOutput())->GetCellData()->GetScalars());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cutScalar->Modified();
|
|
|
+
|
|
|
+ vtkFloatArray* cutVector = vtkFloatArray::New();
|
|
|
+ cutVector->SetNumberOfComponents(3);
|
|
|
+
|
|
|
+ if(usedVectorIndex_ != -1)
|
|
|
+ {
|
|
|
+ if(_source->vectorSource[usedVectorIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ cutVector->DeepCopy((cutSource_->GetOutput())->GetPointData()->GetVectors());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cutVector->DeepCopy((cutSource_->GetOutput())->GetCellData()->GetVectors());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cutVector->Modified();
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ double cutScalarRange_[2];
|
|
|
+
|
|
|
+ (cutSource_->GetOutput())->GetScalarRange(range);
|
|
|
+ cutScalarRange_[0] = range[0];
|
|
|
+ cutScalarRange_[1] = range[1];
|
|
|
+
|
|
|
+
|
|
|
+ int pointNum = 0;
|
|
|
+ pointNum = (cutSource_->GetOutput())->GetNumberOfPoints();
|
|
|
+
|
|
|
+ if (_source->vectorSource[usedVectorIndex_]->GetDataSize() == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double value;
|
|
|
+ double* v;
|
|
|
+ double p[3];
|
|
|
+
|
|
|
+ ofstream f(FileName);
|
|
|
+ if (!f)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ f<<std::setiosflags(ios::left)<<std::setw(30)<<"x"
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(30)<<"y"
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(30)<<"z"
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<"scalar"
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<"v0"
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<"v1"
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<"v2"
|
|
|
+ <<endl;
|
|
|
+
|
|
|
+ for(int j=0; j<pointNum; j++)
|
|
|
+ {
|
|
|
+ (cutSource_->GetOutput())->GetPoint(j, p);
|
|
|
+
|
|
|
+ value = cutScalar->GetValue(j);
|
|
|
+
|
|
|
+ v = cutVector->GetTuple3(j);
|
|
|
+
|
|
|
+ f<<std::setiosflags(ios::left)<<std::setw(20)<<p[0]
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<p[1]
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<p[2]
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<value
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<v[0]
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<v[1]
|
|
|
+ <<std::setiosflags(ios::left)<<std::setw(20)<<v[2]
|
|
|
+ <<endl;
|
|
|
+ }
|
|
|
+ f.close();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get cut scalar data.(获取切面标量数据。)
|
|
|
+* @param: void
|
|
|
+* @ret: float array
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+vtkFloatArray* vtkVISUnSlice::GetCutScalarData(void)
|
|
|
+{
|
|
|
+ if(usedScalarIndex_ == -1)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ vtkFloatArray* cutScalar = vtkFloatArray::New();
|
|
|
+ cutScalar->SetNumberOfComponents(1);
|
|
|
+
|
|
|
+ if(usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if(_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ cutScalar->DeepCopy((cutSource_->GetOutput())->GetPointData()->GetScalars());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cutScalar->DeepCopy((cutSource_->GetOutput())->GetCellData()->GetScalars());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cutScalar->Modified();
|
|
|
+
|
|
|
+ return cutScalar;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get cut vector data.(获取切面矢量数据。)
|
|
|
+* @param: index(index of the vector array)
|
|
|
+* @ret: float array
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+vtkFloatArray* vtkVISUnSlice::GetCutVectorData(int index)
|
|
|
+{
|
|
|
+ if (index < 0 || index > 2)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(usedVectorIndex_ == -1)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ vtkFloatArray* vec = vtkFloatArray::New();
|
|
|
+ vec->SetNumberOfComponents(3);
|
|
|
+
|
|
|
+ if(usedVectorIndex_ != -1)
|
|
|
+ {
|
|
|
+ if(_source->vectorSource[usedVectorIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ vec->DeepCopy((cutSource_->GetOutput())->GetPointData()->GetVectors());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ vec->DeepCopy((cutSource_->GetOutput())->GetCellData()->GetVectors());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vec->Modified();
|
|
|
+
|
|
|
+ vtkFloatArray* cutVector = vtkFloatArray::New();
|
|
|
+ cutVector->SetNumberOfComponents(1);
|
|
|
+ cutVector->SetNumberOfTuples(vec->GetNumberOfTuples());
|
|
|
+ cutVector->CopyComponent(0, vec, index);
|
|
|
+ cutVector->Modified();
|
|
|
+
|
|
|
+ return cutVector;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get cut vector data.(获取切面矢量数据。)
|
|
|
+* @param: void
|
|
|
+* @ret: float array
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+vtkFloatArray* vtkVISUnSlice::GetCutVectorData(void)
|
|
|
+{
|
|
|
+ if(usedVectorIndex_ == -1)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ vtkFloatArray* cutVector = vtkFloatArray::New();
|
|
|
+ cutVector->SetNumberOfComponents(3);
|
|
|
+
|
|
|
+ if(usedVectorIndex_ != -1)
|
|
|
+ {
|
|
|
+ if(_source->vectorSource[usedVectorIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ cutVector->DeepCopy((cutSource_->GetOutput())->GetPointData()->GetVectors());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cutVector->DeepCopy((cutSource_->GetOutput())->GetCellData()->GetVectors());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cutVector->Modified();
|
|
|
+
|
|
|
+ return cutVector;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get cut point data by index.(按索引获取切割点数据。)
|
|
|
+* @param: index Indicate the coordinate(0-x,1-y,2-z)
|
|
|
+* @ret: float array
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+vtkFloatArray* vtkVISUnSlice::GetCutPointData(int index)
|
|
|
+{
|
|
|
+ if (index < 0 || index > 2)
|
|
|
+ {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ vtkFloatArray* cutPointData = vtkFloatArray::New();
|
|
|
+ cutPointData->SetNumberOfComponents(1);
|
|
|
+
|
|
|
+ int pointNum = (cutSource_->GetOutput())->GetNumberOfPoints();
|
|
|
+
|
|
|
+ double point[3];
|
|
|
+
|
|
|
+ for(int j=0; j<pointNum; j++)
|
|
|
+ {
|
|
|
+ (cutSource_->GetOutput())->GetPoint(j, point);
|
|
|
+
|
|
|
+ cutPointData->InsertNextValue(point[index]);
|
|
|
+ }
|
|
|
+ cutPointData->Modified();
|
|
|
+
|
|
|
+ return cutPointData;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Change slice scalar/vector data source(更改切片标量/矢量数据源)
|
|
|
+* @param: scalar
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifySliceSourceScalar(char* scalar)
|
|
|
+{
|
|
|
+ if (gridSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Grid Source are not Setted!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = -1;
|
|
|
+ if(scalar != NULL)
|
|
|
+ {
|
|
|
+ index = _source->GetScalarIndex(scalar);
|
|
|
+ }
|
|
|
+ if (index == -1)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Scalar data are not existed!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_source->scalarSource[index]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (gridSource_->GetPointData())->SetScalars(_source->scalarSource[index]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (gridSource_->GetCellData())->SetScalars(_source->cellScalarSource_[index]);
|
|
|
+ }
|
|
|
+ gridSource_->Modified();
|
|
|
+
|
|
|
+ usedScalarIndex_ = index;
|
|
|
+
|
|
|
+ //2011-05-10 zhuqin add begin.
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, _source->scalarRange[usedScalarIndex_][0],_source->scalarRange[usedScalarIndex_][1]);
|
|
|
+ bandedContourFilter_->ClippingOn();
|
|
|
+ bandedContourFilter_->Modified();
|
|
|
+ }
|
|
|
+ if (contourLinesFilter_ != NULL)
|
|
|
+ {
|
|
|
+ contourLinesFilter_->GenerateValues(conLevel_, _source->scalarRange[usedScalarIndex_][0],_source->scalarRange[usedScalarIndex_][1]);
|
|
|
+ contourLinesFilter_->Modified();
|
|
|
+ }
|
|
|
+ if (contourLabelFilter_!= NULL)
|
|
|
+ {
|
|
|
+ contourLabelFilter_->GenerateValues(conLevel_, _source->scalarRange[usedScalarIndex_][0],_source->scalarRange[usedScalarIndex_][1]);
|
|
|
+ contourLabelFilter_->Modified();
|
|
|
+ }
|
|
|
+ //2011-05-10 zhuqin add end.
|
|
|
+
|
|
|
+
|
|
|
+ for (int i= 0; i<6; i++)
|
|
|
+ {
|
|
|
+ if (i == 0 || i== 1 || i == 3)
|
|
|
+ {
|
|
|
+ if(sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->SetRange(_source->scalarRange[usedScalarIndex_][0],_source->scalarRange[usedScalarIndex_][1]);
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->Modified();
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarRange(_source->scalarRange[usedScalarIndex_][0],_source->scalarRange[usedScalarIndex_][1]);
|
|
|
+
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->Modified();
|
|
|
+ sliceActors_[i]->Modified();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Change slice scalar/vector data source(更改切片标量/矢量数据源)
|
|
|
+* @param: scalar
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifySliceSourceVector(char* vector)
|
|
|
+{
|
|
|
+ if (gridSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Grid Source are not Setted!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = -1;
|
|
|
+
|
|
|
+ if(vector != NULL)
|
|
|
+ {
|
|
|
+ index = _source->GetVectorIndex(vector);
|
|
|
+ }
|
|
|
+ if (index == -1)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Vector data are not existed!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ usedVectorIndex_ = index;
|
|
|
+
|
|
|
+ if(_source->vectorSource[index]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (gridSource_->GetPointData())->SetVectors(_source->vectorSource[index]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (gridSource_->GetCellData())->SetVectors(_source->cellVectorSource_[index]);
|
|
|
+ }
|
|
|
+ gridSource_->Modified();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create slice plane widget(创建切片平面小部件)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateSliceWidget()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double* bounds;
|
|
|
+ bounds = _source->GetSourceBounds();
|
|
|
+
|
|
|
+ planeOrigin_[0] = (bounds[0]+bounds[1])/2;
|
|
|
+ planeOrigin_[1] = (bounds[2]+bounds[3])/2;
|
|
|
+ planeOrigin_[2] = (bounds[4]+bounds[5])/2;
|
|
|
+
|
|
|
+ vtkImplicitPlaneWidget* planeWidget = vtkImplicitPlaneWidget::New();
|
|
|
+ planeWidget->SetInteractor(_renWin->GetInteractor());
|
|
|
+ planeWidget->SetPlaceFactor(1.0);
|
|
|
+
|
|
|
+ planeWidget->SetHandleSize(0.005);
|
|
|
+ planeWidget->SetDiagonalRatio(0.2);
|
|
|
+
|
|
|
+ planeWidget->GetOutlineProperty()->SetOpacity(0.0);
|
|
|
+ planeWidget->GetEdgesProperty()->SetOpacity(0.0);
|
|
|
+
|
|
|
+ planeWidget->GetPlane(slicePlane_);
|
|
|
+ planeWidget->SetInputData(cutSource_->GetOutput());
|
|
|
+
|
|
|
+ planeWidget->TubingOff();
|
|
|
+ //planeWidget->OutsideBoundsOff();
|
|
|
+ planeWidget->SetOrigin(planeOrigin_[0], planeOrigin_[1], planeOrigin_[2]);
|
|
|
+ planeWidget->PlaceWidget(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
|
|
|
+ planeWidget->On();
|
|
|
+
|
|
|
+ planeWidget_ = planeWidget;
|
|
|
+
|
|
|
+ vtkCallbackCommand *cc = vtkCallbackCommand::New();
|
|
|
+ cc->SetCallback(GenerateSliceProData);
|
|
|
+ cc->SetClientData(this);
|
|
|
+
|
|
|
+ planeWidget->AddObserver(vtkCommand::InteractionEvent, cc);
|
|
|
+
|
|
|
+ ShowOffSlicePlane();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Generate Slice ProData(生成切片ProData)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::GenerateSliceProData(vtkObject *caller, unsigned long, void* obj, void *)
|
|
|
+{
|
|
|
+ vtkVISUnSlice* usObj = (vtkVISUnSlice*)obj;
|
|
|
+
|
|
|
+ if (usObj->planeWidget_ == NULL)
|
|
|
+ {
|
|
|
+ usObj->ErrorInfo(1,"Plane Widget Not Created");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ usObj->planeWidget_->GetPlane(usObj->slicePlane_);
|
|
|
+
|
|
|
+ //int num;
|
|
|
+ //num = cutSource_->GetOutput()->GetNumberOfPoints();
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show the slice plane(显示切片平面)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnSlicePlane()
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ planeWidget_->DrawPlaneOn();
|
|
|
+ planeWidget_->UpdatePlacement();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: hide the slice plane(隐藏切片平面)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffSlicePlane()
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ planeWidget_->DrawPlaneOff();
|
|
|
+ planeWidget_->UpdatePlacement();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show On Slice Plane Widget(显示切片平面小部件)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnSlicePlaneWidget()
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ planeWidget_->On();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cutActor_)
|
|
|
+ {
|
|
|
+ cutActor_->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show Off Slice Plane Widget(隐藏切片平面小部件)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffSlicePlaneWidget()
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ planeWidget_->Off();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cutActor_)
|
|
|
+ {
|
|
|
+ cutActor_->VisibilityOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set the normal of the slice plane(设置切片平面的法线)
|
|
|
+* @param: xyz
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetSlicePlaneNormal(double nx, double ny, double nz)
|
|
|
+{
|
|
|
+ if (nx == 0 && ny == 0 && nz == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ planeNormal_[0] = nx;
|
|
|
+ planeNormal_[1] = ny;
|
|
|
+ planeNormal_[2] = nz;
|
|
|
+
|
|
|
+ slicePlane_->SetNormal(nx, ny, nz);
|
|
|
+ planeWidget_->SetNormal(nx, ny, nz);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set the normal of the slice plane(设置切片平面的法线到x坐标轴)
|
|
|
+* @param: x
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetSlicePlaneNormalToX()
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ slicePlane_->SetNormal(1, 0, 0);
|
|
|
+ planeWidget_->SetNormal(1, 0, 0);
|
|
|
+
|
|
|
+ planeNormal_[0] = 1.0;
|
|
|
+ planeNormal_[1] = 0;
|
|
|
+ planeNormal_[2] = 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set the normal of the slice plane(设置切片平面的法线到y坐标轴)
|
|
|
+* @param: y
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetSlicePlaneNormalToY()
|
|
|
+{
|
|
|
+ if (planeWidget_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Plane Widget Not Created");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ slicePlane_->SetNormal(0, 1, 0);
|
|
|
+ planeWidget_->SetNormal(0, 1, 0);
|
|
|
+
|
|
|
+ planeNormal_[0] = 0;
|
|
|
+ planeNormal_[1] = 1.0;
|
|
|
+ planeNormal_[2] = 0;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set the normal of the slice plane(设置切片平面的法线到z坐标轴)
|
|
|
+* @param: z
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetSlicePlaneNormalToZ()
|
|
|
+{
|
|
|
+ if (planeWidget_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Plane Widget Not Created");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ slicePlane_->SetNormal(0, 0, 1);
|
|
|
+ planeWidget_->SetNormal(0, 0, 1);
|
|
|
+
|
|
|
+ planeNormal_[0] = 0;
|
|
|
+ planeNormal_[1] = 0;
|
|
|
+ planeNormal_[2] = 1.0;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get the normal direction of the slice plane(获取切片平面的法线方向)
|
|
|
+* @param: y
|
|
|
+* @ret: double[3]contains the normal direction
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+double* vtkVISUnSlice::GetSlicePlaneNormal()
|
|
|
+{
|
|
|
+ return this->planeNormal_;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set the slice plane origin(设置切片平面原点)
|
|
|
+* @param: xyz
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetSlicePlaneOrigin(double ox, double oy, double oz)
|
|
|
+{
|
|
|
+ if (planeWidget_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Plane Widget Not Created");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ slicePlane_->SetOrigin(ox, oy, oz);
|
|
|
+ planeWidget_->SetOrigin(ox, oy, oz);
|
|
|
+
|
|
|
+ planeOrigin_[0] = ox;
|
|
|
+ planeOrigin_[0] = oy;
|
|
|
+ planeOrigin_[0] = oz;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get the slice plane origin(获取切片平面原点)
|
|
|
+* @param: void
|
|
|
+* @ret: double[3] contains the origin
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+double* vtkVISUnSlice::GetSlicePlaneOrigin()
|
|
|
+{
|
|
|
+ return this->planeOrigin_;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice display pipeline(创建UnSlice显示管线)
|
|
|
+* @param: void
|
|
|
+* @ret: double[3] contains the origin
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceContourDisplay()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ //cout<<range[0]<<" "<<range[1]<<endl;
|
|
|
+
|
|
|
+ //cout<<"cut num: "<<(cutSource_->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+ vtkGeometryFilter *geoFilter = vtkGeometryFilter::New();
|
|
|
+ geoFilter->SetInputData(cutSource_->GetOutput());
|
|
|
+ geoFilter->Update();
|
|
|
+
|
|
|
+ //cout<<"geo num: "<<(geoFilter->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+ vtkBandedPolyDataContourFilter *conFilter = vtkBandedPolyDataContourFilter::New();
|
|
|
+ conFilter->SetInputData(geoFilter->GetOutput());
|
|
|
+ conFilter->GenerateValues(conLevel_, range[0], range[1]);
|
|
|
+ conFilter->ClippingOn();
|
|
|
+ conFilter->Modified();
|
|
|
+ conFilter->Update();
|
|
|
+
|
|
|
+ //cout<<"con num: "<<(conFilter->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ /*mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+
|
|
|
+ if(_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ //cout<<"test here 3333"<<endl;
|
|
|
+ mapper->SetInputConnection(conFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ mapper->SetScalarRange(range[0],range[1]);
|
|
|
+
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkLookupTable *table = (vtkLookupTable*)mapper->GetLookupTable();
|
|
|
+ table->GetHueRange(range);
|
|
|
+ table->SetHueRange(range[1],range[0]);
|
|
|
+ table->SetNumberOfColors(conLevel_);*/
|
|
|
+ mapper->SetInputData(_source->unstruGrid);
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);actor->GetProperty()->SetColor(1,0,0);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceActors_[0] = actor;
|
|
|
+
|
|
|
+ //sliceTable_[0] = table;
|
|
|
+
|
|
|
+ bandedContourFilter_ = conFilter;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show On UnSlice Display(显示UNslice)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnUnSliceContourDisplay()
|
|
|
+{
|
|
|
+ if (sliceActors_[0] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[0]->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show Off UnSlice Display(关闭UNslice显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffUnSliceContourDisplay()
|
|
|
+{
|
|
|
+ if (sliceActors_[0] != NULL)
|
|
|
+ {
|
|
|
+
|
|
|
+ sliceActors_[0]->VisibilityOff();
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Delete UnSlice Display(删除UNslice显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::DeleteUnSliceContourDisplay()
|
|
|
+{
|
|
|
+ if (sliceActors_[0] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[0]->VisibilityOff();
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(sliceActors_[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceActors_[0]->Delete();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Contour Lines Display(创建取消切片等高线显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceContourLinesDisplay()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkContourFilter *conFilter = vtkContourFilter::New();
|
|
|
+ conFilter->SetInputConnection(cutSource_->GetOutputPort());
|
|
|
+ conFilter->GenerateValues(conLevel_, range[0],range[1]);
|
|
|
+ conFilter->Update();
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+ mapper->SetInputConnection(conFilter->GetOutputPort());
|
|
|
+ mapper->SetScalarRange(range[0],range[1]);
|
|
|
+
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkLookupTable *table = (vtkLookupTable*)mapper->GetLookupTable();
|
|
|
+ table->GetHueRange(range);
|
|
|
+ table->SetHueRange(range[1],range[0]);
|
|
|
+ table->SetNumberOfColors(conLevel_);
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ contourLinesFilter_ = conFilter;
|
|
|
+ /*if (sliceMapper_ != NULL)
|
|
|
+ {
|
|
|
+ sliceMapper_->AddItem (mapper);
|
|
|
+ }*/
|
|
|
+ sliceActors_[1] = actor;
|
|
|
+ sliceTable_[1] = table;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show On UnSlice Contour Lines Display(等高线显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnUnSliceContourLinesDisplay()
|
|
|
+{
|
|
|
+ if(sliceActors_[1] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[1]->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show On UnSlice Contour Lines Display(关闭等高线显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffUnSliceContourLinesDisplay()
|
|
|
+{
|
|
|
+ if(sliceActors_[1] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[1]->VisibilityOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Delete UnSlice Contour Lines Display(删除等高线显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::DeleteUnSliceCOntourLinesDisplay()
|
|
|
+{
|
|
|
+ if (sliceActors_[1] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[1]->VisibilityOff();
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(sliceActors_[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceActors_[1]->Delete();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Contour Lines Label Display(创建UNslice等高线标签显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceContourLinesLabelDisplay()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ vtkContourFilter *labelFilter = vtkContourFilter::New();
|
|
|
+ labelFilter->SetInputConnection(cutSource_->GetOutputPort());
|
|
|
+ labelFilter->GenerateValues(conLevel_, range[0],range[1]);
|
|
|
+ labelFilter->Update();
|
|
|
+
|
|
|
+ int numPoints = labelFilter->GetOutput()->GetNumberOfPoints();
|
|
|
+ vtkMaskPoints *mask = vtkMaskPoints::New();
|
|
|
+ mask->SetInputConnection(labelFilter->GetOutputPort());
|
|
|
+ mask->SetOnRatio((double)numPoints/conLevel_);
|
|
|
+ mask->SetMaximumNumberOfPoints(50);
|
|
|
+ mask->RandomModeOn();
|
|
|
+
|
|
|
+ vtkSelectVisiblePoints *visPoints = vtkSelectVisiblePoints::New();
|
|
|
+ visPoints->SetInputConnection(mask->GetOutputPort());
|
|
|
+ visPoints->SetRenderer(_renderer);
|
|
|
+
|
|
|
+ vtkLabeledDataMapper *mapper = vtkLabeledDataMapper::New();
|
|
|
+ mapper->GlobalWarningDisplayOff();
|
|
|
+ mapper->SetInputConnection(mask->GetOutputPort());
|
|
|
+ mapper->SetLabelModeToLabelScalars();
|
|
|
+ mapper->GetLabelTextProperty()->SetFontFamilyToArial();
|
|
|
+ mapper->GetLabelTextProperty()->SetFontSize(10);
|
|
|
+ mapper->GetLabelTextProperty()->SetColor(1,1,1);
|
|
|
+
|
|
|
+ vtkActor2D *actor = vtkActor2D::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor2D(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ contourLabelFilter_ = labelFilter;
|
|
|
+ sliceActors_[2] = (vtkActor*) actor;
|
|
|
+ /*if (sliceMapper_ != NULL)
|
|
|
+ {
|
|
|
+ sliceMapper_->AddItem (mapper);
|
|
|
+ }*/
|
|
|
+ sliceTable_[2] = NULL;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show on UnSlice Contour Lines Label Display(打开UNslice等高线标签显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnUnSliceContourLinesLabelDisplay()
|
|
|
+{
|
|
|
+ if(sliceActors_[2] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[2]->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Show off UnSlice Contour Lines Label Display(关闭UNslice等高线标签显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffUnSliceContourLinesLabelDisplay()
|
|
|
+{
|
|
|
+ if(sliceActors_[2] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[2]->VisibilityOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: delete UnSlice Contour Lines Label Display(删除UNslice等高线标签显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::DeleteUnSliceContourLinesLabelDisplay()
|
|
|
+{
|
|
|
+ if (sliceActors_[2] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[2]->VisibilityOff();
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(sliceActors_[2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceActors_[2]->Delete();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Vector Display(创建UNslice矢量显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceVectorDisplay()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkGlyphSource2D *glyph2D = vtkGlyphSource2D::New();
|
|
|
+ glyph2D->SetGlyphTypeToArrow();
|
|
|
+ glyph2D->SetScale(1.0);
|
|
|
+ glyph2D->SetScale2(1.5);
|
|
|
+ glyph2D->SetCenter(0, 0, 0);
|
|
|
+ glyph2D->FilledOff();
|
|
|
+
|
|
|
+ vtkGlyph3D *glyph3D = vtkGlyph3D::New();
|
|
|
+ glyph3D->SetInputConnection(cutSource_->GetOutputPort());
|
|
|
+ glyph3D->SetSourceData(glyph2D->GetOutput());
|
|
|
+ glyph3D->ScalingOn();
|
|
|
+ glyph3D->ClampingOn();
|
|
|
+ glyph3D->GeneratePointIdsOff();
|
|
|
+ glyph3D->SetIndexModeToOff();
|
|
|
+ glyph3D->SetVectorModeToUseVector();
|
|
|
+ glyph3D->SetScaleFactor(0.2);
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ mapper->SetInputData(glyph3D->GetOutput());
|
|
|
+ mapper->SetScalarRange(range[0], range[1]);
|
|
|
+ mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkLookupTable *table = (vtkLookupTable*)mapper->GetLookupTable();
|
|
|
+ table->GetHueRange(range);
|
|
|
+ table->SetHueRange(range[1], range[0]);
|
|
|
+ table->SetNumberOfColors(conLevel_);
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+ /*if (sliceMapper_ != NULL)
|
|
|
+ {
|
|
|
+ sliceMapper_->AddItem (mapper);
|
|
|
+ }*/
|
|
|
+ sliceActors_[3] = actor;
|
|
|
+ sliceTable_[3] = table;
|
|
|
+ sliceGlyph2D_ = glyph2D;
|
|
|
+ sliceGlyph3D_ = glyph3D;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: show on UnSlice Vector Display(打开UNslice矢量显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnUnSliceVectorDisplay()
|
|
|
+{
|
|
|
+ if(sliceActors_[3] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[3]->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: show off UnSlice Vector Display(关闭UNslice矢量显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffUnSliceVectorDisplay()
|
|
|
+{
|
|
|
+ if(sliceActors_[3] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[3]->VisibilityOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Delete UnSlice Vector Display(删除UNslice矢量显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::DeleteUnSliceVectorDisplay()
|
|
|
+{
|
|
|
+ if (sliceActors_[3] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[3]->VisibilityOff();
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->RemoveActor(sliceActors_[3]);
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceActors_[3]->Delete();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Shade Display(创建UnSlice着色显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceShadeDisplay()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkGeometryFilter *geoFilter=vtkGeometryFilter::New();
|
|
|
+ geoFilter->SetInputData(cutSource_->GetOutput());
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper=vtkDataSetMapper::New();
|
|
|
+ mapper->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ mapper->ScalarVisibilityOff();
|
|
|
+
|
|
|
+ vtkActor *actor=vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+ actor->GetProperty()->SetColor(shadeColor_[0], shadeColor_[1], shadeColor_[2]);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sliceMapper_ != NULL)
|
|
|
+ {
|
|
|
+ sliceMapper_->AddItem (mapper);
|
|
|
+ }
|
|
|
+ sliceTable_[4] = NULL;
|
|
|
+ sliceActors_[4] = actor;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Shade Color(修改UnSlice着色颜色)
|
|
|
+* @param: c0-r c1-g c2-b
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceShadeColor(double c0, double c1, double c2)
|
|
|
+{
|
|
|
+ if (sliceActors_[4]!=NULL)
|
|
|
+ {
|
|
|
+ shadeColor_[0] = c0;
|
|
|
+ shadeColor_[1] = c1;
|
|
|
+ shadeColor_[2] = c2;
|
|
|
+
|
|
|
+ (sliceActors_[4]->GetProperty())->SetColor(c0, c1, c2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: show on UnSlice Shade Color(打开UnSlice着色颜色)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnUnSliceShade()
|
|
|
+{
|
|
|
+ if(sliceActors_[4] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[4]->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: show off UnSlice Shade Color(关闭UnSlice着色颜色)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffUnSliceShade()
|
|
|
+{
|
|
|
+ if(sliceActors_[4] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[4]->VisibilityOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Mesh Display(创建unslice网格显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceMeshDisplay()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkGeometryFilter *geoFilter=vtkGeometryFilter::New();
|
|
|
+ geoFilter->SetInputData(cutSource_->GetOutput());
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper=vtkDataSetMapper::New();
|
|
|
+ mapper->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ mapper->ScalarVisibilityOff();
|
|
|
+
|
|
|
+ vtkActor *actor=vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+ actor->GetProperty()->SetColor(meshColor_[0], meshColor_[1], meshColor_[2]);
|
|
|
+ (actor->GetProperty())->SetRepresentationToWireframe();
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sliceMapper_ != NULL)
|
|
|
+ {
|
|
|
+ sliceMapper_->AddItem (mapper);
|
|
|
+ }
|
|
|
+ sliceTable_[5] = NULL;
|
|
|
+ sliceActors_[5] = actor;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Mesh Color(修改unslice网格显示)
|
|
|
+* @param: c0-r c1-g c2-b
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceMeshColor(double c0, double c1, double c2)
|
|
|
+{
|
|
|
+ if (sliceActors_[5]!=NULL)
|
|
|
+ {
|
|
|
+ shadeColor_[0] = c0;
|
|
|
+ shadeColor_[1] = c1;
|
|
|
+ shadeColor_[2] = c2;
|
|
|
+
|
|
|
+ (sliceActors_[5]->GetProperty())->SetColor(c0, c1, c2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: show on UnSlice Mesh Color(打开unslice网格显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOnUnSliceMesh()
|
|
|
+{
|
|
|
+ if(sliceActors_[5] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[5]->VisibilityOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: show off UnSlice Mesh Color(关闭unslice网格显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ShowOffUnSliceMesh()
|
|
|
+{
|
|
|
+ if(sliceActors_[5] != NULL)
|
|
|
+ {
|
|
|
+ sliceActors_[5]->VisibilityOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set UnSlice Contour Opacity(设置UnSlice轮廓不透明度)
|
|
|
+* @param: value -- opacity value
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetUnSliceContourOpacity(double value)
|
|
|
+{
|
|
|
+ if (sliceActors_[0] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[0]->GetProperty())->SetOpacity(value);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get UnSlice Contour Opacity(获取UnSlice轮廓不透明度)
|
|
|
+* @param: void
|
|
|
+* @ret: opacity value
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+double vtkVISUnSlice::GetUnSliceContourOpacity()
|
|
|
+{
|
|
|
+ if (sliceActors_[0] != NULL)
|
|
|
+ {
|
|
|
+ return (sliceActors_[0]->GetProperty())->GetOpacity();
|
|
|
+ }
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Vector Color Mode(修改UnSlice矢量颜色模式)
|
|
|
+* @param: ColorByScale ColorByScalar ColorByVector
|
|
|
+* @ret: opacity value
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceVectorColorMode(char* mode)
|
|
|
+{
|
|
|
+
|
|
|
+ if (sliceGlyph3D_ != NULL)
|
|
|
+ {
|
|
|
+ if (strcmp(mode, "ColorByScale") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetColorModeToColorByScale();
|
|
|
+ }
|
|
|
+ else if (strcmp(mode, "ColorByScalar") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetColorModeToColorByScalar();
|
|
|
+ }
|
|
|
+ else if (strcmp(mode, "ColorByVector") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetColorModeToColorByVector();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetColorModeToColorByScalar();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Vector Scale Mode(修改UnSlice矢量缩放模式)
|
|
|
+* @param: mode -- Scale mode "ScaleByScalar" "ScaleByVector" "ScaleByVectorComponents" "DataScalingOff"
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceVectorScaleMode(char* mode)
|
|
|
+{
|
|
|
+
|
|
|
+ if (sliceGlyph3D_ != NULL)
|
|
|
+ {
|
|
|
+ if (strcmp(mode, "ScaleByScalar") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetScaleModeToScaleByScalar();
|
|
|
+ }
|
|
|
+ else if (strcmp(mode, "ScaleByVectorComponents") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetScaleModeToScaleByVector();
|
|
|
+ }
|
|
|
+ else if (strcmp(mode, "ColorByVector") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetScaleModeToScaleByVectorComponents();
|
|
|
+ }
|
|
|
+ else if (strcmp(mode, "DataScalingOff") == 0)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetScaleModeToDataScalingOff ();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetScaleModeToScaleByScalar();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Vector Scale factor(修改UnSlice矢量缩放因子)
|
|
|
+* @param: scale -- Scale factor
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceVectorScaleFactor(double scaleFactor)
|
|
|
+{
|
|
|
+
|
|
|
+ if (sliceGlyph3D_ != NULL)
|
|
|
+ {
|
|
|
+ sliceGlyph3D_->SetScaleFactor(scaleFactor);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set UnSlice Vector Filled On(将UnSlice矢量填充设置为打开)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetUnSliceVectorFilledOn()
|
|
|
+{
|
|
|
+ if (sliceGlyph2D_ != NULL)
|
|
|
+ {
|
|
|
+ sliceGlyph2D_->FilledOn();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set UnSlice Vector Filled Off(将UnSlice矢量填充设置为关闭)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetUnSliceVectorFilledOff()
|
|
|
+{
|
|
|
+ if (sliceGlyph2D_ != NULL)
|
|
|
+ {
|
|
|
+ sliceGlyph2D_->FilledOff();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Vector Position(修改UNslice矢量位置)
|
|
|
+* @param: p0-x p1-y p2-z
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceVectorPosition(double p0, double p1, double p2)
|
|
|
+{
|
|
|
+
|
|
|
+ if (sliceGlyph2D_ != NULL)
|
|
|
+ {
|
|
|
+ sliceGlyph2D_->SetCenter(p0, p1, p2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Shade(修改UNslice着色)
|
|
|
+* @param: value -- opacity value
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceShadeOpacity(double value)
|
|
|
+{
|
|
|
+ if (sliceActors_[4] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[4]->GetProperty())->SetOpacity(value);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Contour Level(修改UNslice等高线水准)
|
|
|
+* @param: level
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceContourLevel(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;
|
|
|
+ }
|
|
|
+
|
|
|
+ conLevel_ = level;
|
|
|
+
|
|
|
+ if (sliceTable_[0] != NULL)
|
|
|
+ {
|
|
|
+ sliceTable_[0]->SetNumberOfColors(conLevel_);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, scalarRange_[0], scalarRange_[1]);
|
|
|
+ bandedContourFilter_->ClippingOn();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (contourLinesFilter_ != NULL)
|
|
|
+ {
|
|
|
+ contourLinesFilter_->GenerateValues(conLevel_, scalarRange_[0], scalarRange_[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sliceTable_[1] != NULL)
|
|
|
+ {
|
|
|
+ sliceTable_[1]->SetNumberOfColors(conLevel_);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (contourLabelFilter_!= NULL)
|
|
|
+ {
|
|
|
+ contourLabelFilter_->GenerateValues(conLevel_, scalarRange_[0], scalarRange_[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Vector Position(修改UNslice矢量位置)
|
|
|
+* @param: lineWidth -- line width
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceMeshLineWidth(double lineWidth)
|
|
|
+{
|
|
|
+ if (sliceActors_[5]!=NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[5]->GetProperty())->SetLineWidth(lineWidth);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify UnSlice Lines Width(修改UNslice等高线宽度)
|
|
|
+* @param: lineWidth -- line width
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyUnSliceContourLinesWidth(double lineWidth)
|
|
|
+{
|
|
|
+ if (sliceActors_[1]!=NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[1]->GetProperty())->SetLineWidth(lineWidth);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get slice plane widget(获取切片平面小部件)
|
|
|
+* @param: void
|
|
|
+* @ret: vtkImplicitPlaneWidget
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+vtkImplicitPlaneWidget* vtkVISUnSlice::GetSlicePlaneWidget()
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ return this->planeWidget_;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get slice plane(获取切片平面)
|
|
|
+* @param: void
|
|
|
+* @ret: vtkPlane
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+vtkPlane* vtkVISUnSlice::GetSlicePlane()
|
|
|
+{
|
|
|
+ if(slicePlane_ != NULL)
|
|
|
+ {
|
|
|
+ return this->slicePlane_;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set Slice PlaneWidget Handle Size(设置切片平面小部件句柄大小)
|
|
|
+* @param: size
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifySlicePlaneWidgetHandleSize(double size)
|
|
|
+{
|
|
|
+ if (planeWidget_ != NULL)
|
|
|
+ {
|
|
|
+ planeWidget_->SetHandleSize(size);
|
|
|
+ planeWidget_->UpdatePlacement();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Modify Display Scalar Range(修改显示标量范围)
|
|
|
+* @param: min Scalar max Scalar
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyDisplayScalarRange(double min,double max)
|
|
|
+{
|
|
|
+ scalarRange_[0] = min;
|
|
|
+ scalarRange_[1] = max;
|
|
|
+ if (min == max) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ //cout<<"test here 4444"<<endl;
|
|
|
+
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, min, max);
|
|
|
+ bandedContourFilter_->Modified();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (int i= 0; i<6; i++)
|
|
|
+ {
|
|
|
+ if (i == 0 || i== 1 || i == 3)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->SetRange(min, max);
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->Modified();
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarRange(min, max);
|
|
|
+ (sliceActors_[i]->GetMapper())->Modified();
|
|
|
+
|
|
|
+ sliceActors_[i]->Modified();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Clipping On Slice Contour Display(切片轮廓显示上的剪裁)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ClippingOnSliceContourDisplay()
|
|
|
+{
|
|
|
+
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, scalarRange_[0], scalarRange_[1] );
|
|
|
+ bandedContourFilter_->ClippingOn();
|
|
|
+ bandedContourFilter_->Modified();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (int i= 0; i<6; i++)
|
|
|
+ {
|
|
|
+ if (i == 0 || i== 1 || i == 3)
|
|
|
+ {
|
|
|
+ if(sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->SetRange(scalarRange_[0], scalarRange_[1]);
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->Modified();
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarRange(scalarRange_[0], scalarRange_[1]);
|
|
|
+ (sliceActors_[i]->GetMapper())->Modified();
|
|
|
+
|
|
|
+ sliceActors_[i]->Modified();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Clipping Off Slice Contour Display(剪裁切片轮廓显示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ClippingOffSliceContourDisplay()
|
|
|
+{
|
|
|
+
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, scalarRange_[0], scalarRange_[1] );
|
|
|
+ bandedContourFilter_->ClippingOff();
|
|
|
+ bandedContourFilter_->Modified();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i= 0; i<6; i++)
|
|
|
+ {
|
|
|
+ if (i == 0 || i== 1 || i == 3)
|
|
|
+ {
|
|
|
+ if(sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->SetRange(scalarRange_[0], scalarRange_[1]);
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->Modified();
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarRange(scalarRange_[0], scalarRange_[1]);
|
|
|
+ (sliceActors_[i]->GetMapper())->Modified();
|
|
|
+
|
|
|
+ sliceActors_[i]->Modified();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Set slice source(设置切片源)
|
|
|
+* @param: uGrid:slice source. yValue:slice value of y.
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+bool vtkVISUnSlice::SetBoundSliceSource(vtkUnstructuredGrid* uGrid , double yValue)
|
|
|
+{
|
|
|
+ if (uGrid==NULL)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ uGrid->Modified();
|
|
|
+
|
|
|
+ double pBound[6];
|
|
|
+ uGrid->GetBounds(pBound);
|
|
|
+
|
|
|
+ if (yValue<pBound[2] || yValue>pBound[3])
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkPlane *plane = vtkPlane::New();
|
|
|
+ double planeNormal[3];
|
|
|
+ planeNormal[0] = 0.0;
|
|
|
+ planeNormal[1] = 1.0;
|
|
|
+ planeNormal[2] = 0.0;
|
|
|
+ plane->SetNormal(planeNormal[0], planeNormal[1], planeNormal[2]);
|
|
|
+
|
|
|
+ double planeCoord[3];
|
|
|
+ planeCoord[0] = 0.0;
|
|
|
+ planeCoord[1] = yValue;
|
|
|
+ planeCoord[2] = 0.0;
|
|
|
+ plane->SetOrigin(planeCoord[0],planeCoord[1],planeCoord[2]);
|
|
|
+
|
|
|
+ vtkCutter *cutter = vtkCutter::New();
|
|
|
+ cutter->SetInputData(uGrid);
|
|
|
+ cutter->SetCutFunction(plane);
|
|
|
+ cutter->GenerateCutScalarsOff();
|
|
|
+ cutter->SetSortByToSortByCell();
|
|
|
+ cutter->Update();
|
|
|
+
|
|
|
+ vtkIdType n = cutter->GetOutput()->GetNumberOfPoints();
|
|
|
+ cutSource_ = cutter;
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Get max value of X,and Set the point data source.(获取X的最大值,然后设置点数据源。)
|
|
|
+* @param: Points:point data source. max value of X.
|
|
|
+* @ret: bool
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+bool vtkVISUnSlice::GetXMaxPointData(double* xMax,vtkPoints* Points)
|
|
|
+{
|
|
|
+ cutSource_->Update();
|
|
|
+ vtkFloatArray* cutPointData = vtkFloatArray::New();
|
|
|
+ cutPointData->SetNumberOfComponents(1);
|
|
|
+
|
|
|
+ int pointNum = (cutSource_->GetOutput())->GetNumberOfPoints();
|
|
|
+ if (pointNum <= 0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkDoubleArray* xVector = vtkDoubleArray::New();
|
|
|
+ double point[3];
|
|
|
+
|
|
|
+ for (int j=0; j<pointNum; j++)
|
|
|
+ {
|
|
|
+ (cutSource_->GetOutput())->GetPoint(j, point);
|
|
|
+ xVector->InsertNextValue(point[0]);
|
|
|
+ Points->InsertNextPoint(point[0],point[1],point[2]);
|
|
|
+ }
|
|
|
+ vtkSortDataArray::Sort(xVector);
|
|
|
+ //cout<<"x max ="<<xVector[xVector.size()-1]<<endl;
|
|
|
+ cutPointData->Modified();
|
|
|
+ (*xMax) = xVector->GetValue(xVector->GetMaxId());
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: SetSliceSource_FD(设置切片源。)
|
|
|
+* @param: scalar vector
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::SetSliceSource_FD(char* scalar, char* vector)
|
|
|
+{
|
|
|
+ int index1 = -1;
|
|
|
+ int index2 = -1;
|
|
|
+
|
|
|
+ if(scalar != NULL)
|
|
|
+ {
|
|
|
+ index1 = _source->GetScalarIndex(scalar);
|
|
|
+ }
|
|
|
+ if(vector != NULL)
|
|
|
+ {
|
|
|
+ index2 = _source->GetVectorIndex(vector);
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkUnstructuredGrid *unGrid = vtkUnstructuredGrid::New();
|
|
|
+ unGrid->DeepCopy(_source->unstruGrid);
|
|
|
+
|
|
|
+ if (index1 != -1)
|
|
|
+ {
|
|
|
+ usedScalarIndex_ = index1;
|
|
|
+
|
|
|
+ scalarSource_ = vtkDoubleArray::New();
|
|
|
+ if(_source->scalarSource[index1]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ scalarSource_->DeepCopy(_source->scalarSource[index1]);
|
|
|
+ (unGrid->GetPointData())->SetScalars(scalarSource_);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ scalarSource_->DeepCopy(_source->cellScalarSource_[index1]);
|
|
|
+ (unGrid->GetCellData())->SetScalars(scalarSource_);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (index2 != -1)
|
|
|
+ {
|
|
|
+ usedVectorIndex_ = index2;
|
|
|
+
|
|
|
+ if(_source->vectorSource[index2]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (unGrid->GetPointData())->SetVectors(_source->vectorSource[index2]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (unGrid->GetCellData())->SetVectors(_source->cellVectorSource_[index2]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unGrid->Modified();
|
|
|
+
|
|
|
+ vtkPlane *plane = vtkPlane::New();
|
|
|
+ plane->SetNormal(planeNormal_[0], planeNormal_[1], planeNormal_[2]);
|
|
|
+
|
|
|
+ vtkCutter *cutter = vtkCutter::New();
|
|
|
+ cutter->SetInputData(unGrid);
|
|
|
+ cutter->SetCutFunction(plane);
|
|
|
+ cutter->GenerateCutScalarsOff();
|
|
|
+ cutter->SetSortByToSortByCell();
|
|
|
+ cutter->Update();
|
|
|
+
|
|
|
+ //cout<<"test here 1111"<<(cutter->GetOutput())->GetNumberOfPoints()<<endl;
|
|
|
+
|
|
|
+ gridSource_ = unGrid;
|
|
|
+ cutSource_ = cutter;
|
|
|
+ slicePlane_ = plane;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief:Create Slice Widget_FD(创造切片窗口)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateSliceWidget_FD()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double* bounds;
|
|
|
+ bounds = _source->GetSourceBounds();
|
|
|
+
|
|
|
+ planeOrigin_[0] = (bounds[0]+bounds[1])/2;
|
|
|
+ planeOrigin_[1] = (bounds[2]+bounds[3])/2;
|
|
|
+ planeOrigin_[2] = (bounds[4]+bounds[5])/2;
|
|
|
+
|
|
|
+ vtkImplicitPlaneWidget* planeWidget = vtkImplicitPlaneWidget::New();
|
|
|
+ planeWidget->SetInteractor(_renWin->GetInteractor());
|
|
|
+ planeWidget->SetPlaceFactor(1.0);
|
|
|
+
|
|
|
+ planeWidget->SetHandleSize(0.005);
|
|
|
+ planeWidget->SetDiagonalRatio(0.2);
|
|
|
+
|
|
|
+ planeWidget->GetPlane(slicePlane_);
|
|
|
+ planeWidget->SetInputData(cutSource_->GetOutput());
|
|
|
+
|
|
|
+ planeWidget->TubingOff();
|
|
|
+ //add begin
|
|
|
+ planeWidget->GetEdgesProperty()->SetLineWidth(2.0);
|
|
|
+ planeWidget->GetPlaneProperty()->SetColor(0.5, 0.5, 0.5);
|
|
|
+ planeWidget->GetPlaneProperty()->SetOpacity(0.5);
|
|
|
+ planeWidget->GetSelectedPlaneProperty()->SetOpacity(0.5);
|
|
|
+ planeWidget->OutlineTranslationOff();
|
|
|
+
|
|
|
+ planeWidget->PlaceWidget(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
|
|
|
+ planeWidget->SetOrigin(planeOrigin_[0], planeOrigin_[1], planeOrigin_[2]);
|
|
|
+ slicePlane_->SetOrigin(planeOrigin_[0], planeOrigin_[1], planeOrigin_[2]);
|
|
|
+ vtkFloatArray *arry = GetCutScalarData();
|
|
|
+ if (arry) arry->GetRange(scalarRange_);
|
|
|
+ //add end
|
|
|
+ planeWidget->On();
|
|
|
+
|
|
|
+ planeWidget_ = planeWidget;
|
|
|
+
|
|
|
+ vtkCallbackCommand *cc = vtkCallbackCommand::New();
|
|
|
+ cc->SetCallback(GenerateSliceProData_FD);
|
|
|
+ cc->SetClientData(this);
|
|
|
+
|
|
|
+ planeWidget->AddObserver(vtkCommand::InteractionEvent, cc);
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: GenerateSliceProData_FD(生成切片数据)
|
|
|
+* @param: vtkObject
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::GenerateSliceProData_FD(vtkObject *caller, unsigned long, void* obj, void *)
|
|
|
+{
|
|
|
+ vtkVISUnSlice* usObj = (vtkVISUnSlice*)obj;
|
|
|
+
|
|
|
+ if (usObj->planeWidget_ == NULL)
|
|
|
+ {
|
|
|
+ usObj->ErrorInfo(1,"Plane Widget Not Created");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ usObj->planeWidget_->GetPlane(usObj->slicePlane_);
|
|
|
+ //add begin. when cut plane moving, update the cut plane's scalar range
|
|
|
+ double r[2];
|
|
|
+ vtkFloatArray *arry = usObj->GetCutScalarData();
|
|
|
+ if (arry) arry->GetRange(r);
|
|
|
+ usObj->ModifyDisplayScalarRange_FD(r[0], r[1]);
|
|
|
+ //add end
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Contour Display_FD(创造切片等高线展示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceContourDisplay_FD()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ //range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ //range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ range[0] = scalarRange_[0]; //use current cut plane's scalar range,
|
|
|
+ range[1] = scalarRange_[1]; //instead of the whole input's scalar range.
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+ cutSource_->Update();
|
|
|
+
|
|
|
+ vtkGeometryFilter *geoFilter = vtkGeometryFilter::New();
|
|
|
+ geoFilter->SetInputData(cutSource_->GetOutput());
|
|
|
+ geoFilter->Update();
|
|
|
+
|
|
|
+ vtkBandedPolyDataContourFilter *conFilter = vtkBandedPolyDataContourFilter::New();
|
|
|
+ conFilter->GlobalWarningDisplayOff();
|
|
|
+ conFilter->SetInputData(geoFilter->GetOutput());
|
|
|
+ conFilter->GenerateValues(conLevel_, range[0], range[1]);
|
|
|
+ conFilter->ClippingOn();
|
|
|
+ conFilter->Modified();
|
|
|
+ conFilter->Update();
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+
|
|
|
+ if(_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(conFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetInputConnection(geoFilter->GetOutputPort());
|
|
|
+ }
|
|
|
+ mapper->SetScalarRange(range[0],range[1]);
|
|
|
+
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkLookupTable *table = (vtkLookupTable*)mapper->GetLookupTable();
|
|
|
+ table->GetHueRange(range);
|
|
|
+ table->SetHueRange(range[1],range[0]);
|
|
|
+ table->SetNumberOfColors(conLevel_);
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ sliceActors_[0] = actor;
|
|
|
+
|
|
|
+ sliceTable_[0] = table;
|
|
|
+
|
|
|
+ bandedContourFilter_ = conFilter;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Contour Lines Display_FD(创造切片等高线轮廓展示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceContourLinesDisplay_FD()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ //range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ //range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ range[0] = scalarRange_[0]; //use current cut plane's scalar range,
|
|
|
+ range[1] = scalarRange_[1]; //instead of the whole input's scalar range.
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkContourFilter *conFilter = vtkContourFilter::New();
|
|
|
+ conFilter->GlobalWarningDisplayOff();
|
|
|
+ conFilter->SetInputConnection(cutSource_->GetOutputPort());
|
|
|
+ conFilter->GenerateValues(conLevel_, range[0],range[1]);
|
|
|
+ conFilter->Update();
|
|
|
+
|
|
|
+ vtkDataSetMapper *mapper = vtkDataSetMapper::New();
|
|
|
+ mapper->InterpolateScalarsBeforeMappingOn();
|
|
|
+ mapper->SetInputConnection(conFilter->GetOutputPort());
|
|
|
+ mapper->SetScalarRange(range[0],range[1]);
|
|
|
+
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mapper->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkLookupTable *table = (vtkLookupTable*)mapper->GetLookupTable();
|
|
|
+ table->GetHueRange(range);
|
|
|
+ table->SetHueRange(range[1],range[0]);
|
|
|
+ table->SetNumberOfColors(conLevel_);
|
|
|
+
|
|
|
+ vtkActor *actor = vtkActor::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ contourLinesFilter_ = conFilter;
|
|
|
+ sliceActors_[1] = actor;
|
|
|
+ sliceTable_[1] = table;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief: Create UnSlice Contour Lines Lable Display_FD(创造切片等高线轮廓标签展示)
|
|
|
+* @param: void
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::CreateUnSliceContourLinesLabelDisplay_FD()
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ double range[2];
|
|
|
+ if (usedScalarIndex_ != -1)
|
|
|
+ {
|
|
|
+ //range[0] = _source->scalarRange[usedScalarIndex_][0];
|
|
|
+ //range[1] = _source->scalarRange[usedScalarIndex_][1];
|
|
|
+ range[0] = scalarRange_[0]; //use current cut plane's scalar range,
|
|
|
+ range[1] = scalarRange_[1]; //instead of the whole input's scalar range.
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ range[0] = 0;
|
|
|
+ range[1] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ vtkContourFilter *labelFilter = vtkContourFilter::New();
|
|
|
+ labelFilter->GlobalWarningDisplayOff();
|
|
|
+ labelFilter->SetInputConnection(cutSource_->GetOutputPort());
|
|
|
+ labelFilter->GenerateValues(conLevel_, range[0],range[1]);
|
|
|
+ labelFilter->Update();
|
|
|
+
|
|
|
+ int numPoints = labelFilter->GetOutput()->GetNumberOfPoints();
|
|
|
+ vtkMaskPoints *mask = vtkMaskPoints::New();
|
|
|
+ mask->SetInputConnection(labelFilter->GetOutputPort());
|
|
|
+ mask->SetOnRatio((double)numPoints/conLevel_);
|
|
|
+ mask->SetMaximumNumberOfPoints(50);
|
|
|
+ mask->RandomModeOn();
|
|
|
+
|
|
|
+ vtkSelectVisiblePoints *visPoints = vtkSelectVisiblePoints::New();
|
|
|
+ visPoints->SetInputConnection(mask->GetOutputPort());
|
|
|
+ visPoints->SetRenderer(_renderer);
|
|
|
+
|
|
|
+ vtkLabeledDataMapper *mapper = vtkLabeledDataMapper::New();
|
|
|
+ mapper->GlobalWarningDisplayOff();
|
|
|
+ mapper->SetInputConnection(mask->GetOutputPort());
|
|
|
+ mapper->SetLabelModeToLabelScalars();
|
|
|
+ mapper->GetLabelTextProperty()->SetFontFamilyToArial();
|
|
|
+ mapper->GetLabelTextProperty()->SetFontSize(10);
|
|
|
+ mapper->GetLabelTextProperty()->SetColor(1,1,1);
|
|
|
+
|
|
|
+ vtkActor2D *actor = vtkActor2D::New();
|
|
|
+ actor->SetMapper(mapper);
|
|
|
+
|
|
|
+ if (_renderer != NULL)
|
|
|
+ {
|
|
|
+ _renderer->AddActor2D(actor);
|
|
|
+ }
|
|
|
+
|
|
|
+ contourLabelFilter_ = labelFilter;
|
|
|
+ sliceActors_[2] = (vtkActor*) actor;
|
|
|
+ sliceTable_[2] = NULL;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief:Modify Display Scalar Range_FD(修改展示标量范围)
|
|
|
+* @param: min and max scalar
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifyDisplayScalarRange_FD(double min,double max)
|
|
|
+{
|
|
|
+ scalarRange_[0] = min;
|
|
|
+ scalarRange_[1] = max;
|
|
|
+ if (min == max) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, min, max);
|
|
|
+ bandedContourFilter_->Modified();
|
|
|
+ }
|
|
|
+ //add begin. update contour lines/labels values
|
|
|
+ if (contourLinesFilter_ != NULL)
|
|
|
+ {
|
|
|
+ contourLinesFilter_->GenerateValues(conLevel_, min, max);
|
|
|
+ contourLinesFilter_->Modified();
|
|
|
+ }
|
|
|
+ if (contourLabelFilter_!= NULL)
|
|
|
+ {
|
|
|
+ contourLabelFilter_->GenerateValues(conLevel_, min, max);
|
|
|
+ contourLabelFilter_->Modified();
|
|
|
+ }
|
|
|
+ //add end
|
|
|
+
|
|
|
+ for (int i= 0; i<6; i++)
|
|
|
+ {
|
|
|
+ if (i == 0 || i== 1 || i == 3)
|
|
|
+ {
|
|
|
+
|
|
|
+ if(sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->SetRange(min, max);
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->Modified();
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarRange(min, max);
|
|
|
+ (sliceActors_[i]->GetMapper())->Modified();
|
|
|
+
|
|
|
+ sliceActors_[i]->Modified();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief:Modify slice scalar source_FD(修改切片标量源)
|
|
|
+* @param: scalar
|
|
|
+* @ret: void
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+void vtkVISUnSlice::ModifySliceSourceScalar_FD(char* scalar)
|
|
|
+{
|
|
|
+ if (gridSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Grid Source are not Setted!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int index = -1;
|
|
|
+ if(scalar != NULL)
|
|
|
+ {
|
|
|
+ index = _source->GetScalarIndex(scalar);
|
|
|
+ }
|
|
|
+ if (index == -1)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Scalar data are not existed!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (scalarSource_ != 0)
|
|
|
+ {
|
|
|
+ scalarSource_->Delete();
|
|
|
+ scalarSource_ = 0;
|
|
|
+ }
|
|
|
+ scalarSource_ = vtkDoubleArray::New();
|
|
|
+ if (_source->scalarSource[index]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ scalarSource_->DeepCopy(_source->scalarSource[index]);
|
|
|
+ (gridSource_->GetPointData())->SetScalars(scalarSource_);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ scalarSource_->DeepCopy(_source->cellScalarSource_[index]);
|
|
|
+ (gridSource_->GetCellData())->SetScalars(scalarSource_);
|
|
|
+ }
|
|
|
+ gridSource_->Modified();
|
|
|
+
|
|
|
+ usedScalarIndex_ = index;
|
|
|
+
|
|
|
+ vtkFloatArray *arry = GetCutScalarData();
|
|
|
+ if (arry) arry->GetRange(scalarRange_);
|
|
|
+ //2011-05-10 zhuqin add begin.
|
|
|
+ if(bandedContourFilter_ != NULL)
|
|
|
+ {
|
|
|
+ bandedContourFilter_->GenerateValues(conLevel_, scalarRange_[0],scalarRange_[1]);
|
|
|
+ bandedContourFilter_->ClippingOn();
|
|
|
+ bandedContourFilter_->Modified();
|
|
|
+ }
|
|
|
+ if (contourLinesFilter_ != NULL)
|
|
|
+ {
|
|
|
+ contourLinesFilter_->GenerateValues(conLevel_, scalarRange_[0],scalarRange_[1]);
|
|
|
+ contourLinesFilter_->Modified();
|
|
|
+ }
|
|
|
+ if (contourLabelFilter_!= NULL)
|
|
|
+ {
|
|
|
+ contourLabelFilter_->GenerateValues(conLevel_, scalarRange_[0],scalarRange_[1]);
|
|
|
+ contourLabelFilter_->Modified();
|
|
|
+ }
|
|
|
+ //2011-05-10 zhuqin add end.
|
|
|
+
|
|
|
+
|
|
|
+ for (int i= 0; i<6; i++)
|
|
|
+ {
|
|
|
+ if (i == 0 || i== 1 || i == 3)
|
|
|
+ {
|
|
|
+ if(sliceActors_[i] != NULL)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->SetRange(scalarRange_[0],scalarRange_[1]);
|
|
|
+ (sliceActors_[i]->GetMapper())->GetLookupTable()->Modified();
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarRange(scalarRange_[0],scalarRange_[1]);
|
|
|
+
|
|
|
+ if (_source->scalarSource[usedScalarIndex_]->GetDataSize() != 0)
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarModeToUsePointData();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (sliceActors_[i]->GetMapper())->SetScalarModeToUseCellData();
|
|
|
+ }
|
|
|
+
|
|
|
+ (sliceActors_[i]->GetMapper())->Modified();
|
|
|
+ sliceActors_[i]->Modified();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+* @brief:Get Source Bounds_FD(获取源边界)
|
|
|
+* @param: bounds
|
|
|
+* @ret: bool
|
|
|
+* @birth: created by czm in 20230326
|
|
|
+*/
|
|
|
+bool vtkVISUnSlice::GetSourceBounds_FD(double *bounds)
|
|
|
+{
|
|
|
+ if (cutSource_ == NULL)
|
|
|
+ {
|
|
|
+ ErrorInfo(1,"Slice Source Not Set");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ double *range = _source->GetSourceBounds();
|
|
|
+ for (int i = 0; i < 6; ++i)
|
|
|
+ {
|
|
|
+ bounds[i] = range[i];
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|