DiscussionsIssue archiveModeling Data and Algorithms

Archived discussion

How to build polyline with consistent orientation of the filleting shape, like normal profile for picture frame, window, etc...

Modeling Data and AlgorithmsMon, 01/06/2025 - 21:200 replies

Browse this forum
QuestionAuthor

Hello,

I want to create a line that have consistent profile along it direction. Just like window or picture frame.
Here is the code : The first picture is faulty line, and the second is more or less the desired result. I don't know how to set orientation of the fillet profile so it is proper. I would appreciate any help

TopoDS_Shape CreateDoorPath() {
const double mm = 1.0 / 1000.0;

// Hardcoded points data
std::vector p1Data = { 0.0, 0.0, 0.0 };
std::vector p2Data = { 0.0, 40000.0, 0.0 };
std::vector p3Data = { 0.0, 40000.0, 80000.0 };
std::vector p4Data = { 0.0, 0.0, 80000.0 };
double radius = 1000.0 * mm;

gp_Pnt p1(p1Data[0] * mm, p1Data[1] * mm, p1Data[2] * mm);
gp_Pnt p2(p2Data[0] * mm, p2Data[1] * mm, p2Data[2] * mm);
gp_Pnt p3(p3Data[0] * mm, p3Data[1] * mm, p3Data[2] * mm);
gp_Pnt p4(p4Data[0] * mm, p4Data[1] * mm, p4Data[2] * mm);

// Create sharp edges between consecutive points
TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(p1, p2);
TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge(p2, p3);
TopoDS_Edge edge3 = BRepBuilderAPI_MakeEdge(p3, p4);
TopoDS_Edge edge4 = BRepBuilderAPI_MakeEdge(p4, p1); // Close the path

// Create a wire from the edges
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge1, edge2, edge3, edge4);

// Create the circular profile aligned to the first point
gp_Dir spineDirection = gp_Dir(0, 1, 0);
gp_Ax2 profileAxis(p1, spineDirection); // Profile orientation at the start of the spine

Handle(Geom_Circle) circle = new Geom_Circle(profileAxis, radius);
TopoDS_Edge profileEdge = BRepBuilderAPI_MakeEdge(circle);
TopoDS_Wire profileWire = BRepBuilderAPI_MakeWire(profileEdge);

// Create the pipe with dynamic profile orientation
BRepOffsetAPI_MakePipeShell pipeShell(wire); // Use the sharp wire
gp_Dir biNormal(0, 0, 1);

pipeShell.SetMode(biNormal); // Enable dynamic orientation
pipeShell.Add(profileWire);

// Build the pipe
pipeShell.Build();
if (!pipeShell.IsDone()) {
throw std::runtime_error("Pipe creation failed.");
}

// Return the final pipe shape
return pipeShell.Shape();
}

int main() {

// Draw curve in OCCT

TopoDS_Shape pipeShape = CreateDoorPath();

Discussion

No archived replies

Posts are displayed in their archived order.