/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGTrimmedCurve_HH_ #define _MGTrimmedCurve_HH_ #include #include "mg/Default.h" #include "mg/Pvector.h" #include "mg/Interval.h" #include "mg/Box.h" #include "mg/Position.h" #include "mg/Position_list.h" #include "mg/LBRep.h" #include "mg/RLBRep.h" #include "mg/Ellipse.h" #include "mg/Straight.h" #include "mg/BSumCurve.h" //Define MGTrimmedCurve Class. class MGInterval; class MGBox; class MGVector; class MGUnit_vector; class MGPosition; class MGTransf; class MGCParam_list; class MGStraight; class MGEllipse; class MGCompositeCurve; class MGKnotVector; class MGLBRep; class MGRLBRep; class MGSurface; class MGCCisect_list; class MGCSisect_list; class MGIfstream; class MGOfstream; /** @file */ /** @addtogroup GEO * @{ */ ///MGTrimmedCurve is a part of an original curve of a limitted parameter range. ///MGTrimmedCurve is a part of original curve that has limitted parameter range. ///MGTrimmedCurve is a temporal curve, and does not have update functions. class MG_DLL_DECLR MGTrimmedCurve:public MGCurve{ public: MG_DLL_DECLR friend MGTrimmedCurve operator+ (const MGVector& v, const MGTrimmedCurve& cv2); MG_DLL_DECLR friend MGTrimmedCurve operator* (double scale, const MGTrimmedCurve& cv2); //////////// Constructor ///////// MGTrimmedCurve(); MGTrimmedCurve(const MGTrimmedCurve& tc);///copy constructor. MGTrimmedCurve(const MGCurve& crv, const MGInterval range); ///subcurve of the input curve crv from t1 to t2. ///t1 may be >t2. In this case, the curve will be from t2 to t1. MGTrimmedCurve(const MGCurve& crv, double t1, double t2); ////////////Destructor//////////// ~MGTrimmedCurve(); //////////// Operator overload(演算子多重定義) ///////// ///Assignment. ///When the leaf object of this and crv2 are not equal, this assignment ///does nothing. MGTrimmedCurve& operator=(const MGGel& gel2); MGTrimmedCurve& operator=(const MGTrimmedCurve& el2); ///Logical operator overload(論理演算子多重定義) /// 2つの曲線が等しいかどうか比較し判定する。 ///Comparison of two curves. bool is_same_curve(const MGCurve& curve2)const; bool operator==(const MGTrimmedCurve& gel2)const; bool operator==(const MGCompositeCurve& gel2)const; bool operator==(const MGGel& gel2)const; bool operator<(const MGTrimmedCurve& gel2)const; bool operator<(const MGGel& gel2)const; //////////// Member Function //////////// ///Approximate this curve as a MGLBRep curve ///within the tolerance MGTolerance::line_zero(). ///When parameter_normalization=0, reparameterization will not done, and ///the evaluation at the same parameter has the same values before and after ///of approximate_as_LBRep. void approximate_as_LBRep( MGLBRep& lb,///& vecComSpan ( /O) 共通部分のパラメータ範囲 /// 4nの配列で、vecComSpan(4*i+0),vecComSpan(4*i+1)が自身のパラメータ範囲 /// (vecComSpan(4*i+0) < vecComSpan(4*i+1))、 /// vecComSpan(4*i+2),vecComSpan(4*i+3)がcurve2のパラメータ範囲 /// MGCCisect_list& isect ( /O) 交点 ///戻り値: /// 3:交点も共通部分も求まった /// 2:交点のみが求まった /// 1:共通部分のみが求まった /// 0:交点も共通部分もなかった /// -1:共通エッジの収束計算エラー /// -2:共通エッジが4個以上求まった(のっていないと見なす) ///追記: /// 曲線が共通かどうかの誤差にはline_zero()、をパラメータ範囲の収束計算の /// 誤差には、パラメータ範囲*rc_zero()を使用した int common( const MGCurve& curve2, std::vector& vecComSpan, MGCCisect_list& isect ) const; ///目的:与えられた曲線と自身の共通部分があるかどうか調べる。 ///引数: /// const MGCurve& curve2, (I/ ) 与えられる曲線 /// std::vector& vecComSpan ( /O) 共通部分のパラメータ範囲 /// 4nの配列で、vecComSpan(4*i+0),vecComSpan(4*i+1)が自身のパラメータ範囲 /// (vecComSpan(4*i+0) < vecComSpan(4*i+1))、 /// vecComSpan(4*i+2),vecComSpan(4*i+3)がcurve2のパラメータ範囲 ///戻り値: /// 共通部分の数: 共通部分が求まった /// 0: 共通部分がなかった /// -1: 共通エッジの収束計算エラー /// -2: 共通エッジが4個以上求まった(のっていないと見なす) ///追記: /// 曲線が共通かどうかの誤差にはline_zero()を、パラメータ範囲の収束計算の誤差には、 /// パラメータ範囲*rc_zero()を使用した int common( const MGCurve& curve2, std::vector& vecComSpan ) const; ///copy as a newed curve. The new curve will be MGLBRep or MGRLBRep. ///When original curve was a MGRLBRep, the new curve will be a MGRLBRep. ///Otherwise, the new curve will be a MGLBRep. ///Returned object must be deleted. MGCurve* copy_as_nurbs() const; ///Construct new curve object by changing ///the original object's space dimension. ///User must delete this copied object by "delete". MGCurve* copy_change_dimension( int sdim, ///< new space dimension int start1=0, ///< Destination order of new line. int start2=0 ///< Source order of this line. )const; ///Construct new curve object by copying to newed area, ///and limitting the parameter range to prange. ///Returned is newed object and must be deleted. ///Returned curve is not TrimmedCurve, but a part copy of the original ///curve. MGCurve* copy_limitted(const MGInterval& prange) const; MGCurve* copy_limitted() const; /// Return parameter curve's pointer const MGCurve* base_curve() const {return m_curve;}; ///Compute curvilinear integral of the 1st two coordinates. ///This integral can be used to compute area sorounded by the curve. ///(線積分)を求める。 ///curvilinear_integral from t1 to t2 can be obtained by ///Integral of (x*dy-y*dx) about t, where curve is expressed by ///f(t)=(x(t),y(t)), dx=dx/dt, and dy=dy/dt. double curvilinear_integral(double t1, double t2) const; #ifdef __sgi double curvilinear_integral()const {return curvilinear_integral(param_s(),param_e());} #endif ///Divide this curve at the designated knot multiplicity point. ///Function's return value is the number of the curves after divided. int divide_multi( MGPvector& crv_list, ///=order(), order() is assumed. )const; void drawSE( mgVBO& vbo,///eval(t,nderiv,left);}; ///Extrapolate this curve by an (approximate) chord length. ///The extrapolation is C2 continuous. void extend( double length, ///>t;} ///Provide divide number of curve span for function intersect. int intersect_dnum() const; ///Test if this cure is planar or not. ///MGPlane expression will be out to plane if this is planar. ///Function's return value is true if planar. bool is_planar(MGPlane& plane)const; ///negate_param(t);}; ///Returns the order. int order() const{return m_curve->order();} /// Output function. std::ostream& out(std::ostream&) const; ///IGES output function. int out_to_IGES( MGIgesOfstream& igesfile, int SubordinateEntitySwitch=0 )const; /// Return ending parameter value. double param_e() const; ///Normalize parameter value t to the nearest knot if their distance is ///within tolerance. double param_normalize(double t) const; ///Return parameter range of the curve(パラメータ範囲を返す) MGInterval param_range() const{return m_range;} /// Return starting parameter value. double param_s() const; ///Compute part of this curve from parameter t1 to t2. ///Returned is the pointer to newed object, and so should be deleted ///by calling program, or memory leaked. MGCurve* part( double t1,///=0: number of curves obtained, <0 : Some error detected. int project( const MGFSurface& surf, //given surface. MGPvector& vec_crv_uv, //uv projection curve will be appended. MGPvector& vec_crv, //3d projection curve will be appended. const MGVector& vec //projection vector. //if vec = NULL then calculate perpendicular project. )const; ///Round t into curve's parameter range. /// 入力パラメータをパラメータ範囲でまるめて返却する。 double range(double t) const; ///Return space dimension int sdim() const{return m_curve->sdim();}; ///Return sweep surface from crv ///Returned is a newed MGSurface, must be deleted. ///The sweep surface is defined as: ///This curve(say c(t)) is the rail and the straight line segments from ///C(t)+start_dist*uvec to C(t)+end_dist*uvec are the generatrix. MGSurface* sweep( const MGUnit_vector& uvec, /// oneD( const double g[4] ///& vecComSpan )const; ///Negate the curve direction(曲線の方向を反転する) void negate(); ///Compute all the perpendicular points of this curve and the second one. ///That is, if f(s) and g(t) are the points of the two curves f and g, ///then obtains points where the following conditions are satisfied: /// fs*(f-g)=0. gt*(g-f)=0. ///Here fs and gt are 1st derivatives at s and t of f and g. ///MGPosition P in the MGPosition_list contains this and crv's parameter ///as: P(0)=this curve's parameter, P(1)=crv's parameter value. MGPosition_list perps_in_range( const MGCurve& crv2 ///