本文整理汇总了C++中vtkSmartPointer::GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::GetBounds方法的具体用法?C++ vtkSmartPointer::GetBounds怎么用?C++ vtkSmartPointer::GetBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkSmartPointer
的用法示例。
在下文中一共展示了vtkSmartPointer::GetBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw_robotic_arm
//.........这里部分代码省略.........
CylinderSource10 ->Update();
vtkSmartPointer<vtkTransform> transform10 = vtkSmartPointer<vtkTransform>::New();
//transform->RotateWXYZ(double angle, double x, double y, double z);
transform10->SetMatrix(transform9->GetMatrix());
transform10->Translate(209+Cylinder10_displace+17,0,20);
transform10->RotateWXYZ(90, 0, 0, 1);
//transform10->Translate(Cylinder10_displace,0,0)
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter10 =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter10->SetTransform(transform10);
transformFilter10->SetInputConnection(CylinderSource10->GetOutputPort());
transformFilter10->Update();
static vtkSmartPointer<vtkPolyDataMapper> Cylindermapper10 =
vtkSmartPointer<vtkPolyDataMapper>::New();
Cylindermapper10->SetInput(transformFilter10->GetOutput());
Cylindermapper10->Update();
static vtkSmartPointer<vtkActor> Cylinderactor10 =
vtkSmartPointer<vtkActor>::New();
Cylinderactor10->SetMapper(Cylindermapper10);
vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetRadius(1);
sphereSource->Update();
vtkSmartPointer<vtkTransform> transform_spheresource = vtkSmartPointer<vtkTransform>::New();
//transform->RotateWXYZ(double angle, double x, double y, double z);
transform_spheresource->SetMatrix(transform9->GetMatrix());
transform_spheresource->Translate(289+17+Cylinder10_displace,0,20);
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter_spheresource =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter_spheresource->SetTransform(transform_spheresource);
transformFilter_spheresource->SetInputConnection(sphereSource->GetOutputPort());
transformFilter_spheresource->Update();
static vtkSmartPointer<vtkPolyDataMapper> spheresourcemapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
spheresourcemapper->SetInput(transformFilter_spheresource->GetOutput());
spheresourcemapper->Update();
static vtkSmartPointer<vtkActor> spheresourceactor =
vtkSmartPointer<vtkActor>::New();
spheresourceactor->SetMapper(spheresourcemapper);
//取得針端坐標點
spheresourcemapper ->GetBounds(niddlePos_tmp1);
vtkSmartPointer<vtkSphereSource> sphereSource1 = vtkSmartPointer<vtkSphereSource>::New();
sphereSource1->SetRadius(1);
sphereSource1->Update();
vtkSmartPointer<vtkTransform> transform_spheresource1 = vtkSmartPointer<vtkTransform>::New();
//transform->RotateWXYZ(double angle, double x, double y, double z);
transform_spheresource1->SetMatrix(transform9->GetMatrix());
transform_spheresource1->Translate(120+17+Cylinder10_displace,0,20);
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter_spheresource1 =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter_spheresource1->SetTransform(transform_spheresource1);
transformFilter_spheresource1->SetInputConnection(sphereSource1->GetOutputPort());
transformFilter_spheresource1->Update();
static vtkSmartPointer<vtkPolyDataMapper> spheresourcemapper1 =
vtkSmartPointer<vtkPolyDataMapper>::New();
spheresourcemapper1->SetInput(transformFilter_spheresource1->GetOutput());
spheresourcemapper1->Update();
static vtkSmartPointer<vtkActor> spheresourceactor1 =
vtkSmartPointer<vtkActor>::New();
spheresourceactor1->SetMapper(spheresourcemapper1);
spheresourcemapper1->GetBounds(niddlePos_tmp2);
m_Renderer->AddActor(actor1);
m_Renderer->AddActor(cubeactor2);
m_Renderer->AddActor(cubeactor3);
m_Renderer->AddActor(cubeactor4);
m_Renderer->AddActor(cubeactor5);
m_Renderer->AddActor(cubeactor6);
m_Renderer->AddActor(cubeactor7);
m_Renderer->AddActor(cubeactor8);
m_Renderer->AddActor(cubeactor9);
m_Renderer->AddActor(cubeactor10);
m_Renderer->AddActor(Cylinderactor1);
m_Renderer->AddActor(Cylinderactor2);
m_Renderer->AddActor(Cylinderactor3);
m_Renderer->AddActor(Cylinderactor4);
m_Renderer->AddActor(Cylinderactor5);
m_Renderer->AddActor(Cylinderactor6);
m_Renderer->AddActor(Cylinderactor7);
m_Renderer->AddActor(Cylinderactor8);
m_Renderer->AddActor(Cylinderactor9);
m_Renderer->AddActor(Cylinderactor10);
m_Renderer->AddActor(spheresourceactor);
m_Renderer->AddActor(spheresourceactor1);
}
示例2: abs
vtkSmartPointer<vtkImageData> vtkPolyData2vtkImageData(vtkSmartPointer<vtkPolyData> pd, double* spacing, double margin, int col) {
vtkSmartPointer<vtkImageData> whiteImage = vtkSmartPointer<vtkImageData>::New();
double bounds[6];
pd->GetBounds(bounds);
double dimbounds[6];
for (int i = 0; i < 3;i++) {
double tmp = abs(bounds[i*2]-bounds[i*2+1]);
dimbounds[i*2] = tmp;
dimbounds[i*2+1] = tmp;
}
//add margin for each dimension
for (int i = 0; i < 6; i++) {
double margintmp = std::pow(-1,i+1)*margin*dimbounds[i];
bounds[i] += margintmp;//add 10 % margin
}
whiteImage->SetSpacing(spacing);
int dim[3];
for (int i = 0; i < 3; i++) {
dim[i] = static_cast<int>(ceil((bounds[i * 2 + 1] - bounds[i * 2]) / spacing[i]));
}
whiteImage->SetDimensions(dim);
whiteImage->SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);
double origin[3];
origin[0] = bounds[0] + spacing[0] / 2;
origin[1] = bounds[2] + spacing[1] / 2;
origin[2] = bounds[4] + spacing[2] / 2;
whiteImage->SetOrigin(origin);
#if VTK_MAJOR_VERSION <= 5
whiteImage->SetScalarTypeToUnsignedChar();
whiteImage->AllocateScalars();
#else
whiteImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
#endif
// fill the image with foreground voxels:
unsigned char inval = col;
unsigned char outval = 0;
vtkIdType count = whiteImage->GetNumberOfPoints();
for (vtkIdType i = 0; i < count; ++i) {
whiteImage->GetPointData()->GetScalars()->SetTuple1(i, inval);
}
// polygonal data --> image stencil:
vtkSmartPointer<vtkPolyDataToImageStencil> pol2stenc =
vtkSmartPointer<vtkPolyDataToImageStencil>::New();
#if VTK_MAJOR_VERSION <= 5
pol2stenc->SetInput(pd);
#else
pol2stenc->SetInputData(pd);
#endif
//pol2stenc->SetTolerance(0.0);
pol2stenc->SetOutputOrigin(origin);
pol2stenc->SetOutputSpacing(spacing);
pol2stenc->SetOutputWholeExtent(whiteImage->GetExtent());
pol2stenc->Update();
// cut the corresponding white image and set the background:
vtkSmartPointer<vtkImageStencil> imgstenc =
vtkSmartPointer<vtkImageStencil>::New();
#if VTK_MAJOR_VERSION <= 5
imgstenc->SetInput(whiteImage);
imgstenc->SetStencil(pol2stenc->GetOutput());
#else
imgstenc->SetInputData(whiteImage);
imgstenc->SetStencilConnection(pol2stenc->GetOutputPort());
#endif
imgstenc->ReverseStencilOff();
imgstenc->SetBackgroundValue(outval);
imgstenc->Update();
vtkSmartPointer<vtkImageData> outImage = imgstenc->GetOutput();
return outImage;
}