Files
ViewDesignEngine/include/vde/sdf/sdf_torch.h
T
茂之钳 08b5854c56
CI / Build & Test (push) Failing after 16m59s
CI / Release Build (push) Failing after 42s
feat(sdf): S12-C PyTorch integration + Python bindings
Add batch evaluation/gradient functions for SDF trees (sdf_torch.h/cpp).
Add sdf_gradient.h with finite-difference gradient utilities.
Add Python modules vde.sdf (high-level SDF API) and vde.torch_sdf (PyTorch autograd).
Add test_sdf_torch_bridge.cpp with batch eval/gradient tests.
Integrate into vde_sdf library and test suite.
2026-07-24 07:20:45 +00:00

36 lines
1.2 KiB
C++

#pragma once
#include "vde/sdf/sdf_gradient.h"
#include "vde/sdf/sdf_tree.h"
#include "vde/core/point.h"
#include <vector>
// This header is optional — only compiled if Torch is available
namespace vde::sdf {
/// Evaluate SDF on a batch of points (for batched computation)
/// @param root SDF tree
/// @param points Flat array of x,y,z triplets (size = 3*n)
/// @param n Number of points
/// @param distances Output array (size = n)
void evaluate_batch(const SdfNodePtr& root,
const double* points, int n,
double* distances);
/// Compute gradients for a batch of points
/// @param root SDF tree
/// @param points Flat array of x,y,z triplets
/// @param n Number of points
/// @param gradients Output array (size = 3*n, interleaved x,y,z)
void gradient_batch(const SdfNodePtr& root,
const double* points, int n,
double* gradients);
/// Compute both values and gradients in one pass
void evaluate_with_gradient_batch(const SdfNodePtr& root,
const double* points, int n,
double* distances,
double* gradients);
} // namespace vde::sdf