MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
FSurface.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGFSurface_HH_
6 #define _MGFSurface_HH_
7 
8 #include <deque>
9 #include "mg/Default.h"
10 #include "mg/Unit_vector.h"
11 #include "mg/Position_list.h"
12 #include "mg/Pvector.h"
13 #include "mgGL/VBO.h"
14 
15 class MGCompositeCurve;
16 class MGHHisect_vector;
17 class MGSSisect_list;
18 class MGCSisect_list;
19 class MGObject;
20 class MGCurve;
21 class MGFace;
22 class MGShell;
23 class MGDrawParam;
24 class mgSysGL;
25 class mgVBO;
26 class mgTL2Triangles;
27 
32 class MG_DLL_DECLR MGFSurface{
34 
35 friend class MGFace;
36 friend class MGSurface;
37 friend class MGCurve;
38 friend class MGCompositeCurve;
39 friend class MGTrimmedCurve;
40 friend class MGStraight;
41 friend class MGLBRep;
42 friend class MGSurfCurve;
43 
44 public:
46 
49 
51 MGFSurface(const MGFSurface& fsurf){;};
52 
54 virtual ~MGFSurface(){;};
55 
57 
59 bool operator<(const MGFSurface& f2)const;
60 bool operator>(const MGFSurface& f2)const{return f2<(*this);};
61 
63 
70 virtual void arrow(double u,double v, MGPosition data[10])const=0;
71 virtual void arrow(const MGPosition& uv, MGPosition data[10])const=0;
72 
74 const MGBox& get_box() const;
75 
78 virtual const MGBox box_param2()const=0;
79 
81 virtual MGFSurface* clone_fsurface()const=0;
82 
85 virtual MGFace* clone_as_face()const=0;
86 
89 virtual MGPosition closest(
90  const MGPosition& point
91 )const=0;
92 
95 virtual MGPosition closest_on_boundary(
96  const MGStraight& sl
97 )const=0;
98 
100 void display_arrowsFS(
101  mgSysGL& sgl
102  ,int udiv=4
103  , int vdiv=4
104 )const;
105 
108 void drawWireFS(
109  mgVBO& vbo,
110  double span_length,
111  int line_density=1
112 )const;
113 
114 //Draw 3D curve in world coordinates.
115 //The object is converted to curve(s) and is drawn.
116 void drawWireFS_to_highlight(
117  mgVBO& vbo,
118  double span_length,
119  int line_density
120 )const;
121 
125 virtual MGVector eval(
126  double u,
127  double v,
128  int ndu=0,
129  int ndv=0
130 )const=0;
131 
132 virtual MGVector eval(
133  const MGPosition& uv,
134  int ndu=0,
135  int ndv=0
136 )const=0;
137 
146  const MGFSurface& face2,
147  std::vector<MGPosition>& uvuvs,
148  int npoint=20,
149  double tolerance=0.1
150 )const;
151 
153 MGPvector<MGCurve> get_all_boundaries(void)const;
154 
156 virtual MGFace* get_face_pointer()=0;
157 virtual const MGFace* get_face_pointer()const=0;
158 
160 virtual int get_number_of_boundaries()const=0;
161 
164 virtual MGSurface* get_surface_pointer()=0;
165 virtual const MGSurface* get_surface_pointer()const=0;
166 
169 virtual bool has_commonFS(const MGObject& obj2) const=0;
170 
173 bool hasInnerBoundaryLoop()const{ return number_of_inner_boundaries()>0;};
174 
177 virtual bool hasLoop(const MGBox& uvbox)const{return false;};
178 
184 virtual MGPvector<MGCurve> inner_boundary(int i)const=0;
185 
191 virtual MGPvector<MGCurve> inner_boundary_param(int i)const=0;
192 
194 virtual bool in_range(double u, double v)const=0;
195 virtual bool in_range(const MGPosition& uv) const=0;
196 
205 int in_range_with_on(double u, double v)const{return in_range_with_on(MGPosition(u,v));};
206 virtual int in_range_with_on(const MGPosition& uv)const=0;
207 
209 virtual MGHHisect_vector isect(const MGShell& shell2) const=0;
210 virtual MGSSisect_list isect(const MGFSurface& fsurf) const=0;
211 virtual MGSSisect_list isect(const MGFace& fsurf) const=0;
212 virtual MGSSisect_list isect(const MGSurface& fsurf) const=0;
213 virtual MGCSisect_list isect(const MGCurve& curv) const=0;
214 
219 void intersect12Boundary(
220  const MGFSurface& face2,
221  MGPosition_list& uvuv_list
222 )const;
226 
234 virtual int isect_boundary(
235  const MGFSurface& face2,
236  MGPosition_list& uvuvs,
242  int id1=0
243 )const=0;
244 
249 virtual int isect_incurves(
250  const MGFSurface& face2,
251  int iid,
252  MGPosition_list& uvuv_list,
253  int id1
256 ) const=0;
259 
264 virtual int isect_outcurves(
265  const MGFSurface& face2,
266  MGPosition_list& uvuv_list,
267  int id1
270 )const=0;
273 
277 virtual int isect_guess(
278  const MGCurve& crv,
279  const MGPosition& uvi,
280  double ti,
282  MGPosition& uv,
283  double& t
284 )const;
285 
289 virtual int isect_guess(
290  const MGStraight& sl,
291  const MGPosition& uvi,
292  double ti,
294  MGPosition& uv,
295  double& t
296 )const{return isect_guess_straight(sl,ti,uvi,t,uv);};
297 
301 virtual int isect_guess(
302  const MGCompositeCurve& crv,
303  const MGPosition& uvi,
304  double ti,
306  MGPosition& uv,
307  double& t
308 )const{return isect_guess_composite(crv,uvi,ti,uv,t);};
309 
313 virtual int isect_guess_composite(
314  const MGCompositeCurve& crv,
315  const MGPosition& uvi,
316  double ti,
318  MGPosition& uv,
319  double& t
320 )const;
321 
326 virtual int isect_guess_straight(
327  const MGStraight& sl,
328  double ti,
329  const MGPosition& uvi,
330  double& t,
332  MGPosition& uv
333 )const;
334 
336 virtual double knot_u(int i) const{return 0.0;}
337 
339 virtual double knot_v(int i) const{return 0.0;}
340 
342 virtual const MGKnotVector& knot_vector_u() const=0;
343 virtual MGKnotVector& knot_vector_u()=0;
344 
346 virtual const MGKnotVector& knot_vector_v() const=0;
347 virtual MGKnotVector& knot_vector_v()=0;
348 
353 virtual MGFace* make_face()=0;
354 
356 virtual void negateFS()=0;
357 
359 virtual MGVector normal(const MGPosition& uv) const=0;
360 
362 virtual MGVector normal(double u,double v) const=0;
363 
365 virtual int number_of_inner_boundaries()const{return 0;};
366 
368 virtual const MGObject* object_pointer()const=0;
369 virtual MGObject* object_pointer()=0;
370 
375 virtual int offset_fs(double distance, MGPvector<MGFSurface>& vecOfsFSurface)const=0;
376 
380 virtual bool on(
381  const MGPosition& P,
382  MGPosition& uv
383 )const=0;
386 
389 virtual bool on_a_perimeter(
390  double& u,
391  double& v,
392  int& perim_num
393 )const=0;
395 
397 virtual std::ostream& outFS(std::ostream& ostrm) const=0;
398 
399 
405 virtual MGPvector<MGCurve> outer_boundary()const=0;
406 
410 virtual MGPvector<MGCurve> outer_boundary_param()const=0;
411 
413 virtual MGPosition param(const MGPosition& P)const=0;
414 
416 virtual double param_e_u()const=0;
417 virtual double param_e_v()const=0;
418 
420 virtual double param_s_u()const=0;
421 virtual double param_s_v()const=0;
422 
426 virtual MGPvector<MGCurve> parameter_curves(
427  int is_u,
428  double x
429 )const=0;
430 
432 double param_error() const;
433 double param_error_u() const;
434 double param_error_v() const;
435 
439 virtual MGPosition param_mid()const;
440 
443 virtual MGBox param_range() const=0;
444 
448 virtual bool perp_guess(
449  const MGPosition& P,
450  const MGPosition& uvguess,
451  MGPosition& uv
452 )const=0;
453 
459 virtual bool perp_guess(
460  const MGCurve& curve,
461  const MGPosition& uvguess,
462  double tguess,
463  MGPosition& uv,
464  double& t
465 )const=0;
466 
471 virtual int perp_point(
472  const MGPosition& p,
473  MGPosition& uv,
474  const MGPosition* uvguess=0
475 )const=0;
476 
481 virtual MGPosition_list perps(const MGPosition& P) const=0;
482 
487 virtual int perp_one(
488  const MGPosition& P,
489  MGPosition& uv
490 )const;
491 
510 virtual int project(
511  const MGCurve& crv,
512  MGPvector<MGCurve>& vec_crv_uv,
514  MGPvector<MGCurve>& vec_crv,
516  const MGVector& vec = mgNULL_VEC
517 )const;
519 
534 virtual int project(
535  const MGCurve& crv,
536  MGPvector<MGCurve>& vec_crv,
538  const MGVector& vec = mgNULL_VEC
540 )const;
541 
544 virtual int get_proj_divnum(const MGCurve& crv)const=0;
545 
548 virtual MGPosition range(const MGPosition& uv)const=0;
549 
550 //Obtain main parameter lines of the FSurface without boundaries.
551 //inner_skeleton includes only inner parameter lines without boundaries.
552 //density indicates how many inner parameter lines are necessary
553 //for both u and v directions.
554 MGPvector<MGCurve> inner_skeleton(int density)const;
555 
560 virtual MGPvector<MGCurve> skeleton(int density=1)const;
561 
563 virtual MGPvector<MGCurve> skeleton_at_knots()const;
564 
566 virtual void split(
567  double param,
568  bool is_u,
570  MGPvector<MGFSurface>& surfaces
571 )const=0;
572 
573 
576 void split(
577  const std::vector<const MGCurve*>& splitters, //splitter world curves.
578  const MGVector& dir, //splitter projection direction.
579  //If dir.is_null(), normal projection will be performed.
580  MGPvector<MGFace>& faces//Result splitted face(s) will be appended.
581  //If no splitting was performed, no faces will be appended.
582 )const;
583 
585 void split(
586  const MGPvector<MGCurve>& splitters,//splitter (u,v) curves.
587  MGPvector<MGFace>& faces//Result splitted face(s) will be appended.
588  //If no splitting was performed, no faces will be appended.
589 )const;
590 
595 void extract(
596  const std::vector<const MGCurve*>& trimmers,
597  const MGVector& dir,
598  const MGPosition& uv,
599  std::auto_ptr<MGFace>& eface
601 )const;
602 
604 void shadeFS(
605  mgVBO& vbo,
606  const MGDrawParam& para,
608 )const;
609 
611 virtual void triangulate(
612  const MGDrawParam& para,
613  MGCL::TL_DATA_KIND dkind,
614  std::vector<mgTL2Triangles>& trisVec
615 )const=0;
616 
621 void trim(
622  const std::vector<const MGCurve*>& trimmers,
623  const MGVector& dir,
624  const MGPosition& uv,
625  MGPvector<MGFace>& faces
627 )const;
629 
631 virtual MGUnit_vector unit_normal(const MGPosition& uv) const=0;
632 
634 virtual MGUnit_vector unit_normal(double u,double v) const=0;
635 
636 protected:
637 
640 virtual int coef_sdim() const=0;
641 
644 virtual int isect_area_length() const=0;
645 
651 virtual int isect_direction(
652  const MGFSurface& sf2,
653  int m1,
654  MGPosition& uvuvS,
656  double& du,
657  double& dv,
658  double acuRatio=1.
659 )const;
660 
666 int isect_direction_with_direction(
667  double u,
668  double v,
669  const MGVector& tangent,
670  double& du,
672  double& dv
673 )const;
674 
677 void isect_dt(
678  double u,
679  double v,
680  double& du,
681  double& dv,
682  double acuRatio=1.
683 ) const;
684 
688 virtual void isect_inner_dt(
689  int n,
690  const MGPosition& uvnow,
691  double& du,
692  double& dv,
693  int& kdt,
695  double acuRatio=1.
698 )const;
699 
702 double isect_dt_coef(int n) const;
703 
707 int isect_div_id_max()const;
708 
711 virtual MGCurve* isect_incr_pline(
712  const MGPosition& uv,
713  int kdt,
714  double du,
716  double dv,
717  double& u,
718  double& v,
719  int incr=0
720 )const=0;
721 
735 int isect_start(
736  const MGPosition& uvuv_startIn,
737  MGPosition_list& uvuv_list,
738  const MGFSurface& sf2,
742  MGSSisect& ssi,
743  MGPosition_list::iterator& uvuv_id,
749  int& m1
750 )const;
752 
760 int isect_start_boundary(
761  const MGFSurface& sf2,
762  const MGPosition& uvuv_pre,
763  int kdt,
764  double du,
766  double dv,
767  int lid1,
768  MGPosition& uvuv_now
769 )const;
770 
773 double isect_start_dif(
774  const MGNDDArray& tau,
775  const MGLBRep& line,
776  const MGFSurface& sf2
777 )const;
778 
787 int isect_start_incr(
788  const MGFSurface& sf2,
789  const MGPosition& uvuv_pre,
790  int kdt,
791  double du,
793  double dv,
794  int lid1,
795  MGPosition& uvuv_now
796 )const;
797 
814 int isect_startPt(
815  const MGPosition& uvuv_startIn,
816  MGPosition_list& uvuv_list,
817  const MGFSurface& sf2,
821  double acuRatio,
822  MGBPointSeq& point,
824  MGPosition_list::iterator& uvuv_id,
833  int& m1
834 )const;
836 
849 int isect_startPlane(
850  const MGPosition& uvuvS,
851  MGPosition_list& uvuv_list,
858  const MGPlane& pl,
859  MGSSisect& ssi,
866 )const;
867 
884 int isect_startPlanePt(
885  const MGPosition& uvuv_startIn,
886  MGPosition_list& uvuv_list,
887  const MGPlane& pl2,
891  double acuRatio,
892  MGBPointSeq& point,
903 )const;
904 
906 MGSSisect_list isect_with_surf(
907  MGPosition_list& uvuv_list,
912  const MGFSurface& srf2
913 )const;
914 
917 MGSSisect_list isect_with_plane(
918  MGPosition_list& uvuv_list,
923  const MGPlane& pl,
924  const MGFSurface& fsrf2
925 )const;
926 
927 //Obtain the projected curve of a curve onto the surface.
928 //The direction of the projection is along the vector vec if the vec is not
929 //NULL, and normal to the surface if the vec is NULL.
930 //Output of 'project' is two kind of curves:
931 //one is general world coordinate curves('vec_crv'), and the other is (u,v) curves of
932 //the parameter space of the surfaces(vec_crv_uv).
933 //vec_crv_uv.size() is equal to vec_crv.size(). Let the size be n, then
934 // (vec_crv_uv[i], vec_crv[i]) is one pair for 0<=i<n.
935 //戻り値:
936 // 投影曲線の数: 投影曲線が求まった
937 // 0: 投影曲線が求まらなかった
938 // -1: 内部処理エラー
939 // -2: 収束処理エラー(収束しなかった)
940 int projectbyApproximateAsLBRep(
941  const MGCurve& crv,
942  MGPvector<MGCurve>& vec_crv_uv,
943  //Projected curve(surface parameter (u,v) representation) will be appended.
944  MGPvector<MGCurve>& vec_crv,
945  //Projected curve(world coordinate(x,y,z) representation) will be appended.
946  const MGVector& vec
947 )const;
948 
949 //Obtain the projected curve of a curve onto the surface.
950 //The direction of the projection is along the vector vec if the vec is not
951 //NULL, and normal to the surface if the vec is NULL.
952 //Output of 'project' is two kind of curves:
953 //one is general world coordinate curves('vec_crv'), and the other is (u,v) curves of
954 //the parameter space of the surfaces(vec_crv_uv).
955 //vec_crv_uv.size() is equal to vec_crv.size(). Let the size be n, then
956 // (vec_crv_uv[i], vec_crv[i]) is one pair for 0<=i<n.
957 //戻り値:
958 // 投影曲線の数: 投影曲線が求まった
959 // 0: 投影曲線が求まらなかった
960 // -1: 内部処理エラー
961 // -2: 収束処理エラー(収束しなかった)
962 int projectbyRemovKnots(
963  const MGCurve& crv,
964  MGPvector<MGCurve>& vec_crv_uv,
965  //Projected curve(surface parameter (u,v) representation) will be appended.
966  MGPvector<MGCurve>& vec_crv,
967  //Projected curve(world coordinate(x,y,z) representation) will be appended.
968  const MGVector& vec
969 )const;
970 
972 int projVector(
973  const MGCurve& crv,
974  MGPvector<MGCurve>& vec_crv_uv,
975  MGPvector<MGCurve>& vec_crv,
976  const MGVector& vec
977 ) const;
978 
980 int projNormal(
981  const MGCurve& crv,
982  MGPvector<MGCurve>& vec_crv_uv,
983  MGPvector<MGCurve>& vec_crv
984 )const;
985 
986 private:
987 
991 virtual bool in_range_face(const MGPosition& uv)const{return true;};
992 
995 bool uvuvE_is_a_midpoint(
996  const MGFSurface& f2,
997  int m1,
998  const MGSSisect& ssi,
1000  const MGPosition& uvuvE
1001 )const;
1002 
1009 void projNormalProc(
1010  const MGCurve& crv,
1011  MGPvector<MGLBRep>& crv_xyzuv_vector
1012 )const;
1013 
1015 int projVectorProc(
1016  const MGCurve& crv,
1017  MGPvector<MGLBRep>& vec_crv,
1018  const MGVector& vec
1019 ) const;
1020 
1021 };
1022 
1024 typedef std::pair<const MGBox*,int> mgBCPair;
1025 //Private class to sort boxes by their distances from a position.
1026 class MG_DLL_DECLR MGBox2PositionCompare{
1027 public:
1028  MGBox2PositionCompare(const MGPosition& P):m_position(P){;};
1029  bool operator()(const MGBox* b1, const MGBox* b2)const;
1030  bool operator()(const mgBCPair& b1, const mgBCPair& b2)const;
1031  const MGPosition& m_position;
1032 };
1034  // end of MGObjectRelated group
1036 #endif
MGTrimmedCurve is a part of an original curve of a limitted parameter range.
Definition: TrimmedCurve.h:50
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
MGPlane is infinite plane in 3D space.
Definition: Plane.h:38
A vector of mgTL2Triangle's.
Definition: TL2Triangles.h:25
TL_DATA_KIND
Triangles' data kind.
Definition: MGCL.h:280
virtual int perp_guess(double t0, double t1, const MGPosition &P, double tg, double &t) const
Return perpendicular point from a point P.
int project(const MGFSurface &surf, MGPvector< MGCurve > &vec_crv_uv, MGPvector< MGCurve > &vec_crv, const MGVector &vec) const
MGCompositeCurve is a composite of other leaf curves.
Definition: CompositeCurve.h:39
virtual int isect_guess(const MGCompositeCurve &crv, const MGPosition &uvi, double ti, MGPosition &uv, double &t) const
Definition: FSurface.h:301
double range(double t) const
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
virtual double param(const MGPosition &) const
Compute parameter value of given point.
Definition: VBO.h:86
Is an abstract class which represents a whole geometry and a topology.
Definition: Object.h:42
MGInterval param_range() const
Return parameter range of the curve(パラメータ範囲を返す)
MGShell is a composition of MGFace's(trimmed surface).
Definition: Shell.h:32
int in_range_with_on(double u, double v) const
Definition: FSurface.h:205
virtual int number_of_inner_boundaries() const
Get number of inner boundaries as the output of the function.
Definition: FSurface.h:365
Vector of a general n space dimension.
Definition: Vector.h:26
Defines a Box of any space dimendion.
Definition: Box.h:34
bool operator<(const MGSurfCurve &gel2) const
Defines parameters to draw MGObject, maily to approximate by lines and facets.
Definition: drawParam.h:53
MGFace is a trimmed surface.
Definition: Face.h:51
virtual MGPoint * point()
Return point pointer if this MGGel is an MGPoint, else return null.
Definition: Gel.h:135
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
virtual double param_error() const
Obtain parameter space error.
MGSSisect represents one intersection line of two surfaces.
Definition: SSisect.h:29
Represent a positional data.
Definition: Position.h:28
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
bool in_range(double t) const
Test if input parameter value is inside parameter range of the line.
MGCurve * curve()
Return curve pointer if this MGGel is an MGCurve, else return null.
Definition: Curve.h:287
MGSSisect_list defines linked list of MGSSisect.
Definition: SSisect_list.h:26
MGCSisect_list defines linked list of MGCSisect.
Definition: CSisect_list.h:22
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
ELEMENT_TARGET
Definition: VBO.h:84
virtual double closest(const MGPosition &point) const
Compute the closest point parameter value of this curve from a point.
MGPosition_list perps(const MGCurve &crv2) const
virtual double knot_u(int i) const
Access to i-th element of u knot.
Definition: FSurface.h:336
Defines BPoint seq of a space dimension and of a capacity.
Definition: BPointSeq.h:38
void arrow(double t, MGPosition data[4]) const
Generate arrow data of the tangent at the parameter value t of the curve.
MGCCisect_list isect(const MGCurve &curve2) const
Intersection of Curve.
MGFSurface is an abstract class to provide the comman interfaces to MGFace and MGSurface.
Definition: FSurface.h:33
virtual int isect_guess(const MGStraight &sl, const MGPosition &uvi, double ti, MGPosition &uv, double &t) const
Definition: FSurface.h:289
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
MGHHisect_vector defines a vector of MGHHisect.
Definition: HHisect_vector.h:28
MGFSurface()
Null FSurface.
Definition: FSurface.h:48
container_type::iterator iterator
Definition: Position_list.h:33
void triangulate(const MGLoop &polygon, mgTL2Triangles &triangles)
virtual double knot_v(int i) const
Access to i-th element of v knot.
Definition: FSurface.h:339
void eval_discrete_deviation(const MGCurve &curve2, std::vector< MGPosition > &sts, int npoint=20, double tolerance=0.1) const
Evaluate deviations of two curves(this and curve2) at npoint discrete points.
virtual ~MGFSurface()
Definition: FSurface.h:54
virtual bool on(const MGPosition &point, double &t) const
Test if given point is on the curve or not.
bool operator>(const MGFSurface &f2) const
Definition: FSurface.h:60
Defines non-decreasing double data array.
Definition: NDDArray.h:27
MGFSurface(const MGFSurface &fsurf)
Copy constructor.
Definition: FSurface.h:51
bool hasInnerBoundaryLoop() const
Definition: FSurface.h:173
mgSysGL is a class to provide a facility to draw temporal pictures.
Definition: sysGL.h:26
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
virtual int perp_point(const MGPosition &p, double &t, const double *g=0) const
Compute a foot point of the perpendicular line from point p to the curve.
virtual bool hasLoop(const MGBox &uvbox) const
Definition: FSurface.h:177
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGSurfCurve is a curve on a surface.
Definition: SurfCurve.h:43