14 #include <boost/graph/graph_traits.hpp>
15 #include <boost/graph/properties.hpp>
25 #pragma warning(disable : 4146 26812 26451)
37 typename HalfedgeGraph,
41 typename halfedge_descriptor =
42 typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor >
46 typedef typename boost::property_traits<PointMap>::value_type
Point;
61 draco::Decoder decoder;
62 decoder.SetSkipAttributeTransform(
63 draco::GeometryAttribute::POSITION);
65 std::unique_ptr< draco::PointCloud > pc;
69 auto type_statusor = decoder.GetEncodedGeometryType(&buffer);
70 if(!type_statusor.ok())
72 std::cerr <<
"decode_coarse_mesh: failed to retrieve geometry " << std::endl;
75 const draco::EncodedGeometryType geom_type = type_statusor.value();
76 if(geom_type == draco::TRIANGULAR_MESH)
78 auto statusor = decoder.DecodeMeshFromBuffer(&buffer);
81 std::cerr <<
"decode_coarse_mesh: failed to retrieve coarse mesh " << std::endl;
84 std::unique_ptr< draco::Mesh > in_mesh = std::move(statusor).value();
88 pc = std::move(in_mesh);
93 std::cerr <<
"decode_coarse_mesh: Failed to decode the input file" << std::endl;
101 const draco::PointCloud *p_point_cloud =
102 &(
static_cast< const draco::PointCloud &
>(mesh));
105 std::map< int, vertex_descriptor > map_index_to_vertex;
108 const draco::PointAttribute *
const att =
109 p_point_cloud->GetNamedAttribute(draco::GeometryAttribute::POSITION);
119 const draco::PointAttribute *
const att,
120 std::map< int, vertex_descriptor > *map_index_to_vertex)
122 if(att ==
nullptr || att->size() == 0)
124 std::array< float, 3 > value;
125 for(draco::AttributeValueIndex i(0);
126 i < static_cast< uint32_t >(att->size());
129 if(!att->ConvertValue<
float, 3 >(i, &value[0]))
133 map_index_to_vertex->insert(
134 std::pair< int, vertex_descriptor >(i.value(), v));
136 Point vertex_pos =
Point(value[0], value[1], value[2]);
145 const draco::PointAttribute *
const att,
146 const std::map< int, vertex_descriptor > &map_index_to_vertex)
148 for(draco::FaceIndex i(0); i < p_mesh->num_faces(); ++i)
150 std::vector< int >
face;
152 for(
int j = 0; j < 3; ++j)
167 std::vector< int >&
face,
168 const draco::PointAttribute *
const att)
170 const draco::PointIndex vert_index = p_mesh->face(face_id)[local_corner_id];
172 face.push_back(att->mapped_index(vert_index).value());
178 const std::vector< int >&
face,
179 const std::map< int, vertex_descriptor > &map_index_to_vertex)
182 std::vector< vertex_descriptor > vertexRange;
183 vertexRange.reserve(3);
184 for(
int i = 0; i < 3; i++)
187 vertexRange.push_back(v);
191 CGAL::Euler::add_face< HalfedgeGraph, std::vector< vertex_descriptor > >(