|
|
|
|
|
#ifndef NMPEBIRESULTSNAPSHOTRENDERADAPTER_H
|
|
|
|
|
|
#define NMPEBIRESULTSNAPSHOTRENDERADAPTER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "nmData_global.h"
|
|
|
|
|
|
#include "nmPebiResultSnapshot.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
|
|
|
|
|
|
|
#include <vtkSmartPointer.h>
|
|
|
|
|
|
#include <vtkType.h>
|
|
|
|
|
|
|
|
|
|
|
|
class vtkAlgorithmOutput;
|
|
|
|
|
|
class vtkDoubleArray;
|
|
|
|
|
|
class vtkTrivialProducer;
|
|
|
|
|
|
class vtkUnstructuredGrid;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 将只读结果快照连接到 VTK 渲染管道。
|
|
|
|
|
|
*
|
|
|
|
|
|
* 适配器独占渲染网格和复制缓冲,只向 UI 暴露输出端口。普通 UI 不应从
|
|
|
|
|
|
* 输出管道反查并修改网格、点、单元或压力数组。
|
|
|
|
|
|
*/
|
|
|
|
|
|
class NM_DATA_EXPORT nmPebiResultSnapshotRenderAdapter
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
/** @brief 正式属性数组与渲染网格之间的绑定方式。 */
|
|
|
|
|
|
enum PropertyBindingMode
|
|
|
|
|
|
{
|
|
|
|
|
|
SharedPropertyArray = 0, ///< 临时共享快照只读数组,不产生整帧复制。
|
|
|
|
|
|
CopiedPropertyArray = 1 ///< 复制到双缓冲,隔离不可信下游流程。
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief 旧压力调用方使用的兼容枚举。 */
|
|
|
|
|
|
enum PressureBindingMode
|
|
|
|
|
|
{
|
|
|
|
|
|
SharedPressureFrame = SharedPropertyArray,
|
|
|
|
|
|
CopiedPressureFrame = CopiedPropertyArray
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief 创建尚未绑定快照的渲染适配器。 */
|
|
|
|
|
|
nmPebiResultSnapshotRenderAdapter();
|
|
|
|
|
|
/** @brief 解除 VTK 临时引用并释放适配器持有的只读快照。 */
|
|
|
|
|
|
~nmPebiResultSnapshotRenderAdapter();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 绑定快照并建立仅含内部单元映射的渲染网格结构。
|
|
|
|
|
|
* @param pSnapshot 调用期间保持只读的结果快照。
|
|
|
|
|
|
* @param eBindingMode 共享属性或单帧复制模式。
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool initialize(
|
|
|
|
|
|
const QSharedPointer<const nmPebiResultSnapshot>& pSnapshot,
|
|
|
|
|
|
PropertyBindingMode eBindingMode);
|
|
|
|
|
|
/** @brief 使用旧压力枚举初始化,行为与通用绑定模式一致。 */
|
|
|
|
|
|
bool initialize(
|
|
|
|
|
|
const QSharedPointer<const nmPebiResultSnapshot>& pSnapshot,
|
|
|
|
|
|
PressureBindingMode eBindingMode);
|
|
|
|
|
|
/** @brief 解除输出、属性数组和快照引用,使适配器恢复为空状态。 */
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief 事务式发布指定属性帧,失败时保持原画面和状态不变。 */
|
|
|
|
|
|
bool setPropertyFrame(const QString& sPropertyId, int nFrameIndex);
|
|
|
|
|
|
/** @brief 将指定压力帧发布到当前 VTK 输出端口。 */
|
|
|
|
|
|
bool setPressureFrame(int nFrameIndex);
|
|
|
|
|
|
/** @brief 返回供 Mapper 或过滤器建立连接的 VTK 输出端口。 */
|
|
|
|
|
|
vtkAlgorithmOutput* getOutputPort() const;
|
|
|
|
|
|
/** @brief 返回当前已经绑定的压力帧下标,尚未切帧时为 -1。 */
|
|
|
|
|
|
int getCurrentFrameIndex() const;
|
|
|
|
|
|
/** @brief 返回当前已经绑定的属性 ID,尚未绑定时为空。 */
|
|
|
|
|
|
QString getCurrentPropertyId() const;
|
|
|
|
|
|
/** @brief 返回当前属性对应的稳定 VTK 数组名,尚未绑定时为空。 */
|
|
|
|
|
|
QString getCurrentScalarArrayName() const;
|
|
|
|
|
|
/** @brief 返回适配器渲染网格的单元数。 */
|
|
|
|
|
|
vtkIdType getCellCount() const;
|
|
|
|
|
|
/** @brief 返回当前是否使用零整帧复制的共享压力模式。 */
|
|
|
|
|
|
bool isUsingSharedPressure() const;
|
|
|
|
|
|
/** @brief 返回当前是否使用零整帧复制的共享属性模式。 */
|
|
|
|
|
|
bool isUsingSharedProperties() const;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
/** @brief 禁止复制包含 VTK 管道和快照引用的适配器。 */
|
|
|
|
|
|
nmPebiResultSnapshotRenderAdapter(
|
|
|
|
|
|
const nmPebiResultSnapshotRenderAdapter&);
|
|
|
|
|
|
/** @brief 禁止给适配器赋值。 */
|
|
|
|
|
|
nmPebiResultSnapshotRenderAdapter& operator=(
|
|
|
|
|
|
const nmPebiResultSnapshotRenderAdapter&);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
/** @brief 当前渲染使用的只读快照。 */
|
|
|
|
|
|
QSharedPointer<const nmPebiResultSnapshot> m_pSnapshot;
|
|
|
|
|
|
/** @brief 适配器独占的渲染网格,结构可与快照基础网格共享。 */
|
|
|
|
|
|
vtkSmartPointer<vtkUnstructuredGrid> m_pRenderGrid;
|
|
|
|
|
|
/** @brief 复制模式当前绑定到 CellData 的活动缓冲。 */
|
|
|
|
|
|
vtkSmartPointer<vtkDoubleArray> m_pActiveBuffer;
|
|
|
|
|
|
/** @brief 复制模式在切换成功前独立填充和校验的备用缓冲。 */
|
|
|
|
|
|
vtkSmartPointer<vtkDoubleArray> m_pStandbyBuffer;
|
|
|
|
|
|
/** @brief 将独立渲染网格接入 VTK 管道的生产者。 */
|
|
|
|
|
|
vtkSmartPointer<vtkTrivialProducer> m_pProducer;
|
|
|
|
|
|
/** @brief 当前属性数组绑定方式。 */
|
|
|
|
|
|
PropertyBindingMode m_eBindingMode;
|
|
|
|
|
|
/** @brief 当前已经绑定的属性 ID。 */
|
|
|
|
|
|
QString m_sCurrentPropertyId;
|
|
|
|
|
|
/** @brief 当前已经绑定的属性帧下标。 */
|
|
|
|
|
|
int m_nCurrentFrameIndex;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NMPEBIRESULTSNAPSHOTRENDERADAPTER_H
|