Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HSKPHelper.h
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: a2395e9ab627c3544ab6b2425250c5ca12bf5571 $
13 //
14 
15 #ifndef _HSKPHELPER_H
16 #define _HSKPHELPER_H
17 
18 #ifndef CLASS_HSKPImporter_DEF
19 #define CLASS_HSKPImporter_DEF
20 #include <atlbase.h>
21 #include <atlcom.h>
22 #include <comdef.h>
23 using namespace ATL;
24 #include "SketchUp_i.h"
25 #include "SketchUpAddin.h"
26 #endif
27 
28 #ifdef H_PACK_8
29 #pragma pack(push)
30 #pragma pack(8)
31 #endif
32 
33 // HOOPS/MVO includes
34 #include "HDB.h"
35 #include "HIOManager.h"
36 
37 #include <iostream>
38 #include <map>
39 using namespace std;
40 
41 #include "InheritanceManager.h"
42 #include "HResult.h"
43 
44 // Mesh can be created with optional UV front/back coordinates,
45 // and optional normal vectors. UV coordinates are
46 // currently Point3d's with X=U, Y=V, Z=Q. Q will always be 1
47 // for affine texture transforms.
48 #define PolygonMeshPoints 0
49 #define PolygonMeshUVQFront 1
50 #define PolygonMeshUVQBack 2
51 #define PolygonMeshNormals 4
52 
53 #include <map> // switch to unordered_map when no longer using vs2008
54 
55 template<typename K, typename V>
56 class SKPMap
57 {
58 public:
59  typedef typename std::map<K,V>::iterator Iter;
60 
61  SKPMap() {}
62 
63  void Add(K key, V value)
64  {
65  _data[key] = value;
66  }
67 
68  void Add(K key, V value, Iter it)
69  {
70  _data.insert(it, std::pair<K, V>(key, value));
71  }
72 
73  V Get(K key)
74  {
75  return _data[key];
76  }
77 
78  bool Contains(K key)
79  {
80  return _data.find(key) != _data.end();
81  }
82 
83  bool Contains(K key, Iter &it)
84  {
85  it = _data.find(key);
86  return it != _data.end();
87  }
88 
89 private:
90  std::map<K,V> _data;
91 };
92 
95 
97 {
98 public:
99  HSKPImporter(CComPtr<ISkpTextureWriter2> textureWriter);
100  ~HSKPImporter();
101 
102  void setTotalEntities(CComPtr<ISkpDocument> pDoc);
103  void setInputHandler(HInputHandler* val){m_pInputhandler = val;};
104 
105  HInputHandler* getInputHandler()
106  {
107  return m_pInputhandler;
108  };
109  void set_IgnoreEntities(bool val){ m_bIgnoreEntities = val;};
110 
111  CComPtr<ISkpDocument> getSKPDatabase(const char *, CComPtr<ISkpApplication> pApp);
112  void importSKPPages(CComPtr<ISkpDocument> pDoc,HInputHandlerOptions * options);
113  void importSKPText(CComPtr<ISkpEntityProvider> );
114  void setDefaultOptions(CComPtr<ISkpDocument> pDoc);
115  void conditionStringForSegName(char* zString);
116  void setTextureDirectory();
117  void transformPointsFromRotationTranslate(double *angle,HPoint* axis, HPoint* points,HPoint* origin);
118  double round(double x);
119  void fitToScene(HInputHandlerOptions * options);
120  BOOL deleteDirectory(const TCHAR* sPath);
121  BOOL isDots(const TCHAR* str);
122  void set_importMetadata(bool mdata)
123  {
124  m_bImportMetadata = mdata;
125  }
126 
127 
128 
129  void ImportGeometry(CComPtr<ISkpEntityProvider> entityProvider, int depth);
130 
131 private:
132  void ImportComponents(CComPtr<ISkpEntityProvider> entityProvider, int depth);
133  void ImportGroups(CComPtr<ISkpEntityProvider> entityProvider, int depth);
134  void ImportImages(CComPtr<ISkpEntityProvider> entityProvider, int depth);
135  void ImportFaces(CComPtr<ISkpEntityProvider> entityProvider, int depth);
136  void ImportEdges(CComPtr<ISkpEntityProvider> entityProvider, int depth);
137 
138  void ImportRpReportsAttributes(CComPtr<ISkpAttributeProvider> attributeProvider);
139  void ImportMaterial(CComPtr<ISkpMaterial> material, long textureHandle, const char *localTextureName);
140  void ImportTransform(CComPtr<ISkpTransform> transform);
141  void ImportFace(CComPtr<ISkpFace> face, int depth, NameKeyMap & foundMaterials);
142 
143  // Returns ISkpEntity id. item must implement ISkpEntity
144  static long GetEntityId(IUnknown *item);
145 
146  void ReadOptionsProvider(CComPtr<ISkpNamedValues> pNVs);
147 
148  bool loadImage(long handle, BSTR in_name, char * out_name, CComPtr<ISkpFace> face = 0);
149  bool loadTexture(CComPtr<ISkpMaterial> material, long texHandle, char * out_texName, CComPtr<ISkpFace> face);
150  bool getMaterialTextureColor(CComPtr<ISkpMaterial> material, long textureHandle, char *out_color, CComPtr<ISkpFace> face = 0);
151  bool getMaterialRGBColor(CComPtr<ISkpMaterial> material, char *out_color);
152  bool getMaterialTransmissionColor(CComPtr<ISkpMaterial> material, char *out_color, bool *out_isTranslucent);
153  bool getMaterialColor(CComPtr<ISkpMaterial> material, long textureHandle, char *out_color, bool *out_isTranslucent);
154  bool getOneFaceColor(CComPtr<ISkpFace> face, CComPtr<ISkpMaterial> material, BOOL front, char *out_color, bool *out_isTranslucent);
155  bool getFaceColor(CComPtr<ISkpFace> face, char *out_color);
156 
157 private:
158  HInputHandler * m_pReader;
159  HInputHandler * m_pInputhandler;
160 
161  CComPtr<ISkpTextureWriter2> m_pTextureWriter;
162 
163  char m_cTextureDirectory[MVO_BUFFER_SIZE];
164  bool m_bIsColorByLayer;
165  bool m_bIgnoreEntities;
166  bool m_bImportMetadata;
167  bool m_bSkpFitworld;
168  long m_totalEntities;
169 
170  std::multimap<long, std::pair<long, string> > m_textures;
171 
172  CInheritanceManager m_inheritanceManager;
173  LongKeyMap m_importedCompDefs;
174 };
175 
176 
177 #ifdef H_PACK_8
178 #pragma pack(pop)
179 #endif
180 
181 #endif
182 //#endif
183 
184 
185 
HInputHandler an abstract base class for model and image input.
Definition: HIOManager.h:667
Definition: HSKPHelper.h:56
Definition: InheritanceManager.h:12
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
Definition: HIOManager.h:247
A header file containing the HIO classes for passing to HBaseView::FileInput and HBaseView::FileOutpu...
Definition: HSKPHelper.h:96