Path.Area: respect zero start point when generating path

This commit is contained in:
Zheng, Lei
2018-01-22 16:36:40 +08:00
committed by wmayer
parent 66f29c52ad
commit 004f82b3e7
5 changed files with 14 additions and 10 deletions

View File

@@ -362,7 +362,7 @@ private:
try {
gp_Pnt pend;
std::unique_ptr<Toolpath> path(new Toolpath);
Area::toPath(*path,shapes,&pstart, &pend,
Area::toPath(*path,shapes,start?&pstart:0, &pend,
PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_PATH));
if(!PyObject_IsTrue(return_end))
return Py::asObject(new PathPy(path.release()));
@@ -415,7 +415,7 @@ private:
try {
bool need_arc_plane = arc_plane==Area::ArcPlaneAuto;
std::list<TopoDS_Shape> wires = Area::sortWires(shapes,&pstart,
std::list<TopoDS_Shape> wires = Area::sortWires(shapes,start!=0,&pstart,
&pend, 0, &arc_plane, PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_SORT));
PyObject *list = PyList_New(0);
for(auto &wire : wires)

View File

@@ -2721,7 +2721,8 @@ typedef Standard_Real (gp_Pnt::*AxisGetter)() const;
typedef void (gp_Pnt::*AxisSetter)(Standard_Real);
std::list<TopoDS_Shape> Area::sortWires(const std::list<TopoDS_Shape> &shapes,
gp_Pnt *_pstart, gp_Pnt *_pend, double *stepdown_hint, short *_parc_plane,
bool has_start, gp_Pnt *_pstart, gp_Pnt *_pend,
double *stepdown_hint, short *_parc_plane,
PARAM_ARGS(PARAM_FARG,AREA_PARAMS_SORT))
{
std::list<TopoDS_Shape> wires;
@@ -2814,9 +2815,7 @@ std::list<TopoDS_Shape> Area::sortWires(const std::list<TopoDS_Shape> &shapes,
gp_Pnt pstart,pend;
if(_pstart)
pstart = *_pstart;
bool use_bound = fabs(pstart.X())<Precision::Confusion() &&
fabs(pstart.Y())<Precision::Confusion() &&
fabs(pstart.Z())<Precision::Confusion();
bool use_bound = !has_start || _pstart==NULL;
if(use_bound || sort_mode == SortMode2D5 || sort_mode == SortModeGreedy) {
//Second stage, group shape by its plane, and find overall boundary
@@ -3079,7 +3078,7 @@ void Area::toPath(Toolpath &path, const std::list<TopoDS_Shape> &shapes,
if(_pstart) pstart = *_pstart;
double stepdown_hint = 1.0;
wires = sortWires(shapes,&pstart,pend,&stepdown_hint,
wires = sortWires(shapes,_pstart!=0,&pstart,pend,&stepdown_hint,
PARAM_REF(PARAM_FARG,AREA_PARAMS_ARC_PLANE),
PARAM_FIELDS(PARAM_FARG,AREA_PARAMS_SORT));

View File

@@ -340,7 +340,10 @@ public:
* minimize traval distance
*
* \arg \c shapes: input list of shapes.
* \arg \c pstart: optional start point
* \arg \c has_start: if false or pstart is 0, then a start point will be
* auto selected.
* \arg \c pstart: optional start point. If has_start is false, then the
* auto selected start point will be returned with this point if not NULL.
* \arg \c pend: optional output containing the ending point of the returned
* \arg \c stepdown_hint: optional output of a hint of step down as the max
* distance between two sections.
@@ -352,7 +355,7 @@ public:
* \return sorted wires
*/
static std::list<TopoDS_Shape> sortWires(const std::list<TopoDS_Shape> &shapes,
gp_Pnt *pstart=NULL, gp_Pnt *pend=NULL, double *stepdown_hint=NULL,
bool has_start=false, gp_Pnt *pstart=NULL, gp_Pnt *pend=NULL, double *stepdown_hint=NULL,
short *arc_plane = NULL, PARAM_ARGS_DEF(PARAM_FARG,AREA_PARAMS_SORT));
/** Convert a list of wires to gcode

View File

@@ -56,6 +56,7 @@ FeatureShape::FeatureShape()
{
ADD_PROPERTY(Sources,(0));
ADD_PROPERTY_TYPE(StartPoint,(Base::Vector3d()),"Path",App::Prop_None,"Feed start position");
ADD_PROPERTY_TYPE(UseStartPoint,(false),"Path",App::Prop_None,"Enable feed start position");
PARAM_PROP_ADD("Path",AREA_PARAMS_PATH);
PARAM_PROP_SET_ENUM(Enums,AREA_PARAMS_PATH);
}
@@ -86,7 +87,7 @@ App::DocumentObjectExecReturn *FeatureShape::execute(void)
shapes.push_back(shape);
}
Area::toPath(path,shapes,&pstart,NULL,PARAM_PROP_ARGS(AREA_PARAMS_PATH));
Area::toPath(path,shapes,UseStartPoint.getValue()?&pstart:0,0,PARAM_PROP_ARGS(AREA_PARAMS_PATH));
Path.setValue(path);
return App::DocumentObject::StdReturn;

View File

@@ -53,6 +53,7 @@ public:
// Part::PropertyPartShape Shape;
App::PropertyLinkList Sources;
App::PropertyVector StartPoint;
App::PropertyBool UseStartPoint;
PARAM_PROP_DECLARE(AREA_PARAMS_PATH)
//@{