Choreonoid  1.8
SceneProjector.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BASE_SCENE_PROJECTOR_H
6 #define CNOID_BASE_SCENE_PROJECTOR_H
7 
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13 class CNOID_EXPORT SceneProjector
14 {
15 public:
16  virtual ~SceneProjector();
17  virtual bool project(const SceneWidgetEvent* event, Vector3& out_projected) const = 0;
18 };
19 
20 
21 class CNOID_EXPORT ScenePlaneProjector : public SceneProjector
22 {
23 public:
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
27  ScenePlaneProjector(const Vector3& normal, const Vector3& point);
28  void setPlane(const Vector3& normal, const Vector3& point);
29 
30  const Vector3& normal() const { return normal_; }
31  double d() const { return d_; }
32 
33  virtual bool project(const SceneWidgetEvent* event, Vector3& out_projected) const;
34 
35 private:
36  Vector3 normal_;
37  double d_;
38 
39  bool calcPlaneLineIntersection(
40  const Vector3& lineStart, const Vector3& lineEnd, Vector3& out_isect) const;
41 };
42 
43 
44 class CNOID_EXPORT SceneCylinderProjector : public SceneProjector
45 {
46 public:
47  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48 
50  SceneCylinderProjector(const Vector3& center, double radius, double height, const Quaternion& rotation);
51 
52  void setCylinder(const Vector3& center, double radius, double height, const Quaternion& rotation);
53 
58  bool initializeProjection(const SceneWidgetEvent* event);
59 
60  virtual bool project(const SceneWidgetEvent* event, Vector3& out_projected) const;
61 
62 protected:
64  double radius_;
65  double height_;
68 
69  bool project(
70  const SceneWidgetEvent* event, Vector3& out_isecFront, Vector3& out_isecBack) const;
71  bool calcUnitCylinderLineIntersection(
72  const Vector3& lineStart, const Vector3& lineEnd, Vector3& out_isectFront, Vector3& out_isectBack) const;
73  bool calcCylinderLineIntersection(
74  const Vector3d& lineStart, const Vector3& lineEnd, Vector3& out_isectFront, Vector3& out_isectBack) const;
75 };
76 
77 }
78 
79 #endif
cnoid::SceneCylinderProjector::rotation_
Quaternion rotation_
Definition: SceneProjector.h:66
cnoid::Quaternion
Eigen::Quaterniond Quaternion
Definition: EigenTypes.h:66
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::SceneCylinderProjector::radius_
double radius_
Definition: SceneProjector.h:64
cnoid::ScenePlaneProjector::d
double d() const
Definition: SceneProjector.h:31
cnoid::SceneCylinderProjector::height_
double height_
Definition: SceneProjector.h:65
cnoid::SceneCylinderProjector::isFrontSurfaceProjection
bool isFrontSurfaceProjection
Definition: SceneProjector.h:67
cnoid::ScenePlaneProjector::normal
const Vector3 & normal() const
Definition: SceneProjector.h:30
cnoid::SceneCylinderProjector
Definition: SceneProjector.h:44
cnoid::SceneWidgetEvent
Definition: SceneWidgetEvent.h:15
cnoid::ScenePlaneProjector
Definition: SceneProjector.h:21
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::SceneCylinderProjector::center_
Vector3 center_
Definition: SceneProjector.h:63
cnoid::SceneProjector
Definition: SceneProjector.h:13
SceneWidgetEventHandler.h