split an edge that's part of a solid with ReShape

Hi all:
I am trying to split 1 edge of a solid box and somehow have the shapes updated so that I end up with a new box that has 13 edges instead of 12.
I have included the code which basically shows how I am using BRepTools_Reshape. The sub-shapes are not updated correctly. What am I missing?
I am doing the Apply on the original box. Am I supposed to do it for each face that connects to the split edge as well ?

Attachments: 
Ugo Capeto's picture

here's the code:

#include "occ_header.h"

int main(int argc, char *argv[]) {

TopoDS_Solid aBox;
TopoDS_Edge anEdge;
TopoDS_Vertex Vertex1,Vertex2;

Standard_Real Length=1, Width=1, Depth=1;
TopTools_IndexedMapOfShape edgeMap;
TopTools_IndexedMapOfShape vertexMap;

// create a box

aBox = BRepPrimAPI_MakeBox(Length,Width,Depth);
BRepTools::Write(aBox,"aBox.brep");

// asign an edge to split

TopExp::MapShapes(aBox,TopAbs_EDGE,edgeMap);
anEdge= TopoDS::Edge(edgeMap(1));

// find the end point of this edge

TopExp::MapShapes(anEdge, TopAbs_VERTEX, vertexMap);
Vertex1=TopoDS::Vertex(vertexMap(1));
Vertex2=TopoDS::Vertex(vertexMap(2));

// assign u=Param to split

Standard_Real First,Last,Param;
const Handle(Geom_Curve)& Curve=BRep_Tool::Curve(anEdge,First,Last);
cout << " First= " << First << " Last= " << Last << " \n";
Param = (Last-First)*0.5;

// create two new edges by spliting the original edge
TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(Curve,First,Param);
TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge(Curve,Param,Last);

// create a wire to add these two edges

BRepBuilderAPI_MakeWire wire;
wire.Add(edge1);
wire.Add(edge2);

// replace edge with wire

BRepTools_ReShape *reshaper = new BRepTools_ReShape;
reshaper->Replace(anEdge,wire.Wire());
TopoDS_Shape aBox2=reshaper->Apply(aBox);

BRepTools::Write(aBox2,"aBox2.brep");

return 0;

}

Ugo Capeto's picture

anybody knows what needs to be done for the solid and its sub-shapes to be updated correctly?

Ugo Capeto's picture

update:
if i do the reshaper->apply to 1 of the 2 connected faces, it doesn't work either - the face is not correctly updated (can't be displayed).
how on earth does it work?

Clinton Selke's picture

Your replacing an edge with a wire (two different levels of topology). So that is not going to work. You can replace edge with edge, wire with wire, face with face, etc.
I believe you will need to replace the entire wires around both adjacent faces of the edge to be split.