MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Complex.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGComplex_HH_
6 #define _MGComplex_HH_
7 
8 #include <list>
9 #include "mg/Box.h"
10 #include "topo/Topology.h"
11 
12 //
13 //Define MGComplex Class.
14 
15 class MGPosition;
16 class MGCellNB;
17 class MGCellMap;
18 class MGBoundary;
19 
24 class MG_DLL_DECLR MGComplex: public MGTopology{
26 
27 public:
28 typedef std::list<MGCellNB*> container_type;
29 
30 typedef container_type::iterator cellItr;
31 typedef container_type::const_iterator const_cellItr;
32 
33 typedef container_type::iterator pcellItr;
34 typedef container_type::const_iterator const_pcellItr;
35 
36 typedef container_type::iterator bcellItr;
37 typedef container_type::const_iterator const_bcellItr;
38 
41 MG_DLL_DECLR friend MGComplex operator* (double s, const MGComplex& complex);
42 
44 
46 MGComplex();
47 
51 MGComplex(const MGComplex& complex);
52 
55 MGComplex(const MGCellNB& cell);
56 MGComplex(MGCellNB* cell);
57 
59 
60 virtual ~MGComplex();
61 
63 
67 virtual MGComplex& operator=(const MGGel& gel2);
68 virtual MGComplex& operator=(const MGComplex& gel2);
69 
72 MGComplex operator+ (const MGVector& v) const;
73 
76 MGComplex operator- (const MGVector& v) const;
77 
80 MGComplex operator* (double s) const;
81 
84 MGComplex operator* (const MGMatrix& mat) const;
85 
88 MGComplex operator* (const MGTransf& tr) const;
89 
91 virtual MGComplex& operator+=(const MGVector& v);
92 virtual MGComplex& operator-=(const MGVector& v);
93 virtual MGComplex& operator*=(double scale);
94 virtual MGComplex& operator*=(const MGMatrix& mat);
95 virtual MGComplex& operator*=(const MGTransf& tr);
96 
99 MGComplex operator/ (double s) const{return (*this)*(1./s);};
100 
102 virtual bool operator<(const MGComplex& gel2)const;
103 virtual bool operator<(const MGGel& gel2)const;
104 
106 
108 const_bcellItr bcell_begin() const{ return m_bcells.begin();};
109 bcellItr bcell_begin() { return m_bcells.begin();};
110 
112 const_bcellItr bcell_end() const{ return m_bcells.end();};
113 bcellItr bcell_end() { return m_bcells.end();};
114 
116 const MGCellNB* bcelli(int i) const;
117 MGCellNB* bcelli(int i);
118 
120 const_bcellItr bcellIterator(int i) const;
121 bcellItr bcellIterator(int i);
122 
124 bool bcell_exist()const;
125 
127 MGCellNB* binder(int i) const;
128 
132 std::vector<MGCellNB*> binders() const;
133 
135 const MGBox& box() const;
136 
139 MGPosition center() const;
140 
143 virtual MGComplex* clone() const;
144 
147 void drawWire(
148  mgVBO& vbo,
149  double span_length,
150  int line_density=1
151 )const;
152 
155 virtual void drawWire_in_star(
156  mgVBO& vbo,
157  double span_length,
158  int line_density=1
159 )const;
160 
164 virtual void draw3DVertex(
165  mgVBO& vbo
166 )const;
167 
170 virtual void draw3DVertex_in_star(mgVBO& vbo)const;
171 
174 void erase_first_pcell();
175 
178 void erase_last_pcell();
179 
182 void erase_pcell(MGCellNB* pcell);
183 
185 const MGCellNB* first_pcell()const;
186 MGCellNB* first_pcell();
187 
189 virtual long identify_type()const;
190 
193 bool includes(const MGCellNB* cell)const;
194 
196 const MGCellNB* last_pcell()const;
197 MGCellNB* last_pcell();
198 
200 virtual int manifold_dimension() const;
201 
203 int number_of_bcells() const{return int(m_bcells.size());};
204 
206 int number_of_pcells() const{return int(m_pcells.size());};
207 
209 virtual std::ostream& out(std::ostream&) const;
210 
212 const_pcellItr pcell_begin() const{ return m_pcells.begin();};
213 pcellItr pcell_begin() { return m_pcells.begin();};
214 
216 const_pcellItr pcell_end() const{ return m_pcells.end();};
217 pcellItr pcell_end() { return m_pcells.end();};
218 
220 const MGCellNB* pcelli(int i) const;
221 MGCellNB* pcelli(int i);
222 
224 const_pcellItr pcellIterator(int i) const;
225 pcellItr pcellIterator(int i);
226 
228 bool pcell_exist()const;
229 
234 std::vector<MGCellNB*> pcells();
235 std::vector<const MGCellNB*> pcells() const;
236 
241 MGPosition pick_closest(const MGStraight& sl)const;
242 
245 const MGCellNB* star() const;
246 MGCellNB* star();
247 
248 protected:
249  mutable MGBox m_box;
250 
259 explicit MGComplex(std::list<MGCellNB*>& pcells);
260 
262 MGComplex(const MGComplex& complex,
263  MGCellMap& cmap);
264 
266 cellItr append_bcell(MGCellNB* cell)const;
267 
270 cellItr add_cell(
271  MGCellNB* cell,
272  bool pcell,
273  cellItr loc
274 );
276 
278 cellItr append_pcell(MGCellNB* cell);
279 
281 virtual void compute_box() const;
282 
285 void copy_without_binders(const MGComplex& comp);
286 
290 void erase_all_elements();
291 
293 cellItr prepend_pcell(MGCellNB* cell);
294 
295 virtual std::string whoami()const{return "Complex";};
296 
298 virtual void ReadMembers(MGIfstream& buf);
299 
303 MGComplex& set_complex(const MGComplex& comp2);
304 
306 virtual void WriteMembers(MGOfstream& buf) const;
307 
308 private:
309 
310  container_type m_pcells;
311  mutable container_type m_bcells;
312 
315 
318 void binderTr(const MGVector& v);
319 
322 void binderTr(double s);
323 
326 void binderTr(const MGMatrix& mat);
327 
330 void binderTr(const MGTransf& tr);
331 
333 void copy_all_elements(const MGComplex& comp);
334 
337 void copy_all_elements(
338  const MGComplex& comp,
339  MGCellMap& cmap
340 );
341 
344 void erase_binder(const MGCellNB*);
345 
346 friend class MGCellBase;
347 friend class MGCellNB;
348 friend class MGCell;
349 friend class MGEdge;
350 };
351  // end of TOPO group
353 #endif
CellNB is a cell without boundaries(No Boundaries).
Definition: CellNB.h:38
virtual std::string whoami() const
Definition: Complex.h:295
Is an abstract class and the super class of MGPVertex and MGCellNB.
Definition: CellBase.h:38
container_type::const_iterator const_bcellItr
Definition: Complex.h:37
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
const_pcellItr pcell_begin() const
Obtain first pcell iterator.
Definition: Complex.h:212
virtual MGTopology & operator=(const MGTopology &gel2)
virtual bool operator<(const MGGel &gel2) const
virtual long identify_type() const =0
Return This object's typeID.
container_type::iterator bcellItr
Definition: Complex.h:36
container_type::iterator cellItr
Definition: Complex.h:30
container_type::const_iterator const_pcellItr
Definition: Complex.h:34
container_type::const_iterator const_cellItr
Definition: Complex.h:31
MGTopology is an abstract class which represents a whole Topology.
Definition: Topology.h:33
bcellItr bcell_begin()
Definition: Complex.h:109
int number_of_bcells() const
count number of bcells of the complex
Definition: Complex.h:203
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
virtual void drawWire(mgVBO &vbo, double span_length, int line_density=1) const =0
const_bcellItr bcell_end() const
Obtain end bcell iterator(next of the last bcell).
Definition: Complex.h:112
pcellItr pcell_begin()
Definition: Complex.h:213
const_pcellItr pcell_end() const
Obtain end pcell iterator(next of the last pcell).
Definition: Complex.h:216
Vector of a general n space dimension.
Definition: Vector.h:26
Defines a Box of any space dimendion.
Definition: Box.h:34
MGCell is a general cell that has bound.
Definition: Cell.h:35
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
int number_of_pcells() const
count number of pcells of the complex
Definition: Complex.h:206
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
virtual MGObject * clone() const =0
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
Represent a positional data.
Definition: Position.h:28
const_bcellItr bcell_begin() const
Obtain first bcell iterator.
Definition: Complex.h:108
virtual MGObject & operator-=(const MGVector &v)=0
std::list< MGCellNB * > container_type
Definition: Complex.h:28
MGBox m_box
Definition: Complex.h:249
virtual void ReadMembers(MGIfstream &buf)
MGBoundary is a boundary of more than 1 manifold dimension.
Definition: Boundary.h:35
virtual void WriteMembers(MGOfstream &buf) const
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
container_type::iterator pcellItr
Definition: Complex.h:33
MGComplex is a container of parameter cells and binder cells.
Definition: Complex.h:25
virtual std::ostream & out(std::ostream &) const
Output virtual function.
virtual int manifold_dimension() const
Definition: Gel.h:116
virtual void draw3DVertex(mgVBO &vbo) const =0
virtual const MGBox & box() const =0
Get the box of the object.
pcellItr pcell_end()
Definition: Complex.h:217
virtual MGObject & operator+=(const MGVector &v)=0
Object transformation.
virtual MGObject & operator*=(double scale)=0
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
bcellItr bcell_end()
Definition: Complex.h:113
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30