edgecluster.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 
00025 #ifndef PART_EDGECLUSTER_H
00026 #define PART_EDGECLUSTER_H
00027 
00028 #include <gp_Pnt.hxx>
00029 #include <TopoDS_Edge.hxx>
00030 #include <vector>
00031 #include <map>
00032 
00033 
00034 namespace Part {
00035 
00036 struct Edgesort_gp_Pnt_Less
00037 {
00038     bool operator()(const gp_Pnt & _Left, const gp_Pnt & _Right) const
00039     {
00040         Standard_Real x1,y1,z1,x2,y2,z2;
00041         _Left.Coord(x1,y1,z1);
00042         _Right.Coord(x2,y2,z2);
00043         if ( fabs(x1- x2) > 0.2 )
00044             return x1 < x2;
00045         else if ( fabs(y1 -y2) > 0.2 )
00046             return y1 < y2;
00047         else if ( fabs(z1 -z2) > 0.2 )
00048             return z1 < z2;
00049         return false;
00050     }
00051 };
00052 
00053 
00054 typedef std::vector<TopoDS_Edge> tEdgeVector;
00055 typedef std::map<gp_Pnt,tEdgeVector,Edgesort_gp_Pnt_Less>  tMapPntEdge;
00056 typedef std::pair<gp_Pnt,tEdgeVector> tMapPntEdgePair;
00057 typedef std::vector<std::vector<TopoDS_Edge> > tEdgeClusterVector;
00058 
00059 
00060 class PartExport Edgecluster
00061 {
00062 public:
00063     Edgecluster(const std::vector<TopoDS_Edge>& usorted_edges);
00064     virtual ~Edgecluster(void);
00065 
00066     tEdgeClusterVector GetClusters(void);
00067 
00068 private:
00069     void Perform();
00070     void Perform(const TopoDS_Edge& edge);
00071     bool PerformEdges(gp_Pnt& point);
00072     bool IsValidEdge(const TopoDS_Edge& edge);
00073 
00074     tEdgeClusterVector m_final_cluster;
00075     tEdgeVector m_unsortededges;
00076     tEdgeVector m_edges;
00077 
00078     tMapPntEdge m_vertices;
00079     bool m_done;
00080 
00081     tEdgeVector::const_iterator m_edgeIter;
00082 
00083 };
00084 
00085 }
00086 
00087 #endif // PART_EDGECLUSTER_H

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