| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #ifndef _CurveProjector_h_
|
| | #define _CurveProjector_h_
|
| |
|
| | #include <limits>
|
| |
|
| | #include <TopoDS_Edge.hxx>
|
| |
|
| | #include <Mod/Mesh/App/Mesh.h>
|
| | #include <Mod/MeshPart/MeshPartGlobal.h>
|
| |
|
| | #include <Standard_Version.hxx>
|
| |
|
| | namespace MeshCore
|
| | {
|
| | class MeshKernel;
|
| | class MeshGeomFacet;
|
| | class MeshFacetGrid;
|
| | }
|
| |
|
| | using MeshCore::MeshGeomFacet;
|
| | using MeshCore::MeshKernel;
|
| |
|
| | namespace MeshPart
|
| | {
|
| |
|
| | |
| |
|
| | class MeshPartExport CurveProjector
|
| | {
|
| | public:
|
| | CurveProjector(const TopoDS_Shape& aShape, const MeshKernel& pMesh);
|
| | virtual ~CurveProjector() = default;
|
| |
|
| | struct FaceSplitEdge
|
| | {
|
| | MeshCore::FacetIndex ulFaceIndex;
|
| | Base::Vector3f p1, p2;
|
| | };
|
| |
|
| | template<class T>
|
| | struct TopoDSLess
|
| | {
|
| | bool operator()(const T& x, const T& y) const
|
| | {
|
| | #if OCC_VERSION_HEX >= 0x070800
|
| | std::hash<T> hasher;
|
| | return hasher(x) < hasher(y);
|
| | #else
|
| | constexpr int max = std::numeric_limits<int>::max();
|
| | return x.HashCode(max - 1) < y.HashCode(max - 1);
|
| | #endif
|
| | }
|
| | };
|
| |
|
| | using result_type = std::map<TopoDS_Edge, std::vector<FaceSplitEdge>, TopoDSLess<TopoDS_Edge>>;
|
| |
|
| |
|
| | result_type& result()
|
| | {
|
| | return mvEdgeSplitPoints;
|
| | }
|
| |
|
| | void writeIntersectionPointsToFile(const char* name = "export_pts.asc");
|
| |
|
| | protected:
|
| | virtual void Do() = 0;
|
| | const TopoDS_Shape& _Shape;
|
| | const MeshKernel& _Mesh;
|
| | result_type mvEdgeSplitPoints;
|
| | };
|
| |
|
| |
|
| | |
| |
|
| | class MeshPartExport CurveProjectorShape: public CurveProjector
|
| | {
|
| | public:
|
| | CurveProjectorShape(const TopoDS_Shape& aShape, const MeshKernel& pMesh);
|
| | ~CurveProjectorShape() override = default;
|
| |
|
| | void projectCurve(const TopoDS_Edge& aEdge, std::vector<FaceSplitEdge>& vSplitEdges);
|
| |
|
| | bool findStartPoint(
|
| | const MeshKernel& MeshK,
|
| | const Base::Vector3f& Pnt,
|
| | Base::Vector3f& Rslt,
|
| | MeshCore::FacetIndex& FaceIndex
|
| | );
|
| |
|
| |
|
| | protected:
|
| | void Do() override;
|
| | };
|
| |
|
| |
|
| | |
| |
|
| | class MeshPartExport CurveProjectorSimple: public CurveProjector
|
| | {
|
| | public:
|
| | CurveProjectorSimple(const TopoDS_Shape& aShape, const MeshKernel& pMesh);
|
| | ~CurveProjectorSimple() override = default;
|
| |
|
| |
|
| | void GetSampledCurves(
|
| | const TopoDS_Edge& aEdge,
|
| | std::vector<Base::Vector3f>& rclPoints,
|
| | unsigned long ulNbOfPoints = 30
|
| | );
|
| |
|
| |
|
| | void projectCurve(
|
| | const TopoDS_Edge& aEdge,
|
| | const std::vector<Base::Vector3f>& rclPoints,
|
| | std::vector<FaceSplitEdge>& vSplitEdges
|
| | );
|
| |
|
| | bool findStartPoint(
|
| | const MeshKernel& MeshK,
|
| | const Base::Vector3f& Pnt,
|
| | Base::Vector3f& Rslt,
|
| | MeshCore::FacetIndex& FaceIndex
|
| | );
|
| |
|
| |
|
| | protected:
|
| | void Do() override;
|
| | };
|
| |
|
| | |
| |
|
| | class MeshPartExport CurveProjectorWithToolMesh: public CurveProjector
|
| | {
|
| | public:
|
| | struct LineSeg
|
| | {
|
| | Base::Vector3f p;
|
| | Base::Vector3f n;
|
| | };
|
| |
|
| | CurveProjectorWithToolMesh(const TopoDS_Shape& aShape, const MeshKernel& pMesh, MeshKernel& rToolMesh);
|
| | ~CurveProjectorWithToolMesh() override = default;
|
| |
|
| |
|
| | void makeToolMesh(const TopoDS_Edge& aEdge, std::vector<MeshGeomFacet>& cVAry);
|
| |
|
| |
|
| | MeshKernel& ToolMesh;
|
| |
|
| | protected:
|
| | void Do() override;
|
| | };
|
| |
|
| | |
| | |
| | |
| |
|
| | class MeshPartExport MeshProjection
|
| | {
|
| | public:
|
| |
|
| | struct SplitEdge
|
| | {
|
| | MeshCore::PointIndex uE0, uE1;
|
| | Base::Vector3f cPt;
|
| | };
|
| | struct Edge
|
| | {
|
| | Base::Vector3f cPt1;
|
| | Base::Vector3f cPt2;
|
| | };
|
| | struct PolyLine
|
| | {
|
| | std::vector<Base::Vector3f> points;
|
| | };
|
| |
|
| | explicit MeshProjection(const MeshKernel& rMesh);
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | void findSectionParameters(
|
| | const TopoDS_Edge& edge,
|
| | const Base::Vector3f& dir,
|
| | std::set<double>& parameters
|
| | ) const;
|
| | void discretize(
|
| | const TopoDS_Edge& aEdge,
|
| | std::vector<Base::Vector3f>& polyline,
|
| | std::size_t minPoints = 2
|
| | ) const;
|
| | |
| | |
| | |
| | |
| |
|
| | void projectToMesh(const TopoDS_Shape& aShape, float fMaxDist, std::vector<PolyLine>& rPolyLines) const;
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | void projectOnMesh(
|
| | const std::vector<Base::Vector3f>& pointsIn,
|
| | const Base::Vector3f& dir,
|
| | float tolerance,
|
| | std::vector<Base::Vector3f>& pointsOut
|
| | ) const;
|
| | |
| | |
| |
|
| | void projectParallelToMesh(
|
| | const TopoDS_Shape& aShape,
|
| | const Base::Vector3f& dir,
|
| | std::vector<PolyLine>& rPolyLines
|
| | ) const;
|
| | |
| | |
| |
|
| | void projectParallelToMesh(
|
| | const std::vector<PolyLine>& aEdges,
|
| | const Base::Vector3f& dir,
|
| | std::vector<PolyLine>& rPolyLines
|
| | ) const;
|
| | |
| | |
| | |
| |
|
| | void splitMeshByShape(const TopoDS_Shape& aShape, float fMaxDist) const;
|
| |
|
| | protected:
|
| | void projectEdgeToEdge(
|
| | const TopoDS_Edge& aCurve,
|
| | float fMaxDist,
|
| | const MeshCore::MeshFacetGrid& rGrid,
|
| | std::vector<SplitEdge>& rSplitEdges
|
| | ) const;
|
| | bool findIntersection(const Edge&, const Edge&, const Base::Vector3f& dir, Base::Vector3f& res) const;
|
| |
|
| | private:
|
| | const MeshKernel& _rcMesh;
|
| | };
|
| |
|
| | }
|
| |
|
| | #endif
|
| |
|