Common/Exchange/ToolpathRecords.h

Go to the documentation of this file.
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_TOOLPATHRECORDS_H
00023 #define VOLUMILL_TOOLPATHRECORDS_H
00024 
00025 #include <vector>
00026 #include <boost/variant.hpp>
00027 #include <Geom/Points.h>
00028 
00029 namespace exchange
00030 {
00031    struct RapidMove
00032    {
00033       RapidMove () {}
00034       RapidMove (const geom::Point3d& endPt) : m_endPt (endPt) {}
00035       template<class Archive>
00036       void serialize(Archive & ar, const unsigned int /*version*/)
00037       {
00038          ar & boost::serialization::make_nvp ("endPt", m_endPt);
00039       }
00040       geom::Point3d m_endPt;
00041    };
00042 
00043    struct LinearMove
00044    {
00045       LinearMove() {}
00046       LinearMove (const geom::Point3d& endPt) : m_endPt (endPt) {}
00047       template<class Archive>
00048       void serialize(Archive & ar, const unsigned int /*version*/)
00049       {
00050          ar & boost::serialization::make_nvp ("endPt", m_endPt);
00051       }
00052       geom::Point3d m_endPt;
00053    };
00054 
00056    template<bool CW>
00057    struct Arc
00058    {
00059       Arc() : m_radius (0) {}
00060       Arc (const geom::Point3d& endPt, double radius) : m_endPt (endPt), m_radius (radius) {}
00061       template<class Archive>
00062       void serialize(Archive & ar, const unsigned int /*version*/)
00063       {
00064          ar & boost::serialization::make_nvp ("endPt", m_endPt);
00065          ar & boost::serialization::make_nvp ("radius", m_radius);
00066       }
00067       geom::Point3d m_endPt;
00068       double m_radius;
00069    };
00070 
00071    typedef Arc<true> ArcCW;
00072    typedef Arc<false> ArcCCW;
00073 
00074    struct FeedRate
00075    {
00076       FeedRate (double feedrate = 0.0) : m_feedrate (feedrate) {}
00077       template<class Archive>
00078       void serialize(Archive & ar, const unsigned int /*version*/)
00079       {
00080          ar & boost::serialization::make_nvp ("feedrate", m_feedrate);
00081       }
00082       double m_feedrate;
00083    };
00084 
00085    struct Warning
00086    {
00087       Warning (int warningId = -1) : m_warningId (warningId) {}
00088       template<class Archive>
00089       void serialize(Archive & ar, const unsigned int /*version*/)
00090       {
00091          ar & boost::serialization::make_nvp ("warningId", m_warningId);
00092       }
00093       int m_warningId;
00094    };
00095 
00096    struct CustomRecord
00097    {
00098       CustomRecord() {}
00099       CustomRecord (const std::string& str) : m_string (str) {}
00100       template<class Archive>
00101       void serialize(Archive & ar, const unsigned int /*version*/)
00102       {
00103          ar & boost::serialization::make_nvp ("string", m_string);
00104       }
00105       std::string m_string;
00106    };
00107 
00108    typedef boost::variant<
00109       RapidMove,
00110       LinearMove,
00111       ArcCW,
00112       ArcCCW,
00113       FeedRate,
00114       Warning,
00115       CustomRecord> ToolpathRecord;
00116 
00117    struct ToolpathRecords : public std::vector<ToolpathRecord>
00118    {
00119       template<class Archive>
00120       void serialize(Archive & ar, const unsigned int /*version*/)
00121       {
00122          typedef std::vector<ToolpathRecord> Records;
00123          ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Records);
00124       }
00125    };
00126 
00127    void fromToolpathRecordsToXml (std::ostream& os, const ToolpathRecords& records);
00128    void fromXmlToToolpathRecords (std::istream& is, ToolpathRecords* pRecords);
00129    void fromToolpathRecordsToBinary (std::ostream& os, const ToolpathRecords& records);
00130    void fromBinaryToToolpathRecords (std::istream& is, ToolpathRecords* pRecords);
00131 }
00132 
00133 #endif

Generated on Tue Jan 29 21:37:56 2008 for VoluMill Universal Client by  doxygen 1.4.6