edgesort.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007                                                    *
00003  *   Joachim Zettler <Joachim.Zettler@gmx.de>                              *
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 EDGESORT_H
00025 #define EDGESORT_H
00026 
00027 #include <gp_Pnt.hxx>
00028 #include <TopoDS_Edge.hxx>
00029 #include <Base/BoundBox.h>
00030 #include <list>
00031 #include <map>
00032 
00033 struct Edgesort_gp_Pnt_Less
00034 {
00035     bool operator()(const gp_Pnt & _Left, const gp_Pnt & _Right) const
00036     {
00037         Standard_Real x1,y1,z1,x2,y2,z2;
00038         _Left.Coord(x1,y1,z1);
00039         _Right.Coord(x2,y2,z2);
00040         if ( fabs(x1- x2) > 0.2 )
00041             return x1 < x2;
00042         else if ( fabs(y1 -y2) > 0.2 )
00043             return y1 < y2;
00044         else if ( fabs(z1 -z2) > 0.2 )
00045             return z1 < z2;
00046         return false;
00047     }
00048 };
00049 
00050 struct EdgeSortBoundBox_Less
00051 {
00052     bool operator()(const Base::BoundBox3f& _Left, const Base::BoundBox3f& _Right) const
00053     {
00054         if (_Left.IsInBox(_Right)) return false;
00055 
00056         return true;
00057     }
00058 };
00059 
00060 typedef std::vector<TopoDS_Edge> tEdgeVector;
00061 typedef std::map<gp_Pnt,tEdgeVector,Edgesort_gp_Pnt_Less>  tMapPntEdge;
00062 typedef std::pair<gp_Pnt,tEdgeVector> tMapPntEdgePair;
00063 typedef std::map<Base::BoundBox3f,std::vector<TopoDS_Edge>,EdgeSortBoundBox_Less> tEdgeBBoxMap;
00064 typedef std::pair<Base::BoundBox3f,std::vector<TopoDS_Edge> >tEdgeBBoxPair;
00065 
00066 class Edgesort
00067 {
00068 public:
00069     Standard_EXPORT Edgesort(const TopoDS_Shape& aShape);
00070     Standard_EXPORT virtual ~Edgesort(void);
00071 
00072     Standard_EXPORT void Init();
00073     Standard_EXPORT void ReInit(const TopoDS_Shape& aShape);
00074     Standard_EXPORT bool More();
00075     Standard_EXPORT bool MoreEdge();
00076     Standard_EXPORT void Next();
00077     Standard_EXPORT const TopoDS_Edge& NextEdge();
00078     Standard_EXPORT const TopoDS_Edge& Current();
00079     Standard_EXPORT TopoDS_Shape GetDesiredCutShape(int desiredIndex);
00080 private:
00081     void Perform();
00082     void Perform(const TopoDS_Edge& edge);
00083     bool PerformEdges(gp_Pnt& point);
00084     bool IsValidEdge(const TopoDS_Edge& edge);
00085     Base::BoundBox3f getBoundingBox(std::vector<TopoDS_Edge>& aList);
00086 
00087     TopoDS_Shape m_shape;
00088 
00089     tMapPntEdge m_vertices;
00090     tEdgeBBoxMap m_EdgeBBoxMap;
00091     bool m_done;
00092     bool m_asecondwire;
00093     bool m_whichedgelist;
00094     tEdgeVector m_edges;
00095     //BoundingBox m_edges, m_edges2
00096     tEdgeVector::const_iterator m_edgeIter;
00097 
00098 };
00099 
00100 #endif
00101 

Generated on Wed Nov 23 19:00:10 2011 for FreeCAD by  doxygen 1.6.1