39 #if defined(_MSC_VER) || defined(_LIBCPP_VERSION) 
   41   #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L) 
   45   #include <ext/algorithm> 
  105     for (
unsigned int i=0; i<
points.size(); i++) {
 
  119     for (
unsigned int i=0; i<
points.size(); i++) {
 
  129     for (
unsigned int i=0; i<
points.size(); i++) {
 
  130       points[i].rotate_IP(roll, pitch, yaw);
 
  136     float min_x, min_y, min_z;
 
  137     float max_x, max_y, max_z;
 
  138     min_x = min_y = min_z = 1e6;
 
  139     max_x = max_y = max_z = -1e6;
 
  149       if (x < min_x) min_x = x;
 
  150       if (y < min_y) min_y = y;
 
  151       if (z < min_z) min_z = z;
 
  153       if (x > max_x) max_x = x;
 
  154       if (y > max_y) max_y = y;
 
  155       if (z > max_z) max_z = z;
 
  158     lowerBound(0) = min_x; lowerBound(1) = min_y; lowerBound(2) = min_z;
 
  159     upperBound(0) = max_x; upperBound(1) = max_y; upperBound(2) = max_z;
 
  167     float min_x, min_y, min_z;
 
  168     float max_x, max_y, max_z;
 
  171     min_x = lowerBound(0); min_y = lowerBound(1); min_z = lowerBound(2);
 
  172     max_x = upperBound(0); max_y = upperBound(1); max_z = upperBound(2);
 
  203       double dist = sqrt(x*x+y*y+z*z);
 
  204       if ( dist > thres ) result.
push_back (x,y,z);
 
  214   #if defined(_MSC_VER) || defined(_LIBCPP_VERSION) 
  215     samples.reserve(this->
size());
 
  216     samples.insert(samples.end(), this->begin(), this->end());
 
  217     #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L) 
  218       std::random_device r;
 
  219       std::mt19937 urbg(r());
 
  220       std::shuffle(samples.begin(), samples.end(), urbg);
 
  222       std::random_shuffle(samples.begin(), samples.end());
 
  224     samples.resize(num_samples);
 
  226     random_sample_n(
begin(), 
end(), std::back_insert_iterator<point3d_collection>(samples), num_samples);
 
  227     for (
unsigned int i=0; i<samples.size(); i++) {
 
  236     std::ofstream outfile (filename.c_str());
 
  238     outfile << 
"#VRML V2.0 utf8" << std::endl;
 
  239     outfile << 
"Transform {" << std::endl;
 
  240     outfile << 
"translation 0 0 0" << std::endl;
 
  241     outfile << 
"rotation 0 0 0 0" << std::endl;
 
  242     outfile << 
"  children [" << std::endl;
 
  243     outfile << 
"     Shape{" << std::endl;
 
  244     outfile << 
"  geometry PointSet {" << std::endl;
 
  245     outfile << 
"      coord Coordinate {" << std::endl;
 
  246     outfile << 
"          point [" << std::endl;
 
  249               << 
points.size() << 
" points to "  
  250               << filename.c_str() <<  
".");
 
  252     for (
unsigned int i = 0; i < (
points.size()); i++){
 
  253       outfile << 
"\t\t" << (
points[i])(0) 
 
  259     outfile << 
"                 ]" << std::endl;
 
  260     outfile << 
"      }" << std::endl;
 
  261     outfile << 
"    color Color{" << std::endl;
 
  262     outfile << 
"              color [" << std::endl;
 
  264     for (
unsigned int i = 0; i < 
points.size(); i++){
 
  265       outfile << 
"\t\t 1.0 1.0 1.0 \n";
 
  268     outfile << 
"                 ]" << std::endl;
 
  269     outfile << 
"      }" << std::endl;
 
  271     outfile << 
"   }" << std::endl;
 
  272     outfile << 
"     }" << std::endl;
 
  275     outfile << 
"  ]" << std::endl;
 
  276     outfile << 
"}" << std::endl;
 
  284       for (
unsigned int i=0; i<3; i++){
 
  299     uint32_t pc_size = 0;
 
  300     s.read((
char*)&pc_size, 
sizeof(pc_size));
 
  301     OCTOMAP_DEBUG(
"Reading %d points from binary file...", pc_size);
 
  304       this->
points.reserve(pc_size);
 
  306       for (uint32_t i=0; i<pc_size; i++) {
 
  317     assert(pc_size == this->
size());
 
  328     size_t orig_size = this->
size();
 
  329     if (orig_size > std::numeric_limits<uint32_t>::max()){
 
  330       OCTOMAP_ERROR(
"Pointcloud::writeBinary ERROR: Point cloud too large to be written");
 
  334     uint32_t pc_size = 
static_cast<uint32_t
>(this->
size());
 
  335     OCTOMAP_DEBUG(
"Writing %u points to binary file...", pc_size);
 
  336     s.write((
char*)&pc_size, 
sizeof(pc_size));
 
  349       throw std::runtime_error(
"Invalid input stream for PCD reading.");
 
  356     int points_count = 0;     
 
  357     bool data_ascii = 
false;  
 
  358     bool header_read = 
false; 
 
  361     while (std::getline(s, line)) {
 
  362       if (line.find(
"VERSION") == 0) {
 
  365       } 
else if (line.find(
"FIELDS") == 0) {
 
  367         std::stringstream ss(line);
 
  371         while (ss >> field) {
 
  372           if (field != 
"x" && field != 
"y" && field != 
"z") {
 
  377       } 
else if (line.find(
"SIZE") == 0) {
 
  380       } 
else if (line.find(
"TYPE") == 0) {
 
  383       } 
else if (line.find(
"COUNT") == 0) {
 
  386       } 
else if (line.find(
"WIDTH") == 0) {
 
  388         std::stringstream ss(line);
 
  391       } 
else if (line.find(
"HEIGHT") == 0) {
 
  393         std::stringstream ss(line);
 
  395         ss >> word >> height;
 
  396       } 
else if (line.find(
"VIEWPOINT") == 0) {
 
  399       } 
else if (line.find(
"POINTS") == 0) {
 
  401         std::stringstream ss(line);
 
  403         ss >> word >> points_count;
 
  404       } 
else if (line.find(
"DATA") == 0) {
 
  406         std::stringstream ss(line);
 
  407         std::string word, data_type;
 
  408         ss >> word >> data_type;
 
  409         if (data_type == 
"ascii") {
 
  412           throw std::runtime_error(
 
  413               "readPCD: Unsupported data type: " + data_type +
 
  414               ". Only ASCII supported in this implementation.");
 
  426       throw std::runtime_error(
 
  427           "readPCD: Incomplete or missing header in PCD data.");
 
  431     if (points_count == 0 && width > 0 && height > 0) {
 
  432       points_count = width * height;
 
  435     OCTOMAP_DEBUG(
"readPCD: Reading %d points from PCD stream.\n",
 
  440       this->
points.reserve(points_count); 
 
  442       for (
int i = 0; i < points_count; ++i) {
 
  443         if (!(s >> x >> y >> z)) {
 
  450             throw std::runtime_error(
 
  451                 "readPCD: Error reading point data from PCD stream.");
 
  457       throw std::runtime_error(
"readPCD: Binary PCD files are not supported in " 
  458                                "this implementation.");
 
  462     if (this->
size() != 
static_cast<size_t>(points_count)) {