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 //
22 
23 #ifndef HDWG_HELPER_H_
24 #define HDWG_HELPER_H_ 1
25 
26 #ifdef H_PACK_8
27 #pragma pack(push)
28 #pragma pack(8)
29 #endif
30 
31 
32 //#include <wchar.h>
33 #include <map>
34 #include <vector>
35 #include <string>
36 
37 #include "acgi.h"
38 #include "hc.h"
39 #include "HIOManager.h"
40 #include "HTools.h"
41 #include "HUtility.h"
42 
43 #include "BStream.h"
44 #include "BOpcodeShell.h"
45 
46 #include "sorttab.h "
47 
48 #include "windows.h"
49 #include "stdlib.h"
50 #include "stdio.h"
51 #include "string.h"
52 #include "time.h"
53 
54 #include "dbimage.h"
55 #include "imgdef.h"
56 #include "imgent.h"
57 
58 #include "dbobjptr.h"
59 #include "acdblmgr.h"
60 #include "dbmleader.h" // For AcDbMLeader
61 #include "dblight.h"
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  void importAcDbLight(AcDbLight* pEnt);
821  #ifdef WIN32
822  void importAcDbTable(AcDbTable* pAcDbTable);
823  #endif
824  void importXdata(AcDbEntity *pEnt);
825  void importBlockTableRecord(AcDbBlockTableRecord* pRecord);
826  void attachDWGHandle(AcDbEntity *pEnt);
827 
828  void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, HC_KEY& style_key);
829 
830  virtual void importXdata(resbuf *pBuf);
831  void import_hyperlinks(AcDbEntity *pEnt);
832  void set_marker_settings(const Adesk::Int16 db_pdmode, const double db_pdsize );
833 
834  void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord);
835  void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale);
836  void import_layout(AcDbDatabase *pAcDbDatabase);
837  void update_layout_list(AcDbDatabase* pAcDbDatabase);
838  void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase);
839  void InsertMaskRegion(AcDbRasterImage* pEnt);
840 
841 
842  HC_KEY GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew);
843  HC_KEY GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt);
844 
845 
846  wchar_t* m_CurrentLayoutName;
847  std::map<void * , HC_KEY> m_Segments_map;
848  std::map<void * , HC_KEY>::const_iterator m_keymap_ieterator;
849 
850  // For progress bar
851  int m_nTotalEntities;
852  int m_nCurrentEntityCount;
853  void GetNoOfEntitiesForProgressBar(AcDbDatabase* pAcDbDatabase);
854 
855  friend class HDrawOrderHandler;
856 
857 };
858 
860 {
861 public:
862  HDWG_BStreamImporter(HIOUtilityDWG* pDWGInputHandler, bool is_xref);
864 
865  virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector);
866 
868  // Bstream Toolkit
869  BStreamFileToolkit *m_pBStreamtk;
870  char *m_pBStreamBuffer;
871  int m_nBStreamBuffSize;
872  int m_nBStreamBuffCount;
873  FILE *m_pHSFFile;
874  struct vhash_s * m_vhash_StyleSegName_IsPresentFlag;
875  struct vhash_s * m_vhash_SegName_IsPresentFlag;
877 
878  virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0);
879  virtual bool importXRefs(AcDbDatabase* pHostDb, HC_KEY modelKey, HInputHandlerOptions * pInputOptions);
880  virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0);
881 
882  virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText);
883  virtual void importAcDbDimension(AcDbDimension* pAcDbDimension, dimensionAttributes dimAtt);
884  void import_exploded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const;
885  void import_extruded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const;
886  void import_fancy_pline(const AcDbPolyline& lwBuf, AcDbEntity* pDatabaseEntity) const;
887  void extrude_pline(AcGePoint3dArray dwgPoints, AcGeVector3d normal, double line_thickness) const;
888 
889  Adesk::Boolean import_circle( const AcGePoint3d& pt1,
890  const AcGePoint3d& pt2,
891  const AcGePoint3d& pt3,
892  AcDbEntity* pDatabaseEntity) const;
893 
894  Adesk::Boolean import_circle( const AcGePoint3d& center,
895  const double radius,
896  const AcGeVector3d& normal,
897  AcDbEntity* pDatabaseEntity
898  ) const;
899 
900  Adesk::Boolean import_circular_arc( const AcGePoint3d& center,
901  const double radius,
902  const AcGeVector3d& normal,
903  const AcGeVector3d& startVector,
904  const double sweepAngle,
905  const AcGiArcType arcType,
906  AcDbEntity* pDatabaseEntity
907  ) const;
908 
909  Adesk::Boolean import_circular_arc( const AcGePoint3d& start,
910  const AcGePoint3d& point,
911  const AcGePoint3d& end,
912  const AcGiArcType arcType,
913  AcDbEntity* pDatabaseEntity
914  ) const;
915 
916  Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints,
917  const AcGePoint3d* pVertexList,
918  AcDbEntity* pDatabaseEntity
919  ) const;
920 
921  Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints,
922  const AcGePoint3d* pVertexList,
923  const AcGeVector3d* pNormal,
924  Adesk::LongPtr lBaseSubEntMarker,
925  AcDbEntity* pDatabaseEntity) const;
926 
927  Adesk::Boolean import_pline(const AcDbPolyline& lwBuf,
928  Adesk::UInt32 fromIndex,
929  Adesk::UInt32 numSegs,
930  AcDbEntity* pDatabaseEntity) const;
931 
932  Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints,
933  const AcGePoint3d* pVertexList,
934  const AcGeVector3d* pNormal,
935  const Adesk::LongPtr * pSubEntMarkers,
936  AcDbEntity* pDatabaseEntity) const
937  { /*TODO: Implement this function*/ return Adesk::kFalse;};
938 
939  Adesk::Boolean import_mesh( const Adesk::UInt32 rows,
940  const Adesk::UInt32 columns,
941  const AcGePoint3d* pVertexList,
942  const AcGiEdgeData* pEdgeData,
943  const AcGiFaceData* pFaceData,
944  const AcGiVertexData* pVertexData,
945  const bool bAutoGenerateNormals,
946  AcDbEntity* pDatabaseEntity
947  ) const;
948 
949  Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex,
950  const AcGePoint3d* pVertexList,
951  const Adesk::UInt32 faceListSize,
952  const Adesk::Int32* pFaceList,
953  const AcGiEdgeData* pEdgeData,
954  const AcGiFaceData* pFaceData ,
955  const AcGiVertexData* pVertexData,
956  const struct resbuf* pResBuf,
957  const bool bAutoGenerateNormals,
958  AcDbEntity* pDatabaseEntity
959  ) const;
960 
961  Adesk::Boolean import_text( const AcGePoint3d& position,
962  const AcGeVector3d& normal,
963  const AcGeVector3d& direction,
964  const double height,
965  const double width,
966  const double oblique,
967  const ACHAR* pMsg,
968  AcDbEntity* pDatabaseEntity
969  ) const;
970 
971  Adesk::Boolean import_text( const AcGePoint3d& position,
972  const AcGeVector3d& normal,
973  const AcGeVector3d& direction,
974  const ACHAR* pMsg,
975  const Adesk::LongPtr length,
976  const Adesk::Boolean raw,
977  const AcGiTextStyle &pTextStyle,
978  AcDbEntity* pDatabaseEntity
979  ) const;
980 
981  HC_KEY apply_transforms_and_insert_text(float my_center[],
982  float my_path1[],
983  float my_norm1[],
984  wchar_t const * text,
985  const int alignment) const;
986 
987  void pushModelTransform(AcGeMatrix3d const & xMat);
988  void popModelTransform();
989 
990  inline BOOL GetConnectivityCompression() { return bConnectivityCompression; };
991  inline void SetConnectivityCompression(BOOL val) { bConnectivityCompression = val; }
992  inline BOOL GetVertexCompression() { return bVertexCompression; }
993  inline void SetVertexCompression(BOOL val) { bVertexCompression = val; }
994  inline BOOL GetNormalCompression() { return bNormalCompression; }
995  inline void SetNormalCompression(BOOL val) { bNormalCompression = val; }
996  inline BOOL GetImageCompression() { return bImageCompression; }
997  inline void SetImageCompression(BOOL val) { bImageCompression = val; }
998  inline int GetVertexCompressionBits() { return m_VertexCompressionBits; }
999  inline void SetVertexCompressionBits(int val) { m_VertexCompressionBits = val; }
1000  inline int GetNormalCompressionBits() { return m_NormalCompressionBits; }
1001  inline void SetNormalCompressionBits(int val) { m_NormalCompressionBits = val; }
1002  inline int GetImageCompressionValue() { return m_ImageCompressionValue; }
1003  inline void SetImageCompressionValue(int val) { m_ImageCompressionValue = val; }
1004 
1005 
1006 protected:
1007 
1008  void importAcDbEntity(AcDbEntity* pEnt, TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0);
1009  void importAcDbEntity(AcDbEntity *pEnt, const bool& draw_shaded, int entityType,
1010  TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0);
1011 
1012 
1013  void importBlockTable(AcDbBlockTable* pBlockTable);
1014  void importAcDbMInsertBlock(AcDbMInsertBlock *pAcDbMInsertBlock,TK_Open_Segment * Open_seg_handler);
1015  //void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, HC_KEY parent_seg = INVALID_KEY);
1016  void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, TK_Open_Segment* Open_seg_handler = NULL,
1017  int mib_col = 0 , int mib_row = 0);
1018 
1019  void importAcDbPoint(AcDbPoint *pAcDbPoint);
1020  void importAcDbCircle(AcDbCircle* pAcDbCircle);
1021  void importAcDbMaterial(AcDbMaterial *pAcDbMaterial, AcGiMapper mapper);
1022  void importLBGEData();
1023  void importAcDbLine(AcDbLine *pAcDbLine);
1024  void importAcDbXline(AcDbXline* pXline);
1025  void importAcDb3dPolyline(AcDb3dPolyline *pAcDbPolyline);
1026  void importAcDbRay(AcDbRay* pRay);
1027  void importBlockTableRecord(AcDbBlockTableRecord* pRecord, dimensionData * dData = 0);
1028  void importAcDbViewport(AcDbViewport* pViewport);
1029  void importAcDbRasterImage(AcDbRasterImage* pEnt);
1030  void importAcDbMLeader(AcDbMLeader* pEnt);
1031  void importAcDbLight(AcDbLight* pEnt);
1032  #ifdef WIN32
1033  void importAcDbTable(AcDbTable* pAcDbTable);
1034  #endif
1035 
1036  void importXdata(AcDbEntity *pEnt);
1037  void attachDWGHandle(AcDbEntity *pEnt);
1038  void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, TK_Open_Segment* &parent_seg);
1039  TK_Open_Segment* GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew);
1040  TK_Open_Segment* GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt);
1041 
1042  //void bstream_CreateWireframeCircleWithEllipse(const HPoint &x1, const HPoint &x2, const HPoint &x3 );
1043 
1044  virtual void importXdata(resbuf *pBuf);
1045  void import_hyperlinks(AcDbEntity *pEnt);
1046  void set_marker_settings(const Adesk::Int16 db_pdmode,const double db_pdsize );
1047  void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord);
1048  void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale);
1049  void InsertMaskRegion(AcDbRasterImage* pEnt);
1050  void import_layout(AcDbDatabase *pAcDbDatabase);
1051  void update_layout_list(AcDbDatabase* pAcDbDatabase);
1052  void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase);
1053 
1054  BOOL bConnectivityCompression;
1055  BOOL bVertexCompression;
1056  BOOL bNormalCompression;
1057  BOOL bImageCompression;
1058  int m_VertexCompressionBits;
1059  int m_NormalCompressionBits;
1060  int m_ImageCompressionValue;
1061  bool m_bMergeEntityShells;
1062  time_t m_mtImportStart;
1063  wchar_t * m_pFileName;
1064  bool m_bAmIXref;
1065  bool m_bScratchSegOpen;
1066  wchar_t *m_pXref_hsf_path;
1067  mutable bool m_bShellWithFaceColor;
1068 
1069 
1070  private:
1071  // small fuctions for opening/ closing segments, visibility, heuristics,
1072  // unicode/user opts settings, etc.
1073  // Functions to reduce code size - perform TK operations
1074  int STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * segname) const;
1075  int STREAM_Open_Segment(const char * segname) const;
1076  int STREAM_Close_Segment() const;
1077  int STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const;
1078  int STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const;
1079  int STREAM_Write_Object(BBaseOpcodeHandler * handler) const;
1080  static struct _stat m_MasterHsfFileTime;
1081 
1082  std::map<void * , const char *> m_Segments_map;
1083  std::map<void * ,const char *>::const_iterator m_iterator_segmap;
1084 
1085  friend class HDrawOrderHandler;
1086 };
1087 
1088 // Custom worldDraw object is sent in a call to the
1089 // entitiy's worldDraw function. The entity will then
1090 // end up calling the worldGeometry class's shell function.
1091 // In this case, the HAcGiWorldGeometry's shell member
1092 // function will be called.
1093 class HAcGiWorldDraw : public AcGiWorldDraw
1094 {
1095 public:
1096 
1097  ACRX_DECLARE_MEMBERS(HAcGiWorldDraw);
1098 
1099  HAcGiWorldDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity);
1100  virtual ~HAcGiWorldDraw();
1101 
1102  virtual AcGiRegenType regenType() const;
1103  virtual Adesk::Boolean regenAbort() const;
1104  virtual AcGiSubEntityTraits& subEntityTraits() const;
1105  virtual AcGiGeometry * rawGeometry() const;
1106  virtual AcGiWorldGeometry& geometry() const;
1107  virtual Adesk::Boolean isDragging() const;
1108  virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const;
1109  virtual Adesk::UInt32 numberOfIsolines() const;
1110  virtual AcGiContext * context();
1111 
1112  void setDeviation(double);
1113  void setRegenType(const AcGiRegenType&);
1114 
1115  HDWGImporter* GetHDWGImporter() const;
1116  AcDbEntity* GetCurrentEntity() const;
1117 
1118 private:
1119 
1120  AcGiSubEntityTraits* mpSubEntityTraits;
1121  AcGiWorldGeometry* mpWorldGeometry;
1122  AcGiContext* mpContext;
1123  AcGiRegenType mRegenType;
1124 
1125  HDWGImporter* m_pDWGImporter;
1126  AcDbEntity* m_pAcDbEntity;
1127 };
1128 
1129 // AcGiContext abstracts out the commonality between
1130 // AcGiViewportDraw and AcGiWorldDraw. This allows you
1131 // to code graphics routines in terms of AcGiContext that
1132 // will work in either case. To maintain their original signatures,
1133 // AcGiWorldDraw and AcGiViewportDraw now derive from AcGiContext.
1134 // Only the database member function is implemented.
1135 class HAcGiContext : public AcGiContext
1136 {
1137 public:
1138 
1139  ACRX_DECLARE_MEMBERS(HAcGiContext);
1140  HAcGiContext();
1141  virtual ~HAcGiContext();
1142 
1143  Adesk::Boolean isPsOut() const;
1144  Adesk::Boolean isPlotGeneration() const;
1145  AcDbDatabase * database() const;
1146  bool isBoundaryClipping() const;
1147 
1148 };
1149 
1150 // This class contains the view independent, model coordinate,
1151 // 3D geometry methods for our custom world geometry class.
1152 class HAcGiWorldGeometry: public AcGiWorldGeometry
1153 {
1154 public:
1155 
1156  ACRX_DECLARE_MEMBERS(HAcGiWorldGeometry);
1157 
1158  HAcGiWorldGeometry(HAcGiWorldDraw* pWorldDraw);
1159  ~HAcGiWorldGeometry();
1160 
1161  virtual Adesk::Boolean draw(AcGiDrawable*) const;
1162 
1163  virtual Adesk::Boolean circle (const AcGePoint3d& center,
1164  const double radius,
1165  const AcGeVector3d& normal
1166  ) const;
1167 
1168  virtual Adesk::Boolean circle (const AcGePoint3d& pt1,
1169  const AcGePoint3d& pt2,
1170  const AcGePoint3d& pt3
1171  ) const;
1172 
1173  virtual Adesk::Boolean circularArc(const AcGePoint3d& center,
1174  const double radius,
1175  const AcGeVector3d& normal,
1176  const AcGeVector3d& startVector,
1177  const double sweepAngle,
1178  const AcGiArcType arcType = kAcGiArcSimple
1179  ) const;
1180 
1181  virtual Adesk::Boolean circularArc(const AcGePoint3d& start,
1182  const AcGePoint3d& point,
1183  const AcGePoint3d& end,
1184  const AcGiArcType arcType = kAcGiArcSimple
1185  ) const;
1186 
1187  virtual Adesk::Boolean polyline (const Adesk::UInt32 nbPoints,
1188  const AcGePoint3d* pVertexList,
1189  const AcGeVector3d* pNormal = NULL,
1190  Adesk::LongPtr lBaseSubEntMarker = -1) const;
1191 
1192  virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const ;
1193 
1194  virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines,
1195  const AcGiPolyline* pPolylines) const;
1196  virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices,
1197  const Adesk::UInt32* numPolygonPositions,
1198  const AcGePoint3d* polygonPositions,
1199  const Adesk::UInt32* numPolygonPoints,
1200  const AcGePoint3d* polygonPoints,
1201  const AcCmEntityColor* outlineColors = NULL,
1202  const AcGiLineType* outlineTypes = NULL,
1203  const AcCmEntityColor* fillColors = NULL,
1204  const AcCmTransparency* fillOpacities = NULL) const ;
1205  virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource,
1206  const AcGePoint3d& position,
1207  const AcGeVector3d& u, //orientation and magnitude of width
1208  const AcGeVector3d& v, //orientation and magnitude of height
1209  TransparencyMode transparencyMode
1210  ) const ;
1211  virtual Adesk::Boolean rowOfDots(int count,
1212  const AcGePoint3d& start,
1213  const AcGeVector3d& step
1214  ) const ;
1215  virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center,
1216  const AcGeVector3d& normal,
1217  double majorAxisLength,
1218  double minorAxisLength,
1219  double startDegreeInRads,
1220  double endDegreeInRads,
1221  double tiltDegreeInRads,
1222  AcGiArcType arcType
1223  ) const ;
1224 
1225  virtual Adesk::Boolean polypoint(const Adesk::UInt32 nbPoints,
1226  const AcGePoint3d* pVertexList,
1227  const AcGeVector3d* pNormal = NULL,
1228  const Adesk::LongPtr * pSubEntMarkers = NULL) const;
1229 
1230  virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints,
1231  const AcGePoint3d* pVertexList
1232  ) const;
1233 
1234  virtual Adesk::Boolean mesh (const Adesk::UInt32 rows,
1235  const Adesk::UInt32 columns,
1236  const AcGePoint3d* pVertexList,
1237  const AcGiEdgeData* pEdgeData = NULL,
1238  const AcGiFaceData* pFaceData = NULL,
1239  const AcGiVertexData* pVertexData = NULL,
1240  const bool bAutoGenerateNormals = true
1241  ) const;
1242 
1243  virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex,
1244  const AcGePoint3d* pVertexList,
1245  const Adesk::UInt32 faceListSize,
1246  const Adesk::Int32* pFaceList,
1247  const AcGiEdgeData* pEdgeData = NULL,
1248  const AcGiFaceData* pFaceData = NULL,
1249  const AcGiVertexData* pVertexData = NULL,
1250  const struct resbuf* pResBuf = NULL,
1251  const bool bAutoGenerateNormals = true
1252  ) const;
1253 
1254 
1255  virtual Adesk::Boolean text (const AcGePoint3d& position,
1256  const AcGeVector3d& normal,
1257  const AcGeVector3d& direction,
1258  const double height,
1259  const double width,
1260  const double oblique,
1261  const ACHAR* pMsg
1262  ) const;
1263 
1264  virtual Adesk::Boolean text(const AcGePoint3d& position,
1265  const AcGeVector3d& normal,
1266  const AcGeVector3d& direction,
1267  const ACHAR* pMsg,
1268  const Adesk::Int32 length,
1269  const Adesk::Boolean raw,
1270  const AcGiTextStyle &pTextStyle
1271  ) const;
1272 
1273 
1274  virtual Adesk::Boolean xline (const AcGePoint3d& one_xline_point,
1275  const AcGePoint3d& a_different_xline_point
1276  ) const;
1277 
1278  virtual Adesk::Boolean ray(const AcGePoint3d& rays_starting_point,
1279  const AcGePoint3d& a_different_ray_point
1280  ) const;
1281 
1282  virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf,
1283  Adesk::UInt32 fromIndex = 0,
1284  Adesk::UInt32 numSegs = 0
1285  ) const;
1286 
1287  virtual void getModelToWorldTransform(AcGeMatrix3d &pMatrix) const;
1288  virtual void getWorldToModelTransform(AcGeMatrix3d &pMatrix) const;
1289  virtual void setExtents(AcGePoint3d *pNewExtents) const;
1290 
1291  virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal);// Uses arbitrary Axis algorythm
1292  virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat);
1293  virtual Adesk::Boolean popModelTransform();
1294 
1295  virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary);
1296  virtual void popClipBoundary();
1297  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset);
1298  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset);
1299  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents);
1300  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents);
1301  virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior);
1302 
1303 private:
1304 
1305  // Back pointer stored to the WorldDraw object. This class
1306  // uses it to store the ShellData when the shell member
1307  // function is called.
1308  HAcGiWorldDraw* m_pHAcGiWorldDraw;
1309  unsigned int m_uiOpenSegmentCount;
1310 };
1311 
1312 
1313 // This class applies attributes to subsequently drawn AcGi geometry
1314 // primitives.
1315 class HAcGiSubEntityTraits: public AcGiSubEntityTraits
1316 {
1317 public:
1318 
1319  ACRX_DECLARE_MEMBERS(HAcGiSubEntityTraits);
1320 
1323 
1324  virtual void setColor(const Adesk::UInt16 color);
1325  virtual void setTrueColor(const AcCmEntityColor& color);
1326  virtual void setLayer(const AcDbObjectId layerId);
1327  virtual void setLineType(const AcDbObjectId linetypeId);
1328  virtual void setSelectionMarker(const Adesk::LongPtr markerId);
1329  virtual void setFillType(const AcGiFillType fillType);
1330  virtual void setLineWeight(const AcDb::LineWeight lw);
1331  virtual void setLineTypeScale(double dScale = 1.0);
1332 
1333 
1334  virtual Adesk::UInt16 color() const;
1335  virtual AcCmEntityColor trueColor() const;
1336  virtual AcDbObjectId layerId() const;
1337  virtual AcDbObjectId lineTypeId() const;
1338  virtual AcGiFillType fillType() const;
1339  virtual AcDb::LineWeight lineWeight() const;
1340  virtual double lineTypeScale() const;
1341 
1342  virtual void setThickness(double dThickness);
1343  virtual double thickness() const;
1344 
1345 private:
1346 
1347  Adesk::UInt16 mColorIndex;
1348  AcCmEntityColor mTrueColor;
1349  AcDbObjectId mLayerId;
1350  AcDbObjectId mLinetypeId;
1351  Adesk::LongPtr mMarkerId;
1352  AcGiFillType mFillType;
1353  AcDb::LineWeight mLineWeight;
1354  double mLineTypeScale;
1355  double mThickness;
1356 };
1357 
1358 // Some entities (particularly custom entities from AEC etc.) are viewport entities
1359 // They don't have any visual reprentation in world (worldDraw fails), but they
1360 // have a specific representation in viewport. Hence we are deriving from ViewportDraw
1361 // --- SK 17 mar 09
1362 
1363 class HAcGiViewportDraw : public AcGiViewportDraw
1364 {
1365 public:
1366  ACRX_DECLARE_MEMBERS(HAcGiViewportDraw);
1367  HAcGiViewportDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity);
1368  ~HAcGiViewportDraw();
1369 
1370  virtual AcGiViewport& viewport() const;
1371  virtual AcGiViewportGeometry& geometry() const;
1372  virtual Adesk::UInt32 sequenceNumber() const;
1373  virtual Adesk::Boolean isValidId(const Adesk::ULongPtr acgiId) const;
1374  virtual AcDbObjectId viewportObjectId() const;
1375 
1376  virtual AcGiRegenType regenType() const ;
1377  virtual Adesk::Boolean regenAbort() const {return Adesk::kFalse;};
1378  virtual AcGiSubEntityTraits& subEntityTraits() const ;
1379  virtual AcGiGeometry * rawGeometry() const ;
1380  virtual Adesk::Boolean isDragging() const {return Adesk::kFalse;};
1381 
1382  // This function operates against the current active viewport
1383  //
1384  virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const {return 0.00;};
1385  virtual Adesk::UInt32 numberOfIsolines() const {return 0;};
1386 
1387  virtual AcGiContext * context();
1388 
1389  HDWGImporter* GetHDWGImporter() const;
1390  AcDbEntity* GetCurrentEntity() const;
1391 
1392 private:
1393  AcGiViewport* mpVp;
1394  AcGiViewportGeometry* mpVpGeometry;
1395  AcDbObjectId mpObjId;
1396 
1397  AcGiSubEntityTraits* mpSubEntityTraits;
1398  AcGiContext* mpContext;
1399  AcGiRegenType mRegenType;
1400 
1401  HDWGImporter* m_pDWGImporter;
1402  AcDbEntity* m_pAcDbEntity;
1403 
1404 };
1405 
1406 class HAcGiViewportGeometry : public AcGiViewportGeometry
1407 {
1408 public:
1409  ACRX_DECLARE_MEMBERS(HAcGiViewportGeometry);
1410  HAcGiViewportGeometry(HAcGiViewportDraw* pViewportDraw);
1412  virtual Adesk::Boolean polylineEye(const Adesk::UInt32 nbPoints,
1413  const AcGePoint3d* pPoints) const ;
1414  virtual Adesk::Boolean polygonEye(const Adesk::UInt32 nbPoints,
1415  const AcGePoint3d* pPoints) const ;
1416 
1417  virtual Adesk::Boolean polylineDc(const Adesk::UInt32 nbPoints,
1418  const AcGePoint3d* pPoints) const;
1419  virtual Adesk::Boolean polygonDc(const Adesk::UInt32 nbPoints,
1420  const AcGePoint3d* pPoints) const ;
1421 
1422 
1423  virtual Adesk::Boolean rasterImageDc(
1424  const AcGePoint3d& origin,
1425  const AcGeVector3d& u,
1426  const AcGeVector3d& v,
1427  const AcGeMatrix2d& pixelToDc,
1428  AcDbObjectId entityId,
1429  AcGiImageOrg imageOrg,
1430  Adesk::UInt32 imageWidth,
1431  Adesk::UInt32 imageHeight,
1432  Adesk::Int16 imageColorDepth,
1433  Adesk::Boolean transparency,
1434  ImageSource source,
1435  const AcGeVector3d& unrotatedU,
1436  const AcGiImageOrg origionalImageOrg,
1437  const AcGeMatrix2d& unrotatedPixelToDc,
1438  const Adesk::UInt32 unrotatedImageWidth,
1439  const Adesk::UInt32 unrotatedImageHeight
1440  ) const;
1441 
1442  virtual Adesk::Boolean ownerDrawDc(
1443  long vpnumber,
1444  long left,
1445  long top,
1446  long right,
1447  long bottom,
1448  const OwnerDraw* pOwnerDraw
1449  ) const;
1450 
1451  virtual Adesk::Boolean ownerDraw3d(
1452  AcGePoint3d& minBounds,
1453  AcGePoint3d& maxBounds,
1454  OwnerDraw3d* pOwnerDraw
1455  ) const ;
1456 
1457 
1458  // Coordinate transformations.
1459  //
1460  virtual void getModelToWorldTransform(AcGeMatrix3d&) const ;
1461  virtual void getWorldToModelTransform(AcGeMatrix3d&) const ;
1462 
1463  virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal) ;// Uses arbitrary Axis algorythm
1464  virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat) ;
1465  virtual Adesk::Boolean popModelTransform() ;
1466 
1467  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset);
1468  virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset);
1469  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents);
1470  virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents);
1471  virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior);
1472 
1473 
1474  // For drawing various primitives.
1475  //
1476  virtual Adesk::Boolean circle(const AcGePoint3d& center,
1477  const double radius,
1478  const AcGeVector3d& normal) const ;
1479 
1480  virtual Adesk::Boolean circle(const AcGePoint3d&, const AcGePoint3d&,
1481  const AcGePoint3d&) const ;
1482 
1483  virtual Adesk::Boolean circularArc(const AcGePoint3d& center,
1484  const double radius,
1485  const AcGeVector3d& normal,
1486  const AcGeVector3d& startVector,
1487  const double sweepAngle,
1488  const AcGiArcType arcType = kAcGiArcSimple) const ;
1489 
1490  virtual Adesk::Boolean circularArc(const AcGePoint3d& start,
1491  const AcGePoint3d& point,
1492  const AcGePoint3d& end,
1493  const AcGiArcType arcType = kAcGiArcSimple) const ;
1494 
1495  virtual Adesk::Boolean polyline(const Adesk::UInt32 nbPoints,
1496  const AcGePoint3d* pVertexList,
1497  const AcGeVector3d* pNormal = NULL,
1498  Adesk::LongPtr lBaseSubEntMarker = -1) const ;
1499 
1500  virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const {return Adesk::kTrue;}
1501 
1502  virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines,
1503  const AcGiPolyline* pPolylines) const {return Adesk::kTrue;}
1504  virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices,
1505  const Adesk::UInt32* numPolygonPositions,
1506  const AcGePoint3d* polygonPositions,
1507  const Adesk::UInt32* numPolygonPoints,
1508  const AcGePoint3d* polygonPoints,
1509  const AcCmEntityColor* outlineColors = NULL,
1510  const AcGiLineType* outlineTypes = NULL,
1511  const AcCmEntityColor* fillColors = NULL,
1512  const AcCmTransparency* fillOpacities = NULL) const {return Adesk::kTrue;}
1513  virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource,
1514  const AcGePoint3d& position,
1515  const AcGeVector3d& u, //orientation and magnitude of width
1516  const AcGeVector3d& v, //orientation and magnitude of height
1517  TransparencyMode transparencyMode = kTransparency8Bit
1518  ) const {return Adesk::kTrue;}
1519  virtual Adesk::Boolean rowOfDots(int count,
1520  const AcGePoint3d& start,
1521  const AcGeVector3d& step
1522  ) const {return Adesk::kTrue;}
1523  virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center,
1524  const AcGeVector3d& normal,
1525  double majorAxisLength,
1526  double minorAxisLength,
1527  double startDegreeInRads,
1528  double endDegreeInRads,
1529  double tiltDegreeInRads,
1530  AcGiArcType arcType = kAcGiArcSimple
1531  ) const {return Adesk::kTrue;}
1532 
1533  virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints,
1534  const AcGePoint3d* pVertexList) const ;
1535 
1536  virtual Adesk::Boolean mesh(const Adesk::UInt32 rows,
1537  const Adesk::UInt32 columns,
1538  const AcGePoint3d* pVertexList,
1539  const AcGiEdgeData* pEdgeData = NULL,
1540  const AcGiFaceData* pFaceData = NULL,
1541  const AcGiVertexData* pVertexData = NULL,
1542  const bool bAutoGenerateNormals = true
1543  ) const ;
1544 
1545  virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex,
1546  const AcGePoint3d* pVertexList,
1547  const Adesk::UInt32 faceListSize,
1548  const Adesk::Int32* pFaceList,
1549  const AcGiEdgeData* pEdgeData = NULL,
1550  const AcGiFaceData* pFaceData = NULL,
1551  const AcGiVertexData* pVertexData = NULL,
1552  const struct resbuf* pResBuf = NULL,
1553  const bool bAutoGenerateNormals = true
1554  ) const ;
1555 
1556  virtual Adesk::Boolean text(const AcGePoint3d& position,
1557  const AcGeVector3d& normal,
1558  const AcGeVector3d& direction,
1559  const double height,
1560  const double width,
1561  const double oblique,
1562  const ACHAR* pMsg) const ;
1563 
1564  virtual Adesk::Boolean text(const AcGePoint3d& position,
1565  const AcGeVector3d& normal,
1566  const AcGeVector3d& direction,
1567  const ACHAR* pMsg,
1568  const Adesk::Int32 length,
1569  const Adesk::Boolean raw,
1570  const AcGiTextStyle &pTextStyle
1571  ) const ;
1572 
1573  virtual Adesk::Boolean xline(const AcGePoint3d&,
1574  const AcGePoint3d&) const ;
1575 
1576  virtual Adesk::Boolean ray(const AcGePoint3d&,
1577  const AcGePoint3d&) const ;
1578 
1579  virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf,
1580  Adesk::UInt32 fromIndex = 0,
1581  Adesk::UInt32 numSegs = 0
1582  ) const ;
1583 
1584  virtual Adesk::Boolean draw(AcGiDrawable*) const ;
1585 
1586  virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary);
1587  virtual void popClipBoundary() ;
1588 
1589 private:
1590  // Back pointer stored to the ViewPortDraw object. This class
1591  // uses it to store the ShellData when the shell member
1592  // function is called. ---- SK 18 mar 09
1593  HAcGiViewportDraw* m_pHAcGiViewportDraw;
1594  unsigned int m_uiOpenSegmentCount;
1595 
1596 };
1597 class HAcGiViewport : public AcGiViewport
1598 {
1599 public:
1600  ACRX_DECLARE_MEMBERS(AcGiViewport);
1601  HAcGiViewport(HInputHandlerOptions const * options = 0);
1602  ~HAcGiViewport();
1603 
1604  virtual void getModelToEyeTransform(AcGeMatrix3d& mx) const;
1605  virtual void getEyeToModelTransform(AcGeMatrix3d& mx) const;
1606  virtual void getWorldToEyeTransform(AcGeMatrix3d& mx) const;
1607  virtual void getEyeToWorldTransform(AcGeMatrix3d& mx) const;
1608 
1609  virtual Adesk::Boolean isPerspective() const;
1610  virtual Adesk::Boolean doPerspective(AcGePoint3d&) const;
1611  virtual Adesk::Boolean doInversePerspective(AcGePoint3d&) const;
1612 
1613  virtual void getNumPixelsInUnitSquare(const AcGePoint3d& givenWorldpt,
1614  AcGePoint2d& pixelArea,
1615  bool includePerspective = true) const;
1616 
1617  virtual void getCameraLocation(AcGePoint3d& location) const;
1618  virtual void getCameraTarget(AcGePoint3d& target) const;
1619  virtual void getCameraUpVector(AcGeVector3d& upVector) const;
1620 
1621  virtual Adesk::ULongPtr viewportId() const;
1622  virtual Adesk::Int16 acadWindowId() const;
1623  virtual void getViewportDcCorners(AcGePoint2d& lower_left,
1624  AcGePoint2d& upper_right) const;
1625 
1626  virtual Adesk::Boolean getFrontAndBackClipValues(Adesk::Boolean& clip_front,
1627  Adesk::Boolean& clip_back,
1628  double& front,
1629  double& back) const;
1630  virtual double linetypeScaleMultiplier() const;
1631  virtual double linetypeGenerationCriteria() const;
1632 
1633  virtual AcGeVector3d viewDir() const;
1634 
1635 private:
1636  HInputHandlerOptions const * inputOptions;
1637  AcGePoint3d cameraTarget;
1638  AcGePoint3d cameraLocation;
1639  AcGeVector3d cameraUpVector;
1640 };
1641 
1643 {
1644 public:
1645  HDrawOrderHandler(AcDbBlockTableRecord * pRecord)
1646  {
1647  m_pRecord = pRecord;
1648  m_pObj = 0;
1649  };
1650 
1651  int Open();
1652  bool GetNextEntity(AcDbEntity *& pOutEnt);
1653  int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, HC_KEY block_key, HDWG_3dgsImporter * importer);
1654  int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, TK_Open_Segment * include_seg_handler, HDWG_BStreamImporter * importer);
1655  void Close();
1656 
1657 protected:
1658  AcDbBlockTableRecord * m_pRecord;
1659  AcDbSortentsTable * m_pObj;
1660  AcDbObjectIdArray objArray;
1661  int m_iIndex;
1662  AcDbBlockTableRecordIterator * m_pRecordIter;
1663 
1664 };
1665 
1666 wchar_t * h_dwg_wcsdup(wchar_t const * const wcs);
1667 
1668 // Inline functions for HDWG_BStreamImporter calling opcodehandlers
1669 inline int HDWG_BStreamImporter::STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * seg_name) const
1670 {
1671  // Caller have to delete open_seg_handler, in this version.
1672  open_seg_handler->SetSegment(seg_name);
1673  TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1674  H_ASSERT(hdwg_status == TK_Normal);
1675  return 1;
1676 }
1677 
1678 inline int HDWG_BStreamImporter::STREAM_Open_Segment(const char * seg_name) const
1679 {
1680  // Caller don't have to delete open_seg_handler, in this version.
1681  TK_Open_Segment* open_seg_handler = new TK_Open_Segment;
1682  open_seg_handler->SetSegment(seg_name);
1683  TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1684  H_ASSERT(hdwg_status == TK_Normal);
1685  delete open_seg_handler;
1686 
1687  return 1;
1688 }
1689 
1690 inline int HDWG_BStreamImporter:: STREAM_Close_Segment() const
1691 {
1692  TK_Close_Segment *close_seg_handler = new TK_Close_Segment;
1693  TK_Status hdwg_status = WriteObject(close_seg_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1694  H_ASSERT(hdwg_status == TK_Normal);
1695  delete close_seg_handler;
1696 
1697  return 1;
1698 }
1699 
1700 inline int HDWG_BStreamImporter:: STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const
1701 {
1702  //HC_Set_Visibility("off");
1703  TK_Visibility *vis_handler = new TK_Visibility();
1704  vis_handler->SetGeometry(Geom_Bit);
1705  if(ifOn)
1706  vis_handler->SetValue(1);
1707  else
1708  vis_handler->SetValue(0);
1709  TK_Status hdwg_status = WriteObject(vis_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1710  H_ASSERT(hdwg_status == TK_Normal);
1711  delete vis_handler;
1712 
1713  return 1;
1714 }
1715 
1716 inline int HDWG_BStreamImporter:: STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const
1717 {
1718  //HC_Set_Heuristics("xxxx");
1719  TK_Heuristics* heuristic_handler = new TK_Heuristics;
1720  heuristic_handler->SetMask( Heuristic_Bit);
1721  heuristic_handler->SetValue( Heuristic_Bit);
1722  TK_Status hdwg_status = WriteObject(heuristic_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1723  H_ASSERT(hdwg_status == TK_Normal);
1724  delete heuristic_handler;
1725 
1726  return 1;
1727 }
1728 inline int HDWG_BStreamImporter:: STREAM_Write_Object(BBaseOpcodeHandler * handler) const
1729 {
1730  TK_Status hdwg_status = WriteObject(handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize);
1731  H_ASSERT(hdwg_status == TK_Normal);
1732  delete handler;
1733 
1734  return 1;
1735 }
1736 
1737 #ifdef H_PACK_8
1738 #pragma pack(pop)
1739 #endif
1740 
1741 #endif
Definition: HDWGHelper.h:310
Definition: HDWGHelper.h:1093
Definition: HDWGHelper.h:1315
Definition: HDWGHelper.h:616
Definition: HIOUtilityDWG.h:46
Definition: HDWGHelper.h:430
#define HC_KEY
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:537
Definition: HDWGHelper.h:1597
Definition: HIOUtilityDWG.h:120
Definition: HDWGHelper.h:640
Definition: HDWGHelper.h:347
Definition: HDWGHelper.h:859
Definition: HDWGHelper.h:1363
Definition: HDWGHelper.h:662
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:121
Definition: HIOManager.h:245
Definition: HDWGHelper.h:1135
A header file containing the HIO classes for passing to HBaseView::FileInput and HBaseView::FileOutpu...
Definition: HDWGHelper.h:1152
Definition: HDWGHelper.h:1406
Definition: HDWGHelper.h:1642