本文整理汇总了C++中Span::Intof方法的典型用法代码示例。如果您正苦于以下问题:C++ Span::Intof方法的具体用法?C++ Span::Intof怎么用?C++ Span::Intof使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Span
的用法示例。
在下文中一共展示了Span::Intof方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int Kurve::OffsetMethod1(Kurve& kOffset, double off, int direction, int method, int& ret)const
{
// offset kurve with simple span elimination
// direction 1 = left, -1 = right
// ret = 0 - kurve offset ok
// = 1 - kurve has differential scale (not allowed)
// = 2 - offset failed
// = 3 - offset too large
if(this == &kOffset) FAILURE(L"Illegal Call - 'this' must not be kOffset");
double offset = (direction == GEOFF_LEFT)?off : -off;
if(fabs(offset) < geoff_geometry::TOLERANCE || m_nVertices < 2) {
kOffset = *this;
ret = 0;
return 1;
}
Span curSpan, curSpanOff; // current & offset spans
Span prevSpanOff; // previous offset span
Point p0, p1; // Offset span intersections
// offset Kurve
kOffset = Matrix(*this);
if(m_mirrored) offset = -offset;
int RollDir = ( off < 0 ) ? direction : - direction; // Roll arc direction
double scalex;
if(!GetScale(scalex)) {
ret = 1;
return 0; // differential scale
}
offset /= scalex;
bool bClosed = Closed();
int nspans = nSpans();
if(bClosed) {
Get(nspans, curSpan, true); // assign previus span for closed
prevSpanOff = curSpan.Offset(offset);
nspans++; // read first again
}
for(int spannumber = 1; spannumber <= nspans; spannumber++) {
if(spannumber > nSpans())
Get(1, curSpan, true); // closed kurve - read first span again
else
Get(spannumber, curSpan, true);
if(!curSpan.NullSpan) {
int numint = 0;
curSpanOff = curSpan.Offset(offset);
curSpanOff.ID = 0;
if(!kOffset.m_started) {
kOffset.Start(curSpanOff.p0);
kOffset.AddSpanID(0);
}
if(spannumber > 1) {
// see if tangent
double d = curSpanOff.p0.Dist(prevSpanOff.p1);
if((d > geoff_geometry::TOLERANCE) && (curSpanOff.NullSpan == false && prevSpanOff.NullSpan == false)) {
// see if offset spans intersect
double cp = prevSpanOff.ve ^ curSpanOff.vs;
bool inters = (cp > 0 && direction == GEOFF_LEFT) || (cp < 0 && direction == GEOFF_RIGHT);
if(inters) {
double t[4];
numint = prevSpanOff.Intof(curSpanOff, p0, p1, t);
}
if(numint == 1) {
// intersection - modify previous endpoint
kOffset.Replace(kOffset.m_nVertices-1, prevSpanOff.dir, p0, prevSpanOff.pc, prevSpanOff.ID);
}
else {
// 0 or 2 intersections, add roll around (remove -ve loops in elimination function)
if(kOffset.Add(RollDir, curSpanOff.p0, curSpan.p0, false)) kOffset.AddSpanID(ROLL_AROUND);
}
}
}
// add span
if(spannumber < m_nVertices) {
curSpanOff.ID = spannumber;
kOffset.Add(curSpanOff, false);
}
else if(numint == 1) // or replace the closed first span
kOffset.Replace(0, 0, p0, Point(0, 0), 0);
}
if(!curSpanOff.NullSpan)prevSpanOff = curSpanOff;
} // end of main pre-offsetting loop
#ifdef _DEBUG
//testDraw->AddKurve("", &kOffset, 0, GREEN);
// outXML oxml(L"c:\\temp\\eliminateLoops.xml");
//.........这里部分代码省略.........