GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_structreference.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 
25 #ifndef GLC_STRUCTREFERENCE_H_
26 #define GLC_STRUCTREFERENCE_H_
27 
28 #include <QString>
29 #include <QSet>
30 
31 #include "../geometry/glc_3drep.h"
32 #include "glc_3dviewinstance.h"
33 #include "glc_attributes.h"
34 #include "glc_structinstance.h"
35 
36 #include "../glc_config.h"
37 
39 
42 
43 
45 {
47 
49 
50 public:
52  GLC_StructReference(const QString& name= QString());
53 
56 
59 
61  GLC_StructReference& operator=(const GLC_StructReference&);
62 
64  virtual ~GLC_StructReference();
66 
67 
69 
70 public:
72  inline bool hasStructInstance() const
73  { return !m_SetOfInstance.isEmpty();}
74 
76  inline GLC_StructInstance* firstInstanceHandle() const
77  { return *(m_SetOfInstance.begin());}
78 
80  inline QList<GLC_StructInstance*> listOfStructInstances() const
81  { return m_SetOfInstance.toList();}
82 
84  QSet<GLC_StructOccurence*> setOfStructOccurence() const;
85 
87  inline QList<GLC_StructOccurence*> listOfStructOccurence() const
88  {return setOfStructOccurence().toList();}
89 
91  inline bool hasRepresentation() const
92  {return NULL != m_pRepresentation;}
93 
95 
96  GLC_Rep* representationHandle() const;
97 
99  inline QString name() const
100  {return m_Name;}
101 
103  inline unsigned int numberOfFaces() const
104  {
105  Q_ASSERT(NULL != m_pRepresentation);
106  GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
107  if (NULL != pRep) return pRep->faceCount();
108  else return 0;
109  }
110 
112  inline unsigned int numberOfVertex() const
113  {
114  Q_ASSERT(NULL != m_pRepresentation);
115  GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
116  if (NULL != pRep) return pRep->vertexCount();
117  else return 0;
118  }
119 
121  inline unsigned int numberOfMaterials() const
122  {
123  Q_ASSERT(NULL != m_pRepresentation);
124  GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
125  if (NULL != pRep) return pRep->materialCount();
126  else return 0;
127  }
128 
130  inline unsigned int numberOfBody() const
131  {
132  if(NULL != m_pRepresentation)
133  {
134  GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
135  if (NULL != pRep) return pRep->numberOfBody();
136  else return 0;
137  }
138  else return 0;
139  }
140 
142  inline QSet<GLC_Material*> materialSet() const
143  {
144  Q_ASSERT(NULL != m_pRepresentation);
145  GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
146  if (NULL != pRep) return pRep->materialSet();
147  else return QSet<GLC_Material*>();
148  }
149 
151  inline bool containsAttributes() const
152  { return ((NULL != m_pAttributes) && !m_pAttributes->isEmpty());}
153 
155  inline GLC_Attributes* attributesHandle() const
156  {return m_pAttributes;}
157 
159  QString representationName() const;
160 
162  bool representationIsLoaded() const;
163 
165  QString representationFileName() const;
166 
168  bool representationIsEmpty() const;
169 
171 
173 
175 
176 public:
178  inline void structInstanceCreated(GLC_StructInstance* pInstance)
179  {
180  Q_ASSERT(!m_SetOfInstance.contains(pInstance));
181  m_SetOfInstance << pInstance;
182  }
183 
185  inline void structInstanceDeleted(GLC_StructInstance* pInstance)
186  {m_SetOfInstance.remove(pInstance);}
187 
189  inline void setName(const QString& name)
190  {m_Name= name;}
191 
193  void setRepresentation(const GLC_3DRep& rep);
194 
196  inline void setAttributes(const GLC_Attributes& attr)
197  {
198  delete m_pAttributes;
199  m_pAttributes= new GLC_Attributes(attr);
200  }
201 
203  void setRepresentationName(const QString& representationName);
204 
206 
207  bool loadRepresentation();
208 
210 
211  bool unloadRepresentation();
212 
214 
215  QList<GLC_StructOccurence*> addChild(GLC_StructOccurence* pOccurence);
216 
217 
219 
221 // Private members
223 private:
225  QSet<GLC_StructInstance*> m_SetOfInstance;
226 
229 
231  QString m_Name;
232 
235 
236 };
237 
238 #endif /* GLC_STRUCTREFERENCE_H_ */

©2005-2013 Laurent Ribon