1 | #include "GeoMeshSimpSequence.h"
|
---|
2 |
|
---|
3 | using namespace Geometry;
|
---|
4 | using namespace std;
|
---|
5 |
|
---|
6 | MeshSimplificationSequence::MeshSimplificationSequence()
|
---|
7 | {
|
---|
8 | meshName="";
|
---|
9 | }
|
---|
10 |
|
---|
11 | MeshSimplificationSequence::~MeshSimplificationSequence()
|
---|
12 | {
|
---|
13 | }
|
---|
14 |
|
---|
15 | void MeshSimplificationSequence::Load(Serializer &s)
|
---|
16 | {
|
---|
17 | //Loads a simplification sequence from a file
|
---|
18 | char buffer[256];
|
---|
19 | unsigned int modVertex;
|
---|
20 | char name[256];
|
---|
21 |
|
---|
22 | if (s.ReadData(buffer,256) != NULL)
|
---|
23 | {
|
---|
24 | sscanf(buffer,"%s",&name);
|
---|
25 | meshName=new char[strlen(name)];
|
---|
26 | strcpy(meshName,name);
|
---|
27 | }
|
---|
28 |
|
---|
29 | while (s.ReadData(buffer,256) != NULL)
|
---|
30 | {
|
---|
31 | Geometry::MeshSimplificationSequence::Step simplifstep;
|
---|
32 | //new step
|
---|
33 | sscanf(buffer,"%u %u %u %u %u %f %f %f &",&simplifstep.mV1,&simplifstep.mV0, &simplifstep.mT0,&simplifstep.mT1, &simplifstep.obligatorio,&simplifstep.x, &simplifstep.y, &simplifstep.z);
|
---|
34 | //sscanf(buffer,"%u %u %u %u %u &",&simplifstep.mV1,&simplifstep.mV0, &simplifstep.mT0,&simplifstep.mT1, &simplifstep.obligatorio);
|
---|
35 | //sscanf(buffer + 3,"%u %u %f %f %f %u %u &",&simplifstep.mV0,&simplifstep.mV1,&simplifstep.x, &simplifstep.y, &simplifstep.z, &simplifstep.mT0,&simplifstep.mT1);
|
---|
36 | //sscanf(buffer,"%u %u %u %u %u &",&simplifstep.mV0,&simplifstep.mV1,&simplifstep.mT0,&simplifstep.mT1, &simplifstep.obligatorio);
|
---|
37 |
|
---|
38 | buffer[strlen(buffer)-1]='\0';
|
---|
39 |
|
---|
40 | //if(!simplifstep.obligatorio)
|
---|
41 | //{
|
---|
42 | char *ptr1;
|
---|
43 | ptr1=strtok(buffer,"&");
|
---|
44 | ptr1=strtok(NULL,"&");
|
---|
45 |
|
---|
46 | if (ptr1!=NULL)
|
---|
47 | {
|
---|
48 | char *ptr;
|
---|
49 | ptr=strtok(ptr1," ");
|
---|
50 |
|
---|
51 | while(ptr != NULL )
|
---|
52 | {
|
---|
53 | modVertex = (unsigned int)atoi(ptr);
|
---|
54 | simplifstep.mModfaces.push_back(modVertex);
|
---|
55 | ptr=strtok(NULL," ");
|
---|
56 | }
|
---|
57 | }
|
---|
58 | mSteps.push_back(simplifstep);
|
---|
59 | //}
|
---|
60 |
|
---|
61 | }
|
---|
62 |
|
---|
63 | }
|
---|
64 |
|
---|
65 | void MeshSimplificationSequence::Save(Serializer &s)
|
---|
66 | {
|
---|
67 | //Stores the simplification sequence in a file
|
---|
68 | char simp[256];
|
---|
69 |
|
---|
70 | //Name of the mesh
|
---|
71 | sprintf(simp,"%s\n",meshName);
|
---|
72 | s.WriteData(simp,sizeof(char),strlen(simp));
|
---|
73 |
|
---|
74 | for(unsigned int i=0; i<mSteps.size(); i++)
|
---|
75 | {
|
---|
76 | Geometry::MeshSimplificationSequence::Step paso = mSteps.operator [](i);
|
---|
77 | //sprintf(simp,"%u %u %u %u %u &", paso.mV0, paso.mV1, paso.mT0, paso.mT1,paso.obligatorio);
|
---|
78 | sprintf(simp,"%u %u %u %u %u %f &", paso.mV0, paso.mV1, paso.mT0, paso.mT1,paso.obligatorio,paso.x);
|
---|
79 | s.WriteData(simp,sizeof(char),strlen(simp));
|
---|
80 | for (unsigned int j=0; j<paso.mModfaces.size(); j++)
|
---|
81 | {
|
---|
82 | sprintf(simp," %u",paso.mModfaces.operator [](j));
|
---|
83 | s.WriteData(simp,sizeof(char),strlen(simp));
|
---|
84 | }
|
---|
85 | s.WriteData("\n",sizeof(char),1);
|
---|
86 | }
|
---|
87 | }
|
---|
88 |
|
---|
89 | void MeshSimplificationSequence::putMeshName(char *name)
|
---|
90 | {
|
---|
91 | meshName=name;
|
---|
92 | }
|
---|
93 |
|
---|
94 | char *MeshSimplificationSequence::getMeshName(void)
|
---|
95 | {
|
---|
96 | return meshName;
|
---|
97 | }
|
---|