edgesort.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00096 tEdgeVector::const_iterator m_edgeIter;
00097
00098 };
00099
00100 #endif
00101