【问题标题】:Mesh fails to render when extruding a pentagram in a pentagrammic pattern以五角星图案挤压五角星时网格无法渲染
【发布时间】:2023-01-15 08:32:03
【问题描述】:

我有以下代码旨在以五角星图案挤出五角星:

pentp =
  [ for (j = [0 : 144 : 719]) [sin(j)+1.5, cos(j)]
  ];


union() {
    for (i = [0 : 144 : 719]) {
        rotate([0,0,i]) rotate_extrude(angle = 288, $fn=2) polygon(pentp);
    };
};

预览看起来正确:

所以我想渲染它并导出,这样我就可以在 Blender 中生成漂亮的渲染图。当我点击渲染时,我得到一些几何错误:

Rendering Polygon Mesh using CGAL...
ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 
ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 
ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 
ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 
ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron. 
Geometries in cache: 63
Geometry cache size in bytes: 178448
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Total rendering time: 0:00:00.021
WARNING: No top level geometry to render 

看到错误并不奇怪,因为我试图渲染的形状非常不凸,但我不完全确定网格有什么没有闭合。通过一些实验,我发现问题似乎出在挤压五角星上。

如果我切换到挤压五边形,则没有错误:

pentp =
  [ for (j = [0 : 72 : 359]) [sin(j)+1.5, cos(j)]
  ];


union() {
    for (i = [0 : 144 : 719]) {
        rotate([0,0,i]) rotate_extrude(angle = 288, $fn=2) polygon(pentp);
    };
};

如果我以五边形图案挤出五角星,错误仍然存​​在:

pentp =
  [ for (j = [0 : 144 : 719]) [sin(j)+1.5, cos(j)]
  ];


union() {
    for (i = [0 : 144 : 719]) {
        rotate([0,0,i]) rotate_extrude(angle = 72, convexity=10, $fn=2) polygon(pentp);
    };
};

但是,当我仅使用一个 rotate_extrude 以五边形图案挤出五角星时,没有错误:

pentp =
  [ for (j = [0 : 144 : 719]) [sin(j)+1.5, cos(j)]
  ];

rotate_extrude(angle=360, $fn=5) polygon(pentp);

然而,据我所知,rotate_extrude 似乎无法单独挤压成五角星形。

我可以看到在使用非凸多边形和导致问题的我的盗版挤压方面存在一些融合。但是我无法确定它,也没有办法修复它。

我的初始代码有什么问题。

【问题讨论】:

    标签: cgal cad 3d-modelling openscad


    【解决方案1】:

    问题不在于多边形是非凸的,而是它是自相交的(非简单的)。 OpenSCAD 的意思是“实体建模器”,用于表示具有明确定义的体积(3d 中)或面积(2d 中)的形状。

    对于空间中的任何给定点,该点位于对象内部还是外部应该是明确的。由于五角星的自相交,它并不真正符合这些条件。

    一种解决方法是在进行任何挤压之前将 offset 和 polygon 进行少量调整,以使线条具有一定的厚度。

    pentp =
      [ for (j = [0 : 144 : 719]) [sin(j)+1.5, cos(j)]
      ];
    
    
    union() {
        for (i = [0 : 144 : 719]) {
            rotate([0,0,i]) rotate_extrude(angle = 288, $fn=2) offset(0.001) polygon(pentp);
        };
    };
    

    这主要是因为自相交是通过 2D 子系统固定的:Clipper(又名 libpolyclipping),它比用于联合等 3D 布尔运算的 CGAL 更宽容。

    【讨论】:

      猜你喜欢
      • 2016-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多