43                                                  float far_clipping_plane_distance)
 
   46   , far_clipping_plane_distance_(far_clipping_plane_distance)
 
   47   , near_clipping_plane_distance_(near_clipping_plane_distance)
 
   62     throw std::runtime_error(
"Near clipping plane distance needs to be larger than zero!");
 
   65     throw std::runtime_error(
"Far clipping plane distance must be larger than the near clipping plane distance!");
 
   67   near_clipping_plane_distance_ = near;
 
   68   far_clipping_plane_distance_ = far;
 
   83   return near_clipping_plane_distance_;
 
   88   return far_clipping_plane_distance_;
 
   93 #if HAVE_SSE_EXTENSIONS 
   94 inline unsigned alignment16(
const void* pointer)
 
   96   return ((uintptr_t)pointer & 15);
 
   98 inline bool isAligned16(
const void* pointer)
 
  100   return (((uintptr_t)pointer & 15) == 0);
 
  107 #if HAVE_SSE_EXTENSIONS 
  108   const __m128 mmNear = _mm_set1_ps(near_clipping_plane_distance_);
 
  109   const __m128 mmFar = _mm_set1_ps(far_clipping_plane_distance_);
 
  110   const __m128 mmNF = _mm_mul_ps(mmNear, mmFar);
 
  111   const __m128 mmF_N = _mm_sub_ps(mmFar, mmNear);
 
  112   static const __m128 mmOnes = _mm_set1_ps(1);
 
  113   static const __m128 mmZeros = _mm_set1_ps(0);
 
  115   float* depthEnd = depth + width_ * height_;
 
  116   if (!isAligned16(depth))
 
  119     unsigned first = 16 - alignment16(depth);
 
  121     const float near = near_clipping_plane_distance_;
 
  122     const float far = far_clipping_plane_distance_;
 
  123     const float nf = near * far;
 
  124     const float f_n = far - near;
 
  126     while (depth < depthEnd && idx++ < first)
 
  127       if (*depth != 0 && *depth != 1)
 
  128         *depth = nf / (far - *depth * f_n);
 
  133     unsigned last = (width_ * height_ - first) & 15;
 
  134     float* depth2 = depthEnd - last;
 
  135     while (depth2 < depthEnd)
 
  136       if (*depth2 != 0 && *depth2 != 1)
 
  137         *depth2 = nf / (far - *depth2 * f_n);
 
  144   const __m128* mmEnd = (__m128*)depthEnd;
 
  145   __m128* mmDepth = (__m128*)depth;
 
  147   while (mmDepth < mmEnd)
 
  149     __m128 mask = _mm_and_ps(_mm_cmpneq_ps(*mmDepth, mmOnes), _mm_cmpneq_ps(*mmDepth, mmZeros));
 
  150     *mmDepth = _mm_mul_ps(*mmDepth, mmF_N);
 
  151     *mmDepth = _mm_sub_ps(mmFar, *mmDepth);
 
  152     *mmDepth = _mm_div_ps(mmNF, *mmDepth);
 
  153     *mmDepth = _mm_and_ps(*mmDepth, mask);
 
  159   const float near = near_clipping_plane_distance_;
 
  160   const float far = far_clipping_plane_distance_;
 
  161   const float nf = near * far;
 
  162   const float f_n = far - near;
 
  164   const float* depth_end = depth + width_ * height_;
 
  165   while (depth < depth_end)
 
  167     if (*depth != 0 && *depth != 1)
 
  168       *depth = nf / (far - *depth * f_n);
 
  179 #if HAVE_SSE_EXTENSIONS 
  181   const __m128 mmNear = _mm_set1_ps(near_clipping_plane_distance_);
 
  182   const __m128 mmFar = _mm_set1_ps(far_clipping_plane_distance_);
 
  183   const __m128 mmScale = _mm_sub_ps(mmFar, mmNear);
 
  184   float* depthEnd = depth + width_ * height_;
 
  186   if (!isAligned16(depth))
 
  189     unsigned first = 16 - alignment16(depth);
 
  191     const float scale = far_clipping_plane_distance_ - near_clipping_plane_distance_;
 
  192     const float offset = near_clipping_plane_distance_;
 
  193     while (depth < depthEnd && idx++ < first)
 
  194       if (*depth != 0 && *depth != 1.0)
 
  195         *depth = *depth * scale + offset;
 
  200     unsigned last = (width_ * height_ - first) & 15;
 
  201     float* depth2 = depthEnd - last;
 
  202     while (depth2 < depthEnd)
 
  203       if (*depth2 != 0 && *depth != 1.0)
 
  204         *depth2 = *depth2 * scale + offset;
 
  211   const __m128* mmEnd = (__m128*)depthEnd;
 
  212   __m128* mmDepth = (__m128*)depth;
 
  214   while (mmDepth < mmEnd)
 
  216     *mmDepth = _mm_mul_ps(*mmDepth, mmScale);
 
  217     *mmDepth = _mm_add_ps(*mmDepth, mmNear);
 
  218     *mmDepth = _mm_and_ps(*mmDepth, _mm_and_ps(_mm_cmpneq_ps(*mmDepth, mmNear), _mm_cmpneq_ps(*mmDepth, mmFar)));
 
  222   const float* depth_end = depth + width_ * height_;
 
  223   const float scale = far_clipping_plane_distance_ - near_clipping_plane_distance_;
 
  224   const float offset = near_clipping_plane_distance_;
 
  225   while (depth < depth_end)
 
  229     if (*depth != 0 && *depth != 1.0)
 
  230       *depth = *depth * scale + offset;
 
void setDepthRange(float near, float far)
sets the clipping range
 
void setImageSize(unsigned width, unsigned height)
sets the image size
 
unsigned getHeight() const
returns the height of depth maps
 
float getNearClippingPlaneDistance() const
returns distance to the near clipping plane
 
virtual void transformModelDepthToMetricDepth(float *depth) const
transforms depth values from rendered model to metric depth values
 
virtual ~Parameters()
virtual destructor
 
unsigned getWidth() const
returns the width of depth maps
 
virtual void transformFilteredDepthToMetricDepth(float *depth) const
transforms depth values from filtered depth to metric depth values
 
Parameters(unsigned width, unsigned height, float near_clipping_plane_distance, float far_clipping_plane_distance)
Constructor taking core parameters that are required for all sensors.
 
float getFarClippingPlaneDistance() const
returns the distance to the far clipping plane
 
virtual ~SensorModel()
virtual destructor