proteus  1.8.1
C/C++/Fortran libraries
testDomain.cpp
Go to the documentation of this file.
1 #include "Domain.h"
2 #include <iostream>
3 #include <fstream>
4 #include <string>
5 
6 using namespace std;
7 
8 int main()
9 {
10 
11  string polyfile;
12  string filename;
13  string filenameIn;
14  string units;
15  string name;
16  double x0, y0, z0, Lx, Ly, Lz ;//interval variables
17  vector<double> x;
18  vector<double> y;
19  vector<double> z;
20  vector<int> a;
21  vector<int> b;
22  vector<int> c;
23  vector<int> d;
24  vector<vector<double> > vertices2;
25  vector<vector<vector<double> > > vertices3;
26  vector< vector<int> > segments;
27  vector< vector<double> > holes;
28  vector<double> regions;
29  vector<int> vertexFlags;
30  vector<int> segmentFlags;
31  vector< vector < vector < vector<int> > > >facets;
32  int dim;
33  int answer;
34 
35  ifstream inFile;
36 
37 
38  cout << "Enter the domain, 1 for Rectangular Domain, 2 for Planar Straight Line Graph, 3 for Triangulated Surface Domain, and 4 for Piecewise Linear Complex Domain: " << endl;
39  cin >> answer;
40 
41 
42  if (answer == 1)
43  {
44  //Asking for the Dimensions
45  cout << "Enter 1 for 1D, 2 for 2D, and 3 for 3D asymptote rectangle:"<<endl;
46  cin >> dim;
47 
48 
49  /******* if else below has validation*******
50  //Validation for Dimensions
51  while (dim != 1 && dim != 2 && dim != 3)
52  {
53  cout << "Error: Domain object must have dimension 1, 2 or 3. Please re-enter: " << endl;
54  cin >> dim;
55  }
56 
57  */
58  if(dim == 1)
59  {
60  //Asking for the points
61  cout << "Enter the x0 coordinate:" << endl;
62  cin >> x0;
63  cout << "Enter the Lx coordinate:" << endl;
64  cin >> Lx;
65 
66  RectangularDomain rect(x0, Lx, name, units);
67 
68 
69  //Entering filename
70  cout<<"Enter filename"<<endl;
71  cin >> filenameIn;
72  filename = filenameIn + ".asy";
73 
74  cout << "Writing to "<<filename<< "..." << endl;
75 
76  rect.writeAsymptote(filename.c_str()); //function call
77 
78  }
79  else if(dim == 2)
80  {
81  //Asking for the points
82  cout << "Enter the x0:" << endl;
83  cin >> x0;
84  cout << "Enter the Lx:" << endl;
85  cin >> Lx;
86  cout << "Enter the y0:" << endl;
87  cin >> y0;
88  cout << "Enter the Ly:" << endl;
89  cin >> Ly;
90 
91 
92  RectangularDomain rect2(x0, y0, Lx, Ly, name, units);
93 
94  //Entering filename
95  cout<<"Enter filename"<<endl;
96  cin >> filenameIn;
97  filename = filenameIn + ".asy";
98  cout << "Writing to "<< filename << "..." << endl;
99 
100  polyfile = filenameIn + ".poly";
101 
102  cout << "Writing to "<< polyfile << "..." << endl;
103 
104  rect2.writeAsymptote(filename.c_str()); //function call
105  rect2.writePoly(polyfile.c_str());
106  }
107  else
108  {
109  //Asking for the points
110  cout << "Enter the x0:" << endl;
111  cin >> x0;
112  cout << "Enter the Lx:" << endl;
113  cin >> Lx;
114  cout << "Enter the y0:" << endl;
115  cin >> y0;
116  cout << "Enter the Ly:" << endl;
117  cin >> Ly;
118  cout << "Enter the z0:" << endl;
119  cin >> z0;
120  cout << "Enter the Lz:" << endl;
121  cin >> Lz;
122 
123  RectangularDomain rect3(x0, y0, z0, Lx, Ly, Lz, name, units);
124 
125  //Entering filename
126  cout<<"Enter filename"<<endl;
127  cin >> filenameIn;
128  filename = filenameIn + ".asy";
129  cout << "Writing to "<<filename<< "..." <<endl;
130  polyfile = filenameIn + ".poly";
131  cout << "Writing to" << polyfile << "..."<< endl;
132  rect3.writeAsymptote(filename.c_str());//function call
133  rect3.writePoly(polyfile.c_str());
134  }
135  }
136 
137 
138 
139  else if (answer == 2)
140  {
141  x.push_back(0.0);
142  x.push_back(0.0);
143  x.push_back(1.0);
144  y.push_back(0.0);
145  y.push_back(1.0);
146  y.push_back(0.0);
147 
148  vertices2.push_back(x);
149  vertices2.push_back(y);
150 
151  a.push_back(0);
152  a.push_back(1);
153  a.push_back(2);
154  b.push_back(1);
155  b.push_back(2);
156  b.push_back(0);
157 
158  segments.push_back(a);
159  segments.push_back(b);
160 
161  PlanarStraightLineGraphDomain PSLG(vertices2,segments,holes,regions,vertexFlags,segmentFlags, name, units);
162 
163  cout << "Enter filename: ";
164  cin >> filenameIn;
165  filename = filenameIn + ".asy";
166  polyfile = filenameIn + ".poly";
167  PSLG.writeAsymptote(filename.c_str());
168  PSLG.writePoly(polyfile.c_str());
169 
170  }
171 // else if(answer == 3)
172 // {
173 
174 // // TriangulatedSurfaceDomain TSD( units, name);
175  else if (answer == 4)
176  {
177  x.push_back(0.0);
178  x.push_back(0.0);
179  x.push_back(1.0);
180  x.push_back(1.0);
181  x.push_back(0.0);
182  x.push_back(0.0);
183  x.push_back(1.0);
184  x.push_back(1.0);
185  y.push_back(0.0);
186  y.push_back(1.0);
187  y.push_back(1.0);
188  y.push_back(0.0);
189  y.push_back(0.0);
190  y.push_back(1.0);
191  y.push_back(1.0);
192  y.push_back(0.0);
193  z.push_back(0.0);
194  z.push_back(0.0);
195  z.push_back(0.0);
196  z.push_back(0.0);
197  z.push_back(1.0);
198  z.push_back(1.0);
199  z.push_back(1.0);
200  z.push_back(1.0);
201 
202  vertices3.push_back(x);
203  vertices3.push_back(y);
204  vertices3.push_back(z);
205 
206  a.push_back(0);
207  a.push_back(0);
208  a.push_back(0);
209  a.push_back(4);
210  a.push_back(3);
211  a.push_back(2);
212  b.push_back(1);
213  b.push_back(4);
214  b.push_back(4);
215  b.push_back(5);
216  b.push_back(7);
217  b.push_back(6);
218  c.push_back(2);
219  c.push_back(7);
220  c.push_back(5);
221  c.push_back(6);
222  c.push_back(6);
223  c.push_back(5);
224  d.push_back(3);
225  d.push_back(3);
226  d.push_back(1);
227  d.push_back(7);
228  d.push_back(2);
229  d.push_back(1);
230 
231 
232  facets.push_back(a);
233  facets.push_back(b);
234  facets.push_back(c);
235  facets.push_back(d);
236 
237  PiecewiseLinearComplexDomain PLC(vertices3, facets, name, units);
238 
239  cout << "Enter filename:" << endl;
240  cin >> filenameIn;
241  filename = filenameIn + ".asy";
242  polyfile = filenameIn + ".poly";
243 
244  PLC.writeAsymptote(filename.c_str());
245  PLC.writePoly(polyfile.c_str());
246  }
247  else
248  {
249  cout << "The domain entered is not supported" << endl;
250  }
251 
252  return 0;
253 }
PlanarStraightLineGraphDomain
Definition: Domain.h:37
Domain.h
RectangularDomain
Definition: Domain.h:25
RectangularDomain::writeAsymptote
void writeAsymptote(const char *filename)
Definition: Domain.cpp:112
PiecewiseLinearComplexDomain::writePoly
void writePoly(const char *filename)
Definition: Domain.cpp:512
z
Double * z
Definition: Headers.h:49
c
Double c
Definition: Headers.h:54
RectangularDomain::writePoly
void writePoly(const char *filename)
Definition: Domain.cpp:50
PlanarStraightLineGraphDomain::writeAsymptote
void writeAsymptote(const char *filename)
Definition: Domain.cpp:299
main
int main()
Definition: testDomain.cpp:8
PiecewiseLinearComplexDomain::writeAsymptote
void writeAsymptote(const char *filename)
Definition: Domain.cpp:453
PiecewiseLinearComplexDomain
Definition: Domain.h:102
PlanarStraightLineGraphDomain::writePoly
void writePoly(const char *filename)
Definition: Domain.cpp:227