-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBrepModel.cpp
More file actions
113 lines (106 loc) · 2.19 KB
/
Copy pathBrepModel.cpp
File metadata and controls
113 lines (106 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<iostream>
#include<vector>
#include "BrepModel.h"
using namespace std;
Solid* BrepModel::createSolid(const char* path)
{
FILE *file = fopen(path,"r");
if(file==NULL)
{
printf("%s","open file error!");
return NULL;
}
int numOfVertex,numOfOperator;
fscanf(file,"%d",&numOfVertex);
fscanf(file,"%d\n",&numOfOperator);
vector<Point> ptList(numOfVertex);
Point pt;
for(int i=0;i<numOfVertex;++i)
{
fscanf(file,"%lf",&pt.coords[0]);
fscanf(file,"%lf",&pt.coords[1]);
fscanf(file,"%lf\n",&pt.coords[2]);
pt.index = Point::indexIncrement();
ptList[i] = pt;
}
vector<Vertex*> veList(numOfVertex);
vector<Loop*> loopList;
int type;
int index1,index2;
Loop *loop;
for(int i=0;i<numOfOperator;++i)
{
fscanf(file,"%d",&type);
printf("now processing %d\n",i);
switch(type)
{
case 0:
{
//mvfs
fscanf(file,"%d",&index1);
veList[index1] = EulerOperator::mvfs(ptList[index1],solid);
loop = solid->face->loop;
loopList.push_back(loop);
break;
}
case 1:
{
//mev
fscanf(file,"%d",&index1);
fscanf(file,"%d",&index2);
veList[index2] = EulerOperator::mev(veList[index1],ptList[index2],loop)->ve2;
break;
}
case 2:
{
//mef
fscanf(file,"%d",&index1);
fscanf(file,"%d",&index2);
Face* face = EulerOperator::mef(veList[index1],veList[index2],loop);
loopList.push_back(face->loop);
break;
}
case 3:
{
//kemr
fscanf(file,"%d",&index1);
fscanf(file,"%d",&index2);
Loop* newLoop = EulerOperator::kemr(veList[index1],veList[index2],loop);
loopList.push_back(newLoop);
break;
}
case 4:
{
//kfmrh
fscanf(file,"%d",&index1);
fscanf(file,"%d",&index2);
EulerOperator::kfmrh(loopList[index1],loopList[index2]);
break;
}
case 5:
{
//select loop
fscanf(file,"%d",&index1);
loop = loopList[index1];
break;
}
case 6:
{
//sweep
double dir[3],distance;
for(int i=0;i<3;++i)
{
fscanf(file,"%lf",&dir[i]);
}
fscanf(file,"%lf",&distance);
EulerOperator::sweep(solid->face,dir,distance);
break;
}
default:
printf("%s","unrecognized operator type!");
getchar();
}
}
fclose(file);
return solid;
}