/*************************************************************************** * Copyright (c) 2016 WandererFan * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #ifndef DrawProjectSplit_h_ #define DrawProjectSplit_h_ #include #include #include #include #include #include "DrawUtil.h" #include "Geometry.h" class gp_Pnt; class gp_Ax2; namespace TechDraw { class GeometryObject; using GeometryObjectPtr = std::shared_ptr; class Vertex; class BaseGeom; } namespace TechDraw { //magic number for finding parameter of point on curve #define PARAM_MAX_DIST 0.000001 struct splitPoint { int i; Base::Vector3d v; double param; }; class edgeSortItem { public: edgeSortItem() { startAngle = endAngle = 0.0; idx = 0; } ~edgeSortItem() = default; Base::Vector3d start; Base::Vector3d end; double startAngle; double endAngle; unsigned int idx; static bool edgeLess(const edgeSortItem& e1, const edgeSortItem& e2); static bool edgeEqual(const edgeSortItem& e1, const edgeSortItem& e2); std::string dump(); }; using vertexMap = std::map; class edgeVectorEntry { public: edgeVectorEntry(TopoDS_Edge e, bool flag) { edge = e; validFlag = flag; } ~edgeVectorEntry() = default; TopoDS_Edge edge; bool validFlag; }; class TechDrawExport DrawProjectSplit { public: DrawProjectSplit(); ~DrawProjectSplit(); public: static std::vector getEdgesForWalker(TopoDS_Shape shape, double scale, Base::Vector3d direction); static TechDraw::GeometryObjectPtr buildGeometryObject(TopoDS_Shape shape, const gp_Ax2& viewAxis); static bool isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, double& param, bool allowEnds = false); static std::vector splitEdges(std::vector orig, std::vector splits); static std::vector split1Edge(TopoDS_Edge e, std::vector splitPoints); static std::vector sortSplits(std::vector& s, bool ascend); static bool splitCompare(const splitPoint& p1, const splitPoint& p2); static bool splitEqual(const splitPoint& p1, const splitPoint& p2); static std::vector removeDuplicateEdges(std::vector& inEdges); static std::vector sortEdges(std::vector& e, bool ascend); //routines for revised face finding approach static std::vector scrubEdges(const std::vector &origEdges, std::vector& closedEdges); static std::vector scrubEdges(std::vector& origEdges, std::vector& closedEdges); static vertexMap getUniqueVertexes(std::vector inEdges); static std::vector pruneUnconnected(vertexMap verts, std::vector edges); static std::vector removeOverlapEdges(const std::vector& inEdges); static bool sameEndPoints(const TopoDS_Edge& e1, const TopoDS_Edge& e2); static int isSubset(const TopoDS_Edge &e0, const TopoDS_Edge &e1); static std::vector fuseEdges(const TopoDS_Edge& e0, const TopoDS_Edge& e1); static bool boxesIntersect(const TopoDS_Edge& e0, const TopoDS_Edge& e1); static void dumpVertexMap(vertexMap verts); }; using DrawProjectSplitPython = App::FeaturePythonT; } //namespace TechDraw #endif // #ifndef DrawProjectSplit_h_