Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

GroupRepository.h
00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc.
00002 //
00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
00004 // and considered a trade secret as defined under civil and criminal statutes.
00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
00006 // unauthorized use or misappropriation of its trade secrets.  Use of this information
00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
00009 
00010 #pragma once
00011 
00012 #include "GeometryImporter.h"
00013 #include "VisibilityChecker.h"
00014 
00015 #include <slapi/model/group.h>
00016 #include <slapi/model/entities.h>
00017 
00018 #include <hc.h>
00019 
00020 #include <map>
00021 #include <vector>
00022 #include <cstdint>
00023 
00024 class GroupRepository
00025 {
00026 private:
00027     struct GroupEntry
00028     {
00029         GroupEntry() { }
00030 
00031         GroupEntry(const HC_KEY& segmKey, const SUEntitiesRef& ent)
00032             : segmentKey(segmKey), entities(ent) { }
00033 
00034         HC_KEY        segmentKey;
00035         SUEntitiesRef entities;
00036     };
00037 
00038     typedef std::map<int64_t, GroupEntry> GroupsMap_t;
00039 
00040 public:
00041     class Iterator
00042     {
00043     public:
00044         Iterator();
00045         Iterator(GroupsMap_t::iterator& begin, GroupsMap_t::iterator& end);
00046         Iterator(const Iterator&);
00047         Iterator& operator=(const Iterator&);
00048 
00049         HC_KEY         GetSegmentKey() const;
00050         SUEntitiesRef& GetEntities() const;
00051         void Next();
00052         bool Available() const;
00053 
00054     private:
00055         GroupsMap_t::iterator m_iter;
00056         GroupsMap_t::iterator m_end;
00057     };
00058 
00059 public:
00060     GroupRepository(HC_KEY includeSegmentKey, GeometryImporter& geometryImporter,
00061                     VisibilityChecker& visibilityChecker, ImageRepository& imageRepository,
00062                     TextureWriter& textureWriter, StyleRepository& textureRepository);
00063 
00064     bool     Import(SUEntitiesRef& entities);
00065     Iterator GetIterator();
00066 
00067 private:
00068     GroupRepository(const GroupRepository&);
00069     GroupRepository& operator=(const GroupRepository&);
00070 
00071     int64_t GetId(SUGroupRef& group) const;
00072     HC_KEY  GetGroupKey(SUGroupRef& group) const;
00073     HC_KEY  ImportGroup(SUGroupRef& group);
00074     bool    ImportInstance(SUGroupRef& group, HC_KEY groupKey);
00075     bool    ImportTransform(SUGroupRef& group, std::vector<float>& floatTransform);
00076     void    ApplyGroupColors(SUGroupRef& group);
00077 
00078 private:
00079     HC_KEY m_groupsSegmentKey;
00080     GeometryImporter&   m_geometryImporter;
00081     VisibilityChecker&  m_visibilityChecker;
00082     ImageRepository&    m_imageRepository;
00083     TextureWriter&      m_textureWriter;
00084     StyleRepository&    m_styleRepository;
00085     GroupsMap_t         m_groupsMap;
00086 };