Skip to content

Meshing a signed distance function using the libfive C/C++ API #468

Answered by mkeeter
doug-moen asked this question in Q&A
Discussion options

You must be logged in to vote

Your vague notion is correct!

Here's a sketch of an oracle which wraps a function (float, float, float) -> float:

#include "libfive/oracle/oracle_storage.hpp"

class CurvOracle : public libfive::OracleStorage<LIBFIVE_EVAL_ARRAY_SIZE> {
public:
    CurvOracle(std::function<float(float, float, float)> f)
        : f(f)
    {
        // Nothing to do here
    }

    void evalInterval(libfive::Interval& out) override {
        // Just pick a big ambiguous value.
        out = {-10000.0, 10000.0};
    }

    void evalPoint(float& out, size_t index=0) override {
        const auto pt = points.col(index);
        out = f(pt.x(), pt.y(), pt.z());
    }

    void checkAmbiguous(
            Eigen:…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mkeeter
Comment options

You must be logged in to vote
3 replies
@doug-moen
Comment options

@mkeeter
Comment options

@doug-moen
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants