Xmipp  v3.23.11-Nereus
Functions
sorting.h File Reference
#include "dcel.h"
Include dependency graph for sorting.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void sort (struct DCEL_T *dcel)
 
void clutter (struct DCEL_T *dcel)
 
void set_Highest_First (struct DCEL_T *dcel, int(*f)(struct Point_T *, struct Point_T *))
 

Function Documentation

◆ clutter()

void clutter ( struct DCEL_T dcel)

Definition at line 32 of file sorting.cpp.

33 {
34  int i=0; // Loop counter.
35  int index1=0, index2=0; // Array indexes.
36 
37  // Set seed.
38  srand(time(NULL));
39 
40  // Loop set of points.
41  for (i=0; i<dcel->nVertex ;i++)
42  {
43  // Generate random indexes to swap.
44  index1 = rand() % dcel->nVertex;
45  index2 = rand() % dcel->nVertex;
46 
47  // Swap elements.
48  swap_Vertex( dcel, index1, index2);
49  }
50 }
#define i
int nVertex
Definition: dcel.h:55
int swap_Vertex(struct DCEL_T *dcel, int index1, int index2)
Definition: dcel.cpp:838

◆ set_Highest_First()

void set_Highest_First ( struct DCEL_T dcel,
int(*)(struct Point_T *, struct Point_T *)  f 
)

Definition at line 52 of file sorting.cpp.

53 {
54  int i=0; // Loop counter.
55  int length=0; // Number of vertexes in DCEL.
56  int highest_Index=0; // Index of highest point.
57 
58  // Get number of vertexes.
59  length = get_Number_Vertex( dcel);
60  highest_Index=0;
61 
62  // Find index of highest point.
63  for (i=1; i<length ;i++)
64  {
65  if ((*f) ( &dcel->vertex[i].vertex, &dcel->vertex[highest_Index].vertex))
66  {
67  highest_Index = i;
68  }
69  }
70 
71  // Swap highest vertex and vertex at position 0.
72  swap_Vertex( dcel, 0, highest_Index);
73 
74 #ifdef DEBUG_SORTING
75  printf("Highest point at position %d.", highest_Index);
76  print_Point( &dcel->vertex[0].vertex);
77  fflush(NULL);
78 #endif
79 }
#define i
int get_Number_Vertex(struct DCEL_T *dcel)
Definition: dcel.cpp:638
void print_Point(struct Point_T *point)
Definition: point.cpp:67
double * f
__host__ __device__ float length(float2 v)
struct Dcel_Vertex_T * vertex
Definition: dcel.h:57
struct Point_T vertex
Definition: dcel.h:32
int swap_Vertex(struct DCEL_T *dcel, int index1, int index2)
Definition: dcel.cpp:838

◆ sort()

void sort ( struct DCEL_T dcel)

Definition at line 18 of file sorting.cpp.

19 {
20  // Call quicksort with DCEL structure.
21  quicksort( &dcel->vertex[0], &dcel->vertex[1], 0, dcel->nVertex-2);
22 }
void quicksort(struct Dcel_Vertex_T *origin, struct Dcel_Vertex_T *list, int init_Index, int final_Index)
Definition: sorting.cpp:124
struct Dcel_Vertex_T * vertex
Definition: dcel.h:57
int nVertex
Definition: dcel.h:55