A l'aide je comprend pas !!!

Résolu
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 - 20 févr. 2005 à 14:33
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 - 20 févr. 2005 à 22:39
Bonjours, j'etudie un code en c++ (sachant que ce n'est pas mon langage de prog) et je me retrouve face a c'est quelque ligne que je ne comprend pas. En faite a = , b = et if et swap je pense l'avoir compris.
Mais je n'est trouver aucune information sur setEdgePair, alors si vous savez s'il vous plait aider moi.

a = m_arrTriangles[i].vertexIndices[0];
b = m_arrTriangles[i].vertexIndices[1];
if (a > b)
std::swap(a, b);
if (setEdgePair.find(MAKELONG(a, b)) == setEdgePair.end())
setEdgePair.insert(MAKELONG(a, b));

Et oui je suis trés mauvais en orthographe, donc excusez moi.

16 réponses

cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
20 févr. 2005 à 22:25
il n'a aucun effet sur les 2 lignes la. les valeurs de m_arrTriangles[i].vertexIndices[0] et
m_arrTriangles[i].vertexIndices[1] sont recopiées dans a et b, et à la sortie des deux lignes


if (a > b)
std::swap(a, b);

on est sur que a est inférieur ou égal à b. maintenant ca n'affecte pas les valeurs d'origine de m_arrTriangles...



a++
3
cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
20 févr. 2005 à 15:08
salut,

Dans ton code, setEdgePair est le nom d'une variable.

En ne postant que cette partie de ton code, c'est difficile d'en dire
davantage, mais sans doute setEdgePair est une liste, le find permet de
rechercher un de ses elements (ca retourne setEdgePair.End() si ca na
pas été trouvé), et insert ajoute l'élément dans la liste. voila
si ca a pu t'éclairer....



a++
0
cs_erazor Messages postés 85 Date d'inscription jeudi 7 février 2002 Statut Membre Dernière intervention 8 février 2007
20 févr. 2005 à 15:08
setEdgePair est vraisemblablement un objet definie autre part dans le prog que tu etudie ;-)

trouve un endroit ou il doit etre marqué un truc du genre class blabla{...}setEdgePair; ou un endroit ou c marqué blabla setEdgePair puis trouve la definition de class correspondantes a blabla
0
cs_erazor Messages postés 85 Date d'inscription jeudi 7 février 2002 Statut Membre Dernière intervention 8 février 2007
20 févr. 2005 à 15:10
oups nos reponses se sont croisees
effectivement cosmobob serait plus dans le vra que moi ;-)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 1
20 févr. 2005 à 15:15
Justement je viens demander l'aide car dans le prog c'est le seul endroit ou je trouve SetEdgePair....

Et oui je suis trés mauvais en orthographe, donc excusez moi.
0
cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
20 févr. 2005 à 15:48
ben si SetEdgePair apparait, c'est
qu'il a été déclaré quelque part... fais une recherche ctrl+F dans
l'IDE de ton compilateur, tu va tomber forcément sur la déclaration...



a+
0
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 1
20 févr. 2005 à 16:45
Je n'ai rien trouver !!! Aucune déclaration.

Voici le fichier .h

#pragma once


#include "main include file.h"
#include <vector>


#ifndef byte
typedef unsigned char byte;
#endif // byte


#ifndef word
typedef unsigned short word;
#endif // word


#if defined( _MSC_VER ) || defined( __BORLANDC__ )
# include
# define PACK_STRUCT
# define PATH_MAX _MAX_PATH
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
# include <limits.h>
#else
# error you must byte-align these structures with the appropriate compiler directives
#endif


struct ms3d_header_t
{
char id[10]; // always "MS3D000000"
int version; // 4
} PACK_STRUCT;


struct ms3d_vertex_t
{
byte flags; // SELECTED | SELECTED2 | HIDDEN
float vertex[3]; //
char boneId; // -1 = no bone
byte referenceCount;
} PACK_STRUCT;


struct ms3d_triangle_t
{
word flags; // SELECTED | SELECTED2 | HIDDEN
word vertexIndices[3]; //
float vertexNormals[3][3]; //
float s[3]; //
float t[3]; //
byte smoothingGroup; // 1 - 32
byte groupIndex; //
} PACK_STRUCT;


struct ms3d_edge_t
{
word edgeIndices[2];
} PACK_STRUCT;


struct ms3d_group_t
{
byte flags; // SELECTED | HIDDEN
char name[32]; //
word numtriangles; //
std::vector<word> triangleIndices; // the groups group the triangles
char materialIndex; // -1 = no material
} ;


struct ms3d_material_t
{
char name[32]; //
float ambient[4]; //
float diffuse[4]; //
float specular[4]; //
float emissive[4]; //
float shininess; // 0.0f - 128.0f
float transparency; // 0.0f - 1.0f
char mode; // 0, 1, 2 is unused now
char texture[128]; // texture.bmp
char alphamap[128]; // alpha.bmp
} ;


struct ms3d_keyframe_rot_t
{
float time; // time in seconds
float rotation[3]; // x, y, z angles
} PACK_STRUCT;


struct ms3d_keyframe_pos_t
{
float time; // time in seconds
float position[3]; // local position
} PACK_STRUCT;


typedef struct
{
byte flags; // SELECTED | DIRTY
char name[32]; //
char parentName[32]; //
float rotation[3]; // local reference matrix
float position[3];


word numKeyFramesRot; //
word numKeyFramesTrans; //


std::vector<ms3d_keyframe_rot_t> keyFramesRot; // local animation matrices
std::vector<ms3d_keyframe_pos_t> keyFramesTrans; // local animation matrices
} ms3d_joint_t;


#include


class CMS3DFile
{
public:
CMS3DFile();
virtual ~CMS3DFile();


public:
BOOL LoadFromFile(LPCTSTR lpszFileName);
void Clear();


DWORD GetNumVertices();
void GetVertexAt(int nIndex, ms3d_vertex_t **ppVertex);
DWORD GetNumTriangles();
void GetTriangleAt(int nIndex, ms3d_triangle_t **ppTriangle);
DWORD GetNumEdges();
void GetEdgeAt(int nIndex, ms3d_edge_t **ppEdge);
DWORD GetNumGroups();
void GetGroupAt(int nIndex, ms3d_group_t **ppGroup);
DWORD GetNumMaterials();
void GetMaterialAt(int nIndex, ms3d_material_t **ppMaterial);
DWORD GetNumJoints();
void GetJointAt(int nIndex, ms3d_joint_t **ppJoint);
int FindJointByName(LPCTSTR lpszName);




float GetAnimationFPS();
float GetCurrentTime();
int GetTotalFrames();



private:


std::vector<ms3d_vertex_t> m_arrVertices;
std::vector<ms3d_triangle_t> m_arrTriangles;
std::vector<ms3d_edge_t> m_arrEdges;
std::vector<ms3d_group_t> m_arrGroups;
std::vector<ms3d_material_t> m_arrMaterials;
float m_fAnimationFPS;
float m_fCurrentTime;
int m_iTotalFrames;
std::vector<ms3d_joint_t> m_arrJoints;


private:
CMS3DFile(const CMS3DFile& rhs);
CMS3DFile& operator=(const CMS3DFile& rhs);
};

Et oui je suis trés mauvais en orthographe, donc excusez moi.
0
cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
20 févr. 2005 à 17:51
la déclaration d'une variable se trouve dans le meme fichier que la ou
elle est utilisée... c'est pas le .h qu'il fallait copier c'est le
fichier ou yavait:

a = m_arrTriangles[i].vertexIndices[0];
b = m_arrTriangles[i].vertexIndices[1];
if (a > b)
std::swap(a, b);
if (setEdgePair.find(MAKELONG(a, b)) == setEdgePair.end())
setEdgePair.insert(MAKELONG(a, b));




a+
0
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 1
20 févr. 2005 à 18:32
lol ok je vous mais cela :

#include "MS3DFile.h"
#include <set>


CMS3DFile::CMS3DFile()
: m_fAnimationFPS(24.0f),
m_fCurrentTime(0.0f),
m_iTotalFrames(0)
{
}


CMS3DFile::~CMS3DFile()
{
}


BOOL CMS3DFile::LoadFromFile(LPCTSTR lpszFileName)
{
FILE *fp = fopen(lpszFileName, "rb");
if (!fp)
return FALSE;


DWORD i;
ms3d_header_t header;
fread(&header, 1, sizeof(ms3d_header_t), fp);


if (strncmp(header.id, "MS3D000000", 10) != 0)
return FALSE;


if (header.version != 4)
return FALSE;


// vertices
word nNumVertices;
fread(&nNumVertices, 1, sizeof(word), fp);
m_arrVertices.clear();
m_arrVertices.resize(nNumVertices);


fread(&m_arrVertices[0], nNumVertices, sizeof(ms3d_vertex_t), fp);


// triangles
word nNumTriangles;
fread(&nNumTriangles, 1, sizeof(word), fp);
m_arrTriangles.resize(nNumTriangles);
fread(&m_arrTriangles[0], nNumTriangles, sizeof(ms3d_triangle_t), fp);


// edges
std::set<DWORD> setEdgePair;
for (i = 0; i < m_arrTriangles.size(); i++)
{
WORD a, b;
a = m_arrTriangles[i].vertexIndices[0];
b = m_arrTriangles[i].vertexIndices[1];
if (a > b)
std::swap(a, b);
if (setEdgePair.find(MAKELONG(a, b)) == setEdgePair.end())
setEdgePair.insert(MAKELONG(a, b));


a = m_arrTriangles[i].vertexIndices[1];
b = m_arrTriangles[i].vertexIndices[2];
if (a > b)
std::swap(a, b);
if (setEdgePair.find(MAKELONG(a, b)) == setEdgePair.end())
setEdgePair.insert(MAKELONG(a, b));


a = m_arrTriangles[i].vertexIndices[2];
b = m_arrTriangles[i].vertexIndices[0];
if (a > b)
std::swap(a, b);
if (setEdgePair.find(MAKELONG(a, b)) == setEdgePair.end())
setEdgePair.insert(MAKELONG(a, b));
}


for(std::set<DWORD>::iterator it = setEdgePair.begin(); it != setEdgePair.end(); ++it)
{
DWORD EdgePair = *it;
ms3d_edge_t Edge;
Edge.edgeIndices[0] = LOWORD(EdgePair);
Edge.edgeIndices[1] = HIWORD(EdgePair);
m_arrEdges.push_back(Edge);
}


// groups
word nNumGroups;
fread(&nNumGroups, 1, sizeof(word), fp);
m_arrGroups.resize(nNumGroups);
for (i = 0; i < nNumGroups; i++)
{
fread(&m_arrGroups[i].flags, 1, sizeof(byte), fp);
fread(&m_arrGroups[i].name, 32, sizeof(char), fp);
fread(&m_arrGroups[i].numtriangles, 1, sizeof(word), fp);
m_arrGroups[i].triangleIndices.resize(m_arrGroups[i].numtriangles);
fread(&m_arrGroups[i].triangleIndices[0], m_arrGroups[i].numtriangles, sizeof(word), fp);
fread(&m_arrGroups[i].materialIndex, 1, sizeof(char), fp);
}


// materials
word nNumMaterials;
fread(&nNumMaterials, 1, sizeof(word), fp);
m_arrMaterials.resize(nNumMaterials);
fread(&m_arrMaterials[0], nNumMaterials, sizeof(ms3d_material_t), fp);


fread(&m_fAnimationFPS, 1, sizeof(float), fp);
fread(&m_fCurrentTime, 1, sizeof(float), fp);
fread(&m_iTotalFrames, 1, sizeof(int), fp);


// joints
word nNumJoints;
fread(&nNumJoints, 1, sizeof(word), fp);
m_arrJoints.resize(nNumJoints);
for (i = 0; i < nNumJoints; i++)
{
fread(&m_arrJoints[i].flags, 1, sizeof(byte), fp);
fread(&m_arrJoints[i].name, 32, sizeof(char), fp);
fread(&m_arrJoints[i].parentName, 32, sizeof(char), fp);
fread(&m_arrJoints[i].rotation, 3, sizeof(float), fp);
fread(&m_arrJoints[i].position, 3, sizeof(float), fp);
fread(&m_arrJoints[i].numKeyFramesRot, 1, sizeof(word), fp);
fread(&m_arrJoints[i].numKeyFramesTrans, 1, sizeof(word), fp);
m_arrJoints[i].keyFramesRot.resize(m_arrJoints[i].numKeyFramesRot);
m_arrJoints[i].keyFramesTrans.resize(m_arrJoints[i].numKeyFramesTrans);
fread(&m_arrJoints[i].keyFramesRot[0], m_arrJoints[i].numKeyFramesRot, sizeof(ms3d_keyframe_rot_t), fp);
fread(&m_arrJoints[i].keyFramesTrans[0], m_arrJoints[i].numKeyFramesTrans, sizeof(ms3d_keyframe_pos_t), fp);
}


fclose(fp);


return TRUE;
}


void CMS3DFile::Clear()
{
m_arrVertices.clear();
m_arrTriangles.clear();
m_arrEdges.clear();
m_arrGroups.clear();
m_arrMaterials.clear();
m_arrJoints.clear();
}


DWORD CMS3DFile::GetNumVertices()
{
return (DWORD) m_arrVertices.size();
}


void CMS3DFile::GetVertexAt(int nIndex, ms3d_vertex_t **ppVertex)
{
if (nIndex >= 0 && nIndex < (int) m_arrVertices.size())
*ppVertex = &m_arrVertices[nIndex];
}



DWORD CMS3DFile::GetNumTriangles()
{
return (DWORD) m_arrTriangles.size();
}


void CMS3DFile::GetTriangleAt(int nIndex, ms3d_triangle_t **ppTriangle)
{
if (nIndex >= 0 && nIndex < (int) m_arrTriangles.size())
*ppTriangle = &m_arrTriangles[nIndex];
}


DWORD CMS3DFile::GetNumEdges()
{
return (DWORD) m_arrEdges.size();
}


void CMS3DFile::GetEdgeAt(int nIndex, ms3d_edge_t **ppEdge)
{
if (nIndex >= 0 && nIndex < (int) m_arrEdges.size())
*ppEdge = &m_arrEdges[nIndex];
}


DWORD CMS3DFile::GetNumGroups()
{
return (DWORD) m_arrGroups.size();
}


void CMS3DFile::GetGroupAt(int nIndex, ms3d_group_t **ppGroup)
{
if (nIndex >= 0 && nIndex < (int) m_arrGroups.size())
*ppGroup = &m_arrGroups[nIndex];
}


DWORD CMS3DFile::GetNumMaterials()
{
return (DWORD) m_arrMaterials.size();
}


void CMS3DFile::GetMaterialAt(int nIndex, ms3d_material_t **ppMaterial)
{
if (nIndex >= 0 && nIndex < (int) m_arrMaterials.size())
*ppMaterial = &m_arrMaterials[nIndex];
}


DWORD CMS3DFile::GetNumJoints()
{
return (DWORD) m_arrJoints.size();
}


void CMS3DFile::GetJointAt(int nIndex, ms3d_joint_t **ppJoint)
{
if (nIndex >= 0 && nIndex < (int) m_arrJoints.size())
*ppJoint = &m_arrJoints[nIndex];
}


int CMS3DFile::FindJointByName(LPCTSTR lpszName)
{
for (UINT i = 0; i < m_arrJoints.size(); i++)
{
if (!strcmp(m_arrJoints[i].name, lpszName))
return i;
}


return -1;
}


float CMS3DFile::GetAnimationFPS()
{
return m_fAnimationFPS;
}


float CMS3DFile::GetCurrentTime()
{
return m_fCurrentTime;
}


int CMS3DFile::GetTotalFrames()
{
return m_iTotalFrames;
}

et voila.

Et oui je suis trés mauvais en orthographe, donc excusez moi.
0
kaloway Messages postés 358 Date d'inscription jeudi 24 octobre 2002 Statut Membre Dernière intervention 13 avril 2020
20 févr. 2005 à 19:46
kaloway



tu doit avoir un fichier s'apellant set car #include <set> est une commande de précompilation si mes souvenirs du langage c sont bon.



La variable n'a pas un lien avec la ligne
std::set<DWORD> setEdgePair;
0
cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
20 févr. 2005 à 21:16
ben voila: std::set<DWORD> setEdgePair;

donc setEdgePair est en fait un ensemble de DWORD (un DWORD = un
entier), setEdgePair est donc un ensemble d'entiers. Comme je l'avais
dit avant, .find permet de chercher un entier dans l'ensemble, s'il
n'existe pas ca renvoie .end(), et la methode insert() ajoute un
element (= un nouvel entier) dans l'ensemble.



Sinon le type WORD correspond aux entiers codés sur 2 octets (cad 65536
= 2^16 entiers possibles), et MAKELONG(a,b) permet de creer un entier
codé sur 4 octets (un DWORD quoi) à partir de deux entiers codés sur 2
octets.



voila, si ca a pu un peu t'éclairer...

a++
0
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 1
20 févr. 2005 à 21:33
en faite c'est si on a pas deja mis la valeur dans setEdgePair on la met, je me trompe ?

Et oui je suis trés mauvais en orthographe, donc excusez moi.
0
cosmobob Messages postés 700 Date d'inscription mardi 30 décembre 2003 Statut Membre Dernière intervention 27 janvier 2009 4
20 févr. 2005 à 21:52
oui c'est ca
0
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 1
20 févr. 2005 à 22:03
Ok merci beaucoup, pour le swap (a,b) il a qu'elle effet sur
m_arrTriangles[i].vertexIndices[0];
m_arrTriangles[i].vertexIndices[1];

??????????????????

Et oui je suis trés mauvais en orthographe, donc excusez moi.
0
steve_clamage Messages postés 475 Date d'inscription dimanche 3 octobre 2004 Statut Membre Dernière intervention 11 août 2006 5
20 févr. 2005 à 22:23
aucun, a et b sont des copies
0
ciberrique Messages postés 589 Date d'inscription lundi 25 août 2003 Statut Membre Dernière intervention 18 juillet 2010 1
20 févr. 2005 à 22:39
Ok je vous remercie tous !!!!

Et oui je suis trés mauvais en orthographe, donc excusez moi.
0
Rejoignez-nous