Exemplo 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;
}
Exemplo n.º 2
0
void Arrangement::formFaces ()
{
	for (Faces::iterator f = faces.begin(); f != faces.end(); ++f)
		delete *f;
	faces.clear();

	Edges inner;
	for (Edges::iterator e = edges.begin(); e != edges.end(); ++e) {
		if (!(*e)->flag) {
			Edge *l = (*e)->formLoop();

			Face *f = new Face;
			faces.push_back(f);
			f->id = face_id++;
			addBoundary(l, f);
		}
	}
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void box2dScene::addMovement(){
    ofVec2f mouse(ofGetMouseX(), ofGetMouseY());
    //    float minDis = ofGetMousePressed() ? 100 : 60;
    
    ofPoint mousePos = ofPoint(ofGetMouseX(), ofGetMouseY());
    
    vector<ofPoint> forcesPosVector;
    
    for (auto l = forces.begin(); l !=forces.end(); l++) {
        l->addSinMove(h, amplitude, angleVel, xVel, (RM->getRectForScreen(SCREEN_CENTER).y + RM->getRectForScreen(SCREEN_CENTER).height/2));
        l->addBoundary(w,h,forceR*1.2);
        l->update();
        ofPoint temp;
        temp=l->pos;
        forcesPosVector.push_back(temp);
    }
    
    

    for(int i=0; i<customParticles.size(); i++) {
        customParticles[i].get()->setDamping(damping);
        
        vector<float> distances;
        
        for (int l = 0; l<forcesPosVector.size(); l++) {
            ofPoint diff ;
            if (mouseforce) {
                diff = mousePos - customParticles[i].get()->getPosition();
            } else{
                diff = forcesPosVector[l] - customParticles[i].get()->getPosition();
            }
            
            float temp;
            temp = ofDist(0, 0, diff.x, diff.y);
            
            distances.push_back(temp);
            
        }
        
        
        ofPoint forcePosition;
        
        for (int d = 0; d < distances.size(); d++) {
            
            if (d<forceNum) {
                
                if(mouseforce){
                    forcePosition = mousePos;
                } else{
                    forcePosition = ofPoint(forcesPosVector[d].x,forcesPosVector[d].y);
                }
                
                float fR =forceR*forceRscale[d];
                float rotateR = fR*0.4;
                
                if (distances[d]<fR){
                    customParticles[i].get()->addRepulsionForce(forcePosition, repulF*0.5);}
            }
        }
        
        
//        if (customParticles[i].get()->getVelocity() == ofVec2f(0,0)) {
//            customParticles.erase(customParticles.begin()+i);
//        }
//        
//        if (customParticles[i].get()->getPosition().y < RM->getRectForScreen(SCREEN_CENTER).y) {
//            customParticles.erase(customParticles.begin()+i);
//        }

    }
    
    for(int i=customParticles.size()-1; i>=0; i--) {
        if (customParticles[i].get()->getPosition().y < RM->getRectForScreen(SCREEN_CENTER).y) {
            customParticles.erase(customParticles.begin()+i);
        }
        
        if (customParticles[i].get()->getVelocity() == ofVec2f(0,0)) {
                        customParticles.erase(customParticles.begin()+i);
                    }

    }
    
}