19 aref_tran.pass(
new absref_transmit(
qpt +
qsl,
aref));
23 mfunname(
"polyline::polyline( polyline &pl)");
27 mfunname(
"polyline::polyline(const polyline &pl)");
31 mfunname(
"polyline::polyline(const point* fpt, int fqpt)");
36 mfunname(
"polyline::polyline(const point& fpt1, const point& fpt2)");
44 mfunname(
"polyline& polyline::operator=(const polyline& fpl)");
51 pvecerror(
"void polyline::polyline_init(const point* fpt, int fqpt)");
66 for (
int n = 0; n <
qpt; ++n)
68 for (
int n = 0; n <
qsl; ++n)
80 pvecerror(
"int polyline::check_point_in(point& fpt, vfloat prec)");
81 for (
int n = 0; n <
qpt; ++n) {
82 if (
apeq(
pt[n], fpt, prec))
return 1;
84 for (
int n = 0; n <
qsl; ++n) {
87 vec v2 = fpt -
pt[n + 1];
88 if (check_par(v1, v2, prec) == -1) {
98 int& qpl,
vfloat prec)
const {
99 pvecerror(
"void polyline::cross(const straight& fsl, ...)");
102 for (
int n = 0; n <
qsl; ++n) {
103 pc[qpc] =
sl[n].
cross(fsl, prec);
111 vec v1 = pc[qpc] -
pt[n];
112 if (length(v1) < prec) {
115 vec v2 = pc[qpc] -
pt[n + 1];
116 if (length(v2) < prec) {
118 }
else if (check_par(v1, v2, prec) == -1) {
125 if (qpc > 0 || qpl > 0)
return 1;
130 pvecerror(
"vfloat polyline::dist_two_inter(polyline& pl)");
137 if (type_of_cross == 2 || type_of_cross == 3)
return sldist;
151 pvecerror(
"vfloat polyline::distance(const point& fpt) const");
157 for (n = 0; n <
qsl; n++) {
159 vec v1 = cpt -
pt[n];
160 vec v2 = cpt -
pt[n + 1];
161 if (check_par(v1, v2, 0.01) ==
163 if (sldist < mx) mx = sldist;
165 if ((sldist = length(fpt -
pt[n])) < mx) mx = sldist;
166 if ((sldist = length(fpt -
pt[n + 1])) < mx) mx = sldist;
173 pvecerror(
"vfloat polyline::distance(const point& fpt) const");
179 for (n = 0; n <
qsl; n++) {
181 vec v1 = cpt -
pt[n];
182 vec v2 = cpt -
pt[n + 1];
183 if (check_par(v1, v2, 0.01) ==
190 if ((sldist = length(fpt -
pt[n])) < mx) {
194 if ((sldist = length(fpt -
pt[n + 1])) < mx) {
206 "int cross4pllines(const polyline pl[4], straight& sl, point ptc[4][2])");
209 for (n = 0; n < 4; n++)
210 slpl[n] = pl[n].Gsl(0);
212 pt[0] = (pl[1].
Gpt(0).
v + pl[1].
Gpt(1).
v) * 0.5;
213 pt[1] = (pl[2].
Gpt(0).
v + pl[2].
Gpt(1).
v) * 0.5;
216 for (n = 0; n < 4; n++) {
217 sl.
distance(pl[n].Gsl(0), type_of_cross, ptc[n]);
219 if (pl[n].check_point_in(ptc[n][1], precision) == 0)
227 Ifile <<
"polyline:\n";
230 for (n = 0; n < p.
qpt; n++)
233 for (n = 0; n < p.
qsl; n++)
247 mfunname(
"polyline_pl::polyline_pl( polyline& pl)");
249 mcerr <<
"error in polyline_pl(polyline& pl): qsl=" <<
Gqsl();
257 mfunname(
"polyline_pl::polyline_pl(const polyline& pl");
259 mcerr <<
"error in polyline_pl(polyline& pl): qsl=" <<
Gqsl();
267 mfunname(
"polyline_pl& polyline_pl::operator=(const polyline_pl& fpl)");
275 Ifile <<
"polyline_pl:\n";
287 pvecerror(
"polygon::polygon(const straight* fsl, int fqsl)");
294 for (n = 0; n < fqsl - 1; n++)
295 for (m = n + 1; m < fqsl; m++) {
296 if (fsl[n].Gpiv() == fsl[m].Gpiv())
297 if (check_par(fsl[n].Gdir(), fsl[m].Gdir(), 0) !=
300 mcerr <<
"error in polyline_init(straight* fsl, int fqsl):\n"
301 <<
"Parallel lines with the same pivot cannot form polygin\n";
302 for (
int k = 0; k < fqsl; k++)
303 mcout <<
"n=" << k <<
" fsl[n]=" << fsl[k];
309 for (n = 1; n < fqsl; n++) {
310 ptl[n] = fsl[n - 1].
cross(fsl[n], prec);
312 mcerr <<
"error in polygon::polygon(straight* fsl, int fqsl):\n"
313 <<
" straight lines are not crossed properly\n"
314 <<
"fsl[n-1]=" << fsl[n - 1] <<
"fsl[n]=" << fsl[n]
319 ptl[0] = fsl[fqsl - 1].
cross(fsl[0], prec);
321 mcerr <<
"error in polygon::polygon(straight* fsl, int fqsl):\n"
322 <<
" straight lines are not crossed properly\n"
323 <<
"fsl[fqsl-1]=" << fsl[fqsl - 1] <<
"fsl[0]=" << fsl[0]
328 plane pnl =
plane(fsl[0].Gpiv(), fsl[0].Gdir() || fsl[1].Gdir());
337 mfunname(
"polygon& polygon::operator=(const polygon& fpl)");
346 pvecerror(
"int polygon::check_point_in(point& fpt)");
369 for (n = 0; n <
qpt - 1; n++) {
376 ang2 = 2 * M_PI - ang;
381 if (
fabs(totang) > 6.0)
return 3;
386 pvecerror(
"point polygon::cross(straight& fsl)");
401 pvecerror(
"int polygon::range(const point& fpt, const vec& dir, vfloat& rng, "
410 const int i = check_par(dif, dir, prec);
420 Ifile <<
"polygon:\n";
439 pvecerror(
"rectangle::rectangle(point fpiv, vec fdir[2], vfloat fdim[2], "
441 if (check_perp(fdir[0], fdir[1], prec) != 1) {
442 mcerr <<
"rectangle::rectangle(point fpiv, vec fdir[2], vfloat fdim[2]):\n"
443 <<
" error: sides are not perpendicular\n";
448 mcerr <<
"fdir[2](directions of sides):\n" << fdir[0] << fdir[1];
451 if (fdim[0] <= 0 || fdim[1] <= 0) {
452 mcerr <<
"rectangle::rectangle(point fpiv, vec fdir[2], vfloat fdim[2]):\n"
453 <<
" error: fdim[0] <=0 || fdim[1] <=0\n";
454 mcerr <<
"fdim (dimensions):" << fdim[0] <<
' ' << fdim[1] <<
'\n';
455 mcerr <<
"fdir[2](directions of sides):\n" << fdir[0] << fdir[1];
459 dir1 = unit_vec(fdir[0]);
460 dir2 = unit_vec(fdir[1]);
475 Ifile <<
"rectangle:\n";
478 Ifile <<
"dir1,2(directions of sides):\n" << f.
dir1 << f.
dir2;
479 Ifile <<
"dim (dimensions):" << f.
dim[0] <<
' ' << f.
dim[1] <<
'\n';
499 rv.
turn(axis, angle);
524 :
polygon(), piv(fpiv), dir1(unit_vec(fdir1)), dir2(unit_vec(fdir2)) {
531 *
this =
spquadr(fpiv, sl1, sl2, fdir1, fdir2, plgn);
535 Ifile <<
"spquadr:\n";
DoubleAc fabs(const DoubleAc &f)
#define check_econd11(a, signb, stream)
#define check_econd11a(a, signb, add, stream)
point cross(const straight &sl) const
int check_point_in(const point &fp, vfloat prec) const
int range(const point &fpt, const vec &dir, vfloat &rng, point &fptenr, vfloat prec) const
int check_point_in(const point &fpt, vfloat prec) const
polygon & operator=(const polygon &fpl)
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
polyline_pl & operator=(const polyline_pl &fpl)
static absrefabsref::* aref_pl
polyline & operator=(const polyline &fpl)
void polyline_init(const point *fpt, int fqpt)
straight Gsl(int n) const
vfloat dist_two_inter(polyline &pl, vfloat prec) const
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
friend int plane::cross(const polyline &pll, point *crpt, int &qcrpt, polyline *crpll, int &qcrpll, vfloat prec) const
int check_point_in(const point &fpt, vfloat prec) const
vfloat distance(const point &fpt) const
static absrefabsref::*[4] aref_rct
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
point pt_angle_rad(vfloat rad, vfloat angle)
static absrefabsref::*[4] aref_sp
point cross(const straight &sl, vfloat prec) const
vfloat distance(const straight &sl, int &type_of_cross, point pt[2]) const
void turn(const vec &dir, vfloat angle)
#define statcast(type, name)
int apeq(const circumf &f1, const circumf &f2, vfloat prec)
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
int cross4pllines(const polyline pl[4], vfloat precision, straight &sl, point ptc[4][2])
vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
#define pvecerror(string)