Пример #1
0
Instance *CreateGraphRefInstance(Instance *instance1, ReferenceGraph *refGraph) 
{
   int i;
   Instance *instance2 =
      AllocateInstance(instance1->numVertices, instance1->numEdges);

   for(i=0;i<instance1->numVertices;i++)
   {
      // assign the vertices to the full graph
      instance2->vertices[i] = refGraph->vertices[instance1->vertices[i]].map;
   }

   // reorder indices based on the vertices in the full graph
   SortIndices(instance2->vertices, 0, instance2->numVertices-1);

   for(i=0;i<instance1->numEdges;i++)
   {
      // assign the vertices to the full graph
      instance2->edges[i] = refGraph->edges[instance1->edges[i]].map;
   }

   // reorder indices based on the vertices in the full graph
   SortIndices(instance2->edges, 0, instance2->numEdges-1);

   return instance2;
}
Пример #2
0
void SortIndices(ULONG *A, long p, long r) 
{
   long q;

   if (p < r)
   {
      q = Partition(A, p, r);
      SortIndices(A, p, q-1);
      SortIndices(A, q+1, r);		
   }
}
Пример #3
0
void CalculateRadii(vtkPolyData* mesh, const arma::sp_mat& edge_lengths, arma::vec& radii) {
    const int npts = mesh->GetNumberOfPoints();
    const int ncells = mesh->GetNumberOfCells();
    radii.set_size(npts);

    vtkSmartPointer<vtkIdList> cellIdList = vtkSmartPointer<vtkIdList>::New();
    vtkSmartPointer<vtkIdList> pointIdList = vtkSmartPointer<vtkIdList>::New();

    //for every face calculate gamma_ijk
    arma::vec gamma_percell(ncells);
    for (vtkIdType i = 0; i < ncells; i++) {
        pointIdList->Reset();
        mesh->GetCellPoints(cellIdList->GetId(i), pointIdList);

//!!!        assert(pointIdList->GetNumberOfIds() == 3);

        int ind_i = pointIdList->GetId(0);
        int ind_j = pointIdList->GetId(1);
        int ind_k = pointIdList->GetId(2);

        SortIndices(i, ind_i, ind_j, ind_k);

        const double l_ij = edge_lengths(ind_i, ind_j);
        const double l_ki = edge_lengths(ind_k, ind_i);
        const double l_jk = edge_lengths(ind_j, ind_k);

        gamma_percell(i) = (l_ij + l_ki - l_jk) / 2;
    }

    //for every vertex get minimum gamma    
    for (vtkIdType i = 0; i < npts; i++) {
        cellIdList->Reset();
        mesh->GetPointCells(i, cellIdList);

        radii(i) = DBL_MAX;
        for (vtkIdType j = 0; j < cellIdList->GetNumberOfIds(); j++) {
            if (gamma_percell(j) < radii(i)) radii(i) = gamma_percell(j); //get minimum of gammas from surrounding cells
        }
    }

}
Пример #4
0
void CalculateFaceAnglesE2(vtkPolyData* mesh, const arma::vec& edge_lengths, arma::vec& angles) {
    const int ncells = mesh->GetNumberOfCells();
    angles.set_size(ncells);

    vtkSmartPointer<vtkIdList> pointIdList = vtkSmartPointer<vtkIdList>::New();

    for (vtkIdType i = 0; i < ncells; i++) {
        pointIdList->Reset();
        mesh->GetCellPoints(i, pointIdList);

        int ind_i = pointIdList->GetId(0);
        int ind_j = pointIdList->GetId(1);
        int ind_k = pointIdList->GetId(2);

        SortIndices(i, ind_i, ind_j, ind_k);

        const int l_ij = edge_lengths(ind_i, ind_j);
        const int l_ki = edge_lengths(ind_k, ind_i);
        const int l_kj = edge_lengths(ind_k, ind_j);

        angles(i) = acos((l_ij * l_ij + l_ki * l_ki - l_kj * l_kj) / (2 * l_ki * l_ij));
    }
}
Пример #5
0
std::vector<int> StreamPower::Indexx(std::vector<double>& arr)
{
	return SortIndices(arr);
}