| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #ifndef MESH_SETOPERATIONS_H
|
| | #define MESH_SETOPERATIONS_H
|
| |
|
| | #include <list>
|
| | #include <map>
|
| | #include <set>
|
| |
|
| | #include <Base/Builder3D.h>
|
| |
|
| | #include "Iterator.h"
|
| | #include "MeshKernel.h"
|
| | #include "Visitor.h"
|
| |
|
| |
|
| |
|
| |
|
| | namespace MeshCore
|
| | {
|
| |
|
| | class MeshGeomFacet;
|
| | class MeshGeomEdge;
|
| | class MeshBuilder;
|
| | class MeshKernel;
|
| | class MeshFacetGrid;
|
| | class MeshFacetArray;
|
| | class MeshFacetIterator;
|
| |
|
| | |
| | |
| |
|
| | class MeshExport SetOperations
|
| | {
|
| | public:
|
| | enum OperationType
|
| | {
|
| | Union,
|
| | Intersect,
|
| | Difference,
|
| | Inner,
|
| | Outer
|
| | };
|
| |
|
| |
|
| | SetOperations(
|
| | const MeshKernel& cutMesh1,
|
| | const MeshKernel& cutMesh2,
|
| | MeshKernel& result,
|
| | OperationType opType,
|
| | float minDistanceToPoint = 1e-5F
|
| | );
|
| |
|
| | public:
|
| | |
| | |
| | |
| |
|
| | void Do();
|
| |
|
| | private:
|
| | const MeshKernel& _cutMesh0;
|
| | const MeshKernel& _cutMesh1;
|
| | MeshKernel& _resultMesh;
|
| | OperationType _operationType;
|
| | float _minDistanceToPoint;
|
| |
|
| | private:
|
| |
|
| | class Edge
|
| | {
|
| | public:
|
| | MeshPoint pt1, pt2;
|
| |
|
| | Edge() = default;
|
| |
|
| | Edge(MeshPoint p1, MeshPoint p2)
|
| | {
|
| | if (p1 < p2) {
|
| | pt1 = p1;
|
| | pt2 = p2;
|
| | }
|
| | else {
|
| | pt2 = p1;
|
| | pt1 = p2;
|
| | }
|
| | }
|
| |
|
| | bool operator==(const Edge& edge) const
|
| | {
|
| | return (pt1 == edge.pt1) && (pt2 == edge.pt2);
|
| | }
|
| |
|
| | bool operator<(const Edge& edge) const
|
| | {
|
| | return (pt1 == edge.pt1) ? (pt2 < edge.pt2) : (pt1 < edge.pt1);
|
| | }
|
| | };
|
| |
|
| | class EdgeInfo
|
| | {
|
| | public:
|
| | int fcounter[2] {};
|
| | MeshGeomFacet facets[2][2];
|
| | FacetIndex facet[2] {};
|
| | };
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | class CollectFacetVisitor: public MeshFacetVisitor
|
| | {
|
| | public:
|
| | std::vector<FacetIndex>& _facets;
|
| | const MeshKernel& _mesh;
|
| | std::map<Edge, EdgeInfo>& _edges;
|
| | int _side;
|
| | float _mult;
|
| | int _addFacets {-1};
|
| | Base::Builder3D& _builder;
|
| |
|
| | CollectFacetVisitor(
|
| | const MeshKernel& mesh,
|
| | std::vector<FacetIndex>& facets,
|
| | std::map<Edge, EdgeInfo>& edges,
|
| | int side,
|
| | float mult,
|
| | Base::Builder3D& builder
|
| | );
|
| | bool Visit(
|
| | const MeshFacet& rclFacet,
|
| | const MeshFacet& rclFrom,
|
| | FacetIndex ulFInd,
|
| | unsigned long ulLevel
|
| | ) override;
|
| | bool AllowVisit(
|
| | const MeshFacet& rclFacet,
|
| | const MeshFacet& rclFrom,
|
| | FacetIndex ulFInd,
|
| | unsigned long ulLevel,
|
| | unsigned short neighbourIndex
|
| | ) override;
|
| | };
|
| |
|
| |
|
| | std::set<MeshPoint> _cutPoints;
|
| |
|
| | std::map<Edge, EdgeInfo> _edges;
|
| | |
| |
|
| | std::map<FacetIndex, std::list<std::set<MeshPoint>::iterator>> _facet2points[2];
|
| |
|
| | std::vector<MeshGeomFacet> _facetsOf[2];
|
| |
|
| | std::vector<MeshGeomFacet> _newMeshFacets[2];
|
| |
|
| |
|
| | void Cut(std::set<FacetIndex>& facetsCuttingEdge0, std::set<FacetIndex>& facetsCuttingEdge1);
|
| |
|
| | void TriangulateMesh(const MeshKernel& cutMesh, int side);
|
| |
|
| | void CollectFacets(int side, float mult);
|
| |
|
| | void CloseGaps(MeshBuilder& meshBuilder);
|
| |
|
| |
|
| | Base::Builder3D _builder;
|
| | };
|
| |
|
| | |
| | |
| |
|
| | class MeshExport MeshIntersection
|
| | {
|
| | public:
|
| | struct Tuple
|
| | {
|
| | Base::Vector3f p1, p2;
|
| | FacetIndex f1, f2;
|
| | };
|
| | struct Triple
|
| | {
|
| | Base::Vector3f p;
|
| | FacetIndex f1, f2;
|
| | };
|
| | struct Pair
|
| | {
|
| | Base::Vector3f p;
|
| | FacetIndex f;
|
| | };
|
| |
|
| | MeshIntersection(const MeshKernel& m1, const MeshKernel& m2, float dist)
|
| | : kernel1(m1)
|
| | , kernel2(m2)
|
| | , minDistance(dist)
|
| | {}
|
| |
|
| | bool hasIntersection() const;
|
| | void getIntersection(std::list<Tuple>&) const;
|
| | |
| | |
| | |
| | |
| |
|
| | void connectLines(bool onlyclosed, const std::list<Tuple>&, std::list<std::list<Triple>>&);
|
| |
|
| | private:
|
| | static bool testIntersection(const MeshKernel& k1, const MeshKernel& k2);
|
| |
|
| | private:
|
| | const MeshKernel& kernel1;
|
| | const MeshKernel& kernel2;
|
| | float minDistance;
|
| | };
|
| |
|
| |
|
| | }
|
| |
|
| | #endif
|
| |
|