Lingkan
CAD practitioner
Hey guys,
I'm trying to create a restricted Surface from a TopoDS_Shell, which internally is made up of a collection of Geom_BSplineSurfaces (on the geometry level).
Now this surface gets referenced multiple times and cut by a TopoDS_Wire to create new surfaces...
I have code that implements the mentioned use-case for planar surfaces, but the wrong shape is constructed for curved surfaces. I'm using the BRepBuilderAPI_MakeFace API, which also states that it will only work for non-planar surfaces when the surface contains p-curves for every edge inside TopoDS_Wire:
I could need some help, as I have no idea how to approach this problem.
Here is a code prototype of how I handle this for planar surfaces:
The actual code lives here.
And images for context:
I'm trying to create a restricted Surface from a TopoDS_Shell, which internally is made up of a collection of Geom_BSplineSurfaces (on the geometry level).
Now this surface gets referenced multiple times and cut by a TopoDS_Wire to create new surfaces...
I have code that implements the mentioned use-case for planar surfaces, but the wrong shape is constructed for curved surfaces. I'm using the BRepBuilderAPI_MakeFace API, which also states that it will only work for non-planar surfaces when the surface contains p-curves for every edge inside TopoDS_Wire:
BRepBuilderAPI_MakeFace: Make a face from a Surface and a wire. If the surface S is not plane, it must contain pcurves for all edges in W, otherwise the wrong shape will be created.
I could need some help, as I have no idea how to approach this problem.
Here is a code prototype of how I handle this for planar surfaces:
C++:
TopoDS_Wire wire = ...;
std::vector<TopoDS_Face> faces =
OCCUtils::ShapeComponents::AllFacesWithin(shape);
BRepBuilderAPI_Sewing shellMaker;
for (TopoDS_Face const &face : faces) {
GeomAdaptor_Surface surfaceAdapter =
OCCUtils::Surface::FromFace(TopoDS::Face(face));
// TODO: Currently cutting curved surfaces with a wire is not supported
// BRepBuilderAPI_MakeFace: Make a face from a Surface and a wire. If the
// surface S is not plane, it must contain pcurves for all edges in W,
// otherwise the wrong shape will be created.
auto faceBuilder =
BRepBuilderAPI_MakeFace(surfaceAdapter.Surface(), wire, Standard_True);
faceBuilder.Build();
if (!faceBuilder.IsDone()) {
// ...
return {};
}
ShapeFix_Face fix(faceBuilder.Face());
fix.Perform();
if (fix.Status(ShapeExtend_FAIL)) {
// ...
return {};
}
shellMaker.Add(fix.Face());
}
shellMaker.Perform();
TopoDS_Shape sewedShape = shellMaker.SewedShape();
int numShells = 0;
auto shell = TopoDS_Shell();
TopExp_Explorer shellExplorer(sewedShape, TopAbs_SHELL);
for (; shellExplorer.More(); shellExplorer.Next()) {
shell = TopoDS::Shell(shellExplorer.Current());
numShells++;
}
if (numShells != 1) {
// ...
}
return shell;
The actual code lives here.
And images for context: