Subject: CGAL users discussion list
List archive
- From: Yaoyu Hu <>
- To:
- Subject: [cgal-discuss] How to read a PLY with properties as Point_set_3
- Date: Wed, 20 Oct 2021 19:20:35 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-hdrordr: A9a23:urlrpKD4s3ME9O/lHenP55DYdb4zR+YMi2TDsHoQdfU1SK2lfq+V9sjzuSWZtN9zYh8dcLK7U5VoKEm0naKdirN9AV7NZmbbhFc=
- Ironport-phdr: A9a23:tm3I5hebE10Hl5WXSXUwZHDZlGM+j97LVj580XLHo4xHfqnrxZn+JkuXvawr0AWRG9SCoK8bw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94PPbwlSgDexfLx+IRW0oA7MqsQYnIxuJ7orxBDUuHVIYeNWxW1pJVKXgRnx49q78YBg/SpNpf8v7tZMXqrmcas2S7xYFykmPHsu5ML3rxnDTBCA6WUaX24LjxdHGQnF7BX9Xpfsriv3s/d21SeGMcHqS70/RDKv5LppRhD1kicKLzE2/mHZhMJzkaxVvg6uqgdlzILIeoyYLuZycr/fcN4cWGFPXtxRVytEAo6kbYQAFe0BPOZFr4LgpVUOsAa1CA6sBOPyyj5HnHj23K0n0+g8FQzL3w0tEskBsHTRttr1NaMSXfqpw6nPyDXOdvVb0iry54bUaB4uu+2MXa5ufsrLz0kiDwHIg1qNpYD5MD2YyusAvmqH4+dhVO+jlmEqpQFtrjWvwsohipXFi4wVx13Y+yt0wJo5KcG4RUJnb9OpDZtduS6cOoBrQc0iW3lltDgmxrACo5K2fygHxI45yxLDaPGLaYiF7g7lWe2MOzl3nmhld6i6hxuq8Uiv1On8Vs6s3VZPtCVFk93MumkT2BPO98SLU/V980e91TqV2ADT7eZEIU8wlaXFMZIu3rkwlp8LvUTCGC/5hln2gbeIekk4/uWk8efqb7X8qpOCK4N5iRvyP6QylsCnBOQ3KAkOX2yV+eSm073j+FX0QLVXjvw2iKbZt5DbJdkGqqO9AAJY050u6xm6Dzi80dQYmWMLI05CeBKCl4TpIU3BIOjkDfejhFShiCtkx//cMb3lG5nCM3nDkKz9crZg8E5c0xE+zctf5pJRErEOOuj/Wk73tNzCDx82KRa4w+j9CIY16oRLUm2GBuqVMbjZrESTzuMpOeiFIoEP6xjnLP1w1vfpnGJxuUJVKam0zJIQeW3hT6Q4C0qcaHvoxNwGFDFZ7UIFUOX2hQjaAnZobHGoUvdkjtnaIIevDIOGS4z0xbLchGG0GZpZYm0AAVeJQy+An2qsVPIFaSbUKchkwGVsvV2JRIoo1BXovwj/meIPEw==
Hi,
PointSet_t point_set;
// Default color.
const Color_t color_black { { 0, 0, 0 } };
// The color map.
PS_ColorMap_t color;
bool success = false;
boost::tie( color, success ) =
point_set.add_property_map<Color_t>("color", color_black);
assert (success);
// Read PLY.
CGAL::read_PLY_with_properties(
ifs,
point_set.index_back_inserter(),
CGAL::make_ply_point_reader( PS_PointMap_t() ),
CGAL::make_ply_normal_reader( PS_NormalMap_t() ),
std::make_tuple( PS_ColorMap_t(), CGAL::Construct_array(),
CGAL::PLY_property<unsigned char>("red"),
CGAL::PLY_property<unsigned char>("green"),
CGAL::PLY_property<unsigned char>("blue") ) ) )
return point_set;
}
I am trying to read a binary PLY file as CGAL::Point_set_3 but I can't get it right.
I am using CGAL 5.3.
I suppose there is not a dedicated example showing how to read a PLY file as Point_set_3 that has properties. For my PLY file, there are point normal and color stored. The code I tried to read it as CGAL::Point_set_3 is as follows:
=== Code begins. ===
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_t;
typedef Kernel_t::Point_3 Point_t;
typedef Kernel_t::Vector_3 Vector_t;
typedef std::array< unsigned char, 3 > Color_t;
typedef CGAL::Point_set_3<Point_t> PointSet_t;
typedef Kernel_t::Point_3 Point_t;
typedef Kernel_t::Vector_3 Vector_t;
typedef std::array< unsigned char, 3 > Color_t;
typedef CGAL::Point_set_3<Point_t> PointSet_t;
typedef PointSet_t::Point_map PS_PointMap_t;
typedef PointSet_t::Vector_map PS_NormalMap_t;
typedef PointSet_t::Property_map<Color_t> PS_ColorMap_t;
typedef PointSet_t::Vector_map PS_NormalMap_t;
typedef PointSet_t::Property_map<Color_t> PS_ColorMap_t;
PointSet_t sr::read_ply_as_point_set( const std::string& fn ) {
std::ifstream ifs(fn);
std::ifstream ifs(fn);
PointSet_t point_set;
// Default color.
const Color_t color_black { { 0, 0, 0 } };
// The color map.
PS_ColorMap_t color;
bool success = false;
boost::tie( color, success ) =
point_set.add_property_map<Color_t>("color", color_black);
assert (success);
// Read PLY.
CGAL::read_PLY_with_properties(
ifs,
point_set.index_back_inserter(),
CGAL::make_ply_point_reader( PS_PointMap_t() ),
CGAL::make_ply_normal_reader( PS_NormalMap_t() ),
std::make_tuple( PS_ColorMap_t(), CGAL::Construct_array(),
CGAL::PLY_property<unsigned char>("red"),
CGAL::PLY_property<unsigned char>("green"),
CGAL::PLY_property<unsigned char>("blue") ) ) )
return point_set;
}
=== Code ends. ===
The codes that I am not sure about are the lines of CGAL::make_ply_point_reader() and CGAL::make_ply_normal_reader(), they are probably wrong but I don't know how to get it right.
Thanks!
Yaoyu
- [cgal-discuss] How to read a PLY with properties as Point_set_3, Yaoyu Hu, 10/21/2021
- Re: [cgal-discuss] How to read a PLY with properties as Point_set_3, Andreas Fabri, 10/21/2021
- Re: [cgal-discuss] How to read a PLY with properties as Point_set_3, Yaoyu Hu, 10/21/2021
- Re: [cgal-discuss] How to read a PLY with properties as Point_set_3, Yaoyu Hu, 10/23/2021
- Re: [cgal-discuss] How to read a PLY with properties as Point_set_3, Yaoyu Hu, 10/21/2021
- Re: [cgal-discuss] How to read a PLY with properties as Point_set_3, Andreas Fabri, 10/21/2021
Archive powered by MHonArc 2.6.19+.