libsurf
Programmer's Documentation

compositecurve.h (r6227/r5902)
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_COMPOSITECURVE_H
16 #define SURF_COMPOSITECURVE_H
17 
18 #include "abstractcurve.h"
19 
32 {
33 public:
34 
36  CompositeCurve(const std::string & s = "") : AbstractCurve(s) {}
37 
39  const Vector & init(const AbstractCurveArray & ca);
40 
42  virtual CompositeCurve *clone() const;
43 
45  virtual Vct3 eval(Real t) const;
46 
48  virtual Vct3 derive(Real t, uint k) const;
49 
51  virtual void apply();
52 
54  virtual void tgline(Real t, Vct3 & c, Vct3 & dc) const;
55 
57  virtual void initGrid(Vector &t) const;
58 
60  uint nSegments() const {return m_curves.size();}
61 
63  AbstractCurvePtr curveSegment(uint k) const {
64  assert(k < m_curves.size());
65  return m_curves[k];
66  }
67 
69  virtual XmlElement toXml(bool share = false) const;
70 
72  virtual void fromXml(const XmlElement & xe);
73 
75  virtual int toIges(IgesFile & file, int tfi = 0) const;
76 
78  virtual bool fromIges(const IgesFile & file, const IgesDirEntry & dir);
79 
81  void flipSegments();
82 
84  void clearSurface() {
85  m_curves.clear();
86  m_tbreak.clear();
87  }
88 
89 protected:
90 
92  uint segment(Real t, Real & ti) const {
93  size_t lb = std::distance(m_tbreak.begin(),
94  std::lower_bound(m_tbreak.begin(),
95  m_tbreak.end(), t) );
96  lb = std::max(size_t(1), std::min(lb, m_tbreak.size()-1) );
97  ti = (t - m_tbreak[lb-1]) / (m_tbreak[lb] - m_tbreak[lb-1]);
98  ti = clamp(ti, 0.0, 1.0);
99  return lb;
100  }
101 
103  void breakPoints();
104 
105 protected:
106 
108  AbstractCurveArray m_curves;
109 
111  Vector m_tbreak;
112 };
113 
114 #endif // COMPOSITECURVE_H
virtual Vct3 derive(Real t, uint k) const
compute kth derivative
Definition: compositecurve.cpp:45
Base class for all curve objects.
Definition: abstractcurve.h:31
uint nSegments() const
number of curve segments
Definition: compositecurve.h:60
const Vector & init(const AbstractCurveArray &ca)
initialize with a set of curves
Definition: compositecurve.cpp:25
uint segment(Real t, Real &ti) const
compute segment for parameter t
Definition: compositecurve.h:92
Composite curve.
Definition: compositecurve.h:31
void flipSegments()
keep segment ordering, but flip segments if needed (called by fromIges())
Definition: compositecurve.cpp:254
Data in each directory entry of an IGES file.
Definition: igesdirentry.h:31
AbstractCurvePtr curveSegment(uint k) const
low-level access to segment curves
Definition: compositecurve.h:63
Main interface to IGES files.
Definition: igesfile.h:32
virtual void initGrid(Vector &t) const
disctretization
Definition: compositecurve.cpp:71
AbstractCurveArray m_curves
constituent curves
Definition: compositecurve.h:108
virtual int toIges(IgesFile &file, int tfi=0) const
write curve to iges file
Definition: compositecurve.cpp:154
void breakPoints()
establish break points based on arclength parametrization
Definition: compositecurve.cpp:89
virtual bool fromIges(const IgesFile &file, const IgesDirEntry &dir)
extract curve from iges file
Definition: compositecurve.cpp:177
Vector m_tbreak
parameter space breakpoints
Definition: compositecurve.h:111
virtual void tgline(Real t, Vct3 &c, Vct3 &dc) const
compute point and first derivative in one sweep
Definition: compositecurve.cpp:63
virtual void apply()
apply hard transformation
Definition: compositecurve.cpp:53
virtual CompositeCurve * clone() const
create a clone
Definition: compositecurve.cpp:32
virtual XmlElement toXml(bool share=false) const
XML output.
Definition: compositecurve.cpp:112
void clearSurface()
erase curve segments
Definition: compositecurve.h:84
CompositeCurve(const std::string &s="")
create undefined curve object
Definition: compositecurve.h:36
virtual void fromXml(const XmlElement &xe)
XML input.
Definition: compositecurve.cpp:129
virtual Vct3 eval(Real t) const
evaluate spline curve
Definition: compositecurve.cpp:37
Generated on Wed Jan 19 2022 03:03:14 for libsurf by   doxygen 1.8.5