MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Loop.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGLoop_HH_
6 #define _MGLoop_HH_
7 
8 #include "mg/Pvector.h"
9 #include "topo/LSPoint_vector.h"
10 #include "topo/Boundary.h"
11 #include "topo/TrimLoop.h"
12 
13 class MGInterval;
14 class MGPosition;
15 class MGCurve;
16 class MGStraight;
17 class MGSurface;
18 class MGLCisect_vector;
19 class MGLLisect_vector;
20 class MGPVertex;
21 class MGLEPoint;
22 class MGLPoint;
23 class MGLoop;
24 class MGEdge;
25 class MGFSurface;
26 class MGFace;
32 //
33 //Define MGLoop Class.
34 
36 
44 class MG_DLL_DECLR MGLoop:public MGBoundary{
45 
46 public:
47 
48 enum LoopKind{
49  UNDEFINED=-1,
50  INACTIVE=0,
51  PERIMITER_LOOP=1,
52  OUTER_LOOP=2,
53  INNER_LOOP=3,
54  NETWORK=4
55 };
56 
58 MG_DLL_DECLR friend MGEdge* edge_from_iterator(pcellItr i);
59 MG_DLL_DECLR friend const MGEdge* edge_from_iterator(const_pcellItr i);
60 
62 
64 MG_DLL_DECLR friend MGVector eval(const MGLEPoint& t, int nderi=0);
65 
67 
76 MG_DLL_DECLR friend int inside_outer_loop(
77  const MGPosition& uv,
78  const std::vector<const MGLoop*>& loop,
79  const MGSurface* surf=0
80 );
81 
83 
85 MGLoop();
86 
88 explicit MGLoop(MGEdge* edge);
89 
91 MGLoop(const MGLoop& loop2);
92 
103 MGLoop(const MGCurve& param_curve, const MGCurve& world_curve);
104 MGLoop(const MGCurve& param_curve, const MGInterval& range1,
105  const MGCurve& world_curve, const MGInterval& range2);
106 MGLoop(std::auto_ptr<MGCurve>& param_curve, std::auto_ptr<MGCurve>& world_curve);
107 
109 
111 
115 MGLoop& operator=(const MGGel& gel2);
116 MGLoop& operator=(const MGLoop& gel2);
117 
119 MGLoop& operator+=(const MGVector& v);
120 MGLoop& operator-=(const MGVector& v);
121 MGLoop& operator*=(double scale);
122 MGLoop& operator*=(const MGMatrix& mat);
123 MGLoop& operator*=(const MGTransf& tr);
124 
130 bool operator<(const MGLoop& gel2)const;
131 bool operator<(const MGComplex& gel2)const;
132 bool operator<(const MGGel& gel2)const;
133 
135 
137 bool active() const;
138 
141 void append(MGEdge* edge);
142 
147 void append_edge_from_crv(
148  const MGSurface& srf,
149  const MGCurve& wcrv,
150  double& tLast,
152  double terror,
154  const std::vector<double>& pspan,
155  int peri_num,
156  bool orientation_is_opposite=false
157 );
158 
161 double area()const;
162 
167 bool both_end_on_perimeter(int& pid_s, int& pid_e,const MGFSurface* srf=0) const;
168 
171 MGLoop* clone(MGCell& parent)const;
172 MGLoop* clone()const;
173 
176 MGLoop* clone_without_binders(MGCell& parent) const;
178 
180 bool closed() const;
181 
186 MGLEPoint closest(const MGPosition& P, double& distance) const;
187 
197 bool closest_world(
198  const MGStraight& sl,
199  MGLEPoint& closest,
200  double& dist
201 )const;
202 
215 int common(
216  const MGLoop& loop2,
217  std::vector<MGLEPoint>& pranges1,
218  std::vector<double>& branges1,
219  std::vector<MGLEPoint>& pranges2,
220  std::vector<double>& branges2
221 )const;
222 
225 double compute_area()const;
226 
229 void copy_boundary(const MGBoundary& loop);
230 
232 void copy_boundary_without_binders(const MGBoundary& loop);
233 
238 MGPvector<MGCurve> curves()const;
239 
245 MGPvector<MGCurve> curves_world()const;
246 
248 MGEdge* edge(int i);
249 const MGEdge* edge(int i) const;
250 
252 bool edge_exist() const{return pcell_exist();};
253 
256 int edge_num(const MGEdge* e)const;
257 
260 MGPosition end_point() const;
261 
264 MGLEPoint end_LPoint() const;
265 
269 double error()const;
270 
272 MGVector eval(const MGLPoint& t, int nderi=0)const;
273 
275 MGVector eval(int i, double t, int nderi=0)const;
276 
279 const MGFace* face() const;
280 MGFace* face();
281 
283 const MGEdge* first_edge() const;
284 MGEdge* first_edge();
285 
290 int get_loop_id_in_face()const;
291 
302 int inside(double u, double v) const;
303 int inside(const MGPosition& uv) const;
304 
306 long identify_type()const;
307 
310 MGLCisect_vector isect(const MGCurve& param_curve) const;
311 
314 MGLCisect_vector isect(
315  double error,//error to get intersection of the loops and sl.
316  const MGCurve& param_curve
317 ) const;
318 
321 std::vector<MGLEPoint> isect_1D(
322  double f,
323  int coordinate=0
324 ) const;
325 
330 MGLCisect_vector isect_with_endpoints
331 (const MGCurve& param_curve) const;
332 
334 bool is_inactive(const MGFSurface* srf=0) const;
335 
339 bool is_inner_boundary(const MGFSurface* srf=0) const;
340 
344 bool is_outer_boundary(const MGFSurface* srf=0) const;
345 
349 bool is_perimeter_boundary(const MGFSurface* srf=0) const;
350 
352 bool is_network(const MGFSurface* srf=0) const{return m_kind==NETWORK;};
353 
355 MGLLisect_vector isect(const MGLoop& loop2)const;
356 
362 void join(bool start, const MGLoop& loop2);
363 void join(bool start, MGLoop* loop2);
364 void join(bool start, std::auto_ptr<MGLoop>& loop2);
365 
368 void join_C1_edges(
369  int parameter_normalization=2
371  //=0: no parameter normalization.
372  //=1: normalize to range=(n, n+1) for the n-th edge.
373  //=2: normalize to make the average length of the 1st derivative
374  // is as equal to 1. as possible. Let the n-th edge's parameter range
375  // is (TSn, TEn), then, TSn=TEn-1.
376 );
377 
379 const MGEdge* last_edge() const;
380 MGEdge* last_edge();
381 
385 void make_close();
386 
392 bool make_vertex(
393  const MGLEPoint& lp,
394  MGEdge*& pre,
395  MGEdge*& aft,
396  MGPVertex** pvertex=0
397 );
398 
400 int manifold_dimension() const{return 1;};
401 
409 bool merge_network(
410  const MGCurve& param_curve,
411  double error
412 );
413 
427 bool merge_trim(const MGCurve& param_curve);
428 bool merge_trim(const MGCurve& param_curve, const MGInterval& range1);
429 bool merge_trim(const MGCurve& param_curve, const MGCurve& world_curve);
430 bool merge_trim(const MGCurve& param_curve, const MGInterval& range1,
431  const MGCurve& world_curve);
432 bool merge_trim(const MGLoop& loop2);
433 
437 MGPosition mid_point()const;
438 
441 void negate();
442 
452 void negate_as_boundary(const MGCellNB* parent=0);
453 
455 int number_of_edges()const{return number_of_pcells();};
456 
460 bool on_perimeter_end(int& pid_e,const MGFSurface* surf=0)const;
461 bool on_perimeter_start(int& pid_s,const MGFSurface* surf=0)const;
462 
464 bool on_surface_perimeter(const MGFace& f)const;
465 
467 std::ostream& out(std::ostream&) const;
468 
470 void prepend(MGEdge* e);
471 
474 bool remove_pendent_edge(const MGFSurface& face);
475 
478 void remove_garbage_edge(double error);
479 
481 const MGSurface* surface()const;
482 
485 MGLEPoint start_LPoint() const;
486 
489 MGPosition start_point() const;
490 
499 std::vector<MGEdge*> subdivide(
500  const std::vector<MGLEPoint>& ranges
501 );
502 
506 MGEdge* subdivide(
507  MGLEPoint& le1, MGLEPoint& le2
508 );
509 
513 void trim(const MGLEPoint& t1, const MGLEPoint& t2);
514 
516 void trim_end(const MGLEPoint& t1);
517 
519 void trim_start(const MGLEPoint& t1);
520 
521 protected:
522 
526 MGLoop(
527  std::list<MGCellNB*> boundaries
528 );
529 
532 MGLoop(
533  const MGLoop& loop,
534  MGCellMap& cmap
535 );
536 
541 MGLoop* clone(MGCell& parent,MGCellMap& cmap) const;
542 MGLoop* clone(MGCellMap& cmap) const;
543 
544 std::string whoami()const{return "Loop";};
545 
547 void ReadMembers(MGIfstream& buf);
548 
550 void WriteMembers(MGOfstream& buf) const;
551 
553 
554 private:
555  mutable LoopKind m_kind;
556 
557  mutable double m_area;
558 
561  mutable int m_perim_num_s;
562  mutable int m_perim_num_e;
563 
567 void compute_kind(const MGFSurface* srf=0)const;
568 
571 void get_kind(const MGFSurface* srf=0) const;
572 
578 bool get_perimeter_num(int& pid_s, int& pid_e,const MGFSurface* srf=0) const;
579 
589 int in_on_curves(
590  const MGPosition& uv,
591  const double error[3],
595  const MGPvector<MGCurve>& crvs,
596  const MGStraight& sl
599 )const;
600 
611 int inside_test(
612  const MGPosition& uv
613 )const;
614 
619 std::vector<MGLEPoint> isect_1D_tess(
620  double f,
621  int coordinate=0
622 ) const;
623 
626 MGLSPoint_vector isect_binder(const MGFSurface& face) const;
627 
629 void make_loop(std::auto_ptr<MGCurve>& param_curve, std::auto_ptr<MGCurve>& world_curve);
630 
636 bool makeVertexWithLcis(
637  const MGLEPoint& lp,
638  MGLCisect_vector& lcis,
639  MGPVertex*& pvertex
641 );
642 
644 bool merge_trim(const MGCurve& param_curve, const MGInterval& range1,
645  const MGCurve* world_curve);
646 
648 bool merge_loop(const MGLoop& loop2);
649 
653 void trim_param_set(const MGLEPoint& t, bool start);
654 
655 friend class MGFace;
656 friend class MGEdge;
657 
658 };
659 
661 extern MG_DLL_DECLR void build_networks(
662  const MGFSurface& surf,
663  const MGPvector<MGCurve>& pcurves,
664  MGPvector<MGLoop>& networks
665 );
666 
669 extern MG_DLL_DECLR std::auto_ptr<MGLoop> trim_out_subloop(const MGLEPoint& ts, const MGLEPoint& te);
670  // end of TOPO group
672 #endif
CellNB is a cell without boundaries(No Boundaries).
Definition: CellNB.h:38
int manifold_dimension() const
Get manifold dimension.
Definition: Loop.h:400
int number_of_pcells() const
Obtain how many parameter cells are included in the boundary.
MGLCisect_vector defines linked list of MGLCisect.
Definition: LCisect_vector.h:23
virtual long identify_type() const =0
Return Object's type ID (TID)
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
MG_DLL_DECLR std::auto_ptr< MGLoop > trim_out_subloop(const MGLEPoint &ts, const MGLEPoint &te)
virtual MGFace * face()
Return MGFace pointer if this MGGel is an MGFace, else return null.
Definition: Gel.h:151
virtual MGSurface * surf()
Return MGSurface pointer if this MGGel is an MGSurface, else return null.
Definition: Gel.h:143
MGLPoint is to represent Loop's point.
Definition: LPoint.h:23
virtual void negate_as_boundary(const MGCellNB *parent=0)
virtual void copy_boundary_without_binders(const MGBoundary &bnd)
virtual void ReadMembers(MGIfstream &buf)
Read Object's member data.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
MGLLisect_vector defines a vector of MGLLisect.
Definition: LLisect_vector.h:23
virtual bool closed() const =0
Test if this is closed boundary.
Vector of a general n space dimension.
Definition: Vector.h:26
MGCell is a general cell that has bound.
Definition: Cell.h:35
virtual MGBoundary * clone() const =0
MGFace is a trimmed surface.
Definition: Face.h:51
virtual void negate()
virtual MGBoundary & operator*=(double scale)
Definition: Boundary.h:67
bool edge_exist() const
Test if at least one edge is included in this loop.
Definition: Loop.h:252
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
virtual void WriteMembers(MGOfstream &buf) const
Write Object's Member Data.
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
virtual MGBoundary * clone_without_binders() const =0
Represent a positional data.
Definition: Position.h:28
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
Is to represent a Loop's point.
Definition: LEPoint.h:28
MGLoop is a boundary of a face, a boundary of 2D manifold cell.
Definition: Loop.h:44
virtual MGBoundary & operator+=(const MGVector &v)
Object transformation.
Definition: Boundary.h:65
MGBoundary is a boundary of more than 1 manifold dimension.
Definition: Boundary.h:35
virtual bool operator<(const MGComplex &gel2) const
comparison
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
bool pcell_exist() const
Cehck if pcell exist.
LoopKind
Definition: Loop.h:48
MGComplex is a container of parameter cells and binder cells.
Definition: Complex.h:25
virtual bool active() const =0
Test if this is an active boundary.
std::string whoami() const
Definition: Loop.h:544
int number_of_edges() const
Get the number of edge included.
Definition: Loop.h:455
MGLSPoint_vector defines a vector of MGLSPoint.
Definition: LSPoint_vector.h:18
virtual std::ostream & out(std::ostream &) const
Output virtual function.
bool is_network(const MGFSurface *srf=0) const
Test if this loop is network.
Definition: Loop.h:352
virtual void copy_boundary(const MGBoundary &bnd)
virtual MGBoundary & operator-=(const MGVector &v)
Definition: Boundary.h:66
MGPVertex is a parameter cell of the manifold dimension 0.
Definition: PVertex.h:34
MG_DLL_DECLR void build_networks(const MGFSurface &surf, const MGPvector< MGCurve > &pcurves, MGPvector< MGLoop > &networks)
Build networks of surf, given parameter curves vector.
virtual MGBoundary & operator=(const MGBoundary &gel2)
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30