1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-05 22:37:35 +02:00

updated polysections

This commit is contained in:
Justin Lin
2017-05-10 16:27:35 +08:00
parent 81b0b6dd6b
commit 2f13a9f2bd
2 changed files with 7 additions and 24 deletions

View File

@@ -14,26 +14,14 @@ You can also view it as a better polyline3d module if you want. If you have only
When using this module, you should use points to represent each cross-section. When using this module, you should use points to represent each cross-section.
You need to provide indexes of triangles, too. This module provides three prepared triangles indexes. One is `"RADIAL"`. For example, if you have a cross-section such as: If your 2D shape is not solid, indexes of triangles are required. This module has a built-in index vector suitable for one type of hollow shapes. For example, if you have a cross-section such as:
![polysections](images/lib-polysections-3.JPG)
When using `"RADIAL"` (default), the module will cut them into triangles from the first point to each remaining point:
![polysections](images/lib-polysections-4.JPG)
If your cross-sections are hollow, you may use `"HOLLOW"`. For example:
![polysections](images/lib-polysections-5.JPG) ![polysections](images/lib-polysections-5.JPG)
When using `"HOLLOW"`, the above shape will be cut into triangles such as: When `triangles` is `"HOLLOW"`, the above shape will be cut into triangles such as:
![polysections](images/lib-polysections-6.JPG) ![polysections](images/lib-polysections-6.JPG)
When using `"TAPE"`, a tape shape will be cut into triangles such as:
![polysections](images/lib-polysections-10.JPG)
You can cut triangles by yourself, for example, the indexes of the above triangles is: You can cut triangles by yourself, for example, the indexes of the above triangles is:
[ [
@@ -50,7 +38,7 @@ Triangles may be defined in any order.
## Parameters ## Parameters
- `sections` : A list of cross-sections. Each cross-section is represented by a list of points. See the example below. - `sections` : A list of cross-sections. Each cross-section is represented by a list of points. See the example below.
- `triangles` : `"RADIAL"` (default), `"HOLLOW"`, `"TAPE"` or user-defined indexes. See example below. - `triangles` : `"SOLID"` (default), `"HOLLOW"`, or user-defined indexes. See example below.
## Examples ## Examples

View File

@@ -11,10 +11,9 @@
* *
**/ **/
include <__private__/__triangles_radial.scad>;
include <__private__/__triangles_tape.scad>; include <__private__/__triangles_tape.scad>;
module polysections(sections, triangles) { module polysections(sections, triangles = "SOLID") {
module solid_sections() { module solid_sections() {
leng_sections = len(sections); leng_sections = len(sections);
leng_pts_section = len(sections[0]); leng_pts_section = len(sections[0]);
@@ -80,12 +79,8 @@ module polysections(sections, triangles) {
) )
) idxes; ) idxes;
function tris() = triangles == "RADIAL" ? __triangles_radial(sections[0]) : function tris() =
( triangles == "HOLLOW" ? hollow_tris() : triangles;
triangles == "HOLLOW" ? hollow_tris() : (
triangles == "TAPE" ? __triangles_tape(sections[0]) : triangles
)
);
module two_sections(section1, section2) { module two_sections(section1, section2) {
for(idx = tris()) { for(idx = tris()) {
@@ -114,7 +109,7 @@ module polysections(sections, triangles) {
} }
// //
if(triangles == undef) { if(triangles == "SOLID") {
solid_sections(); solid_sections();
} else { } else {
triangles_defined_sections(); triangles_defined_sections();