Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

2.5 KB
Raw Blame
#pragma once
#include <memory>
#include "rust/cxx.h"

#include "rust/cxx.h"
#include <cstddef>

namespace carbon_fcl {
struct Contact;          // generated by cxx from the shared struct
struct InternalContact;  // generated by cxx from the shared struct
struct SingleContact;    // generated by cxx from the shared struct

// Wrapper around fcl::BVHModel<fcl::OBBRSS<double>>. Type-erased so this header
// (included by cxx-generated glue) stays complete without pulling in FCL/Eigen;
// shim.cc casts `model` back to the concrete BVH model.
struct Bvh {
  std::shared_ptr<void> model;
};

// Broadphase manager (type-erased, same rationale as Bvh).
struct Manager {
  std::shared_ptr<void> impl;
};

uint64_t raw_contacts_enumerated();
uint64_t narrow_pairs_run();

std::unique_ptr<Manager> manager_new();
void manager_add(Manager &m, const Bvh &bvh);
void manager_setup(Manager &m);
rust::Vec<InternalContact> manager_internal_contacts(const Manager &m, size_t num_max_contacts);
void manager_set_active(Manager &m, size_t index, bool active);
rust::Vec<SingleContact> manager_collide_single(const Manager &m, const Bvh &moving,
                                                int64_t moving_index, double tx, double ty,
                                                double tz, size_t num_max_contacts);
rust::Vec<SingleContact> manager_collide_single_multi(const Manager &m, const Bvh &moving,
                                                      rust::Slice<const int64_t> skip_indices,
                                                      double tx, double ty, double tz,
                                                      size_t num_max_contacts);
rust::Vec<SingleContact> manager_classify_multi(const Manager &m, const Bvh &moving,
                                                rust::Slice<const int64_t> skip_indices,
                                                rust::Slice<const int64_t> ov_idx,
                                                rust::Slice<const double> ov_am, double tx,
                                                double ty, double tz, double tol,
                                                bool want_touch_near, size_t num_max_contacts);

std::unique_ptr<Bvh> new_bvh(rust::Slice<const double> verts,
                             rust::Slice<const uint32_t> tris);

rust::Vec<Contact> collide_pair(const Bvh &a, double ax, double ay, double az,
                                const Bvh &b, double bx, double by, double bz,
                                size_t num_max_contacts);

double distance_pair(const Bvh &a, const Bvh &b);
}  // namespace carbon_fcl