WhipExamples/WriteBlocks.cpp

00001 //
00002 //  Copyright (c) 2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
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 Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 
00022 #include "whiptk/whip_toolkit.h"
00023 #include "whiptk/w2d_class_factory.h"
00024 
00025 void WriteBlocks()
00026 {
00027     WT_W2D_Class_Factory cf;
00028 
00029     WT_File *file1 = cf.Create_File(), *file2 = cf.Create_File(), *file = cf.Create_File();
00030     if (file == NULL)
00031         return;
00032     if (file1 == NULL)
00033         return;
00034     if (file2 == NULL)
00035         return;
00036 
00037     file->set_filename("c:\\test.dwf");
00038     file->heuristics().set_target_version(55);
00039 
00040     file1->set_filename("c:\\test1.dwf");
00041     file1->heuristics().set_target_version(55);
00042 
00043     file2->set_filename("c:\\test2.dwf");
00044     file2->heuristics().set_target_version(55);
00045 
00046     file->set_file_mode(WT_File::Block_Write);
00047     file->open();
00048 
00049     WT_BlockRef graphics_ref;
00050     graphics_ref.set_format(WT_BlockRef::Graphics);
00051 
00052     GUID _guid;
00053     CoCreateGuid(&_guid);
00054     WD_GUID guid;
00055     memcpy(&guid,&_guid,sizeof(guid));
00056 
00057     WT_Guid graphics_block_guid(guid);
00058     graphics_ref.set_block_guid(graphics_block_guid);
00059 
00060     FILETIME ft;
00061     GetSystemTimeAsFileTime(&ft);
00062 
00063     WT_FileTime graphics_creation_time(ft.dwLowDateTime, ft.dwHighDateTime);
00064     graphics_ref.set_creation_time(graphics_creation_time);
00065 
00066     WT_FileTime graphics_modification_time(ft.dwLowDateTime, ft.dwHighDateTime);
00067     graphics_ref.set_modification_time(graphics_modification_time);
00068     graphics_ref.set_validity(WD_True);
00069 
00070     file->desired_rendition().blockref() = graphics_ref;
00071     file->write_block(*file1);
00072 
00073     WT_BlockRef overlay_ref;
00074     overlay_ref.set_format(WT_BlockRef::Overlay);
00075 
00076     CoCreateGuid(&_guid);
00077     memcpy(&guid,&_guid,sizeof(guid));
00078 
00079     WT_Guid overlay_block_guid(guid);
00080     overlay_ref.set_block_guid(overlay_block_guid);
00081 
00082     WT_FileTime overlay_creation_time(ft.dwLowDateTime, ft.dwHighDateTime);
00083     overlay_ref.set_creation_time(overlay_creation_time);
00084 
00085     WT_FileTime overlay_modification_time(ft.dwLowDateTime, ft.dwHighDateTime);
00086     overlay_ref.set_modification_time(overlay_modification_time);
00087     overlay_ref.set_validity(WD_True);
00088 
00089     file->desired_rendition().blockref() = overlay_ref;
00090 
00091     file->write_block(*file2);
00092     file->close();
00093     
00094     cf.Destroy( file );
00095     cf.Destroy( file1 );
00096     cf.Destroy( file2 );
00097     
00098 }

Generated on Tue Jan 6 22:41:12 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5