Changeset 64:046379da1097 in rrlib_geometry


Ignore:
Timestamp:
07.01.2014 14:09:38 (6 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
13.10
Children:
65:b4f7906764d3, 66:bbb9483fe715
Phase:
public
Message:

Replaced array size by const value and variable-length-arrays by std::vector

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • curves/tBezierCurve.hpp

    r60 r64  
    127127const typename tBezierCurve<Tdimension, TElement, Tdegree>::tSubdivision tBezierCurve<Tdimension, TElement, Tdegree>::GetSubdivision() const 
    128128{ 
    129   typename tShape::tPoint left_half[this->NumberOfControlPoints()]; 
    130   typename tShape::tPoint right_half[this->NumberOfControlPoints()]; 
    131   typename tShape::tPoint temp_points[this->NumberOfControlPoints()]; 
    132   std::memcpy(temp_points, this->control_points, this->NumberOfControlPoints() * sizeof(typename tShape::tPoint)); 
     129  const size_t cNUMBER_OF_CONTROL_POINTS = Tdegree + 1; 
     130  typename tShape::tPoint left_half[cNUMBER_OF_CONTROL_POINTS]; 
     131  typename tShape::tPoint right_half[cNUMBER_OF_CONTROL_POINTS]; 
     132  typename tShape::tPoint temp_points[cNUMBER_OF_CONTROL_POINTS]; 
     133  std::memcpy(temp_points, this->control_points, cNUMBER_OF_CONTROL_POINTS * sizeof(typename tShape::tPoint)); 
    133134 
    134135  left_half[0] = temp_points[0]; 
     
    147148  } 
    148149 
    149   return std::make_pair(tBezierCurve(left_half, left_half + this->NumberOfControlPoints()), tBezierCurve(right_half, right_half + this->NumberOfControlPoints())); 
     150  return std::make_pair(tBezierCurve(left_half, left_half + cNUMBER_OF_CONTROL_POINTS), tBezierCurve(right_half, right_half + cNUMBER_OF_CONTROL_POINTS)); 
    150151} 
    151152 
     
    158159  assert((0.0 <= t) && (t <= 1.0)); 
    159160 
    160   typename tShape::tPoint temp_points[this->NumberOfControlPoints()]; 
    161   std::memcpy(temp_points, this->control_points, (this->NumberOfControlPoints()) * sizeof(typename tShape::tPoint)); 
     161  const size_t cNUMBER_OF_CONTROL_POINTS = Tdegree + 1; 
     162  typename tShape::tPoint temp_points[cNUMBER_OF_CONTROL_POINTS]; 
     163  std::memcpy(temp_points, this->control_points, cNUMBER_OF_CONTROL_POINTS * sizeof(typename tShape::tPoint)); 
    162164 
    163165  size_t k = 0; 
  • test/test_kd_tree.cpp

    r60 r64  
    157157    std::normal_distribution<tElement> distribution_x; 
    158158    std::normal_distribution<tElement> distribution_y; 
    159   } clusters[number_of_clusters]; 
     159  }; 
     160  std::vector<tCluster> clusters(number_of_clusters); 
    160161 
    161162  auto random_cluster_center_component = std::bind(std::uniform_real_distribution<tElement>(-0.5 * cWINDOW_SIZE, 0.5 * cWINDOW_SIZE), rng_engine); 
Note: See TracChangeset for help on using the changeset viewer.