3 #if (defined __APPLE__) 4 #include <pcl/surface/qhull.h> 6 #include <qhull/qhull_a.h> 23 int ptype = i_link->
coldetModel->getPrimitiveType();
28 std::vector<Vector3> boundingBoxData;
29 i_link->
coldetModel->getBoundingBoxData(0, boundingBoxData);
30 if (boundingBoxData.size() != 2){
31 std::cerr <<
"unexpected bounding box data size(" << i_link->
name 32 <<
", " << boundingBoxData.size() <<
")" << std::endl;
35 const Vector3 &
c = boundingBoxData[0];
36 const Vector3 &s = boundingBoxData[1];
38 coldetModel->setName(std::string(i_link->
name.c_str()));
40 coldetModel->setNumPrimitiveParams(3);
41 for (
int i=0;
i<3;
i++){
42 coldetModel->setPrimitiveParam(
i, s[
i]);
44 double R[] = {1,0,0,0,1,0,0,0,1};
45 coldetModel->setPrimitivePosition(R, c.data());
46 coldetModel->setNumVertices(8);
47 coldetModel->setVertex(0, c[0]+s[0], c[1]+s[1], c[2]+s[2]);
48 coldetModel->setVertex(1, c[0]-s[0], c[1]+s[1], c[2]+s[2]);
49 coldetModel->setVertex(2, c[0]-s[0], c[1]-s[1], c[2]+s[2]);
50 coldetModel->setVertex(3, c[0]+s[0], c[1]-s[1], c[2]+s[2]);
51 coldetModel->setVertex(4, c[0]+s[0], c[1]+s[1], c[2]-s[2]);
52 coldetModel->setVertex(5, c[0]-s[0], c[1]+s[1], c[2]-s[2]);
53 coldetModel->setVertex(6, c[0]-s[0], c[1]-s[1], c[2]-s[2]);
54 coldetModel->setVertex(7, c[0]+s[0], c[1]-s[1], c[2]-s[2]);
55 int numTriangles = 12;
56 coldetModel->setNumTriangles(numTriangles);
57 int triangles[] = {0,2,3,
69 for(
int j=0;
j < numTriangles; ++
j){
70 int t0 = triangles[
j*3];
71 int t1 = triangles[
j*3+1];
72 int t2 = triangles[
j*3+2];
73 coldetModel->setTriangle(
j, t0, t1, t2);
81 for (
unsigned int i=0;
i<i_body->numLinks();
i++){
90 int ptype = i_link->
coldetModel->getPrimitiveType();
96 coldetModel->setName(i_link->
name.c_str());
99 int numVertices = i_link->
coldetModel->getNumVertices();
100 double points[numVertices*3];
102 for (
int i=0;
i<numVertices;
i++){
104 points[
i*3+0] = v[0];
105 points[
i*3+1] = v[1];
106 points[
i*3+2] = v[2];
109 boolT ismalloc = False;
111 if (qh_new_qhull (3,numVertices,points,ismalloc,flags,NULL,stderr))
return;
114 qh_vertexneighbors();
116 coldetModel->setNumVertices(qh num_vertices);
117 coldetModel->setNumTriangles(qh num_facets);
118 int index[numVertices];
122 int p = qh_pointid(vertex->point);
123 index[p] = vertexIndex;
124 coldetModel->setVertex(vertexIndex++, points[p*3+0], points[p*3+1], points[p*3+2]);
127 int num = qh num_facets;
128 int triangleIndex = 0;
131 setT *vertices = qh_facet3vertex (facet);
133 FOREACHvertexreverse12_ (vertices) {
135 p[j] = index[qh_pointid(vertex->point)];
137 fprintf(stderr,
"extra vertex %d\n",j);
141 coldetModel->setTriangle(triangleIndex++, p[0], p[1], p[2]);
144 coldetModel->build();
147 qh_freeqhull(!qh_ALL);
148 int curlong, totlong;
149 qh_memfreeshort (&curlong, &totlong);
150 if (curlong || totlong) {
151 fprintf(stderr,
"convhulln: did not free %d bytes of long memory (%d pieces)\n", totlong, curlong);
void convertToAABB(hrp::BodyPtr i_body)
ColdetModelPtr coldetModel
void convertToConvexHull(hrp::BodyPtr i_body)
def j(str, encoding="cp932")
std::string sprintf(char const *__restrict fmt,...)
boost::intrusive_ptr< ColdetModel > ColdetModelPtr