mirror of https://github.com/CGAL/cgal
PLY: Support writing per-face/vertex property lists
This commit is contained in:
parent
acbd1ee182
commit
59d70a5018
|
|
@ -298,6 +298,42 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename Index,
|
||||||
|
typename PropertyMap,
|
||||||
|
typename VectorType = typename boost::property_traits<PropertyMap>::value_type,
|
||||||
|
typename ElementType = typename VectorType::value_type>
|
||||||
|
class Simple_property_vector_printer
|
||||||
|
: public Abstract_property_printer<Index>
|
||||||
|
{
|
||||||
|
PropertyMap m_pmap;
|
||||||
|
public:
|
||||||
|
Simple_property_vector_printer(const PropertyMap& pmap) : m_pmap(pmap) { }
|
||||||
|
|
||||||
|
virtual void print(std::ostream& stream, const Index& index)
|
||||||
|
{
|
||||||
|
const VectorType& vec = get(m_pmap, index);
|
||||||
|
if(get_mode(stream) == CGAL::IO::ASCII)
|
||||||
|
{
|
||||||
|
stream << vec.size();
|
||||||
|
for(const ElementType& v : vec)
|
||||||
|
{
|
||||||
|
stream << " " << v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned char size = (unsigned char)(vec.size());
|
||||||
|
stream.write(reinterpret_cast<char*>(&size), sizeof(size));
|
||||||
|
for(const ElementType& v : vec)
|
||||||
|
{
|
||||||
|
ElementType t = ElementType(v);
|
||||||
|
stream.write(reinterpret_cast<char*>(&t), sizeof(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace IO
|
} // namespace IO
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -590,6 +590,17 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
|
||||||
typedef typename SMesh::template Property_map<Simplex, boost::uint64_t> Uint64_map;
|
typedef typename SMesh::template Property_map<Simplex, boost::uint64_t> Uint64_map;
|
||||||
typedef typename SMesh::template Property_map<Simplex, float> Float_map;
|
typedef typename SMesh::template Property_map<Simplex, float> Float_map;
|
||||||
typedef typename SMesh::template Property_map<Simplex, double> Double_map;
|
typedef typename SMesh::template Property_map<Simplex, double> Double_map;
|
||||||
|
// vector types for "property list"s
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::int8_t>> vector_Int8_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::uint8_t>> vector_Uint8_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::int16_t>> vector_Int16_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::uint16_t>> vector_Uint16_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::int32_t>> vector_Int32_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::uint32_t>> vector_Uint32_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::int64_t>> vector_Int64_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<boost::uint64_t>> vector_Uint64_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<float>> vector_Float_map;
|
||||||
|
typedef typename SMesh::template Property_map<Simplex, std::vector<double>> vector_Double_map;
|
||||||
|
|
||||||
std::vector<std::string> prop = sm.template properties<Simplex>();
|
std::vector<std::string> prop = sm.template properties<Simplex>();
|
||||||
|
|
||||||
|
|
@ -702,6 +713,106 @@ void fill_header(std::ostream& os, const Surface_mesh<Point>& sm,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
vector_Int8_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::int8_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar char " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Int8_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Uint8_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::uint8_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar uchar " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Uint8_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Int16_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::int16_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar short " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Int16_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Uint16_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::uint16_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar ushort " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Uint16_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Int32_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::int32_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar int " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Int32_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Uint32_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::uint32_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar uint " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Uint32_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Int64_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::int64_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar int " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Int64_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Uint64_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<boost::uint64_t>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar uint " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Uint64_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Float_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<float>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar float " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Float_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
vector_Double_map pmap;
|
||||||
|
boost::tie(pmap, okay) = sm.template property_map<Simplex,std::vector<double>>(prop[i]);
|
||||||
|
if(okay)
|
||||||
|
{
|
||||||
|
os << "property list uchar double " << name << std::endl;
|
||||||
|
printers.push_back(new internal::Simple_property_vector_printer<Simplex,vector_Double_map>(pmap));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue