Lagrange
Loading...
Searching...
No Matches
SmoothedMeshGradientField.h
1/*
2 * Copyright 2026 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/volume/api.h>
16
17#include <Eigen/Core>
18
19// clang-format off
20#include <lagrange/utils/warnoff.h>
21#include <openvdb/openvdb.h>
22#include <openvdb/tools/Interpolation.h>
23#include <lagrange/utils/warnon.h>
24// clang-format on
25
26namespace lagrange::volume {
27
32class LA_VOLUME_API SmoothedMeshGradientField
33{
34public:
35 using Grid = openvdb::Vec3SGrid;
36 using Accessor = Grid::ConstAccessor;
37
49 template <typename Scalar, typename Index>
52 double voxel_size,
53 double epsilon,
54 double query_reach);
55
57 Grid::ConstPtr grid() const { return m_grid; }
58
60 Accessor accessor() const { return m_grid->getConstAccessor(); }
61
72 bool sample_direction(
73 const Eigen::Vector3d& position,
74 Eigen::Vector3d& direction_out,
75 Accessor* accessor = nullptr) const;
76
77private:
78 // The grid is never mutated after construction.
79 Grid::Ptr m_grid;
80};
81
82} // namespace lagrange::volume
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:73
Grid::ConstPtr grid() const
Return a read-only shared handle to the underlying OpenVDB grid.
Definition SmoothedMeshGradientField.h:57
Accessor accessor() const
Return a read-only accessor to the underlying OpenVDB grid.
Definition SmoothedMeshGradientField.h:60
SmoothedMeshGradientField(const SurfaceMesh< Scalar, Index > &mesh, double voxel_size, double epsilon, double query_reach)
Construct a smoothed gradient field for a triangle surface mesh.
Definition SmoothedMeshGradientField.cpp:33