Debian Codegraph @

tools/physicalModeling/mesh2faust/vega/libraries/objMesh/objMeshOctree.h

raw symbols SCIP
1 /*************************************************************************
2 * *
3 * Vega FEM Simulation Library Version 3.1 *
4 * *
5 * "objMesh" library , Copyright (C) 2007 CMU, 2009 MIT, 2016 USC *
6 * All rights reserved. *
7 * *
8 * Code authors: Jernej Barbic, Christopher Twigg, Daniel Schroeder *
9 * http://www.jernejbarbic.com/code *
10 * *
11 * Research: Jernej Barbic, Fun Shing Sin, Daniel Schroeder, *
12 * Doug L. James, Jovan Popovic *
13 * *
14 * Funding: National Science Foundation, Link Foundation, *
15 * Singapore-MIT GAMBIT Game Lab, *
16 * Zumberge Research and Innovation Fund at USC *
17 * *
18 * This library is free software; you can redistribute it and/or *
19 * modify it under the terms of the BSD-style license that is *
20 * included with this library in the file LICENSE.txt *
21 * *
22 * This library is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file *
25 * LICENSE.TXT for more details. *
26 * *
27 *************************************************************************/
28
29 #ifndef _OBJMESHOCTREE_H_
30 #define _OBJMESHOCTREE_H_
31
32 // Jernej Barbic, CMU
33 // builds an octree on top of the geometry from a given obj file
34 // Can be intersected with a sphere or a line segment.
35
36 #include "octree.h"
37 #include "objMesh.h"
38
39 template<class TriangleClass>
40 class ObjMeshOctree
41 {
42 public:
43 // builds an octree on top of the objMesh
44 // maxNumTrianglesInLeafNode = max number of triangles in an octree leaf node
45 // maxTreeDepth = max tree depth
46 // (if tree depth were to exceed maxTreeDepth, a leaf node may have more than maxNumTrianglesInLeafNode triangles)
47 ObjMeshOctree(const ObjMesh * objMesh, int maxNumTrianglesInLeafNode, int maxTreeDepth, int printInfo = 0);
48 ~ObjMeshOctree() { delete(root); }
49
50 // sphere-triangles query
51 // retrieves all triangles intersected by the sphere
52 // (can potentially return the same triangle several times; call <TriangleClass>::makeUniqueList to make the list unique if needed)
53 void rangeQuery(std::vector< TriangleClass* > & triangleList, const SimpleSphere & simpleSphere)
54 { root->buildCollisionList(triangleList, simpleSphere); }
55
56 // line segment-triangles query
57 // retrieves all triangles intersected by the line segment
58 // (can potentially return the same triangle several times; call <TriangleClass>::makeUniqueList to make the list unique if needed)
59 void lineSegmentIntersection(std::vector< TriangleClass* > & triangleList, const Vec3d & segmentStart, const Vec3d & segmentEnd, std::vector<Vec3d> * intersectionList = NULL)
60 { root->buildCollisionList(triangleList, segmentStart, segmentEnd, intersectionList); }
61
62 void renderOctree() { root->render(); }
63 void renderOctree(int level) { root->render(level); }
64 void renderOctree(int level, int boxIndex) { root->render(level, boxIndex); }
65 void setPrintOctreeInfo(int info) { root->setRenderInfo(info); }
66
67 BoundingBox boundingBox() { return (root->getBoundingBox()) ; }
68
69 protected:
70 std::vector<TriangleClass> triangles;
71
72 Octree<TriangleClass> * root;
73 int maxNumTrianglesInLeafNode; // max number of triangles in an octree leaf node
74 int maxTreeDepth; // max tree depth
75
76 static const double bboxExpansionRatio;
77 };
78
79 #endif
80