|
Point Cloud Library (PCL)
1.5.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2007-2012, Ares Lagae 00006 * Copyright (c) 2010-2011, Willow Garage, Inc. 00007 * 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions 00012 * are met: 00013 * 00014 * * Redistributions of source code must retain the above copyright 00015 * notice, this list of conditions and the following disclaimer. 00016 * * Redistributions in binary form must reproduce the above 00017 * copyright notice, this list of conditions and the following 00018 * disclaimer in the documentation and/or other materials provided 00019 * with the distribution. 00020 * * Neither the name of Willow Garage, Inc. nor the names of its 00021 * contributors may be used to endorse or promote products derived 00022 * from this software without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00025 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00026 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00027 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00028 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00029 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00030 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00031 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00033 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00034 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00035 * POSSIBILITY OF SUCH DAMAGE. 00036 * 00037 * $Id: ply_parser.h 4252 2012-02-04 01:10:24Z nizar $ 00038 * 00039 */ 00040 00041 #ifndef PCL_IO_PLY_PLY_PARSER_H 00042 #define PCL_IO_PLY_PLY_PARSER_H 00043 00044 #include <fstream> 00045 #include <iostream> 00046 #include <istream> 00047 #include <sstream> 00048 #include <string> 00049 #include <vector> 00050 00051 #ifdef _MSC_VER 00052 #include <functional> 00053 #include <memory> 00054 #include <tuple> 00055 #else 00056 #include <tr1/functional> 00057 #include <tr1/memory> 00058 #endif 00059 00060 #include <boost/mpl/fold.hpp> 00061 #include <boost/mpl/inherit.hpp> 00062 #include <boost/mpl/inherit_linearly.hpp> 00063 #include <boost/mpl/joint_view.hpp> 00064 #include <boost/mpl/transform.hpp> 00065 #include <boost/mpl/vector.hpp> 00066 00067 #include <pcl/io/ply/ply.h> 00068 #include <pcl/io/ply/io_operators.h> 00069 #include <pcl/pcl_macros.h> 00070 00071 namespace pcl 00072 { 00073 namespace io 00074 { 00075 namespace ply 00076 { 00083 class PCL_EXPORTS ply_parser 00084 { 00085 public: 00086 00087 typedef std::tr1::function<void (std::size_t, const std::string&)> info_callback_type; 00088 typedef std::tr1::function<void (std::size_t, const std::string&)> warning_callback_type; 00089 typedef std::tr1::function<void (std::size_t, const std::string&)> error_callback_type; 00090 00091 typedef std::tr1::function<void ()> magic_callback_type; 00092 typedef std::tr1::function<void (format_type, const std::string&)> format_callback_type; 00093 typedef std::tr1::function<void (const std::string&)> comment_callback_type; 00094 typedef std::tr1::function<void (const std::string&)> obj_info_callback_type; 00095 typedef std::tr1::function<bool ()> end_header_callback_type; 00096 00097 typedef std::tr1::function<void ()> begin_element_callback_type; 00098 typedef std::tr1::function<void ()> end_element_callback_type; 00099 typedef std::tr1::tuple<begin_element_callback_type, end_element_callback_type> element_callbacks_type; 00100 typedef std::tr1::function<element_callbacks_type (const std::string&, std::size_t)> element_definition_callback_type; 00101 00102 template <typename ScalarType> 00103 struct scalar_property_callback_type 00104 { 00105 typedef std::tr1::function<void (ScalarType)> type; 00106 }; 00107 00108 template <typename ScalarType> 00109 struct scalar_property_definition_callback_type 00110 { 00111 typedef typename scalar_property_callback_type<ScalarType>::type scalar_property_callback_type; 00112 typedef std::tr1::function<scalar_property_callback_type (const std::string&, const std::string&)> type; 00113 }; 00114 00115 typedef boost::mpl::vector<int8, int16, int32, uint8, uint16, uint32, float32, float64> scalar_types; 00116 00117 class scalar_property_definition_callbacks_type 00118 { 00119 private: 00120 template <typename T> 00121 struct callbacks_element 00122 { 00123 typedef T scalar_type; 00124 typename scalar_property_definition_callback_type<scalar_type>::type callback; 00125 }; 00126 00127 typedef boost::mpl::inherit_linearly< 00128 scalar_types, 00129 boost::mpl::inherit< 00130 boost::mpl::_1, 00131 callbacks_element<boost::mpl::_2> 00132 > 00133 >::type callbacks; 00134 callbacks callbacks_; 00135 00136 public: 00137 template <typename ScalarType> 00138 const typename scalar_property_definition_callback_type<ScalarType>::type& 00139 get () const 00140 { 00141 return (static_cast<const callbacks_element<ScalarType>&> (callbacks_).callback); 00142 } 00143 00144 template <typename ScalarType> 00145 typename scalar_property_definition_callback_type<ScalarType>::type& 00146 get () 00147 { 00148 return (static_cast<callbacks_element<ScalarType>&> (callbacks_).callback); 00149 } 00150 00151 template <typename ScalarType> 00152 friend typename scalar_property_definition_callback_type<ScalarType>::type& 00153 at (scalar_property_definition_callbacks_type& scalar_property_definition_callbacks) 00154 { 00155 return (scalar_property_definition_callbacks.get<ScalarType> ()); 00156 } 00157 00158 template <typename ScalarType> 00159 friend const typename scalar_property_definition_callback_type<ScalarType>::type& 00160 at (const scalar_property_definition_callbacks_type& scalar_property_definition_callbacks) 00161 { 00162 return (scalar_property_definition_callbacks.get<ScalarType> ()); 00163 } 00164 }; 00165 00166 template <typename SizeType, typename ScalarType> 00167 struct list_property_begin_callback_type 00168 { 00169 typedef std::tr1::function<void (SizeType)> type; 00170 }; 00171 00172 template <typename SizeType, typename ScalarType> 00173 struct list_property_element_callback_type 00174 { 00175 typedef std::tr1::function<void (ScalarType)> type; 00176 }; 00177 00178 template <typename SizeType, typename ScalarType> 00179 struct list_property_end_callback_type 00180 { 00181 typedef std::tr1::function<void ()> type; 00182 }; 00183 00184 template <typename SizeType, typename ScalarType> 00185 struct list_property_definition_callback_type 00186 { 00187 typedef typename list_property_begin_callback_type<SizeType, ScalarType>::type list_property_begin_callback_type; 00188 typedef typename list_property_element_callback_type<SizeType, ScalarType>::type list_property_element_callback_type; 00189 typedef typename list_property_end_callback_type<SizeType, ScalarType>::type list_property_end_callback_type; 00190 typedef std::tr1::function< 00191 std::tr1::tuple< 00192 list_property_begin_callback_type, 00193 list_property_element_callback_type, 00194 list_property_end_callback_type 00195 > (const std::string&, const std::string&)> type; 00196 }; 00197 00198 typedef boost::mpl::vector<uint8, uint16, uint32> size_types; 00199 00200 class list_property_definition_callbacks_type 00201 { 00202 private: 00203 template <typename T> struct pair_with : boost::mpl::pair<T,boost::mpl::_> {}; 00204 template<typename Sequence1, typename Sequence2> 00205 struct sequence_product : 00206 boost::mpl::fold< 00207 Sequence1, 00208 boost::mpl::vector0<>, 00209 boost::mpl::joint_view< 00210 boost::mpl::_1, 00211 boost::mpl::transform< 00212 Sequence2, 00213 pair_with<boost::mpl::_2> 00214 > 00215 > 00216 > 00217 {}; 00218 00219 template <typename T> 00220 struct callbacks_element 00221 { 00222 typedef typename T::first size_type; 00223 typedef typename T::second scalar_type; 00224 typename list_property_definition_callback_type<size_type, scalar_type>::type callback; 00225 }; 00226 00227 typedef boost::mpl::inherit_linearly< 00228 sequence_product<size_types, scalar_types>::type, 00229 boost::mpl::inherit< 00230 boost::mpl::_1, 00231 callbacks_element<boost::mpl::_2> 00232 > 00233 >::type callbacks; 00234 callbacks callbacks_; 00235 00236 public: 00237 template <typename SizeType, typename ScalarType> 00238 typename list_property_definition_callback_type<SizeType, ScalarType>::type& 00239 get () 00240 { 00241 return (static_cast<callbacks_element<boost::mpl::pair<SizeType, ScalarType> >&> (callbacks_).callback); 00242 } 00243 00244 template <typename SizeType, typename ScalarType> 00245 const typename list_property_definition_callback_type<SizeType, ScalarType>::type& 00246 get () const 00247 { 00248 return (static_cast<const callbacks_element<boost::mpl::pair<SizeType, ScalarType> >&> (callbacks_).callback); 00249 } 00250 00251 template <typename SizeType, typename ScalarType> 00252 friend typename list_property_definition_callback_type<SizeType, ScalarType>::type& 00253 at (list_property_definition_callbacks_type& list_property_definition_callbacks) 00254 { 00255 return (list_property_definition_callbacks.get<SizeType, ScalarType> ()); 00256 } 00257 00258 template <typename SizeType, typename ScalarType> 00259 friend const typename list_property_definition_callback_type<SizeType, ScalarType>::type& 00260 at (const list_property_definition_callbacks_type& list_property_definition_callbacks) 00261 { 00262 return (list_property_definition_callbacks.get<SizeType, ScalarType> ()); 00263 } 00264 }; 00265 00266 inline void 00267 info_callback (const info_callback_type& info_callback); 00268 00269 inline void 00270 warning_callback (const warning_callback_type& warning_callback); 00271 00272 inline void 00273 error_callback (const error_callback_type& error_callback); 00274 00275 inline void 00276 magic_callback (const magic_callback_type& magic_callback); 00277 00278 inline void 00279 format_callback (const format_callback_type& format_callback); 00280 00281 inline void 00282 element_definition_callback (const element_definition_callback_type& element_definition_callback); 00283 00284 inline void 00285 scalar_property_definition_callbacks (const scalar_property_definition_callbacks_type& scalar_property_definition_callbacks); 00286 00287 inline void 00288 list_property_definition_callbacks (const list_property_definition_callbacks_type& list_property_definition_callbacks); 00289 00290 inline void 00291 comment_callback (const comment_callback_type& comment_callback); 00292 00293 inline void 00294 obj_info_callback (const obj_info_callback_type& obj_info_callback); 00295 00296 inline void 00297 end_header_callback (const end_header_callback_type& end_header_callback); 00298 00299 typedef int flags_type; 00300 enum flags { }; 00301 00302 ply_parser (flags_type flags = 0) 00303 : flags_ (flags) 00304 {} 00305 00306 bool parse (const std::string& filename); 00307 //inline bool parse (const std::string& filename); 00308 00309 private: 00310 00311 struct property 00312 { 00313 property (const std::string& name) : name (name) {} 00314 virtual ~property () {} 00315 virtual bool parse (class ply_parser& ply_parser, format_type format, std::istream& istream) = 0; 00316 std::string name; 00317 }; 00318 00319 template <typename ScalarType> 00320 struct scalar_property : public property 00321 { 00322 typedef ScalarType scalar_type; 00323 typedef typename scalar_property_callback_type<scalar_type>::type callback_type; 00324 scalar_property (const std::string& name, callback_type callback) 00325 : property (name) 00326 , callback (callback) 00327 {} 00328 bool parse (class ply_parser& ply_parser, 00329 format_type format, 00330 std::istream& istream) 00331 { 00332 return ply_parser.parse_scalar_property<scalar_type> (format, istream, callback); 00333 } 00334 callback_type callback; 00335 }; 00336 00337 template <typename SizeType, typename ScalarType> 00338 struct list_property : public property 00339 { 00340 typedef SizeType size_type; 00341 typedef ScalarType scalar_type; 00342 typedef typename list_property_begin_callback_type<size_type, scalar_type>::type begin_callback_type; 00343 typedef typename list_property_element_callback_type<size_type, scalar_type>::type element_callback_type; 00344 typedef typename list_property_end_callback_type<size_type, scalar_type>::type end_callback_type; 00345 list_property (const std::string& name, 00346 begin_callback_type begin_callback, 00347 element_callback_type element_callback, 00348 end_callback_type end_callback) 00349 : property (name) 00350 , begin_callback (begin_callback) 00351 , element_callback (element_callback) 00352 , end_callback (end_callback) 00353 {} 00354 bool parse (class ply_parser& ply_parser, 00355 format_type format, 00356 std::istream& istream) 00357 { 00358 return ply_parser.parse_list_property<size_type, scalar_type> (format, 00359 istream, 00360 begin_callback, 00361 element_callback, 00362 end_callback); 00363 } 00364 begin_callback_type begin_callback; 00365 element_callback_type element_callback; 00366 end_callback_type end_callback; 00367 }; 00368 00369 struct element 00370 { 00371 element (const std::string& name, 00372 std::size_t count, 00373 const begin_element_callback_type& begin_element_callback, 00374 const end_element_callback_type& end_element_callback) 00375 : name (name) 00376 , count (count) 00377 , begin_element_callback (begin_element_callback) 00378 , end_element_callback (end_element_callback) 00379 {} 00380 std::string name; 00381 std::size_t count; 00382 begin_element_callback_type begin_element_callback; 00383 end_element_callback_type end_element_callback; 00384 std::vector<std::tr1::shared_ptr<property> > properties; 00385 }; 00386 00387 flags_type flags_; 00388 00389 info_callback_type info_callback_; 00390 warning_callback_type warning_callback_; 00391 error_callback_type error_callback_; 00392 00393 magic_callback_type magic_callback_; 00394 format_callback_type format_callback_; 00395 element_definition_callback_type element_definition_callbacks_; 00396 scalar_property_definition_callbacks_type scalar_property_definition_callbacks_; 00397 list_property_definition_callbacks_type list_property_definition_callbacks_; 00398 comment_callback_type comment_callback_; 00399 obj_info_callback_type obj_info_callback_; 00400 end_header_callback_type end_header_callback_; 00401 00402 template <typename ScalarType> inline void 00403 parse_scalar_property_definition (const std::string& property_name); 00404 00405 template <typename SizeType, typename ScalarType> inline void 00406 parse_list_property_definition (const std::string& property_name); 00407 00408 template <typename ScalarType> inline bool 00409 parse_scalar_property (format_type format, 00410 std::istream& istream, 00411 const typename scalar_property_callback_type<ScalarType>::type& scalar_property_callback); 00412 00413 template <typename SizeType, typename ScalarType> inline bool 00414 parse_list_property (format_type format, 00415 std::istream& istream, 00416 const typename list_property_begin_callback_type<SizeType, ScalarType>::type& list_property_begin_callback, 00417 const typename list_property_element_callback_type<SizeType, ScalarType>::type& list_property_element_callback, 00418 const typename list_property_end_callback_type<SizeType, ScalarType>::type& list_property_end_callback); 00419 00420 std::size_t line_number_; 00421 element* current_element_; 00422 }; 00423 } // namespace ply 00424 } // namespace io 00425 } // namespace pcl 00426 00427 /* inline bool pcl::io::ply::ply_parser::parse (const std::string& filename) */ 00428 /* { */ 00429 /* std::ifstream ifstream (filename.c_str ()); */ 00430 /* return (parse (ifstream)); */ 00431 /* } */ 00432 00433 inline void pcl::io::ply::ply_parser::info_callback (const info_callback_type& info_callback) 00434 { 00435 info_callback_ = info_callback; 00436 } 00437 00438 inline void pcl::io::ply::ply_parser::warning_callback (const warning_callback_type& warning_callback) 00439 { 00440 warning_callback_ = warning_callback; 00441 } 00442 00443 inline void pcl::io::ply::ply_parser::error_callback (const error_callback_type& error_callback) 00444 { 00445 error_callback_ = error_callback; 00446 } 00447 00448 inline void pcl::io::ply::ply_parser::magic_callback (const magic_callback_type& magic_callback) 00449 { 00450 magic_callback_ = magic_callback; 00451 } 00452 00453 inline void pcl::io::ply::ply_parser::format_callback (const format_callback_type& format_callback) 00454 { 00455 format_callback_ = format_callback; 00456 } 00457 00458 inline void pcl::io::ply::ply_parser::element_definition_callback (const element_definition_callback_type& element_definition_callback) 00459 { 00460 element_definition_callbacks_ = element_definition_callback; 00461 } 00462 00463 inline void pcl::io::ply::ply_parser::scalar_property_definition_callbacks (const scalar_property_definition_callbacks_type& scalar_property_definition_callbacks) 00464 { 00465 scalar_property_definition_callbacks_ = scalar_property_definition_callbacks; 00466 } 00467 00468 inline void pcl::io::ply::ply_parser::list_property_definition_callbacks (const list_property_definition_callbacks_type& list_property_definition_callbacks) 00469 { 00470 list_property_definition_callbacks_ = list_property_definition_callbacks; 00471 } 00472 00473 inline void pcl::io::ply::ply_parser::comment_callback (const comment_callback_type& comment_callback) 00474 { 00475 comment_callback_ = comment_callback; 00476 } 00477 00478 inline void pcl::io::ply::ply_parser::obj_info_callback (const obj_info_callback_type& obj_info_callback) 00479 { 00480 obj_info_callback_ = obj_info_callback; 00481 } 00482 00483 inline void pcl::io::ply::ply_parser::end_header_callback (const end_header_callback_type& end_header_callback) 00484 { 00485 end_header_callback_ = end_header_callback; 00486 } 00487 00488 template <typename ScalarType> 00489 inline void pcl::io::ply::ply_parser::parse_scalar_property_definition (const std::string& property_name) 00490 { 00491 typedef ScalarType scalar_type; 00492 typename scalar_property_definition_callback_type<scalar_type>::type& scalar_property_definition_callback = 00493 scalar_property_definition_callbacks_.get<scalar_type> (); 00494 typename scalar_property_callback_type<scalar_type>::type scalar_property_callback; 00495 if (scalar_property_definition_callback) 00496 { 00497 scalar_property_callback = scalar_property_definition_callback (current_element_->name, property_name); 00498 } 00499 if (!scalar_property_callback) 00500 { 00501 if (warning_callback_) 00502 { 00503 warning_callback_ (line_number_, 00504 "property ‘" + std::string (type_traits<scalar_type>::name ()) + " " + 00505 property_name + "’ of element ‘" + current_element_->name + "’ is not handled"); 00506 } 00507 } 00508 current_element_->properties.push_back (std::tr1::shared_ptr<property> (new scalar_property<scalar_type> (property_name, scalar_property_callback))); 00509 } 00510 00511 template <typename SizeType, typename ScalarType> 00512 inline void pcl::io::ply::ply_parser::parse_list_property_definition (const std::string& property_name) 00513 { 00514 typedef SizeType size_type; 00515 typedef ScalarType scalar_type; 00516 typename list_property_definition_callback_type<size_type, scalar_type>::type& list_property_definition_callback = 00517 list_property_definition_callbacks_.get<size_type, scalar_type> (); 00518 typedef typename list_property_begin_callback_type<size_type, scalar_type>::type list_property_begin_callback_type; 00519 typedef typename list_property_element_callback_type<size_type, scalar_type>::type list_property_element_callback_type; 00520 typedef typename list_property_end_callback_type<size_type, scalar_type>::type list_property_end_callback_type; 00521 std::tr1::tuple<list_property_begin_callback_type, list_property_element_callback_type, list_property_end_callback_type> list_property_callbacks; 00522 if (list_property_definition_callback) 00523 { 00524 list_property_callbacks = list_property_definition_callback (current_element_->name, property_name); 00525 } 00526 if (!std::tr1::get<0> (list_property_callbacks) || !std::tr1::get<1> (list_property_callbacks) || !std::tr1::get<2> (list_property_callbacks)) 00527 { 00528 if (warning_callback_) 00529 { 00530 warning_callback_ (line_number_, 00531 "property ‘list " + std::string (type_traits<size_type>::name ()) + " " + 00532 std::string (type_traits<scalar_type>::name ()) + " " + 00533 property_name + "’ of element ‘" + 00534 current_element_->name + "’ is not handled"); 00535 } 00536 } 00537 current_element_->properties.push_back (std::tr1::shared_ptr<property> ( 00538 new list_property<size_type, scalar_type> ( 00539 property_name, 00540 std::tr1::get<0> (list_property_callbacks), 00541 std::tr1::get<1> (list_property_callbacks), 00542 std::tr1::get<2> (list_property_callbacks)))); 00543 } 00544 00545 template <typename ScalarType> 00546 inline bool pcl::io::ply::ply_parser::parse_scalar_property (format_type format, 00547 std::istream& istream, 00548 const typename scalar_property_callback_type<ScalarType>::type& scalar_property_callback) 00549 { 00550 using namespace io_operators; 00551 typedef ScalarType scalar_type; 00552 if (format == ascii_format) 00553 { 00554 scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN (); 00555 char space = ' '; 00556 istream >> value; 00557 if (!istream.eof ()) 00558 istream >> space >> std::ws; 00559 if (!istream || !isspace (space)) 00560 { 00561 if (error_callback_) 00562 error_callback_ (line_number_, "parse error"); 00563 return (false); 00564 } 00565 if (scalar_property_callback) 00566 scalar_property_callback (value); 00567 return (true); 00568 } 00569 else 00570 { 00571 scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN (); 00572 istream.read (reinterpret_cast<char*> (&value), sizeof (scalar_type)); 00573 if (!istream) 00574 { 00575 if (error_callback_) 00576 error_callback_ (line_number_, "parse error"); 00577 return (false); 00578 } 00579 if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) || 00580 ((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order))) 00581 swap_byte_order (value); 00582 if (scalar_property_callback) 00583 scalar_property_callback (value); 00584 return (true); 00585 } 00586 } 00587 00588 template <typename SizeType, typename ScalarType> 00589 inline bool pcl::io::ply::ply_parser::parse_list_property (format_type format, std::istream& istream, 00590 const typename list_property_begin_callback_type<SizeType, ScalarType>::type& list_property_begin_callback, 00591 const typename list_property_element_callback_type<SizeType, ScalarType>::type& list_property_element_callback, 00592 const typename list_property_end_callback_type<SizeType, ScalarType>::type& list_property_end_callback) 00593 { 00594 using namespace io_operators; 00595 typedef SizeType size_type; 00596 typedef ScalarType scalar_type; 00597 if (format == ascii_format) 00598 { 00599 size_type size = std::numeric_limits<size_type>::infinity (); 00600 char space = ' '; 00601 istream >> size; 00602 if (!istream.eof ()) 00603 { 00604 istream >> space >> std::ws; 00605 } 00606 if (!istream || !isspace (space)) 00607 { 00608 if (error_callback_) 00609 { 00610 error_callback_ (line_number_, "parse error"); 00611 } 00612 return (false); 00613 } 00614 if (list_property_begin_callback) 00615 { 00616 list_property_begin_callback (size); 00617 } 00618 for (std::size_t index = 0; index < size; ++index) 00619 { 00620 scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN (); 00621 char space = ' '; 00622 istream >> value; 00623 if (!istream.eof ()) 00624 { 00625 istream >> space >> std::ws; 00626 } 00627 if (!istream || !isspace (space)) 00628 { 00629 if (error_callback_) 00630 { 00631 error_callback_ (line_number_, "parse error"); 00632 } 00633 return (false); 00634 } 00635 if (list_property_element_callback) 00636 { 00637 list_property_element_callback (value); 00638 } 00639 } 00640 if (list_property_end_callback) 00641 { 00642 list_property_end_callback (); 00643 } 00644 return (true); 00645 } 00646 else 00647 { 00648 size_type size = std::numeric_limits<size_type>::infinity (); 00649 istream.read (reinterpret_cast<char*> (&size), sizeof (size_type)); 00650 if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) || 00651 ((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order))) 00652 { 00653 swap_byte_order (size); 00654 } 00655 if (!istream) 00656 { 00657 if (error_callback_) 00658 { 00659 error_callback_ (line_number_, "parse error"); 00660 } 00661 return (false); 00662 } 00663 if (list_property_begin_callback) 00664 { 00665 list_property_begin_callback (size); 00666 } 00667 for (std::size_t index = 0; index < size; ++index) { 00668 scalar_type value = std::numeric_limits<scalar_type>::quiet_NaN (); 00669 istream.read (reinterpret_cast<char*> (&value), sizeof (scalar_type)); 00670 if (!istream) { 00671 if (error_callback_) { 00672 error_callback_ (line_number_, "parse error"); 00673 } 00674 return (false); 00675 } 00676 if (((format == binary_big_endian_format) && (host_byte_order == little_endian_byte_order)) || 00677 ((format == binary_little_endian_format) && (host_byte_order == big_endian_byte_order))) 00678 { 00679 swap_byte_order (value); 00680 } 00681 if (list_property_element_callback) 00682 { 00683 list_property_element_callback (value); 00684 } 00685 } 00686 if (list_property_end_callback) 00687 { 00688 list_property_end_callback (); 00689 } 00690 return (true); 00691 } 00692 } 00693 00694 #endif // PCL_IO_PLY_PLY_PARSER_H
1.8.0