24 #include "SimpleOpt.h"
45 std::cerr <<
"pt2arch:" << std::endl;
46 std::cerr <<
"convert 'x y z' file to an input file to build the arch with calipous tcl module" << std::endl;
47 std::cerr <<
"syntax: pt2arch [-n string|--name string] [-s double|--side double] [-?|-h|--help] thickness depth < point_file > arch_file" << std::endl;
48 std::cerr <<
" thickness: in the plane of the arch" << std::endl;
49 std::cerr <<
" depth: perpendicularly to the plane of the arch" << std::endl;
50 std::cerr <<
" -n name: give the name to the arch" << std::endl;
51 std::cerr <<
" (default: arch)" << std::endl;
52 std::cerr <<
" -s code: position of the points on the arch" << std::endl;
53 std::cerr <<
" -1: intrados (default)" << std::endl;
54 std::cerr <<
" 1: extrados" << std::endl;
55 std::cerr <<
" 0: centre" << std::endl;
56 std::cerr <<
"author: P.Smars, 2010-16" << std::endl;
57 std::cerr <<
"version: 2016-10-28" << std::endl;
61 int main(
int argc,
char *argv[] )
63 std::string name(
"arch");
68 if (args.LastError() == SO_SUCCESS)
72 else if (args.OptionId() ==
OPT_NAME)
73 name = args.OptionArg();
74 else if (args.OptionId() ==
OPT_SIDE)
76 std::istringstream i(args.OptionArg());
83 std::cerr <<
"Invalid argument: " << args.OptionText() << std::endl;
84 return error(args.LastError());
89 if (args.FileCount() != 2)
return error(-2);
91 for (
int k= 0; k < 2; k++) o << args.File(k) <<
" ";
92 std::istringstream i(o.str().c_str());
93 double thickness, depth;
94 i >> thickness >> depth;
95 double ui = -(1+pos)/2.*thickness;
96 double us = (1-pos)/2.*thickness;
101 std::vector<a_point *> intrados;
102 std::vector<a_point *> normals;
103 for (
int i = 0; i < npts; i++)
105 a_point * p =
new a_point;
107 intrados.push_back(p);
109 a_point * p1 = intrados[0];
110 a_point * p = intrados[intrados.size()/2];
111 a_point * p2 = intrados[intrados.size()-1];
112 a_point d1 = (*p-*p1).normalise();
113 a_point d2 = (*p2-*p).normalise();
114 a_point n = cross(d2,d1).normalise();
117 a_point d = (*p2-*p).normalise();
118 a_point * pn =
new a_point(cross(n,d).normalise());
119 normals.push_back(pn);
120 for (
int i=1; i<npts-1; i++)
122 a_point * p1 = intrados[i-1];
123 a_point * p = intrados[i];
124 a_point * p2 = intrados[i+1];
125 a_point d1 = (*p-*p1).normalise();
126 a_point d2 = (*p2-*p).normalise();
127 a_point d = (d1+d2)/2.;
128 a_point * pn =
new a_point(cross(n,d).normalise());
129 normals.push_back(pn);
131 p1 = intrados[intrados.size()-2];
132 p = intrados[intrados.size()-1];
133 d = (*p-*p1).normalise();
134 pn =
new a_point(cross(n,d).normalise());
135 normals.push_back(pn);
136 std::cout <<
"#created by pt2arch!" << std::endl;
137 std::cout <<
"#*********************************************" << std::endl;
138 std::cout <<
"#define structure" << std::endl;
139 std::cout <<
"a_structure " << name << std::endl;
140 for (
int i = 0; i < npts-1; i++)
142 std::cout <<
"#define block: " << i << std::endl;
143 a_point p1 = *intrados[i];
144 a_point p2 = *intrados[i+1];
145 a_point d1 = *normals[i];
146 a_point d2 = *normals[i+1];
147 std::cout <<
"a_point p" << i <<
"_0 " << p1+d1*us << std::endl;
148 std::cout <<
"a_point p" << i <<
"_1 " << p1+d1*ui << std::endl;
149 std::cout <<
"a_point p" << i <<
"_2 " << p2+d2*ui << std::endl;
150 std::cout <<
"a_point p" << i <<
"_3 " << p2+d2*us << std::endl;
151 std::cout <<
"a_block_2d4 b" << i;
152 std::cout <<
" p" << i <<
"_0";
153 std::cout <<
" p" << i <<
"_1";
154 std::cout <<
" p" << i <<
"_2";
155 std::cout <<
" p" << i <<
"_3" << std::endl;
156 std::cout <<
"b" << i <<
" thickness " << depth << std::endl;
157 std::cout << name <<
" add_block b" << i << std::endl;
159 std::cout <<
"#link blocks" << std::endl;
160 for (
int i = 0; i < npts-2; i++)
161 std::cout << name <<
" link_blocks " << i <<
" 2 " << i+1 <<
" 0" << std::endl;
162 std::cout <<
"#exit faces" << std::endl;
163 std::cout <<
"b0 exit 0" << std::endl;
164 std::cout <<
"b" << npts-2 <<
" exit 2" << std::endl;
165 std::cout <<
"#*********************************************" << std::endl;
166 std::cout <<
"#* edit the following lines to suit your needs" << std::endl;
167 std::cout <<
"#*********************************************" << std::endl;
168 std::cout <<
"set base_face 0" << std::endl;
169 std::cout <<
"a_material mat" << std::endl;
170 std::cout <<
" mat ref 1" << std::endl;
171 std::cout <<
" mat name edit_name" << std::endl;
172 std::cout <<
" mat density 1." << std::endl;
173 std::cout <<
"s material mat" << std::endl;
174 std::cout <<
"a_fcriteria_in c" << std::endl;
175 std::cout <<
" c max 1." << std::endl;
176 std::cout <<
"s criteria c" << std::endl;
177 std::cout <<
"#*********************************************" << std::endl;
178 for(std::vector<a_point *>::iterator it = intrados.begin(); it != intrados.end(); ++it)
delete *it;
179 for(std::vector<a_point *>::iterator it = normals.begin(); it != normals.end(); ++it)
delete *it;
int main(int argc, char *argv[])
CSimpleOpt::SOption g_rgOptions[]