本文整理汇总了C++中vtkSmartPointer::AutomaticOn方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::AutomaticOn方法的具体用法?C++ vtkSmartPointer::AutomaticOn怎么用?C++ vtkSmartPointer::AutomaticOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkSmartPointer
的用法示例。
在下文中一共展示了vtkSmartPointer::AutomaticOn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void mitk::UnstructuredGridClusteringFilter::GenerateData()
{
mitk::UnstructuredGrid::Pointer inputGrid = const_cast<mitk::UnstructuredGrid*>(this->GetInput());
if(inputGrid.IsNull()) return;
vtkSmartPointer<vtkUnstructuredGrid> vtkInpGrid = inputGrid->GetVtkUnstructuredGrid();
vtkSmartPointer<vtkPoints> inpPoints = vtkInpGrid->GetPoints();
pLocator =vtkSmartPointer<vtkPointLocator>::New();
vtkSmartPointer<vtkDoubleArray> distances = vtkSmartPointer<vtkDoubleArray>::New();
if(inputGrid->GetVtkUnstructuredGrid()->GetPointData()->GetNumberOfArrays() > 0)
{
m_DistCalc = true;
distances = dynamic_cast<vtkDoubleArray*>(vtkInpGrid->GetPointData()->GetArray(0));
}
pLocator->SetDataSet(vtkInpGrid);
pLocator->AutomaticOn();
pLocator->SetNumberOfPointsPerBucket(2);
pLocator->BuildLocator();
//fill the visited map with false for checking
for(int i=0; i<inpPoints->GetNumberOfPoints();i++)
{
visited[i] = false;
isNoise[i] = false;
clusterMember[i] = false;
}
for(int i=0; i<inpPoints->GetNumberOfPoints();i++)
{
if(!visited[i])
{
visited[i] = true; //mark P as visited
vtkSmartPointer<vtkIdList> idList = vtkSmartPointer<vtkIdList>::New(); //represent N
pLocator->FindPointsWithinRadius(m_eps, inpPoints->GetPoint(i), idList); //N = D.regionQuery(P, eps)
if(idList->GetNumberOfIds() < m_MinPts) //if sizeof(N) < MinPts
{
isNoise[i] = true; //mark P as NOISE
}
else
{
vtkSmartPointer<vtkPoints> cluster = vtkSmartPointer<vtkPoints>::New(); //represent a cluster
clusterVector.push_back(cluster); //C = next cluster
this->ExpandCluster(i,idList,cluster,inpPoints); //expandCluster(P, N, C, eps, MinPts) mod. the parameter list
}
}
}
//OUTPUT LOGIC
m_Clusters = clusterVector;
int numberOfClusterPoints = 0;
int IdOfBiggestCluster = 0;
for(unsigned int i=0; i<m_Clusters.size();i++)
{
vtkSmartPointer<vtkDoubleArray> array = vtkSmartPointer<vtkDoubleArray>::New();
vtkSmartPointer<vtkPoints> points = m_Clusters.at(i);
if(m_DistCalc)
{
array->SetNumberOfComponents(1);
array->SetNumberOfTuples(points->GetNumberOfPoints());
for(int j=0; j<points->GetNumberOfPoints();j++)
{
double point[3];
points->GetPoint(j,point);
if(clustersPointsIDs.at(i).at(j)<inpPoints->GetNumberOfPoints())
{
if(distances->GetValue(clustersPointsIDs.at(i).at(j)) > 0.001)
{
double dist[1] = {distances->GetValue(clustersPointsIDs.at(i).at(j))};
array->SetTuple(j, dist);
}
else
{
double dist[1] = {0.0};
array->SetTuple(j, dist);
}
}
}
m_DistanceArrays.push_back(array);
}
if(points->GetNumberOfPoints() > numberOfClusterPoints)
{
numberOfClusterPoints = points->GetNumberOfPoints();
IdOfBiggestCluster = i;
}
}
vtkSmartPointer<vtkUnstructuredGrid> biggestCluster = vtkSmartPointer<vtkUnstructuredGrid>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points = m_Clusters.at(IdOfBiggestCluster);
vtkSmartPointer<vtkPolyVertex> verts = vtkSmartPointer<vtkPolyVertex>::New();
verts->GetPointIds()->SetNumberOfIds(m_Clusters.at(IdOfBiggestCluster)->GetNumberOfPoints());
for(int i=0; i<m_Clusters.at(IdOfBiggestCluster)->GetNumberOfPoints(); i++)
{
verts->GetPointIds()->SetId(i,i);
}
//.........这里部分代码省略.........