39 #if defined(_MSC_VER) || defined(_LIBCPP_VERSION) 42 #include <ext/algorithm> 101 for (
unsigned int i=0; i<
points.size(); i++) {
115 for (
unsigned int i=0; i<
points.size(); i++) {
125 for (
unsigned int i=0; i<
points.size(); i++) {
126 points[i].rotate_IP(roll, pitch, yaw);
132 float min_x, min_y, min_z;
133 float max_x, max_y, max_z;
134 min_x = min_y = min_z = 1e6;
135 max_x = max_y = max_z = -1e6;
145 if (x < min_x) min_x = x;
146 if (y < min_y) min_y = y;
147 if (z < min_z) min_z = z;
149 if (x > max_x) max_x = x;
150 if (y > max_y) max_y = y;
151 if (z > max_z) max_z = z;
154 lowerBound(0) = min_x; lowerBound(1) = min_y; lowerBound(2) = min_z;
155 upperBound(0) = max_x; upperBound(1) = max_y; upperBound(2) = max_z;
163 float min_x, min_y, min_z;
164 float max_x, max_y, max_z;
167 min_x = lowerBound(0); min_y = lowerBound(1); min_z = lowerBound(2);
168 max_x = upperBound(0); max_y = upperBound(1); max_z = upperBound(2);
199 double dist = sqrt(x*x+y*y+z*z);
200 if ( dist > thres ) result.
push_back (x,y,z);
210 #if defined(_MSC_VER) || defined(_LIBCPP_VERSION) 211 samples.reserve(this->
size());
212 samples.insert(samples.end(), this->
begin(), this->
end());
213 std::random_shuffle(samples.begin(), samples.end());
214 samples.resize(num_samples);
216 random_sample_n(
begin(),
end(), std::back_insert_iterator<point3d_collection>(samples), num_samples);
217 for (
unsigned int i=0; i<samples.size(); i++) {
226 std::ofstream outfile (filename.c_str());
228 outfile <<
"#VRML V2.0 utf8" << std::endl;
229 outfile <<
"Transform {" << std::endl;
230 outfile <<
"translation 0 0 0" << std::endl;
231 outfile <<
"rotation 0 0 0 0" << std::endl;
232 outfile <<
" children [" << std::endl;
233 outfile <<
" Shape{" << std::endl;
234 outfile <<
" geometry PointSet {" << std::endl;
235 outfile <<
" coord Coordinate {" << std::endl;
236 outfile <<
" point [" << std::endl;
239 <<
points.size() <<
" points to " 240 << filename.c_str() <<
".");
242 for (
unsigned int i = 0; i < (
points.size()); i++){
243 outfile <<
"\t\t" << (
points[i])(0)
249 outfile <<
" ]" << std::endl;
250 outfile <<
" }" << std::endl;
251 outfile <<
" color Color{" << std::endl;
252 outfile <<
" color [" << std::endl;
254 for (
unsigned int i = 0; i <
points.size(); i++){
255 outfile <<
"\t\t 1.0 1.0 1.0 \n";
258 outfile <<
" ]" << std::endl;
259 outfile <<
" }" << std::endl;
261 outfile <<
" }" << std::endl;
262 outfile <<
" }" << std::endl;
265 outfile <<
" ]" << std::endl;
266 outfile <<
"}" << std::endl;
274 for (
unsigned int i=0; i<3; i++){
289 uint32_t pc_size = 0;
290 s.read((
char*)&pc_size,
sizeof(pc_size));
291 OCTOMAP_DEBUG(
"Reading %d points from binary file...", pc_size);
294 this->
points.reserve(pc_size);
296 for (uint32_t i=0; i<pc_size; i++) {
307 assert(pc_size == this->
size());
318 size_t orig_size = this->
size();
319 if (orig_size > std::numeric_limits<uint32_t>::max()){
320 OCTOMAP_ERROR(
"Pointcloud::writeBinary ERROR: Point cloud too large to be written");
324 uint32_t pc_size =
static_cast<uint32_t
>(this->
size());
325 OCTOMAP_DEBUG(
"Writing %u points to binary file...", pc_size);
326 s.write((
char*)&pc_size,
sizeof(pc_size));
Vector3 transform(const Vector3 &v) const
Transformation of a vector.
#define OCTOMAP_DEBUG(...)
void minDist(double thres)
void writeVrml(std::string filename)
Export the Pointcloud to a VRML file.
pose6d current_inv_transform
void transform(pose6d transform)
Apply transform to each point.
void push_back(float x, float y, float z)
std::ostream & writeBinary(std::ostream &s) const
void subSampleRandom(unsigned int num_samples, Pointcloud &sample_cloud)
std::vector< octomath::Vector3 > point3d_collection
std::istream & readBinary(std::istream &s)
point3d_collection points
std::istream & readBinary(std::istream &s)
This class represents a tree-dimensional pose of an object.
#define OCTOMAP_WARNING(...)
void calcBBX(point3d &lowerBound, point3d &upperBound) const
Calculate bounding box of Pointcloud.
std::istream & read(std::istream &s)
This class represents a three-dimensional vector.
#define OCTOMAP_DEBUG_STR(args)
void transformAbsolute(pose6d transform)
Apply transform to each point, undo previous transforms.
octomath::Vector3 point3d
Use Vector3 (float precision) as a point3d in octomap.
point3d getPoint(unsigned int i) const
void rotate(double roll, double pitch, double yaw)
Rotate each point in pointcloud.
void crop(point3d lowerBound, point3d upperBound)
Crop Pointcloud to given bounding box.
#define OCTOMAP_ERROR(...)
Pose6D inv() const
Inversion.
point3d_collection::const_iterator const_iterator