#if !defined(AFX_IMINDISTANCE_H__029401C5_EC54_41FD_B8C8_5B65BA17BC4F__INCLUDED_) #define AFX_IMINDISTANCE_H__029401C5_EC54_41FD_B8C8_5B65BA17BC4F__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "mathlib.h" // Point #include "tuples.h" // Pair #include "ADFCreator_debug_flags.h" #include using namespace std; namespace SDF { enum PointClass {INTERIOR, EXTERIOR, DONT_KNOW}; ostream& operator<< (ostream &os, const PointClass &ptclass); class SdfValue { friend ostream& operator<< (ostream &os, const SdfValue &sdf); public: double abs_distance; Point closest_point; Vector gradient; PointClass dist_class; SdfValue(const double &abs_dist, const Point &Pc, const Vector &grad, const PointClass &klass) : abs_distance(abs_dist) , closest_point(Pc) , gradient(grad) , dist_class(klass) { if(!( this->abs_distance >= 0.0f )) { __ERROR__("Someone tried to create an SdfValue with a negative abs_dist: " << this->abs_distance); assert(this->abs_distance >= 0.0f); } } double getSignedDistance() const { if(this->dist_class == INTERIOR) { return this->abs_distance; } else if(this->dist_class == EXTERIOR) { return -1.0f * this->abs_distance; } else { __ERROR__("Someone tried to read a signed distance field, but the distance class was unknown."); assert(false); return 0.0f; } } }; //----------------------- // Implementors should be geometry objects for which // signed distance fields from a given point can be calculated. // // An implementor may or may not use the TriMeshSdfAlgo's. // For example, an implementation for a sphere would not need those algorithms. //----------------------- class ISDF { public: // Make sure this is virtual..pretty important virtual SdfValue calc_sdf_from_pt(const Point &from) const = 0; }; } #endif // !defined(AFX_IMINDISTANCE_H__029401C5_EC54_41FD_B8C8_5B65BA17BC4F__INCLUDED_)