Subject: CGAL users discussion list
List archive
- From: Andreas Fabri <>
- To: "Yaoyu Hu ( via cgal-discuss Mailing List)" <>
- Subject: Re: [cgal-discuss] How to read a PLY with properties as Point_set_3
- Date: Thu, 21 Oct 2021 08:10:03 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=None ; spf=None
- Ironport-hdrordr: A9a23:dH5xLarxrOH0x3i+4n25S48aV5oVeYIsimQD101hICG9E/bo8vxG+c5w6faaslgssQEb9OxoR5PwOU80maQU3WBpB8baYOCEghrLEGgB1+TfKlTbckWUmtK1vp0AT0ERMqySMbDF4PyKhDVRr7sbsb+6GB/Ev5a480tQ
- Ironport-phdr: A9a23:zk8CohZ5fS9F+y8p59PvUg7/LTGn1oqcDmcuAnoPtbtCf+yZ8oj4OwSHvLMx1gePDNyQtq0MotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2O2+5YHfbx9MiTagbr9/LBe7phjNu8cLhodvNrw/wQbTrHtSfORWy2JoJVaNkBv5+8y94p1t/TlOtvw478JPXrn0cKo+TbxDETQpKHs169HxtRnCVgSA+H0RWXgLnxVSAgjF6Bb6Xortsib/q+Fw1jWWMdHwQLspQjmp8btlRwH0hycGLz458X/YispsjKJAvRmtowVzz5PIbI2JMfZzeL7Wc9EHSmpbRsteSy9PDI2zYIQBEuQPI+hYoYn/qFYVtxSyGROhCfnzxjJGhHL727Ax3eQ7EQHB2QwtB84DsHLJo9XvKqgdS/u1x7TIwzrZdPxWwzb945XPfx87p/GDQKhwftTLxkk0DQ/FgE+fppf/PzOUzekNvHaU7+1lVe2xl24nsQFwoja1ycgwlonJgZgVy1De+Splx4Y1IMS1RUhmatGrDJVerTuVN5dqQsw8WWFovj43xLMbtZO5cyUH1JoqyRHeZvGEfYWF4hHuWeWfLDl4mX5oeLCyihax/ES81OHyWca53EtXoyRLndfBsn8A2hLd58W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YPM+lWsaI1JMi7bOCu2aixPe8mkijw3kpd54Uo+0SA7Sd1Uabm1pwfwrnM1w2LTTr1lxGvu8rtmKhLaDYXE3al2CbtD5JWfLw0doEOXzT9a/arz8lz0sa+E0VT80SuUhZfgJfBkfW6YFH62ABMz1UZqHe7njGpiTdzlmNxxkJ+9HaWheHlKUpcfGtCRW0nikrwZ4+qj5YcUVT6N2DBcTOq6EH/yrRBtap2JHXUW1YOdC/zfTkKbw==
Hello,
At least on Windows if you read a binary ply file you must open the stream in binary mode.
Can you try std::ifstream ifs(fn, std::ios::binary);
Best,
Andreas
On 10/21/2021 1:20 AM, Yaoyu Hu
( via cgal-discuss Mailing List) wrote:
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
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
-- Andreas Fabri, PhD Chief Officer, GeometryFactory Editor, The CGAL Project
- [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+.