コード例 #1
0
ファイル: parmLinkMgr.cpp プロジェクト: CarltonFraley/OpenVSP
void ParmLinkMgr::ReadLinks(xmlNodePtr root, vector< Geom* > & geomVec)
{
	vector< Geom* > gVec = geomVec;
	gVec.push_back( aircraftPtr->getUserGeom() );

	xmlNodePtr node_list = xmlGetNode( root, "ParmLink_List", 0 );
	if ( node_list  )
	{
		int num_links = xmlGetNumNames( node_list, "Link" );
		for ( int i = 0 ; i < num_links ; i++ )
		{
			xmlNodePtr link_node = xmlGetNode( node_list, "Link", i );
			if ( link_node )
			{
				int geomA_id = xmlFindInt( link_node, "GeomA", 0 );
				Stringc groupA_name = Stringc( xmlFindString( link_node, "GroupA", " " ) );
				Stringc parmA_name =  Stringc( xmlFindString( link_node, "ParmA", " " ) );

				Parm* parmA = FindParm( gVec, geomA_id, groupA_name, parmA_name );

				int geomB_id = xmlFindInt( link_node, "GeomB", 0 );
				Stringc groupB_name = Stringc( xmlFindString( link_node, "GroupB", " " ) );
				Stringc parmB_name = Stringc( xmlFindString( link_node, "ParmB", " " ) );

				Parm* parmB = FindParm( gVec, geomB_id, groupB_name, parmB_name );


				if ( parmA && parmB )
				{
					ParmLink* pl = new ParmLink();

					pl->SetParmA( parmA );
					pl->SetParmB( parmB );

					pl->SetOffsetFlag( !!xmlFindInt( link_node, "OffsetFlag", 0 ) );
					pl->SetOffset( xmlFindDouble( link_node, "Offset", 0.0 ) );
					pl->SetScaleFlag( !!xmlFindInt( link_node, "ScaleFlag", 0 ) );
					pl->SetScale( xmlFindDouble( link_node, "Scale", 1.0 ) );

					pl->SetLowerLimitFlag( !!xmlFindInt( link_node, "LowerLimitFlag", 0 ) );
					pl->SetLowerLimit( xmlFindDouble( link_node, "LowerLimit", 0.0 ) );
					pl->SetUpperLimitFlag( !!xmlFindInt( link_node, "UpperLimitFlag", 0 ) );
					pl->SetUpperLimit( xmlFindDouble( link_node, "UpperLimit", 0.0 ) );

					pl->GetParmA()->set_linked_flag( true );
					pl->GetParmB()->set_linked_flag( true );

					m_ParmLinkVec.push_back( pl );
					m_CurrParmLinkIndex = (int)m_ParmLinkVec.size() - 1;
				}
			}
		}
	}
}
コード例 #2
0
ファイル: materialMgr.cpp プロジェクト: CarltonFraley/OpenVSP
void Material::read( xmlNodePtr root )
{
	int i;
	double tmp[4];
	xmlNodePtr node;

	char* str = xmlFindString( root, "Name", "Default_Name" );
	name = str;				// name is a stringc

    node = xmlGetNode( root, "Ambient", 0 );
	xmlExtractDoubleArray( node, ',', tmp, 4 );
	for ( i = 0 ; i < 4 ; i++ )
		amb[i] = (float)tmp[i];
	
    node = xmlGetNode( root, "Diffuse", 0 );
	xmlExtractDoubleArray( node, ',', tmp, 4 );
	for ( i = 0 ; i < 4 ; i++ )
		diff[i] = (float)tmp[i];

    node = xmlGetNode( root, "Specular", 0 );
	xmlExtractDoubleArray( node, ',', tmp, 4 );
	for ( i = 0 ; i < 4 ; i++ )
		spec[i] = (float)tmp[i];

    node = xmlGetNode( root, "Emission", 0 );
	xmlExtractDoubleArray( node, ',', tmp, 4 );
	for ( i = 0 ; i < 4 ; i++ )
		emiss[i] = (float)tmp[i];

	node = xmlGetNode( root, "Shininess", 0 );
	shine = (float)xmlExtractDouble( node );

}
コード例 #3
0
ファイル: labelGeom.cpp プロジェクト: KubaO/OpenVSP
void RulerLabel::readRulerLabel(Aircraft * airPtr, xmlNodePtr root)
{
	xmlNodePtr ruler_node = xmlGetNode( root, "Ruler_Parms", 0 );
	if ( ruler_node )
	{
		vertex2.read(airPtr, ruler_node, "Vertex2_Parms");
		rulerOffset = xmlFindDouble(ruler_node, "RulerOffset", rulerOffset);
		attachState = xmlFindInt(ruler_node, "AttachState", attachState);
		xLock = xmlFindInt(ruler_node, "XLock", xLock);
		yLock = xmlFindInt(ruler_node, "YLock", yLock);
		zLock = xmlFindInt(ruler_node, "ZLock", zLock);
		rulerDistance = xmlFindDouble(ruler_node, "RulerDistance", rulerDistance);

		precision = xmlFindInt(ruler_node, "Precision", precision);
		unitString = xmlFindString(ruler_node, "UnitString", unitString.get_char_star());
	}
}
コード例 #4
0
ファイル: labelGeom.cpp プロジェクト: KubaO/OpenVSP
void LabelGeom::readLabelGeom(xmlNodePtr root)
{
	xmlNodePtr label_node;

	//===== Read Parameters =====//
	label_node = xmlGetNode( root, "Label_Parms", 0 );
	if ( label_node )
	{
//		type = xmlFindInt( label_node, "TypeInt", type );
//		type_str = xmlFindString( label_node, "TypeStr", type_str.get_char_star());
		name_str = xmlFindString( label_node, "NameStr", name_str.get_char_star());

		color.set_x( xmlFindDouble( label_node, "ColorR", color.x() ) );
		color.set_y( xmlFindDouble( label_node, "ColorG", color.y() ) );
		color.set_z( xmlFindDouble( label_node, "ColorB", color.z() ) );

		drawMode = xmlFindInt( label_node, "DrawMode", drawMode );
		textSize = (float)xmlFindDouble( label_node, "TextSize", textSize );
		viewScale = xmlFindDouble( label_node, "ViewScale", viewScale );
	}
}
コード例 #5
0
//==== Read Fuse Cross Section File ====//
void FuselageXSec::read_parms(xmlNodePtr node)
{
	int i;
	xstype = xmlFindInt( node, "Type", xstype );

	height =  xmlFindDouble( node, "Height", height() );
	width  =  xmlFindDouble( node, "Width",  width() );

	max_width_loc  = xmlFindDouble( node, "Max_Width_Location",  max_width_loc() );
	corner_rad     = xmlFindDouble( node, "Corner_Radius",  corner_rad() );
	top_tan_angle = xmlFindDouble( node, "Top_Tan_Angle", top_tan_angle());
	bot_tan_angle = xmlFindDouble( node, "Bot_Tan_Angle", bot_tan_angle());

	top_str  = xmlFindDouble( node, "Top_Tan_Strength",    top_str() );
	upp_str  = xmlFindDouble( node, "Upper_Tan_Strength",  upp_str() );
	low_str  = xmlFindDouble( node, "Lower_Tan_Strength",  low_str() );
	bot_str  = xmlFindDouble( node, "Bottom_Tan_Strength", bot_str() );

	if ( xstype == FXS_FROM_FILE )
	{
		xstype = FXS_GENERAL;				// If this fails fall back on something...

		fileName = Stringc( xmlFindString( node, "File_Name", "File_Xsec" ) );					// fileName is a Stringc

		xmlNodePtr yn = xmlGetNode( node, "File_Y_Pnts", 0 );
		xmlNodePtr zn = xmlGetNode( node, "File_Z_Pnts", 0 );

		if ( yn && zn )
		{
			int numy = xmlGetNumArray( yn, ',' );
			int numz = xmlGetNumArray( zn, ',' );
			if ( numy == numz )
			{
				int num_pnts = numy;
				double* arry = (double*)malloc( num_pnts*sizeof(double) );
				double* arrz = (double*)malloc( num_pnts*sizeof(double) );
				xmlExtractDoubleArray( yn, ',', arry, num_pnts );
				xmlExtractDoubleArray( zn, ',', arrz, num_pnts );

				xstype = FXS_FROM_FILE;	

				file_crv.init( num_pnts );
				for ( i = 0 ; i < num_pnts ; i++ )
				{
					file_crv.load_pnt( i, vec3d( 0.0, arry[i],  arrz[i] ));
				}
				free( arry );
				free( arrz );

				file_crv.comp_tans();

				vec3d top_tan = vec3d( 0.0, 1.0, 0.0 );
				double tan_mag = file_crv.get_tan(0).mag();

				file_crv.load_tan( 0, top_tan*tan_mag );

				int last_id =  file_crv.get_num_pnts() - 1;
				vec3d bot_tan = vec3d( 0.0, -1.0, 0.0 );
				tan_mag = file_crv.get_tan( last_id ).mag();
				file_crv.load_tan( last_id, bot_tan*tan_mag );
			}
		}
	}
	else if ( xstype == FXS_EDIT_CRV )
	{
		edit_crv.read( node );
	}
	set_type(xstype);  

}
コード例 #6
0
ファイル: af.cpp プロジェクト: Phoenix-Integration/OpenVSP
void Af::read(xmlNodePtr node)
{
  int i;

  int temp_type = xmlFindInt( node, "Type", 0 );
  inverted_flag = xmlFindInt( node, "Inverted_Flag", inverted_flag );

  camber        = xmlFindDouble( node, "Camber", camber() );
  camber_loc    = xmlFindDouble( node, "Camber_Loc", camber_loc() );
  thickness     = xmlFindDouble( node, "Thickness", thickness() );
  thickness_loc = xmlFindDouble( node, "Thickness_Loc", thickness_loc() );

  radius_le    = xmlFindDouble( node, "Radius_Le", radius_le() );
  radius_te    = xmlFindDouble( node, "Radius_Te", radius_te() );

  sixser = xmlFindInt( node, "Six_Series", sixser );
  ideal_cl = xmlFindDouble( node, "Ideal_Cl", ideal_cl() );
  a = xmlFindDouble( node, "A", a() );

  slat_flag = xmlFindInt( node, "Slat_Flag", slat_flag );
  slat_shear_flag = xmlFindInt( node, "Slat_Shear_Flag", slat_shear_flag );
  slat_chord = xmlFindDouble( node, "Slat_Chord", slat_chord() );
  slat_angle = xmlFindDouble( node, "Slat_Angle", slat_angle() );

  flap_flag = xmlFindInt( node, "Flap_Flag", flap_flag );
  flap_shear_flag = xmlFindInt( node, "Flap_Shear_Flag", flap_shear_flag );
  flap_chord = xmlFindDouble( node, "Flap_Chord", flap_chord() );
  flap_angle = xmlFindDouble( node, "Flap_Angle", flap_angle() );

  if ( temp_type == AIRFOIL_FILE )
  {
    vec3d pnt;
    name = xmlFindString( node, "Name", name );
    orig_af_thickness = (float)xmlFindDouble( node, "Original_AF_Thickness", orig_af_thickness );
    radius_le_correction_factor = (float)xmlFindDouble( node, "Radius_LE_Correction_Factor", radius_le_correction_factor );
    radius_te_correction_factor = (float)xmlFindDouble( node, "Radius_TE_Correction_Factor", radius_te_correction_factor );

    xmlNodePtr upp_node = xmlGetNode( node, "Upper_Pnts", 0 );

    if ( upp_node )
    {
      int num_arr =  xmlGetNumArray( upp_node, ',' );
      double* arr = (double*)malloc( num_arr*sizeof(double) );
      xmlExtractDoubleArray( upp_node, ',', arr, num_arr );

      int num_upper = num_arr/2;

      upper_curve.init(num_upper);
      for ( i = 0 ; i < num_arr ; i+=2)
      {
        pnt = vec3d(arr[i], 0.0, arr[i+1]);
        upper_curve.load_pnt( i/2, pnt );
      }
      free(arr);
    }
    xmlNodePtr low_node = xmlGetNode( node, "Lower_Pnts", 0 );

    if ( low_node )
    {
      int num_arr =  xmlGetNumArray( low_node, ',' );
      double* arr = (double*)malloc( num_arr*sizeof(double) );
      xmlExtractDoubleArray( low_node, ',', arr, num_arr );

      int num_lower = num_arr/2;

      lower_curve.init(num_lower);
      for ( i = 0 ; i < num_arr ; i+=2)
      {
        pnt = vec3d(arr[i], 0.0, arr[i+1]);
        lower_curve.load_pnt( i/2, pnt );
      }
      free(arr);
    }
  }

  set_type(temp_type);
}
コード例 #7
0
VspPreferences::VspPreferences()
{
	outputNameVec.push_back( Stringc("No_Default") );

	m_DefaultCompFileVec.clear();
	DefaultCompFile dcf;
	dcf.m_Name = Stringc("Default");
	dcf.m_File = Stringc("");
	m_DefaultCompFileVec.push_back( dcf );

//	xmlDocPtr doc;

//	LIBXML_TEST_VERSION
	xmlKeepBlanksDefault(0);

	//==== Build an XML tree from a the file ====//
	m_XmlDoc = xmlParseFile("VspPreferences.xml");
	if (m_XmlDoc == NULL) return;

	xmlNodePtr root = xmlDocGetRootElement(m_XmlDoc);
	if (root == NULL)
	{
		fprintf(stderr,"empty document\n");
		xmlFreeDoc(m_XmlDoc);
		return;
	}

	if ( xmlStrcmp( root->name, (const xmlChar *)"Vsp_Preferences" ) )
	{
		fprintf(stderr, "document of the wrong type, VSP Preferences Name list not found\n");
		xmlFreeDoc(m_XmlDoc);
		return;
	}

	m_DefaultCompFileID = xmlFindInt(root, "DefaultComponentFileID", 0);

	xmlNodePtr defaultCompListNode = xmlGetNode(root, "DefaultComponentFileList", 0);
	if (defaultCompListNode)
	{
		//==== Read Default Comp Files ====//
		int num_def_files = xmlGetNumNames( defaultCompListNode, "DefaultComponentFile" );
		for ( int i = 0 ; i < num_def_files ; i++ )
		{
			xmlNodePtr def_file_node = xmlGetNode( defaultCompListNode, "DefaultComponentFile", i );
			if ( def_file_node )
			{
				dcf.m_Name = Stringc( xmlFindString( def_file_node, "Name", "Default_Name" ) );
				dcf.m_File = Stringc( xmlFindString( def_file_node, "File", "Default_File" ) );
				m_DefaultCompFileVec.push_back( dcf );
			}
		}
	}

	xmlNodePtr outputNames = xmlGetNode(root, "Vsp_OutputNames", 0);
	if (outputNames)
	{
		//==== Read Names ====//
		int num_names = xmlGetNumNames( outputNames, "OutputName" );
		for ( int i = 0 ; i < num_names ; i++ )
		{
			xmlNodePtr name_node = xmlGetNode( outputNames, "OutputName", i );
			char* str = xmlFindString( name_node, "Value", "Default_Name" );
			outputNameVec.push_back( Stringc(str) );
		}
	}

	xmlNodePtr materialDefines = xmlGetNode(root, "Vsp_Material_Defines", 0);
	if (materialDefines)
	{
		matMgrPtr->readFile(materialDefines);
	}

	windowMgrStyle = xmlFindInt(root, "WindowManagerStyle", 0);
	autoSaveInterval = xmlFindInt(root, "AutoSaveInterval", 180);

}