22 #include <pcl/io/io.h> 23 #include <pcl/io/pcd_io.h> 35 globalMapPtr(new pcl::PointCloud<pcl::PointXYZRGBA>()),
36 edgeCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA>),
37 outEdgeCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA>)
41 uint8_t PbMap::serializeGetVersion()
const {
return 0; }
51 for (
uint32_t i = 0; i <
n; i++) out << vPlanes[i];
85 void PbMap::savePbMap(
string filePath)
90 serialize_pbmap << *
this;
93 pcl::io::savePCDFile(filePath +
"/cloud.pcd", *this->globalMapPtr);
99 pcl::PCDReader reader;
100 string PbMapFile = filePath;
101 reader.read(PbMapFile.append(
"/cloud.pcd"), *(this->globalMapPtr));
104 PbMapFile = filePath;
106 if (f.
open(PbMapFile.append(
"/planes.pbmap")))
109 serialized_pbmap >> *
this;
112 cout <<
"Error: cannot open " << PbMapFile <<
"\n";
119 void PbMap::MergeWith(
PbMap& pbm, Eigen::Matrix4f& T)
122 for (
size_t i = 0; i < pbm.
vPlanes.size(); i++)
134 T.block<3, 3>(0, 0) * plane.
v3center + T.block(0, 3, 3, 1);
137 pcl::transformPointCloud(
140 pcl::transformPointCloud(
143 plane.
id = vPlanes.size();
145 vPlanes.push_back(plane);
149 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr alignedPointCloud(
150 new pcl::PointCloud<pcl::PointXYZRGBA>);
151 pcl::transformPointCloud(*pbm.
globalMapPtr, *alignedPointCloud, T);
153 *globalMapPtr += *alignedPointCloud;
158 void PbMap::printPbMap(
string txtFilePbm)
160 cout <<
"PbMap 0.2\n\n";
163 pbm.open(txtFilePbm.c_str());
164 pbm <<
"PbMap 0.2\n\n";
165 pbm <<
"MapPlanes " << vPlanes.size() << endl;
166 for (
unsigned i = 0; i < vPlanes.size(); i++)
168 pbm <<
" ID " << vPlanes[i].id <<
" obs " << vPlanes[i].numObservations;
169 pbm <<
" areaVoxels " << vPlanes[i].areaVoxels <<
" areaHull " 170 << vPlanes[i].areaHull;
171 pbm <<
" ratioXY " << vPlanes[i].elongation <<
" structure " 172 << vPlanes[i].bFromStructure <<
" label " << vPlanes[i].label;
174 << vPlanes[i].v3normal <<
"\n center\n" 175 << vPlanes[i].v3center;
176 pbm <<
"\n PpalComp\n" 177 << vPlanes[i].v3PpalDir <<
"\n RGB\n" 178 << vPlanes[i].v3colorNrgb;
179 pbm <<
"\n Neighbors (" << vPlanes[i].neighborPlanes.size() <<
"): ";
180 for (
auto it = vPlanes[i].neighborPlanes.begin();
181 it != vPlanes[i].neighborPlanes.end(); it++)
182 pbm << it->first <<
" ";
183 pbm <<
"\n CommonObservations: ";
184 for (
auto it = vPlanes[i].neighborPlanes.begin();
185 it != vPlanes[i].neighborPlanes.end(); it++)
186 pbm << it->second <<
" ";
187 pbm <<
"\n ConvexHull (" << vPlanes[i].polygonContourPtr->size()
189 for (
unsigned j = 0; j < vPlanes[i].polygonContourPtr->size(); j++)
190 pbm <<
"\t" << vPlanes[i].polygonContourPtr->points[j].x <<
" " 191 << vPlanes[i].polygonContourPtr->points[j].y <<
" " 192 << vPlanes[i].polygonContourPtr->points[j].z << endl;
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr polygonContourPtr
A class used to store a planar feature (Plane for short).
Eigen::Vector3f v3PpalDir
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr planePointCloudPtr
GLsizei const GLchar ** string
pcl::PointCloud< PointT >::Ptr globalMapPtr
void close()
Close the file.
Virtual base class for "archives": classes abstracting I/O streams.
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
Eigen::Vector3f v3center
! Geometric description
std::vector< Plane > vPlanes
Saves data to a file and transparently compress the data using the given compression level...
unsigned __int32 uint32_t
A class used to store a Plane-based Map (PbMap).