libsurf
Programmer's Documentation

curve.h (r6227/r5844)
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 #ifndef SURF_CURVE_H
16 #define SURF_CURVE_H
17 
18 #include "forward.h"
19 #include "abstractcurve.h"
20 #include <string>
21 #include <boost/shared_ptr.hpp>
22 #include <genua/point.h>
23 #include <genua/splinebasis.h>
24 #include <genua/trafo.h>
25 
35 class Curve : public AbstractCurve
36 {
37 public:
38 
40  explicit Curve(const std::string & name = "NoNameCurve");
41 
43  virtual ~Curve() {}
44 
46  void initSpline(const Vector & knots, const PointList<3> & ctp);
47 
49  void interpolate(const PointList<3> &a);
50 
52  void interpolate(const PointList<3> & a, Vector & u);
53 
55  void interpolate(const PointList<3> &pts, const PointList<3> & tng,
56  Vector & u);
57 
59  void approximate(const PointList<3> & pts, const Vector & uip);
60 
62  void bezier(const Vct3 bp[]);
63 
65  void bezier(const Vct3 &p0, const Vct3 &t0,
66  const Vct3 &p1, const Vct3 &t1);
67 
69  void akima(const PointList<3> &pts);
70 
72  Vct3 eval(Real t) const;
73 
75  Vct3 derive(Real t, uint k) const;
76 
78  void tgline(Real t, Vct3 & c, Vct3 & dc) const;
79 
81  Real curvature(Real t) const;
82 
84  void initGrid(Vector &t) const;
85 
87  Vct3 center() const;
88 
90  const PointList<3> & controls() const {return cp;}
91 
93  PointList<3> & controls() {return cp;}
94 
96  const Vector & knots() const {return bas.getKnots();}
97 
99  void adapt(const Vector & nk);
100 
102  void reverse();
103 
105  void apply();
106 
108  void applyFromXml(const XmlElement & xt);
109 
111  XmlElement trafoToXml() const;
112 
114  virtual XmlElement toXml(bool share = false) const;
115 
117  virtual void fromXml(const XmlElement & xe);
118 
120  virtual Curve *clone() const;
121 
123  virtual int toIges(IgesFile & file, int tfi = 0) const;
124 
126  virtual bool fromIges(const IgesFile & file, const IgesDirEntry & dir);
127 
129  static CurvePtr createFromXml(const XmlElement & xe);
130 
135  static uint arclenParamet(const CurvePtrArray & cpa, Vector & vp);
136 
137 protected:
138 
141 
144 
146  Mtx44 tfs;
147 };
148 
149 inline Curve *new_clone(const Curve & c)
150 {
151  return c.clone();
152 }
153 
154 
155 
156 
157 #endif
158 
Base class for all curve objects.
Definition: abstractcurve.h:31
void initGrid(Vector &t) const
default discretization
Definition: curve.cpp:410
Vct3 eval(Real t) const
evaluate spline curve
Definition: curve.cpp:247
Vct3 center() const
compute line center of control points
Definition: curve.cpp:373
const std::string & name() const
return name
Definition: abstractcurve.h:45
void interpolate(const PointList< 3 > &a)
create curve passing through points a
Definition: curve.cpp:59
virtual bool fromIges(const IgesFile &file, const IgesDirEntry &dir)
extract curve from iges file
Definition: curve.cpp:559
Data in each directory entry of an IGES file.
Definition: igesdirentry.h:31
void tgline(Real t, Vct3 &c, Vct3 &dc) const
compute point and first derivative in one sweep
Definition: curve.cpp:276
const Vector & knots() const
access knot vector
Definition: curve.h:96
void akima(const PointList< 3 > &pts)
generate a closed curve using Akima interpolation
Definition: curve.cpp:220
Main interface to IGES files.
Definition: igesfile.h:32
void applyFromXml(const XmlElement &xt)
apply transformation as contained in Xml representation
Definition: curve.cpp:465
void reverse()
reverse parametrization direction
Definition: curve.cpp:388
SplineBasis bas
DeBoor basis.
Definition: curve.h:140
XmlElement trafoToXml() const
create xml representation for transformation sequence
Definition: curve.cpp:475
Vct3 derive(Real t, uint k) const
compute kth derivative
Definition: curve.cpp:259
static uint arclenParamet(const CurvePtrArray &cpa, Vector &vp)
Parametrization of curve sets.
Definition: curve.cpp:489
void bezier(const Vct3 bp[])
create a single cubic Bezier segment from four Bezier points
Definition: curve.cpp:41
Curve(const std::string &name="NoNameCurve")
default intialization
Definition: curve.cpp:30
Cubic section curve.
Definition: curve.h:35
PointList< 3 > & controls()
access control points
Definition: curve.h:93
PointList< 3 > cp
control points
Definition: curve.h:143
Mtx44 tfs
stores transformation sequence
Definition: curve.h:146
virtual XmlElement toXml(bool share=false) const
XML output.
Definition: curve.cpp:416
void apply()
apply transformation to control points
Definition: curve.cpp:400
virtual void fromXml(const XmlElement &xe)
XML input.
Definition: curve.cpp:430
const Vector & getKnots() const
void initSpline(const Vector &knots, const PointList< 3 > &ctp)
initialize curve from knots and control points
Definition: curve.cpp:35
void adapt(const Vector &nk)
adapt to different knot vector
Definition: curve.cpp:316
static CurvePtr createFromXml(const XmlElement &xe)
static factory function: create a CurvePtr from XML
Definition: curve.cpp:457
virtual int toIges(IgesFile &file, int tfi=0) const
write curve to iges file
Definition: curve.cpp:531
Real curvature(Real t) const
compute curvature at t
Definition: curve.cpp:292
void approximate(const PointList< 3 > &pts, const Vector &uip)
approximate while passing through first/last points
Definition: curve.cpp:171
const PointList< 3 > & controls() const
access control points
Definition: curve.h:90
virtual Curve * clone() const
create a clone
Definition: curve.cpp:484
virtual ~Curve()
virtual destructor
Definition: curve.h:43
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5