[Bf-blender-cvs] [4a7ec6d9eb8] temp-geometry-nodes-distribute-points-cleanup: Remove template from cyHeap.h

Dalai Felinto noreply at git.blender.org
Fri Dec 11 12:32:50 CET 2020


Commit: 4a7ec6d9eb873ee43df10896f090a3e879984026
Author: Dalai Felinto
Date:   Fri Dec 11 12:05:50 2020 +0100
Branches: temp-geometry-nodes-distribute-points-cleanup
https://developer.blender.org/rB4a7ec6d9eb873ee43df10896f090a3e879984026

Remove template from cyHeap.h

===================================================================

M	source/blender/nodes/geometry/nodes/cyHeap.h
M	source/blender/nodes/geometry/nodes/cySampleElim.hh

===================================================================

diff --git a/source/blender/nodes/geometry/nodes/cyHeap.h b/source/blender/nodes/geometry/nodes/cyHeap.h
index b731868eddc..265c29b9e4b 100644
--- a/source/blender/nodes/geometry/nodes/cyHeap.h
+++ b/source/blender/nodes/geometry/nodes/cyHeap.h
@@ -51,7 +51,7 @@ namespace cy {
 //!
 //! The main data can be kept in an external array or within the Heap class.
 
-template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
+class Heap {
  public:
   //////////////////////////////////////////////////////////////////////////!//!//!
   //!@name Constructor and Destructor
@@ -81,12 +81,12 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   }
 
   //! Copies the main data items from an array into the internal storage of this class.
-  void CopyData(DATA_TYPE const *items, SIZE_TYPE itemCount)
+  void CopyData(float const *items, size_t itemCount)
   {
     ClearData();
     size = itemCount;
-    data = new DATA_TYPE[size];
-    for (SIZE_TYPE i = 0; i < size; i++)
+    data = new float[size];
+    for (size_t i = 0; i < size; i++)
       data[i] = items[i];
     deleteData = true;
   }
@@ -97,7 +97,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! The given items pointer still points to the same data, but the class claims
   //! ownership of the data. Therefore, when the class object is deleted, the data
   //! items are deleted as well. If this is not desirable, use SetDataPointer.
-  void MoveData(DATA_TYPE *items, SIZE_TYPE itemCount)
+  void MoveData(float *items, size_t itemCount)
   {
     ClearData();
     data = items;
@@ -111,7 +111,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! of the data. Therefore, it does not deallocate memory used for the main data
   //! when it is deleted, and the data items must be deleted externally.
   //! However, the data items must NOT be deleted while an object of this class is used.
-  void SetDataPointer(DATA_TYPE *items, SIZE_TYPE itemCount)
+  void SetDataPointer(float *items, size_t itemCount)
   {
     ClearData();
     data = items;
@@ -126,15 +126,15 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   {
     ClearHeap();
     heapItemCount = size;
-    heap = new SIZE_TYPE[size + 1];
-    heapPos = new SIZE_TYPE[size];
-    for (SIZE_TYPE i = 0; i < heapItemCount; i++)
+    heap = new size_t[size + 1];
+    heapPos = new size_t[size];
+    for (size_t i = 0; i < heapItemCount; i++)
       heapPos[i] = i + 1;
-    for (SIZE_TYPE i = 1; i <= heapItemCount; i++)
+    for (size_t i = 1; i <= heapItemCount; i++)
       heap[i] = i - 1;
     if (heapItemCount <= 1)
       return;
-    for (SIZE_TYPE ix = heapItemCount / 2; ix > 0; ix--)
+    for (size_t ix = heapItemCount / 2; ix > 0; ix--)
       HeapMoveDown(ix);
   }
 
@@ -142,7 +142,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //!@name Access and manipulation methods
 
   //! Returns the item from the main data with the given id.
-  DATA_TYPE const &GetItem(SIZE_TYPE id) const
+  float const &GetItem(size_t id) const
   {
     assert(id < size);
     return data[id];
@@ -151,7 +151,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! Sets the item with the given id and updates the heap structure accordingly.
   //! Returns false if the item is not in the heap anymore (removed by Pop) or if its heap position
   //! is not changed.
-  bool SetItem(SIZE_TYPE id, DATA_TYPE const &item)
+  bool SetItem(size_t id, float const &item)
   {
     assert(id < size);
     data[id] = item;
@@ -162,7 +162,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! This method is useful for fixing the heap position after an item is modified externally.
   //! Returns false if the item is not in the heap anymore (removed by Pop) or if its heap position
   //! is not changed.
-  bool MoveItem(SIZE_TYPE id)
+  bool MoveItem(size_t id)
   {
     return HeapOrder(heapPos[id]);
   }
@@ -171,7 +171,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! This method is useful for fixing the heap position after an item is modified externally to
   //! increase its priority. Returns false if the item is not in the heap anymore (removed by Pop)
   //! or if its heap position is not changed.
-  bool MoveItemUp(SIZE_TYPE id)
+  bool MoveItemUp(size_t id)
   {
     return HeapMoveUp(heapPos[id]);
   }
@@ -180,20 +180,20 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! This method is useful for fixing the heap position after an item is modified externally to
   //! decrease its priority. Returns false if the item is not in the heap anymore (removed by Pop)
   //! or if its heap position is not changed.
-  bool MoveItemDown(SIZE_TYPE id)
+  bool MoveItemDown(size_t id)
   {
     return HeapMoveDown(heapPos[id]);
   }
 
   //! Returns if the item with the given id is in the heap or removed by Pop.
-  bool IsInHeap(SIZE_TYPE id) const
+  bool IsInHeap(size_t id) const
   {
     assert(id < size);
     return heapPos[id] <= heapItemCount;
   }
 
   //! Returns the number of items in the heap.
-  SIZE_TYPE NumItemsInHeap() const
+  size_t NumItemsInHeap() const
   {
     return heapItemCount;
   }
@@ -201,7 +201,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! Returns the item from the heap with the given heap position.
   //! Note that items that are removed from the heap appear in the inverse order
   //! with which they were removed after the last item in the heap.
-  DATA_TYPE const &GetFromHeap(SIZE_TYPE heapIndex) const
+  float const &GetFromHeap(size_t heapIndex) const
   {
     assert(heapIndex < size);
     return data[heap[heapIndex + 1]];
@@ -210,21 +210,21 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! Returns the id of the item from the heap with the given heap position.
   //! Note that items that are removed from the heap appear in the inverse order
   //! with which they were removed after the last item in the heap.
-  SIZE_TYPE GetIDFromHeap(SIZE_TYPE heapIndex) const
+  size_t GetIDFromHeap(size_t heapIndex) const
   {
     assert(heapIndex < size);
     return heap[heapIndex + 1];
   }
 
   //! Returns the item at the top of the heap.
-  DATA_TYPE const &GetTopItem() const
+  float const &GetTopItem() const
   {
     assert(size >= 1);
     return data[heap[1]];
   }
 
   //! Returns the id of the item at the top of the heap.
-  SIZE_TYPE GetTopItemID() const
+  size_t GetTopItemID() const
   {
     assert(size >= 1);
     return heap[1];
@@ -233,7 +233,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //! Removes and returns the item at the top of the heap.
   //! The removed item is not deleted, but it is removed from the heap
   //! by placing it right after the last item in the heap.
-  void Pop(DATA_TYPE &item)
+  void Pop(float &item)
   {
     Pop();
     item = data[heap[heapItemCount]];
@@ -253,12 +253,12 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   //////////////////////////////////////////////////////////////////////////!//!//!
   //!@name Internal structures and methods
 
-  DATA_TYPE *data;          // The main data pointer.
-  SIZE_TYPE *heap;          // The heap array, keeping the id of each data item.
-  SIZE_TYPE *heapPos;       // The heap position of each item.
-  SIZE_TYPE heapItemCount;  // The number of items in the heap.
-  SIZE_TYPE size;           // The total item count, including the ones removed from the heap.
-  bool deleteData;          // Determines whether the data pointer owns the memory it points to.
+  float *data;           // The main data pointer.
+  size_t *heap;          // The heap array, keeping the id of each data item.
+  size_t *heapPos;       // The heap position of each item.
+  size_t heapItemCount;  // The number of items in the heap.
+  size_t size;           // The total item count, including the ones removed from the heap.
+  bool deleteData;       // Determines whether the data pointer owns the memory it points to.
 
   // Clears the data pointer and deallocates memory if the data is owned.
   void ClearData()
@@ -282,7 +282,7 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
 
   // Checks if the item should be moved.
   // Returns true if the item is in the heap.
-  bool HeapOrder(SIZE_TYPE ix)
+  bool HeapOrder(size_t ix)
   {
     if (ix > heapItemCount)
       return false;
@@ -292,11 +292,11 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   }
 
   // Checks if the item should be moved up, returns true if the item is moved.
-  bool HeapMoveUp(SIZE_TYPE ix)
+  bool HeapMoveUp(size_t ix)
   {
-    SIZE_TYPE org = ix;
+    size_t org = ix;
     while (ix >= 2) {
-      SIZE_TYPE parent = ix / 2;
+      size_t parent = ix / 2;
       if (!IsSmaller(parent, ix))
         break;
       SwapItems(parent, ix);
@@ -306,10 +306,10 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   }
 
   // Checks if the item should be moved down, returns true if the item is moved.
-  bool HeapMoveDown(SIZE_TYPE ix)
+  bool HeapMoveDown(size_t ix)
   {
-    SIZE_TYPE org = ix;
-    SIZE_TYPE child = ix * 2;
+    size_t org = ix;
+    size_t child = ix * 2;
     while (child + 1 <= heapItemCount) {
       if (IsSmaller(child, child + 1))
         child++;
@@ -330,15 +330,15 @@ template<typename DATA_TYPE, typename SIZE_TYPE = size_t> class Heap {
   }
 
   // Returns if the item at ix1 is smaller than the one at ix2.
-  bool IsSmaller(SIZE_TYPE ix1, SIZE_TYPE ix2)
+  bool IsSmaller(size_t ix1, size_t ix2)
   {
     return data[heap[ix1]] < data[heap[ix2]];
   }
 
   // Swaps the heap positions of items at ix1 and ix2.
-  void SwapItems(SIZE_TYPE ix1, SIZE_TYPE ix2)
+  void SwapItems(size_t ix1, size_t ix2)
   {
-    SIZE_TYPE t = heap[ix1];
+    size_t t = heap[ix1];
     heap[ix1] = heap[ix2];
     heap[ix2] = t;
     heapPos[heap[ix1]] = ix1;
diff --git a/source/blender/nodes/geometry/nodes/cySampleElim.hh b/source/blender/nodes/geometry/nodes/cySampleElim.hh
index

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list