Skip to content

Commit

Permalink
Remove outdated Boost version checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
vcarpani committed Jan 25, 2019
1 parent 192e6d2 commit b238924
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 84 deletions.
26 changes: 5 additions & 21 deletions common/include/pcl/common/impl/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
template <typename T>
pcl::common::UniformGenerator<T>::UniformGenerator(T min, T max, pcl::uint32_t seed)
: distribution_ (min, max)
, generator_ (rng_, distribution_)
, generator_ (rng_, distribution_)
{
parameters_ = Parameters (min, max, seed);
if(parameters_.seed != -1)
Expand All @@ -60,7 +60,7 @@ template <typename T>
pcl::common::UniformGenerator<T>::UniformGenerator(const Parameters& parameters)
: parameters_ (parameters)
, distribution_ (parameters_.min, parameters_.max)
, generator_ (rng_, distribution_)
, generator_ (rng_, distribution_)
{
if(parameters_.seed != -1)
rng_.seed (parameters_.seed);
Expand All @@ -84,12 +84,8 @@ pcl::common::UniformGenerator<T>::setParameters (T min, T max, pcl::uint32_t see
parameters_.min = min;
parameters_.max = max;
parameters_.seed = seed;
#if BOOST_VERSION >= 104700
typename DistributionType::param_type params (parameters_.min, parameters_.max);
distribution_.param (params);
#else
distribution_ = DistributionType (parameters_.min, parameters_.max);
#endif
distribution_.reset ();
generator_.distribution () = distribution_;
if (seed != -1)
Expand All @@ -104,12 +100,8 @@ template <typename T> void
pcl::common::UniformGenerator<T>::setParameters (const Parameters& parameters)
{
parameters_ = parameters;
#if BOOST_VERSION >= 104700
typename DistributionType::param_type params (parameters_.min, parameters_.max);
distribution_.param (params);
#else
distribution_ = DistributionType (parameters_.min, parameters_.max);
#endif
distribution_.reset ();
generator_.distribution () = distribution_;
if (parameters_.seed != -1)
Expand All @@ -120,7 +112,7 @@ pcl::common::UniformGenerator<T>::setParameters (const Parameters& parameters)
template <typename T>
pcl::common::NormalGenerator<T>::NormalGenerator(T mean, T sigma, pcl::uint32_t seed)
: distribution_ (mean, sigma)
, generator_ (rng_, distribution_)
, generator_ (rng_, distribution_)
{
parameters_ = Parameters (mean, sigma, seed);
if(parameters_.seed != -1)
Expand All @@ -133,7 +125,7 @@ template <typename T>
pcl::common::NormalGenerator<T>::NormalGenerator(const Parameters& parameters)
: parameters_ (parameters)
, distribution_ (parameters_.mean, parameters_.sigma)
, generator_ (rng_, distribution_)
, generator_ (rng_, distribution_)
{
if(parameters_.seed != -1)
rng_.seed (parameters_.seed);
Expand All @@ -142,7 +134,7 @@ pcl::common::NormalGenerator<T>::NormalGenerator(const Parameters& parameters)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename T> void
pcl::common::NormalGenerator<T>::setSeed (pcl::uint32_t seed)
{
{
if (seed != -1)
{
parameters_.seed = seed;
Expand All @@ -157,12 +149,8 @@ pcl::common::NormalGenerator<T>::setParameters (T mean, T sigma, pcl::uint32_t s
parameters_.mean = mean;
parameters_.sigma = sigma;
parameters_.seed = seed;
#if BOOST_VERSION >= 104700
typename DistributionType::param_type params (parameters_.mean, parameters_.sigma);
distribution_.param (params);
#else
distribution_ = DistributionType (parameters_.mean, parameters_.sigma);
#endif
distribution_.reset ();
generator_.distribution () = distribution_;
if (seed != -1)
Expand All @@ -174,12 +162,8 @@ template <typename T> void
pcl::common::NormalGenerator<T>::setParameters (const Parameters& parameters)
{
parameters_ = parameters;
#if BOOST_VERSION >= 104700
typename DistributionType::param_type params (parameters_.mean, parameters_.sigma);
distribution_.param (params);
#else
distribution_ = DistributionType (parameters_.mean, parameters_.sigma);
#endif
distribution_.reset ();
generator_.distribution () = distribution_;
if (parameters_.seed != -1)
Expand Down
16 changes: 5 additions & 11 deletions common/src/time_trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pcl::TimeTrigger::~TimeTrigger ()
quit_ = true;
condition_.notify_all (); // notify all threads about updated quit_
lock.unlock (); // unlock, to join all threads (needs to be done after notify_all)

timer_thread_.join ();
}

Expand All @@ -85,7 +85,7 @@ pcl::TimeTrigger::registerCallback (const callback_type& callback)
}

//////////////////////////////////////////////////////////////////////////////////////////////
void
void
pcl::TimeTrigger::setInterval (double interval_seconds)
{
boost::unique_lock<boost::mutex> lock (condition_mutex_);
Expand All @@ -95,7 +95,7 @@ pcl::TimeTrigger::setInterval (double interval_seconds)
}

//////////////////////////////////////////////////////////////////////////////////////////////
void
void
pcl::TimeTrigger::start ()
{
boost::unique_lock<boost::mutex> lock (condition_mutex_);
Expand All @@ -107,7 +107,7 @@ pcl::TimeTrigger::start ()
}

//////////////////////////////////////////////////////////////////////////////////////////////
void
void
pcl::TimeTrigger::stop ()
{
boost::unique_lock<boost::mutex> lock (condition_mutex_);
Expand All @@ -119,7 +119,7 @@ pcl::TimeTrigger::stop ()
}

//////////////////////////////////////////////////////////////////////////////////////////////
void
void
pcl::TimeTrigger::thread_function ()
{
double time = 0;
Expand All @@ -135,13 +135,7 @@ pcl::TimeTrigger::thread_function ()
{
callbacks_();
double rest = interval_ + time - getTime ();
#if defined(BOOST_HAS_WINTHREADS) && (BOOST_VERSION < 105500)
//infinite timed_wait bug: https://svn.boost.org/trac/boost/ticket/9079
if (rest > 0.0) // without a deadlock is possible, until notify() is called
condition_.timed_wait (lock, boost::posix_time::microseconds (static_cast<int64_t> ((rest * 1000000))));
#else
condition_.timed_wait (lock, boost::posix_time::microseconds (static_cast<int64_t> ((rest * 1000000))));
#endif
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions io/src/hdl_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,7 @@ pcl::HDLGrabber::setLaserColorRGB (const pcl::RGB& color,
bool
pcl::HDLGrabber::isAddressUnspecified (const boost::asio::ip::address& ipAddress)
{
#if BOOST_VERSION>=104700
return (ipAddress.is_unspecified ());
#else
if (ipAddress.is_v4 ())
return (ipAddress.to_v4 ().to_ulong () == 0);

return (false);
#endif
}

/////////////////////////////////////////////////////////////////////////////
Expand Down
60 changes: 27 additions & 33 deletions io/src/pcd_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ pcl::PCDWriter::setLockingPermissions (const std::string &file_name,
(void)lock;
#ifndef WIN32
#ifndef NO_MANDATORY_LOCKING
// Boost version 1.49 introduced permissions
#if BOOST_VERSION >= 104900
// Attempt to lock the file.
// Attempt to lock the file.
// For mandatory locking, the filesystem must be mounted with the "mand" option in Linux (see http://www.hackinglinuxexposed.com/articles/20030623.html)
lock = boost::interprocess::file_lock (file_name.c_str ());
if (lock.try_lock ())
Expand All @@ -83,7 +81,6 @@ pcl::PCDWriter::setLockingPermissions (const std::string &file_name,
}
#endif
#endif
#endif
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -95,8 +92,6 @@ pcl::PCDWriter::resetLockingPermissions (const std::string &file_name,
(void)lock;
#ifndef WIN32
#ifndef NO_MANDATORY_LOCKING
// Boost version 1.49 introduced permissions
#if BOOST_VERSION >= 104900
(void)file_name;
namespace fs = boost::filesystem;
try
Expand All @@ -110,7 +105,6 @@ pcl::PCDWriter::resetLockingPermissions (const std::string &file_name,
lock.unlock ();
#endif
#endif
#endif
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -394,7 +388,7 @@ pcl::PCDReader::readHeader (const std::string &file_name, pcl::PCLPointCloud2 &c
return (-1);
}

// Open file in binary mode to avoid problem of
// Open file in binary mode to avoid problem of
// std::getline() corrupting the result of ifstream::tellg()
std::ifstream fs;
fs.open (file_name.c_str (), std::ios::binary);
Expand Down Expand Up @@ -456,7 +450,7 @@ pcl::PCDReader::readBodyASCII (std::istream &fs, pcl::PCLPointCloud2 &cloud, int
// Tokenize the line
boost::trim (line);
boost::split (st, line, boost::is_any_of ("\t\r "), boost::token_compress_on);

if (idx >= nr_points)
{
PCL_WARN ("[pcl::PCDReader::read] input has more points (%d) than advertised (%d)!\n", idx, nr_points);
Expand Down Expand Up @@ -713,7 +707,7 @@ pcl::PCDReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,

if (res < 0)
return (res);

// if ascii
if (data_type == 0)
{
Expand All @@ -734,7 +728,7 @@ pcl::PCDReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
// Close file
fs.close ();
}
else
else
/// ---[ Binary mode only
/// We must re-open the file and read with mmap () for binary
{
Expand All @@ -749,7 +743,7 @@ pcl::PCDReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
// Infer file size
const size_t file_size = io::raw_lseek (fd, 0, SEEK_END);
io::raw_lseek (fd, 0, SEEK_SET);

size_t mmap_size = offset + data_idx; // ...because we mmap from the start of the file.
if (data_type == 2)
{
Expand All @@ -762,7 +756,7 @@ pcl::PCDReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,
PCL_ERROR ("[pcl::PCDReader::read] Error during lseek ()!\n");
return (-1);
}

// Read compressed size to compute how much must be mapped
unsigned int compressed_size = 0;
ssize_t num_read = io::raw_read (fd, &compressed_size, 4);
Expand Down Expand Up @@ -794,10 +788,10 @@ pcl::PCDReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud,

// Prepare the map
#ifdef _WIN32
// As we don't know the real size of data (compressed or not),
// As we don't know the real size of data (compressed or not),
// we set dwMaximumSizeHigh = dwMaximumSizeLow = 0 so as to map the whole file
HANDLE fm = CreateFileMapping ((HANDLE) _get_osfhandle (fd), NULL, PAGE_READONLY, 0, 0, NULL);
// As we don't know the real size of data (compressed or not),
// As we don't know the real size of data (compressed or not),
// we set dwNumberOfBytesToMap = 0 so as to map the whole file
unsigned char *map = static_cast<unsigned char*> (MapViewOfFile (fm, FILE_MAP_READ, 0, 0, 0));
if (map == NULL)
Expand Down Expand Up @@ -929,7 +923,7 @@ pcl::PCDWriter::generateHeaderASCII (const pcl::PCLPointCloud2 &cloud,
result = stream.str ();
boost::trim (result);
oss << result << "\nCOUNT ";

stream.str ("");
// Write the TYPE of each field
for (size_t d = 0; d < cloud.fields.size () - 1; ++d)
Expand All @@ -938,9 +932,9 @@ pcl::PCDWriter::generateHeaderASCII (const pcl::PCLPointCloud2 &cloud,
if (cloud.fields[d].name == "_")
continue;
int count = abs (static_cast<int> (cloud.fields[d].count));
if (count == 0)
if (count == 0)
count = 1; // we simply cannot tolerate 0 counts (coming from older converter code)

stream << count << " ";
}
// Ignore invalid padded dimensions that are inherited from binary data
Expand All @@ -958,9 +952,9 @@ pcl::PCDWriter::generateHeaderASCII (const pcl::PCLPointCloud2 &cloud,
boost::trim (result);
oss << result << "\nWIDTH " << cloud.width << "\nHEIGHT " << cloud.height << "\n";

oss << "VIEWPOINT " << origin[0] << " " << origin[1] << " " << origin[2] << " " << orientation.w () << " " <<
oss << "VIEWPOINT " << origin[0] << " " << origin[1] << " " << origin[2] << " " << orientation.w () << " " <<
orientation.x () << " " << orientation.y () << " " << orientation.z () << "\n";

oss << "POINTS " << cloud.width * cloud.height << "\n";

return (oss.str ());
Expand All @@ -982,7 +976,7 @@ pcl::PCDWriter::generateHeaderBinary (const pcl::PCLPointCloud2 &cloud,
unsigned int fsize = 0;
for (size_t i = 0; i < cloud.fields.size (); ++i)
fsize += cloud.fields[i].count * getFieldSize (cloud.fields[i].datatype);

// The size of the fields cannot be larger than point_step
if (fsize > cloud.point_step)
{
Expand All @@ -999,15 +993,15 @@ pcl::PCDWriter::generateHeaderBinary (const pcl::PCLPointCloud2 &cloud,
if (toffset != cloud.fields[i].offset)
{
// If we're at the last "valid" field
int fake_offset = (i == 0) ?
int fake_offset = (i == 0) ?
// Use the current_field offset
(cloud.fields[i].offset)
:
// Else, do cur_field.offset - prev_field.offset + sizeof (prev_field)
(cloud.fields[i].offset -
(cloud.fields[i-1].offset +
(cloud.fields[i].offset -
(cloud.fields[i-1].offset +
cloud.fields[i-1].count * getFieldSize (cloud.fields[i].datatype)));

toffset += fake_offset;

field_names << " _"; // By convention, _ is an invalid field name
Expand Down Expand Up @@ -1064,7 +1058,7 @@ pcl::PCDWriter::generateHeaderBinaryCompressed (std::ostream &os,
unsigned int fsize = 0;
for (size_t i = 0; i < cloud.fields.size (); ++i)
fsize += cloud.fields[i].count * getFieldSize (cloud.fields[i].datatype);

// The size of the fields cannot be larger than point_step
if (fsize > cloud.point_step)
{
Expand All @@ -1087,14 +1081,14 @@ pcl::PCDWriter::generateHeaderBinaryCompressed (std::ostream &os,
field_counts << " " << count;
}
os << field_names.str ();
os << "\nSIZE" << field_sizes.str ()
<< "\nTYPE" << field_types.str ()
os << "\nSIZE" << field_sizes.str ()
<< "\nTYPE" << field_types.str ()
<< "\nCOUNT" << field_counts.str ();
os << "\nWIDTH " << cloud.width << "\nHEIGHT " << cloud.height << "\n";

os << "VIEWPOINT " << origin[0] << " " << origin[1] << " " << origin[2] << " " << orientation.w () << " " <<
orientation.x () << " " << orientation.y () << " " << orientation.z () << "\n";

os << "POINTS " << cloud.width * cloud.height << "\n";

return (os ? 0 : -1);
Expand Down Expand Up @@ -1156,7 +1150,7 @@ pcl::PCDWriter::writeASCII (const std::string &file_name, const pcl::PCLPointClo
continue;

int count = cloud.fields[d].count;
if (count == 0)
if (count == 0)
count = 1; // we simply cannot tolerate 0 counts (coming from older converter code)

for (int c = 0; c < count; ++c)
Expand Down Expand Up @@ -1368,15 +1362,15 @@ pcl::PCDWriter::writeBinaryCompressed (std::ostream &os, const pcl::PCLPointClou
{
if (cloud.fields[i].name == "_")
continue;

fields_sizes[nri] = cloud.fields[i].count * pcl::getFieldSize (cloud.fields[i].datatype);
fsize += fields_sizes[nri];
fields[nri] = cloud.fields[i];
++nri;
}
fields_sizes.resize (nri);
fields.resize (nri);

// Compute the size of data
data_size = cloud.width * cloud.height * fsize;

Expand Down Expand Up @@ -1411,7 +1405,7 @@ pcl::PCDWriter::writeBinaryCompressed (std::ostream &os, const pcl::PCLPointClou
pters[i] = &only_valid_data[toff];
toff += fields_sizes[i] * cloud.width * cloud.height;
}

// Go over all the points, and copy the data in the appropriate places
for (size_t i = 0; i < cloud.width * cloud.height; ++i)
{
Expand Down
Loading

0 comments on commit b238924

Please sign in to comment.