Merge pull request #773 from realthunder/PathArea
Path.Area: bug fix and new feature
This commit is contained in:
@@ -119,10 +119,11 @@ public:
|
||||
"fromShape(Shape): Returns a Path object from a Part Shape"
|
||||
);
|
||||
add_keyword_method("fromShapes",&Module::fromShapes,
|
||||
"fromShapes(shapes, start=Vector(), " PARAM_PY_ARGS_DOC(ARG,AREA_PARAMS_PATH) ")\n"
|
||||
"fromShapes(shapes, start=Vector(), return_end=False" PARAM_PY_ARGS_DOC(ARG,AREA_PARAMS_PATH) ")\n"
|
||||
"\nReturns a Path object from a list of shapes\n"
|
||||
"\n* shapes: input list of shapes.\n"
|
||||
"\n* start (Vector()): optional start position.\n"
|
||||
"\n* return_end (False): if True, returns tuple (path, endPosition).\n"
|
||||
PARAM_PY_DOC(ARG, AREA_PARAMS_PATH)
|
||||
);
|
||||
add_keyword_method("sortWires",&Module::sortWires,
|
||||
@@ -325,11 +326,12 @@ private:
|
||||
PARAM_PY_DECLARE_INIT(PARAM_FARG,AREA_PARAMS_PATH)
|
||||
PyObject *pShapes=NULL;
|
||||
PyObject *start=NULL;
|
||||
static char* kwd_list[] = {"shapes", "start",
|
||||
PyObject *return_end=Py_False;
|
||||
static char* kwd_list[] = {"shapes", "start", "return_end",
|
||||
PARAM_FIELD_STRINGS(ARG,AREA_PARAMS_PATH), NULL};
|
||||
if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(),
|
||||
"O|O!" PARAM_PY_KWDS(AREA_PARAMS_PATH),
|
||||
kwd_list, &pShapes, &(Base::VectorPy::Type), &start,
|
||||
"O|O!O" PARAM_PY_KWDS(AREA_PARAMS_PATH),
|
||||
kwd_list, &pShapes, &(Base::VectorPy::Type), &start, &return_end,
|
||||
PARAM_REF(PARAM_FARG,AREA_PARAMS_PATH)))
|
||||
throw Py::Exception();
|
||||
|
||||
@@ -357,10 +359,16 @@ private:
|
||||
}
|
||||
|
||||
try {
|
||||
gp_Pnt pend;
|
||||
std::unique_ptr<Toolpath> path(new Toolpath);
|
||||
Area::toPath(*path,shapes,&pstart, NULL,
|
||||
Area::toPath(*path,shapes,&pstart, &pend,
|
||||
PARAM_PY_FIELDS(PARAM_FARG,AREA_PARAMS_PATH));
|
||||
return Py::asObject(new PathPy(path.release()));
|
||||
if(!PyObject_IsTrue(return_end))
|
||||
return Py::asObject(new PathPy(path.release()));
|
||||
Py::Tuple tuple(2);
|
||||
tuple.setItem(0, Py::asObject(new PathPy(path.release())));
|
||||
tuple.setItem(1, Py::asObject(new Base::VectorPy(Base::Vector3d(pend.X(),pend.Y(),pend.Z()))));
|
||||
return tuple;
|
||||
} PATH_CATCH
|
||||
}
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ struct WireJoiner {
|
||||
BRepBndLib::Add(e,bound);
|
||||
bound.SetGap(0.1);
|
||||
if (bound.IsVoid()) {
|
||||
if(Area::TraceEnabled())
|
||||
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
|
||||
AREA_WARN("failed to get bound of edge");
|
||||
return false;
|
||||
}
|
||||
@@ -687,7 +687,7 @@ struct WireJoiner {
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}else if(Area::TraceEnabled())
|
||||
}else if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
|
||||
AREA_WARN("BRepExtrema_DistShapeShape failed");
|
||||
}
|
||||
}
|
||||
@@ -711,7 +711,7 @@ struct WireJoiner {
|
||||
mkEdge2.Init(curve, pt, pend);
|
||||
}
|
||||
if(!mkEdge1.IsDone() || !mkEdge2.IsDone()) {
|
||||
if(Area::TraceEnabled())
|
||||
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
|
||||
AREA_WARN((reversed?"reversed ":"")<<"edge split failed "<<
|
||||
AREA_XYZ(pstart)<<", " << AREA_XYZ(pt)<< ", "<<AREA_XYZ(pend)<<
|
||||
", "<<", err: " << mkEdge1.Error() << ", " << mkEdge2.Error());
|
||||
@@ -1032,6 +1032,9 @@ int Area::project(TopoDS_Shape &shape_out,
|
||||
FC_TIME_LOG(t1,"WireJoiner findClosedWires");
|
||||
|
||||
Area area(params);
|
||||
area.myParams.SectionCount = 0;
|
||||
area.myParams.Offset = 0.0;
|
||||
area.myParams.PocketMode = 0;
|
||||
area.myParams.Explode = false;
|
||||
area.myParams.FitArcs = false;
|
||||
area.myParams.Reorient = false;
|
||||
@@ -1131,12 +1134,14 @@ std::vector<shared_ptr<Area> > Area::makeSections(
|
||||
double height = z-tolerance;
|
||||
if(z-zMin<myParams.SectionTolerance){
|
||||
height = zMin+myParams.SectionTolerance;
|
||||
AREA_WARN("hit bottom " <<z<<','<<zMin<<','<<height);
|
||||
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
|
||||
AREA_WARN("hit bottom " <<z<<','<<zMin<<','<<height);
|
||||
heights.push_back(height);
|
||||
if(myParams.Stepdown>0.0) break;
|
||||
}else if(zMax-z<myParams.SectionTolerance) {
|
||||
height = zMax-myParams.SectionTolerance;
|
||||
AREA_WARN("hit top " <<z<<','<<zMax<<','<<height);
|
||||
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
|
||||
AREA_WARN("hit top " <<z<<','<<zMax<<','<<height);
|
||||
heights.push_back(height);
|
||||
if(myParams.Stepdown<0.0) break;
|
||||
}else
|
||||
@@ -2979,7 +2984,6 @@ bool Area::aborting() {
|
||||
}
|
||||
|
||||
AreaStaticParams::AreaStaticParams()
|
||||
:PARAM_INIT(PARAM_FNAME,AREA_PARAMS_EXTRA_CONF)
|
||||
{}
|
||||
|
||||
AreaStaticParams Area::s_params;
|
||||
@@ -2992,8 +2996,3 @@ const AreaStaticParams &Area::getDefaultParams() {
|
||||
return s_params;
|
||||
}
|
||||
|
||||
#define AREA_LOG_CHECK_DEFINE(_1,_2,_elem) \
|
||||
bool Area::BOOST_PP_CAT(_elem,Enabled)() {\
|
||||
return s_params.LogLevel >= BOOST_PP_CAT(LogLevel,_elem);\
|
||||
}
|
||||
BOOST_PP_SEQ_FOR_EACH(AREA_LOG_CHECK_DEFINE,_,AREA_PARAM_LOG_LEVEL)
|
||||
|
||||
@@ -75,8 +75,6 @@ struct PathExport AreaParams: CAreaParams {
|
||||
};
|
||||
|
||||
struct PathExport AreaStaticParams: AreaParams {
|
||||
PARAM_DECLARE(PARAM_FNAME,AREA_PARAMS_EXTRA_CONF);
|
||||
|
||||
AreaStaticParams();
|
||||
};
|
||||
|
||||
@@ -378,13 +376,6 @@ public:
|
||||
|
||||
static void setDefaultParams(const AreaStaticParams ¶ms);
|
||||
static const AreaStaticParams &getDefaultParams();
|
||||
|
||||
|
||||
#define AREA_LOG_CHECK_DECLARE(_1,_2,_elem) \
|
||||
static bool BOOST_PP_CAT(_elem,Enabled)();
|
||||
BOOST_PP_SEQ_FOR_EACH(AREA_LOG_CHECK_DECLARE,_,AREA_PARAM_LOG_LEVEL)
|
||||
|
||||
PARAM_ENUM_DECLARE(AREA_PARAMS_LOG_LEVEL)
|
||||
};
|
||||
|
||||
} //namespace Path
|
||||
|
||||
@@ -255,20 +255,7 @@
|
||||
AREA_PARAMS_CONF \
|
||||
AREA_PARAMS_OPCODE
|
||||
|
||||
#define AREA_PARAM_LOG_LEVEL (Error)(Warning)(Log)(Trace)
|
||||
#if FC_DEBUG
|
||||
# define AREA_PARAMS_LOG_LEVEL \
|
||||
((enum, log_level, LogLevel, 3, "Area log level", AREA_PARAM_LOG_LEVEL))
|
||||
#else
|
||||
# define AREA_PARAMS_LOG_LEVEL \
|
||||
((enum, log_level, LogLevel, 1, "Area log level", AREA_PARAM_LOG_LEVEL))
|
||||
#endif
|
||||
|
||||
#define AREA_PARAMS_EXTRA_CONF \
|
||||
AREA_PARAMS_LOG_LEVEL
|
||||
|
||||
#define AREA_PARAMS_STATIC_CONF \
|
||||
AREA_PARAMS_CONF \
|
||||
AREA_PARAMS_EXTRA_CONF
|
||||
AREA_PARAMS_CONF
|
||||
|
||||
#endif //PATH_AreaParam_H
|
||||
|
||||
@@ -149,10 +149,9 @@ static const PyMethodDef areaOverrides[] = {
|
||||
},
|
||||
{
|
||||
"setDefaultParams",(PyCFunction)areaSetParams, METH_VARARGS|METH_KEYWORDS|METH_STATIC,
|
||||
"setDefaultParams(" PARAM_PY_ARGS_DOC(NAME,AREA_PARAMS_EXTRA_CONF) ", key=value...):\n"
|
||||
"setDefaultParams(key=value...):\n"
|
||||
"Static method to set the default parameters of all following Path.Area, plus the following\n"
|
||||
"additional parameters.\n"
|
||||
PARAM_PY_DOC(NAME,AREA_PARAMS_EXTRA_CONF)
|
||||
},
|
||||
{
|
||||
"getDefaultParams",(PyCFunction)areaGetParams, METH_VARARGS|METH_STATIC,
|
||||
|
||||
Reference in New Issue
Block a user