diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 104c62b953..079a263f5e 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -217,9 +217,9 @@ bool Area::isCoplanar(const TopoDS_Shape &s1, const TopoDS_Shape &s2) { return planeFinder.Found(); } -int Area::addShape(CArea &area, const TopoDS_Shape &shape, const gp_Trsf *trsf, +int Area::addShape(CArea &area, const TopoDS_Shape &shape, const gp_Trsf *trsf, double deflection, const TopoDS_Shape *plane, bool force_coplanar, - CArea *areaOpen, bool to_edges, bool reorient) + CArea *areaOpen, bool to_edges, bool reorient) { bool haveShape = false; int skipped = 0; @@ -279,7 +279,7 @@ int Area::addShape(CArea &area, const TopoDS_Shape &shape, const gp_Trsf *trsf, } void Area::addWire(CArea &area, const TopoDS_Wire& wire, - const gp_Trsf *trsf, double deflection, bool to_edges) + const gp_Trsf *trsf, double deflection, bool to_edges) { CCurve ccurve; BRepTools_WireExplorer xp(trsf?TopoDS::Wire( @@ -331,7 +331,7 @@ void Area::addWire(CArea &area, const TopoDS_Wire& wire, //fall through } default: { // Discretize all other type of curves - GCPnts_QuasiUniformDeflection discretizer(curve, deflection, + GCPnts_QuasiUniformDeflection discretizer(curve, deflection, curve.FirstParameter(), curve.LastParameter()); if (discretizer.IsDone () && discretizer.NbPoints () > 1) { int nbPoints = discretizer.NbPoints (); @@ -408,7 +408,7 @@ void Area::add(const TopoDS_Shape &shape,short op) { if(shape.IsNull()) throw Base::ValueError("null shape"); - if(op!=OperationCompound) + if(op!=OperationCompound) toClipperOp(op); bool haveSolid = false; @@ -515,7 +515,7 @@ struct WireJoiner { getEndPoints(e,p1,p2); if(bbox) hasBox= getBBox(e,box); } - EdgeInfo(const TopoDS_Edge &e, const gp_Pnt &pt1, + EdgeInfo(const TopoDS_Edge &e, const gp_Pnt &pt1, const gp_Pnt &pt2, bool bbox) :edge(e),p1(pt1),p2(pt2),iteration(0) ,used(false),hasBox(false) @@ -547,8 +547,8 @@ struct WireJoiner { struct PntGetter { typedef const gp_Pnt& result_type; - result_type operator()(const EdgeValue &v) const { - return v.pt(); + result_type operator()(const EdgeValue &v) const { + return v.pt(); } }; @@ -557,7 +557,7 @@ struct WireJoiner { struct BoxGetter { typedef const Box& result_type; - result_type operator()(Edges::iterator it) const { + result_type operator()(Edges::iterator it) const { return it->box; } }; @@ -581,7 +581,7 @@ struct WireJoiner { void add(Edges::iterator it) { vmap.insert(EdgeValue(it,true)); vmap.insert(EdgeValue(it,false)); - if(it->hasBox) + if(it->hasBox) boxMap.insert(it); } @@ -668,6 +668,9 @@ struct WireJoiner { // split any edges that are intersected by othe edge's end point in the middle void splitEdges() { +#if (BOOST_VERSION < 105500) + throw Base::RuntimeError("Module must be built with boost version >= 1.55"); +#else for(auto it=edges.begin();it!=edges.end();) { const auto &info = *it; if(!info.hasBox) { @@ -728,7 +731,7 @@ struct WireJoiner { if(!mkEdge1.IsDone() || !mkEdge2.IsDone()) { if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) AREA_WARN((reversed?"reversed ":"")<<"edge split failed "<< - AREA_XYZ(pstart)<<", " << AREA_XYZ(pt)<< ", "<= 1.55"); +#else // It seems OCC projector sometimes mess up the tolerance of edges // which are supposed to be connected. So use a lesser preceision // below, and call makeCleanWire to fix the tolerance @@ -825,7 +832,7 @@ struct WireJoiner { for(auto &v : r.ret) --v.it->iteration; stack.pop_back(); - if(stack.size()) + if(stack.size()) ++stack.back().idx; } if(stack.empty()) { @@ -857,7 +864,7 @@ struct WireJoiner { } // TechDraw even uses 0.1 as tolerance. Really? Why? TopoDS_Wire wire = makeCleanWire(wireData,0.01); - if(!BRep_Tool::IsClosed(wire)) + if(!BRep_Tool::IsClosed(wire)) throw Base::RuntimeError("Area: failed to close projection wire"); builder.Add(comp,wire); ++count; @@ -866,6 +873,7 @@ struct WireJoiner { } AREA_TRACE("found " << count << " closed wires, skipped " << skips); return skips; +#endif } //! make a clean wire with sorted, oriented, connected, etc edges @@ -926,7 +934,7 @@ void Area::explode(const TopoDS_Shape &shape) { void Area::showShape(const TopoDS_Shape &shape, const char *name, const char *fmt, ...) { if(FC_LOG_INSTANCE.level()>FC_LOGLEVEL_TRACE) { - App::Document *pcDoc = App::GetApplication().getActiveDocument(); + App::Document *pcDoc = App::GetApplication().getActiveDocument(); if (!pcDoc) pcDoc = App::GetApplication().newDocument(); char buf[256]; @@ -1016,7 +1024,7 @@ struct FindPlane { pln = adapt.Plane(); }else{ BRepLib_FindSurface finder(shape.Located(TopLoc_Location()),-1,Standard_True); - if (!finder.Found()) + if (!finder.Found()) return; // TODO: It seemed that FindSurface disregard shape's @@ -1048,7 +1056,7 @@ struct FindPlane { bool x0 = fabs(dir.X()) > Area::makeSections( tolerance = -myParams.SectionTolerance; } int count = myParams.SectionCount; - if(count<0 || count*d > dz) + if(count<0 || count*d > dz) count = floor(dz/d)+1; heights.reserve(count); for(int i=0;i > Area::makeSections( case SectionModeWorkplane: z = -z; break; - default: + default: throw Base::ValueError("invalid section mode"); } if(z-zMin > Area::makeSections( showShape(shape,0,"section_%u_face",i); for(auto it=wires.begin(),itNext=it;it!=wires.end();it=itNext) { ++itNext; - if(BRep_Tool::IsClosed(*it)) + if(BRep_Tool::IsClosed(*it)) wires.erase(it); } for(TopExp_Explorer xp(shape,myParams.Fill==FillNone?TopAbs_WIRE:TopAbs_FACE); @@ -1427,11 +1435,11 @@ TopoDS_Shape Area::getPlane(gp_Trsf *trsf) { return myShapePlane; } -bool Area::isBuilt() const { +bool Area::isBuilt() const { return (myArea || mySections.size()); } -std::list Area::getProjectedShapes(const gp_Trsf &trsf, bool inverse) const +std::list Area::getProjectedShapes(const gp_Trsf &trsf, bool inverse) const { std::list ret; TopLoc_Location loc(trsf); @@ -1444,7 +1452,7 @@ std::list Area::getProjectedShapes(const gp_Trsf &trsf, bool invers if(skipped < 0) { ++mySkippedShapes; continue; - }else + }else mySkippedShapes += skipped; if(!out.IsNull()) ret.emplace_back(s.op,inverse?out.Moved(locInverse):out); @@ -1527,7 +1535,7 @@ void Area::build() { gp_Trsf trsf(myTrsf.Inverted()); for(const auto &c : myArea->m_curves) { TopoDS_Wire wire = toShape(c,&trsf); - if(!wire.IsNull()) + if(!wire.IsNull()) joiner.add(wire); } joiner.join(Precision::Confusion()); @@ -1643,7 +1651,7 @@ TopoDS_Shape Area::getShape(int index) { std::list > areas; makeOffset(areas,PARAM_FIELDS(AREA_MY,AREA_PARAMS_OFFSET)); - if(areas.empty()) + if(areas.empty()) areas.push_back(make_shared(*myArea)); Area areaPocket(&myParams); @@ -1682,7 +1690,7 @@ TopoDS_Shape Area::getShape(int index) { if(shape.IsNull()) continue; builder.Add(compound,shape); } - if(myParams.Thicken) + if(myParams.Thicken) FC_DURATION_LOG(d,"Thicken"); // make sure the compound has at least one edge @@ -1768,7 +1776,7 @@ void Area::makeOffset(list > &areas, #ifdef AREA_OFFSET_ALGO PARAM_ENUM_CONVERT(AREA_MY,PARAM_FNAME,PARAM_ENUM_EXCEPT,AREA_PARAMS_CLIPPER_FILL); #endif - + for(int i=0;count<0||i()); CArea &area = *areas.back(); @@ -1814,7 +1822,7 @@ void Area::makeOffset(list > &areas, } TopoDS_Shape Area::makePocket(int index, PARAM_ARGS(PARAM_FARG,AREA_PARAMS_POCKET)) { - if(tool_radius < Precision::Confusion()) + if(tool_radius < Precision::Confusion()) throw Base::ValueError("tool radius too small"); if(stepover == 0.0) @@ -1840,7 +1848,7 @@ TopoDS_Shape Area::makePocket(int index, PARAM_ARGS(PARAM_FARG,AREA_PARAMS_POCKE shift *= index; } - if(angle<-360.0) + if(angle<-360.0) angle += ceil(fabs(angle)/360.0)*360.0; else if(angle>360.0) angle -= floor(angle/360.0)*360.0; @@ -1958,7 +1966,7 @@ TopoDS_Wire Area::toShape(const CCurve &_c, const gp_Trsf *trsf, int reorient) { CCurve cReversed; if(reorient) { - if(_c.IsClosed() && + if(_c.IsClosed() && ((reorient>0 && _c.IsClockwise()) || (reorient<0 && !_c.IsClockwise()))) { @@ -2014,12 +2022,12 @@ TopoDS_Wire Area::toShape(const CCurve &_c, const gp_Trsf *trsf, int reorient) { if(c.IsClosed() && !BRep_Tool::IsClosed(mkWire.Wire())){ // This should never happen after changing libarea's - // Point::tolerance to be the same as Precision::Confusion(). + // Point::tolerance to be the same as Precision::Confusion(). // Just leave it here in case. BRepAdaptor_Curve curve(mkWire.Edge()); gp_Pnt p1(curve.Value(curve.FirstParameter())); gp_Pnt p2(curve.Value(curve.LastParameter())); - AREA_WARN("warning: patch open wire type " << + AREA_WARN("warning: patch open wire type " << c.m_vertices.back().m_type<pend(); return myBestWire->wire; @@ -2394,7 +2402,7 @@ struct ShapeInfo{ // first<<", " << myBestParameter << ", " << last<<')'); continue; } - AREA_WARN((reversed?"reversed ":"")<<"edge split failed "< &list, ShapeParams ¶ms) :myList(list) ,myTrsf(trsf) ,myArcPlane(arc_plane) ,myArcPlaneFound(plane_found), myParams(params) @@ -2492,7 +2500,7 @@ struct ShapeInfoBuilder { } myList.push_back(ShapeInfo(finder,shape,myParams)); if(myArcPlaneFound || - myArcPlane==Area::ArcPlaneNone || + myArcPlane==Area::ArcPlaneNone || myArcPlane==Area::ArcPlaneVariable) return; @@ -2550,7 +2558,7 @@ struct ShapeInfoBuilder { default: return; } - AREA_WARN("force arc plane " << AREA_XYZ(dir) << + AREA_WARN("force arc plane " << AREA_XYZ(dir) << " to " << AREA_XYZ(dstPos.Direction())); myTrsf.SetTransformation(pos); gp_Trsf trsf; @@ -2579,7 +2587,7 @@ struct WireOrienter { TopoDS_Shape &wire = wires.back(); if(BRep_Tool::IsClosed(wire)) { - if(orientation==Area::OrientationReversed) + if(orientation==Area::OrientationReversed) wire.Reverse(); }else if(direction!=Area::DirectionNone) { gp_Pnt p1,p2; @@ -2611,7 +2619,7 @@ struct WireOrienter { } }; -std::list Area::sortWires(const std::list &shapes, +std::list Area::sortWires(const std::list &shapes, gp_Pnt *_pstart, gp_Pnt *_pend, double *stepdown_hint, short *_parc_plane, PARAM_ARGS(PARAM_FARG,AREA_PARAMS_SORT)) { @@ -2663,7 +2671,7 @@ std::list Area::sortWires(const std::list &shapes, builder.Add(comp,shape); } TopExp_Explorer xp(comp,TopAbs_EDGE); - if(xp.More()) + if(xp.More()) shape_list.push_back(ShapeInfo(comp,rparams)); }else{ //first pass, find plane of each shape @@ -2677,12 +2685,12 @@ std::list Area::sortWires(const std::list &shapes, FC_TIME_LOG(t1,"plane finding"); } - if(shape_list.empty()) + if(shape_list.empty()) return wires; - + Bnd_Box bounds; gp_Pnt pstart,pend; - if(_pstart) + if(_pstart) pstart = *_pstart; bool use_bound = fabs(pstart.X()) Area::sortWires(const std::list &shapes, BRepBndLib::Add(info.myShape, bounds, Standard_False); } } - + for(auto itNext=shape_list.begin(),it=itNext;it!=shape_list.end();it=itNext) { ++itNext; if(!it->myPlanar) continue; @@ -2711,9 +2719,9 @@ std::list Area::sortWires(const std::list &shapes, bool empty = true; for(auto itNext3=itNext,itNext2=itNext;itNext2!=shape_list.end();itNext2=itNext3) { ++itNext3; - if(!itNext2->myPlanar || + if(!itNext2->myPlanar || !it->myPln.Position().IsCoplanar(itNext2->myPln.Position(), - Precision::Confusion(),Precision::Confusion())) + Precision::Confusion(),Precision::Confusion())) continue; if(itNext == itNext2) ++itNext; builder.Add(comp,itNext2->myShape); @@ -2770,10 +2778,10 @@ std::list Area::sortWires(const std::list &shapes, if(sort_mode==SortMode2D5 && stepdown_hint) { if(!best_it->myPlanar) hint_first = true; - else if(hint_first) + else if(hint_first) hint_first = false; else{ - // Calculate distance of two gp_pln. + // Calculate distance of two gp_pln. // // Can't use gp_pln.Distance(), because it only calculate // the distance if two plane are parallel. And it checks @@ -2814,8 +2822,8 @@ static inline void addParameter(bool verbose, Command &cmd, const char *name, cmd.Parameters[name] = relative?d:next; } -static inline void addGCode(bool verbose, Toolpath &path, const gp_Pnt &last, - const gp_Pnt &next, const char *name) +static inline void addGCode(bool verbose, Toolpath &path, const gp_Pnt &last, + const gp_Pnt &next, const char *name) { Command cmd; cmd.Name = name; @@ -2826,8 +2834,8 @@ static inline void addGCode(bool verbose, Toolpath &path, const gp_Pnt &last, return; } -static inline void addG1(bool verbose,Toolpath &path, const gp_Pnt &last, - const gp_Pnt &next, double f, double &last_f) +static inline void addG1(bool verbose,Toolpath &path, const gp_Pnt &last, + const gp_Pnt &next, double f, double &last_f) { addGCode(verbose,path,last,next,"G1"); if(f>Precision::Confusion()) { @@ -2841,10 +2849,10 @@ static inline void addG1(bool verbose,Toolpath &path, const gp_Pnt &last, typedef Standard_Real (gp_Pnt::*AxisGetter)() const; typedef void (gp_Pnt::*AxisSetter)(Standard_Real); -static void addG0(bool verbose, Toolpath &path, - gp_Pnt last, const gp_Pnt &next, +static void addG0(bool verbose, Toolpath &path, + gp_Pnt last, const gp_Pnt &next, AxisGetter getter, AxisSetter setter, - double retraction, double resume_height, + double retraction, double resume_height, double f, double &last_f) { gp_Pnt pt(last); @@ -2868,9 +2876,9 @@ static void addG0(bool verbose, Toolpath &path, addGCode(verbose,path,pt,next,"G0"); } -static void addGArc(bool verbose,bool abs_center, Toolpath &path, - const gp_Pnt &pstart, const gp_Pnt &pend, const gp_Pnt ¢er, - bool clockwise, double f, double &last_f) +static void addGArc(bool verbose,bool abs_center, Toolpath &path, + const gp_Pnt &pstart, const gp_Pnt &pend, const gp_Pnt ¢er, + bool clockwise, double f, double &last_f) { Command cmd; cmd.Name = clockwise?"G2":"G3"; @@ -2929,7 +2937,7 @@ void Area::toPath(Toolpath &path, const std::list &shapes, double stepdown_hint = 1.0; wires = sortWires(shapes,&pstart,pend,&stepdown_hint, - PARAM_REF(PARAM_FARG,AREA_PARAMS_ARC_PLANE), + PARAM_REF(PARAM_FARG,AREA_PARAMS_ARC_PLANE), PARAM_FIELDS(PARAM_FARG,AREA_PARAMS_SORT)); // absolute mode @@ -2946,7 +2954,7 @@ void Area::toPath(Toolpath &path, const std::list &shapes, currentArcPlane=ArcPlaneXY; addGCode(path,"G17"); } - + AxisGetter getter; AxisSetter setter; switch(retract_axis) { @@ -3018,7 +3026,7 @@ void Area::toPath(Toolpath &path, const std::list &shapes, (pTmp.*setter)(0.0); (plastTmp.*setter)(0.0); - if(!first && pTmp.SquareDistance(plastTmp)>threshold) + if(!first && pTmp.SquareDistance(plastTmp)>threshold) addG0(verbose,path,plast,p,getter,setter,retraction,resume_height,vf,cur_f); else addG1(verbose,path,plast,p,vf,cur_f); @@ -3033,7 +3041,7 @@ void Area::toPath(Toolpath &path, const std::list &shapes, switch (curve.GetType()) { case GeomAbs_Line: { if(segmentation > Precision::Confusion()) { - GCPnts_UniformAbscissa discretizer(curve, segmentation, + GCPnts_UniformAbscissa discretizer(curve, segmentation, curve.FirstParameter(), curve.LastParameter()); if (discretizer.IsDone () && discretizer.NbPoints () > 2) { int nbPoints = discretizer.NbPoints (); @@ -3111,7 +3119,7 @@ void Area::toPath(Toolpath &path, const std::list &shapes, } if(fabs(first-last)>M_PI) { - // Split arc(circle) larger than half circle. + // Split arc(circle) larger than half circle. gp_Pnt mid = curve.Value((last-first)*0.5+first); addGArc(verbose,abs_center,path,plast,mid,center,clockwise,nf,cur_f); plast = mid; @@ -3129,7 +3137,7 @@ void Area::toPath(Toolpath &path, const std::list &shapes, } default: { // Discretize all other type of curves - GCPnts_QuasiUniformDeflection discretizer(curve, deflection, + GCPnts_QuasiUniformDeflection discretizer(curve, deflection, curve.FirstParameter(), curve.LastParameter()); if (discretizer.IsDone () && discretizer.NbPoints () > 1) { int nbPoints = discretizer.NbPoints (); @@ -3163,7 +3171,7 @@ bool Area::aborting() { AreaStaticParams::AreaStaticParams() {} - + AreaStaticParams Area::s_params; void Area::setDefaultParams(const AreaStaticParams ¶ms){