For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

How to build wires from BRepAlgo_Section?

Dave Cowden's picture
Forums: 

Hi, everyone:

I am successfully using BRepAlgo[Api]_Section to compute the intersection curve of a shape and a plane.

The problem is, the result is a compound of edges, that are not organized in wires.

It is not trivial it would seem, to re-organize them into wires.

Actually, what i'd like to is get a face, so that I can use ShapeAnalysis_FreeBounds::OuterWire() and other methods that let me properly know how the edges relate to the original shape.

Am i better off just using BRep_Algo_Cut and a halfspace, so that I have a solid shape?

Bearloga's picture

Try using the class ShapeAnalysis_WireOrder. It allows to order a list of edges in a number of connected chains.

Dave Cowden's picture

sweet, i'll give it a try. thanks!

Svetlozar Kostadinov's picture

10x from me too! This may be very useful.

arkoala's picture

Hi guys,

How do you use ShapeAnalysis_WireOrder. I thought it would be passing by reference a wire and getting modified and ordered.

Is it need to pass vertex by vertex using "Add" function and getting the edges using "Chain"?
Then, what if the original wire had circular edges? That info would lost!

I'm sure you had the same problem and you got it!

Thanks

David Egan's picture

this may help....

// obtain the list of edges

for(Exo.Init(aCutOperation2->Shape() ,TopAbs_EDGE);Exo.More();Exo.Next())
{
TopoDS_Edge aCurrentEdge = TopoDS::Edge(Exo.Current());
WaterLineEdges->Append(aCurrentEdge);
}

Handle(TopTools_HSequenceOfShape) Wires = new TopTools_HSequenceOfShape();

Handle(TopTools_HSequenceOfShape) ClosedWires = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) OpenWires = new TopTools_HSequenceOfShape();

// get a list of wires from the edges

ShapeAnalysis_FreeBounds::ConnectEdgesToWires(WaterLineEdges,m_GlobalTolerance ,false,Wires);
// should be one open wire for symmetric case
//if a closed wire + open then we have a bubble
// so only take openwires for symmetric

//split wires into open and closed
ShapeAnalysis_FreeBounds::SplitWires(Wires,m_GlobalTolerance,false,ClosedWires,OpenWires);

Divya's picture

Hi David,
This is for one wire but how do i do it when it has multiple number of closed wires in one shape!!

David Egan's picture

oops , the first bit got cutoff
// define the list of edges
Handle(TopTools_HSequenceOfShape)Edges = new TopTools_HSequenceOfShape();

// get the section
BRepAlgoAPI_BooleanOperation * aCutOperation2 = new BRepAlgoAPI_Section(aShape, CutSolid) ;

arkoala's picture

I think I've got it.
By now, it is working properly but I will have to test it deeper.

This is my code. I start with "wire" created by BRepOffsetAPI_MakeOffset and sometimes that function created not sorted wires.
Handle(TopTools_HSequenceOfShape) wireSequence = new TopTools_HSequenceOfShape();
wireSequence->Append((TopoDS_Shape)(wire));
Handle(TopTools_HSequenceOfShape) wireSorted = new TopTools_HSequenceOfShape();

ShapeAnalysis_FreeBounds::ConnectWiresToWires(wireSequence,Precision::Confusion(),false,wireSorted);
wire = TopoDS::Wire(wireSorted->Value(1));

Thank you David for show me the right direction.

Divya's picture

I used the following code:
ShapeAnalysis_WireOrder myOrderer;
ShapeAnalysis_WireOrder(Standard_True,1);
TopoDS_Shape sh;
Handle(TopTools_HSequenceOfShape) Edges = new TopTools_HSequenceOfShape();
for(int c=1;c {
sh=Edges->Value(c);
TopoDS_Edge nEdge=TopoDS::Edge(sh);
TopoDS_Vertex FV,LV;
gp_Pnt FV1,LV1;
gp_XYZ P1,P2;
FV=TopExp::FirstVertex(nEdge,Standard_True);
LV=TopExp::LastVertex(nEdge,Standard_True);
FV1=BRep_Tool::Pnt(FV);
LV1=BRep_Tool::Pnt(LV);
P1.SetX(FV1.X());P1.SetY(FV1.Y());P1.SetZ(FV1.Z());
P2.SetX(LV1.X());P2.SetY(LV1.Y());P2.SetZ(LV1.Z());
myOrderer.Add(P1,P2);
}
myOrderer.Perform();
if(myOrderer.IsDone())//the result is that edges are sequenced

now ho do I collect those sequenced edges from ShapeAnalysis_Wireorder.

Divya's picture

Hi as u said u are using shapes in opencascade. can you tell us what class and function to use for slicing?

Divya's picture

Hi, Dave:
I'm trying to represent 2slices separating(branching)to the next level from one.can you suggest me as in wat functions to use?