/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGFSurface_HH_ #define _MGFSurface_HH_ #include #include "mg/Default.h" #include "mg/Unit_vector.h" #include "mg/Position_list.h" #include "mg/Pvector.h" #include "mgGL/VBO.h" class MGCompositeCurve; class MGHHisect_vector; class MGSSisect_list; class MGCSisect_list; class MGObject; class MGCurve; class MGFace; class MGShell; class MGDrawParam; class mgSysGL; class mgVBO; class mgTL2Triangles; /** @addtogroup MGObjectRelated * @{ */ ///MGFSurface is an abstract class to provide the comman interfaces to MGFace and MGSurface. class MG_DLL_DECLR MGFSurface{ friend class MGFace; friend class MGSurface; friend class MGCurve; friend class MGCompositeCurve; friend class MGTrimmedCurve; friend class MGStraight; friend class MGLBRep; friend class MGSurfCurve; public: //////// Constructor //////// ///Null FSurface. MGFSurface(){;} ///Copy constructor. MGFSurface(const MGFSurface& fsurf){;}; //////////// Virtual Destructor //////////// virtual ~MGFSurface(){;}; //////// operator overload//////// ///Comparison operator. bool operator<(const MGFSurface& f2)const; bool operator>(const MGFSurface& f2)const{return f2<(*this);}; /////////Member function//////// ///Generate arrow data of the tangent along u and v and the normal ///at the parameter value (u,v) of the FSurface. ///data[0] is the origin of the u-tangent arrow, data[1] is the top of the u-tangent arrow, ///data[2], [3] are two bottoms of u-tangent arrowhead. ///data[0], [4], [5], [6] are the points of v-tangent arrow. ///data[0], [7], [8], [9] are the points of v-tangent arrow. virtual void arrow(double u,double v, MGPosition data[10])const=0; virtual void arrow(const MGPosition& uv, MGPosition data[10])const=0; ///Get the box of the object. const MGBox& get_box() const; ///Return box of the parameter space of the FSurface. ///After trimmed one. virtual const MGBox box_param2()const=0; ///Get the clone of this MGFSurface. virtual MGFSurface* clone_fsurface()const=0; ///Get the clone of this as a MGFace. ///If this is MGSurface, it is converted to MGFace. virtual MGFace* clone_as_face()const=0; ///Compute closest point from a point. ///Returned is the parameter value of the FSurface that is closest to point. virtual MGPosition closest( const MGPosition& point///& uvuvs,///< the nearest points pairs are set. int npoint=20, /// get_all_boundaries(void)const; ///get face pointer if this is MGFace, else null will be returned. virtual MGFace* get_face_pointer()=0; virtual const MGFace* get_face_pointer()const=0; ///Get number of inner boundaries as the output of the function. virtual int get_number_of_boundaries()const=0; ///get surface pointer. Null will never be returned if this is valid MGFSurface. ///That is, if this is MGFace, base surface will be returned. virtual MGSurface* get_surface_pointer()=0; virtual const MGSurface* get_surface_pointer()const=0; ///Test if this and 2nd object has common area about their box(), ///taking error into account. virtual bool has_commonFS(const MGObject& obj2) const=0; ///Test if this FSurface has inner boundary loops or not. ///If this has one, return true. bool hasInnerBoundaryLoop()const{ return number_of_inner_boundaries()>0;}; ///Test if this FSurface has boundary loops or not in the specified box. ///If this has one, return true. virtual bool hasLoop(const MGBox& uvbox)const{return false;}; ///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=0; ///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=0; ///Test if parameter value (u,v) is in the range of the FSurface parameter. virtual bool in_range(double u, double v)const=0; virtual bool in_range(const MGPosition& uv) const=0; ///Test if (u,v) is inside the face. ///Function's return value is: /// 0:outside the face. /// 1:unknown. /// 2:inside the face, not on a boundary. /// <0:(u,v) is on an inner boundary, and abs(return code) is the loop id. /// 4:(u,v) is on the outer boundary. /// >=10: (u,v) is on a perimeter, (10+perimeter number) will be returned. int in_range_with_on(double u, double v)const{return in_range_with_on(MGPosition(u,v));}; virtual int in_range_with_on(const MGPosition& uv)const=0; ///Intersection. virtual MGHHisect_vector isect(const MGShell& shell2) const=0; virtual MGSSisect_list isect(const MGFSurface& fsurf) const=0; virtual MGSSisect_list isect(const MGFace& fsurf) const=0; virtual MGSSisect_list isect(const MGSurface& fsurf) const=0; virtual MGCSisect_list isect(const MGCurve& curv) const=0; ///Compute all the intersection points of this face's boundaries(out or inner) ///with face2, and vice versa. ///These intersection points are used to compute surface to surface ///intersection lines. void intersect12Boundary( const MGFSurface& face2, ///& vecOfsFSurface)const=0; ///Test if a point P is on the FSurface. ///Returned is true if the point P is on the FSurface. ///false(0) if P was not on the FSurface. virtual bool on( const MGPosition& P,///< The target point. MGPosition& uv /// outer_boundary()const=0; ///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=0; ///Obtain parameter value of the FSurface whose world coordinates are P. virtual MGPosition param(const MGPosition& P)const=0; /// Return ending parameter value. virtual double param_e_u()const=0; virtual double param_e_v()const=0; /// Return starting parameter value of the base surface. virtual double param_s_u()const=0; virtual double param_s_v()const=0; ///Obtain parameter curves. ///In the case of MGSurface, parameter curve is only one. However, in the case ///of MGFace, number of parameter curves are more than one. virtual MGPvector parameter_curves( int is_u, ///0) or not(0) virtual int perp_one( const MGPosition& P, ///< 指定点(point) MGPosition& uv ///=0: number of curves obtained, <0 : Some error detected. virtual int project( const MGCurve& crv, ///& vec_crv_uv, ///& vec_crv, ///=0: number of curves obtained, <0 : Some error detected. virtual int project( const MGCurve& crv, ///& vec_crv, /// inner_skeleton(int density)const; ///Obtain boundary and main parameter lines of the FSurface. ///skeleton includes boundary() and inner parameter lines. ///density indicates how many inner parameter lines are necessary ///for both u and v directions. virtual MGPvector skeleton(int density=1)const; ///Obtain all the parameter curves at knots of u and v knot vector. virtual MGPvector skeleton_at_knots()const; ///split this fsurface at the parameter param. virtual void split( double param,///& surfaces///& splitters, //splitter world curves. const MGVector& dir, //splitter projection direction. //If dir.is_null(), normal projection will be performed. MGPvector& faces//Result splitted face(s) will be appended. //If no splitting was performed, no faces will be appended. )const; ///split this fsurface with splitters. splitters are 2D (u,v) surfaces's parameter curves. void split( const MGPvector& splitters,//splitter (u,v) curves. MGPvector& faces//Result splitted face(s) will be appended. //If no splitting was performed, no faces will be appended. )const; ///Extract a sub surface with trimmers. trimmers are 3D curves and will be projected ///onto this surface tword the direction dir. If dir is null vector, surface normal ///prjection will be performed. Extraction is so performed that the smallest region ///enclosed by trimmers that includes the surface point uv will be extracted. void extract( const std::vector& trimmers, ///& eface///& trisVec )const=0; ///Trim this fsurface with trimmers. trimmers are 3D curves and will be projected ///onto this surface tword the direction dir. If dir is null vector, surface normal ///prjection will be performed. Trimming is so performed that the smallest region enclosed ///by trimmers that includes the surface point uv will be removed. void trim( const std::vector& trimmers, ///& faces///& vec_crv_uv, //Projected curve(surface parameter (u,v) representation) will be appended. MGPvector& vec_crv, //Projected curve(world coordinate(x,y,z) representation) will be appended. const MGVector& vec )const; //Obtain the projected curve of a curve onto the surface. //The direction of the projection is along the vector vec if the vec is not //NULL, and normal to the surface if the vec is NULL. //Output of 'project' is two kind of curves: //one is general world coordinate curves('vec_crv'), and the other is (u,v) curves of //the parameter space of the surfaces(vec_crv_uv). //vec_crv_uv.size() is equal to vec_crv.size(). Let the size be n, then // (vec_crv_uv[i], vec_crv[i]) is one pair for 0<=i& vec_crv_uv, //Projected curve(surface parameter (u,v) representation) will be appended. MGPvector& vec_crv, //Projected curve(world coordinate(x,y,z) representation) will be appended. const MGVector& vec )const; ///カーブを折れで分割して行い、後で接続する int projVector( const MGCurve& crv, MGPvector& vec_crv_uv, MGPvector& vec_crv, const MGVector& vec ) const; ///カーブを折れで分割して行い、後で接続する int projNormal( const MGCurve& crv, MGPvector& vec_crv_uv, MGPvector& vec_crv )const; private: ///Test in_range if this is a face, if not, do nothing. ///This is to accelerate the test of in_range in isect_guess(). ///See isect_guess(MGCurve). virtual bool in_range_face(const MGPosition& uv)const{return true;}; ///uvuvE_is_a_midpoint() is used by isect_with_surf() to determine if ///uvuvE is a mid point at the intersectio and should be neglected. bool uvuvE_is_a_midpoint( const MGFSurface& f2, int m1, ///& crv_xyzuv_vector///& vec_crv, ///<5次元曲線が返る const MGVector& vec ) const; }; ///@cond typedef std::pair mgBCPair; //Private class to sort boxes by their distances from a position. class MG_DLL_DECLR MGBox2PositionCompare{ public: MGBox2PositionCompare(const MGPosition& P):m_position(P){;}; bool operator()(const MGBox* b1, const MGBox* b2)const; bool operator()(const mgBCPair& b1, const mgBCPair& b2)const; const MGPosition& m_position; }; ///@endcond /** @} */ // end of MGObjectRelated group #endif