WireExplorer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007                                                    *
00003  *   Stephane Routelous <stephane.routelous@exotk.org                      *
00004  *                                                                         *
00005  *   This file is part of the FreeCAD CAx development system.              *
00006  *                                                                         *
00007  *   This library is free software; you can redistribute it and/or         *
00008  *   modify it under the terms of the GNU Library General Public           *
00009  *   License as published by the Free Software Foundation; either          *
00010  *   version 2 of the License, or (at your option) any later version.      *
00011  *                                                                         *
00012  *   This library  is distributed in the hope that it will be useful,      *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU Library General Public License for more details.                  *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU Library General Public     *
00018  *   License along with this library; see the file COPYING.LIB. If not,    *
00019  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00020  *   Suite 330, Boston, MA  02111-1307, USA                                *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef WIREEXPLORER_H
00025 #define WIREEXPLORER_H
00026 
00027 #include <TopoDS_Wire.hxx>
00028 #include <TopoDS_Edge.hxx>
00029 #include <gp_Pnt.hxx>
00030 #include <TopTools_MapOfShape.hxx>
00031 #include <map>
00032 #include <list>
00033 #include <vector>
00034 
00035 struct WireExplorer_gp_PntLess
00036 {
00037     bool operator()(const gp_Pnt& _Left, const gp_Pnt& _Right) const
00038     {
00039         Standard_Real x1,y1,z1,x2,y2,z2;
00040         _Left.Coord(x1,y1,z1);
00041         _Right.Coord(x2,y2,z2);
00042         if ( x1 != x2 )
00043             return x1 < x2;
00044         else if ( y1 != y2 )
00045             return y1 < y2;
00046         return z1 < z2;
00047     }
00048 };
00049 
00050 typedef std::vector<TopoDS_Edge> tEdgeVector;
00051 typedef std::map<gp_Pnt,tEdgeVector,WireExplorer_gp_PntLess>  tMapPntShapes;
00052 typedef std::pair<gp_Pnt,tEdgeVector> tMapPntShapesPair;
00053 
00054 class WireExplorer
00055 {
00056 public:
00057     Standard_EXPORT WireExplorer(const TopoDS_Wire& wire);
00058     Standard_EXPORT virtual ~WireExplorer(void);
00059 
00060     Standard_EXPORT void Init();
00061     Standard_EXPORT bool More();
00062     Standard_EXPORT bool MoreEdge();
00063     Standard_EXPORT void Next();
00064     Standard_EXPORT const TopoDS_Edge& NextEdge();
00065     Standard_EXPORT const TopoDS_Edge& Current();
00066 private:
00067     void Perform();
00068     void Perform(const TopoDS_Edge& edge);
00069     bool PerformEdges(gp_Pnt& point);
00070     bool IsValidEdge(const TopoDS_Edge& edge);
00071     TopoDS_Wire m_wire;
00072 
00073     tMapPntShapes m_vertices;
00074 
00075     bool m_done;
00076     tEdgeVector m_edges;
00077     tEdgeVector::const_iterator m_edgeIter;
00078 };
00079 
00080 #endif
00081 

Generated on Wed Nov 23 19:01:02 2011 for FreeCAD by  doxygen 1.6.1