opennurbs_curveonsurface.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_CURVE_ON_SURFACE_INC_)
18 #define OPENNURBS_CURVE_ON_SURFACE_INC_
19 
20 class ON_CLASS ON_CurveOnSurface : public ON_Curve
21 {
22  ON_OBJECT_DECLARE(ON_CurveOnSurface);
23 
24 public:
25  ON_CurveOnSurface() ON_NOEXCEPT;
26 
27  /*
28  Remarks:
29  Deletes m_c2, m_c3, and m_s. Use ON_CurveProxy or ON_SurfaceProxy
30  if you need to use curves or a surface that you do not want deleted.
31  */
32  virtual ~ON_CurveOnSurface();
33 
34 private:
35  ON_CurveOnSurface(const ON_CurveOnSurface&); // no implementation
36 
37 private:
38  ON_CurveOnSurface& operator=(const ON_CurveOnSurface&); // no implementation
39 
40 #if defined(ON_HAS_RVALUEREF)
41 public:
42  // rvalue copy constructor
43  ON_CurveOnSurface( ON_CurveOnSurface&& ) ON_NOEXCEPT;
44 
45  // The rvalue assignment operator calls ON_Object::operator=(ON_Object&&)
46  // which could throw exceptions. See the implementation of
47  // ON_Object::operator=(ON_Object&&) for details.
49 #endif
50 
51 public:
52  /*
53  Parameters:
54  p2dCurve - [in] ~ON_CurveOnSurface() will delete this curve.
55  Use an ON_CurveProxy if you don't want the original deleted.
56  p3dCurve - [in] ~ON_CurveOnSurface() will delete this curve.
57  Use an ON_CurveProxy if you don't want the original deleted.
58  pSurface - [in] ~ON_CurveOnSurface() will delete this surface.
59  Use an ON_SurfaceProxy if you don't want the original deleted.
60  */
61  ON_CurveOnSurface( ON_Curve* p2dCurve, // required 2d curve
62  ON_Curve* p3dCurve, // optional 3d curve
63  ON_Surface* pSurface // required surface
64  );
65 
66  // virtual ON_Object::SizeOf override
67  unsigned int SizeOf() const override;
68 
69 
70  /////////////////////////////////////////////////////////////////
71  // ON_Object overrides
72 
73  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
74 
75  void Dump( ON_TextLog& ) const override; // for debugging
76 
77  bool Write(
78  ON_BinaryArchive& // open binary file
79  ) const override;
80 
81  bool Read(
82  ON_BinaryArchive& // open binary file
83  ) override;
84 
85  /////////////////////////////////////////////////////////////////
86  // ON_Geometry overrides
87 
88  int Dimension() const override;
89 
90  // virtual ON_Geometry GetBBox override
91  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
92 
93  bool Transform(
94  const ON_Xform&
95  ) override;
96 
97  // (optional - default uses Transform for 2d and 3d objects)
98  bool SwapCoordinates(
99  int, int // indices of coords to swap
100  ) override;
101 
102  /////////////////////////////////////////////////////////////////
103  // ON_Curve overrides
104 
105  ON_Interval Domain() const override;
106 
107  int SpanCount() const override; // number of smooth spans in curve
108 
109  bool GetSpanVector( // span "knots"
110  double* // array of length SpanCount() + 1
111  ) const override; //
112 
113  int Degree( // returns maximum algebraic degree of any span
114  // ( or a good estimate if curve spans are not algebraic )
115  ) const override;
116 
117 
118  // (optional - override if curve is piecewise smooth)
119  bool GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
120  double, // t = parameter in domain
121  double*, // tminus
122  double* // tplus
123  ) const override;
124 
125  bool IsLinear( // true if curve locus is a line segment between
126  // between specified points
127  double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
128  ) const override;
129 
130  bool IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
131  // specified points
132  const ON_Plane* = nullptr, // if not nullptr, test is performed in this plane
133  ON_Arc* = nullptr, // if not nullptr and true is returned, then arc parameters
134  // are filled in
135  double = ON_ZERO_TOLERANCE // tolerance to use when checking
136  ) const override;
137 
138  bool IsPlanar(
139  ON_Plane* = nullptr, // if not nullptr and true is returned, then plane parameters
140  // are filled in
141  double = ON_ZERO_TOLERANCE // tolerance to use when checking
142  ) const override;
143 
144  bool IsInPlane(
145  const ON_Plane&, // plane to test
146  double = ON_ZERO_TOLERANCE // tolerance to use when checking
147  ) const override;
148 
149  bool IsClosed( // true if curve is closed (either curve has
150  void // clamped end knots and euclidean location of start
151  ) const override; // CV = euclidean location of end CV, or curve is
152  // periodic.)
153 
154  bool IsPeriodic( // true if curve is a single periodic segment
155  void
156  ) const override;
157 
158  bool Reverse() override; // reverse parameterizatrion
159  // Domain changes from [a,b] to [-b,-a]
160 
161  bool Evaluate( // returns false if unable to evaluate
162  double, // evaluation parameter
163  int, // number of derivatives (>=0)
164  int, // array stride (>=Dimension())
165  double*, // array of length stride*(ndir+1)
166  int = 0, // optional - determines which side to evaluate from
167  // 0 = default
168  // < 0 to evaluate from below,
169  // > 0 to evaluate from above
170  int* = 0 // optional - evaluation hint (int) used to speed
171  // repeated evaluations
172  ) const override;
173 
174  int GetNurbForm( // returns 0: unable to create NURBS representation
175  // with desired accuracy.
176  // 1: success - returned NURBS parameterization
177  // matches the curve's to wthe desired accuracy
178  // 2: success - returned NURBS point locus matches
179  // the curve's to the desired accuracy but, on
180  // the interior of the curve's domain, the
181  // curve's parameterization and the NURBS
182  // parameterization may not match to the
183  // desired accuracy.
184  ON_NurbsCurve&,
185  double = 0.0,
186  const ON_Interval* = nullptr // OPTIONAL subdomain of 2d curve
187  ) const override;
188 
189  /////////////////////////////////////////////////////////////////
190  // Interface
192  // ~ON_CurveOnSurface() deletes these classes. Use a
193  // ON_CurveProxy and/or ON_SurfaceProxy wrapper if you don't want
194  // the destructor to destroy the curves
195  ON_Curve* m_c2; // REQUIRED parameter space (2d) curve
196  ON_Curve* m_c3; // OPTIONAL 3d curve (approximation) to srf(crv2(t))
197  ON_Surface* m_s;
198 };
199 
200 
201 #endif
virtual bool IsClosed() const
Test a curve to see if it is closed.
virtual int SpanCount() const =0
Get number of nonempty smooth (c-infinity) spans in curve
virtual int Dimension() const
Dimension of the object.
An ON_Arc is a subcurve of 3d circle.
Definition: opennurbs_arc.h:33
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
This is the virtual function that actually calculates axis aligned bounding boxes.
virtual bool IsArc(const ON_Plane *plane=nullptr, ON_Arc *arc=nullptr, double tolerance=ON_ZERO_TOLERANCE) const
Test a curve to see if the locus if its points is an arc or circle.
virtual bool GetSpanVector(double *knots) const =0
Get number of parameters of "knots".
virtual bool Reverse()=0
Reverse the direction of the curve.
virtual bool GetParameterTolerance(double t, double *tminus, double *tplus) const
Returns maximum algebraic degree of any span or a good estimate if curve spans are not algebraic...
ON_Curve is a pure virtual class for curve objects
Definition: opennurbs_curve.h:93
Definition: opennurbs_curveonsurface.h:20
virtual int GetNurbForm(ON_NurbsCurve &nurbs_curve, double tolerance=0.0, const ON_Interval *subdomain=nullptr) const
Get a NURBS curve representation of this curve.
virtual int Degree() const =0
Returns maximum algebraic degree of any span or a good estimate if curve spans are not algebraic...
virtual bool IsPlanar(ON_Plane *plane=nullptr, double tolerance=ON_ZERO_TOLERANCE) const
Test a curve to see if it is planar.
virtual bool SwapCoordinates(int i, int j)
Swaps object coordinate values with indices i and j.
virtual bool IsInPlane(const ON_Plane &test_plane, double tolerance=ON_ZERO_TOLERANCE) const =0
Test a curve to see if it lies in a specific plane.
bool Transform(const ON_Xform &xform) override
overrides virtual ON_Geometry::Transform(). ON_Curve::Transform() calls ON_Geometry::Transform(xform)...
Definition: opennurbs_xform.h:28
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
ON_Curve & operator=(const ON_Curve &)
virtual bool IsPeriodic() const
Test a curve to see if it is periodic.
virtual bool Evaluate(double t, int der_count, int v_stride, double *v, int side=0, int *hint=0) const =0
This evaluator actually does all the work. The other ON_Curve evaluation tools call this virtual func...
Definition: opennurbs_nurbscurve.h:26
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
virtual bool Read(ON_BinaryArchive &binary_archive)
Low level archive writing tool used by ON_BinaryArchive::ReadObject().
bool IsValid(class ON_TextLog *text_log=nullptr) const override
Tests an object to see if its data members are correctly initialized.
virtual bool Write(ON_BinaryArchive &binary_archive) const
Low level archive writing tool used by ON_BinaryArchive::WriteObject().
Definition: opennurbs_plane.h:20
Definition: opennurbs_surface.h:57
unsigned int SizeOf() const override
virtual ON_Object::SizeOf override
virtual bool IsLinear(double tolerance=ON_ZERO_TOLERANCE) const
Test a curve to see if the locus if its points is a line segment.
Definition: opennurbs_point.h:46
virtual ON_Interval Domain() const =0