Ejemplo n.º 1
0
//----------------------------------------------------------
void ofTextureAdv::setPoints(ofPoint inputPts[4], ofPoint outputPts[4]){
	for (int i = 0; i < 4; i++){
	    quad[i].set(outputPts[i].x, outputPts[i].y, 0);
	    utQuad[i].set(inputPts[i].x, inputPts[i].y, 0);
	}
	updatePoints();
}
Ejemplo n.º 2
0
void LC_DlgSplinePoints::setSpline(LC_SplinePoints& b)
{
    bezier = &b;
    //pen = spline->getPen();
    ui->wPen->setPen(b.getPen(false), true, false, "Pen");
    RS_Graphic* graphic = b.getGraphic();
    if (graphic) {
        ui->cbLayer->init(*(graphic->getLayerList()), false, false);
    }
    RS_Layer* lay = b.getLayer(false);
    if (lay) {
        ui->cbLayer->setLayer(*lay);
    }

    ui->cbClosed->setChecked(b.isClosed());

    //number of control points
    auto const& bData = b.getData();
    auto const n = bData.splinePoints.size();
    if (n <= 2) {
        ui->rbControlPoints->setChecked(true);
        ui->rbSplinePoints->setEnabled(false);
    } else
        ui->rbSplinePoints->setChecked(true);
    updatePoints();
}
Ejemplo n.º 3
0
//the game loop, calls all of the supplemental
//methods of the application to continuously
//update and maintain the functionality of the
//game
void Application::gameLoop()
{
    while(gameRunning)
    {
        handleEnvironment();

        updateMonsters();

        handleEvents();

        updatePlayer();

        handleArrows();

        handlePhysics();

        delta.start();

        checkBoundaries();
        updateFPS();
        updatePoints();
        drawSurface();

        if(finished)
        {
            showFinal();
        }

    }
}
Ejemplo n.º 4
0
void GeneticAlgorithm::run()
{
    initGenerator();

    for (int i = 0; i < GA_MAXITER; i++) {

        QList<double> *points = new QList<double>();
        for( int j = 0; j < GA_POWER; j++){
            points->append(m_genotype.at(j).x);
        }
        emit updatePoints(points);
        reproductionOperator();
        mutationOperator();
        reductionOperator();


        QVector<gene> tmp = m_genotype;
        tmp.removeAll(tmp.first());
        if (tmp.isEmpty()) {
            qDebug() << "EARLY END";
            qDebug() << "Total iterations: " << i;
            break;
        }
    }

    qDebug() << "Result:" << m_genotype.last().fitness;

}
Ejemplo n.º 5
0
void BoxContact::update()
{
    /**
     * Retrieve boxes
     */
    auto & shapeA = (BoxShape&)*m_bodyA.shape();
    auto & shapeB = (BoxShape&)*m_bodyB.shape();
    auto boxA = shapeA.instanciate(m_bodyA.transform());
    auto boxB = shapeB.instanciate(m_bodyB.transform());

    /**
     * Intersect
     */
    CollideBox3D collideBox3D(boxA, boxB);
    m_intersect = collideBox3D.execute();

    /**
     * Update contact points
     */
    if (m_intersect)
    {
        updatePoints({collideBox3D.numIntersections, collideBox3D.intersections});
    }
    else
    {
        clearPoints();
    }

}
Ejemplo n.º 6
0
EditCurve::EditCurve(BezierCurve *targetCurve, Color curveColor) : UIElement() {

    this->targetCurve = targetCurve;

    poly = new Polycode::Polygon();

    for(int i=0; i < CURVE_SIZE; i++) {
        poly->addVertex(0.0, 0.0, 0.0);
    }

    visMesh = new ScreenMesh(Mesh::LINE_STRIP_MESH);
    visMesh->getMesh()->addPolygon(poly);

    visMesh->lineSmooth = true;
    visMesh->lineWidth = 2.0;

    addChild(visMesh);
    visMesh->setPosition(0, 254);
    visMesh->color = curveColor;

    pointsBase = new UIElement();
    addChild(pointsBase);

    pointToRemove = NULL;

    updateCurve();
    updatePoints();

    Deactivate();
}
Ejemplo n.º 7
0
ArbRamp::ArbRamp(QWidget *parent) : QMainWindow(parent), ui(new Ui::ArbRamp) {
    ui->setupUi(this);
    curLine=-1;
    nLines=0;
    render=new RenderRamp();
    ui->scrollArea->setWidget(render);
    delegate=new RampDelegate(ui->tableWidget);
    ui->tableWidget->setItemDelegate(delegate);
    setCurrentFile("");
    curDir="";
    readSettings();
    addAction=new QAction(tr("Insert"),this);
    delAction=new QAction(tr("Delete"),this);
    updateAction=new QAction(tr("Update view"),this);
    ui->mainToolBar->addAction(addAction);
    ui->mainToolBar->addAction(delAction);
    ui->mainToolBar->addAction(updateAction);
    //Connect signal and slots.
    connect(ui->action_About,SIGNAL(triggered()),this,SLOT(about()));
    connect(ui->action_Quit,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui->action_Save,SIGNAL(triggered()),this,SLOT(save()));
    connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(saveAs()));
    connect(ui->action_Open,SIGNAL(triggered()),this,SLOT(open()));
    connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newRamp()));
    connect(ui->action_Export,SIGNAL(triggered()),this,SLOT(exportRamp()));
    connect(ui->mainToolBar,SIGNAL(actionTriggered(QAction*)),this,
            SLOT(chooseAction(QAction*)));
    connect(this,SIGNAL(renderUpdate(QList<QPoint>)),render,
            SLOT(updatePoints(QList<QPoint>)));
    connect(ui->tableWidget,SIGNAL(currentCellChanged(int,int,int,int)),this,
            SLOT(currentLine(int,int,int,int)));
    //So that wasModified has access to the real size of the RenderRamp object.
    show();
    wasModified();
}
Ejemplo n.º 8
0
void CircleShape::setPointCount( size_t count ) {
    m_pointCount = count;

    m_vertices.resize( m_pointCount );

    updatePoints();
}
Ejemplo n.º 9
0
//--------------------------------------------------------------
void Wave::update(float dt)
{
	m_age += dt;
	if (m_age>m_ageMax) m_age = m_ageMax;
	m_color.a = 255*(1.0-m_age/m_ageMax);
	m_radius += m_radiusSpeed*dt;
	updatePoints();
}
Ejemplo n.º 10
0
void DrawingItemGroup::removeItem(DrawingItem* item)
{
	if (item && containsItem(item))
	{
		mItems.removeAll(item);
		updatePoints();
	}
}
Ejemplo n.º 11
0
void DrawingItemGroup::addItem(DrawingItem* item)
{
	if (item && !containsItem(item))
	{
		mItems.append(item);
		updatePoints();
	}
}
Ejemplo n.º 12
0
void DrawingItemGroup::flipItem(const QPointF& parentPos)
{
	DrawingItem::flipItem(parentPos);

	for(auto itemIter = mItems.begin(); itemIter != mItems.end(); itemIter++)
		(*itemIter)->flipItem(QPointF(0.0, 0.0));
	updatePoints();
}
Ejemplo n.º 13
0
void EditCurve::Update() {
    if(pointToRemove) {
        targetCurve->removePoint(pointToRemove->point);
        updatePoints();
        updateCurve();
        pointToRemove = NULL;
    }
}
void PathStrokeRenderer::timerEvent(QTimerEvent *e)
{
    if (e->timerId() == m_timer.timerId()) {
        updatePoints();
    } // else if (e->timerId() == m_fpsTimer.timerId()) {
//         emit frameRate(m_frameCount);
//         m_frameCount = 0;
//     }
}
Ejemplo n.º 15
0
//----------------------------------------------------------
void ofTextureAdv::setPoint(int which, float x, float y){
    
	if( which>4 || which < 0){
		printf("ofTextureAdv:: please choose point 0-3\n");
		return;
	}
    
	quad[which].set(x, y, 0);
    
	updatePoints();
}
Ejemplo n.º 16
0
//--------------------------------------------------------------
void Wave::setNbPoints(int nb)
{
	if (nb != m_nbPoints)
	{
		m_nbPoints = nb;

		m_points.clear();
		for (int i=0;i<m_nbPoints;i++)
		{
			m_points.push_back( ofVec3f() );
		}
	}
	updatePoints();
}
Ejemplo n.º 17
0
void WarpedWorld::updatePointPos() {
    int dragX = mX - prevPoint.x;
    int dragY = mY - prevPoint.y;
    
    if(fastMove == true) {
        dragX *= 1.8;
        dragY *= 1.8;
    }
    
    
    // check if corner is selected.
    if(corner >= 0) {
        quad.setOutputPoint(corner, ofPoint(currentPt.x+dragX, currentPt.y+dragY));
        updatePoints();
    }
}
Ejemplo n.º 18
0
/**
*	@brief Updates characters health if it takes damage and health is refreshed etc.
*	@param health The amount of health to add/subtract.
*	@todo when dead give signal to pop-up menu or something like that.
*	@return true if alive, false if dead
*/
bool Character::updateCharacterHealth(int health)
{
	characterHealth += health;
	if (DEBUG > 0)
	{
		printf("\nCharacter::updateCharacterHealth(int): player %d's health is %d \n",characterID, characterHealth);
	}
	if(characterHealth < 1)
	{
		updatePoints(-1);
		if (DEBUG > 0)
		{
			printf("\n\n---player %d is dead %d points---\n\n",characterID, pointsValue);
		}
		updateCharacterHealth(10);		///< resets characters health if dead
		return false;
	}
	return true;
}
Ejemplo n.º 19
0
ArchimedeanSpiral::ArchimedeanSpiral(double x0, double y0, double a)
{
  init();

  m_name = QCoreApplication::translate("ArchimedeanSpiral", "Archimedean Spiral");
  m_param = Parameter(0, 3.99, "t");
  m_param.interval().setLowerEnd(0, true);

  Variable var("a", a);
  var.interval().setLowerEnd(0);
  var.setColor(QColor(255, 128, 0));
  setVariable(var);

  setVariable("x0", x0, false);
  setVariable("y0", y0, false);

  initDimension();
  updatePoints();
}
Ejemplo n.º 20
0
Lemniscate::Lemniscate(double a, double x0, double y0)
{
  init();

  m_name = QCoreApplication::translate("Lemniscate", "Lemniscate");
  m_param = Parameter(0, 2*PI, "t");
  m_param.interval().setLowerEnd(0, true);
  m_param.interval().setUpperEnd(2 * PI, true);

  Variable var("a", a);
  var.interval().setLowerEnd(0);
  var.setColor(QColor(255, 128, 0));
  setVariable(var);

  setVariable("x0", x0, false);
  setVariable("y0", y0, false);

  initDimension();
  updatePoints();
}
Ejemplo n.º 21
0
void CTFObjectiveResource :: think ()
{
	if ( m_bInitialised && ( m_fNextCheckMonitoredPoint < engine->Time() ) )
	{
		bool bupdate = (m_fUpdatePointTime < engine->Time());

		int team = 0;

		do
		{
			if ( m_iMonitorPoint[team] != -1 )
			{
				for ( int j = 0; j < MAX_PREVIOUS_POINTS; j ++ )
				{
					int prev = GetPreviousPointForPoint(m_iMonitorPoint[team],(team+2),j);

					if ( (prev != -1) && (GetOwningTeam(prev)!=(team+2)) )
					{
						bupdate = true;
						break;
					}
				}
			}
			team++;
		}while ((team < 2) && (bupdate==false));

		if ( bupdate )
		{
			extern ConVar rcbot_tf2_autoupdate_point_time;

			updatePoints();

			m_fNextCheckMonitoredPoint = engine->Time() + 5.0f;
			m_fUpdatePointTime = engine->Time() + rcbot_tf2_autoupdate_point_time.GetFloat();
		}
		else
			m_fNextCheckMonitoredPoint = engine->Time() + 1.0f;
	}
	
}
Ejemplo n.º 22
0
Cycloid::Cycloid(double r, double m, double x0, double y0)
{
  init();

  m_name = QCoreApplication::translate("Cycloid", "Cycloid");
  m_param = Parameter(-2*PI, 2*PI, "t");

  Variable var("r",r);
  var.interval().setLowerEnd(0);
  var.setColor(QColor(255, 128, 0));
  setVariable(var);

  var = Variable("mu", m);
  var.setColor(QColor(0, 128, 255));
  var.setFormula("<mi color=\"#0088FF\">&mu;</mi>");
  setVariable(var);

  setVariable("x0", x0, false);
  setVariable("y0", y0, false);

  updatePoints();
  initDimension();
}
Ejemplo n.º 23
0
void DrawingItemGroup::clearItems()
{
	while (!mItems.empty()) delete mItems.takeLast();
	updatePoints();
}
Ejemplo n.º 24
0
	void SegmentShape::setPoints(const Vector2f& p1, const Vector2f& p2)
	{
		updatePoints(p1, p2);
		setPosition(m_center.toSFML());
	}
Ejemplo n.º 25
0
void Background::update() {
	move();
	updatePoints();
}
Ejemplo n.º 26
0
bool Plot3DDialog::updatePlot()
{
	int axis=-1;

	if (generalDialog->currentWidget()==(QWidget*)bars)
	{
		emit updateBars(boxBarsRad->text().toDouble());
	}

	if (generalDialog->currentWidget()==(QWidget*)points)
	{
		if (boxPointStyle->currentItem() == 0)
			emit updatePoints(boxSize->text().toDouble(), boxSmooth->isChecked());
		else if (boxPointStyle->currentItem() == 1)
			emit updateCross(boxCrossRad->text().toDouble(), boxCrossLinewidth->text().toDouble(),
					boxCrossSmooth->isChecked(), boxBoxed->isChecked());
		else if (boxPointStyle->currentItem() == 2)
			emit updateCones(boxConesRad->text().toDouble(), boxQuality->value());
	}

	if (generalDialog->currentWidget()==(QWidget*)title)
	{
		emit updateTitle(boxTitle->text(),titleColor,titleFont);
	}

	if (generalDialog->currentWidget()==(QWidget*)colors)
	{
		emit updateTransparency(boxTransparency->value()*0.01);
		emit updateDataColors(fromColor,toColor);
		emit updateColors(meshColor,axesColor,numColor,labelColor,bgColor,gridColor);
	}

	if (generalDialog->currentWidget()==(QWidget*)general)
	{
		emit showColorLegend(boxLegend->isChecked());
		emit updateMeshLineWidth(boxMeshLineWidth->value());
		emit adjustLabels(boxDistance->value());
		emit updateResolution (boxResolution->value());
		emit showColorLegend(boxLegend->isChecked());
		emit setNumbersFont(numbersFont);
		emit updateZoom(boxZoom->value()*0.01);
		emit updateScaling(boxXScale->value()*0.01,boxYScale->value()*0.01,
				boxZScale->value()*0.01);
	}

	if (generalDialog->currentWidget()==(QWidget*)scale)
	{
		axis=axesList->currentRow();
		QString from=boxFrom->text().toLower();
		QString to=boxTo->text().toLower();
		double start,end;
		bool error=false;
		try
		{
			MyParser parser;
			parser.SetExpr(from.toAscii().constData());
			start=parser.Eval();
		}
		catch(mu::ParserError &e)
		{
			QMessageBox::critical(0,tr("Start limit error"),  QString::fromStdString(e.GetMsg()));
			boxFrom->setFocus();
			error=true;
			return false;
		}
		try
		{
			MyParser parser;
			parser.SetExpr(to.toAscii().constData());
			end=parser.Eval();
		}
		catch(mu::ParserError &e)
		{
			QMessageBox::critical(0,tr("End limit error"), QString::fromStdString(e.GetMsg()));
			boxTo->setFocus();
			error=true;
			return false;
		}

		if (start>=end)
		{
			QMessageBox::critical(0,tr("Input error"),
					tr("Please enter scale limits that satisfy: from < to!"));
			boxTo->setFocus();
			return false;
		}

		if (! error)
			emit updateScale(axis,scaleOptions(axis, start, end,
						boxMajors->text(), boxMinors->text()));
	}

	if (generalDialog->currentWidget()==(QWidget*)axes)
	{
		axis=axesList2->currentRow();
		labels[axis] = boxLabel->text();
		emit updateLabel(axis, boxLabel->text(),axisFont(axis));
		emit updateTickLength(axis,boxMajorLength->text().toDouble(),
				boxMinorLength->text().toDouble());
	}

	return true;
}
Ejemplo n.º 27
0
int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
{
    const SELECTION& selection = m_selectionTool->GetSelection();

    if( selection.Size() == 1 )
    {
        Activate();

        KIGFX::VIEW_CONTROLS* controls = getViewControls();
        KIGFX::VIEW* view = getView();
        PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
        EDA_ITEM* item = selection.items.GetPickedItem( 0 );

        m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );

        if( !m_editPoints )
            return 0;

        view->Add( m_editPoints.get() );
        m_editedPoint = NULL;
        bool modified = false;

        // Main loop: keep receiving events
        while( OPT_TOOL_EVENT evt = Wait() )
        {
            if( !m_editPoints ||
                evt->Matches( m_selectionTool->ClearedEvent ) ||
                evt->Matches( m_selectionTool->UnselectedEvent ) ||
                evt->Matches( m_selectionTool->SelectedEvent ) )
            {
                break;
            }

            if( evt->IsMotion() )
            {
                EDIT_POINT* point = m_editPoints->FindPoint( evt->Position() );

                if( m_editedPoint != point )
                    setEditedPoint( point );
            }

            else if( evt->IsAction( &COMMON_ACTIONS::pointEditorAddCorner ) )
            {
                addCorner( controls->GetCursorPosition() );
                updatePoints();
            }

            else if( evt->IsAction( &COMMON_ACTIONS::pointEditorRemoveCorner ) )
            {
                if( m_editedPoint )
                {
                    removeCorner( m_editedPoint );
                    updatePoints();
                }
            }

            else if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
            {
                if( !modified )
                {
                    // Save items, so changes can be undone
                    editFrame->OnModify();
                    editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
                    controls->ForceCursorPosition( false );
                    m_original = *m_editedPoint;    // Save the original position
                    controls->SetAutoPan( true );
                    modified = true;
                }

                bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
                if( enableAltConstraint != (bool) m_altConstraint )  // alternative constraint
                    setAltConstraint( enableAltConstraint );

                m_editedPoint->SetPosition( controls->GetCursorPosition() );

                if( m_altConstraint )
                    m_altConstraint->Apply();
                else
                    m_editedPoint->ApplyConstraint();

                updateItem();
                updatePoints();

                m_editPoints->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
            }

            else if( evt->IsAction( &COMMON_ACTIONS::pointEditorUpdate ) )
            {
                updatePoints();
            }

            else if( evt->IsMouseUp( BUT_LEFT ) )
            {
                controls->SetAutoPan( false );
                setAltConstraint( false );
                modified = false;
                m_toolMgr->PassEvent();
            }

            else if( evt->IsCancel() )
            {
                if( modified )      // Restore the last change
                {
                    wxCommandEvent dummy;
                    editFrame->RestoreCopyFromUndoList( dummy );

                    updatePoints();
                    modified = false;
                }

                // Let the selection tool receive the event too
                m_toolMgr->PassEvent();

                break;
            }

            else
            {
                m_toolMgr->PassEvent();
            }
        }

        if( m_editPoints )
        {
            finishItem();
            item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
            view->Remove( m_editPoints.get() );
            m_editPoints.reset();
        }

        controls->ShowCursor( false );
        controls->SetAutoPan( false );
        controls->SetSnapping( false );
        controls->ForceCursorPosition( false );
    }

    return 0;
}
Ejemplo n.º 28
0
int main (int argc, char **argv)
{
	Options mergetr = readParameters (argc, argv);

	char filename_mesh_node[FILENAME_MAX];
	char filename_mesh_ele[FILENAME_MAX];
	char filename_otoczka[FILENAME_MAX];
	char filename_output_node[FILENAME_MAX];
	char filename_output_ele[FILENAME_MAX];
	int no_of_meshes = argc-mergetr.args_start;

	strcpy (filename_otoczka, mergetr.input);
	if ( strstr (filename_otoczka, ".poly") == NULL) 
		strcat (filename_otoczka,  ".poly");

	strcpy (filename_output_node, mergetr.output);
	strcat (filename_output_node,  ".node");
	strcpy (filename_output_ele, mergetr.output);
	strcat (filename_output_ele,  ".ele");

	fprintf(stdout, "************************************\n");
	fprintf(stdout, "***** M * E * R * G * E * T * R ****\n");
	fprintf(stdout, "************************************\n");
	fprintf(stdout, "* Otoczka filename: %s\n", filename_otoczka);
	fprintf(stdout, "* Output filenames: %s & %s\n", filename_output_node, filename_output_ele);
	fprintf(stdout, "* Triangle options: %s\n", mergetr.tr_opt);
	fprintf(stdout, "************************************\n");

	struct triangulateio *siatka;
	struct triangulateio otoczka;
	struct triangulateio out;	
	EdgeList **v;
	PointList **p;
	int i;

	siatka = malloc ( no_of_meshes * sizeof *siatka);
	v = malloc ( no_of_meshes * sizeof **v );
	p = malloc ( no_of_meshes * sizeof **p );
		
	if (siatka == NULL || v == NULL || p == NULL) {
		fprintf (stderr, "** Error! Not enough memory!");
		return -1;
	}		

	initTriangulation (&otoczka);
	
	/* OTOCZKA */
	FILE *file_otoczka = fopen( filename_otoczka, "r"); 

	if (file_otoczka == NULL) {
		fprintf(stderr, "** Error while opening %s\n", filename_otoczka);
		return -100;
	}

	readPoints (file_otoczka, &otoczka);
	readSegments (file_otoczka, &otoczka);
	readHoles (file_otoczka, &otoczka);
	readRegions (file_otoczka, &otoczka);

	fclose (file_otoczka);

	/* MESHES */
	for (i = 0; i < (argc - mergetr.args_start); i++) {

		strcpy (filename_mesh_node, argv[mergetr.args_start+i]);
		strcat (filename_mesh_node, ".node");
		strcpy (filename_mesh_ele, argv[mergetr.args_start+i]);
		strcat (filename_mesh_ele, ".ele");

		fprintf(stdout, "************************************\n");
		fprintf(stdout, "* Mesh filenames: %s & %s\n", filename_mesh_node, filename_mesh_ele);
		
		fprintf(stdout, "************************************\n");

		FILE *file_mesh_node = fopen( filename_mesh_node, "r"); 
		FILE *file_mesh_ele = fopen( filename_mesh_ele, "r");
		
		if (file_mesh_node == NULL) {
			fprintf(stderr, "** Error while opening %s\n", filename_mesh_node);
			return -101;
		}
		if (file_mesh_node == NULL) {
			fprintf(stderr, "** Error while opening %s\n", filename_mesh_ele);
			return -102;
		}

		initTriangulation (&siatka[i]);
		readPoints (file_mesh_node, &siatka[i]);
		readTriangles (file_mesh_ele, &siatka[i]); 
	
		fclose (file_mesh_node);
		fclose (file_mesh_ele);	
	
		v[i] = createEdgeList(siatka[i]);
		markBndEdges (siatka[i], v[i]);
		p[i] = makePointList (otoczka, siatka[i], v[i]);
		
		updatePoints (&otoczka, siatka[i], v[i], p[i]);
		updateSegments (&otoczka, siatka[i], v[i], p[i]);
		updateHoles (&otoczka, siatka[i]);
	}

	fprintf(stdout, "************************************\n");

	/* TRIANGULAtE */
	initTriangulation (&out);
	strcat (mergetr.tr_opt, "pYYQ");

	triangulate (mergetr.tr_opt, &otoczka, &out, (struct triangulateio *) NULL);
	
	/* GLUE HOLES */
	/* markNotBndEdges (siatka1, v); */
	for (i = 0; i < no_of_meshes; i++) {
		glueNotBndPoints (&out, siatka[i], p[i]); /* DOKLEJANIE DO OUT */
		fixPointListNumbers (&out, &siatka[i], p[i]);
		glueInteriorTriangles (&out, siatka[i], p[i]);
		removeHole (&out);
	}	

	FILE *file_output_node = fopen (filename_output_node, "w");
	FILE *file_output_ele = fopen (filename_output_ele, "w");
	
	writePoints (file_output_node, out);
	writeTriangles (file_output_ele, out);

	fclose (file_output_node);
	fclose (file_output_ele);

	fprintf(stdout, "************************************\n");

	free (p);
	free (v);
	freeTriangulation (&otoczka);
	freeTriangulation (&out);
	for (i = 0; i < no_of_meshes; i++)
		freeTriangulation (&siatka[i]);
		
	return 0;
}
Ejemplo n.º 29
0
void SimpleChart::init()
{
    // Set the time to zero
    time = sf::Time(sf::Time::Zero);
    // initialize the axis
    xAxis.setOrigin(xAxis.getLocalBounds().width / 2, xAxis.getLocalBounds().height / 2);
    yAxis.setOrigin(yAxis.getLocalBounds().width / 2, yAxis.getLocalBounds().height / 2);
    xAxis.setPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
    yAxis.setPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
    yAxis.rotate(90);
    xAxis.setFillColor(AXIS_COLOR);
    yAxis.setFillColor(AXIS_COLOR);

    // Load the fonts
    quicksandFontBold.loadFromFile(QUICKSAND_BOLD_FONT);
    quicksandFontRegular.loadFromFile(QUICKSAND_REGULAR_FONT);

    // Initialize the title
    title.setString(SIMPLE_TITLE_STRING);
    title.setFont(quicksandFontBold);
    title.setPosition(SIMPLE_TITLE_POS_X, SIMPLE_TITLE_POS_Y);
    title.setCharacterSize((uint)SIMPLE_TITLE_SIZE);

    // initialize the function name
    functionName.setString(getFunctionTitle());
    functionName.setFont(quicksandFontRegular);
    functionName.setPosition(SIMPLE_FUNCTION_POS_X, SIMPLE_FUNCTION_POS_Y);
    functionName.setCharacterSize((uint)SIMPLE_FUNCTION_SIZE);

    // initialize the variable names
    for (int i = 0; i < variables.index.size(); i++) {
        sf::Text newVariableName;
        variableNames.push_back(newVariableName);
        variableNames[i].setFont(quicksandFontBold);
        variableNames[i].setPosition(SIMPLE_OPTION_POS_X[i], SIMPLE_OPTION_POS_Y);
        variableNames[i].setCharacterSize((uint)SIMPLE_OPTION_SIZE);

        // Set the string of the variable names
        variableNames[i].setString(SIMPLE_OPTION[variables.index[i]]);
    }

    // initialize the values of the variables
    for (int i = 0; i < variables.index.size(); i++) {
        sf::Text newVariableValue;
        variableValue.push_back(newVariableValue);
        variableValue[i].setFont(quicksandFontRegular);
        variableValue[i].setPosition(SIMPLE_OPTION_POS_X[i], SIMPLE_OPTION_VALUE_POS_Y);
        variableValue[i].setCharacterSize((uint)SIMPLE_OPTION_SIZE);
    }

    // nitialize the annotations
    for (int i = 0; i < 3; i++) {
        sf::Text newAnnotation;
        annotation.push_back(newAnnotation);
        annotation[i].setFont(quicksandFontRegular);
        annotation[i].setString(ANNOTATION[i]);
        annotation[i].setPosition(ANNOTATION_POS_X, ANNOTATION_POS_Y[i]);
        annotation[i].setCharacterSize((uint)ANNOTATION_SIZE);
    }

    // Start the axis with the default scale
    updateScale();
    // Start the points with the default variables and scale
    updatePoints();

    // initialize the selected option
    selected = 0;
}
Ejemplo n.º 30
0
void SimpleChart::update()
{
    time += clock.restart();
    if (time > sf::seconds(KEYBOARD_DELAY)) {
        // If user presses escape the window goes back to the function selector
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) {
            this->changeState(this->stateManager, new SelectFunction());
        }

        // If the user presses "+", the chart zooms in
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Add) && !addKey) {
            zoomIn();
            updatePoints();
            variables.setScale((int)scale);
        }

        // If the user presses "+", the chart zooms out
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Subtract) && !subtractKey) {
            zoomOut();
            updatePoints();
            variables.setScale((int)scale);
        }
    }

    // If the user presses R, the selected variable randomize
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::R) && !rKey) {
        variables.randomize(selected);
        updatePoints();
    }

    // If the user presses up, the selected variable increase
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up)) {
        variables.increase(selected);
        updatePoints();
    }

    // If the user presses down, the selected variable decrease
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down)) {
        variables.decrease(selected);
        updatePoints();
    }

    // If the user presses left, the variable at the left is selected
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left) && !leftKey)
        selected--;

    // If the user presses right, the selected variable at the right is selected
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Right) && !rightKey)
        selected++;

    // Check if the selected variable reached the end of a side
    if (selected < 0)
        selected = (int)(variables.index.size() - 1);
    else if (selected >= (int)(variables.index.size()))
        selected = 0;

    // Check if a key is holded
    addKey = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Add);
    subtractKey = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Subtract);
    rKey = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::R);
    leftKey = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Left);
    rightKey = sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Right);
}