00001 //------------------------------------------------------------------- 00004 // Copyright (c) 2007 Celeritive Technologies, Inc. 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License, or (at your option) any later version. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 //------------------------------------------------------------------- 00021 #pragma once 00022 #ifndef VOLUMILL_DXFLIB_H 00023 #define VOLUMILL_DXFLIB_H 00024 00025 #include <Geom/Curve.h> 00026 #include <Exchange/VoluMillExchange.h> 00027 #include <Exchange/ToolpathRecords.h> 00028 #include <dl_creationadapter.h> 00029 #include <dl_dxf.h> 00030 00031 namespace exchange 00032 { 00033 00034 const int CURVE_IGNORED = 0; 00035 const int CURVE_PART = 1; 00036 const int CURVE_MATERIAL = 2; 00037 00038 class DXFReader : public DL_CreationAdapter { 00039 public: 00040 DXFReader (exchange::VoluMill2dInput* pInput) : m_pInput (pInput) {} 00041 DXFReader (const std::map<std::string, int>& layerMap, exchange::VoluMill2dInput* pInput) 00042 : m_layerMap (layerMap), m_pInput (pInput) {} 00043 virtual void addLine(const DL_LineData& data); 00044 virtual void addArc(const DL_ArcData& data); 00045 virtual void addCircle(const DL_CircleData& data); 00046 00047 //void printAttributes(); 00048 private: 00049 std::map<std::string, int> m_layerMap; 00050 exchange::VoluMill2dInput* m_pInput; 00051 }; 00052 00053 class DXFLayerReader : public DL_CreationAdapter 00054 { 00055 public: 00056 virtual void addLayer (const DL_LayerData& data); 00057 std::vector<std::string> m_layers; 00058 }; 00059 00060 class DXFWriter 00061 { 00062 public: 00063 DXFWriter (const exchange::VoluMill2dInput& input) : m_input (input) {} 00064 void operator ()(const char* fileName); 00065 private: 00066 const exchange::VoluMill2dInput& m_input; 00067 }; 00068 00069 class DXFToolpathRecordWriter 00070 { 00071 public: 00072 DXFToolpathRecordWriter (const exchange::ToolpathRecords& records) : m_records (records) {} 00073 void operator ()(const char* fileName); 00074 private: 00075 const exchange::ToolpathRecords& m_records; 00076 }; 00077 } 00078 #endif