draco/mesh/mesh_are_equivalent.h
Ondrej Stava ef7ad0fda3 Merging latest changes from the private repo.
1. Added support for loading sub-objects in .OBJ into a generic
attribute.

2. Added missing mesh_are_equivlent classes needed for certain unit
tests.

3. Updated javascript decoder reflecting our latest changes + added
support for GeometryAttribute::custom_id() method.

4. Added checks for valid quantization bits to our draco_encoder app.
2017-02-14 14:33:55 -08:00

71 lines
2.4 KiB
C++

// Copyright 2016 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef DRACO_MESH_MESH_ARE_EQUIVALENT_H_
#define DRACO_MESH_MESH_ARE_EQUIVALENT_H_
#include "core/vector_d.h"
#include "mesh/mesh.h"
// This file defines a functor to compare two meshes for equivalency up
// to permutation of the vertices.
namespace draco {
// A functor to compare two meshes for equivalency up to permutation of the
// vertices.
class MeshAreEquivalent {
public:
// Returns true if both meshes are equivalent up to permutation of
// the internal order of vertices. This includes all attributes.
bool operator()(const Mesh &mesh0, const Mesh &mesh1);
private:
// Internal type to keep overview.
struct MeshInfo {
explicit MeshInfo(const Mesh &in_mesh) : mesh(in_mesh) {}
const Mesh &mesh;
std::vector<FaceIndex> ordered_index_of_face;
IndexTypeVector<FaceIndex, int> corner_index_of_smallest_vertex;
};
// Prepare functor for actual comparision.
void Init(const Mesh &mesh0, const Mesh &mesh1);
// Get position as Vector3f of corner c of face f.
static Vector3f GetPostion(const Mesh &mesh, FaceIndex f, int32_t c);
// Internal helper function mostly for debugging.
void PrintPostion(const Mesh &mesh, FaceIndex f, int32_t c);
// Get the corner index of the lex smallest vertex of face f.
static int32_t ComputeCornerIndexOfSmallestPointXYZ(const Mesh &mesh,
FaceIndex f);
// Less compare functor for two faces (represented by their indices)
// with respect to their lex order.
struct FaceIndexLess {
FaceIndexLess(const MeshInfo &in_mesh_info) : mesh_info(in_mesh_info) {}
bool operator()(FaceIndex f0, FaceIndex f1) const;
const MeshInfo &mesh_info;
};
void InitCornerIndexOfSmallestPointXYZ();
void InitOrderedFaceIndex();
std::vector<MeshInfo> mesh_infos_;
int32_t num_faces_;
};
} // namespace draco
#endif // DRACO_MESH_MESH_ARE_EQUIVALENT_H_