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  Version 2.0.0, packaged on July 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU Lesser General Public License as published by
00011  the Free Software Foundation; either version 3 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU Lesser General Public License for more details.
00018 
00019  You should have received a copy of the GNU Lesser General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 *****************************************************************************/
00024 
00026 
00027 #ifndef GLC_STRUCTREFERENCE_H_
00028 #define GLC_STRUCTREFERENCE_H_
00029 
00030 #include <QString>
00031 #include <QSet>
00032 
00033 #include "../geometry/glc_3drep.h"
00034 #include "glc_3dviewinstance.h"
00035 #include "glc_attributes.h"
00036 #include "glc_structinstance.h"
00037 
00038 #include "../glc_config.h"
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         QList<GLC_StructOccurence*> listOfStructOccurence() const;
00085 
00087         inline bool hasRepresentation() const
00088         {return NULL != m_pRepresentation;}
00089 
00091         inline GLC_Rep* representationHandle() const
00092         {
00093                 return m_pRepresentation;
00094         }
00095 
00097         inline QString name() const
00098         {return m_Name;}
00099 
00101         inline unsigned int numberOfFaces() const
00102         {
00103                 Q_ASSERT(NULL != m_pRepresentation);
00104                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00105                 if (NULL != pRep) return pRep->faceCount();
00106                 else return 0;
00107         }
00108 
00110         inline unsigned int numberOfVertex() const
00111         {
00112                 Q_ASSERT(NULL != m_pRepresentation);
00113                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00114                 if (NULL != pRep) return pRep->vertexCount();
00115                 else return 0;
00116         }
00117 
00119         inline unsigned int numberOfMaterials() const
00120         {
00121                 Q_ASSERT(NULL != m_pRepresentation);
00122                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00123                 if (NULL != pRep) return pRep->materialCount();
00124                 else return 0;
00125         }
00126 
00128         inline unsigned int numberOfBody() const
00129         {
00130                 if(NULL != m_pRepresentation)
00131                 {
00132                         GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00133                         if (NULL != pRep) return pRep->numberOfBody();
00134                         else return 0;
00135                 }
00136                 else return 0;
00137         }
00138 
00140         inline QSet<GLC_Material*> materialSet() const
00141         {
00142                 Q_ASSERT(NULL != m_pRepresentation);
00143                 GLC_3DRep* pRep= dynamic_cast<GLC_3DRep*>(m_pRepresentation);
00144                 if (NULL != pRep) return pRep->materialSet();
00145                 else return QSet<GLC_Material*>();
00146         }
00147 
00149         inline bool containsAttributes() const
00150         { return ((NULL != m_pAttributes) && !m_pAttributes->isEmpty());}
00151 
00153         inline GLC_Attributes* attributesHandle() const
00154         {return m_pAttributes;}
00155 
00157 
00159 
00161 
00162 public:
00164         inline void structInstanceCreated(GLC_StructInstance* pInstance)
00165         {
00166                 Q_ASSERT(!m_SetOfInstance.contains(pInstance));
00167                 m_SetOfInstance << pInstance;
00168         }
00169 
00171         inline void structInstanceDeleted(GLC_StructInstance* pInstance)
00172         {m_SetOfInstance.remove(pInstance);}
00173 
00175         inline void setName(const QString& name)
00176         {m_Name= name;}
00177 
00179 
00180         void setRepresentation(const GLC_3DRep& rep);
00181 
00183         void setAttributes(const GLC_Attributes& attr)
00184         {
00185                 delete m_pAttributes;
00186                 m_pAttributes= new GLC_Attributes(attr);
00187         }
00188 
00190 
00192 // Private members
00194 private:
00196         QSet<GLC_StructInstance*> m_SetOfInstance;
00197 
00199         GLC_Rep* m_pRepresentation;
00200 
00202         QString m_Name;
00203 
00205         GLC_Attributes* m_pAttributes;
00206         
00207 };
00208 
00209 #endif /* GLC_STRUCTREFERENCE_H_ */

SourceForge.net Logo

©2005-2010 Laurent Ribon