1.多终端同步
2.markdown公式渲染
参考:
[1].https://cloud.tencent.com/developer/article/1046404
[2].https://www.jianshu.com/p/7ab21c7f0674
1.多终端同步
2.markdown公式渲染
参考:
[1].https://cloud.tencent.com/developer/article/1046404
[2].https://www.jianshu.com/p/7ab21c7f0674
循环直到回到起始点
1 | 注意:左转和右转是针对当前循环的位置 |
无法追踪斜线,改进:终止条件改为访问起始点多次
Catch2是一个header-only测试框架。
1 | #define CATCH_CONFIG_MAIN // 宏定义指明main()函数 |
vtk多个窗口进行交互,每个窗口需要有单独的vtkRenderWindowInteractor。
在render的时候,执行vtkRenderWindowInteractor::Start之后,主线程会被阻塞。
所以以下方式进行渲染是错误的。1
2
3
4
5
6
7
8
9
10void Render(int i)
{
....
interactor->Start();
}
for(int i=0;i<N;i++)
{
Render(i);
}
vtk中使用vtkWindowToImageFilter和vtkAVIWriter来实现render window内容的录制。但是在录制过程中需要自行Modify vtkWindowToImageFilter数据以及vtkAVIWriter的writer方法。
自然而然的想法是使用Timer来定时执行。通过指定帧率,可以计算出采样帧的时间间隔。
方案一:
对interactor创建timer callbak,在callback中写render window帧。此种方案有个问题,当鼠标进行交互时,会block timer的callback。
方案二:
对render window创建render event的callback,在callback中计时,超出interval时间,则进行写帧。
std::set使用自定义key时,需要指定comparator,具体做法如下:1
2
3
4
5
6
7
8
9
10struct cmpByStringLength
{
bool operator()(const std::string& a, const std::string& b) const
{
return a.length() < b.length();
}
};
// ...
std::map<std::string, std::string, cmpByStringLength> myMap;
使用时,正常插入没问题,查找时遇到invalid comparator问题。
原因是comparator不符合规定。
comparator需要时strict weak ordering,需要注意的是,comparator(x,x)必须返回false。
参考:
[1].https://stackoverflow.com/questions/9648100/using-own-comparator-operator-for-map-giving-error-in-case-if-key-not-found
[2].https://stackoverflow.com/questions/32263560/errorinvalid-comparator-when-sorting-using-custom-comparison-function
1 | for (int i = 0; i < lines->GetNumberOfCells(); i++) |
输出结果:1
2
3
4
5
6
7
8
9
10
11
12P1 : 131 111,177,121
P2 : 130 111,177,121
P1 : 130 112,178,120
P2 : 129 112,178,120
P1 : 129 112,178,119
P2 : 128 112,178,119
P1 : 128 112,177,118
P2 : 127 112,177,118
P1 : 127 112,176,117
P2 : 126 112,176,117
P1 : 126 111,175,116
...
发现每次输出P1跟P2坐标相同,好久没发现问题所在。追踪到源码,发现这么一段warning,细想一下,这样设计业很好理解。1
2
3
4
5
6
7
8
9
10
11// Description:
// Return a pointer to a double point x[3] for a specific id.
// WARNING: Just don't use this error-prone method, the returned pointer
// and its values are only valid as long as another method invocation is not
// performed. Prefer GetPoint() with the return value in argument.
double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id); }
// Description:
// Copy point components into user provided array v[3] for specified
// id.
void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x); }
更新程序使用1
2
3
4double p1[3];
double p2[3];
polydata->GetPoints()->GetPoint(pid1, p1);
polydata->GetPoints()->GetPoint(pid2, p2);
目标达成。
1 | double spacing[3]; |
以上代码会导致reader->GetOutput()和joinFilter->GetOutput()数据的spacing信息不一致。
JoinSeriesImageFilter会将z轴方向的spacing固定为1。