MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
TrimmedCurve.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGTrimmedCurve_HH_
6 #define _MGTrimmedCurve_HH_
7 
8 #include <vector>
9 #include "mg/Default.h"
10 #include "mg/Pvector.h"
11 #include "mg/Interval.h"
12 #include "mg/Box.h"
13 #include "mg/Position.h"
14 #include "mg/Position_list.h"
15 #include "mg/LBRep.h"
16 #include "mg/RLBRep.h"
17 #include "mg/Ellipse.h"
18 #include "mg/Straight.h"
19 #include "mg/BSumCurve.h"
20 
21 //Define MGTrimmedCurve Class.
22 
23 class MGInterval;
24 class MGBox;
25 class MGVector;
26 class MGUnit_vector;
27 class MGPosition;
28 class MGTransf;
29 class MGCParam_list;
30 class MGStraight;
31 class MGEllipse;
32 class MGCompositeCurve;
33 class MGKnotVector;
34 class MGLBRep;
35 class MGRLBRep;
36 class MGSurface;
37 class MGCCisect_list;
38 class MGCSisect_list;
39 class MGIfstream;
40 class MGOfstream;
46 
50 class MG_DLL_DECLR MGTrimmedCurve:public MGCurve{
51 
52 public:
53 
54 MG_DLL_DECLR friend MGTrimmedCurve operator+ (const MGVector& v, const MGTrimmedCurve& cv2);
55 MG_DLL_DECLR friend MGTrimmedCurve operator* (double scale, const MGTrimmedCurve& cv2);
56 
58 
61 MGTrimmedCurve(const MGCurve& crv, const MGInterval range);
62 
65 MGTrimmedCurve(const MGCurve& crv, double t1, double t2);
66 
69 
71 
75 MGTrimmedCurve& operator=(const MGGel& gel2);
77 
81 bool is_same_curve(const MGCurve& curve2)const;
82 bool operator==(const MGTrimmedCurve& gel2)const;
83 bool operator==(const MGCompositeCurve& gel2)const;
84 bool operator==(const MGGel& gel2)const;
85 bool operator<(const MGTrimmedCurve& gel2)const;
86 bool operator<(const MGGel& gel2)const;
87 
89 
96  MGLBRep& lb,
97  int ordr=0,
98  int parameter_normalization=0,
105  bool neglectMulti=false
106 )const;
109 
111 int bdim() const;
112 
116  const MGInterval&
117 ) const;
118 
121  int dim,
122  int start1,
123  int start2
124 ){
125  assert(false);//This cannot be used.
126  return *this;
127 }
131  double t1,
132  double t2
133 ){
134  assert(false);//The use is prohibitted.
135 }
136 
139 MGCurve* clone() const;
140 
159 int common(
160  const MGCurve& curve2,
161  std::vector<double>& vecComSpan,
162  MGCCisect_list& isect
163 ) const;
164 
180 int common(
181  const MGCurve& curve2,
182  std::vector<double>& vecComSpan
183 ) const;
184 
189 MGCurve* copy_as_nurbs() const;
190 
195  int sdim,
196  int start1=0,
197  int start2=0
198 )const;
199 
205 MGCurve* copy_limitted(const MGInterval& prange) const;
206 MGCurve* copy_limitted() const;
207 
209 const MGCurve* base_curve() const {return m_curve;};
210 
217 double curvilinear_integral(double t1, double t2) const;
218 
219 #ifdef __sgi
220  double curvilinear_integral()const
221  {return curvilinear_integral(param_s(),param_e());}
222 #endif
223 
226 int divide_multi(
227  MGPvector<MGCurve>& crv_list,
228  int multiplicity=-1
229 )const;
232 
233 void drawSE(
234  mgVBO& vbo,
235  double span_length,
236  double t0,
237  double t1
238 )const;
240 
243  double t,
244  int nderiv=0,
245  int left=0
246 )const{return m_curve->eval(t,nderiv,left);};
248 
251 void extend(
252  double length,
253  bool start=false
254 );
256 
258 long identify_type() const;
259 
261 bool in_range(double t) const{return m_range>>t;}
262 
264 int intersect_dnum() const;
265 
269 bool is_planar(MGPlane& plane)const;
270 
272 bool is_same_range()const{return m_sameRange;};
273 
275 MGCCisect_list isect(const MGCurve& curve2) const;
276 MGCCisect_list isect(const MGStraight& curve2)const;
277 MGCCisect_list isect(const MGRLBRep& curve2)const;
278 MGCCisect_list isect(const MGEllipse& curve2)const;
279 MGCCisect_list isect(const MGLBRep& curve2)const;
280 MGCCisect_list isect(const MGSurfCurve& curve2)const;
281 MGCCisect_list isect(const MGBSumCurve& curve2)const;
282 MGCCisect_list isect(const MGTrimmedCurve& curve2)const;
283 MGCCisect_list isect(const MGCompositeCurve& curve2)const;
284 
286 MGCSisect_list isect(const MGSurface& surf) const;
287 MGCSisect_list isect(const MGPlane& surf) const;
288 MGCSisect_list isect(const MGSphere& surf)const;
289 MGCSisect_list isect(const MGCylinder& surf)const;
290 MGCSisect_list isect(const MGSBRep& surf)const;
291 MGCSisect_list isect(const MGRSBRep& surf)const;
292 MGCSisect_list isect(const MGBSumSurf& surf)const;
293 
295 double knot(int i) const;
296 
298 const MGKnotVector& knot_vector() const;
299 
304 double length(double t1, double t2) const;
305 
306 #ifdef __sgi
307  double length() const{return length(param_s(), param_e());}
308 #endif
309 
314 double length_param( double t, double len) const;
315 
319 
321 double negate_param(double t)const{return m_curve->negate_param(t);};
322 
324 int order() const{return m_curve->order();}
325 
327 std::ostream& out(std::ostream&) const;
328 
330 int out_to_IGES(
331  MGIgesOfstream& igesfile,
332  int SubordinateEntitySwitch=0
333 )const;
334 
336 double param_e() const;
337 
340 double param_normalize(double t) const;
341 
343 MGInterval param_range() const{return m_range;}
344 
346 double param_s() const;
347 
351 MGCurve* part(
352  double t1,
353  double t2,
354  int multiple=0
355 ) const;
357 
363  const MGPosition& P
364 )const;
365 
373 MGPosition_list perps(const MGCurve& crv2)const{return perps_in_range(crv2);};
374 MGPosition_list perps(const MGStraight& crv2)const{return perps_in_range(crv2);};
375 MGPosition_list perps(const MGRLBRep& crv2)const{return perps_in_range(crv2);};
376 MGPosition_list perps(const MGEllipse& crv2)const{return perps_in_range(crv2);};
377 MGPosition_list perps(const MGLBRep& crv2)const{return perps_in_range(crv2);};
378 MGPosition_list perps(const MGSurfCurve& crv2)const;
379 MGPosition_list perps(const MGBSumCurve& crv2)const{return perps_in_range(crv2);};
380 
404 int project(
405  const MGFSurface& surf, //given surface.
406  MGPvector<MGCurve>& vec_crv_uv, //uv projection curve will be appended.
407  MGPvector<MGCurve>& vec_crv, //3d projection curve will be appended.
408  const MGVector& vec //projection vector.
409  //if vec = NULL then calculate perpendicular project.
410 )const;
411 
414 double range(double t) const;
415 
417 int sdim() const{return m_curve->sdim();};
418 
425  const MGUnit_vector& uvec,
426  double start_dist,
427  double end_dist
428 )const;
429 
432 
434 MGCurve& unlimit();
435 
439 
443 
444 std::string whoami()const{return "TrimmedCurve";};
445 
446 protected:
447 
451  double f,
452  int coordinate=0
453 )const;
454 
459 std::auto_ptr<MGCurve> oneD(
460  const double g[4]
461 ) const;
462 
466 void ReadMembers(MGIfstream& buf);
467 
471 void WriteMembers(MGOfstream& buf) const;
472 
473 private:
474 
475  const MGCurve* m_curve;
476  mutable bool m_sameRange;
477  MGInterval m_range;
478  mutable MGKnotVector* m_knotV;
479 
482 MGBox* compute_box()const;
483 
487 
490 MGTrimmedCurve& coordinate_exchange(int i, int j);
491 
493 MGCCisect_list isect_in_range(const MGCurve& curve2)const;
494 
496 MGCCisect_list isect_withC1LB(const MGLBRep& curve2)const;
497 
499 MGCSisect_list isect_in_range(const MGSurface& surf)const;
500 
504 void narrow_into_range(
505  const MGCurve& curve2,
506  std::vector<double>& vecComSpan
507 )const;
508 
510 void negate();
511 
519 MGPosition_list perps_in_range(
520  const MGCurve& crv2
521 )const;
522 
527 void remove_knot();
528 
532 MGTrimmedCurve& operator*=(double scale);
533 MGTrimmedCurve& operator*=(const MGMatrix& mat);
535 
537 MGTrimmedCurve operator+ (const MGVector& v) const;
538 MGTrimmedCurve operator- (const MGVector& v) const;
539 MGTrimmedCurve operator* (double scale) const;
540 MGTrimmedCurve operator* (const MGMatrix& mat) const;
541 MGTrimmedCurve operator* (const MGTransf& tr) const;
542 
543 friend class MGSurfCurve;
544 friend class MGLBRep;
545 
546 };
547  // end of GEO group
549 #endif
MGVector eval(double t, int nderiv=0, int left=0) const
Evaluate n'th derivative data. n=0 means positional data evaluation.
Definition: TrimmedCurve.h:242
virtual MGCurve & operator=(const MGCurve &gel2)
Assignment.
Definition: Curve.h:84
virtual MGCurve & unlimit_start()=0
Unlimit parameter range of the curve to the start point direction.
virtual long identify_type() const =0
Return This object's typeID.
virtual MGCurve & unlimit()=0
Unlimit parameter range of the curve(limitをはずす).
MGTrimmedCurve is a part of an original curve of a limitted parameter range.
Definition: TrimmedCurve.h:50
virtual void remove_knot()
Remove redundant knot, and reduce the b-rep dimension.
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
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
virtual MGCurve * copy_change_dimension(int sdim, int start1=0, int start2=0) const =0
Construct new curve object by changing the original object's space dimension.
MGCylinder is a Cylinder in 3D space.
Definition: Cylinder.h:37
MGPosition_list perps(const MGRLBRep &crv2) const
Definition: TrimmedCurve.h:375
virtual int common(const MGCurve &curve2, std::vector< double > &vecComSpan, MGCCisect_list &isect) const
Test if this has a common line part with the 2nd curve.
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
virtual MGCParam_list perps(const MGPosition &P) const
Compute all foot points of the perpendicular line from point to the curve.
virtual double length_param(double t, double len) const
Inverse function of length.
MGPosition_list perps(const MGCurve &crv2) const
Definition: TrimmedCurve.h:373
virtual void negate()=0
Negate the curve direction(曲線の方向を反転する).
virtual void drawSE(mgVBO &vbo, double span_length, double t0, double t1) const
Draw this curve into vbo, approximating with polyline.
MGCompositeCurve is a composite of other leaf curves.
Definition: CompositeCurve.h:39
MGTrimmedCurve(Trimmed curve)
Definition: MGCL.h:150
virtual MGCurve & operator+=(const MGVector &v)=0
Object transformation.
virtual MGCurve * clone() const =0
Construct new geometry object by copying to newed area.
virtual MGCurve & coordinate_exchange(int i, int j)=0
Exchange ordering of the coordinates.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
friend class MGTrimmedCurve
Definition: Curve.h:1253
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
bool is_same_range() const
Definition: TrimmedCurve.h:272
MGInterval param_range() const
Return parameter range of the curve(パラメータ範囲を返す)
Definition: TrimmedCurve.h:343
virtual int project(const MGFSurface &surf, MGPvector< MGCurve > &vec_crv_uv, MGPvector< MGCurve > &vec_crv, const MGVector &vec) const
Obtain the projected curve of a curve onto the surface.
const MGCurve * base_curve() const
Return parameter curve's pointer.
Definition: TrimmedCurve.h:209
Vector of a general n space dimension.
Definition: Vector.h:26
virtual int bdim() const =0
Returns B-Rep Dimension.
virtual MGCCisect_list isect_withC1LB(const MGLBRep &curve2) const
Compute intersections with MGLBRep curve2 that does not have C0 continuity in it. ...
Defines a Box of any space dimendion.
Definition: Box.h:34
Define MGBSumCurve Class(Boolean sum curve of three curves).
Definition: BSumCurve.h:28
virtual MGCurve & limit(const MGInterval &rng)=0
Update this by limiting the parameter range of the curve.
virtual MGCurve * copy_limitted(const MGInterval &prange) const
Construct new curve object limitting the parameter range to prange.
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
virtual void ReadMembers(MGIfstream &buf)
メンバデータを読み出す関数.
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
virtual MGCurve * part(double t1, double t2, int multiple=0) const =0
Compute part of this curve from parameter t1 to t2.
MGPosition_list perps(const MGEllipse &crv2) const
Definition: TrimmedCurve.h:376
int order() const
Returns the order.
Definition: TrimmedCurve.h:324
virtual double knot(int i) const =0
Access to i-th element of knot.
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
virtual double param_normalize(double t) const =0
Normalize parameter value t to the nearest knot if their distance is within tolerance.
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
virtual void approximate_as_LBRep(MGLBRep &lb, int ordr=0, int parameter_normalization=0, bool neglectMulti=false) const
Approximate this curve as a MGLBRep.
Represent a positional data.
Definition: Position.h:28
virtual double param_s() const =0
Return starting parameter value.
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
MGCSisect_list defines linked list of MGCSisect.
Definition: CSisect_list.h:22
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
virtual double range(double t) const
Round t into curve's parameter range.
virtual MGCurve & unlimit_end()=0
Unlimit parameter range of the curve to the end point direction.
Defines Boolean sum surface.
Definition: BSumSurf.h:26
virtual MGSurface * sweep(const MGUnit_vector &uvec, double start_dist, double end_dist) const =0
Return sweep surface from crv.
virtual MGCurve & operator-=(const MGVector &v)=0
MGParam_Vector provides a list to store parameters of a curve.
Definition: CParam_list.h:18
MGSphere is a Sphere in 3D space.
Definition: Sphere.h:42
virtual void WriteMembers(MGOfstream &buf) const
メンバデータを書き込む関数.
Defines a list of MGCCisect(curve to curve intersection).
Definition: CCisect_list.h:20
virtual std::ostream & out(std::ostream &) const
Output virtual function.
virtual const MGKnotVector & knot_vector() const =0
Returns the knot vector of the curve.
virtual void extend(double length, bool start=false)=0
Extrapolate this curve by an (approximate) chord length.
MGFSurface is an abstract class to provide the comman interfaces to MGFace and MGSurface.
Definition: FSurface.h:33
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
Defines Rational Line B-Representation.
Definition: RLBRep.h:32
MGCURVE_TYPE
Curve type(曲線の種類).
Definition: MGCL.h:143
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
virtual MGCurve & operator*=(double scale)=0
virtual double length() const
Compute whole curve length.
Definition: Curve.h:624
MGPosition_list perps(const MGLBRep &crv2) const
Definition: TrimmedCurve.h:377
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
MGCURVE_TYPE type() const
Return curve type(曲線のタイプを返す)
Definition: TrimmedCurve.h:431
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
MGPosition_list perps(const MGBSumCurve &crv2) const
Definition: TrimmedCurve.h:379
virtual bool operator==(const MGCompositeCurve &crv) const
Comparison.
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
double negate_param(double t) const
Obtain parameter value if this curve is negated by "negate()".
Definition: TrimmedCurve.h:321
virtual std::auto_ptr< MGCurve > oneD(const double g[4]) const =0
Obtain transformed 1D curve expression of this curve.
virtual MGCurve * copy_as_nurbs() const =0
copy as a newed curve.
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
virtual int divide_multi(MGPvector< MGCurve > &crv_list, int multiplicity=-1) const
Divide this curve at the designated knot multiplicity point.
virtual bool operator<(const MGGel &gel2) const =0
virtual MGBox box_limitted(const MGInterval &) const =0
Return minimum box that includes the curve of parameter interval.
virtual MGCParam_list intersect_1D(double f, int coordinate=0) const
Compute intersection point of 1D sub curve of original curve.
virtual double param_e() const =0
Return ending parameter value.
virtual double curvilinear_integral() const
Definition: Curve.h:299
virtual MGCCisect_list isect(const MGCurve &curve2) const =0
Intersection of Curve and other geometry.
virtual int intersect_dnum() const =0
Provide divide number of curve span for function intersect.
std::string whoami() const
Definition: TrimmedCurve.h:444
virtual bool is_planar(MGPlane &plane) const
Test if this cure is planar or not.
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
MGTrimmedCurve & change_dimension(int dim, int start1, int start2)
Changing this object's space dimension.
Definition: TrimmedCurve.h:120
bool in_range(double t) const
Test if input parameter value is inside parameter range of the line.
Definition: TrimmedCurve.h:261
int sdim() const
Return space dimension.
Definition: TrimmedCurve.h:417
void change_range(double t1, double t2)
Definition: TrimmedCurve.h:130
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGPosition_list perps(const MGStraight &crv2) const
Definition: TrimmedCurve.h:374
MGSurfCurve is a curve on a surface.
Definition: SurfCurve.h:43
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30