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 // 00022 00023 #ifndef HDWG_HELPER_H_ 00024 #define HDWG_HELPER_H_ 1 00025 00026 #ifdef H_PACK_8 00027 #pragma pack(push) 00028 #pragma pack(8) 00029 #endif 00030 00031 00032 //#include <wchar.h> 00033 #include <map> 00034 #include <vector> 00035 #include <string> 00036 00037 #include "acgi.h" 00038 #include "hc.h" 00039 #include "HIOManager.h" 00040 #include "HTools.h" 00041 #include "HUtility.h" 00042 00043 #include "BStream.h" 00044 #include "BOpcodeShell.h" 00045 00046 #include "sorttab.h " 00047 00048 #include "windows.h" 00049 #include "stdlib.h" 00050 #include "stdio.h" 00051 #include "string.h" 00052 #include "time.h" 00053 00054 #include "dbimage.h" 00055 #include "imgdef.h" 00056 #include "imgent.h" 00057 00058 #include "dbobjptr.h" 00059 #include "acdblmgr.h" 00060 #include "dbmleader.h" // For AcDbMLeader 00061 #include "dblight.h" 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 void importAcDbLight(AcDbLight* pEnt); 00821 #ifdef WIN32 00822 void importAcDbTable(AcDbTable* pAcDbTable); 00823 #endif 00824 void importXdata(AcDbEntity *pEnt); 00825 void importBlockTableRecord(AcDbBlockTableRecord* pRecord); 00826 void attachDWGHandle(AcDbEntity *pEnt); 00827 00828 void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, HC_KEY& style_key); 00829 00830 virtual void importXdata(resbuf *pBuf); 00831 void import_hyperlinks(AcDbEntity *pEnt); 00832 void set_marker_settings(const Adesk::Int16 db_pdmode, const double db_pdsize ); 00833 00834 void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord); 00835 void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale); 00836 void import_layout(AcDbDatabase *pAcDbDatabase); 00837 void update_layout_list(AcDbDatabase* pAcDbDatabase); 00838 void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase); 00839 void InsertMaskRegion(AcDbRasterImage* pEnt); 00840 00841 00842 HC_KEY GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew); 00843 HC_KEY GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt); 00844 00845 00846 wchar_t* m_CurrentLayoutName; 00847 std::map<void * , HC_KEY> m_Segments_map; 00848 std::map<void * , HC_KEY>::const_iterator m_keymap_ieterator; 00849 00850 // For progress bar 00851 int m_nTotalEntities; 00852 int m_nCurrentEntityCount; 00853 void GetNoOfEntitiesForProgressBar(AcDbDatabase* pAcDbDatabase); 00854 00855 friend class HDrawOrderHandler; 00856 00857 }; 00858 00859 class HDWG_BStreamImporter : public HDWGImporter 00860 { 00861 public: 00862 HDWG_BStreamImporter(HIOUtilityDWG* pDWGInputHandler, bool is_xref); 00863 ~HDWG_BStreamImporter(); 00864 00865 virtual void recomputeAndImportDimensions(std::vector<dimensionData> * dimensionVector); 00866 00868 // Bstream Toolkit 00869 BStreamFileToolkit *m_pBStreamtk; 00870 char *m_pBStreamBuffer; 00871 int m_nBStreamBuffSize; 00872 int m_nBStreamBuffCount; 00873 FILE *m_pHSFFile; 00874 struct vhash_s * m_vhash_StyleSegName_IsPresentFlag; 00875 struct vhash_s * m_vhash_SegName_IsPresentFlag; 00877 00878 virtual bool importDWGFile(const wchar_t * FileName, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0); 00879 virtual bool importXRefs(AcDbDatabase* pHostDb, HC_KEY modelKey, HInputHandlerOptions * pInputOptions); 00880 virtual bool importDWGDatabase(AcDbDatabase* pAcDbDatabase, HC_KEY modelKey, HInputHandlerOptions * pInputOptions = 0); 00881 00882 virtual void importAcDbMTextFragment(AcDbMTextFragment* pAcDbMTextFragment, AcDbMText* pOrigAcDbMText); 00883 virtual void importAcDbDimension(AcDbDimension* pAcDbDimension, dimensionAttributes dimAtt); 00884 void import_exploded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const; 00885 void import_extruded_pline(const AcDbPolyline& lwBuf, int i, AcDbEntity* pDatabaseEntity) const; 00886 void import_fancy_pline(const AcDbPolyline& lwBuf, AcDbEntity* pDatabaseEntity) const; 00887 void extrude_pline(AcGePoint3dArray dwgPoints, AcGeVector3d normal, double line_thickness) const; 00888 00889 Adesk::Boolean import_circle( const AcGePoint3d& pt1, 00890 const AcGePoint3d& pt2, 00891 const AcGePoint3d& pt3, 00892 AcDbEntity* pDatabaseEntity) const; 00893 00894 Adesk::Boolean import_circle( const AcGePoint3d& center, 00895 const double radius, 00896 const AcGeVector3d& normal, 00897 AcDbEntity* pDatabaseEntity 00898 ) const; 00899 00900 Adesk::Boolean import_circular_arc( const AcGePoint3d& center, 00901 const double radius, 00902 const AcGeVector3d& normal, 00903 const AcGeVector3d& startVector, 00904 const double sweepAngle, 00905 const AcGiArcType arcType, 00906 AcDbEntity* pDatabaseEntity 00907 ) const; 00908 00909 Adesk::Boolean import_circular_arc( const AcGePoint3d& start, 00910 const AcGePoint3d& point, 00911 const AcGePoint3d& end, 00912 const AcGiArcType arcType, 00913 AcDbEntity* pDatabaseEntity 00914 ) const; 00915 00916 Adesk::Boolean import_polygon( const Adesk::UInt32 nbPoints, 00917 const AcGePoint3d* pVertexList, 00918 AcDbEntity* pDatabaseEntity 00919 ) const; 00920 00921 Adesk::Boolean import_polyline( const Adesk::UInt32 nbPoints, 00922 const AcGePoint3d* pVertexList, 00923 const AcGeVector3d* pNormal, 00924 Adesk::LongPtr lBaseSubEntMarker, 00925 AcDbEntity* pDatabaseEntity) const; 00926 00927 Adesk::Boolean import_pline(const AcDbPolyline& lwBuf, 00928 Adesk::UInt32 fromIndex, 00929 Adesk::UInt32 numSegs, 00930 AcDbEntity* pDatabaseEntity) const; 00931 00932 Adesk::Boolean import_polypoint(const Adesk::UInt32 nbPoints, 00933 const AcGePoint3d* pVertexList, 00934 const AcGeVector3d* pNormal, 00935 const Adesk::LongPtr * pSubEntMarkers, 00936 AcDbEntity* pDatabaseEntity) const 00937 { /*TODO: Implement this function*/ return Adesk::kFalse;}; 00938 00939 Adesk::Boolean import_mesh( const Adesk::UInt32 rows, 00940 const Adesk::UInt32 columns, 00941 const AcGePoint3d* pVertexList, 00942 const AcGiEdgeData* pEdgeData, 00943 const AcGiFaceData* pFaceData, 00944 const AcGiVertexData* pVertexData, 00945 const bool bAutoGenerateNormals, 00946 AcDbEntity* pDatabaseEntity 00947 ) const; 00948 00949 Adesk::Boolean import_shell(const Adesk::UInt32 nbVertex, 00950 const AcGePoint3d* pVertexList, 00951 const Adesk::UInt32 faceListSize, 00952 const Adesk::Int32* pFaceList, 00953 const AcGiEdgeData* pEdgeData, 00954 const AcGiFaceData* pFaceData , 00955 const AcGiVertexData* pVertexData, 00956 const struct resbuf* pResBuf, 00957 const bool bAutoGenerateNormals, 00958 AcDbEntity* pDatabaseEntity 00959 ) const; 00960 00961 Adesk::Boolean import_text( const AcGePoint3d& position, 00962 const AcGeVector3d& normal, 00963 const AcGeVector3d& direction, 00964 const double height, 00965 const double width, 00966 const double oblique, 00967 const ACHAR* pMsg, 00968 AcDbEntity* pDatabaseEntity 00969 ) const; 00970 00971 Adesk::Boolean import_text( const AcGePoint3d& position, 00972 const AcGeVector3d& normal, 00973 const AcGeVector3d& direction, 00974 const ACHAR* pMsg, 00975 const Adesk::LongPtr length, 00976 const Adesk::Boolean raw, 00977 const AcGiTextStyle &pTextStyle, 00978 AcDbEntity* pDatabaseEntity 00979 ) const; 00980 00981 HC_KEY apply_transforms_and_insert_text(float my_center[], 00982 float my_path1[], 00983 float my_norm1[], 00984 wchar_t const * text, 00985 const int alignment) const; 00986 00987 void pushModelTransform(AcGeMatrix3d const & xMat); 00988 void popModelTransform(); 00989 00990 inline BOOL GetConnectivityCompression() { return bConnectivityCompression; }; 00991 inline void SetConnectivityCompression(BOOL val) { bConnectivityCompression = val; } 00992 inline BOOL GetVertexCompression() { return bVertexCompression; } 00993 inline void SetVertexCompression(BOOL val) { bVertexCompression = val; } 00994 inline BOOL GetNormalCompression() { return bNormalCompression; } 00995 inline void SetNormalCompression(BOOL val) { bNormalCompression = val; } 00996 inline BOOL GetImageCompression() { return bImageCompression; } 00997 inline void SetImageCompression(BOOL val) { bImageCompression = val; } 00998 inline int GetVertexCompressionBits() { return m_VertexCompressionBits; } 00999 inline void SetVertexCompressionBits(int val) { m_VertexCompressionBits = val; } 01000 inline int GetNormalCompressionBits() { return m_NormalCompressionBits; } 01001 inline void SetNormalCompressionBits(int val) { m_NormalCompressionBits = val; } 01002 inline int GetImageCompressionValue() { return m_ImageCompressionValue; } 01003 inline void SetImageCompressionValue(int val) { m_ImageCompressionValue = val; } 01004 01005 01006 protected: 01007 01008 void importAcDbEntity(AcDbEntity* pEnt, TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0); 01009 void importAcDbEntity(AcDbEntity *pEnt, const bool& draw_shaded, int entityType, 01010 TK_Open_Segment* parent_seg = NULL, bool for_blk_ref=false, dimensionAttributes * dAtt = 0); 01011 01012 01013 void importBlockTable(AcDbBlockTable* pBlockTable); 01014 void importAcDbMInsertBlock(AcDbMInsertBlock *pAcDbMInsertBlock,TK_Open_Segment * Open_seg_handler); 01015 //void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, HC_KEY parent_seg = INVALID_KEY); 01016 void importAcDbBlockReference(AcDbBlockReference *pAcDbBlockReference, TK_Open_Segment* Open_seg_handler = NULL, 01017 int mib_col = 0 , int mib_row = 0); 01018 01019 void importAcDbPoint(AcDbPoint *pAcDbPoint); 01020 void importAcDbCircle(AcDbCircle* pAcDbCircle); 01021 void importAcDbMaterial(AcDbMaterial *pAcDbMaterial, AcGiMapper mapper); 01022 void importLBGEData(); 01023 void importAcDbLine(AcDbLine *pAcDbLine); 01024 void importAcDbXline(AcDbXline* pXline); 01025 void importAcDb3dPolyline(AcDb3dPolyline *pAcDbPolyline); 01026 void importAcDbRay(AcDbRay* pRay); 01027 void importBlockTableRecord(AcDbBlockTableRecord* pRecord, dimensionData * dData = 0); 01028 void importAcDbViewport(AcDbViewport* pViewport); 01029 void importAcDbRasterImage(AcDbRasterImage* pEnt); 01030 void importAcDbMLeader(AcDbMLeader* pEnt); 01031 void importAcDbLight(AcDbLight* pEnt); 01032 #ifdef WIN32 01033 void importAcDbTable(AcDbTable* pAcDbTable); 01034 #endif 01035 01036 void importXdata(AcDbEntity *pEnt); 01037 void attachDWGHandle(AcDbEntity *pEnt); 01038 void get_entity_material_style(AcDbEntity* pEnt, const AcDbLayerTableRecord *pLayerTableRecord, TK_Open_Segment* &parent_seg); 01039 TK_Open_Segment* GetBlockTableRecordSegmentFromId(const AcDbObjectId& blockTableRecordID, bool& isNew); 01040 TK_Open_Segment* GetBlockTableRecordSegmentForEntity(AcDbEntity *pEnt); 01041 01042 //void bstream_CreateWireframeCircleWithEllipse(const HPoint &x1, const HPoint &x2, const HPoint &x3 ); 01043 01044 virtual void importXdata(resbuf *pBuf); 01045 void import_hyperlinks(AcDbEntity *pEnt); 01046 void set_marker_settings(const Adesk::Int16 db_pdmode,const double db_pdsize ); 01047 void import_entity_linetype(AcDbEntity *pEnt, const AcDbLayerTableRecord *pLayerTableRecord); 01048 void import_entity_linetype(const AcDbObjectId& pLinetypeId, double linetype_scale); 01049 void InsertMaskRegion(AcDbRasterImage* pEnt); 01050 void import_layout(AcDbDatabase *pAcDbDatabase); 01051 void update_layout_list(AcDbDatabase* pAcDbDatabase); 01052 void set_initial_view_for_model_space(AcDbDatabase* pAcDbDatabase); 01053 01054 BOOL bConnectivityCompression; 01055 BOOL bVertexCompression; 01056 BOOL bNormalCompression; 01057 BOOL bImageCompression; 01058 int m_VertexCompressionBits; 01059 int m_NormalCompressionBits; 01060 int m_ImageCompressionValue; 01061 bool m_bMergeEntityShells; 01062 time_t m_mtImportStart; 01063 wchar_t * m_pFileName; 01064 bool m_bAmIXref; 01065 bool m_bScratchSegOpen; 01066 wchar_t *m_pXref_hsf_path; 01067 mutable bool m_bShellWithFaceColor; 01068 01069 01070 private: 01071 // small fuctions for opening/ closing segments, visibility, heuristics, 01072 // unicode/user opts settings, etc. 01073 // Functions to reduce code size - perform TK operations 01074 int STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * segname) const; 01075 int STREAM_Open_Segment(const char * segname) const; 01076 int STREAM_Close_Segment() const; 01077 int STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const; 01078 int STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const; 01079 int STREAM_Write_Object(BBaseOpcodeHandler * handler) const; 01080 static struct _stat m_MasterHsfFileTime; 01081 01082 std::map<void * , const char *> m_Segments_map; 01083 std::map<void * ,const char *>::const_iterator m_iterator_segmap; 01084 01085 friend class HDrawOrderHandler; 01086 }; 01087 01088 // Custom worldDraw object is sent in a call to the 01089 // entitiy's worldDraw function. The entity will then 01090 // end up calling the worldGeometry class's shell function. 01091 // In this case, the HAcGiWorldGeometry's shell member 01092 // function will be called. 01093 class HAcGiWorldDraw : public AcGiWorldDraw 01094 { 01095 public: 01096 01097 ACRX_DECLARE_MEMBERS(HAcGiWorldDraw); 01098 01099 HAcGiWorldDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity); 01100 virtual ~HAcGiWorldDraw(); 01101 01102 virtual AcGiRegenType regenType() const; 01103 virtual Adesk::Boolean regenAbort() const; 01104 virtual AcGiSubEntityTraits& subEntityTraits() const; 01105 virtual AcGiGeometry * rawGeometry() const; 01106 virtual AcGiWorldGeometry& geometry() const; 01107 virtual Adesk::Boolean isDragging() const; 01108 virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const; 01109 virtual Adesk::UInt32 numberOfIsolines() const; 01110 virtual AcGiContext * context(); 01111 01112 void setDeviation(double); 01113 void setRegenType(const AcGiRegenType&); 01114 01115 HDWGImporter* GetHDWGImporter() const; 01116 AcDbEntity* GetCurrentEntity() const; 01117 01118 private: 01119 01120 AcGiSubEntityTraits* mpSubEntityTraits; 01121 AcGiWorldGeometry* mpWorldGeometry; 01122 AcGiContext* mpContext; 01123 AcGiRegenType mRegenType; 01124 01125 HDWGImporter* m_pDWGImporter; 01126 AcDbEntity* m_pAcDbEntity; 01127 }; 01128 01129 // AcGiContext abstracts out the commonality between 01130 // AcGiViewportDraw and AcGiWorldDraw. This allows you 01131 // to code graphics routines in terms of AcGiContext that 01132 // will work in either case. To maintain their original signatures, 01133 // AcGiWorldDraw and AcGiViewportDraw now derive from AcGiContext. 01134 // Only the database member function is implemented. 01135 class HAcGiContext : public AcGiContext 01136 { 01137 public: 01138 01139 ACRX_DECLARE_MEMBERS(HAcGiContext); 01140 HAcGiContext(); 01141 virtual ~HAcGiContext(); 01142 01143 Adesk::Boolean isPsOut() const; 01144 Adesk::Boolean isPlotGeneration() const; 01145 AcDbDatabase * database() const; 01146 bool isBoundaryClipping() const; 01147 01148 }; 01149 01150 // This class contains the view independent, model coordinate, 01151 // 3D geometry methods for our custom world geometry class. 01152 class HAcGiWorldGeometry: public AcGiWorldGeometry 01153 { 01154 public: 01155 01156 ACRX_DECLARE_MEMBERS(HAcGiWorldGeometry); 01157 01158 HAcGiWorldGeometry(HAcGiWorldDraw* pWorldDraw); 01159 ~HAcGiWorldGeometry(); 01160 01161 virtual Adesk::Boolean draw(AcGiDrawable*) const; 01162 01163 virtual Adesk::Boolean circle (const AcGePoint3d& center, 01164 const double radius, 01165 const AcGeVector3d& normal 01166 ) const; 01167 01168 virtual Adesk::Boolean circle (const AcGePoint3d& pt1, 01169 const AcGePoint3d& pt2, 01170 const AcGePoint3d& pt3 01171 ) const; 01172 01173 virtual Adesk::Boolean circularArc(const AcGePoint3d& center, 01174 const double radius, 01175 const AcGeVector3d& normal, 01176 const AcGeVector3d& startVector, 01177 const double sweepAngle, 01178 const AcGiArcType arcType = kAcGiArcSimple 01179 ) const; 01180 01181 virtual Adesk::Boolean circularArc(const AcGePoint3d& start, 01182 const AcGePoint3d& point, 01183 const AcGePoint3d& end, 01184 const AcGiArcType arcType = kAcGiArcSimple 01185 ) const; 01186 01187 virtual Adesk::Boolean polyline (const Adesk::UInt32 nbPoints, 01188 const AcGePoint3d* pVertexList, 01189 const AcGeVector3d* pNormal = NULL, 01190 Adesk::LongPtr lBaseSubEntMarker = -1) const; 01191 01192 virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const ; 01193 01194 virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines, 01195 const AcGiPolyline* pPolylines) const; 01196 virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices, 01197 const Adesk::UInt32* numPolygonPositions, 01198 const AcGePoint3d* polygonPositions, 01199 const Adesk::UInt32* numPolygonPoints, 01200 const AcGePoint3d* polygonPoints, 01201 const AcCmEntityColor* outlineColors = NULL, 01202 const AcGiLineType* outlineTypes = NULL, 01203 const AcCmEntityColor* fillColors = NULL, 01204 const AcCmTransparency* fillOpacities = NULL) const ; 01205 virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource, 01206 const AcGePoint3d& position, 01207 const AcGeVector3d& u, //orientation and magnitude of width 01208 const AcGeVector3d& v, //orientation and magnitude of height 01209 TransparencyMode transparencyMode 01210 ) const ; 01211 virtual Adesk::Boolean rowOfDots(int count, 01212 const AcGePoint3d& start, 01213 const AcGeVector3d& step 01214 ) const ; 01215 virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center, 01216 const AcGeVector3d& normal, 01217 double majorAxisLength, 01218 double minorAxisLength, 01219 double startDegreeInRads, 01220 double endDegreeInRads, 01221 double tiltDegreeInRads, 01222 AcGiArcType arcType 01223 ) const ; 01224 01225 virtual Adesk::Boolean polypoint(const Adesk::UInt32 nbPoints, 01226 const AcGePoint3d* pVertexList, 01227 const AcGeVector3d* pNormal = NULL, 01228 const Adesk::LongPtr * pSubEntMarkers = NULL) const; 01229 01230 virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints, 01231 const AcGePoint3d* pVertexList 01232 ) const; 01233 01234 virtual Adesk::Boolean mesh (const Adesk::UInt32 rows, 01235 const Adesk::UInt32 columns, 01236 const AcGePoint3d* pVertexList, 01237 const AcGiEdgeData* pEdgeData = NULL, 01238 const AcGiFaceData* pFaceData = NULL, 01239 const AcGiVertexData* pVertexData = NULL, 01240 const bool bAutoGenerateNormals = true 01241 ) const; 01242 01243 virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex, 01244 const AcGePoint3d* pVertexList, 01245 const Adesk::UInt32 faceListSize, 01246 const Adesk::Int32* pFaceList, 01247 const AcGiEdgeData* pEdgeData = NULL, 01248 const AcGiFaceData* pFaceData = NULL, 01249 const AcGiVertexData* pVertexData = NULL, 01250 const struct resbuf* pResBuf = NULL, 01251 const bool bAutoGenerateNormals = true 01252 ) const; 01253 01254 01255 virtual Adesk::Boolean text (const AcGePoint3d& position, 01256 const AcGeVector3d& normal, 01257 const AcGeVector3d& direction, 01258 const double height, 01259 const double width, 01260 const double oblique, 01261 const ACHAR* pMsg 01262 ) const; 01263 01264 virtual Adesk::Boolean text(const AcGePoint3d& position, 01265 const AcGeVector3d& normal, 01266 const AcGeVector3d& direction, 01267 const ACHAR* pMsg, 01268 const Adesk::Int32 length, 01269 const Adesk::Boolean raw, 01270 const AcGiTextStyle &pTextStyle 01271 ) const; 01272 01273 01274 virtual Adesk::Boolean xline (const AcGePoint3d& one_xline_point, 01275 const AcGePoint3d& a_different_xline_point 01276 ) const; 01277 01278 virtual Adesk::Boolean ray(const AcGePoint3d& rays_starting_point, 01279 const AcGePoint3d& a_different_ray_point 01280 ) const; 01281 01282 virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf, 01283 Adesk::UInt32 fromIndex = 0, 01284 Adesk::UInt32 numSegs = 0 01285 ) const; 01286 01287 virtual void getModelToWorldTransform(AcGeMatrix3d &pMatrix) const; 01288 virtual void getWorldToModelTransform(AcGeMatrix3d &pMatrix) const; 01289 virtual void setExtents(AcGePoint3d *pNewExtents) const; 01290 01291 virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal);// Uses arbitrary Axis algorythm 01292 virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat); 01293 virtual Adesk::Boolean popModelTransform(); 01294 01295 virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary); 01296 virtual void popClipBoundary(); 01297 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset); 01298 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset); 01299 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents); 01300 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents); 01301 virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior); 01302 01303 private: 01304 01305 // Back pointer stored to the WorldDraw object. This class 01306 // uses it to store the ShellData when the shell member 01307 // function is called. 01308 HAcGiWorldDraw* m_pHAcGiWorldDraw; 01309 unsigned int m_uiOpenSegmentCount; 01310 }; 01311 01312 01313 // This class applies attributes to subsequently drawn AcGi geometry 01314 // primitives. 01315 class HAcGiSubEntityTraits: public AcGiSubEntityTraits 01316 { 01317 public: 01318 01319 ACRX_DECLARE_MEMBERS(HAcGiSubEntityTraits); 01320 01321 HAcGiSubEntityTraits(); 01322 ~HAcGiSubEntityTraits(); 01323 01324 virtual void setColor(const Adesk::UInt16 color); 01325 virtual void setTrueColor(const AcCmEntityColor& color); 01326 virtual void setLayer(const AcDbObjectId layerId); 01327 virtual void setLineType(const AcDbObjectId linetypeId); 01328 virtual void setSelectionMarker(const Adesk::LongPtr markerId); 01329 virtual void setFillType(const AcGiFillType fillType); 01330 virtual void setLineWeight(const AcDb::LineWeight lw); 01331 virtual void setLineTypeScale(double dScale = 1.0); 01332 01333 01334 virtual Adesk::UInt16 color() const; 01335 virtual AcCmEntityColor trueColor() const; 01336 virtual AcDbObjectId layerId() const; 01337 virtual AcDbObjectId lineTypeId() const; 01338 virtual AcGiFillType fillType() const; 01339 virtual AcDb::LineWeight lineWeight() const; 01340 virtual double lineTypeScale() const; 01341 01342 virtual void setThickness(double dThickness); 01343 virtual double thickness() const; 01344 01345 private: 01346 01347 Adesk::UInt16 mColorIndex; 01348 AcCmEntityColor mTrueColor; 01349 AcDbObjectId mLayerId; 01350 AcDbObjectId mLinetypeId; 01351 Adesk::LongPtr mMarkerId; 01352 AcGiFillType mFillType; 01353 AcDb::LineWeight mLineWeight; 01354 double mLineTypeScale; 01355 double mThickness; 01356 }; 01357 01358 // Some entities (particularly custom entities from AEC etc.) are viewport entities 01359 // They don't have any visual reprentation in world (worldDraw fails), but they 01360 // have a specific representation in viewport. Hence we are deriving from ViewportDraw 01361 // --- SK 17 mar 09 01362 01363 class HAcGiViewportDraw : public AcGiViewportDraw 01364 { 01365 public: 01366 ACRX_DECLARE_MEMBERS(HAcGiViewportDraw); 01367 HAcGiViewportDraw(HDWGImporter* pDWGImporter, AcDbEntity* pAcDbEntity); 01368 ~HAcGiViewportDraw(); 01369 01370 virtual AcGiViewport& viewport() const; 01371 virtual AcGiViewportGeometry& geometry() const; 01372 virtual Adesk::UInt32 sequenceNumber() const; 01373 virtual Adesk::Boolean isValidId(const Adesk::ULongPtr acgiId) const; 01374 virtual AcDbObjectId viewportObjectId() const; 01375 01376 virtual AcGiRegenType regenType() const ; 01377 virtual Adesk::Boolean regenAbort() const {return Adesk::kFalse;}; 01378 virtual AcGiSubEntityTraits& subEntityTraits() const ; 01379 virtual AcGiGeometry * rawGeometry() const ; 01380 virtual Adesk::Boolean isDragging() const {return Adesk::kFalse;}; 01381 01382 // This function operates against the current active viewport 01383 // 01384 virtual double deviation(const AcGiDeviationType, const AcGePoint3d&) const {return 0.00;}; 01385 virtual Adesk::UInt32 numberOfIsolines() const {return 0;}; 01386 01387 virtual AcGiContext * context(); 01388 01389 HDWGImporter* GetHDWGImporter() const; 01390 AcDbEntity* GetCurrentEntity() const; 01391 01392 private: 01393 AcGiViewport* mpVp; 01394 AcGiViewportGeometry* mpVpGeometry; 01395 AcDbObjectId mpObjId; 01396 01397 AcGiSubEntityTraits* mpSubEntityTraits; 01398 AcGiContext* mpContext; 01399 AcGiRegenType mRegenType; 01400 01401 HDWGImporter* m_pDWGImporter; 01402 AcDbEntity* m_pAcDbEntity; 01403 01404 }; 01405 01406 class HAcGiViewportGeometry : public AcGiViewportGeometry 01407 { 01408 public: 01409 ACRX_DECLARE_MEMBERS(HAcGiViewportGeometry); 01410 HAcGiViewportGeometry(HAcGiViewportDraw* pViewportDraw); 01411 ~HAcGiViewportGeometry(); 01412 virtual Adesk::Boolean polylineEye(const Adesk::UInt32 nbPoints, 01413 const AcGePoint3d* pPoints) const ; 01414 virtual Adesk::Boolean polygonEye(const Adesk::UInt32 nbPoints, 01415 const AcGePoint3d* pPoints) const ; 01416 01417 virtual Adesk::Boolean polylineDc(const Adesk::UInt32 nbPoints, 01418 const AcGePoint3d* pPoints) const; 01419 virtual Adesk::Boolean polygonDc(const Adesk::UInt32 nbPoints, 01420 const AcGePoint3d* pPoints) const ; 01421 01422 01423 virtual Adesk::Boolean rasterImageDc( 01424 const AcGePoint3d& origin, 01425 const AcGeVector3d& u, 01426 const AcGeVector3d& v, 01427 const AcGeMatrix2d& pixelToDc, 01428 AcDbObjectId entityId, 01429 AcGiImageOrg imageOrg, 01430 Adesk::UInt32 imageWidth, 01431 Adesk::UInt32 imageHeight, 01432 Adesk::Int16 imageColorDepth, 01433 Adesk::Boolean transparency, 01434 ImageSource source, 01435 const AcGeVector3d& unrotatedU, 01436 const AcGiImageOrg origionalImageOrg, 01437 const AcGeMatrix2d& unrotatedPixelToDc, 01438 const Adesk::UInt32 unrotatedImageWidth, 01439 const Adesk::UInt32 unrotatedImageHeight 01440 ) const; 01441 01442 virtual Adesk::Boolean ownerDrawDc( 01443 long vpnumber, 01444 long left, 01445 long top, 01446 long right, 01447 long bottom, 01448 const OwnerDraw* pOwnerDraw 01449 ) const; 01450 01451 virtual Adesk::Boolean ownerDraw3d( 01452 AcGePoint3d& minBounds, 01453 AcGePoint3d& maxBounds, 01454 OwnerDraw3d* pOwnerDraw 01455 ) const ; 01456 01457 01458 // Coordinate transformations. 01459 // 01460 virtual void getModelToWorldTransform(AcGeMatrix3d&) const ; 01461 virtual void getWorldToModelTransform(AcGeMatrix3d&) const ; 01462 01463 virtual Adesk::Boolean pushModelTransform(const AcGeVector3d & vNormal) ;// Uses arbitrary Axis algorythm 01464 virtual Adesk::Boolean pushModelTransform(const AcGeMatrix3d & xMat) ; 01465 virtual Adesk::Boolean popModelTransform() ; 01466 01467 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint3d& offset); 01468 virtual AcGeMatrix3d pushPositionTransform (AcGiPositionTransformBehavior behavior, const AcGePoint2d& offset); 01469 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint3d& extents); 01470 virtual AcGeMatrix3d pushScaleTransform (AcGiScaleTransformBehavior behavior, const AcGePoint2d& extents); 01471 virtual AcGeMatrix3d pushOrientationTransform (AcGiOrientationTransformBehavior behavior); 01472 01473 01474 // For drawing various primitives. 01475 // 01476 virtual Adesk::Boolean circle(const AcGePoint3d& center, 01477 const double radius, 01478 const AcGeVector3d& normal) const ; 01479 01480 virtual Adesk::Boolean circle(const AcGePoint3d&, const AcGePoint3d&, 01481 const AcGePoint3d&) const ; 01482 01483 virtual Adesk::Boolean circularArc(const AcGePoint3d& center, 01484 const double radius, 01485 const AcGeVector3d& normal, 01486 const AcGeVector3d& startVector, 01487 const double sweepAngle, 01488 const AcGiArcType arcType = kAcGiArcSimple) const ; 01489 01490 virtual Adesk::Boolean circularArc(const AcGePoint3d& start, 01491 const AcGePoint3d& point, 01492 const AcGePoint3d& end, 01493 const AcGiArcType arcType = kAcGiArcSimple) const ; 01494 01495 virtual Adesk::Boolean polyline(const Adesk::UInt32 nbPoints, 01496 const AcGePoint3d* pVertexList, 01497 const AcGeVector3d* pNormal = NULL, 01498 Adesk::LongPtr lBaseSubEntMarker = -1) const ; 01499 01500 virtual Adesk::Boolean polyline(const AcGiPolyline& polylineObj) const {return Adesk::kTrue;} 01501 01502 virtual Adesk::Boolean polyPolyline (Adesk::UInt32 nbPolylines, 01503 const AcGiPolyline* pPolylines) const {return Adesk::kTrue;} 01504 virtual Adesk::Boolean polyPolygon(const Adesk::UInt32 numPolygonIndices, 01505 const Adesk::UInt32* numPolygonPositions, 01506 const AcGePoint3d* polygonPositions, 01507 const Adesk::UInt32* numPolygonPoints, 01508 const AcGePoint3d* polygonPoints, 01509 const AcCmEntityColor* outlineColors = NULL, 01510 const AcGiLineType* outlineTypes = NULL, 01511 const AcCmEntityColor* fillColors = NULL, 01512 const AcCmTransparency* fillOpacities = NULL) const {return Adesk::kTrue;} 01513 virtual Adesk::Boolean image(const AcGiImageBGRA32& imageSource, 01514 const AcGePoint3d& position, 01515 const AcGeVector3d& u, //orientation and magnitude of width 01516 const AcGeVector3d& v, //orientation and magnitude of height 01517 TransparencyMode transparencyMode = kTransparency8Bit 01518 ) const {return Adesk::kTrue;} 01519 virtual Adesk::Boolean rowOfDots(int count, 01520 const AcGePoint3d& start, 01521 const AcGeVector3d& step 01522 ) const {return Adesk::kTrue;} 01523 virtual Adesk::Boolean ellipticalArc(const AcGePoint3d& center, 01524 const AcGeVector3d& normal, 01525 double majorAxisLength, 01526 double minorAxisLength, 01527 double startDegreeInRads, 01528 double endDegreeInRads, 01529 double tiltDegreeInRads, 01530 AcGiArcType arcType = kAcGiArcSimple 01531 ) const {return Adesk::kTrue;} 01532 01533 virtual Adesk::Boolean polygon(const Adesk::UInt32 nbPoints, 01534 const AcGePoint3d* pVertexList) const ; 01535 01536 virtual Adesk::Boolean mesh(const Adesk::UInt32 rows, 01537 const Adesk::UInt32 columns, 01538 const AcGePoint3d* pVertexList, 01539 const AcGiEdgeData* pEdgeData = NULL, 01540 const AcGiFaceData* pFaceData = NULL, 01541 const AcGiVertexData* pVertexData = NULL, 01542 const bool bAutoGenerateNormals = true 01543 ) const ; 01544 01545 virtual Adesk::Boolean shell(const Adesk::UInt32 nbVertex, 01546 const AcGePoint3d* pVertexList, 01547 const Adesk::UInt32 faceListSize, 01548 const Adesk::Int32* pFaceList, 01549 const AcGiEdgeData* pEdgeData = NULL, 01550 const AcGiFaceData* pFaceData = NULL, 01551 const AcGiVertexData* pVertexData = NULL, 01552 const struct resbuf* pResBuf = NULL, 01553 const bool bAutoGenerateNormals = true 01554 ) const ; 01555 01556 virtual Adesk::Boolean text(const AcGePoint3d& position, 01557 const AcGeVector3d& normal, 01558 const AcGeVector3d& direction, 01559 const double height, 01560 const double width, 01561 const double oblique, 01562 const ACHAR* pMsg) const ; 01563 01564 virtual Adesk::Boolean text(const AcGePoint3d& position, 01565 const AcGeVector3d& normal, 01566 const AcGeVector3d& direction, 01567 const ACHAR* pMsg, 01568 const Adesk::Int32 length, 01569 const Adesk::Boolean raw, 01570 const AcGiTextStyle &pTextStyle 01571 ) const ; 01572 01573 virtual Adesk::Boolean xline(const AcGePoint3d&, 01574 const AcGePoint3d&) const ; 01575 01576 virtual Adesk::Boolean ray(const AcGePoint3d&, 01577 const AcGePoint3d&) const ; 01578 01579 virtual Adesk::Boolean pline(const AcDbPolyline& lwBuf, 01580 Adesk::UInt32 fromIndex = 0, 01581 Adesk::UInt32 numSegs = 0 01582 ) const ; 01583 01584 virtual Adesk::Boolean draw(AcGiDrawable*) const ; 01585 01586 virtual Adesk::Boolean pushClipBoundary(AcGiClipBoundary * pBoundary); 01587 virtual void popClipBoundary() ; 01588 01589 private: 01590 // Back pointer stored to the ViewPortDraw object. This class 01591 // uses it to store the ShellData when the shell member 01592 // function is called. ---- SK 18 mar 09 01593 HAcGiViewportDraw* m_pHAcGiViewportDraw; 01594 unsigned int m_uiOpenSegmentCount; 01595 01596 }; 01597 class HAcGiViewport : public AcGiViewport 01598 { 01599 public: 01600 ACRX_DECLARE_MEMBERS(AcGiViewport); 01601 HAcGiViewport(HInputHandlerOptions const * options = 0); 01602 ~HAcGiViewport(); 01603 01604 virtual void getModelToEyeTransform(AcGeMatrix3d& mx) const; 01605 virtual void getEyeToModelTransform(AcGeMatrix3d& mx) const; 01606 virtual void getWorldToEyeTransform(AcGeMatrix3d& mx) const; 01607 virtual void getEyeToWorldTransform(AcGeMatrix3d& mx) const; 01608 01609 virtual Adesk::Boolean isPerspective() const; 01610 virtual Adesk::Boolean doPerspective(AcGePoint3d&) const; 01611 virtual Adesk::Boolean doInversePerspective(AcGePoint3d&) const; 01612 01613 virtual void getNumPixelsInUnitSquare(const AcGePoint3d& givenWorldpt, 01614 AcGePoint2d& pixelArea, 01615 bool includePerspective = true) const; 01616 01617 virtual void getCameraLocation(AcGePoint3d& location) const; 01618 virtual void getCameraTarget(AcGePoint3d& target) const; 01619 virtual void getCameraUpVector(AcGeVector3d& upVector) const; 01620 01621 virtual Adesk::ULongPtr viewportId() const; 01622 virtual Adesk::Int16 acadWindowId() const; 01623 virtual void getViewportDcCorners(AcGePoint2d& lower_left, 01624 AcGePoint2d& upper_right) const; 01625 01626 virtual Adesk::Boolean getFrontAndBackClipValues(Adesk::Boolean& clip_front, 01627 Adesk::Boolean& clip_back, 01628 double& front, 01629 double& back) const; 01630 virtual double linetypeScaleMultiplier() const; 01631 virtual double linetypeGenerationCriteria() const; 01632 01633 virtual AcGeVector3d viewDir() const; 01634 01635 private: 01636 HInputHandlerOptions const * inputOptions; 01637 AcGePoint3d cameraTarget; 01638 AcGePoint3d cameraLocation; 01639 AcGeVector3d cameraUpVector; 01640 }; 01641 01642 class HDrawOrderHandler 01643 { 01644 public: 01645 HDrawOrderHandler(AcDbBlockTableRecord * pRecord) 01646 { 01647 m_pRecord = pRecord; 01648 m_pObj = 0; 01649 }; 01650 01651 int Open(); 01652 bool GetNextEntity(AcDbEntity *& pOutEnt); 01653 int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, HC_KEY block_key, HDWG_3dgsImporter * importer); 01654 int CheckDrawOrderAndSetVisibility(AcDbEntity * pEnt, TK_Open_Segment * include_seg_handler, HDWG_BStreamImporter * importer); 01655 void Close(); 01656 01657 protected: 01658 AcDbBlockTableRecord * m_pRecord; 01659 AcDbSortentsTable * m_pObj; 01660 AcDbObjectIdArray objArray; 01661 int m_iIndex; 01662 AcDbBlockTableRecordIterator * m_pRecordIter; 01663 01664 }; 01665 01666 wchar_t * h_dwg_wcsdup(wchar_t const * const wcs); 01667 01668 // Inline functions for HDWG_BStreamImporter calling opcodehandlers 01669 inline int HDWG_BStreamImporter::STREAM_Open_Segment(TK_Open_Segment* open_seg_handler, const char * seg_name) const 01670 { 01671 // Caller have to delete open_seg_handler, in this version. 01672 open_seg_handler->SetSegment(seg_name); 01673 TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01674 H_ASSERT(hdwg_status == TK_Normal); 01675 return 1; 01676 } 01677 01678 inline int HDWG_BStreamImporter::STREAM_Open_Segment(const char * seg_name) const 01679 { 01680 // Caller don't have to delete open_seg_handler, in this version. 01681 TK_Open_Segment* open_seg_handler = new TK_Open_Segment; 01682 open_seg_handler->SetSegment(seg_name); 01683 TK_Status hdwg_status = WriteObject(open_seg_handler,m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01684 H_ASSERT(hdwg_status == TK_Normal); 01685 delete open_seg_handler; 01686 01687 return 1; 01688 } 01689 01690 inline int HDWG_BStreamImporter:: STREAM_Close_Segment() const 01691 { 01692 TK_Close_Segment *close_seg_handler = new TK_Close_Segment; 01693 TK_Status hdwg_status = WriteObject(close_seg_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01694 H_ASSERT(hdwg_status == TK_Normal); 01695 delete close_seg_handler; 01696 01697 return 1; 01698 } 01699 01700 inline int HDWG_BStreamImporter:: STREAM_Set_Visibility(TKO_Geometry_Bits Geom_Bit, bool ifOn) const 01701 { 01702 //HC_Set_Visibility("off"); 01703 TK_Visibility *vis_handler = new TK_Visibility(); 01704 vis_handler->SetGeometry(Geom_Bit); 01705 if(ifOn) 01706 vis_handler->SetValue(1); 01707 else 01708 vis_handler->SetValue(0); 01709 TK_Status hdwg_status = WriteObject(vis_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01710 H_ASSERT(hdwg_status == TK_Normal); 01711 delete vis_handler; 01712 01713 return 1; 01714 } 01715 01716 inline int HDWG_BStreamImporter:: STREAM_Set_Heuristics(TKO_Heuristic_Bits Heuristic_Bit) const 01717 { 01718 //HC_Set_Heuristics("xxxx"); 01719 TK_Heuristics* heuristic_handler = new TK_Heuristics; 01720 heuristic_handler->SetMask( Heuristic_Bit); 01721 heuristic_handler->SetValue( Heuristic_Bit); 01722 TK_Status hdwg_status = WriteObject(heuristic_handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01723 H_ASSERT(hdwg_status == TK_Normal); 01724 delete heuristic_handler; 01725 01726 return 1; 01727 } 01728 inline int HDWG_BStreamImporter:: STREAM_Write_Object(BBaseOpcodeHandler * handler) const 01729 { 01730 TK_Status hdwg_status = WriteObject(handler, m_pBStreamtk, m_pHSFFile, m_pBStreamBuffer, m_nBStreamBuffSize); 01731 H_ASSERT(hdwg_status == TK_Normal); 01732 delete handler; 01733 01734 return 1; 01735 } 01736 01737 #ifdef H_PACK_8 01738 #pragma pack(pop) 01739 #endif 01740 01741 #endif