8#ifndef model_SweepPlane_H_
9#define model_SweepPlane_H_
26 template <
typename LineType,
int dim>
28 public std::map<float,std::pair<std::map<typename LineType::KeyType,const LineType*>,std::map<typename LineType::KeyType,const LineType*>>>,
29 public std::deque<std::pair<const LineType*,const LineType*>>
33 typedef std::map<typename LineType::KeyType,const LineType*>
EventMapType;
59 void addSegment(
const double& xStart,
const double& xEnd,
const LineType& line)
62 const bool success1=
events()[std::min(xStart,xEnd)].first.emplace(line.key,&line).second;
63 const bool success2=
events()[std::max(xStart,xEnd)].second.emplace(line.key,&line).second;
64 if(success1!=success2)
66 throw std::runtime_error(
"SweepPlane segment insertion error.");
74 std::map<typename LineType::KeyType,const LineType*> activeSegments;
79 for(
const auto& startingSegment :
event.second.first)
81 for(
const auto& activeSegment : activeSegments)
83 if(activeSegment.second!=startingSegment.second)
85 IntersectionPairContainerType::emplace_back(activeSegment.second,startingSegment.second);
89 const bool success=activeSegments.emplace(startingSegment.first,startingSegment.second).second;
92 throw std::runtime_error(
"SweepPlane::computeIntersectionPairs() cannot add segment.");
97 for(
const auto& endingSegment :
event.second.second)
99 const size_t nErased=activeSegments.erase(endingSegment.first);
102 throw std::runtime_error(
"SweepPlane::computeIntersectionPairs() cannot erase segment.");
108 assert(activeSegments.size()==0);
const std::pair< const LineType *, const LineType * > & potentialIntersectionPair(const size_t &k) const
void addSegment(const double &xStart, const double &xEnd, const LineType &line)
const IntersectionPairContainerType & potentialIntersectionPairs() const
EventContainerType & events()
void computeIntersectionPairs()
const EventContainerType & events() const
std::map< float, std::pair< EventMapType, EventMapType > > EventContainerType
std::deque< std::pair< const LineType *, const LineType * > > IntersectionPairContainerType
std::map< typename LineType::KeyType, const LineType * > EventMapType
enum insertvertexresult success