MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Object.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGObject_HH_
6 #define _MGObject_HH_
7 
8 #include "mg/MGCL.h"
9 #include "mg/Pvector.h"
10 #include "mg/drawParam.h"
11 #include "mg/Plist.h"
12 #include "mg/Position.h"
13 #include "mg/isects.h"
14 #include "mg/AttribedGel.h"
15 
16 //
17 //Define MGObject Class.
18 class MGIfstream;
19 class MGOfstream;
20 class MGBox;
21 class MGVector;
22 class MGMatrix;
23 class MGTransf;
24 class MGObject;
25 class MGGeometry;
26 class MGTopology;
27 class MGPoint;
28 class MGStraight;
29 class MGCurve;
30 class MGFSurface;
31 class MGSurface;
32 class MGFace;
33 class MGShell;
34 class mgTL2Triangles;
35 
41 class MG_DLL_DECLR MGObject:public MGAttribedGel{
43 
44 public:
45 
47 
49 MGObject();
50 
52 MGObject(const MGObject& obj2);
53 
55 virtual ~MGObject();
56 
60 virtual MGObject& operator=(const MGObject& obj2){return set_object(obj2);};
61 
63 virtual MGObject& operator+=(const MGVector& v)=0;
64 virtual MGObject& operator-=(const MGVector& v)=0;
65 virtual MGObject& operator*=(double scale)=0;
66 virtual MGObject& operator*=(const MGMatrix& mat)=0;
67 virtual MGObject& operator*=(const MGTransf& tr)=0;
68 
70 
72 virtual std::ostream& out(std::ostream&) const;
73 
77 MGAppearance* appearance(){return m_appearance;};
78 const MGAppearance* appearance()const{return m_appearance;};
79 
81 virtual const MGBox& box() const=0;
82 
85 virtual MGObject* clone() const=0;
86 
89 virtual void drawWire(
90  mgVBO& vbo,
91  double span_length,
92  int line_density=1
93 )const=0;
94 
98 virtual void draw3DVertex(mgVBO& vbo)const=0;
99 
101 virtual void shade(
102  mgVBO& vbo,
103  const MGDrawParam& para,
105 )const{drawWire(vbo,para.span_length_wire());};
106 
110 
112 virtual void make_display_list(
114 )const;
115 
118 bool has_common(const MGObject& obj2) const;
119 
121 const MGObject* includes_object()const{return this;};
123 MGObject* includes_object(){return this;};
124 
134 virtual MGisects intersection(const MGObject& obj2)const=0;
135 virtual MGisects intersection(const MGPoint& obj2)const{return MGisects();};
136 virtual MGisects intersection(const MGCurve& obj2)const=0;
137 virtual MGisects intersection(const MGFSurface& obj2)const=0;
138 virtual MGisects intersection(const MGSurface& obj2)const=0;
139 virtual MGisects intersection(const MGFace& obj2)const=0;
140 virtual MGisects intersection(const MGShell& obj2)const=0;
141 
146 virtual MGPosition pick_closest(const MGStraight& sl)const{
147  return MGPosition();
148 }
149 
151 void remove_appearance();
152 
154 virtual MGObject* object(){return this;};
155 virtual const MGObject* object()const{return this;};
156 
158 virtual const MGFSurface* fsurface()const{return (const MGFSurface*)0;};
159 virtual MGFSurface* fsurface(){return (MGFSurface*)0;};
160 
161 //set the copy of appr2 to this MGAttribedgel.
162 void set_appearance(const MGAppearance& appr2);
163 
165 virtual void transform(const MGVector& v){(*this)+=v;};
166 virtual void transform(double scale){(*this)*=scale;};
167 virtual void transform(const MGMatrix& mat){(*this)*=mat;};
168 virtual void transform(const MGTransf& tr){(*this)*=tr;};
169 
170 protected:
171 
173 virtual void ReadMembers(MGIfstream& buf);
174 
176 virtual void WriteMembers(MGOfstream& buf)const;
177 
181 MGObject& set_object(const MGObject& gel2);
182 
183 private:
184 
185 MGAppearance* m_appearance;
186 
187 friend class MGIfstream;
188 friend class MGOfstream;
189 
190 };
191 
193 MG_DLL_DECLR MGObject* MGNullObj(long TID);
194  // end of MGObjectRelated group
196 #endif
virtual void transform(const MGMatrix &mat)
scaling.
Definition: Object.h:167
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
Definition: MGCL.h:272
const MGAppearance * appearance() const
Definition: Object.h:78
MGPoint represents one dimensional manifold, a point in a space.
Definition: Point.h:28
A vector of mgTL2Triangle's.
Definition: TL2Triangles.h:25
virtual void WriteMembers(MGOfstream &buf) const
Write all member data.
MGTopology is an abstract class which represents a whole Topology.
Definition: Topology.h:33
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
virtual MGAppearance * ensure_appearance()=0
Definition: VBO.h:86
Is an abstract class which represents a whole geometry and a topology.
Definition: Object.h:42
MG_DLL_DECLR MGVector & operator*=(MGVector &v, const MGMatrix &m)
MGShell is a composition of MGFace's(trimmed surface).
Definition: Shell.h:32
Vector of a general n space dimension.
Definition: Vector.h:26
MGGeometry is an abstract class which represents a whole geometry.
Definition: Geometry.h:36
virtual MGFSurface * fsurface()
Definition: Object.h:159
Defines a Box of any space dimendion.
Definition: Box.h:34
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
double span_length_wire() const
Definition: drawParam.h:93
virtual MGPosition pick_closest(const MGStraight &sl) const
Definition: Object.h:146
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
Is an abstract class which provides interfaces of MGGel that has MGAppearance.
Definition: AttribedGel.h:32
virtual void set_appearance(const MGAppearance &appr2)=0
virtual void transform(const MGTransf &tr)
matrix transformation.
Definition: Object.h:168
Represent a positional data.
Definition: Position.h:28
virtual const MGObject * object() const
Definition: Object.h:155
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
virtual void transform(const MGVector &v)
Transform the gel by the argument.
Definition: Object.h:165
ELEMENT_TARGET
Definition: VBO.h:84
const MGObject * includes_object() const
Test if this gel includes an object.
Definition: Object.h:121
VIEWMODE
Definition: MGCL.h:271
virtual std::ostream & out(std::ostream &) const =0
Output virtual function.
virtual const MGFSurface * fsurface() const
Get the MGFSurface pointer if this is MGSurface or MGFace.
Definition: Object.h:158
MGFSurface is an abstract class to provide the comman interfaces to MGFace and MGSurface.
Definition: FSurface.h:33
virtual MGisects intersection(const MGPoint &obj2) const
Definition: Object.h:135
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
virtual void shade(mgVBO &vbo, const MGDrawParam &para, mgVBO::ELEMENT_TARGET target=mgVBO::SHADING) const
Shade the object in world coordinates.
Definition: Object.h:101
virtual void remove_appearance()=0
Remove the MGAppearance of this MGAttribedGel.
A container class to hold MGGLAttrib objects.
Definition: Appearance.h:33
MGisects defines a vector of MGisect.
Definition: isects.h:44
MGAppearance * appearance()
Definition: Object.h:77
virtual void ReadMembers(MGIfstream &buf)
Read all member data.
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
virtual MGGel * clone() const =0
virtual MGObject & operator=(const MGObject &obj2)
Definition: Object.h:60
virtual void make_display_list(MGCL::VIEWMODE vmode=MGCL::DONTCARE) const
Make a display list of this gel.
Definition: Gel.h:112
friend class MGObject
Definition: AttribedGel.h:34
MGObject * includes_object()
Test if this gel includes an object.
Definition: Object.h:123
virtual MGObject * object()
Return MGObject pointer if this MGGel is an MGObject, else return null.
Definition: Object.h:154
virtual void transform(double scale)
translation
Definition: Object.h:166
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30