Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HDWGHelper.h
1 // (C) Copyright 1996,1998 by Autodesk, Inc.
2 //
3 // Permission to use, copy, modify, and distribute this software in
4 // object code form for any purpose and without fee is hereby granted,
5 // provided that the above copyright notice appears in all copies and
6 // that both that copyright notice and the limited warranty and
7 // restricted rights notice below appear in all supporting
8 // documentation.
9 //
10 // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11 // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
12 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
13 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
14 // UNINTERRUPTED OR ERROR FREE.
15 //
16 // Use, duplication, or disclosure by the U.S. Government is subject to
17 // restrictions set forth in FAR 52.227-19 (Commercial Computer
18 // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
19 // (Rights in Technical Data and Computer Software), as applicable.
20 //
21 // $Id: fd5f25f3ae8bc2199c7bd3531ea98c4d7451b3ef $
22 //
23 
24 #ifndef HDWG_HELPER_H_
25 #define HDWG_HELPER_H_ 1
26 
27 #ifdef H_PACK_8
28 #pragma pack(push)
29 #pragma pack(8)
30 #endif
31 
32 
33 //#include <wchar.h>
34 #include <map>
35 #include <vector>
36 #include <string>
37 
38 #include "acgi.h"
39 #include "hc.h"
40 #include "HIOManager.h"
41 #include "HTools.h"
42 #include "HUtility.h"
43 
44 #include "BStream.h"
45 #include "BOpcodeShell.h"
46 
47 #include "sorttab.h "
48 
49 #include "windows.h"
50 #include "stdlib.h"
51 #include "stdio.h"
52 #include "string.h"
53 #include "time.h"
54 
55 #include "dbimage.h"
56 #include "imgdef.h"
57 #include "imgent.h"
58 
59 #include "dbobjptr.h"
60 #include "acdblmgr.h"
61 #include "dbmleader.h" // For AcDbMLeader
62 #include "dbspfilt.h" // For Clips on blockref
63 #include "dbole.h"
64 #include "dbtrans.h" // For Transaction objects
65 
66 
67 
68 #define _t(str) L##str
69 typedef unsigned int UINT;
70 
71 
72 
74 class HIOConnectorDWG;
75 class HIOUtilityDWG;
76 
77 class AcDbMText;
78 struct AcDbMTextFragment;
79 class AcDbCircle;
80 class AcDbLeader;
81 class AcDbMLeader;
82 class AcDbDimension;
83 class AcDbMaterial;
84 class AcDbPoint;
85 class AcDbMInsertBlock;
86 class AcDbLine;
87 class AcDbXline;
88 class AcDbRay;
89 class AcDbPolygonMesh;
90 
91 #ifdef WIN32
92 class AcDbTable;
93 #endif
94 
95 typedef int BOOL;
96 
97 // Functions to condition strings form database to be used as segment name.
98 void condition_string_for_segment_name(char* zString);
99 void condition_string_for_segment_name(wchar_t* zString);
100 void condition_string_for_user_options(char* zString);
101 void condition_string_for_user_options(wchar_t* zString);
102 void condition_string_for_special_characters(wchar_t* zString);
103 
104 // To get the rectangle from bounding box
105 void Get_Image_Rectangle_For_Shell(AcDbRasterImage* pEnt, HPoint * Rect);
106 // AcDbRatsterImage import Functions
107 void InsertClipRegion(AcDbRasterImage* pEnt, BStreamFileToolkit * pBStreamtk = 0);
108 int GetImageFileName(AcDbRasterImageDef* ImageDef, char * pFilePath, char * pImageName) ;
109 // Camera settings in viewports
110 int GetCameraForInitialView(HCamera &camera , AcDbViewportTableRecord* pRecord);
112 void SetRenderMode(HInputHandlerOptions * pInputOptions, AcDbViewportTableRecord* pRecord);
113 // text transformation matrix
114 void GetModelingMatrixForText(float my_center[], float my_path1[], float my_norm1[], float h_matrix_trans[]);
115 // For Stream Writing
116 TK_Status WriteObject(BBaseOpcodeHandler * handler, BStreamFileToolkit * tk, FILE * fp, char * buffer, int size);
117 // For Getting Layout views and clip regions
118 void get_layout_data(AcDbObjectId viewPortId,AcDbDatabase *pAcDbDatabase,HPoint *ClipPoint,float *matrix,int *no_ClipPoint,AcCmEntityColor* entityColor, bool * is_On);
119 // Convert to lower case
120 void ConverToLower(char * to_lower);
121 // Check for file existance
122 bool hio_dwg_check_file_exist(const wchar_t * full_filepath);
123 // For Clips on BlockRefs
124 BOOL insertClip(AcDbBlockReference * ref, BStreamFileToolkit * pBStreamtk = 0);
125 // Checking for invalid entities (having large and invalid values)
126 bool CheckForInvalidExtents(AcDbEntity * pEnt);
127 
128 inline void extract_matrix(AcGeMatrix3d const & in_mat, float out_mat[16])
129 {
130  AcGeMatrix3d trans_matrix(in_mat);
131  trans_matrix.transposeIt();
132  for (int i = 0; i < 4; i++)
133  {
134  for (int j = 0; j < 4; j++)
135  {
136  out_mat[4 * i + j] = (float)trans_matrix(i, j);
137  }
138  }
139 }
140 
141 
142 // define HIODWG_IMPORT_POINTS if you want to import the 0 dimensional entities viz. AcDbPoint etc.
143 //#define HIODWG_IMPORT_POINTS
144 
145 #define HDWG_PI ((double)3.14159265358979323846)
146 #define HDWG_F_PI ((float)HDWG_PI)
147 #define H_MM_TO_POINTS 2.83465f
148 #define H_LWDEFAULT AcDb::kLnWt025;
149 #define HDWG_MATERIALS_LIBRARY_SEGMENT "DWG_MATERIALS_STYLE_LIBRARY"
150 #define HIODWG_SCRATCH_SEGMENT "/include library/dwg_scratch_segment"
151 
152 #define GetBValueFromRGBM(rgbm) ((unsigned char)(rgbm))
153 #define GetGValueFromRGBM(rgbm) ((unsigned char)((unsigned long)(rgbm)>>8))
154 #define GetRValueFromRGBM(rgbm) ((unsigned char)((unsigned long)(rgbm)>>16))
155 #define GetMValueFromRGBM(rgbm) ((unsigned char)((unsigned long)(rgbm)>>24))
156 
157 #define countof(array) sizeof(array)/sizeof(array[0])
158 #define nEntNames countof(EntityList)
159 
160 
161 #define MARKER_OPCODE_START_FILL -1
162 #define MARKER_OPCODE_RESTART_FILL -2
163 #define MARKER_OPCODE_END_FILL -3
164 #define MARKER_OPCODE_ELLIPSE -4
165 #define MARKER_OPCODE_CIRCULAR_ARC -5
166 #define MARKER_OPCODE_INFINITE_LINE -6
167 #define MARKER_OPCODE_INFINITE_RAY -7
168 #define MARKER_OPCODE_START_CONTRAST_COLOR -8
169 #define MARKER_OPCODE_START_NORMAL_COLOR -9
170 #define MARKER_OPCODE_START_RGB_COLOR -10
171 #define MARKER_OPCODE_START_INDEXED_COLOR -11
172 #define MARKER_OPCODE_TERMINATE 0
173 #define MARKER_OPCODE_POINT 1
174 #define MARKER_OPCODE_LINE_2 2
175 #define MARKER_OPCODE_LINE_3 3
176 #define MARKER_OPCODE_LINE_4 4
177 #define MARKER_OPCODE_LINE_5 5
178 #define MARKER_OPCODE_LINE_6 6
179 #define MARKER_OPCODE_LINE_7 7
180 #define MARKER_OPCODE_LINE_8 8
181 #define MARKER_OPCODE_LINE_9 9
182 #define MARKER_OPCODE_LINE_10 10
183 #define MARKER_OPCODE_LINE_11 11
184 #define MARKER_OPCODE_LINE_12 12
185 #define MARKER_OPCODE_LINE_13 13
186 
187 
188 const char PDMODE_4[] = // a half sized vertical bar (upper half)
189  {
190  100, 0, 0,
191  MARKER_OPCODE_LINE_2, 0, 0,
192  0, 100,
193  MARKER_OPCODE_TERMINATE
194  };
195 
196 const char PDMODE_34[] = // a circle with + sign. + spills outside the circle
197  {
198  100, 0, 0,
199  MARKER_OPCODE_LINE_2, -100, 0,
200  100, 0,
201  MARKER_OPCODE_LINE_2, 0, -100,
202  0, 100,
203  MARKER_OPCODE_ELLIPSE, -60, -60, 60, 60,
204 
205  MARKER_OPCODE_TERMINATE
206  };
207 
208 const char PDMODE_35[] = // a circle with x sign. x spills outside the circle
209  {
210  100, 0, 0,
211  MARKER_OPCODE_LINE_2, -100, -100,
212  100, 100,
213  MARKER_OPCODE_LINE_2, -100, 100,
214  100, -100,
215  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
216 
217  MARKER_OPCODE_TERMINATE
218  };
219 
220 const char PDMODE_36[] = // a circle over a half-vertical-bar
221  {
222  100, 0, 0,
223  MARKER_OPCODE_LINE_2, 0, 0,
224  0, 100,
225  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
226 
227  MARKER_OPCODE_TERMINATE
228  };
229 
230 const char PDMODE_66[] = // a square over + sign (+ spilling out a bit)
231  {
232  100, 0, 0,
233  MARKER_OPCODE_LINE_2, -100, 0,
234  100, 0,
235  MARKER_OPCODE_LINE_2, 0, -100,
236  0, 100,
237  MARKER_OPCODE_LINE_5, -60, -60, -60, 60,
238  60, 60, 60, -60, -60, -60,
239  MARKER_OPCODE_TERMINATE
240  };
241 
242 const char PDMODE_68[] = // a square over half-vertical-bar
243  {
244  100, 0, 0,
245  MARKER_OPCODE_LINE_2, 0, 0,
246  0, 100,
247  MARKER_OPCODE_LINE_5, -100, -100, -100, 100,
248  100, 100, 100, -100,-100, -100,
249  MARKER_OPCODE_TERMINATE
250  };
251 
252 const char PDMODE_96[] = // a square and a circle over a dot
253  {
254  100, 0, 0,
255  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
256  MARKER_OPCODE_LINE_5, -100, -100, -100, 100,
257  100, 100, 100, -100,-100, -100,
258  MARKER_OPCODE_POINT, 0, 0,
259  MARKER_OPCODE_TERMINATE
260  };
261 
262 const char PDMODE_97[] = // a square and a circle
263  {
264  100, 0, 0,
265  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
266  MARKER_OPCODE_LINE_5, -100, -100, -100, 100,
267  100, 100, 100, -100,-100, -100,
268  MARKER_OPCODE_TERMINATE
269  };
270 
271 const char PDMODE_98[] = // a square and a circle over + (spillage of +)
272  {
273  100, 0, 0,
274  MARKER_OPCODE_LINE_2, -100, 0,
275  100, 0,
276  MARKER_OPCODE_LINE_2, 0, -100,
277  0, 100,
278  MARKER_OPCODE_LINE_5, -60, -60, -60, 60,
279  60, 60, 60, -60, -60, -60,
280  MARKER_OPCODE_ELLIPSE, -60, -60, 60, 60,
281  MARKER_OPCODE_TERMINATE
282  };
283 
284 const char PDMODE_99[] = // a square and a circle over a cross
285  {
286  100, 0, 0,
287  MARKER_OPCODE_LINE_2, -100, -100,
288  100, 100,
289  MARKER_OPCODE_LINE_2, -100, 100,
290  100, -100,
291  MARKER_OPCODE_LINE_5, -100, -100, -100, 100,
292  100, 100, 100, -100, -100, -100,
293  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
294  MARKER_OPCODE_TERMINATE
295  };
296 
297 const char PDMODE_100[] = // a square and a circle over a half-vertical-bar
298  {
299  100, 0, 0,
300  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
301  MARKER_OPCODE_LINE_2, 0, 0,
302  0, 100,
303  MARKER_OPCODE_LINE_5, -100, -100, -100, 100,
304  100, 100, 100, -100, -100, -100,
305  MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100,
306  MARKER_OPCODE_TERMINATE
307  };
308 
309 
311 {
312  Adesk::Int16 iSymbolPDMODE; // PDMODE value (Ref. to AutoCAD command reference
313  char *pSymbolName; // Corresponding HOOPS marker symbol name or glyph name
314  const char *pSymbolDefinition; // Glyph definition array. 0 for standard HOOPS markers
315  unsigned int nSybolDefinitionSize; // Size of Glyph definition array. 0 for standard HOOPS markers
316  int opcode_index; // Corresponding opcode enum.
317 };
318 
319 static HIODWG_GLYPH GlyphTable[] =
320 {
321  0, ".", 0, 0, TKO_Marker_Dot,
322  2, "+", 0, 0, TKO_Marker_Plus,
323  3, "x", 0, 0, TKO_Marker_X,
324  4, "PDMODE_4", PDMODE_4, countof(PDMODE_4), -1,
325 
326  32, "(.)", 0, 0, TKO_Marker_Circle_Dot,
327  33, "O", 0, 0, TKO_Marker_Circle ,
328  34, "PDMODE_34", PDMODE_34, countof(PDMODE_34), -1,
329  35, "PDMODE_35", PDMODE_35, countof(PDMODE_35), -1,
330  36, "PDMODE_36", PDMODE_36, countof(PDMODE_36), -1,
331 
332  64, "[.]", 0, 0, TKO_Marker_Box_Dot,
333  65, "[]", 0, 0, TKO_Marker_Box,
334  66, "PDMODE_66", PDMODE_66, countof(PDMODE_66), -1,
335  67, "[x]", 0, 0, TKO_Marker_Box_X ,
336  68, "PDMODE_68", PDMODE_68, countof(PDMODE_68), -1,
337 
338  96, "PDMODE_96", PDMODE_96, countof(PDMODE_96), -1,
339  97, "PDMODE_97", PDMODE_97, countof(PDMODE_97), -1,
340  98, "PDMODE_98", PDMODE_98, countof(PDMODE_98), -1,
341  99, "PDMODE_99", PDMODE_99, countof(PDMODE_99), -1,
342  100, "PDMODE_100", PDMODE_100, countof(PDMODE_100),-1
343 };
344 
345 
346 
347 struct ENTNAMES
348 {
349  const wchar_t *pName;
350  void (* func)(AcDbEntity *);
351 };
352 
353 static ENTNAMES EntityList[] =
354 {
355  // import explicitly
356  L"AcDbBlockReference", 0, //0
357  L"AcDbMInsertBlock", 0, //1
358 
359  // import both shaded & wireframe modes
360  L"AcDbBlockTableRecord", 0, //2
361  L"AcDb3dSolid", 0, //3
362  L"AcDbBody", 0, //4
363  L"AcDbFace", 0, //5
364  L"AcDbRegion", 0, //6
365  L"AcDbShape", 0, //7
366  L"AcDbSolid", 0, //8
367  L"AcDbFace", 0, //9
368  L"AcDbPolyFaceMesh", 0, //10
369  L"AcDbPolygonMesh", 0, //11
370  L"AcDbExtrudedSurface", 0, //12
371 
372  // import wireframe mode only
373  L"AcDbHatch", 0, //13
374  L"AcDbMText", 0, //14
375  L"AcDbText", 0, //15
376  L"AcDbCurve", 0, //16
377  L"AcDb2dPolyline", 0, //17
378  L"AcDb3dPolyline", 0, //18
379  L"AcDbArc", 0, //19
380  L"AcDbCircle", 0, //20
381  L"AcDbEllipse", 0, //21
382  L"AcDbLeader", 0, //22
383  L"AcDbLine", 0, //23
384  L"AcDbPolyline", 0, //24
385  L"AcDbRay", 0, //25
386  L"AcDbSpline", 0, //26
387  L"AcDbXline", 0, //27
388  L"AcDbVertex", 0, //28
389  L"AcDb2dVertex", 0, //29
390  L"AcDb3dPolylineVertex", 0, //30
391  L"AcDbMline", 0, //31
392  L"AcDbPoint", 0, //32
393  L"AcDbPolyFaceMeshVertex", 0, //33
394  L"AcDbPolygonMeshVertex", 0, //34
395  L"AcDbBlockBegin", 0, //35
396  L"AcDbBlockEnd", 0, //36
397  L"AcDbFcf", 0, //37
398  L"AcDbFrame", 0, //38
399  L"AcDbOleFrame", 0, //39
400  L"AcDbOle2Frame", 0, //40
401  L"AcDbRasterImage", 0, //41
402  L"AcDbZombieEntity", 0, //42
403  L"AcDbSequenceEnd", 0, //43
404  L"AcDbAttribute", 0, //44
405  L"AcDbTrace", 0, //45
406  L"AcDbFaceRecord", 0, //46
407  L"AcDbViewport", 0, //47
408  L"AcDb2LineAngularDimension", 0, //48
409  L"AcDb3PointAngularDimension", 0, //49
410  L"AcDbAlignedDimension", 0, //50
411  L"AcDbDiametricDimension", 0, //51
412  L"AcDbOrdinateDimension", 0, //52
413  L"AcDbRadialDimension", 0, //53
414  L"AcDbRotatedDimension", 0, //54
415  L"AcDbArcDimension", 0, //55
416  L"AcDbDimension", 0, //56
417  L"AcDbTable", 0, //57
418  L"AcDbWipeout", 0, //58
419 
420  // DON'T import: things which I don't think make sense for importing to HOOPS
421  // for example attribute definitions - they do have some visual representation
422  // which we don't want to draw
423  L"AcDbAttributeDefinition", 0, //59
424  L"AecDbSlab", 0, //60
425 
426 };
427 
428 
429 // Base class DWG Importer. Implements common activities viz. ACAD database traversal etc.
431 {
432 public:
433  HDWGImporter(HIOUtilityDWG* pDWGInputHandler);
434  virtual ~HDWGImporter();
435 
436  // must have functions for any DWG Importers - Import DWG File or AcDbDatabase
437  virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0) = 0;
438  virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0) = 0;
439 
440  virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText) = 0;
441 
442  virtual Adesk::Boolean import_circle( const AcGePoint3d& pt1,
443  const AcGePoint3d& pt2,
444  const AcGePoint3d& pt3,
445  AcDbEntity* pDatabaseEntity) const = 0;
446 
447  Adesk::Boolean import_circle( const AcGePoint3d& center,
448  const double radius,
449  const AcGeVector3d& normal,
450  AcDbEntity* pDatabaseEntity
451  ) const;
452 
453  virtual Adesk::Boolean import_circular_arc( const AcGePoint3d& center,
454  const double radius,
455  const AcGeVector3d& normal,
456  const AcGeVector3d& startVector,
457  const double sweepAngle,
458  const AcGiArcType arcType,
459  AcDbEntity* pDatabaseEntity
460  ) const = 0;
461 
462  virtual Adesk::Boolean import_circular_arc( const AcGePoint3d& start,
463  const AcGePoint3d& point,
464  const AcGePoint3d& end,
465  const AcGiArcType arcType,
466  AcDbEntity* pDatabaseEntity
467  ) const = 0;
468 
469  virtual Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints,
470  const AcGePoint3d* pVertexList,
471  AcDbEntity* pDatabaseEntity
472  ) const = 0;
473 
474  virtual Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints,
475  const AcGePoint3d* pVertexList,
476  const AcGeVector3d* pNormal,
477  Adesk::LongPtr lBaseSubEntMarker,
478  AcDbEntity* pDatabaseEntity) const = 0;
479 
480  virtual Adesk::Boolean import_pline(const AcDbPolyline& lwBuf,
481  Adesk::UInt32 fromIndex,
482  Adesk::UInt32 numSegs,
483  AcDbEntity* pDatabaseEntity) const = 0;
484 
485  Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints,
486  const AcGePoint3d* pVertexList,
487  const AcGeVector3d* pNormal,
488  const Adesk::LongPtr * pSubEntMarkers,
489  AcDbEntity* pDatabaseEntity) const
490  { /*TODO: Implement this function*/ return Adesk::kFalse;};
491 
492  virtual Adesk::Boolean import_mesh( const Adesk::UInt32 rows,
493  const Adesk::UInt32 columns,
494  const AcGePoint3d* pVertexList,
495  const AcGiEdgeData* pEdgeData,
496  const AcGiFaceData* pFaceData,
497  const AcGiVertexData* pVertexData,
498  const bool bAutoGenerateNormals,
499  AcDbEntity* pDatabaseEntity
500  ) const = 0;
501 
502  virtual Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex,
503  const AcGePoint3d* pVertexList,
504  const Adesk::UInt32 faceListSize,
505  const Adesk::Int32* pFaceList,
506  const AcGiEdgeData* pEdgeData,
507  const AcGiFaceData* pFaceData ,
508  const AcGiVertexData* pVertexData,
509  const struct resbuf* pResBuf,
510  const bool bAutoGenerateNormals,
511  AcDbEntity* pDatabaseEntity
512  ) const = 0;
513 
514  virtual Adesk::Boolean import_text( const AcGePoint3d& position,
515  const AcGeVector3d& normal,
516  const AcGeVector3d& direction,
517  const double height,
518  const double width,
519  const double oblique,
520  const ACHAR* pMsg,
521  AcDbEntity* pDatabaseEntity
522  ) const = 0;
523 
524  virtual Adesk::Boolean import_text( const AcGePoint3d& position,
525  const AcGeVector3d& normal,
526  const AcGeVector3d& direction,
527  const ACHAR* pMsg,
528  const Adesk::LongPtr length,
529  const Adesk::Boolean raw,
530  const AcGiTextStyle &pTextStyle,
531  AcDbEntity* pDatabaseEntity
532  ) const=0 ;
533 
534  virtual void pushModelTransform(AcGeMatrix3d const & xMat) = 0;
535  virtual void popModelTransform() = 0;
536 
537 
538  double get_deviation() const { return m_Deviation; }
539 
540  void set_deviation( double dev ) { m_Deviation = dev; }
541 
542  int get_num_isolines() const { return m_numIsolines; }
543 
544  void setIs2dEntity(bool val) { m_bIs2DEntity = val;}
545 
546  HInputHandlerOptions const * GetInputOptions() const { return m_pInputOptions; }
547 
548 protected:
549 
550  void importAcDbPoint(AcDbPoint *pAcDbPoint);
551  void importAcDbMText(AcDbMText* pAcDbMText);
552  void importAcDbCircle(AcDbCircle* pAcDbCircle);
553  void importAcDbMaterial(AcDbMaterial *pAcDbMaterial);
554 
555  bool shouldOverrideMaterial(AcDbMaterial * pAcDbMaterial);
556  bool hasValidRGBValues(AcCmEntityColor const * in_color, float & out_red, float & out_green, float & out_blue) const;
557 
558  virtual void importXdata(AcDbEntity *pEnt)=0;
559  virtual void importXdata(resbuf *pBuf) = 0;
560  void import_hyperlinks(AcDbEntity *pEnt);
561  virtual void attachDWGHandle(AcDbEntity *pEnt)=0;
562 
563  virtual bool get_entity_rgb(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, float& red, float& green, float& blue, bool& is_by_block, bool for_blk_ref=false);
564  virtual void get_entity_transparency(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, int &alpha_value, bool& is_by_block );
565  virtual void get_entity_visibility(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, bool& is_visible );
566  virtual void get_entity_line_weight(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, float& ret_line_weight, bool& is_by_block);
567 
568  HIOUtilityDWG* m_pDWGInputHandler;
569  HIOConnectorDWG* m_pConnectivityInfo;
570  HC_KEY m_modelKey;
571  wchar_t* m_pDWGTextureDirectory;
572  bool m_bDrawWireframe;
573  bool m_bIs3D;
574  double m_Deviation;
575  bool m_bImportXData;
576  bool m_bImportWireframeForBrep;
577  int m_numIsolines;
578  struct vlist_s* m_listRegAppNames;
579  struct vlist_s* m_listEntityType;
580  bool m_bAttachDWGHandles;
581  bool m_bAmIsolidHatch;
582 
583  HInputHandlerOptions * m_pInputOptions;
584 
585  float m_wmin[3];
586  float m_wmax[3];
587  int m_nLine_count;
588  int m_nPoint_count;
589  int m_nCircle_count;
590  int m_nArc_count;
591  int m_nSolid_count;
592  int m_nSolid3D_count;
593  int m_nGroup_count;
594  int m_nPloyLine_count;
595  int m_nShell_count;
596  int m_nText_count;
597  int m_nPloygon_count;
598 
599  wchar_t const * m_fileName;
600  std::map<int, wchar_t*> layer_record;
601  std::map<int, wchar_t*> group_record;
602  std::map<int, wchar_t*> entity_record;
603  std::map<int, wchar_t*> block_ref_record;
604  std::vector<AcDbObjectId> m_VpIdCount;
605  int m_BlockRefIndex;
606  struct vlist_s* m_listDWGLayouts;
607  bool m_bImportAllLayouts;
608  bool m_bCleanVpList;
609  bool m_bIgnoreOffEntity;
610  double m_dGlobalScaleFactor;
611  bool m_bIs2DEntity;
612  bool m_bIsSHXFont;
613  bool m_bDWGInsertMeshesAsShells;
614  bool m_bDisableDWGDrawOrder;
615 
617  {
619  {
620  r = -1;
621  g = -1;
622  b = -1;
623  isVisible = false;
624  }
625  dimensionAttributes(float red, float green, float blue, bool visibility)
626  {
627  r = red;
628  g = green;
629  b = blue;
630  isVisible = visibility;
631  }
632  float r, g, b;
633  bool isVisible;
634  };
635 
636  mutable std::map<std::wstring, std::string> m_fontmap;
637  void populate_fontmap() const;
638 
639  /* dimensionData and m_dimensions are used to regenerate missing dimensions at runtime */
641  {
642  dimensionData(HC_KEY dKey, HC_KEY sKey, AcDbHandle h, AcDbBlockTableRecord * btr)
643  {
644  destinationKey = dKey;
645  sourceKey = sKey;
646  dimensionHandle = h;
647  dimensionBTR = btr;
648  dAtt;
649  }
650 
651  dimensionAttributes dAtt;
652  HC_KEY destinationKey; // key to the segment where the dimension will be inserted
653  HC_KEY sourceKey; // key to the segment containing the recomputed dimension BTR
654  AcDbHandle dimensionHandle; // handle of the dimension object
655  AcDbBlockTableRecord * dimensionBTR; // recomputed dimension BTR
656  };
657  std::vector<dimensionData> m_dimensions;
658  virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector) = 0;
659 };
660 
661 // DWG import implementation for HIOUtilityDWG interface
663 {
664 public:
665  HDWG_3dgsImporter(HIOUtilityDWG* pDWGInputHandler) : HDWGImporter(pDWGInputHandler)
666  {
667  m_CurrentLayoutName = 0;
668  };
669  ~HDWG_3dgsImporter(){;};
670 
671  virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector);
672 
673  virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0);
674  virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0);
675 
676  virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText);
677  virtual void importAcDbDimension(AcDbDimension* pAcDbDimension);
678 
679  Adesk::Boolean import_circle( const AcGePoint3d& pt1,
680  const AcGePoint3d& pt2,
681  const AcGePoint3d& pt3,
682  AcDbEntity* pDatabaseEntity) const;
683 
684  Adesk::Boolean import_circle( const AcGePoint3d& center,
685  const double radius,
686  const AcGeVector3d& normal,
687  AcDbEntity* pDatabaseEntity
688  ) const;
689 
690  Adesk::Boolean import_circular_arc( const AcGePoint3d& center,
691  const double radius,
692  const AcGeVector3d& normal,
693  const AcGeVector3d& startVector,
694  const double sweepAngle,
695  const AcGiArcType arcType,
696  AcDbEntity* pDatabaseEntity
697  ) const;
698 
699  Adesk::Boolean import_circular_arc( const AcGePoint3d& start,
700  const AcGePoint3d& point,
701  const AcGePoint3d& end,
702  const AcGiArcType arcType,
703  AcDbEntity* pDatabaseEntity
704  ) const;
705 
706  Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints,
707  const AcGePoint3d* pVertexList,
708  AcDbEntity* pDatabaseEntity
709  ) const;
710  HC_KEY HDWG_3dgsImporter::extrude_pline(AcGePoint3dArray dwgPoints, AcGeVector3d normal, double line_thickness) const;
711  Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints,
712  const AcGePoint3d* pVertexList,
713  const AcGeVector3d* pNormal,
714  Adesk::LongPtr lBaseSubEntMarker,
715  AcDbEntity* pDatabaseEntity) const;
716 
717  void import_extruded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const;
718  void import_exploded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const;
719  void import_fancy_pline(const AcDbPolyline& lwBuf, AcDbEntity* pDatabaseEntity) const;
720 
721  Adesk::Boolean import_pline(const AcDbPolyline& lwBuf,
722  Adesk::UInt32 fromIndex,
723  Adesk::UInt32 numSegs,
724  AcDbEntity* pDatabaseEntity) const;
725  HC_KEY extrude_elliptical_arc (
726  const double *ofst,
727  const double thickness,
728  const double *p0,
729  const double *p1,
730  const double *p2,
731  double start,
732  double end) const;
733 
734  Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints,
735  const AcGePoint3d* pVertexList,
736  const AcGeVector3d* pNormal,
737  const Adesk::LongPtr * pSubEntMarkers,
738  AcDbEntity* pDatabaseEntity) const
739  { /*TODO: Implement this function*/ return Adesk::kFalse;};
740 
741  Adesk::Boolean import_mesh( const Adesk::UInt32 rows,
742  const Adesk::UInt32 columns,
743  const AcGePoint3d* pVertexList,
744  const AcGiEdgeData* pEdgeData,
745  const AcGiFaceData* pFaceData,
746  const AcGiVertexData* pVertexData,
747  const bool bAutoGenerateNormals,
748  AcDbEntity* pDatabaseEntity
749  ) const;
750 
751  Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex,
752  const AcGePoint3d* pVertexList,
753  const Adesk::UInt32 faceListSize,
754  const Adesk::Int32* pFaceList,
755  const AcGiEdgeData* pEdgeData,
756  const AcGiFaceData* pFaceData ,
757  const AcGiVertexData* pVertexData,
758  const struct resbuf* pResBuf,
759  const bool bAutoGenerateNormals,
760  AcDbEntity* pDatabaseEntity
761  ) const;
762 
763  Adesk::Boolean import_text( const AcGePoint3d& position,
764  const AcGeVector3d& normal,
765  const AcGeVector3d& direction,
766  const double height,
767  const double width,
768  const double oblique,
769  const ACHAR* pMsg,
770  AcDbEntity* pDatabaseEntity
771  ) const;
772 
773  Adesk::Boolean import_text( const AcGePoint3d& position,
774  const AcGeVector3d& normal,
775  const AcGeVector3d& direction,
776  const ACHAR* pMsg,
777  const Adesk::LongPtr length,
778  const Adesk::Boolean raw,
779  const AcGiTextStyle &pTextStyle,
780  AcDbEntity* pDatabaseEntity
781  ) const;
782 
783  HC_KEY import_text( float my_center[],
784  float my_path1[],
785  float my_norm1[],
786  wchar_t const * text,
787  const char* alignment
788  ) const; // deprecated
789 
790  HC_KEY apply_transforms_and_insert_text(float my_center[],
791  float my_path1[],
792  float my_norm1[],
793  wchar_t const * text,
794  const char* alignment
795  ) const;
796 
797  void pushModelTransform(AcGeMatrix3d const & xMat);
798  void popModelTransform();
799 
800 private:
801 
802  void importAcDbEntity(AcDbEntity* pEnt, HC_KEY parent_seg = INVALID_KEY, bool for_blk_ref=false);
803  void importAcDbEntity(AcDbEntity *pEnt, const bool& draw_shaded,
804  HC_KEY parent_seg = INVALID_KEY, bool for_blk_ref=false);
805 
806  void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, HC_KEY parent_seg = INVALID_KEY, int mib_col=0, int mib_row=0);
807  void importAcDbMInsertBlock(AcDbMInsertBlock *pAcDbMInsertBlock,HC_KEY parent_seg);
808 
809  void importAcDbPoint(AcDbPoint *pAcDbPoint);
810  void importAcDbCircle(AcDbCircle* pAcDbCircle);
811  void importAcDbMaterial(AcDbMaterial *pAcDbMaterial, AcGiMapper mapper);
812  void importLBGEData();
813  void importAcDbLine(AcDbLine *pAcDbLine);
814  void importAcDb3dPolyline(AcDb3dPolyline *pAcDbPolyline);
815  void importAcDbXline(AcDbXline* pXline);
816  void importAcDbRay(AcDbRay* pRay);
817  void importAcDbViewport(AcDbViewport* pViewport);
818  void importAcDbRasterImage(AcDbRasterImage* pEnt);
819  void importAcDbMLeader(AcDbMLeader* pEnt);
820  #ifdef WIN32
821  void importAcDbTable(AcDbTable* pAcDbTable);
822  #endif
823  void importXdata(AcDbEntity *pEnt);
824  void importBlockTableRecord(AcDbBlockTableRecord* pRecord);
825  void attachDWGHandle(AcDbEntity *pEnt);
826 
827  void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, HC_KEY& style_key);
828 
829  virtual void importXdata(resbuf *pBuf);
830  void import_hyperlinks(AcDbEntity *pEnt);
831  void set_marker_settings(const Adesk::Int16 db_pdmode, const double db_pdsize );
832 
833  void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord);
834  void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale);
835  void import_layout(AcDbDatabase *pAcDbDatabase);
836  void update_layout_list(AcDbDatabase* pAcDbDatabase);
837  void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase);
838  void InsertMaskRegion(AcDbRasterImage* pEnt);
839 
840 
841  HC_KEY GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew);
842  HC_KEY GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt);
843 
844 
845  wchar_t* m_CurrentLayoutName;
846  std::map<void * , HC_KEY> m_Segments_map;
847  std::map<void * , HC_KEY>::const_iterator m_keymap_ieterator;
848 
849  // For progress bar
850  int m_nTotalEntities;
851  int m_nCurrentEntityCount;
852  void GetNoOfEntitiesForProgressBar(AcDbDatabase* pAcDbDatabase);
853 
854  friend class HDrawOrderHandler;
855 
856 };
857 
859 {
860 public:
861  HDWG_BStreamImporter(HIOUtilityDWG* pDWGInputHandler, bool is_xref);
863 
864  virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector);
865 
867  // Bstream Toolkit
868  BStreamFileToolkit *m_pBStreamtk;
869  char *m_pBStreamBuffer;
870  int m_nBStreamBuffSize;
871  int m_nBStreamBuffCount;
872  FILE *m_pHSFFile;
873  struct vhash_s * m_vhash_StyleSegName_IsPresentFlag;
874  struct vhash_s * m_vhash_SegName_IsPresentFlag;
876 
877  virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0);
878  virtual bool importXRefs(AcDbDatabase* pHostDb, HC_KEY modelKey, HInputHandlerOptions * pInputOptions);
879  virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0);
880 
881  virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText);
882  virtual void importAcDbDimension(AcDbDimension* pAcDbDimension, dimensionAttributes dimAtt);
883  void import_exploded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const;
884  void import_extruded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const;
885  void import_fancy_pline(const AcDbPolyline& lwBuf, AcDbEntity* pDatabaseEntity) const;
886  void extrude_pline(AcGePoint3dArray dwgPoints, AcGeVector3d normal, double line_thickness) const;
887 
888  Adesk::Boolean import_circle( const AcGePoint3d& pt1,
889  const AcGePoint3d& pt2,
890  const AcGePoint3d& pt3,
891  AcDbEntity* pDatabaseEntity) const;
892 
893  Adesk::Boolean import_circle( const AcGePoint3d& center,
894  const double radius,
895  const AcGeVector3d& normal,
896  AcDbEntity* pDatabaseEntity
897  ) const;
898 
899  Adesk::Boolean import_circular_arc( const AcGePoint3d& center,
900  const double radius,
901  const AcGeVector3d& normal,
902  const AcGeVector3d& startVector,
903  const double sweepAngle,
904  const AcGiArcType arcType,
905  AcDbEntity* pDatabaseEntity
906  ) const;
907 
908  Adesk::Boolean import_circular_arc( const AcGePoint3d& start,
909  const AcGePoint3d& point,
910  const AcGePoint3d& end,
911  const AcGiArcType arcType,
912  AcDbEntity* pDatabaseEntity
913  ) const;
914 
915  Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints,
916  const AcGePoint3d* pVertexList,
917  AcDbEntity* pDatabaseEntity
918  ) const;
919 
920  Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints,
921  const AcGePoint3d* pVertexList,
922  const AcGeVector3d* pNormal,
923  Adesk::LongPtr lBaseSubEntMarker,
924  AcDbEntity* pDatabaseEntity) const;
925 
926  Adesk::Boolean import_pline(const AcDbPolyline& lwBuf,
927  Adesk::UInt32 fromIndex,
928  Adesk::UInt32 numSegs,
929  AcDbEntity* pDatabaseEntity) const;
930 
931  Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints,
932  const AcGePoint3d* pVertexList,
933  const AcGeVector3d* pNormal,
934  const Adesk::LongPtr * pSubEntMarkers,
935  AcDbEntity* pDatabaseEntity) const
936  { /*TODO: Implement this function*/ return Adesk::kFalse;};
937 
938  Adesk::Boolean import_mesh( const Adesk::UInt32 rows,
939  const Adesk::UInt32 columns,
940  const AcGePoint3d* pVertexList,
941  const AcGiEdgeData* pEdgeData,
942  const AcGiFaceData* pFaceData,
943  const AcGiVertexData* pVertexData,
944  const bool bAutoGenerateNormals,
945  AcDbEntity* pDatabaseEntity
946  ) const;
947 
948  Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex,
949  const AcGePoint3d* pVertexList,
950  const Adesk::UInt32 faceListSize,
951  const Adesk::Int32* pFaceList,
952  const AcGiEdgeData* pEdgeData,
953  const AcGiFaceData* pFaceData ,
954  const AcGiVertexData* pVertexData,
955  const struct resbuf* pResBuf,
956  const bool bAutoGenerateNormals,
957  AcDbEntity* pDatabaseEntity
958  ) const;
959 
960  Adesk::Boolean import_text( const AcGePoint3d& position,
961  const AcGeVector3d& normal,
962  const AcGeVector3d& direction,
963  const double height,
964  const double width,
965  const double oblique,
966  const ACHAR* pMsg,
967  AcDbEntity* pDatabaseEntity
968  ) const;
969 
970  Adesk::Boolean import_text( const AcGePoint3d& position,
971  const AcGeVector3d& normal,
972  const AcGeVector3d& direction,
973  const ACHAR* pMsg,
974  const Adesk::LongPtr length,
975  const Adesk::Boolean raw,
976  const AcGiTextStyle &pTextStyle,
977  AcDbEntity* pDatabaseEntity
978  ) const;
979 
980  HC_KEY apply_transforms_and_insert_text(float my_center[],
981  float my_path1[],
982  float my_norm1[],
983  wchar_t const * text,
984  const int alignment) const;
985 
986  void pushModelTransform(AcGeMatrix3d const & xMat);
987  void popModelTransform();
988 
989  inline BOOL GetConnectivityCompression() { return bConnectivityCompression; };
990  inline void SetConnectivityCompression(BOOL val) { bConnectivityCompression = val; }
991  inline BOOL GetVertexCompression() { return bVertexCompression; }
992  inline void SetVertexCompression(BOOL val) { bVertexCompression = val; }
993  inline BOOL GetNormalCompression() { return bNormalCompression; }
994  inline void SetNormalCompression(BOOL val) { bNormalCompression = val; }
995  inline BOOL GetImageCompression() { return bImageCompression; }
996  inline void SetImageCompression(BOOL val) { bImageCompression = val; }
997  inline int GetVertexCompressionBits() { return m_VertexCompressionBits; }
998  inline void SetVertexCompressionBits(int val) { m_VertexCompressionBits = val; }
999  inline int GetNormalCompressionBits() { return m_NormalCompressionBits; }
1000  inline void SetNormalCompressionBits(int val) { m_NormalCompressionBits = val; }
1001  inline int GetImageCompressionValue() { return m_ImageCompressionValue; }
1002  inline void SetImageCompressionValue(int val) { m_ImageCompressionValue = val; }
1003 
1004 
1005 protected:
1006 
1007  void importAcDbEntity(AcDbEntity* pEnt, TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0);
1008  void importAcDbEntity(AcDbEntity *pEnt, const bool& draw_shaded, int entityType,
1009  TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0);
1010 
1011 
1012  void importBlockTable(AcDbBlockTable* pBlockTable);
1013  void importAcDbMInsertBlock(AcDbMInsertBlock *pAcDbMInsertBlock,TK_Open_Segment * Open_seg_handler);
1014  //void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, HC_KEY parent_seg = INVALID_KEY);
1015  void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, TK_Open_Segment* Open_seg_handler = NULL,
1016  int mib_col = 0 , int mib_row = 0);
1017 
1018  void importAcDbPoint(AcDbPoint *pAcDbPoint);
1019  void importAcDbCircle(AcDbCircle* pAcDbCircle);
1020  void importAcDbMaterial(AcDbMaterial *pAcDbMaterial, AcGiMapper mapper);
1021  void importLBGEData();
1022  void importAcDbLine(AcDbLine *pAcDbLine);
1023  void importAcDbXline(AcDbXline* pXline);
1024  void importAcDb3dPolyline(AcDb3dPolyline *pAcDbPolyline);
1025  void importAcDbRay(AcDbRay* pRay);
1026  void importBlockTableRecord(AcDbBlockTableRecord* pRecord, dimensionData * dData = 0);
1027  void importAcDbViewport(AcDbViewport* pViewport);
1028  void importAcDbRasterImage(AcDbRasterImage* pEnt);
1029  void importAcDbMLeader(AcDbMLeader* pEnt);
1030  #ifdef WIN32
1031  void importAcDbTable(AcDbTable* pAcDbTable);
1032  #endif
1033 
1034  void importXdata(AcDbEntity *pEnt);
1035  void attachDWGHandle(AcDbEntity *pEnt);
1036  void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, TK_Open_Segment* &parent_seg);
1037  TK_Open_Segment* GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew);
1038  TK_Open_Segment* GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt);
1039 
1040  //void bstream_CreateWireframeCircleWithEllipse(const HPoint &x1, const HPoint &x2, const HPoint &x3 );
1041 
1042  virtual void importXdata(resbuf *pBuf);
1043  void import_hyperlinks(AcDbEntity *pEnt);
1044  void set_marker_settings(const Adesk::Int16 db_pdmode,const double db_pdsize );
1045  void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord);
1046  void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale);
1047  void InsertMaskRegion(AcDbRasterImage* pEnt);
1048  void import_layout(AcDbDatabase *pAcDbDatabase);
1049  void update_layout_list(AcDbDatabase* pAcDbDatabase);
1050  void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase);
1051 
1052  BOOL bConnectivityCompression;
1053  BOOL bVertexCompression;
1054  BOOL bNormalCompression;
1055  BOOL bImageCompression;
1056  int m_VertexCompressionBits;
1057  int m_NormalCompressionBits;
1058  int m_ImageCompressionValue;
1059  bool m_bMergeEntityShells;
1060  time_t m_mtImportStart;
1061  wchar_t * m_pFileName;
1062  bool m_bAmIXref;
1063  bool m_bScratchSegOpen;
1064  wchar_t *m_pXref_hsf_path;
1065  mutable bool m_bShellWithFaceColor;
1066 
1067 
1068  private:
1069  // small fuctions for opening/ closing segments, visibility, heuristics,
1070  // unicode/user opts settings, etc.
1071  // Functions to reduce code size - perform TK operations
1072  int STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * segname) const;
1073  int STREAM_Open_Segment(const char * segname) const;
1074  int STREAM_Close_Segment() const;
1075  int STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const;
1076  int STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const;
1077  int STREAM_Write_Object(BBaseOpcodeHandler * handler) const;
1078  static struct _stat m_MasterHsfFileTime;
1079 
1080  std::map<void * , const char *> m_Segments_map;
1081  std::map<void * ,const char *>::const_iterator m_iterator_segmap;
1082 
1083  friend class HDrawOrderHandler;
1084 };
1085 
1086 // Custom worldDraw object is sent in a call to the
1087 // entitiy's worldDraw function. The entity will then
1088 // end up calling the worldGeometry class's shell function.
1089 // In this case, the HAcGiWorldGeometry's shell member
1090 // function will be called.
1091 class HAcGiWorldDraw : public AcGiWorldDraw
1092 {
1093 public:
1094 
1095  ACRX_DECLARE_MEMBERS(HAcGiWorldDraw);
1096 
1097  HAcGiWorldDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity);
1098  virtual ~HAcGiWorldDraw();
1099 
1100  virtual AcGiRegenType regenType() const;
1101  virtual Adesk::Boolean regenAbort() const;
1102  virtual AcGiSubEntityTraits& subEntityTraits() const;
1103  virtual AcGiGeometry * rawGeometry() const;
1104  virtual AcGiWorldGeometry& geometry() const;
1105  virtual Adesk::Boolean isDragging() const;
1106  virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const;
1107  virtual Adesk::UInt32 numberOfIsolines() const;
1108  virtual AcGiContext * context();
1109 
1110  void setDeviation(double);
1111  void setRegenType(const AcGiRegenType&);
1112 
1113  HDWGImporter* GetHDWGImporter() const;
1114  AcDbEntity* GetCurrentEntity() const;
1115 
1116 private:
1117 
1118  AcGiSubEntityTraits* mpSubEntityTraits;
1119  AcGiWorldGeometry* mpWorldGeometry;
1120  AcGiContext* mpContext;
1121  AcGiRegenType mRegenType;
1122 
1123  HDWGImporter* m_pDWGImporter;
1124  AcDbEntity* m_pAcDbEntity;
1125 };
1126 
1127 // AcGiContext abstracts out the commonality between
1128 // AcGiViewportDraw and AcGiWorldDraw. This allows you
1129 // to code graphics routines in terms of AcGiContext that
1130 // will work in either case. To maintain their original signatures,
1131 // AcGiWorldDraw and AcGiViewportDraw now derive from AcGiContext.
1132 // Only the database member function is implemented.
1133 class HAcGiContext : public AcGiContext
1134 {
1135 public:
1136 
1137  ACRX_DECLARE_MEMBERS(HAcGiContext);
1138  HAcGiContext();
1139  virtual ~HAcGiContext();
1140 
1141  Adesk::Boolean isPsOut() const;
1142  Adesk::Boolean isPlotGeneration() const;
1143  AcDbDatabase * database() const;
1144  bool isBoundaryClipping() const;
1145 
1146 };
1147 
1148 // This class contains the view independent, model coordinate,
1149 // 3D geometry methods for our custom world geometry class.
1150 class HAcGiWorldGeometry: public AcGiWorldGeometry
1151 {
1152 public:
1153 
1154  ACRX_DECLARE_MEMBERS(HAcGiWorldGeometry);
1155 
1156  HAcGiWorldGeometry(HAcGiWorldDraw* pWorldDraw);
1157  ~HAcGiWorldGeometry();
1158 
1159  virtual Adesk::Boolean draw(AcGiDrawable*) const;
1160 
1161  virtual Adesk::Boolean circle (const AcGePoint3d& center,
1162  const double radius,
1163  const AcGeVector3d& normal
1164  ) const;
1165 
1166  virtual Adesk::Boolean circle (const AcGePoint3d& pt1,
1167  const AcGePoint3d& pt2,
1168  const AcGePoint3d& pt3
1169  ) const;
1170 
1171  virtual Adesk::Boolean circularArc(const AcGePoint3d& center,
1172  const double radius,
1173  const AcGeVector3d& normal,
1174  const AcGeVector3d& startVector,
1175  const double sweepAngle,
1176  const AcGiArcType arcType = kAcGiArcSimple
1177  ) const;
1178 
1179  virtual Adesk::Boolean circularArc(const AcGePoint3d& start,
1180  const AcGePoint3d& point,
1181  const AcGePoint3d& end,
1182  const AcGiArcType arcType = kAcGiArcSimple
1183  ) const;
1184 
1185  virtual Adesk::Boolean polyline (const Adesk::UInt32 nbPoints,
1186  const AcGePoint3d* pVertexList,
1187  const AcGeVector3d* pNormal = NULL,
1188  Adesk::LongPtr lBaseSubEntMarker = -1) const;
1189 
1190  virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const ;
1191 
1192  virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines,
1193  const AcGiPolyline* pPolylines) const;
1194  virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices,
1195  const Adesk::UInt32* numPolygonPositions,
1196  const AcGePoint3d* polygonPositions,
1197  const Adesk::UInt32* numPolygonPoints,
1198  const AcGePoint3d* polygonPoints,
1199  const AcCmEntityColor* outlineColors = NULL,
1200  const AcGiLineType* outlineTypes = NULL,
1201  const AcCmEntityColor* fillColors = NULL,
1202  const AcCmTransparency* fillOpacities = NULL) const ;
1203  virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource,
1204  const AcGePoint3d& position,
1205  const AcGeVector3d& u, //orientation and magnitude of width
1206  const AcGeVector3d& v, //orientation and magnitude of height
1207  TransparencyMode transparencyMode
1208  ) const ;
1209  virtual Adesk::Boolean rowOfDots(int count,
1210  const AcGePoint3d& start,
1211  const AcGeVector3d& step
1212  ) const ;
1213  virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center,
1214  const AcGeVector3d& normal,
1215  double majorAxisLength,
1216  double minorAxisLength,
1217  double startDegreeInRads,
1218  double endDegreeInRads,
1219  double tiltDegreeInRads,
1220  AcGiArcType arcType
1221  ) const ;
1222 
1223  virtual Adesk::Boolean polypoint(const Adesk::UInt32 nbPoints,
1224  const AcGePoint3d* pVertexList,
1225  const AcGeVector3d* pNormal = NULL,
1226  const Adesk::LongPtr * pSubEntMarkers = NULL) const;
1227 
1228  virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints,
1229  const AcGePoint3d* pVertexList
1230  ) const;
1231 
1232  virtual Adesk::Boolean mesh (const Adesk::UInt32 rows,
1233  const Adesk::UInt32 columns,
1234  const AcGePoint3d* pVertexList,
1235  const AcGiEdgeData* pEdgeData = NULL,
1236  const AcGiFaceData* pFaceData = NULL,
1237  const AcGiVertexData* pVertexData = NULL,
1238  const bool bAutoGenerateNormals = true
1239  ) const;
1240 
1241  virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex,
1242  const AcGePoint3d* pVertexList,
1243  const Adesk::UInt32 faceListSize,
1244  const Adesk::Int32* pFaceList,
1245  const AcGiEdgeData* pEdgeData = NULL,
1246  const AcGiFaceData* pFaceData = NULL,
1247  const AcGiVertexData* pVertexData = NULL,
1248  const struct resbuf* pResBuf = NULL,
1249  const bool bAutoGenerateNormals = true
1250  ) const;
1251 
1252 
1253  virtual Adesk::Boolean text (const AcGePoint3d& position,
1254  const AcGeVector3d& normal,
1255  const AcGeVector3d& direction,
1256  const double height,
1257  const double width,
1258  const double oblique,
1259  const ACHAR* pMsg
1260  ) const;
1261 
1262  virtual Adesk::Boolean text(const AcGePoint3d& position,
1263  const AcGeVector3d& normal,
1264  const AcGeVector3d& direction,
1265  const ACHAR* pMsg,
1266  const Adesk::Int32 length,
1267  const Adesk::Boolean raw,
1268  const AcGiTextStyle &pTextStyle
1269  ) const;
1270 
1271 
1272  virtual Adesk::Boolean xline (const AcGePoint3d& one_xline_point,
1273  const AcGePoint3d& a_different_xline_point
1274  ) const;
1275 
1276  virtual Adesk::Boolean ray(const AcGePoint3d& rays_starting_point,
1277  const AcGePoint3d& a_different_ray_point
1278  ) const;
1279 
1280  virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf,
1281  Adesk::UInt32 fromIndex = 0,
1282  Adesk::UInt32 numSegs = 0
1283  ) const;
1284 
1285  virtual void getModelToWorldTransform(AcGeMatrix3d &pMatrix) const;
1286  virtual void getWorldToModelTransform(AcGeMatrix3d &pMatrix) const;
1287  virtual void setExtents(AcGePoint3d *pNewExtents) const;
1288 
1289  virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal);// Uses arbitrary Axis algorythm
1290  virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat);
1291  virtual Adesk::Boolean popModelTransform();
1292 
1293  virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary);
1294  virtual void popClipBoundary();
1295  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset);
1296  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset);
1297  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents);
1298  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents);
1299  virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior);
1300 
1301 private:
1302 
1303  // Back pointer stored to the WorldDraw object. This class
1304  // uses it to store the ShellData when the shell member
1305  // function is called.
1306  HAcGiWorldDraw* m_pHAcGiWorldDraw;
1307  unsigned int m_uiOpenSegmentCount;
1308 };
1309 
1310 
1311 // This class applies attributes to subsequently drawn AcGi geometry
1312 // primitives.
1313 class HAcGiSubEntityTraits: public AcGiSubEntityTraits
1314 {
1315 public:
1316 
1317  ACRX_DECLARE_MEMBERS(HAcGiSubEntityTraits);
1318 
1321 
1322  virtual void setColor(const Adesk::UInt16 color);
1323  virtual void setTrueColor(const AcCmEntityColor& color);
1324  virtual void setLayer(const AcDbObjectId layerId);
1325  virtual void setLineType(const AcDbObjectId linetypeId);
1326  virtual void setSelectionMarker(const Adesk::LongPtr markerId);
1327  virtual void setFillType(const AcGiFillType fillType);
1328  virtual void setLineWeight(const AcDb::LineWeight lw);
1329  virtual void setLineTypeScale(double dScale = 1.0);
1330 
1331 
1332  virtual Adesk::UInt16 color() const;
1333  virtual AcCmEntityColor trueColor() const;
1334  virtual AcDbObjectId layerId() const;
1335  virtual AcDbObjectId lineTypeId() const;
1336  virtual AcGiFillType fillType() const;
1337  virtual AcDb::LineWeight lineWeight() const;
1338  virtual double lineTypeScale() const;
1339 
1340  virtual void setThickness(double dThickness);
1341  virtual double thickness() const;
1342 
1343 private:
1344 
1345  Adesk::UInt16 mColorIndex;
1346  AcCmEntityColor mTrueColor;
1347  AcDbObjectId mLayerId;
1348  AcDbObjectId mLinetypeId;
1349  Adesk::LongPtr mMarkerId;
1350  AcGiFillType mFillType;
1351  AcDb::LineWeight mLineWeight;
1352  double mLineTypeScale;
1353  double mThickness;
1354 };
1355 
1356 // Some entities (particularly custom entities from AEC etc.) are viewport entities
1357 // They don't have any visual reprentation in world (worldDraw fails), but they
1358 // have a specific representation in viewport. Hence we are deriving from ViewportDraw
1359 // --- SK 17 mar 09
1360 
1361 class HAcGiViewportDraw : public AcGiViewportDraw
1362 {
1363 public:
1364  ACRX_DECLARE_MEMBERS(HAcGiViewportDraw);
1365  HAcGiViewportDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity);
1366  ~HAcGiViewportDraw();
1367 
1368  virtual AcGiViewport& viewport() const;
1369  virtual AcGiViewportGeometry& geometry() const;
1370  virtual Adesk::UInt32 sequenceNumber() const;
1371  virtual Adesk::Boolean isValidId(const Adesk::ULongPtr acgiId) const;
1372  virtual AcDbObjectId viewportObjectId() const;
1373 
1374  virtual AcGiRegenType regenType() const ;
1375  virtual Adesk::Boolean regenAbort() const {return Adesk::kFalse;};
1376  virtual AcGiSubEntityTraits& subEntityTraits() const ;
1377  virtual AcGiGeometry * rawGeometry() const ;
1378  virtual Adesk::Boolean isDragging() const {return Adesk::kFalse;};
1379 
1380  // This function operates against the current active viewport
1381  //
1382  virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const {return 0.00;};
1383  virtual Adesk::UInt32 numberOfIsolines() const {return 0;};
1384 
1385  virtual AcGiContext * context();
1386 
1387  HDWGImporter* GetHDWGImporter() const;
1388  AcDbEntity* GetCurrentEntity() const;
1389 
1390 private:
1391  AcGiViewport* mpVp;
1392  AcGiViewportGeometry* mpVpGeometry;
1393  AcDbObjectId mpObjId;
1394 
1395  AcGiSubEntityTraits* mpSubEntityTraits;
1396  AcGiContext* mpContext;
1397  AcGiRegenType mRegenType;
1398 
1399  HDWGImporter* m_pDWGImporter;
1400  AcDbEntity* m_pAcDbEntity;
1401 
1402 };
1403 
1404 class HAcGiViewportGeometry : public AcGiViewportGeometry
1405 {
1406 public:
1407  ACRX_DECLARE_MEMBERS(HAcGiViewportGeometry);
1408  HAcGiViewportGeometry(HAcGiViewportDraw* pViewportDraw);
1410  virtual Adesk::Boolean polylineEye(const Adesk::UInt32 nbPoints,
1411  const AcGePoint3d* pPoints) const ;
1412  virtual Adesk::Boolean polygonEye(const Adesk::UInt32 nbPoints,
1413  const AcGePoint3d* pPoints) const ;
1414 
1415  virtual Adesk::Boolean polylineDc(const Adesk::UInt32 nbPoints,
1416  const AcGePoint3d* pPoints) const;
1417  virtual Adesk::Boolean polygonDc(const Adesk::UInt32 nbPoints,
1418  const AcGePoint3d* pPoints) const ;
1419 
1420 
1421  virtual Adesk::Boolean rasterImageDc(
1422  const AcGePoint3d& origin,
1423  const AcGeVector3d& u,
1424  const AcGeVector3d& v,
1425  const AcGeMatrix2d& pixelToDc,
1426  AcDbObjectId entityId,
1427  AcGiImageOrg imageOrg,
1428  Adesk::UInt32 imageWidth,
1429  Adesk::UInt32 imageHeight,
1430  Adesk::Int16 imageColorDepth,
1431  Adesk::Boolean transparency,
1432  ImageSource source,
1433  const AcGeVector3d& unrotatedU,
1434  const AcGiImageOrg origionalImageOrg,
1435  const AcGeMatrix2d& unrotatedPixelToDc,
1436  const Adesk::UInt32 unrotatedImageWidth,
1437  const Adesk::UInt32 unrotatedImageHeight
1438  ) const;
1439 
1440  virtual Adesk::Boolean ownerDrawDc(
1441  long vpnumber,
1442  long left,
1443  long top,
1444  long right,
1445  long bottom,
1446  const OwnerDraw* pOwnerDraw
1447  ) const;
1448 
1449  virtual Adesk::Boolean ownerDraw3d(
1450  AcGePoint3d& minBounds,
1451  AcGePoint3d& maxBounds,
1452  OwnerDraw3d* pOwnerDraw
1453  ) const ;
1454 
1455 
1456  // Coordinate transformations.
1457  //
1458  virtual void getModelToWorldTransform(AcGeMatrix3d&) const ;
1459  virtual void getWorldToModelTransform(AcGeMatrix3d&) const ;
1460 
1461  virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal) ;// Uses arbitrary Axis algorythm
1462  virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat) ;
1463  virtual Adesk::Boolean popModelTransform() ;
1464 
1465  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset);
1466  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset);
1467  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents);
1468  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents);
1469  virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior);
1470 
1471 
1472  // For drawing various primitives.
1473  //
1474  virtual Adesk::Boolean circle(const AcGePoint3d& center,
1475  const double radius,
1476  const AcGeVector3d& normal) const ;
1477 
1478  virtual Adesk::Boolean circle(const AcGePoint3d&, const AcGePoint3d&,
1479  const AcGePoint3d&) const ;
1480 
1481  virtual Adesk::Boolean circularArc(const AcGePoint3d& center,
1482  const double radius,
1483  const AcGeVector3d& normal,
1484  const AcGeVector3d& startVector,
1485  const double sweepAngle,
1486  const AcGiArcType arcType = kAcGiArcSimple) const ;
1487 
1488  virtual Adesk::Boolean circularArc(const AcGePoint3d& start,
1489  const AcGePoint3d& point,
1490  const AcGePoint3d& end,
1491  const AcGiArcType arcType = kAcGiArcSimple) const ;
1492 
1493  virtual Adesk::Boolean polyline(const Adesk::UInt32 nbPoints,
1494  const AcGePoint3d* pVertexList,
1495  const AcGeVector3d* pNormal = NULL,
1496  Adesk::LongPtr lBaseSubEntMarker = -1) const ;
1497 
1498  virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const {return Adesk::kTrue;}
1499 
1500  virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines,
1501  const AcGiPolyline* pPolylines) const {return Adesk::kTrue;}
1502  virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices,
1503  const Adesk::UInt32* numPolygonPositions,
1504  const AcGePoint3d* polygonPositions,
1505  const Adesk::UInt32* numPolygonPoints,
1506  const AcGePoint3d* polygonPoints,
1507  const AcCmEntityColor* outlineColors = NULL,
1508  const AcGiLineType* outlineTypes = NULL,
1509  const AcCmEntityColor* fillColors = NULL,
1510  const AcCmTransparency* fillOpacities = NULL) const {return Adesk::kTrue;}
1511  virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource,
1512  const AcGePoint3d& position,
1513  const AcGeVector3d& u, //orientation and magnitude of width
1514  const AcGeVector3d& v, //orientation and magnitude of height
1515  TransparencyMode transparencyMode = kTransparency8Bit
1516  ) const {return Adesk::kTrue;}
1517  virtual Adesk::Boolean rowOfDots(int count,
1518  const AcGePoint3d& start,
1519  const AcGeVector3d& step
1520  ) const {return Adesk::kTrue;}
1521  virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center,
1522  const AcGeVector3d& normal,
1523  double majorAxisLength,
1524  double minorAxisLength,
1525  double startDegreeInRads,
1526  double endDegreeInRads,
1527  double tiltDegreeInRads,
1528  AcGiArcType arcType = kAcGiArcSimple
1529  ) const {return Adesk::kTrue;}
1530 
1531  virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints,
1532  const AcGePoint3d* pVertexList) const ;
1533 
1534  virtual Adesk::Boolean mesh(const Adesk::UInt32 rows,
1535  const Adesk::UInt32 columns,
1536  const AcGePoint3d* pVertexList,
1537  const AcGiEdgeData* pEdgeData = NULL,
1538  const AcGiFaceData* pFaceData = NULL,
1539  const AcGiVertexData* pVertexData = NULL,
1540  const bool bAutoGenerateNormals = true
1541  ) const ;
1542 
1543  virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex,
1544  const AcGePoint3d* pVertexList,
1545  const Adesk::UInt32 faceListSize,
1546  const Adesk::Int32* pFaceList,
1547  const AcGiEdgeData* pEdgeData = NULL,
1548  const AcGiFaceData* pFaceData = NULL,
1549  const AcGiVertexData* pVertexData = NULL,
1550  const struct resbuf* pResBuf = NULL,
1551  const bool bAutoGenerateNormals = true
1552  ) const ;
1553 
1554  virtual Adesk::Boolean text(const AcGePoint3d& position,
1555  const AcGeVector3d& normal,
1556  const AcGeVector3d& direction,
1557  const double height,
1558  const double width,
1559  const double oblique,
1560  const ACHAR* pMsg) const ;
1561 
1562  virtual Adesk::Boolean text(const AcGePoint3d& position,
1563  const AcGeVector3d& normal,
1564  const AcGeVector3d& direction,
1565  const ACHAR* pMsg,
1566  const Adesk::Int32 length,
1567  const Adesk::Boolean raw,
1568  const AcGiTextStyle &pTextStyle
1569  ) const ;
1570 
1571  virtual Adesk::Boolean xline(const AcGePoint3d&,
1572  const AcGePoint3d&) const ;
1573 
1574  virtual Adesk::Boolean ray(const AcGePoint3d&,
1575  const AcGePoint3d&) const ;
1576 
1577  virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf,
1578  Adesk::UInt32 fromIndex = 0,
1579  Adesk::UInt32 numSegs = 0
1580  ) const ;
1581 
1582  virtual Adesk::Boolean draw(AcGiDrawable*) const ;
1583 
1584  virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary);
1585  virtual void popClipBoundary() ;
1586 
1587 private:
1588  // Back pointer stored to the ViewPortDraw object. This class
1589  // uses it to store the ShellData when the shell member
1590  // function is called. ---- SK 18 mar 09
1591  HAcGiViewportDraw* m_pHAcGiViewportDraw;
1592  unsigned int m_uiOpenSegmentCount;
1593 
1594 };
1595 class HAcGiViewport : public AcGiViewport
1596 {
1597 public:
1598  ACRX_DECLARE_MEMBERS(AcGiViewport);
1599  HAcGiViewport(HInputHandlerOptions const * options = 0);
1600  ~HAcGiViewport();
1601 
1602  virtual void getModelToEyeTransform(AcGeMatrix3d& mx) const;
1603  virtual void getEyeToModelTransform(AcGeMatrix3d& mx) const;
1604  virtual void getWorldToEyeTransform(AcGeMatrix3d& mx) const;
1605  virtual void getEyeToWorldTransform(AcGeMatrix3d& mx) const;
1606 
1607  virtual Adesk::Boolean isPerspective() const;
1608  virtual Adesk::Boolean doPerspective(AcGePoint3d&) const;
1609  virtual Adesk::Boolean doInversePerspective(AcGePoint3d&) const;
1610 
1611  virtual void getNumPixelsInUnitSquare(const AcGePoint3d& givenWorldpt,
1612  AcGePoint2d& pixelArea,
1613  bool includePerspective = true) const;
1614 
1615  virtual void getCameraLocation(AcGePoint3d& location) const;
1616  virtual void getCameraTarget(AcGePoint3d& target) const;
1617  virtual void getCameraUpVector(AcGeVector3d& upVector) const;
1618 
1619  virtual Adesk::ULongPtr viewportId() const;
1620  virtual Adesk::Int16 acadWindowId() const;
1621  virtual void getViewportDcCorners(AcGePoint2d& lower_left,
1622  AcGePoint2d& upper_right) const;
1623 
1624  virtual Adesk::Boolean getFrontAndBackClipValues(Adesk::Boolean& clip_front,
1625  Adesk::Boolean& clip_back,
1626  double& front,
1627  double& back) const;
1628  virtual double linetypeScaleMultiplier() const;
1629  virtual double linetypeGenerationCriteria() const;
1630 
1631  virtual AcGeVector3d viewDir() const;
1632 
1633 private:
1634  HInputHandlerOptions const * inputOptions;
1635  AcGePoint3d cameraTarget;
1636  AcGePoint3d cameraLocation;
1637  AcGeVector3d cameraUpVector;
1638 };
1639 
1641 {
1642 public:
1643  HDrawOrderHandler(AcDbBlockTableRecord * pRecord)
1644  {
1645  m_pRecord = pRecord;
1646  m_pObj = 0;
1647  };
1648 
1649  int Open();
1650  bool GetNextEntity(AcDbEntity *& pOutEnt);
1651  int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, HC_KEY block_key, HDWG_3dgsImporter * importer);
1652  int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, TK_Open_Segment * include_seg_handler, HDWG_BStreamImporter * importer);
1653  void Close();
1654 
1655 protected:
1656  AcDbBlockTableRecord * m_pRecord;
1657  AcDbSortentsTable * m_pObj;
1658  AcDbObjectIdArray objArray;
1659  int m_iIndex;
1660  AcDbBlockTableRecordIterator * m_pRecordIter;
1661 
1662 };
1663 
1664 wchar_t * h_dwg_wcsdup(wchar_t const * const wcs);
1665 
1666 // Inline functions for HDWG_BStreamImporter calling opcodehandlers
1667 inline int HDWG_BStreamImporter::STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * seg_name) const
1668 {
1669  // Caller have to delete open_seg_handler, in this version.
1670  open_seg_handler->SetSegment(seg_name);
1671  TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1672  H_ASSERT(hdwg_status == TK_Normal);
1673  return 1;
1674 }
1675 
1676 inline int HDWG_BStreamImporter::STREAM_Open_Segment(const char * seg_name) const
1677 {
1678  // Caller don't have to delete open_seg_handler, in this version.
1679  TK_Open_Segment* open_seg_handler = new TK_Open_Segment;
1680  open_seg_handler->SetSegment(seg_name);
1681  TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1682  H_ASSERT(hdwg_status == TK_Normal);
1683  delete open_seg_handler;
1684 
1685  return 1;
1686 }
1687 
1688 inline int HDWG_BStreamImporter:: STREAM_Close_Segment() const
1689 {
1690  TK_Close_Segment *close_seg_handler = new TK_Close_Segment;
1691  TK_Status hdwg_status = WriteObject(close_seg_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1692  H_ASSERT(hdwg_status == TK_Normal);
1693  delete close_seg_handler;
1694 
1695  return 1;
1696 }
1697 
1698 inline int HDWG_BStreamImporter:: STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const
1699 {
1700  //HC_Set_Visibility("off");
1701  TK_Visibility *vis_handler = new TK_Visibility();
1702  vis_handler->SetGeometry(Geom_Bit);
1703  if(ifOn)
1704  vis_handler->SetValue(1);
1705  else
1706  vis_handler->SetValue(0);
1707  TK_Status hdwg_status = WriteObject(vis_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1708  H_ASSERT(hdwg_status == TK_Normal);
1709  delete vis_handler;
1710 
1711  return 1;
1712 }
1713 
1714 inline int HDWG_BStreamImporter:: STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const
1715 {
1716  //HC_Set_Heuristics("xxxx");
1717  TK_Heuristics* heuristic_handler = new TK_Heuristics;
1718  heuristic_handler->SetMask( Heuristic_Bit);
1719  heuristic_handler->SetValue( Heuristic_Bit);
1720  TK_Status hdwg_status = WriteObject(heuristic_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1721  H_ASSERT(hdwg_status == TK_Normal);
1722  delete heuristic_handler;
1723 
1724  return 1;
1725 }
1726 inline int HDWG_BStreamImporter:: STREAM_Write_Object(BBaseOpcodeHandler * handler) const
1727 {
1728  TK_Status hdwg_status = WriteObject(handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1729  H_ASSERT(hdwg_status == TK_Normal);
1730  delete handler;
1731 
1732  return 1;
1733 }
1734 
1735 #ifdef H_PACK_8
1736 #pragma pack(pop)
1737 #endif
1738 
1739 #endif
Definition: HDWGHelper.h:310
Definition: HDWGHelper.h:1091
Definition: HDWGHelper.h:1313
Definition: HDWGHelper.h:616
Definition: HIOUtilityDWG.h:50
Definition: HDWGHelper.h:430
#define HC_KEY
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:543
Definition: HDWGHelper.h:1595
Definition: HIOUtilityDWG.h:124
Definition: HDWGHelper.h:640
Definition: HDWGHelper.h:347
Definition: HDWGHelper.h:858
Definition: HDWGHelper.h:1361
Definition: HDWGHelper.h:662
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
Definition: HIOManager.h:247
Definition: HDWGHelper.h:1133
A header file containing the HIO classes for passing to HBaseView::FileInput and HBaseView::FileOutpu...
Definition: HDWGHelper.h:1150
Definition: HDWGHelper.h:1404
Definition: HDWGHelper.h:1640