00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef Cutting_Tools
00029 #define Cutting_Tools
00030
00031
00032 #include <Handle_Geom_BSplineCurve.hxx>
00033 #include <TColgp_Array1OfVec.hxx>
00034 #include <Handle_TColgp_HArray1OfPnt.hxx>
00035 #include <Base/BoundBox.h>
00036 #include <Mod/Mesh/App/Core/MeshKernel.h>
00037 #include <map>
00038
00039 #include "stuff.h"
00040
00041 namespace MeshCore {
00042 class MeshAlgorithm;
00043 class MeshFacetGrid;
00044 }
00045
00051 struct CuttingToolsSettings
00052 {
00054 float limit_angle;
00057 float cad_radius;
00059 float master_radius;
00061 float slave_radius;
00063 float level_distance;
00065 float correction_factor;
00067 float sheet_thickness;
00069 float max_Vel;
00071 float max_Acc;
00073 int spring_pretension;
00075 float y_offset_robot;
00077 float x_offset_robot;
00079 float error_tolerance;
00080
00083 bool clockwise;
00084 };
00085
00087 struct SpiralHelper
00088 {
00090 gp_Pnt SurfacePoint;
00092 gp_Vec LineD1;
00094 gp_Vec SurfaceNormal;
00095 };
00096
00097 struct BoundBox3f_Less
00098 {
00099 bool operator()(const Base::BoundBox3f& _Left, const Base::BoundBox3f& _Right) const
00100 {
00101 if (_Left.IsInBox(_Right)) return false;
00102
00103 return true;
00104 }
00105 };
00106
00107 struct Face_Less
00108 {
00109 bool operator()(const TopoDS_Face& _Left, const TopoDS_Face& _Right) const
00110 {
00111 return(_Left.HashCode(IntegerLast())<_Right.HashCode(IntegerLast()));
00112 }
00113 };
00114
00115
00116
00117
00123 class CamExport cutting_tools
00124 {
00125 public:
00130 cutting_tools(TopoDS_Shape aShape);
00131
00138 cutting_tools(TopoDS_Shape aShape, float pitch);
00139
00141 ~cutting_tools();
00142
00143 TopoDS_Wire ordercutShape(const TopoDS_Shape &aShape);
00144 double GetEdgeLength(const TopoDS_Edge& anEdge);
00145 bool OffsetWires_Standard();
00146 bool OffsetWires_FeatureBased();
00147 bool OffsetWires_Spiral();
00148
00149 bool SetMachiningOrder(const TopoDS_Face &aFace, float x,float y,float z);
00150
00151
00152
00153
00154
00156 bool arrangecuts_ZLEVEL();
00157
00158 bool calculateAccurateSlaveZLevel(std::vector<std::pair<gp_Pnt,double> >&OffsetPoints, double current_z_level, double &slave_z_level, double &average_sheet_thickness,double &average_angle, bool &cutpos);
00159
00160 bool initializeMeshStuff();
00161 bool arrangecuts_SPIRAL();
00162 bool arrangecuts_FEATURE_BASED();
00163 inline const std::vector<Handle_Geom_BSplineCurve>* getOutputhigh()
00164 {
00165 return &m_all_offset_cuts_high;
00166 }
00167 inline const std::vector<Handle_Geom_BSplineCurve>* getOutputlow()
00168 {
00169 return &m_all_offset_cuts_low;
00170 }
00171 inline std::vector<std::pair<float,TopoDS_Shape> > getCutShape()
00172 {
00173 return m_ordered_cuts;
00174 }
00175
00176 std::vector<float> getFlatAreas();
00177 CuttingToolsSettings m_UserSettings;
00178
00179 private:
00180
00181 bool CheckEdgeTangency(const TopoDS_Edge& edge1, const TopoDS_Edge& edge2);
00182 bool CheckPoints(Handle(TColgp_HArray1OfPnt) PointArray);
00183 bool getShapeBB();
00184 bool fillFaceWireMap();
00185 bool CheckforLastPoint(const gp_Pnt& lastPoint,int &start_index,int &start_array,const std::vector<std::vector<std::pair<gp_Pnt,double> > >& MasterPointsStorage);
00186 bool CheckforLastPoint(const gp_Pnt& lastPoint,int &start_index,int &start_array,const std::vector<std::vector<gp_Pnt> >& SlavePointsStorage);
00187 bool CheckforLastPoint(const gp_Pnt& lastPoint, int &start_index_master,int &start_array_master,int &start_index_slave,int &start_array_slave,const std::vector<std::vector<std::pair<gp_Pnt,double> > >& MasterPointsStorage, const std::vector<std::vector<gp_Pnt> >& SlavePointsStorage);
00188 TopoDS_Shape getProperCut(TopoDS_Shape& aShape);
00189 Handle_Geom_BSplineCurve InterpolateOrderedPoints(Handle(TColgp_HArray1OfPnt) InterpolationPoints,const bool direction);
00190
00191
00192 bool fillFaceBBoxes();
00193 Base::BoundBox3f getWireBBox(TopoDS_Wire aWire);
00194 bool checkPointinFaceBB(const gp_Pnt &aPnt,const Base::BoundBox3f &aBndBox);
00195 bool classifyShape();
00196
00197
00198 bool cut(float z_level, float min_level, TopoDS_Shape &aCutShape,float &z_level_corrected);
00199 bool cut_Mesh(float z_level, float min_level, std::list<std::vector<Base::Vector3f> > &result,float &z_level_corrected);
00200 std::vector<SpiralHelper> OffsetSpiral(const std::vector<SpiralHelper>& SpiralPoints,bool master_or_slave=true);
00201 gp_Dir getPerpendicularVec(gp_Vec& anInput);
00202 std::vector<std::pair<float,TopoDS_Shape> > m_ordered_cuts;
00203 std::vector<std::pair<TopoDS_Face,Base::BoundBox3f> > m_face_bboxes;
00204 std::vector<std::pair<TopoDS_Face,Base::BoundBox3f> >::iterator m_face_bb_it;
00205
00206 std::vector<Handle_Geom_BSplineCurve> m_all_offset_cuts_high,m_all_offset_cuts_low;
00207
00208 std::map<TopoDS_Face,std::map<Base::BoundBox3f,TopoDS_Wire,BoundBox3f_Less>,Face_Less > m_FaceWireMap;
00209 std::vector<std::pair<float,TopoDS_Shape> >::iterator m_ordered_cuts_it;
00210
00211
00212 bool m_cad;
00213 TopoDS_Shape m_Shape;
00214 MeshCore::MeshKernel m_CAD_Mesh;
00215 MeshCore::MeshAlgorithm * m_aMeshAlgo;
00216 MeshCore::MeshFacetGrid * m_CAD_Mesh_Grid;
00217 bool m_mirrortobothsides;
00218
00219
00220
00221 float m_pitch;
00222
00223 float m_minlevel,m_maxlevel;
00224
00225 float m_radius,m_radius_slave;
00226
00227 float m_sheet_thickness;
00228 bool m_direction;
00229 std::vector<std::pair<Base::Vector3f,TopoDS_Face> > m_MachiningOrder;
00230
00231
00232
00233
00234
00235
00236
00237
00238 };
00239
00240 #endif
00241
00242
00243
00244