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 <slapi/model/model.h> 00013 00014 #include <hc.h> 00015 00016 #include <memory> 00017 #include <functional> 00018 00019 #include "InheritanceManager.h" 00020 00021 class TextureWriter; 00022 class ImageRepository; 00023 class StyleRepository; 00024 class VisibilityChecker; 00025 class GeometryImporter; 00026 class DefinitionRepository; 00027 class GroupRepository; 00028 00029 class ModelImporter 00030 { 00031 public: 00032 static bool LoadModelFromFile(const char* fileName, SUModelRef& model); 00033 00034 public: 00035 ModelImporter(bool ignoreOffEntities, bool importMetadata); 00036 00037 bool Import(HC_KEY sceneSegmentKey, HC_KEY modelSegmentKey, HC_KEY includeSegmentKey, 00038 SUModelRef& model, std::function<void(const std::string&, float)>& progressReporter); 00039 00040 private: 00041 ModelImporter(const ModelImporter&); 00042 ModelImporter& operator=(const ModelImporter&); 00043 00044 void Reset(HC_KEY modelSegmentKey, HC_KEY includeSegmentKey, SUModelRef& model); 00045 bool SetTopLevelAttributes(SUModelRef& model, HC_KEY modelSegmentKey); 00046 bool SetModelOptions(SUModelRef& model, HC_KEY modelKey); 00047 bool SetModelMetadata(SUModelRef& model, HC_KEY modelKey); 00048 bool SetCamera(SUModelRef& model, HC_KEY sceneSegmentKey); 00049 bool ImportDefinitions(SUModelRef& model); 00050 bool ImportGeometryAndInstances(SUModelRef& model, HC_KEY modelSegmentKey); 00051 bool ImportGroups(SUModelRef& model, HC_KEY modelSegmentKey); 00052 bool ImportGroupDefinitions(SUModelRef& model, HC_KEY modelSegmentKey); 00053 bool ImportInstancesContainedInAllGroups(SUModelRef& model); 00054 bool ImportInstancesContainedInDefinition(SUComponentDefinitionRef& definition); 00055 bool ImportAttributeDictionary(SUAttributeDictionaryRef& dictionary, std::stringstream& metadata); 00056 bool GetSKPUnitOptions(SUOptionsProviderRef& optionsProvider, std::stringstream& options); 00057 bool GetSKPNamedOptions(SUOptionsProviderRef& optionsProvider, std::stringstream& options); 00058 bool GetLengthUnit(SUOptionsProviderRef& optionsProvider, std::stringstream& options); 00059 bool GetLengthFormat(SUOptionsProviderRef& optionsProvider, std::stringstream& options); 00060 std::string TypedValueToString(SUTypedValueRef& value); 00061 00062 private: 00063 // Using std::shared_ptr because it allows incomplete types, 00064 // not because these are intended to be shared externally. 00065 std::shared_ptr<TextureWriter> m_textureWriter; 00066 std::shared_ptr<ImageRepository> m_imageRepository; 00067 std::shared_ptr<StyleRepository> m_styleRepository; 00068 std::shared_ptr<VisibilityChecker> m_visibilityChecker; 00069 std::shared_ptr<GeometryImporter> m_geometryImporter; 00070 std::shared_ptr<GroupRepository> m_groupRepository; 00071 std::shared_ptr<DefinitionRepository> m_definitionRepository; 00072 00073 InheritanceManager m_inheritanceManager; 00074 bool m_ignoreOffEntities; 00075 bool m_importMetadata; 00076 };