best_fit.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
00025 #ifndef BEST_FIT_H
00026 #define BEST_FIT_H
00027
00028
00029 #include <Mod/Mesh/App/Core/Approximation.h>
00030 #include <Mod/Mesh/App/Core/Evaluation.h>
00031 #include <Mod/Mesh/App/Core/MeshKernel.h>
00032 #include <Base/Exception.h>
00033 #include <gp_Vec.hxx>
00034 #include <TopoDS_Shape.hxx>
00035 #include <TopoDS_Face.hxx>
00036 #include <SMESH_Mesh.hxx>
00037 #include <SMDS_VolumeTool.hxx>
00038
00039
00040 #define SMALL_NUM 1e-6
00041 #define ERR_TOL 0.001 // Abbruchkriterium für Least-Square-Matching (Fehleränderung zweier aufeinanderfolgenden Iterationsschritten)
00042
00043
00053 class CamExport best_fit
00054 {
00055 public:
00056 best_fit();
00057 ~best_fit();
00058
00064 void Load(const MeshCore::MeshKernel &InputMesh, const TopoDS_Shape &CAD_Shape);
00065
00066 bool Initialize_Mesh_Geometrie_1();
00067 bool Initialize_Mesh_Geometrie_2();
00068
00072 bool MeshFit_Coarse();
00073
00077 bool ShapeFit_Coarse();
00078
00082 bool PointCloud_Coarse();
00083
00085 bool Perform();
00086
00088 bool Perform_PointCloud();
00089
00090 bool output_best_fit_mesh();
00091
00092
00093
00094
00095
00096
00097
00101 double CompTotalError();
00102
00107 double CompTotalError(MeshCore::MeshKernel &mesh);
00108
00116 static bool Tesselate_Shape(const TopoDS_Shape &shape, MeshCore::MeshKernel &mesh, float deflection);
00117
00125 static bool Tesselate_Face (const TopoDS_Face &aface, MeshCore::MeshKernel &mesh, float deflection);
00126
00132 static std::vector<Base::Vector3f> Comp_Normals(MeshCore::MeshKernel &Mesh);
00133
00137 bool Coarse_correction();
00138
00142 double ANN();
00143
00145 TopoDS_Shape m_Cad;
00146
00148 MeshCore::MeshKernel m_Mesh;
00149
00151 MeshCore::MeshKernel m_MeshWork;
00152
00154 MeshCore::MeshKernel m_CadMesh;
00155
00156
00157 std::vector<Base::Vector3f> m_pntCloud_1;
00158 std::vector<Base::Vector3f> m_pntCloud_2;
00159
00160
00162 std::vector<Base::Vector3f> m_pnts;
00163
00165 std::vector<Base::Vector3f> m_normals;
00166
00168 std::vector<double> m_error;
00169
00171 std::vector<std::vector<Base::Vector3f> > m_LSPnts;
00172
00174 std::vector<double> m_weights;
00175
00177 std::vector<double> m_weights_loc;
00178
00180 gp_Vec m_cad2orig;
00181
00183 std::vector<TopoDS_Face> m_LowFaces;
00184
00185 private:
00193 inline bool RotMat(Base::Matrix4D &matrix, double degree, int rotationAxis);
00194
00202 inline bool TransMat(Base::Matrix4D &matrix, double translation, int translationAxis);
00203
00211 inline bool PointNormalTransform(std::vector<Base::Vector3f> &pnts,
00212 std::vector<Base::Vector3f> &normals,
00213 Base::Matrix4D &M);
00214
00220 bool PointTransform(std::vector<Base::Vector3f> &pnts, const Base::Matrix4D &M);
00221
00223 bool Comp_Weights();
00224
00226 bool LSM();
00227
00234 std::vector<double> Comp_Jacobi(const std::vector<double> ¶ms);
00235
00243 std::vector<std::vector<double> > Comp_Hess (const std::vector<double> ¶ms);
00244
00245 SMESH_Mesh *m_referencemesh;
00246 SMESH_Mesh *m_meshtobefit;
00247 SMESH_Gen *m_aMeshGen1;
00248 SMESH_Gen *m_aMeshGen2;
00249
00250
00251
00252
00253
00254 };
00255
00256 #endif