GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
mesh_are_equivalent.h
Go to the documentation of this file.
1// Copyright 2016 The Draco Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15#ifndef DRACO_MESH_MESH_ARE_EQUIVALENT_H_
16#define DRACO_MESH_MESH_ARE_EQUIVALENT_H_
17
18#include "draco/core/vector_d.h"
19#include "draco/mesh/mesh.h"
20
21// This file defines a functor to compare two meshes for equivalency up
22// to permutation of the vertices.
23namespace draco {
24
25// A functor to compare two meshes for equivalency up to permutation of the
26// vertices.
28 public:
29 // Returns true if both meshes are equivalent up to permutation of
30 // the internal order of vertices. This includes all attributes.
31 bool operator()(const Mesh &mesh0, const Mesh &mesh1);
32
33 private:
34 // Internal type to keep overview.
35 struct MeshInfo {
36 explicit MeshInfo(const Mesh &in_mesh) : mesh(in_mesh) {}
37 const Mesh &mesh;
38 std::vector<FaceIndex> ordered_index_of_face;
39 IndexTypeVector<FaceIndex, int> corner_index_of_smallest_vertex;
40 };
41
42 // Prepare functor for actual comparison.
43 void Init(const Mesh &mesh0, const Mesh &mesh1);
44
45 // Get position as Vector3f of corner c of face f.
46 static Vector3f GetPosition(const Mesh &mesh, FaceIndex f, int32_t c);
47 // Internal helper function mostly for debugging.
48 void PrintPosition(const Mesh &mesh, FaceIndex f, int32_t c);
49 // Get the corner index of the lex smallest vertex of face f.
50 static int32_t ComputeCornerIndexOfSmallestPointXYZ(const Mesh &mesh,
51 FaceIndex f);
52
53 // Less compare functor for two faces (represented by their indices)
54 // with respect to their lex order.
55 struct FaceIndexLess {
56 explicit FaceIndexLess(const MeshInfo &in_mesh_info)
57 : mesh_info(in_mesh_info) {}
58 bool operator()(FaceIndex f0, FaceIndex f1) const;
59 const MeshInfo &mesh_info;
60 };
61
62 void InitCornerIndexOfSmallestPointXYZ();
63 void InitOrderedFaceIndex();
64
65 std::vector<MeshInfo> mesh_infos_;
66 int32_t num_faces_;
67};
68
69} // namespace draco
70
71#endif // DRACO_MESH_MESH_ARE_EQUIVALENT_H_
Definition draco_index_type_vector.h:32
Definition mesh_are_equivalent.h:27
bool operator()(const Mesh &mesh0, const Mesh &mesh1)
Definition mesh_are_equivalent.cc:106
Definition mesh.h:52
Definition attribute_octahedron_transform.cc:21
VectorD< float, 3 > Vector3f
Definition vector_d.h:340
FaceIndex FaceIndex
Definition mesh_edgebreaker_encoder_impl.cc:36
double f(const std::string &, double, bool) noexcept
Definition profile_cpp_calls_2.cpp:4