本文整理汇总了C++中TiXmlAttribute::DoubleValue方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlAttribute::DoubleValue方法的具体用法?C++ TiXmlAttribute::DoubleValue怎么用?C++ TiXmlAttribute::DoubleValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlAttribute
的用法示例。
在下文中一共展示了TiXmlAttribute::DoubleValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//TODO: Optimize this ..
void Sprite::init(TiXmlElement * pElement)
{
if(pElement->ValueStr() != "sprite")
return;
TiXmlAttribute * pAtt = pElement->FirstAttribute();
setFPS( pAtt->IntValue() );
TiXmlElement * pChild = pElement->FirstChildElement();
while(pChild != NULL)
{
if(pChild->ValueStr() != "surface")
continue;
std::string fileName = pChild->GetText();
SDL_SurfacePtr pSurface = load_image(fileName);
float zoom = 1.0f;
float rot = 0.0f;
float alpha = 1.0;
TiXmlAttribute * pAttrib = pChild->FirstAttribute();
if(pAttrib != NULL)
{
SDL_Rect rect = {-1,-1,-1,-1};
while(pAttrib != NULL)
{
//std::cout << pAttrib->Name() << std::endl;
if(pAttrib->Name() == std::string("x"))
rect.x = pAttrib->IntValue();
else if(pAttrib->Name() == std::string("y"))
rect.y = pAttrib->IntValue();
else if(pAttrib->Name() == std::string("w"))
rect.w = pAttrib->IntValue();
else if(pAttrib->Name() == std::string("h"))
rect.h = pAttrib->IntValue();
else if(pAttrib->Name() == std::string("rot"))
rot = pAttrib->DoubleValue();
else if(pAttrib->Name() == std::string("zoom"))
zoom = pAttrib->DoubleValue();
else if(pAttrib->Name() == std::string("alpha"))
alpha = pAttrib->DoubleValue();
pAttrib = pAttrib->Next();
}
if( rect.x != -1 && rect.y != -1 && rect.w != -1 && rect.h != -1)
pSurface = getSurface( pSurface.get(), rect );
if( zoom != 1.0 || rot != 0.0f )
pSurface = rotozoomSurface( pSurface.get(), rot, zoom, 1); //1 is for smoothing
if( alpha != 1.0 )
{
int a = 255*alpha;
SDL_SetAlpha( pSurface.get(), SDL_SRCALPHA|SDL_RLEACCEL, a);
}
}
m_Sprites.push_back( new SDL_SurfacePtr(pSurface) );
pChild = pChild->NextSiblingElement();
}
}
示例2: SetFromXMLElement
void CCuboid::SetFromXMLElement(TiXmlElement* pElem)
{
double l[3] = {0, 0, 0};
double d[3] = {0, 0, 1};
double x[3] = {1, 0, 0};
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "lx") {l[0] = a->DoubleValue();}
else if(name == "ly"){l[1] = a->DoubleValue();}
else if(name == "lz"){l[2] = a->DoubleValue();}
else if(name == "dx"){d[0] = a->DoubleValue();}
else if(name == "dy"){d[1] = a->DoubleValue();}
else if(name == "dz"){d[2] = a->DoubleValue();}
else if(name == "xx"){x[0] = a->DoubleValue();}
else if(name == "xy"){x[1] = a->DoubleValue();}
else if(name == "xz"){x[2] = a->DoubleValue();}
else if(name == "wx"){m_x = a->DoubleValue();}
else if(name == "wy"){m_y = a->DoubleValue();}
else if(name == "wz"){m_z = a->DoubleValue();}
}
m_pos = gp_Ax2(make_point(l), make_vector(d), make_vector(x));
CSolid::SetFromXMLElement(pElem);
}
示例3: ReadFromXMLElement
// static member function
HeeksObj* HLine::ReadFromXMLElement(TiXmlElement* pElem)
{
gp_Pnt p0(0, 0, 0), p1(0, 0, 0);
HeeksColor c;
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "col"){c = HeeksColor((long)(a->IntValue()));}
else if(name == "sx"){p0.SetX(a->DoubleValue());}
else if(name == "sy"){p0.SetY(a->DoubleValue());}
else if(name == "sz"){p0.SetZ(a->DoubleValue());}
else if(name == "ex"){p1.SetX(a->DoubleValue());}
else if(name == "ey"){p1.SetY(a->DoubleValue());}
else if(name == "ez"){p1.SetZ(a->DoubleValue());}
}
HLine* new_object = new HLine(p0, p1, &c);
new_object->ReadBaseXML(pElem);
if(new_object->GetNumChildren()>2)
{
//This is a new style line, with children points
new_object->Remove(new_object->A);
new_object->Remove(new_object->B);
delete new_object->A;
delete new_object->B;
new_object->A = (HPoint*)new_object->GetFirstChild();
new_object->B = (HPoint*)new_object->GetNextChild();
new_object->A->m_draw_unselected = false;
new_object->B->m_draw_unselected = false;
new_object->A->SetSkipForUndo(true);
new_object->B->SetSkipForUndo(true);
}
// The OpenCascade libraries throw an exception when one tries to
// create a gp_Lin() object using a vector that doesn't point
// anywhere. If this is a zero-length line then we're in
// trouble. Don't bother with it.
if (new_object->A == NULL || new_object->B == NULL || ((new_object->A->m_p.X() == new_object->B->m_p.X()) &&
(new_object->A->m_p.Y() == new_object->B->m_p.Y()) &&
(new_object->A->m_p.Z() == new_object->B->m_p.Z())))
{
delete new_object;
return(NULL);
}
return new_object;
}
示例4: SetFromXMLElement
void CCylinder::SetFromXMLElement(TiXmlElement* pElem)
{
// get the attributes
double l[3] = {0, 0, 0};
double d[3] = {0, 0, 1};
double x[3] = {1, 0, 0};
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "lx") {l[0] = a->DoubleValue();}
else if(name == "ly"){l[1] = a->DoubleValue();}
else if(name == "lz"){l[2] = a->DoubleValue();}
else if(name == "dx"){d[0] = a->DoubleValue();}
else if(name == "dy"){d[1] = a->DoubleValue();}
else if(name == "dz"){d[2] = a->DoubleValue();}
else if(name == "xx"){x[0] = a->DoubleValue();}
else if(name == "xy"){x[1] = a->DoubleValue();}
else if(name == "xz"){x[2] = a->DoubleValue();}
else if(name == "r"){m_radius = a->DoubleValue();}
else if(name == "h"){m_height = a->DoubleValue();}
}
m_pos = gp_Ax2(make_point(l), make_vector(d), make_vector(x));
CSolid::SetFromXMLElement(pElem);
}
示例5: ReadFromXMLElement
//static
HeeksObj* HPoint::ReadFromXMLElement(TiXmlElement* pElem)
{
gp_Pnt p;
HeeksColor c;
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "col"){c = HeeksColor((long)(a->IntValue()));}
else if(name == "x"){p.SetX(a->DoubleValue());}
else if(name == "y"){p.SetY(a->DoubleValue());}
else if(name == "z"){p.SetZ(a->DoubleValue());}
}
HPoint* new_object = new HPoint(p, &c);
new_object->ReadBaseXML(pElem);
return new_object;
}
示例6: ReadFromXMLElement
// static member function
HeeksObj* HImage::ReadFromXMLElement(TiXmlElement* pElem)
{
wxString filepath;
double x[4][3];
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "filepath"){filepath.assign(Ctt(a->Value()));}
else if(name == "x00"){x[0][0] = a->DoubleValue();}
else if(name == "x01"){x[0][1] = a->DoubleValue();}
else if(name == "x02"){x[0][2] = a->DoubleValue();}
else if(name == "x10"){x[1][0] = a->DoubleValue();}
else if(name == "x11"){x[1][1] = a->DoubleValue();}
else if(name == "x12"){x[1][2] = a->DoubleValue();}
else if(name == "x20"){x[2][0] = a->DoubleValue();}
else if(name == "x21"){x[2][1] = a->DoubleValue();}
else if(name == "x22"){x[2][2] = a->DoubleValue();}
else if(name == "x30"){x[3][0] = a->DoubleValue();}
else if(name == "x31"){x[3][1] = a->DoubleValue();}
else if(name == "x32"){x[3][2] = a->DoubleValue();}
}
HImage *new_object = new HImage(filepath.c_str());
memcpy(new_object->m_x[0], x[0], 12*sizeof(double));
new_object->m_rectangle_intialized = true;
new_object->ReadBaseXML(pElem);
return new_object;
}
示例7: if
Globals::Globals(TiXmlElement *root)
:
nodeCounter(-1),
linkCounter(-1),
speciesCounter(-1)
{
cout << "Populating sigmoid table...";
for (int a=0; a<6001; a++)
{
signedSigmoidTable[a] = ((1 / (1+exp(-((a-3000)/1000.0)))) - 0.5)*2.0;
unsignedSigmoidTable[a] = 1 / (1+exp(-((a-3000)/1000.0)));
}
cout << "done!\n";
TiXmlAttribute *firstAttribute = root->FirstAttribute();
while (firstAttribute)
{
if (iequals(firstAttribute->Name(),"NodeCounter"))
{
nodeCounter = firstAttribute->IntValue();
}
else if (iequals(firstAttribute->Name(),"LinkCounter"))
{
linkCounter = firstAttribute->IntValue();
}
else if (iequals(firstAttribute->Name(),"SpeciesCounter"))
{
speciesCounter = firstAttribute->IntValue();
}
else
{
addParameter( firstAttribute->Name() , firstAttribute->DoubleValue());
}
firstAttribute = firstAttribute->Next();
}
if (nodeCounter==-1 || linkCounter==-1 || speciesCounter==-1)
{
throw CREATE_LOCATEDEXCEPTION_INFO("MALFORMED XML!");
}
cacheParameters();
initRandom();
}
示例8: ReadFromXMLElement
HeeksObj* Constraint::ReadFromXMLElement(TiXmlElement* pElem)
{
const char* type=0;
EnumConstraintType etype=(EnumConstraintType)0;
const char* angle=0;
EnumAbsoluteAngle eangle=(EnumAbsoluteAngle)0;
double length=0;
int obj1_id=0;
int obj2_id=0;
int obj1_type=0;
int obj2_type=0;
ConstrainedObject* obj1=0;
ConstrainedObject* obj2=0;
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "type"){type = a->Value();}
else if(name == "angle"){angle = a->Value();}
else if(name == "length"){length = a->DoubleValue();}
else if(name == "obj1_id"){obj1_id = a->IntValue();}
else if(name == "obj1_type"){obj1_type = a->IntValue();}
else if(name == "obj2_id"){obj2_id = a->IntValue();}
else if(name == "obj2_type"){obj2_type = a->IntValue();}
}
//Ugh, we need to convert the strings back into types
for(unsigned i=0; i < sizeof(ConstraintTypes); i++)
{
if(strcmp(ConstraintTypes[i].c_str(),type)==0)
{
etype = (EnumConstraintType)i;
break;
}
}
for(unsigned i=0; i < sizeof(AbsoluteAngle); i++)
{
if(strcmp(AbsoluteAngle[i].c_str(),angle)==0)
{
eangle = (EnumAbsoluteAngle)i;
break;
}
}
//JT
//Ok.. There is a problem here.. Further up stream there a conditions where the xml has been written out for obj1_id, obj2_id != 0 for objects that don't exist
//This is a huge pain, since the error is being introduced on the file save, and doesn't show up, until you load the file.
// Sometimes you get a segmentation fault right at load... Or when you're really lucky it shows up when solvesketch kicks in and you have no clue whats going on.
// At this point,until these critters get irridicated CheckforValidConstraint basically tries to see if the constraint makes sense
// I hope to install this at both ends when constraints are being written out or read in my attempt to identify, isolate and irradicate these most annoying
// critters
#ifdef CHECK_FOR_INVALID_CONSTRAINT
bool blockConstraint =false;
blockConstraint = checkForInvalidConstraint(type,etype,angle,eangle,length,obj1_id,obj2_id,obj1_type,obj2_type);
if (blockConstraint)
{
return NULL;
}
#endif
//Get real pointers to the objects
obj1 = (ConstrainedObject*)wxGetApp().GetIDObject(obj1_type,obj1_id);
obj2 = (ConstrainedObject*)wxGetApp().GetIDObject(obj2_type,obj2_id);
Constraint *c = new Constraint(etype,eangle,length,obj1,obj2);
unsigned int len;
char *str = new char[512];
char *cstr = str;
printf("Searched for: 0x%X:0x%X, 0x%X:0x%X\n", obj1_type, obj1_id, obj2_type, obj2_id);
if(obj1)
{
obj1->constraints.push_back(c);
obj1->ToString(str,&len,512);
cstr = str+len;
}
if(obj2)
{
obj2->constraints.push_back(c);
obj2->ToString(cstr,&len,512);
cstr = cstr+len;
}
printf("%s",str);
//Don't let the xml reader try to insert us in the tree
return NULL;
}
示例9: ReadFromXMLElement
void CAdaptiveParams::ReadFromXMLElement(TiXmlElement* pElem)
{
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "leadoffdz"){m_leadoffdz = a->DoubleValue();}
else if(name == "leadofflen"){m_leadofflen = a->DoubleValue();}
else if(name == "leadoffrad"){m_leadoffrad = a->DoubleValue();}
else if(name == "retractzheight"){m_retractzheight = a->DoubleValue();}
else if(name == "leadoffsamplestep"){m_leadoffsamplestep = a->DoubleValue();}
else if(name == "toolcornerrad"){m_toolcornerrad = a->DoubleValue();}
else if(name == "toolflatrad"){m_toolflatrad = a->DoubleValue();}
else if(name == "samplestep"){m_samplestep = a->DoubleValue();}
else if(name == "stepdown"){m_stepdown = a->DoubleValue();}
else if(name == "clearcuspheight"){m_clearcuspheight = a->DoubleValue();}
else if(name == "triangleweaveres"){m_triangleweaveres = a->DoubleValue();}
else if(name == "flatradweaveres"){m_flatradweaveres = a->DoubleValue();}
else if(name == "dchangright"){m_dchangright = a->DoubleValue();}
else if(name == "dchangrightoncontour"){m_dchangrightoncontour = a->DoubleValue();}
else if(name == "dchangleft"){m_dchangleft = a->DoubleValue();}
else if(name == "dchangefreespace"){m_dchangefreespace = a->DoubleValue();}
else if(name == "sidecutdisplch"){m_sidecutdisplch = a->DoubleValue();}
else if(name == "fcut"){m_fcut = a->DoubleValue();}
else if(name == "fretract"){m_fretract = a->DoubleValue();}
else if(name == "thintol"){m_thintol = a->DoubleValue();}
else if(name == "startpoint_x"){m_startpoint_x = a->DoubleValue();}
else if(name == "startpoint_y"){m_startpoint_y = a->DoubleValue();}
else if(name == "startvel_x"){m_startvel_x = a->DoubleValue();}
else if(name == "startvel_y"){m_startvel_y = a->DoubleValue();}
else if(name == "minz"){m_minz = a->DoubleValue();}
else if(name == "boundaryclear"){m_boundaryclear = a->DoubleValue();}
else if(name == "boundary_x0"){m_boundary_x0 = a->DoubleValue();}
else if(name == "boundary_x1"){m_boundary_x1 = a->DoubleValue();}
else if(name == "boundary_y0"){m_boundary_y0 = a->DoubleValue();}
else if(name == "boundary_y1"){m_boundary_y1 = a->DoubleValue();}
}
}
示例10: ReadFromXMLElement
// static
HeeksObj* HDimension::ReadFromXMLElement(TiXmlElement* pElem)
{
double m[16];
wxString text;
HeeksColor c;
double p0[3] = {0, 0, 0};
double p1[3] = {0, 0, 0};
double p2[3] = {0, 0, 0};
double scale=1;
DimensionMode mode = TwoPointsDimensionMode;
DimensionUnits units = DimensionUnitsGlobal;
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "col"){c = HeeksColor((long)(a->IntValue()));}
else if(name == "m0"){m[0] = a->DoubleValue();}
else if(name == "m1"){m[1] = a->DoubleValue();}
else if(name == "m2"){m[2] = a->DoubleValue();}
else if(name == "m3"){m[3] = a->DoubleValue();}
else if(name == "m4"){m[4] = a->DoubleValue();}
else if(name == "m5"){m[5] = a->DoubleValue();}
else if(name == "m6"){m[6] = a->DoubleValue();}
else if(name == "m7"){m[7] = a->DoubleValue();}
else if(name == "m8"){m[8] = a->DoubleValue();}
else if(name == "m9"){m[9] = a->DoubleValue();}
else if(name == "ma"){m[10]= a->DoubleValue();}
else if(name == "mb"){m[11]= a->DoubleValue();}
else if(name == "scale"){scale= a->DoubleValue();}
else if(name == "mode"){mode = (DimensionMode)(a->IntValue());}
else if(name == "units"){
const char* str = a->Value();
switch(str[0])
{
case 'm':
units = DimensionUnitsMM;
break;
case 'i':
units = DimensionUnitsInches;
break;
}
}
}
HDimension* new_object = new HDimension(make_matrix(m), make_point(p0), make_point(p1), make_point(p2), mode, units, &c);
new_object->ReadBaseXML(pElem);
new_object->m_scale = scale;
if(new_object->GetNumChildren()>3)
{
//This is a new style line, with children points
new_object->Remove(new_object->A);
new_object->Remove(new_object->B);
new_object->Remove(new_object->m_p2);
delete new_object->A;
delete new_object->B;
delete new_object->m_p2;
new_object->A = (HPoint*)new_object->GetFirstChild();
new_object->B = (HPoint*)new_object->GetNextChild();
new_object->m_p2 = (HPoint*)new_object->GetNextChild();
new_object->A->m_draw_unselected = false;
new_object->B->m_draw_unselected = false;
new_object->m_p2->m_draw_unselected = false;
new_object->A->SetSkipForUndo(true);
new_object->B->SetSkipForUndo(true);
new_object->m_p2->SetSkipForUndo(true);
}
return new_object;
}
示例11: CompileFace
void MeshCompiler::CompileFace( TiXmlElement* Face )
{
uint NumVertsInFace = 0;
uint TempIndices[4];
Vector TempPositions[4];
for( TiXmlElement* Vert = Face->FirstChildElement( "vert" ); Vert; Vert = Vert->NextSiblingElement( "vert" ) )
{
// Push back cached indices to handle 4-sided faces
if( NumVertsInFace == 3 )
{
m_Indices.PushBack( TempIndices[0] );
m_Indices.PushBack( TempIndices[2] );
}
m_TempPos = Vector( 0.f, 0.f, 0.f );
m_TempUV = Vector2( 0.f, 0.f );
m_TempNorm = Vector( 0.f, 0.f, 0.f );
m_TempBoneIndex = SBoneData();
m_TempBoneWeight = SBoneWeights();
TiXmlElement* Pos = Vert->FirstChildElement( "pos" );
if( Pos )
{
TiXmlAttribute* PosAttr = Pos->FirstAttribute();
m_TempPos.x = (float)PosAttr->DoubleValue();
PosAttr = PosAttr->Next();
m_TempPos.y = (float)PosAttr->DoubleValue();
PosAttr = PosAttr->Next();
m_TempPos.z = (float)PosAttr->DoubleValue();
}
TempPositions[ NumVertsInFace ] = m_TempPos;
TiXmlElement* UVEl = Vert->FirstChildElement( "uv" );
if( UVEl )
{
m_Header.m_HasUVs = true;
TiXmlAttribute* UVAttr = UVEl->FirstAttribute();
m_TempUV.x = (float)UVAttr->DoubleValue();
UVAttr = UVAttr->Next();
m_TempUV.y = (float)UVAttr->DoubleValue();
// Blender uses OpenGL-style (bottom-to-top) texture coordinates;
// For now, at least, always convert to Direct3D-style.
m_TempUV.y = 1.0f - m_TempUV.y;
}
TiXmlElement* Norm = Vert->FirstChildElement( "norm" );
if( Norm )
{
m_Header.m_HasNormals = true;
TiXmlAttribute* NormAttr = Norm->FirstAttribute();
m_TempNorm.x = (float)NormAttr->DoubleValue();
NormAttr = NormAttr->Next();
m_TempNorm.y = (float)NormAttr->DoubleValue();
NormAttr = NormAttr->Next();
m_TempNorm.z = (float)NormAttr->DoubleValue();
}
int bIdx = 0;
for( TiXmlElement* Bone = Vert->FirstChildElement( "bone" ); Bone; Bone = Bone->NextSiblingElement( "bone" ) )
{
TiXmlAttribute* BoneAttr = Bone->FirstAttribute();
m_TempBoneIndex.m_Data[ bIdx ] = GetIndexForBone( HashedString( BoneAttr->Value() ) );
BoneAttr = BoneAttr->Next();
m_TempBoneWeight.m_Data[ bIdx ] = static_cast<float>( BoneAttr->DoubleValue() );
++bIdx;
}
uint32 Index = GetIndexForTempVertex();
if( Index == 65536 && !m_Header.m_LongIndices )
{
PRINTF( "Warning: Exceeded 65536 indices.\n" );
PRINTF( "\tUse -l to compile with long indices.\n" );
}
m_Indices.PushBack( Index );
// Cache indices to handle 4-side faces
TempIndices[ NumVertsInFace++ ] = Index;
}
if( NumVertsInFace == 4 )
{
m_RawTris.PushBack( Triangle( TempPositions[0], TempPositions[1], TempPositions[2] ) );
m_RawTris.PushBack( Triangle( TempPositions[0], TempPositions[2], TempPositions[3] ) );
}
else
{
m_RawTris.PushBack( Triangle( TempPositions[0], TempPositions[1], TempPositions[2] ) );
}
}