/usr/include/choreonoid-1.1/cnoid/src/Collision/ColdetModel.h is in libcnoid-dev 1.1.0+dfsg-6.1+b4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | /**
@author Shin'ichiro Nakaoka
*/
#ifndef CNOID_COLDET_MODEL_H_INCLUDED
#define CNOID_COLDET_MODEL_H_INCLUDED
#include <string>
#include <vector>
#include <cnoid/EigenTypes>
#include <cnoid/Referenced>
#include "exportdecl.h"
namespace IceMaths {
class Matrix4x4;
}
namespace cnoid {
class ColdetModelSharedDataSet;
class CNOID_EXPORT ColdetModel : public Referenced
{
public:
enum PrimitiveType { SP_MESH, SP_BOX, SP_CYLINDER, SP_CONE, SP_SPHERE, SP_PLANE };
/**
* @brief constructor
*/
ColdetModel();
/**
* @brief copy constructor
*
* Shape information stored in dataSet is shared with org
*/
ColdetModel(const ColdetModel& org);
/**
* @brief destructor
*/
virtual ~ColdetModel();
/**
* @brief set name of this model
* @param name name of this model
*/
inline void setName(const std::string& name) { name_ = name; }
/**
* @brief get name of this model
* @return name name of this model
*/
inline const std::string& name() const { return name_; }
/**
* @brief set the number of vertices
* @param n the number of vertices
*/
void setNumVertices(int n);
/**
* @brief get the number of vertices
* @return the number of vertices
*/
int getNumVertices() const;
/**
* @brief set the number of triangles
* @param n the number of triangles
*/
void setNumTriangles(int n);
int getNumTriangles() const;
/**
* @brief add a vertex
* @param index index of the vertex
* @param x x position of the vertex
* @param y y position of the vertex
* @param z z position of the vertex
*/
void setVertex(int index, float x, float y, float z);
/**
add a vertex to the end of the vector
*/
void addVertex(float x, float y, float z);
/**
* @brief get a vertex
* @param index index of the vertex
* @param out_x x position of the vertex
* @param out_y y position of the vertex
* @param out_z z position of the vertex
*/
void getVertex(int index, float& out_x, float& out_y, float& out_z) const;
/**
* @brief add a triangle
* @param index index of the triangle
* @param v1 index of the first vertex
* @param v2 index of the second vertex
* @param v3 index of the third vertex
*/
void setTriangle(int index, int v1, int v2, int v3);
/**
add a triangle to the end of the vector
*/
void addTriangle(int v1, int v2, int v3);
void getTriangle(int index, int& out_v1, int& out_v2, int& out_v3) const;
/**
* @brief build tree of bounding boxes to accelerate collision check
*
* This method must be called before doing collision check
*/
void build();
/**
* @brief check if build() is already called or not
* @return true if build() is already called, false otherwise
*/
inline bool isValid() const { return isValid_; }
/**
* @brief set position and orientation of this model
* @param R new orientation
* @param p new position
*/
void setPosition(const Matrix3& R, const Vector3& p);
/**
* @brief set position and orientation of this model
* @param R new orientation (length = 9)
* @param p new position (length = 3)
*/
void setPosition(const double* R, const double* p);
/**
* @brief set primitive type
* @param ptype primitive type
*/
void setPrimitiveType(PrimitiveType ptype);
/**
* @brief get primitive type
* @return primitive type
*/
PrimitiveType getPrimitiveType() const;
/**
* @brief set the number of parameters of primitive
* @param nparam the number of parameters of primitive
*/
void setNumPrimitiveParams(unsigned int nparam);
/**
* @brief set a parameter of primitive
* @param index index of the parameter
* @param value value of the parameter
* @return true if the parameter is set successfully, false otherwise
*/
bool setPrimitiveParam(unsigned int index, float value);
/**
* @brief get a parameter of primitive
* @param index index of the parameter
* @param value value of the parameter
* @return true if the parameter is gotten successfully, false otherwise
*/
bool getPrimitiveParam(unsigned int index, float &value) const;
/**
* @brief set position and orientation of primitive
* @param R orientation relative to link (length = 9)
* @param p position relative to link (length = 3)
*/
void setPrimitivePosition(const double* R, const double* p);
/**
* @brief compute distance between a point and this mesh along ray
* @param point a point
* @param dir direction of ray
* @return distance if ray collides with this mesh, FLT_MAX otherwise
*/
double computeDistanceWithRay(const double *point, const double *dir);
/**
* @brief check collision between this triangle mesh and a point cloud
* @param i_cloud points
* @param i_radius radius of spheres assigned to the points
* @return true if colliding, false otherwise
*/
bool checkCollisionWithPointCloud(const std::vector<Vector3> &i_cloud,
double i_radius);
void getBoundingBoxData(const int depth, std::vector<Vector3>& out_boxes);
int getAABBTreeDepth();
int getAABBmaxNum();
int numofBBtoDepth(int minNumofBB);
private:
/**
* @brief common part of constuctors
*/
void initialize();
ColdetModelSharedDataSet* dataSet;
IceMaths::Matrix4x4* transform;
IceMaths::Matrix4x4* pTransform; ///< transform of primitive
std::string name_;
bool isValid_;
friend class ColdetModelPair;
};
typedef boost::intrusive_ptr<ColdetModel> ColdetModelPtr;
}
#endif
|