// SimplerConvexUmbrellaSdfAlgo.h: interface for the SimplerConvexUmbrellaSdfAlgo class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_SIMPLERCONVEXUMBRELLASDFALGO_H__C48F190F_B16C_461B_9AAB_1872F1E833D1__INCLUDED_) #define AFX_SIMPLERCONVEXUMBRELLASDFALGO_H__C48F190F_B16C_461B_9AAB_1872F1E833D1__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "ConvexUmbrellaTriMeshSdfAlgorithm.h" namespace SDF { //-------------------------------- // 2005-12-06 UPDATE - Actually..this is unsound. Consider the juice squeezer shape.. // none of its faces would lie on the convex hull.. // // (Steve) // This is a simpler variation of the convex umbrella algorithm. // Instead of projecting umbrella edges onto p_perp, we simply // look for a triangle that must be on the convex umbrella. // // We do this by going through every triangle, and calculating other triangles' // relative positions to it. There are three possible relative positions: // COPLANAR - the two triangles are co-planar // B_BEHIND_A - tri B is behind A - meaning its centroid is behind A's face plane // B_INFRONT_A - ditto. // For any triangle A, if there exists two triangles B1 B2 such that B1 is behind // and B2 is in front, then A must NOT be a face on the convex umbrella. // But if B1 and B2 do not exist, then all other triangles B are either coplanar, // or ALL have relative position p - where p is either BEHIND or INFRONT. // If p is BEHIND, we classify the point as outside. // If p is INFRONT, we classify the point as inside. // //-------------------------------- class SimplerConvexUmbrellaSdfAlgo : public ConvexUmbrellaTriMeshSdfAlgorithm { protected: enum RelativePosition {COPLANAR, B_BEHIND_A, B_INFRONT_A, RELPOS_DONT_KNOW}; //-------------------------------- // This assumes a and b share at least one vertex - ie. they're both part // of an umbrella. We do NOT assume they share an edge. // NOTE: This function is NOT commutative, ie. rel_pos(a,b) != rel_pos(b,a) //-------------------------------- RelativePosition calc_relative_position_of_umbrella_tris( const MeshTriangle &a, const MeshTriangle &b ) { RelativePosition out = RELPOS_DONT_KNOW; if( a.norm == b.norm ) { out = COPLANAR; } else if(b.is_behind(a)) { out = B_BEHIND_A; } else { // B must be in front. out = B_INFRONT_A; } return out; } public: SimplerConvexUmbrellaSdfAlgo(); virtual ~SimplerConvexUmbrellaSdfAlgo(); PointClass classify_pt_by_umbrella_tris( const TriangleList &tris, const Point &x, const Point &p); }; } #endif // !defined(AFX_SIMPLERCONVEXUMBRELLASDFALGO_H__C48F190F_B16C_461B_9AAB_1872F1E833D1__INCLUDED_)