增加了表面删除功能
parent
6d26cabb2b
commit
972deee3ad
|
|
@ -239,6 +239,8 @@ find_package(Python REQUIRED)
|
||||||
# OpenMesh
|
# OpenMesh
|
||||||
find_package(OpenMesh CONFIG REQUIRED)
|
find_package(OpenMesh CONFIG REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# VCGLIB
|
# VCGLIB
|
||||||
find_path(VCGLIB_INCLUDE_DIRS "img/img.h")
|
find_path(VCGLIB_INCLUDE_DIRS "img/img.h")
|
||||||
|
|
||||||
|
|
@ -254,6 +256,10 @@ find_package(GDAL CONFIG REQUIRED)
|
||||||
# sqlite3
|
# sqlite3
|
||||||
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
||||||
|
|
||||||
|
# openmesh
|
||||||
|
find_package(OpenMesh CONFIG REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
# opencv
|
# opencv
|
||||||
set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
|
set(OpenCV_DIR "${VCPKG_INSTALLED_DIR}/x64-windows/share/opencv4")
|
||||||
find_package(OpenCV REQUIRED) # 找到opencv库
|
find_package(OpenCV REQUIRED) # 找到opencv库
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ list(APPEND LAMPCAE_Runtimes_Libraries
|
||||||
OpenCASCADE::TKOpenGl OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
OpenCASCADE::TKOpenGl OpenCASCADE::TKOffset OpenCASCADE::TKSTL OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||||
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||||
${OpenCV_LIBRARIES}
|
${OpenCV_LIBRARIES}
|
||||||
|
OpenMeshCore OpenMeshTools
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ std::set<vtkIdType> vtkDataRelated::GetCoplanarPointId(vtkDataSet *data, vtkIdTy
|
||||||
|
|
||||||
std::set<VTKIDPAIR> seedNeibors = GetNeighborPointID(polyData, pSeedId);
|
std::set<VTKIDPAIR> seedNeibors = GetNeighborPointID(polyData, pSeedId);
|
||||||
vtkSmartPointer<vtkDataArray> pointNormals = GetVTKDataNormals(polyData, 0)->GetPointData()->GetNormals();
|
vtkSmartPointer<vtkDataArray> pointNormals = GetVTKDataNormals(polyData, 0)->GetPointData()->GetNormals();
|
||||||
if (pointNormals->GetNumberOfTuples() == 0) return coplanarPointIds;
|
if (pointNormals==nullptr == 0) return coplanarPointIds;
|
||||||
coplanarPointIds.insert(pSeedId);
|
coplanarPointIds.insert(pSeedId);
|
||||||
|
|
||||||
VTKIDPAIR inverse, self{ pSeedId, pSeedId };
|
VTKIDPAIR inverse, self{ pSeedId, pSeedId };
|
||||||
|
|
|
||||||
|
|
@ -47,14 +47,18 @@ endif()
|
||||||
|
|
||||||
list(APPEND _runtimes_libraries
|
list(APPEND _runtimes_libraries
|
||||||
OpenCASCADE::Freetype OpenCASCADE::TKBRep OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIVtk OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKernel Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersModeling VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingGL2PSOpenGL2 VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib
|
OpenCASCADE::Freetype OpenCASCADE::TKBRep OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIVtk OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKernel Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersModeling VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingGL2PSOpenGL2 VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib
|
||||||
|
OpenMeshCore OpenMeshTools
|
||||||
|
)
|
||||||
|
list(APPEND _runtimes_libraries
|
||||||
|
VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::DICOMParser VTK::FiltersCore VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersHybrid VTK::FiltersModeling VTK::FiltersSources VTK::IOCore VTK::IOChemistry VTK::IOGeometry VTK::IOImage VTK::IOLegacy VTK::ImagingCore VTK::ImagingSources VTK::RenderingCore VTK::RenderingLOD VTK::doubleconversion VTK::jpeg VTK::jsoncpp VTK::lz4 VTK::lzma VTK::metaio VTK::png VTK::pugixml VTK::sys VTK::tiff VTK::zlib
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# 链接依赖库
|
# 链接依赖库
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
target_link_libraries(MainWidgets PRIVATE
|
target_link_libraries(MainWidgets PRIVATE
|
||||||
${_runtimes_libraries}
|
${_runtimes_libraries}
|
||||||
${_depend_library}
|
${_depend_library}
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "MeshData/meshSet.h"
|
#include "MeshData/meshSet.h"
|
||||||
#include "Settings/BusAPI.h"
|
#include "Settings/BusAPI.h"
|
||||||
#include "Settings/GraphOption.h"
|
#include "Settings/GraphOption.h"
|
||||||
|
#include "Common/DebugLogger.h"
|
||||||
#include <vtkUnstructuredGrid.h>
|
#include <vtkUnstructuredGrid.h>
|
||||||
#include <vtkActor.h>
|
#include <vtkActor.h>
|
||||||
#include <vtkUnsignedCharArray.h>
|
#include <vtkUnsignedCharArray.h>
|
||||||
|
|
@ -21,15 +22,26 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkThreshold.h>
|
||||||
|
#include <vtkGeometryFilter.h>
|
||||||
|
#include <vtkVertexGlyphFilter.h>
|
||||||
|
#include <vtkVertex.h>
|
||||||
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkDataSetMapper.h>
|
||||||
|
#include <vtkUnstructuredGridWriter.h>
|
||||||
|
#include <vtkPolyDataWriter.h>
|
||||||
|
#include <vtkSTLWriter.h>
|
||||||
#ifdef LAMPCAE_HAS_OPENMP
|
#ifdef LAMPCAE_HAS_OPENMP
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace MainWidget
|
namespace MainWidget {
|
||||||
{
|
MeshKernalViewObj::MeshKernalViewObj(MeshData::MeshKernal* k)
|
||||||
MeshKernalViewObj::MeshKernalViewObj(MeshData::MeshKernal *k)
|
: _kernal(k)
|
||||||
: _kernal(k), _displayData(vtkUnstructuredGrid::New()),
|
, _displayData(vtkUnstructuredGrid::New())
|
||||||
_meshData(MeshData::MeshData::getInstance())
|
, _meshData(MeshData::MeshData::getInstance())
|
||||||
{
|
{
|
||||||
_actor[0] = vtkActor::New();
|
_actor[0] = vtkActor::New();
|
||||||
_actor[1] = vtkActor::New();
|
_actor[1] = vtkActor::New();
|
||||||
|
|
@ -41,26 +53,25 @@ namespace MainWidget
|
||||||
MeshKernalViewObj::~MeshKernalViewObj()
|
MeshKernalViewObj::~MeshKernalViewObj()
|
||||||
{
|
{
|
||||||
// if (_actor != nullptr) _actor->Delete();
|
// if (_actor != nullptr) _actor->Delete();
|
||||||
if (_displayData != nullptr)
|
if(_displayData != nullptr)
|
||||||
_displayData->Delete();
|
_displayData->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkDataSet *MeshKernalViewObj::getDisplayData()
|
vtkDataSet* MeshKernalViewObj::getDisplayData()
|
||||||
{
|
{
|
||||||
return _displayData;
|
return _displayData;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkActor **MeshKernalViewObj::getActor()
|
vtkActor** MeshKernalViewObj::getActor()
|
||||||
{
|
{
|
||||||
return _actor;
|
return _actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::setPointColor(const QColor &c, bool disOnly)
|
void MeshKernalViewObj::setPointColor(const QColor& c, bool disOnly)
|
||||||
{
|
{
|
||||||
vtkDataArray *dpointColor = _displayData->GetPointData()->GetScalars();
|
vtkDataArray* dpointColor = _displayData->GetPointData()->GetScalars();
|
||||||
double col[3]{c.red()*1.0, c.green()*1.0, c.blue()*1.0};
|
double col[3]{ c.red() * 1.0, c.green() * 1.0, c.blue() * 1.0 };
|
||||||
if (nullptr == dpointColor)
|
if(nullptr == dpointColor) {
|
||||||
{
|
|
||||||
dpointColor = vtkUnsignedCharArray::New();
|
dpointColor = vtkUnsignedCharArray::New();
|
||||||
dpointColor->SetNumberOfComponents(3);
|
dpointColor->SetNumberOfComponents(3);
|
||||||
_displayData->GetPointData()->SetScalars(dpointColor);
|
_displayData->GetPointData()->SetScalars(dpointColor);
|
||||||
|
|
@ -71,12 +82,11 @@ namespace MainWidget
|
||||||
dpointColor->FillComponent(2, col[2]);
|
dpointColor->FillComponent(2, col[2]);
|
||||||
_displayData->Modified();
|
_displayData->Modified();
|
||||||
|
|
||||||
if (disOnly)
|
if(disOnly)
|
||||||
return;
|
return;
|
||||||
auto dataset = _kernal->getMeshData();
|
auto dataset = _kernal->getMeshData();
|
||||||
vtkDataArray *pointColor = dataset->GetPointData()->GetScalars();
|
vtkDataArray* pointColor = dataset->GetPointData()->GetScalars();
|
||||||
if (nullptr == pointColor)
|
if(nullptr == pointColor) {
|
||||||
{
|
|
||||||
pointColor = vtkUnsignedCharArray::New();
|
pointColor = vtkUnsignedCharArray::New();
|
||||||
pointColor->SetNumberOfComponents(3);
|
pointColor->SetNumberOfComponents(3);
|
||||||
pointColor->SetNumberOfTuples(dataset->GetNumberOfPoints());
|
pointColor->SetNumberOfTuples(dataset->GetNumberOfPoints());
|
||||||
|
|
@ -87,44 +97,50 @@ namespace MainWidget
|
||||||
pointColor->FillComponent(2, col[2]);
|
pointColor->FillComponent(2, col[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::setPointDisplayColor(QList<int> &indexs, const QColor &color,bool isModitfy)
|
void MeshKernalViewObj::setPointDisplayColor(QList<int>& indexs, const QColor& color,
|
||||||
|
bool isModitfy)
|
||||||
{
|
{
|
||||||
//qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshKernalViewObj::setPointDisplayColor start ";
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
|
||||||
|
// MeshKernalViewObj::setPointDisplayColor start ";
|
||||||
std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
|
std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
|
||||||
//qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshKernalViewObj::setPointDisplayColor create set ";
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
|
||||||
vtkDataArray *colorArray = _displayData->GetPointData()->GetScalars();
|
// MeshKernalViewObj::setPointDisplayColor create set ";
|
||||||
vtkDataArray *indexArray = _displayData->GetPointData()->GetArray("IDS"); // display data , kernel idx, point idx
|
vtkDataArray* colorArray = _displayData->GetPointData()->GetScalars();
|
||||||
//vtkDataArray *selectArray = _displayData->GetPointData()->GetArray("SELECT"); // select state array
|
vtkDataArray* indexArray =
|
||||||
if (nullptr == colorArray || nullptr == indexArray)
|
_displayData->GetPointData()->GetArray("IDS"); // display data , kernel idx, point idx
|
||||||
|
// vtkDataArray *selectArray = _displayData->GetPointData()->GetArray("SELECT"); // select
|
||||||
|
// state array
|
||||||
|
if(nullptr == colorArray || nullptr == indexArray)
|
||||||
return;
|
return;
|
||||||
double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0}; // color
|
double col[3]{ color.red() * 1.0, color.green() * 1.0, color.blue() * 1.0 }; // color
|
||||||
const int nPoint = indexArray->GetNumberOfTuples(); // 所有显示 点的数量
|
const int nPoint = indexArray->GetNumberOfTuples(); // 所有显示 点的数量
|
||||||
for (int i = 0; i < nPoint; ++i) // 遍历所有的显示点
|
for(int i = 0; i < nPoint; ++i) // 遍历所有的显示点
|
||||||
{
|
{
|
||||||
if (indexs.isEmpty())
|
if(indexs.isEmpty())
|
||||||
break;
|
break;
|
||||||
int pointindex = indexArray->GetComponent(i, 1);
|
int pointindex = indexArray->GetComponent(i, 1);
|
||||||
if (indexSet.find(pointindex)!=indexSet.end()) // 选择点是否在 渲染 点集中, 选中 && 渲染 修改
|
if(indexSet.find(pointindex)
|
||||||
|
!= indexSet.end()) // 选择点是否在 渲染 点集中, 选中 && 渲染 修改
|
||||||
{
|
{
|
||||||
colorArray->SetComponent(i, 0, col[0]);
|
colorArray->SetComponent(i, 0, col[0]);
|
||||||
colorArray->SetComponent(i, 1, col[1]);
|
colorArray->SetComponent(i, 1, col[1]);
|
||||||
colorArray->SetComponent(i, 2, col[2]);
|
colorArray->SetComponent(i, 2, col[2]);
|
||||||
//indexs.removeOne(pointindex);
|
// indexs.removeOne(pointindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isModitfy) {
|
if(isModitfy) {
|
||||||
_displayData->Modified();
|
_displayData->Modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshKernalViewObj::setPointDisplayColor finish ";
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
|
||||||
|
// MeshKernalViewObj::setPointDisplayColor finish ";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::setCellColor(const QColor &c, bool disOnly)
|
void MeshKernalViewObj::setCellColor(const QColor& c, bool disOnly)
|
||||||
{
|
{
|
||||||
double col[3]{c.red()*1.0, c.green()*1.0, c.blue()*1.0};
|
double col[3]{ c.red() * 1.0, c.green() * 1.0, c.blue() * 1.0 };
|
||||||
vtkDataArray *dcellcolor = _displayData->GetCellData()->GetScalars();
|
vtkDataArray* dcellcolor = _displayData->GetCellData()->GetScalars();
|
||||||
if (dcellcolor == nullptr)
|
if(dcellcolor == nullptr) {
|
||||||
{
|
|
||||||
dcellcolor = vtkUnsignedCharArray::New();
|
dcellcolor = vtkUnsignedCharArray::New();
|
||||||
dcellcolor->SetNumberOfComponents(3);
|
dcellcolor->SetNumberOfComponents(3);
|
||||||
_displayData->GetCellData()->SetScalars(dcellcolor);
|
_displayData->GetCellData()->SetScalars(dcellcolor);
|
||||||
|
|
@ -136,12 +152,11 @@ namespace MainWidget
|
||||||
dcellcolor->FillComponent(2, col[2]);
|
dcellcolor->FillComponent(2, col[2]);
|
||||||
_displayData->Modified();
|
_displayData->Modified();
|
||||||
|
|
||||||
if (disOnly)
|
if(disOnly)
|
||||||
return;
|
return;
|
||||||
auto dataset = _kernal->getMeshData();
|
auto dataset = _kernal->getMeshData();
|
||||||
vtkDataArray *cellcolor = dataset->GetCellData()->GetScalars();
|
vtkDataArray* cellcolor = dataset->GetCellData()->GetScalars();
|
||||||
if (nullptr == cellcolor)
|
if(nullptr == cellcolor) {
|
||||||
{
|
|
||||||
cellcolor = vtkUnsignedCharArray::New();
|
cellcolor = vtkUnsignedCharArray::New();
|
||||||
cellcolor->SetNumberOfComponents(3);
|
cellcolor->SetNumberOfComponents(3);
|
||||||
dataset->GetCellData()->SetScalars(cellcolor);
|
dataset->GetCellData()->SetScalars(cellcolor);
|
||||||
|
|
@ -152,42 +167,43 @@ namespace MainWidget
|
||||||
cellcolor->FillComponent(2, col[2]);
|
cellcolor->FillComponent(2, col[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::setCellDisplayColor(QList<int> &indexs, const QColor &color,bool isModitfy)
|
void MeshKernalViewObj::setCellDisplayColor(QList<int>& indexs, const QColor& color,
|
||||||
|
bool isModitfy)
|
||||||
{
|
{
|
||||||
//qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshKernalViewObj::setCellDisplayColor start ";
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
|
||||||
|
// MeshKernalViewObj::setCellDisplayColor start ";
|
||||||
std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
|
std::set<int> indexSet(indexs.begin(), indexs.end()); // 转换为 set-- std 实现是B+树
|
||||||
//qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshKernalViewObj::setPointDisplayColor create set ";
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
|
||||||
vtkDataArray *colorArray = _displayData->GetCellData()->GetScalars();
|
// MeshKernalViewObj::setPointDisplayColor create set ";
|
||||||
vtkDataArray *indexArray = _displayData->GetCellData()->GetArray("IDS"); // display data , kernel idx, cell idx
|
vtkDataArray* colorArray = _displayData->GetCellData()->GetScalars();
|
||||||
double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0};
|
vtkDataArray* indexArray =
|
||||||
if (nullptr == colorArray || nullptr == indexArray)
|
_displayData->GetCellData()->GetArray("IDS"); // display data , kernel idx, cell idx
|
||||||
|
double col[3]{ color.red() * 1.0, color.green() * 1.0, color.blue() * 1.0 };
|
||||||
|
if(nullptr == colorArray || nullptr == indexArray)
|
||||||
return;
|
return;
|
||||||
const int nCell = indexArray->GetNumberOfTuples();
|
const int nCell = indexArray->GetNumberOfTuples();
|
||||||
|
|
||||||
int nprocess = 4;
|
int nprocess = 4;
|
||||||
#ifdef LAMPCAE_HAS_OPENMP
|
#ifdef LAMPCAE_HAS_OPENMP
|
||||||
int ncore = QThread::idealThreadCount();
|
int ncore = QThread::idealThreadCount();
|
||||||
nprocess = ncore - 1 > 0 ? ncore - 1 : ncore;
|
nprocess = ncore - 1 > 0 ? ncore - 1 : ncore;
|
||||||
omp_set_num_threads(nprocess);
|
omp_set_num_threads(nprocess);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QList<int> spliters{0};
|
QList<int> spliters{ 0 };
|
||||||
const int countPart = nCell / nprocess;
|
const int countPart = nCell / nprocess;
|
||||||
while (spliters.last() < nCell - 1)
|
while(spliters.last() < nCell - 1) {
|
||||||
{
|
|
||||||
int cu = spliters.last() + countPart;
|
int cu = spliters.last() + countPart;
|
||||||
if (abs(cu - nCell) < 0.2 * countPart)
|
if(abs(cu - nCell) < 0.2 * countPart)
|
||||||
cu = nCell - 1;
|
cu = nCell - 1;
|
||||||
spliters.append(cu);
|
spliters.append(cu);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto serial = [=](int beg, int end)
|
auto serial = [=](int beg, int end) {
|
||||||
{
|
for(int i = beg; i <= end; ++i) {
|
||||||
for (int i = beg; i <= end; ++i)
|
|
||||||
{
|
|
||||||
int cellid = indexArray->GetComponent(i, 1);
|
int cellid = indexArray->GetComponent(i, 1);
|
||||||
// if(indexs.contains(cellid))
|
// if(indexs.contains(cellid))
|
||||||
if ( indexSet.find(cellid)!=indexSet.end()) // 判断是否在显示对象中
|
if(indexSet.find(cellid) != indexSet.end()) // 判断是否在显示对象中
|
||||||
{
|
{
|
||||||
colorArray->SetComponent(i, 0, col[0]);
|
colorArray->SetComponent(i, 0, col[0]);
|
||||||
colorArray->SetComponent(i, 1, col[1]);
|
colorArray->SetComponent(i, 1, col[1]);
|
||||||
|
|
@ -198,8 +214,7 @@ namespace MainWidget
|
||||||
#ifdef LAMPCAE_HAS_OPENMP
|
#ifdef LAMPCAE_HAS_OPENMP
|
||||||
#pragma omp parallel for shared(colorArray, spliters)
|
#pragma omp parallel for shared(colorArray, spliters)
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0; i < nprocess; ++i)
|
for(int i = 0; i < nprocess; ++i) {
|
||||||
{
|
|
||||||
int beg = spliters[i];
|
int beg = spliters[i];
|
||||||
int end = spliters[i + 1];
|
int end = spliters[i + 1];
|
||||||
serial(beg, end);
|
serial(beg, end);
|
||||||
|
|
@ -209,18 +224,19 @@ namespace MainWidget
|
||||||
_displayData->Modified();
|
_displayData->Modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshKernalViewObj::setCellDisplayColor finish ";
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<"
|
||||||
|
// MeshKernalViewObj::setCellDisplayColor finish ";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::setPointDisplayColorByDisplayIndex(QList<int> &indexs, const QColor &color)
|
void MeshKernalViewObj::setPointDisplayColorByDisplayIndex(QList<int>& indexs,
|
||||||
|
const QColor& color)
|
||||||
{
|
{
|
||||||
vtkDataArray *colorArray = _displayData->GetPointData()->GetScalars();
|
vtkDataArray* colorArray = _displayData->GetPointData()->GetScalars();
|
||||||
vtkDataArray *indexArray = _displayData->GetPointData()->GetArray("IDS");
|
vtkDataArray* indexArray = _displayData->GetPointData()->GetArray("IDS");
|
||||||
if (nullptr == colorArray || nullptr == indexArray)
|
if(nullptr == colorArray || nullptr == indexArray)
|
||||||
return;
|
return;
|
||||||
double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0};
|
double col[3]{ color.red() * 1.0, color.green() * 1.0, color.blue() * 1.0 };
|
||||||
for (int index : indexs)
|
for(int index : indexs) {
|
||||||
{
|
|
||||||
colorArray->SetComponent(index, 0, col[0]);
|
colorArray->SetComponent(index, 0, col[0]);
|
||||||
colorArray->SetComponent(index, 1, col[1]);
|
colorArray->SetComponent(index, 1, col[1]);
|
||||||
colorArray->SetComponent(index, 2, col[2]);
|
colorArray->SetComponent(index, 2, col[2]);
|
||||||
|
|
@ -228,15 +244,15 @@ namespace MainWidget
|
||||||
_displayData->Modified();
|
_displayData->Modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::setCellDisplayColorByDisplayIndex(QList<int> &indexs, const QColor &color)
|
void MeshKernalViewObj::setCellDisplayColorByDisplayIndex(QList<int>& indexs,
|
||||||
|
const QColor& color)
|
||||||
{
|
{
|
||||||
vtkDataArray *colorArray = _displayData->GetCellData()->GetScalars();
|
vtkDataArray* colorArray = _displayData->GetCellData()->GetScalars();
|
||||||
vtkDataArray *indexArray = _displayData->GetCellData()->GetArray("IDS");
|
vtkDataArray* indexArray = _displayData->GetCellData()->GetArray("IDS");
|
||||||
if (nullptr == colorArray || nullptr == indexArray)
|
if(nullptr == colorArray || nullptr == indexArray)
|
||||||
return;
|
return;
|
||||||
double col[3]{color.red()*1.0, color.green()*1.0, color.blue()*1.0};
|
double col[3]{ color.red() * 1.0, color.green() * 1.0, color.blue() * 1.0 };
|
||||||
for (int index : indexs)
|
for(int index : indexs) {
|
||||||
{
|
|
||||||
colorArray->SetComponent(index, 0, col[0]);
|
colorArray->SetComponent(index, 0, col[0]);
|
||||||
colorArray->SetComponent(index, 1, col[1]);
|
colorArray->SetComponent(index, 1, col[1]);
|
||||||
colorArray->SetComponent(index, 2, col[2]);
|
colorArray->SetComponent(index, 2, col[2]);
|
||||||
|
|
@ -244,24 +260,23 @@ namespace MainWidget
|
||||||
_displayData->Modified();
|
_displayData->Modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::showCells(const QList<int> &indexs, bool show)
|
void MeshKernalViewObj::showCells(const QList<int>& indexs, bool show)
|
||||||
{
|
{
|
||||||
auto dataSet = _kernal->getMeshData();
|
auto dataSet = _kernal->getMeshData();
|
||||||
vtkDataArray *showArray = dataSet->GetCellData()->GetArray("SHOW");
|
vtkDataArray* showArray = dataSet->GetCellData()->GetArray("SHOW");
|
||||||
if (showArray == nullptr)
|
if(showArray == nullptr)
|
||||||
return;
|
return;
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (show)
|
if(show)
|
||||||
value = 1;
|
value = 1;
|
||||||
for (int index : indexs)
|
for(int index : indexs)
|
||||||
showArray->SetComponent(index, 0, value);
|
showArray->SetComponent(index, 0, value);
|
||||||
|
|
||||||
this->updateDisplayMember();
|
this->updateDisplayMember();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::highLight()
|
void MeshKernalViewObj::highLight()
|
||||||
{
|
{
|
||||||
auto gp = Setting::BusAPI::instance()->getGraphOption();
|
auto gp = Setting::BusAPI::instance()->getGraphOption();
|
||||||
QColor color = gp->getHighLightColor();
|
QColor color = gp->getHighLightColor();
|
||||||
_actor[POINTACTOR]->GetMapper()->SetScalarVisibility(false);
|
_actor[POINTACTOR]->GetMapper()->SetScalarVisibility(false);
|
||||||
_actor[EDGEACTOR]->GetMapper()->SetScalarVisibility(false);
|
_actor[EDGEACTOR]->GetMapper()->SetScalarVisibility(false);
|
||||||
|
|
@ -276,13 +291,12 @@ namespace MainWidget
|
||||||
|
|
||||||
void MeshKernalViewObj::clearHighLight()
|
void MeshKernalViewObj::clearHighLight()
|
||||||
{
|
{
|
||||||
auto gp = Setting::BusAPI::instance()->getGraphOption();
|
auto gp = Setting::BusAPI::instance()->getGraphOption();
|
||||||
QColor color = gp->getMeshEdgeColor();
|
QColor color = gp->getMeshEdgeColor();
|
||||||
_actor[POINTACTOR]->GetMapper()->SetScalarVisibility(true);
|
_actor[POINTACTOR]->GetMapper()->SetScalarVisibility(true);
|
||||||
_actor[EDGEACTOR]->GetMapper()->SetScalarVisibility(true);
|
_actor[EDGEACTOR]->GetMapper()->SetScalarVisibility(true);
|
||||||
_actor[FACEACTOR]->GetMapper()->SetScalarVisibility(true);
|
_actor[FACEACTOR]->GetMapper()->SetScalarVisibility(true);
|
||||||
if (gp->isShowMeshEdge() && gp->isShowMeshFace())
|
if(gp->isShowMeshEdge() && gp->isShowMeshFace()) {
|
||||||
{
|
|
||||||
_actor[EDGEACTOR]->GetMapper()->SetScalarVisibility(false);
|
_actor[EDGEACTOR]->GetMapper()->SetScalarVisibility(false);
|
||||||
_actor[EDGEACTOR]->GetProperty()->SetColor(color.red(), color.green(), color.blue());
|
_actor[EDGEACTOR]->GetProperty()->SetColor(color.red(), color.green(), color.blue());
|
||||||
}
|
}
|
||||||
|
|
@ -297,50 +311,70 @@ namespace MainWidget
|
||||||
|
|
||||||
void MeshKernalViewObj::generateIDProp()
|
void MeshKernalViewObj::generateIDProp()
|
||||||
{
|
{
|
||||||
auto dataset = _kernal->getMeshData();
|
auto dataset = _kernal->getMeshData();
|
||||||
const int id = _kernal->getID(); // IDS (kernalid,pointId)
|
const int id = _kernal->getID(); // IDS (kernalid,pointId)
|
||||||
// cell ID与显示隐藏状态
|
// cell ID与显示隐藏状态
|
||||||
vtkSmartPointer<vtkUnsignedIntArray> kcellid_index = vtkSmartPointer<vtkUnsignedIntArray>::New();
|
vtkSmartPointer<vtkUnsignedIntArray> kcellid_index =
|
||||||
|
vtkSmartPointer<vtkUnsignedIntArray>::New();
|
||||||
kcellid_index->SetNumberOfComponents(2); // 设置 dimension
|
kcellid_index->SetNumberOfComponents(2); // 设置 dimension
|
||||||
kcellid_index->SetName("IDS");
|
kcellid_index->SetName("IDS");
|
||||||
const int ncell = dataset->GetNumberOfCells();
|
const int ncell = dataset->GetNumberOfCells();
|
||||||
for (int i = 0; i < ncell; ++i)
|
for(int i = 0; i < ncell; ++i)
|
||||||
kcellid_index->InsertNextTuple2(id, i); // 这里添加 网格id ,与 cell 序号
|
kcellid_index->InsertNextTuple2(id, i); // 这里添加 网格id ,与 cell 序号
|
||||||
dataset->GetCellData()->AddArray(kcellid_index);
|
dataset->GetCellData()->AddArray(kcellid_index);
|
||||||
|
|
||||||
vtkSmartPointer<vtkUnsignedIntArray> cstatesArray = vtkSmartPointer<vtkUnsignedIntArray>::New();
|
vtkSmartPointer<vtkUnsignedIntArray> cstatesArray =
|
||||||
|
vtkSmartPointer<vtkUnsignedIntArray>::New();
|
||||||
cstatesArray->SetName("SHOW");
|
cstatesArray->SetName("SHOW");
|
||||||
cstatesArray->SetNumberOfValues(ncell);
|
cstatesArray->SetNumberOfValues(ncell);
|
||||||
cstatesArray->Fill(1);
|
cstatesArray->Fill(1);
|
||||||
dataset->GetCellData()->AddArray(cstatesArray);
|
dataset->GetCellData()->AddArray(cstatesArray);
|
||||||
|
|
||||||
// vtkSmartPointer<vtkUnsignedCharArray> selectSateArray = vtkSmartPointer<vtkUnsignedCharArray>::New();
|
vtkSmartPointer<vtkIntArray> metralArray =
|
||||||
// selectSateArray->SetName("SELECT");
|
vtkSmartPointer<vtkIntArray>::New();
|
||||||
// selectSateArray->SetNumberOfValues(ncell);
|
metralArray->SetName("MATERIAL");
|
||||||
// selectSateArray->Fill(0);
|
metralArray->SetNumberOfValues(ncell);
|
||||||
// dataset->GetCellData()->AddArray(selectSateArray); // select
|
metralArray->Fill(-1);
|
||||||
|
dataset->GetCellData()->AddArray(metralArray);
|
||||||
|
|
||||||
|
|
||||||
|
// vtkSmartPointer<vtkUnsignedCharArray> selectSateArray =
|
||||||
|
// vtkSmartPointer<vtkUnsignedCharArray>::New(); selectSateArray->SetName("SELECT");
|
||||||
|
// selectSateArray->SetNumberOfValues(ncell);
|
||||||
|
// selectSateArray->Fill(0);
|
||||||
|
// dataset->GetCellData()->AddArray(selectSateArray); // select
|
||||||
|
|
||||||
// point ID与显示隐藏状态
|
// point ID与显示隐藏状态
|
||||||
vtkSmartPointer<vtkUnsignedIntArray> kpointid_index = vtkSmartPointer<vtkUnsignedIntArray>::New();
|
vtkSmartPointer<vtkUnsignedIntArray> kpointid_index =
|
||||||
|
vtkSmartPointer<vtkUnsignedIntArray>::New();
|
||||||
kpointid_index->SetNumberOfComponents(2);
|
kpointid_index->SetNumberOfComponents(2);
|
||||||
kpointid_index->SetName("IDS");
|
kpointid_index->SetName("IDS");
|
||||||
const int npoint = dataset->GetNumberOfPoints();
|
const int npoint = dataset->GetNumberOfPoints();
|
||||||
for (int i = 0; i < npoint; ++i)
|
for(int i = 0; i < npoint; ++i)
|
||||||
kpointid_index->InsertNextTuple2(id, i);
|
kpointid_index->InsertNextTuple2(id, i);
|
||||||
dataset->GetPointData()->AddArray(kpointid_index);
|
dataset->GetPointData()->AddArray(kpointid_index);
|
||||||
|
|
||||||
vtkSmartPointer<vtkUnsignedIntArray> pstatesArray = vtkSmartPointer<vtkUnsignedIntArray>::New();
|
vtkSmartPointer<vtkUnsignedIntArray> pstatesArray =
|
||||||
|
vtkSmartPointer<vtkUnsignedIntArray>::New();
|
||||||
pstatesArray->SetName("SHOW");
|
pstatesArray->SetName("SHOW");
|
||||||
pstatesArray->SetNumberOfValues(npoint);
|
pstatesArray->SetNumberOfValues(npoint);
|
||||||
pstatesArray->Fill(1);
|
pstatesArray->Fill(1);
|
||||||
dataset->GetPointData()->AddArray(pstatesArray);
|
dataset->GetPointData()->AddArray(pstatesArray);
|
||||||
|
|
||||||
// vtkSmartPointer<vtkUnsignedCharArray> pselectSateArray = vtkSmartPointer<vtkUnsignedCharArray>::New();
|
vtkSmartPointer<vtkIntArray> pmetralArray =
|
||||||
// pselectSateArray->SetName("SELECT");
|
vtkSmartPointer<vtkIntArray>::New();
|
||||||
// pselectSateArray->SetNumberOfValues(ncell);
|
pmetralArray->SetName("MATERIAL"); // 材料
|
||||||
// pselectSateArray->Fill(0);
|
pmetralArray->SetNumberOfValues(ncell);
|
||||||
// dataset->GetPointData()->AddArray(pselectSateArray); // select
|
pmetralArray->Fill(-1);
|
||||||
|
dataset->GetPointData()->AddArray(pmetralArray);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// vtkSmartPointer<vtkUnsignedCharArray> pselectSateArray =
|
||||||
|
// vtkSmartPointer<vtkUnsignedCharArray>::New(); pselectSateArray->SetName("SELECT");
|
||||||
|
// pselectSateArray->SetNumberOfValues(ncell);
|
||||||
|
// pselectSateArray->Fill(0);
|
||||||
|
// dataset->GetPointData()->AddArray(pselectSateArray); // select
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshKernalViewObj::init()
|
void MeshKernalViewObj::init()
|
||||||
|
|
@ -376,37 +410,158 @@ namespace MainWidget
|
||||||
|
|
||||||
void MeshKernalViewObj::updateDisplayMember()
|
void MeshKernalViewObj::updateDisplayMember()
|
||||||
{
|
{
|
||||||
auto dataset = _kernal->getMeshData();
|
DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
vtkDataArray *array = dataset->GetCellData()->GetArray("SHOW");
|
auto dataset = _kernal->getMeshData();
|
||||||
if (array == nullptr)
|
qDebug() << QString("point number %1").arg(dataset->GetNumberOfPoints());
|
||||||
|
qDebug() << QString("cell number %1").arg(dataset->GetNumberOfCells());
|
||||||
|
|
||||||
|
|
||||||
|
vtkPolyData* dataold = vtkPolyData::SafeDownCast(dataset);
|
||||||
|
vtkPolyData* datanew = nullptr;
|
||||||
|
DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
|
// 创建 vtkThreshold 过滤器
|
||||||
|
vtkSmartPointer<vtkThreshold> threshold = vtkSmartPointer<vtkThreshold>::New();
|
||||||
|
threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "SHOW");
|
||||||
|
threshold->SetInputData(dataset);
|
||||||
|
threshold->SetLowerThreshold(0.5); // 设置筛选条件,大于 100 的面将被保留
|
||||||
|
threshold->SetUpperThreshold(1.5);
|
||||||
|
threshold->Update();
|
||||||
|
_displayData->DeepCopy(threshold->GetOutput());
|
||||||
|
// vtkSmartPointer<vtkGeometryFilter> geofilter = vtkSmartPointer<vtkGeometryFilter>::New();
|
||||||
|
// geofilter->SetInputData(threshold->GetOutput());
|
||||||
|
// geofilter->Update();
|
||||||
|
// datanew = vtkPolyData::SafeDownCast(geofilter->GetOutput());
|
||||||
|
// qDebug() << (QString("void MeshKernalViewObj::updateDisplayMember() %1\n")
|
||||||
|
// .arg(datanew == nullptr));
|
||||||
|
//
|
||||||
|
// QString("cell number %1").arg(nullptr == datanew);
|
||||||
|
// vtkDataArray* cellNewIDS = datanew->GetPointData()->GetArray("IDS");
|
||||||
|
// std::set<int> pointSet;
|
||||||
|
// for(int i = 0; i < cellNewIDS->GetNumberOfTuples(); i++) {
|
||||||
|
// pointSet.insert(cellNewIDS->GetComponent(i, 1));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Points
|
||||||
|
// vtkDataArray* PointShowArray = dataold->GetPointData()->GetArray("SHOW");
|
||||||
|
// vtkDataArray* PointIDSArray = dataold->GetPointData()->GetArray("IDS");
|
||||||
|
// int numArrays = dataold->GetNumberOfPoints();
|
||||||
|
// vtkPointData* pointDataold = dataold->GetPointData();
|
||||||
|
//
|
||||||
|
// // 复制与粘贴
|
||||||
|
// vtkDataArray* cellIDSArray = dataold->GetCellData()->GetArray("IDS");
|
||||||
|
// int maxIds=0;
|
||||||
|
// for(int i=0;i<cellIDSArray->GetNumberOfTuples();i++){
|
||||||
|
// maxIds=std::max(maxIds,int(cellIDSArray->GetComponent(i,1)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int kid=_kernal->getID();
|
||||||
|
//
|
||||||
|
// DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
|
// for(int i = 0; i < numArrays; ++i) {
|
||||||
|
// if(fabs(PointShowArray->GetComponent(i, 0)) > 0.5
|
||||||
|
// && pointSet.find(int(PointIDSArray->GetComponent(i, 1))) == pointSet.end()) { // 显示同时又不在显示的点
|
||||||
|
// // 处理几何
|
||||||
|
// vtkIdType pid=datanew->GetPoints()->InsertNextPoint(dataold->GetPoint(i));
|
||||||
|
// vtkVertex* newVertex = vtkVertex::New();
|
||||||
|
// newVertex->GetPointIds()->SetId(pid, pid);
|
||||||
|
// datanew->GetPolys()->InsertNextCell(newVertex);
|
||||||
|
//
|
||||||
|
// int numArrays = pointDataold->GetNumberOfArrays();
|
||||||
|
// for(int i = 0; i < numArrays; ++i) {
|
||||||
|
// vtkDataArray* dataArray = pointDataold->GetArray(i);
|
||||||
|
// if(nullptr==dataArray){continue;}
|
||||||
|
// const char* arrayName = dataArray->GetName();
|
||||||
|
// vtkDataArray* dataArraynew=datanew->GetPointData()->GetArray(arrayName);
|
||||||
|
// if(nullptr==dataArraynew){continue;}
|
||||||
|
// datanew->GetPointData()->GetArray(arrayName)->InsertNextTuple(dataArray->GetTuple(i));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 处理显示
|
||||||
|
// datanew->GetCellData()->GetArray("IDS")->InsertNextTuple2(kid , maxIds++);
|
||||||
|
// datanew->GetCellData()->GetArray("SHOW")->InsertNextTuple1(1);
|
||||||
|
// datanew->GetCellData()->GetArray("MATERIAL")->InsertNextTuple1(-1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
|
// vtkSmartPointer<vtkGeometryFilter> geofilters =vtkSmartPointer<vtkGeometryFilter>::New();
|
||||||
|
// geofilters->AddInputData(datanew);
|
||||||
|
//// geofilters->AddInputData(polygon);
|
||||||
|
// geofilters->Update();
|
||||||
|
//// DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
|
// DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
|
// datanew=geofilters->GetOutput();
|
||||||
|
_displayData->DeepCopy(datanew);
|
||||||
|
// // 分析平衡性
|
||||||
|
// qDebug()<<QString("Point nummber %1\n").arg(_displayData->GetNumberOfPoints());
|
||||||
|
// qDebug()<<QString("Point nummber IDS %1\n").arg(_displayData->GetPointData()->GetArray("IDS")->GetNumberOfTuples());
|
||||||
|
// qDebug()<<QString("Point nummber SHOW %1\n").arg(_displayData->GetPointData()->GetArray("SHOW")->GetNumberOfTuples());
|
||||||
|
// qDebug()<<QString("Point nummber MATERIAL %1\n").arg(_displayData->GetPointData()->GetArray("MATERIAL")->GetNumberOfTuples());
|
||||||
|
// qDebug()<<QString("cell nummber %1\n").arg(_displayData->GetNumberOfCells());
|
||||||
|
// qDebug()<<QString("cell nummber IDS %1\n").arg(_displayData->GetCellData()->GetArray("IDS")->GetNumberOfTuples());
|
||||||
|
// qDebug()<<QString("cell nummber SHOW %1\n").arg(_displayData->GetCellData()->GetArray("SHOW")->GetNumberOfTuples());
|
||||||
|
// qDebug()<<QString("cell nummber MATERIAL %1\n").arg(_displayData->GetCellData()->GetArray("MATERIAL")->GetNumberOfTuples());
|
||||||
|
//
|
||||||
|
// vtkSmartPointer<vtkPolyDataWriter> writer = vtkSmartPointer<vtkPolyDataWriter>::New();
|
||||||
|
// writer->SetInputData(_displayData);
|
||||||
|
// writer->SetFileTypeToBinary();
|
||||||
|
// writer->SetFileName("testOut.vtk");
|
||||||
|
// writer->Write();
|
||||||
|
//
|
||||||
|
// vtkSmartPointer<vtkSTLWriter> stlwriter = vtkSmartPointer<vtkSTLWriter>::New();
|
||||||
|
// stlwriter->SetInputData(_displayData);
|
||||||
|
// // writer->SetInputData(ungird);
|
||||||
|
// stlwriter->SetFileTypeToBinary();
|
||||||
|
// stlwriter->SetFileName("testOut.stl");
|
||||||
|
// stlwriter->Write();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// DebugInfo("void MeshKernalViewObj::updateDisplayMember()\n");
|
||||||
|
_displayData->Modified();
|
||||||
|
}
|
||||||
|
void MeshKernalViewObj::modifyPointDisplay()
|
||||||
|
{
|
||||||
|
_displayData->Modified();
|
||||||
|
}
|
||||||
|
void MeshKernalViewObj::showPoints(const QList<int>& index, bool show)
|
||||||
|
{
|
||||||
|
std::set<int> indexSet(index.begin(), index.end());
|
||||||
|
// 判断是否需要显示
|
||||||
|
auto dataSet = _kernal->getMeshData();
|
||||||
|
vtkDataArray* showArray = dataSet->GetPointData()->GetArray("SHOW");
|
||||||
|
if(showArray == nullptr)
|
||||||
return;
|
return;
|
||||||
|
int value = 0;
|
||||||
vtkSmartPointer<vtkIdTypeArray> idArray = vtkSmartPointer<vtkIdTypeArray>::New();
|
if(show)
|
||||||
const int n = array->GetNumberOfTuples();
|
value = 1;
|
||||||
for (int i = 0; i < n; ++i)
|
int pointid = -1;
|
||||||
{
|
for(int i = 0; i < showArray->GetNumberOfTuples(); ++i) {
|
||||||
double v = fabs(array->GetComponent(i, 0));
|
int pointid = showArray->GetComponent(i, 1);
|
||||||
if (v > 0.5)
|
if(indexSet.find(pointid) != indexSet.end()) // 判断是否正确
|
||||||
idArray->InsertNextValue(i);
|
{
|
||||||
|
showArray->SetComponent(i, 0, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
vtkSmartPointer<vtkSelectionNode> selectionNode = vtkSmartPointer<vtkSelectionNode>::New();
|
// 更新cell显示
|
||||||
selectionNode->SetFieldType(vtkSelectionNode::CELL);
|
QList<int> hideCells;
|
||||||
selectionNode->SetContentType(vtkSelectionNode::INDICES);
|
hideCells.clear();
|
||||||
selectionNode->SetSelectionList(idArray);
|
// 计算联通单元
|
||||||
vtkSmartPointer<vtkSelection> selection = vtkSmartPointer<vtkSelection>::New();
|
size_t ncell = dataSet->GetNumberOfCells();
|
||||||
selection->AddNode(selectionNode);
|
vtkDataArray* cids = dataSet->GetCellData()->GetArray("IDS");
|
||||||
|
for(size_t cellId = 0; cellId < ncell; cellId++) {
|
||||||
vtkSmartPointer<vtkExtractSelection> extractionSelection = vtkSmartPointer<vtkExtractSelection>::New();
|
vtkCell* cell = dataSet->GetCell(cellId);
|
||||||
extractionSelection->SetInputData(0, dataset);
|
vtkIdList* pointIds = cell->GetPointIds();
|
||||||
extractionSelection->SetInputData(1, selection);
|
for(vtkIdType j = 0; j < pointIds->GetNumberOfIds(); ++j) {
|
||||||
extractionSelection->Update();
|
vtkIdType pointId = pointIds->GetId(j);
|
||||||
|
if(fabs(showArray->GetComponent(pointId, 0)) < 0.5) // 存在一个隐藏
|
||||||
_displayData->DeepCopy(extractionSelection->GetOutput());
|
{
|
||||||
_displayData->Modified();
|
hideCells.push_back(cids->GetComponent(cellId, 1));
|
||||||
}
|
break;
|
||||||
void MeshKernalViewObj::modifyPointDisplay() {
|
}
|
||||||
_displayData->Modified();
|
}
|
||||||
|
}
|
||||||
|
this->showCells(hideCells, show);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace MainWidget
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
#define EDGEACTOR 1
|
#define EDGEACTOR 1
|
||||||
#define FACEACTOR 2
|
#define FACEACTOR 2
|
||||||
|
|
||||||
|
#include "mainWidgetsAPI.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "meshViewProvider.h"
|
#include "meshViewProvider.h"
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace MeshData
|
||||||
|
|
||||||
namespace MainWidget
|
namespace MainWidget
|
||||||
{
|
{
|
||||||
class MeshKernalViewObj :public QObject
|
class MAINWIDGETSAPI MeshKernalViewObj :public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
@ -120,6 +120,9 @@ namespace MainWidget
|
||||||
* @param show 是否显示
|
* @param show 是否显示
|
||||||
*/
|
*/
|
||||||
void showCells(const QList<int>& index, bool show);
|
void showCells(const QList<int>& index, bool show);
|
||||||
|
|
||||||
|
void showPoints(const QList<int>& index, bool show);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 强制刷新显示对象
|
* @brief 强制刷新显示对象
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,21 @@
|
||||||
#include "Settings/BusAPI.h"
|
#include "Settings/BusAPI.h"
|
||||||
#include "Settings/GraphOption.h"
|
#include "Settings/GraphOption.h"
|
||||||
#include "Common/DebugLogger.h"
|
#include "Common/DebugLogger.h"
|
||||||
|
#include "PythonModule/PyAgent.h"
|
||||||
#include <vtkActor.h>
|
#include <vtkActor.h>
|
||||||
#include <vtkDataSetMapper.h>
|
#include <vtkDataSetMapper.h>
|
||||||
#include <vtkDataSet.h>
|
#include <vtkDataSet.h>
|
||||||
#include <vtkProperty.h>
|
#include <vtkProperty.h>
|
||||||
#include <vtkPointData.h>
|
#include <vtkPointData.h>
|
||||||
#include <vtkDataArray.h>
|
#include <vtkDataArray.h>
|
||||||
|
#include <vtkSelectionNode.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <vtkExtractSelection.h>
|
||||||
|
#include <vtkAppendFilter.h>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <vtkUnstructuredGridWriter.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
namespace MainWidget
|
namespace MainWidget
|
||||||
{
|
{
|
||||||
|
|
@ -35,6 +42,7 @@ namespace MainWidget
|
||||||
|
|
||||||
connect(_mainWindow, SIGNAL(updateMeshSetVisibleSig(MeshData::MeshSet*)), this,SLOT(updateMeshSetVisibily(MeshData::MeshSet*)));
|
connect(_mainWindow, SIGNAL(updateMeshSetVisibleSig(MeshData::MeshSet*)), this,SLOT(updateMeshSetVisibily(MeshData::MeshSet*)));
|
||||||
connect(_mainWindow, SIGNAL(updateMeshSetColorSig(int)), this,SLOT(updateMeshSetColor(int)));
|
connect(_mainWindow, SIGNAL(updateMeshSetColorSig(int)), this,SLOT(updateMeshSetColor(int)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshViewProvider::~MeshViewProvider()
|
MeshViewProvider::~MeshViewProvider()
|
||||||
|
|
@ -409,5 +417,13 @@ namespace MainWidget
|
||||||
{
|
{
|
||||||
return &_highLightSelectItems;
|
return &_highLightSelectItems;
|
||||||
}
|
}
|
||||||
|
MeshKernalViewObj* MeshViewProvider::getViewObjects(MeshData::MeshKernal* k)
|
||||||
|
{
|
||||||
|
if(_viewObjects.contains(k)){
|
||||||
|
return _viewObjects.value(k);
|
||||||
|
}else{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -102,6 +102,9 @@ namespace MainWidget
|
||||||
*/
|
*/
|
||||||
QMultiHash<int, int> *getSelectItem();
|
QMultiHash<int, int> *getSelectItem();
|
||||||
|
|
||||||
|
MeshKernalViewObj * getViewObjects(MeshData::MeshKernal * k);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief 新建或者删除网格,更新显示
|
* @brief 新建或者删除网格,更新显示
|
||||||
|
|
@ -134,6 +137,7 @@ namespace MainWidget
|
||||||
*/
|
*/
|
||||||
void updateMeshSetColor(int setid);
|
void updateMeshSetColor(int setid);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief 移除显示对象,窗口将不再显示
|
* @brief 移除显示对象,窗口将不再显示
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,14 @@ namespace MainWidget
|
||||||
|
|
||||||
// 模型的世界坐标系
|
// 模型的世界坐标系
|
||||||
connect(this, SIGNAL(WorldPointMouseMove(double, double, double)),mw,SIGNAL(showStateToolbarPositionSIGNGAL(double, double, double)));
|
connect(this, SIGNAL(WorldPointMouseMove(double, double, double)),mw,SIGNAL(showStateToolbarPositionSIGNGAL(double, double, double)));
|
||||||
|
|
||||||
|
// 网格操作
|
||||||
|
connect(this, SIGNAL(deleteMeshSig(GUI::MainWindow *)), this, SLOT(deleteMesh(GUI::MainWindow *)));
|
||||||
|
connect(this, SIGNAL(copyMeshSig(GUI::MainWindow *)), this, SLOT(copyMesh(GUI::MainWindow *)));
|
||||||
|
connect(this, SIGNAL(clipMeshSig(GUI::MainWindow *)), this, SLOT(clipMesh(GUI::MainWindow *)));
|
||||||
|
|
||||||
|
connect(this->_meshProvider, SIGNAL(importMeshDataSetSig(vtkDataSet*)), this, SIGNAL(importMeshDataSetSig(vtkDataSet*)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PreWindow::~PreWindow()
|
PreWindow::~PreWindow()
|
||||||
|
|
@ -234,4 +242,5 @@ namespace MainWidget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,10 @@ namespace MainWidget
|
||||||
|
|
||||||
void highLightGeoComponentSig(Geometry::GeoComponent *aGC);
|
void highLightGeoComponentSig(Geometry::GeoComponent *aGC);
|
||||||
|
|
||||||
|
// 网格
|
||||||
|
void importMeshDataSetSig(vtkDataSet* dataset);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//设置选择模式
|
//设置选择模式
|
||||||
void setSelectModel(int mode) override;
|
void setSelectModel(int mode) override;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ add_library(MainWindow
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
target_compile_definitions(MainWindow PRIVATE "MAINWINDOW_API")
|
target_compile_definitions(MainWindow PRIVATE "MAINWINDOW_API")
|
||||||
|
|
||||||
list(APPEND _depend_library Common PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostRenderData PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence Common)
|
list(APPEND _depend_library Common PythonModule SARibbonBar Settings DataProperty MeshData Material Geometry ConfigOptions SelfDefObject ModelData ModuleBase PluginManager GmshModule PostInterface PostRenderData PostWidgets ProjectTree GeometryCommand GeometryWidgets IO SolverControl MainWidgets UserGuidence Common)
|
||||||
if(_WIN_)
|
if(_WIN_)
|
||||||
list(APPEND _depend_library XGenerateReport)
|
list(APPEND _depend_library XGenerateReport)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,9 @@ namespace GUI {
|
||||||
connect(this, SIGNAL(printMessageSig(Common::Message, QString)), this,
|
connect(this, SIGNAL(printMessageSig(Common::Message, QString)), this,
|
||||||
SLOT(printMessage(Common::Message, QString)));
|
SLOT(printMessage(Common::Message, QString)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 文件
|
// 文件
|
||||||
connect(_ui->actionNew, SIGNAL(triggered()), this, SLOT(on_actionNew()));
|
connect(_ui->actionNew, SIGNAL(triggered()), this, SLOT(on_actionNew()));
|
||||||
connect(_ui->actionOpen, SIGNAL(triggered()), this, SLOT(on_actionOpen()));
|
connect(_ui->actionOpen, SIGNAL(triggered()), this, SLOT(on_actionOpen()));
|
||||||
|
|
@ -432,7 +435,12 @@ namespace GUI {
|
||||||
connect(_ui->actionLoadGeometricCorrectionFile,SIGNAL(triggered()),this, SLOT(on_actionLoadGeometricCorrectionFile_triggereds()));
|
connect(_ui->actionLoadGeometricCorrectionFile,SIGNAL(triggered()),this, SLOT(on_actionLoadGeometricCorrectionFile_triggereds()));
|
||||||
connect(_ui->actionLoadRadioModelFile,SIGNAL(triggered()),this, SLOT(on_actionLoadRadioModelFile_triggereds()));
|
connect(_ui->actionLoadRadioModelFile,SIGNAL(triggered()),this, SLOT(on_actionLoadRadioModelFile_triggereds()));
|
||||||
|
|
||||||
|
// 网格操作
|
||||||
|
connect(_ui->actionMeshDelete, SIGNAL(triggered()),this,SLOT(on_deleteMesh()));
|
||||||
|
connect(_ui->actionMeshCopy, SIGNAL(triggered()),this,SLOT(on_copyMesh()));
|
||||||
|
connect(_ui->actionMeshClip, SIGNAL(triggered()),this,SLOT(on_clipMesh()));
|
||||||
|
// 网格三角网
|
||||||
|
connect(_ui->actionMeshTriangleSurface,SIGNAL(triggered()),this,SLOT(on_actionMeshTriangleSurface()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1736,6 +1744,30 @@ namespace GUI {
|
||||||
void MainWindow::on_actionLoadRadioModelFile_triggereds() {
|
void MainWindow::on_actionLoadRadioModelFile_triggereds() {
|
||||||
DebugInfo("on_actionLoadRadioModelFile_triggered\n");
|
DebugInfo("on_actionLoadRadioModelFile_triggered\n");
|
||||||
emit this->on_loadPreMeshFile(this, "radi");
|
emit this->on_loadPreMeshFile(this, "radi");
|
||||||
|
}
|
||||||
|
void MainWindow::on_deleteMesh() {
|
||||||
|
DebugInfo("MainWindow::on_deleteMesh\n");
|
||||||
|
emit this->on_deleteMeshSIGNAL(this);
|
||||||
|
}
|
||||||
|
void MainWindow::on_copyMesh() {
|
||||||
|
DebugInfo("MainWindow::on_copyMesh\n");
|
||||||
|
emit this->on_copyMeshSIGNAL(this);
|
||||||
|
}
|
||||||
|
void MainWindow::on_clipMesh() {
|
||||||
|
DebugInfo("MainWindow::on_clipMesh\n");
|
||||||
|
emit this->on_clipMeshSIGNAL(this);
|
||||||
|
}
|
||||||
|
void MainWindow::on_saveMeshEdit() {
|
||||||
|
DebugInfo("MainWindow::on_saveMeshEdit\n");
|
||||||
|
emit this->on_saveMeshSIGNAL(this);
|
||||||
|
}
|
||||||
|
void MainWindow::on_actionMeshTriangleSurface() {
|
||||||
|
DebugInfo("MainWindow::on_actionMeshTriangleSurface\n");
|
||||||
|
emit this->on_actionMeshTriangleSurfaceSIGNAL(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,11 @@ namespace GUI {
|
||||||
SARibbonActionsManager* getActionManager();
|
SARibbonActionsManager* getActionManager();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
// 网格操作
|
||||||
|
void on_deleteMeshSIGNAL(GUI::MainWindow* m);
|
||||||
|
void on_copyMeshSIGNAL(GUI::MainWindow* m);
|
||||||
|
void on_clipMeshSIGNAL(GUI::MainWindow* m);
|
||||||
|
void on_saveMeshSIGNAL(GUI::MainWindow* m);
|
||||||
/*更新注册接口*/
|
/*更新注册接口*/
|
||||||
void updateInterfaces();
|
void updateInterfaces();
|
||||||
/*发送信息给状态栏 */
|
/*发送信息给状态栏 */
|
||||||
|
|
@ -339,6 +344,8 @@ namespace GUI {
|
||||||
|
|
||||||
void on_loadPreMeshFile(GUI::MainWindow* m,QString modeltype);
|
void on_loadPreMeshFile(GUI::MainWindow* m,QString modeltype);
|
||||||
|
|
||||||
|
void on_actionMeshTriangleSurfaceSIGNAL(GUI::MainWindow* m);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/*状态栏显示信息 */
|
/*状态栏显示信息 */
|
||||||
void setStatusBarInfo(QString);
|
void setStatusBarInfo(QString);
|
||||||
|
|
@ -413,8 +420,13 @@ namespace GUI {
|
||||||
void on_actionLoadGeometricCorrectionFile_triggereds();
|
void on_actionLoadGeometricCorrectionFile_triggereds();
|
||||||
void on_actionLoadRadioModelFile_triggereds();
|
void on_actionLoadRadioModelFile_triggereds();
|
||||||
|
|
||||||
|
// 网格操作
|
||||||
|
void on_deleteMesh();
|
||||||
|
void on_copyMesh();
|
||||||
|
void on_clipMesh();
|
||||||
|
|
||||||
|
void on_saveMeshEdit();
|
||||||
|
void on_actionMeshTriangleSurface();
|
||||||
private slots:
|
private slots:
|
||||||
/*关闭主窗口 */
|
/*关闭主窗口 */
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,15 @@
|
||||||
<addaction name="actionBoxMeshSurfaceNode"/>
|
<addaction name="actionBoxMeshSurfaceNode"/>
|
||||||
<addaction name="actionBoxMeshSurfaceCell"/>
|
<addaction name="actionBoxMeshSurfaceCell"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuMeshEdit">
|
||||||
|
<property name="title">
|
||||||
|
<string>MeshEdit</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionMeshDelete"/>
|
||||||
|
<addaction name="actionMeshCopy"/>
|
||||||
|
<addaction name="actionMeshClip"/>
|
||||||
|
<addaction name="actionMeshTriangleSurface"/>
|
||||||
|
</widget>
|
||||||
<addaction name="actionSurfaceMesh"/>
|
<addaction name="actionSurfaceMesh"/>
|
||||||
<addaction name="actionSolidMesh"/>
|
<addaction name="actionSolidMesh"/>
|
||||||
<addaction name="actionFluidMesh"/>
|
<addaction name="actionFluidMesh"/>
|
||||||
|
|
@ -397,6 +406,7 @@
|
||||||
<addaction name="actionVTKTranslation"/>
|
<addaction name="actionVTKTranslation"/>
|
||||||
<addaction name="menuView_2"/>
|
<addaction name="menuView_2"/>
|
||||||
<addaction name="menuSelect"/>
|
<addaction name="menuSelect"/>
|
||||||
|
<addaction name="menuMeshEdit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuWindows">
|
<widget class="QMenu" name="menuWindows">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
@ -2722,6 +2732,26 @@
|
||||||
<string>BoxMeshSurfaceCell</string>
|
<string>BoxMeshSurfaceCell</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionMeshDelete">
|
||||||
|
<property name="text">
|
||||||
|
<string>MeshDelete</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMeshCopy">
|
||||||
|
<property name="text">
|
||||||
|
<string>MeshCopy</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMeshClip">
|
||||||
|
<property name="text">
|
||||||
|
<string>MeshClip</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMeshTriangleSurface">
|
||||||
|
<property name="text">
|
||||||
|
<string>MeshTriangleSurface</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../qrc/qianfan.qrc"/>
|
<include location="../qrc/qianfan.qrc"/>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,19 @@ namespace MeshData
|
||||||
UserDef = 101,
|
UserDef = 101,
|
||||||
EndType = 100000,
|
EndType = 100000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum vtkDataFieldName{
|
||||||
|
IDS,
|
||||||
|
SHOW,
|
||||||
|
MATERIAL
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* const vtkDataFieldNameStr[] = {
|
||||||
|
"IDS", // 索引
|
||||||
|
"SHOW", // 可见性
|
||||||
|
"MATERIAL" //材料
|
||||||
|
};
|
||||||
|
|
||||||
class SetMember;
|
class SetMember;
|
||||||
|
|
||||||
class MESHDATAAPI MeshSet : public DataProperty::ComponentBase
|
class MESHDATAAPI MeshSet : public DataProperty::ComponentBase
|
||||||
|
|
|
||||||
|
|
@ -546,6 +546,9 @@ namespace ModuleBase
|
||||||
int range[4];
|
int range[4];
|
||||||
this->getBoxRange(range);
|
this->getBoxRange(range);
|
||||||
vtkActorCollection *actors = _renderer->GetActors();
|
vtkActorCollection *actors = _renderer->GetActors();
|
||||||
|
if(nullptr==actors){
|
||||||
|
return;
|
||||||
|
}
|
||||||
actors->InitTraversal(); // 初始化指针
|
actors->InitTraversal(); // 初始化指针
|
||||||
const int nac = actors->GetNumberOfItems();
|
const int nac = actors->GetNumberOfItems();
|
||||||
for (int i = 0; i < nac; ++i)
|
for (int i = 0; i < nac; ++i)
|
||||||
|
|
@ -571,13 +574,20 @@ namespace ModuleBase
|
||||||
visiblePointsFilter->SetRenderer(_renderer);
|
visiblePointsFilter->SetRenderer(_renderer);
|
||||||
visiblePointsFilter->Update();
|
visiblePointsFilter->Update();
|
||||||
vtkDataSet* visiablePoints=visiblePointsFilter->GetOutput();
|
vtkDataSet* visiablePoints=visiblePointsFilter->GetOutput();
|
||||||
|
if(nullptr==visiablePoints){
|
||||||
|
DebugInfo("visiablePoints is null\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 选择范围分析
|
// 选择范围分析
|
||||||
QMultiHash<int,int> visiable_select{};
|
QMultiHash<int,int> visiable_select{};
|
||||||
vtkRenderer *render = this->GetInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
|
vtkRenderer *render = this->GetInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
|
||||||
vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();
|
vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();
|
||||||
coordinate->SetCoordinateSystemToWorld();
|
coordinate->SetCoordinateSystemToWorld();
|
||||||
vtkDataArray *ids = visiablePoints->GetPointData()->GetArray("IDS");
|
vtkDataArray *ids = visiablePoints->GetPointData()->GetArray("IDS");
|
||||||
|
if(nullptr==ids){
|
||||||
|
DebugInfo("visiablePoints->GetPointData()->GetArray(IDS) cids or pids is null\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const int npoint = visiablePoints->GetNumberOfPoints();
|
const int npoint = visiablePoints->GetNumberOfPoints();
|
||||||
|
|
||||||
for (int i = 0; i < npoint; ++i)
|
for (int i = 0; i < npoint; ++i)
|
||||||
|
|
@ -597,6 +607,11 @@ namespace ModuleBase
|
||||||
size_t ncell=dataset->GetNumberOfCells();
|
size_t ncell=dataset->GetNumberOfCells();
|
||||||
vtkDataArray* cids=dataset->GetCellData()->GetArray("IDS");
|
vtkDataArray* cids=dataset->GetCellData()->GetArray("IDS");
|
||||||
vtkDataArray* pids=dataset->GetPointData()->GetArray("IDS");
|
vtkDataArray* pids=dataset->GetPointData()->GetArray("IDS");
|
||||||
|
if(nullptr==cids||nullptr==pids){
|
||||||
|
DebugInfo("void PropPickerInteractionStyle::boxSelectMeshSurfaceCell() cids or pids is null\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for(size_t cellId=0;cellId<ncell;cellId++){
|
for(size_t cellId=0;cellId<ncell;cellId++){
|
||||||
vtkCell* cell = dataset->GetCell(cellId);
|
vtkCell* cell = dataset->GetCell(cellId);
|
||||||
double* c_id=cids->GetTuple2(cellId);
|
double* c_id=cids->GetTuple2(cellId);
|
||||||
|
|
@ -611,7 +626,6 @@ namespace ModuleBase
|
||||||
}else{}
|
}else{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit highLight(&_selectItems); // 绑定高亮事件
|
emit highLight(&_selectItems); // 绑定高亮事件
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,6 @@ add_library(PluginMeshDataExchange
|
||||||
${_interface}
|
${_interface}
|
||||||
${_header}
|
${_header}
|
||||||
${_source}
|
${_source}
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,369 @@
|
||||||
|
/**
|
||||||
|
* @file MeshOperator.cpp
|
||||||
|
* @brief None
|
||||||
|
* @author 陈增辉 (3045316072@qq.com)
|
||||||
|
* @version 2.5.0
|
||||||
|
* @date 24-7-8
|
||||||
|
* @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "MeshOperator.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include "MainWidgets/meshViewProvider.h"
|
||||||
|
#include "MainWidgets/meshKernalViewObject.h"
|
||||||
|
#include "MainWidgets/preWindow.h"
|
||||||
|
#include "MainWindow/SubWindowManager.h"
|
||||||
|
#include "MainWindow/MainWindow.h"
|
||||||
|
#include "MeshData/meshSingleton.h"
|
||||||
|
#include "MeshData/meshSet.h"
|
||||||
|
#include "MeshData/meshKernal.h"
|
||||||
|
#include "Settings/BusAPI.h"
|
||||||
|
#include "Settings/GraphOption.h"
|
||||||
|
#include "Common/DebugLogger.h"
|
||||||
|
#include "PythonModule/PyAgent.h"
|
||||||
|
#include <vtkActor.h>
|
||||||
|
#include <vtkDataSetMapper.h>
|
||||||
|
#include <vtkDataSet.h>
|
||||||
|
#include <vtkProperty.h>
|
||||||
|
#include <vtkPointData.h>
|
||||||
|
#include <vtkDataArray.h>
|
||||||
|
#include <vtkSelectionNode.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <vtkExtractSelection.h>
|
||||||
|
#include <vtkAppendFilter.h>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <vtkUnstructuredGridWriter.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
namespace MeshData {
|
||||||
|
MeshOperator::MeshOperator(GUI::MainWindow* _mainwindow): QObject(_mainwindow){
|
||||||
|
_mainwindow = _mainwindow;
|
||||||
|
_meshData = MeshData::MeshData::getInstance();
|
||||||
|
_preWindow = _mainwindow->getSubWindowManager()->getPreWindow();
|
||||||
|
_selectModel = _preWindow->getSelectModel();
|
||||||
|
_meshProvider = _preWindow->getMeshViewProvider();
|
||||||
|
|
||||||
|
}
|
||||||
|
MeshOperator::~MeshOperator(){
|
||||||
|
|
||||||
|
}
|
||||||
|
void MeshOperator::on_deleteMesh(){
|
||||||
|
QMultiHash<int, int> *selectItems = _preWindow->getSelectItems(); // 选择 mesh
|
||||||
|
this->deleteMesh(selectItems);
|
||||||
|
}
|
||||||
|
void MeshOperator::on_copyMesh(){
|
||||||
|
QMultiHash<int, int> *selectItems = _preWindow->getSelectItems(); // 选择 mesh
|
||||||
|
this->copyMesh(selectItems);
|
||||||
|
}
|
||||||
|
void MeshOperator::on_clipMesh(){
|
||||||
|
QMultiHash<int, int> *selectItems = _preWindow->getSelectItems(); // 选择 mesh
|
||||||
|
this->clipMesh(selectItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshOperator::on_selectMeshChange(int mode){
|
||||||
|
_selectModel = (ModuleBase::SelectModel)mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MeshOperator::deleteMesh(QMultiHash<int, int>* items) {
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::deleteMesh start ";
|
||||||
|
if (items->isEmpty())
|
||||||
|
return;
|
||||||
|
QList<int> datasetList = items->uniqueKeys(); // 获取所有的key
|
||||||
|
qDebug()<<QString("kernel size: %1").arg(datasetList.size());
|
||||||
|
for (auto dataset : datasetList)
|
||||||
|
{
|
||||||
|
auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
|
||||||
|
auto vObjs = _meshProvider->getViewObjects(k); // 获取对应的view对象
|
||||||
|
QList<int> members = items->values(); // 获取所有的value
|
||||||
|
if (vObjs == nullptr)
|
||||||
|
continue;
|
||||||
|
if(members.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_selectModel == ModuleBase::BoxMeshNode || _selectModel == ModuleBase::MeshNode||_selectModel==ModuleBase::BoxMeshSurfaceNode) {
|
||||||
|
vObjs->showPoints(members,false);
|
||||||
|
} else if(_selectModel == ModuleBase::BoxMeshCell || _selectModel == ModuleBase::MeshCell||_selectModel==ModuleBase::BoxMeshSurfaceCell) {
|
||||||
|
vObjs->showCells(members,false);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//k->getMeshData()->DeepCopy(vObjs->getDisplayData());// 更新结果 与 显示保持一致
|
||||||
|
//vObjs->getDisplayData()->DeepCopy(k->getMeshData());
|
||||||
|
vObjs->modifyPointDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
_preWindow->reRender();
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::deleteMesh finish ";
|
||||||
|
|
||||||
|
}
|
||||||
|
// 模型复制
|
||||||
|
void MeshOperator::copyMesh(QMultiHash<int, int>* items) {
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh start ";
|
||||||
|
// 设置文件保存地址
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save Mesh File"), "", tr("VTK(*.vtk)"));
|
||||||
|
if(fileName.isEmpty()){
|
||||||
|
return;
|
||||||
|
}else{}
|
||||||
|
if (items->isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QColor c = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor();
|
||||||
|
QList<int> datasetList = items->uniqueKeys(); // 获取所有的key
|
||||||
|
qDebug()<<QString("kernel size: %1").arg(datasetList.size());
|
||||||
|
vtkPolyData *polyData = vtkPolyData::New();// 创建新的对象
|
||||||
|
vtkSmartPointer<vtkAppendFilter> appf = vtkSmartPointer<vtkAppendFilter>::New();
|
||||||
|
for (auto dataset : datasetList)
|
||||||
|
{
|
||||||
|
auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
|
||||||
|
auto vObjs = _meshProvider->getViewObjects(k); // 获取对应的view对象
|
||||||
|
QList<int> members = items->values(); //
|
||||||
|
|
||||||
|
if (vObjs == nullptr)
|
||||||
|
continue;
|
||||||
|
if(members.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_selectModel == ModuleBase::BoxMeshNode || _selectModel == ModuleBase::MeshNode||_selectModel==ModuleBase::BoxMeshSurfaceNode) { // 复制Points
|
||||||
|
vtkPointData* points=k->getMeshData()->GetPointData();
|
||||||
|
vtkDataArray* pids=points->GetArray("IDS");
|
||||||
|
int ppid=-1;
|
||||||
|
int npoint=k->getMeshData()->GetNumberOfPoints(); // 点的数量
|
||||||
|
std::set<int> memberSet(members.begin(),members.end()); // 点集
|
||||||
|
vtkSmartPointer<vtkIdTypeArray> idArray = vtkSmartPointer<vtkIdTypeArray>::New(); // 复制点
|
||||||
|
for(int pid=0;pid<npoint;++pid){
|
||||||
|
double* p=pids->GetTuple2(pid);
|
||||||
|
ppid=p[1];
|
||||||
|
if(memberSet.find(ppid)!=memberSet.end()){ // 目标点直接复制
|
||||||
|
idArray->InsertNextValue(pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qDebug()<<QString("Cell %1 %2").arg(npoint,idArray->GetNumberOfValues());
|
||||||
|
// 复制点集
|
||||||
|
vtkSmartPointer<vtkSelectionNode> selectionNode = vtkSmartPointer<vtkSelectionNode>::New();
|
||||||
|
selectionNode->SetFieldType(vtkSelectionNode::POINT);
|
||||||
|
selectionNode->SetContentType(vtkSelectionNode::INDICES);
|
||||||
|
selectionNode->SetSelectionList(idArray);
|
||||||
|
vtkSmartPointer<vtkSelection> selection = vtkSmartPointer<vtkSelection>::New();
|
||||||
|
selection->AddNode(selectionNode);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkExtractSelection> extractionSelection = vtkSmartPointer<vtkExtractSelection>::New();
|
||||||
|
extractionSelection->SetInputData(0, k->getMeshData());
|
||||||
|
extractionSelection->SetInputData(1, selection);
|
||||||
|
extractionSelection->Update();
|
||||||
|
appf->AddInputData(extractionSelection->GetOutput());
|
||||||
|
vtkDataSet* copyVtkdata=appf->GetOutput();
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish "<<QString(" copyVtkdata number: %1").arg(copyVtkdata->GetNumberOfPoints());
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish "<<QString(" copyVtkdata point value ids : %1").arg(idArray->GetNumberOfValues());
|
||||||
|
|
||||||
|
} else if(_selectModel == ModuleBase::BoxMeshCell || _selectModel == ModuleBase::MeshCell||_selectModel==ModuleBase::BoxMeshSurfaceCell) { // 绘制cell
|
||||||
|
int ppid=-1;
|
||||||
|
int npoint=k->getMeshData()->GetNumberOfPoints(); // 点的数量
|
||||||
|
// 复制面片
|
||||||
|
vtkSmartPointer<vtkIdTypeArray> idArray = vtkSmartPointer<vtkIdTypeArray>::New();
|
||||||
|
std::set<int> memberSet(members.begin(),members.end()); // 点集
|
||||||
|
int ncell=k->getMeshData()->GetNumberOfCells();
|
||||||
|
vtkDataArray* pids=k->getMeshData()->GetPointData()->GetArray("IDS");
|
||||||
|
for(size_t cellId=0;cellId<ncell;cellId++){
|
||||||
|
vtkCell* cell = k->getMeshData()->GetCell(cellId);
|
||||||
|
|
||||||
|
vtkIdList* pointIds = cell->GetPointIds();
|
||||||
|
for (vtkIdType j = 0; j < pointIds->GetNumberOfIds(); ++j)
|
||||||
|
{
|
||||||
|
vtkIdType pointId = pointIds->GetId(j);
|
||||||
|
double *p = pids->GetTuple2(pointId);
|
||||||
|
ppid=p[1];
|
||||||
|
if(memberSet.find(ppid)!=memberSet.end()){ // 目标点直接复制
|
||||||
|
idArray->InsertNextValue(cellId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vtkSmartPointer<vtkSelectionNode> selectionNode = vtkSmartPointer<vtkSelectionNode>::New();
|
||||||
|
selectionNode->SetFieldType(vtkSelectionNode::CELL);
|
||||||
|
selectionNode->SetContentType(vtkSelectionNode::INDICES);
|
||||||
|
selectionNode->SetSelectionList(idArray);
|
||||||
|
vtkSmartPointer<vtkSelection> selection = vtkSmartPointer<vtkSelection>::New();
|
||||||
|
selection->AddNode(selectionNode);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkExtractSelection> extractionSelection = vtkSmartPointer<vtkExtractSelection>::New();
|
||||||
|
extractionSelection->SetInputData(0, k->getMeshData());
|
||||||
|
extractionSelection->SetInputData(1, selection);
|
||||||
|
extractionSelection->Update();
|
||||||
|
appf->AddInputData(extractionSelection->GetOutput());
|
||||||
|
vtkDataSet* copyVtkdata=appf->GetOutput();
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish "<<QString(" copyVtkdata number: %1").arg(copyVtkdata->GetNumberOfPoints());
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish "<<QString(" copyVtkdata cell value ids : %1").arg(idArray->GetNumberOfValues());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
appf->Update();
|
||||||
|
vtkDataSet* copyVtkdata=appf->GetOutput();
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish "<<QString(" copyVtkdata number: %1").arg(copyVtkdata->GetNumberOfPoints());
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish "<<QString(" copyVtkdata cells: %1").arg(copyVtkdata->GetNumberOfCells());
|
||||||
|
// 复制数据
|
||||||
|
if(QFileInfo(fileName).exists()){
|
||||||
|
QFile(fileName).remove();
|
||||||
|
}else{}
|
||||||
|
vtkSmartPointer<vtkUnstructuredGridWriter> writer = vtkSmartPointer<vtkUnstructuredGridWriter>::New();
|
||||||
|
writer->SetInputData(copyVtkdata);
|
||||||
|
writer->SetFileTypeToBinary();
|
||||||
|
writer->SetFileName(fileName.toLocal8Bit().constData());
|
||||||
|
writer->Write();
|
||||||
|
// 重新加载数据
|
||||||
|
if(QFileInfo(fileName).exists()){
|
||||||
|
QString pyCode = QString("MainWindow.importMesh(\"%1\",\"%2\",%3)")
|
||||||
|
.arg(fileName)
|
||||||
|
.arg("VTK(*.vtk)")
|
||||||
|
.arg(-1);
|
||||||
|
Py::PythonAgent::getInstance()->submit(pyCode); // 加载数据
|
||||||
|
}else{
|
||||||
|
QMessageBox::warning(nullptr,"Warning","Copy Mesh File Save Failed !");
|
||||||
|
emit _mainwindow->importMeshDataSetSig(copyVtkdata);
|
||||||
|
}
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::copyMesh finish ";
|
||||||
|
// 模型复制
|
||||||
|
}
|
||||||
|
// 模型裁剪
|
||||||
|
void MeshOperator::clipMesh(QMultiHash<int, int>* items) {
|
||||||
|
// qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::clipMesh start ";
|
||||||
|
// // 设置文件保存地址
|
||||||
|
// QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save Mesh File"), "", tr("VTK(*.vtk)"));
|
||||||
|
// if(fileName.isEmpty()){
|
||||||
|
// return;
|
||||||
|
// }else{}
|
||||||
|
// if (items->isEmpty())
|
||||||
|
// return;
|
||||||
|
// _highLightSelectItems = *items;
|
||||||
|
// QColor c = Setting::BusAPI::instance()->getGraphOption()->getHighLightColor();
|
||||||
|
// QList<int> datasetList = items->uniqueKeys(); // 获取所有的key
|
||||||
|
// qDebug()<<QString("kernel size: %1").arg(datasetList.size());
|
||||||
|
// vtkPolyData *polyData = vtkPolyData::New();// 创建新的对象
|
||||||
|
// vtkSmartPointer<vtkAppendFilter> appf = vtkSmartPointer<vtkAppendFilter>::New();
|
||||||
|
// for (auto dataset : datasetList)
|
||||||
|
// {
|
||||||
|
// auto k = _meshData->getKernalByID(dataset); // 获取对应的kernal
|
||||||
|
// auto vObjs = _viewObjects.value(k); // 获取对应的view对象
|
||||||
|
// QList<int> members = items->values(); //
|
||||||
|
//
|
||||||
|
// if (vObjs == nullptr)
|
||||||
|
// continue;
|
||||||
|
// if(members.isEmpty()){
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(_selectModel == ModuleBase::BoxMeshNode || _selectModel == ModuleBase::MeshNode||_selectModel==ModuleBase::BoxMeshSurfaceNode) { // 复制Points
|
||||||
|
// vtkPointData* points=k->getMeshData()->GetPointData();
|
||||||
|
// vtkDataArray* pids=points->GetArray("IDS");
|
||||||
|
// int ppid=-1;
|
||||||
|
// int npoint=k->getMeshData()->GetNumberOfPoints(); // 点的数量
|
||||||
|
// std::set<int> memberSet(members.begin(),members.end()); // 点集
|
||||||
|
// vtkSmartPointer<vtkIdTypeArray> idArray = vtkSmartPointer<vtkIdTypeArray>::New(); // 复制点
|
||||||
|
// for(int pid=0;pid<npoint;++pid){
|
||||||
|
// double* p=pids->GetTuple2(pid);
|
||||||
|
// ppid=p[1];
|
||||||
|
// if(memberSet.find(ppid)!=memberSet.end()){ // 目标点直接复制
|
||||||
|
// idArray->InsertNextValue(pid);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 复制点集
|
||||||
|
// vtkSmartPointer<vtkSelectionNode> selectionNode = vtkSmartPointer<vtkSelectionNode>::New();
|
||||||
|
// selectionNode->SetFieldType(vtkSelectionNode::POINT);
|
||||||
|
// selectionNode->SetContentType(vtkSelectionNode::INDICES);
|
||||||
|
// selectionNode->SetSelectionList(idArray);
|
||||||
|
// vtkSmartPointer<vtkSelection> selection = vtkSmartPointer<vtkSelection>::New();
|
||||||
|
// selection->AddNode(selectionNode);
|
||||||
|
//
|
||||||
|
// vtkSmartPointer<vtkExtractSelection> extractionSelection = vtkSmartPointer<vtkExtractSelection>::New();
|
||||||
|
// extractionSelection->SetInputData(0, k->getMeshData());
|
||||||
|
// extractionSelection->SetInputData(1, selection);
|
||||||
|
// extractionSelection->Update();
|
||||||
|
// appf->AddInputData(extractionSelection->GetOutput());
|
||||||
|
//
|
||||||
|
// } else if(_selectModel == ModuleBase::BoxMeshCell || _selectModel == ModuleBase::MeshCell||_selectModel==ModuleBase::BoxMeshSurfaceCell) { // 绘制cell
|
||||||
|
// int ppid=-1;
|
||||||
|
// int npoint=k->getMeshData()->GetNumberOfPoints(); // 点的数量
|
||||||
|
// // 复制面片
|
||||||
|
// vtkSmartPointer<vtkIdTypeArray> idArray = vtkSmartPointer<vtkIdTypeArray>::New();
|
||||||
|
// std::set<int> memberSet(members.begin(),members.end()); // 点集
|
||||||
|
// int ncell=k->getMeshData()->GetNumberOfCells();
|
||||||
|
// vtkDataArray* pids=k->getMeshData()->GetPointData()->GetArray("IDS");
|
||||||
|
// for(size_t cellId=0;cellId<ncell;cellId++){
|
||||||
|
// vtkCell* cell = k->getMeshData()->GetCell(cellId);
|
||||||
|
//
|
||||||
|
// vtkIdList* pointIds = cell->GetPointIds();
|
||||||
|
// for (vtkIdType j = 0; j < pointIds->GetNumberOfIds(); ++j)
|
||||||
|
// {
|
||||||
|
// vtkIdType pointId = pointIds->GetId(j);
|
||||||
|
// double *p = pids->GetTuple2(pointId);
|
||||||
|
// ppid=p[1];
|
||||||
|
// if(memberSet.find(ppid)!=memberSet.end()){ // 目标点直接复制
|
||||||
|
// idArray->InsertNextValue(cellId);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// vtkSmartPointer<vtkSelectionNode> selectionNode = vtkSmartPointer<vtkSelectionNode>::New();
|
||||||
|
// selectionNode->SetFieldType(vtkSelectionNode::CELL);
|
||||||
|
// selectionNode->SetContentType(vtkSelectionNode::INDICES);
|
||||||
|
// selectionNode->SetSelectionList(idArray);
|
||||||
|
// vtkSmartPointer<vtkSelection> selection = vtkSmartPointer<vtkSelection>::New();
|
||||||
|
// selection->AddNode(selectionNode);
|
||||||
|
//
|
||||||
|
// vtkSmartPointer<vtkExtractSelection> extractionSelection = vtkSmartPointer<vtkExtractSelection>::New();
|
||||||
|
// extractionSelection->SetInputData(0, k->getMeshData());
|
||||||
|
// extractionSelection->SetInputData(1, selection);
|
||||||
|
// extractionSelection->Update();
|
||||||
|
// appf->AddInputData(extractionSelection->GetOutput());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// appf->Update();
|
||||||
|
// vtkDataSet* copyVtkdata=appf->GetOutput();
|
||||||
|
// // 复制数据
|
||||||
|
// if(QFileInfo(fileName).exists()){
|
||||||
|
// QFile(fileName).remove();
|
||||||
|
// }else{}
|
||||||
|
// vtkSmartPointer<vtkUnstructuredGridWriter> writer = vtkSmartPointer<vtkUnstructuredGridWriter>::New();
|
||||||
|
// writer->SetInputData(copyVtkdata);
|
||||||
|
// writer->SetFileTypeToBinary();
|
||||||
|
// writer->SetFileName(fileName.toLocal8Bit().constData());
|
||||||
|
// writer->Write();
|
||||||
|
// // 重新加载数据
|
||||||
|
// if(QFileInfo(fileName).exists()){
|
||||||
|
// QString pyCode = QString("MainWindow.importMesh(\"%1\",\"%2\",%3)")
|
||||||
|
// .arg(fileName)
|
||||||
|
// .arg("VTK(*.vtk)")
|
||||||
|
// .arg(-1);
|
||||||
|
// Py::PythonAgent::getInstance()->submit(pyCode); // 加载数据
|
||||||
|
// }else{
|
||||||
|
// QMessageBox::warning(nullptr,"Warning","Copy Mesh File Save Failed !");
|
||||||
|
// //emit _mainWindow->importMeshDataSetSig(copyVtkdata);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")<<" MeshViewProvider::clipMesh finish ";
|
||||||
|
//模型裁剪
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeshOperator::on_saveMesh() {
|
||||||
|
// 更新保存模型
|
||||||
|
int nKernal = _meshData->getKernalCount();
|
||||||
|
if (nKernal == 0)
|
||||||
|
return;
|
||||||
|
for(int i=0;i<nKernal;++i){
|
||||||
|
auto k = _meshData->getKernalAt(i); // 获取对应的kernal
|
||||||
|
auto vObjs = _meshProvider->getViewObjects(k); // 获取对应的view对象
|
||||||
|
if (!(k->isVisible())||nullptr==vObjs)
|
||||||
|
continue;
|
||||||
|
// 根据显示更新实体
|
||||||
|
k->getMeshData()->DeepCopy(vObjs->getDisplayData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace MeshData
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**
|
||||||
|
* @file MeshOperator.h
|
||||||
|
* @brief None
|
||||||
|
* @author 陈增辉 (3045316072@qq.com)
|
||||||
|
* @version 2.5.0
|
||||||
|
* @date 24-7-8
|
||||||
|
* @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LAMPCAE_MESHOPERATOR_H
|
||||||
|
#define LAMPCAE_MESHOPERATOR_H
|
||||||
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
|
#include "MainWindow/MainWindow.h"
|
||||||
|
#include "ModuleBase/ModuleType.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QMultiHash>
|
||||||
|
|
||||||
|
|
||||||
|
namespace MeshData {
|
||||||
|
class MeshData;
|
||||||
|
class MeshKernal;
|
||||||
|
class MeshSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MainWidget {
|
||||||
|
class PreWindow;
|
||||||
|
class MeshViewProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MeshData {
|
||||||
|
|
||||||
|
class MeshOperator:public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MeshOperator(GUI::MainWindow* _mainwindow= nullptr);
|
||||||
|
~MeshOperator() override;
|
||||||
|
public:
|
||||||
|
// 网格操作
|
||||||
|
void deleteMesh(QMultiHash<int, int> *items);
|
||||||
|
void copyMesh(QMultiHash<int, int> *items);
|
||||||
|
void clipMesh(QMultiHash<int, int> *items);
|
||||||
|
void on_deleteMesh();
|
||||||
|
void on_copyMesh();
|
||||||
|
void on_clipMesh();
|
||||||
|
void on_saveMesh();
|
||||||
|
|
||||||
|
void on_selectMeshChange(int);
|
||||||
|
private:
|
||||||
|
GUI::MainWindow* _mainwindow;
|
||||||
|
MeshData* _meshData;
|
||||||
|
ModuleBase::SelectModel _selectModel{ModuleBase::None};
|
||||||
|
MainWidget::PreWindow* _preWindow;
|
||||||
|
MainWidget::MeshViewProvider* _meshProvider;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace MeshData
|
||||||
|
|
||||||
|
#endif // LAMPCAE_MESHOPERATOR_H
|
||||||
|
|
@ -17,6 +17,14 @@
|
||||||
#include <vtkSphereSource.h>
|
#include <vtkSphereSource.h>
|
||||||
#include <vtkTubeFilter.h>
|
#include <vtkTubeFilter.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <vtkGeometryFilter.h>
|
||||||
|
#include <vtkPolyDataNormals.h>
|
||||||
|
#include <vtkSmoothPolyDataFilter.h>
|
||||||
|
#include <vtkDataSetSurfaceFilter.h>
|
||||||
|
#include "MainWindow/MainWindow.h"
|
||||||
|
#include "MainWindow/SubWindowManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace MeshData
|
namespace MeshData
|
||||||
{
|
{
|
||||||
|
|
@ -165,6 +173,15 @@ namespace MeshData
|
||||||
if (dataset == nullptr)
|
if (dataset == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// 网格面片三角化
|
||||||
|
emit _mainwindow->printMessage(Common::Message::Normal,u8"surface triangulation .....");
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
|
||||||
|
surfaceFilter->SetInputData(dataset);
|
||||||
|
surfaceFilter->Update();
|
||||||
|
dataset = surfaceFilter->GetOutput();
|
||||||
|
|
||||||
|
|
||||||
auto k = new MeshKernal();
|
auto k = new MeshKernal();
|
||||||
k->setName(QString("Mesh_%1").arg(k->getID()));
|
k->setName(QString("Mesh_%1").arg(k->getID()));
|
||||||
k->setMeshData(dataset);
|
k->setMeshData(dataset);
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,9 @@ namespace MeshData {
|
||||||
|
|
||||||
if (nullptr!=dataset )
|
if (nullptr!=dataset )
|
||||||
{
|
{
|
||||||
|
qDebug()<<QString("read data sucessfully! Points %1\n").arg(dataset->GetNumberOfPoints());
|
||||||
|
qDebug()<<QString("read data sucessfully! Cells %1\n").arg(dataset->GetNumberOfCells());
|
||||||
|
|
||||||
MeshKernal *k = new MeshKernal;
|
MeshKernal *k = new MeshKernal;
|
||||||
k->setName(name);
|
k->setName(name);
|
||||||
k->setPath(path);
|
k->setPath(path);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "VTKdataExchange.h"
|
#include "VTKdataExchange.h"
|
||||||
#include "MeshData/meshSingleton.h"
|
#include "MeshData/meshSingleton.h"
|
||||||
#include "MeshData/meshKernal.h"
|
#include "MeshData/meshKernal.h"
|
||||||
|
#include "Common/Types.h"
|
||||||
#include <vtkSmartPointer.h>
|
#include <vtkSmartPointer.h>
|
||||||
#include <vtkDataSetReader.h>
|
#include <vtkDataSetReader.h>
|
||||||
#include <vtkDataSet.h>
|
#include <vtkDataSet.h>
|
||||||
|
|
@ -16,6 +17,12 @@
|
||||||
#include <vtkSTLWriter.h>
|
#include <vtkSTLWriter.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <vtkGeometryFilter.h>
|
#include <vtkGeometryFilter.h>
|
||||||
|
#include <vtkPolyDataNormals.h>
|
||||||
|
#include <vtkSmoothPolyDataFilter.h>
|
||||||
|
#include <vtkDataSetSurfaceFilter.h>
|
||||||
|
#include "MainWindow/MainWindow.h"
|
||||||
|
#include "MainWindow/SubWindowManager.h"
|
||||||
|
|
||||||
|
|
||||||
namespace MeshData
|
namespace MeshData
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +58,15 @@ namespace MeshData
|
||||||
}
|
}
|
||||||
if (dataset != nullptr)
|
if (dataset != nullptr)
|
||||||
{
|
{
|
||||||
|
// 网格面片三角化
|
||||||
|
emit _mainwindow->printMessage(Common::Message::Normal,u8"surface triangulation .....");
|
||||||
|
|
||||||
|
// vtkSmartPointer<vtkDataSetSurfaceFilter> surfaceFilter = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
|
||||||
|
// surfaceFilter->SetInputData(dataset);
|
||||||
|
// surfaceFilter->Update();
|
||||||
|
// dataset = surfaceFilter->GetOutput();
|
||||||
|
|
||||||
|
|
||||||
MeshKernal *k = new MeshKernal;
|
MeshKernal *k = new MeshKernal;
|
||||||
k->setName(name);
|
k->setName(name);
|
||||||
k->setPath(path);
|
k->setPath(path);
|
||||||
|
|
@ -277,7 +293,6 @@ namespace MeshData
|
||||||
}
|
}
|
||||||
bool VTKdataExchange::writeTecplot()
|
bool VTKdataExchange::writeTecplot()
|
||||||
{
|
{
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,102 +20,124 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QFileDialog>
|
#include <vtkAxesActor.h>
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
namespace WBFZ {
|
namespace WBFZ {
|
||||||
DialogImportModelDataset::DialogImportModelDataset(GUI::MainWindow* _mainwindow, QWidget* parent)
|
DialogImportModelDataset::DialogImportModelDataset(GUI::MainWindow* _mainwindow, QWidget* parent)
|
||||||
: QDialog(_mainwindow),
|
: QDialog(_mainwindow),
|
||||||
_mainwindow(_mainwindow),
|
_mainwindow(_mainwindow),
|
||||||
ui(new Ui::DialogImportModelDataset)
|
ui(new Ui::DialogImportModelDataset)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->initLibrary();
|
||||||
|
this->initVTKView();// 初始化VTK视图
|
||||||
|
|
||||||
this->initLibrary(); //初始化comboBox和listMidget内容
|
// 初始化 comboBox 的选项
|
||||||
|
QMap<QString, QString> categories = {
|
||||||
|
{"forest", "森林"},
|
||||||
|
{"crop", "农作物"},
|
||||||
|
{"grass", "草地"},
|
||||||
|
{"uav", "人工"},
|
||||||
|
{"water", "水体"},
|
||||||
|
{"dwater", "动态水体"},
|
||||||
|
{"road", "道路"},
|
||||||
|
{"geo", "几何"},
|
||||||
|
{"radi", "辐射"},
|
||||||
|
{"soil", "土壤"},
|
||||||
|
{"land", "陆表"},
|
||||||
|
{"vegetation", "植被"},
|
||||||
|
{"water_scene", "水体场景"}
|
||||||
|
};
|
||||||
|
for (auto category : categories.values()) {
|
||||||
|
ui->FiltercomboBox->addItem(category);
|
||||||
|
}
|
||||||
|
|
||||||
this->initVTKView(); // 初始化VTK视图
|
|
||||||
|
|
||||||
// 连接 comboBox 的 setCurrentText 信号与更新 listWidget 的槽函数
|
|
||||||
connect(ui->FiltercomboBox, QOverload<const QString &>::of(&QComboBox::setCurrentText),
|
connect(ui->FiltercomboBox, QOverload<const QString &>::of(&QComboBox::setCurrentText),
|
||||||
this, &DialogImportModelDataset::updateModellistWidget);
|
this, &DialogImportModelDataset::updateModellistWidget);
|
||||||
|
|
||||||
// 连接 comboBox 的 currentIndexChanged 信号与更新 listWidget 的槽函数
|
ui->FiltercomboBox->setCurrentText("crop");
|
||||||
connect(ui->FiltercomboBox, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
|
||||||
this, &DialogImportModelDataset::updateModellistWidget);
|
|
||||||
|
|
||||||
// 连接 listWidget 的 currentItemChanged 信号与更新 VTK 的槽函数
|
// 初始显示第一个选项对应的 listWidget 内容
|
||||||
// connect(ui->ModellistWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
|
updateModellistWidget(ui->FiltercomboBox->currentText());
|
||||||
// this, SLOT(handleItemClicked(QListWidgetItem*, QListWidgetItem*)));
|
|
||||||
connect(ui->ModellistWidget, QOverload<QListWidgetItem *, QListWidgetItem *>::of(&QListWidget::currentItemChanged),
|
|
||||||
this, &DialogImportModelDataset::handleItemClicked);
|
|
||||||
|
|
||||||
// 连接 pushButton 的 clicked 信号与更新 listWidget 的槽函数
|
// 连接 comboBox 的 currentIndexChanged 信号与更新 listWidget 的槽函数
|
||||||
connect(ui->Addmodel_pushButton, SIGNAL(clicked()), this, SLOT(on_push_add_models_slot()));
|
connect(ui->FiltercomboBox, QOverload<const QString &>::of(&QComboBox::currentIndexChanged),
|
||||||
// connect(ui->Addmodel_pushButton, &QPushButton::clicked, this, &DialogImportModelDataset::on_push_add_models);
|
this, &DialogImportModelDataset::updateModellistWidget);
|
||||||
|
|
||||||
}
|
// 初始显示第一个选项对应的 listWidget 内容
|
||||||
|
updateModellistWidget(ui->FiltercomboBox->currentText());
|
||||||
|
|
||||||
DialogImportModelDataset::~DialogImportModelDataset()
|
// 初始化其它设置
|
||||||
{
|
_librarySettingPath = QString("%1\\model\\library.ini").arg(Setting::BusAPI::instance()->getApplicationExePath()); // 替换为实际的配置文件路径
|
||||||
delete ui;
|
initLibrary(); // 初始化库
|
||||||
delete _qvtkWidget; // 释放内存
|
|
||||||
}
|
connect(ui->ModellistWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
|
||||||
|
this,SLOT(handleItemClicked(QListWidgetItem*, QListWidgetItem*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogImportModelDataset::~DialogImportModelDataset()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
delete _qvtkWidget; // 释放内存
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化模型库
|
// 初始化模型库
|
||||||
void DialogImportModelDataset::initLibrary() {
|
void DialogImportModelDataset::initLibrary() {
|
||||||
|
|
||||||
//清除FiltercomboBox内容
|
if(QFileInfo(_librarySettingPath).exists()){
|
||||||
ui->FiltercomboBox->clear();
|
qDebug()<<"_librarySettingPath exists";
|
||||||
|
// 判断所有模型类型是否存在
|
||||||
// 初始化其它设置
|
|
||||||
_librarySettingPath = "D:\\WBFZCPP\\source\\LAMPCAE\\cmake-build-release\\Release\\model\\library.ini"; // 替换为实际的配置文件路径
|
|
||||||
|
|
||||||
// 读取INI文件中的Names分组
|
|
||||||
QSettings settings(_librarySettingPath, QSettings::IniFormat);
|
|
||||||
settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
|
|
||||||
|
|
||||||
settings.beginGroup("Names");
|
|
||||||
QStringList keys = settings.childKeys();
|
|
||||||
for (const QString &key : keys) {
|
|
||||||
_categories[settings.value(key).toString()] = key; // 将中文名称作为键,英文名称作为值存储
|
|
||||||
}
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
for (auto category : _categories.keys()) {
|
|
||||||
ui->FiltercomboBox->addItem(category);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置comboBox默认选项为"森林"
|
|
||||||
ui->FiltercomboBox->setCurrentText("森林"); // 使用中文名称
|
|
||||||
|
|
||||||
// 初始显示默认选项对应的 listWidget 内容
|
|
||||||
updateModellistWidget(ui->FiltercomboBox->currentText());
|
|
||||||
|
|
||||||
// 初始显示选项对应的 listWidget 内容
|
|
||||||
updateModellistWidget(ui->FiltercomboBox->currentText());
|
|
||||||
|
|
||||||
// 连接 listWidget 的 currentItemChanged 信号与更新 VTK 的槽函数
|
|
||||||
// connect(ui->ModellistWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
|
|
||||||
// this, SLOT(handleItemClicked(QListWidgetItem*, QListWidgetItem*)));
|
|
||||||
connect(ui->ModellistWidget, QOverload<QListWidgetItem *, QListWidgetItem *>::of(&QListWidget::currentItemChanged),
|
|
||||||
this, &DialogImportModelDataset::handleItemClicked);
|
|
||||||
|
|
||||||
|
|
||||||
// 连接 pushButton 的 clicked 信号与更新 listWidget 的槽函数
|
|
||||||
// connect(ui->Addmodel_pushButton, SIGNAL(clicked()), this, SLOT(on_push_add_models()));
|
|
||||||
connect(ui->Addmodel_pushButton, &QPushButton::clicked, this, &DialogImportModelDataset::on_push_add_models);
|
}else{}
|
||||||
|
|
||||||
|
QSettings settings(_librarySettingPath, QSettings::IniFormat);
|
||||||
|
|
||||||
|
QStringList categories = {"forest", "crop", "grass", "uav", "water", "dwater", "road", "geo", "radi", "soil", "land", "vegetation", "water_scene"};
|
||||||
|
QMap<QString, QStringList> models = {
|
||||||
|
{"forest", {"forest.stl"}},
|
||||||
|
{"crop", {"crop.stl"}},
|
||||||
|
{"grass", {"grass.stl"}},
|
||||||
|
{"uav", {"uav.stl"}},
|
||||||
|
{"water", {"water.stl"}},
|
||||||
|
{"dwater", {"dwater.stl"}},
|
||||||
|
{"road", {"road.stl"}},
|
||||||
|
{"geo", {"geo.stl"}},
|
||||||
|
{"radi", {"radi.stl"}},
|
||||||
|
{"soil", {"soil.stl"}},
|
||||||
|
{"land", {"land.stl"}},
|
||||||
|
{"vegetation", {"vegetation.stl"}},
|
||||||
|
{"water_scene", {"water_scene.stl"}}
|
||||||
|
};
|
||||||
|
QString exepath= Setting::BusAPI::instance()->getApplicationExePath(); // 指针调用 -> ,类::静态方法
|
||||||
|
qDebug()<<exepath;
|
||||||
|
settings.beginGroup("Models");
|
||||||
|
for (const QString &category : categories) {
|
||||||
|
settings.setValue(category, models[category]);
|
||||||
|
}
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup("Detail");
|
||||||
|
for (const QString &category : categories) {
|
||||||
|
for (const QString &model : models[category]) {
|
||||||
|
QString path = QString("%1/model/%2").arg(exepath).arg(model);
|
||||||
|
settings.setValue(model, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
// Here you can add more initialization code if needed
|
// Here you can add more initialization code if needed
|
||||||
Setting::BusAPI* busapi = Setting::BusAPI::instance(); // 指针调用 -> ,类::静态方法
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模型筛选
|
// 模型筛选
|
||||||
void DialogImportModelDataset::filterModel(QString filterStr) {
|
void DialogImportModelDataset::filterModelChinese(QString filterStr) {
|
||||||
QSettings settings(_librarySettingPath, QSettings::IniFormat);
|
QSettings settings(_librarySettingPath, QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Models");
|
settings.beginGroup("Models");
|
||||||
QString key = getEnglishCategory(filterStr);
|
QString key = getEnglishCategory(filterStr);
|
||||||
QStringList models = settings.value(key).toStringList();
|
QStringList models = settings.value(key).toStringList();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
|
@ -125,30 +147,56 @@ namespace WBFZ {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 模型筛选
|
||||||
|
void DialogImportModelDataset::filterModelEnglish(QString filterStr) {
|
||||||
|
QSettings settings(_librarySettingPath, QSettings::IniFormat);
|
||||||
|
|
||||||
|
settings.beginGroup("Models");
|
||||||
|
QString key = getEnglishCategory(filterStr);
|
||||||
|
QStringList models = settings.value(key).toStringList();
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
ui->ModellistWidget->clear();
|
||||||
|
if (!models.isEmpty()) {
|
||||||
|
ui->ModellistWidget->addItems(models);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 更新 listWidget 的槽函数
|
// 更新 listWidget 的槽函数
|
||||||
void DialogImportModelDataset::updateModellistWidget(const QString &filterStr) {
|
void DialogImportModelDataset::updateModellistWidget(const QString &filterStr) {
|
||||||
qDebug() << "void DialogImportModelDataset::handleItemClicked";
|
qDebug() << "void DialogImportModelDataset::handleItemClicked";
|
||||||
filterModel(filterStr);
|
filterModelChinese(filterStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据中文分类名称获取英文分类名称
|
// 根据中文分类名称获取英文分类名称
|
||||||
QString DialogImportModelDataset::getEnglishCategory(const QString &chineseCategory) {
|
QString DialogImportModelDataset::getEnglishCategory(const QString &chineseCategory) {
|
||||||
return _categories.value(chineseCategory, "");
|
QMap<QString, QString> categories = {
|
||||||
}
|
{"森林", "forest"},
|
||||||
|
{"农作物", "crop"},
|
||||||
|
{"草地", "grass"},
|
||||||
|
{"人工", "uav"},
|
||||||
|
{"水体", "water"},
|
||||||
|
{"动态水体", "dwater"},
|
||||||
|
{"道路", "road"},
|
||||||
|
{"几何", "geo"},
|
||||||
|
{"辐射", "radi"},
|
||||||
|
{"土壤", "soil"},
|
||||||
|
{"陆表", "land"},
|
||||||
|
{"植被", "vegetation"},
|
||||||
|
{"水体场景", "water_scene"}
|
||||||
|
};
|
||||||
|
return categories.value(chineseCategory, "");
|
||||||
|
}
|
||||||
void DialogImportModelDataset::handleItemClicked(QListWidgetItem *current, QListWidgetItem *previous)
|
void DialogImportModelDataset::handleItemClicked(QListWidgetItem *current, QListWidgetItem *previous)
|
||||||
{
|
{
|
||||||
|
qDebug() << "void DialogImportModelDataset::handleItemClicked "<<current->text();
|
||||||
qDebug() << "void DialogImportModelDataset::handleItemClicked(QListWidgetItem *current, QListWidgetItem *previous)";
|
|
||||||
|
|
||||||
if (!current) return; // 确保当前项非空
|
if (!current) return; // 确保当前项非空
|
||||||
|
|
||||||
// 读取 item 文本或其他相关信息
|
// 读取 item 文本或其他相关信息
|
||||||
QString itemName = current->text();
|
QString itemName = current->text();
|
||||||
qDebug() << "Current item selected: " << itemName;
|
qDebug() << "Current item selected: " << itemName;
|
||||||
|
QString iniFilePath = QString("%1\\model\\library.ini").arg(Setting::BusAPI::instance()->getApplicationExePath());
|
||||||
// 定义 INI 文件的路径
|
|
||||||
QString iniFilePath = "D:\\WBFZCPP\\source\\LAMPCAE\\cmake-build-release\\Release\\model\\library.ini";
|
|
||||||
|
|
||||||
// 检查文件是否存在
|
// 检查文件是否存在
|
||||||
if (!QFileInfo::exists(iniFilePath)) {
|
if (!QFileInfo::exists(iniFilePath)) {
|
||||||
|
|
@ -162,17 +210,12 @@ namespace WBFZ {
|
||||||
|
|
||||||
// 获取与当前 item 名称匹配的路径
|
// 获取与当前 item 名称匹配的路径
|
||||||
QString modelPath = settings.value(itemName).toString();
|
QString modelPath = settings.value(itemName).toString();
|
||||||
|
|
||||||
if (modelPath.isEmpty()) {
|
if (modelPath.isEmpty()) {
|
||||||
qDebug() << "No model path found for item: " << itemName;
|
qDebug() << "No model path found for item: " << itemName;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Model path: " << modelPath;
|
qDebug() << "Model path: " << modelPath;
|
||||||
|
|
||||||
// 根据获取的路径导入预览模型
|
|
||||||
this->importPreViewModel(modelPath);
|
this->importPreViewModel(modelPath);
|
||||||
this->importMeshModelToMainWindows(modelPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -188,9 +231,10 @@ namespace WBFZ {
|
||||||
}
|
}
|
||||||
// 初始化三维模型
|
// 初始化三维模型
|
||||||
void DialogImportModelDataset::importPreViewModel(QString stdPath) {
|
void DialogImportModelDataset::importPreViewModel(QString stdPath) {
|
||||||
|
qDebug()<<"void DialogImportModelDataset::importPreViewModel(QString stdPath) start";
|
||||||
//清楚所有模型
|
//清楚所有模型
|
||||||
_render->RemoveAllViewProps();
|
// _render->RemoveAllViewProps();
|
||||||
// 在你的主窗口或者其他适当的位置初始化 VTK 相关变量
|
|
||||||
vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
|
vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
|
||||||
reader->SetFileName(stdPath.toLocal8Bit().data()); // 设置 STL 模型文件路径
|
reader->SetFileName(stdPath.toLocal8Bit().data()); // 设置 STL 模型文件路径
|
||||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
|
|
@ -198,17 +242,19 @@ namespace WBFZ {
|
||||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
actor->SetMapper(mapper);
|
actor->SetMapper(mapper);
|
||||||
_render->AddActor(actor);
|
_render->AddActor(actor);
|
||||||
// 更新渲染窗口
|
// 调整相机以确保整个场景可见
|
||||||
_renderWindow->Render();
|
_render->ResetCamera();
|
||||||
|
_renderWindow->AddRenderer(_render);
|
||||||
|
_renderWindow->Render();
|
||||||
_qvtkWidget->update();
|
_qvtkWidget->update();
|
||||||
|
qDebug()<<"void DialogImportModelDataset::importPreViewModel(QString stdPath) finish!!!";
|
||||||
}
|
}
|
||||||
void DialogImportModelDataset::initVTKView() {
|
void DialogImportModelDataset::initVTKView() {
|
||||||
// 添加控件
|
// 添加控件
|
||||||
_qvtkWidget = new QVTKOpenGLNativeWidget(this);
|
_qvtkWidget = new QVTKOpenGLNativeWidget(this);
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout(ui->modelViewContent);
|
QVBoxLayout *mainLayout = new QVBoxLayout(ui->modelViewContent);
|
||||||
mainLayout->addWidget(_qvtkWidget);
|
mainLayout->addWidget(_qvtkWidget);
|
||||||
|
|
||||||
// 初始化渲染器
|
// 初始化渲染器
|
||||||
_renderWindow = _qvtkWidget->renderWindow();
|
_renderWindow = _qvtkWidget->renderWindow();
|
||||||
_render = vtkSmartPointer<vtkOpenGLRenderer>::New();
|
_render = vtkSmartPointer<vtkOpenGLRenderer>::New();
|
||||||
|
|
@ -220,177 +266,69 @@ namespace WBFZ {
|
||||||
_render->SetBackground2(topcolor.redF(), topcolor.greenF(), topcolor.blueF());
|
_render->SetBackground2(topcolor.redF(), topcolor.greenF(), topcolor.blueF());
|
||||||
_render->SetBackground(bottomcolor.redF(), bottomcolor.greenF(), bottomcolor.blueF());
|
_render->SetBackground(bottomcolor.redF(), bottomcolor.greenF(), bottomcolor.blueF());
|
||||||
|
|
||||||
|
|
||||||
|
// 创建一个坐标系
|
||||||
|
vtkSmartPointer<vtkAxesActor> axes = vtkSmartPointer<vtkAxesActor>::New();
|
||||||
|
|
||||||
|
// 将坐标系添加到渲染器中
|
||||||
|
vtkSmartPointer<vtkOrientationMarkerWidget> widget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
|
||||||
|
widget->SetOrientationMarker(axes);
|
||||||
|
widget->SetInteractor(_renderWindow->GetInteractor());
|
||||||
|
widget->SetViewport(0.0, 0.0, 0.2, 0.2); // 设置坐标系小部件的位置和大小
|
||||||
|
widget->EnabledOn();
|
||||||
|
|
||||||
|
|
||||||
// 开启硬件加速特性
|
// 开启硬件加速特性
|
||||||
_render->UseDepthPeelingOn();
|
_render->UseDepthPeelingOn();
|
||||||
_render->SetUseFXAA(true);
|
_render->SetUseFXAA(true);
|
||||||
_interactor = _renderWindow->GetInteractor();
|
_interactor = _renderWindow->GetInteractor();
|
||||||
_renderWindow->AddRenderer(_render);
|
_renderWindow->AddRenderer(_render);
|
||||||
}
|
|
||||||
|
|
||||||
void DialogImportModelDataset::on_push_add_models_slot() {
|
|
||||||
|
|
||||||
//模型文件选择框
|
|
||||||
QString filePath = QFileDialog::getOpenFileName(this, tr("请选择要上传的模型文件"), "", tr("ALL Files (*)"));
|
|
||||||
if (filePath.isEmpty()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//中文类名输入框
|
|
||||||
QString chineseClass = QInputDialog::getText(this, tr("提示"), tr("请输入模型的中文类名:"));
|
|
||||||
if(chineseClass.isEmpty()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//英文类名输入框
|
|
||||||
QString englishClass = QInputDialog::getText(this, tr("提示"), tr("请输入模型的英文类名:"));
|
|
||||||
if(englishClass.isEmpty()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//读入ini文件并获取需要上传的模型文件名称
|
|
||||||
QString iniFilePath = "D:\\WBFZCPP\\source\\LAMPCAE\\cmake-build-release\\Release\\model\\Library.ini";
|
|
||||||
QSettings iniFile(iniFilePath, QSettings::IniFormat);
|
|
||||||
iniFile.setIniCodec(QTextCodec::codecForName("UTF-8"));
|
|
||||||
|
|
||||||
QString fileName = QFileInfo(filePath).fileName();
|
|
||||||
QString baseName = QFileInfo(filePath).baseName();
|
|
||||||
|
|
||||||
//获取Names分组键名和值
|
|
||||||
iniFile.beginGroup("Names");
|
|
||||||
QStringList namesKeys = iniFile.childKeys();
|
|
||||||
QStringList namesValues;
|
|
||||||
QString matchedKey = ""; //中文类反查英文类
|
|
||||||
|
|
||||||
for (const QString &nameKey : namesKeys){
|
|
||||||
QString value = iniFile.value(nameKey).toString();
|
|
||||||
namesValues.append(value);
|
|
||||||
if (value == chineseClass) {
|
|
||||||
matchedKey = nameKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
//根据englishClass和chineseClass判断模型所属的类别是否存在,不需要新建Names分组
|
|
||||||
if((namesKeys.contains(englishClass)) || (namesValues.contains(chineseClass))) {
|
|
||||||
// 复制文件
|
|
||||||
QDir dir(QString("%1\\model").arg(Setting::BusAPI::instance()->getApplicationExePath()));
|
|
||||||
if(!dir.exists()) {
|
|
||||||
dir.mkpath(".");
|
|
||||||
}
|
|
||||||
QString newFilePath = dir.filePath(fileName);
|
|
||||||
QFile::copy(filePath, newFilePath);
|
|
||||||
|
|
||||||
// 若matchedKey没有匹配上(即中文类有,但是英文没有)
|
|
||||||
if(matchedKey.isEmpty()) {
|
|
||||||
matchedKey = englishClass;
|
|
||||||
}
|
|
||||||
// 根据Models分组的值判断模型名称是否已经存在
|
|
||||||
iniFile.beginGroup("Models");
|
|
||||||
QString modelFileName = iniFile.value(matchedKey, "").toString();
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
if (modelFileName.contains(fileName)) {
|
|
||||||
qDebug() << "Models/" + matchedKey;
|
|
||||||
QMessageBox::warning(this, tr(u8"错误"), tr(u8"模型名称已经存在"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建新的Models分组值
|
|
||||||
iniFile.beginGroup("Models");
|
|
||||||
QString currentValue = iniFile.value(matchedKey, "").toString();
|
|
||||||
QString newValue;
|
|
||||||
if(!currentValue.isEmpty()) {
|
|
||||||
newValue = currentValue + "," + fileName;
|
|
||||||
} else {
|
|
||||||
newValue = fileName;
|
|
||||||
}
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
// 手动更新ini文件,避免引号
|
|
||||||
QFile file(iniFilePath);
|
|
||||||
if(file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
|
||||||
QTextStream in(&file);
|
|
||||||
in.setCodec("UTF-8"); // 确保读取时使用UTF-8编码
|
|
||||||
QString content = in.readAll();
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
// 查找Models分组的位置
|
|
||||||
int modelsStartPos = content.indexOf("[Models]");
|
|
||||||
int modelsEndPos = content.indexOf("[", modelsStartPos + 1);
|
|
||||||
if(modelsEndPos == -1)
|
|
||||||
modelsEndPos = content.length();
|
|
||||||
|
|
||||||
QString modelsSection = content.mid(modelsStartPos, modelsEndPos - modelsStartPos);
|
|
||||||
QString modelsKey = matchedKey + "=";
|
|
||||||
int pos = modelsSection.indexOf(modelsKey);
|
|
||||||
|
|
||||||
if(pos != -1) {
|
|
||||||
// 找到现有键,更新其值
|
|
||||||
int endPos = modelsSection.indexOf('\n', pos);
|
|
||||||
if(endPos == -1)
|
|
||||||
endPos = modelsSection.length();
|
|
||||||
QString currentLine = modelsSection.mid(pos, endPos - pos);
|
|
||||||
if(!currentLine.contains(fileName)) {
|
|
||||||
currentLine += "," + fileName;
|
|
||||||
modelsSection.replace(pos, endPos - pos, currentLine);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 添加新的键值对
|
|
||||||
modelsSection += "\n" + modelsKey + newValue + "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重建ini文件内容,确保只替换Models分组
|
|
||||||
content.replace(modelsStartPos, modelsEndPos - modelsStartPos, modelsSection);
|
|
||||||
|
|
||||||
if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
|
||||||
QTextStream out(&file);
|
|
||||||
out.setCodec("UTF-8"); // 确保写入时使用UTF-8编码
|
|
||||||
out << content;
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//更新Deatail分组的内容
|
|
||||||
iniFile.beginGroup("Detail");
|
|
||||||
iniFile.setValue(fileName, newFilePath);
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
QMessageBox::information(this, tr("提示"), tr("模型文件加载成功"));
|
|
||||||
|
|
||||||
// 更新comboBOX选项 与 listWidget内容
|
|
||||||
this->initLibrary();
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断模型所属的类别不存在,需要新建Names分组
|
|
||||||
else{
|
|
||||||
QDir dir("D:\\WBFZCPP\\source\\LAMPCAE\\cmake-build-release\\Release\\model"); // 改成相对路径
|
|
||||||
if (!dir.exists()) {
|
|
||||||
dir.mkpath(".");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString newFilePath = dir.filePath(fileName);
|
|
||||||
QFile::copy(filePath, newFilePath); //复制文件
|
|
||||||
|
|
||||||
// 确保写入INI文件时正确处理UTF-8编码
|
|
||||||
iniFile.beginGroup("Names");
|
|
||||||
iniFile.setValue(englishClass, chineseClass);
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
iniFile.beginGroup("Models");
|
|
||||||
iniFile.setValue(englishClass, fileName);
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
iniFile.beginGroup("Detail");
|
|
||||||
iniFile.setValue(fileName, newFilePath);
|
|
||||||
iniFile.endGroup();
|
|
||||||
|
|
||||||
QMessageBox::information(this, tr("提示"), tr("模型文件加载成功"));
|
|
||||||
|
|
||||||
//更新comboBOX选项 与 listWidget内容
|
|
||||||
this->initLibrary();
|
|
||||||
qDebug()<<"on_click_over";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void DialogImportModelDataset::accept()
|
||||||
|
{
|
||||||
|
QListWidgetItem *current=ui->ModellistWidget->currentItem();
|
||||||
|
if (!current) {return;} // 确保当前项非空
|
||||||
|
// 读取 item 文本或其他相关信息
|
||||||
|
QString itemName = current->text();
|
||||||
|
qDebug() << "Current item selected: " << itemName;
|
||||||
|
QString iniFilePath = QString("%1\\model\\library.ini").arg(Setting::BusAPI::instance()->getApplicationExePath());
|
||||||
|
|
||||||
|
// 检查文件是否存在
|
||||||
|
if (!QFileInfo::exists(iniFilePath)) {
|
||||||
|
qDebug() << "INI file not found: " << iniFilePath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用 QSettings 读取 INI 文件
|
||||||
|
QSettings settings(iniFilePath, QSettings::IniFormat);
|
||||||
|
settings.beginGroup("Detail");
|
||||||
|
|
||||||
|
// 获取与当前 item 名称匹配的路径
|
||||||
|
QString modelPath = settings.value(itemName).toString();
|
||||||
|
if (modelPath.isEmpty()) {
|
||||||
|
qDebug() << "No model path found for item: " << itemName;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Model path: " << modelPath;
|
||||||
|
this->importPreViewModel(modelPath);
|
||||||
|
}
|
||||||
|
settings.endGroup();
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
// 窗体点击按钮的类别
|
||||||
|
void DialogImportModelDataset::setCurrentCatorgy(QString cato) {
|
||||||
|
qDebug()<<"DialogImportModelDataset::setCurrentCatorgy(QString cato) "<< cato;
|
||||||
|
// ui->FiltercomboBox->setCurrentText(cato);
|
||||||
|
|
||||||
|
connect(ui->FiltercomboBox, QOverload<const QString &>::of(&QComboBox::setCurrentText),
|
||||||
|
this, &DialogImportModelDataset::updateModellistWidget);
|
||||||
|
|
||||||
|
ui->FiltercomboBox->setCurrentText(cato);
|
||||||
|
|
||||||
|
// 初始显示第一个选项对应的 listWidget 内容
|
||||||
|
updateModellistWidget(ui->FiltercomboBox->currentText());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace WBFZ
|
} // namespace WBFZ
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,13 @@ namespace WBFZ {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initLibrary();
|
void initLibrary();
|
||||||
void filterModel(QString filterStr);// 根据条件筛选
|
void filterModelChinese(QString filterStr);// 根据条件筛选
|
||||||
|
void filterModelEnglish(QString filterStr);// 根据条件筛选
|
||||||
|
void setCurrentCatorgy(QString cato);
|
||||||
QString getEnglishCategory(const QString &chineseCategory); // 新增中英文转换函数声明
|
QString getEnglishCategory(const QString &chineseCategory); // 新增中英文转换函数声明
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// virtual void accept();
|
virtual void accept();
|
||||||
void updateModellistWidget(const QString &filterStr); // 声明 updateModellistWidget 函数
|
void updateModellistWidget(const QString &filterStr); // 声明 updateModellistWidget 函数
|
||||||
void handleItemClicked(QListWidgetItem *current, QListWidgetItem *previous);
|
void handleItemClicked(QListWidgetItem *current, QListWidgetItem *previous);
|
||||||
void on_push_add_models_slot();
|
void on_push_add_models_slot();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "Common/DebugLogger.h"
|
#include "Common/DebugLogger.h"
|
||||||
#include "AsciiOpenDialog.h"
|
#include "AsciiOpenDialog.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include "MeshOperator.h"
|
||||||
|
|
||||||
GUI::MainWindow* MeshData::MeshDataExchangePlugin::_mainwindow = nullptr;
|
GUI::MainWindow* MeshData::MeshDataExchangePlugin::_mainwindow = nullptr;
|
||||||
namespace MeshData {
|
namespace MeshData {
|
||||||
|
|
@ -29,13 +30,26 @@ namespace MeshData {
|
||||||
_describe = "MeshDataExchangePlugin Installed Successfully";
|
_describe = "MeshDataExchangePlugin Installed Successfully";
|
||||||
_mainwindow = m;
|
_mainwindow = m;
|
||||||
|
|
||||||
connect(_mainwindow, SIGNAL(on_actionvtkPointSamplorTriggleSIGNAL(GUI::MainWindow*)),this,SLOT(vtkPointSamplerDialog(GUI::MainWindow*)));
|
connect(_mainwindow, SIGNAL(on_actionvtkPointSamplorTriggleSIGNAL(GUI::MainWindow*)), this,
|
||||||
connect(_mainwindow, SIGNAL(on_loadPreMeshFile(GUI::MainWindow*,QString)),this,SLOT(on_LoadPreMeshFileDialog(GUI::MainWindow*,QString)));
|
SLOT(vtkPointSamplerDialog(GUI::MainWindow*)));
|
||||||
|
connect(_mainwindow, SIGNAL(on_loadPreMeshFile(GUI::MainWindow*, QString)), this,
|
||||||
|
SLOT(on_LoadPreMeshFileDialog(GUI::MainWindow*, QString)));
|
||||||
|
|
||||||
_toolboxMenu=new QMenu("ImportTestBar");
|
_toolboxMenu = new QMenu("ImportTestBar");
|
||||||
QAction* action_ModelFilterImport=_toolboxMenu->addAction("ModelFilterImport");
|
QAction* action_ModelFilterImport = _toolboxMenu->addAction("ModelFilterImport");
|
||||||
connect(action_ModelFilterImport, SIGNAL(triggered()),this, SLOT(on_TestLoadModelImport()));
|
connect(action_ModelFilterImport, SIGNAL(triggered()), this,
|
||||||
|
SLOT(on_TestLoadModelImport()));
|
||||||
m->menuBar()->addMenu(_toolboxMenu);
|
m->menuBar()->addMenu(_toolboxMenu);
|
||||||
|
|
||||||
|
connect(_mainwindow, SIGNAL(on_deleteMeshSIGNAL(GUI::MainWindow*)), this,
|
||||||
|
SLOT(on_deleteMesh(GUI::MainWindow*)));
|
||||||
|
connect(_mainwindow, SIGNAL(on_copyMeshSIGNAL(GUI::MainWindow*)), this,
|
||||||
|
SLOT(on_copyMesh(GUI::MainWindow*)));
|
||||||
|
connect(_mainwindow, SIGNAL(on_clipMeshSIGNAL(GUI::MainWindow*)), this,
|
||||||
|
SLOT(on_clipMesh(GUI::MainWindow*)));
|
||||||
|
connect(_mainwindow, SIGNAL(on_saveMeshSIGNAL(GUI::MainWindow*)), this,
|
||||||
|
SLOT(on_saveMesh(GUI::MainWindow*)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MeshDataExchangePlugin::install()
|
bool MeshDataExchangePlugin::install()
|
||||||
|
|
@ -54,8 +68,8 @@ namespace MeshData {
|
||||||
IO::IOConfigure::RegisterMeshImporter("PDB(*.pdb)", PDBimportMesh);
|
IO::IOConfigure::RegisterMeshImporter("PDB(*.pdb)", PDBimportMesh);
|
||||||
IO::IOConfigure::RegisterMeshImporter("Patran(*.bdf)", BDFimportMesh);
|
IO::IOConfigure::RegisterMeshImporter("Patran(*.bdf)", BDFimportMesh);
|
||||||
IO::IOConfigure::RegisterPclImporter("VegetationPointCloud(*.xyz)", XYZimportPCL); // 点云
|
IO::IOConfigure::RegisterPclImporter("VegetationPointCloud(*.xyz)", XYZimportPCL); // 点云
|
||||||
IO::IOConfigure::RegisterPclImporter("Point Cloud Data(*.pcd)",PCDimportPCL);
|
IO::IOConfigure::RegisterPclImporter("Point Cloud Data(*.pcd)", PCDimportPCL);
|
||||||
IO::IOConfigure::RegisterPclImporter("Polygon File Format(*.ply)",PLYimportPCL);
|
IO::IOConfigure::RegisterPclImporter("Polygon File Format(*.ply)", PLYimportPCL);
|
||||||
|
|
||||||
IO::IOConfigure::RegisterMeshExporter("CGNS(*.cgns)", CGNSexportMesh);
|
IO::IOConfigure::RegisterMeshExporter("CGNS(*.cgns)", CGNSexportMesh);
|
||||||
IO::IOConfigure::RegisterMeshExporter("Fluent(*.msh)", MSHexportMesh);
|
IO::IOConfigure::RegisterMeshExporter("Fluent(*.msh)", MSHexportMesh);
|
||||||
|
|
@ -69,8 +83,8 @@ namespace MeshData {
|
||||||
IO::IOConfigure::RegisterMeshExporter("SU2(*.su2)", SU2exportMesh);
|
IO::IOConfigure::RegisterMeshExporter("SU2(*.su2)", SU2exportMesh);
|
||||||
IO::IOConfigure::RegisterMeshExporter("LS-DYNA(*.key)", KEYexportMesh);
|
IO::IOConfigure::RegisterMeshExporter("LS-DYNA(*.key)", KEYexportMesh);
|
||||||
IO::IOConfigure::RegisterMeshExporter("PDB(*.pdb)", PDBexportMesh);
|
IO::IOConfigure::RegisterMeshExporter("PDB(*.pdb)", PDBexportMesh);
|
||||||
IO::IOConfigure::RegisterPclExporter("Point Cloud Data(*.pcd)",PCDexportPCL);
|
IO::IOConfigure::RegisterPclExporter("Point Cloud Data(*.pcd)", PCDexportPCL);
|
||||||
IO::IOConfigure::RegisterPclExporter("vtk polygon Data(*.ply)",PLYexportPCL);
|
IO::IOConfigure::RegisterPclExporter("vtk polygon Data(*.ply)", PLYexportPCL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -115,33 +129,52 @@ namespace MeshData {
|
||||||
{
|
{
|
||||||
return _mainwindow;
|
return _mainwindow;
|
||||||
}
|
}
|
||||||
void MeshDataExchangePlugin::vtkPointSamplerDialog(GUI::MainWindow* m) {
|
void MeshDataExchangePlugin::vtkPointSamplerDialog(GUI::MainWindow* m)
|
||||||
|
{
|
||||||
DebugInfo("MeshSurfaceSamplingPlugin::vtkPointSamplerDialog has init\n");
|
DebugInfo("MeshSurfaceSamplingPlugin::vtkPointSamplerDialog has init\n");
|
||||||
MeshSurfaceSampling::DialogMeshSurfaceVtkPointSampling* w = new MeshSurfaceSampling::DialogMeshSurfaceVtkPointSampling(m);
|
MeshSurfaceSampling::DialogMeshSurfaceVtkPointSampling* w =
|
||||||
|
new MeshSurfaceSampling::DialogMeshSurfaceVtkPointSampling(m);
|
||||||
w->show();
|
w->show();
|
||||||
}
|
}
|
||||||
// 用户点击按钮,触达这个函数执行
|
// 用户点击按钮,触达这个函数执行
|
||||||
void MeshDataExchangePlugin::on_TestLoadModelImport()
|
void MeshDataExchangePlugin::on_TestLoadModelImport()
|
||||||
{
|
{
|
||||||
WBFZ::DialogImportModelDataset* dialog=new WBFZ::DialogImportModelDataset(_mainwindow);
|
WBFZ::DialogImportModelDataset* dialog = new WBFZ::DialogImportModelDataset(_mainwindow);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
}
|
}
|
||||||
void MeshDataExchangePlugin::on_LoadPreMeshFileDialog(GUI::MainWindow* _m, QString _fileType) {
|
void MeshDataExchangePlugin::on_LoadPreMeshFileDialog(GUI::MainWindow* _m, QString _fileType)
|
||||||
|
{
|
||||||
// emit this->on_loadPreMeshFile(this, "radi");
|
// emit this->on_loadPreMeshFile(this, "radi");
|
||||||
WBFZ::DialogImportModelDataset* dialog=new WBFZ::DialogImportModelDataset(_mainwindow);
|
WBFZ::DialogImportModelDataset* dialog = new WBFZ::DialogImportModelDataset(_mainwindow);
|
||||||
dialog->setCurrentCatorgy(_fileType);
|
dialog->setCurrentCatorgy(_fileType);
|
||||||
dialog->exec();
|
dialog->exec();
|
||||||
}
|
}
|
||||||
|
void MeshDataExchangePlugin::on_deleteMesh(GUI::MainWindow* m)
|
||||||
|
{
|
||||||
|
MeshOperator* _meshOperator = new MeshOperator(m);
|
||||||
|
_meshOperator->on_deleteMesh();
|
||||||
|
}
|
||||||
|
void MeshDataExchangePlugin::on_copyMesh(GUI::MainWindow* m)
|
||||||
|
{
|
||||||
|
MeshOperator* _meshOperator = new MeshOperator(m);
|
||||||
|
_meshOperator->on_copyMesh();
|
||||||
|
}
|
||||||
|
void MeshDataExchangePlugin::on_clipMesh(GUI::MainWindow* m)
|
||||||
|
{
|
||||||
|
MeshOperator* _meshOperator = new MeshOperator(m);
|
||||||
|
_meshOperator->on_clipMesh();
|
||||||
|
}
|
||||||
|
void MeshDataExchangePlugin::on_saveMesh(GUI::MainWindow* m) {
|
||||||
|
MeshOperator* _meshOperator = new MeshOperator(m);
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
} // namespace MeshData
|
||||||
|
|
||||||
|
|
||||||
void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* ps)
|
void Register(GUI::MainWindow* m, QList<Plugins::PluginBase*>* ps)
|
||||||
{
|
{
|
||||||
Plugins::PluginBase* p_meshdataExchangeplugin = new MeshData::MeshDataExchangePlugin(m);
|
Plugins::PluginBase* p_meshdataExchangeplugin = new MeshData::MeshDataExchangePlugin(m);
|
||||||
ps->append(p_meshdataExchangeplugin);
|
ps->append(p_meshdataExchangeplugin);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGNSimportMesh(QString AbFileName, int modelId)
|
bool CGNSimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
@ -155,6 +188,9 @@ bool CGNSimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool CGNSexportMesh(QString AbFileName, int modelId)
|
bool CGNSexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto CGNSwriter = new MeshData::CGNSdataExchange(
|
auto CGNSwriter = new MeshData::CGNSdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CGNSwriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CGNSwriter);
|
||||||
|
|
@ -164,6 +200,8 @@ bool CGNSexportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool MSHimportMesh(QString AbFileName, int modelId)
|
bool MSHimportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
auto MSHreader = new MeshData::MSHdataExchange(AbFileName, MeshData::MESH_READ,
|
auto MSHreader = new MeshData::MSHdataExchange(AbFileName, MeshData::MESH_READ,
|
||||||
MeshData::MeshDataExchangePlugin::getMWpt());
|
MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(MSHreader);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(MSHreader);
|
||||||
|
|
@ -173,6 +211,10 @@ bool MSHimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool MSHexportMesh(QString AbFileName, int modelId)
|
bool MSHexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto MSHwriter = new MeshData::MSHdataExchange(
|
auto MSHwriter = new MeshData::MSHdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(MSHwriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(MSHwriter);
|
||||||
|
|
@ -191,6 +233,9 @@ bool NEUimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool NEUexportMesh(QString AbFileName, int modelId)
|
bool NEUexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto NEUwriter = new MeshData::NEUdataExchange(
|
auto NEUwriter = new MeshData::NEUdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(NEUwriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(NEUwriter);
|
||||||
|
|
@ -209,6 +254,9 @@ bool VTK_DAT_STL_importMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool VTK_DAT_STL_exportMesh(QString AbFileName, int modelId)
|
bool VTK_DAT_STL_exportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto VTK_DAT_STL_writer = new MeshData::VTKdataExchange(
|
auto VTK_DAT_STL_writer = new MeshData::VTKdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(VTK_DAT_STL_writer);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(VTK_DAT_STL_writer);
|
||||||
|
|
@ -227,6 +275,9 @@ bool INPimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool INPexportMesh(QString AbFileName, int modelId)
|
bool INPexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto INPwriter = new MeshData::INPdataExchange(
|
auto INPwriter = new MeshData::INPdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(INPwriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(INPwriter);
|
||||||
|
|
@ -245,6 +296,9 @@ bool CNTMimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool CNTMexportMesh(QString AbFileName, int modelId)
|
bool CNTMexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto CNTMwriter = new MeshData::CNTMdataExchange(
|
auto CNTMwriter = new MeshData::CNTMdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CNTMwriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(CNTMwriter);
|
||||||
|
|
@ -273,6 +327,9 @@ bool SU2importMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool SU2exportMesh(QString AbFileName, int modelId)
|
bool SU2exportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto SU2writer = new MeshData::CNTMdataExchange(
|
auto SU2writer = new MeshData::CNTMdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2writer);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2writer);
|
||||||
|
|
@ -292,6 +349,9 @@ bool AnotherSU2importMesh(QString AbFileName)
|
||||||
|
|
||||||
bool AnotherSU2exportMesh(QString AbFileName, int modelId)
|
bool AnotherSU2exportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto SU2writer = new MeshData::CNTMdataExchange(
|
auto SU2writer = new MeshData::CNTMdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2writer);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(SU2writer);
|
||||||
|
|
@ -312,6 +372,9 @@ bool KEYimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool KEYexportMesh(QString AbFileName, int modelId)
|
bool KEYexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto KEYwirter = new MeshData::KEYdataExchange(
|
auto KEYwirter = new MeshData::KEYdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(KEYwirter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(KEYwirter);
|
||||||
|
|
@ -342,6 +405,9 @@ bool MESHDATAEXCHANGEPLUGINAPI BDFimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI PDBexportMesh(QString AbFileName, int modelId)
|
bool MESHDATAEXCHANGEPLUGINAPI PDBexportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto PDBWriter = new MeshData::PDBdataExchange(
|
auto PDBWriter = new MeshData::PDBdataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(PDBWriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(PDBWriter);
|
||||||
|
|
@ -352,8 +418,8 @@ bool MESHDATAEXCHANGEPLUGINAPI PDBexportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI FOAMimportMesh(QString AbFileName, int modelId)
|
bool MESHDATAEXCHANGEPLUGINAPI FOAMimportMesh(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
auto foamReader = new MeshData::FoamDataExchange(AbFileName, MeshData::MESH_READ,
|
auto foamReader = new MeshData::FoamDataExchange(AbFileName, MeshData::MESH_READ,
|
||||||
MeshData::MeshDataExchangePlugin::getMWpt());
|
MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(foamReader);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(foamReader);
|
||||||
emit tc->threadStart(); // emit MSHreader->start();
|
emit tc->threadStart(); // emit MSHreader->start();
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -361,6 +427,9 @@ bool MESHDATAEXCHANGEPLUGINAPI FOAMimportMesh(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI FOAMexportMesh(QString AbFileName, int id)
|
bool MESHDATAEXCHANGEPLUGINAPI FOAMexportMesh(QString AbFileName, int id)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto FoamWriter = new MeshData::FoamDataExchange(
|
auto FoamWriter = new MeshData::FoamDataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), id);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), id);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(FoamWriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(FoamWriter);
|
||||||
|
|
@ -371,10 +440,10 @@ bool MESHDATAEXCHANGEPLUGINAPI FOAMexportMesh(QString AbFileName, int id)
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI XYZimportPCL(QString AbFileName, int id)
|
bool MESHDATAEXCHANGEPLUGINAPI XYZimportPCL(QString AbFileName, int id)
|
||||||
{
|
{
|
||||||
MeshData::loadXYZImportPCL(AbFileName, MeshData::MeshDataExchangePlugin::getMWpt());
|
MeshData::loadXYZImportPCL(AbFileName, MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
// auto xyzReader = new MeshData::PointClouddataExchange(
|
// auto xyzReader = new MeshData::PointClouddataExchange(
|
||||||
// AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt(), id);
|
// AbFileName, MeshData::MESH_READ, MeshData::MeshDataExchangePlugin::getMWpt(), id);
|
||||||
// ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(xyzReader);
|
// ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(xyzReader);
|
||||||
// emit tc->threadStart(); // emit MSHwriter->start();
|
// emit tc->threadStart(); // emit MSHwriter->start();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -396,15 +465,17 @@ bool MESHDATAEXCHANGEPLUGINAPI PLYimportPCL(QString AbFileName, int id)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bool MESHDATAEXCHANGEPLUGINAPI XYZexportPCL(QString AbFileName, int modelId)
|
||||||
//bool MESHDATAEXCHANGEPLUGINAPI XYZexportPCL(QString AbFileName, int modelId)
|
|
||||||
//{
|
//{
|
||||||
//
|
//
|
||||||
// return false;
|
// return false;
|
||||||
//}
|
// }
|
||||||
|
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI PCDexportPCL(QString AbFileName, int modelId)
|
bool MESHDATAEXCHANGEPLUGINAPI PCDexportPCL(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto pcdWriter = new MeshData::PointClouddataExchange(
|
auto pcdWriter = new MeshData::PointClouddataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdWriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdWriter);
|
||||||
|
|
@ -414,6 +485,9 @@ bool MESHDATAEXCHANGEPLUGINAPI PCDexportPCL(QString AbFileName, int modelId)
|
||||||
|
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI PLYexportPCL(QString AbFileName, int modelId)
|
bool MESHDATAEXCHANGEPLUGINAPI PLYexportPCL(QString AbFileName, int modelId)
|
||||||
{
|
{
|
||||||
|
MeshData::MeshOperator* _meshOperator = new MeshData::MeshOperator(MeshData::MeshDataExchangePlugin::getMWpt());
|
||||||
|
_meshOperator->on_saveMesh();
|
||||||
|
|
||||||
auto pcdWriter = new MeshData::PointClouddataExchange(
|
auto pcdWriter = new MeshData::PointClouddataExchange(
|
||||||
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
AbFileName, MeshData::MESH_WRITE, MeshData::MeshDataExchangePlugin::getMWpt(), modelId);
|
||||||
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdWriter);
|
ModuleBase::ThreadControl* tc = new ModuleBase::ThreadControl(pcdWriter);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace MeshData {
|
namespace MeshData {
|
||||||
|
class MeshOperator;
|
||||||
|
|
||||||
enum MeshOperation { MESH_NONE, MESH_READ, MESH_WRITE };
|
enum MeshOperation { MESH_NONE, MESH_READ, MESH_WRITE };
|
||||||
|
|
||||||
class MESHDATAEXCHANGEPLUGINAPI MeshDataExchangePlugin : public Plugins::PluginBase {
|
class MESHDATAEXCHANGEPLUGINAPI MeshDataExchangePlugin : public Plugins::PluginBase {
|
||||||
|
|
@ -26,9 +30,14 @@ namespace MeshData {
|
||||||
static GUI::MainWindow* _mainwindow;
|
static GUI::MainWindow* _mainwindow;
|
||||||
QMenuBar* menuBar= nullptr;
|
QMenuBar* menuBar= nullptr;
|
||||||
QMenu* _toolboxMenu=nullptr;
|
QMenu* _toolboxMenu=nullptr;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void on_TestLoadModelImport();
|
void on_TestLoadModelImport();
|
||||||
void on_LoadPreMeshFileDialog(GUI::MainWindow* _m, QString _fileType);
|
void on_LoadPreMeshFileDialog(GUI::MainWindow* _m, QString _fileType);
|
||||||
|
void on_deleteMesh(GUI::MainWindow* m);
|
||||||
|
void on_copyMesh(GUI::MainWindow* m);
|
||||||
|
void on_clipMesh(GUI::MainWindow* m);
|
||||||
|
void on_saveMesh(GUI::MainWindow* m);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +79,6 @@ extern "C"
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI PCDexportPCL(QString AbFileName,int modelId);
|
bool MESHDATAEXCHANGEPLUGINAPI PCDexportPCL(QString AbFileName,int modelId);
|
||||||
bool MESHDATAEXCHANGEPLUGINAPI PLYexportPCL(QString AbFileName,int modelId);
|
bool MESHDATAEXCHANGEPLUGINAPI PLYexportPCL(QString AbFileName,int modelId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -52,9 +52,13 @@ namespace WBFZ
|
||||||
void actionAttriutionDBShow(GUI::MainWindow* m);
|
void actionAttriutionDBShow(GUI::MainWindow* m);
|
||||||
// 图像展示工具
|
// 图像展示工具
|
||||||
void actionImageShowToolShow(GUI::MainWindow* m);
|
void actionImageShowToolShow(GUI::MainWindow* m);
|
||||||
|
// RCS展示工具
|
||||||
void actionactionRCShowTool(GUI::MainWindow* m);
|
void actionactionRCShowTool(GUI::MainWindow* m);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,8 @@ add_library(PointCloudOperator
|
||||||
${_source}
|
${_source}
|
||||||
MeshOpearatorCommon.cpp
|
MeshOpearatorCommon.cpp
|
||||||
MeshOpearatorCommon.h
|
MeshOpearatorCommon.h
|
||||||
|
OpenMeshOperator.cpp
|
||||||
|
OpenMeshOperator.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -116,6 +118,7 @@ list(APPEND _runtimes_libraries
|
||||||
|
|
||||||
list(APPEND _runtimes_libraries
|
list(APPEND _runtimes_libraries
|
||||||
OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
OpenCASCADE::Freetype OpenCASCADE::TKBO OpenCASCADE::TKBRep OpenCASCADE::TKBool OpenCASCADE::TKCAF OpenCASCADE::TKCDF OpenCASCADE::TKG2d OpenCASCADE::TKG3d OpenCASCADE::TKGeomAlgo OpenCASCADE::TKGeomBase OpenCASCADE::TKHLR OpenCASCADE::TKIGES OpenCASCADE::TKLCAF OpenCASCADE::TKMath OpenCASCADE::TKMesh OpenCASCADE::TKPrim OpenCASCADE::TKSTEP OpenCASCADE::TKSTEP209 OpenCASCADE::TKSTEPAttr OpenCASCADE::TKSTEPBase OpenCASCADE::TKService OpenCASCADE::TKShHealing OpenCASCADE::TKTopAlgo OpenCASCADE::TKV3d OpenCASCADE::TKVCAF OpenCASCADE::TKXCAF OpenCASCADE::TKXDEIGES OpenCASCADE::TKXSBase OpenCASCADE::TKernel Qt5::Widgets Qt5::Xml VTK::CommonColor VTK::CommonComputationalGeometry VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonMath VTK::CommonMisc VTK::CommonSystem VTK::CommonTransforms VTK::FiltersCore VTK::FiltersExtraction VTK::FiltersGeneral VTK::FiltersGeometry VTK::FiltersSources VTK::FiltersStatistics VTK::IOCore VTK::IOLegacy VTK::IOXML VTK::IOXMLParser VTK::ImagingCore VTK::ImagingFourier VTK::ImagingMath VTK::InteractionStyle VTK::ParallelCore VTK::ParallelDIY VTK::RenderingCore VTK::RenderingFreeType VTK::RenderingOpenGL2 VTK::RenderingUI VTK::RenderingVolume VTK::RenderingVolumeOpenGL2 VTK::doubleconversion VTK::expat VTK::freetype VTK::glew VTK::lz4 VTK::lzma VTK::sys VTK::zlib VTK::IOGeometry
|
||||||
|
OpenMeshCore OpenMeshTools
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
/**
|
||||||
|
* @file OpenMeshOperator.cpp
|
||||||
|
* @brief None
|
||||||
|
* @author 陈增辉 (3045316072@qq.com)
|
||||||
|
* @version 2.5.0
|
||||||
|
* @date 24-7-8
|
||||||
|
* @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "OpenMeshOperator.h"
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkPolyDataReader.h>
|
||||||
|
#include <vtkPointData.h>
|
||||||
|
#include <vtkDataArray.h>
|
||||||
|
#include <vtkFloatArray.h>
|
||||||
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkPoints.h>
|
||||||
|
#include <vtkCell.h>
|
||||||
|
|
||||||
|
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||||
|
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
|
||||||
|
#include <memory>
|
||||||
|
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||||
|
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
|
||||||
|
#include <memory>
|
||||||
|
#include <vcg/complex/complex.h>
|
||||||
|
#include <vcg/complex/algorithms/create/platonic.h>
|
||||||
|
#include <vcg/complex/algorithms/clean.h>
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkPoints.h>
|
||||||
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkPolygon.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace MeshOperator {
|
||||||
|
|
||||||
|
bool OpenMeshOperator::vtkdataset2VCG(vtkSmartPointer<vtkPolyData> polyData, VCGMesh& mesh)
|
||||||
|
{
|
||||||
|
mesh.Clear();
|
||||||
|
|
||||||
|
// Convert points
|
||||||
|
for (vtkIdType i = 0; i < polyData->GetNumberOfPoints(); ++i) {
|
||||||
|
double coords[3];
|
||||||
|
polyData->GetPoint(i, coords);
|
||||||
|
VCGVertex v;
|
||||||
|
v.P() = vcg::Point3f(coords[0], coords[1], coords[2]);
|
||||||
|
mesh.vert.push_back(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkCellArray* cells = polyData->GetPolys();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool OpenMeshOperator::OpenMesh2VCG(vtkSmartPointer<vtkPolyData> polydata, VCGMesh& mesh)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} // namespace MeshOperator
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
* @file OpenMeshOperator.h
|
||||||
|
* @brief 网格处理算法
|
||||||
|
* @author 陈增辉 (3045316072@qq.com)
|
||||||
|
* @version 2.5.0
|
||||||
|
* @date 24-7-8
|
||||||
|
* @copyright Copyright (c) Since 2024 中科卫星应用研究院 All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LAMPCAE_OPENMESHOPERATOR_H
|
||||||
|
#define LAMPCAE_OPENMESHOPERATOR_H
|
||||||
|
#include "PointCloudOperatorAPI.h"
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkPolyDataReader.h>
|
||||||
|
#include <vtkPointData.h>
|
||||||
|
#include <vtkDataArray.h>
|
||||||
|
#include <vtkFloatArray.h>
|
||||||
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkPoints.h>
|
||||||
|
#include <vtkCell.h>
|
||||||
|
|
||||||
|
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||||
|
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
|
||||||
|
#include <memory>
|
||||||
|
#include <vcg/complex/complex.h>
|
||||||
|
#include <vcg/complex/algorithms/create/platonic.h>
|
||||||
|
#include <vcg/complex/algorithms/clean.h>
|
||||||
|
#include <vtkSmartPointer.h>
|
||||||
|
#include <vtkPoints.h>
|
||||||
|
#include <vtkCellArray.h>
|
||||||
|
#include <vtkPolyData.h>
|
||||||
|
#include <vtkPolygon.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace MeshOperator {
|
||||||
|
|
||||||
|
|
||||||
|
class VCGVertex;
|
||||||
|
class VCGEdge;
|
||||||
|
class VCGFace;
|
||||||
|
|
||||||
|
struct VCGUsedTypes : public vcg::UsedTypes<vcg::Use<VCGVertex>::AsVertexType, vcg::Use<VCGEdge>::AsEdgeType, vcg::Use<VCGFace>::AsFaceType>{};
|
||||||
|
|
||||||
|
class VCGVertex : public vcg::Vertex<VCGUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::Mark> {};
|
||||||
|
|
||||||
|
class VCGEdge : public vcg::Edge<VCGUsedTypes> {};
|
||||||
|
|
||||||
|
class VCGFace : public vcg::Face<VCGUsedTypes, vcg::face::VFAdj> {};
|
||||||
|
|
||||||
|
class VCGMesh : public vcg::tri::TriMesh<std::vector<VCGVertex>, std::vector<VCGFace>> {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class POINTCLOUDOPERATORAPI OpenMeshOperator {
|
||||||
|
static bool vtkdataset2VCG(vtkSmartPointer<vtkPolyData> polydata, VCGMesh& mesh);
|
||||||
|
static bool OpenMesh2VCG(vtkSmartPointer<vtkPolyData> polydata,VCGMesh& mesh);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace MeshOperator
|
||||||
|
|
||||||
|
#endif // LAMPCAE_OPENMESHOPERATOR_H
|
||||||
Loading…
Reference in New Issue