20 #include <pcl/io/io.h> 21 #include <pcl/io/pcd_io.h> 34 globalMapPtr(new pcl::PointCloud<pcl::PointXYZRGBA>()),
35 edgeCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA>),
36 outEdgeCloudPtr(new pcl::PointCloud<pcl::PointXYZRGBA>)
59 for (
uint32_t i = 0; i <
n; i++) out << vPlanes[i];
104 void PbMap::savePbMap(
string filePath)
111 filePath +
"/planes.pbmap");
112 serialize_pbmap << *
this;
113 serialize_pbmap.close();
117 pcl::io::savePCDFile(filePath +
"/cloud.pcd", *this->globalMapPtr);
123 pcl::PCDReader reader;
124 string PbMapFile = filePath;
125 reader.read(PbMapFile.append(
"/cloud.pcd"), *(this->globalMapPtr));
130 PbMapFile = filePath;
132 if (serialized_pbmap.
open(PbMapFile.append(
"/planes.pbmap")))
134 serialized_pbmap >> *
this;
137 cout <<
"Error: cannot open " << PbMapFile <<
"\n";
138 serialized_pbmap.
close();
144 void PbMap::MergeWith(
PbMap& pbm, Eigen::Matrix4f& T)
147 for (
size_t i = 0; i < pbm.
vPlanes.size(); i++)
159 T.block(0, 0, 3, 3) * plane.
v3center + T.block(0, 3, 3, 1);
162 pcl::transformPointCloud(
165 pcl::transformPointCloud(
168 plane.
id = vPlanes.size();
170 vPlanes.push_back(plane);
174 pcl::PointCloud<pcl::PointXYZRGBA>::Ptr alignedPointCloud(
175 new pcl::PointCloud<pcl::PointXYZRGBA>);
176 pcl::transformPointCloud(*pbm.
globalMapPtr, *alignedPointCloud, T);
178 *globalMapPtr += *alignedPointCloud;
183 void PbMap::printPbMap(
string txtFilePbm)
185 cout <<
"PbMap 0.2\n\n";
188 pbm.open(txtFilePbm.c_str());
189 pbm <<
"PbMap 0.2\n\n";
190 pbm <<
"MapPlanes " << vPlanes.size() << endl;
191 for (
unsigned i = 0; i < vPlanes.size(); i++)
193 pbm <<
" ID " << vPlanes[i].id <<
" obs " << vPlanes[i].numObservations;
194 pbm <<
" areaVoxels " << vPlanes[i].areaVoxels <<
" areaHull " 195 << vPlanes[i].areaHull;
196 pbm <<
" ratioXY " << vPlanes[i].elongation <<
" structure " 197 << vPlanes[i].bFromStructure <<
" label " << vPlanes[i].label;
199 << vPlanes[i].v3normal <<
"\n center\n" 200 << vPlanes[i].v3center;
201 pbm <<
"\n PpalComp\n" 202 << vPlanes[i].v3PpalDir <<
"\n RGB\n" 203 << vPlanes[i].v3colorNrgb;
204 pbm <<
"\n Neighbors (" << vPlanes[i].neighborPlanes.size() <<
"): ";
206 vPlanes[i].neighborPlanes.begin();
207 it != vPlanes[i].neighborPlanes.end(); it++)
208 pbm << it->first <<
" ";
209 pbm <<
"\n CommonObservations: ";
211 vPlanes[i].neighborPlanes.begin();
212 it != vPlanes[i].neighborPlanes.end(); it++)
213 pbm << it->second <<
" ";
214 pbm <<
"\n ConvexHull (" << vPlanes[i].polygonContourPtr->size()
216 for (
unsigned j = 0; j < vPlanes[i].polygonContourPtr->size(); j++)
217 pbm <<
"\t" << vPlanes[i].polygonContourPtr->points[j].x <<
" " 218 << vPlanes[i].polygonContourPtr->points[j].y <<
" " 219 << vPlanes[i].polygonContourPtr->points[j].z << endl;
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr polygonContourPtr
The virtual base class which provides a unified interface for all persistent objects in MRPT...
A class used to store a planar feature (Plane for short).
Eigen::Vector3f v3PpalDir
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
for(ctr=DCTSIZE;ctr > 0;ctr--)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr planePointCloudPtr
GLsizei const GLchar ** string
pcl::PointCloud< PointT >::Ptr globalMapPtr
#define CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level...
unsigned id
! Parameters to allow the plane-based representation of the map by a graph
Eigen::Vector3f v3center
! Geometric description
std::vector< Plane > vPlanes
unsigned __int32 uint32_t
A class used to store a Plane-based Map (PbMap).