CurveProjector.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Juergen Riegel         <juergen.riegel@web.de>          *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 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         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef _CurveProjector_h_
00025 #define _CurveProjector_h_
00026 
00027 #ifdef FC_USE_GTS
00028 #  include <gts.h>
00029 #endif
00030 
00031 #include <gp_Pln.hxx>
00032 
00033 #include <Base/Vector3D.h>
00034 
00035 
00036 class TopoDS_Edge;
00037 class TopoDS_Shape;
00038 #include <TopoDS_Edge.hxx>
00039 
00040 #include <Mod/Mesh/App/Mesh.h>
00041 
00042 namespace MeshCore
00043 {
00044 class MeshKernel;
00045 class MeshGeomFacet;
00046 };
00047 
00048 using MeshCore::MeshKernel;
00049 using MeshCore::MeshGeomFacet;
00050 
00051 namespace MeshPart
00052 {
00053 
00056 class MeshPartExport CurveProjector
00057 {
00058 public:
00059   CurveProjector(const TopoDS_Shape &aShape, const MeshKernel &pMesh);
00060   virtual ~CurveProjector() {}
00061 
00062   struct FaceSplitEdge
00063   {
00064     unsigned long ulFaceIndex;
00065     Base::Vector3f p1,p2;
00066   };
00067 
00068   template<class T>
00069     struct TopoDSLess : public std::binary_function<T, T, bool> {
00070     bool operator()(const T& x, const T& y) const { 
00071       return x.HashCode(INT_MAX-1) < y.HashCode(INT_MAX-1);
00072     }
00073   };
00074 
00075   typedef std::map<TopoDS_Edge, std::vector<FaceSplitEdge>,TopoDSLess<TopoDS_Edge> > result_type;
00076 
00077 
00078   result_type &result(void) {return  mvEdgeSplitPoints;}
00079 
00080   void writeIntersectionPointsToFile(const char *name="export_pts.asc");
00081 
00082 protected:
00083   virtual void Do()=0;
00084   const TopoDS_Shape &_Shape;
00085   const MeshKernel &_Mesh;
00086   result_type mvEdgeSplitPoints;
00087 
00088 };
00089 
00090 
00093 class MeshPartExport CurveProjectorShape: public CurveProjector
00094 {
00095 public:
00096   CurveProjectorShape(const TopoDS_Shape &aShape, const MeshKernel &pMesh);
00097   virtual ~CurveProjectorShape() {}
00098 
00099   void projectCurve(const TopoDS_Edge& aEdge,
00100                     std::vector<FaceSplitEdge> &vSplitEdges);
00101 
00102   bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex);
00103 
00104 
00105 
00106 protected:
00107   virtual void Do();
00108 };
00109 
00110 
00111 
00114 class MeshPartExport CurveProjectorSimple: public CurveProjector
00115 {
00116 public:
00117   CurveProjectorSimple(const TopoDS_Shape &aShape, const MeshKernel &pMesh);
00118   virtual ~CurveProjectorSimple() {}
00119 
00121   void GetSampledCurves( const TopoDS_Edge& aEdge, std::vector<Base::Vector3f>& rclPoints, unsigned long ulNbOfPoints = 30);
00122 
00123 
00124   void projectCurve(const TopoDS_Edge& aEdge,
00125                     const std::vector<Base::Vector3f> &rclPoints,
00126                     std::vector<FaceSplitEdge> &vSplitEdges);
00127 
00128   bool findStartPoint(const MeshKernel &MeshK,const Base::Vector3f &Pnt,Base::Vector3f &Rslt,unsigned long &FaceIndex);
00129 
00130 
00131 
00132 protected:
00133   virtual void Do();
00134 };
00135 
00138 class MeshPartExport CurveProjectorWithToolMesh: public CurveProjector
00139 {
00140 public:
00141   struct LineSeg {
00142     Base::Vector3f p;
00143     Base::Vector3f n;
00144   };
00145 
00146   CurveProjectorWithToolMesh(const TopoDS_Shape &aShape, const MeshKernel &pMesh,MeshKernel &rToolMesh);
00147   virtual ~CurveProjectorWithToolMesh() {}
00148 
00149 
00150   void makeToolMesh(const TopoDS_Edge& aEdge,std::vector<MeshGeomFacet> &cVAry );
00151 
00152 
00153   MeshKernel &ToolMesh;
00154 
00155 protected:
00156   virtual void Do();
00157 };
00158 
00159 } // namespace MeshPart
00160 
00161 #endif

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