Beispiel #1
0
mtsStateTable::mtsStateTable(size_t size, const std::string & name):
    HistoryLength(size),
    IndexWriter(0),
    IndexReader(0),
    IndexDelayed(0),
    Delay(0.0),
    AutomaticAdvanceFlag(true),
    StateVector(0),
    StateVectorDataNames(0),
    Ticks(size, mtsStateIndex::TimeTicksType(0)),
    Tic(0.0),
    Toc(0.0),
    Period(0.0),
    SumOfPeriods(0.0),
    AveragePeriod(0.0),
    Name(name)
{
    // make sure history length is at least 3
    if (this->HistoryLength < 3) {
        CMN_LOG_CLASS_INIT_VERBOSE << "constructor: history lenght sets to 3 (minimum required)" << std::endl;
        this->HistoryLength = 3;
    }

    // set the default number of elements for data collection batch
    this->DataCollection.BatchSize = this->HistoryLength / 3;
    if (this->DataCollection.BatchSize == 0) {
        this->DataCollection.BatchSize = 1;
    }
    this->DataCollection.TimeIntervalForProgressEvent = 1.0 * cmn_s;
    this->DataCollection.BatchRange.SetValid(true);
    this->DataCollection.BatchRange.SetAutomaticTimestamp(false);

    // Get a pointer to the time server
    TimeServer = &mtsTaskManager::GetInstance()->GetTimeServer();

    // Add Tic and Toc to the StateTable. We add Toc first, to make things easier
    // in mtsStateTable::Advance.  Do not change this.
    TocId = NewElement("Toc", &Toc);
    TicId = NewElement("Tic", &Tic);
    // Add Period to the StateTable.
    PeriodId = NewElement("Period", &Period);

    // Add statistics
    NewElement("PeriodStatistics", &PeriodStats);
}
Beispiel #2
0
void UMcf::dumpXml(const wchar_t* path)
{
    if (!path)
        return;

    XML::gcXMLDocument doc;

    auto root = doc.Create("appupdate");
    auto mcfElFiles = root.NewElement("mcf");

    mcfElFiles.SetAttribute("build",  m_sHeader->getBuild());
    mcfElFiles.SetAttribute("appid",  m_sHeader->getId());

    auto filesElFiles = mcfElFiles.NewElement( "files" );

    for (auto file : m_pFileList)
    {
        auto el = filesElFiles.NewElement("file");
        file->genXml(el);
    }

    doc.SaveFile(gcString(path).c_str());
}
   Element::Pointer UpdatedLagrangianUwPFICElement::Clone( IndexType NewId, NodesArrayType const& rThisNodes ) const
   {

      UpdatedLagrangianUwPFICElement NewElement( NewId, GetGeometry().Create( rThisNodes ), pGetProperties() );

      //-----------//

      NewElement.mThisIntegrationMethod = mThisIntegrationMethod;


      if ( NewElement.mConstitutiveLawVector.size() != mConstitutiveLawVector.size() )
      {
         NewElement.mConstitutiveLawVector.resize(mConstitutiveLawVector.size());

         if( NewElement.mConstitutiveLawVector.size() != NewElement.GetGeometry().IntegrationPointsNumber() )
            KRATOS_THROW_ERROR( std::logic_error, "constitutive law not has the correct size ", NewElement.mConstitutiveLawVector.size() )
      }
Beispiel #4
0
static int Add(PQueue *h, intptr_t key, const void *data)
{
    PQueueElement *x;

    if ((x = NewElement(h)) == NULL) {
        return iError.NullPtrError("iPQueue.Add");
    }

    /* just insert on root list, and make sure it's not the new min */
    if (data) memcpy(x->Data , data,h->ElementSize);
    if (key < CCL_PRIORITY_MIN) key = CCL_PRIORITY_MIN;
    if (key > CCL_PRIORITY_MAX) key = CCL_PRIORITY_MAX;
    x->Key = key;

    insertel(h, x);

    return 1;
}
Beispiel #5
0
// ELEMENT を読み込む
ELEMENT *ReadElement(BUF *b)
{
	UINT i;
	char name[MAX_ELEMENT_NAME_LEN + 1];
	UINT type, num_value;
	VALUE **values;
	ELEMENT *e;
	// 引数チェック
	if (b == NULL)
	{
		return NULL;
	}

	// 名前
	if (ReadBufStr(b, name, sizeof(name)) == false)
	{
		return NULL;
	}

	// 項目の種類
	type = ReadBufInt(b);

	// 項目数
	num_value = ReadBufInt(b);
	if (num_value > MAX_VALUE_NUM)
	{
		// 個数オーバー
		return NULL;
	}

	// VALUE
	values = (VALUE **)Malloc(sizeof(VALUE *) * num_value);
	for (i = 0;i < num_value;i++)
	{
		values[i] = ReadValue(b, type);
	}

	// ELEMENT を作成
	e = NewElement(name, type, num_value, values);

	Free(values);

	return e;
}
Beispiel #6
0
QMenu* sTreeWidget::newMenu(xmlItem obj){
    QMenu* menu = new QMenu;
    qDebug() << obj.nodeName();
    if(obj.nodeName() == md_spravochniki){
        QAction *act = new QAction("Новый справочник..",this);
        connect(act,SIGNAL(triggered()),this,SLOT(NewObjMd()));
        menu->addAction(act);
    }

    if(obj.nodeName() == md_documents){
        QAction *act = new QAction("Новый документ..",this);
        connect(act,SIGNAL(triggered()),this,SLOT(NewObjMd()));
        menu->addAction(act);
    }

    if(obj.nodeName() == md_element){
        QAction *act = new QAction("Добавить",this);
        connect(act,SIGNAL(triggered()),this,SLOT(NewElement()));
        menu->addAction(act);
    }

    if(obj.nodeName() == md_forms){
        QAction *act = new QAction("Добавить",this);
        connect(act,SIGNAL(triggered()),this,SLOT(NewForm()));
        menu->addAction(act);
    }


    if(obj.nodeName() == md_field){
        QAction *edit = new QAction("Редактировать",this);
        connect(edit,SIGNAL(triggered()),this,SLOT(EditElement()));
        menu->addAction(edit);

        QAction *del = new QAction("Удалить",this);
        connect(del,SIGNAL(triggered()),this,SLOT(DelElement()));
        menu->addAction(del);
    }

    return menu;
}
Element::Pointer AxisymUpdatedLagrangianElement::Clone( IndexType NewId, NodesArrayType const& rThisNodes ) const
{

    AxisymUpdatedLagrangianElement NewElement(NewId, GetGeometry().Create( rThisNodes ), pGetProperties() );

    //-----------//

    NewElement.mThisIntegrationMethod = mThisIntegrationMethod;

    if ( NewElement.mConstitutiveLawVector.size() != mConstitutiveLawVector.size() )
      {
	NewElement.mConstitutiveLawVector.resize(mConstitutiveLawVector.size());
	
	if( NewElement.mConstitutiveLawVector.size() != NewElement.GetGeometry().IntegrationPointsNumber() )
	  KRATOS_THROW_ERROR( std::logic_error, "constitutive law not has the correct size ", NewElement.mConstitutiveLawVector.size() );
      }
    

    for(unsigned int i=0; i<mConstitutiveLawVector.size(); i++)
      {
	NewElement.mConstitutiveLawVector[i] = mConstitutiveLawVector[i]->Clone();
      }

    //-----------//

    if ( NewElement.mDeformationGradientF0.size() != mDeformationGradientF0.size() )
      NewElement.mDeformationGradientF0.resize(mDeformationGradientF0.size());

    for(unsigned int i=0; i<mDeformationGradientF0.size(); i++)
    {
        NewElement.mDeformationGradientF0[i] = mDeformationGradientF0[i];
    }

    NewElement.mDeterminantF0 = mDeterminantF0;

        
    return Element::Pointer( new AxisymUpdatedLagrangianElement(NewElement) );
}
Beispiel #8
0
int main(int argc, char** argv)
{
    wchar_t reffn[] = L"../dcm/TEST.DCM";

    wprintf( L"Open %s ... ", reffn );

    if ( OpenDCM( reffn ) == true )
    {
        wprintf( L"OK.\n" );
        wprintf( L"\n" );

        DCMTagElement* pTagModal = FindElement( 0x00080060 );
        DCMTagElement* pTagKVP = FindElement( 0x00180060 );
        DCMTagElement* pTagIPP = FindElement( 0x00200032 );
        DCMTagElement* pTagIOP = FindElement( 0x00200037 );
        DCMTagElement* pTagFORUID = FindElement( 0x00200052 );

        DCMTagElement* pTagSPP = FindElement( 0x00280002 );
        DCMTagElement* pTagPI  = FindElement( 0x00280004 );
        DCMTagElement* pTagRow = FindElement( 0x00280010 );
        DCMTagElement* pTagCol = FindElement( 0x00280011 );
        DCMTagElement* pTagPxS = FindElement( 0x00280030 );

        printf( "\n" );
        printf( "Modality                   : %s\n", pTagModal->staticbuffer );
        printf( "KVP                        : %s\n", pTagKVP->staticbuffer );
        printf( "Image Position Patient     : %s\n", pTagIPP->staticbuffer );
        printf( "Image Orientation Patient  : %s\n", pTagIOP->staticbuffer );
        printf( "Frame of Reference UID     : %s\n", pTagFORUID->staticbuffer );

        printf( "\n" );

        printf( "Samples per pixel          : %d\n", GetElem2WORD( pTagSPP ) );
        printf( "Photometric Interpretation : %s\n", pTagPI->staticbuffer );
        printf( "Rows                       : %d\n", GetElem2WORD( pTagRow ) );
        printf( "Colums                     : %d\n", GetElem2WORD( pTagCol ) );
        printf( "Pixel Spacing              : %s\n", pTagPxS->staticbuffer );

        CloseDCM();
    }
    else
    {
        wprintf( L"Failure !\n" );
        system("PAUSE");

        return 0;
    }

    wchar_t newDCMn[] = L"NEW.DCM";

    wprintf( L"\n\n" );
    wprintf( L"Creating %s ... ", newDCMn );

    if ( _waccess( newDCMn, F_OK) == 0 )
    {
        if ( _wunlink( newDCMn ) != 0 )
        {
            wprintf( L"Failure\nFile existed and not be removed !\n" );
            return 0;
        }
    }

    if ( NewDCM( newDCMn ) == true )
    {
        wprintf( L"Ok !\n" );
        wprintf( L"Adding some tags ... \n" );

        // Modality = CT
        DCMTagElement* newTagModal = NULL;
        if ( NewElement( 0x00080060, &newTagModal ) == true )
        {
            WriteAnsiString( newTagModal, "CT" );
        }
        else
        {
            wprintf( L"Failed to create Modality tag.\n" );
            CloseDCM();
            return 0;
        }

        // An empty image for test.
        ImageInformation imginfo = {0};
        imginfo.width  = 500;
        imginfo.height = 500;
        imginfo.spacing_w = 0.25f;
        imginfo.spacing_h = 0.25f;
        imginfo.bpp    = 16;
        imginfo.pixels = new char[ 500*500*2 ];

        if ( imginfo.pixels != NULL )
        {
            memset( imginfo.pixels, 0, 500*500*2 );
            if ( AddImage( &imginfo ) == false )
            {
                wprintf( L"Error: Failed to add an image.\n" );
                delete[] imginfo.pixels;

                return 0;
            }

            DCMTagElement* newTagPI = NULL;
            if ( NewElement( 0x00280004, &newTagPI ) == true )
            {
                WriteAnsiString( newTagPI, "MONOCHROME2" );
            }

            DCMTagElement* newTagIT = NULL;
            if ( NewElement( 0x00080008, &newTagIT ) == true )
            {
                WriteAnsiString( newTagIT, "ORIGINAL\\PRIMARY\\AXIAL" );
            }
        }

        wprintf( L"Writing ..." );

        if( SaveDCM( newDCMn ) == true )
        {
            wprintf( L"Ok.\n");
        }
        else
        {
            wprintf( L"Failed.\n");
        }

        CloseDCM();
    }
    else
    {
        printf("Failure !\n");
    }

    system("PAUSE");

    return 0;
}
Beispiel #9
0
	// optimized SetElement,  returning the fetched Melement*
ChMelement* ChSparseMatrix::SetElement (int row, int col, double val, register ChMelement* guess)
{
	#ifdef CH_DEBUG
		assert (row >= 0);		// boundary checks
		assert (col >= 0);
		assert (row < rows );
		assert (col < columns);
		assert (guess->row == row)
	#endif

	ChMelement* enext;
	ChMelement* eprev;
	ChMelement* newguess;

	while (guess->col != col)
	{
		// forward search
		if (guess->col < col)
		{
			enext=guess->next;
			if (enext)
			{
				if (enext->col <= col)
					guess = enext;	// .. and repeat
				else // if (enext->col >  col)
				{
					newguess = NewElement (val, enext, guess, row, col);
					guess->next=newguess;
					enext->prev=newguess;
					return (newguess);
				}
			}
			else
			{
				newguess = NewElement(val, NULL, guess, row, col);
				guess->next = newguess;
				return (newguess);
			}
		}

		// backward search
		if (guess->col > col)
		{
			eprev=guess->prev;
			if (eprev)
			{
				if (eprev->col >= col)
					guess = eprev;	// .. and repeat
				else // if (eprev->col <  col)
				{
					newguess = NewElement (val, guess, eprev, row, col);
					eprev->next=newguess;
					guess->prev=newguess;
					return (newguess);
				}
			}
			else
			{
				newguess = NewElement(val, guess, NULL, row, col);
				guess->prev = newguess;
				return (newguess);
			}
		}

	}	// end while loop

	guess->val = val;
	return (guess);
}
int main(int argc, char **argv)
{
//printf("nazwa: %s \n",argv[1]);



    FILE *file;
    file = fopen(argv[1],"rb");
    if(file!=NULL) printf("Działa \n");
    else fprintf(stderr,"Błąd \n");



    char c = fgetc(file);
    int i =0;






    char * a= malloc(sizeof(char));

    while(c!=EOF) {


        if(c=='\n' )
        {
            a[i]='\0';
            i =0;
//printf("%s\n",a);
            NewElement(a);
            free(a);
            a= malloc(sizeof(char));
            c =  fgetc(file);
            continue;

        }

        a[i]=c;

        c =  fgetc(file);
        a = realloc(a,sizeof(char) * (i+2));

        i++;
    }
    free(a);



//printf("Add \n");
//for(i=0;i<=w;i++)pointer =



    printf("Show \n");
    ShowStack();

    printf("Delete stack\n");
    DeleteAll();









    fclose(file);





    return 0;
}