本文整理汇总了C++中imagetype::RegionType::GetUpperIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ RegionType::GetUpperIndex方法的具体用法?C++ RegionType::GetUpperIndex怎么用?C++ RegionType::GetUpperIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagetype::RegionType
的用法示例。
在下文中一共展示了RegionType::GetUpperIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void Mesh::save(string filename, ImageType::Pointer image_ref)
{
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkDoubleArray> pointNormalsArray = vtkSmartPointer<vtkDoubleArray>::New();
pointNormalsArray->SetNumberOfComponents(3); //3d normals (ie x,y,z)
pointNormalsArray->SetNumberOfTuples(points_.size());
CVector3 p, n;
for (unsigned int i=0; i<points_.size(); i++) {
p = points_[i]->getPosition();
n = points_[i]->getNormal();
points->InsertNextPoint(p[0],p[1],p[2]);
pointNormalsArray->SetTuple3(i, n[0], n[1], n[2]) ;
}
vtkSmartPointer<vtkPolyData> source = vtkSmartPointer<vtkPolyData>::New();
source->SetPoints(points);
source->GetPointData()->SetNormals(pointNormalsArray);
source->Allocate(triangles_.size());
for (unsigned int i=0; i<triangles_.size(); i+=3) {
vtkIdType pts[3] = {triangles_[i],triangles_[i+1],triangles_[i+2]};
source->InsertNextCell(VTK_TRIANGLE,3,pts);
}
if (image_ref.IsNotNull())
{
ImageType::RegionType largestRegion = image_ref->GetLargestPossibleRegion();
ImageType::IndexType downSliceIndex, downSliceMIndex, upperSliceIndex, upperSliceMIndex;
downSliceIndex.Fill(0);
downSliceMIndex.Fill(0);
downSliceMIndex[1] = 1;
upperSliceIndex = largestRegion.GetUpperIndex();
upperSliceMIndex = upperSliceIndex; upperSliceMIndex[1] = upperSliceMIndex[1]-1;
PointType downSlicePoint, downSliceMPoint, upperSlicePoint, upperSliceMPoint;
image_ref->TransformIndexToPhysicalPoint(downSliceIndex, downSlicePoint);
image_ref->TransformIndexToPhysicalPoint(downSliceMIndex, downSliceMPoint);
image_ref->TransformIndexToPhysicalPoint(upperSliceIndex, upperSlicePoint);
image_ref->TransformIndexToPhysicalPoint(upperSliceMIndex, upperSliceMPoint);
CVector3 downSliceNormal = CVector3(downSlicePoint[0]-downSliceMPoint[0],downSlicePoint[1]-downSliceMPoint[1],downSlicePoint[2]-downSliceMPoint[2]).Normalize(), upperSliceNormal = CVector3(upperSlicePoint[0]-upperSliceMPoint[0],upperSlicePoint[1]-upperSliceMPoint[1],upperSlicePoint[2]-upperSliceMPoint[2]).Normalize();
vtkSmartPointer<vtkPlane> downPlane = vtkSmartPointer<vtkPlane>::New(), upperPlane = vtkSmartPointer<vtkPlane>::New();
downPlane->SetOrigin(downSlicePoint[0],downSlicePoint[1],downSlicePoint[2]);
downPlane->SetNormal(downSliceNormal[0],downSliceNormal[1],downSliceNormal[2]);
upperPlane->SetOrigin(upperSlicePoint[0],upperSlicePoint[1],upperSlicePoint[2]);
upperPlane->SetNormal(upperSliceNormal[0],upperSliceNormal[1],upperSliceNormal[2]);
vtkSmartPointer<vtkClipPolyData> downClipper = vtkSmartPointer<vtkClipPolyData>::New();
downClipper->SetInputData(source);
downClipper->SetClipFunction(downPlane);
downClipper->InsideOutOn();
downClipper->Update();
vtkSmartPointer<vtkClipPolyData> upperClipper = vtkSmartPointer<vtkClipPolyData>::New();
upperClipper->SetInputData(downClipper->GetOutput());
upperClipper->SetClipFunction(upperPlane);
upperClipper->InsideOutOn();
upperClipper->Update();
source = upperClipper->GetOutput();
}
vtkSmartPointer<vtkPolyDataWriter> writer = vtkSmartPointer<vtkPolyDataWriter>::New();
writer->SetFileName(filename.c_str());
writer->SetInputData(source);
writer->Write();
}