00001 // (C) Copyright 1996,1998 by Autodesk, Inc. 00002 // 00003 // Permission to use, copy, modify, and distribute this software in 00004 // object code form for any purpose and without fee is hereby granted, 00005 // provided that the above copyright notice appears in all copies and 00006 // that both that copyright notice and the limited warranty and 00007 // restricted rights notice below appear in all supporting 00008 // documentation. 00009 // 00010 // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 00011 // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF 00012 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. 00013 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE 00014 // UNINTERRUPTED OR ERROR FREE. 00015 // 00016 // Use, duplication, or disclosure by the U.S. Government is subject to 00017 // restrictions set forth in FAR 52.227-19 (Commercial Computer 00018 // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 00019 // (Rights in Technical Data and Computer Software), as applicable. 00020 // 00021 // $Id$ 00022 // 00023 00024 #ifndef HDWG_HELPER_H_ 00025 #define HDWG_HELPER_H_ 1 00026 00027 #ifdef H_PACK_8 00028 #pragma pack(push) 00029 #pragma pack(8) 00030 #endif 00031 00032 00033 //#include <wchar.h> 00034 #include <map> 00035 #include <vector> 00036 #include <string> 00037 00038 #include "acgi.h" 00039 #include "hc.h" 00040 #include "HIOManager.h" 00041 #include "HTools.h" 00042 #include "HUtility.h" 00043 00044 #include "BStream.h" 00045 #include "BOpcodeShell.h" 00046 00047 #include "sorttab.h " 00048 00049 #include "windows.h" 00050 #include "stdlib.h" 00051 #include "stdio.h" 00052 #include "string.h" 00053 #include "time.h" 00054 00055 #include "dbimage.h" 00056 #include "imgdef.h" 00057 #include "imgent.h" 00058 00059 #include "dbobjptr.h" 00060 #include "acdblmgr.h" 00061 #include "dbmleader.h" // For AcDbMLeader 00062 #include "dbspfilt.h" // For Clips on blockref 00063 #include "dbole.h" 00064 #include "dbtrans.h" // For Transaction objects 00065 00066 00067 00068 #define _t(str) L##str 00069 typedef unsigned int UINT; 00070 00071 00072 00073 class HInputHandlerOptions; 00074 class HIOConnectorDWG; 00075 class HIOUtilityDWG; 00076 00077 class AcDbMText; 00078 struct AcDbMTextFragment; 00079 class AcDbCircle; 00080 class AcDbLeader; 00081 class AcDbMLeader; 00082 class AcDbDimension; 00083 class AcDbMaterial; 00084 class AcDbPoint; 00085 class AcDbMInsertBlock; 00086 class AcDbLine; 00087 class AcDbXline; 00088 class AcDbRay; 00089 class AcDbPolygonMesh; 00090 00091 #ifdef WIN32 00092 class AcDbTable; 00093 #endif 00094 00095 typedef int BOOL; 00096 00097 // Functions to condition strings form database to be used as segment name. 00098 void condition_string_for_segment_name(char* zString); 00099 void condition_string_for_segment_name(wchar_t* zString); 00100 void condition_string_for_user_options(char* zString); 00101 void condition_string_for_user_options(wchar_t* zString); 00102 void condition_string_for_special_characters(wchar_t* zString); 00103 00104 // To get the rectangle from bounding box 00105 void Get_Image_Rectangle_For_Shell(AcDbRasterImage* pEnt, HPoint * Rect); 00106 // AcDbRatsterImage import Functions 00107 void InsertClipRegion(AcDbRasterImage* pEnt, BStreamFileToolkit * pBStreamtk = 0); 00108 int GetImageFileName(AcDbRasterImageDef* ImageDef, char * pFilePath, char * pImageName) ; 00109 // Camera settings in viewports 00110 int GetCameraForInitialView(HCamera &camera , AcDbViewportTableRecord* pRecord); 00112 void SetRenderMode(HInputHandlerOptions * pInputOptions, AcDbViewportTableRecord* pRecord); 00113 // text transformation matrix 00114 void GetModelingMatrixForText(float my_center[], float my_path1[], float my_norm1[], float h_matrix_trans[]); 00115 // For Stream Writing 00116 TK_Status WriteObject(BBaseOpcodeHandler * handler, BStreamFileToolkit * tk, FILE * fp, char * buffer, int size); 00117 // For Getting Layout views and clip regions 00118 void get_layout_data(AcDbObjectId viewPortId,AcDbDatabase *pAcDbDatabase,HPoint *ClipPoint,float *matrix,int *no_ClipPoint,AcCmEntityColor* entityColor, bool * is_On); 00119 // Convert to lower case 00120 void ConverToLower(char * to_lower); 00121 // Check for file existance 00122 bool hio_dwg_check_file_exist(const wchar_t * full_filepath); 00123 // For Clips on BlockRefs 00124 BOOL insertClip(AcDbBlockReference * ref, BStreamFileToolkit * pBStreamtk = 0); 00125 // Checking for invalid entities (having large and invalid values) 00126 bool CheckForInvalidExtents(AcDbEntity * pEnt); 00127 00128 inline void extract_matrix(AcGeMatrix3d const & in_mat, float out_mat[16]) 00129 { 00130 AcGeMatrix3d trans_matrix(in_mat); 00131 trans_matrix.transposeIt(); 00132 for (int i = 0; i < 4; i++) 00133 { 00134 for (int j = 0; j < 4; j++) 00135 { 00136 out_mat[4 * i + j] = (float)trans_matrix(i, j); 00137 } 00138 } 00139 } 00140 00141 00142 // define HIODWG_IMPORT_POINTS if you want to import the 0 dimensional entities viz. AcDbPoint etc. 00143 //#define HIODWG_IMPORT_POINTS 00144 00145 #define HDWG_PI ((double)3.14159265358979323846) 00146 #define HDWG_F_PI ((float)HDWG_PI) 00147 #define H_MM_TO_POINTS 2.83465f 00148 #define H_LWDEFAULT AcDb::kLnWt025; 00149 #define HDWG_MATERIALS_LIBRARY_SEGMENT "DWG_MATERIALS_STYLE_LIBRARY" 00150 #define HIODWG_SCRATCH_SEGMENT "/include library/dwg_scratch_segment" 00151 00152 #define GetBValueFromRGBM(rgbm) ((unsigned char)(rgbm)) 00153 #define GetGValueFromRGBM(rgbm) ((unsigned char)((unsigned long)(rgbm)>>8)) 00154 #define GetRValueFromRGBM(rgbm) ((unsigned char)((unsigned long)(rgbm)>>16)) 00155 #define GetMValueFromRGBM(rgbm) ((unsigned char)((unsigned long)(rgbm)>>24)) 00156 00157 #define countof(array) sizeof(array)/sizeof(array[0]) 00158 #define nEntNames countof(EntityList) 00159 00160 00161 #define MARKER_OPCODE_START_FILL -1 00162 #define MARKER_OPCODE_RESTART_FILL -2 00163 #define MARKER_OPCODE_END_FILL -3 00164 #define MARKER_OPCODE_ELLIPSE -4 00165 #define MARKER_OPCODE_CIRCULAR_ARC -5 00166 #define MARKER_OPCODE_INFINITE_LINE -6 00167 #define MARKER_OPCODE_INFINITE_RAY -7 00168 #define MARKER_OPCODE_START_CONTRAST_COLOR -8 00169 #define MARKER_OPCODE_START_NORMAL_COLOR -9 00170 #define MARKER_OPCODE_START_RGB_COLOR -10 00171 #define MARKER_OPCODE_START_INDEXED_COLOR -11 00172 #define MARKER_OPCODE_TERMINATE 0 00173 #define MARKER_OPCODE_POINT 1 00174 #define MARKER_OPCODE_LINE_2 2 00175 #define MARKER_OPCODE_LINE_3 3 00176 #define MARKER_OPCODE_LINE_4 4 00177 #define MARKER_OPCODE_LINE_5 5 00178 #define MARKER_OPCODE_LINE_6 6 00179 #define MARKER_OPCODE_LINE_7 7 00180 #define MARKER_OPCODE_LINE_8 8 00181 #define MARKER_OPCODE_LINE_9 9 00182 #define MARKER_OPCODE_LINE_10 10 00183 #define MARKER_OPCODE_LINE_11 11 00184 #define MARKER_OPCODE_LINE_12 12 00185 #define MARKER_OPCODE_LINE_13 13 00186 00187 00188 const char PDMODE_4[] = // a half sized vertical bar (upper half) 00189 { 00190 100, 0, 0, 00191 MARKER_OPCODE_LINE_2, 0, 0, 00192 0, 100, 00193 MARKER_OPCODE_TERMINATE 00194 }; 00195 00196 const char PDMODE_34[] = // a circle with + sign. + spills outside the circle 00197 { 00198 100, 0, 0, 00199 MARKER_OPCODE_LINE_2, -100, 0, 00200 100, 0, 00201 MARKER_OPCODE_LINE_2, 0, -100, 00202 0, 100, 00203 MARKER_OPCODE_ELLIPSE, -60, -60, 60, 60, 00204 00205 MARKER_OPCODE_TERMINATE 00206 }; 00207 00208 const char PDMODE_35[] = // a circle with x sign. x spills outside the circle 00209 { 00210 100, 0, 0, 00211 MARKER_OPCODE_LINE_2, -100, -100, 00212 100, 100, 00213 MARKER_OPCODE_LINE_2, -100, 100, 00214 100, -100, 00215 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00216 00217 MARKER_OPCODE_TERMINATE 00218 }; 00219 00220 const char PDMODE_36[] = // a circle over a half-vertical-bar 00221 { 00222 100, 0, 0, 00223 MARKER_OPCODE_LINE_2, 0, 0, 00224 0, 100, 00225 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00226 00227 MARKER_OPCODE_TERMINATE 00228 }; 00229 00230 const char PDMODE_66[] = // a square over + sign (+ spilling out a bit) 00231 { 00232 100, 0, 0, 00233 MARKER_OPCODE_LINE_2, -100, 0, 00234 100, 0, 00235 MARKER_OPCODE_LINE_2, 0, -100, 00236 0, 100, 00237 MARKER_OPCODE_LINE_5, -60, -60, -60, 60, 00238 60, 60, 60, -60, -60, -60, 00239 MARKER_OPCODE_TERMINATE 00240 }; 00241 00242 const char PDMODE_68[] = // a square over half-vertical-bar 00243 { 00244 100, 0, 0, 00245 MARKER_OPCODE_LINE_2, 0, 0, 00246 0, 100, 00247 MARKER_OPCODE_LINE_5, -100, -100, -100, 100, 00248 100, 100, 100, -100,-100, -100, 00249 MARKER_OPCODE_TERMINATE 00250 }; 00251 00252 const char PDMODE_96[] = // a square and a circle over a dot 00253 { 00254 100, 0, 0, 00255 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00256 MARKER_OPCODE_LINE_5, -100, -100, -100, 100, 00257 100, 100, 100, -100,-100, -100, 00258 MARKER_OPCODE_POINT, 0, 0, 00259 MARKER_OPCODE_TERMINATE 00260 }; 00261 00262 const char PDMODE_97[] = // a square and a circle 00263 { 00264 100, 0, 0, 00265 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00266 MARKER_OPCODE_LINE_5, -100, -100, -100, 100, 00267 100, 100, 100, -100,-100, -100, 00268 MARKER_OPCODE_TERMINATE 00269 }; 00270 00271 const char PDMODE_98[] = // a square and a circle over + (spillage of +) 00272 { 00273 100, 0, 0, 00274 MARKER_OPCODE_LINE_2, -100, 0, 00275 100, 0, 00276 MARKER_OPCODE_LINE_2, 0, -100, 00277 0, 100, 00278 MARKER_OPCODE_LINE_5, -60, -60, -60, 60, 00279 60, 60, 60, -60, -60, -60, 00280 MARKER_OPCODE_ELLIPSE, -60, -60, 60, 60, 00281 MARKER_OPCODE_TERMINATE 00282 }; 00283 00284 const char PDMODE_99[] = // a square and a circle over a cross 00285 { 00286 100, 0, 0, 00287 MARKER_OPCODE_LINE_2, -100, -100, 00288 100, 100, 00289 MARKER_OPCODE_LINE_2, -100, 100, 00290 100, -100, 00291 MARKER_OPCODE_LINE_5, -100, -100, -100, 100, 00292 100, 100, 100, -100, -100, -100, 00293 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00294 MARKER_OPCODE_TERMINATE 00295 }; 00296 00297 const char PDMODE_100[] = // a square and a circle over a half-vertical-bar 00298 { 00299 100, 0, 0, 00300 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00301 MARKER_OPCODE_LINE_2, 0, 0, 00302 0, 100, 00303 MARKER_OPCODE_LINE_5, -100, -100, -100, 100, 00304 100, 100, 100, -100, -100, -100, 00305 MARKER_OPCODE_ELLIPSE, -100, -100, 100, 100, 00306 MARKER_OPCODE_TERMINATE 00307 }; 00308 00309 00310 struct HIODWG_GLYPH 00311 { 00312 Adesk::Int16 iSymbolPDMODE; // PDMODE value (Ref. to AutoCAD command reference 00313 char *pSymbolName; // Corresponding HOOPS marker symbol name or glyph name 00314 const char *pSymbolDefinition; // Glyph definition array. 0 for standard HOOPS markers 00315 unsigned int nSybolDefinitionSize; // Size of Glyph definition array. 0 for standard HOOPS markers 00316 int opcode_index; // Corresponding opcode enum. 00317 }; 00318 00319 static HIODWG_GLYPH GlyphTable[] = 00320 { 00321 0, ".", 0, 0, TKO_Marker_Dot, 00322 2, "+", 0, 0, TKO_Marker_Plus, 00323 3, "x", 0, 0, TKO_Marker_X, 00324 4, "PDMODE_4", PDMODE_4, countof(PDMODE_4), -1, 00325 00326 32, "(.)", 0, 0, TKO_Marker_Circle_Dot, 00327 33, "O", 0, 0, TKO_Marker_Circle , 00328 34, "PDMODE_34", PDMODE_34, countof(PDMODE_34), -1, 00329 35, "PDMODE_35", PDMODE_35, countof(PDMODE_35), -1, 00330 36, "PDMODE_36", PDMODE_36, countof(PDMODE_36), -1, 00331 00332 64, "[.]", 0, 0, TKO_Marker_Box_Dot, 00333 65, "[]", 0, 0, TKO_Marker_Box, 00334 66, "PDMODE_66", PDMODE_66, countof(PDMODE_66), -1, 00335 67, "[x]", 0, 0, TKO_Marker_Box_X , 00336 68, "PDMODE_68", PDMODE_68, countof(PDMODE_68), -1, 00337 00338 96, "PDMODE_96", PDMODE_96, countof(PDMODE_96), -1, 00339 97, "PDMODE_97", PDMODE_97, countof(PDMODE_97), -1, 00340 98, "PDMODE_98", PDMODE_98, countof(PDMODE_98), -1, 00341 99, "PDMODE_99", PDMODE_99, countof(PDMODE_99), -1, 00342 100, "PDMODE_100", PDMODE_100, countof(PDMODE_100),-1 00343 }; 00344 00345 00346 00347 struct ENTNAMES 00348 { 00349 const wchar_t *pName; 00350 void (* func)(AcDbEntity *); 00351 }; 00352 00353 static ENTNAMES EntityList[] = 00354 { 00355 // import explicitly 00356 L"AcDbBlockReference", 0, //0 00357 L"AcDbMInsertBlock", 0, //1 00358 00359 // import both shaded & wireframe modes 00360 L"AcDbBlockTableRecord", 0, //2 00361 L"AcDb3dSolid", 0, //3 00362 L"AcDbBody", 0, //4 00363 L"AcDbFace", 0, //5 00364 L"AcDbRegion", 0, //6 00365 L"AcDbShape", 0, //7 00366 L"AcDbSolid", 0, //8 00367 L"AcDbFace", 0, //9 00368 L"AcDbPolyFaceMesh", 0, //10 00369 L"AcDbPolygonMesh", 0, //11 00370 L"AcDbExtrudedSurface", 0, //12 00371 00372 // import wireframe mode only 00373 L"AcDbHatch", 0, //13 00374 L"AcDbMText", 0, //14 00375 L"AcDbText", 0, //15 00376 L"AcDbCurve", 0, //16 00377 L"AcDb2dPolyline", 0, //17 00378 L"AcDb3dPolyline", 0, //18 00379 L"AcDbArc", 0, //19 00380 L"AcDbCircle", 0, //20 00381 L"AcDbEllipse", 0, //21 00382 L"AcDbLeader", 0, //22 00383 L"AcDbLine", 0, //23 00384 L"AcDbPolyline", 0, //24 00385 L"AcDbRay", 0, //25 00386 L"AcDbSpline", 0, //26 00387 L"AcDbXline", 0, //27 00388 L"AcDbVertex", 0, //28 00389 L"AcDb2dVertex", 0, //29 00390 L"AcDb3dPolylineVertex", 0, //30 00391 L"AcDbMline", 0, //31 00392 L"AcDbPoint", 0, //32 00393 L"AcDbPolyFaceMeshVertex", 0, //33 00394 L"AcDbPolygonMeshVertex", 0, //34 00395 L"AcDbBlockBegin", 0, //35 00396 L"AcDbBlockEnd", 0, //36 00397 L"AcDbFcf", 0, //37 00398 L"AcDbFrame", 0, //38 00399 L"AcDbOleFrame", 0, //39 00400 L"AcDbOle2Frame", 0, //40 00401 L"AcDbRasterImage", 0, //41 00402 L"AcDbZombieEntity", 0, //42 00403 L"AcDbSequenceEnd", 0, //43 00404 L"AcDbAttribute", 0, //44 00405 L"AcDbTrace", 0, //45 00406 L"AcDbFaceRecord", 0, //46 00407 L"AcDbViewport", 0, //47 00408 L"AcDb2LineAngularDimension", 0, //48 00409 L"AcDb3PointAngularDimension", 0, //49 00410 L"AcDbAlignedDimension", 0, //50 00411 L"AcDbDiametricDimension", 0, //51 00412 L"AcDbOrdinateDimension", 0, //52 00413 L"AcDbRadialDimension", 0, //53 00414 L"AcDbRotatedDimension", 0, //54 00415 L"AcDbArcDimension", 0, //55 00416 L"AcDbDimension", 0, //56 00417 L"AcDbTable", 0, //57 00418 L"AcDbWipeout", 0, //58 00419 00420 // DON'T import: things which I don't think make sense for importing to HOOPS 00421 // for example attribute definitions - they do have some visual representation 00422 // which we don't want to draw 00423 L"AcDbAttributeDefinition", 0, //59 00424 L"AecDbSlab", 0, //60 00425 00426 }; 00427 00428 00429 // Base class DWG Importer. Implements common activities viz. ACAD database traversal etc. 00430 class HDWGImporter 00431 { 00432 public: 00433 HDWGImporter(HIOUtilityDWG* pDWGInputHandler); 00434 virtual ~HDWGImporter(); 00435 00436 // must have functions for any DWG Importers - Import DWG File or AcDbDatabase 00437 virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0) = 0; 00438 virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0) = 0; 00439 00440 virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText) = 0; 00441 00442 virtual Adesk::Boolean import_circle( const AcGePoint3d& pt1, 00443 const AcGePoint3d& pt2, 00444 const AcGePoint3d& pt3, 00445 AcDbEntity* pDatabaseEntity) const = 0; 00446 00447 Adesk::Boolean import_circle( const AcGePoint3d& center, 00448 const double radius, 00449 const AcGeVector3d& normal, 00450 AcDbEntity* pDatabaseEntity 00451 ) const; 00452 00453 virtual Adesk::Boolean import_circular_arc( const AcGePoint3d& center, 00454 const double radius, 00455 const AcGeVector3d& normal, 00456 const AcGeVector3d& startVector, 00457 const double sweepAngle, 00458 const AcGiArcType arcType, 00459 AcDbEntity* pDatabaseEntity 00460 ) const = 0; 00461 00462 virtual Adesk::Boolean import_circular_arc( const AcGePoint3d& start, 00463 const AcGePoint3d& point, 00464 const AcGePoint3d& end, 00465 const AcGiArcType arcType, 00466 AcDbEntity* pDatabaseEntity 00467 ) const = 0; 00468 00469 virtual Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints, 00470 const AcGePoint3d* pVertexList, 00471 AcDbEntity* pDatabaseEntity 00472 ) const = 0; 00473 00474 virtual Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints, 00475 const AcGePoint3d* pVertexList, 00476 const AcGeVector3d* pNormal, 00477 Adesk::LongPtr lBaseSubEntMarker, 00478 AcDbEntity* pDatabaseEntity) const = 0; 00479 00480 virtual Adesk::Boolean import_pline(const AcDbPolyline& lwBuf, 00481 Adesk::UInt32 fromIndex, 00482 Adesk::UInt32 numSegs, 00483 AcDbEntity* pDatabaseEntity) const = 0; 00484 00485 Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints, 00486 const AcGePoint3d* pVertexList, 00487 const AcGeVector3d* pNormal, 00488 const Adesk::LongPtr * pSubEntMarkers, 00489 AcDbEntity* pDatabaseEntity) const 00490 { /*TODO: Implement this function*/ return Adesk::kFalse;}; 00491 00492 virtual Adesk::Boolean import_mesh( const Adesk::UInt32 rows, 00493 const Adesk::UInt32 columns, 00494 const AcGePoint3d* pVertexList, 00495 const AcGiEdgeData* pEdgeData, 00496 const AcGiFaceData* pFaceData, 00497 const AcGiVertexData* pVertexData, 00498 const bool bAutoGenerateNormals, 00499 AcDbEntity* pDatabaseEntity 00500 ) const = 0; 00501 00502 virtual Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex, 00503 const AcGePoint3d* pVertexList, 00504 const Adesk::UInt32 faceListSize, 00505 const Adesk::Int32* pFaceList, 00506 const AcGiEdgeData* pEdgeData, 00507 const AcGiFaceData* pFaceData , 00508 const AcGiVertexData* pVertexData, 00509 const struct resbuf* pResBuf, 00510 const bool bAutoGenerateNormals, 00511 AcDbEntity* pDatabaseEntity 00512 ) const = 0; 00513 00514 virtual Adesk::Boolean import_text( const AcGePoint3d& position, 00515 const AcGeVector3d& normal, 00516 const AcGeVector3d& direction, 00517 const double height, 00518 const double width, 00519 const double oblique, 00520 const ACHAR* pMsg, 00521 AcDbEntity* pDatabaseEntity 00522 ) const = 0; 00523 00524 virtual Adesk::Boolean import_text( const AcGePoint3d& position, 00525 const AcGeVector3d& normal, 00526 const AcGeVector3d& direction, 00527 const ACHAR* pMsg, 00528 const Adesk::LongPtr length, 00529 const Adesk::Boolean raw, 00530 const AcGiTextStyle &pTextStyle, 00531 AcDbEntity* pDatabaseEntity 00532 ) const=0 ; 00533 00534 virtual void pushModelTransform(AcGeMatrix3d const & xMat) = 0; 00535 virtual void popModelTransform() = 0; 00536 00537 00538 double get_deviation() const { return m_Deviation; } 00539 00540 void set_deviation( double dev ) { m_Deviation = dev; } 00541 00542 int get_num_isolines() const { return m_numIsolines; } 00543 00544 void setIs2dEntity(bool val) { m_bIs2DEntity = val;} 00545 00546 HInputHandlerOptions const * GetInputOptions() const { return m_pInputOptions; } 00547 00548 protected: 00549 00550 void importAcDbPoint(AcDbPoint *pAcDbPoint); 00551 void importAcDbMText(AcDbMText* pAcDbMText); 00552 void importAcDbCircle(AcDbCircle* pAcDbCircle); 00553 void importAcDbMaterial(AcDbMaterial *pAcDbMaterial); 00554 00555 bool shouldOverrideMaterial(AcDbMaterial * pAcDbMaterial); 00556 bool hasValidRGBValues(AcCmEntityColor const * in_color, float & out_red, float & out_green, float & out_blue) const; 00557 00558 virtual void importXdata(AcDbEntity *pEnt)=0; 00559 virtual void importXdata(resbuf *pBuf) = 0; 00560 void import_hyperlinks(AcDbEntity *pEnt); 00561 virtual void attachDWGHandle(AcDbEntity *pEnt)=0; 00562 00563 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); 00564 virtual void get_entity_transparency(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, int &alpha_value, bool& is_by_block ); 00565 virtual void get_entity_visibility(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, bool& is_visible ); 00566 virtual void get_entity_line_weight(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord, float& ret_line_weight, bool& is_by_block); 00567 00568 HIOUtilityDWG* m_pDWGInputHandler; 00569 HIOConnectorDWG* m_pConnectivityInfo; 00570 HC_KEY m_modelKey; 00571 wchar_t* m_pDWGTextureDirectory; 00572 bool m_bDrawWireframe; 00573 bool m_bIs3D; 00574 double m_Deviation; 00575 bool m_bImportXData; 00576 bool m_bImportWireframeForBrep; 00577 int m_numIsolines; 00578 struct vlist_s* m_listRegAppNames; 00579 struct vlist_s* m_listEntityType; 00580 bool m_bAttachDWGHandles; 00581 bool m_bAmIsolidHatch; 00582 00583 HInputHandlerOptions * m_pInputOptions; 00584 00585 float m_wmin[3]; 00586 float m_wmax[3]; 00587 int m_nLine_count; 00588 int m_nPoint_count; 00589 int m_nCircle_count; 00590 int m_nArc_count; 00591 int m_nSolid_count; 00592 int m_nSolid3D_count; 00593 int m_nGroup_count; 00594 int m_nPloyLine_count; 00595 int m_nShell_count; 00596 int m_nText_count; 00597 int m_nPloygon_count; 00598 00599 wchar_t const * m_fileName; 00600 std::map<int, wchar_t*> layer_record; 00601 std::map<int, wchar_t*> group_record; 00602 std::map<int, wchar_t*> entity_record; 00603 std::map<int, wchar_t*> block_ref_record; 00604 std::vector<AcDbObjectId> m_VpIdCount; 00605 int m_BlockRefIndex; 00606 struct vlist_s* m_listDWGLayouts; 00607 bool m_bImportAllLayouts; 00608 bool m_bCleanVpList; 00609 bool m_bIgnoreOffEntity; 00610 double m_dGlobalScaleFactor; 00611 bool m_bIs2DEntity; 00612 bool m_bIsSHXFont; 00613 bool m_bDWGInsertMeshesAsShells; 00614 bool m_bDisableDWGDrawOrder; 00615 00616 struct dimensionAttributes 00617 { 00618 dimensionAttributes() 00619 { 00620 r = -1; 00621 g = -1; 00622 b = -1; 00623 isVisible = false; 00624 } 00625 dimensionAttributes(float red, float green, float blue, bool visibility) 00626 { 00627 r = red; 00628 g = green; 00629 b = blue; 00630 isVisible = visibility; 00631 } 00632 float r, g, b; 00633 bool isVisible; 00634 }; 00635 00636 mutable std::map<std::wstring, std::string> m_fontmap; 00637 void populate_fontmap() const; 00638 00639 /* dimensionData and m_dimensions are used to regenerate missing dimensions at runtime */ 00640 struct dimensionData 00641 { 00642 dimensionData(HC_KEY dKey, HC_KEY sKey, AcDbHandle h, AcDbBlockTableRecord * btr) 00643 { 00644 destinationKey = dKey; 00645 sourceKey = sKey; 00646 dimensionHandle = h; 00647 dimensionBTR = btr; 00648 dAtt; 00649 } 00650 00651 dimensionAttributes dAtt; 00652 HC_KEY destinationKey; // key to the segment where the dimension will be inserted 00653 HC_KEY sourceKey; // key to the segment containing the recomputed dimension BTR 00654 AcDbHandle dimensionHandle; // handle of the dimension object 00655 AcDbBlockTableRecord * dimensionBTR; // recomputed dimension BTR 00656 }; 00657 std::vector<dimensionData> m_dimensions; 00658 virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector) = 0; 00659 }; 00660 00661 // DWG import implementation for HIOUtilityDWG interface 00662 class HDWG_3dgsImporter : public HDWGImporter 00663 { 00664 public: 00665 HDWG_3dgsImporter(HIOUtilityDWG* pDWGInputHandler) : HDWGImporter(pDWGInputHandler) 00666 { 00667 m_CurrentLayoutName = 0; 00668 }; 00669 ~HDWG_3dgsImporter(){;}; 00670 00671 virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector); 00672 00673 virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0); 00674 virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0); 00675 00676 virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText); 00677 virtual void importAcDbDimension(AcDbDimension* pAcDbDimension); 00678 00679 Adesk::Boolean import_circle( const AcGePoint3d& pt1, 00680 const AcGePoint3d& pt2, 00681 const AcGePoint3d& pt3, 00682 AcDbEntity* pDatabaseEntity) const; 00683 00684 Adesk::Boolean import_circle( const AcGePoint3d& center, 00685 const double radius, 00686 const AcGeVector3d& normal, 00687 AcDbEntity* pDatabaseEntity 00688 ) const; 00689 00690 Adesk::Boolean import_circular_arc( const AcGePoint3d& center, 00691 const double radius, 00692 const AcGeVector3d& normal, 00693 const AcGeVector3d& startVector, 00694 const double sweepAngle, 00695 const AcGiArcType arcType, 00696 AcDbEntity* pDatabaseEntity 00697 ) const; 00698 00699 Adesk::Boolean import_circular_arc( const AcGePoint3d& start, 00700 const AcGePoint3d& point, 00701 const AcGePoint3d& end, 00702 const AcGiArcType arcType, 00703 AcDbEntity* pDatabaseEntity 00704 ) const; 00705 00706 Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints, 00707 const AcGePoint3d* pVertexList, 00708 AcDbEntity* pDatabaseEntity 00709 ) const; 00710 HC_KEY HDWG_3dgsImporter::extrude_pline(AcGePoint3dArray dwgPoints, AcGeVector3d normal, double line_thickness) const; 00711 Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints, 00712 const AcGePoint3d* pVertexList, 00713 const AcGeVector3d* pNormal, 00714 Adesk::LongPtr lBaseSubEntMarker, 00715 AcDbEntity* pDatabaseEntity) const; 00716 00717 void import_extruded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const; 00718 void import_exploded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const; 00719 void import_fancy_pline(const AcDbPolyline& lwBuf, AcDbEntity* pDatabaseEntity) const; 00720 00721 Adesk::Boolean import_pline(const AcDbPolyline& lwBuf, 00722 Adesk::UInt32 fromIndex, 00723 Adesk::UInt32 numSegs, 00724 AcDbEntity* pDatabaseEntity) const; 00725 HC_KEY extrude_elliptical_arc ( 00726 const double *ofst, 00727 const double thickness, 00728 const double *p0, 00729 const double *p1, 00730 const double *p2, 00731 double start, 00732 double end) const; 00733 00734 Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints, 00735 const AcGePoint3d* pVertexList, 00736 const AcGeVector3d* pNormal, 00737 const Adesk::LongPtr * pSubEntMarkers, 00738 AcDbEntity* pDatabaseEntity) const 00739 { /*TODO: Implement this function*/ return Adesk::kFalse;}; 00740 00741 Adesk::Boolean import_mesh( const Adesk::UInt32 rows, 00742 const Adesk::UInt32 columns, 00743 const AcGePoint3d* pVertexList, 00744 const AcGiEdgeData* pEdgeData, 00745 const AcGiFaceData* pFaceData, 00746 const AcGiVertexData* pVertexData, 00747 const bool bAutoGenerateNormals, 00748 AcDbEntity* pDatabaseEntity 00749 ) const; 00750 00751 Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex, 00752 const AcGePoint3d* pVertexList, 00753 const Adesk::UInt32 faceListSize, 00754 const Adesk::Int32* pFaceList, 00755 const AcGiEdgeData* pEdgeData, 00756 const AcGiFaceData* pFaceData , 00757 const AcGiVertexData* pVertexData, 00758 const struct resbuf* pResBuf, 00759 const bool bAutoGenerateNormals, 00760 AcDbEntity* pDatabaseEntity 00761 ) const; 00762 00763 Adesk::Boolean import_text( const AcGePoint3d& position, 00764 const AcGeVector3d& normal, 00765 const AcGeVector3d& direction, 00766 const double height, 00767 const double width, 00768 const double oblique, 00769 const ACHAR* pMsg, 00770 AcDbEntity* pDatabaseEntity 00771 ) const; 00772 00773 Adesk::Boolean import_text( const AcGePoint3d& position, 00774 const AcGeVector3d& normal, 00775 const AcGeVector3d& direction, 00776 const ACHAR* pMsg, 00777 const Adesk::LongPtr length, 00778 const Adesk::Boolean raw, 00779 const AcGiTextStyle &pTextStyle, 00780 AcDbEntity* pDatabaseEntity 00781 ) const; 00782 00783 HC_KEY import_text( float my_center[], 00784 float my_path1[], 00785 float my_norm1[], 00786 wchar_t const * text, 00787 const char* alignment 00788 ) const; // deprecated 00789 00790 HC_KEY apply_transforms_and_insert_text(float my_center[], 00791 float my_path1[], 00792 float my_norm1[], 00793 wchar_t const * text, 00794 const char* alignment 00795 ) const; 00796 00797 void pushModelTransform(AcGeMatrix3d const & xMat); 00798 void popModelTransform(); 00799 00800 private: 00801 00802 void importAcDbEntity(AcDbEntity* pEnt, HC_KEY parent_seg = INVALID_KEY, bool for_blk_ref=false); 00803 void importAcDbEntity(AcDbEntity *pEnt, const bool& draw_shaded, 00804 HC_KEY parent_seg = INVALID_KEY, bool for_blk_ref=false); 00805 00806 void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, HC_KEY parent_seg = INVALID_KEY, int mib_col=0, int mib_row=0); 00807 void importAcDbMInsertBlock(AcDbMInsertBlock *pAcDbMInsertBlock,HC_KEY parent_seg); 00808 00809 void importAcDbPoint(AcDbPoint *pAcDbPoint); 00810 void importAcDbCircle(AcDbCircle* pAcDbCircle); 00811 void importAcDbMaterial(AcDbMaterial *pAcDbMaterial, AcGiMapper mapper); 00812 void importLBGEData(); 00813 void importAcDbLine(AcDbLine *pAcDbLine); 00814 void importAcDb3dPolyline(AcDb3dPolyline *pAcDbPolyline); 00815 void importAcDbXline(AcDbXline* pXline); 00816 void importAcDbRay(AcDbRay* pRay); 00817 void importAcDbViewport(AcDbViewport* pViewport); 00818 void importAcDbRasterImage(AcDbRasterImage* pEnt); 00819 void importAcDbMLeader(AcDbMLeader* pEnt); 00820 #ifdef WIN32 00821 void importAcDbTable(AcDbTable* pAcDbTable); 00822 #endif 00823 void importXdata(AcDbEntity *pEnt); 00824 void importBlockTableRecord(AcDbBlockTableRecord* pRecord); 00825 void attachDWGHandle(AcDbEntity *pEnt); 00826 00827 void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, HC_KEY& style_key); 00828 00829 virtual void importXdata(resbuf *pBuf); 00830 void import_hyperlinks(AcDbEntity *pEnt); 00831 void set_marker_settings(const Adesk::Int16 db_pdmode, const double db_pdsize ); 00832 00833 void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord); 00834 void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale); 00835 void import_layout(AcDbDatabase *pAcDbDatabase); 00836 void update_layout_list(AcDbDatabase* pAcDbDatabase); 00837 void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase); 00838 void InsertMaskRegion(AcDbRasterImage* pEnt); 00839 00840 00841 HC_KEY GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew); 00842 HC_KEY GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt); 00843 00844 00845 wchar_t* m_CurrentLayoutName; 00846 std::map<void * , HC_KEY> m_Segments_map; 00847 std::map<void * , HC_KEY>::const_iterator m_keymap_ieterator; 00848 00849 // For progress bar 00850 int m_nTotalEntities; 00851 int m_nCurrentEntityCount; 00852 void GetNoOfEntitiesForProgressBar(AcDbDatabase* pAcDbDatabase); 00853 00854 friend class HDrawOrderHandler; 00855 00856 }; 00857 00858 class HDWG_BStreamImporter : public HDWGImporter 00859 { 00860 public: 00861 HDWG_BStreamImporter(HIOUtilityDWG* pDWGInputHandler, bool is_xref); 00862 ~HDWG_BStreamImporter(); 00863 00864 virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector); 00865 00867 // Bstream Toolkit 00868 BStreamFileToolkit *m_pBStreamtk; 00869 char *m_pBStreamBuffer; 00870 int m_nBStreamBuffSize; 00871 int m_nBStreamBuffCount; 00872 FILE *m_pHSFFile; 00873 struct vhash_s * m_vhash_StyleSegName_IsPresentFlag; 00874 struct vhash_s * m_vhash_SegName_IsPresentFlag; 00876 00877 virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0); 00878 virtual bool importXRefs(AcDbDatabase* pHostDb, HC_KEY modelKey, HInputHandlerOptions * pInputOptions); 00879 virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0); 00880 00881 virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText); 00882 virtual void importAcDbDimension(AcDbDimension* pAcDbDimension, dimensionAttributes dimAtt); 00883 void import_exploded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const; 00884 void import_extruded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const; 00885 void import_fancy_pline(const AcDbPolyline& lwBuf, AcDbEntity* pDatabaseEntity) const; 00886 void extrude_pline(AcGePoint3dArray dwgPoints, AcGeVector3d normal, double line_thickness) const; 00887 00888 Adesk::Boolean import_circle( const AcGePoint3d& pt1, 00889 const AcGePoint3d& pt2, 00890 const AcGePoint3d& pt3, 00891 AcDbEntity* pDatabaseEntity) const; 00892 00893 Adesk::Boolean import_circle( const AcGePoint3d& center, 00894 const double radius, 00895 const AcGeVector3d& normal, 00896 AcDbEntity* pDatabaseEntity 00897 ) const; 00898 00899 Adesk::Boolean import_circular_arc( const AcGePoint3d& center, 00900 const double radius, 00901 const AcGeVector3d& normal, 00902 const AcGeVector3d& startVector, 00903 const double sweepAngle, 00904 const AcGiArcType arcType, 00905 AcDbEntity* pDatabaseEntity 00906 ) const; 00907 00908 Adesk::Boolean import_circular_arc( const AcGePoint3d& start, 00909 const AcGePoint3d& point, 00910 const AcGePoint3d& end, 00911 const AcGiArcType arcType, 00912 AcDbEntity* pDatabaseEntity 00913 ) const; 00914 00915 Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints, 00916 const AcGePoint3d* pVertexList, 00917 AcDbEntity* pDatabaseEntity 00918 ) const; 00919 00920 Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints, 00921 const AcGePoint3d* pVertexList, 00922 const AcGeVector3d* pNormal, 00923 Adesk::LongPtr lBaseSubEntMarker, 00924 AcDbEntity* pDatabaseEntity) const; 00925 00926 Adesk::Boolean import_pline(const AcDbPolyline& lwBuf, 00927 Adesk::UInt32 fromIndex, 00928 Adesk::UInt32 numSegs, 00929 AcDbEntity* pDatabaseEntity) const; 00930 00931 Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints, 00932 const AcGePoint3d* pVertexList, 00933 const AcGeVector3d* pNormal, 00934 const Adesk::LongPtr * pSubEntMarkers, 00935 AcDbEntity* pDatabaseEntity) const 00936 { /*TODO: Implement this function*/ return Adesk::kFalse;}; 00937 00938 Adesk::Boolean import_mesh( const Adesk::UInt32 rows, 00939 const Adesk::UInt32 columns, 00940 const AcGePoint3d* pVertexList, 00941 const AcGiEdgeData* pEdgeData, 00942 const AcGiFaceData* pFaceData, 00943 const AcGiVertexData* pVertexData, 00944 const bool bAutoGenerateNormals, 00945 AcDbEntity* pDatabaseEntity 00946 ) const; 00947 00948 Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex, 00949 const AcGePoint3d* pVertexList, 00950 const Adesk::UInt32 faceListSize, 00951 const Adesk::Int32* pFaceList, 00952 const AcGiEdgeData* pEdgeData, 00953 const AcGiFaceData* pFaceData , 00954 const AcGiVertexData* pVertexData, 00955 const struct resbuf* pResBuf, 00956 const bool bAutoGenerateNormals, 00957 AcDbEntity* pDatabaseEntity 00958 ) const; 00959 00960 Adesk::Boolean import_text( const AcGePoint3d& position, 00961 const AcGeVector3d& normal, 00962 const AcGeVector3d& direction, 00963 const double height, 00964 const double width, 00965 const double oblique, 00966 const ACHAR* pMsg, 00967 AcDbEntity* pDatabaseEntity 00968 ) const; 00969 00970 Adesk::Boolean import_text( const AcGePoint3d& position, 00971 const AcGeVector3d& normal, 00972 const AcGeVector3d& direction, 00973 const ACHAR* pMsg, 00974 const Adesk::LongPtr length, 00975 const Adesk::Boolean raw, 00976 const AcGiTextStyle &pTextStyle, 00977 AcDbEntity* pDatabaseEntity 00978 ) const; 00979 00980 HC_KEY apply_transforms_and_insert_text(float my_center[], 00981 float my_path1[], 00982 float my_norm1[], 00983 wchar_t const * text, 00984 const int alignment) const; 00985 00986 void pushModelTransform(AcGeMatrix3d const & xMat); 00987 void popModelTransform(); 00988 00989 inline BOOL GetConnectivityCompression() { return bConnectivityCompression; }; 00990 inline void SetConnectivityCompression(BOOL val) { bConnectivityCompression = val; } 00991 inline BOOL GetVertexCompression() { return bVertexCompression; } 00992 inline void SetVertexCompression(BOOL val) { bVertexCompression = val; } 00993 inline BOOL GetNormalCompression() { return bNormalCompression; } 00994 inline void SetNormalCompression(BOOL val) { bNormalCompression = val; } 00995 inline BOOL GetImageCompression() { return bImageCompression; } 00996 inline void SetImageCompression(BOOL val) { bImageCompression = val; } 00997 inline int GetVertexCompressionBits() { return m_VertexCompressionBits; } 00998 inline void SetVertexCompressionBits(int val) { m_VertexCompressionBits = val; } 00999 inline int GetNormalCompressionBits() { return m_NormalCompressionBits; } 01000 inline void SetNormalCompressionBits(int val) { m_NormalCompressionBits = val; } 01001 inline int GetImageCompressionValue() { return m_ImageCompressionValue; } 01002 inline void SetImageCompressionValue(int val) { m_ImageCompressionValue = val; } 01003 01004 01005 protected: 01006 01007 void importAcDbEntity(AcDbEntity* pEnt, TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0); 01008 void importAcDbEntity(AcDbEntity *pEnt, const bool& draw_shaded, int entityType, 01009 TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0); 01010 01011 01012 void importBlockTable(AcDbBlockTable* pBlockTable); 01013 void importAcDbMInsertBlock(AcDbMInsertBlock *pAcDbMInsertBlock,TK_Open_Segment * Open_seg_handler); 01014 //void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, HC_KEY parent_seg = INVALID_KEY); 01015 void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, TK_Open_Segment* Open_seg_handler = NULL, 01016 int mib_col = 0 , int mib_row = 0); 01017 01018 void importAcDbPoint(AcDbPoint *pAcDbPoint); 01019 void importAcDbCircle(AcDbCircle* pAcDbCircle); 01020 void importAcDbMaterial(AcDbMaterial *pAcDbMaterial, AcGiMapper mapper); 01021 void importLBGEData(); 01022 void importAcDbLine(AcDbLine *pAcDbLine); 01023 void importAcDbXline(AcDbXline* pXline); 01024 void importAcDb3dPolyline(AcDb3dPolyline *pAcDbPolyline); 01025 void importAcDbRay(AcDbRay* pRay); 01026 void importBlockTableRecord(AcDbBlockTableRecord* pRecord, dimensionData * dData = 0); 01027 void importAcDbViewport(AcDbViewport* pViewport); 01028 void importAcDbRasterImage(AcDbRasterImage* pEnt); 01029 void importAcDbMLeader(AcDbMLeader* pEnt); 01030 #ifdef WIN32 01031 void importAcDbTable(AcDbTable* pAcDbTable); 01032 #endif 01033 01034 void importXdata(AcDbEntity *pEnt); 01035 void attachDWGHandle(AcDbEntity *pEnt); 01036 void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, TK_Open_Segment* &parent_seg); 01037 TK_Open_Segment* GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew); 01038 TK_Open_Segment* GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt); 01039 01040 //void bstream_CreateWireframeCircleWithEllipse(const HPoint &x1, const HPoint &x2, const HPoint &x3 ); 01041 01042 virtual void importXdata(resbuf *pBuf); 01043 void import_hyperlinks(AcDbEntity *pEnt); 01044 void set_marker_settings(const Adesk::Int16 db_pdmode,const double db_pdsize ); 01045 void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord); 01046 void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale); 01047 void InsertMaskRegion(AcDbRasterImage* pEnt); 01048 void import_layout(AcDbDatabase *pAcDbDatabase); 01049 void update_layout_list(AcDbDatabase* pAcDbDatabase); 01050 void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase); 01051 01052 BOOL bConnectivityCompression; 01053 BOOL bVertexCompression; 01054 BOOL bNormalCompression; 01055 BOOL bImageCompression; 01056 int m_VertexCompressionBits; 01057 int m_NormalCompressionBits; 01058 int m_ImageCompressionValue; 01059 bool m_bMergeEntityShells; 01060 time_t m_mtImportStart; 01061 wchar_t * m_pFileName; 01062 bool m_bAmIXref; 01063 bool m_bScratchSegOpen; 01064 wchar_t *m_pXref_hsf_path; 01065 mutable bool m_bShellWithFaceColor; 01066 01067 01068 private: 01069 // small fuctions for opening/ closing segments, visibility, heuristics, 01070 // unicode/user opts settings, etc. 01071 // Functions to reduce code size - perform TK operations 01072 int STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * segname) const; 01073 int STREAM_Open_Segment(const char * segname) const; 01074 int STREAM_Close_Segment() const; 01075 int STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const; 01076 int STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const; 01077 int STREAM_Write_Object(BBaseOpcodeHandler * handler) const; 01078 static struct _stat m_MasterHsfFileTime; 01079 01080 std::map<void * , const char *> m_Segments_map; 01081 std::map<void * ,const char *>::const_iterator m_iterator_segmap; 01082 01083 friend class HDrawOrderHandler; 01084 }; 01085 01086 // Custom worldDraw object is sent in a call to the 01087 // entitiy's worldDraw function. The entity will then 01088 // end up calling the worldGeometry class's shell function. 01089 // In this case, the HAcGiWorldGeometry's shell member 01090 // function will be called. 01091 class HAcGiWorldDraw : public AcGiWorldDraw 01092 { 01093 public: 01094 01095 ACRX_DECLARE_MEMBERS(HAcGiWorldDraw); 01096 01097 HAcGiWorldDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity); 01098 virtual ~HAcGiWorldDraw(); 01099 01100 virtual AcGiRegenType regenType() const; 01101 virtual Adesk::Boolean regenAbort() const; 01102 virtual AcGiSubEntityTraits& subEntityTraits() const; 01103 virtual AcGiGeometry * rawGeometry() const; 01104 virtual AcGiWorldGeometry& geometry() const; 01105 virtual Adesk::Boolean isDragging() const; 01106 virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const; 01107 virtual Adesk::UInt32 numberOfIsolines() const; 01108 virtual AcGiContext * context(); 01109 01110 void setDeviation(double); 01111 void setRegenType(const AcGiRegenType&); 01112 01113 HDWGImporter* GetHDWGImporter() const; 01114 AcDbEntity* GetCurrentEntity() const; 01115 01116 private: 01117 01118 AcGiSubEntityTraits* mpSubEntityTraits; 01119 AcGiWorldGeometry* mpWorldGeometry; 01120 AcGiContext* mpContext; 01121 AcGiRegenType mRegenType; 01122 01123 HDWGImporter* m_pDWGImporter; 01124 AcDbEntity* m_pAcDbEntity; 01125 }; 01126 01127 // AcGiContext abstracts out the commonality between 01128 // AcGiViewportDraw and AcGiWorldDraw. This allows you 01129 // to code graphics routines in terms of AcGiContext that 01130 // will work in either case. To maintain their original signatures, 01131 // AcGiWorldDraw and AcGiViewportDraw now derive from AcGiContext. 01132 // Only the database member function is implemented. 01133 class HAcGiContext : public AcGiContext 01134 { 01135 public: 01136 01137 ACRX_DECLARE_MEMBERS(HAcGiContext); 01138 HAcGiContext(); 01139 virtual ~HAcGiContext(); 01140 01141 Adesk::Boolean isPsOut() const; 01142 Adesk::Boolean isPlotGeneration() const; 01143 AcDbDatabase * database() const; 01144 bool isBoundaryClipping() const; 01145 01146 }; 01147 01148 // This class contains the view independent, model coordinate, 01149 // 3D geometry methods for our custom world geometry class. 01150 class HAcGiWorldGeometry: public AcGiWorldGeometry 01151 { 01152 public: 01153 01154 ACRX_DECLARE_MEMBERS(HAcGiWorldGeometry); 01155 01156 HAcGiWorldGeometry(HAcGiWorldDraw* pWorldDraw); 01157 ~HAcGiWorldGeometry(); 01158 01159 virtual Adesk::Boolean draw(AcGiDrawable*) const; 01160 01161 virtual Adesk::Boolean circle (const AcGePoint3d& center, 01162 const double radius, 01163 const AcGeVector3d& normal 01164 ) const; 01165 01166 virtual Adesk::Boolean circle (const AcGePoint3d& pt1, 01167 const AcGePoint3d& pt2, 01168 const AcGePoint3d& pt3 01169 ) const; 01170 01171 virtual Adesk::Boolean circularArc(const AcGePoint3d& center, 01172 const double radius, 01173 const AcGeVector3d& normal, 01174 const AcGeVector3d& startVector, 01175 const double sweepAngle, 01176 const AcGiArcType arcType = kAcGiArcSimple 01177 ) const; 01178 01179 virtual Adesk::Boolean circularArc(const AcGePoint3d& start, 01180 const AcGePoint3d& point, 01181 const AcGePoint3d& end, 01182 const AcGiArcType arcType = kAcGiArcSimple 01183 ) const; 01184 01185 virtual Adesk::Boolean polyline (const Adesk::UInt32 nbPoints, 01186 const AcGePoint3d* pVertexList, 01187 const AcGeVector3d* pNormal = NULL, 01188 Adesk::LongPtr lBaseSubEntMarker = -1) const; 01189 01190 virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const ; 01191 01192 virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines, 01193 const AcGiPolyline* pPolylines) const; 01194 virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices, 01195 const Adesk::UInt32* numPolygonPositions, 01196 const AcGePoint3d* polygonPositions, 01197 const Adesk::UInt32* numPolygonPoints, 01198 const AcGePoint3d* polygonPoints, 01199 const AcCmEntityColor* outlineColors = NULL, 01200 const AcGiLineType* outlineTypes = NULL, 01201 const AcCmEntityColor* fillColors = NULL, 01202 const AcCmTransparency* fillOpacities = NULL) const ; 01203 virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource, 01204 const AcGePoint3d& position, 01205 const AcGeVector3d& u, //orientation and magnitude of width 01206 const AcGeVector3d& v, //orientation and magnitude of height 01207 TransparencyMode transparencyMode 01208 ) const ; 01209 virtual Adesk::Boolean rowOfDots(int count, 01210 const AcGePoint3d& start, 01211 const AcGeVector3d& step 01212 ) const ; 01213 virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center, 01214 const AcGeVector3d& normal, 01215 double majorAxisLength, 01216 double minorAxisLength, 01217 double startDegreeInRads, 01218 double endDegreeInRads, 01219 double tiltDegreeInRads, 01220 AcGiArcType arcType 01221 ) const ; 01222 01223 virtual Adesk::Boolean polypoint(const Adesk::UInt32 nbPoints, 01224 const AcGePoint3d* pVertexList, 01225 const AcGeVector3d* pNormal = NULL, 01226 const Adesk::LongPtr * pSubEntMarkers = NULL) const; 01227 01228 virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints, 01229 const AcGePoint3d* pVertexList 01230 ) const; 01231 01232 virtual Adesk::Boolean mesh (const Adesk::UInt32 rows, 01233 const Adesk::UInt32 columns, 01234 const AcGePoint3d* pVertexList, 01235 const AcGiEdgeData* pEdgeData = NULL, 01236 const AcGiFaceData* pFaceData = NULL, 01237 const AcGiVertexData* pVertexData = NULL, 01238 const bool bAutoGenerateNormals = true 01239 ) const; 01240 01241 virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex, 01242 const AcGePoint3d* pVertexList, 01243 const Adesk::UInt32 faceListSize, 01244 const Adesk::Int32* pFaceList, 01245 const AcGiEdgeData* pEdgeData = NULL, 01246 const AcGiFaceData* pFaceData = NULL, 01247 const AcGiVertexData* pVertexData = NULL, 01248 const struct resbuf* pResBuf = NULL, 01249 const bool bAutoGenerateNormals = true 01250 ) const; 01251 01252 01253 virtual Adesk::Boolean text (const AcGePoint3d& position, 01254 const AcGeVector3d& normal, 01255 const AcGeVector3d& direction, 01256 const double height, 01257 const double width, 01258 const double oblique, 01259 const ACHAR* pMsg 01260 ) const; 01261 01262 virtual Adesk::Boolean text(const AcGePoint3d& position, 01263 const AcGeVector3d& normal, 01264 const AcGeVector3d& direction, 01265 const ACHAR* pMsg, 01266 const Adesk::Int32 length, 01267 const Adesk::Boolean raw, 01268 const AcGiTextStyle &pTextStyle 01269 ) const; 01270 01271 01272 virtual Adesk::Boolean xline (const AcGePoint3d& one_xline_point, 01273 const AcGePoint3d& a_different_xline_point 01274 ) const; 01275 01276 virtual Adesk::Boolean ray(const AcGePoint3d& rays_starting_point, 01277 const AcGePoint3d& a_different_ray_point 01278 ) const; 01279 01280 virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf, 01281 Adesk::UInt32 fromIndex = 0, 01282 Adesk::UInt32 numSegs = 0 01283 ) const; 01284 01285 virtual void getModelToWorldTransform(AcGeMatrix3d &pMatrix) const; 01286 virtual void getWorldToModelTransform(AcGeMatrix3d &pMatrix) const; 01287 virtual void setExtents(AcGePoint3d *pNewExtents) const; 01288 01289 virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal);// Uses arbitrary Axis algorythm 01290 virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat); 01291 virtual Adesk::Boolean popModelTransform(); 01292 01293 virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary); 01294 virtual void popClipBoundary(); 01295 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset); 01296 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset); 01297 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents); 01298 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents); 01299 virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior); 01300 01301 private: 01302 01303 // Back pointer stored to the WorldDraw object. This class 01304 // uses it to store the ShellData when the shell member 01305 // function is called. 01306 HAcGiWorldDraw* m_pHAcGiWorldDraw; 01307 unsigned int m_uiOpenSegmentCount; 01308 }; 01309 01310 01311 // This class applies attributes to subsequently drawn AcGi geometry 01312 // primitives. 01313 class HAcGiSubEntityTraits: public AcGiSubEntityTraits 01314 { 01315 public: 01316 01317 ACRX_DECLARE_MEMBERS(HAcGiSubEntityTraits); 01318 01319 HAcGiSubEntityTraits(); 01320 ~HAcGiSubEntityTraits(); 01321 01322 virtual void setColor(const Adesk::UInt16 color); 01323 virtual void setTrueColor(const AcCmEntityColor& color); 01324 virtual void setLayer(const AcDbObjectId layerId); 01325 virtual void setLineType(const AcDbObjectId linetypeId); 01326 virtual void setSelectionMarker(const Adesk::LongPtr markerId); 01327 virtual void setFillType(const AcGiFillType fillType); 01328 virtual void setLineWeight(const AcDb::LineWeight lw); 01329 virtual void setLineTypeScale(double dScale = 1.0); 01330 01331 01332 virtual Adesk::UInt16 color() const; 01333 virtual AcCmEntityColor trueColor() const; 01334 virtual AcDbObjectId layerId() const; 01335 virtual AcDbObjectId lineTypeId() const; 01336 virtual AcGiFillType fillType() const; 01337 virtual AcDb::LineWeight lineWeight() const; 01338 virtual double lineTypeScale() const; 01339 01340 virtual void setThickness(double dThickness); 01341 virtual double thickness() const; 01342 01343 private: 01344 01345 Adesk::UInt16 mColorIndex; 01346 AcCmEntityColor mTrueColor; 01347 AcDbObjectId mLayerId; 01348 AcDbObjectId mLinetypeId; 01349 Adesk::LongPtr mMarkerId; 01350 AcGiFillType mFillType; 01351 AcDb::LineWeight mLineWeight; 01352 double mLineTypeScale; 01353 double mThickness; 01354 }; 01355 01356 // Some entities (particularly custom entities from AEC etc.) are viewport entities 01357 // They don't have any visual reprentation in world (worldDraw fails), but they 01358 // have a specific representation in viewport. Hence we are deriving from ViewportDraw 01359 // --- SK 17 mar 09 01360 01361 class HAcGiViewportDraw : public AcGiViewportDraw 01362 { 01363 public: 01364 ACRX_DECLARE_MEMBERS(HAcGiViewportDraw); 01365 HAcGiViewportDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity); 01366 ~HAcGiViewportDraw(); 01367 01368 virtual AcGiViewport& viewport() const; 01369 virtual AcGiViewportGeometry& geometry() const; 01370 virtual Adesk::UInt32 sequenceNumber() const; 01371 virtual Adesk::Boolean isValidId(const Adesk::ULongPtr acgiId) const; 01372 virtual AcDbObjectId viewportObjectId() const; 01373 01374 virtual AcGiRegenType regenType() const ; 01375 virtual Adesk::Boolean regenAbort() const {return Adesk::kFalse;}; 01376 virtual AcGiSubEntityTraits& subEntityTraits() const ; 01377 virtual AcGiGeometry * rawGeometry() const ; 01378 virtual Adesk::Boolean isDragging() const {return Adesk::kFalse;}; 01379 01380 // This function operates against the current active viewport 01381 // 01382 virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const {return 0.00;}; 01383 virtual Adesk::UInt32 numberOfIsolines() const {return 0;}; 01384 01385 virtual AcGiContext * context(); 01386 01387 HDWGImporter* GetHDWGImporter() const; 01388 AcDbEntity* GetCurrentEntity() const; 01389 01390 private: 01391 AcGiViewport* mpVp; 01392 AcGiViewportGeometry* mpVpGeometry; 01393 AcDbObjectId mpObjId; 01394 01395 AcGiSubEntityTraits* mpSubEntityTraits; 01396 AcGiContext* mpContext; 01397 AcGiRegenType mRegenType; 01398 01399 HDWGImporter* m_pDWGImporter; 01400 AcDbEntity* m_pAcDbEntity; 01401 01402 }; 01403 01404 class HAcGiViewportGeometry : public AcGiViewportGeometry 01405 { 01406 public: 01407 ACRX_DECLARE_MEMBERS(HAcGiViewportGeometry); 01408 HAcGiViewportGeometry(HAcGiViewportDraw* pViewportDraw); 01409 ~HAcGiViewportGeometry(); 01410 virtual Adesk::Boolean polylineEye(const Adesk::UInt32 nbPoints, 01411 const AcGePoint3d* pPoints) const ; 01412 virtual Adesk::Boolean polygonEye(const Adesk::UInt32 nbPoints, 01413 const AcGePoint3d* pPoints) const ; 01414 01415 virtual Adesk::Boolean polylineDc(const Adesk::UInt32 nbPoints, 01416 const AcGePoint3d* pPoints) const; 01417 virtual Adesk::Boolean polygonDc(const Adesk::UInt32 nbPoints, 01418 const AcGePoint3d* pPoints) const ; 01419 01420 01421 virtual Adesk::Boolean rasterImageDc( 01422 const AcGePoint3d& origin, 01423 const AcGeVector3d& u, 01424 const AcGeVector3d& v, 01425 const AcGeMatrix2d& pixelToDc, 01426 AcDbObjectId entityId, 01427 AcGiImageOrg imageOrg, 01428 Adesk::UInt32 imageWidth, 01429 Adesk::UInt32 imageHeight, 01430 Adesk::Int16 imageColorDepth, 01431 Adesk::Boolean transparency, 01432 ImageSource source, 01433 const AcGeVector3d& unrotatedU, 01434 const AcGiImageOrg origionalImageOrg, 01435 const AcGeMatrix2d& unrotatedPixelToDc, 01436 const Adesk::UInt32 unrotatedImageWidth, 01437 const Adesk::UInt32 unrotatedImageHeight 01438 ) const; 01439 01440 virtual Adesk::Boolean ownerDrawDc( 01441 long vpnumber, 01442 long left, 01443 long top, 01444 long right, 01445 long bottom, 01446 const OwnerDraw* pOwnerDraw 01447 ) const; 01448 01449 virtual Adesk::Boolean ownerDraw3d( 01450 AcGePoint3d& minBounds, 01451 AcGePoint3d& maxBounds, 01452 OwnerDraw3d* pOwnerDraw 01453 ) const ; 01454 01455 01456 // Coordinate transformations. 01457 // 01458 virtual void getModelToWorldTransform(AcGeMatrix3d&) const ; 01459 virtual void getWorldToModelTransform(AcGeMatrix3d&) const ; 01460 01461 virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal) ;// Uses arbitrary Axis algorythm 01462 virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat) ; 01463 virtual Adesk::Boolean popModelTransform() ; 01464 01465 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset); 01466 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset); 01467 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents); 01468 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents); 01469 virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior); 01470 01471 01472 // For drawing various primitives. 01473 // 01474 virtual Adesk::Boolean circle(const AcGePoint3d& center, 01475 const double radius, 01476 const AcGeVector3d& normal) const ; 01477 01478 virtual Adesk::Boolean circle(const AcGePoint3d&, const AcGePoint3d&, 01479 const AcGePoint3d&) const ; 01480 01481 virtual Adesk::Boolean circularArc(const AcGePoint3d& center, 01482 const double radius, 01483 const AcGeVector3d& normal, 01484 const AcGeVector3d& startVector, 01485 const double sweepAngle, 01486 const AcGiArcType arcType = kAcGiArcSimple) const ; 01487 01488 virtual Adesk::Boolean circularArc(const AcGePoint3d& start, 01489 const AcGePoint3d& point, 01490 const AcGePoint3d& end, 01491 const AcGiArcType arcType = kAcGiArcSimple) const ; 01492 01493 virtual Adesk::Boolean polyline(const Adesk::UInt32 nbPoints, 01494 const AcGePoint3d* pVertexList, 01495 const AcGeVector3d* pNormal = NULL, 01496 Adesk::LongPtr lBaseSubEntMarker = -1) const ; 01497 01498 virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const {return Adesk::kTrue;} 01499 01500 virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines, 01501 const AcGiPolyline* pPolylines) const {return Adesk::kTrue;} 01502 virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices, 01503 const Adesk::UInt32* numPolygonPositions, 01504 const AcGePoint3d* polygonPositions, 01505 const Adesk::UInt32* numPolygonPoints, 01506 const AcGePoint3d* polygonPoints, 01507 const AcCmEntityColor* outlineColors = NULL, 01508 const AcGiLineType* outlineTypes = NULL, 01509 const AcCmEntityColor* fillColors = NULL, 01510 const AcCmTransparency* fillOpacities = NULL) const {return Adesk::kTrue;} 01511 virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource, 01512 const AcGePoint3d& position, 01513 const AcGeVector3d& u, //orientation and magnitude of width 01514 const AcGeVector3d& v, //orientation and magnitude of height 01515 TransparencyMode transparencyMode = kTransparency8Bit 01516 ) const {return Adesk::kTrue;} 01517 virtual Adesk::Boolean rowOfDots(int count, 01518 const AcGePoint3d& start, 01519 const AcGeVector3d& step 01520 ) const {return Adesk::kTrue;} 01521 virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center, 01522 const AcGeVector3d& normal, 01523 double majorAxisLength, 01524 double minorAxisLength, 01525 double startDegreeInRads, 01526 double endDegreeInRads, 01527 double tiltDegreeInRads, 01528 AcGiArcType arcType = kAcGiArcSimple 01529 ) const {return Adesk::kTrue;} 01530 01531 virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints, 01532 const AcGePoint3d* pVertexList) const ; 01533 01534 virtual Adesk::Boolean mesh(const Adesk::UInt32 rows, 01535 const Adesk::UInt32 columns, 01536 const AcGePoint3d* pVertexList, 01537 const AcGiEdgeData* pEdgeData = NULL, 01538 const AcGiFaceData* pFaceData = NULL, 01539 const AcGiVertexData* pVertexData = NULL, 01540 const bool bAutoGenerateNormals = true 01541 ) const ; 01542 01543 virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex, 01544 const AcGePoint3d* pVertexList, 01545 const Adesk::UInt32 faceListSize, 01546 const Adesk::Int32* pFaceList, 01547 const AcGiEdgeData* pEdgeData = NULL, 01548 const AcGiFaceData* pFaceData = NULL, 01549 const AcGiVertexData* pVertexData = NULL, 01550 const struct resbuf* pResBuf = NULL, 01551 const bool bAutoGenerateNormals = true 01552 ) const ; 01553 01554 virtual Adesk::Boolean text(const AcGePoint3d& position, 01555 const AcGeVector3d& normal, 01556 const AcGeVector3d& direction, 01557 const double height, 01558 const double width, 01559 const double oblique, 01560 const ACHAR* pMsg) const ; 01561 01562 virtual Adesk::Boolean text(const AcGePoint3d& position, 01563 const AcGeVector3d& normal, 01564 const AcGeVector3d& direction, 01565 const ACHAR* pMsg, 01566 const Adesk::Int32 length, 01567 const Adesk::Boolean raw, 01568 const AcGiTextStyle &pTextStyle 01569 ) const ; 01570 01571 virtual Adesk::Boolean xline(const AcGePoint3d&, 01572 const AcGePoint3d&) const ; 01573 01574 virtual Adesk::Boolean ray(const AcGePoint3d&, 01575 const AcGePoint3d&) const ; 01576 01577 virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf, 01578 Adesk::UInt32 fromIndex = 0, 01579 Adesk::UInt32 numSegs = 0 01580 ) const ; 01581 01582 virtual Adesk::Boolean draw(AcGiDrawable*) const ; 01583 01584 virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary); 01585 virtual void popClipBoundary() ; 01586 01587 private: 01588 // Back pointer stored to the ViewPortDraw object. This class 01589 // uses it to store the ShellData when the shell member 01590 // function is called. ---- SK 18 mar 09 01591 HAcGiViewportDraw* m_pHAcGiViewportDraw; 01592 unsigned int m_uiOpenSegmentCount; 01593 01594 }; 01595 class HAcGiViewport : public AcGiViewport 01596 { 01597 public: 01598 ACRX_DECLARE_MEMBERS(AcGiViewport); 01599 HAcGiViewport(HInputHandlerOptions const * options = 0); 01600 ~HAcGiViewport(); 01601 01602 virtual void getModelToEyeTransform(AcGeMatrix3d& mx) const; 01603 virtual void getEyeToModelTransform(AcGeMatrix3d& mx) const; 01604 virtual void getWorldToEyeTransform(AcGeMatrix3d& mx) const; 01605 virtual void getEyeToWorldTransform(AcGeMatrix3d& mx) const; 01606 01607 virtual Adesk::Boolean isPerspective() const; 01608 virtual Adesk::Boolean doPerspective(AcGePoint3d&) const; 01609 virtual Adesk::Boolean doInversePerspective(AcGePoint3d&) const; 01610 01611 virtual void getNumPixelsInUnitSquare(const AcGePoint3d& givenWorldpt, 01612 AcGePoint2d& pixelArea, 01613 bool includePerspective = true) const; 01614 01615 virtual void getCameraLocation(AcGePoint3d& location) const; 01616 virtual void getCameraTarget(AcGePoint3d& target) const; 01617 virtual void getCameraUpVector(AcGeVector3d& upVector) const; 01618 01619 virtual Adesk::ULongPtr viewportId() const; 01620 virtual Adesk::Int16 acadWindowId() const; 01621 virtual void getViewportDcCorners(AcGePoint2d& lower_left, 01622 AcGePoint2d& upper_right) const; 01623 01624 virtual Adesk::Boolean getFrontAndBackClipValues(Adesk::Boolean& clip_front, 01625 Adesk::Boolean& clip_back, 01626 double& front, 01627 double& back) const; 01628 virtual double linetypeScaleMultiplier() const; 01629 virtual double linetypeGenerationCriteria() const; 01630 01631 virtual AcGeVector3d viewDir() const; 01632 01633 private: 01634 HInputHandlerOptions const * inputOptions; 01635 AcGePoint3d cameraTarget; 01636 AcGePoint3d cameraLocation; 01637 AcGeVector3d cameraUpVector; 01638 }; 01639 01640 class HDrawOrderHandler 01641 { 01642 public: 01643 HDrawOrderHandler(AcDbBlockTableRecord * pRecord) 01644 { 01645 m_pRecord = pRecord; 01646 m_pObj = 0; 01647 }; 01648 01649 int Open(); 01650 bool GetNextEntity(AcDbEntity *& pOutEnt); 01651 int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, HC_KEY block_key, HDWG_3dgsImporter * importer); 01652 int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, TK_Open_Segment * include_seg_handler, HDWG_BStreamImporter * importer); 01653 void Close(); 01654 01655 protected: 01656 AcDbBlockTableRecord * m_pRecord; 01657 AcDbSortentsTable * m_pObj; 01658 AcDbObjectIdArray objArray; 01659 int m_iIndex; 01660 AcDbBlockTableRecordIterator * m_pRecordIter; 01661 01662 }; 01663 01664 wchar_t * h_dwg_wcsdup(wchar_t const * const wcs); 01665 01666 // Inline functions for HDWG_BStreamImporter calling opcodehandlers 01667 inline int HDWG_BStreamImporter::STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * seg_name) const 01668 { 01669 // Caller have to delete open_seg_handler, in this version. 01670 open_seg_handler->SetSegment(seg_name); 01671 TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01672 H_ASSERT(hdwg_status == TK_Normal); 01673 return 1; 01674 } 01675 01676 inline int HDWG_BStreamImporter::STREAM_Open_Segment(const char * seg_name) const 01677 { 01678 // Caller don't have to delete open_seg_handler, in this version. 01679 TK_Open_Segment* open_seg_handler = new TK_Open_Segment; 01680 open_seg_handler->SetSegment(seg_name); 01681 TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01682 H_ASSERT(hdwg_status == TK_Normal); 01683 delete open_seg_handler; 01684 01685 return 1; 01686 } 01687 01688 inline int HDWG_BStreamImporter:: STREAM_Close_Segment() const 01689 { 01690 TK_Close_Segment *close_seg_handler = new TK_Close_Segment; 01691 TK_Status hdwg_status = WriteObject(close_seg_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01692 H_ASSERT(hdwg_status == TK_Normal); 01693 delete close_seg_handler; 01694 01695 return 1; 01696 } 01697 01698 inline int HDWG_BStreamImporter:: STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const 01699 { 01700 //HC_Set_Visibility("off"); 01701 TK_Visibility *vis_handler = new TK_Visibility(); 01702 vis_handler->SetGeometry(Geom_Bit); 01703 if(ifOn) 01704 vis_handler->SetValue(1); 01705 else 01706 vis_handler->SetValue(0); 01707 TK_Status hdwg_status = WriteObject(vis_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01708 H_ASSERT(hdwg_status == TK_Normal); 01709 delete vis_handler; 01710 01711 return 1; 01712 } 01713 01714 inline int HDWG_BStreamImporter:: STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const 01715 { 01716 //HC_Set_Heuristics("xxxx"); 01717 TK_Heuristics* heuristic_handler = new TK_Heuristics; 01718 heuristic_handler->SetMask( Heuristic_Bit); 01719 heuristic_handler->SetValue( Heuristic_Bit); 01720 TK_Status hdwg_status = WriteObject(heuristic_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01721 H_ASSERT(hdwg_status == TK_Normal); 01722 delete heuristic_handler; 01723 01724 return 1; 01725 } 01726 inline int HDWG_BStreamImporter:: STREAM_Write_Object(BBaseOpcodeHandler * handler) const 01727 { 01728 TK_Status hdwg_status = WriteObject(handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01729 H_ASSERT(hdwg_status == TK_Normal); 01730 delete handler; 01731 01732 return 1; 01733 } 01734 01735 #ifdef H_PACK_8 01736 #pragma pack(pop) 01737 #endif 01738 01739 #endif