├── .gitignore ├── COPYING ├── Makefile ├── README.md ├── examples ├── box │ ├── box-faces.png │ ├── box-faces.scad │ ├── box.ascii.stl │ ├── box.scad │ └── box.stp ├── cylinder │ ├── cyl-ascii.stl │ ├── cyl-faces.png │ ├── cyl-faces.scad │ ├── cyl.scad │ └── cyl.stp └── tetrix-32mmChannel │ ├── 39065_txm-32mmchannel.step │ ├── channel-ascii.stl │ ├── channel-faces.png │ ├── channel-faces.scad │ └── channel.scad ├── explore-shape.cpp ├── explore-shape.h ├── openscad-step-reader.cpp ├── openscad-triangle-writer.cpp ├── openscad-triangle-writer.h ├── shape_explorer.cpp ├── tessellation.cpp ├── tessellation.h └── triangle.h /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.o 3 | *~ 4 | openscad-step-reader 5 | 6 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ## This make file is hard-coded to work on Debian 10 with the following 2 | ## packages: 3 | ## apt-get install libocct-data-exchange-dev libocct-draw-dev libocct-foundation-dev \ 4 | ## libocct-modeling-algorithms-dev libocct-modeling-data-dev \ 5 | ## libocct-ocaf-dev libocct-visualization-dev \ 6 | ## libtbb-dev 7 | ## 8 | ## Other systems will likely need adjustments. 9 | ## 10 | ## An easy(?) way to see how to build with OpenCASCADE on your system 11 | ## is to follow the installation examples of: 12 | ## https://github.com/miho/OCC-CSG/ 13 | ## 14 | ## After building it, run: 15 | ## cmake . 16 | ## make VERBOSE=1 17 | ## And you'll see the exact G++ command-line that was used. 18 | ## 19 | ## 20 | 21 | CPPFLAGS=-I/usr/include/opencascade 22 | CXXFLAGS=-std=c++11 -g -O0 23 | 24 | LDFLAGS=-lTKSTL -lTKXDESTEP -lTKBinXCAF -lTKXmlXCAF -lTKXDEIGES -lTKXCAF \ 25 | -lTKIGES -lTKSTEP -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKXSBase \ 26 | -lTKStd -lTKStdL -lTKXml -lTKBin -lTKXmlL -lTKBinL -lTKCAF -lTKXCAF \ 27 | -lTKLCAF -lTKCDF -lTKMeshVS -lTKOpenGl -lTKV3d -lTKService \ 28 | -lTKXMesh -lTKMesh -lTKOffset -lTKFeat -lTKFillet -lTKHLR -lTKBool \ 29 | -lTKBO -lTKShHealing -lTKPrim -lTKTopAlgo -lTKGeomAlgo -lTKBRep \ 30 | -lTKGeomBase -lTKG3d -lTKG2d -lTKIGES -lTKSTEP -lTKSTEP209 \ 31 | -lTKSTEPAttr -lTKSTEPBase -lTKXSBase -lTKStd -lTKStdL -lTKXml \ 32 | -lTKBin -lTKXmlL -lTKBinL -lTKCAF -lTKLCAF -lTKCDF -lTKMeshVS \ 33 | -lTKOpenGl -lTKV3d -lTKService -lTKXMesh -lTKMesh -lTKOffset \ 34 | -lTKFeat -lTKFillet -lTKHLR -lTKBool -lTKBO -lTKShHealing \ 35 | -lTKPrim -lTKTopAlgo -lTKGeomAlgo -lTKBRep -lTKGeomBase \ 36 | -lTKG3d -lTKG2d \ 37 | \ 38 | /usr/lib/x86_64-linux-gnu/libTKMath.so.7.3.0 \ 39 | /usr/lib/x86_64-linux-gnu/libTKernel.so.7.3.0 \ 40 | \ 41 | -lfreetype -lpthread -lrt -lstdc++ -ldl -lm\ 42 | 43 | 44 | all: openscad-step-reader 45 | 46 | openscad-step-reader: openscad-step-reader.o \ 47 | tessellation.o \ 48 | openscad-triangle-writer.o \ 49 | explore-shape.o 50 | 51 | openscad-step-reader.o: openscad-step-reader.cpp triangle.h 52 | 53 | tessellation.o: tessellation.cpp tessellation.h triangle.h 54 | 55 | openscad-triangle-writer.o: openscad-triangle-writer.cpp openscad-triangle-writer.h triangle.h 56 | 57 | explore-shape.o: explore-shape.cpp explore-shape.h 58 | 59 | 60 | .PHONY: clean 61 | clean: 62 | rm -f explore-shape.o openscad-step-reader.o openscad-step-reader tessellation.o openscad-triangle-writer.o 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openscad-step-reader 2 | 3 | A proof-of-concept project, testing OpenSCAD / STEP files loading. 4 | 5 | ## Usage 6 | 7 | 8 | $ openscad-step-reader 9 | 10 | A proof-of-concept program for STEP/OpenSCAD integration 11 | 12 | usage: openscad-step-reader [options] INPUT.STEP 13 | 14 | Output is written to STDOUT. 15 | 16 | options are: 17 | -h, --help this help screen 18 | -V, --version version information 19 | 20 | -o, --stl-occt convert the input STEP file into ASCII STL file 21 | using OpenCASCADE code. This should be the baseline 22 | when debugging/troubleshooting incorrect outputs. 23 | 24 | -a, --stl-ascii convert the input STEP file into custom ASCII STL file, 25 | using our code. This is a good test to check mesh 26 | triangulation code. EXCEPT for the 'normal' values 27 | which are not produced, the vertex values should be 28 | equivalent to those with --stl-occt. 29 | 30 | -s, --stl-scad convert the input STEP file into SCAD code, containing 31 | a single 'polyhedron' call with the STL triangles stored 32 | in SCAD vectors. 33 | 34 | -f, --stl-faces convert the input STEP file into SCAD code, retaining the 35 | 'face' information from the STEP file. Each face will be rendered 36 | in a different color in openscad $preview mode. 37 | 38 | -e, --explore Work-in-progress code, used for development and exploration 39 | of OpenCASCADE class hierarchy, e.g. 40 | Shell->Face->Surface->Wire->Edge->Vertex. 41 | produces debug messges and no useful output. 42 | 43 | 44 | ## Examples 45 | 46 | See the [examples] sub directory for STEP files and their STL/SCAD output. 47 | 48 | e.g. the files in `examples/box` were created with: 49 | 50 | openscad-step-reader --stl-ascii examples/box/box.stp > examples/box/box-ascii.stl 51 | openscad-step-reader --stl-scad examples/box/box.stp > examples/box/box.scad 52 | openscad-step-reader --stl-faces examples/box/box.stp > examples/box/box-faces.scad 53 | 54 | 55 | The `--explore` option is a development tool to help learn 56 | and understand the OpenCASCADE hierarchy class model (e.g. 57 | shape->shell->face->surface->wire->edge->vertex). 58 | 59 | $ openscad-step-reader --explore example/cylinder/cyl.stp 60 | 61 | Shell 0 62 | Face 0 Type = 1:Cylinder 63 | Wire 0 64 | edge 0 65 | VertexFirst 2, -4.89859e-16, 10 66 | VertexLast 2, -4.89859e-16, 10 67 | edge 1 68 | VertexFirst 2, -4.89859e-16, 0 69 | VertexLast 2, -4.89859e-16, 10 70 | edge 2 71 | VertexFirst 2, -4.89859e-16, 0 72 | VertexLast 2, -4.89859e-16, 0 73 | edge 3 74 | VertexFirst 2, -4.89859e-16, 0 75 | VertexLast 2, -4.89859e-16, 10 76 | Face 0 Type = 0:Plane 77 | Wire 0 78 | edge 0 79 | VertexFirst 2, -4.89859e-16, 10 80 | VertexLast 2, -4.89859e-16, 10 81 | Face 0 Type = 0:Plane 82 | Wire 0 83 | edge 0 84 | VertexFirst 2, -4.89859e-16, 0 85 | VertexLast 2, -4.89859e-16, 0 86 | 87 | 88 | The `--stl-scad` converts to STEP to triangles (just like an STL file), 89 | then writes the triangles as openSCAD code: 90 | 91 | $ openscad-step-reader --stl-scad example/box/box.stp 92 | points = [ 93 | [0,10,0],[0,0,0],[0,0,10], // Triangle 1 / 12 94 | [0,10,10],[0,10,0],[0,0,10], 95 | [10,0,10],[10,0,0],[10,10,0], 96 | [10,0,10],[10,10,0],[10,10,10], 97 | [0,0,0],[10,0,0],[10,0,10], 98 | [0,0,10],[0,0,0],[10,0,10], 99 | [10,10,10],[10,10,0],[0,10,0], 100 | [10,10,10],[0,10,0],[0,10,10], 101 | [0,0,0],[0,10,0],[10,10,0], 102 | [10,0,0],[0,0,0],[10,10,0], // Triangle 10 / 12 103 | [10,10,10],[0,10,10],[0,0,10], 104 | [10,10,10],[0,0,10],[10,0,10], 105 | ]; 106 | faces = [ 107 | [0,1,2], // Triangle 1 / 12 108 | [3,4,5], 109 | [6,7,8], 110 | [9,10,11], 111 | [12,13,14], 112 | [15,16,17], 113 | [18,19,20], 114 | [21,22,23], 115 | [24,25,26], 116 | [27,28,29], // Triangle 10 / 12 117 | [30,31,32], 118 | [33,34,35], 119 | ]; 120 | module solid_object() { 121 | polyhedron (points,faces); 122 | } 123 | 124 | solid_object(); 125 | 126 | 127 | ## License 128 | 129 | Written by Assaf Gordon (assafgordon@gmail.com) 130 | License: LGPLv2.1 or later 131 | -------------------------------------------------------------------------------- /examples/box/box-faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agordon/openscad-step-reader/801da20a643d64372bf148be86fe0036fc9e0776/examples/box/box-faces.png -------------------------------------------------------------------------------- /examples/box/box-faces.scad: -------------------------------------------------------------------------------- 1 | face_1_points = [ 2 | [0,10,0],[0,0,0],[0,0,10], // Triangle 1 / 2 3 | [0,10,10],[0,10,0],[0,0,10], 4 | ]; 5 | face_1_faces = [ 6 | [0,1,2], // Triangle 1 / 2 7 | [3,4,5], 8 | ]; 9 | 10 | face_2_points = [ 11 | [10,0,10],[10,0,0],[10,10,0], // Triangle 1 / 2 12 | [10,0,10],[10,10,0],[10,10,10], 13 | ]; 14 | face_2_faces = [ 15 | [0,1,2], // Triangle 1 / 2 16 | [3,4,5], 17 | ]; 18 | 19 | face_3_points = [ 20 | [0,0,0],[10,0,0],[10,0,10], // Triangle 1 / 2 21 | [0,0,10],[0,0,0],[10,0,10], 22 | ]; 23 | face_3_faces = [ 24 | [0,1,2], // Triangle 1 / 2 25 | [3,4,5], 26 | ]; 27 | 28 | face_4_points = [ 29 | [10,10,10],[10,10,0],[0,10,0], // Triangle 1 / 2 30 | [10,10,10],[0,10,0],[0,10,10], 31 | ]; 32 | face_4_faces = [ 33 | [0,1,2], // Triangle 1 / 2 34 | [3,4,5], 35 | ]; 36 | 37 | face_5_points = [ 38 | [0,0,0],[0,10,0],[10,10,0], // Triangle 1 / 2 39 | [10,0,0],[0,0,0],[10,10,0], 40 | ]; 41 | face_5_faces = [ 42 | [0,1,2], // Triangle 1 / 2 43 | [3,4,5], 44 | ]; 45 | 46 | face_6_points = [ 47 | [10,10,10],[0,10,10],[0,0,10], // Triangle 1 / 2 48 | [10,10,10],[0,0,10],[10,0,10], 49 | ]; 50 | face_6_faces = [ 51 | [0,1,2], // Triangle 1 / 2 52 | [3,4,5], 53 | ]; 54 | 55 | module crazy_colors() { 56 | color("Violet") 57 | polyhedron(face_1_points, face_1_faces); 58 | color("red") 59 | polyhedron(face_2_points, face_2_faces); 60 | color("blue") 61 | polyhedron(face_3_points, face_3_faces); 62 | color("LawnGreen") 63 | polyhedron(face_4_points, face_4_faces); 64 | color("Orange") 65 | polyhedron(face_5_points, face_5_faces); 66 | color("DeepPink") 67 | polyhedron(face_6_points, face_6_faces); 68 | } 69 | function add_offset(vec,ofs) = [for (x=vec) x + [ofs,ofs,ofs]]; 70 | module solid_object() { 71 | tmp1_points = face_1_points; 72 | tmp1_faces = face_1_faces; 73 | 74 | tmp2_points = concat(tmp1_points, face_2_points); 75 | tmp2_faces = concat(tmp1_faces,add_offset(face_2_faces,len(tmp1_points))); 76 | 77 | tmp3_points = concat(tmp2_points, face_3_points); 78 | tmp3_faces = concat(tmp2_faces,add_offset(face_3_faces,len(tmp2_points))); 79 | 80 | tmp4_points = concat(tmp3_points, face_4_points); 81 | tmp4_faces = concat(tmp3_faces,add_offset(face_4_faces,len(tmp3_points))); 82 | 83 | tmp5_points = concat(tmp4_points, face_5_points); 84 | tmp5_faces = concat(tmp4_faces,add_offset(face_5_faces,len(tmp4_points))); 85 | 86 | tmp6_points = concat(tmp5_points, face_6_points); 87 | tmp6_faces = concat(tmp5_faces,add_offset(face_6_faces,len(tmp5_points))); 88 | 89 | polyhedron (tmp6_points, tmp6_faces); 90 | } 91 | 92 | 93 | if ($preview) {; 94 | crazy_colors(); 95 | } else { 96 | solid_object(); 97 | } 98 | -------------------------------------------------------------------------------- /examples/box/box.ascii.stl: -------------------------------------------------------------------------------- 1 | solid 2 | facet normal 42 42 42 3 | outer loop 4 | vertex 0 10 0 5 | vertex 0 0 0 6 | vertex 0 0 10 7 | endloop 8 | endfacet 9 | facet normal 42 42 42 10 | outer loop 11 | vertex 0 10 10 12 | vertex 0 10 0 13 | vertex 0 0 10 14 | endloop 15 | endfacet 16 | facet normal 42 42 42 17 | outer loop 18 | vertex 10 0 10 19 | vertex 10 0 0 20 | vertex 10 10 0 21 | endloop 22 | endfacet 23 | facet normal 42 42 42 24 | outer loop 25 | vertex 10 0 10 26 | vertex 10 10 0 27 | vertex 10 10 10 28 | endloop 29 | endfacet 30 | facet normal 42 42 42 31 | outer loop 32 | vertex 0 0 0 33 | vertex 10 0 0 34 | vertex 10 0 10 35 | endloop 36 | endfacet 37 | facet normal 42 42 42 38 | outer loop 39 | vertex 0 0 10 40 | vertex 0 0 0 41 | vertex 10 0 10 42 | endloop 43 | endfacet 44 | facet normal 42 42 42 45 | outer loop 46 | vertex 10 10 10 47 | vertex 10 10 0 48 | vertex 0 10 0 49 | endloop 50 | endfacet 51 | facet normal 42 42 42 52 | outer loop 53 | vertex 10 10 10 54 | vertex 0 10 0 55 | vertex 0 10 10 56 | endloop 57 | endfacet 58 | facet normal 42 42 42 59 | outer loop 60 | vertex 0 0 0 61 | vertex 0 10 0 62 | vertex 10 10 0 63 | endloop 64 | endfacet 65 | facet normal 42 42 42 66 | outer loop 67 | vertex 10 0 0 68 | vertex 0 0 0 69 | vertex 10 10 0 70 | endloop 71 | endfacet 72 | facet normal 42 42 42 73 | outer loop 74 | vertex 10 10 10 75 | vertex 0 10 10 76 | vertex 0 0 10 77 | endloop 78 | endfacet 79 | facet normal 42 42 42 80 | outer loop 81 | vertex 10 10 10 82 | vertex 0 0 10 83 | vertex 10 0 10 84 | endloop 85 | endfacet 86 | endsolid 87 | -------------------------------------------------------------------------------- /examples/box/box.scad: -------------------------------------------------------------------------------- 1 | points = [ 2 | [0,10,0],[0,0,0],[0,0,10], // Triangle 1 / 12 3 | [0,10,10],[0,10,0],[0,0,10], 4 | [10,0,10],[10,0,0],[10,10,0], 5 | [10,0,10],[10,10,0],[10,10,10], 6 | [0,0,0],[10,0,0],[10,0,10], 7 | [0,0,10],[0,0,0],[10,0,10], 8 | [10,10,10],[10,10,0],[0,10,0], 9 | [10,10,10],[0,10,0],[0,10,10], 10 | [0,0,0],[0,10,0],[10,10,0], 11 | [10,0,0],[0,0,0],[10,10,0], // Triangle 10 / 12 12 | [10,10,10],[0,10,10],[0,0,10], 13 | [10,10,10],[0,0,10],[10,0,10], 14 | ]; 15 | faces = [ 16 | [0,1,2], // Triangle 1 / 12 17 | [3,4,5], 18 | [6,7,8], 19 | [9,10,11], 20 | [12,13,14], 21 | [15,16,17], 22 | [18,19,20], 23 | [21,22,23], 24 | [24,25,26], 25 | [27,28,29], // Triangle 10 / 12 26 | [30,31,32], 27 | [33,34,35], 28 | ]; 29 | module solid_object() { 30 | polyhedron (points,faces); 31 | } 32 | 33 | solid_object(); 34 | -------------------------------------------------------------------------------- /examples/box/box.stp: -------------------------------------------------------------------------------- 1 | ISO-10303-21; 2 | HEADER; 3 | FILE_DESCRIPTION(('FreeCAD Model'),'2;1'); 4 | FILE_NAME('/home/gordon/sources/OCC-CSG/build/box.stp', 5 | '2019-09-06T06:29:46',('Author'),(''), 6 | 'Open CASCADE STEP processor 7.3','FreeCAD','Unknown'); 7 | FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }')); 8 | ENDSEC; 9 | DATA; 10 | #1 = APPLICATION_PROTOCOL_DEFINITION('international standard', 11 | 'automotive_design',2000,#2); 12 | #2 = APPLICATION_CONTEXT( 13 | 'core data for automotive mechanical design processes'); 14 | #3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10); 15 | #4 = PRODUCT_DEFINITION_SHAPE('','',#5); 16 | #5 = PRODUCT_DEFINITION('design','',#6,#9); 17 | #6 = PRODUCT_DEFINITION_FORMATION('','',#7); 18 | #7 = PRODUCT('Cube','Cube','',(#8)); 19 | #8 = PRODUCT_CONTEXT('',#2,'mechanical'); 20 | #9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design'); 21 | #10 = ADVANCED_BREP_SHAPE_REPRESENTATION('',(#11,#15),#345); 22 | #11 = AXIS2_PLACEMENT_3D('',#12,#13,#14); 23 | #12 = CARTESIAN_POINT('',(0.,0.,0.)); 24 | #13 = DIRECTION('',(0.,0.,1.)); 25 | #14 = DIRECTION('',(1.,0.,-0.)); 26 | #15 = MANIFOLD_SOLID_BREP('',#16); 27 | #16 = CLOSED_SHELL('',(#17,#137,#237,#284,#331,#338)); 28 | #17 = ADVANCED_FACE('',(#18),#32,.F.); 29 | #18 = FACE_BOUND('',#19,.F.); 30 | #19 = EDGE_LOOP('',(#20,#55,#83,#111)); 31 | #20 = ORIENTED_EDGE('',*,*,#21,.F.); 32 | #21 = EDGE_CURVE('',#22,#24,#26,.T.); 33 | #22 = VERTEX_POINT('',#23); 34 | #23 = CARTESIAN_POINT('',(0.,0.,0.)); 35 | #24 = VERTEX_POINT('',#25); 36 | #25 = CARTESIAN_POINT('',(0.,0.,10.)); 37 | #26 = SURFACE_CURVE('',#27,(#31,#43),.PCURVE_S1.); 38 | #27 = LINE('',#28,#29); 39 | #28 = CARTESIAN_POINT('',(0.,0.,0.)); 40 | #29 = VECTOR('',#30,1.); 41 | #30 = DIRECTION('',(0.,0.,1.)); 42 | #31 = PCURVE('',#32,#37); 43 | #32 = PLANE('',#33); 44 | #33 = AXIS2_PLACEMENT_3D('',#34,#35,#36); 45 | #34 = CARTESIAN_POINT('',(0.,0.,0.)); 46 | #35 = DIRECTION('',(1.,0.,-0.)); 47 | #36 = DIRECTION('',(0.,0.,1.)); 48 | #37 = DEFINITIONAL_REPRESENTATION('',(#38),#42); 49 | #38 = LINE('',#39,#40); 50 | #39 = CARTESIAN_POINT('',(0.,0.)); 51 | #40 = VECTOR('',#41,1.); 52 | #41 = DIRECTION('',(1.,0.)); 53 | #42 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 54 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 55 | ) ); 56 | #43 = PCURVE('',#44,#49); 57 | #44 = PLANE('',#45); 58 | #45 = AXIS2_PLACEMENT_3D('',#46,#47,#48); 59 | #46 = CARTESIAN_POINT('',(0.,0.,0.)); 60 | #47 = DIRECTION('',(-0.,1.,0.)); 61 | #48 = DIRECTION('',(0.,0.,1.)); 62 | #49 = DEFINITIONAL_REPRESENTATION('',(#50),#54); 63 | #50 = LINE('',#51,#52); 64 | #51 = CARTESIAN_POINT('',(0.,0.)); 65 | #52 = VECTOR('',#53,1.); 66 | #53 = DIRECTION('',(1.,0.)); 67 | #54 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 68 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 69 | ) ); 70 | #55 = ORIENTED_EDGE('',*,*,#56,.T.); 71 | #56 = EDGE_CURVE('',#22,#57,#59,.T.); 72 | #57 = VERTEX_POINT('',#58); 73 | #58 = CARTESIAN_POINT('',(0.,10.,0.)); 74 | #59 = SURFACE_CURVE('',#60,(#64,#71),.PCURVE_S1.); 75 | #60 = LINE('',#61,#62); 76 | #61 = CARTESIAN_POINT('',(0.,0.,0.)); 77 | #62 = VECTOR('',#63,1.); 78 | #63 = DIRECTION('',(-0.,1.,0.)); 79 | #64 = PCURVE('',#32,#65); 80 | #65 = DEFINITIONAL_REPRESENTATION('',(#66),#70); 81 | #66 = LINE('',#67,#68); 82 | #67 = CARTESIAN_POINT('',(0.,0.)); 83 | #68 = VECTOR('',#69,1.); 84 | #69 = DIRECTION('',(0.,-1.)); 85 | #70 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 86 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 87 | ) ); 88 | #71 = PCURVE('',#72,#77); 89 | #72 = PLANE('',#73); 90 | #73 = AXIS2_PLACEMENT_3D('',#74,#75,#76); 91 | #74 = CARTESIAN_POINT('',(0.,0.,0.)); 92 | #75 = DIRECTION('',(0.,0.,1.)); 93 | #76 = DIRECTION('',(1.,0.,-0.)); 94 | #77 = DEFINITIONAL_REPRESENTATION('',(#78),#82); 95 | #78 = LINE('',#79,#80); 96 | #79 = CARTESIAN_POINT('',(0.,0.)); 97 | #80 = VECTOR('',#81,1.); 98 | #81 = DIRECTION('',(0.,1.)); 99 | #82 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 100 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 101 | ) ); 102 | #83 = ORIENTED_EDGE('',*,*,#84,.T.); 103 | #84 = EDGE_CURVE('',#57,#85,#87,.T.); 104 | #85 = VERTEX_POINT('',#86); 105 | #86 = CARTESIAN_POINT('',(0.,10.,10.)); 106 | #87 = SURFACE_CURVE('',#88,(#92,#99),.PCURVE_S1.); 107 | #88 = LINE('',#89,#90); 108 | #89 = CARTESIAN_POINT('',(0.,10.,0.)); 109 | #90 = VECTOR('',#91,1.); 110 | #91 = DIRECTION('',(0.,0.,1.)); 111 | #92 = PCURVE('',#32,#93); 112 | #93 = DEFINITIONAL_REPRESENTATION('',(#94),#98); 113 | #94 = LINE('',#95,#96); 114 | #95 = CARTESIAN_POINT('',(0.,-10.)); 115 | #96 = VECTOR('',#97,1.); 116 | #97 = DIRECTION('',(1.,0.)); 117 | #98 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 118 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 119 | ) ); 120 | #99 = PCURVE('',#100,#105); 121 | #100 = PLANE('',#101); 122 | #101 = AXIS2_PLACEMENT_3D('',#102,#103,#104); 123 | #102 = CARTESIAN_POINT('',(0.,10.,0.)); 124 | #103 = DIRECTION('',(-0.,1.,0.)); 125 | #104 = DIRECTION('',(0.,0.,1.)); 126 | #105 = DEFINITIONAL_REPRESENTATION('',(#106),#110); 127 | #106 = LINE('',#107,#108); 128 | #107 = CARTESIAN_POINT('',(0.,0.)); 129 | #108 = VECTOR('',#109,1.); 130 | #109 = DIRECTION('',(1.,0.)); 131 | #110 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 132 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 133 | ) ); 134 | #111 = ORIENTED_EDGE('',*,*,#112,.F.); 135 | #112 = EDGE_CURVE('',#24,#85,#113,.T.); 136 | #113 = SURFACE_CURVE('',#114,(#118,#125),.PCURVE_S1.); 137 | #114 = LINE('',#115,#116); 138 | #115 = CARTESIAN_POINT('',(0.,0.,10.)); 139 | #116 = VECTOR('',#117,1.); 140 | #117 = DIRECTION('',(-0.,1.,0.)); 141 | #118 = PCURVE('',#32,#119); 142 | #119 = DEFINITIONAL_REPRESENTATION('',(#120),#124); 143 | #120 = LINE('',#121,#122); 144 | #121 = CARTESIAN_POINT('',(10.,0.)); 145 | #122 = VECTOR('',#123,1.); 146 | #123 = DIRECTION('',(0.,-1.)); 147 | #124 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 148 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 149 | ) ); 150 | #125 = PCURVE('',#126,#131); 151 | #126 = PLANE('',#127); 152 | #127 = AXIS2_PLACEMENT_3D('',#128,#129,#130); 153 | #128 = CARTESIAN_POINT('',(0.,0.,10.)); 154 | #129 = DIRECTION('',(0.,0.,1.)); 155 | #130 = DIRECTION('',(1.,0.,-0.)); 156 | #131 = DEFINITIONAL_REPRESENTATION('',(#132),#136); 157 | #132 = LINE('',#133,#134); 158 | #133 = CARTESIAN_POINT('',(0.,0.)); 159 | #134 = VECTOR('',#135,1.); 160 | #135 = DIRECTION('',(0.,1.)); 161 | #136 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 162 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 163 | ) ); 164 | #137 = ADVANCED_FACE('',(#138),#152,.T.); 165 | #138 = FACE_BOUND('',#139,.T.); 166 | #139 = EDGE_LOOP('',(#140,#170,#193,#216)); 167 | #140 = ORIENTED_EDGE('',*,*,#141,.F.); 168 | #141 = EDGE_CURVE('',#142,#144,#146,.T.); 169 | #142 = VERTEX_POINT('',#143); 170 | #143 = CARTESIAN_POINT('',(10.,0.,0.)); 171 | #144 = VERTEX_POINT('',#145); 172 | #145 = CARTESIAN_POINT('',(10.,0.,10.)); 173 | #146 = SURFACE_CURVE('',#147,(#151,#163),.PCURVE_S1.); 174 | #147 = LINE('',#148,#149); 175 | #148 = CARTESIAN_POINT('',(10.,0.,0.)); 176 | #149 = VECTOR('',#150,1.); 177 | #150 = DIRECTION('',(0.,0.,1.)); 178 | #151 = PCURVE('',#152,#157); 179 | #152 = PLANE('',#153); 180 | #153 = AXIS2_PLACEMENT_3D('',#154,#155,#156); 181 | #154 = CARTESIAN_POINT('',(10.,0.,0.)); 182 | #155 = DIRECTION('',(1.,0.,-0.)); 183 | #156 = DIRECTION('',(0.,0.,1.)); 184 | #157 = DEFINITIONAL_REPRESENTATION('',(#158),#162); 185 | #158 = LINE('',#159,#160); 186 | #159 = CARTESIAN_POINT('',(0.,0.)); 187 | #160 = VECTOR('',#161,1.); 188 | #161 = DIRECTION('',(1.,0.)); 189 | #162 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 190 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 191 | ) ); 192 | #163 = PCURVE('',#44,#164); 193 | #164 = DEFINITIONAL_REPRESENTATION('',(#165),#169); 194 | #165 = LINE('',#166,#167); 195 | #166 = CARTESIAN_POINT('',(0.,10.)); 196 | #167 = VECTOR('',#168,1.); 197 | #168 = DIRECTION('',(1.,0.)); 198 | #169 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 199 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 200 | ) ); 201 | #170 = ORIENTED_EDGE('',*,*,#171,.T.); 202 | #171 = EDGE_CURVE('',#142,#172,#174,.T.); 203 | #172 = VERTEX_POINT('',#173); 204 | #173 = CARTESIAN_POINT('',(10.,10.,0.)); 205 | #174 = SURFACE_CURVE('',#175,(#179,#186),.PCURVE_S1.); 206 | #175 = LINE('',#176,#177); 207 | #176 = CARTESIAN_POINT('',(10.,0.,0.)); 208 | #177 = VECTOR('',#178,1.); 209 | #178 = DIRECTION('',(-0.,1.,0.)); 210 | #179 = PCURVE('',#152,#180); 211 | #180 = DEFINITIONAL_REPRESENTATION('',(#181),#185); 212 | #181 = LINE('',#182,#183); 213 | #182 = CARTESIAN_POINT('',(0.,0.)); 214 | #183 = VECTOR('',#184,1.); 215 | #184 = DIRECTION('',(0.,-1.)); 216 | #185 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 217 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 218 | ) ); 219 | #186 = PCURVE('',#72,#187); 220 | #187 = DEFINITIONAL_REPRESENTATION('',(#188),#192); 221 | #188 = LINE('',#189,#190); 222 | #189 = CARTESIAN_POINT('',(10.,0.)); 223 | #190 = VECTOR('',#191,1.); 224 | #191 = DIRECTION('',(0.,1.)); 225 | #192 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 226 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 227 | ) ); 228 | #193 = ORIENTED_EDGE('',*,*,#194,.T.); 229 | #194 = EDGE_CURVE('',#172,#195,#197,.T.); 230 | #195 = VERTEX_POINT('',#196); 231 | #196 = CARTESIAN_POINT('',(10.,10.,10.)); 232 | #197 = SURFACE_CURVE('',#198,(#202,#209),.PCURVE_S1.); 233 | #198 = LINE('',#199,#200); 234 | #199 = CARTESIAN_POINT('',(10.,10.,0.)); 235 | #200 = VECTOR('',#201,1.); 236 | #201 = DIRECTION('',(0.,0.,1.)); 237 | #202 = PCURVE('',#152,#203); 238 | #203 = DEFINITIONAL_REPRESENTATION('',(#204),#208); 239 | #204 = LINE('',#205,#206); 240 | #205 = CARTESIAN_POINT('',(0.,-10.)); 241 | #206 = VECTOR('',#207,1.); 242 | #207 = DIRECTION('',(1.,0.)); 243 | #208 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 244 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 245 | ) ); 246 | #209 = PCURVE('',#100,#210); 247 | #210 = DEFINITIONAL_REPRESENTATION('',(#211),#215); 248 | #211 = LINE('',#212,#213); 249 | #212 = CARTESIAN_POINT('',(0.,10.)); 250 | #213 = VECTOR('',#214,1.); 251 | #214 = DIRECTION('',(1.,0.)); 252 | #215 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 253 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 254 | ) ); 255 | #216 = ORIENTED_EDGE('',*,*,#217,.F.); 256 | #217 = EDGE_CURVE('',#144,#195,#218,.T.); 257 | #218 = SURFACE_CURVE('',#219,(#223,#230),.PCURVE_S1.); 258 | #219 = LINE('',#220,#221); 259 | #220 = CARTESIAN_POINT('',(10.,0.,10.)); 260 | #221 = VECTOR('',#222,1.); 261 | #222 = DIRECTION('',(-0.,1.,0.)); 262 | #223 = PCURVE('',#152,#224); 263 | #224 = DEFINITIONAL_REPRESENTATION('',(#225),#229); 264 | #225 = LINE('',#226,#227); 265 | #226 = CARTESIAN_POINT('',(10.,0.)); 266 | #227 = VECTOR('',#228,1.); 267 | #228 = DIRECTION('',(0.,-1.)); 268 | #229 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 269 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 270 | ) ); 271 | #230 = PCURVE('',#126,#231); 272 | #231 = DEFINITIONAL_REPRESENTATION('',(#232),#236); 273 | #232 = LINE('',#233,#234); 274 | #233 = CARTESIAN_POINT('',(10.,0.)); 275 | #234 = VECTOR('',#235,1.); 276 | #235 = DIRECTION('',(0.,1.)); 277 | #236 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 278 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 279 | ) ); 280 | #237 = ADVANCED_FACE('',(#238),#44,.F.); 281 | #238 = FACE_BOUND('',#239,.F.); 282 | #239 = EDGE_LOOP('',(#240,#261,#262,#283)); 283 | #240 = ORIENTED_EDGE('',*,*,#241,.F.); 284 | #241 = EDGE_CURVE('',#22,#142,#242,.T.); 285 | #242 = SURFACE_CURVE('',#243,(#247,#254),.PCURVE_S1.); 286 | #243 = LINE('',#244,#245); 287 | #244 = CARTESIAN_POINT('',(0.,0.,0.)); 288 | #245 = VECTOR('',#246,1.); 289 | #246 = DIRECTION('',(1.,0.,-0.)); 290 | #247 = PCURVE('',#44,#248); 291 | #248 = DEFINITIONAL_REPRESENTATION('',(#249),#253); 292 | #249 = LINE('',#250,#251); 293 | #250 = CARTESIAN_POINT('',(0.,0.)); 294 | #251 = VECTOR('',#252,1.); 295 | #252 = DIRECTION('',(0.,1.)); 296 | #253 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 297 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 298 | ) ); 299 | #254 = PCURVE('',#72,#255); 300 | #255 = DEFINITIONAL_REPRESENTATION('',(#256),#260); 301 | #256 = LINE('',#257,#258); 302 | #257 = CARTESIAN_POINT('',(0.,0.)); 303 | #258 = VECTOR('',#259,1.); 304 | #259 = DIRECTION('',(1.,0.)); 305 | #260 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 306 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 307 | ) ); 308 | #261 = ORIENTED_EDGE('',*,*,#21,.T.); 309 | #262 = ORIENTED_EDGE('',*,*,#263,.T.); 310 | #263 = EDGE_CURVE('',#24,#144,#264,.T.); 311 | #264 = SURFACE_CURVE('',#265,(#269,#276),.PCURVE_S1.); 312 | #265 = LINE('',#266,#267); 313 | #266 = CARTESIAN_POINT('',(0.,0.,10.)); 314 | #267 = VECTOR('',#268,1.); 315 | #268 = DIRECTION('',(1.,0.,-0.)); 316 | #269 = PCURVE('',#44,#270); 317 | #270 = DEFINITIONAL_REPRESENTATION('',(#271),#275); 318 | #271 = LINE('',#272,#273); 319 | #272 = CARTESIAN_POINT('',(10.,0.)); 320 | #273 = VECTOR('',#274,1.); 321 | #274 = DIRECTION('',(0.,1.)); 322 | #275 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 323 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 324 | ) ); 325 | #276 = PCURVE('',#126,#277); 326 | #277 = DEFINITIONAL_REPRESENTATION('',(#278),#282); 327 | #278 = LINE('',#279,#280); 328 | #279 = CARTESIAN_POINT('',(0.,0.)); 329 | #280 = VECTOR('',#281,1.); 330 | #281 = DIRECTION('',(1.,0.)); 331 | #282 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 332 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 333 | ) ); 334 | #283 = ORIENTED_EDGE('',*,*,#141,.F.); 335 | #284 = ADVANCED_FACE('',(#285),#100,.T.); 336 | #285 = FACE_BOUND('',#286,.T.); 337 | #286 = EDGE_LOOP('',(#287,#308,#309,#330)); 338 | #287 = ORIENTED_EDGE('',*,*,#288,.F.); 339 | #288 = EDGE_CURVE('',#57,#172,#289,.T.); 340 | #289 = SURFACE_CURVE('',#290,(#294,#301),.PCURVE_S1.); 341 | #290 = LINE('',#291,#292); 342 | #291 = CARTESIAN_POINT('',(0.,10.,0.)); 343 | #292 = VECTOR('',#293,1.); 344 | #293 = DIRECTION('',(1.,0.,-0.)); 345 | #294 = PCURVE('',#100,#295); 346 | #295 = DEFINITIONAL_REPRESENTATION('',(#296),#300); 347 | #296 = LINE('',#297,#298); 348 | #297 = CARTESIAN_POINT('',(0.,0.)); 349 | #298 = VECTOR('',#299,1.); 350 | #299 = DIRECTION('',(0.,1.)); 351 | #300 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 352 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 353 | ) ); 354 | #301 = PCURVE('',#72,#302); 355 | #302 = DEFINITIONAL_REPRESENTATION('',(#303),#307); 356 | #303 = LINE('',#304,#305); 357 | #304 = CARTESIAN_POINT('',(0.,10.)); 358 | #305 = VECTOR('',#306,1.); 359 | #306 = DIRECTION('',(1.,0.)); 360 | #307 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 361 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 362 | ) ); 363 | #308 = ORIENTED_EDGE('',*,*,#84,.T.); 364 | #309 = ORIENTED_EDGE('',*,*,#310,.T.); 365 | #310 = EDGE_CURVE('',#85,#195,#311,.T.); 366 | #311 = SURFACE_CURVE('',#312,(#316,#323),.PCURVE_S1.); 367 | #312 = LINE('',#313,#314); 368 | #313 = CARTESIAN_POINT('',(0.,10.,10.)); 369 | #314 = VECTOR('',#315,1.); 370 | #315 = DIRECTION('',(1.,0.,-0.)); 371 | #316 = PCURVE('',#100,#317); 372 | #317 = DEFINITIONAL_REPRESENTATION('',(#318),#322); 373 | #318 = LINE('',#319,#320); 374 | #319 = CARTESIAN_POINT('',(10.,0.)); 375 | #320 = VECTOR('',#321,1.); 376 | #321 = DIRECTION('',(0.,1.)); 377 | #322 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 378 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 379 | ) ); 380 | #323 = PCURVE('',#126,#324); 381 | #324 = DEFINITIONAL_REPRESENTATION('',(#325),#329); 382 | #325 = LINE('',#326,#327); 383 | #326 = CARTESIAN_POINT('',(0.,10.)); 384 | #327 = VECTOR('',#328,1.); 385 | #328 = DIRECTION('',(1.,0.)); 386 | #329 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 387 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 388 | ) ); 389 | #330 = ORIENTED_EDGE('',*,*,#194,.F.); 390 | #331 = ADVANCED_FACE('',(#332),#72,.F.); 391 | #332 = FACE_BOUND('',#333,.F.); 392 | #333 = EDGE_LOOP('',(#334,#335,#336,#337)); 393 | #334 = ORIENTED_EDGE('',*,*,#56,.F.); 394 | #335 = ORIENTED_EDGE('',*,*,#241,.T.); 395 | #336 = ORIENTED_EDGE('',*,*,#171,.T.); 396 | #337 = ORIENTED_EDGE('',*,*,#288,.F.); 397 | #338 = ADVANCED_FACE('',(#339),#126,.T.); 398 | #339 = FACE_BOUND('',#340,.T.); 399 | #340 = EDGE_LOOP('',(#341,#342,#343,#344)); 400 | #341 = ORIENTED_EDGE('',*,*,#112,.F.); 401 | #342 = ORIENTED_EDGE('',*,*,#263,.T.); 402 | #343 = ORIENTED_EDGE('',*,*,#217,.T.); 403 | #344 = ORIENTED_EDGE('',*,*,#310,.F.); 404 | #345 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) 405 | GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#349)) GLOBAL_UNIT_ASSIGNED_CONTEXT 406 | ((#346,#347,#348)) REPRESENTATION_CONTEXT('Context #1', 407 | '3D Context with UNIT and UNCERTAINTY') ); 408 | #346 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); 409 | #347 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); 410 | #348 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); 411 | #349 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#346, 412 | 'distance_accuracy_value','confusion accuracy'); 413 | #350 = PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#7)); 414 | ENDSEC; 415 | END-ISO-10303-21; 416 | -------------------------------------------------------------------------------- /examples/cylinder/cyl-ascii.stl: -------------------------------------------------------------------------------- 1 | solid 2 | facet normal 42 42 42 3 | outer loop 4 | vertex -0.70921 -1.87003 10 5 | vertex -1.13613 -1.64597 10 6 | vertex -0.70921 -1.87003 0 7 | endloop 8 | endfacet 9 | facet normal 42 42 42 10 | outer loop 11 | vertex -0.241073 -1.98542 10 12 | vertex -0.70921 -1.87003 10 13 | vertex -0.70921 -1.87003 0 14 | endloop 15 | endfacet 16 | facet normal 42 42 42 17 | outer loop 18 | vertex -0.241073 -1.98542 10 19 | vertex -0.70921 -1.87003 0 20 | vertex -0.241073 -1.98542 0 21 | endloop 22 | endfacet 23 | facet normal 42 42 42 24 | outer loop 25 | vertex 1.94188 0.478631 10 26 | vertex 2 -4.89859e-16 10 27 | vertex 2 -4.89859e-16 0 28 | endloop 29 | endfacet 30 | facet normal 42 42 42 31 | outer loop 32 | vertex 0.241073 -1.98542 10 33 | vertex -0.241073 -1.98542 10 34 | vertex -0.241073 -1.98542 0 35 | endloop 36 | endfacet 37 | facet normal 42 42 42 38 | outer loop 39 | vertex 1.94188 0.478631 10 40 | vertex 2 -4.89859e-16 0 41 | vertex 1.94188 0.478631 0 42 | endloop 43 | endfacet 44 | facet normal 42 42 42 45 | outer loop 46 | vertex 0.241073 -1.98542 10 47 | vertex -0.241073 -1.98542 0 48 | vertex 0.241073 -1.98542 0 49 | endloop 50 | endfacet 51 | facet normal 42 42 42 52 | outer loop 53 | vertex 1.77091 0.929446 10 54 | vertex 1.94188 0.478631 0 55 | vertex 1.77091 0.929446 0 56 | endloop 57 | endfacet 58 | facet normal 42 42 42 59 | outer loop 60 | vertex 0.70921 -1.87003 10 61 | vertex 0.241073 -1.98542 10 62 | vertex 0.241073 -1.98542 0 63 | endloop 64 | endfacet 65 | facet normal 42 42 42 66 | outer loop 67 | vertex 0.70921 -1.87003 10 68 | vertex 0.241073 -1.98542 0 69 | vertex 0.70921 -1.87003 0 70 | endloop 71 | endfacet 72 | facet normal 42 42 42 73 | outer loop 74 | vertex 1.77091 0.929446 10 75 | vertex 1.94188 0.478631 10 76 | vertex 1.94188 0.478631 0 77 | endloop 78 | endfacet 79 | facet normal 42 42 42 80 | outer loop 81 | vertex 1.49702 1.32625 10 82 | vertex 1.77091 0.929446 0 83 | vertex 1.49702 1.32625 0 84 | endloop 85 | endfacet 86 | facet normal 42 42 42 87 | outer loop 88 | vertex 1.13613 -1.64597 10 89 | vertex 0.70921 -1.87003 10 90 | vertex 0.70921 -1.87003 0 91 | endloop 92 | endfacet 93 | facet normal 42 42 42 94 | outer loop 95 | vertex 1.13613 -1.64597 10 96 | vertex 0.70921 -1.87003 0 97 | vertex 1.13613 -1.64597 0 98 | endloop 99 | endfacet 100 | facet normal 42 42 42 101 | outer loop 102 | vertex 1.49702 1.32625 10 103 | vertex 1.77091 0.929446 10 104 | vertex 1.77091 0.929446 0 105 | endloop 106 | endfacet 107 | facet normal 42 42 42 108 | outer loop 109 | vertex 1.49702 -1.32625 10 110 | vertex 1.13613 -1.64597 10 111 | vertex 1.13613 -1.64597 0 112 | endloop 113 | endfacet 114 | facet normal 42 42 42 115 | outer loop 116 | vertex 1.13613 1.64597 10 117 | vertex 1.49702 1.32625 0 118 | vertex 1.13613 1.64597 0 119 | endloop 120 | endfacet 121 | facet normal 42 42 42 122 | outer loop 123 | vertex 1.49702 -1.32625 10 124 | vertex 1.13613 -1.64597 0 125 | vertex 1.49702 -1.32625 0 126 | endloop 127 | endfacet 128 | facet normal 42 42 42 129 | outer loop 130 | vertex 1.13613 1.64597 10 131 | vertex 1.49702 1.32625 10 132 | vertex 1.49702 1.32625 0 133 | endloop 134 | endfacet 135 | facet normal 42 42 42 136 | outer loop 137 | vertex 1.77091 -0.929446 10 138 | vertex 1.49702 -1.32625 0 139 | vertex 1.77091 -0.929446 0 140 | endloop 141 | endfacet 142 | facet normal 42 42 42 143 | outer loop 144 | vertex 0.70921 1.87003 10 145 | vertex 1.13613 1.64597 0 146 | vertex 0.70921 1.87003 0 147 | endloop 148 | endfacet 149 | facet normal 42 42 42 150 | outer loop 151 | vertex 0.70921 1.87003 10 152 | vertex 1.13613 1.64597 10 153 | vertex 1.13613 1.64597 0 154 | endloop 155 | endfacet 156 | facet normal 42 42 42 157 | outer loop 158 | vertex 1.77091 -0.929446 10 159 | vertex 1.49702 -1.32625 10 160 | vertex 1.49702 -1.32625 0 161 | endloop 162 | endfacet 163 | facet normal 42 42 42 164 | outer loop 165 | vertex 1.94188 -0.478631 10 166 | vertex 1.77091 -0.929446 0 167 | vertex 1.94188 -0.478631 0 168 | endloop 169 | endfacet 170 | facet normal 42 42 42 171 | outer loop 172 | vertex 1.94188 -0.478631 10 173 | vertex 1.94188 -0.478631 0 174 | vertex 2 -4.89859e-16 0 175 | endloop 176 | endfacet 177 | facet normal 42 42 42 178 | outer loop 179 | vertex 1.94188 -0.478631 10 180 | vertex 1.77091 -0.929446 10 181 | vertex 1.77091 -0.929446 0 182 | endloop 183 | endfacet 184 | facet normal 42 42 42 185 | outer loop 186 | vertex 0.241073 1.98542 10 187 | vertex 0.70921 1.87003 0 188 | vertex 0.241073 1.98542 0 189 | endloop 190 | endfacet 191 | facet normal 42 42 42 192 | outer loop 193 | vertex 0.241073 1.98542 10 194 | vertex 0.70921 1.87003 10 195 | vertex 0.70921 1.87003 0 196 | endloop 197 | endfacet 198 | facet normal 42 42 42 199 | outer loop 200 | vertex 2 -4.89859e-16 10 201 | vertex 1.94188 -0.478631 10 202 | vertex 2 -4.89859e-16 0 203 | endloop 204 | endfacet 205 | facet normal 42 42 42 206 | outer loop 207 | vertex -0.241073 1.98542 10 208 | vertex 0.241073 1.98542 0 209 | vertex -0.241073 1.98542 0 210 | endloop 211 | endfacet 212 | facet normal 42 42 42 213 | outer loop 214 | vertex -0.241073 1.98542 10 215 | vertex 0.241073 1.98542 10 216 | vertex 0.241073 1.98542 0 217 | endloop 218 | endfacet 219 | facet normal 42 42 42 220 | outer loop 221 | vertex -0.70921 1.87003 10 222 | vertex -0.241073 1.98542 0 223 | vertex -0.70921 1.87003 0 224 | endloop 225 | endfacet 226 | facet normal 42 42 42 227 | outer loop 228 | vertex -0.70921 1.87003 10 229 | vertex -0.241073 1.98542 10 230 | vertex -0.241073 1.98542 0 231 | endloop 232 | endfacet 233 | facet normal 42 42 42 234 | outer loop 235 | vertex -1.13613 1.64597 10 236 | vertex -0.70921 1.87003 0 237 | vertex -1.13613 1.64597 0 238 | endloop 239 | endfacet 240 | facet normal 42 42 42 241 | outer loop 242 | vertex -1.13613 1.64597 10 243 | vertex -0.70921 1.87003 10 244 | vertex -0.70921 1.87003 0 245 | endloop 246 | endfacet 247 | facet normal 42 42 42 248 | outer loop 249 | vertex -1.49702 1.32625 10 250 | vertex -1.13613 1.64597 0 251 | vertex -1.49702 1.32625 0 252 | endloop 253 | endfacet 254 | facet normal 42 42 42 255 | outer loop 256 | vertex -1.49702 1.32625 10 257 | vertex -1.13613 1.64597 10 258 | vertex -1.13613 1.64597 0 259 | endloop 260 | endfacet 261 | facet normal 42 42 42 262 | outer loop 263 | vertex -1.77091 0.929446 10 264 | vertex -1.49702 1.32625 0 265 | vertex -1.77091 0.929446 0 266 | endloop 267 | endfacet 268 | facet normal 42 42 42 269 | outer loop 270 | vertex -1.77091 0.929446 10 271 | vertex -1.49702 1.32625 10 272 | vertex -1.49702 1.32625 0 273 | endloop 274 | endfacet 275 | facet normal 42 42 42 276 | outer loop 277 | vertex -1.94188 0.478631 10 278 | vertex -1.77091 0.929446 10 279 | vertex -1.77091 0.929446 0 280 | endloop 281 | endfacet 282 | facet normal 42 42 42 283 | outer loop 284 | vertex -1.94188 0.478631 10 285 | vertex -1.77091 0.929446 0 286 | vertex -1.94188 0.478631 0 287 | endloop 288 | endfacet 289 | facet normal 42 42 42 290 | outer loop 291 | vertex -2 2.02129e-15 10 292 | vertex -1.94188 0.478631 10 293 | vertex -1.94188 0.478631 0 294 | endloop 295 | endfacet 296 | facet normal 42 42 42 297 | outer loop 298 | vertex -2 2.02129e-15 10 299 | vertex -1.94188 0.478631 0 300 | vertex -2 2.02129e-15 0 301 | endloop 302 | endfacet 303 | facet normal 42 42 42 304 | outer loop 305 | vertex -1.94188 -0.478631 10 306 | vertex -2 2.02129e-15 10 307 | vertex -2 2.02129e-15 0 308 | endloop 309 | endfacet 310 | facet normal 42 42 42 311 | outer loop 312 | vertex -1.94188 -0.478631 10 313 | vertex -2 2.02129e-15 0 314 | vertex -1.94188 -0.478631 0 315 | endloop 316 | endfacet 317 | facet normal 42 42 42 318 | outer loop 319 | vertex -1.77091 -0.929446 10 320 | vertex -1.94188 -0.478631 10 321 | vertex -1.94188 -0.478631 0 322 | endloop 323 | endfacet 324 | facet normal 42 42 42 325 | outer loop 326 | vertex -1.77091 -0.929446 10 327 | vertex -1.94188 -0.478631 0 328 | vertex -1.77091 -0.929446 0 329 | endloop 330 | endfacet 331 | facet normal 42 42 42 332 | outer loop 333 | vertex -1.49702 -1.32625 10 334 | vertex -1.77091 -0.929446 10 335 | vertex -1.77091 -0.929446 0 336 | endloop 337 | endfacet 338 | facet normal 42 42 42 339 | outer loop 340 | vertex -1.49702 -1.32625 10 341 | vertex -1.77091 -0.929446 0 342 | vertex -1.49702 -1.32625 0 343 | endloop 344 | endfacet 345 | facet normal 42 42 42 346 | outer loop 347 | vertex -1.13613 -1.64597 10 348 | vertex -1.49702 -1.32625 10 349 | vertex -1.49702 -1.32625 0 350 | endloop 351 | endfacet 352 | facet normal 42 42 42 353 | outer loop 354 | vertex -1.13613 -1.64597 10 355 | vertex -1.49702 -1.32625 0 356 | vertex -1.13613 -1.64597 0 357 | endloop 358 | endfacet 359 | facet normal 42 42 42 360 | outer loop 361 | vertex -1.13613 -1.64597 10 362 | vertex -1.13613 -1.64597 0 363 | vertex -0.70921 -1.87003 0 364 | endloop 365 | endfacet 366 | facet normal 42 42 42 367 | outer loop 368 | vertex -1.94188 0.478631 10 369 | vertex -2 2.02129e-15 10 370 | vertex -1.94188 -0.478631 10 371 | endloop 372 | endfacet 373 | facet normal 42 42 42 374 | outer loop 375 | vertex -1.94188 0.478631 10 376 | vertex -1.94188 -0.478631 10 377 | vertex -1.77091 -0.929446 10 378 | endloop 379 | endfacet 380 | facet normal 42 42 42 381 | outer loop 382 | vertex 0.70921 -1.87003 10 383 | vertex -0.70921 -1.87003 10 384 | vertex -0.241073 -1.98542 10 385 | endloop 386 | endfacet 387 | facet normal 42 42 42 388 | outer loop 389 | vertex 0.70921 -1.87003 10 390 | vertex -0.241073 -1.98542 10 391 | vertex 0.241073 -1.98542 10 392 | endloop 393 | endfacet 394 | facet normal 42 42 42 395 | outer loop 396 | vertex 1.49702 -1.32625 10 397 | vertex -1.49702 -1.32625 10 398 | vertex -1.13613 -1.64597 10 399 | endloop 400 | endfacet 401 | facet normal 42 42 42 402 | outer loop 403 | vertex 1.49702 -1.32625 10 404 | vertex -1.13613 -1.64597 10 405 | vertex -0.70921 -1.87003 10 406 | endloop 407 | endfacet 408 | facet normal 42 42 42 409 | outer loop 410 | vertex 1.49702 -1.32625 10 411 | vertex 0.70921 -1.87003 10 412 | vertex 1.13613 -1.64597 10 413 | endloop 414 | endfacet 415 | facet normal 42 42 42 416 | outer loop 417 | vertex 1.49702 -1.32625 10 418 | vertex -0.70921 -1.87003 10 419 | vertex 0.70921 -1.87003 10 420 | endloop 421 | endfacet 422 | facet normal 42 42 42 423 | outer loop 424 | vertex -1.13613 1.64597 10 425 | vertex -1.49702 1.32625 10 426 | vertex -1.77091 0.929446 10 427 | endloop 428 | endfacet 429 | facet normal 42 42 42 430 | outer loop 431 | vertex 1.94188 -0.478631 10 432 | vertex 1.49702 -1.32625 10 433 | vertex 1.77091 -0.929446 10 434 | endloop 435 | endfacet 436 | facet normal 42 42 42 437 | outer loop 438 | vertex -0.241073 1.98542 10 439 | vertex -0.70921 1.87003 10 440 | vertex -1.13613 1.64597 10 441 | endloop 442 | endfacet 443 | facet normal 42 42 42 444 | outer loop 445 | vertex -0.241073 1.98542 10 446 | vertex -1.13613 1.64597 10 447 | vertex -1.77091 0.929446 10 448 | endloop 449 | endfacet 450 | facet normal 42 42 42 451 | outer loop 452 | vertex 1.77091 0.929446 10 453 | vertex 2 -4.89859e-16 10 454 | vertex 1.94188 0.478631 10 455 | endloop 456 | endfacet 457 | facet normal 42 42 42 458 | outer loop 459 | vertex 1.77091 0.929446 10 460 | vertex 0.70921 1.87003 10 461 | vertex 0.241073 1.98542 10 462 | endloop 463 | endfacet 464 | facet normal 42 42 42 465 | outer loop 466 | vertex 1.77091 0.929446 10 467 | vertex 0.241073 1.98542 10 468 | vertex -0.241073 1.98542 10 469 | endloop 470 | endfacet 471 | facet normal 42 42 42 472 | outer loop 473 | vertex 1.77091 0.929446 10 474 | vertex -1.77091 0.929446 10 475 | vertex -1.94188 0.478631 10 476 | endloop 477 | endfacet 478 | facet normal 42 42 42 479 | outer loop 480 | vertex 1.77091 0.929446 10 481 | vertex -1.77091 -0.929446 10 482 | vertex -1.49702 -1.32625 10 483 | endloop 484 | endfacet 485 | facet normal 42 42 42 486 | outer loop 487 | vertex 1.77091 0.929446 10 488 | vertex 1.94188 -0.478631 10 489 | vertex 2 -4.89859e-16 10 490 | endloop 491 | endfacet 492 | facet normal 42 42 42 493 | outer loop 494 | vertex 1.77091 0.929446 10 495 | vertex -1.94188 0.478631 10 496 | vertex -1.77091 -0.929446 10 497 | endloop 498 | endfacet 499 | facet normal 42 42 42 500 | outer loop 501 | vertex 1.77091 0.929446 10 502 | vertex -1.49702 -1.32625 10 503 | vertex 1.49702 -1.32625 10 504 | endloop 505 | endfacet 506 | facet normal 42 42 42 507 | outer loop 508 | vertex 1.77091 0.929446 10 509 | vertex 1.49702 -1.32625 10 510 | vertex 1.94188 -0.478631 10 511 | endloop 512 | endfacet 513 | facet normal 42 42 42 514 | outer loop 515 | vertex 1.77091 0.929446 10 516 | vertex -0.241073 1.98542 10 517 | vertex -1.77091 0.929446 10 518 | endloop 519 | endfacet 520 | facet normal 42 42 42 521 | outer loop 522 | vertex 1.49702 1.32625 10 523 | vertex 1.13613 1.64597 10 524 | vertex 0.70921 1.87003 10 525 | endloop 526 | endfacet 527 | facet normal 42 42 42 528 | outer loop 529 | vertex 1.49702 1.32625 10 530 | vertex 0.70921 1.87003 10 531 | vertex 1.77091 0.929446 10 532 | endloop 533 | endfacet 534 | facet normal 42 42 42 535 | outer loop 536 | vertex -1.94188 -0.478631 0 537 | vertex -2 2.02129e-15 0 538 | vertex -1.94188 0.478631 0 539 | endloop 540 | endfacet 541 | facet normal 42 42 42 542 | outer loop 543 | vertex -1.77091 -0.929446 0 544 | vertex -1.94188 -0.478631 0 545 | vertex -1.94188 0.478631 0 546 | endloop 547 | endfacet 548 | facet normal 42 42 42 549 | outer loop 550 | vertex -0.241073 -1.98542 0 551 | vertex -0.70921 -1.87003 0 552 | vertex 0.70921 -1.87003 0 553 | endloop 554 | endfacet 555 | facet normal 42 42 42 556 | outer loop 557 | vertex 0.241073 -1.98542 0 558 | vertex -0.241073 -1.98542 0 559 | vertex 0.70921 -1.87003 0 560 | endloop 561 | endfacet 562 | facet normal 42 42 42 563 | outer loop 564 | vertex -1.13613 -1.64597 0 565 | vertex -1.49702 -1.32625 0 566 | vertex 1.49702 -1.32625 0 567 | endloop 568 | endfacet 569 | facet normal 42 42 42 570 | outer loop 571 | vertex -0.70921 -1.87003 0 572 | vertex -1.13613 -1.64597 0 573 | vertex 1.49702 -1.32625 0 574 | endloop 575 | endfacet 576 | facet normal 42 42 42 577 | outer loop 578 | vertex 1.13613 -1.64597 0 579 | vertex 0.70921 -1.87003 0 580 | vertex 1.49702 -1.32625 0 581 | endloop 582 | endfacet 583 | facet normal 42 42 42 584 | outer loop 585 | vertex 0.70921 -1.87003 0 586 | vertex -0.70921 -1.87003 0 587 | vertex 1.49702 -1.32625 0 588 | endloop 589 | endfacet 590 | facet normal 42 42 42 591 | outer loop 592 | vertex -1.77091 0.929446 0 593 | vertex -1.49702 1.32625 0 594 | vertex -1.13613 1.64597 0 595 | endloop 596 | endfacet 597 | facet normal 42 42 42 598 | outer loop 599 | vertex 1.77091 -0.929446 0 600 | vertex 1.49702 -1.32625 0 601 | vertex 1.94188 -0.478631 0 602 | endloop 603 | endfacet 604 | facet normal 42 42 42 605 | outer loop 606 | vertex -1.13613 1.64597 0 607 | vertex -0.70921 1.87003 0 608 | vertex -0.241073 1.98542 0 609 | endloop 610 | endfacet 611 | facet normal 42 42 42 612 | outer loop 613 | vertex -1.77091 0.929446 0 614 | vertex -1.13613 1.64597 0 615 | vertex -0.241073 1.98542 0 616 | endloop 617 | endfacet 618 | facet normal 42 42 42 619 | outer loop 620 | vertex 1.94188 0.478631 0 621 | vertex 2 -4.89859e-16 0 622 | vertex 1.77091 0.929446 0 623 | endloop 624 | endfacet 625 | facet normal 42 42 42 626 | outer loop 627 | vertex 0.241073 1.98542 0 628 | vertex 0.70921 1.87003 0 629 | vertex 1.77091 0.929446 0 630 | endloop 631 | endfacet 632 | facet normal 42 42 42 633 | outer loop 634 | vertex -0.241073 1.98542 0 635 | vertex 0.241073 1.98542 0 636 | vertex 1.77091 0.929446 0 637 | endloop 638 | endfacet 639 | facet normal 42 42 42 640 | outer loop 641 | vertex -1.94188 0.478631 0 642 | vertex -1.77091 0.929446 0 643 | vertex 1.77091 0.929446 0 644 | endloop 645 | endfacet 646 | facet normal 42 42 42 647 | outer loop 648 | vertex -1.49702 -1.32625 0 649 | vertex -1.77091 -0.929446 0 650 | vertex 1.77091 0.929446 0 651 | endloop 652 | endfacet 653 | facet normal 42 42 42 654 | outer loop 655 | vertex 2 -4.89859e-16 0 656 | vertex 1.94188 -0.478631 0 657 | vertex 1.77091 0.929446 0 658 | endloop 659 | endfacet 660 | facet normal 42 42 42 661 | outer loop 662 | vertex -1.77091 -0.929446 0 663 | vertex -1.94188 0.478631 0 664 | vertex 1.77091 0.929446 0 665 | endloop 666 | endfacet 667 | facet normal 42 42 42 668 | outer loop 669 | vertex 1.49702 -1.32625 0 670 | vertex -1.49702 -1.32625 0 671 | vertex 1.77091 0.929446 0 672 | endloop 673 | endfacet 674 | facet normal 42 42 42 675 | outer loop 676 | vertex 1.94188 -0.478631 0 677 | vertex 1.49702 -1.32625 0 678 | vertex 1.77091 0.929446 0 679 | endloop 680 | endfacet 681 | facet normal 42 42 42 682 | outer loop 683 | vertex -1.77091 0.929446 0 684 | vertex -0.241073 1.98542 0 685 | vertex 1.77091 0.929446 0 686 | endloop 687 | endfacet 688 | facet normal 42 42 42 689 | outer loop 690 | vertex 0.70921 1.87003 0 691 | vertex 1.13613 1.64597 0 692 | vertex 1.49702 1.32625 0 693 | endloop 694 | endfacet 695 | facet normal 42 42 42 696 | outer loop 697 | vertex 1.77091 0.929446 0 698 | vertex 0.70921 1.87003 0 699 | vertex 1.49702 1.32625 0 700 | endloop 701 | endfacet 702 | endsolid 703 | -------------------------------------------------------------------------------- /examples/cylinder/cyl-faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agordon/openscad-step-reader/801da20a643d64372bf148be86fe0036fc9e0776/examples/cylinder/cyl-faces.png -------------------------------------------------------------------------------- /examples/cylinder/cyl-faces.scad: -------------------------------------------------------------------------------- 1 | face_1_points = [ 2 | [-0.70921,-1.87003,10],[-1.13613,-1.64597,10],[-0.70921,-1.87003,0], // Triangle 1 / 52 3 | [-0.241073,-1.98542,10],[-0.70921,-1.87003,10],[-0.70921,-1.87003,0], 4 | [-0.241073,-1.98542,10],[-0.70921,-1.87003,0],[-0.241073,-1.98542,0], 5 | [1.94188,0.478631,10],[2,-4.89859e-16,10],[2,-4.89859e-16,0], 6 | [0.241073,-1.98542,10],[-0.241073,-1.98542,10],[-0.241073,-1.98542,0], 7 | [1.94188,0.478631,10],[2,-4.89859e-16,0],[1.94188,0.478631,0], 8 | [0.241073,-1.98542,10],[-0.241073,-1.98542,0],[0.241073,-1.98542,0], 9 | [1.77091,0.929446,10],[1.94188,0.478631,0],[1.77091,0.929446,0], 10 | [0.70921,-1.87003,10],[0.241073,-1.98542,10],[0.241073,-1.98542,0], 11 | [0.70921,-1.87003,10],[0.241073,-1.98542,0],[0.70921,-1.87003,0], // Triangle 10 / 52 12 | [1.77091,0.929446,10],[1.94188,0.478631,10],[1.94188,0.478631,0], 13 | [1.49702,1.32625,10],[1.77091,0.929446,0],[1.49702,1.32625,0], 14 | [1.13613,-1.64597,10],[0.70921,-1.87003,10],[0.70921,-1.87003,0], 15 | [1.13613,-1.64597,10],[0.70921,-1.87003,0],[1.13613,-1.64597,0], 16 | [1.49702,1.32625,10],[1.77091,0.929446,10],[1.77091,0.929446,0], 17 | [1.49702,-1.32625,10],[1.13613,-1.64597,10],[1.13613,-1.64597,0], 18 | [1.13613,1.64597,10],[1.49702,1.32625,0],[1.13613,1.64597,0], 19 | [1.49702,-1.32625,10],[1.13613,-1.64597,0],[1.49702,-1.32625,0], 20 | [1.13613,1.64597,10],[1.49702,1.32625,10],[1.49702,1.32625,0], 21 | [1.77091,-0.929446,10],[1.49702,-1.32625,0],[1.77091,-0.929446,0], // Triangle 20 / 52 22 | [0.70921,1.87003,10],[1.13613,1.64597,0],[0.70921,1.87003,0], 23 | [0.70921,1.87003,10],[1.13613,1.64597,10],[1.13613,1.64597,0], 24 | [1.77091,-0.929446,10],[1.49702,-1.32625,10],[1.49702,-1.32625,0], 25 | [1.94188,-0.478631,10],[1.77091,-0.929446,0],[1.94188,-0.478631,0], 26 | [1.94188,-0.478631,10],[1.94188,-0.478631,0],[2,-4.89859e-16,0], 27 | [1.94188,-0.478631,10],[1.77091,-0.929446,10],[1.77091,-0.929446,0], 28 | [0.241073,1.98542,10],[0.70921,1.87003,0],[0.241073,1.98542,0], 29 | [0.241073,1.98542,10],[0.70921,1.87003,10],[0.70921,1.87003,0], 30 | [2,-4.89859e-16,10],[1.94188,-0.478631,10],[2,-4.89859e-16,0], 31 | [-0.241073,1.98542,10],[0.241073,1.98542,0],[-0.241073,1.98542,0], // Triangle 30 / 52 32 | [-0.241073,1.98542,10],[0.241073,1.98542,10],[0.241073,1.98542,0], 33 | [-0.70921,1.87003,10],[-0.241073,1.98542,0],[-0.70921,1.87003,0], 34 | [-0.70921,1.87003,10],[-0.241073,1.98542,10],[-0.241073,1.98542,0], 35 | [-1.13613,1.64597,10],[-0.70921,1.87003,0],[-1.13613,1.64597,0], 36 | [-1.13613,1.64597,10],[-0.70921,1.87003,10],[-0.70921,1.87003,0], 37 | [-1.49702,1.32625,10],[-1.13613,1.64597,0],[-1.49702,1.32625,0], 38 | [-1.49702,1.32625,10],[-1.13613,1.64597,10],[-1.13613,1.64597,0], 39 | [-1.77091,0.929446,10],[-1.49702,1.32625,0],[-1.77091,0.929446,0], 40 | [-1.77091,0.929446,10],[-1.49702,1.32625,10],[-1.49702,1.32625,0], 41 | [-1.94188,0.478631,10],[-1.77091,0.929446,10],[-1.77091,0.929446,0], // Triangle 40 / 52 42 | [-1.94188,0.478631,10],[-1.77091,0.929446,0],[-1.94188,0.478631,0], 43 | [-2,2.02129e-15,10],[-1.94188,0.478631,10],[-1.94188,0.478631,0], 44 | [-2,2.02129e-15,10],[-1.94188,0.478631,0],[-2,2.02129e-15,0], 45 | [-1.94188,-0.478631,10],[-2,2.02129e-15,10],[-2,2.02129e-15,0], 46 | [-1.94188,-0.478631,10],[-2,2.02129e-15,0],[-1.94188,-0.478631,0], 47 | [-1.77091,-0.929446,10],[-1.94188,-0.478631,10],[-1.94188,-0.478631,0], 48 | [-1.77091,-0.929446,10],[-1.94188,-0.478631,0],[-1.77091,-0.929446,0], 49 | [-1.49702,-1.32625,10],[-1.77091,-0.929446,10],[-1.77091,-0.929446,0], 50 | [-1.49702,-1.32625,10],[-1.77091,-0.929446,0],[-1.49702,-1.32625,0], 51 | [-1.13613,-1.64597,10],[-1.49702,-1.32625,10],[-1.49702,-1.32625,0], // Triangle 50 / 52 52 | [-1.13613,-1.64597,10],[-1.49702,-1.32625,0],[-1.13613,-1.64597,0], 53 | [-1.13613,-1.64597,10],[-1.13613,-1.64597,0],[-0.70921,-1.87003,0], 54 | ]; 55 | face_1_faces = [ 56 | [0,1,2], // Triangle 1 / 52 57 | [3,4,5], 58 | [6,7,8], 59 | [9,10,11], 60 | [12,13,14], 61 | [15,16,17], 62 | [18,19,20], 63 | [21,22,23], 64 | [24,25,26], 65 | [27,28,29], // Triangle 10 / 52 66 | [30,31,32], 67 | [33,34,35], 68 | [36,37,38], 69 | [39,40,41], 70 | [42,43,44], 71 | [45,46,47], 72 | [48,49,50], 73 | [51,52,53], 74 | [54,55,56], 75 | [57,58,59], // Triangle 20 / 52 76 | [60,61,62], 77 | [63,64,65], 78 | [66,67,68], 79 | [69,70,71], 80 | [72,73,74], 81 | [75,76,77], 82 | [78,79,80], 83 | [81,82,83], 84 | [84,85,86], 85 | [87,88,89], // Triangle 30 / 52 86 | [90,91,92], 87 | [93,94,95], 88 | [96,97,98], 89 | [99,100,101], 90 | [102,103,104], 91 | [105,106,107], 92 | [108,109,110], 93 | [111,112,113], 94 | [114,115,116], 95 | [117,118,119], // Triangle 40 / 52 96 | [120,121,122], 97 | [123,124,125], 98 | [126,127,128], 99 | [129,130,131], 100 | [132,133,134], 101 | [135,136,137], 102 | [138,139,140], 103 | [141,142,143], 104 | [144,145,146], 105 | [147,148,149], // Triangle 50 / 52 106 | [150,151,152], 107 | [153,154,155], 108 | ]; 109 | 110 | face_2_points = [ 111 | [-1.94188,0.478631,10],[-2,2.02129e-15,10],[-1.94188,-0.478631,10], // Triangle 1 / 24 112 | [-1.94188,0.478631,10],[-1.94188,-0.478631,10],[-1.77091,-0.929446,10], 113 | [0.70921,-1.87003,10],[-0.70921,-1.87003,10],[-0.241073,-1.98542,10], 114 | [0.70921,-1.87003,10],[-0.241073,-1.98542,10],[0.241073,-1.98542,10], 115 | [1.49702,-1.32625,10],[-1.49702,-1.32625,10],[-1.13613,-1.64597,10], 116 | [1.49702,-1.32625,10],[-1.13613,-1.64597,10],[-0.70921,-1.87003,10], 117 | [1.49702,-1.32625,10],[0.70921,-1.87003,10],[1.13613,-1.64597,10], 118 | [1.49702,-1.32625,10],[-0.70921,-1.87003,10],[0.70921,-1.87003,10], 119 | [-1.13613,1.64597,10],[-1.49702,1.32625,10],[-1.77091,0.929446,10], 120 | [1.94188,-0.478631,10],[1.49702,-1.32625,10],[1.77091,-0.929446,10], // Triangle 10 / 24 121 | [-0.241073,1.98542,10],[-0.70921,1.87003,10],[-1.13613,1.64597,10], 122 | [-0.241073,1.98542,10],[-1.13613,1.64597,10],[-1.77091,0.929446,10], 123 | [1.77091,0.929446,10],[2,-4.89859e-16,10],[1.94188,0.478631,10], 124 | [1.77091,0.929446,10],[0.70921,1.87003,10],[0.241073,1.98542,10], 125 | [1.77091,0.929446,10],[0.241073,1.98542,10],[-0.241073,1.98542,10], 126 | [1.77091,0.929446,10],[-1.77091,0.929446,10],[-1.94188,0.478631,10], 127 | [1.77091,0.929446,10],[-1.77091,-0.929446,10],[-1.49702,-1.32625,10], 128 | [1.77091,0.929446,10],[1.94188,-0.478631,10],[2,-4.89859e-16,10], 129 | [1.77091,0.929446,10],[-1.94188,0.478631,10],[-1.77091,-0.929446,10], 130 | [1.77091,0.929446,10],[-1.49702,-1.32625,10],[1.49702,-1.32625,10], // Triangle 20 / 24 131 | [1.77091,0.929446,10],[1.49702,-1.32625,10],[1.94188,-0.478631,10], 132 | [1.77091,0.929446,10],[-0.241073,1.98542,10],[-1.77091,0.929446,10], 133 | [1.49702,1.32625,10],[1.13613,1.64597,10],[0.70921,1.87003,10], 134 | [1.49702,1.32625,10],[0.70921,1.87003,10],[1.77091,0.929446,10], 135 | ]; 136 | face_2_faces = [ 137 | [0,1,2], // Triangle 1 / 24 138 | [3,4,5], 139 | [6,7,8], 140 | [9,10,11], 141 | [12,13,14], 142 | [15,16,17], 143 | [18,19,20], 144 | [21,22,23], 145 | [24,25,26], 146 | [27,28,29], // Triangle 10 / 24 147 | [30,31,32], 148 | [33,34,35], 149 | [36,37,38], 150 | [39,40,41], 151 | [42,43,44], 152 | [45,46,47], 153 | [48,49,50], 154 | [51,52,53], 155 | [54,55,56], 156 | [57,58,59], // Triangle 20 / 24 157 | [60,61,62], 158 | [63,64,65], 159 | [66,67,68], 160 | [69,70,71], 161 | ]; 162 | 163 | face_3_points = [ 164 | [-1.94188,-0.478631,0],[-2,2.02129e-15,0],[-1.94188,0.478631,0], // Triangle 1 / 24 165 | [-1.77091,-0.929446,0],[-1.94188,-0.478631,0],[-1.94188,0.478631,0], 166 | [-0.241073,-1.98542,0],[-0.70921,-1.87003,0],[0.70921,-1.87003,0], 167 | [0.241073,-1.98542,0],[-0.241073,-1.98542,0],[0.70921,-1.87003,0], 168 | [-1.13613,-1.64597,0],[-1.49702,-1.32625,0],[1.49702,-1.32625,0], 169 | [-0.70921,-1.87003,0],[-1.13613,-1.64597,0],[1.49702,-1.32625,0], 170 | [1.13613,-1.64597,0],[0.70921,-1.87003,0],[1.49702,-1.32625,0], 171 | [0.70921,-1.87003,0],[-0.70921,-1.87003,0],[1.49702,-1.32625,0], 172 | [-1.77091,0.929446,0],[-1.49702,1.32625,0],[-1.13613,1.64597,0], 173 | [1.77091,-0.929446,0],[1.49702,-1.32625,0],[1.94188,-0.478631,0], // Triangle 10 / 24 174 | [-1.13613,1.64597,0],[-0.70921,1.87003,0],[-0.241073,1.98542,0], 175 | [-1.77091,0.929446,0],[-1.13613,1.64597,0],[-0.241073,1.98542,0], 176 | [1.94188,0.478631,0],[2,-4.89859e-16,0],[1.77091,0.929446,0], 177 | [0.241073,1.98542,0],[0.70921,1.87003,0],[1.77091,0.929446,0], 178 | [-0.241073,1.98542,0],[0.241073,1.98542,0],[1.77091,0.929446,0], 179 | [-1.94188,0.478631,0],[-1.77091,0.929446,0],[1.77091,0.929446,0], 180 | [-1.49702,-1.32625,0],[-1.77091,-0.929446,0],[1.77091,0.929446,0], 181 | [2,-4.89859e-16,0],[1.94188,-0.478631,0],[1.77091,0.929446,0], 182 | [-1.77091,-0.929446,0],[-1.94188,0.478631,0],[1.77091,0.929446,0], 183 | [1.49702,-1.32625,0],[-1.49702,-1.32625,0],[1.77091,0.929446,0], // Triangle 20 / 24 184 | [1.94188,-0.478631,0],[1.49702,-1.32625,0],[1.77091,0.929446,0], 185 | [-1.77091,0.929446,0],[-0.241073,1.98542,0],[1.77091,0.929446,0], 186 | [0.70921,1.87003,0],[1.13613,1.64597,0],[1.49702,1.32625,0], 187 | [1.77091,0.929446,0],[0.70921,1.87003,0],[1.49702,1.32625,0], 188 | ]; 189 | face_3_faces = [ 190 | [0,1,2], // Triangle 1 / 24 191 | [3,4,5], 192 | [6,7,8], 193 | [9,10,11], 194 | [12,13,14], 195 | [15,16,17], 196 | [18,19,20], 197 | [21,22,23], 198 | [24,25,26], 199 | [27,28,29], // Triangle 10 / 24 200 | [30,31,32], 201 | [33,34,35], 202 | [36,37,38], 203 | [39,40,41], 204 | [42,43,44], 205 | [45,46,47], 206 | [48,49,50], 207 | [51,52,53], 208 | [54,55,56], 209 | [57,58,59], // Triangle 20 / 24 210 | [60,61,62], 211 | [63,64,65], 212 | [66,67,68], 213 | [69,70,71], 214 | ]; 215 | 216 | module crazy_colors() { 217 | color("Violet") 218 | polyhedron(face_1_points, face_1_faces); 219 | color("red") 220 | polyhedron(face_2_points, face_2_faces); 221 | color("blue") 222 | polyhedron(face_3_points, face_3_faces); 223 | } 224 | function add_offset(vec,ofs) = [for (x=vec) x + [ofs,ofs,ofs]]; 225 | module solid_object() { 226 | tmp1_points = face_1_points; 227 | tmp1_faces = face_1_faces; 228 | 229 | tmp2_points = concat(tmp1_points, face_2_points); 230 | tmp2_faces = concat(tmp1_faces,add_offset(face_2_faces,len(tmp1_points))); 231 | 232 | tmp3_points = concat(tmp2_points, face_3_points); 233 | tmp3_faces = concat(tmp2_faces,add_offset(face_3_faces,len(tmp2_points))); 234 | 235 | polyhedron (tmp3_points, tmp3_faces); 236 | } 237 | 238 | 239 | if ($preview) {; 240 | crazy_colors(); 241 | } else { 242 | solid_object(); 243 | } 244 | -------------------------------------------------------------------------------- /examples/cylinder/cyl.scad: -------------------------------------------------------------------------------- 1 | points = [ 2 | [-0.70921,-1.87003,10],[-1.13613,-1.64597,10],[-0.70921,-1.87003,0], // Triangle 1 / 100 3 | [-0.241073,-1.98542,10],[-0.70921,-1.87003,10],[-0.70921,-1.87003,0], 4 | [-0.241073,-1.98542,10],[-0.70921,-1.87003,0],[-0.241073,-1.98542,0], 5 | [1.94188,0.478631,10],[2,-4.89859e-16,10],[2,-4.89859e-16,0], 6 | [0.241073,-1.98542,10],[-0.241073,-1.98542,10],[-0.241073,-1.98542,0], 7 | [1.94188,0.478631,10],[2,-4.89859e-16,0],[1.94188,0.478631,0], 8 | [0.241073,-1.98542,10],[-0.241073,-1.98542,0],[0.241073,-1.98542,0], 9 | [1.77091,0.929446,10],[1.94188,0.478631,0],[1.77091,0.929446,0], 10 | [0.70921,-1.87003,10],[0.241073,-1.98542,10],[0.241073,-1.98542,0], 11 | [0.70921,-1.87003,10],[0.241073,-1.98542,0],[0.70921,-1.87003,0], // Triangle 10 / 100 12 | [1.77091,0.929446,10],[1.94188,0.478631,10],[1.94188,0.478631,0], 13 | [1.49702,1.32625,10],[1.77091,0.929446,0],[1.49702,1.32625,0], 14 | [1.13613,-1.64597,10],[0.70921,-1.87003,10],[0.70921,-1.87003,0], 15 | [1.13613,-1.64597,10],[0.70921,-1.87003,0],[1.13613,-1.64597,0], 16 | [1.49702,1.32625,10],[1.77091,0.929446,10],[1.77091,0.929446,0], 17 | [1.49702,-1.32625,10],[1.13613,-1.64597,10],[1.13613,-1.64597,0], 18 | [1.13613,1.64597,10],[1.49702,1.32625,0],[1.13613,1.64597,0], 19 | [1.49702,-1.32625,10],[1.13613,-1.64597,0],[1.49702,-1.32625,0], 20 | [1.13613,1.64597,10],[1.49702,1.32625,10],[1.49702,1.32625,0], 21 | [1.77091,-0.929446,10],[1.49702,-1.32625,0],[1.77091,-0.929446,0], // Triangle 20 / 100 22 | [0.70921,1.87003,10],[1.13613,1.64597,0],[0.70921,1.87003,0], 23 | [0.70921,1.87003,10],[1.13613,1.64597,10],[1.13613,1.64597,0], 24 | [1.77091,-0.929446,10],[1.49702,-1.32625,10],[1.49702,-1.32625,0], 25 | [1.94188,-0.478631,10],[1.77091,-0.929446,0],[1.94188,-0.478631,0], 26 | [1.94188,-0.478631,10],[1.94188,-0.478631,0],[2,-4.89859e-16,0], 27 | [1.94188,-0.478631,10],[1.77091,-0.929446,10],[1.77091,-0.929446,0], 28 | [0.241073,1.98542,10],[0.70921,1.87003,0],[0.241073,1.98542,0], 29 | [0.241073,1.98542,10],[0.70921,1.87003,10],[0.70921,1.87003,0], 30 | [2,-4.89859e-16,10],[1.94188,-0.478631,10],[2,-4.89859e-16,0], 31 | [-0.241073,1.98542,10],[0.241073,1.98542,0],[-0.241073,1.98542,0], // Triangle 30 / 100 32 | [-0.241073,1.98542,10],[0.241073,1.98542,10],[0.241073,1.98542,0], 33 | [-0.70921,1.87003,10],[-0.241073,1.98542,0],[-0.70921,1.87003,0], 34 | [-0.70921,1.87003,10],[-0.241073,1.98542,10],[-0.241073,1.98542,0], 35 | [-1.13613,1.64597,10],[-0.70921,1.87003,0],[-1.13613,1.64597,0], 36 | [-1.13613,1.64597,10],[-0.70921,1.87003,10],[-0.70921,1.87003,0], 37 | [-1.49702,1.32625,10],[-1.13613,1.64597,0],[-1.49702,1.32625,0], 38 | [-1.49702,1.32625,10],[-1.13613,1.64597,10],[-1.13613,1.64597,0], 39 | [-1.77091,0.929446,10],[-1.49702,1.32625,0],[-1.77091,0.929446,0], 40 | [-1.77091,0.929446,10],[-1.49702,1.32625,10],[-1.49702,1.32625,0], 41 | [-1.94188,0.478631,10],[-1.77091,0.929446,10],[-1.77091,0.929446,0], // Triangle 40 / 100 42 | [-1.94188,0.478631,10],[-1.77091,0.929446,0],[-1.94188,0.478631,0], 43 | [-2,2.02129e-15,10],[-1.94188,0.478631,10],[-1.94188,0.478631,0], 44 | [-2,2.02129e-15,10],[-1.94188,0.478631,0],[-2,2.02129e-15,0], 45 | [-1.94188,-0.478631,10],[-2,2.02129e-15,10],[-2,2.02129e-15,0], 46 | [-1.94188,-0.478631,10],[-2,2.02129e-15,0],[-1.94188,-0.478631,0], 47 | [-1.77091,-0.929446,10],[-1.94188,-0.478631,10],[-1.94188,-0.478631,0], 48 | [-1.77091,-0.929446,10],[-1.94188,-0.478631,0],[-1.77091,-0.929446,0], 49 | [-1.49702,-1.32625,10],[-1.77091,-0.929446,10],[-1.77091,-0.929446,0], 50 | [-1.49702,-1.32625,10],[-1.77091,-0.929446,0],[-1.49702,-1.32625,0], 51 | [-1.13613,-1.64597,10],[-1.49702,-1.32625,10],[-1.49702,-1.32625,0], // Triangle 50 / 100 52 | [-1.13613,-1.64597,10],[-1.49702,-1.32625,0],[-1.13613,-1.64597,0], 53 | [-1.13613,-1.64597,10],[-1.13613,-1.64597,0],[-0.70921,-1.87003,0], 54 | [-1.94188,0.478631,10],[-2,2.02129e-15,10],[-1.94188,-0.478631,10], 55 | [-1.94188,0.478631,10],[-1.94188,-0.478631,10],[-1.77091,-0.929446,10], 56 | [0.70921,-1.87003,10],[-0.70921,-1.87003,10],[-0.241073,-1.98542,10], 57 | [0.70921,-1.87003,10],[-0.241073,-1.98542,10],[0.241073,-1.98542,10], 58 | [1.49702,-1.32625,10],[-1.49702,-1.32625,10],[-1.13613,-1.64597,10], 59 | [1.49702,-1.32625,10],[-1.13613,-1.64597,10],[-0.70921,-1.87003,10], 60 | [1.49702,-1.32625,10],[0.70921,-1.87003,10],[1.13613,-1.64597,10], 61 | [1.49702,-1.32625,10],[-0.70921,-1.87003,10],[0.70921,-1.87003,10], // Triangle 60 / 100 62 | [-1.13613,1.64597,10],[-1.49702,1.32625,10],[-1.77091,0.929446,10], 63 | [1.94188,-0.478631,10],[1.49702,-1.32625,10],[1.77091,-0.929446,10], 64 | [-0.241073,1.98542,10],[-0.70921,1.87003,10],[-1.13613,1.64597,10], 65 | [-0.241073,1.98542,10],[-1.13613,1.64597,10],[-1.77091,0.929446,10], 66 | [1.77091,0.929446,10],[2,-4.89859e-16,10],[1.94188,0.478631,10], 67 | [1.77091,0.929446,10],[0.70921,1.87003,10],[0.241073,1.98542,10], 68 | [1.77091,0.929446,10],[0.241073,1.98542,10],[-0.241073,1.98542,10], 69 | [1.77091,0.929446,10],[-1.77091,0.929446,10],[-1.94188,0.478631,10], 70 | [1.77091,0.929446,10],[-1.77091,-0.929446,10],[-1.49702,-1.32625,10], 71 | [1.77091,0.929446,10],[1.94188,-0.478631,10],[2,-4.89859e-16,10], // Triangle 70 / 100 72 | [1.77091,0.929446,10],[-1.94188,0.478631,10],[-1.77091,-0.929446,10], 73 | [1.77091,0.929446,10],[-1.49702,-1.32625,10],[1.49702,-1.32625,10], 74 | [1.77091,0.929446,10],[1.49702,-1.32625,10],[1.94188,-0.478631,10], 75 | [1.77091,0.929446,10],[-0.241073,1.98542,10],[-1.77091,0.929446,10], 76 | [1.49702,1.32625,10],[1.13613,1.64597,10],[0.70921,1.87003,10], 77 | [1.49702,1.32625,10],[0.70921,1.87003,10],[1.77091,0.929446,10], 78 | [-1.94188,-0.478631,0],[-2,2.02129e-15,0],[-1.94188,0.478631,0], 79 | [-1.77091,-0.929446,0],[-1.94188,-0.478631,0],[-1.94188,0.478631,0], 80 | [-0.241073,-1.98542,0],[-0.70921,-1.87003,0],[0.70921,-1.87003,0], 81 | [0.241073,-1.98542,0],[-0.241073,-1.98542,0],[0.70921,-1.87003,0], // Triangle 80 / 100 82 | [-1.13613,-1.64597,0],[-1.49702,-1.32625,0],[1.49702,-1.32625,0], 83 | [-0.70921,-1.87003,0],[-1.13613,-1.64597,0],[1.49702,-1.32625,0], 84 | [1.13613,-1.64597,0],[0.70921,-1.87003,0],[1.49702,-1.32625,0], 85 | [0.70921,-1.87003,0],[-0.70921,-1.87003,0],[1.49702,-1.32625,0], 86 | [-1.77091,0.929446,0],[-1.49702,1.32625,0],[-1.13613,1.64597,0], 87 | [1.77091,-0.929446,0],[1.49702,-1.32625,0],[1.94188,-0.478631,0], 88 | [-1.13613,1.64597,0],[-0.70921,1.87003,0],[-0.241073,1.98542,0], 89 | [-1.77091,0.929446,0],[-1.13613,1.64597,0],[-0.241073,1.98542,0], 90 | [1.94188,0.478631,0],[2,-4.89859e-16,0],[1.77091,0.929446,0], 91 | [0.241073,1.98542,0],[0.70921,1.87003,0],[1.77091,0.929446,0], // Triangle 90 / 100 92 | [-0.241073,1.98542,0],[0.241073,1.98542,0],[1.77091,0.929446,0], 93 | [-1.94188,0.478631,0],[-1.77091,0.929446,0],[1.77091,0.929446,0], 94 | [-1.49702,-1.32625,0],[-1.77091,-0.929446,0],[1.77091,0.929446,0], 95 | [2,-4.89859e-16,0],[1.94188,-0.478631,0],[1.77091,0.929446,0], 96 | [-1.77091,-0.929446,0],[-1.94188,0.478631,0],[1.77091,0.929446,0], 97 | [1.49702,-1.32625,0],[-1.49702,-1.32625,0],[1.77091,0.929446,0], 98 | [1.94188,-0.478631,0],[1.49702,-1.32625,0],[1.77091,0.929446,0], 99 | [-1.77091,0.929446,0],[-0.241073,1.98542,0],[1.77091,0.929446,0], 100 | [0.70921,1.87003,0],[1.13613,1.64597,0],[1.49702,1.32625,0], 101 | [1.77091,0.929446,0],[0.70921,1.87003,0],[1.49702,1.32625,0], // Triangle 100 / 100 102 | ]; 103 | faces = [ 104 | [0,1,2], // Triangle 1 / 100 105 | [3,4,5], 106 | [6,7,8], 107 | [9,10,11], 108 | [12,13,14], 109 | [15,16,17], 110 | [18,19,20], 111 | [21,22,23], 112 | [24,25,26], 113 | [27,28,29], // Triangle 10 / 100 114 | [30,31,32], 115 | [33,34,35], 116 | [36,37,38], 117 | [39,40,41], 118 | [42,43,44], 119 | [45,46,47], 120 | [48,49,50], 121 | [51,52,53], 122 | [54,55,56], 123 | [57,58,59], // Triangle 20 / 100 124 | [60,61,62], 125 | [63,64,65], 126 | [66,67,68], 127 | [69,70,71], 128 | [72,73,74], 129 | [75,76,77], 130 | [78,79,80], 131 | [81,82,83], 132 | [84,85,86], 133 | [87,88,89], // Triangle 30 / 100 134 | [90,91,92], 135 | [93,94,95], 136 | [96,97,98], 137 | [99,100,101], 138 | [102,103,104], 139 | [105,106,107], 140 | [108,109,110], 141 | [111,112,113], 142 | [114,115,116], 143 | [117,118,119], // Triangle 40 / 100 144 | [120,121,122], 145 | [123,124,125], 146 | [126,127,128], 147 | [129,130,131], 148 | [132,133,134], 149 | [135,136,137], 150 | [138,139,140], 151 | [141,142,143], 152 | [144,145,146], 153 | [147,148,149], // Triangle 50 / 100 154 | [150,151,152], 155 | [153,154,155], 156 | [156,157,158], 157 | [159,160,161], 158 | [162,163,164], 159 | [165,166,167], 160 | [168,169,170], 161 | [171,172,173], 162 | [174,175,176], 163 | [177,178,179], // Triangle 60 / 100 164 | [180,181,182], 165 | [183,184,185], 166 | [186,187,188], 167 | [189,190,191], 168 | [192,193,194], 169 | [195,196,197], 170 | [198,199,200], 171 | [201,202,203], 172 | [204,205,206], 173 | [207,208,209], // Triangle 70 / 100 174 | [210,211,212], 175 | [213,214,215], 176 | [216,217,218], 177 | [219,220,221], 178 | [222,223,224], 179 | [225,226,227], 180 | [228,229,230], 181 | [231,232,233], 182 | [234,235,236], 183 | [237,238,239], // Triangle 80 / 100 184 | [240,241,242], 185 | [243,244,245], 186 | [246,247,248], 187 | [249,250,251], 188 | [252,253,254], 189 | [255,256,257], 190 | [258,259,260], 191 | [261,262,263], 192 | [264,265,266], 193 | [267,268,269], // Triangle 90 / 100 194 | [270,271,272], 195 | [273,274,275], 196 | [276,277,278], 197 | [279,280,281], 198 | [282,283,284], 199 | [285,286,287], 200 | [288,289,290], 201 | [291,292,293], 202 | [294,295,296], 203 | [297,298,299], // Triangle 100 / 100 204 | ]; 205 | module solid_object() { 206 | polyhedron (points,faces); 207 | } 208 | 209 | solid_object(); 210 | -------------------------------------------------------------------------------- /examples/cylinder/cyl.stp: -------------------------------------------------------------------------------- 1 | ISO-10303-21; 2 | HEADER; 3 | FILE_DESCRIPTION(('FreeCAD Model'),'2;1'); 4 | FILE_NAME('/home/gordon/sources/OCC-CSG/build/cyl.stp', 5 | '2019-09-06T09:54:44',('Author'),(''), 6 | 'Open CASCADE STEP processor 7.3','FreeCAD','Unknown'); 7 | FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }')); 8 | ENDSEC; 9 | DATA; 10 | #1 = APPLICATION_PROTOCOL_DEFINITION('international standard', 11 | 'automotive_design',2000,#2); 12 | #2 = APPLICATION_CONTEXT( 13 | 'core data for automotive mechanical design processes'); 14 | #3 = SHAPE_DEFINITION_REPRESENTATION(#4,#10); 15 | #4 = PRODUCT_DEFINITION_SHAPE('','',#5); 16 | #5 = PRODUCT_DEFINITION('design','',#6,#9); 17 | #6 = PRODUCT_DEFINITION_FORMATION('','',#7); 18 | #7 = PRODUCT('Cylinder','Cylinder','',(#8)); 19 | #8 = PRODUCT_CONTEXT('',#2,'mechanical'); 20 | #9 = PRODUCT_DEFINITION_CONTEXT('part definition',#2,'design'); 21 | #10 = ADVANCED_BREP_SHAPE_REPRESENTATION('',(#11,#15),#113); 22 | #11 = AXIS2_PLACEMENT_3D('',#12,#13,#14); 23 | #12 = CARTESIAN_POINT('',(0.,0.,0.)); 24 | #13 = DIRECTION('',(0.,0.,1.)); 25 | #14 = DIRECTION('',(1.,0.,-0.)); 26 | #15 = MANIFOLD_SOLID_BREP('',#16); 27 | #16 = CLOSED_SHELL('',(#17,#105,#109)); 28 | #17 = ADVANCED_FACE('',(#18),#31,.T.); 29 | #18 = FACE_BOUND('',#19,.T.); 30 | #19 = EDGE_LOOP('',(#20,#54,#77,#104)); 31 | #20 = ORIENTED_EDGE('',*,*,#21,.F.); 32 | #21 = EDGE_CURVE('',#22,#22,#24,.T.); 33 | #22 = VERTEX_POINT('',#23); 34 | #23 = CARTESIAN_POINT('',(2.,-4.898587196589E-16,10.)); 35 | #24 = SURFACE_CURVE('',#25,(#30,#42),.PCURVE_S1.); 36 | #25 = CIRCLE('',#26,2.); 37 | #26 = AXIS2_PLACEMENT_3D('',#27,#28,#29); 38 | #27 = CARTESIAN_POINT('',(0.,0.,10.)); 39 | #28 = DIRECTION('',(0.,0.,1.)); 40 | #29 = DIRECTION('',(1.,0.,-0.)); 41 | #30 = PCURVE('',#31,#36); 42 | #31 = CYLINDRICAL_SURFACE('',#32,2.); 43 | #32 = AXIS2_PLACEMENT_3D('',#33,#34,#35); 44 | #33 = CARTESIAN_POINT('',(0.,0.,0.)); 45 | #34 = DIRECTION('',(0.,0.,1.)); 46 | #35 = DIRECTION('',(1.,0.,-0.)); 47 | #36 = DEFINITIONAL_REPRESENTATION('',(#37),#41); 48 | #37 = LINE('',#38,#39); 49 | #38 = CARTESIAN_POINT('',(0.,10.)); 50 | #39 = VECTOR('',#40,1.); 51 | #40 = DIRECTION('',(1.,0.)); 52 | #41 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 53 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 54 | ) ); 55 | #42 = PCURVE('',#43,#48); 56 | #43 = PLANE('',#44); 57 | #44 = AXIS2_PLACEMENT_3D('',#45,#46,#47); 58 | #45 = CARTESIAN_POINT('',(0.,0.,10.)); 59 | #46 = DIRECTION('',(0.,0.,1.)); 60 | #47 = DIRECTION('',(1.,0.,-0.)); 61 | #48 = DEFINITIONAL_REPRESENTATION('',(#49),#53); 62 | #49 = CIRCLE('',#50,2.); 63 | #50 = AXIS2_PLACEMENT_2D('',#51,#52); 64 | #51 = CARTESIAN_POINT('',(0.,0.)); 65 | #52 = DIRECTION('',(1.,0.)); 66 | #53 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 67 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 68 | ) ); 69 | #54 = ORIENTED_EDGE('',*,*,#55,.F.); 70 | #55 = EDGE_CURVE('',#56,#22,#58,.T.); 71 | #56 = VERTEX_POINT('',#57); 72 | #57 = CARTESIAN_POINT('',(2.,-4.898587196589E-16,0.)); 73 | #58 = SEAM_CURVE('',#59,(#63,#70),.PCURVE_S1.); 74 | #59 = LINE('',#60,#61); 75 | #60 = CARTESIAN_POINT('',(2.,-4.898587196589E-16,0.)); 76 | #61 = VECTOR('',#62,1.); 77 | #62 = DIRECTION('',(0.,0.,1.)); 78 | #63 = PCURVE('',#31,#64); 79 | #64 = DEFINITIONAL_REPRESENTATION('',(#65),#69); 80 | #65 = LINE('',#66,#67); 81 | #66 = CARTESIAN_POINT('',(6.28318530718,-0.)); 82 | #67 = VECTOR('',#68,1.); 83 | #68 = DIRECTION('',(0.,1.)); 84 | #69 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 85 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 86 | ) ); 87 | #70 = PCURVE('',#31,#71); 88 | #71 = DEFINITIONAL_REPRESENTATION('',(#72),#76); 89 | #72 = LINE('',#73,#74); 90 | #73 = CARTESIAN_POINT('',(0.,-0.)); 91 | #74 = VECTOR('',#75,1.); 92 | #75 = DIRECTION('',(0.,1.)); 93 | #76 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 94 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 95 | ) ); 96 | #77 = ORIENTED_EDGE('',*,*,#78,.T.); 97 | #78 = EDGE_CURVE('',#56,#56,#79,.T.); 98 | #79 = SURFACE_CURVE('',#80,(#85,#92),.PCURVE_S1.); 99 | #80 = CIRCLE('',#81,2.); 100 | #81 = AXIS2_PLACEMENT_3D('',#82,#83,#84); 101 | #82 = CARTESIAN_POINT('',(0.,0.,0.)); 102 | #83 = DIRECTION('',(0.,0.,1.)); 103 | #84 = DIRECTION('',(1.,0.,-0.)); 104 | #85 = PCURVE('',#31,#86); 105 | #86 = DEFINITIONAL_REPRESENTATION('',(#87),#91); 106 | #87 = LINE('',#88,#89); 107 | #88 = CARTESIAN_POINT('',(0.,0.)); 108 | #89 = VECTOR('',#90,1.); 109 | #90 = DIRECTION('',(1.,0.)); 110 | #91 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 111 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 112 | ) ); 113 | #92 = PCURVE('',#93,#98); 114 | #93 = PLANE('',#94); 115 | #94 = AXIS2_PLACEMENT_3D('',#95,#96,#97); 116 | #95 = CARTESIAN_POINT('',(0.,0.,0.)); 117 | #96 = DIRECTION('',(0.,0.,1.)); 118 | #97 = DIRECTION('',(1.,0.,-0.)); 119 | #98 = DEFINITIONAL_REPRESENTATION('',(#99),#103); 120 | #99 = CIRCLE('',#100,2.); 121 | #100 = AXIS2_PLACEMENT_2D('',#101,#102); 122 | #101 = CARTESIAN_POINT('',(0.,0.)); 123 | #102 = DIRECTION('',(1.,0.)); 124 | #103 = ( GEOMETRIC_REPRESENTATION_CONTEXT(2) 125 | PARAMETRIC_REPRESENTATION_CONTEXT() REPRESENTATION_CONTEXT('2D SPACE','' 126 | ) ); 127 | #104 = ORIENTED_EDGE('',*,*,#55,.T.); 128 | #105 = ADVANCED_FACE('',(#106),#43,.T.); 129 | #106 = FACE_BOUND('',#107,.T.); 130 | #107 = EDGE_LOOP('',(#108)); 131 | #108 = ORIENTED_EDGE('',*,*,#21,.T.); 132 | #109 = ADVANCED_FACE('',(#110),#93,.F.); 133 | #110 = FACE_BOUND('',#111,.T.); 134 | #111 = EDGE_LOOP('',(#112)); 135 | #112 = ORIENTED_EDGE('',*,*,#78,.F.); 136 | #113 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) 137 | GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#117)) GLOBAL_UNIT_ASSIGNED_CONTEXT 138 | ((#114,#115,#116)) REPRESENTATION_CONTEXT('Context #1', 139 | '3D Context with UNIT and UNCERTAINTY') ); 140 | #114 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); 141 | #115 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); 142 | #116 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); 143 | #117 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#114, 144 | 'distance_accuracy_value','confusion accuracy'); 145 | #118 = PRODUCT_RELATED_PRODUCT_CATEGORY('part',$,(#7)); 146 | ENDSEC; 147 | END-ISO-10303-21; 148 | -------------------------------------------------------------------------------- /examples/tetrix-32mmChannel/channel-faces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agordon/openscad-step-reader/801da20a643d64372bf148be86fe0036fc9e0776/examples/tetrix-32mmChannel/channel-faces.png -------------------------------------------------------------------------------- /explore-shape.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | /* good resources: 39 | https://github.com/miho/OCC-CSG 40 | https://github.com/lvk88/OccTutorial 41 | https://dev.opencascade.org/doc/overview/html/index.html#OCCT_OVW_SECTION_7 42 | 43 | */ 44 | 45 | std::string SurfaceTypeName ( enum GeomAbs_SurfaceType t ) 46 | { 47 | switch (t) 48 | { 49 | case GeomAbs_Plane: 50 | return "Plane"; 51 | case GeomAbs_Cylinder: 52 | return "Cylinder"; 53 | case GeomAbs_Cone: 54 | return "Cone"; 55 | case GeomAbs_Sphere: 56 | return "Sphere"; 57 | case GeomAbs_Torus: 58 | return "Torus"; 59 | case GeomAbs_BezierSurface: 60 | return "Bezier"; 61 | case GeomAbs_BSplineSurface: 62 | return "BSplineSurface"; 63 | case GeomAbs_SurfaceOfRevolution: 64 | return "SurfaceOfRevolution"; 65 | case GeomAbs_SurfaceOfExtrusion: 66 | return "SurfaceOfExtrusion"; 67 | case GeomAbs_OffsetSurface: 68 | return "OffsetSurface"; 69 | case GeomAbs_OtherSurface: 70 | return "OtherSurface"; 71 | } 72 | return "UNKNOWN"; 73 | } 74 | 75 | std::string OrientationName (enum TopAbs_Orientation o) 76 | { 77 | switch (o) 78 | { 79 | case TopAbs_FORWARD: 80 | return "FORWARD"; 81 | case TopAbs_REVERSED: 82 | return "REVERSED"; 83 | case TopAbs_INTERNAL: 84 | return "INTERNAL"; 85 | case TopAbs_EXTERNAL: 86 | return "EXTERNAL"; 87 | } 88 | return "UNKNOWN"; 89 | } 90 | 91 | 92 | 93 | void get_vertex_points_test1 (const TopoDS_Shape& shape) 94 | { 95 | // from: https://www.opencascade.com/content/extracting-boundary-topodsshape 96 | TopTools_IndexedMapOfShape vertices; 97 | TopExp::MapShapes(shape,TopAbs_VERTEX,vertices); 98 | 99 | Handle_TColgp_HArray1OfPnt result = new TColgp_HArray1OfPnt(1,vertices.Extent()); 100 | 101 | for(Standard_Integer i = 1;i<=vertices.Extent();i++) 102 | { 103 | TopoDS_Vertex vertex = TopoDS::Vertex(vertices.FindKey(i)); 104 | gp_Pnt currentGeometricPoint = BRep_Tool::Pnt(vertex); 105 | result->SetValue(i,currentGeometricPoint); 106 | } 107 | 108 | //Convert to array 109 | //See: https://github.com/lvk88/OccTutorial/blob/master/Chapter1_Basics/src/WriteCoordinatesToFile.cpp 110 | const TColgp_Array1OfPnt& points = result->Array1(); 111 | 112 | for(Standard_Integer i = points.Lower();i <= points.Upper();i++) 113 | { 114 | std::cout << " vertex " << i << ": " << points.Value(i).X() << " " << points.Value(i).Y() << " " << points.Value(i).Z() << std::endl; 115 | 116 | auto &p = points.Value(i); 117 | } 118 | } 119 | 120 | 121 | 122 | void get_vertex_points_test2 (const TopoDS_Shape& shape) 123 | { 124 | //from: https://www.opencascade.com/content/how-get-wires-single-face 125 | int i = 0; 126 | for (TopExp_Explorer anExp(shape, TopAbs_EDGE); anExp.More(); anExp.Next()) 127 | { 128 | // Iterate over edges in input shape. 129 | const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current()); 130 | 131 | std::cout << "Edge " << i << " orientatino = " << OrientationName(anEdge.Orientation()) << std::endl; 132 | 133 | // Take the first and the last vertices from edge 134 | TopoDS_Vertex aVFirst = TopExp::FirstVertex(anEdge); 135 | TopoDS_Vertex aVLast = TopExp::LastVertex(anEdge); 136 | 137 | // Take geometrical information from vertices. 138 | gp_Pnt aPntFirst = BRep_Tool::Pnt(aVFirst); 139 | gp_Pnt aPntLast = BRep_Tool::Pnt(aVLast); 140 | 141 | if (anEdge.Orientation() == TopAbs_FORWARD) 142 | { 143 | } 144 | else 145 | { 146 | } 147 | ++i; 148 | } 149 | 150 | } 151 | 152 | 153 | void get_vertex_points_test3 (const TopoDS_Shape& shape) 154 | { 155 | //from: https://www.opencascade.com/content/how-get-wires-single-face 156 | int i = 0; 157 | for (TopExp_Explorer anExp(shape, TopAbs_VERTEX); anExp.More(); anExp.Next()) 158 | { 159 | const TopoDS_Vertex& anVertex = TopoDS::Vertex(anExp.Current()); 160 | 161 | std::cout << "Vertex " << i << " orientatino = " << OrientationName(anVertex.Orientation()) << std::endl; 162 | 163 | // Take geometrical information from vertices. 164 | gp_Pnt aPnt = BRep_Tool::Pnt(anVertex); 165 | 166 | ++i; 167 | } 168 | } 169 | 170 | 171 | void get_wire_edge_points_test4(const TopoDS_Shape& shape) 172 | { 173 | int wire_idx = 0; 174 | for (TopExp_Explorer WireExp(shape, TopAbs_WIRE); WireExp.More(); WireExp.Next()) 175 | { 176 | const TopoDS_Wire& aWire = TopoDS::Wire(WireExp.Current()); 177 | std::cout << " Wire " << wire_idx << std::endl; 178 | 179 | int edge_idx = 0; 180 | for (TopExp_Explorer EdgeExp(aWire, TopAbs_EDGE); EdgeExp.More(); EdgeExp.Next()) 181 | { 182 | std::cout << " edge " << edge_idx << std::endl; 183 | 184 | const TopoDS_Edge& anEdge = TopoDS::Edge(EdgeExp.Current()); 185 | 186 | // Take the first and the last vertices from edge 187 | TopoDS_Vertex aVFirst = TopExp::FirstVertex(anEdge); 188 | TopoDS_Vertex aVLast = TopExp::LastVertex(anEdge); 189 | 190 | // Take geometrical information from vertices. 191 | gp_Pnt aPntFirst = BRep_Tool::Pnt(aVFirst); 192 | gp_Pnt aPntLast = BRep_Tool::Pnt(aVLast); 193 | 194 | 195 | std::cout << " VertexFirst " << aPntFirst.X() << ", " 196 | << aPntFirst.Y() << ", " 197 | << aPntFirst.Z() << std::endl; 198 | std::cout << " VertexLast " << aPntLast.X() << ", " 199 | << aPntLast.Y() << ", " 200 | << aPntLast.Z() << std::endl; 201 | 202 | ++edge_idx; 203 | } 204 | ++wire_idx; 205 | } 206 | } 207 | 208 | TopoDS_Shape make_solid(const TopoDS_Shape& shape) 209 | { 210 | BRepBuilderAPI_MakeSolid solidmaker; 211 | int i = 0; 212 | for (TopExp_Explorer fExpl(shape, TopAbs_SHELL); fExpl.More(); fExpl.Next()) 213 | { 214 | const TopoDS_Shell &curShell = TopoDS::Shell(fExpl.Current()); 215 | ++i; 216 | 217 | //debugGetVerticesOfShape(curShell); 218 | solidmaker.Add(curShell); 219 | } 220 | std::cout << std::endl; 221 | TopoDS_Shape solid = solidmaker.Solid(); 222 | 223 | return solid; 224 | } 225 | 226 | 227 | void explore_shape(const TopoDS_Shape& shape) 228 | { 229 | int shell_i = 0; 230 | for (TopExp_Explorer ShellExp(shape, TopAbs_SHELL); ShellExp.More(); ShellExp.Next()) 231 | { 232 | const TopoDS_Shell &curShell = TopoDS::Shell(ShellExp.Current()); 233 | 234 | std::cout << "Shell " << shell_i << std::endl; 235 | 236 | int i = 0; 237 | for (TopExp_Explorer FaceExp(curShell, TopAbs_FACE); FaceExp.More(); FaceExp.Next()) 238 | { 239 | const TopoDS_Face &aFace = TopoDS::Face(FaceExp.Current()); 240 | 241 | //from: https://www.opencascade.com/content/how-determine-whether-topodsface-flat-or-volumetric 242 | BRepAdaptor_Surface anAdaptor(aFace); 243 | std::cout << " Face " << i << " Type = " << anAdaptor.GetType() << ":" << SurfaceTypeName(anAdaptor.GetType()) << std::endl; 244 | 245 | get_wire_edge_points_test4(aFace); 246 | } 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /explore-shape.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #ifndef __EXPLORE__ 15 | #define __EXPLORE__ 16 | 17 | void explore_shape(const TopoDS_Shape& shape); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /openscad-step-reader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "triangle.h" 24 | #include "tessellation.h" 25 | #include "openscad-triangle-writer.h" 26 | #include "explore-shape.h" 27 | 28 | static struct option options[] = { 29 | {"help", no_argument, 0, 'h' }, 30 | {"version", no_argument, 0, 'V' }, 31 | {"stl-ascii", no_argument, 0, 'a' }, 32 | {"stl-scad", no_argument, 0, 's' }, 33 | {"stl-faces", no_argument, 0, 'f' }, 34 | {"stl-occt", no_argument, 0, 'o' }, 35 | {"stl-lin-tol", required_argument, 0, 'L'}, 36 | {"explore", no_argument, 0, 'e' }, 37 | }; 38 | 39 | void show_help() 40 | { 41 | 42 | std::cout << "openscad-step-reader\n" 43 | "\n" 44 | "A proof-of-concept program for STEP/OpenSCAD integration\n" 45 | "\n" 46 | "usage: openscad-step-reader [options] INPUT.STEP\n" 47 | "\n" 48 | "Output is written to STDOUT.\n" 49 | "\n" 50 | "options are:\n" 51 | " -h, --help this help screen\n" 52 | " -V, --version version information\n" 53 | "\n" 54 | " -o, --stl-occt convert the input STEP file into ASCII STL file\n" 55 | " using OpenCASCADE code. This should be the baseline\n" 56 | " when debugging/troubleshooting incorrect outputs.\n" 57 | "\n" 58 | " -a, --stl-ascii convert the input STEP file into custom ASCII STL file,\n" 59 | " using our code. This is a good test to check mesh\n" 60 | " triangulation code. EXCEPT for the 'normal' values\n" 61 | " which are not produced, the vertex values should be\n" 62 | " equivalent to those with --stl-occt.\n" 63 | "\n" 64 | " -s, --stl-scad convert the input STEP file into SCAD code, containing\n" 65 | " a single 'polyhedron' call with the STL triangles stored\n" 66 | " in SCAD vectors.\n" 67 | "\n" 68 | " -f, --stl-faces convert the input STEP file into SCAD code, retaining the\n" 69 | " 'face' information from the STEP file. Each face will be rendered\n" 70 | " in a different color in openscad $preview mode.\n" 71 | "\n" 72 | " -e, --explore Work-in-progress code, used for development and exploration\n" 73 | " of OpenCASCADE class hierarchy, e.g.\n" 74 | " Shell->Face->Surface->Wire->Edge->Vertex.\n" 75 | " produces debug messges and no useful output.\n" 76 | "\n" 77 | "Written by Assaf Gordon (assafgordon@gmail.com)\n" 78 | "License: LGPLv2.1 or later\n" 79 | "\n"; 80 | exit(0); 81 | } 82 | 83 | void show_version() 84 | { 85 | std::cout << 42 << endl; 86 | exit(0); 87 | } 88 | 89 | 90 | int main(int argc, char *argv[]) 91 | { 92 | double stl_lin_tol = 0.5 ; //default linear tolerace. 93 | int c; 94 | 95 | enum { 96 | OUT_UNDEFINED, 97 | OUT_STL_ASCII, 98 | OUT_STL_SCAD, 99 | OUT_STL_FACES, 100 | OUT_STL_OCCT, 101 | OUT_EXPLORE 102 | } output = OUT_UNDEFINED; 103 | 104 | while ((c = getopt_long(argc, argv, "hVasfoL:e", options, NULL))!=-1) { 105 | switch (c) 106 | { 107 | case 'h': 108 | show_help(); 109 | break; 110 | 111 | case 'v': 112 | show_version(); 113 | break; 114 | 115 | case 'a': 116 | output = OUT_STL_ASCII; 117 | break; 118 | 119 | case 's': 120 | output = OUT_STL_SCAD; 121 | break; 122 | 123 | case 'f': 124 | output = OUT_STL_FACES; 125 | break; 126 | 127 | case 'o': 128 | output = OUT_STL_OCCT; 129 | break; 130 | 131 | case 'e': 132 | output = OUT_EXPLORE; 133 | break; 134 | 135 | case 'L': 136 | stl_lin_tol = atof(optarg); 137 | if (stl_lin_tol<=0) 138 | errx(1,"invalid tolerance value '%s'",optarg); 139 | break; 140 | 141 | } 142 | } 143 | 144 | if (optind >= argc) 145 | errx(1,"missing input STEP filename. Use --help for usage information"); 146 | 147 | if (output == OUT_UNDEFINED) 148 | errx(1,"missing output format option. Use --help for usage information"); 149 | 150 | std::string filename(argv[optind]); 151 | 152 | /* Load the shape from STEP file. 153 | See https://github.com/miho/OCC-CSG/blob/master/src/occ-csg.cpp#L311 154 | and https://github.com/lvk88/OccTutorial/blob/master/OtherExamples/runners/convertStepToStl.cpp 155 | */ 156 | TopoDS_Shape shape; 157 | 158 | STEPControl_Reader Reader; 159 | enum IFSelect_ReturnStatus s = Reader.ReadFile(filename.c_str()); 160 | if (s != IFSelect_RetDone) 161 | err(1,"failed to load STEP file '%s'", filename.c_str()); 162 | Reader.TransferRoots(); 163 | shape = Reader.OneShape(); 164 | 165 | /* Is this required (for Tessellation and/or StlAPI_Writer?) */ 166 | BRepMesh_IncrementalMesh mesh( shape, stl_lin_tol); 167 | mesh.Perform(); 168 | 169 | Face_vector faces; 170 | 171 | if ( (output==OUT_STL_ASCII) || (output==OUT_STL_SCAD) || (output==OUT_STL_FACES) ) 172 | faces = tessellate_shape (shape); 173 | 174 | switch (output) 175 | { 176 | case OUT_STL_ASCII: 177 | write_triangles_ascii_stl(faces); 178 | break; 179 | 180 | case OUT_STL_SCAD: 181 | write_triangle_scad(faces); 182 | break; 183 | 184 | case OUT_STL_FACES: 185 | write_faces_scad(faces); 186 | break; 187 | 188 | case OUT_STL_OCCT: 189 | try 190 | { 191 | StlAPI_Writer writer; 192 | writer.Write(shape,"/dev/stdout"); 193 | } catch(Standard_ConstructionError& e) { 194 | errx(1,"failed to write OCCT/STL: %s", e.GetMessageString()); 195 | } 196 | break; 197 | 198 | case OUT_EXPLORE: 199 | explore_shape (shape); 200 | break; 201 | } 202 | 203 | return 0; 204 | } 205 | -------------------------------------------------------------------------------- /openscad-triangle-writer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include "triangle.h" 21 | 22 | using namespace std; 23 | 24 | 25 | /* Write the faces/triangles as an ASCII stl file 26 | (with invalud 'normals' value - but these are ignored anyhow in OpenSCAD */ 27 | void write_triangles_ascii_stl(const Face_vector& faces) 28 | { 29 | cout << "solid" << endl; 30 | for (auto &f : faces) 31 | f.write_ascii_stl(cout); 32 | cout << "endsolid" << endl; 33 | } 34 | 35 | /* Write the faces/triangles as two vectors (one "POINTS", one "FACES") 36 | that will be used with a single call to "polyhedron"). */ 37 | void write_triangle_scad(const Face_vector& faces) 38 | { 39 | Face all; 40 | 41 | // Merge all faces (i.e. triangles from all faces) 42 | // into one "face" (just a container, no special meaning of a "face"). 43 | for (auto &f : faces) 44 | all.add_face(f); 45 | 46 | // Write vector of points and faces 47 | cout << "points = " ; 48 | all.write_points_vector(cout); 49 | cout << "faces = "; 50 | all.write_face_vector(cout); 51 | 52 | // Call Polyhedron 53 | cout << "module solid_object() {" << endl; 54 | cout << " polyhedron (points,faces);"<< endl; 55 | cout << "}" << endl; 56 | cout << endl; 57 | cout << "solid_object();" << endl; 58 | } 59 | 60 | 61 | 62 | 63 | #define NUM_COLORS 12 64 | const char* colors[NUM_COLORS] = { 65 | "black", 66 | "Violet", 67 | "red", 68 | "blue", 69 | "LawnGreen", 70 | "Orange", 71 | "DeepPink", 72 | "Gold", 73 | "Cyan", 74 | "Olive", 75 | "Gray", 76 | "SpringGreen" 77 | }; 78 | 79 | 80 | /* Write every faces (i.e. all trianges of each face) into a separate points/faces 81 | vector pairs. 82 | 83 | Include $preview code to show each face in a different color 84 | (sadly, resulting in an invalid 3D object which can't be exported to STL, 85 | because each face is a 2D object with depth of ZERO). 86 | 87 | In non-preview mode, 88 | Include code to merge all the vectors and make a single "Polyhedron" call. */ 89 | void write_faces_scad (const Face_vector& faces) 90 | { 91 | int i = 1; 92 | for (auto &f : faces) { 93 | cout << "face_" << i << "_points = " ; 94 | f.write_points_vector(cout); 95 | cout << "face_" << i << "_faces = " ; 96 | f.write_face_vector(cout); 97 | cout << endl ; 98 | ++i; 99 | } 100 | 101 | /* crazy colors version, draw each face by itself */ 102 | cout << "module crazy_colors() {" << endl; 103 | for (i=1;i<=faces.size();++i) { 104 | const char* color = colors[i%NUM_COLORS] ; 105 | cout << "color(\"" << color << "\")" << endl; 106 | cout << "polyhedron(face_" << i <<"_points, face_" << i << "_faces);" << endl ; 107 | } 108 | cout << "}" << endl; 109 | 110 | cout << "function add_offset(vec,ofs) = [for (x=vec) x + [ofs,ofs,ofs]];" << endl; 111 | cout << "module solid_object() {" << endl; 112 | cout << " tmp1_points = face_1_points;" << endl; 113 | cout << " tmp1_faces = face_1_faces;" << endl; 114 | cout << endl; 115 | for (i=2;i<=faces.size();++i) { 116 | cout << " tmp"< 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #ifndef __OPENSCAD_TRIANGLE_WRITER__ 15 | #define __OPENSCAD_TRIANGLE_WRITER__ 16 | 17 | void write_faces_scad (const Face_vector& faces); 18 | 19 | void write_triangles_ascii_stl(const Face_vector& faces); 20 | 21 | void write_triangle_scad(const Face_vector& faces); 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /shape_explorer.cpp: -------------------------------------------------------------------------------- 1 | std::string SurfaceTypeName ( enum GeomAbs_SurfaceType t ) 2 | { 3 | switch (t) 4 | { 5 | case GeomAbs_Plane: 6 | return "Plane"; 7 | case GeomAbs_Cylinder: 8 | return "Cylinder"; 9 | case GeomAbs_Cone: 10 | return "Cone"; 11 | case GeomAbs_Sphere: 12 | return "Sphere"; 13 | case GeomAbs_Torus: 14 | return "Torus"; 15 | case GeomAbs_BezierSurface: 16 | return "Bezier"; 17 | case GeomAbs_BSplineSurface: 18 | return "BSplineSurface"; 19 | case GeomAbs_SurfaceOfRevolution: 20 | return "SurfaceOfRevolution"; 21 | case GeomAbs_SurfaceOfExtrusion: 22 | return "SurfaceOfExtrusion"; 23 | case GeomAbs_OffsetSurface: 24 | return "OffsetSurface"; 25 | case GeomAbs_OtherSurface: 26 | return "OtherSurface"; 27 | } 28 | return "UNKNOWN"; 29 | } 30 | 31 | std::string OrientationName (enum TopAbs_Orientation o) 32 | { 33 | switch (o) 34 | { 35 | case TopAbs_FORWARD: 36 | return "FORWARD"; 37 | case TopAbs_REVERSED: 38 | return "REVERSED"; 39 | case TopAbs_INTERNAL: 40 | return "INTERNAL"; 41 | case TopAbs_EXTERNAL: 42 | return "EXTERNAL"; 43 | } 44 | return "UNKNOWN"; 45 | } 46 | -------------------------------------------------------------------------------- /tessellation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | 66 | #include "triangle.h" 67 | #include "tessellation.h" 68 | 69 | Face tessellate_face(const TopoDS_Face &aFace) 70 | { 71 | Face output_face; 72 | 73 | /* This code is based on 74 | https://www.opencascade.com/content/how-get-triangles-vertices-data-absolute-coords-native-opengl-rendering 75 | */ 76 | TopAbs_Orientation faceOrientation = aFace.Orientation(); 77 | 78 | TopLoc_Location aLocation; 79 | Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation(aFace,aLocation); 80 | 81 | if(!aTr.IsNull()) 82 | { 83 | const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); 84 | const Poly_Array1OfTriangle& triangles = aTr->Triangles(); 85 | const TColgp_Array1OfPnt2d & uvNodes = aTr->UVNodes(); 86 | 87 | TColgp_Array1OfPnt aPoints(1, aNodes.Length()); 88 | for(Standard_Integer i = 1; i < aNodes.Length()+1; i++) 89 | aPoints(i) = aNodes(i).Transformed(aLocation); 90 | 91 | Standard_Integer nnn = aTr->NbTriangles(); 92 | Standard_Integer nt,n1,n2,n3; 93 | 94 | for( nt = 1 ; nt < nnn+1 ; nt++) 95 | { 96 | triangles(nt).Get(n1,n2,n3); 97 | 98 | if (faceOrientation != TopAbs_Orientation::TopAbs_FORWARD) 99 | { 100 | int tmp = n1; 101 | n1 = n3; 102 | n3 = tmp; 103 | } 104 | 105 | gp_Pnt aPnt1 = aPoints(n1); 106 | gp_Pnt aPnt2 = aPoints(n2); 107 | gp_Pnt aPnt3 = aPoints(n3); 108 | 109 | const Triangle tr(aPnt1, aPnt2, aPnt3); 110 | output_face.addTriangle(tr); 111 | } 112 | } 113 | 114 | return output_face; 115 | } 116 | 117 | 118 | Face_vector tessellate_shape (const TopoDS_Shape& shape) 119 | { 120 | Face_vector output_faces; 121 | 122 | for (TopExp_Explorer FaceExp(shape, TopAbs_FACE); FaceExp.More(); FaceExp.Next()) 123 | { 124 | const TopoDS_Face &aFace = TopoDS::Face(FaceExp.Current()); 125 | 126 | const Face &f = tessellate_face(aFace); 127 | output_faces.push_back(f); 128 | } 129 | 130 | return output_faces; 131 | } 132 | -------------------------------------------------------------------------------- /tessellation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #ifndef __TESSELLATION__ 15 | #define __TESSELLATION__ 16 | 17 | Face tessellate_face(const TopoDS_Face &aFace); 18 | Face_vector tessellate_shape (const TopoDS_Shape& shape); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /triangle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Assaf Gordon 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | */ 14 | #ifndef __TRIANGLE__ 15 | #define __TRIANGLE__ 16 | 17 | class Point { 18 | double _x,_y,_z; 19 | public: 20 | Point() : _x(0), _y(0), _z(0) {}; 21 | Point(double x, double y, double z):_x(x),_y(y),_z(z) {}; 22 | Point(const gp_Pnt& p) : _x(p.X()),_y(p.Y()),_z(p.Z()) {} ; 23 | double x() const { return _x; }; 24 | double y() const { return _y; }; 25 | double z() const { return _z; }; 26 | 27 | void write_ascii_stl(std::ostream &ostrm) const 28 | { 29 | ostrm << "vertex " << _x << " " << _y << " " << _z ; 30 | } 31 | 32 | }; 33 | static ostream & operator << (ostream &out, const Point &p) 34 | { 35 | out << "[" << p.x() << "," << p.y() << "," << p.z() << "]"; 36 | return out; 37 | } 38 | 39 | 40 | class Triangle { 41 | Point _p1, _p2, _p3; 42 | public: 43 | Triangle() {} ; 44 | Triangle(const Point& p1, const Point& p2, const Point& p3) : _p1(p1), _p2(p2), _p3(p3) {} 45 | 46 | void write_points_vector(std::ostream &ostrm) const 47 | { 48 | ostrm << _p1 << "," << _p2 << "," << _p3 ; 49 | } 50 | 51 | void write_ascii_stl(std::ostream &ostrm) const 52 | { 53 | ostrm << " " ; 54 | _p1.write_ascii_stl(ostrm); 55 | ostrm << endl; 56 | 57 | ostrm << " " ; 58 | _p2.write_ascii_stl(ostrm); 59 | ostrm << endl; 60 | 61 | ostrm << " " ; 62 | _p3.write_ascii_stl(ostrm); 63 | ostrm << endl; 64 | } 65 | 66 | }; 67 | 68 | 69 | 70 | class Face { 71 | std::vector triangles; 72 | public: 73 | Face() {}; 74 | void addTriangle(const Triangle& tr) { triangles.push_back(tr); }; 75 | 76 | void add_face(const Face& other_face) 77 | { 78 | triangles.insert(triangles.end(), 79 | other_face.triangles.begin(), 80 | other_face.triangles.end()); 81 | } 82 | 83 | void write_ascii_stl(std::ostream &ostrm) const 84 | { 85 | for (auto &t : triangles) { 86 | ostrm << " facet normal 42 42 42" << std::endl; 87 | ostrm << " outer loop" << std::endl; 88 | t.write_ascii_stl(ostrm); 89 | ostrm << " endloop" << std::endl; 90 | ostrm << " endfacet" << std::endl; 91 | } 92 | } 93 | 94 | void write_points_vector(std::ostream &ostrm) const 95 | { 96 | int i = 1 ; 97 | ostrm << "[" << std::endl; 98 | for (auto &t : triangles) { 99 | ostrm << " "; 100 | t.write_points_vector(ostrm); 101 | ostrm << ","; 102 | if (i==1 || (i%10==0 && triangles.size()>10)) 103 | ostrm << " // Triangle " << i << " / " << triangles.size(); 104 | ostrm << std::endl; 105 | ++i; 106 | } 107 | ostrm << "];" << std::endl; 108 | } 109 | 110 | void write_face_vector(std::ostream &ostrm) const 111 | { 112 | ostrm << "[" << std::endl; 113 | for (int i=0;i10)) 117 | ostrm << " // Triangle " << (i+1) << " / " << triangles.size(); 118 | ostrm << std::endl; 119 | } 120 | ostrm << "];" << std::endl; 121 | } 122 | }; 123 | typedef std::vector Face_vector; 124 | 125 | 126 | #endif 127 | --------------------------------------------------------------------------------