
通过这个例子可以直观理解隐函数是什么、在空间中怎么分布、怎么布尔运算。
1.完整代码
#include<vtkBox.h>
#include<vtkNew.h>
#include<vtkActor.h>
#include<vtkSphere.h>
#include<vtkAutoInit.h>
#include<vtkProperty.h>
#include<vtkRenderer.h>
#include<vtkImageData.h>
#include<vtkContourFilter.h>
#include<vtkImplicitBoolean.h>
#include<vtkDataSetMapper.h>
#include<vtkRenderWindow.h>
#include<vtkPolyDataMapper.h>
#include<vtkSampleFunction.h>
#include<vtkRenderWindowInteractor.h>
#include<vtkActor2D.h>
#include<vtkTextActor.h>
#include<vtkTextProperty.h>
#include<vtkCommand.h>
#include<vtkSliderWidget.h>
#include<vtkSliderRepresentation2D.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle)
VTK_MODULE_INIT(vtkRenderingFreeType)
#include<QString>
class myCallback: public vtkCommand
{
public:
static myCallback *New() {
return new myCallback;
}
void Execute(vtkObject *caller, unsigned long eventId, void *callData) override
{
vtkSliderWidget *widget = (vtkSliderWidget *)caller;
vtkSliderRepresentation2D *slider = (vtkSliderRepresentation2D *)widget->GetRepresentation();
m_contour1->SetValue(0, slider->GetValue());
m_contour2->SetValue(0, slider->GetValue());
m_contour3->SetValue(0, slider->GetValue());
}
vtkContourFilter *m_contour1;
vtkContourFilter *m_contour2;
vtkContourFilter *m_contour3;
private:
myCallback() {
m_contour1 = nullptr;
m_contour2 = nullptr;
m_contour3 = nullptr;
}
~myCallback() {}
};
#define Create(type,name)\
vtkNew<type> name;
int main()
{
//两个隐函数,方盒子和球
Create(vtkBox, box);
bo

最低0.47元/天 解锁文章
2022

被折叠的 条评论
为什么被折叠?



