25 #include "SimpleOpt.h"
39 std::cerr <<
"rib0:" << std::endl;
40 std::cerr <<
" extrude a profile along a path" << std::endl;
41 std::cerr <<
"syntax: rib0 path_file profile_file [-?|-h|--help] [-d nx ny nz|--dir nx ny nz] > output_file" << std::endl;
42 std::cerr <<
" path_file : '.pt' file:" << std::endl;
43 std::cerr <<
" n_pt" << std::endl;
44 std::cerr <<
" x1 y1 z1" << std::endl;
45 std::cerr <<
" x2 y2 z2" << std::endl;
46 std::cerr <<
" ..." << std::endl;
47 std::cerr <<
" profile_file: '.pt2' file:" << std::endl;
48 std::cerr <<
" n_pt" << std::endl;
49 std::cerr <<
" x1 y1" << std::endl;
50 std::cerr <<
" x2 y2" << std::endl;
51 std::cerr <<
" ..." << std::endl;
52 std::cerr <<
" -d: 3D direction of the x axis of the profile_file" << std::endl;
53 std::cerr <<
"author: P.Smars, 2001-2008" << std::endl;
54 std::cerr <<
"version: 2008-04-30" << std::endl;
58 std::vector<a_point *>
path;
60 a_point
dir(
int i,
int l)
69 return (*
path[imax]-*
path[imin]).normalise();
74 const a_point vertical(0,0,1);
76 const double cosv_lim = 0.95;
94 d = (*
path[imax]-*
path[imin]).normalise();
95 cosv = fabs(d*vertical);
96 }
while ((cosv>cosv_lim)&&changed);
99 std::cerr <<
"the path is nearly vertical" << std::endl;
100 std::cerr <<
"you should define the direction of the normal to the structure with the -d option" << std::endl;
101 std::cerr <<
"(this is also the 3D direction of the x axis of the profile file)" << std::endl;
104 return (
cross(vertical,d)).normalise();
107 int main(
int argc,
char *argv[] )
110 bool without_normal =
true;
114 if (args.LastError() == SO_SUCCESS)
118 else if (args.OptionId() ==
OPT_DIR)
120 char ** arg0 = args.MultiArg(3);
123 std::cerr <<
"the number of arguments is not correct" << std::endl;
127 for (
int i = 0; i < 3; i++)
129 std::istringstream
in(arg0[i]);
132 u.set(x[0],x[1],x[2]);
134 if (u.norm()==0.)
return error(-2);
135 without_normal =
false;
140 std::cerr <<
"Invalid argument: " << args.OptionText() << std::endl;
141 return error(args.LastError());
146 if (args.FileCount() != 2)
return error(-3);
148 std::ifstream f_path(args.File(0));
149 if (!f_path) {std::cerr <<
"file '" << args.File(1) <<
"' does not exist" << std::endl;
return error(-4);}
150 std::ifstream f_temp(args.File(1));
151 if (!f_temp) {std::cerr <<
"file '" << args.File(0) <<
"' does not exist" << std::endl;
return error(-5);}
157 for (
int k = 0; k < n_path; k++)
160 f_path >> x >> y >> z;
161 pt =
new a_point(x,y,z);
169 std::vector<a_point *> temp(n_temp);
170 for (
int k = 0; k < n_temp; k++)
174 pt =
new a_point(x,y,0);
179 a_point vertical(0,0,1);
180 std::cout << n_path*n_temp << std::endl;
181 for (
int k = 0; k < n_path; k++)
183 a_point pt0 = *
path[k];
184 a_point dt =
dir(k,n_path);
187 a_point
v = (
cross(dt,u)).normalise();
188 for (
int m = 0; m < n_temp; m++)
190 a_point point0 = *temp[m];
191 a_point pointn = pt0;
192 pointn += (point0.x())*u;
193 pointn += (point0.y())*
v;
194 std::cout << pointn << std::endl;
197 std::cout << (n_path-1)*(n_temp-1)*2 << std::endl;
198 for (
int k = 0; k < n_path-1; k++)
200 for (
int m = 0; m < n_temp-1; m++)
206 std::cout << i1 <<
"\t" << j2 <<
"\t" << j1 << std::endl;
207 std::cout << i1 <<
"\t" << i2 <<
"\t" << j2 << std::endl;
e_point cross(e_point &a, e_point &b)
double v(const uint32_t step, const uint32_t n)
int main(int argc, char *argv[])
a_point normal(int i, int l)
CSimpleOpt::SOption g_rgOptions[]
std::vector< a_point * > path
a_point dir(int i, int l)