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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
|
@q pntrvcf0.web @>
@q * Copyright and License.@>
@q This file is part of GNU 3DLDF, a package for three-dimensional drawing. @>
@q Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @>
@q 2011, 2012, 2013 The Free Software Foundation @>
@q GNU 3DLDF is free software; you can redistribute it and/or modify @>
@q it under the terms of the GNU General Public License as published by @>
@q the Free Software Foundation; either version 3 of the License, or @>
@q (at your option) any later version. @>
@q GNU 3DLDF is distributed in the hope that it will be useful, @>
@q but WITHOUT ANY WARRANTY; without even the implied warranty of @>
@q MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @>
@q GNU General Public License for more details. @>
@q You should have received a copy of the GNU General Public License @>
@q along with GNU 3DLDF; if not, write to the Free Software @>
@q Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @>
@q GNU 3DLDF is a GNU package. @>
@q It is part of the GNU Project of the @>
@q Free Software Foundation @>
@q and is published under the GNU General Public License. @>
@q See the website http://www.gnu.org @>
@q for more information. @>
@q GNU 3DLDF is available for downloading from @>
@q http://www.gnu.org/software/3dldf/LDF.html. @>
@q (``@@'' stands for a single at-sign in the following paragraph.) @>
@q Please send bug reports to Laurence.Finston@@gmx.de @>
@q The mailing list help-3dldf@@gnu.org is available for people to @>
@q ask other users for help. @>
@q The mailing list info-3dldf@@gnu.org is for sending @>
@q announcements to users. To subscribe to these mailing lists, send an @>
@q email with ``subscribe <email-address>'' as the subject. @>
@q The author can be contacted at: @>
@q Laurence D. Finston @>
@q c/o Free Software Foundation, Inc. @>
@q 51 Franklin St, Fifth Floor @>
@q Boston, MA 02110-1301 @>
@q USA @>
@q Laurence.Finston@@gmx.de (@@ stands for a single ``at'' sign.)@>
@q * (0) Additional |struct Pointer_Vector| Functions.@>
@** Additional {\bf struct Pointer\_Vector} functions
\quad ({\tt pntrvcf0\PERIOD web}).\hfil
\LOG
\initials{LDF 2007.07.27.}
Created this file. It contains code for |struct Pointer_Vector| functions
that require completely defined types which are unavailable in
\filename{pntrvctr.web}.
\ENDLOG
\immediate\write\functexifile{File: pntrvcf0.web^^J}
@q * (1) Include files.@>
@* Include files.
@<Include files@>=
#include "loader.h++"
#ifdef __GNUC__
#include <getopt.h>
#endif
#include "pspglb.h++"
#include "io.h++"
#include "gsltmplt.h++"
#include "creatnew.h++"
#include "pntrvctr.h++"
#include "primes.h++"
#include "complex.h++"
#include "matrices.h++"
#include "colors.h++"
#include "transfor.h++"
#include "pens.h++"
#include "dashptrn.h++"
#include "shapes.h++"
#include "pictures.h++"
#include "points.h++"
#include "lines.h++"
#include "planes.h++"
#include "nurbs.h++"
#include "paths.h++"
#include "curves.h++"
#include "polygons.h++"
#include "triangle.h++"
#include "rectangs.h++"
#include "conicsct.h++"
#include "ellipses.h++"
#include "circles.h++"
#include "ellpsslc.h++"
#include "crclslc.h++"
#include "parabola.h++"
#include "hyprbola.h++"
#include "cncsctlt.h++"
#include "arc.h++"
#include "helices.h++"
#include "origami.h++"
#if 0
#include "patterns.h++"
#endif
#include "solids.h++"
#include "solfaced.h++"
#include "cuboid.h++"
#include "polyhed.h++"
#include "ddchdrn.h++"
#include "rhtchdrn.h++"
#include "plyhdslc.h++"
#include "cones.h++"
#include "cylinder.h++"
#include "ellpsoid.h++"
#include "spheres.h++"
#include "sphrdevl.h++"
#include "parabold.h++"
#include "paraellp.h++"
#include "parahypr.h++"
#include "glyphs.h++"
#include "pctfncs0.h++"
#include "utility.h++"
@q * (1) Rectify.@>
@* Rectify.
\initials{LDF 2007.07.27.}
\LOG
\initials{LDF 2007.07.27.}
Added this function.
\initials{LDF 2007.07.29.}
Finished writing this function. It seems to work correctly now.
\initials{LDF 2007.08.06.}
Added optional |Transform* transform| argument. The default is 0.
\initials{LDF 2007.08.06.}
Added optional |bool do_transform| argument. The default is |true|.
\ENDLOG
@q ** (2) Definition.@>
@
@<Define |Pointer_Vector| specializations@>=
template<>
int
Pointer_Vector<Point, Point>::rectify(Scanner_Node scanner_node,
bool do_test,
bool do_cull,
bool do_transform,
real tolerance,
Transform* transform,
Point* p)
{
@q *** (3) Preliminaries.@>
#if DEBUG_COMPILE
bool DEBUG = false; /* |true| */ @;
#endif /* |DEBUG_COMPILE| */@;
stringstream cerr_strm;
bool error_stop_value = true;
bool warning_stop_value = true;
string thread_name = "";
if (scanner_node)
scanner_node->get_thread_name_and_stop_values(&thread_name,
&error_stop_value,
&warning_stop_value);
using namespace Scan_Parse;
@q *** (3)@>
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name
<< "Entering `Pointer_Vector::rectify'.";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
@q *** (3)@>
int status;
if (do_cull)
{
@q **** (4)@>
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name << "In `Pointer_Vector::rectify':"
<< endl
<< "`do_cull' is `true'. Calling `Pointer_Vector::cull'.";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
@q **** (4)@>
status = cull(Sorting::SORTING_EQUAL,
tolerance,
scanner_node,
p);
@q **** (4)@>
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name << "In `Pointer_Vector::rectify':"
<< endl
<< "`Pointer_Vector::cull' returned " << status
<< ".";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
@q **** (4)@>
} /* |if (do_cull)| */
@q *** (3)@>
else /* |!do_cull| */
{
@q **** (4)@>
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name << "In `Pointer_Vector::rectify':"
<< endl
<< "`do_cull' == `false'. Not calling `Pointer_Vector::cull'.";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
@q **** (4)@>
} /* |else| (|!do_cull|) */
@q *** (3) Error handling: Fewer than three |Points| on the |vector|.@>
@ Error handling: Fewer than three |Points| on the |vector|.
\initials{LDF 2007.07.27.}
@<Define |Pointer_Vector| specializations@>=
if (ctr < 3)
{
cerr_strm << thread_name << "ERROR! In `Pointer_Vector::rectify':"
<< endl
<< "`ctr' < 3. Cannot determine a plane for rectification."
<< endl
<< "Exiting function unsuccessfully with return value 1.";
log_message(cerr_strm);
cerr_message(cerr_strm, error_stop_value);
cerr_strm.str("");
return 1;
} /* |if (ctr < 3)| */
@q *** (3)@>
@
@<Define |Pointer_Vector| specializations@>=
Path q;
q += *(v[0]);
q += *(v[1]);
q += *(v[2]);
Plane w = q.get_plane();
@q *** (3)@>
@
@<Define |Pointer_Vector| specializations@>=
if (do_test)
{
for (int i = 3; i < ctr; ++i)
{
if (!(*v[i]).is_on_plane(w, tolerance))
{
cerr_strm << thread_name << "WARNING! "
<< "In `Pointer_Vector<Point, Point>::rectify':"
<< endl
<< "`Points' are not all coplanar. Can't rectify "
<< "`Point_Vector<Point>'."
<< endl
<< "Exiting function unsuccessfully with return value 1.";
log_message(cerr_strm);
cerr_message(cerr_strm, warning_stop_value);
cerr_strm.str("");
return 1;
} /* |if| */
} /* |for| */
} /* |if (do_test)| */
@q *** (3)@>
@
@<Define |Pointer_Vector| specializations@>=
Point normal = q.get_normal();
normal.shift(*(v[0]));
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_mutex.lock();
q.show("q:");
normal.show("normal:");
cerr_mutex.unlock();
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
Transform t;
t.align_with_axis(*(v[0]), normal, 'y');
for (vector<Point*>::iterator iter = v.begin();
iter != v.end();
++iter)
{
**iter *= t;
}
@q *** (3)@>
@
\LOG
\initials{LDF 2007.08.19.}
Added error handling code for the case that |i <= 1|.
\ENDLOG
@<Define |Pointer_Vector| specializations@>=
Point approx_center(0, 0, 0);
{
int i = 0;
real curr_max_value = (MAX_REAL / 4) * 3;
for (; i < ctr; ++i)
{
approx_center += *(v[i]);
if ( approx_center.get_x() > curr_max_value
|| approx_center.get_y() > curr_max_value
|| approx_center.get_z() > curr_max_value)
{
break;
}
} /* |for| */
if (i > 1)
approx_center /= i;
else
{
cerr_strm << "ERROR! In `Pointer_Vector<Point, Point>::rectify':"
<< endl
<< "Error setting `approx_center', "
<< "`i' <= i (`i' == " << i << ")"
<< endl
<< "Exiting function unsuccessfully with return value 1.";
log_message(cerr_strm);
cerr_message(cerr_strm, warning_stop_value);
cerr_strm.str("");
approx_center = INVALID_POINT;
return 1;
} /* |else| (|i <= 1|) */
} /* End of group */
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_mutex.lock();
approx_center.show("approx_center before shift:");
cerr_mutex.unlock();
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
Transform u;
u *= approx_center.shift(-approx_center);
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_mutex.lock();
approx_center.show("approx_center after shift:");
cerr_mutex.unlock();
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
t *= u;
for (vector<Point*>::iterator iter = v.begin();
iter != v.end();
++iter)
{
**iter *= u;
}
if (do_transform && transform != static_cast<Transform*>(0))
*transform = t;
@q *** (3)@>
@
@<Define |Pointer_Vector| specializations@>=
vector<Point*> northeast;
vector<Point*> northwest;
vector<Point*> southeast;
vector<Point*> southwest;
for (vector<Point*>::const_iterator iter = v.begin();
iter != v.end();
++iter)
{
if ((**iter).get_x() >= 0 && (**iter).get_z() >= 0)
northeast.push_back(*iter);
else if ((**iter).get_x() < 0 && (**iter).get_z() >= 0)
northwest.push_back(*iter);
else if ((**iter).get_x() < 0 && (**iter).get_z() < 0)
southwest.push_back(*iter);
else if ((**iter).get_x() >= 0 && (**iter).get_z() < 0)
southeast.push_back(*iter);
} /* |for| */
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_mutex.lock();
cerr << "Showing `northeast':" << endl;
for (vector<Point*>::const_iterator iter = northeast.begin();
iter != northeast.end();
++iter)
(**iter).show();
cerr << "Showing `northwest':" << endl;
for (vector<Point*>::const_iterator iter = northwest.begin();
iter != northwest.end();
++iter)
(**iter).show();
cerr << "Showing `southwest':" << endl;
for (vector<Point*>::const_iterator iter = southwest.begin();
iter != southwest.end();
++iter)
(**iter).show();
cerr << "Showing `southeast':" << endl;
for (vector<Point*>::const_iterator iter = southeast.begin();
iter != southeast.end();
++iter)
(**iter).show();
cerr_mutex.unlock();
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
Point pos_x_axis_point(1, 0, 0);
Point neg_x_axis_point(-1, 0, 0);
Compare_Angles cmp_ang_pos(&ORIGIN, &pos_x_axis_point);
Compare_Angles cmp_ang_neg(&ORIGIN, &neg_x_axis_point);
sort(northeast.begin(), northeast.end(), cmp_ang_pos);
sort(northwest.begin(), northwest.end(), cmp_ang_neg);
sort(southwest.rbegin(), southwest.rend(), cmp_ang_neg);
sort(southeast.rbegin(), southeast.rend(), cmp_ang_pos);
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_mutex.lock();
cerr << "After sorting:\nShowing `northeast':" << endl;
for (vector<Point*>::const_iterator iter = northeast.begin();
iter != northeast.end();
++iter)
(**iter).show();
cerr << "Showing `northwest':" << endl;
for (vector<Point*>::const_iterator iter = northwest.begin();
iter != northwest.end();
++iter)
(**iter).show();
cerr << "Showing `southwest':" << endl;
for (vector<Point*>::const_iterator iter = southwest.begin();
iter != southwest.end();
++iter)
(**iter).show();
cerr << "Showing `southeast':" << endl;
for (vector<Point*>::const_iterator iter = southeast.begin();
iter != southeast.end();
++iter)
(**iter).show();
cerr_mutex.unlock();
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
{
int i = 0;
t.inverse(true);
for (vector<Point*>::const_iterator iter = northeast.begin();
iter != northeast.end();
++iter)
{
**iter *= t;
v[i++] = *iter;
}
for (vector<Point*>::reverse_iterator iter = northwest.rbegin();
iter != northwest.rend();
++iter)
{
**iter *= t;
v[i++] = *iter;
}
for (vector<Point*>::reverse_iterator iter = southwest.rbegin();
iter != southwest.rend();
++iter)
{
**iter *= t;
v[i++] = *iter;
}
for (vector<Point*>::const_iterator iter = southeast.begin();
iter != southeast.end();
++iter)
{
**iter *= t;
v[i++] = *iter;
}
} /* End of group */
@q *** (3)@>
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name
<< "Exiting `Pointer_Vector::rectify' "
<< "successfully with return value 0.";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
return 0;
} /* End of |Pointer_Vector<Point, Point>::rectify| definition. */
@q *** (3)@>
@q ** (2)@>
@q * (1) Get |Conic_Section_Lattice|.@>
@* Get |Conic_Section_Lattice|.
\initials{LDF 2007.07.29.}
\LOG
\initials{LDF 2007.07.29.}
Added this function.
\initials{LDF 2007.08.06.}
Finished writing this function.
\ENDLOG
@q ** (2) Definition.@>
@<Define |Pointer_Vector| specializations@>=
template<>
Conic_Section_Lattice*
Pointer_Vector<Point, Point>::get_conic_section_lattice(
Scanner_Node scanner_node,
bool do_cull,
bool do_rectify,
real tolerance,
bool do_test,
bool do_transform,
Transform* t)
{
@q *** (3) Preliminaries.@>
#if DEBUG_COMPILE
bool DEBUG = false; /* |true| */ @;
#endif /* |DEBUG_COMPILE| */@;
stringstream cerr_strm;
bool error_stop_value = true;
bool warning_stop_value = true;
string thread_name = "";
if (scanner_node)
scanner_node->get_thread_name_and_stop_values(&thread_name,
&error_stop_value,
&warning_stop_value);
using namespace Scan_Parse;
@q *** (3)@>
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name
<< "Entering `Pointer_Vector::get_conic_section_lattice'.";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
@q *** (3)@>
int status;
if ((do_test && v.size() < 6) || (!do_test && v.size() < 5))
{
cerr_strm << thread_name
<< "ERROR! Pointer_Vector::get_conic_section_lattice':"
<< endl
<< "`Pointer_Vector<Point>' has too few points: "
<< v.size()
<< endl
<< "At least 6 are required if testing the points and "
<< "at least 5 if not."
<< endl
<< "Exiting function unsuccessfully with return value 0.";
log_message(cerr_strm);
cerr_message(cerr_strm, error_stop_value);
cerr_strm.str("");
return 0;
} /* |if ((do_test && v.size() < 6) || (!do_test && v.size() < 5))| */
@q *** (3)@>
#if 0
cerr_mutex.lock();
cerr << "In `Pointer_Vector::get_conic_section_lattice':" << endl;
show("Before rectification:");
cerr_mutex.unlock();
#endif
if (do_transform && t == static_cast<Transform*>(0))
t = create_new<Transform>(0);
status = rectify(scanner_node,
do_test,
do_cull,
do_transform,
tolerance,
t,
static_cast<Point*>(0));
#if 0
cerr_mutex.lock();
show("After rectification:");
cerr_mutex.unlock();
#endif
@q *** (3) Error handling: |rectify| returned a non-null value.@>
@ Error handling: |rectify| returned a non-null value.
\initials{LDF 2007.08.06.}
@<Define |Pointer_Vector| specializations@>=
if (status != 0)
{
cerr_strm << thread_name << "ERROR! "
<< "In `Pointer_Vector::get_conic_section_lattice':"
<< endl
<< "`rectify' returned " << status
<< "Exiting function unsuccessfully with return value 0.";
log_message(cerr_strm);
cerr_message(cerr_strm, error_stop_value);
cerr_strm.str("");
delete t;
t = 0;
return 0;
} /* |if (status != 0)| */
@q *** (3) Test points.@>
@ Test points.
\initials{LDF 2007.08.06.}
@<Define |Pointer_Vector| specializations@>=
if (do_test)
{
bool ignore_extra_points = true;
bool b = Conic_Section::are_on_conic_section(
this,
static_cast<void*>(scanner_node),
tolerance,
0,
ignore_extra_points);
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name
<< "In `Pointer_Vector::get_conic_section_lattice':"
<< endl
<< "`Conic_Section::are_on_conic_section' returned " << b;
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
@q *** (3) Error handling: |Conic_Section::are_on_conic_section| @>
@q *** (3)returned |false|. @>
@ Error handling: |Conic_Section::are_on_conic_section|
returned |false|.
\initials{LDF 2007.08.06.}
@<Define |Pointer_Vector| specializations@>=
if (b == false)
{
cerr_strm << thread_name
<< "ERROR! In `Pointer_Vector::get_conic_section_lattice':"
<< endl
<< "`Conic_Section::are_on_conic_section' returned `false'."
<< endl
<< "Can't generate curve. Exiting function with return value 0.";
log_message(cerr_strm);
cerr_message(cerr_strm, error_stop_value);
cerr_strm.str("");
return 0;
} /* |if (b == false)| */
} /* |if (test_points)| */
@q *** (3)@>
@
@<Define |Pointer_Vector| specializations@>=
Conic_Section_Lattice* c
= create_new<Conic_Section_Lattice>(0, scanner_node);
c->transform = t;
for (int i = 4; i >= 0; --i)
{
c->lattice_points[i] = *(v[i]);
c->lattice.push_back(&(c->lattice_points[i]));
}
if (do_test && v.size() >= 6)
{
c->pt6 = *(v[5]);
}
else
c->pt6 = INVALID_POINT;
@q *** (3) Set |approx_center|.@>
@ Set |approx_center|.
\initials{LDF 2007.08.16.}
\LOG
\initials{LDF 2007.08.16.}
Added this section.
\initials{LDF 2007.08.19.}
Now throwing |Bad_Assignment_Type| if the loop that's supposed to set
|Point approx_center| fails.
\ENDLOG
@<Define |Pointer_Vector| specializations@>=
{ /* Beginning of group. */
Bad_Assignment_Type bad_assignment;
c->approx_center = *(v[0]);
int i;
try
{
for (i = 1; i < 6; ++i)
{
if ( c->approx_center.get_x() + v[i]->get_x() <= MAX_REAL
&& c->approx_center.get_y() + v[i]->get_y() <= MAX_REAL
&& c->approx_center.get_z() + v[i]->get_z() <= MAX_REAL
&& c->approx_center.get_w() + v[i]->get_w() <= MAX_REAL)
c->approx_center += *(v[i]);
else
break;
} /* |for| */
if (i > 1)
c->approx_center /= i + 1;
else
throw bad_assignment;
} /* |try| */
catch (...)
{
cerr_strm << thread_name << "WARNING!"
<< endl
<< "In `Pointer_Vector::get_conic_section_lattice':"
<< endl
<< "Failed to set `approx_center'.";
log_message(cerr_strm);
cerr_message(cerr_strm, warning_stop_value);
cerr_strm.str("");
c->approx_center = INVALID_POINT;
} /* |catch| */
} /* End of group. */
@q *** (3)@>
@
@<Define |Pointer_Vector| specializations@>=
#if DEBUG_COMPILE
if (DEBUG)
{
cerr_strm << thread_name
<< "Exiting `Pointer_Vector::get_conic_section_lattice'.";
log_message(cerr_strm);
cerr_message(cerr_strm);
cerr_strm.str("");
} /* |if (DEBUG)| */
#endif /* |DEBUG_COMPILE| */@;
return c;
} /* End of |Pointer_Vector<Point, Point>::get_conic_section_lattice|
definition. */
@q * (1) Putting additional |struct Pointer_Vector| functions together.@>
@* Putting additional {\bf struct Pointer\_Vector} functions together.
\immediate\write\functexifile{^^JEnd of file: pntrvcf0.web^^J}
@q ** This is what's compiled.@>
@ This is what's compiled.
@c
@<Include files@>@;
@<Define |Pointer_Vector| specializations@>@;
@q ** This is what's written to \filename{pntrvcf0.h}.@>
@ This is what's written to the \filename{pntrvcf0.h}.
@(pntrvcf0.h@>=
/* Nothing */
@q * Emacs-Lisp code for use in indirect buffers when using the @>
@q GNU Emacs editor. The local variable list is not evaluated when an @>
@q indirect buffer is visited, so it's necessary to evaluate the @>
@q following s-expression in order to use the facilities normally @>
@q accessed via the local variables list. @>
@q \initials{LDF 2004.02.12}. @>
@q (progn (cweb-mode) (outline-minor-mode t)) @>
@q * Local variables for Emacs.@>
@q Local Variables: @>
@q mode:CWEB @>
@q eval:(display-time) @>
@q run-cweave-on-file:"3DLDFprg.web" @>
@q eval:(read-abbrev-file) @>
@q indent-tabs-mode:nil @>
@q eval:(outline-minor-mode) @>
@q fill-column:80 @>
@q End: @>
|