glc_structreference.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 *****************************************************************************/
00022 
00024 
00025 #ifndef GLC_STRUCTREFERENCE_H_
00026 #define GLC_STRUCTREFERENCE_H_
00027 
00028 #include <QString>
00029 #include <QSet>
00030 
00031 #include "../geometry/glc_3drep.h"
00032 #include "glc_3dviewinstance.h"
00033 #include "glc_attributes.h"
00034 #include "glc_structinstance.h"
00035 
00036 #include "../glc_config.h"
00037 
00038 class GLC_StructOccurence;
00039 
00042 
00043 
00044 class GLC_LIB_EXPORT GLC_StructReference
00045 {
00047 
00049 
00050 public:
00052         GLC_StructReference(const QString& name= QString());
00053 
00055         GLC_StructReference(GLC_Rep*);
00056 
00058         GLC_StructReference(const GLC_StructReference&);
00059 
00061         GLC_StructReference& operator=(const GLC_StructReference&);
00062 
00064         virtual ~GLC_StructReference();
00066 
00067 
00069 
00070 public:
00072         inline bool hasStructInstance() const
00073         { return !m_SetOfInstance.isEmpty();}
00074 
00076         inline GLC_StructInstance* firstInstanceHandle() const
00077         { return *(m_SetOfInstance.begin());}
00078 
00080         inline QList<GLC_StructInstance*> listOfStructInstances() const
00081         { return m_SetOfInstance.toList();}
00082 
00084         QSet<GLC_StructOccurence*> setOfStructOccurence() const;
00085 
00087         inline QList<GLC_StructOccurence*> listOfStructOccurence() const
00088         {return setOfStructOccurence().toList();}
00089 
00091         inline bool hasRepresentation() const
00092         {return NULL != m_pRepresentation;}
00093 
00095 
00096         GLC_Rep* representationHandle() const;
00097 
00099         inline QString name() const
00100         {return m_Name;}
00101 
00103         inline unsigned int numberOfFaces() const
00104         {
00105                 Q_ASSERT(NULL != m_pRepresentation);
00106                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00107                 if (NULL != pRep) return pRep->faceCount();
00108                 else return 0;
00109         }
00110 
00112         inline unsigned int numberOfVertex() const
00113         {
00114                 Q_ASSERT(NULL != m_pRepresentation);
00115                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00116                 if (NULL != pRep) return pRep->vertexCount();
00117                 else return 0;
00118         }
00119 
00121         inline unsigned int numberOfMaterials() const
00122         {
00123                 Q_ASSERT(NULL != m_pRepresentation);
00124                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00125                 if (NULL != pRep) return pRep->materialCount();
00126                 else return 0;
00127         }
00128 
00130         inline unsigned int numberOfBody() const
00131         {
00132                 if(NULL != m_pRepresentation)
00133                 {
00134                         GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00135                         if (NULL != pRep) return pRep->numberOfBody();
00136                         else return 0;
00137                 }
00138                 else return 0;
00139         }
00140 
00142         inline QSet<GLC_Material*> materialSet() const
00143         {
00144                 Q_ASSERT(NULL != m_pRepresentation);
00145                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00146                 if (NULL != pRep) return pRep->materialSet();
00147                 else return QSet<GLC_Material*>();
00148         }
00149 
00151         inline bool containsAttributes() const
00152         { return ((NULL != m_pAttributes) && !m_pAttributes->isEmpty());}
00153 
00155         inline GLC_Attributes* attributesHandle() const
00156         {return m_pAttributes;}
00157 
00159         QString representationName() const;
00160 
00162         bool representationIsLoaded() const;
00163 
00165         QString representationFileName() const;
00166 
00168         bool representationIsEmpty() const;
00169 
00171 
00173 
00175 
00176 public:
00178         inline void structInstanceCreated(GLC_StructInstance* pInstance)
00179         {
00180                 Q_ASSERT(!m_SetOfInstance.contains(pInstance));
00181                 m_SetOfInstance << pInstance;
00182         }
00183 
00185         inline void structInstanceDeleted(GLC_StructInstance* pInstance)
00186         {m_SetOfInstance.remove(pInstance);}
00187 
00189         inline void setName(const QString& name)
00190         {m_Name= name;}
00191 
00193         void setRepresentation(const GLC_3DRep& rep);
00194 
00196         inline void setAttributes(const GLC_Attributes& attr)
00197         {
00198                 delete m_pAttributes;
00199                 m_pAttributes= new GLC_Attributes(attr);
00200         }
00201 
00203         void setRepresentationName(const QString& representationName);
00204 
00206 
00207         bool loadRepresentation();
00208 
00210 
00211         bool unloadRepresentation();
00212 
00214 
00215         bool addChild(GLC_StructOccurence* pOccurence);
00216 
00217 
00219 
00221 // Private members
00223 private:
00225         QSet<GLC_StructInstance*> m_SetOfInstance;
00226 
00228         GLC_Rep* m_pRepresentation;
00229 
00231         QString m_Name;
00232 
00234         GLC_Attributes* m_pAttributes;
00235         
00236 };
00237 
00238 #endif /* GLC_STRUCTREFERENCE_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon