Skip to content

Commit

Permalink
reorg: remove hash_* namespaces (#2025)
Browse files Browse the repository at this point in the history
* reorg: hash_*::hash to hash_* (remove hash_* namespaces)

* reorg: apply-style
  • Loading branch information
pvarvak authored Jun 30, 2020
1 parent 488e324 commit 1d89934
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 76 deletions.
2 changes: 1 addition & 1 deletion cpp/open3d/core/MemoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ std::shared_ptr<DeviceMemoryManager> MemoryManager::GetDeviceMemoryManager(
const Device& device) {
static std::unordered_map<Device::DeviceType,
std::shared_ptr<DeviceMemoryManager>,
utility::hash_enum_class::hash>
utility::hash_enum_class>
map_device_type_to_memory_manager = {
{Device::DeviceType::CPU,
std::make_shared<CPUMemoryManager>()},
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/core/kernel/BinaryEW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace open3d {
namespace core {
namespace kernel {

const std::unordered_set<BinaryEWOpCode, utility::hash_enum_class::hash>
const std::unordered_set<BinaryEWOpCode, utility::hash_enum_class>
s_boolean_binary_ew_op_codes{
BinaryEWOpCode::LogicalAnd, BinaryEWOpCode::LogicalOr,
BinaryEWOpCode::LogicalXor, BinaryEWOpCode::Gt,
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/core/kernel/BinaryEW.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum class BinaryEWOpCode {
Ne,
};

extern const std::unordered_set<BinaryEWOpCode, utility::hash_enum_class::hash>
extern const std::unordered_set<BinaryEWOpCode, utility::hash_enum_class>
s_boolean_binary_ew_op_codes;

void BinaryEW(const Tensor& lhs,
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/core/kernel/Reduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace kernel {

enum class ReductionOpCode { Sum, Prod, Min, Max, ArgMin, ArgMax };

static const std::unordered_set<ReductionOpCode, utility::hash_enum_class::hash>
static const std::unordered_set<ReductionOpCode, utility::hash_enum_class>
regular_reduce_ops = {ReductionOpCode::Sum, ReductionOpCode::Prod,
ReductionOpCode::Min, ReductionOpCode::Max};
static const std::unordered_set<ReductionOpCode, utility::hash_enum_class::hash>
static const std::unordered_set<ReductionOpCode, utility::hash_enum_class>
arg_reduce_ops = {ReductionOpCode::ArgMin, ReductionOpCode::ArgMax};

void Reduction(const Tensor& src,
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/geometry/HalfEdgeTriangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ HalfEdgeTriangleMesh::CreateFromTriangleMesh(const TriangleMesh &mesh) {
// Collect half edges
// Check: for valid manifolds, there mustn't be duplicated half-edges
std::unordered_map<Eigen::Vector2i, size_t,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
vertex_indices_to_half_edge_index;

for (size_t triangle_index = 0;
Expand Down
6 changes: 2 additions & 4 deletions cpp/open3d/geometry/LineSetFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ std::shared_ptr<LineSet> LineSet::CreateFromTriangleMesh(
auto line_set = std::make_shared<LineSet>();
line_set->points_ = mesh.vertices_;

std::unordered_set<Eigen::Vector2i,
utility::hash_eigen::hash<Eigen::Vector2i>>
std::unordered_set<Eigen::Vector2i, utility::hash_eigen<Eigen::Vector2i>>
inserted_edges;
auto InsertEdge = [&](int vidx0, int vidx1) {
Eigen::Vector2i edge(std::min(vidx0, vidx1), std::max(vidx0, vidx1));
Expand Down Expand Up @@ -125,8 +124,7 @@ std::shared_ptr<LineSet> LineSet::CreateFromTetraMesh(const TetraMesh &mesh) {
auto line_set = std::make_shared<LineSet>();
line_set->points_ = mesh.vertices_;

std::unordered_set<Eigen::Vector2i,
utility::hash_eigen::hash<Eigen::Vector2i>>
std::unordered_set<Eigen::Vector2i, utility::hash_eigen<Eigen::Vector2i>>
inserted_edges;
auto InsertEdge = [&](int vidx0, int vidx1) {
Eigen::Vector2i edge(std::min(vidx0, vidx1), std::max(vidx0, vidx1));
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/geometry/PointCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ std::shared_ptr<PointCloud> PointCloud::VoxelDownSample(
utility::LogError("[VoxelDownSample] voxel_size is too small.");
}
std::unordered_map<Eigen::Vector3i, AccumulatedPoint,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_accpoint;

Eigen::Vector3d ref_coord;
Expand Down Expand Up @@ -366,7 +366,7 @@ PointCloud::VoxelDownSampleAndTrace(double voxel_size,
utility::LogError("[VoxelDownSample] voxel_size is too small.");
}
std::unordered_map<Eigen::Vector3i, AccumulatedPointForTrace,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_accpoint;
int cid_temp[3] = {1, 2, 4};
for (size_t i = 0; i < points_.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/geometry/SurfaceReconstructionAlphaShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ std::shared_ptr<TriangleMesh> TriangleMesh::CreateFromPointCloudAlphaShape(
"[CreateFromPointCloudAlphaShape] remove triangles within "
"the mesh");
std::unordered_map<Eigen::Vector3i, int,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
triangle_count;
for (size_t tidx = 0; tidx < mesh->triangles_.size(); ++tidx) {
Eigen::Vector3i triangle = mesh->triangles_[tidx];
Expand Down
7 changes: 3 additions & 4 deletions cpp/open3d/geometry/TetraMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ TetraMesh TetraMesh::operator+(const TetraMesh &mesh) const {
TetraMesh &TetraMesh::RemoveDuplicatedVertices() {
typedef decltype(tetras_)::value_type::Scalar Index;
typedef std::tuple<double, double, double> Coordinate3;
std::unordered_map<Coordinate3, size_t,
utility::hash_tuple::hash<Coordinate3>>
std::unordered_map<Coordinate3, size_t, utility::hash_tuple<Coordinate3>>
point_to_old_index;
std::vector<Index> index_old_to_new(vertices_.size());
size_t old_vertex_num = vertices_.size();
Expand Down Expand Up @@ -104,7 +103,7 @@ TetraMesh &TetraMesh::RemoveDuplicatedVertices() {
TetraMesh &TetraMesh::RemoveDuplicatedTetras() {
typedef decltype(tetras_)::value_type::Scalar Index;
typedef std::tuple<Index, Index, Index, Index> Index4;
std::unordered_map<Index4, size_t, utility::hash_tuple::hash<Index4>>
std::unordered_map<Index4, size_t, utility::hash_tuple<Index4>>
tetra_to_old_index;
size_t old_tetra_num = tetras_.size();
size_t k = 0;
Expand Down Expand Up @@ -242,7 +241,7 @@ std::shared_ptr<TriangleMesh> TetraMesh::ExtractTriangleMesh(
std::get<1>(b) == std::get<1>(a);
};

std::unordered_map<Index2, size_t, utility::hash_tuple::hash<Index2>>
std::unordered_map<Index2, size_t, utility::hash_tuple<Index2>>
intersecting_edges;

const int tetra_edges[][2] = {{0, 1}, {0, 2}, {0, 3},
Expand Down
26 changes: 12 additions & 14 deletions cpp/open3d/geometry/TriangleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,7 @@ std::shared_ptr<PointCloud> TriangleMesh::SamplePointsPoissonDisk(

TriangleMesh &TriangleMesh::RemoveDuplicatedVertices() {
typedef std::tuple<double, double, double> Coordinate3;
std::unordered_map<Coordinate3, size_t,
utility::hash_tuple::hash<Coordinate3>>
std::unordered_map<Coordinate3, size_t, utility::hash_tuple<Coordinate3>>
point_to_old_index;
std::vector<int> index_old_to_new(vertices_.size());
bool has_vert_normal = HasVertexNormals();
Expand Down Expand Up @@ -714,7 +713,7 @@ TriangleMesh &TriangleMesh::RemoveDuplicatedTriangles() {
"that are not handled in this function");
}
typedef std::tuple<int, int, int> Index3;
std::unordered_map<Index3, size_t, utility::hash_tuple::hash<Index3>>
std::unordered_map<Index3, size_t, utility::hash_tuple<Index3>>
triangle_to_old_index;
bool has_tri_normal = HasTriangleNormals();
size_t old_triangle_num = triangles_.size();
Expand Down Expand Up @@ -996,11 +995,11 @@ template <typename F>
bool OrientTriangleHelper(const std::vector<Eigen::Vector3i> &triangles,
F &swap) {
std::unordered_map<Eigen::Vector2i, Eigen::Vector2i,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
edge_to_orientation;
std::unordered_set<int> unvisited_triangles;
std::unordered_map<Eigen::Vector2i, std::unordered_set<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
adjacent_triangles;
std::queue<int> triangle_queue;

Expand Down Expand Up @@ -1115,10 +1114,10 @@ bool TriangleMesh::OrientTriangles() {

std::unordered_map<Eigen::Vector2i,
std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
TriangleMesh::GetEdgeToTrianglesMap() const {
std::unordered_map<Eigen::Vector2i, std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
trias_per_edge;
auto AddEdge = [&](int vidx0, int vidx1, int tidx) {
trias_per_edge[GetOrderedEdge(vidx0, vidx1)].push_back(tidx);
Expand All @@ -1134,10 +1133,10 @@ TriangleMesh::GetEdgeToTrianglesMap() const {

std::unordered_map<Eigen::Vector2i,
std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
TriangleMesh::GetEdgeToVerticesMap() const {
std::unordered_map<Eigen::Vector2i, std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
trias_per_edge;
auto AddEdge = [&](int vidx0, int vidx1, int vidx2) {
trias_per_edge[GetOrderedEdge(vidx0, vidx1)].push_back(vidx2);
Expand Down Expand Up @@ -1213,8 +1212,7 @@ Eigen::Vector4d TriangleMesh::GetTrianglePlane(size_t triangle_idx) const {
}

int TriangleMesh::EulerPoincareCharacteristic() const {
std::unordered_set<Eigen::Vector2i,
utility::hash_eigen::hash<Eigen::Vector2i>>
std::unordered_set<Eigen::Vector2i, utility::hash_eigen<Eigen::Vector2i>>
edges;
for (auto triangle : triangles_) {
edges.emplace(GetOrderedEdge(triangle(0), triangle(1)));
Expand Down Expand Up @@ -1630,15 +1628,15 @@ std::shared_ptr<TriangleMesh> TriangleMesh::Crop(

std::unordered_map<Eigen::Vector2i,
double,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
TriangleMesh::ComputeEdgeWeightsCot(
const std::unordered_map<Eigen::Vector2i,
std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
&edges_to_vertices,
double min_weight) const {
std::unordered_map<Eigen::Vector2i, double,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
weights;
for (const auto &edge_v2s : edges_to_vertices) {
Eigen::Vector2i edge = edge_v2s.first;
Expand Down
8 changes: 4 additions & 4 deletions cpp/open3d/geometry/TriangleMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ class TriangleMesh : public MeshBase {
/// triangle indices the given edge belongs to.
std::unordered_map<Eigen::Vector2i,
std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
GetEdgeToTrianglesMap() const;

/// Function that returns a map from edges (vertex0, vertex1) to the
/// vertex (vertex2) indices the given edge belongs to.
std::unordered_map<Eigen::Vector2i,
std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
GetEdgeToVerticesMap() const;

/// Function that computes the area of a mesh triangle
Expand Down Expand Up @@ -729,11 +729,11 @@ class TriangleMesh : public MeshBase {
/// \return cot weight per edge.
std::unordered_map<Eigen::Vector2i,
double,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
ComputeEdgeWeightsCot(
const std::unordered_map<Eigen::Vector2i,
std::vector<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
&edges_to_vertices,
double min_weight = std::numeric_limits<double>::lowest()) const;

Expand Down
11 changes: 5 additions & 6 deletions cpp/open3d/geometry/TriangleMeshSimplification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SimplifyVertexClustering(
};

std::unordered_map<Eigen::Vector3i, std::unordered_set<int>,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxel_vertices;
std::unordered_map<Eigen::Vector3i, int,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxel_vert_ind;
int new_vidx = 0;
for (size_t vidx = 0; vidx < vertices_.size(); ++vidx) {
Expand Down Expand Up @@ -220,8 +220,7 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SimplifyVertexClustering(
}

// connect vertices
std::unordered_set<Eigen::Vector3i,
utility::hash_eigen::hash<Eigen::Vector3i>>
std::unordered_set<Eigen::Vector3i, utility::hash_eigen<Eigen::Vector3i>>
triangles;
for (const auto& triangle : triangles_) {
int vidx0 = voxel_vert_ind[GetVoxelIdx(vertices_[triangle(0)])];
Expand Down Expand Up @@ -333,10 +332,10 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SimplifyQuadricDecimation(
// Get valid edges and compute cost
// Note: We could also select all vertex pairs as edges with dist < eps
std::unordered_map<Eigen::Vector2i, Eigen::Vector3d,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
vbars;
std::unordered_map<Eigen::Vector2i, double,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
costs;
auto CostEdgeComp = [](const CostEdge& a, const CostEdge& b) {
return std::get<0>(a) > std::get<0>(b);
Expand Down
8 changes: 4 additions & 4 deletions cpp/open3d/geometry/TriangleMeshSubdivide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SubdivideMidpoint(
// Also adds edge - new vertex refrence to new_verts map.
auto SubdivideEdge =
[&](std::unordered_map<Eigen::Vector2i, int,
utility::hash_eigen::hash<Eigen::Vector2i>>&
utility::hash_eigen<Eigen::Vector2i>>&
new_verts,
int vidx0, int vidx1) {
int min = std::min(vidx0, vidx1);
Expand Down Expand Up @@ -83,7 +83,7 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SubdivideMidpoint(
};
for (int iter = 0; iter < number_of_iterations; ++iter) {
std::unordered_map<Eigen::Vector2i, int,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
new_verts;
std::vector<Eigen::Vector3i> new_triangles(4 * mesh->triangles_.size());
for (size_t tidx = 0; tidx < mesh->triangles_.size(); ++tidx) {
Expand Down Expand Up @@ -121,10 +121,10 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SubdivideLoop(
"handled in this function");
}
typedef std::unordered_map<Eigen::Vector2i, int,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
EdgeNewVertMap;
typedef std::unordered_map<Eigen::Vector2i, std::unordered_set<int>,
utility::hash_eigen::hash<Eigen::Vector2i>>
utility::hash_eigen<Eigen::Vector2i>>
EdgeTrianglesMap;
typedef std::vector<std::unordered_set<int>> VertexNeighbours;

Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/geometry/VoxelGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ VoxelGrid &VoxelGrid::operator+=(const VoxelGrid &voxelgrid) {
"the other not.");
}
std::unordered_map<Eigen::Vector3i, AvgColorVoxel,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_accpoint;
Eigen::Vector3d ref_coord;
Eigen::Vector3i voxel_index;
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/geometry/VoxelGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class VoxelGrid : public Geometry3D {
/// Voxels contained in voxel grid
std::unordered_map<Eigen::Vector3i,
Voxel,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxels_;
};

Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/geometry/VoxelGridFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::shared_ptr<VoxelGrid> VoxelGrid::CreateFromPointCloudWithinBounds(
output->voxel_size_ = voxel_size;
output->origin_ = min_bound;
std::unordered_map<Eigen::Vector3i, AvgColorVoxel,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_accpoint;
Eigen::Vector3d ref_coord;
Eigen::Vector3i voxel_index;
Expand Down
6 changes: 3 additions & 3 deletions cpp/open3d/ml/impl/misc/VoxelPooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void _VoxelPooling(size_t num_inp,
typedef Eigen::Array<TFeat, Eigen::Dynamic, 1> FeatureVec_t;

std::unordered_map<Eigen::Vector3i, ACCUMULATOR,
open3d::utility::hash_eigen::hash<Eigen::Vector3i>>
open3d::utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_accpoint;

Vec3_t voxel_center;
Expand Down Expand Up @@ -363,7 +363,7 @@ void _VoxelPoolingBackprop(TFeat* features_backprop,
tbb::task_group task_group;

std::unordered_map<Eigen::Vector3i, ACCUMULATOR,
open3d::utility::hash_eigen::hash<Eigen::Vector3i>>
open3d::utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_accpoint;

task_group.run([&] {
Expand All @@ -388,7 +388,7 @@ void _VoxelPoolingBackprop(TFeat* features_backprop,
});

std::unordered_map<Eigen::Vector3i, size_t,
open3d::utility::hash_eigen::hash<Eigen::Vector3i>>
open3d::utility::hash_eigen<Eigen::Vector3i>>
voxelindex_to_gradindex;

task_group.run([&] {
Expand Down
5 changes: 2 additions & 3 deletions cpp/open3d/pipelines/integration/ScalableTSDFVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ void ScalableTSDFVolume::Integrate(
auto pointcloud = geometry::PointCloud::CreateFromDepthImage(
image.depth_, intrinsic, extrinsic, 1000.0, 1000.0,
depth_sampling_stride_);
std::unordered_set<Eigen::Vector3i,
utility::hash_eigen::hash<Eigen::Vector3i>>
std::unordered_set<Eigen::Vector3i, utility::hash_eigen<Eigen::Vector3i>>
touched_volume_units_;
for (const auto &point : pointcloud->points_) {
auto min_bound = LocateVolumeUnit(
Expand Down Expand Up @@ -215,7 +214,7 @@ ScalableTSDFVolume::ExtractTriangleMesh() {
auto mesh = std::make_shared<geometry::TriangleMesh>();
double half_voxel_length = voxel_length_ * 0.5;
std::unordered_map<
Eigen::Vector4i, int, utility::hash_eigen::hash<Eigen::Vector4i>,
Eigen::Vector4i, int, utility::hash_eigen<Eigen::Vector4i>,
std::equal_to<Eigen::Vector4i>,
Eigen::aligned_allocator<std::pair<const Eigen::Vector4i, int>>>
edgeindex_to_vertexindex;
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/pipelines/integration/ScalableTSDFVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ScalableTSDFVolume : public TSDFVolume {
/// to (x + 1, y + 1, z + 1) * volume_unit_length_
std::unordered_map<Eigen::Vector3i,
VolumeUnit,
utility::hash_eigen::hash<Eigen::Vector3i>>
utility::hash_eigen<Eigen::Vector3i>>
volume_units_;

private:
Expand Down
Loading

0 comments on commit 1d89934

Please sign in to comment.