/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGRLBRep_HH_ #define _MGRLBRep_HH_ #include "mg/LBRep.h" // MGRLBRep.h // // Forward Declaration class MGPosition; class MGKnotArray; class MGCParam_list; class MGPosition_list; class MGIfstream; class MGOfstream; /** @file */ /** @addtogroup GEO * @{ */ /// Defines Rational Line B-Representation. /// This NURBS is a homogeneous form, i.e., B-Coefficients have /// weight included values. /// When usual NURBS form is (xi, yi, zi, wi) , /// MGRLBRep form is (xi*wi, yi*wi, zi*wi, wi) for i=0,..., n-1. class MG_DLL_DECLR MGRLBRep: public MGCurve { public: ///Friend Function MG_DLL_DECLR friend MGRLBRep operator+ (const MGVector& v, const MGRLBRep& lb); MG_DLL_DECLR friend MGRLBRep operator* (double scale, const MGRLBRep&); //////////// Constructor //////////// ///Default(dummy) constructor. MGRLBRep():MGCurve(){;} ///Construct Line NURBS, providing all the member data. ///***** This is the fundamental constructor(when homogeneous=1).***** MGRLBRep( const MGKnotVector& t, ///& weights///=0, ///< =0: start of this and start of brep1, ///< =1: start of this and end of brep1, ///< =2: end of this and start of brep1, ///< =3: end of this and end of brep1, ///< continuity and which can be obtained using continuity(). const MGRLBRep& brep2 ///NURBS 2. ); /// Gets new NURBS by computing a part of the original. New one is exactly /// the same as the original except that it is partial. ///If multiple==true(!=0), knot(i)=t1 and knot(n+i)=t2 for i=0,..., k-1 ///will be guaranteed. Here, n=bdim() and k=order(). ///Both t1 and t2 must be inside te range of old_brep. MGRLBRep( double t1, ///=0. int which, ///=0, ///< =0: start of this to start of brep2, ///< =1: start of this to end of brep2, ///< =2: end of this to start of brep2, ///< =3: end of this to end of brep2. double& ratio ///< Ratio of 1st derivatives of the two line will ///< be returned, ///< ratio= d2/d1, where d1=1st deriv of this and d2=of brep2 ) const; ///Exchange ordering of the coordinates. ///Exchange coordinates (i) and (j). MGRLBRep& coordinate_exchange(int i, int j); ///Construct new curve object by copying to newed area. ///User must delete this copied object by "delete". MGRLBRep* clone() 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{return clone();}; ///Construct new curve object by changing ///the original object's space dimension. ///User must delete this copied object by "delete". MGRLBRep* 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. MGCurve* copy_limitted(const MGInterval& prange) const; ///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; ///Display control polygons using mgVBO::MGDrawPointSeq() void display_control_polygon(mgSysGL& sgl)const; ///Draw this line's 1st and 2nd coordinates in 2D space ///using drawing function moveto( , ) and lineto( , ). ///wind[] is the window of the screen to draw the line in. ///Clipping will be performed about the wind[]. ///(wind[0], wind[1]) is the center coordinates of the window. ///wind[2] is width and wind[3] is hight of the window. When wind[2]<=0, ///no clipping is performed. Even when wind[2]<=0, wind[3] is necessary ///to input to specify the resolution of the line. In this case, ///wind[0] and wind[1] are not referended. ///ynum is the resolution of the line, is the number of ///straight line segments for the curve length of wind[3](height of window). ///***draw_2D does not perform box including judment, always performs clipping ///operation and draws the line. Users must do obvious box inclusion test ///if maximum drawing performance is necessary. void draw_2D( void (*moveto)(int, int),///< Move to function. void (*lineto)(int, int),///< Line to function. const double wind[4], ///=4. MGRLBRep& extend( int start, ///param_e(), extension will be done at the end point. double dk ///=4. For example when ///pl and this are 4 dimension (x,y,z,p), and coodinate =1, ///3D data (y,z,p) are extracted from pl and this, then ///intersection will be performed. MGCParam_list isect_3D( const MGPlane& pl, ///< Plane. int coordinate=0 ///< Coordinate kind of 3D sub space. ) const; ///Access to i-th element of knot ///( left-hand side version) double& knot(int i){return m_line.knot(i);} ///Access to i-th element of knot ///(right hand side version) double knot(int i) const{return m_line.knot(i);} ///Returns a pointer to the knot vector data. const double* knot_data() const{return m_line.knot_data();} ///Returns the knot vector. ///RHS version. const MGKnotVector& knot_vector() const{return m_line.knot_vector();} ///Returns the knot vector. ///LHS version. MGKnotVector& knot_vector(){return m_line.knot_vector();} /// 自身に指定したパラメータ範囲のlimitをつける。 ///Get the sub interval line of the original line. MGRLBRep& limit(const MGInterval& itvl); ///Returns the B-coef's. ///RHS version. const MGBPointSeq& line_bcoef() const{return m_line.line_bcoef();}; ///Returns the B-coef's. ///LHS version. MGBPointSeq& line_bcoef(){update_mark(); return m_line.line_bcoef();}; ///Change direction of the line. void negate(){m_line.negate();}; ///Obtain parameter value if this curve is negated by "negate()". double negate_param(double t)const{return m_line.negate_param(t);}; ///Return non_homogeneous B-Coefficients with weights of ///the rational B-Spline. This MGBPointSeq includes weights. MGBPointSeq non_homogeneous_bcoef() const; ///Test if this is actually non_rational, i.e. , all of the weights are ///same values. If non_rational return true, else false. int non_rational() const; ///Returns the order. int order() const{return m_line.order();} /// Return ending parameter value. double param_e() const{return m_line.param_e();}; ///Normalize parameter value t to the nearest knot if their distance is ///within tolerance. double param_normalize(double t) const{return m_line.param_normalize(t);} /// Return starting parameter value. double param_s() const{return m_line.param_s();}; ///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. MGRLBRep* part( double t1,///< From parameter. double t2,///< To parameter. int multiple=0 /// rebuild_with_new_knot_configuration( double error, //Error alowed to rebuild. If error<=0., MGTolerance::line_zero() //will be employed. int parameter_normalization //Indicates how the parameter normalization be done: //=0: no parameter normalization. //=1: normalize to range=(0., 1.); //=2: normalize to make the average length of the 1st derivative // is as equal to 1. as possible. )const; ///ノット削除関数 ///トレランスはline_zeroを使用する。元のノットが細かいものほど削除しやすい ///removal knot. line_zero tolerance is used. void remove_knot(); ///Returns the space dimension. int sdim() const{return m_line.sdim()-1;}; ///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] ///=0) or draw_2D(<0) ///