#ifndef DUST3D_REGION_FILLER_H #define DUST3D_REGION_FILLER_H #include #include #include class RegionFiller { public: struct Node { QVector3D position; float radius = 0.0; size_t source = 0; }; RegionFiller(const std::vector *vertices, const std::vector> *polylines); ~RegionFiller(); bool fill(); void fillWithoutPartition(); const std::vector &getOldAndNewVertices(); const std::vector> &getNewFaces(); private: const std::vector *m_sourceVertices = nullptr; std::vector> *m_sourcePolylines = nullptr; int m_sideNum = 0; int m_sumOfSegments = 0; std::vector m_sideSegmentNums; std::vector m_oldAndNewVertices; std::vector> m_newFaces; std::vector>> m_newRegions; std::set m_centerSources; float averageRadius(size_t *maxNodeIndex=nullptr); void createPointsBetween(size_t fromIndex, size_t toIndex, size_t segments, std::vector *newPointIndices); std::vector createPointsBetween(size_t fromIndex, size_t toIndex, size_t segments); void collectEdgePoints(size_t polyline, int startPos, int stopPos, std::vector *pointIndices); std::vector collectEdgePoints(size_t polyline, int startPos, int stopPos); std::vector reversed(const std::vector &pointIndices); std::vector createPointsToMapBetween(size_t fromIndex, size_t toIndex, size_t segments, std::map, std::vector> *map); bool resolveOddSidedEvenSumOfSegments(int siUpperBound); bool resolveOddSidedOddSumOfSegments(int siUpperBound); bool resolveEvenSidedEvenSumOfSegmentsAndBothL2L2AreEven(); bool resolveEvenSidedEvenSumOfSegmentsAndBothL2L2AreOdd(); bool resolveEvenSideEvenSumOfSegmentsAndL1IsEvenL2IsOdd(); bool resolveEvenSideEvenSumOfSegmentsAndL1IsOddL2IsEven(); bool resolveQuadrilateralRegion(); bool resolveQuadrilateralRegionWithIntegerSolution(int m, int n, int p, int q, bool pqSwapped); bool resolveQuadrilateralRegionMismatchSimilarCase(int m, int n, int p, int q, bool pqSwapped); bool resolveQuadrilateralRegionWithNonIntegerSolution(int m, int n, int p, int q, bool pqSwapped); bool resolveQuadrilateralRegionDirectCase(); void convertRegionsToFaces(); void prepare(); bool createCoonsPatch(const std::vector> ®ion); bool convertRegionsToPatches(); bool createCoonsPatchFrom(const std::vector &c0, const std::vector &c1, const std::vector &d0, const std::vector &d1, bool fillLastTriangle=false); bool createCoonsPatchThreeSidedRegion(const std::vector> ®ion); void convertPolylinesToFaces(); }; #endif