Getting boundary nodes of reclassified STL Python API
I have an STL (2D) which I reparametrise into surfaces and remesh successfully. I then want to access the nodes in the reparametrised boundaries with the end goal of adding them to BSpline
s using the OpenCASCADE kernel.
My understanding is that in the Python API calling
s = gmsh.model.getEntities(2)
bcs = gmsh.model.getBoundary(s, combined=False, recursive=True)
Should return the boundary nodes of each surface in s
but instead it returns a single point that was added during the reparametrisation process. From what I understand the problem is due to createGeometry
representing the geometry with just a mesh instead of the Built-in CAD. I am not sure how the Curves
of the reparametrised surfaces are stored internally but shouldn't we be able to manipulate them e.g. get their points or reparametrise them (gmsh.model.getParametrization
)?
Is there a way to get the nodes of the Curves (ideally ordered by adjacency) of the reclassidied Surfaces?
MWE
STL: mwe2.stl
#! /usr/bin/env python3
import math
import os
import pathlib
import sys
import gmsh
gmsh.initialize()
gmsh.model.add("Minimal Working Example")
root = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))
gmsh.merge(str(root / "mwe2.stl"))
angle = 40
gmsh.model.mesh.classifySurfaces(
angle=angle * math.pi / 180.0,
boundary=True,
forReparametrization=True,
curveAngle=math.pi,
)
# Reparametrise
gmsh.model.mesh.createGeometry()
# Create a volume from all the surfaces
s = gmsh.model.getEntities(2)
l = gmsh.model.geo.addSurfaceLoop([e[1] for e in s])
gmsh.model.geo.synchronize()
# Specify uniform element sizes
f = gmsh.model.mesh.field.add("MathEval")
gmsh.model.mesh.field.setString(f, "F", "0.001")
gmsh.model.mesh.field.setAsBackgroundMesh(f)
gmsh.model.mesh.generate(2)
bcs = gmsh.model.getBoundary(s, combined=False, recursive=True)
for i, bc in enumerate(bcs):
print("idx: ", i, bc) # yields single point
if "-nopopup" not in sys.argv:
gmsh.fltk.run()
gmsh.finalize()
Related
On a somewhat related note, I was looking around the API and I stumbled onto the gmsh.model.occ.convertToNURBS(v)
, where v
is a 3D OCC entity. From reading the BRepBuilderAPI_NurbsConvert
docs this should convert all the OCC Line
entities to BSpline
, is that right or am I missing something?
Related post: #1862 (closed)
Related commit: d22b4971