MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Edge.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGEdge_HH_
6 #define _MGEdge_HH_
7 
8 #include "mg/Box.h"
9 #include "mg/TrimmedCurve.h"
10 #include "topo/Complex.h"
11 #include "topo/CellNB.h"
12 
13 class MGStraight;
14 class MGSurface;
15 class MGPVertex;
16 class MGBVertex;
17 class MGLoop;
18 class MGFace;
19 
20 //
21 //Define MGEdge Class.
22 
27 
33 class MG_DLL_DECLR MGEdge: public MGCellNB{
34 
35 public:
36 
39 MG_DLL_DECLR friend MGEdge operator* (double s, const MGEdge& e);
40 
42 
44 MGEdge();
45 
47 MGEdge(const MGEdge& e, bool copy_boundary=true, bool no_binder=false);
48 
52 MGEdge(
53  MGGeometry* geo,
54  MGPVertex* boundaries[2],
55  MGCellNB* binder
56  );
57 
63 MGEdge(const MGCurve& crv);
64 explicit MGEdge(MGCurve* crv);
65 
72 MGEdge(const MGCurve& crv, const MGInterval& range);
73 MGEdge(MGCurve* crv, const MGInterval& range);
74 
77 MGEdge(
78  const MGSurface&surf,
79  const MGCurve& pcrv,
80  const MGInterval& prange,
81  const MGCurve& wcrv
82  );
84 
86 ~MGEdge();
87 
89 
95 MGEdge& operator=(const MGGel& gel2);
96 MGEdge& operator=(const MGEdge& gel2);
97 
100 MGEdge operator+ (const MGVector& v) const;
101 
104 MGEdge operator- (const MGVector& v) const;
105 
108 MGEdge operator* (double s) const;
109 
112 MGEdge operator* (const MGMatrix& mat) const;
113 
116 MGEdge operator* (const MGTransf& tr) const;
117 
120 MGEdge operator/ (double s) const{return (*this)*(1./s);};
121 
123 bool operator==(const MGEdge& gel2)const;
124 bool operator==(const MGGel& gel2)const;
125 bool operator<(const MGEdge& gel2)const;
126 bool operator<(const MGGel& gel2)const;
127 bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));};
128 bool operator!=(const MGEdge& gel2)const{return !(gel2==(*this));};
129 
131 MGEdge& operator+=(const MGVector& v);
132 MGEdge& operator-=(const MGVector& v);
133 MGEdge& operator*=(double scale);
134 MGEdge& operator*=(const MGMatrix& mat);
135 MGEdge& operator*=(const MGTransf& tr);
136 
137 std::ostream& out(std::ostream& ostrm) const;
138 
140 
142 bool active_end() const{ return m_vertex[1]!=0;}
143 bool active_start() const{ return m_vertex[0]!=0;}
144 
147 const MGEdge* aft_edge(bool at_end=true, int* vertexID=0)const;
148 MGEdge* aft_edge(bool at_end=true, int* vertexID=0);
149 
152 MGEdge* binder_edge() const;
153 
155 const MGBox& box() const;
156 
158 MGPosition center_param() const;
159 
162 MGEdge* clone() const;
165 
168 MGEdge* clone_binder(const MGCellBase& e) const;
169 
191 void compute_continuity(
192  const MGEdge& edge2,
193  double diatance[7],
194  double tangent[4],
195  double normal[4]
196 )const;
197 
202 void connect(MGCellBase& cell2);
203 void connect(MGEdge& cell2);
204 
209 void connect_at_id(int id1, MGEdge* e2, int id2);
210 
212 void connect_at_start(MGPVertex& pvert){connect(0,pvert);};
213 
215 void connect_at_end(MGPVertex& pvert){connect(1,pvert);};
216 
220 MGCurve* base_curve();
221 const MGCurve* base_curve() const;
222 
228 MGCurve* curve_limitted() const;
229 
231 void delete_binder_edge();
232 
235 void disconnect_at_id(int id);
236 
239 void drawWire(
240  mgVBO& vbo,
241  double span_length,
242  int line_density=1
243 )const;
244 
248 void draw3DVertex(
249  mgVBO& vbo
250 )const;
251 
252 //Obtain this edge's parent loop's edge iterator as a member of the parent loop.
253 //This must have the parent loop, i.e. loop() must not null.
254 MGComplex::const_pcellItr edge_iterator()const;
255 MGComplex::pcellItr edge_iterator();
256 
257 //Obtain this edge number as a member of the parent loop.
258 //This must have the parent loop, i.e. loop() must not null.
259 int edge_num()const;
260 
262 MGPosition end_point()const{return eval(param_e());};
263 
266 MGVector eval(double t, int nderiv=0)const;
267 
274 MGVector eval_star(
275  double t,
276  int nderi=0
277 )const;
278 
281 bool equal_direction_to_binder()const;
282 
284 const MGFace* face() const;
285 MGFace* face();
286 
288 const MGEdge* first_partner() const;
289 
291 void free_end_neighbourhood();
292 
296 void free_neighbourhood(int i, int j=0);
297 
299 void free_start_neighbourhood();
300 
302 long identify_type()const;
303 
307 bool is_connected_and_same_direction(
308  bool start,
309  const MGEdge& edge2
310 )const;
311 
313 bool is_end_point(double t)const;
314 
316 bool is_start_point(double t)const;
317 
320 bool is_free()const{ return number_of_partners()==0;};
321 
326 void join(bool start, MGEdge* e2);
327 
329 const MGLoop* loop() const;
330 MGLoop* loop();
331 
335 MGCellNB* make_binder() const;
336 
342 MGEdge* make_binder_with_curve()const;
343 
345 int manifold_dimension() const{return 1;};
346 
348 const MGEdge* member_partner_edge(int i)const;
349 
352 MGPosition mid_point()const;
353 
355 void negate();
356 
360 std::vector<const MGCellNB*> neighbours() const;
361 
363 bool on_surface_perimeter() const{return surface_perimeter()>=0;};
364 bool on_surface_perimeter(const MGFace& f) const{return surface_perimeter(f)>=0;};
365 bool on_surface_perimeter(const MGSurface& sf) const{return surface_perimeter(sf)>=0;};
366 
368 double parameter_error()const;
369 
377 double param_bcell(double tp, const double* guess=0)const;
378 
387 double param_pcell(double tb, const double* guess=0)const;
388 
390 double param_e()const;
391 
393 double param_s()const;
394 
396 double param_span()const{return param_e()-param_s();};
397 
404 std::vector<const MGEdge*> partner_edges() const;
405 
410 MGPosition pick_closest(const MGStraight& sl)const;
411 
422 void polygonize(double error);
423 
426 const MGEdge* pre_edge(bool at_start=true) const;
427 MGEdge* pre_edge(bool at_start=true);
428 
430 MGInterval range()const;
431 
439 MGEdge* set_binder_edge(const MGCurve& wcrv)const;
440 MGEdge* set_binder_edge(const MGCurve& wcrv, const MGInterval& range)const;
441 
446 MGEdge* set_binder_edge(MGCurve* wcrv)const;
447 MGEdge* set_binder_edge(MGCurve* wcrv, const MGInterval& range)const;
448 
451 void set_end(double t);
452 
455 void set_start(double t);
456 
459 void set_only_param_range(double ts, double te);
460 
463 void set_i_th_binder(int i, MGBVertex& binder)const;
464 
468 const MGSurface* star_surface()const;
469 
471 MGPosition start_point()const{return eval(param_s());};
472 
475 int surface_perimeter() const;
476 int surface_perimeter(const MGSurface& sf) const;
477 int surface_perimeter(const MGFace& face) const;
478 
480 void trim_end(double t){trim(t,false);};
481 
483 void trim_start(double t){trim(t,true);};
484 
486 MGTrimmedCurve trimmed_curve() const;
487 
489 const MGPVertex* vertex(int id)const{return m_vertex[id];};
490 const MGPVertex* vertex_start()const{return m_vertex[0];};
491 const MGPVertex* vertex_end()const{return m_vertex[1];};
492 MGPVertex* vertex(int id){return m_vertex[id];};
493 MGPVertex* vertex_start(){return m_vertex[0];};
494 MGPVertex* vertex_end(){return m_vertex[1];};
495 
499 MGCurve* world_curve();
500 const MGCurve* world_curve() const;
501 
502 std::string whoami()const{return "Edge";};
503 
504 protected:
505 
507 void ReadMembers(MGIfstream& buf);
508 
510 void WriteMembers(MGOfstream& buf) const;
511 
512 private:
513 
514  MGPVertex* m_vertex[2];
515  mutable MGBox m_box;
518  mutable double m_perror;
519  mutable int m_equal_to_binder;
523 
525 void bn_binder_tr(const MGVector& v);
526 void bn_binder_tr(double s);
527 void bn_binder_tr(const MGMatrix& mat);
528 void bn_binder_tr(const MGTransf& tr);
529 
531 void connect(int id, MGPVertex& pvert);
532 
534 void set_box_as_null() const;
535 
540 MGEdge* clone(MGCellMap& cmap) const;
541 
542 void compute_box() const;
543 
546 void compute_continuity2(
547  const MGInterval& span,
548  int npoint,
549  const MGEdge& edge2,
550  double distance[7],
551  double tangent[4],
552  double normal[4]
553 )const;
554 
556 void copy_all_boundaries(const MGCellBase& cellin);
557 
561 void copy_all_boundaries(const MGCellBase& cellin, MGCellMap& cmap);
562 
564 void copy_box(const MGCellBase& cellin) const;
565 
567 void copy_perror(const MGCellBase& cellin) const;
568 
571 void get_all_boundary_binders(std::vector<MGCellNB*>& cvec) const;
572 
578 MGGeometry* make_binder_extent() const;
579 
586 void make_extent() const;
587 
589 void negate_boundary();
590 
594 void trim(double t, bool start);
595 
596 friend class MGFace;
597 friend class MGLoop;
598 
599 };
600  // end of TOPO group
602 #endif
CellNB is a cell without boundaries(No Boundaries).
Definition: CellNB.h:38
MGBVertex is 0 manifold dimension binder cell, is an point.
Definition: BVertex.h:30
Is an abstract class and the super class of MGPVertex and MGCellNB.
Definition: CellBase.h:38
virtual void WriteMembers(MGOfstream &buf) const
Write Object's Member Data.
MGTrimmedCurve is a part of an original curve of a limitted parameter range.
Definition: TrimmedCurve.h:50
bool active_end() const
Test if active at start or end.
Definition: Edge.h:142
virtual void free_neighbourhood(int i, int j=0)=0
Free neighbourhood relation at j-th boundary's i-th pcell of this cell.
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
virtual MGFace * face()
Return MGFace pointer if this MGGel is an MGFace, else return null.
Definition: Gel.h:151
MGPVertex * vertex_start()
Definition: Edge.h:493
bool is_free() const
Definition: Edge.h:320
const MGPVertex * vertex_end() const
Definition: Edge.h:491
virtual bool operator<(const MGGel &gel2) const
virtual long identify_type() const =0
Return Object's type ID (TID)
container_type::const_iterator const_pcellItr
Definition: Complex.h:34
const MGBox & box() const =0
Obtain the box of the cell.
void connect_at_start(MGPVertex &pvert)
Connect the start of this to the pvert's edge at pvert.
Definition: Edge.h:212
MGPosition start_point() const
Obtain the end point of the edge.
Definition: Edge.h:471
virtual MGCellNB & operator=(const MGCellNB &gel2)
virtual void compute_box() const =0
compute box of the cell in m_box.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
virtual void negate()
Negate the direction of the cell.
virtual void drawWire(mgVBO &vbo, double span_length, int line_density=1) const =0
bool on_surface_perimeter(const MGSurface &sf) const
Definition: Edge.h:365
void trim_start(double t)
Trim the loop. Result is from t1 to end.
Definition: Edge.h:483
bool on_surface_perimeter() const
Test if the edge is a part of a surface perimeter.
Definition: Edge.h:363
int manifold_dimension() const
Obtain manifold dimension.
Definition: Edge.h:345
Vector of a general n space dimension.
Definition: Vector.h:26
virtual void connect(MGCellBase &cell2)
virtual std::ostream & out(std::ostream &) const
Output virtual function.
int number_of_partners() const
MGGeometry is an abstract class which represents a whole geometry.
Definition: Geometry.h:36
virtual MGCellNB * clone_without_boundaries() const =0
virtual double parameter_error() const =0
Return parameter space error of the cell.
Defines a Box of any space dimendion.
Definition: Box.h:34
MGFace is a trimmed surface.
Definition: Face.h:51
virtual MGPosition pick_closest(const MGStraight &sl) const
Definition: Object.h:146
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
MGEdge is an instance of MGCellNB, represents a boundary element of 2D manifold.
Definition: Edge.h:33
bool on_surface_perimeter(const MGFace &f) const
Definition: Edge.h:364
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
bool operator!=(const MGGel &gel2) const
Definition: Edge.h:127
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
Represent a positional data.
Definition: Position.h:28
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
bool operator!=(const MGEdge &gel2) const
Definition: Edge.h:128
const MGPVertex * vertex(int id) const
Get the vertex at the start or end.
Definition: Edge.h:489
MGLoop is a boundary of a face, a boundary of 2D manifold cell.
Definition: Loop.h:44
virtual MGCellNB * clone_binder(const MGCellBase &c) const =0
virtual MGCellNB & operator-=(const MGVector &v)
MGPVertex * vertex_end()
Definition: Edge.h:494
virtual MGCellNB & operator*=(double scale)
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
std::string whoami() const
Definition: Edge.h:502
container_type::iterator pcellItr
Definition: Complex.h:33
friend class MGEdge
Definition: CellNB.h:298
virtual MGCellNB * make_binder() const =0
virtual MGCellNB & operator+=(const MGVector &v)
Object transformation.
const MGPVertex * vertex_start() const
Definition: Edge.h:490
virtual void draw3DVertex(mgVBO &vbo) const =0
bool active_start() const
Definition: Edge.h:143
virtual std::vector< const MGCellNB * > neighbours() const =0
virtual bool operator==(const MGGel &gel2) const
Comparison.
Definition: Gel.h:80
virtual void ReadMembers(MGIfstream &buf)
Read Object's member data.
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
virtual MGPosition center_param() const =0
Obtain the center parameter value of this cell.
MGPVertex is a parameter cell of the manifold dimension 0.
Definition: PVertex.h:34
MGPVertex * vertex(int id)
Definition: Edge.h:492
void trim_end(double t)
Trim the loop. Result is from start to t1.
Definition: Edge.h:480
MGPosition end_point() const
Obtain the end point of the edge.
Definition: Edge.h:262
void connect_at_end(MGPVertex &pvert)
Connect the end of this to the pvert's edge at pvert.
Definition: Edge.h:215
virtual MGCellNB * clone() const =0
double param_span() const
Obtain parameter span of this edge.
Definition: Edge.h:396
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30