You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.5 KiB
C++
121 lines
3.5 KiB
C++
#include "FITKCFDPostProbe.h"
|
|
#include "FITKCFDPost3DManager.h"
|
|
#include "FITKCFDPostData.h"
|
|
|
|
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
|
|
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
|
|
|
|
#include <vtkProbeFilter.h>
|
|
#include <vtkDataSetMapper.h>
|
|
#include <vtkUnstructuredGrid.h>
|
|
#include <vtkPointData.h>
|
|
#include <vtkPolyData.h>
|
|
#include <vtkQuad.h>
|
|
#include <vtkIdList.h>
|
|
#include <vtkCell.h>
|
|
|
|
#include <QDebug>
|
|
|
|
namespace Interface
|
|
{
|
|
Interface::FITKCFDPostProbe::FITKCFDPostProbe(int parentID)
|
|
{
|
|
_CFDPostParentID = parentID;
|
|
Interface::FITKCFDPost3DManager* dataManger = FITKAPP->getGlobalData()->getPostData<Interface::FITKCFDPostData>()->getPostDataManager();
|
|
if (dataManger == nullptr)return;
|
|
Interface::FITKAbstractCFDPostData* parentData = dataManger->getDataByID(_CFDPostParentID);
|
|
if (parentData == nullptr)return;
|
|
|
|
_polyData = vtkPolyData::New();
|
|
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
|
_polyData->SetPoints(points);
|
|
|
|
vtkSmartPointer<vtkCellArray> cellArray = vtkSmartPointer<vtkCellArray>::New();
|
|
_polyData->SetPolys(cellArray);
|
|
|
|
_probeFilter = vtkProbeFilter::New();
|
|
_probeFilter->SetInputData(0, _polyData);
|
|
_probeFilter->SetInputData(1, parentData->getOutput());
|
|
|
|
vtkDataSetMapper* mapper = vtkDataSetMapper::New();
|
|
mapper->SetInputConnection(_probeFilter->GetOutputPort());
|
|
_mappers.append(mapper);
|
|
}
|
|
|
|
FITKCFDPostProbe::~FITKCFDPostProbe()
|
|
{
|
|
if (_polyData) {
|
|
_polyData->Delete();
|
|
_polyData = nullptr;
|
|
}
|
|
|
|
if (_probeFilter) {
|
|
_probeFilter->Delete();
|
|
_probeFilter = nullptr;
|
|
}
|
|
}
|
|
FITKPostDataType FITKCFDPostProbe::getPostDataType()
|
|
{
|
|
return FITKPostDataType::Post_Probe;
|
|
}
|
|
|
|
vtkDataSet* FITKCFDPostProbe::getOutput()
|
|
{
|
|
if (_probeFilter == nullptr)return nullptr;
|
|
return _probeFilter->GetOutput();
|
|
}
|
|
|
|
vtkAlgorithmOutput* FITKCFDPostProbe::getOutputPort()
|
|
{
|
|
if (_probeFilter == nullptr)return nullptr;
|
|
return _probeFilter->GetOutputPort();
|
|
}
|
|
|
|
int FITKCFDPostProbe::insertPoint(double* point)
|
|
{
|
|
if (_polyData == nullptr)return -1;
|
|
vtkPoints* points = _polyData->GetPoints();
|
|
if (points == nullptr)return -1;
|
|
int pointID = points->InsertNextPoint(point);
|
|
return pointID;
|
|
}
|
|
|
|
int FITKCFDPostProbe::getPointCount()
|
|
{
|
|
if (_polyData == nullptr)return 0;
|
|
vtkPoints* vtkpoints = _polyData->GetPoints();
|
|
if (vtkpoints == nullptr)return 0;
|
|
int pointNum = vtkpoints->GetNumberOfPoints();
|
|
return pointNum;
|
|
}
|
|
|
|
void FITKCFDPostProbe::getPointAtInter(double* point, int index)
|
|
{
|
|
if (index < 0 || index >= getPointCount())return;
|
|
if (_polyData == nullptr)return;
|
|
vtkPoints* vtkpoints = _polyData->GetPoints();
|
|
if (vtkpoints == nullptr)return;
|
|
double* p = vtkpoints->GetPoint(index);
|
|
point[0] = p[0];
|
|
point[1] = p[1];
|
|
point[2] = p[2];
|
|
}
|
|
|
|
vtkPolyData* FITKCFDPostProbe::getPolyData()
|
|
{
|
|
return _polyData;
|
|
}
|
|
|
|
void FITKCFDPostProbe::reset()
|
|
{
|
|
if (_polyData == nullptr)return;
|
|
if (_polyData->GetPoints()) {
|
|
_polyData->GetPoints()->Reset();
|
|
}
|
|
if (_polyData->GetPolys()) {
|
|
_polyData->GetPolys()->Reset();
|
|
}
|
|
}
|
|
}
|
|
|