SpringbackCorrection.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 _SpringbackCorrection_H_
00025 #define _SpringbackCorrection_H_
00026
00027
00028 #include <Mod/Mesh/App/Core/TopoAlgorithm.h>
00029 #include "cutting_tools.h"
00030
00038 class MeshFacet;
00039
00040
00041
00042
00043 # define cMin 15.0
00044 # define toolRad 5.0
00045
00054 struct EdgeStruct
00055 {
00056 TopoDS_Edge anEdge;
00057 std::vector<TopoDS_Face> aFace;
00058 std::vector<gp_Pnt> pntList;
00059 double MaxOffset;
00060 double MinOffset;
00061 };
00062
00072 struct MeshPnt
00073 {
00074 int index;
00075 double minCurv;
00076 double maxCurv;
00077 double error;
00078 Base::Vector3f pnt;
00079 Base::Vector3f normal;
00080 };
00081
00089 struct FacePnt
00090 {
00091 Base::Vector3f pnt;
00092 std::vector<double> distances;
00093 std::vector<double> MinEdgeOff;
00094 std::vector<double> MaxEdgeOff;
00095 };
00096
00097 struct EdgeStruct_Less
00098 {
00099 bool operator()(const EdgeStruct& _Left, const EdgeStruct& _Right) const
00100 {
00101
00102 if (_Left.anEdge.IsSame(_Right.anEdge)) return false;
00103
00104 return true;
00105 }
00106 };
00107
00108 struct Edge_Less
00109 {
00110 bool operator()(const TopoDS_Edge& _Left, const TopoDS_Edge& _Right) const
00111 {
00112 return(_Left.HashCode(IntegerLast())<_Right.HashCode(IntegerLast()));
00113 }
00114 };
00115
00116
00117
00118
00119 struct MeshPntLess
00120 {
00121 bool operator()(const Base::Vector3f& _Left, const Base::Vector3f& _Right) const
00122 {
00123 if ( fabs(_Left.x - _Right.x) > 0.0001 )
00124 return _Left.x < _Right.x;
00125 else if ( fabs(_Left.y - _Right.y) > 0.0001)
00126 return _Left.y < _Right.y;
00127 else if ( fabs(_Left.z - _Right.z) > 0.0001 )
00128 return _Left.z < _Right.z;
00129 return false;
00130
00131 }
00132 };
00133
00134 class CamExport SpringbackCorrection : public MeshCore::MeshFacetVisitor
00135 {
00136 public:
00138 SpringbackCorrection();
00144 SpringbackCorrection(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh);
00146
00147
00148 ~SpringbackCorrection();
00150 bool Load(const MeshCore::MeshKernel& aMesh);
00152 bool Load(const TopoDS_Shape& aShape);
00154 bool Load(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh);
00158 bool Init();
00160 bool Init_Setting(struct CuttingToolsSettings& set);
00161
00168 bool Perform(int deg_Tol, bool out);
00169
00171 bool SetFixEdges();
00174 bool CalcCurv();
00175
00182 std::vector<double> MeshCurvature(const TopoDS_Face& aFace, const MeshCore::MeshKernel& mesh);
00183
00187 bool GetCurvature(TopoDS_Face aFace);
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00205 int GetBoundary(const MeshCore::MeshKernel &mesh, MeshCore::MeshPointArray &meshPnts);
00206
00213 bool SmoothMesh(MeshCore::MeshKernel &mesh, double maxTranslation);
00222 bool SmoothMesh(MeshCore::MeshKernel &mesh, std::vector<int> indicies, double maxTranslation);
00229
00236 std::vector<int> FaceCheck(MeshCore::MeshKernel &mesh, int deg_tol);
00243 std::vector<int> InitFaceCheck(MeshCore::MeshKernel &mesh, int deg_tol);
00244
00245
00246
00247
00248
00250 bool FacetRegionGrowing(MeshCore::MeshKernel &mesh,
00251 std::vector<MeshCore::MeshFacet> &arr,
00252 MeshCore::MeshFacetArray &mFacets);
00253
00254
00256 bool Visit(const MeshCore::MeshFacet &rclFacet, const MeshCore::MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel);
00257
00263 bool TransferFaceTriangulationtoFreeCAD(const TopoDS_Face& aFace, MeshCore::MeshKernel& TFaceMesh);
00264
00267 std::vector< std::pair<unsigned long, double> > RegionEvaluate(const MeshCore::MeshKernel &mesh, std::vector<unsigned long> &RegionFacets, std::vector<Base::Vector3f> &normals);
00268
00270 MeshCore::MeshKernel m_Mesh;
00273 MeshCore::MeshKernel m_Mesh_vis;
00275 MeshCore::MeshKernel m_Mesh_vis2;
00277 MeshCore::MeshKernel m_CadMesh;
00279 std::vector<Base::Vector3f> m_dist_vec;
00280
00281 private:
00282
00284 TopoDS_Shape m_Shape;
00287 std::vector<double> m_CurvPos;
00290 std::vector<double> m_CurvNeg;
00292 std::vector<double> m_CurvMax;
00294 std::vector<EdgeStruct> m_EdgeStruct;
00297 std::vector<unsigned long> m_RingVector;
00300 std::vector< std::vector<unsigned long> > m_RegionVector;
00303 std::vector< std::vector<unsigned long> > m_Regions;
00305
00307 CuttingToolsSettings m_set;
00310 int m_RingCurrent;
00311 private:
00313 std::vector<MeshCore::MeshKernel> m_MeshVec;
00315 MeshCore::MeshKernel MeshRef;
00317
00319 std::vector<Base::Vector3f> m_normals;
00322 std::vector<double> m_error;
00324 std::vector<double> m_FaceAng;
00326 std::vector<MeshPnt> m_MeshStruct;
00329 std::vector<double> m_Offset;
00330 public:
00332 std::map<Base::Vector3f,MeshPnt,MeshPntLess > MeshMap;
00334 std::map<TopoDS_Edge, std::vector<double>, Edge_Less> EdgeMap;
00335
00338 std::vector<TopoDS_Face> m_FixFaces;
00339 };
00340
00341 #endif