How to split an edge by a parameter?

Hi
How can I split an edge by a parameter?

Thanks.

Sean

Cauchy Ding's picture

Hi Sean,

If you already have the split parameter, you only need to create another two Geom_TrimmedCurve and build two sub edges.

Ding

seanliu's picture

Hi Cauchy:
Thank you for your reply.
One more question:
I am trying to split an existing edge into two edges instead of creating two new edges. Can I achieve that by your answer?

Thanks in advance.

Sean

Cauchy Ding's picture

Hi Sean,

Two edges means two new edges, you have to create them by BRepBuilderAPI_MakeEdge API. For example if you want to splite an edge from a wire, you have to splite the edge firstly into two new edges, and group with other edges into a new wire.

Ding

Shang-Sheng Liu's picture

Let's take the example of a solid cube. it has 12 edges.

i want to split 1 edge, let's say at the middle and end up with a solid cube that has 13 edges.

What is the process in order to achieve this?

Sharjith Naramparambath's picture

A solid cube having 13 edges is not a topologically valid cube. You can extract an edge from a topological object and create new split edges using underlying information from the original edge and make good use of the new edges for something you desire. However you cannot expect a split edge to remain in the original topological data structure. You may reconstruct the wire from the split edges and rebuild the cube's topology successfully but the resulting solid will be a valid topological object but not a cube.
If your intention is to do something like splitting the edge and deforming the object by pulling the new vertex, you must keep in mind that those are not topological(B-Rep) objects that CAD systems work on for such operations. They are indeed mesh objects built from the original topological objects.

Cauchy Ding's picture

Hi Shang,

In my App, to split an edge on a face/shell/solid, the flow chart looks like this:

1. Project or extrema vertex onto edge to get the parameter on 3d curve of the destination edge.
Distance_VertexEdge(vertice, edge, prjPnts, paramsOnEdge); The paramsOnEdge is the parameter on the 3d curve.
BRepExtrema_ExtPC is the occ API in Distance_VertexEdge.

2. Try to splite the edge into two sub edges in face. Here you should cut the edge by parameter curve instead of 3d curve.
Repair_SplitEdge(const TopoDS_Edge& edge, const TopoDS_Face& face, const std::vector& params, std::vector& subEdges, bool b2dParam)
Because the parameter in step 1 is only parameter on 3d curve, here you should convert params into the pcurve. The converting API is GeomAPI_ProjectPointOnSurf and Geom2dAPI_ProjectPointOnCurve.
In Repair_SplitEdge, you should create two new Handle_Geom2d_TrimmedCurve and build two sub edges using these two trimmed 2d curve and the face.

3. After getting the two sub edges, you can regroup the wire, the API looks like
Repair_ReplaceEdges(wire, delEdges, addEdges, newWire); delEdges is the edge to be splitted, addEdges is the new two sub edges. It will call occ API BRepBuilderAPI_MakeWire.
Now, you will get a newWire in face.

4. After getting the new wire, you can reshape the raw face, the API looks like
Repair_ReplaceWire(wire, newWire, face, newFace), it will call occ API BRepTools_ReShape.

5. If the face is on a shell or solid, you should replace face with new face from the shell and call sew APIs to stitch them together again.
Repair_ReplaceFace(facePairs, shellSolid, newShellSolid), it will call occ API BRepTools_ReShape
and BRepOffsetAPI_Sewing.

It's just my solution.

Roman Lygin's picture

Sean,
If you need to split an isolated edge then the comments given above by Cauchy should work fine. Although Geom_TrimmedCurve is not recommended, to avoid dual restriction (by Geom_TrimmedCurve and edge itself) as parameters on the original edge should work fine. However, remember to copy the original curve (twice) to have independent underlying curves, as sharing should be avoided for the geom objects.

If you need to split within an existing shape (like splitting one edge in a cube to have 13 edges in total above) then you need to do more. You need to feed original edge and TopoDS_Wire (or TopoDS_Compound) of two new edges into BRepTools_ReShape and call Apply() for the original global shape.

Hope this helps.
Roman