return _e1.isIn(_chararct_val_for_e1) && _e2.isIn(_chararct_val_for_e2);
}
-bool EdgeIntersector::intersect(const Bounds *whereToFind, std::vector<Node *>& newNodes, bool& order, MergePoints& commonNode)
+bool EdgeIntersector::intersect(std::vector<Node *>& newNodes, bool& order, MergePoints& commonNode)
{
std::list< IntersectElement > listOfIntesc=getIntersectionsCharacteristicVal();
std::list< IntersectElement >::iterator iter;
return true;
}
+/*! If the 2 edges share one extremity, we can optimize since we already know where is the intersection.
+ * In the case of ArcCSegIntersector, this also helps avoid degenerated cases.
+ */
+void EdgeIntersector::identifyEarlyIntersection(bool& i1S2S, bool& i1E2S, bool& i1S2E, bool& i1E2E)
+{
+ i1S2S = _e1.getStartNode() == _e2.getStartNode();
+ i1E2S = _e1.getEndNode() == _e2.getStartNode();
+ i1S2E = _e1.getStartNode() == _e2.getEndNode();
+ i1E2E = _e1.getEndNode() == _e2.getEndNode();
+ if (i1S2S || i1E2S || i1S2E || i1E2E)
+ {
+ Node * node;
+ bool i_1S(false),i_1E(false),i_2S(false),i_2E(false);
+ if (i1S2S || i1E2S) // Common node is e2 start
+ {
+ node = _e2.getStartNode();
+ i_1S = i1S2S; i_2S = true;
+ i_1E = i1E2S; i_2E = false;
+ }
+ else // Common node is e2 end
+ {
+ node = _e2.getEndNode();
+ i_1S = i1S2E; i_2S = false;
+ i_1E = i1E2E; i_2E = true;
+ }
+ node->incrRef();
+ _earlyInter = new IntersectElement(_e1.getCharactValue(*node), _e2.getCharactValue(*node),
+ i_1S,i_1E,i_2S,i_2E,node,_e1,_e2,keepOrder());
+ }
+}
+
/*!
* Locates 'node' regarding edge this->_e1. If node is located close to (with distant lt epsilon) start or end point of _e1,
* 'node' takes its place. In this case 'obvious' is set to true and 'commonNode' stores information of merge point and finally 'where' is set.
delete merge;
merge=0;
EdgeIntersector *intersector=BuildIntersectorWith(this,other);
- ret=Intersect(this,other,intersector,merge,commonNode,outVal1,outVal2);
+ ret=Intersect(this,other,intersector,commonNode,outVal1,outVal2);
delete intersector;
return ret;
}
ComposedEdge *f2=new ComposedEdge;
SegSegIntersector inters(*e1,*e2);
bool b1,b2;
- inters.areOverlappedOrOnlyColinears(0,b1,b2);
+ inters.areOverlappedOrOnlyColinears(b1,b2);
if(IntersectOverlapped(e1,e2,&inters,commonNode,*f1,*f2))
{
result[i][j]=f1->getCommonLengthWith(*f2)/e1->getCurveLength();
return getMiddleOfPoints(p1, p2, mid);
}
-bool Edge::Intersect(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, const Bounds *whereToFind, MergePoints& commonNode,
+bool Edge::Intersect(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, MergePoints& commonNode,
ComposedEdge& outValForF1, ComposedEdge& outValForF2)
{
bool obviousNoIntersection;
bool areOverlapped;
- intersector->areOverlappedOrOnlyColinears(whereToFind,obviousNoIntersection,areOverlapped);
+ intersector->areOverlappedOrOnlyColinears(obviousNoIntersection,areOverlapped);
if(areOverlapped)
return IntersectOverlapped(f1,f2,intersector,commonNode,outValForF1,outValForF2);
if(obviousNoIntersection)
return false;
std::vector<Node *> newNodes;
bool order;
- if(intersector->intersect(whereToFind,newNodes,order,commonNode))
+ if(intersector->intersect(newNodes,order,commonNode))
{
if(newNodes.empty())
throw Exception("Internal error occurred - error in intersector implementation!");// This case should never happen
}
return true;
}
- else//no intersection inside whereToFind
+ else
return false;
}