#ifndef ADFCREATOR_CJL #define ADFCREATOR_CJL #include #include "gl/glu.h" #include "gl/gl.h" #include "mathlib.h" #include "langlib.h" #include "ledslib.h" #include "stllib.h" #include "parsestl.h" #include using namespace std; #include "ISDF.h" #include "ADFCreator_debug_flags.h" #include "OctreeADF.h" inline void freeOctreeVtx( octreeVtx *ptr ) { delete ptr->v; delete ptr->Pc; delete ptr; } void RayTracer(octreeNode *ADF); /* Leaf Node Predicate Prototype */ bool isLeafNode (octreeNode *node); /* Are Children Subdivided Predicate Prototype */ bool areChildrenSub (octreeNode *node); /* Is Node Containing Point In, On, or Out "Predicate" Prototype */ int isInOnOut (octreeNode *node, Point *pt); /* Find Node at Next Subdivision Level Which Contains Point Prototype */ octreeNode *whichNode (octreeNode *node, Point *pt); /* Find Smallest Node Which Contains Point Prototype */ octreeNode *findNode (octreeNode *octreeNode, Point *p); /* Trilinear Interpolation Prototype */ double findInterpDist(const octreeNode *node, const Point *pt); /* Classify a Vertex as In, On, or Out Function Prototype */ int classifyVertex (octreeVtx *vtx); /* Classify Octree Node as In, On, or Out Function */ int classifyNode (octreeNode *node); /* Classify Octree Nodes as In, On, or Out Function Prototype */ int classifyOctree (octreeNode *node); /* Create and Initialize a New Octree Node Function Prototype */ //octreeNode *createOctreeNode (void); /* Construct a Cubical Bounding Box for Given STL Function Prototype */ octreeNode *createBoundingBox (CLEDSGeometry *STL); /* Adaptively Sampled Distance Field Octree Top-Down Construction Function Prototype */ void buildTopDownADF (const SDF::ISDF &model, octreeNode *node, double errorLimit , int maxLevels); /* Subdivision for Bottom-Up Construction Function Prototype */ octreeNode *subdivideADF (CLEDSGeometry *STL, octreeNode *node, int subDepth); /* Merging for Bottom-Up Construction Function Prototype */ octreeNode *mergeADF (octreeNode *node, double errorLimit); /* Adaptively Sampled Distance Field Octree Bottom-Up Construction Function Prototype */ octreeNode *buildBottomUpADF (CLEDSGeometry *STL, octreeNode *node, int subDepth, double errorLimit); /* Sampling Predicates */ bool shouldSubNodeFrisken (const SDF::ISDF &model, octreeNode *node, octreeVtx *funcDist[3][3][3], double errorLimit); bool shouldSubNodeRand (CLEDSGeometry *STL, octreeNode *node, octreeVtx *funcDist[3][3][3], double errorLimit); bool shouldSubNodeAddDepth (CLEDSGeometry *STL, octreeNode *node, octreeVtx *funcDist[3][3][3], double errorLimit, double subDepth); /* Magnitude Prototype */ double norm (Vector pt); /* Sign for Double Values Function Prototype */ int sign(float x); /* Index of Maximum Vector Component Prototype */ int maxInd (Vector l); /* Projection Prototype */ Vector proj (Vector A, Vector B); /* Minimum Distance from Triangle to Point Prototype */ octreeVtx *minDistTri (Point P1, Point P2, Point P3, const Point &testPoint, Vector &tri_norm); /* Minimum Distance from STL to Point Prototype */ octreeVtx *minDistSTL(CLEDSGeometry *STL, Point *pt); /* Implicit Distance of Sphere Function Prototype */ octreeVtx *minDistSphere (Point *pt); /* Clear a File Function Prototype */ void clearFile(char* filename); /* Print the Octree Node to a File Function Prototype */ void printNode(octreeNode* node, char* filename); /* Absolute Value for Double Values Function Prototype */ double abs (double num); /* Maximum Value for Double Values Function Prototype */ double max (double num1, double num2, double num3); void renderNode (octreeNode *node); void renderOctree (octreeNode *node); void renderADF (); void displayADF (int *argc, char* argv[]); void saveADF (char* filename); void writeNodes (FILE* file, octreeNode *node,int parentId,int thisId,int octant); //void loadADF (char* filename); //octreeNode *readNodes (std::ifstream file, octreeNode *node); bool MeetsTolerance(double actualDistance , double interpDist , double errorLimit); bool RandomPointCollider(double errorLimit); #endif