Path.Area: improved section plane tolerance issue
This commit is contained in:
@@ -557,6 +557,8 @@ std::vector<shared_ptr<Area> > Area::makeSections(
|
||||
bounds.SetGap(0.0);
|
||||
Standard_Real xMin, yMin, zMin, xMax, yMax, zMax;
|
||||
bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
|
||||
AREA_TRACE("section bounds X("<<xMin<<','<<xMax<<"), Y("<<
|
||||
yMin<<','<<yMax<<"), Z("<<zMin<<','<<zMax<<')');
|
||||
|
||||
std::vector<double> heights;
|
||||
if(_heights.empty()) {
|
||||
@@ -587,31 +589,32 @@ std::vector<shared_ptr<Area> > Area::makeSections(
|
||||
z = zMax;
|
||||
else if(z < zMin)
|
||||
z = zMin;
|
||||
double dz;
|
||||
if(myParams.Stepdown>0.0)
|
||||
double dz,tolerance;
|
||||
if(myParams.Stepdown>0.0) {
|
||||
dz = z - zMin;
|
||||
else
|
||||
tolerance = myParams.SectionTolerance;
|
||||
}else{
|
||||
dz = zMax - z;
|
||||
|
||||
tolerance = -myParams.SectionTolerance;
|
||||
}
|
||||
int count = myParams.SectionCount;
|
||||
if(count<0 || count*d > dz)
|
||||
count = floor(dz/d)+1;
|
||||
heights.reserve(count);
|
||||
for(int i=0;i<count;++i,z-=myParams.Stepdown) {
|
||||
if(myParams.Stepdown>0.0) {
|
||||
if(z-zMin<myParams.SectionTolerance){
|
||||
double zNew = zMin+myParams.SectionTolerance;
|
||||
AREA_TRACE("hit bottom " <<z<<','<<zMin<<','<<zNew);
|
||||
heights.push_back(zNew);
|
||||
break;
|
||||
}
|
||||
double height = z-tolerance;
|
||||
if(z-zMin<myParams.SectionTolerance){
|
||||
height = zMin+myParams.SectionTolerance;
|
||||
AREA_WARN("hit bottom " <<z<<','<<zMin<<','<<height);
|
||||
heights.push_back(height);
|
||||
if(myParams.Stepdown>0.0) break;
|
||||
}else if(zMax-z<myParams.SectionTolerance) {
|
||||
double zNew = zMax-myParams.SectionTolerance;
|
||||
AREA_TRACE("hit top " <<z<<','<<zMin<<','<<zNew);
|
||||
heights.push_back(zNew);
|
||||
break;
|
||||
}
|
||||
heights.push_back(z);
|
||||
height = zMax-myParams.SectionTolerance;
|
||||
AREA_WARN("hit top " <<z<<','<<zMax<<','<<height);
|
||||
heights.push_back(height);
|
||||
if(myParams.Stepdown<0.0) break;
|
||||
}else
|
||||
heights.push_back(height);
|
||||
}
|
||||
}else{
|
||||
heights.reserve(_heights.size());
|
||||
@@ -636,12 +639,12 @@ std::vector<shared_ptr<Area> > Area::makeSections(
|
||||
if(hitMin) continue;
|
||||
hitMin = true;
|
||||
double zNew = zMin+myParams.SectionTolerance;
|
||||
AREA_TRACE("hit bottom " <<z<<','<<zMin<<','<<zNew);
|
||||
AREA_WARN("hit bottom " <<z<<','<<zMin<<','<<zNew);
|
||||
z = zNew;
|
||||
}else if (zMax-z<myParams.SectionTolerance) {
|
||||
if(hitMax) continue;
|
||||
double zNew = zMax-myParams.SectionTolerance;
|
||||
AREA_TRACE("hit top " <<z<<','<<zMin<<','<<zNew);
|
||||
AREA_WARN("hit top " <<z<<','<<zMax<<','<<zNew);
|
||||
z = zNew;
|
||||
}
|
||||
heights.push_back(z);
|
||||
|
||||
@@ -46,7 +46,8 @@ extern PartExport Py::Object shape2pyshape(const TopoDS_Shape &shape);
|
||||
if(Area::_l##Enabled()){\
|
||||
std::stringstream str;\
|
||||
str << "Path.Area: " << _msg;\
|
||||
Base::Console()._l("%s\n",str.str().c_str());\
|
||||
const char *_f = strrchr(__FILE__, '/');\
|
||||
Base::Console()._l("%s:(%d) - %s\n",_f?_f+1:__FILE__,__LINE__,str.str().c_str());\
|
||||
}\
|
||||
QCoreApplication::sendPostedEvents();\
|
||||
if(Area::aborting()) {\
|
||||
@@ -62,7 +63,7 @@ extern PartExport Py::Object shape2pyshape(const TopoDS_Shape &shape);
|
||||
#define AREA_XY(_pt) '('<<(_pt).x<<", " << (_pt).y<<')'
|
||||
|
||||
#define AREA_TRACE(_msg) do{\
|
||||
if(Area::TraceEnabled()) AREA_LOG('('<<__LINE__<<"): " <<_msg);\
|
||||
if(Area::TraceEnabled()) AREA_LOG(_msg);\
|
||||
}while(0)
|
||||
|
||||
#define AREA_DBG AREA_WARN
|
||||
|
||||
@@ -138,10 +138,10 @@
|
||||
#define AREA_PARAMS_SECTION \
|
||||
((long,count,SectionCount,0,"Number of sections to generate. -1 means full sections."))\
|
||||
((double,stepdown,Stepdown,1.0,"Step down distance for each section.\n"\
|
||||
"Positive value means going from top down, and negative the other way round",App::PropertyLength))\
|
||||
"Positive value means going from top down, and negative the other way round",App::PropertyDistance))\
|
||||
((double,offset,SectionOffset,0.0,"Offset for the first section. The direction of the offset is\n"\
|
||||
"determined by the section direction (i.e. the signess of Stepdown). If going from top down,\n"\
|
||||
"a positive value means offset downward, and if bottom up, it means upward",App::PropertyLength))\
|
||||
"a positive value means offset downward, and if bottom up, it means upward",App::PropertyDistance))\
|
||||
((double,tolerance,SectionTolerance,1e-5,"Offset value added when hitting the boundary.\n"\
|
||||
"When the section hits or over the shape boundary, a section with the height of that boundary\n"\
|
||||
"will be created. A small offset is usually required to avoid the tagnetial cut.",\
|
||||
|
||||
Reference in New Issue
Block a user