Go to the documentation of this file.
39 #if defined(_MSC_VER) || defined(_LIBCPP_VERSION)
41 #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L)
45 #include <ext/algorithm>
104 for (
unsigned int i=0; i<
points.size(); i++) {
118 for (
unsigned int i=0; i<
points.size(); i++) {
128 for (
unsigned int i=0; i<
points.size(); i++) {
129 points[i].rotate_IP(roll, pitch, yaw);
135 float min_x, min_y, min_z;
136 float max_x, max_y, max_z;
137 min_x = min_y = min_z = 1e6;
138 max_x = max_y = max_z = -1e6;
148 if (x < min_x) min_x = x;
149 if (y < min_y) min_y = y;
150 if (z < min_z) min_z = z;
152 if (x > max_x) max_x = x;
153 if (y > max_y) max_y = y;
154 if (z > max_z) max_z = z;
157 lowerBound(0) = min_x; lowerBound(1) = min_y; lowerBound(2) = min_z;
158 upperBound(0) = max_x; upperBound(1) = max_y; upperBound(2) = max_z;
166 float min_x, min_y, min_z;
167 float max_x, max_y, max_z;
170 min_x = lowerBound(0); min_y = lowerBound(1); min_z = lowerBound(2);
171 max_x = upperBound(0); max_y = upperBound(1); max_z = upperBound(2);
202 double dist = sqrt(x*x+y*y+z*z);
203 if ( dist > thres ) result.
push_back (x,y,z);
213 #if defined(_MSC_VER) || defined(_LIBCPP_VERSION)
214 samples.reserve(this->
size());
215 samples.insert(samples.end(), this->begin(), this->end());
216 #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L)
217 std::random_device r;
218 std::mt19937 urbg(r());
219 std::shuffle(samples.begin(), samples.end(), urbg);
221 std::random_shuffle(samples.begin(), samples.end());
223 samples.resize(num_samples);
225 random_sample_n(
begin(),
end(), std::back_insert_iterator<point3d_collection>(samples), num_samples);
226 for (
unsigned int i=0; i<samples.size(); i++) {
235 std::ofstream outfile (filename.c_str());
237 outfile <<
"#VRML V2.0 utf8" << std::endl;
238 outfile <<
"Transform {" << std::endl;
239 outfile <<
"translation 0 0 0" << std::endl;
240 outfile <<
"rotation 0 0 0 0" << std::endl;
241 outfile <<
" children [" << std::endl;
242 outfile <<
" Shape{" << std::endl;
243 outfile <<
" geometry PointSet {" << std::endl;
244 outfile <<
" coord Coordinate {" << std::endl;
245 outfile <<
" point [" << std::endl;
248 <<
points.size() <<
" points to "
249 << filename.c_str() <<
".");
251 for (
unsigned int i = 0; i < (
points.size()); i++){
252 outfile <<
"\t\t" << (
points[i])(0)
258 outfile <<
" ]" << std::endl;
259 outfile <<
" }" << std::endl;
260 outfile <<
" color Color{" << std::endl;
261 outfile <<
" color [" << std::endl;
263 for (
unsigned int i = 0; i <
points.size(); i++){
264 outfile <<
"\t\t 1.0 1.0 1.0 \n";
267 outfile <<
" ]" << std::endl;
268 outfile <<
" }" << std::endl;
270 outfile <<
" }" << std::endl;
271 outfile <<
" }" << std::endl;
274 outfile <<
" ]" << std::endl;
275 outfile <<
"}" << std::endl;
283 for (
unsigned int i=0; i<3; i++){
298 uint32_t pc_size = 0;
299 s.read((
char*)&pc_size,
sizeof(pc_size));
300 OCTOMAP_DEBUG(
"Reading %d points from binary file...", pc_size);
303 this->
points.reserve(pc_size);
305 for (uint32_t i=0; i<pc_size; i++) {
316 assert(pc_size == this->
size());
327 size_t orig_size = this->
size();
328 if (orig_size > std::numeric_limits<uint32_t>::max()){
329 OCTOMAP_ERROR(
"Pointcloud::writeBinary ERROR: Point cloud too large to be written");
333 uint32_t pc_size =
static_cast<uint32_t
>(this->
size());
334 OCTOMAP_DEBUG(
"Writing %u points to binary file...", pc_size);
335 s.write((
char*)&pc_size,
sizeof(pc_size));
point3d_collection points
std::istream & readBinary(std::istream &s)
void calcBBX(point3d &lowerBound, point3d &upperBound) const
Calculate bounding box of Pointcloud.
void crop(point3d lowerBound, point3d upperBound)
Crop Pointcloud to given bounding box.
void push_back(float x, float y, float z)
point3d getPoint(unsigned int i) const
#define OCTOMAP_DEBUG(...)
#define OCTOMAP_DEBUG_STR(args)
This class represents a three-dimensional vector.
void subSampleRandom(unsigned int num_samples, Pointcloud &sample_cloud)
std::ostream & writeBinary(std::ostream &s) const
Vector3 transform(const Vector3 &v) const
Transformation of a vector.
void writeVrml(std::string filename)
Export the Pointcloud to a VRML file.
void rotate(double roll, double pitch, double yaw)
Rotate each point in pointcloud.
pose6d current_inv_transform
std::istream & read(std::istream &s)
#define OCTOMAP_ERROR(...)
void transform(pose6d transform)
Apply transform to each point.
std::vector< octomath::Vector3 > point3d_collection
std::istream & readBinary(std::istream &s)
void minDist(double thres)
#define OCTOMAP_WARNING(...)
point3d_collection::const_iterator const_iterator
This class represents a tree-dimensional pose of an object.
void transformAbsolute(pose6d transform)
Apply transform to each point, undo previous transforms.
octomath::Vector3 point3d
Use Vector3 (float precision) as a point3d in octomap.
octomap
Author(s): Kai M. Wurm
, Armin Hornung
autogenerated on Tue Dec 12 2023 03:39:40