Commit db4c9ac6b4ab0c37370488766332dc457ecd7e9f

Authored by Rémi Cresson (IRSTEA)
2 parents 9ef7c889 686636ec
Exists in master

Merge branch 'msbuild_portability'

Conflicts:
	include/grmGraphOperations.txx
include/grmGraph.h
... ... @@ -43,7 +43,7 @@ namespace grm
43 43 Node is identified by the location
44 44 of the first pixel of the region.
45 45 */
46   - long unsigned int m_Id;
  46 + std::size_t m_Id;
47 47  
48 48 /*
49 49 Bounding box of the region
... ... @@ -77,7 +77,6 @@ namespace grm
77 77 return ptr;
78 78 }
79 79 };
80   -
81 80  
82 81 template<class DerivedNode>
83 82 struct Node : BaseNode
... ...
include/grmGraphOperations.txx
... ... @@ -39,7 +39,7 @@ namespace grm
39 39 {
40 40 for(auto& r : seg.m_Graph.m_Nodes)
41 41 {
42   - long int neighborhood[4];
  42 + NeighIDType neighborhood[4];
43 43 FOURNeighborhood(neighborhood, r->m_Id, width, height);
44 44 for(short j = 0; j < 4; ++j)
45 45 {
... ... @@ -53,7 +53,7 @@ namespace grm
53 53 {
54 54 for(auto& r : seg.m_Graph.m_Nodes)
55 55 {
56   - long int neighborhood[8];
  56 + NeighIDType neighborhood[8];
57 57 EIGHTNeighborhood(neighborhood, r->m_Id, width, height);
58 58 bool haveNeighbors = false;
59 59 for(short j = 0; j < 8; ++j)
... ... @@ -79,7 +79,7 @@ namespace grm
79 79 void GraphOperations<TSegmenter>::UpdateMergingCosts(SegmenterType& seg)
80 80 {
81 81 float min_cost;
82   - long unsigned int min_id = 0;
  82 + std::size_t min_id = 0;
83 83 std::size_t idx, min_idx;
84 84  
85 85 for(auto& r : seg.m_Graph.m_Nodes)
... ... @@ -145,21 +145,21 @@ namespace grm
145 145 typename GraphOperations<TSegmenter>::NodePointerType
146 146 GraphOperations<TSegmenter>::CheckLMBF(NodePointerType a, float t)
147 147 {
148   - // TO FIX: if no-data are present within the image, an edgeless node is possible
149   - // Here we check if the list of edges is empty prior to cost check.
150   - // if(a->m_Valid)
151   - if(a->m_Valid && a->m_Edges.size() > 0)
  148 + // TO FIX: if no-data are present within the image, an edgeless node is possible
  149 + // Here we check if the list of edges is empty prior to cost check.
  150 + // if(a->m_Valid)
  151 + if(a->m_Valid && a->m_Edges.size() > 0)
152 152 {
153 153 float cost = a->m_Edges.front().m_Cost;
154 154  
155 155 if(cost < t)
156 156 {
157 157 NodePointerType b = a->m_Edges.front().GetRegion();
158   -
  158 +
159 159 if( b->m_Valid)
160 160 {
161 161 NodePointerType best_b = b->m_Edges.front().GetRegion();
162   -
  162 +
163 163 if(a == best_b)
164 164 {
165 165 if(a->m_Id < b->m_Id)
... ... @@ -177,10 +177,10 @@ namespace grm
177 177 typename GraphOperations<TSegmenter>::NodePointerType
178 178 GraphOperations<TSegmenter>::CheckBF(NodePointerType a, float t)
179 179 {
180   - // TO FIX: if no-data are present within the image, an edgeless node is possible
181   - // Here we check if the list of edges is empty prior to cost check.
182   - // if(a->m_Valid)
183   - if(a->m_Valid && a->m_Edges.size() > 0)
  180 + // TO FIX: if no-data are present within the image, an edgeless node is possible
  181 + // Here we check if the list of edges is empty prior to cost check.
  182 + // if(a->m_Valid)
  183 + if(a->m_Valid && a->m_Edges.size() > 0)
184 184 {
185 185 float cost = a->m_Edges.front().m_Cost;
186 186  
... ... @@ -324,7 +324,7 @@ namespace grm
324 324  
325 325 /* Update the costs of merging between adjacent nodes */
326 326 UpdateMergingCosts(seg);
327   -
  327 +
328 328 for(auto& region : seg.m_Graph.m_Nodes)
329 329 {
330 330  
... ... @@ -418,7 +418,7 @@ namespace grm
418 418 {
419 419 bool merged = false;
420 420  
421   - std::vector<long unsigned int> randomIndices(seg.m_Graph.m_Nodes.size());
  421 + std::vector<std::size_t> randomIndices(seg.m_Graph.m_Nodes.size());
422 422 std::iota(randomIndices.begin(), randomIndices.end(), 0);
423 423 std::shuffle(randomIndices.begin(), randomIndices.end(), std::mt19937{std::random_device{}()});
424 424  
... ...
include/grmNeighborhood.h
... ... @@ -18,17 +18,25 @@
18 18 #ifndef GRM_NEIGHBORHOOD_H
19 19 #define GRM_NEIGHBORHOOD_H
20 20  
  21 +#include <cstddef>
  22 +
  23 +#if defined(_WIN32)
  24 +typedef __int64 NeighIDType;
  25 +#else
  26 +typedef long int NeighIDType;
  27 +#endif
  28 +
21 29 enum CONNECTIVITY{FOUR = 0, EIGHT};
22 30  
23 31 namespace grm
24 32 {
25   - void FOURNeighborhood(long int * neighborhood,
26   - const long unsigned int id,
  33 + void FOURNeighborhood(NeighIDType * neighborhood,
  34 + const std::size_t id,
27 35 const unsigned int width,
28 36 const unsigned int height);
29 37  
30   - void EIGHTNeighborhood(long int * neighborhood,
31   - const long unsigned int id,
  38 + void EIGHTNeighborhood(NeighIDType * neighborhood,
  39 + const std::size_t id,
32 40 const unsigned int width,
33 41 const unsigned int height);
34 42 } // end of namespace grm
... ...
include/grmSegmenter.h
... ... @@ -129,7 +129,7 @@ namespace grm
129 129 this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
130 130 this->m_NumberOfComponentsPerPixel = this->m_InputImage->GetNumberOfComponentsPerPixel();
131 131  
132   - const long unsigned int num_nodes = this->m_ImageWidth * this->m_ImageHeight;
  132 + const std::size_t num_nodes = this->m_ImageWidth * this->m_ImageHeight;
133 133 this->m_Graph.m_Nodes.reserve(num_nodes);
134 134  
135 135 std::vector<bool> noDataFlags;
... ... @@ -163,7 +163,6 @@ namespace grm
163 163  
164 164 this->m_Graph.m_Nodes.push_back(n);
165 165 ++idx;
166   -
167 166 }
168 167 }
169 168  
... ...
src/grmNeighborhood.cxx
... ... @@ -19,13 +19,13 @@
19 19  
20 20 namespace grm
21 21 {
22   - void FOURNeighborhood(long int * neighborhood,
23   - const long unsigned int id,
  22 + void FOURNeighborhood(NeighIDType * neighborhood,
  23 + const std::size_t id,
24 24 const unsigned int width,
25 25 const unsigned int height)
26 26 {
27   - const unsigned int x = id % width;
28   - const unsigned int y = id / width;
  27 + const std::size_t x = id % width;
  28 + const std::size_t y = id / width;
29 29  
30 30 /* top */
31 31 neighborhood[0] = ( y > 0 ? (id - width) : -1 );
... ... @@ -40,13 +40,13 @@ namespace grm
40 40 neighborhood[3] = ( x > 0 ? (id - 1) : -1 );
41 41 }
42 42  
43   - void EIGHTNeighborhood(long int * neighborhood,
44   - const long unsigned int id,
  43 + void EIGHTNeighborhood(NeighIDType * neighborhood,
  44 + const std::size_t id,
45 45 const unsigned int width,
46 46 const unsigned int height)
47 47 {
48   - const unsigned int x = id % width;
49   - const unsigned int y = id / width;
  48 + const std::size_t x = id % width;
  49 + const std::size_t y = id / width;
50 50  
51 51 /* top */
52 52 neighborhood[0] = ( y > 0 ? (id - width) : -1 );
... ...