/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGSurface_HH_ #define _MGSurface_HH_ #include #include #include "mg/Default.h" #include "mg/Geometry.h" #include "mg/Position_list.h" #include "mg/SSisect_list.h" #include "mg/FSurface.h" #include "mg/Pvector.h" // MGSurface.h class MGDrawParam; class MGBPointSeq; class MGPosition; class MGVector; class MGTransf; class MGUnit_vector; class MGCurve; class MGEllipse; class MGStraight; class MGCompositeCurve; class MGSurfCurve; class MGLBRep; class MGSPointSeq; class MGCSisect_list; class MGPlane; class MGSBRep; class MGSSisect; class MGSSisect_list; class MGPosition_list; class MGIfstream; class MGOfstream; class MGRLBRep; class MGCParam_list; class MGNDDArray; class MGFace; class MGShell; class MGHHisect_vector; class mgTL2Triangles; /** @addtogroup GEO * @{ */ /// MGSurface is an abstract class of 3D surface. /// Surface is represented using two parameter u and v:f(u,v). class MG_DLL_DECLR MGSurface: public MGGeometry, public MGFSurface{ public: //////////// Constructor. コンストラクタ //////////// ///Void Constructor. 初期化なしでオブジェクトを作成する。 MGSurface(void); ///Copy Constructor. MGSurface(const MGSurface& srf):MGGeometry(srf){;}; //////////// Destructor. 仮想デストラクタ //////////// virtual ~MGSurface(); //////////// Operator overload. 演算子多重定義 //////////// ///Assignment. ///When the leaf object of this and obj2 are not equal, this assignment ///does nothing. virtual MGSurface& operator=(const MGSurface& gel2){MGGeometry::operator=(gel2);return *this;}; ///Object transformation. MGSurface& operator+=(const MGVector& v)=0; MGSurface& operator-=(const MGVector& v)=0; MGSurface& operator*=(double scale)=0; MGSurface& operator*=(const MGMatrix& mat)=0; MGSurface& operator*=(const MGTransf& tr)=0; ///comparison virtual bool operator==(const MGGel& gel2)const=0; virtual bool operator<(const MGGel& gel2)const=0; ////////////Logical operator overload///////// //////////// Member function. メンバ関数 //////////// ///Approximate this surface as an MGSBRep. std::unique_ptr approximate_as_SBRep( int parameter_normalization=2, ///=4 is recommended. ///& srfl ///<分割した曲面リスト )const; ///Compute if MGSurfCurve scurve(*this, param_curve) has the same direction to world_curve. ///Assuming that scurve and world_curve are the same curve. ///Function's return value is: ///1: same direction, -1:oppositie direction. int equal_direction( const MGCurve& param_curve, ///<(u,v) parameter representation curve of this. const MGCurve& world_curve ///=4. ///The extrapolation is done so that extrapolating length is "length" ///at the position of the parameter value "param" of the perimeter. virtual MGSurface& extend( int perimeter, /// pspan[2],///& trisVec )const; ///Compute the approximate plane in the parameter range from (u0, v0) to (u1,v1). ///Also, test if the surface is within surface_tol and angle from the plane. ///The plane's origin is center point of the plane when the surface is mapped onto the plane. ///the uderiv is the direction from the point(u0, v0) to (u1,v0). ///Function's return value is true when the surface is within the tolerance surface_tol, ///and the surface normals are within angle from the plane's normal ///plane, width, and height are valid only when function's return value is true. bool test_and_get_approximate_plane( double u0,///=10: (u,v) is on a perimeter, (10+perimeter number) will be returned. int in_range_with_on(const MGPosition& uv)const; ///Test if surface limitted by the parameter range bx is flat and small. ///That is, surface is flat within surftol from the average plane, ///and all of the egedes are small compared with melen2. bool is_flat_and_small( const MGBox& bx,//Paramete range of the surface. double surftol, //Input the maximum deviation allowed from a plane. double melen2, //square of maximum edge length allowed of the surface edge. bool& direction//true: u-direction is more non flat or longer. // false: v-direction is more non flat or longer. )const; ///Obtain i-th inner_boundary curves(world coordinates representation) of the FSurface. ///Let the output of inner_boundary(i) be wcurves and ///of inner_boundary_param(i) be pcurves, then wcurves[j] corresponds ///to pcurves[j] one to one. Number of inner_boundary can be obtained ///by the function number_of_inner_boundary(). virtual MGPvector inner_boundary(int i)const; ///Obtain i-th inner_boundary curves. ///Obtain i-th inner_boundary curves(world coordinates representation) ///of the FSurface. Let the output of inner_boundary(i) be wcurves and ///of inner_boundary_param(i) be pcurves, then wcurves[j] corresponds ///to pcurves[j] one to one. Number of inner_boundary can be obtained ///by the function number_of_inner_boundary(). virtual MGPvector inner_boundary_param(int i)const; ///Default surface-curve intersection function. ///Restriction for this surface and curve: /// 1. this surface and curve must not have C0 continuity in it. /// 2. param_s() and param_e() of this surface and curve must return /// real start and end parameter values. That is, must be finite. MGCSisect_list intersect(const MGCurve& curve) const; ///Default surface-curve intersection function. MGCSisect_list intersect(const MGEllipse& el) const; ///Compute the intersections of two objects. ///Intersections are obtained from two objects, which are known using ///the MGisects::object1() and object2(). ///****NOTE**** ///When two objects' manifold dimension are the same, object1 is this object ///at the invocation of MGObject::intersection(), and object2 is the argument ///object. ///However, their manifold dimension are not the same, object1 is always ///the lower dimension's object and object2 is the higer dimension's object. MGisects intersection(const MGObject& obj2)const; MGisects intersection(const MGCurve& obj2)const; MGisects intersection(const MGFSurface& obj2)const; MGisects intersection(const MGSurface& obj2)const; MGisects intersection(const MGFace& obj2)const; MGisects intersection(const MGShell& obj2)const; ///Surface and Surface intersection. ///Surface と Surface の交線を求める。 virtual MGSSisect_list isect(const MGSurface& srf2)const=0; virtual MGSSisect_list isect(const MGPlane& srf2)const=0; virtual MGSSisect_list isect(const MGSphere& srf2)const=0; virtual MGSSisect_list isect(const MGCylinder& srf2)const=0; virtual MGSSisect_list isect(const MGSBRep& srf2)const=0; virtual MGSSisect_list isect(const MGRSBRep& srf2)const=0; virtual MGSSisect_list isect(const MGBSumSurf& srf2)const=0; MGSSisect_list isect(const MGFace& f) const; MGSSisect_list isect(const MGFSurface& fsurf) const; MGHHisect_vector isect(const MGShell& shl) const; ///Curve and Surface intersection. /// Surface と Curve の交点を求める。 virtual MGCSisect_list isect(const MGCurve& curve) const=0; ///Return order of intersection line order of MGLBRep. ///The default is 4. virtual int isect_order() const=0; ///@cond ///isect_startH compute one intersection line of two surfaces, this and sf2, /// given starting intersetion point uvuv((u1,v1) of this and (u2,v2) of sf2). /// isect_startH halts the computation when intersection /// reached to a boundary of this or sf2, or reached to one of the points /// in uvuv_list. ///The function's return value is: /// =0: Intersection was not obtained. /// !=0: Intersection was obtained as follows: /// =1: End point is a point on a perimeter of one of the surfaces. /// =3: End point is one of boundary points in uvuv_list. /// =4: End point is the starting point. /// =7: isect_start halted the computation since intersection was lost /// during the computation. int isect_startH( const MGPosition& uvuv_startIn, /// offset( double ofs_value, ///<オフセット量 int& error ///<エラーコード 0:成功 -2:曲率半径以上のオフセット不可 -3:面生成コンストラクタエラー )const; ///Offset. ///distance is plus value if the direction is toward normal vector of the ///FSurface. Minus if against the normal vector. ///エラーコード 0:成功 -1:曲率半径以上のオフセット不可 -3:面生成コンストラクタエラー int offset_fs( double distance, MGPvector& vecOfsFSurface )const; ///C1 continuous Surface offset. ///C1連続曲面の一定オフセット関数 ///オフセット方向は、ノーマル方向を正とする。曲率半径より大きいオフセットは行わない。 ///戻り値は、オフセットした曲面のオートポインタが返却される。エラーのときヌルが返る。 ///トレランスはline_zero()を使用している。 ///C1 continuous Surface offset. positive offset value means offset normal direction. ///the radius of curvature is larger than offset value.line_zero() is used. virtual std::unique_ptr offset_c1( double ofs_value, ///<オフセット量 int& error ///<エラーコード 0:成功 -1:面におれがある ///< -2:曲率半径以上のオフセット不可 -3:面生成コンストラクタエラー )const; ///Test if point P is ont the surface or not. /// 与えられた誤差内で点が面上にあるかどうかテストする。 ///Test if point P is ont the surface or not. Even if P is not on the ///surface, return parameter of the nearest point of the surface. virtual bool on( const MGPosition& P, /// outer_boundary()const; ///Obtain boundary curves(parameter space representation) of the FSurface. ///Let the output of boundary() be wcurves and of boundary_parameter() ///be pcurves, then wcurves[i] corresponds to pcurves[i] one to one. virtual MGPvector outer_boundary_param()const; ///Return surface parameter value of a point on the surface. /// 自身の上の指定点を表すパラメータ値を返す。 ///If input point is not on the surface, return the nearest point on the ///surface. virtual MGPosition param( const MGPosition & /// parameter_curves( int is_u, ///=uv1(0) or uv0(1)>=uv1(1), ///=uv1(0) or uv0(1)>=uv1(1), ///=t1, no limit for curve2 parameter range. const MGPosition& tuvg,///=uv1(0) or uv0(1)>=uv1(1), ///=t1, no limit for curve2 parameter range. const MGPosition& tuvg, ///& surfaces///=uv1(0) or uv0(1)>=uv1(1), ///=t1, no limit for curve2 parameter range. const MGPosition& tuvg,///MGTolerance::mach_zero(). void nearest_non_degenerated(double& u,double& v) const; friend class MGStraight; friend class MGLBRep; friend class MGSurfCurve; friend class MGSBRep; friend class MGPlane; friend class MGCylinder; friend class MGFSurface; friend class MGFace; friend class MGBSumSurf; ///Check if the intersection line lineb's start and end tangent vectors are accurate ///enough. If they do not have enough accuracy, isect_start_tan returns ///which end did not have the accuracy. /// 1:start, 2:end, 3:start and end. If both ends had enough accuracy, returns 0. MG_DLL_DECLR friend int isect_start_tan( const MGFSurface& sf1,/// createSurfaceFromRibs( const MGPvector& curves, ///<リブ曲線列 bool direction_adjustment=true ///< =true, curves[.] direction are adjusted to line /// createSurfaceFromRibs( const std::vector& curves,///<リブ曲線列 bool direction_adjustment=true///< =true, curves[.] direction are adjusted to line /// create_ruled_surface( const MGCurve& cross1, ///< a curve as Edge No.1. const MGCurve& cross2, ///< another curve as Edge No.2. bool direction_adjustment=true///< =true, curves[.] direction are adjusted to line /// create_revolved_surface( const MGCurve& curve, ///< generatrix curve const MGStraight& axis, ///< revolution axis double angle = mgDBLPAI ///< revolution angle ); ///Test if pline has the same direction to world_curve. ///Assuming that pline=MGSurfCurve(MGSurface srf, parameter_curve of the srf) and ///world_curve are the same curve. ///Function's return value is: ///1: same direction, -1:oppositie direction. int SurfCurve_equal_direction( const MGCurve& pline, ///