Esempio n. 1
0
RHatchData& RHatchData::operator =(const RHatchData& other) {
    REntityData::operator=(other);

    solid = other.solid;
    scaleFactor = other.scaleFactor;
    angle = other.angle;
    patternName = other.patternName;
    originPoint = other.originPoint;
    //other.getPainterPath(false);
    other.getPainterPaths(false);
    //painterPath = other.painterPath;
    painterPaths = other.painterPaths;
    boundaryPath = other.boundaryPath;
    dirty = other.dirty;
    gotDraft = other.gotDraft;

    boundary.clear();

    for (int i=0; i<other.boundary.size(); ++i) {
        newLoop();
        QList<QSharedPointer<RShape> > loop = other.boundary.at(i);
        for (int k=0; k<loop.size(); ++k) {
            QSharedPointer<RShape> shape = loop.at(k);

            QSharedPointer<RLine> line = shape.dynamicCast<RLine>();
            if (!line.isNull()) {
                addBoundary(QSharedPointer<RShape>(new RLine(*line)));
                continue;
            }

            QSharedPointer<RArc> arc = shape.dynamicCast<RArc>();
            if (!arc.isNull()) {
                addBoundary(QSharedPointer<RShape>(new RArc(*arc)));
                continue;
            }

            QSharedPointer<RCircle> circle = shape.dynamicCast<RCircle>();
            if (!circle.isNull()) {
                addBoundary(QSharedPointer<RShape>(new RCircle(*circle)));
                continue;
            }

            QSharedPointer<REllipse> ellipseArc = shape.dynamicCast<REllipse>();
            if (!ellipseArc.isNull()) {
                addBoundary(QSharedPointer<RShape>(new REllipse(*ellipseArc)));
                continue;
            }

            QSharedPointer<RSpline> spline = shape.dynamicCast<RSpline>();
            if (!spline.isNull()) {
                addBoundary(QSharedPointer<RShape>(new RSpline(*spline)));
                continue;
            }
        }
    }

    return *this;
}
Esempio n. 2
0
int Slice::GenerateLoops()
{
    unsigned int s;
    bool triangulateSuccess;
    int fillVoidIndicator;


	for(s=0; s<segmentList.size(); s++)//pick a segment, any segment
	{
		if(!segmentList[s]->pLoop)//only if it doesnt belong to a loop already
		{
			Loop newLoop(segmentList[s], this);
			if(newLoop.Grow() >= 3)//this filters out single segment danglers, and 1dimentional loops
			{
				loopList.push_back(newLoop);//add to the list of loops for this slice
				numLoops++;
			}
			else//failed loop
			{
				newLoop.Destroy();//segment's parent pointer is set back to null
				//these passed-up segments should not be claimed by a loop again.
				//the new loop will now fall out of scope.
			}
		}
	}


    //run through various filters in before determining fill or void
    for(unsigned int l = 0; l < loopList.size(); l++)//looplist.size keeps growing..
    {
        loopList[l].Simplify();//remove small segments
        loopList[l].CorrectDoubleBacks();
    }

    for(unsigned int l = 0; l < loopList.size(); l++)//looplist.size keeps growing..
    {
        loopList[l].AttemptSplitUp(this);//split figure eights.
    }

    for(unsigned int l = 0; l < loopList.size(); l++)
    {
        fillVoidIndicator = loopList[l].DetermineTypeBySides();


        loopList[l].formPolygon();

        triangulateSuccess = loopList[l].formTriStrip();
        if(!triangulateSuccess)
            qDebug() << "B9Loop: Warning Tesselator Memory Starved!";
    }


    return numLoops;
}
Esempio n. 3
0
bool Loop::AttemptSplitUp(Slice* pslice)
{
    unsigned int s1;
    unsigned int s2;
    unsigned int s;
    QVector2D intersectpoint;
    Segment* currSeg;
    std::vector<Segment*> keeplist;
    for(s1 = 0; s1 < segListp.size(); s1++)
    {
        for(s2 = 0; s2 < segListp.size(); s2++)
        {
            if(s1 == s2)
                continue;
            if(segListp[s2] == segListp[s1]->leadingSeg || segListp[s2] == segListp[s1]->trailingSeg)
                continue;
            if(SegmentsAffiliated(segListp[s1], segListp[s2], 0.00001))
                continue;

            if(SegmentIntersection(intersectpoint, segListp[s1]->p1, segListp[s1]->p2, segListp[s2]->p1, segListp[s2]->p2))
            {
                Segment* seg1 = new Segment(intersectpoint, segListp[s1]->p2);
                Segment* seg2 = new Segment(segListp[s2]->p1, intersectpoint);

                seg1->trailingSeg = seg2;
                seg2->leadingSeg = seg1;

                seg1->leadingSeg = segListp[s1]->leadingSeg;
                seg2->trailingSeg = segListp[s2]->trailingSeg;

                segListp[s1]->leadingSeg->trailingSeg = seg1;
                segListp[s2]->trailingSeg->leadingSeg = seg2;

                segListp[s1]->p2 = intersectpoint;
                segListp[s2]->p1 = intersectpoint;
                segListp[s1]->FormNormal();
                segListp[s2]->FormNormal();

                segListp[s1]->leadingSeg = segListp[s2];
                segListp[s2]->trailingSeg = segListp[s1];

                pslice->segmentList.push_back(seg1);
                pslice->segmentList.push_back(seg2);
                segListp.push_back(seg1);
                segListp.push_back(seg2);

                currSeg = seg1;

                //fill the list of segments for the new loop
                do
                {
                    currSeg->pLoop = NULL;
                    currSeg->chucked = true;
                    currSeg = currSeg->leadingSeg;
                } while(currSeg != seg1);


                keeplist.clear();

                for(s = 0; s < segListp.size(); s++)
                {
                    if(segListp[s]->chucked)
                    {
                        segListp[s]->chucked = false;
                    }
                    else
                    {
                        keeplist.push_back(segListp[s]);
                    }
                }
                segListp.clear();
                segListp = keeplist;
                numSegs = segListp.size();

                //make a new loop, growing it off of the seg1;
                Loop newLoop(seg1->leadingSeg, pslice);
                if(newLoop.Grow() >= 3)
                {
                    pSlice->loopList.push_back(newLoop);
                }
                else
                {
                    newLoop.Destroy();
                }

                return true;
            }
        }
    }

    return false;
}