ParaView Clip / Slice,Box参数:位置,旋转,比例的含义;在Matlab中重构Box

时间:2017-04-19 15:43:22

标签: matlab mesh triangulation paraview rotational-matrices

我想在给定的三角形几何旁边定义一个特定大小和位置的 3D Box

因此,我在ParaView中打开几何网格。然后,我使用类型“Box”的 Clip(或Slice)。通过这种方式,我获得了一个盒子的ParaView 3D小部件,可以使用鼠标快速,交互地移动,旋转和调整大小。

属性面板始终显示框参数

  • 位置
  • 轮换
  • 缩放

到目前为止一切顺利,但是如何在ParaView外部使用这些值来处理这个框,例如在MATLAB中?盒子的实际坐标是多少?

Ventricle Placement Below Atria

1 个答案:

答案 0 :(得分:0)

我们从ParaView中复制盒子属性:

box = struct();
box.translate = [-274.8975, -114.0316, -333.6671];
box.rotate    = [27.066, 119.62, -175.472];
box.scale     = [1.031, 0.663, 1.2233];

框大小相对于定义剪辑过滤器的几何尺寸。因此,首先获取几何体的范围,其顶点存储在surfpts中。

surfpts = ...; % [nPoints x 3]
mn = min(surfpts,[],1); 
mx = max(surfpts,[],1);

在这个例子中,我想用一个点网格填充框。

box.xyz = arrayfun(@(a,b) linspace(a,b,n)', mn, mx, 'UniformOutput',false);
box.xyz = cell2mat(box.xyz);
[X,Y,Z] = ndgrid(box.xyz(:,1), box.xyz(:,2), box.xyz(:,3));
box.XYZ = [X(:), Y(:), Z(:)];

现在我们必须根据我们对Paraview框3d小部件所做的操作来缩放,旋转和平移我们的网格(按此顺序!)。

% Scaling
box.XYZ = bsxfun(@times, box.XYZ, box.scale);
% Rotation 
box.XYZ = (rotz(box.rotate(3)) * rotx(box.rotate(1)) * roty(box.rotate(2)) * box.XYZ')';
% Translation
box.XYZ = bsxfun(@plus, box.XYZ, box.translate);

最后,我们再次打开ParaView中创建的框来检查结果。它与盒子完全匹配。

TR = delaunayTriangulation(box.XYZ);
[box_tri, box_pts] = TR.freeBoundary();
vtkwrite('tmp_box.vtk','polydata','triangle',box_pts(:,1),box_pts(:,2),box_pts(:,3),box_tri)