OpenCOVER
coLine.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8#ifndef CO_LINE
9#define CO_LINE
10
11#include <osg/Geometry>
12#include <osg/Geode>
13#include <util/coExport.h>
14
15namespace opencover
16{
17class PLUGIN_UTILEXPORT coLine
18{
19
20private:
21 bool _show;
22 osg::Vec3 _dirVec;
23 osg::Vec3 _point1;
24 osg::Vec3 _point2;
25 osg::Vec4 _color;
26 osg::ref_ptr<osg::Vec3Array> _vertices;
27 osg::ref_ptr<osg::Vec4Array> _colors;
28 osg::ref_ptr<osg::Geometry> _geom;
29 osg::ref_ptr<osg::Geode> _geode;
30
31 void drawLine();
32
33
34public:
35 coLine(osg::Vec3 point1, osg::Vec3 point2, bool show = false, osg::Vec4 color = osg::Vec4(1,0,0,1));
36 virtual ~coLine();
37
38 // update line
39 virtual void update(osg::Vec3 point1, osg::Vec3 point2);
40
41 // return current position
42 osg::Vec3 getPosition() const
43 {
44 return _point1;
45 };
46
47 // return current direction vector
48 osg::Vec3 getDirectionVector() const
49 {
50 return _dirVec;
51 };
52
53 // get the shortest distance between two infinite lines (Gerade)
54 // returns true, if a shortest distance can be calculated
55 // false if the two lines are parallel
56 bool getShortestLineDistance(const osg::Vec3 &lp1, const osg::Vec3 &lp2, double &shortestDistance) const;
57
58 // find the two points X1 on Line1 and X2 on Line2 such that the distance between X1 and X2 is minimal
59 // returns true is lines are skew and a point of shortest distance can be calculated
60 // returns false if the two lines are parallel
61 // lp1 and lp2 are the two points which create the Line2
62 // Line 1 ist the this coLine object
63 bool getPointsOfShortestDistance(const osg::Vec3 &lp1, const osg::Vec3 &lp2, osg::Vec3& pointLine1, osg::Vec3& pointLine2) const;
64
65
66 void setColor(osg::Vec4 color);
67 void show();
68 void hide();
69};
70}
71#endif
Definition: ARToolKit.h:33
Definition: coLine.h:18
bool getShortestLineDistance(const osg::Vec3 &lp1, const osg::Vec3 &lp2, double &shortestDistance) const
void setColor(osg::Vec4 color)
osg::Vec3 getPosition() const
Definition: coLine.h:42
virtual void update(osg::Vec3 point1, osg::Vec3 point2)
coLine(osg::Vec3 point1, osg::Vec3 point2, bool show=false, osg::Vec4 color=osg::Vec4(1, 0, 0, 1))
osg::Vec3 getDirectionVector() const
Definition: coLine.h:48
bool getPointsOfShortestDistance(const osg::Vec3 &lp1, const osg::Vec3 &lp2, osg::Vec3 &pointLine1, osg::Vec3 &pointLine2) const