Commit a8a1f8d3 authored by lode_leroy's avatar lode_leroy

initial import

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@3 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 02ce3527
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
pycam - CNC Toolpath Generation in python
=========================================
Copyright (C) 2008 Lode Leroy
-----------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
See COPYING
......@@ -48,6 +48,9 @@ For visualization, install
TODO:
* Python code
** clean up module/package use, being all "import" statements
* Geometry
** intersect_torus_line
-> try to find a better implementation
......
solid box0
facet normal -0.000000 0.000000 1.000000
outer loop
vertex -4.961088 -4.824490 4.188777
vertex -0.772311 -0.635713 4.188777
vertex -4.961088 -0.635713 4.188777
endloop
endfacet
facet normal -0.000000 0.000000 1.000000
outer loop
vertex -4.961088 -4.824490 4.188777
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -0.635713 4.188777
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -0.772311 -4.824490 0.000000
vertex -4.961088 -0.635713 0.000000
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -0.772311 -4.824490 0.000000
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal 1.000000 -0.000000 0.000000
outer loop
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -0.635713 0.000000
vertex -0.772311 -0.635713 4.188777
endloop
endfacet
facet normal 1.000000 -0.000000 0.000000
outer loop
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -4.824490 0.000000
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -0.635713 4.188777
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -4.824490 4.188777
vertex -4.961088 -0.635713 4.188777
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -4.961088 -0.635713 4.188777
vertex -0.772311 -0.635713 0.000000
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -4.961088 -0.635713 4.188777
vertex -0.772311 -0.635713 4.188777
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -0.772311 -4.824490 4.188777
vertex -4.961088 -4.824490 4.188777
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -0.772311 -4.824490 0.000000
vertex -0.772311 -4.824490 4.188777
endloop
endfacet
endsolid box0
solid box1
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 2.563112 -5.599983 2.267282
vertex 5.339321 -3.997340 0.000022
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 5.339321 -3.997340 0.000022
vertex 5.339006 -0.790934 2.266127
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213384 -3.997869 0.000000
vertex -0.213699 -0.791464 2.266105
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562510 0.811179 -0.001155
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 2.562824 -2.395226 -2.267260
vertex 2.562510 0.811179 -0.001155
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 5.339321 -3.997340 0.000022
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562797 -2.393577 4.533387
vertex -0.213699 -0.791464 2.266105
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.563112 -5.599983 2.267282
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 5.339006 -0.790934 2.266127
vertex 2.562510 0.811179 -0.001155
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562797 -2.393577 4.533387
vertex 5.339006 -0.790934 2.266127
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 5.339321 -3.997340 0.000022
vertex 2.563112 -5.599983 2.267282
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562824 -2.395226 -2.267260
vertex 5.339321 -3.997340 0.000022
endloop
endfacet
endsolid box1
solid box0
facet normal -0.000000 0.000000 1.000000
outer loop
vertex -4.961088 -4.824490 4.188777
vertex -0.772311 -0.635713 4.188777
vertex -4.961088 -0.635713 4.188777
endloop
endfacet
facet normal -0.000000 0.000000 1.000000
outer loop
vertex -4.961088 -4.824490 4.188777
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -0.635713 4.188777
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -0.772311 -4.824490 0.000000
vertex -4.961088 -0.635713 0.000000
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -0.772311 -4.824490 0.000000
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal 1.000000 -0.000000 0.000000
outer loop
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -0.635713 0.000000
vertex -0.772311 -0.635713 4.188777
endloop
endfacet
facet normal 1.000000 -0.000000 0.000000
outer loop
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -4.824490 0.000000
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -0.635713 4.188777
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -4.824490 4.188777
vertex -4.961088 -0.635713 4.188777
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -4.961088 -0.635713 4.188777
vertex -0.772311 -0.635713 0.000000
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -4.961088 -0.635713 4.188777
vertex -0.772311 -0.635713 4.188777
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -0.772311 -4.824490 4.188777
vertex -4.961088 -4.824490 4.188777
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -0.772311 -4.824490 0.000000
vertex -0.772311 -4.824490 4.188777
endloop
endfacet
endsolid box0
solid box1
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 2.563112 -5.599983 2.267282
vertex 5.339321 -3.997340 0.000022
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 5.339321 -3.997340 0.000022
vertex 5.339006 -0.790934 2.266127
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213384 -3.997869 0.000000
vertex -0.213699 -0.791464 2.266105
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562510 0.811179 -0.001155
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 2.562824 -2.395226 -2.267260
vertex 2.562510 0.811179 -0.001155
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 5.339321 -3.997340 0.000022
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562797 -2.393577 4.533387
vertex -0.213699 -0.791464 2.266105
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.563112 -5.599983 2.267282
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 5.339006 -0.790934 2.266127
vertex 2.562510 0.811179 -0.001155
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562797 -2.393577 4.533387
vertex 5.339006 -0.790934 2.266127
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 5.339321 -3.997340 0.000022
vertex 2.563112 -5.599983 2.267282
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562824 -2.395226 -2.267260
vertex 5.339321 -3.997340 0.000022
endloop
endfacet
endsolid box1
solid box0
facet normal -0.000000 0.000000 1.000000
outer loop
vertex -4.961088 -4.824490 4.188777
vertex -0.772311 -0.635713 4.188777
vertex -4.961088 -0.635713 4.188777
endloop
endfacet
facet normal -0.000000 0.000000 1.000000
outer loop
vertex -4.961088 -4.824490 4.188777
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -0.635713 4.188777
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -0.772311 -4.824490 0.000000
vertex -4.961088 -0.635713 0.000000
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -0.772311 -4.824490 0.000000
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal 1.000000 -0.000000 0.000000
outer loop
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -0.635713 0.000000
vertex -0.772311 -0.635713 4.188777
endloop
endfacet
facet normal 1.000000 -0.000000 0.000000
outer loop
vertex -0.772311 -4.824490 4.188777
vertex -0.772311 -4.824490 0.000000
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -0.635713 4.188777
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -4.961088 -4.824490 4.188777
vertex -4.961088 -0.635713 4.188777
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -4.961088 -0.635713 4.188777
vertex -0.772311 -0.635713 0.000000
vertex -4.961088 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -4.961088 -0.635713 4.188777
vertex -0.772311 -0.635713 4.188777
vertex -0.772311 -0.635713 0.000000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -0.772311 -4.824490 4.188777
vertex -4.961088 -4.824490 4.188777
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -4.961088 -4.824490 0.000000
vertex -0.772311 -4.824490 0.000000
vertex -0.772311 -4.824490 4.188777
endloop
endfacet
endsolid box0
solid box1
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 2.563112 -5.599983 2.267282
vertex 5.339321 -3.997340 0.000022
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal 0.707143 -0.408041 0.577452
outer loop
vertex 5.339321 -3.997340 0.000022
vertex 5.339006 -0.790934 2.266127
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213384 -3.997869 0.000000
vertex -0.213699 -0.791464 2.266105
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal -0.707143 0.408041 -0.577452
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562510 0.811179 -0.001155
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 2.562824 -2.395226 -2.267260
vertex 2.562510 0.811179 -0.001155
endloop
endfacet
facet normal 0.707070 0.408176 -0.577446
outer loop
vertex 5.339006 -0.790934 2.266127
vertex 5.339321 -3.997340 0.000022
vertex 2.562824 -2.395226 -2.267260
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562797 -2.393577 4.533387
vertex -0.213699 -0.791464 2.266105
endloop
endfacet
facet normal -0.707070 -0.408176 0.577446
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.563112 -5.599983 2.267282
vertex 2.562797 -2.393577 4.533387
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 5.339006 -0.790934 2.266127
vertex 2.562510 0.811179 -0.001155
endloop
endfacet
facet normal -0.000080 0.816637 0.577152
outer loop
vertex -0.213699 -0.791464 2.266105
vertex 2.562797 -2.393577 4.533387
vertex 5.339006 -0.790934 2.266127
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 5.339321 -3.997340 0.000022
vertex 2.563112 -5.599983 2.267282
endloop
endfacet
facet normal 0.000080 -0.816637 -0.577152
outer loop
vertex -0.213384 -3.997869 0.000000
vertex 2.562824 -2.395226 -2.267260
vertex 5.339321 -3.997340 0.000022
endloop
endfacet
endsolid box1
solid sphere0
facet normal 0.191480 -0.962637 -0.191480
outer loop
vertex -0.363256 -0.020265 -0.978284
vertex 0.615028 -0.020265 0.000000
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal -0.191480 -0.962637 -0.191480
outer loop
vertex -1.341540 -0.020265 0.000000
vertex -0.363256 -0.020265 -0.978284
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal -0.191480 -0.962637 0.191480
outer loop
vertex -0.363256 -0.020265 0.978284
vertex -1.341540 -0.020265 0.000000
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal 0.191480 -0.962637 0.191480
outer loop
vertex 0.615028 -0.020265 0.000000
vertex -0.363256 -0.020265 0.978284
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal 0.541419 -0.810291 -0.224263
outer loop
vertex 0.914933 0.533888 -1.278189
vertex 1.444376 0.533888 0.000000
vertex 0.615028 -0.020265 0.000000
endloop
endfacet
facet normal 0.314507 -0.895640 -0.314507
outer loop
vertex 0.914933 0.533888 -1.278189
vertex 0.615028 -0.020265 0.000000
vertex -0.363256 -0.020265 -0.978284
endloop
endfacet
facet normal 0.224263 -0.810291 -0.541419
outer loop
vertex -0.363256 0.533888 -1.807632
vertex 0.914933 0.533888 -1.278189
vertex -0.363256 -0.020265 -0.978284
endloop
endfacet
facet normal -0.224263 -0.810291 -0.541419
outer loop
vertex -1.641445 0.533888 -1.278189
vertex -0.363256 0.533888 -1.807632
vertex -0.363256 -0.020265 -0.978284
endloop
endfacet
facet normal -0.314507 -0.895640 -0.314507
outer loop
vertex -1.641445 0.533888 -1.278189
vertex -0.363256 -0.020265 -0.978284
vertex -1.341540 -0.020265 0.000000
endloop
endfacet
facet normal -0.541419 -0.810291 -0.224263
outer loop
vertex -2.170888 0.533888 0.000000
vertex -1.641445 0.533888 -1.278189
vertex -1.341540 -0.020265 0.000000
endloop
endfacet
facet normal -0.541419 -0.810291 0.224263
outer loop
vertex -1.641445 0.533888 1.278189
vertex -2.170888 0.533888 0.000000
vertex -1.341540 -0.020265 0.000000
endloop
endfacet
facet normal -0.314507 -0.895640 0.314507
outer loop
vertex -1.641445 0.533888 1.278189
vertex -1.341540 -0.020265 0.000000
vertex -0.363256 -0.020265 0.978284
endloop
endfacet
facet normal -0.224263 -0.810291 0.541419
outer loop
vertex -0.363256 0.533888 1.807632
vertex -1.641445 0.533888 1.278189
vertex -0.363256 -0.020265 0.978284
endloop
endfacet
facet normal 0.224263 -0.810291 0.541419
outer loop
vertex 0.914933 0.533888 1.278189
vertex -0.363256 0.533888 1.807632
vertex -0.363256 -0.020265 0.978284
endloop
endfacet
facet normal 0.314507 -0.895640 0.314507
outer loop
vertex 0.914933 0.533888 1.278189
vertex -0.363256 -0.020265 0.978284
vertex 0.615028 -0.020265 0.000000
endloop
endfacet
facet normal 0.541419 -0.810291 0.224263
outer loop
vertex 1.444376 0.533888 0.000000
vertex 0.914933 0.533888 1.278189
vertex 0.615028 -0.020265 0.000000
endloop
endfacet
facet normal 0.811572 -0.542275 -0.217460
outer loop
vertex 1.682110 1.363236 -1.180893
vertex 1.998529 1.363236 0.000000
vertex 1.444376 0.533888 0.000000
endloop
endfacet
facet normal 0.718010 -0.629293 -0.297409
outer loop
vertex 1.682110 1.363236 -1.180893
vertex 1.444376 0.533888 0.000000
vertex 0.914933 0.533888 -1.278189
endloop
endfacet
facet normal 0.614016 -0.495952 -0.614016
outer loop
vertex 0.817637 1.363236 -2.045366
vertex 1.682110 1.363236 -1.180893
vertex 0.914933 0.533888 -1.278189
endloop
endfacet
facet normal 0.297409 -0.629293 -0.718010
outer loop
vertex 0.817637 1.363236 -2.045366
vertex 0.914933 0.533888 -1.278189
vertex -0.363256 0.533888 -1.807632
endloop
endfacet
facet normal 0.217460 -0.542275 -0.811572
outer loop
vertex -0.363256 1.363236 -2.361785
vertex 0.817637 1.363236 -2.045366
vertex -0.363256 0.533888 -1.807632
endloop
endfacet
facet normal -0.217460 -0.542275 -0.811572
outer loop
vertex -1.544149 1.363236 -2.045366
vertex -0.363256 1.363236 -2.361785
vertex -0.363256 0.533888 -1.807632
endloop
endfacet
facet normal -0.297409 -0.629293 -0.718010
outer loop
vertex -1.544149 1.363236 -2.045366
vertex -0.363256 0.533888 -1.807632
vertex -1.641445 0.533888 -1.278189
endloop
endfacet
facet normal -0.614016 -0.495952 -0.614016
outer loop
vertex -2.408622 1.363236 -1.180893
vertex -1.544149 1.363236 -2.045366
vertex -1.641445 0.533888 -1.278189
endloop
endfacet
facet normal -0.718010 -0.629293 -0.297409
outer loop
vertex -2.408622 1.363236 -1.180893
vertex -1.641445 0.533888 -1.278189
vertex -2.170888 0.533888 0.000000
endloop
endfacet
facet normal -0.811572 -0.542275 -0.217460
outer loop
vertex -2.725041 1.363236 0.000000
vertex -2.408622 1.363236 -1.180893
vertex -2.170888 0.533888 0.000000
endloop
endfacet
facet normal -0.811572 -0.542275 0.217460
outer loop
vertex -2.408622 1.363236 1.180893
vertex -2.725041 1.363236 0.000000
vertex -2.170888 0.533888 0.000000
endloop
endfacet
facet normal -0.718010 -0.629293 0.297409
outer loop
vertex -2.408622 1.363236 1.180893
vertex -2.170888 0.533888 0.000000
vertex -1.641445 0.533888 1.278189
endloop
endfacet
facet normal -0.614016 -0.495952 0.614016
outer loop
vertex -1.544149 1.363236 2.045366
vertex -2.408622 1.363236 1.180893
vertex -1.641445 0.533888 1.278189
endloop
endfacet
facet normal -0.297409 -0.629293 0.718010
outer loop
vertex -1.544149 1.363236 2.045366
vertex -1.641445 0.533888 1.278189
vertex -0.363256 0.533888 1.807632
endloop
endfacet
facet normal -0.217460 -0.542275 0.811572
outer loop
vertex -0.363256 1.363236 2.361785
vertex -1.544149 1.363236 2.045366
vertex -0.363256 0.533888 1.807632
endloop
endfacet
facet normal 0.217460 -0.542275 0.811572
outer loop
vertex 0.817637 1.363236 2.045366
vertex -0.363256 1.363236 2.361785
vertex -0.363256 0.533888 1.807632
endloop
endfacet
facet normal 0.297409 -0.629293 0.718010
outer loop
vertex 0.817637 1.363236 2.045366
vertex -0.363256 0.533888 1.807632
vertex 0.914933 0.533888 1.278189
endloop
endfacet
facet normal 0.614016 -0.495952 0.614016
outer loop
vertex 1.682110 1.363236 1.180893
vertex 0.817637 1.363236 2.045366
vertex 0.914933 0.533888 1.278189
endloop
endfacet
facet normal 0.718010 -0.629293 0.297409
outer loop
vertex 1.682110 1.363236 1.180893
vertex 0.914933 0.533888 1.278189
vertex 1.444376 0.533888 0.000000
endloop
endfacet
facet normal 0.811572 -0.542275 0.217460
outer loop
vertex 1.998529 1.363236 0.000000
vertex 1.682110 1.363236 1.180893
vertex 1.444376 0.533888 0.000000
endloop
endfacet
facet normal 0.962637 -0.191480 -0.191480
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 2.193122 2.341520 0.000000
vertex 1.998529 1.363236 0.000000
endloop
endfacet
facet normal 0.935113 -0.250563 -0.250563
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 1.998529 1.363236 0.000000
vertex 1.682110 1.363236 -1.180893
endloop
endfacet
facet normal 0.821798 -0.152081 -0.549108
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 1.998529 2.341520 -0.978284
vertex 1.682110 1.363236 -1.180893
endloop
endfacet
facet normal 0.680710 -0.270678 -0.680710
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 1.682110 1.363236 -1.180893
vertex 0.817637 1.363236 -2.045366
endloop
endfacet
facet normal 0.549108 -0.152081 -0.821798
outer loop
vertex 0.615028 2.341520 -2.361785
vertex 1.444376 2.341520 -1.807632
vertex 0.817637 1.363236 -2.045366
endloop
endfacet
facet normal 0.250563 -0.250563 -0.935113
outer loop
vertex 0.615028 2.341520 -2.361785
vertex 0.817637 1.363236 -2.045366
vertex -0.363256 1.363236 -2.361785
endloop
endfacet
facet normal 0.191480 -0.191480 -0.962637
outer loop
vertex -0.363256 2.341520 -2.556378
vertex 0.615028 2.341520 -2.361785
vertex -0.363256 1.363236 -2.361785
endloop
endfacet
facet normal -0.191480 -0.191480 -0.962637
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -0.363256 2.341520 -2.556378
vertex -0.363256 1.363236 -2.361785
endloop
endfacet
facet normal -0.250563 -0.250563 -0.935113
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -0.363256 1.363236 -2.361785
vertex -1.544149 1.363236 -2.045366
endloop
endfacet
facet normal -0.549108 -0.152081 -0.821798
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -1.341540 2.341520 -2.361785
vertex -1.544149 1.363236 -2.045366
endloop
endfacet
facet normal -0.680710 -0.270678 -0.680710
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -1.544149 1.363236 -2.045366
vertex -2.408622 1.363236 -1.180893
endloop
endfacet
facet normal -0.821798 -0.152081 -0.549108
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.170888 2.341520 -1.807632
vertex -2.408622 1.363236 -1.180893
endloop
endfacet
facet normal -0.935113 -0.250563 -0.250563
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.408622 1.363236 -1.180893
vertex -2.725041 1.363236 0.000000
endloop
endfacet
facet normal -0.962637 -0.191480 -0.191480
outer loop
vertex -2.919634 2.341520 0.000000
vertex -2.725041 2.341520 -0.978284
vertex -2.725041 1.363236 0.000000
endloop
endfacet
facet normal -0.962637 -0.191480 0.191480
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.919634 2.341520 0.000000
vertex -2.725041 1.363236 0.000000
endloop
endfacet
facet normal -0.935113 -0.250563 0.250563
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.725041 1.363236 0.000000
vertex -2.408622 1.363236 1.180893
endloop
endfacet
facet normal -0.821798 -0.152081 0.549108
outer loop
vertex -2.170888 2.341520 1.807632
vertex -2.725041 2.341520 0.978284
vertex -2.408622 1.363236 1.180893
endloop
endfacet
facet normal -0.680710 -0.270678 0.680710
outer loop
vertex -2.170888 2.341520 1.807632
vertex -2.408622 1.363236 1.180893
vertex -1.544149 1.363236 2.045366
endloop
endfacet
facet normal -0.549108 -0.152081 0.821798
outer loop
vertex -1.341540 2.341520 2.361785
vertex -2.170888 2.341520 1.807632
vertex -1.544149 1.363236 2.045366
endloop
endfacet
facet normal -0.250563 -0.250563 0.935113
outer loop
vertex -1.341540 2.341520 2.361785
vertex -1.544149 1.363236 2.045366
vertex -0.363256 1.363236 2.361785
endloop
endfacet
facet normal -0.191480 -0.191480 0.962637
outer loop
vertex -0.363256 2.341520 2.556378
vertex -1.341540 2.341520 2.361785
vertex -0.363256 1.363236 2.361785
endloop
endfacet
facet normal 0.191480 -0.191480 0.962637
outer loop
vertex 0.615028 2.341520 2.361785
vertex -0.363256 2.341520 2.556378
vertex -0.363256 1.363236 2.361785
endloop
endfacet
facet normal 0.250563 -0.250563 0.935113
outer loop
vertex 0.615028 2.341520 2.361785
vertex -0.363256 1.363236 2.361785
vertex 0.817637 1.363236 2.045366
endloop
endfacet
facet normal 0.549108 -0.152081 0.821798
outer loop
vertex 1.444376 2.341520 1.807632
vertex 0.615028 2.341520 2.361785
vertex 0.817637 1.363236 2.045366
endloop
endfacet
facet normal 0.680710 -0.270678 0.680710
outer loop
vertex 1.444376 2.341520 1.807632
vertex 0.817637 1.363236 2.045366
vertex 1.682110 1.363236 1.180893
endloop
endfacet
facet normal 0.821798 -0.152081 0.549108
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.444376 2.341520 1.807632
vertex 1.682110 1.363236 1.180893
endloop
endfacet
facet normal 0.935113 -0.250563 0.250563
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.682110 1.363236 1.180893
vertex 1.998529 1.363236 0.000000
endloop
endfacet
facet normal 0.962637 -0.191480 0.191480
outer loop
vertex 2.193122 2.341520 0.000000
vertex 1.998529 2.341520 0.978284
vertex 1.998529 1.363236 0.000000
endloop
endfacet
facet normal 0.962637 0.191480 -0.191480
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 1.998529 3.319804 0.000000
vertex 2.193122 2.341520 0.000000
endloop
endfacet
facet normal 0.935113 0.250563 -0.250563
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 1.682110 3.319804 -1.180893
vertex 1.998529 3.319804 0.000000
endloop
endfacet
facet normal 0.821798 0.152081 -0.549108
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 1.682110 3.319804 -1.180893
vertex 1.998529 2.341520 -0.978284
endloop
endfacet
facet normal 0.680710 0.270678 -0.680710
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 0.817637 3.319804 -2.045366
vertex 1.682110 3.319804 -1.180893
endloop
endfacet
facet normal 0.549108 0.152081 -0.821798
outer loop
vertex 0.615028 2.341520 -2.361785
vertex 0.817637 3.319804 -2.045366
vertex 1.444376 2.341520 -1.807632
endloop
endfacet
facet normal 0.250563 0.250563 -0.935113
outer loop
vertex 0.615028 2.341520 -2.361785
vertex -0.363256 3.319804 -2.361785
vertex 0.817637 3.319804 -2.045366
endloop
endfacet
facet normal 0.191480 0.191480 -0.962637
outer loop
vertex -0.363256 2.341520 -2.556378
vertex -0.363256 3.319804 -2.361785
vertex 0.615028 2.341520 -2.361785
endloop
endfacet
facet normal -0.191480 0.191480 -0.962637
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -0.363256 3.319804 -2.361785
vertex -0.363256 2.341520 -2.556378
endloop
endfacet
facet normal -0.250563 0.250563 -0.935113
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -1.544149 3.319804 -2.045366
vertex -0.363256 3.319804 -2.361785
endloop
endfacet
facet normal -0.549108 0.152081 -0.821798
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -1.544149 3.319804 -2.045366
vertex -1.341540 2.341520 -2.361785
endloop
endfacet
facet normal -0.680710 0.270678 -0.680710
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -2.408622 3.319804 -1.180893
vertex -1.544149 3.319804 -2.045366
endloop
endfacet
facet normal -0.821798 0.152081 -0.549108
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.408622 3.319804 -1.180893
vertex -2.170888 2.341520 -1.807632
endloop
endfacet
facet normal -0.935113 0.250563 -0.250563
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.725041 3.319804 0.000000
vertex -2.408622 3.319804 -1.180893
endloop
endfacet
facet normal -0.962637 0.191480 -0.191480
outer loop
vertex -2.919634 2.341520 0.000000
vertex -2.725041 3.319804 0.000000
vertex -2.725041 2.341520 -0.978284
endloop
endfacet
facet normal -0.962637 0.191480 0.191480
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.725041 3.319804 0.000000
vertex -2.919634 2.341520 0.000000
endloop
endfacet
facet normal -0.935113 0.250563 0.250563
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.408622 3.319804 1.180893
vertex -2.725041 3.319804 0.000000
endloop
endfacet
facet normal -0.821798 0.152081 0.549108
outer loop
vertex -2.170888 2.341520 1.807632
vertex -2.408622 3.319804 1.180893
vertex -2.725041 2.341520 0.978284
endloop
endfacet
facet normal -0.680710 0.270678 0.680710
outer loop
vertex -2.170888 2.341520 1.807632
vertex -1.544149 3.319804 2.045366
vertex -2.408622 3.319804 1.180893
endloop
endfacet
facet normal -0.549108 0.152081 0.821798
outer loop
vertex -1.341540 2.341520 2.361785
vertex -1.544149 3.319804 2.045366
vertex -2.170888 2.341520 1.807632
endloop
endfacet
facet normal -0.250563 0.250563 0.935113
outer loop
vertex -1.341540 2.341520 2.361785
vertex -0.363256 3.319804 2.361785
vertex -1.544149 3.319804 2.045366
endloop
endfacet
facet normal -0.191480 0.191480 0.962637
outer loop
vertex -0.363256 2.341520 2.556378
vertex -0.363256 3.319804 2.361785
vertex -1.341540 2.341520 2.361785
endloop
endfacet
facet normal 0.191480 0.191480 0.962637
outer loop
vertex 0.615028 2.341520 2.361785
vertex -0.363256 3.319804 2.361785
vertex -0.363256 2.341520 2.556378
endloop
endfacet
facet normal 0.250563 0.250563 0.935113
outer loop
vertex 0.615028 2.341520 2.361785
vertex 0.817637 3.319804 2.045366
vertex -0.363256 3.319804 2.361785
endloop
endfacet
facet normal 0.549108 0.152081 0.821798
outer loop
vertex 1.444376 2.341520 1.807632
vertex 0.817637 3.319804 2.045366
vertex 0.615028 2.341520 2.361785
endloop
endfacet
facet normal 0.680710 0.270678 0.680710
outer loop
vertex 1.444376 2.341520 1.807632
vertex 1.682110 3.319804 1.180893
vertex 0.817637 3.319804 2.045366
endloop
endfacet
facet normal 0.821798 0.152081 0.549108
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.682110 3.319804 1.180893
vertex 1.444376 2.341520 1.807632
endloop
endfacet
facet normal 0.935113 0.250563 0.250563
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.998529 3.319804 0.000000
vertex 1.682110 3.319804 1.180893
endloop
endfacet
facet normal 0.962637 0.191480 0.191480
outer loop
vertex 2.193122 2.341520 0.000000
vertex 1.998529 3.319804 0.000000
vertex 1.998529 2.341520 0.978284
endloop
endfacet
facet normal 0.811572 0.542275 -0.217460
outer loop
vertex 1.682110 3.319804 -1.180893
vertex 1.444376 4.149152 0.000000
vertex 1.998529 3.319804 0.000000
endloop
endfacet
facet normal 0.718010 0.629293 -0.297409
outer loop
vertex 1.682110 3.319804 -1.180893
vertex 0.914933 4.149152 -1.278189
vertex 1.444376 4.149152 0.000000
endloop
endfacet
facet normal 0.614016 0.495952 -0.614016
outer loop
vertex 0.817637 3.319804 -2.045366
vertex 0.914933 4.149152 -1.278189
vertex 1.682110 3.319804 -1.180893
endloop
endfacet
facet normal 0.297409 0.629293 -0.718010
outer loop
vertex 0.817637 3.319804 -2.045366
vertex -0.363256 4.149152 -1.807632
vertex 0.914933 4.149152 -1.278189
endloop
endfacet
facet normal 0.217460 0.542275 -0.811572
outer loop
vertex -0.363256 3.319804 -2.361785
vertex -0.363256 4.149152 -1.807632
vertex 0.817637 3.319804 -2.045366
endloop
endfacet
facet normal -0.217460 0.542275 -0.811572
outer loop
vertex -1.544149 3.319804 -2.045366
vertex -0.363256 4.149152 -1.807632
vertex -0.363256 3.319804 -2.361785
endloop
endfacet
facet normal -0.297409 0.629293 -0.718010
outer loop
vertex -1.544149 3.319804 -2.045366
vertex -1.641445 4.149152 -1.278189
vertex -0.363256 4.149152 -1.807632
endloop
endfacet
facet normal -0.614016 0.495952 -0.614016
outer loop
vertex -2.408622 3.319804 -1.180893
vertex -1.641445 4.149152 -1.278189
vertex -1.544149 3.319804 -2.045366
endloop
endfacet
facet normal -0.718010 0.629293 -0.297409
outer loop
vertex -2.408622 3.319804 -1.180893
vertex -2.170888 4.149152 0.000000
vertex -1.641445 4.149152 -1.278189
endloop
endfacet
facet normal -0.811572 0.542275 -0.217460
outer loop
vertex -2.725041 3.319804 0.000000
vertex -2.170888 4.149152 0.000000
vertex -2.408622 3.319804 -1.180893
endloop
endfacet
facet normal -0.811572 0.542275 0.217460
outer loop
vertex -2.408622 3.319804 1.180893
vertex -2.170888 4.149152 0.000000
vertex -2.725041 3.319804 0.000000
endloop
endfacet
facet normal -0.718010 0.629293 0.297409
outer loop
vertex -2.408622 3.319804 1.180893
vertex -1.641445 4.149152 1.278189
vertex -2.170888 4.149152 0.000000
endloop
endfacet
facet normal -0.614016 0.495952 0.614016
outer loop
vertex -1.544149 3.319804 2.045366
vertex -1.641445 4.149152 1.278189
vertex -2.408622 3.319804 1.180893
endloop
endfacet
facet normal -0.297409 0.629293 0.718010
outer loop
vertex -1.544149 3.319804 2.045366
vertex -0.363256 4.149152 1.807632
vertex -1.641445 4.149152 1.278189
endloop
endfacet
facet normal -0.217460 0.542275 0.811572
outer loop
vertex -0.363256 3.319804 2.361785
vertex -0.363256 4.149152 1.807632
vertex -1.544149 3.319804 2.045366
endloop
endfacet
facet normal 0.217460 0.542275 0.811572
outer loop
vertex 0.817637 3.319804 2.045366
vertex -0.363256 4.149152 1.807632
vertex -0.363256 3.319804 2.361785
endloop
endfacet
facet normal 0.297409 0.629293 0.718010
outer loop
vertex 0.817637 3.319804 2.045366
vertex 0.914933 4.149152 1.278189
vertex -0.363256 4.149152 1.807632
endloop
endfacet
facet normal 0.614016 0.495952 0.614016
outer loop
vertex 1.682110 3.319804 1.180893
vertex 0.914933 4.149152 1.278189
vertex 0.817637 3.319804 2.045366
endloop
endfacet
facet normal 0.718010 0.629293 0.297409
outer loop
vertex 1.682110 3.319804 1.180893
vertex 1.444376 4.149152 0.000000
vertex 0.914933 4.149152 1.278189
endloop
endfacet
facet normal 0.811572 0.542275 0.217460
outer loop
vertex 1.998529 3.319804 0.000000
vertex 1.444376 4.149152 0.000000
vertex 1.682110 3.319804 1.180893
endloop
endfacet
facet normal 0.541419 0.810291 -0.224263
outer loop
vertex 0.914933 4.149152 -1.278189
vertex 0.615028 4.703305 0.000000
vertex 1.444376 4.149152 0.000000
endloop
endfacet
facet normal 0.314507 0.895640 -0.314507
outer loop
vertex 0.914933 4.149152 -1.278189
vertex -0.363256 4.703305 -0.978284
vertex 0.615028 4.703305 0.000000
endloop
endfacet
facet normal 0.224263 0.810291 -0.541419
outer loop
vertex -0.363256 4.149152 -1.807632
vertex -0.363256 4.703305 -0.978284
vertex 0.914933 4.149152 -1.278189
endloop
endfacet
facet normal -0.224263 0.810291 -0.541419
outer loop
vertex -1.641445 4.149152 -1.278189
vertex -0.363256 4.703305 -0.978284
vertex -0.363256 4.149152 -1.807632
endloop
endfacet
facet normal -0.314507 0.895640 -0.314507
outer loop
vertex -1.641445 4.149152 -1.278189
vertex -1.341540 4.703305 0.000000
vertex -0.363256 4.703305 -0.978284
endloop
endfacet
facet normal -0.541419 0.810291 -0.224263
outer loop
vertex -2.170888 4.149152 0.000000
vertex -1.341540 4.703305 0.000000
vertex -1.641445 4.149152 -1.278189
endloop
endfacet
facet normal -0.541419 0.810291 0.224263
outer loop
vertex -1.641445 4.149152 1.278189
vertex -1.341540 4.703305 0.000000
vertex -2.170888 4.149152 0.000000
endloop
endfacet
facet normal -0.314507 0.895640 0.314507
outer loop
vertex -1.641445 4.149152 1.278189
vertex -0.363256 4.703305 0.978284
vertex -1.341540 4.703305 0.000000
endloop
endfacet
facet normal -0.224263 0.810291 0.541419
outer loop
vertex -0.363256 4.149152 1.807632
vertex -0.363256 4.703305 0.978284
vertex -1.641445 4.149152 1.278189
endloop
endfacet
facet normal 0.224263 0.810291 0.541419
outer loop
vertex 0.914933 4.149152 1.278189
vertex -0.363256 4.703305 0.978284
vertex -0.363256 4.149152 1.807632
endloop
endfacet
facet normal 0.314507 0.895640 0.314507
outer loop
vertex 0.914933 4.149152 1.278189
vertex 0.615028 4.703305 0.000000
vertex -0.363256 4.703305 0.978284
endloop
endfacet
facet normal 0.541419 0.810291 0.224263
outer loop
vertex 1.444376 4.149152 0.000000
vertex 0.615028 4.703305 0.000000
vertex 0.914933 4.149152 1.278189
endloop
endfacet
facet normal 0.191480 0.962637 -0.191480
outer loop
vertex -0.363256 4.703305 -0.978284
vertex -0.363256 4.897898 0.000000
vertex 0.615028 4.703305 0.000000
endloop
endfacet
facet normal -0.191480 0.962637 -0.191480
outer loop
vertex -1.341540 4.703305 0.000000
vertex -0.363256 4.897898 0.000000
vertex -0.363256 4.703305 -0.978284
endloop
endfacet
facet normal -0.191480 0.962637 0.191480
outer loop
vertex -0.363256 4.703305 0.978284
vertex -0.363256 4.897898 0.000000
vertex -1.341540 4.703305 0.000000
endloop
endfacet
facet normal 0.191480 0.962637 0.191480
outer loop
vertex 0.615028 4.703305 0.000000
vertex -0.363256 4.897898 0.000000
vertex -0.363256 4.703305 0.978284
endloop
endfacet
endsolid sphere0
solid sphere0
facet normal 0.191480 -0.962637 -0.191480
outer loop
vertex -0.363256 -0.020265 -0.978284
vertex 0.615028 -0.020265 0.000000
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal -0.191480 -0.962637 -0.191480
outer loop
vertex -1.341540 -0.020265 0.000000
vertex -0.363256 -0.020265 -0.978284
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal -0.191480 -0.962637 0.191480
outer loop
vertex -0.363256 -0.020265 0.978284
vertex -1.341540 -0.020265 0.000000
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal 0.191480 -0.962637 0.191480
outer loop
vertex 0.615028 -0.020265 0.000000
vertex -0.363256 -0.020265 0.978284
vertex -0.363256 -0.214858 0.000000
endloop
endfacet
facet normal 0.541419 -0.810291 -0.224263
outer loop
vertex 0.914933 0.533888 -1.278189
vertex 1.444376 0.533888 0.000000
vertex 0.615028 -0.020265 0.000000
endloop
endfacet
facet normal 0.314507 -0.895640 -0.314507
outer loop
vertex 0.914933 0.533888 -1.278189
vertex 0.615028 -0.020265 0.000000
vertex -0.363256 -0.020265 -0.978284
endloop
endfacet
facet normal 0.224263 -0.810291 -0.541419
outer loop
vertex -0.363256 0.533888 -1.807632
vertex 0.914933 0.533888 -1.278189
vertex -0.363256 -0.020265 -0.978284
endloop
endfacet
facet normal -0.224263 -0.810291 -0.541419
outer loop
vertex -1.641445 0.533888 -1.278189
vertex -0.363256 0.533888 -1.807632
vertex -0.363256 -0.020265 -0.978284
endloop
endfacet
facet normal -0.314507 -0.895640 -0.314507
outer loop
vertex -1.641445 0.533888 -1.278189
vertex -0.363256 -0.020265 -0.978284
vertex -1.341540 -0.020265 0.000000
endloop
endfacet
facet normal -0.541419 -0.810291 -0.224263
outer loop
vertex -2.170888 0.533888 0.000000
vertex -1.641445 0.533888 -1.278189
vertex -1.341540 -0.020265 0.000000
endloop
endfacet
facet normal -0.541419 -0.810291 0.224263
outer loop
vertex -1.641445 0.533888 1.278189
vertex -2.170888 0.533888 0.000000
vertex -1.341540 -0.020265 0.000000
endloop
endfacet
facet normal -0.314507 -0.895640 0.314507
outer loop
vertex -1.641445 0.533888 1.278189
vertex -1.341540 -0.020265 0.000000
vertex -0.363256 -0.020265 0.978284
endloop
endfacet
facet normal -0.224263 -0.810291 0.541419
outer loop
vertex -0.363256 0.533888 1.807632
vertex -1.641445 0.533888 1.278189
vertex -0.363256 -0.020265 0.978284
endloop
endfacet
facet normal 0.224263 -0.810291 0.541419
outer loop
vertex 0.914933 0.533888 1.278189
vertex -0.363256 0.533888 1.807632
vertex -0.363256 -0.020265 0.978284
endloop
endfacet
facet normal 0.314507 -0.895640 0.314507
outer loop
vertex 0.914933 0.533888 1.278189
vertex -0.363256 -0.020265 0.978284
vertex 0.615028 -0.020265 0.000000
endloop
endfacet
facet normal 0.541419 -0.810291 0.224263
outer loop
vertex 1.444376 0.533888 0.000000
vertex 0.914933 0.533888 1.278189
vertex 0.615028 -0.020265 0.000000
endloop
endfacet
facet normal 0.811572 -0.542275 -0.217460
outer loop
vertex 1.682110 1.363236 -1.180893
vertex 1.998529 1.363236 0.000000
vertex 1.444376 0.533888 0.000000
endloop
endfacet
facet normal 0.718010 -0.629293 -0.297409
outer loop
vertex 1.682110 1.363236 -1.180893
vertex 1.444376 0.533888 0.000000
vertex 0.914933 0.533888 -1.278189
endloop
endfacet
facet normal 0.614016 -0.495952 -0.614016
outer loop
vertex 0.817637 1.363236 -2.045366
vertex 1.682110 1.363236 -1.180893
vertex 0.914933 0.533888 -1.278189
endloop
endfacet
facet normal 0.297409 -0.629293 -0.718010
outer loop
vertex 0.817637 1.363236 -2.045366
vertex 0.914933 0.533888 -1.278189
vertex -0.363256 0.533888 -1.807632
endloop
endfacet
facet normal 0.217460 -0.542275 -0.811572
outer loop
vertex -0.363256 1.363236 -2.361785
vertex 0.817637 1.363236 -2.045366
vertex -0.363256 0.533888 -1.807632
endloop
endfacet
facet normal -0.217460 -0.542275 -0.811572
outer loop
vertex -1.544149 1.363236 -2.045366
vertex -0.363256 1.363236 -2.361785
vertex -0.363256 0.533888 -1.807632
endloop
endfacet
facet normal -0.297409 -0.629293 -0.718010
outer loop
vertex -1.544149 1.363236 -2.045366
vertex -0.363256 0.533888 -1.807632
vertex -1.641445 0.533888 -1.278189
endloop
endfacet
facet normal -0.614016 -0.495952 -0.614016
outer loop
vertex -2.408622 1.363236 -1.180893
vertex -1.544149 1.363236 -2.045366
vertex -1.641445 0.533888 -1.278189
endloop
endfacet
facet normal -0.718010 -0.629293 -0.297409
outer loop
vertex -2.408622 1.363236 -1.180893
vertex -1.641445 0.533888 -1.278189
vertex -2.170888 0.533888 0.000000
endloop
endfacet
facet normal -0.811572 -0.542275 -0.217460
outer loop
vertex -2.725041 1.363236 0.000000
vertex -2.408622 1.363236 -1.180893
vertex -2.170888 0.533888 0.000000
endloop
endfacet
facet normal -0.811572 -0.542275 0.217460
outer loop
vertex -2.408622 1.363236 1.180893
vertex -2.725041 1.363236 0.000000
vertex -2.170888 0.533888 0.000000
endloop
endfacet
facet normal -0.718010 -0.629293 0.297409
outer loop
vertex -2.408622 1.363236 1.180893
vertex -2.170888 0.533888 0.000000
vertex -1.641445 0.533888 1.278189
endloop
endfacet
facet normal -0.614016 -0.495952 0.614016
outer loop
vertex -1.544149 1.363236 2.045366
vertex -2.408622 1.363236 1.180893
vertex -1.641445 0.533888 1.278189
endloop
endfacet
facet normal -0.297409 -0.629293 0.718010
outer loop
vertex -1.544149 1.363236 2.045366
vertex -1.641445 0.533888 1.278189
vertex -0.363256 0.533888 1.807632
endloop
endfacet
facet normal -0.217460 -0.542275 0.811572
outer loop
vertex -0.363256 1.363236 2.361785
vertex -1.544149 1.363236 2.045366
vertex -0.363256 0.533888 1.807632
endloop
endfacet
facet normal 0.217460 -0.542275 0.811572
outer loop
vertex 0.817637 1.363236 2.045366
vertex -0.363256 1.363236 2.361785
vertex -0.363256 0.533888 1.807632
endloop
endfacet
facet normal 0.297409 -0.629293 0.718010
outer loop
vertex 0.817637 1.363236 2.045366
vertex -0.363256 0.533888 1.807632
vertex 0.914933 0.533888 1.278189
endloop
endfacet
facet normal 0.614016 -0.495952 0.614016
outer loop
vertex 1.682110 1.363236 1.180893
vertex 0.817637 1.363236 2.045366
vertex 0.914933 0.533888 1.278189
endloop
endfacet
facet normal 0.718010 -0.629293 0.297409
outer loop
vertex 1.682110 1.363236 1.180893
vertex 0.914933 0.533888 1.278189
vertex 1.444376 0.533888 0.000000
endloop
endfacet
facet normal 0.811572 -0.542275 0.217460
outer loop
vertex 1.998529 1.363236 0.000000
vertex 1.682110 1.363236 1.180893
vertex 1.444376 0.533888 0.000000
endloop
endfacet
facet normal 0.962637 -0.191480 -0.191480
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 2.193122 2.341520 0.000000
vertex 1.998529 1.363236 0.000000
endloop
endfacet
facet normal 0.935113 -0.250563 -0.250563
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 1.998529 1.363236 0.000000
vertex 1.682110 1.363236 -1.180893
endloop
endfacet
facet normal 0.821798 -0.152081 -0.549108
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 1.998529 2.341520 -0.978284
vertex 1.682110 1.363236 -1.180893
endloop
endfacet
facet normal 0.680710 -0.270678 -0.680710
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 1.682110 1.363236 -1.180893
vertex 0.817637 1.363236 -2.045366
endloop
endfacet
facet normal 0.549108 -0.152081 -0.821798
outer loop
vertex 0.615028 2.341520 -2.361785
vertex 1.444376 2.341520 -1.807632
vertex 0.817637 1.363236 -2.045366
endloop
endfacet
facet normal 0.250563 -0.250563 -0.935113
outer loop
vertex 0.615028 2.341520 -2.361785
vertex 0.817637 1.363236 -2.045366
vertex -0.363256 1.363236 -2.361785
endloop
endfacet
facet normal 0.191480 -0.191480 -0.962637
outer loop
vertex -0.363256 2.341520 -2.556378
vertex 0.615028 2.341520 -2.361785
vertex -0.363256 1.363236 -2.361785
endloop
endfacet
facet normal -0.191480 -0.191480 -0.962637
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -0.363256 2.341520 -2.556378
vertex -0.363256 1.363236 -2.361785
endloop
endfacet
facet normal -0.250563 -0.250563 -0.935113
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -0.363256 1.363236 -2.361785
vertex -1.544149 1.363236 -2.045366
endloop
endfacet
facet normal -0.549108 -0.152081 -0.821798
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -1.341540 2.341520 -2.361785
vertex -1.544149 1.363236 -2.045366
endloop
endfacet
facet normal -0.680710 -0.270678 -0.680710
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -1.544149 1.363236 -2.045366
vertex -2.408622 1.363236 -1.180893
endloop
endfacet
facet normal -0.821798 -0.152081 -0.549108
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.170888 2.341520 -1.807632
vertex -2.408622 1.363236 -1.180893
endloop
endfacet
facet normal -0.935113 -0.250563 -0.250563
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.408622 1.363236 -1.180893
vertex -2.725041 1.363236 0.000000
endloop
endfacet
facet normal -0.962637 -0.191480 -0.191480
outer loop
vertex -2.919634 2.341520 0.000000
vertex -2.725041 2.341520 -0.978284
vertex -2.725041 1.363236 0.000000
endloop
endfacet
facet normal -0.962637 -0.191480 0.191480
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.919634 2.341520 0.000000
vertex -2.725041 1.363236 0.000000
endloop
endfacet
facet normal -0.935113 -0.250563 0.250563
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.725041 1.363236 0.000000
vertex -2.408622 1.363236 1.180893
endloop
endfacet
facet normal -0.821798 -0.152081 0.549108
outer loop
vertex -2.170888 2.341520 1.807632
vertex -2.725041 2.341520 0.978284
vertex -2.408622 1.363236 1.180893
endloop
endfacet
facet normal -0.680710 -0.270678 0.680710
outer loop
vertex -2.170888 2.341520 1.807632
vertex -2.408622 1.363236 1.180893
vertex -1.544149 1.363236 2.045366
endloop
endfacet
facet normal -0.549108 -0.152081 0.821798
outer loop
vertex -1.341540 2.341520 2.361785
vertex -2.170888 2.341520 1.807632
vertex -1.544149 1.363236 2.045366
endloop
endfacet
facet normal -0.250563 -0.250563 0.935113
outer loop
vertex -1.341540 2.341520 2.361785
vertex -1.544149 1.363236 2.045366
vertex -0.363256 1.363236 2.361785
endloop
endfacet
facet normal -0.191480 -0.191480 0.962637
outer loop
vertex -0.363256 2.341520 2.556378
vertex -1.341540 2.341520 2.361785
vertex -0.363256 1.363236 2.361785
endloop
endfacet
facet normal 0.191480 -0.191480 0.962637
outer loop
vertex 0.615028 2.341520 2.361785
vertex -0.363256 2.341520 2.556378
vertex -0.363256 1.363236 2.361785
endloop
endfacet
facet normal 0.250563 -0.250563 0.935113
outer loop
vertex 0.615028 2.341520 2.361785
vertex -0.363256 1.363236 2.361785
vertex 0.817637 1.363236 2.045366
endloop
endfacet
facet normal 0.549108 -0.152081 0.821798
outer loop
vertex 1.444376 2.341520 1.807632
vertex 0.615028 2.341520 2.361785
vertex 0.817637 1.363236 2.045366
endloop
endfacet
facet normal 0.680710 -0.270678 0.680710
outer loop
vertex 1.444376 2.341520 1.807632
vertex 0.817637 1.363236 2.045366
vertex 1.682110 1.363236 1.180893
endloop
endfacet
facet normal 0.821798 -0.152081 0.549108
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.444376 2.341520 1.807632
vertex 1.682110 1.363236 1.180893
endloop
endfacet
facet normal 0.935113 -0.250563 0.250563
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.682110 1.363236 1.180893
vertex 1.998529 1.363236 0.000000
endloop
endfacet
facet normal 0.962637 -0.191480 0.191480
outer loop
vertex 2.193122 2.341520 0.000000
vertex 1.998529 2.341520 0.978284
vertex 1.998529 1.363236 0.000000
endloop
endfacet
facet normal 0.962637 0.191480 -0.191480
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 1.998529 3.319804 0.000000
vertex 2.193122 2.341520 0.000000
endloop
endfacet
facet normal 0.935113 0.250563 -0.250563
outer loop
vertex 1.998529 2.341520 -0.978284
vertex 1.682110 3.319804 -1.180893
vertex 1.998529 3.319804 0.000000
endloop
endfacet
facet normal 0.821798 0.152081 -0.549108
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 1.682110 3.319804 -1.180893
vertex 1.998529 2.341520 -0.978284
endloop
endfacet
facet normal 0.680710 0.270678 -0.680710
outer loop
vertex 1.444376 2.341520 -1.807632
vertex 0.817637 3.319804 -2.045366
vertex 1.682110 3.319804 -1.180893
endloop
endfacet
facet normal 0.549108 0.152081 -0.821798
outer loop
vertex 0.615028 2.341520 -2.361785
vertex 0.817637 3.319804 -2.045366
vertex 1.444376 2.341520 -1.807632
endloop
endfacet
facet normal 0.250563 0.250563 -0.935113
outer loop
vertex 0.615028 2.341520 -2.361785
vertex -0.363256 3.319804 -2.361785
vertex 0.817637 3.319804 -2.045366
endloop
endfacet
facet normal 0.191480 0.191480 -0.962637
outer loop
vertex -0.363256 2.341520 -2.556378
vertex -0.363256 3.319804 -2.361785
vertex 0.615028 2.341520 -2.361785
endloop
endfacet
facet normal -0.191480 0.191480 -0.962637
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -0.363256 3.319804 -2.361785
vertex -0.363256 2.341520 -2.556378
endloop
endfacet
facet normal -0.250563 0.250563 -0.935113
outer loop
vertex -1.341540 2.341520 -2.361785
vertex -1.544149 3.319804 -2.045366
vertex -0.363256 3.319804 -2.361785
endloop
endfacet
facet normal -0.549108 0.152081 -0.821798
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -1.544149 3.319804 -2.045366
vertex -1.341540 2.341520 -2.361785
endloop
endfacet
facet normal -0.680710 0.270678 -0.680710
outer loop
vertex -2.170888 2.341520 -1.807632
vertex -2.408622 3.319804 -1.180893
vertex -1.544149 3.319804 -2.045366
endloop
endfacet
facet normal -0.821798 0.152081 -0.549108
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.408622 3.319804 -1.180893
vertex -2.170888 2.341520 -1.807632
endloop
endfacet
facet normal -0.935113 0.250563 -0.250563
outer loop
vertex -2.725041 2.341520 -0.978284
vertex -2.725041 3.319804 0.000000
vertex -2.408622 3.319804 -1.180893
endloop
endfacet
facet normal -0.962637 0.191480 -0.191480
outer loop
vertex -2.919634 2.341520 0.000000
vertex -2.725041 3.319804 0.000000
vertex -2.725041 2.341520 -0.978284
endloop
endfacet
facet normal -0.962637 0.191480 0.191480
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.725041 3.319804 0.000000
vertex -2.919634 2.341520 0.000000
endloop
endfacet
facet normal -0.935113 0.250563 0.250563
outer loop
vertex -2.725041 2.341520 0.978284
vertex -2.408622 3.319804 1.180893
vertex -2.725041 3.319804 0.000000
endloop
endfacet
facet normal -0.821798 0.152081 0.549108
outer loop
vertex -2.170888 2.341520 1.807632
vertex -2.408622 3.319804 1.180893
vertex -2.725041 2.341520 0.978284
endloop
endfacet
facet normal -0.680710 0.270678 0.680710
outer loop
vertex -2.170888 2.341520 1.807632
vertex -1.544149 3.319804 2.045366
vertex -2.408622 3.319804 1.180893
endloop
endfacet
facet normal -0.549108 0.152081 0.821798
outer loop
vertex -1.341540 2.341520 2.361785
vertex -1.544149 3.319804 2.045366
vertex -2.170888 2.341520 1.807632
endloop
endfacet
facet normal -0.250563 0.250563 0.935113
outer loop
vertex -1.341540 2.341520 2.361785
vertex -0.363256 3.319804 2.361785
vertex -1.544149 3.319804 2.045366
endloop
endfacet
facet normal -0.191480 0.191480 0.962637
outer loop
vertex -0.363256 2.341520 2.556378
vertex -0.363256 3.319804 2.361785
vertex -1.341540 2.341520 2.361785
endloop
endfacet
facet normal 0.191480 0.191480 0.962637
outer loop
vertex 0.615028 2.341520 2.361785
vertex -0.363256 3.319804 2.361785
vertex -0.363256 2.341520 2.556378
endloop
endfacet
facet normal 0.250563 0.250563 0.935113
outer loop
vertex 0.615028 2.341520 2.361785
vertex 0.817637 3.319804 2.045366
vertex -0.363256 3.319804 2.361785
endloop
endfacet
facet normal 0.549108 0.152081 0.821798
outer loop
vertex 1.444376 2.341520 1.807632
vertex 0.817637 3.319804 2.045366
vertex 0.615028 2.341520 2.361785
endloop
endfacet
facet normal 0.680710 0.270678 0.680710
outer loop
vertex 1.444376 2.341520 1.807632
vertex 1.682110 3.319804 1.180893
vertex 0.817637 3.319804 2.045366
endloop
endfacet
facet normal 0.821798 0.152081 0.549108
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.682110 3.319804 1.180893
vertex 1.444376 2.341520 1.807632
endloop
endfacet
facet normal 0.935113 0.250563 0.250563
outer loop
vertex 1.998529 2.341520 0.978284
vertex 1.998529 3.319804 0.000000
vertex 1.682110 3.319804 1.180893
endloop
endfacet
facet normal 0.962637 0.191480 0.191480
outer loop
vertex 2.193122 2.341520 0.000000
vertex 1.998529 3.319804 0.000000
vertex 1.998529 2.341520 0.978284
endloop
endfacet
facet normal 0.811572 0.542275 -0.217460
outer loop
vertex 1.682110 3.319804 -1.180893
vertex 1.444376 4.149152 0.000000
vertex 1.998529 3.319804 0.000000
endloop
endfacet
facet normal 0.718010 0.629293 -0.297409
outer loop
vertex 1.682110 3.319804 -1.180893
vertex 0.914933 4.149152 -1.278189
vertex 1.444376 4.149152 0.000000
endloop
endfacet
facet normal 0.614016 0.495952 -0.614016
outer loop
vertex 0.817637 3.319804 -2.045366
vertex 0.914933 4.149152 -1.278189
vertex 1.682110 3.319804 -1.180893
endloop
endfacet
facet normal 0.297409 0.629293 -0.718010
outer loop
vertex 0.817637 3.319804 -2.045366
vertex -0.363256 4.149152 -1.807632
vertex 0.914933 4.149152 -1.278189
endloop
endfacet
facet normal 0.217460 0.542275 -0.811572
outer loop
vertex -0.363256 3.319804 -2.361785
vertex -0.363256 4.149152 -1.807632
vertex 0.817637 3.319804 -2.045366
endloop
endfacet
facet normal -0.217460 0.542275 -0.811572
outer loop
vertex -1.544149 3.319804 -2.045366
vertex -0.363256 4.149152 -1.807632
vertex -0.363256 3.319804 -2.361785
endloop
endfacet
facet normal -0.297409 0.629293 -0.718010
outer loop
vertex -1.544149 3.319804 -2.045366
vertex -1.641445 4.149152 -1.278189
vertex -0.363256 4.149152 -1.807632
endloop
endfacet
facet normal -0.614016 0.495952 -0.614016
outer loop
vertex -2.408622 3.319804 -1.180893
vertex -1.641445 4.149152 -1.278189
vertex -1.544149 3.319804 -2.045366
endloop
endfacet
facet normal -0.718010 0.629293 -0.297409
outer loop
vertex -2.408622 3.319804 -1.180893
vertex -2.170888 4.149152 0.000000
vertex -1.641445 4.149152 -1.278189
endloop
endfacet
facet normal -0.811572 0.542275 -0.217460
outer loop
vertex -2.725041 3.319804 0.000000
vertex -2.170888 4.149152 0.000000
vertex -2.408622 3.319804 -1.180893
endloop
endfacet
facet normal -0.811572 0.542275 0.217460
outer loop
vertex -2.408622 3.319804 1.180893
vertex -2.170888 4.149152 0.000000
vertex -2.725041 3.319804 0.000000
endloop
endfacet
facet normal -0.718010 0.629293 0.297409
outer loop
vertex -2.408622 3.319804 1.180893
vertex -1.641445 4.149152 1.278189
vertex -2.170888 4.149152 0.000000
endloop
endfacet
facet normal -0.614016 0.495952 0.614016
outer loop
vertex -1.544149 3.319804 2.045366
vertex -1.641445 4.149152 1.278189
vertex -2.408622 3.319804 1.180893
endloop
endfacet
facet normal -0.297409 0.629293 0.718010
outer loop
vertex -1.544149 3.319804 2.045366
vertex -0.363256 4.149152 1.807632
vertex -1.641445 4.149152 1.278189
endloop
endfacet
facet normal -0.217460 0.542275 0.811572
outer loop
vertex -0.363256 3.319804 2.361785
vertex -0.363256 4.149152 1.807632
vertex -1.544149 3.319804 2.045366
endloop
endfacet
facet normal 0.217460 0.542275 0.811572
outer loop
vertex 0.817637 3.319804 2.045366
vertex -0.363256 4.149152 1.807632
vertex -0.363256 3.319804 2.361785
endloop
endfacet
facet normal 0.297409 0.629293 0.718010
outer loop
vertex 0.817637 3.319804 2.045366
vertex 0.914933 4.149152 1.278189
vertex -0.363256 4.149152 1.807632
endloop
endfacet
facet normal 0.614016 0.495952 0.614016
outer loop
vertex 1.682110 3.319804 1.180893
vertex 0.914933 4.149152 1.278189
vertex 0.817637 3.319804 2.045366
endloop
endfacet
facet normal 0.718010 0.629293 0.297409
outer loop
vertex 1.682110 3.319804 1.180893
vertex 1.444376 4.149152 0.000000
vertex 0.914933 4.149152 1.278189
endloop
endfacet
facet normal 0.811572 0.542275 0.217460
outer loop
vertex 1.998529 3.319804 0.000000
vertex 1.444376 4.149152 0.000000
vertex 1.682110 3.319804 1.180893
endloop
endfacet
facet normal 0.541419 0.810291 -0.224263
outer loop
vertex 0.914933 4.149152 -1.278189
vertex 0.615028 4.703305 0.000000
vertex 1.444376 4.149152 0.000000
endloop
endfacet
facet normal 0.314507 0.895640 -0.314507
outer loop
vertex 0.914933 4.149152 -1.278189
vertex -0.363256 4.703305 -0.978284
vertex 0.615028 4.703305 0.000000
endloop
endfacet
facet normal 0.224263 0.810291 -0.541419
outer loop
vertex -0.363256 4.149152 -1.807632
vertex -0.363256 4.703305 -0.978284
vertex 0.914933 4.149152 -1.278189
endloop
endfacet
facet normal -0.224263 0.810291 -0.541419
outer loop
vertex -1.641445 4.149152 -1.278189
vertex -0.363256 4.703305 -0.978284
vertex -0.363256 4.149152 -1.807632
endloop
endfacet
facet normal -0.314507 0.895640 -0.314507
outer loop
vertex -1.641445 4.149152 -1.278189
vertex -1.341540 4.703305 0.000000
vertex -0.363256 4.703305 -0.978284
endloop
endfacet
facet normal -0.541419 0.810291 -0.224263
outer loop
vertex -2.170888 4.149152 0.000000
vertex -1.341540 4.703305 0.000000
vertex -1.641445 4.149152 -1.278189
endloop
endfacet
facet normal -0.541419 0.810291 0.224263
outer loop
vertex -1.641445 4.149152 1.278189
vertex -1.341540 4.703305 0.000000
vertex -2.170888 4.149152 0.000000
endloop
endfacet
facet normal -0.314507 0.895640 0.314507
outer loop
vertex -1.641445 4.149152 1.278189
vertex -0.363256 4.703305 0.978284
vertex -1.341540 4.703305 0.000000
endloop
endfacet
facet normal -0.224263 0.810291 0.541419
outer loop
vertex -0.363256 4.149152 1.807632
vertex -0.363256 4.703305 0.978284
vertex -1.641445 4.149152 1.278189
endloop
endfacet
facet normal 0.224263 0.810291 0.541419
outer loop
vertex 0.914933 4.149152 1.278189
vertex -0.363256 4.703305 0.978284
vertex -0.363256 4.149152 1.807632
endloop
endfacet
facet normal 0.314507 0.895640 0.314507
outer loop
vertex 0.914933 4.149152 1.278189
vertex 0.615028 4.703305 0.000000
vertex -0.363256 4.703305 0.978284
endloop
endfacet
facet normal 0.541419 0.810291 0.224263
outer loop
vertex 1.444376 4.149152 0.000000
vertex 0.615028 4.703305 0.000000
vertex 0.914933 4.149152 1.278189
endloop
endfacet
facet normal 0.191480 0.962637 -0.191480
outer loop
vertex -0.363256 4.703305 -0.978284
vertex -0.363256 4.897898 0.000000
vertex 0.615028 4.703305 0.000000
endloop
endfacet
facet normal -0.191480 0.962637 -0.191480
outer loop
vertex -1.341540 4.703305 0.000000
vertex -0.363256 4.897898 0.000000
vertex -0.363256 4.703305 -0.978284
endloop
endfacet
facet normal -0.191480 0.962637 0.191480
outer loop
vertex -0.363256 4.703305 0.978284
vertex -0.363256 4.897898 0.000000
vertex -1.341540 4.703305 0.000000
endloop
endfacet
facet normal 0.191480 0.962637 0.191480
outer loop
vertex 0.615028 4.703305 0.000000
vertex -0.363256 4.897898 0.000000
vertex -0.363256 4.703305 0.978284
endloop
endfacet
endsolid sphere0
solid model0
facet normal 0.596285 0.298142 -0.745356
outer loop
vertex -2.000000 1.000000 4.000000
vertex -3.000000 -2.000000 2.000000
vertex -5.000000 2.000000 2.000000
endloop
endfacet
facet normal -0.596285 -0.298142 0.745356
outer loop
vertex -5.000000 2.000000 2.000000
vertex -3.000000 -2.000000 2.000000
vertex -2.000000 1.000000 4.000000
endloop
endfacet
facet normal 0.520266 0.346844 -0.780399
outer loop
vertex 0.000000 -2.000000 4.000000
vertex -3.000000 -2.000000 2.000000
vertex -2.000000 1.000000 4.000000
endloop
endfacet
facet normal -0.520266 -0.346844 0.780399
outer loop
vertex -2.000000 1.000000 4.000000
vertex -3.000000 -2.000000 2.000000
vertex 0.000000 -2.000000 4.000000
endloop
endfacet
facet normal 0.534522 0.267261 -0.801784
outer loop
vertex 0.000000 -2.000000 4.000000
vertex -2.000000 -4.000000 2.000000
vertex -3.000000 -2.000000 2.000000
endloop
endfacet
facet normal -0.534522 -0.267261 0.801784
outer loop
vertex -3.000000 -2.000000 2.000000
vertex -2.000000 -4.000000 2.000000
vertex 0.000000 -2.000000 4.000000
endloop
endfacet
facet normal 0.000000 0.707107 -0.707107
outer loop
vertex 0.000000 -2.000000 4.000000
vertex 2.000000 -4.000000 2.000000
vertex -2.000000 -4.000000 2.000000
endloop
endfacet
facet normal 0.000000 -0.707107 0.707107
outer loop
vertex -2.000000 -4.000000 2.000000
vertex 2.000000 -4.000000 2.000000
vertex 0.000000 -2.000000 4.000000
endloop
endfacet
facet normal -0.486664 0.324443 -0.811107
outer loop
vertex 0.000000 -2.000000 4.000000
vertex 4.000000 -1.000000 2.000000
vertex 2.000000 -4.000000 2.000000
endloop
endfacet
facet normal 0.486664 -0.324443 0.811107
outer loop
vertex 2.000000 -4.000000 2.000000
vertex 4.000000 -1.000000 2.000000
vertex 0.000000 -2.000000 4.000000
endloop
endfacet
facet normal -0.486664 0.324443 -0.811107
outer loop
vertex 2.000000 1.000000 4.000000
vertex 4.000000 -1.000000 2.000000
vertex 0.000000 -2.000000 4.000000
endloop
endfacet
facet normal 0.486664 -0.324443 0.811107
outer loop
vertex 0.000000 -2.000000 4.000000
vertex 4.000000 -1.000000 2.000000
vertex 2.000000 1.000000 4.000000
endloop
endfacet
facet normal -0.588348 0.196116 -0.784465
outer loop
vertex 2.000000 1.000000 4.000000
vertex 5.000000 2.000000 2.000000
vertex 4.000000 -1.000000 2.000000
endloop
endfacet
facet normal 0.588348 -0.196116 0.784465
outer loop
vertex 4.000000 -1.000000 2.000000
vertex 5.000000 2.000000 2.000000
vertex 2.000000 1.000000 4.000000
endloop
endfacet
facet normal -0.132164 -0.792982 -0.594737
outer loop
vertex 2.000000 1.000000 4.000000
vertex -1.000000 3.000000 2.000000
vertex 5.000000 2.000000 2.000000
endloop
endfacet
facet normal 0.132164 0.792982 0.594737
outer loop
vertex 5.000000 2.000000 2.000000
vertex -1.000000 3.000000 2.000000
vertex 2.000000 1.000000 4.000000
endloop
endfacet
facet normal 0.000000 -0.707107 -0.707107
outer loop
vertex -2.000000 1.000000 4.000000
vertex -1.000000 3.000000 2.000000
vertex 2.000000 1.000000 4.000000
endloop
endfacet
facet normal 0.000000 0.707107 0.707107
outer loop
vertex 2.000000 1.000000 4.000000
vertex -1.000000 3.000000 2.000000
vertex -2.000000 1.000000 4.000000
endloop
endfacet
facet normal 0.184900 -0.739600 -0.647150
outer loop
vertex -2.000000 1.000000 4.000000
vertex -5.000000 2.000000 2.000000
vertex -1.000000 3.000000 2.000000
endloop
endfacet
facet normal -0.184900 0.739600 0.647150
outer loop
vertex -1.000000 3.000000 2.000000
vertex -5.000000 2.000000 2.000000
vertex -2.000000 1.000000 4.000000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -2.000000 1.000000 4.000000
vertex 2.000000 1.000000 4.000000
vertex 0.000000 -2.000000 4.000000
endloop
endfacet
facet normal 0.000000 0.000000 1.000000
outer loop
vertex 0.000000 -2.000000 4.000000
vertex 2.000000 1.000000 4.000000
vertex -2.000000 1.000000 4.000000
endloop
endfacet
endsolid model0
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Geometry import *
from pycam.Cutters.CylindricalCutter import *
from pycam.Gui.Visualization import ShowTestScene
if __name__ == "__main__":
dir = Point(0,0,-1)
#c = CylindricalCutter(1, Point(0,0,6))
c = CylindricalCutter(1, Point(2,0,6))
#c = CylindricalCutter(1, Point(-2.2,0.2,6))
#c = CylindricalCutter(1, Point(-1.7,-0.2,6))
print "c=", c
#t = Triangle(Point(-3,0,2), Point(2,2,3), Point(2,-2,4))
#t = Triangle(Point(-2,0,2), Point(2,-1,4), Point(2,1,3))
#t = Triangle(Point(2,0,4), Point(2,-1,2), Point(2,1,2))
#t = Triangle(Point(2,0,4), Point(2,1,2), Point(2,-1,2))
#t = Triangle(Point(-3,0,4), Point(2,2,2), Point(2,-2,2))
t = Triangle(Point(-3,0,2.5), Point(3,0,2.5), Point(0,1,1.5))
print "t=", t
if False:
print "plane:"
(cl_p,ccp_p,cp_p,d_p) = c.intersect_circle_plane(dir,t)
print "ccp=", ccp_p
print "cp=", cp_p
print "cl=", cl_p
print "d=", d_p
print "triangle:"
(cl_t,d_t) = c.intersect_circle_triangle(dir,t)
print "cl=", cl_t
print "d=", d_t
print "point:"
(cl_v,ccp_v,cp_v,d_v) = c.intersect_circle_point(dir,t.p1)
print "ccp=", ccp_v
print "cp=", cp_v
print "cl=", cl_v
print "d=", d_v
l = Line(t.p2,t.p3)
print "line:", l
(cl_l,ccp_l,cp_l,d_l) = c.intersect_circle_line(dir,l)
print "ccp=", ccp_l
print "cp=", cp_l
print "cl=", cl_l
print "d=", d_l
print "edge:", l
(cl_e,d_e) = c.intersect_circle_edge(dir,l)
print "cl=", cl_e
print "d=", d_e
print "piece:"
(cl,d) = c.intersect(dir,t)
print "cl=", cl
if False:
samples = 50
x0 = -5.0
x1 = +5.0
y0 = -5.0
y1 = +5.0
z = 10
dir = Point(0,0,-1)
pathlist = []
for i in range(0,samples):
x = x0 + i * ((x1-x0) / samples)
p = Path()
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
c.moveto(Point(x,y,z))
cl = c.drop(t)
if cl:
p.append(cl)
else:
p.append(Point(x,y,0))
pathlist.append(p)
c.moveto(Point(x0,y0,z))
ShowTestScene(t, c, pathlist)
if True:
samples = 50
layers = 10
x0 = -5.0
x1 = +5.0
y0 = -5.0
y1 = +5.0
z0 = 0
z1 = 4
dir = Point(1,0,0)
pathlist = []
for i in range(0, layers):
z = z1-i*float(z1-z0)/layers
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
p = Point(x0,y,z)
c.moveto(p)
(cl,l) = c.intersect(dir,t)
if cl:
p = Path()
#p.append(c.center)
#p.append(ccp)
#p.append(cp)
p.append(cl)
p.append(cl.sub(dir.mul(l)))
pathlist.append(p)
c.moveto(Point(x0,y0,z1))
ShowTestScene(t, c, pathlist)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Geometry import *
from pycam.Cutters.SphericalCutter import *
from pycam.Cutters.CylindricalCutter import *
from pycam.Cutters.ToroidalCutter import *
from pycam.Gui.Visualization import ShowTestScene
from pycam.Importers.TestModel import TestModel
from pycam.PathGenerators.DropCutter import DropCutter
from pycam.Exporters.SimpleGCodeExporter import SimpleGCodeExporter
if __name__ == "__main__":
c = SphericalCutter(1, Point(0,0,7))
#c = CylindricalCutter(1, Point(0,0,7))
#c = ToroidalCutter(1, 0.25, Point(0,0,7))
print "c=", c
model = TestModel()
if True:
samples = 20
lines = 20
x0 = -7.0
x1 = +7.0
y0 = -7.0
y1 = +7.0
z0 = 0
z1 = 4
dx = (x1-x0)/samples
dy = (y1-y0)/lines
pg = DropCutter(c, model)
pathlist = pg.GenerateToolPath(x0, x1, y0, y1, z0, z1, dx, dy)
g = SimpleGCodeExporter("cutter2.nc", z1)
g.AddPathList(pathlist)
g.close()
ShowTestScene(model, c, pathlist)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Exporters.MGEDExporter import MGEDExporter
from pycam.Importers.TestModel import TestModel
model = TestModel()
file = MGEDExporter("TestModel.txt")
file.AddModel(model)
file.close()
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Geometry.PolygonExtractor import *
import sys
print ""
col = [ 0xff0000, 0x00ff00, 0x0000ff, 0x00ffff, 0xff00ff, 0xffff00,
0x007f3f, 0x3f007f, 0x7f3f00, 0x3f7f00, 0x003f7f, 0x7f003f ]
def r(x):
return ((col[(x)%12]>>16)&0xff)
def g(x):
return ((col[(x)%12]>> 8)&0xff)
def b(x):
return ((col[(x)%12]>> 0)&0xff)
def test_image(image):
pe = PolygonExtractor(policy=PolygonExtractor.CONTOUR)
h = len(image)
w = len(image[0])
for dir in [0, 1]:
pe.new_direction(dir)
imax = 0
jmax = 0
if dir==0:
imax=w
jmax=h
else:
imax=h
jmax=w
for j in range(0,jmax):
pe.new_scanline()
x=0
y=0
if (dir==0):
x = 0
y = j
else:
x = j
y = 0
c = image[y][x]
for i in range(0,imax):
if dir==0:
x = i
else:
y = i
if image[y][x] != c:
if dir==0:
pe.append(Point(x-0.5,y, 0))
else:
pe.append(Point(x,y-0.5, 0))
c = image[y][x]
pe.end_scanline()
pe.end_direction()
pe.finish()
# w = int(w*1.5)
# h = int(h*2)
fg = 0xae
bg = 0xfe
for dir in [0,1,2]:
screen = []
for i in range(0,h):
screen.append([])
for j in range(0,w):
screen[i].append([bg,bg,bg])
path_list = None
if dir == 0:
path_list = pe.hor_path_list
elif dir == 1:
path_list = pe.ver_path_list
else:
if hasattr(pe, "merge_path_list"):
path_list = pe.merge_path_list
else:
path_list = []
for curr_path in path_list:
for point in curr_path.points:
x = (int)(point.x)
y = (int)(point.y)
screen[y][x][0] = r(curr_path.id);
screen[y][x][1] = g(curr_path.id);
screen[y][x][2] = b(curr_path.id);
if dir==0:
for i in range(x+1, w):
if screen[y][i][0] == bg:
screen[y][i][0] = fg
screen[y][i][1] = fg
screen[y][i][2] = fg
elif screen[y][i][0] == fg:
screen[y][i][0] = bg
screen[y][i][1] = bg
screen[y][i][2] = bg
else:
for i in range(y+1,h):
if screen[i][x][0] == bg:
screen[i][x][0] = fg
screen[i][x][1] = fg
screen[i][x][2] = fg
elif screen[i][x][0] == fg:
screen[i][x][0] = bg
screen[i][x][1] = bg
screen[i][x][2] = bg
l = "+"
for i in range(0, w):
l += "-"
l += "+"
print l
for j in range(0, h):
l = "|"
for i in range(0, w):
if (screen[j][i][0] == bg):
l += " "
elif (screen[j][i][0] == fg):
l += "."
else:
l += "*"
l += "|"
print l
l = "+"
for i in range(0,w):
l += "-"
l += "+"
print l
filename = None
if dir==0:
filename = "polygon_h.svg"
elif dir==1:
filename = "polygon_v.svg"
else:
filename = "polygon.svg"
f = open(filename,"w")
f.write("<?xml version='1.0'?>\n")
f.write("<svg")
f.write(" xmlns='http://www.w3.org/2000/svg'")
f.write(" width='%f'" % (10+(w)*30))
f.write(" height='%f'" % (10+(h)*30))
f.write(">\n")
f.write("<g transform='translate(10,10)'>\n")
f.write("<g transform='scale(20)'>\n")
for winding in range(0,10):
f.write("<g ")
if (pe.policy == PolygonExtractor.CONTOUR) and (winding&1)==0:
f.write(" fill='#ffffff'")
else:
f.write(" fill='#e0e0e0'")
f.write(" stroke-width='0.1'")
f.write(">\n")
s = ""
for path in path_list:
if path.winding!=winding:
continue
f.write("<path")
f.write(" stroke='#%02x%02x%02x'" %(r(path.id),g(path.id),b(path.id)))
f.write(" d='")
first = True
for point in path.points:
x = point.x
y = point.y;
s += "<text x='%g' y='%g' font-size='0.3' fill='#000000'>%d</text>\n" % (x, y, point.id)
if first:
first = False
f.write("M ")
else:
f.write(" L ")
f.write("%g %g" % (x,y))
f.write(" z'/>\n")
f.write(s)
f.write("</g>\n")
f.write("<g font-size='0.3' fill='#000000' opacity='0.5'>\n")
for j in range(0,h):
for i in range(0,w):
c = image[j][i]
if c != ' ':
f.write("<text x='%g' y='%g'>%c</text>\n" % (i*1.0,j*1.0,c))
f.write("</g>\n")
f.write("</g>\n")
f.write("</g>\n")
f.write("</svg>\n")
if __name__ == "__main__":
test = 0
if len(sys.argv)>1:
test = int(sys.argv[1])
if (test==0):
image = [
" ",
" ** ",
" **** ",
" ****** ",
" ****** ",
" **** ",
" ** ",
" ",
]
test_image(image)
if (test==1):
image = [
" ",
" ****** ",
" *** ***** ",
" ** ***** ",
" *** ",
" ",
]
test_image(image)
if (test==2):
image = [
" ",
" *** ",
" ***** ** ",
" ***** *** ",
" ***** ",
" ",
]
test_image(image)
if (test==3):
image = [
" ",
" ******* ",
" ********* ",
" *** *** *** ",
" ** *** ** ",
" ",
" ",
]
test_image(image)
if (test==4):
image = [
" ",
" ** *** ** ",
" *** *** *** ",
" ********* ",
" ******* ",
" ",
" ",
]
test_image(image)
if (test==5):
image = [
" ",
" ******* ",
" ********* ",
" *** *** *** ",
" ** *** ** ",
" *** *** *** ",
" ********* ",
" ******* ",
" ",
" ",
]
test_image(image)
if (test==6):
image = [
" ",
" ******* ",
" ********* ",
" *** *** *** ",
" ********* ",
" ******* ",
" ",
" ",
]
test_image(image)
if (test==7):
image = [
" ",
" *********** ",
" ***** ***** ",
" ** ***** ** ",
" *********** ",
" ",
" ",
]
test_image(image)
if (test==8):
image = [
" ",
" *********** ",
" ** ** ",
" ** ***** ** ",
" ** *** *** ** ",
" ** ** ** ** ",
" ** *** *** ** ",
" ** ***** ** ",
" ** ** ",
" *********** ",
" ",
" ",
]
test_image(image)
if (test==10):
image = [
" ",
" ******************** ",
" **************************** ",
" ************ ************ ",
" ***** ******** ********* ******* ",
" ************** ***** ****** ",
" ******************** ******* ",
" *********************** ",
" "
]
test_image(image)
if (test==11):
image = [
" ",
" ********************************************** ",
" ****** *** *** *** *** *** *** ******* ",
" ***** * * * * * * ****** ",
" ****** *** *** *** *** *** *** ******* ",
" ********************************************** ",
" "
]
test_image(image)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Geometry import *
from pycam.Cutters.SphericalCutter import *
from pycam.Cutters.CylindricalCutter import *
from pycam.Cutters.ToroidalCutter import *
from pycam.Gui.Visualization import ShowTestScene
from pycam.Importers import STLImporter
from pycam.PathGenerators.PushCutter import PushCutter
from pycam.PathProcessors import *
from pycam.Exporters.SimpleGCodeExporter import SimpleGCodeExporter
if __name__ == "__main__":
c = SphericalCutter(0.1, Point(0,0,7))
#c = CylindricalCutter(1, Point(0,0,7))
#c = ToroidalCutter(1, 0.25, Point(0,0,7))
print "c=", c
#model = TestModel()
#model = STLImporter.ImportModel("Samples/STL/Box0.stl")
#model = STLImporter.ImportModel("Samples/STL/Box1.stl")
model = STLImporter.ImportModel("Samples/STL/Box0+1.stl")
#model = Model()
#model.append(Triangle(Point(0,0,0),Point(0,5,4),Point(0,-5,4)))
#model.append(Triangle(Point(2,0,0),Point(2,-5,4),Point(2,5,4)))
if True:
lines = 20
layers = 4
x0 = -7.0
x1 = +7.0
y0 = -7.0
y1 = +7.0
z0 = 2.0
z1 = 4.0
pc = PushCutter(c, model, SimpleCutter())
#pc = PushCutter(c, model, ZigZagCutter())
#pc = PushCutter(c, model, PolygonCutter())
dx = 0
if lines>1:
dy = float(y1-y0)/(lines-1)
else:
dy = INFINITE
if layers>1:
dz = float(z1-z0)/(layers-1)
else:
dz = INFINITE
pathlist = pc.GenerateToolPath(x0,x1,y0,y1,z0,z1,dx,dy,dz)
c.moveto(Point(x0,y0,z0))
ShowTestScene(model, c, pathlist)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Importers import STLImporter
from pycam.Gui.Visualization import ShowTestScene
model = STLImporter.ImportModel("Samples/STL/SampleScene.stl")
ShowTestScene(model)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
import math
from pycam.Geometry import *
from pycam.Cutters.SphericalCutter import *
from pycam.Gui.Visualization import ShowTestScene
if __name__ == "__main__":
if False:
cutter = SphericalCutter(1, Point(-10,0.5,0))
edge = Line(Point(0,0,-10),Point(0,0,10))
dir = Point(1,0,0)
print "cutter=", cutter
print "edge=", edge
print "dir=", dir
(cl,ccp,cp,d) = cutter.intersect_sphere_line(dir, edge)
print "cp=", cp
print "ccp=", ccp
print "d=", d
print "cl=", cl
exit()
if False:
cutter = SphericalCutter(1, Point(-10,0,0))
edge = Line(Point(0,-5,1),Point(3,+5,1))
dir = Point(1,-0.2,0)
print "cutter=", cutter
print "edge=", edge
print "dir=", dir
(cl,ccp,cp,d) = cutter.intersect_cylinder_line(dir, edge)
print "cp=", cp
print "ccp=", ccp
print "d=", d
print "cl=", cl
dir = Point(0,0,-1)
c = SphericalCutter(1, Point(0,0,6))
#c = SphericalCutter(1, Point(-2.2,0.2,6))
#c = SphericalCutter(1, Point(-1.7,0.5,6))
print "c=", c
t = Triangle(Point(-2,0,2), Point(2,1,3), Point(2,-1,4))
#t = Triangle(Point(-2,0,2), Point(2,-1,4), Point(2,1,3))
#t = Triangle(Point(2,0,4), Point(2,-1,2), Point(2,1,2))
print "t=", t
if False:
(cl_p,ccp_p,cp_p,d_p) = c.intersect_sphere_plane(dir,t)
print "ccp=", ccp_p
print "cp=", cp_p
print "cl=", cl_p
print "d=", d_p
(cl_v,ccp_v,cp_v,d_v) = c.intersect_sphere_point(dir,t.p1)
print "ccp=", ccp_v
print "cp=", cp_v
print "cl=", cl_v
print "d=", d_v
(cl_e,ccp_e,cp_e,d_e) = c.intersect_sphere_line(dir,Line(t.p1,t.p2))
print "ccp=", ccp_e
print "cp=", cp_e
print "cl=", cl_e
print "d=", d_e
(cl,d) = c.intersect(dir,t)
print "cl=", cl
if False:
samples = 50
x0 = -5.0
x1 = +5.0
y0 = -5.0
y1 = +5.0
z = 10
pathlist = []
for i in range(0,samples):
x = x0 + i * ((x1-x0) / samples)
p = Path()
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
c.moveto(Point(x,y,z))
cl = c.drop(t)
if cl:
p.append(cl)
else:
p.append(Point(x,y,0))
pathlist.append(p)
c.moveto(Point(x0,y0,z))
ShowTestScene(t, c, pathlist)
if True:
samples = 50
layers = 10
x0 = -5.0
x1 = +5.0
y0 = -3.0
y1 = +3.0
z0 = 0
z1 = 3
dir = Point(1,0,0)
pathlist = []
for i in range(0, layers):
z = z1-i*float(z1-z0)/layers
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
c.moveto(Point(x0,y,z))
(cl,l) = c.intersect(dir,t)
if cl:
p = Path()
#p.append(c.center)
#p.append(ccp)
#p.append(cp)
p.append(cl)
p.append(cl.sub(dir.mul(l)))
pathlist.append(p)
c.moveto(Point(x0,y0,z))
ShowTestScene(t, c, pathlist)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Geometry import *
from pycam.Cutters.ToroidalCutter import *
from pycam.Gui.Visualization import ShowTestScene
import math
if __name__ == "__main__":
if False:
cutter = ToroidalCutter(1, 0.25, Point(-10,0.5,0))
edge = Line(Point(0,0,-10),Point(0,0,10))
dir = Point(1,0,0)
print "cutter=", cutter
print "edge=", edge
print "dir=", dir
(cl,ccp,cp,d) = cutter.intersect_sphere_line(dir, edge)
print "cp=", cp
print "ccp=", ccp
print "d=", d
print "cl=", cl
exit()
if False:
cutter = ToroidalCutter(1, 0.25, Point(-10,0,0))
edge = Line(Point(0,-5,1),Point(3,+5,1))
dir = Point(1,-0.2,0)
print "cutter=", cutter
print "edge=", edge
print "dir=", dir
(cl,ccp,cp,d) = cutter.intersect_cylinder_line(dir, edge)
print "cp=", cp
print "ccp=", ccp
print "d=", d
print "cl=", cl
#dir = Point(0,0,-1)
#c = ToroidalCutter(1, 0.25, Point(0,0,6))
#c = ToroidalCutter(1, 0.25, Point(-2.2,0.2,6))
#c = ToroidalCutter(1, 0.25, Point(-1.7,0.5,6))
dir = Point(1,0,0)
c = ToroidalCutter(1, 0.25, Point(-10,0.1,1.9))
print "c=", c
t = Triangle(Point(-2,0,2), Point(2,1,3), Point(2,-1,4))
print "t=", t
if False:
if False:
(cl_p,ccp_p,cp_p,d_p) = c.intersect_torus_plane(dir,t)
print "ccp=", ccp_p
print "cp=", cp_p
print "cl=", cl_p
print "d=", d_p
if False:
p = t.p1
(cl_v,ccp_v,cp_v,d_v) = c.intersect_torus_point(dir,p)
print "ccp=", ccp_v
print "cp=", cp_v
print "cl=", cl_v
print "d=", d_v
if False:
e = Line(t.p1,t.p2)
(cl_e,ccp_e,cp_e,d_e) = c.intersect_torus_line(dir,e)
print "ccp=", ccp_e
print "cp=", cp_e
print "cl=", cl_e
print "d=", d_e
if False:
(cl,d) = c.intersect(dir,t)
print "cl=", cl
if False:
samples = 50
x0 = -5.0
x1 = +5.0
y0 = -5.0
y1 = +5.0
z = 10
pathlist = []
for i in range(0,samples):
x = x0 + i * ((x1-x0) / samples)
p = Path()
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
c.moveto(Point(x,y,z))
cl = c.drop(t)
if cl:
p.append(cl)
else:
p.append(Point(x,y,0))
pathlist.append(p)
c.moveto(Point(x0,y0,z))
ShowTestScene(t, c, pathlist)
if True:
samples = 100
layers = 10
x0 = -5.0
x1 = +5.0
y0 = -5.0
y1 = +5.0
z0 = 0
z1 = 3
dir = Point(1,0,0)
pathlist = []
for i in range(0, layers):
z = z1-i*float(z1-z0)/layers
for j in range(0,samples):
y = y0 + j * ((y1-y0) / samples)
c.moveto(Point(x0,y,z))
(cl,l) = c.intersect(dir,t)
if cl:
p = Path()
#p.append(c.center)
#p.append(ccp)
#p.append(cp)
p.append(cl)
p.append(cl.sub(dir.mul(l)))
pathlist.append(p)
c.moveto(Point(x0,y0,z))
ShowTestScene(t, c, pathlist)
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Geometry.TriangleKdtree import *
from pycam.Geometry.Model import Model
from pycam.Importers.TestModel import TestModel
def comb_tomged(f, triangles, name, color):
comb = ""
for t in triangles:
comb += " u triangle%d" % t.id
if len(comb)>512:
f.write("comb "+name+comb+"\n")
comb = ""
if len(comb)>0:
f.write("comb "+name+comb+"\n")
f.write("mater " + name + " del " + color + " 1\n")
print "# get model"
testmodel = TestModel()
print "# subdivide"
model = testmodel.subdivide(5)
print "# build kdtree"
kdtree = BuildKdtree2d(model.triangles(), 2, 0.1)
#print "#kdtree=",kdtree
x = 2
y = 2
r = 0.1
minx = x-r
miny = y-r
maxx = x+r
maxy = y+r
print "# query kdtree"
ResetKdtree2dStats(False)
tests = SearchKdtree2d(kdtree, minx, maxx, miny, maxy)
print "# query kdtree"
ResetKdtree2dStats(True)
hits = SearchKdtree2d(kdtree, minx, maxx, miny, maxy)
#print "# hits=%d / tests=%d" % GetKdtree2dStats(), "/ triangles=%d" % len(model.triangles())
print "# hits=%d " % len(hits), "/ tests=%d" % len(tests), "/ triangles=%d" % len(model.triangles())
print "# write mged"
f = file("test.txt","w")
f.write("in query.s arb8 %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n" %
(minx, miny, 0, maxx, miny, 0, minx, maxy, 0, maxx, maxy, 0, minx, miny, 10, maxx, miny, 10, minx, maxy, 10, maxx, maxy, 10))
f.write("comb query.c u query.s\n")
f.write("mater query.c del 255 255 255 0\n")
if False:
for t in model.triangles():
f.write(t.to_mged())
comb_tomged(f, model.triangles(), "model.c", "255 0 0")
else:
for t in tests:
f.write(t.to_mged())
comb_tomged(f, tests, "tests.c", "0 255 0")
comb_tomged(f, hits, "hits.c", "0 0 255")
#print kdtree
#f.write(kdtree.to_mged(-7,-7,7,7))
f.write(SearchKdtree2d_mged(kdtree, minx, maxx, miny, maxy,-7,-7,+7,+7))
f.close()
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
import math
from pycam.Geometry import *
if __name__ == "__main__":
p1 = Point(1,0,0)
p2 = Point(0,1,0)
p3 = Point(0,0,1)
print "p1=" + str(p1);
print "p2=" + str(p2);
print "p3=" + str(p3);
print "p2-p1=" + str(p2.sub(p1))
print "p3-p2=" + str(p3.sub(p2))
print "p1-p3=" + str(p1.sub(p3))
print "p2.p1=" + str(p2.dot(p1))
print "p3.p2=" + str(p3.dot(p2))
print "p1.p3=" + str(p1.dot(p3))
print "p1xp2=" + str(p1.cross(p2))
print "p2xp3=" + str(p2.cross(p3))
print "p3xp1=" + str(p3.cross(p1))
t = Triangle(p1,p2,p3)
print t
t.calc_circumcircle()
print "circ(t) = %s@%s" % (t.radius,t.center())
f = file("triangle0.txt","w")
f.write(t.to_mged(sphere=True))
f.close()
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from pycam.Gui.Visualization import Visualization
from pycam.Importers.TestModel import TestModel
model = TestModel()
def DrawScene():
model.to_OpenGL()
Visualization("VisualizationTest", DrawScene)
import sys
import os
sys.path.insert(0, os.path.join(sys.prefix, "PyOpenGL-3.0.0b5-py2.5.egg"))
sys.path.insert(0, os.path.join(sys.prefix, "setuptools-0.6c8-py2.5.egg"))
from pycam.Gui.SimpleGui import SimpleGui
from pycam.Importers.TestModel import TestModel
gui = SimpleGui()
gui.model = TestModel()
gui.mainloop()
import pycam.Geometry
from pycam.Geometry import *
from pycam.Geometry.utils import *
from pycam.Geometry.utils import *
from math import sqrt
class BaseCutter:
id = 0
def __init__(self, location, radius):
self.location = location
self.id = BaseCutter.id
BaseCutter.id += 1
self.radius = radius
self.radiussq = radius*radius
self.minx = location.x-radius
self.maxx = location.x+radius
self.miny = location.y-radius
self.maxy = location.y+radius
def __repr__(self):
return "BaseCutter"
def to_mged(self):
return ""
def moveto(self, location):
self.location = location
self.minx = location.x-self.radius
self.maxx = location.x+self.radius
self.miny = location.y-self.radius
self.maxy = location.y+self.radius
def intersect(self, direction, triangle):
return (None, None, None, INFINITE)
def drop(self, triangle):
# check bounding box collision
if self.minx > triangle.maxx():
return None
if self.maxx < triangle.minx():
return None
if self.miny > triangle.maxy():
return None
if self.maxy < triangle.miny():
return None
# check bounding sphere collision
c = triangle.center()
if sqr(c.x-self.location.x)+sqr(c.y-self.location.y)>self.radiussq+self.radius*triangle.radius()+triangle.radiussq():
return None
(cl,d)= self.intersect(Point(0,0,-1), triangle)
return cl
def push(self, dx, dy, triangle):
# check bounding box collision
if dx == 0:
if self.miny > triangle.maxy():
return None
if self.maxy < triangle.miny():
return None
if dy == 0:
if self.minx > triangle.maxx():
return None
if self.maxx < triangle.minx():
return None
if triangle.maxz()<self.location.z:
return None
# check bounding sphere collision
c = triangle.center()
d = (c.x-self.location.x)*dy-(c.y-self.location.y)*dx
t = self.radius + triangle.radius()
if d < -t or d > t:
return None
(cl,d)= self.intersect(Point(dx,dy,0), triangle)
return cl
import pycam.Geometry
from pycam.Geometry import *
from pycam.Geometry.utils import *
from pycam.Geometry.intersection import *
from pycam.Cutters.BaseCutter import BaseCutter
from math import sqrt
try:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
except:
pass
class CylindricalCutter(BaseCutter):
def __init__(self, radius, location=Point(0,0,0), height=10):
BaseCutter.__init__(self, location, radius)
self.height = height
self.axis = Point(0,0,1)
self.center = location
def __repr__(self):
return "CylindricalCutter<%s,%s>" % (self.location,self.radius)
def to_mged(self):
s = ""
s += "in cutter%d_cyl.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.location.x, self.location.y, self.location.z, self.height, self.radius)
s += "\n"
s += "comb cutter%d_cyl.c u cutter%d_cyl.s\n" % (self.id, self.id)
s += "r cutter%d.r u cutter%d_cyl.c\n" % (self.id, self.id)
return s
def to_OpenGL(self):
glPushMatrix()
glTranslate(self.center.x, self.center.y, self.center.z)
if not hasattr(self,"_cylinder"):
self._cylinder = gluNewQuadric()
gluCylinder(self._cylinder, self.radius, self.radius, self.height, 10, 10)
if not hasattr(self,"_disk"):
self._disk = gluNewQuadric()
gluDisk(self._disk, 0, self.radius, 10, 10)
glPopMatrix()
def moveto(self, location):
BaseCutter.moveto(self, location)
self.center = location
def intersect_circle_plane(self, direction, triangle):
(ccp,cp,d) = intersect_circle_plane(self.center, self.radius, direction, triangle)
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,d)
return (None, None, None, INFINITE)
def intersect_circle_triangle(self, direction, triangle):
(cl,ccp,cp,d) = self.intersect_circle_plane(direction, triangle)
if cp and triangle.point_inside(cp):
return (cl,d)
return (None,INFINITE)
def intersect_circle_point(self, direction, point):
(ccp,cp,l) = intersect_circle_point(self.center, self.axis, self.radius, self.radiussq, direction, point)
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,l)
return (None,None,None,INFINITE)
def intersect_circle_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_circle_point(direction, point)
return (cl,l)
def intersect_circle_line(self, direction, edge):
(ccp,cp,l) = intersect_circle_line(self.center, self.axis, self.radius, self.radiussq, direction, edge)
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,l)
return (None,None,None,INFINITE)
def intersect_circle_edge(self, direction, edge):
(cl,ccp,cp,l) = self.intersect_circle_line(direction, edge)
if cp:
# check if the contact point is between the endpoints
m = cp.sub(edge.p1).dot(edge.dir())
if m<0 or m>edge.len():
return (None,INFINITE)
return (cl,l)
def intersect_cylinder_point(self, direction, point):
(ccp,cp,l) = intersect_cylinder_point(self.center, self.axis, self.radius, self.radiussq, direction, point)
# offset intersection
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_cylinder_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_cylinder_point(direction, point)
if ccp and ccp.z < self.center.z:
return (None, INFINITE)
return (cl, l)
def intersect_cylinder_line(self, direction, edge):
(ccp,cp,l) = intersect_cylinder_line(self.center, self.axis, self.radius, self.radiussq, direction, edge)
# offset intersection
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,l)
return (None,None,None,INFINITE)
def intersect_cylinder_edge(self, direction, edge):
(cl,ccp,cp,l) = self.intersect_cylinder_line(direction, edge)
if not ccp:
return (None,INFINITE)
m = cp.sub(edge.p1).dot(edge.dir())
if m<0 or m>edge.len():
return (None,INFINITE)
if ccp.z<self.center.z:
return (None,INFINITE)
return (cl,l)
def intersect(self, direction, triangle):
(cl_t,d_t) = self.intersect_circle_triangle(direction, triangle)
(cl_p1,d_p1) = self.intersect_circle_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_circle_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_circle_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_circle_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_circle_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_circle_edge(direction, Line(triangle.p3,triangle.p1))
d = INFINITE
cl = None
if d_t < d:
d = d_t
cl = cl_t
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
if direction.x != 0 or direction.y != 0:
(cl_p1,d_p1) = self.intersect_cylinder_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_cylinder_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_cylinder_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_cylinder_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_cylinder_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_cylinder_edge(direction, Line(triangle.p3,triangle.p1))
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
return (cl,d)
import pycam.Geometry
from pycam.Geometry import *
from pycam.Geometry.utils import *
from pycam.Geometry.intersection import *
from pycam.Cutters.BaseCutter import BaseCutter
from math import sqrt
try:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
except:
pass
class SphericalCutter(BaseCutter):
def __init__(self, radius, location=Point(0,0,0), height=10):
BaseCutter.__init__(self, location, radius)
self.height = height
self.axis = Point(0,0,1)
self.center = Point(location.x, location.y, location.z+radius)
def __repr__(self):
return "SphericalCutter<%s,%s>" % (self.location,self.radius)
def to_mged(self):
s = ""
s += "in cutter%d_sph.s sph" % (self.id)
s += " %f %f %f %f" % (self.center.x, self.center.y, self.center.z, self.radius)
s += "\n"
s += "in cutter%d_cyl.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.center.x, self.center.y, self.center.z, self.height, self.radius)
s += "\n"
s += "comb cutter%d_sph.c u cutter%d_sph.s\n" % (self.id, self.id)
s += "comb cutter%d_cyl.c u cutter%d_cyl.s - cutter%d_sph.s\n" % (self.id, self.id, self.id)
s += "r cutter%d.r u cutter%d_cyl.c u cutter%d_sph.c\n" % (self.id, self.id, self.id)
return s
def to_OpenGL(self):
glPushMatrix()
glTranslate(self.center.x, self.center.y, self.center.z)
if not hasattr(self,"_sphere"):
self._sphere = gluNewQuadric()
gluSphere(self._sphere, self.radius, 10, 10)
if not hasattr(self,"_cylinder"):
self._cylinder = gluNewQuadric()
gluCylinder(self._cylinder, self.radius, self.radius, self.height, 10, 10)
glPopMatrix()
def moveto(self, location):
BaseCutter.moveto(self, location)
self.center = Point(location.x, location.y, location.z+self.radius)
def intersect_sphere_plane(self, direction, triangle):
(ccp,cp,d) = intersect_sphere_plane(self.center, self.radius, direction, triangle)
# offset intersection
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,d)
return (None, None, None, INFINITE)
def intersect_sphere_triangle(self, direction, triangle):
(cl,ccp,cp,d) = self.intersect_sphere_plane(direction, triangle)
if cp and triangle.point_inside(cp):
return (cl,d)
return (None,INFINITE)
def intersect_sphere_point(self, direction, point):
(ccp,cp,l) = intersect_sphere_point(self.center, self.radius, self.radiussq, direction, point)
# offset intersection
cl = self.location.add(direction.mul(l))
return (cl,ccp,cp,l)
def intersect_sphere_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_sphere_point(direction, point)
return (cl,l)
def intersect_sphere_line(self, direction, edge):
(ccp,cp,l) = intersect_sphere_line(self.center, self.radius, self.radiussq, direction, edge)
# offset intersection
if ccp:
cl = cp.sub(ccp.sub(self.location))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_sphere_edge(self, direction, edge):
(cl,ccp,cp,l) = self.intersect_sphere_line(direction, edge)
if cp:
# check if the contact point is between the endpoints
d = edge.p2.sub(edge.p1)
m = cp.sub(edge.p1).dot(d)
if m<0 or m>d.normsq():
return (None,INFINITE)
return (cl,l)
def intersect_cylinder_point(self, direction, point):
(ccp,cp,l)=intersect_cylinder_point(self.center, self.axis, self.radius, self.radiussq, direction, point)
# offset intersection
if ccp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,l)
return (None,None,None,INFINITE)
def intersect_cylinder_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_cylinder_point(direction, point)
if ccp and ccp.z < self.center.z:
return (None, INFINITE)
return (cl, l)
def intersect_cylinder_line(self, direction, edge):
(ccp,cp,l) = intersect_cylinder_line(self.center, self.axis, self.radius, self.radiussq, direction, edge)
# offset intersection
if ccp:
cl = self.location.add(cp.sub(ccp))
return (cl,ccp,cp,l)
return (None,None,None,INFINITE)
def intersect_cylinder_edge(self, direction, edge):
(cl,ccp,cp,l) = self.intersect_cylinder_line(direction, edge)
if not ccp:
return (None,INFINITE)
m = cp.sub(edge.p1).dot(edge.dir())
if m<0 or m>edge.len():
return (None,INFINITE)
if ccp.z<self.center.z:
return (None,INFINITE)
return (cl,l)
def intersect(self, direction, triangle):
(cl_t,d_t) = self.intersect_sphere_triangle(direction, triangle)
(cl_p1,d_p1) = self.intersect_sphere_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_sphere_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_sphere_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_sphere_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_sphere_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_sphere_edge(direction, Line(triangle.p3,triangle.p1))
d = INFINITE
cl = None
if d_t < d:
d = d_t
cl = cl_t
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
if direction.x != 0 or direction.y != 0:
(cl_p1,d_p1) = self.intersect_cylinder_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_cylinder_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_cylinder_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_cylinder_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_cylinder_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_cylinder_edge(direction, Line(triangle.p1,triangle.p3))
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
return (cl,d)
def drop_bis(self, triangle):
n = triangle.normal()
if abs(n.dot(self.axis))<epsilon:
d = triangle.p1.sub(self.center).dot(n)
if abs(d)>= self.radius-epsilon:
return None
(cl,d)= self.intersect(Point(0,0,-1), triangle)
return cl
import pycam.Geometry
from pycam.Geometry import *
from pycam.Geometry.utils import *
from pycam.Geometry.intersection import *
from pycam.Cutters.BaseCutter import BaseCutter
from math import sqrt
try:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
except:
pass
class ToroidalCutter(BaseCutter):
def __init__(self, radius, minorradius, location=Point(0,0,0), height=10):
BaseCutter.__init__(self, location, radius)
self.majorradius = radius-minorradius
self.minorradius = minorradius
self.height = height
self.axis = Point(0,0,1)
self.center = Point(location.x, location.y, location.z+minorradius)
self.majorradiussq = sqr(self.majorradius)
self.minorradiussq = sqr(self.minorradius)
def __repr__(self):
return "ToroidalCutter<%s,%f,R=%f,r=%f>" % (self.location,self.radius,self.majorradius,self.minorradius)
def to_mged(self):
s = ""
s += "in cutter%d_tor.s tor" % (self.id)
s += " %f %f %f" % (self.center.x, self.center.y, self.center.z)
s += " %f %f %f" % (0, 0, 1)
s += " %f %f" % (self.majorradius, self.minorradius)
s += "\n"
s += "in cutter%d_cyl.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.center.x, self.center.y, self.center.z, self.height, self.radius)
s += "\n"
s += "in cutter%d_bot.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.center.x, self.center.y, self.center.z, -self.minorradius, self.majorradius)
s += "\n"
s += "comb cutter%d_tor.c u cutter%d_tor.s - cutter%d_cyl.s - cutter%d_bot.s\n" % (self.id, self.id, self.id, self.id)
s += "comb cutter%d_cyl.c u cutter%d_cyl.s\n" % (self.id, self.id)
s += "comb cutter%d_bot.c u cutter%d_bot.s\n" % (self.id, self.id)
s += "r cutter%d.r u cutter%d_tor.c u cutter%d_cyl.c u cutter%d_bot.c\n" % (self.id, self.id, self.id, self.id)
return s
def to_OpenGL(self):
glPushMatrix()
glTranslate(self.center.x, self.center.y, self.center.z)
glutSolidTorus(self.majorradius, self.minorradius, 20, 10)
if not hasattr(self,"_cylinder"):
self._cylinder = gluNewQuadric()
gluCylinder(self._cylinder, self.radius, self.radius, self.height, 20, 10)
glPopMatrix()
glPushMatrix()
glTranslate(self.location.x, self.location.y, self.location.z)
if not hasattr(self,"_disk"):
self._disk = gluNewQuadric()
gluDisk(self._disk, 0, self.majorradius, 20, 10)
glPopMatrix()
def moveto(self, location):
BaseCutter.moveto(self, location)
self.center = Point(location.x, location.y, location.z+self.minorradius)
def intersect_torus_plane(self, direction, triangle):
(ccp,cp,l) = intersect_torus_plane(self.center, self.axis, self.majorradius, self.minorradius, direction, triangle)
if cp:
cl = cp.add(self.location.sub(ccp))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_torus_triangle(self, direction, triangle):
(cl,ccp,cp,d) = self.intersect_torus_plane(direction, triangle)
if cp and triangle.point_inside(cp):
return (cl,d)
return (None,INFINITE)
def intersect_torus_point(self, direction, point):
(ccp,cp,l) = intersect_torus_point(self.center, self.axis, self.majorradius, self.minorradius, self.majorradiussq, self.minorradiussq, direction, point)
if ccp:
cl = point.add(self.location.sub(ccp))
return (cl, ccp, point, l)
return (None, None, None, INFINITE)
def intersect_torus_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_torus_point(direction, point)
return (cl,l)
def intersect_torus_edge(self, direction, edge): # TODO: calculate "optimal" scale = max(dir.dot(axis)/minor,dir.dot(dir.cross(axis).normalized())/major)
# "When in doubt, use brute force." Ken Thompson
min_m = 0
min_l = INFINITE
min_cl = None
scale = int(edge.len()/self.minorradius*2)
if scale<3:
scale = 3
for i in range(0,scale+1):
m = float(i)/(scale)
p = edge.point(m)
(cl,ccp,cp,l) = self.intersect_torus_point(direction, p)
if not cl:
continue
if l<min_l:
min_m = m
min_l = l
min_cl = cl
if min_l == INFINITE:
return (None, INFINITE)
scale2 = 10
for i in range(1,scale2+1):
m = min_m + ((float(i)/(scale2))*2-1)/scale
if m<0 or m>1:
continue
p = edge.point(m)
(cl,ccp,cp,l) = self.intersect_torus_point(direction, p)
if not cl:
continue
if l<min_l:
min_l = l
min_cl = cl
return (min_cl, min_l)
def intersect_cylinder_point(self, direction, point):
(ccp,cp,l) = intersect_cylinder_point(self.center, self.axis, self.radius, self.radiussq, direction, point)
# offset intersection
if ccp:
cl = self.location.add(direction.mul(l))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_cylinder_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_cylinder_point(direction, point)
if ccp and ccp.z < self.center.z:
return (None, INFINITE)
return (cl, l)
def intersect_cylinder_line(self, direction, edge):
(ccp,cp,l) = intersect_cylinder_line(self.center, self.axis, self.radius, self.radiussq, direction, edge)
# offset intersection
if ccp:
cl = self.location.add(cp.sub(ccp))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_cylinder_edge(self, direction, edge):
(cl,ccp,cp,l) = self.intersect_cylinder_line(direction, edge)
if ccp and ccp.z<self.center.z:
return (None,INFINITE)
if ccp:
m = cp.sub(edge.p1).dot(edge.dir())
if m<0 or m>edge.len():
return (None,INFINITE)
return (cl,l)
def intersect_circle_plane(self, direction, triangle):
(ccp,cp,l) = intersect_circle_plane(self.center, self.majorradius, direction, triangle)
# offset intersection
if ccp:
cl = cp.sub(ccp.sub(self.location))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_circle_triangle(self, direction, triangle):
(cl,ccp,cp,d) = self.intersect_circle_plane(direction, triangle)
if cp and triangle.point_inside(cp):
return (cl,d)
return (None,INFINITE)
def intersect_circle_point(self, direction, point):
(ccp, cp, l) = intersect_circle_point(self.location, self.axis, self.majorradius, self.majorradiussq, direction, point)
if ccp:
cl = cp.sub(ccp.sub(self.location))
return (cl,ccp,point,l)
return (None,None,None,INFINITE)
def intersect_circle_vertex(self, direction, point):
(cl,ccp,cp,l) = self.intersect_circle_point(direction, point)
return (cl,l)
def intersect_circle_line(self, direction, edge):
(ccp,cp,l) = intersect_circle_line(self.location, self.axis, self.majorradius, self.majorradiussq, direction, edge)
if ccp:
cl = cp.sub(ccp.sub(self.location))
return (cl,ccp,cp,l)
return (None, None, None, INFINITE)
def intersect_circle_edge(self, direction, edge):
(cl,ccp,cp,l) = self.intersect_circle_line(direction, edge)
if cp:
# check if the contact point is between the endpoints
m = cp.sub(edge.p1).dot(edge.dir())
if m<0 or m>edge.len():
return (None,INFINITE)
return (cl,l)
def intersect(self, direction, triangle):
(cl_t,d_t) = self.intersect_torus_triangle(direction, triangle)
(cl_p1,d_p1) = self.intersect_torus_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_torus_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_torus_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_torus_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_torus_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_torus_edge(direction, Line(triangle.p3,triangle.p1))
d = INFINITE
cl = None
if d_t < d:
d = d_t
cl = cl_t
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
(cl_t,d_t) = self.intersect_circle_triangle(direction, triangle)
(cl_p1,d_p1) = self.intersect_circle_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_circle_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_circle_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_circle_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_circle_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_circle_edge(direction, Line(triangle.p3,triangle.p1))
if d_t < d:
d = d_t
cl = cl_t
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
if direction.x != 0 or direction.y != 0:
(cl_p1,d_p1) = self.intersect_cylinder_vertex(direction, triangle.p1)
(cl_p2,d_p2) = self.intersect_cylinder_vertex(direction, triangle.p2)
(cl_p3,d_p3) = self.intersect_cylinder_vertex(direction, triangle.p3)
(cl_e1,d_e1) = self.intersect_cylinder_edge(direction, Line(triangle.p1,triangle.p2))
(cl_e2,d_e2) = self.intersect_cylinder_edge(direction, Line(triangle.p2,triangle.p3))
(cl_e3,d_e3) = self.intersect_cylinder_edge(direction, Line(triangle.p3,triangle.p1))
if d_p1 < d:
d = d_p1
cl = cl_p1
if d_p2 < d:
d = d_p2
cl = cl_p2
if d_p3 < d:
d = d_p3
cl = cl_p3
if d_e1 < d:
d = d_e1
cl = cl_e1
if d_e2 < d:
d = d_e2
cl = cl_e2
if d_e3 < d:
d = d_e3
cl = cl_e3
return (cl,d)
list = [ "SphericalCutter", "CylindricalCutter", "ToroidalCutter" ]
__all__ = [ "BaseCutter" ] + list
from BaseCutter import BaseCutter
from SphericalCutter import SphericalCutter
from CylindricalCutter import CylindricalCutter
from ToroidalCutter import ToroidalCutter
from pycam.Geometry import *
class MGEDExporter:
def __init__(self, filename):
self.file = file(filename,"w")
def close(self):
self.file.close()
def AddCutter(self, cutter):
self.file.write(cutter.to_mged())
def AddModel(self, model):
self.file.write(model.to_mged())
def AddPath(self, path):
prev = path.points[0]
for i in range(1, len(path.points)):
next = path.points[i]
self.file.write(Line(prev,next).to_mged())
prev = next
def AddPathList(self, pathlist):
for path in pathlist:
self.AddPath(path)
from gcode import gcode
# simplistic GCode exporter
# does each run, and moves the tool to the safetyheight in between
class SimpleGCodeExporter:
def __init__(self, filename, safetyheight=7.0, homeheight=7.0):
self.file = file(filename,"w")
self.gcode = gcode(homeheight, safetyheight)
gc = self.gcode
self.file.write(gc.begin()+"\n")
self.file.write(gc.safety()+"\n")
def close(self):
gc = self.gcode
self.file.write(gc.safety()+"\n")
self.file.write(gc.end()+"\n")
self.file.close()
def AddPath(self, path):
gc = self.gcode
point = path.points[0]
self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
for point in path.points:
self.file.write(gc.cut(point.x,point.y,point.z)+"\n")
self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
def AddPathList(self, pathlist):
for path in pathlist:
self.AddPath(path)
def ExportPathList(filename, pathlist):
exporter = SimpleGCodeExporter(filename)
exporter.AddPathList(pathlist)
exporter.close()
list = ["MGEDExporter", "SimpleGCodeExporter"]
__all__ = list
## gcode.py is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2 of the License, or (at your
## option) any later version. gcode.py is distributed in the hope that it
## will be useful, but WITHOUT ANY WARRANTY; without even the implied
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
## the GNU General Public License for more details. You should have
## received a copy of the GNU General Public License along with gcode.py; if
## not, write to the Free Software Foundation, Inc., 59 Temple Place,
## Suite 330, Boston, MA 02111-1307 USA
##
## gcode.py is Copyright (C) 2005 Chris Radek
## chris@timeguy.com
class gcode:
lastx = lasty = lastz = lasta = lastgcode = None
lastfeed = None
def __init__(self, homeheight = 1.5, safetyheight = 0.04):
self.homeheight = homeheight
self.safetyheight = self.lastz = safetyheight
def begin(self):
return "G00 Z%.4f\n" % (self.safetyheight) + \
"G17 G21 G40 G49\n" + "G54 G80 G90 G94\n" + \
"S1000 M3\n" + "G04 P3" + \
"T1 M6 F0.1\n"
def end(self):
return self.safety() + "\n" + "M2\n"
def exactpath(self):
return "G61"
def continuous(self):
return "G64"
def rapid(self, x = None, y = None, z = None, a = None, gcode = "G00", feed=None):
gcodestring = feedstring = xstring = ystring = zstring = astring = ""
if x == None: x = self.lastx
if y == None: y = self.lasty
if z == None: z = self.lastz
if a == None: a = self.lasta
if gcode != self.lastgcode:
gcodestring = gcode
self.lastgcode = gcode
if x != self.lastx:
xstring = " X%.4f" % (x)
self.lastx = x
if y != self.lasty:
ystring = " Y%.4f" % (y)
self.lasty = y
if z != self.lastz:
zstring = " Z%.4f" % (z)
self.lastz = z
if a != self.lasta:
astring = " A%.4f" % (a)
self.lasta = a
if gcode == "G01" and feed and feed != self.lastfeed:
feedstring = " F%.4f" % (feed)
self.lastfeed = feed
return gcodestring + feedstring + xstring + ystring + zstring + astring
def cut(self, x = None, y = None, z = None, a = None, feed=None):
if x == None: x = self.lastx
if y == None: y = self.lasty
if z == None: z = self.lastz
if a == None: a = self.lasta
return self.rapid(x, y, z, a, gcode="G01", feed=feed)
def home(self):
return self.rapid(z=self.homeheight)
def safety(self):
return self.rapid(z=self.safetyheight)
import math
class Line:
id=0
def __init__(self,p1,p2):
self.id = Line.id
Line.id += 1
self.p1 = p1
self.p2 = p2
def __repr__(self):
return "Line<%g,%g,%g>-<%g,%g,%g>" % (self.p1.x,self.p1.y,self.p1.z,
self.p2.x,self.p2.y,self.p2.z)
def to_mged(self):
s = ""
s += "in line%d rcc %f %f %f %f %f %f 0.01\n" % (self.id,
self.p1.x,self.p1.y,self.p1.z,
self.p2.x-self.p1.x,self.p2.y-self.p1.y,self.p2.z-self.p1.z)
return s
def dir(self):
if not hasattr(self,"_dir"):
self._dir = self.p2.sub(self.p1)
self._dir.normalize()
return self._dir
def len(self):
if not hasattr(self,"_len"):
self._len = self.p2.sub(self.p1).norm()
return self._len
def point(self, l):
return self.p1.add(self.dir().mul(l*self.len()))
def closest_point(self, p):
v = self.dir()
l = self.p1.dot(v)-p.dot(v)
return self.p1.sub(v.mul(l))
def dist_to_point_sq(self, p):
return p.sub(self.closest_point(p)).normsq()
def dist_to_point(self, p):
return sqrt(self.dist_to_point_sq(p))
from utils import *
from Point import *
from Line import *
from Triangle import *
try:
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
except:
pass
class Model:
id = 0
def __init__(self):
self.id = Model.id
Model.id += 1
self._triangles = []
self.name = "model%d" % self.id
def to_mged(self): # TODO: optimize to not export points multiple times
s = "in %s bot" % self.name
s += " %d" % (len(self._triangles)*3)
s += " %d" % len(self._triangles)
s += " 1 3"
for t in self._triangles:
s += " %g %g %g" % (t.p1.x,t.p1.y,t.p1.z)
s += " %g %g %g" % (t.p2.x,t.p2.y,t.p2.z)
s += " %g %g %g" % (t.p3.x,t.p3.y,t.p3.z)
i = 0
for t in self._triangles:
s += " %d %d %d" % (i, i+1, i+2)
i += 3
s += "\n"
return s
def to_OpenGL(self):
if True:
glBegin(GL_TRIANGLES)
for t in self._triangles:
glVertex3f(t.p1.x, t.p1.y, t.p1.z)
glVertex3f(t.p2.x, t.p2.y, t.p2.z)
glVertex3f(t.p3.x, t.p3.y, t.p3.z)
glEnd()
else:
for t in self._triangles:
t.to_OpenGL()
def append(self, t):
self._triangles.append(t)
def triangles(self):
return self._triangles
def subdivide(self, depth):
model = Model()
for t in self._triangles:
for s in t.subdivide(depth):
model.append(s)
return model
class Path:
id = 0
def __init__(self):
self.id = Path.id
Path.id += 1
self.top_join = None
self.bot_join = None
self.winding=0
self.points = []
def __repr__(self):
s = ""
s += "path %d: " % self.id
first = True
for p in self.points:
if first:
first = False
else:
s +="-"
s += "%d(%g,%g,%g)" % (p.id, p.x, p.y, p.z)
return s
def append(self, p):
self.points.append(p)
def reverse(self):
self.points.reverse()
from Point import *
class Plane:
id = 0
def __init__(self, p, n):
self.id = Plane.id
Plane.id += 1
self.p = p
self.n = n
def __repr__(self):
return "Plane<%s,%s>" % (self.p,self.n)
def to_mged(self):
s = ""
s += "in plane%d half"%(self.id)
s += " %f %f %f"% (self.n.x, self.n.y, self.n.z)
s += " %f "% (self.p.dot(self.n))
s += "\n"
return s
import math
class Point:
id=0
def __init__(self,x,y,z):
self.id = Point.id
Point.id += 1
self.x = float(x)
self.y = float(y)
self.z = float(z)
def __repr__(self):
return "Point<%g,%g,%g>" % (self.x,self.y,self.z)
def to_mged(self):
s = ""
s += "in point%d sph %f %f %f 0.03\n" % (self.id,self.x,self.y,self.z)
return s
def mul(self, c):
return Point(self.x*c,self.y*c,self.z*c)
def div(self, c):
return Point(self.x/c,self.y/c,self.z/c)
def add(p1, p2):
return Point(p1.x+p2.x,p1.y+p2.y,p1.z+p2.z)
def sub(p1, p2):
return Point(p1.x-p2.x,p1.y-p2.y,p1.z-p2.z)
def dot(p1, p2):
return p1.x*p2.x + p1.y*p2.y + p1.z*p2.z
def cross(p1, p2):
return Point(p1.y*p2.z-p2.y*p1.z, p2.x*p1.z-p1.x*p2.z, p1.x*p2.y-p2.x*p1.y)
def normsq(self):
if not hasattr(self, "_normsq"):
self._normsq = self.dot(self)
return self._normsq
def norm(self):
if not hasattr(self, "_norm"):
self._norm = math.sqrt(self.normsq())
return self._norm
def normalize(self):
n = self.norm()
self.x /= n
self.y /= n
self.z /= n
self._norm = 1.0
self._normsq = 1.0
from pycam.Utils.iterators import *
from pycam.Geometry.utils import *
from pycam.Geometry.Path import *
from pycam.Geometry.Point import *
DEBUG_POLYGONEXTRACTOR=False
class PolygonExtractor:
CONTOUR=1
MONOTONE=2
def __init__(self, policy=MONOTONE):
self.policy = policy
def append(self, p):
if (self.current_dir==0):
self.curr_line.append(p)
elif self.current_dir==1:
# store as flipped
self.curr_line.append(Point(p.y, p.x, p.z))
def new_direction(self, dir):
self.current_dir = dir
self.all_path_list = []
self.curr_path_list = []
self.prev_line = []
self.curr_line = []
def end_direction(self):
self.new_scanline()
self.end_scanline()
if DEBUG_POLYGONEXTRACTOR: print "%d paths" % len(self.all_path_list)
for path in self.all_path_list:
if DEBUG_POLYGONEXTRACTOR: print "%d:" % path.id,
if DEBUG_POLYGONEXTRACTOR: print "%d ->" % path.top_join.id
for point in path.points:
if DEBUG_POLYGONEXTRACTOR: print "(%g,%g)" % (point.x, point.y),
if DEBUG_POLYGONEXTRACTOR: print "->%d" % path.bot_join.id
path_list = []
while len(self.all_path_list)>0:
p0 = self.all_path_list[0]
for path in self.all_path_list:
if path.id < p0.id:
p0 = path
if DEBUG_POLYGONEXTRACTOR: print "linking %d" % p0.id
self.all_path_list.remove(p0)
p1 = p0.bot_join
while True:
if DEBUG_POLYGONEXTRACTOR: print "splice %d into %d" % (p1.id, p0.id)
self.all_path_list.remove(p1)
p1.reverse()
p0.points += p1.points
if p1.top_join == p0:
break;
p2 = p1.top_join
if DEBUG_POLYGONEXTRACTOR: print "splicing %d into %d" % (p2.id, p0.id)
self.all_path_list.remove(p2)
p0.points += p2.points
p1 = p2.bot_join
path_list.append(p0)
if DEBUG_POLYGONEXTRACTOR: print "%d paths" % len(path_list)
for path in path_list:
if DEBUG_POLYGONEXTRACTOR: print "path %d(w=%d): " % (path.id, path.winding),
for point in path.points:
if DEBUG_POLYGONEXTRACTOR: print "(%g,%g)" % (point.x, point.y),
if DEBUG_POLYGONEXTRACTOR: print
if self.current_dir==0:
self.hor_path_list = path_list
elif self.current_dir==1:
# flip back since we stored the points flipped (see add_point)
for path in path_list:
path.reverse()
for point in path.points:
(point.x,point.y) = (point.y,point.x)
self.ver_path_list = path_list
def finish(self):
if self.policy == PolygonExtractor.CONTOUR:
if self.hor_path_list and self.ver_path_list:
self.merge_path_lists()
def new_scanline(self):
self.curr_line = []
def end_scanline(self):
last = 0
inside = False
s = ""
for point in self.curr_line:
next = point.x
if inside:
s += "*" * int(next-last)
else:
s += " " * int(next-last)
last = next
inside = not inside
if DEBUG_POLYGONEXTRACTOR: print s
if DEBUG_POLYGONEXTRACTOR: print "active paths: ",
for path in self.curr_path_list:
if DEBUG_POLYGONEXTRACTOR: print "%d(%g,%g)" % (path.id, path.points[-1].x, path.points[-1].y),
if DEBUG_POLYGONEXTRACTOR: print
if DEBUG_POLYGONEXTRACTOR: print "prev points: ",
for point in self.prev_line:
if DEBUG_POLYGONEXTRACTOR: print "(%g,%g)" % (point.x, point.y),
if DEBUG_POLYGONEXTRACTOR: print
if DEBUG_POLYGONEXTRACTOR: print "active points: ",
for point in self.curr_line:
if DEBUG_POLYGONEXTRACTOR: print "(%g,%g)" % (point.x, point.y),
if DEBUG_POLYGONEXTRACTOR: print
prev_point = Iterator(self.prev_line)
curr_point = Iterator(self.curr_line)
curr_path = Iterator(self.curr_path_list)
winding = 0
while prev_point.remains()>0 or curr_point.remains()>0:
if DEBUG_POLYGONEXTRACTOR: print "num_prev=", prev_point.remains(), ", num_curr=",curr_point.remains()
if prev_point.remains()==0 and curr_point.remains()>=2:
c0 = curr_point.next()
c1 = curr_point.next()
# new path starts
p0 = Path()
p0.winding = winding+1
if DEBUG_POLYGONEXTRACTOR: print "new path %d(%g,%g)" % ( p0.id, c0.x, c0.y)
p0.append(c0)
self.curr_path_list.append(p0)
p1 = Path()
p1.winding = winding
if DEBUG_POLYGONEXTRACTOR: print "new path %d(%g,%g)" % (p1.id, c1.x, c1.y)
p1.append(c1)
self.curr_path_list.append(p1)
p0.top_join = p1
p1.top_join = p0
continue
if prev_point.remains()>=2 and curr_point.remains()==0:
#old path ends
p0 = curr_path.takeNext()
if DEBUG_POLYGONEXTRACTOR: print "end path %d" % p0.id
self.all_path_list.append(p0)
prev_point.next()
p1 = curr_path.takeNext()
if DEBUG_POLYGONEXTRACTOR: print "end path %d" % p1.id
self.all_path_list.append(p1)
prev_point.next()
p0.bot_join = p1
p1.bot_join = p0
continue
if prev_point.remains()>=2 and curr_point.remains()>=2:
p0 = prev_point.peek(0)
p1 = prev_point.peek(1)
c0 = curr_point.peek(0)
c1 = curr_point.peek(1)
if DEBUG_POLYGONEXTRACTOR: print "overlap test: p0=%g p1=%g" % (p0.x, p1.x)
if DEBUG_POLYGONEXTRACTOR: print "overlap test: c0=%g c1=%g" % (c0.x, c1.x)
if c1.x < p0.x:
# new segment is completely to the left
# new path starts
s0 = Path()
if DEBUG_POLYGONEXTRACTOR: print "new path %d(%g,%g) w=%d" % (s0.id, c0.x, c0.y, winding+1)
s0.append(c0)
curr_path.insert(s0)
s1 = Path()
s0.winding = winding+1
s1.winding = winding
if DEBUG_POLYGONEXTRACTOR: print "new path %d(%g,%g) w=%d" % (s1.id, c1.x, c1.y, winding)
s1.append(c1)
curr_path.insert(s1)
curr_point.next()
curr_point.next()
s0.top_join = s1
s1.top_join = s0
elif c0.x > p1.x:
# new segment is completely to the right
# old path ends
s0 = curr_path.takeNext()
if DEBUG_POLYGONEXTRACTOR: print "end path %d" % s0.id
self.all_path_list.append(s0)
prev_point.next()
s1 = curr_path.takeNext()
if DEBUG_POLYGONEXTRACTOR: print "end path %d" % s1.id
self.all_path_list.append(s1)
prev_point.next()
s0.bot_join = s1;
s1.bot_join = s0;
winding = s1.winding;
else:
# new segment is overlapping
left_path = curr_path.next()
right_path = curr_path.peek()
left_point = c0
right_point = c1
winding = left_path.winding
curr_point.next()
prev_point.next()
overlap_p = True
overlap_c = True
while overlap_c or overlap_p:
overlap_p = False
overlap_c = False
# check for path joins
if prev_point.remains()>=2:
p2 = prev_point.peek(1)
if DEBUG_POLYGONEXTRACTOR: print "join test: p0=%g p1=%g p2=%g" % (p0.x, p1.x, p2.x)
if DEBUG_POLYGONEXTRACTOR: print "join test: c0=%g c1=%g" % (c0.x, c1.x)
if p2.x <= c1.x:
overlap_p = True
if self.policy == PolygonExtractor.CONTOUR:
s0 = curr_path.takeNext()
s1 = curr_path.takeNext()
if curr_path.remains()>=1:
right_path = curr_path.peek()
self.all_path_list.append(s0)
self.all_path_list.append(s1);
if DEBUG_POLYGONEXTRACTOR: print "path %d joins %d" % (s0.id, s1.id)
s0.bot_join = s1;
s1.bot_join = s0;
elif self.policy == PolygonExtractor.MONOTONE:
s0 = curr_path.takeNext()
left_path.bot_join = s0
s0.bot_join = left_path
if DEBUG_POLYGONEXTRACTOR: print "path %d joins %d" % (left_path.id, s0.id)
curr_path.remove(left_path)
self.all_path_list.append(left_path)
self.all_path_list.append(s0)
s1 = curr_path.next()
left_path = s1
right_path = curr_path.peek()
prev_point.next()
prev_point.next()
winding = s1.winding
p0 = p2
if prev_point.remains()>=1:
p1 = prev_point.peek(0)
else:
overlap_p = False
# check for path splits
if curr_point.remains()>=2:
c2 = curr_point.peek(1)
if DEBUG_POLYGONEXTRACTOR: print "split test: p0=%g p1=%g" % (p0.x, p1.x)
if DEBUG_POLYGONEXTRACTOR: print "split test: c0=%g c1=%g c2=%g" % (c0.x, c1.x, c2.x)
if c2.x <= p1.x:
overlap_c = True
s0 = Path()
s1 = Path()
s0.winding=winding+1
s1.winding=winding
s0.top_join = s1
s1.top_join = s0
if DEBUG_POLYGONEXTRACTOR: print "region split into %d and %d (w=%d)" %(s0.id, s1.id, winding+1)
curr_point.next()
c0 = curr_point.next()
if self.policy == PolygonExtractor.CONTOUR:
s0.append(c1)
curr_path.insert(s0)
s1.append(c2)
curr_path.insert(s1)
elif self.policy == PolygonExtractor.MONOTONE:
s0.append(left_point)
s1.append(c1)
curr_path.insertBefore(s0)
curr_path.insertBefore(s1)
left_point = c2
if curr_point.remains()>=1:
c1 = curr_point.peek(0)
right_point = c1
else:
overlap_c = False
if DEBUG_POLYGONEXTRACTOR: print "add to path %d(%g,%g)" % (left_path.id, left_point.x, left_point.y)
left_path.append(left_point)
right_path.append(right_point)
if right_path == curr_path.peek():
curr_path.next()
if DEBUG_POLYGONEXTRACTOR: print "add to path %d(%g,%g)" % (right_path.id, right_point.x, right_point.y)
winding = right_path.winding;
prev_point.next()
curr_point.next()
if DEBUG_POLYGONEXTRACTOR: print "active paths: ",
for path in self.curr_path_list:
if DEBUG_POLYGONEXTRACTOR: print "%d(%g,%g,w=%d)" % (path.id, path.points[-1].x, path.points[-1].y, path.winding),
if DEBUG_POLYGONEXTRACTOR: print
self.prev_line = self.curr_line
def merge_path_lists(self):
self.merge_path_list = []
pass
dx = 1
dy = 1
# find matching path to merge with */
for s0 in self.hor_path_list:
if DEBUG_POLYGONEXTRACTOR: print "merging %d" % s0.id
if DEBUG_POLYGONEXTRACTOR: print "s0=", s0
#TODO: store/cache topmost point inside the path
# find top of path to merge
point_iter = Iterator(s0.points)
top0 = CyclicIterator(point_iter.seq, point_iter.ind)
min_x0 = top0.peek().x
min_y0 = top0.peek().y
while point_iter.remains()>0:
point = point_iter.peek()
if point and ((point.y<min_y0) or (point.y==min_y0 and point.x>min_x0)):
min_y0 = point.y
min_x0 = point.x
top0 = CyclicIterator(point_iter.seq, point_iter.ind)
point_iter.next()
if DEBUG_POLYGONEXTRACTOR: print "top0: x=", min_x0, "y=",min_y0, "p=",top0.peek().id
# find matching path to merge with
path_iter = Iterator(self.ver_path_list)
while path_iter.remains()>0:
s1 = path_iter.next()
if DEBUG_POLYGONEXTRACTOR: print "trying %d" % s1.id
if DEBUG_POLYGONEXTRACTOR: print "s1=", s1
min_d = -1
point_iter = Iterator(s1.points)
top1 = None
min_x1 = 0
min_y1 = 0
while point_iter.remains()>0:
point = point_iter.peek()
# check points in second quadrant # TODO: if none found: check other quadrants
if point.y<=min_y0 and point.x<=min_x0:
d = sqr(point.x-min_x0)+sqr(point.y-min_y0)
if (d<min_d or top1==None):
min_x1 = point.x
min_y1 = point.y
min_d = d
top1 = CyclicIterator(point_iter.seq, point_iter.ind)
point_iter.next()
if DEBUG_POLYGONEXTRACTOR: print "min_y0=%g min_y1=%g (d=%g)" % (min_y0, min_y1, min_d)
if min_d < 0:
continue
if DEBUG_POLYGONEXTRACTOR: print "top1: x=", min_x1, "y=",min_y1, "p=",top1.peek().id
if (min_y1 >= min_y0-dy) and (min_y1 <= min_y0+dy) and (min_x1 >= min_x0-dx) and (min_x1 <= min_x0+dx):
# we have a potential match
if DEBUG_POLYGONEXTRACTOR: print "matched %d" % s1.id
if DEBUG_POLYGONEXTRACTOR: print "i0=%d i1=%d" % (top0.peek().id, top1.peek().id)
if DEBUG_POLYGONEXTRACTOR: print "s1=", s1
total = len(s0.points) + len(s1.points)
p = Path()
p.winding = s0.winding
p0 = top0.next()
p1 = top1.next()
next_p0 = top0.peek()
next_p1 = top1.peek()
if p0.y == next_p0.y:
while (p1.y < p0.y) and (next_p1.y < p0.y) and (p0.x <= p1.x) and (p1.x <= next_p0.x):
p1 = top1.next()
next_p1 = top1.peek()
if DEBUG_POLYGONEXTRACTOR: print "top0=%d: (%g,%g)" % (p0.id, p0.x, p0.y)
if DEBUG_POLYGONEXTRACTOR: print "top1=%d: (%g,%g)" % (p1.id, p1.x, p1.y)
last = p0;
pathlen = 0
while pathlen < total:
next_p0 = top0.peek()
next_p1 = top1.peek()
pathlen = len(p.points)
if DEBUG_POLYGONEXTRACTOR: print "last=%d: (%g, %g)" % (last.id, last.x, last.y)
if DEBUG_POLYGONEXTRACTOR: print "p0: %d(%g,%g)\t" % (p0.id, p0.x, p0.y),
if DEBUG_POLYGONEXTRACTOR: print "next_p0: %d(%g,%g)" % (next_p0.id, next_p0.x, next_p0.y)
if DEBUG_POLYGONEXTRACTOR: print "p1: %d(%g,%g)\t" % (p1.id, p1.x, p1.y),
if DEBUG_POLYGONEXTRACTOR: print "next_p1: %d(%g,%g)" % (next_p1.id, next_p1.x, next_p1.y)
if DEBUG_POLYGONEXTRACTOR: print "|p1-last|=%g |p0-last|=%g" % (sqr(p1.x - last.x) + sqr(p1.y - last.y), sqr(p0.x - last.x) + sqr(p0.y - last.y))
if sqr(p1.x - last.x) + sqr(p1.y - last.y) < sqr(p0.x - last.x) + sqr(p0.y - last.y):
if DEBUG_POLYGONEXTRACTOR: print "0: p1=%d: (%g,%g)" % (p1.id, p1.x, p1.y)
p.append(p1)
last = p1
p1 = top1.next()
continue
else:
if DEBUG_POLYGONEXTRACTOR: print "1: p0=%d: (%g,%g)" % (p0.id, p0.x, p0.y)
p.append(p0)
last = p0
p0 = top0.next()
continue;
if pathlen == len(p):
if DEBUG_POLYGONEXTRACTOR: print "failed: size=%d total=%d" %(len(p), total)
p = None
break
if p:
self.merge_path_list.append(p)
if DEBUG_POLYGONEXTRACTOR: print "done: size=%d total=%d" % (len(p.points), total)
break
from Point import *
from Plane import *
from utils import *
ORIENTATION_CCW = 2
ORIENTATION_CW = 3
try:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
except:
pass
class Triangle:
id = 0
# points are expected to be in ClockWise order
def __init__(self, p1=None, p2=None, p3=None):
self.id = Triangle.id
Triangle.id += 1
self.p1 = p1
self.p2 = p2
self.p3 = p3
def __repr__(self):
return "Triangle<%s,%s,%s>" % (self.p1,self.p2,self.p3)
def name(self):
return "triangle%d" % self.id
def to_mged(self, sphere=False):
s = "in %s bot 3 1" % self.name()
s += " 1 3"
s += " %f %f %f" % (self.p1.x,self.p1.y,self.p1.z)
s += " %f %f %f" % (self.p2.x,self.p2.y,self.p2.z)
s += " %f %f %f" % (self.p3.x,self.p3.y,self.p3.z)
s += " 0 1 2"
s += "\n"
if sphere and hasattr(self, "_center"):
s += "in %s_sph sph " % self.name()
s += " %f %f %f" % (self._center.x, self._center.y, self._center.z)
s += " %f" % self._radius
s += "\n"
return s
def to_OpenGL(self):
glBegin(GL_TRIANGLES)
glVertex3f(self.p1.x, self.p1.y, self.p1.z)
glVertex3f(self.p2.x, self.p2.y, self.p2.z)
glVertex3f(self.p3.x, self.p3.y, self.p3.z)
glEnd()
if hasattr(self, "_center"):
glPushMatrix()
glTranslate(self._center.x, self._center.y, self._center.z)
if not hasattr(self,"_sphere"):
self._sphere = gluNewQuadric()
gluSphere(self._sphere, self._radius, 10, 10)
glPopMatrix()
def normal(self):
if not hasattr(self, '_normal'):
self._normal = self.p3.sub(self.p1).cross(self.p2.sub(self.p1))
denom = self._normal.norm()
# # TODO: fix kludge: make surface normal point up for now
# if self._normal.z < 0:
# denom = -denom
self._normal = self._normal.div(denom)
return self._normal
def plane(self):
if not hasattr(self, '_plane'):
if hasattr(self, '_center'):
self._plane=Plane(self._center, self.normal())
else:
self._plane=Plane(self.p1, self.normal())
return self._plane
def point_inside(self, p):
# http://www.blackpawn.com/texts/pointinpoly/default.html
# Compute vectors
v0 = self.p3.sub(self.p1)
v1 = self.p2.sub(self.p1)
v2 = p.sub(self.p1)
# Compute dot products
dot00 = v0.dot(v0)
dot01 = v0.dot(v1)
dot02 = v0.dot(v2)
dot11 = v1.dot(v1)
dot12 = v1.dot(v2)
# Compute barycentric coordinates
invDenom = 1 / (dot00 * dot11 - dot01 * dot01)
u = (dot11 * dot02 - dot01 * dot12) * invDenom
v = (dot00 * dot12 - dot01 * dot02) * invDenom
# Check if point is in triangle
return (u > 0) and (v > 0) and (u + v < 1)
def minx(self):
if not hasattr(self, "_minx"):
self._minx = min3(self.p1.x, self.p2.x, self.p3.x)
return self._minx
def miny(self):
if not hasattr(self, "_miny"):
self._miny = min3(self.p1.y, self.p2.y, self.p3.y)
return self._miny
def minz(self):
if not hasattr(self, "_minz"):
self._minz = min3(self.p1.z, self.p2.z, self.p3.z)
return self._minz
def maxx(self):
if not hasattr(self, "_maxx"):
self._maxx = max3(self.p1.x, self.p2.x, self.p3.x)
return self._maxx
def maxy(self):
if not hasattr(self, "_maxy"):
self._maxy = max3(self.p1.y, self.p2.y, self.p3.y)
return self._maxy
def maxz(self):
if not hasattr(self, "_maxz"):
self._maxz = max3(self.p1.z, self.p2.z, self.p3.z)
return self._maxz
def center(self):
if not hasattr(self, "_center"):
self.calc_circumcircle()
return self._center
def radius(self):
if not hasattr(self, "_radius"):
self.calc_circumcircle()
return self._radius
def radiussq(self):
if not hasattr(self, "_radiussq"):
self.calc_circumcircle()
return self._radiussq
def calc_circumcircle(self):
normal = self.p2.sub(self.p1).cross(self.p3.sub(self.p2))
denom = normal.norm()
self._radius = (self.p2.sub(self.p1).norm()*self.p3.sub(self.p2).norm()*self.p3.sub(self.p1).norm())/(2*denom)
self._radiussq = self._radius*self._radius
denom2 = 2*denom*denom;
alpha = self.p3.sub(self.p2).normsq()*(self.p1.sub(self.p2).dot(self.p1.sub(self.p3))) / (denom2)
beta = self.p1.sub(self.p3).normsq()*(self.p2.sub(self.p1).dot(self.p2.sub(self.p3))) / (denom2)
gamma = self.p1.sub(self.p2).normsq()*(self.p3.sub(self.p1).dot(self.p3.sub(self.p2))) / (denom2)
self._center = Point(self.p1.x*alpha+self.p2.x*beta+self.p3.x*gamma,
self.p1.y*alpha+self.p2.y*beta+self.p3.y*gamma,
self.p1.z*alpha+self.p2.z*beta+self.p3.z*gamma)
def subdivide(self, depth):
sub = []
if depth == 0:
sub.append(self)
else:
p4 = self.p1.add(self.p2).div(2)
p5 = self.p2.add(self.p3).div(2)
p6 = self.p3.add(self.p1).div(2)
sub += Triangle(self.p1,p4,p6).subdivide(depth-1)
sub += Triangle(p6,p5,self.p3).subdivide(depth-1)
sub += Triangle(p6,p4,p5).subdivide(depth-1)
sub += Triangle(p4,self.p2,p5).subdivide(depth-1)
return sub
import math
from Point import *
from Line import *
from Triangle import *
from kdtree import *
def BuildKdtree2d(triangles, cutoff=3, cutoff_distance=1.0):
nodes = []
for t in triangles:
n = Node();
n.triangle = t
n.bound = []
n.bound.append(min(min(t.p1.x,t.p2.x),t.p3.x))
n.bound.append(min(min(t.p1.y,t.p2.y),t.p3.y))
n.bound.append(max(max(t.p1.x,t.p2.x),t.p3.x))
n.bound.append(max(max(t.p1.y,t.p2.y),t.p3.y))
nodes.append(n)
return kd_tree(nodes, cutoff, cutoff_distance)
tests = 0
hits = 0
overlaptest=True
mged = ""
def ResetKdtree2dStats(overlap=True):
global tests, hits, overlaptest
hits = 0
tests = 0
overlaptest = overlap
mged = ""
def GetKdtree2dStats():
global tests, hits
return (hits, tests)
def SearchKdtree2d(kdtree, minx, maxx, miny, maxy):
if kdtree.bucket:
triangles = []
for n in kdtree.nodes:
global tests, hits, overlaptest
tests += 1
if not overlaptest:
# print "not testing overlap"
triangles.append(n.triangle)
hits += 1
else:
if not (n.bound[0]>maxx
or n.bound[1]>maxy
or n.bound[2]<minx
or n.bound[3]<miny):
triangles.append(n.triangle)
hits += 1
return triangles
else:
# return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)+SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
if kdtree.cutdim==0:
if maxx<kdtree.minval:
return []
elif maxx<=kdtree.cutval:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)
else:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)+SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
elif kdtree.cutdim==1:
if maxy<kdtree.minval:
return []
elif maxy<=kdtree.cutval:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)
else:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)+SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
elif kdtree.cutdim==2:
if minx>kdtree.maxval:
return []
elif minx>kdtree.cutval:
return SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
else:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)+SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
elif kdtree.cutdim==3:
if miny>kdtree.maxval:
return []
elif miny>kdtree.cutval:
return SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
else:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)+SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
def SearchKdtree2d_mged(kdtree, minx, maxx, miny, maxy, _minx, _maxx, _miny, _maxy):
if kdtree.bucket:
s = ""
s += "in kdtree_%d arb8 " % kdtree.id
s += " %f %f %f " % (_minx, _miny, 0)
s += " %f %f %f " % (_maxx, _miny, 0)
s += " %f %f %f " % (_maxx, _maxy, 0)
s += " %f %f %f " % (_minx, _maxy, 0)
s += " %f %f %f " % (_minx, _miny, 10)
s += " %f %f %f " % (_maxx, _miny, 10)
s += " %f %f %f " % (_maxx, _maxy, 10)
s += " %f %f %f" % (_minx, _maxy, 10)
s += "\n"
return s
else:
if kdtree.cutdim==0:
if maxx<kdtree.minval:
return ""
elif maxx<=kdtree.cutval:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, kdtree.cutval, kdtree.maxval, _miny, _maxy)
elif kdtree.cutdim==1:
if maxy<kdtree.minval:
return ""
elif maxy<=kdtree.cutval:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, _minx, _maxx, kdtree.cutval, kdtree.maxval)
elif kdtree.cutdim==2:
if minx>kdtree.maxval:
return ""
elif minx>kdtree.cutval:
return SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, kdtree.cutval, kdtree.maxval, _miny, _maxy)
elif kdtree.cutdim==3:
if miny>kdtree.maxval:
return ""
elif miny>kdtree.cutval:
return SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, _minx, _maxx, kdtree.cutval, kdtree.maxval)
__all__ = ["utils", "Line", "Model", "Path", "Plane", "Point", "Triangle",
"PolygonExtractor", "TriangleKdtree", "intersection", "kdtree"]
from Point import Point
from Line import Line
from Triangle import Triangle
from Model import Model
from Path import Path
from Plane import Plane
from utils import *
from PolygonExtractor import PolygonExtractor
from math import sqrt
import pycam.Geometry
from pycam.Geometry.utils import *
from pycam.Geometry.Plane import Plane
from pycam.Geometry.Line import Line
from pycam.Geometry.Point import Point
def intersect_plane_point(plane, direction, point):
denom = plane.n.dot(direction)
if denom == 0:
return (None, INFINITE)
l = -(plane.n.dot(point) - plane.n.dot(plane.p)) / denom
cp = point.add(direction.mul(l))
return (cp, l)
def intersect_cylinder_point(center, axis, radius, radiussq, direction, point):
# take a plane along direction and axis
n = direction.cross(axis)
n.normalize()
# distance of the point to this plane
d = n.dot(point)-n.dot(center)
if d<-radius or d>radius:
return (None,None,INFINITE)
# ccl is on cylinder
d2 = sqrt(radiussq-d*d)
ccl = center.add(n.mul(d)).add(direction.mul(d2))
# take plane through ccl and axis
p = Plane(ccl,direction)
# intersect point with plane
(ccp,l)=intersect_plane_point(p, direction, point)
return (ccp,point,-l)
def intersect_cylinder_line(center, axis, radius, radiussq, direction, edge):
d = edge.dir()
# take a plane throught the line and along the cylinder axis (1)
n = d.cross(axis)
if n.normsq()==0:
# no contact point, but should check here if torus *always* intersects line...
return (None,None,INFINITE)
n.normalize()
# the contact line between the cylinder and this plane (1)
# is where the surface normal is perpendicular to the plane
# so line := ccl + \lambda * axis
if n.dot(direction)<0:
ccl = center.sub(n.mul(radius))
else:
ccl = center.add(n.mul(radius))
# now extrude the contact line along the direction, this is a plane (2)
n2 = direction.cross(axis)
if n2.normsq()==0:
# no contact point, but should check here if torus *always* intersects line...
return (None,None,INFINITE)
n2.normalize()
p = Plane(ccl, n2)
# intersect this plane with the line, this gives us the contact point
(cp,l) = intersect_plane_point(p, d, edge.p1)
if not cp:
return (None,None,INFINITE)
# now take a plane through the contact line and perpendicular to the direction (3)
p2 = Plane(ccl, direction)
# the intersection of this plane (3) with the line throught the contact point
# gives us the cutter contact point
(ccp,l) = intersect_plane_point(p2, direction, cp)
cp = ccp.add(direction.mul(-l))
return (ccp,cp,-l)
def intersect_circle_plane(center, radius, direction, triangle):
# let n be the normal to the plane
n = triangle.normal()
if n.dot(direction) == 0:
return (None,None,INFINITE)
# project onto z=0
n2 = Point(n.x,n.y,0)
if n2.normsq() == 0:
(cp,d) = intersect_plane_point(triangle.plane(), direction, center)
ccp = cp.sub(direction.mul(d))
return (ccp,cp,d)
n2.normalize()
# the cutter contact point is on the circle, where the surface normal is n
ccp = center.add(n2.mul(-radius))
# intersect the plane with a line through the contact point
(cp,d) = intersect_plane_point(triangle.plane(), direction, ccp)
return (ccp,cp,d)
def intersect_circle_point(center, axis, radius, radiussq, direction, point):
# take a plane through the base
p = Plane(center, axis)
# intersect with line gives ccp
(ccp,l) = intersect_plane_point(p, direction, point)
# check if inside circle
if ccp and (center.sub(ccp).normsq()<=radiussq):
return (ccp,point,-l)
return (None,None,INFINITE)
def intersect_circle_line(center, axis, radius, radiussq, direction, edge):
# make a plane by sliding the line along the direction (1)
d = edge.dir()
if d.dot(axis)==0:
if direction.dot(axis)==0:
return (None,None,INFINITE)
p = Plane(center,axis)
(p1,l) = intersect_plane_point(p,direction,edge.p1)
(p2,l) = intersect_plane_point(p,direction,edge.p2)
pc = Line(p1,p2).closest_point(center)
d_sq = pc.sub(center).normsq()
if d_sq>radiussq:
return (None,None,INFINITE)
a = sqrt(radiussq-d_sq)
d1 = p1.sub(pc).dot(d)
d2 = p2.sub(pc).dot(d)
ccp = None
cp = None
if d1>-a and d1<a:
ccp = p1
cp = p1
elif d2>-a and d2<a:
ccp = p2
cp = p2
elif (d1<-a and d2>a) or (d2<-a and d1>a):
ccp = pc
cp = pc.sub(direction.mul(l))
return (ccp,cp,-l)
n = d.cross(direction)
if n.normsq()==0:
# no contact point, but should check here if circle *always* intersects line...
return (None,None,INFINITE)
n.normalize()
# take a plane through the base
p = Plane(center, axis)
# intersect base with line
(lp,l) = intersect_plane_point(p, d, edge.p1)
if not lp:
return (None,None,INFINITE)
# intersection of 2 planes: lp + \lambda v
v = axis.cross(n)
if v.normsq()==0:
return (None,None,INFINITE)
v.normalize()
# take plane through intersection line and parallel to axis
n2 = v.cross(axis)
if n2.normsq()==0:
return (None,None,INFINITE)
n2.normalize()
# distance from center to this plane
dist = n2.dot(center)-n2.dot(lp)
distsq = dist*dist
if distsq>radiussq:
return (None,None,INFINITE)
# must be on circle
dist2 = sqrt(radiussq-distsq)
if d.dot(axis)<0:
dist2 = -dist2
ccp = center.sub(n2.mul(dist)).sub(v.mul(dist2))
p = Plane(edge.p1,d.cross(direction).cross(d))
(cp,l) = intersect_plane_point(p,direction,ccp)
return (ccp,cp,l)
def intersect_sphere_plane(center, radius, direction, triangle):
# let n be the normal to the plane
n = triangle.normal()
if n.dot(direction) == 0:
return (None,None,INFINITE)
# the cutter contact point is on the sphere, where the surface normal is n
if n.dot(direction)<0:
ccp = center.sub(n.mul(radius))
else:
ccp = center.add(n.mul(radius))
# intersect the plane with a line through the contact point
(cp,d) = intersect_plane_point(triangle.plane(), direction, ccp)
return (ccp,cp,d)
def intersect_sphere_point(center, radius, radiussq, direction, point):
# line equation
# (1) x = p_0 + \lambda * d
# sphere equation
# (2) (x-x_0)^2 = R^2
# (1) in (2) gives a quadratic in \lambda
p0_x0 = center.sub(point)
a = direction.normsq()
b = 2*p0_x0.dot(direction)
c = p0_x0.normsq() - radiussq
d = b*b-4*a*c
if d<0:
return (None,None,INFINITE)
if a<0:
l = (-b+sqrt(d))/(2*a)
else:
l = (-b-sqrt(d))/(2*a)
# cutter contact point
ccp = point.add(direction.mul(-l))
return (ccp,point,l)
def intersect_sphere_line(center, radius, radiussq, direction, edge):
# make a plane by sliding the line along the direction (1)
d = edge.dir()
n = d.cross(direction)
if n.normsq()==0:
# no contact point, but should check here if sphere *always* intersects line...
return (None,None,INFINITE)
n.normalize()
# calculate the distance from the sphere center to the plane
dist = -(center.dot(n)-edge.p1.dot(n))
if abs(dist)>radius:
return (None,None,INFINITE)
# this gives us the intersection circle on the sphere
# now take a plane through the edge and perpendicular to the direction (2)
# find the center on the circle closest to this plane
# which means the other component is perpendicular to this plane (2)
n2 = n.cross(d)
n2.normalize()
# the contact point is on a big circle through the sphere...
dist2 = sqrt(radiussq-dist*dist)
# ... and it's on the plane (1)
ccp = center.add(n.mul(dist)).add(n2.mul(dist2))
# now intersect a line through this point with the plane (2)
p = Plane(edge.p1, n2)
(cp,l) = intersect_plane_point(p, direction, ccp)
return (ccp,cp,l)
def intersect_torus_plane(center, axis, majorradius, minorradius, direction, triangle):
# take normal to the plane
n = triangle.normal()
if n.dot(direction)==0:
return (None,None,INFINITE)
if n.dot(axis)==1:
return (None,None,INFINITE)
# find place on torus where surface normal is n
b = n.mul(-1)
z = axis
a = b.sub(z.mul(z.dot(b)))
a_sq = a.normsq()
if a_sq<=0:
return (None,None,INFINITE)
a = a.div(sqrt(a_sq))
ccp = center.add(a.mul(majorradius)).add(b.mul(minorradius))
# find intersection with plane
p = triangle.plane()
(cp,l) = intersect_plane_point(p, direction, ccp)
return (ccp,cp,l)
def intersect_torus_point(center, axis, majorradius, minorradius, majorradiussq, minorradiussq, direction, point):
dist = 0
if direction.x==0 and direction.y==0: # drop
minlsq = sqr(majorradius-minorradius)
maxlsq = sqr(majorradius+minorradius)
l_sq = sqr(point.x-center.x)+sqr(point.y-center.y)
if (l_sq<minlsq) or (l_sq>maxlsq):
return (None,None,INFINITE)
l = sqrt(l_sq)
z_sq = minorradiussq - sqr(majorradiussq - l)
if z_sq < 0:
return (None,None,INFINITE)
z = sqrt(z_sq)
ccp=Point(point.x,point.y,center.z-z)
dist = center.z-z
elif direction.z==0: # push
z = point.z - center.z
if z<-minorradius or z>minorradius:
return (None,None,INFINITE)
l = majorradius + sqrt(minorradiussq - sqr(z))
n = axis.cross(direction)
d = n.dot(point)-n.dot(center)
if d<-l or d>l:
return (None,None,INFINITE)
a = sqrt(l*l-d*d)
ccp = center.add(n.mul(d).add(direction.mul(a)))
ccp.z = point.z
dist = point.sub(ccp).dot(direction)
else: # general case
x = point.sub(center)
v = direction.mul(-1)
x_x = x.dot(x)
x_v = x.dot(v)
x1 = Point(x.x,x.y,0)
v1 = Point(v.x,v.y,0)
x1_x1 = x1.dot(x1)
x1_v1 = x1.dot(v1)
v1_v1 = v1.dot(v1)
R2 = majorradiussq
r2 = minorradiussq
a = 1.0
b = 4*x_v
c = 2*(x_x)+4*sqr(x_v)+2*(R2-r2)-4*R2*v1_v1
d = 4*x_x*x_v+4*x_v*(R2-r2)-8*R2*(x1_v1)
e = sqr(x_x)+2*x_x*(R2-r2)+sqr(R2-r2)-4*R2*x1_x1
r = poly4_roots(a,b,c,d,e)
if not r:
return (None,None,INFINITE)
elif len(r)==1:
l = r[0]
elif len(r)==2:
l = min(r[0],r[1])
elif len(r)==3:
l = min(min(r[0],r[1]),r[2])
elif len(r)==4:
l = min(min(r[0],r[1]),min(r[2],r[3]))
else:
return (None,None,INFINITE)
ccp = point.add(direction.mul(-l))
dist = l
return (ccp,point,dist)
#!/usr/bin/env python
import math
class Node:
def __repr__(self):
s = "";
for i in range(0,len(self.bound)):
s += "%g : " % (self.bound[i])
return s
def find_max_spread(nodes):
minval = []
maxval = []
n = nodes[0]
numdim = len(n.bound)
for b in n.bound:
minval.append(b)
maxval.append(b)
for n in nodes:
for j in range(0, numdim):
minval[j] = min(minval[j], n.bound[j])
maxval[j] = max(maxval[j], n.bound[j])
maxspreaddim = 0
maxspread = maxval[0]-minval[0]
for i in range(1,numdim):
spread = maxval[i]-minval[i]
if spread > maxspread:
maxspread = spread
maxspreaddim = i
return (maxspreaddim, maxspread)
class kd_tree:
id = 0
def __repr__(self):
if self.bucket:
return "(#%d)" % (len(self.nodes))
else:
return "(%f<=%s,%d:%f,%s<=%f)" % (self.minval,self.lo, self.cutdim,self.cutval,self.hi,self.maxval)
def to_mged(self, minx, maxx, miny, maxy):
s = ""
if self.bucket:
s += "in kdtree_%d arb8 " % self.id
s += " %f %f %f " % (minx, miny, 0)
s += " %f %f %f " % (maxx, miny, 0)
s += " %f %f %f " % (maxx, maxy, 0)
s += " %f %f %f " % (minx, maxy, 0)
s += " %f %f %f " % (minx, miny, 10)
s += " %f %f %f " % (maxx, miny, 10)
s += " %f %f %f " % (maxx, maxy, 10)
s += " %f %f %f" % (minx, maxy, 10)
s += "\n"
else:
if True: # show bounding box
if self.cutdim == 0 or self.cutdim == 2:
s += self.lo.to_mged(self.minval,self.cutval,miny,maxy)
s += self.hi.to_mged(self.cutval,self.maxval,miny,maxy)
elif self.cutdim == 1 or self.cutdim == 3:
s += self.lo.to_mged(minx,maxx,self.minval,self.cutval)
s += self.hi.to_mged(minx,maxx,self.cutval,self.maxval)
else: # show partitions
if self.cutdim == 0 or self.cutdim == 2:
s += self.lo.to_mged(minx,self.cutval,miny,maxy)
s += self.hi.to_mged(self.cutval,maxx,miny,maxy)
elif self.cutdim == 1 or self.cutdim == 3:
s += self.lo.to_mged(minx,maxx,miny,self.cutval)
s += self.hi.to_mged(minx,maxx,self.cutval,maxy)
return s
def __init__(self, nodes, cutoff, cutoff_distance):
self.id = kd_tree.id
kd_tree.id += 1
self.cutoff = cutoff
self.cutoff_distance = cutoff_distance
if (len(nodes)<=self.cutoff):
self.bucket = True
self.nodes = nodes
else:
(cutdim,spread) = find_max_spread(nodes)
if spread <= self.cutoff_distance:
self.bucket = True
self.nodes = nodes
else:
self.bucket = False
self.cutdim = cutdim
nodes.sort(cmp=lambda x,y:cmp(x.bound[cutdim],y.bound[cutdim]))
median = len(nodes)/2
self.minval = nodes[0].bound[cutdim]
self.maxval = nodes[-1].bound[cutdim]
self.cutval = nodes[median].bound[cutdim]
self.lo = kd_tree(nodes[0:median], cutoff, cutoff_distance)
self.hi = kd_tree(nodes[median:], cutoff, cutoff_distance)
INFINITE = 10000
epsilon = 0.0001
def sqr(x):
return x*x
def min3(x,y,z):
if x<y:
xy = x
else:
xy = y
if xy<z:
return xy
else:
return z
def max3(x,y,z):
if x>y:
xy = x
else:
xy = y
if xy>z:
return xy
else:
return z
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
from OpenGL.GL import *
from OpenGL.Tk import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
import tkFileDialog
from pycam import *
from pycam.Cutters import *
from pycam.PathGenerators import *
from pycam.PathProcessors import *
from pycam.Geometry.utils import *
from pycam.Importers import *
from pycam.Exporters import *
class OpenglWidget(Opengl):
def __init__(self, master=None, cnf={}, **kw):
Opengl.__init__(self, master, kw)
glShadeModel(GL_FLAT)
# glShadeModel(GL_SMOOTH)
glMatrixMode(GL_MODELVIEW)
glMaterial(GL_FRONT_AND_BACK, GL_AMBIENT, (0.1, 0.1, 0.1, 1.0))
glMaterial(GL_FRONT_AND_BACK, GL_SPECULAR, (0.1, 0.1, 0.1, 1.0))
glMaterial(GL_FRONT_AND_BACK, GL_SHININESS, (0.5))
# glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
def basic_lighting(self):
Opengl.basic_lighting(self)
# "Let There Be Light"
glPushMatrix()
glLoadIdentity()
glLightfv(GL_LIGHT0, GL_AMBIENT, (0.5, 0.5, 0.5, 1.0))
glLightfv(GL_LIGHT0, GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
glLightfv(GL_LIGHT0, GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
glLightfv(GL_LIGHT0, GL_POSITION, (2, 2, +10, 1.0))
glEnable(GL_LIGHT0)
glDisable(GL_LIGHTING)
glPopMatrix()
class SimpleGui(Frame):
def Redraw(self, event=None):
# default scale and orientation
glScalef(0.25, 0.25, 0.25)
glRotatef(110,1.0,0.0,0.0)
glRotatef(180,0.0,1.0,0.0)
glRotatef(160,0.0,0.0,1.0)
glTranslatef(0,0,-2)
# axes
glBegin(GL_LINES)
glColor3f(1,0,0)
glVertex3f(0,0,0)
glVertex3f(5,0,0)
glEnd()
glBegin(GL_LINES)
glColor3f(0,1,0)
glVertex3f(0,0,0)
glVertex3f(0,5,0)
glEnd()
glBegin(GL_LINES)
glColor3f(0,0,1)
glVertex3f(0,0,0)
glVertex3f(0,0,5)
glEnd()
if self.model:
glColor3f(0.5,.5,1)
self.model.to_OpenGL()
if self.toolpath:
last = None
for path in self.toolpath:
if last:
glColor3f(.5,1,.5)
glBegin(GL_LINES)
glVertex3f(last.x,last.y,last.z)
last = path.points[0]
glVertex3f(last.x,last.y,last.z)
glEnd()
glColor3f(1,.5,.5)
glBegin(GL_LINE_STRIP)
for point in path.points:
glVertex3f(point.x,point.y,point.z)
glEnd()
last = path.points[-1]
def browseOpen(self):
filename = tkFileDialog.Open(self, filetypes=[("STL files", ".stl")]).show()
self.model = None
if filename:
self.InputFileName.set(filename)
self.model = STLImporter.ImportModel(filename)
self.toolpath = None
self.ogl.tkRedraw()
def generateToolpath(self):
radius = float(self.CutterRadius.get())
if self.CutterName.get() == "SphericalCutter":
self.cutter = SphericalCutter(radius)
elif self.CutterName.get() == "CylindricalCutter":
self.cutter = CylindricalCutter(radius)
elif self.CutterName.get() == "ToroidalCutter":
toroid = float(self.ToroidRadius.get())
self.cutter = ToroidalCutter(radius, toroid)
minx = float(self.MinX.get())
maxx = float(self.MaxX.get())
miny = float(self.MinY.get())
maxy = float(self.MaxY.get())
minz = float(self.MinZ.get())
maxz = float(self.MaxZ.get())
samples = float(self.Samples.get())
lines = float(self.Lines.get())
layers = float(self.Layers.get())
if self.PathGeneratorName.get() == "DropCutter":
if self.PathProcessorName.get() == "ZigZagCutter":
self.option = PathAccumulator(zigzag=True)
else:
self.option = None
self.pathgenerator = DropCutter(self.cutter, self.model, self.option);
if samples>1:
dx = (maxx-minx)/(samples-1)
else:
dx = INFINITE
if lines>1:
dy = (maxy-miny)/(lines-1)
else:
dy = INFINITE
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dx, dy)
elif self.PathGeneratorName.get() == "PushCutter":
if self.PathProcessorName.get() == "PathAccumulator":
self.option = PathAccumulator()
elif self.PathProcessorName.get() == "SimpleCutter":
self.option = SimpleCutter()
elif self.PathProcessorName.get() == "ZigZagCutter":
self.option = ZigZagCutter()
elif self.PathProcessorName.get() == "PolygonCutter":
self.option = PolygonCutter()
else:
self.option = None
self.pathgenerator = PushCutter(self.cutter, self.model, self.option);
if lines>1:
dy = (maxy-miny)/(lines-1)
else:
dy = INFINITE
if layers>1:
dz = (maxz-minz)/(layers-1)
else:
dz = INFINITE
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, 0, dy, dz)
self.ogl.tkRedraw()
def browseSaveAs(self):
filename = tkFileDialog.SaveAs(self, filetypes=[("GCODE files", ".nc .gc")]).show()
if filename:
self.OutputFileName.set(filename)
if self.toolpath:
exporter = SimpleGCodeExporter.ExportPathList(filename, self.toolpath)
def createWidgets(self):
self.TopFrame = Frame(self).pack(side=TOP, expand=1, fill=X)
self.InputFileFrame = Frame(self.TopFrame)
self.InputFileFrame.pack(side=TOP, anchor=W, expand=1, fill=X)
Label(self.InputFileFrame, width=10, text="Input File: ").pack(side=LEFT, anchor=W)
self.InputFileName = StringVar()
Entry(self.InputFileFrame, textvariable=self.InputFileName).pack(side=LEFT, expand=1, fill=X)
Button(self.InputFileFrame, text="Import...",command=self.browseOpen).pack(side=RIGHT)
self.CutterFrame = Frame(self.TopFrame)
self.CutterFrame.pack(side=TOP, anchor=W)
Label(self.CutterFrame, text="Tool: ").pack(side=LEFT)
self.CutterName = StringVar()
self.CutterName.set(Cutters.list[0])
for cutter in Cutters.list:
Radiobutton(self.CutterFrame, text=cutter, variable=self.CutterName, value=cutter).pack(side=LEFT)
self.PathGeneratorFrame = Frame(self.TopFrame)
self.PathGeneratorFrame.pack(side=TOP, anchor=W)
Label(self.PathGeneratorFrame, text="PathGenerator: ").pack(side=LEFT)
self.PathGeneratorName = StringVar()
self.PathGeneratorName.set(PathGenerators.list[0])
for PathGenerator in PathGenerators.list:
Radiobutton(self.PathGeneratorFrame, text=PathGenerator, variable=self.PathGeneratorName, value=PathGenerator).pack(side=LEFT)
self.PathProcessorFrame = Frame(self.TopFrame)
self.PathProcessorFrame.pack(side=TOP, anchor=W)
Label(self.PathProcessorFrame, text="Postprocessor: ").pack(side=LEFT)
self.PathProcessorName = StringVar()
self.PathProcessorName.set(PathProcessors.list[0])
for option in PathProcessors.list:
Radiobutton(self.PathProcessorFrame, text=option, variable=self.PathProcessorName, value=option).pack(side=LEFT)
self.ConfigurationFrame = Frame(self.TopFrame)
self.ConfigurationFrame.pack(side=TOP, anchor=W, expand=1, fill=X)
Label(self.ConfigurationFrame, text="Tool Radius: ").pack(side=LEFT)
self.CutterRadius = StringVar()
self.CutterRadius.set("1.0")
s = Spinbox(self.ConfigurationFrame, width=5, text='Radius', from_=0.1, to=5.0, increment=0.1, format="%2.1f")
s.pack(side=LEFT)
s["textvariable"] = self.CutterRadius
Label(self.ConfigurationFrame, text="Torus Radius: ").pack(side=LEFT)
self.ToroidRadius = StringVar()
self.ToroidRadius.set("0.25")
s = Spinbox(self.ConfigurationFrame, width=5, text='Toroid', from_=0.1, to=5.0, increment=0.1, format="%2.1f")
s["textvariable"] = self.ToroidRadius
s.pack(side=LEFT)
self.MinX = StringVar()
self.MinX.set("-7")
self.MinY = StringVar()
self.MinY.set("-7")
self.MinZ = StringVar()
self.MinZ.set("0")
self.MaxX = StringVar()
self.MaxX.set("+7")
self.MaxY = StringVar()
self.MaxY.set("+7")
self.MaxZ = StringVar()
self.MaxZ.set("+3")
self.StockModelFrame1 = Frame(self.TopFrame)
self.StockModelFrame1.pack(side=TOP, anchor=W, expand=1, fill=X)
Label(self.StockModelFrame1, text="Min X").pack(side=LEFT)
Entry(self.StockModelFrame1, textvariable=self.MinX, width=6).pack(side=LEFT)
Label(self.StockModelFrame1, text="Min Y").pack(side=LEFT)
Entry(self.StockModelFrame1, textvariable=self.MinY, width=6).pack(side=LEFT)
Label(self.StockModelFrame1, text="Min Z").pack(side=LEFT)
Entry(self.StockModelFrame1, textvariable=self.MinZ, width=6).pack(side=LEFT)
self.StockModelFrame2 = Frame(self.TopFrame)
self.StockModelFrame2.pack(side=TOP, anchor=W, expand=1, fill=X)
Label(self.StockModelFrame2, text="Max X").pack(side=LEFT)
Entry(self.StockModelFrame2, textvariable=self.MaxX, width=6).pack(side=LEFT)
Label(self.StockModelFrame2, text="Max Y").pack(side=LEFT)
Entry(self.StockModelFrame2, textvariable=self.MaxY, width=6).pack(side=LEFT)
Label(self.StockModelFrame2, text="Max Z").pack(side=LEFT)
Entry(self.StockModelFrame2, textvariable=self.MaxZ, width=6).pack(side=LEFT)
self.ConfigFrame = Frame(self.TopFrame)
self.ConfigFrame.pack(side=TOP, anchor=W, expand=1, fill=X)
self.Layers = StringVar()
self.Layers.set("1")
Label(self.ConfigFrame, text="Layers").pack(side=LEFT)
Entry(self.ConfigFrame, textvariable=self.Layers, width=6).pack(side=LEFT)
self.Samples = StringVar()
self.Samples.set("50")
Label(self.ConfigFrame, text="Samples").pack(side=LEFT)
Entry(self.ConfigFrame, textvariable=self.Samples, width=6).pack(side=LEFT)
self.Lines = StringVar()
self.Lines.set("20")
Label(self.ConfigFrame, text="Lines").pack(side=LEFT)
Entry(self.ConfigFrame, textvariable=self.Lines, width=6).pack(side=LEFT)
Button(self.ConfigFrame, text="Generate Toolpath", command=self.generateToolpath).pack(side=RIGHT)
self.OutputFileFrame = Frame(self.TopFrame)
self.OutputFileFrame.pack(side=TOP, anchor=W, expand=1, fill=X)
Label(self.OutputFileFrame, width=10, text= "Output File: ").pack(side=LEFT)
self.OutputFileName = StringVar()
self.OutputFileField = Entry(self.OutputFileFrame, textvariable=self.OutputFileName).pack(side=LEFT, expand=1, fill=X)
self.OutputFileBrowse = Button(self.OutputFileFrame, text="Export...", command=self.browseSaveAs).pack(side=RIGHT)
self.ogl = OpenglWidget(self, width=600, height=500)
self.ogl.pack(side='bottom', expand=1, fill=BOTH)
self.ogl.set_background(0,0,0)
self.ogl.bind('<Button-2>',self.ogl.tkRecordMouse)
self.ogl.bind('<B2-Motion>', self.ogl.tkTranslate)
self.ogl.bind('<Button-1>', self.ogl.StartRotate)
self.ogl.bind('<B1-Motion>', self.ogl.tkRotate)
self.ogl.bind('<Button-3>', self.ogl.tkRecordMouse)
self.ogl.bind('<B3-Motion>', self.ogl.tkScale)
self.ogl.redraw = self.Redraw
self.pack(expand=1, fill=BOTH)
def __init__(self, master=None):
Frame.__init__(self, master)
self.model = None
self.toolpath = None
self.createWidgets()
def cutmodel(self, z):
cutter = SphericalCutter(1, Point(0,0,7))
pc = DropCutter(cutter, self.model, PathAccumulator())
x0 = -7.0
x1 = +7.0
y0 = -7.0
y1 = +7.0
z0 = 0.0
z1 = 4.0
samples = 20
lines = 20
layers = 10
dx = (x1-x0)/samples
dy = (y1-y0)/lines
dz = (z1-z0)/(layers+1)
self.toolpath = pc.GenerateToolPath(x0,x1,y0,y1,z0,z1,dx,dy,dz)
if __name__ == "__main__":
app = SimpleGui()
app.model = TestModel.TestModel()
app.cutmodel(3.0)
app.mainloop()
import string
import math
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.constant import Constant
GLUT_WHEEL_UP=Constant('GLUT_WHEEL_UP',3)
GLUT_WHEEL_DOWN=Constant('GLUT_WHEEL_DOWN',4)
from pycam.Geometry.utils import *
_DrawCurrentSceneFunc = None
# Some api in the chain is translating the keystrokes to this octal string
# so instead of saying: ESCAPE = 27, we use the following.
ESCAPE = '\033'
# Number of the glut window.
window = 0
# Rotations for cube.
xrot = 110
yrot = 180
zrot = 250
scale = 0.5
xdist = 0
ydist = -1.0
zdist = -8.0
texture_num = 2
object = 0
light = 0
polygon_mode = GL_FILL
width = 320
height = 200
# A general OpenGL initialization function. Sets all of the initial parameters.
def InitGL(Width, Height): # We call this right after our OpenGL window is created.
global width, height
width = Width
height = Height
glClearColor(0.0, 0.0, 0.0, 0.0) # This Will Clear The Background Color To Black
glClearDepth(1.0) # Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS) # The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
# glShadeModel(GL_SMOOTH) # Enables Smooth Color Shading
glShadeModel(GL_FLAT) # Enables Flat Color Shading
glMatrixMode(GL_PROJECTION)
glLoadIdentity() # Reset The Projection Matrix
# Calculate The Aspect Ratio Of The Window
gluPerspective(60.0, float(Width)/float(Height), 0.1, 100.0)
glLightfv(GL_LIGHT0, GL_AMBIENT, (0.5, 0.5, 0.5, 1.0)) # Setup The Ambient Light
glLightfv(GL_LIGHT0, GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0)) # Setup The Diffuse Light
glLightfv(GL_LIGHT0, GL_POSITION, (-10.0, 0.0, 0.0, 1.0)) # Position The Light
glEnable(GL_LIGHT0) # Enable Light One
glMatrixMode(GL_MODELVIEW)
glMaterial(GL_FRONT_AND_BACK, GL_SPECULAR, (0.1, 0.1, 0.1, 1.0))
# glMaterial(GL_FRONT_AND_BACK, GL_SHININESS, (0.5))
glPolygonMode(GL_FRONT_AND_BACK, polygon_mode)
def ReSizeGLScene(Width, Height):
if Height == 0: # Prevent A Divide By Zero If The Window Is Too Small
Height = 1
global width, height
width = Width
height = Height
glViewport(0, 0, Width, Height) # Reset The Current Viewport And Perspective Transformation
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(60.0, float(Width)/float(Height), 0.1, 100.0)
glMatrixMode(GL_MODELVIEW)
# The main drawing function.
def DrawGLScene():
global xrot, yrot, zrot, scale, xdist, ydist, zdist, light
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Clear The Screen And The Depth Buffer
glLoadIdentity() # Reset The View
glTranslatef(xdist,ydist,zdist) # Move Into The Screen
glRotatef(xrot,1.0,0.0,0.0) # Rotate The Cube On It's X Axis
glRotatef(yrot,0.0,1.0,0.0) # Rotate The Cube On It's Y Axis
glRotatef(zrot,0.0,0.0,1.0) # Rotate The Cube On It's Z Axis
glScalef(scale,scale,scale)
if light:
glEnable(GL_LIGHTING)
else:
glDisable(GL_LIGHTING)
if _DrawCurrentSceneFunc:
_DrawCurrentSceneFunc()
# since this is double buffered, swap the buffers to display what just got drawn.
glutSwapBuffers()
# The function called whenever a key is pressed
def keyPressed(key, x, y):
global light, polygon_mode
global xrot, yrot, zrot
key = string.upper(key)
if key == ESCAPE or key=='Q':
# If escape is pressed, kill everything.
sys.exit()
elif key == 'S':
light = not light
elif key == '=':
print "rot=<%g,%g,%g>" % (xrot,yrot,zrot)
elif key == 'T': # top
xrot=0
yrot=0
zrot=0
elif key == 'F': # front
xrot=-90
yrot=0
zrot=0
elif key == 'R': # right
xrot=-90
yrot=0
zrot=-90
elif key == 'L': # left
xrot=-90
yrot=0
zrot=+90
elif key == 'M':
if polygon_mode == GL_FILL:
polygon_mode = GL_LINE
else:
polygon_mode = GL_FILL
glPolygonMode(GL_FRONT_AND_BACK, polygon_mode)
class mouseState:
button = None
state = None
x=0
y=0
def mousePressed(button, state, x, y):
global xrot, yrot, zrot, xdist, ydist, zdist, scale
if button==GLUT_WHEEL_DOWN:
scale *= 1.1
elif button==GLUT_WHEEL_UP:
scale /= 1.1
mouseState.button = button
mouseState.state = state
mouseState.x=float(x)
mouseState.y=float(y)
def mouseMoved(x, y):
global xrot, yrot, zrot, xdist, ydist, zdist, scale
global width, height
x = float(x)
y = float(y)
a1 = math.atan2(mouseState.y-height/2.0, mouseState.x-width/2.0)
r1 = math.sqrt(sqr(mouseState.y-height/2.0)+sqr(mouseState.x-width/2.0))
a2 = math.atan2(y-height/2.0, x-width/2.0)
r2 = math.sqrt(sqr(y-height/2.0)+sqr(x-width/2.0))
da = abs(a2-a1)
dr = 0
if r2>r1:
dr = r1/r2
else:
dr = r2/r1
if mouseState.button == GLUT_LEFT_BUTTON or mouseState.button == GLUT_RIGHT_BUTTON:
a3 = math.acos(mouseState.x/width-0.5)
a4 = math.acos(x/width-0.5)
zrot = zrot - (a4-a3)*180/math.pi*2
if mouseState.button == GLUT_RIGHT_BUTTON:
a3 = math.acos(mouseState.y/height-0.5)
a4 = math.acos(y/height-0.5)
if x>width/2.0:
yrot = yrot + (a4-a3)*180/math.pi*2
else:
yrot = yrot - (a4-a3)*180/math.pi*2
if mouseState.button == GLUT_LEFT_BUTTON:
a3 = math.acos(mouseState.y/width-0.5)
a4 = math.acos(y/width-0.5)
xrot = xrot - (a4-a3)*180/math.pi*2
mouseState.x=x
mouseState.y=y
def Visualization(title, drawScene=DrawGLScene, width=320, height=200):
global window, _DrawCurrentSceneFunc
glutInit(sys.argv)
_DrawCurrentSceneFunc = drawScene
# Select type of Display mode:
# Double buffer
# RGBA color
# Alpha components supported
# Depth buffer
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
# get a 640 x 480 window
glutInitWindowSize(640, 480)
# the window starts at the upper left corner of the screen
glutInitWindowPosition(0, 0)
# Okay, like the C version we retain the window id to use when closing, but for those of you new
# to Python (like myself), remember this assignment would make the variable local and not global
# if it weren't for the global declaration at the start of main.
window = glutCreateWindow(title)
# Register the drawing function with glut, BUT in Python land, at least using PyOpenGL, we need to
# set the function pointer and invoke a function to actually register the callback, otherwise it
# would be very much like the C version of the code.
glutDisplayFunc(DrawGLScene)
# Uncomment this line to get full screen.
# glutFullScreen()
# When we are doing nothing, redraw the scene.
glutIdleFunc(DrawGLScene)
# Register the function called when our window is resized.
glutReshapeFunc(ReSizeGLScene)
# Register the function called when the keyboard is pressed.
glutKeyboardFunc(keyPressed)
# Register the function called when the mouse is pressed.
glutMouseFunc(mousePressed)
# Register the function called when the mouse is pressed.
glutMotionFunc(mouseMoved)
# Initialize our window.
InitGL(640, 480)
# Start Event Processing Engine
glutMainLoop()
test_model = None
test_cutter = None
test_pathlist = None
def DrawTestScene():
global test_model, test_cutter, test_pathlist
if test_model:
glColor4f(1,0.5,0.5,0.1)
test_model.to_OpenGL()
if test_cutter:
glColor3f(0.5,0.5,0.5)
test_cutter.to_OpenGL()
if test_pathlist:
for path in test_pathlist:
glColor3f(0.5,0.5,1)
glBegin(GL_LINE_STRIP)
for point in path.points:
glVertex3f(point.x, point.y, point.z)
# glVertex3f(point.x, point.y, point.z+1)
glEnd()
def ShowTestScene(model=None, cutter=None, pathlist=None):
global test_model, test_cutter, test_pathlist
test_model = model
test_cutter = cutter
test_pathlist = pathlist
Visualization("TestScene", DrawTestScene)
__all__ = ["Vizualisation"]
import re
from pycam.Geometry import *
def ImportModel(filename):
model = Model()
f = file(filename,"r")
solid = re.compile("\s*solid\s+(\w+)\s+")
endsolid = re.compile("\s*endsolid\s+")
facet = re.compile("\s*facet\s+")
normal = re.compile("\s*facet\s+normal\s+(?P<x>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<y>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<z>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+")
endfacet = re.compile("\s*endfacet\s+")
loop = re.compile("\s*outer\s+loop\s+")
endloop = re.compile("\s*endloop\s+")
vertex = re.compile("\s*vertex\s+(?P<x>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<y>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+(?P<z>[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?)\s+")
model = Model()
t = None
p1 = None
p2 = None
p3 = None
for line in f:
m = solid.match(line)
if m:
model.name = m.group(1)
continue
m = facet.match(line)
if m:
m = normal.match(line)
if m:
n = Point(float(m.group('x')),float(m.group('y')),float(m.group('z')))
continue
m = loop.match(line)
if m:
continue
m = vertex.match(line)
if m:
p = Point(float(m.group('x')),float(m.group('y')),float(m.group('z')))
# TODO: check for duplicate points (using kdtree?)
if p1 == None:
p1 = p
elif p2 == None:
p2 = p
elif p3 == None:
p3 = p
else:
print "ERROR: more then 3 points in facet"
continue
m = endloop.match(line)
if m:
continue
m = endfacet.match(line)
if m:
# make sure the points are in ClockWise order
if n.dot(p3.sub(p1).cross(p2.sub(p1)))>0:
t = Triangle(p1, p2, p3)
else:
t = Triangle(p1, p3, p2)
t._normal = n
n=p1=p2=p3=None
# if t.normal().z < 0:
# continue
model.append(t)
continue
m = endsolid.match(line)
if m:
continue
return model
from pycam.Geometry import *
def TestModel():
points = []
points.append(Point(-2,1,4))
points.append(Point(2,1,4))
points.append(Point(0,-2,4))
points.append(Point(-5,2,2))
points.append(Point(-1,3,2))
points.append(Point(5,2,2))
points.append(Point(4,-1,2))
points.append(Point(2,-4,2))
points.append(Point(-2,-4,2))
points.append(Point(-3,-2,2))
model = Model()
model.append(Triangle(points[0],points[1],points[2]))
model.append(Triangle(points[0],points[3],points[4]))
model.append(Triangle(points[0],points[4],points[1]))
model.append(Triangle(points[1],points[4],points[5]))
model.append(Triangle(points[1],points[5],points[6]))
model.append(Triangle(points[1],points[6],points[2]))
model.append(Triangle(points[2],points[6],points[7]))
model.append(Triangle(points[2],points[7],points[8]))
model.append(Triangle(points[2],points[8],points[9]))
model.append(Triangle(points[2],points[9],points[0]))
model.append(Triangle(points[0],points[9],points[3]))
return model
list = ["STLImporter"]
__all__ = ["TestModel"] + list
from pycam.PathProcessors import *
from pycam.Geometry import *
from pycam.Geometry.utils import *
class DropCutter:
def __init__(self, cutter, model, PathProcessor=None):
self.cutter = cutter
self.model = model
self.processor = PathProcessor
def GenerateToolPath(self, minx, maxx, miny, maxy, z0, z1, dx, dy, dz=0):
if self.processor:
pa = self.processor
else:
pa = PathAccumulator()
pa.new_direction(0)
y = miny
while y<=maxy:
x = minx
pa.new_scanline()
while x<=maxx:
p = Point(x,y,z1)
z_max = -INFINITE
cl_max = None
self.cutter.moveto(p)
for t in self.model.triangles():
if t.normal().z < 0: continue;
cl = self.cutter.drop(t)
if cl and (cl.z > z_max or cl_max is None):
z_max = cl.z
cl_max = cl
if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0)
pa.append(cl_max)
x += dx
pa.end_scanline()
y += dy
pa.end_direction()
pa.finish()
return pa.paths
from pycam.PathProcessors import *
from pycam.Geometry import *
from pycam.Geometry.utils import *
class Hit:
def __init__(self, cl, t, d, dir):
self.cl = cl
self.t = t
self.d = d
self.dir = dir
def cmp(a,b):
return cmp(a.d, b.d)
class PushCutter:
def __init__(self, cutter, model, pathextractor=None):
self.cutter = cutter
self.model = model
self.pa = pathextractor
def GenerateToolPath(self, minx, maxx, miny, maxy, minz, maxz, dx, dy, dz):
if dx==0:
forward = Point(1,0,0)
backward = Point(-1,0,0)
elif dy == 0:
forward = Point(0,1,0)
backward = Point(0,-1,0)
z = maxz
c = self.cutter
model = self.model
paths = []
while z >= minz:
self.pa.new_direction(0)
x = minx
y = miny
while x<=maxx and y<=maxy:
self.pa.new_scanline()
# find all hits along scan line
hits = []
prev = Point(x,y,z)
c.moveto(prev)
for t in model.triangles():
if t.normal().z < 0: continue;
# normals point outward... and we want to approach the model from the outside!
n = t.normal().dot(forward)
if n>=0:
(cl,d) = c.intersect(backward, t)
if cl:
# print "< cl=",cl,",d=",-d,",t=",t
hits.append(Hit(cl,t,-d,backward))
if n<=0:
(cl,d) = c.intersect(forward, t)
if cl:
# print "> cl=",cl,",d=",d,",t=",t
hits.append(Hit(cl,t,d,forward))
# sort along the scan direction
hits.sort(Hit.cmp)
# remove duplicates (typically edges)
i = 1
while i < len(hits):
while i<len(hits) and abs(hits[i].d - hits[i-1].d)<epsilon:
del hits[i]
i += 1
# find parts of scanline where model is below z-level
i = 0
while i < len(hits):
next = hits[i].cl
self.pa.append(prev)
self.pa.append(next)
i += 1
# find next hit cutter location that is below z-level
while i < len(hits):
prev = hits[i].cl
c.moveto(prev)
c.moveto(prev.sub(hits[i].dir.mul(epsilon)))
zmax = -INFINITE
for t in model.triangles():
if t.normal().z < 0: continue;
cl = c.drop(t)
if cl and cl.z > zmax and cl.z < INFINITE:
zmax = cl.z
i += 1
if zmax <= z+epsilon:
break
if dx == 0:
x = maxx
if dy == 0:
y = maxy
next = Point(x,y,z)
self.pa.append(prev)
self.pa.append(next)
if dx != 0:
x += dx
else:
x = minx
if dy != 0:
y += dy
else:
y = miny
self.pa.end_scanline()
self.pa.end_direction()
self.pa.finish()
paths += self.pa.paths
z -= dz
return paths
list = ["DropCutter", "PushCutter"]
__all__ = list
from DropCutter import DropCutter
from PushCutter import PushCutter
from pycam.Geometry import *
class PathAccumulator:
def __init__(self, zigzag=False):
self.paths = []
self.curr_path = None
self.zigzag = zigzag
def append(self, p):
if self.curr_path == None:
self.curr_path = Path()
self.curr_path.append(p)
def new_direction(self, dir):
self.scanline = 0
def end_direction(self):
pass
def new_scanline(self):
self.scanline += 1
if self.curr_path:
print "ERROR: curr_path expected to be empty"
self.curr_path = None
def end_scanline(self):
if self.curr_path:
if self.zigzag and (self.scanline%2 == 0):
self.curr_path.reverse()
self.paths.append(self.curr_path)
self.curr_path = None
def finish(self):
pass
from pycam.Geometry import *
from pycam.Geometry.PolygonExtractor import *
class PolygonCutter:
def __init__(self):
self.paths = []
self.curr_path = None
self.scanline = None
self.pe = PolygonExtractor(PolygonExtractor.MONOTONE)
def append(self, p):
self.pe.append(p)
def new_direction(self, dir):
self.pe.new_direction(dir)
def end_direction(self):
self.pe.end_direction()
def new_scanline(self):
self.pe.new_scanline()
def end_scanline(self):
self.pe.end_scanline()
def finish(self):
self.pe.finish()
paths = []
for path in self.pe.hor_path_list:
points = path.points
for i in range(0, (len(points)+1)/2):
p = Path()
if i % 2 == 0:
p.append(points[i])
p.append(points[-i-1])
else:
p.append(points[-i-1])
p.append(points[i])
paths.append(p)
self.paths = paths
from pycam.Geometry import *
class SimpleCutter:
def __init__(self):
self.paths = []
self.curr_path = None
def append(self, p):
curr_path = None
if self.curr_path == None:
curr_path = Path()
self.curr_path = curr_path
else:
curr_path = self.curr_path
self.curr_path = None
curr_path.append(p)
if self.curr_path == None:
self.paths.append(curr_path)
def new_direction(self, dir):
pass
def end_direction(self):
pass
def new_scanline(self):
if self.curr_path:
print "ERROR: curr_path expected to be empty"
self.curr_path = None
def end_scanline(self):
if self.curr_path:
print "ERROR: curr_path expected to be empty"
self.curr_path = None
def finish(self):
pass
from pycam.Geometry import *
class ZigZagCutter:
def __init__(self):
self.paths = []
self.curr_path = None
self.scanline = None
def append(self, p):
curr_path = None
if self.curr_path == None:
curr_path = Path()
self.curr_path = curr_path
else:
curr_path = self.curr_path
self.curr_path = None
curr_path.append(p)
if self.curr_path == None:
if (self.scanline % 2) == 0:
self.curr_scanline.append(curr_path)
else:
curr_path.reverse()
self.curr_scanline.insert(0, curr_path)
def new_direction(self, dir):
self.scanline = 0
def end_direction(self):
pass
def new_scanline(self):
self.scanline += 1
self.curr_scanline = []
def end_scanline(self):
self.paths += self.curr_scanline
self.curr_scanline = None
def finish(self):
pass
list = ["PathAccumulator", "SimpleCutter", "ZigZagCutter", "PolygonCutter"]
__all__ = list
from PathAccumulator import PathAccumulator
from SimpleCutter import SimpleCutter
from ZigZagCutter import ZigZagCutter
from PolygonCutter import PolygonCutter
__all__ = [ "iterators", "polynomials"]
class Iterator:
def __init__(self, seq, start=0):
self.seq = seq
self.ind = start
def next(self):
if self.ind >= len(self.seq):
return None
else:
v = self.seq[self.ind]
self.ind += 1
return v
def insertBefore(self, v):
self.seq.insert(self.ind-1, v)
self.ind += 1
def insert(self, v):
self.seq.insert(self.ind, v)
self.ind += 1
def replace(self, v, w):
for i in range(0,len(self.seq)):
if self.seq[i]==v:
self.seq[i]=w
def remove(self, v):
for i in range(0,len(self.seq)):
if self.seq[i]==v:
del self.seq[i]
if i<self.ind:
self.ind -= 1
return
def takeNext(self):
if self.ind >= len(self.seq):
return None
else:
return self.seq.pop(self.ind)
def copy(self):
return Iterator(self.seq, self.ind)
def peek(self, i=0):
if self.ind+i >= len(self.seq):
return None
else:
return self.seq[self.ind+i]
def remains(self):
return len(self.seq)-self.ind
class CyclicIterator:
def __init__(self, seq, start=0):
self.seq = seq
self.ind = start
self.count = len(seq)
def next(self):
v = self.seq[self.ind]
self.ind += 1
if self.ind == len(self.seq):
self.ind = 0
return v
def copy(self):
return CyclicIterator(self.seq, self.ind)
def peek(self, i=0):
idx = self.ind+i
while idx>=len(self.seq):
idx -= len(self.seq)
return self.seq[idx]
if __name__ == "__main__":
l = [1, 2, 4, 6]
print "l=", l
i = Iterator(l)
print i.peek()
while True:
v = i.next()
if v == None:
break
if v == 4:
i.insertBefore(3)
i.insert(5)
print "l=", l
i = Iterator(l)
print "peek(0)=", i.peek(0)
print "peek(1)=", i.peek(1)
print "i.next()=", i.next()
print "peek(0)=", i.peek(0)
print "peek(1)=", i.peek(1)
print "remains=", i.remains()
print "l=", l
sum = 0
i = CyclicIterator(l)
print "cycle :",
while sum<30:
v = i.next()
print v,
sum += v
print "=", sum
i = Iterator(l)
print "l=", l
i.next()
i.next()
print "next,next : ", i.peek()
i.remove(2)
print "remove(2) : ", i.peek()
i.remove(4)
print "remove(4) : ", i.peek()
print "l=", l
from math import *
# see BRL-CAD/src/libbn/poly.c
EPSILON=1e-4
SMALL=1e-4
INV_2=0.5
INV_3=1.0/3.0
INV_4=0.25
INV_27=1.0/27.0
SQRT3=sqrt(3.0)
PI_DIV_3=pi/3.0
def near_zero(x, epsilon=EPSILON):
if x>-epsilon and x<epsilon:
return True
else:
return False
def cuberoot(x):
if x>=0:
return pow(x,INV_3)
else:
return -pow(-x,INV_3)
def poly1_roots(a,b):
if near_zero(a):
return None
return (-b/a,)
def poly2_roots(a,b,c):
d = b*b-4*a*c
if d < 0:
return None
if near_zero(a):
return poly1_roots(b,c)
if d == 0:
return (-b/(2*a), )
q = sqrt(d)
if a<0:
return ((-b+q)/(2*a),(-b-q)/(2*a))
else:
return ((-b-q)/(2*a),(-b+q)/(2*a))
def poly3_roots(a,b,c,d):
if near_zero(a):
return poly2_roots(b,c,d)
c1=b/a
c2=c/a
c3=d/a
c1_3=c1*INV_3
a = c2-c1*c1_3
b = (2*c1*c1*c1-9*c1*c2+27*c3)*INV_27
delta = a*a
delta = b*b*INV_4+delta*a*INV_27
if delta>0:
r_delta = sqrt(delta)
A = -INV_2*b + r_delta
B = -INV_2*b - r_delta
A = cuberoot(A)
B = cuberoot(B)
return (A+B-c1_3, )
elif delta==0:
b_2 = -b*INV_2
s = cuberoot(b_2)
return (2*s-c1_3,-s-c1_3,-s-c1_3,)
else:
if a>0:
fact = 0
phi = 0
cs_phi = 1.0
sn_phi_s3 = 0.0
else:
a *= -INV_3
fact = sqrt(a)
f = -b*INV_2/(a*fact)
if f >= 1.0:
phi = 0
cs_phi = 1.0
sn_phi_s3 = 0.0
elif f <= -1.0:
phi = PI_DIV_3
cs_phi = cos(phi)
sn_phi_s3 = sin(phi)*SQRT3
else:
phi = acos(f)*INV_3
cs_phi = cos(phi)
sn_phi_s3 = sin(phi)*SQRT3
r1 = 2*fact*cs_phi
r2 = fact*( sn_phi_s3 - cs_phi)
r3 = fact*(-sn_phi_s3 - cs_phi)
return (r1-c1_3, r2-c1_3, r3-c1_3)
def max3(a,b,c):
if a>b:
max_ab = a
else:
max_ab = b
if c>max_ab:
return c
else:
return max_ab
def poly4_roots(a,b,c,d,e):
if a==0:
return poly3_roots(b,c,d,e)
c1 = float(b)/a
c2 = float(c)/a
c3 = float(d)/a
c4 = float(e)/a
roots3 = poly3_roots(1.0, -c2, c3*c1-4*c4, -c3*c3-c4*c1*c1+4*c4*c2)
if not roots3:
return None
if len(roots3)==1:
U = roots3[0]
else:
U = max3(roots3[0],roots3[1],roots3[2])
p = c1*c1*INV_4+U-c2
U *= INV_2
q = U*U-c4
if p<0:
if p<-SMALL:
return None
p = 0
else:
p = sqrt(p)
if q<0:
if q<-SMALL:
return None
q = 0
else:
q = sqrt(q)
quad1 = [1.0,c1*INV_2-p,0]
quad2 = [1.0,c1*INV_2+p,0]
q1 = U - q
q2 = U + q
p = quad1[1]*q2+quad2[1]*q1-c3
if near_zero(p):
quad1[2] = q1
quad2[2] = q2
else:
q = quad1[1]*q1+quad2[1]*q2-c3
if near_zero(q):
quad1[2] = q2
quad2[2] = q1
else:
return None
# print "f1(x)=%g*x**2%+g*x%+g" % (quad1[0], quad1[1], quad1[2])
# print "f2(x)=%g*x**2%+g*x%+g" % (quad2[0], quad2[1], quad2[2])
roots1 = poly2_roots(quad1[0], quad1[1], quad1[2])
roots2 = poly2_roots(quad2[0], quad2[1], quad2[2])
if roots1 and roots2:
return roots1+roots2
elif roots1:
return roots1
elif roots2:
return roots2
else:
return None
def test_poly1(a,b):
roots = poly1_roots(a,b)
print a, "*x+",b,"=0 ", roots
if roots:
for r in roots:
f = a*r+b
if not near_zero(f):
print "ERROR:",
print " f(",r,") =", f
def test_poly2(a,b,c):
roots = poly2_roots(a,b,c)
print a, "*x^2+",b,"*x+",c,"=0 ", roots
if roots:
for r in roots:
f = a*r*r+b*r+c
if not near_zero(f):
print "ERROR:",
print " f(",r,") = ", f
def test_poly3(a,b,c,d):
roots = poly3_roots(a,b,c,d)
print a, "*x^3+",b,"*x^2+",c,"*x+",d,"=0 ", roots
if roots:
for r in roots:
f = a*r*r*r+b*r*r+c*r+d
if not near_zero(f):
print "ERROR:",
print " f(",r,") = ", f
def test_poly4(a,b,c,d,e):
roots = poly4_roots(a,b,c,d,e)
print "f(x)=%g*x**4%+g*x**3%+g*x**2%+g*x%+g" % (a,b,c,d,e)
print "roots:", roots
if roots:
for r in roots:
f = a*r*r*r*r+b*r*r*r+c*r*r+d*r+e
if not near_zero(f, epsilon=SMALL):
print "ERROR:",
print " f(",r,") = ", f
return roots
if __name__ == "__main__":
test_poly1(1,2)
test_poly2(1,2,0)
test_poly2(1,2,1)
test_poly2(1,2,2)
test_poly3(1,0,0,0)
test_poly3(1,0,0,-1)
test_poly3(1,-1,0,0)
test_poly3(1,0,-2,0)
test_poly3(1,0,-2,1)
test_poly4(1,0,0,0,0)
test_poly4(1,0,0,0,-1)
test_poly4(1,0,-2,0,1)
test_poly4(1,-10,35,-50,+24)
test_poly4(1,0,6,-60,36)
test_poly4(1,-25,235.895,-995.565,1585.25);
def find_root_subdivide(f, x0, x1, tolerance, scale):
ymin = 0
xmin = 0
imin = 0
while x1-x0>tolerance:
for i in range(0,scale):
x = x1 + (i/scale)*(x1-x0)
y = f(x)
abs_y = abs(y)
if i==0:
ymin = abs_y
xmin = x
imin = 0
else:
if abs_y<ymin:
ymin = abs_y
xmin = x
imin = i
x0 = xmin - 1/scale
x1 = xmin + 1/scale
scale /= 10
return xmin
def find_root_newton_raphson(f, df, x0, tolerance, maxiter):
x = x0
iter = 0
while iter<maxiter:
y = f(x)
if y == 0:
return x
dy = df(x)
if dy == 0:
return None
dx = y/dy
x = x - dx
if dx < tolerance:
break
iter += 1
return x
def find_root(f, df=None, x0=0, x1=1, tolerance=0.001):
return find_root_subdivide(f=f,x0=x0,x1=x1,tolerance=tolerance, scale=10.0)
__all__ = [ "Utils", "Geometry", "Cutters", "PathGenerators", "PathProcessors", "Importers", "Exporters", "Gui"]
import pycam.Utils
import pycam.Geometry
import pycam.Cutters
import pycam.PathGenerators
import pycam.PathProcessors
import pycam.Importers
import pycam.Exporters
import pycam.Gui
from distutils.core import setup
import py2exe
import distutils.sysconfig
import glob
setup(
name="pycam",
description="Python CAM",
version="0.1",
windows=[
{
'script' : 'pycam.py',
}
],
options = {
'py2exe': {
"packages": 'ctypes, logging, weakref, pycam',
"includes": 'distutils.util',
"excludes": 'OpenGL',
}
},
data_files= [
'README.TXT',
distutils.sysconfig.get_python_lib()+"/PyOpenGL-3.0.0b5-py2.5.egg",
distutils.sysconfig.get_python_lib()+"/setuptools-0.6c8-py2.5.egg",
('Samples', glob.glob('Samples/stl/*.stl')),
],
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment