libsurf
Programmer's Documentation

linecurve.h (r6227/r5385)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 
16 #ifndef SURF_LINECURVE_H
17 #define SURF_LINECURVE_H
18 
19 #include "abstractcurve.h"
20 
32 class LineCurve : public AbstractCurve
33 {
34 public:
35 
37  LineCurve(const std::string & s = std::string()) : AbstractCurve(s) {}
38 
40  virtual LineCurve *clone() const {return (new LineCurve(*this));}
41 
43  Vct3 eval(Real t) const {
44  assert(t >= 0 and t <= 1);
45  return (1.0-t)*pStart + t*pEnd;
46  }
47 
49  Vct3 derive(Real t, uint k) const {
50  if (k == 0)
51  return eval(t);
52  else if (k == 1)
53  return pEnd - pStart;
54  else
55  return Vct3();
56  }
57 
59  void apply();
60 
62  void tgline(Real t, Vct3 & c, Vct3 & dc) const {
63  c = eval(t);
64  dc = pEnd - pStart;
65  }
66 
68  Real curvature(Real) const {return 0.0;}
69 
71  void initGrid(Vector & t) const;
72 
74  virtual XmlElement toXml(bool share = false) const;
75 
77  virtual void fromXml(const XmlElement & xe);
78 
80  virtual int toIges(IgesFile & file, int tfi = 0) const;
81 
83  virtual bool fromIges(const IgesFile & file, const IgesDirEntry & dir);
84 
85 private:
86 
88  Vct3 pStart;
89 
91  Vct3 pEnd;
92 };
93 
94 #endif // LINECURVE_H
Vct3 derive(Real t, uint k) const
compute kth derivative
Definition: linecurve.h:49
Base class for all curve objects.
Definition: abstractcurve.h:31
Vct3 pStart
start point
Definition: linecurve.h:88
Data in each directory entry of an IGES file.
Definition: igesdirentry.h:31
Vct3 pEnd
end point
Definition: linecurve.h:91
Real curvature(Real) const
compute curvature at t
Definition: linecurve.h:68
Straight line segment with AbstractCurve interface.
Definition: linecurve.h:32
Main interface to IGES files.
Definition: igesfile.h:32
virtual int toIges(IgesFile &file, int tfi=0) const
write curve to iges file
Definition: linecurve.cpp:73
virtual LineCurve * clone() const
create a clone
Definition: linecurve.h:40
virtual bool fromIges(const IgesFile &file, const IgesDirEntry &dir)
extract curve from iges file
Definition: linecurve.cpp:52
void apply()
apply hard transformation
Definition: linecurve.cpp:29
LineCurve(const std::string &s=std::string())
create undefined curve
Definition: linecurve.h:37
void initGrid(Vector &t) const
generate a reasonable discretization
Definition: linecurve.cpp:22
void tgline(Real t, Vct3 &c, Vct3 &dc) const
compute point and first derivative in one sweep
Definition: linecurve.h:62
virtual void fromXml(const XmlElement &xe)
XML input.
Definition: linecurve.cpp:45
virtual XmlElement toXml(bool share=false) const
XML output.
Definition: linecurve.cpp:36
Vct3 eval(Real t) const
evaluate spline curve
Definition: linecurve.h:43
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5