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

Surface intersections

Gabriele Cuccolini's picture
Forums: 

Hi, I've a problem about the intersection between two surfaces.
The first is trimmed while the second is untrimmed.

I use the BRepAlgoAPI_Section to intersect the two surfaces and obtain the intersection 

edges (in my case only one):

This is my code, here I make the intersection:

TopoDS_Face trimface, face;

// ...... filling face and trimface from IGES file

            
BRepAlgoAPI_Section ffsect( trimface, face, Standard_True);
ffsect.Approximation(Standard_True);
ffsect.Build();

Here I iterate between the section edges. For each edge I create a TopoDS_Edge to put on screen.

Standard_Real pFirst, pLast;    

TopTools_ListOfShape edges = ffsect.SectionEdges();

TopTools_ListIteratorOfListOfShape eIter(edges);
while ( eIter.More() ) {
        
    // For each edge I create a TopoDS_Edge object and I put it on screen    
    TopoDS_Edge edge = TopoDS::Edge(eIter.Value());            
    Handle(AIS_Shape) anAisEdge;
    anAisEdge = new AIS_Shape(edge);
    anAisEdge->SetColor(Quantity_NOC_RED);
    anAisEdge->SetWidth(2.0);
    // get my Ais_InteractiveContext
    myOccView->getContext()->Display(anAisEdge);
    

    // Create a Geom_BSplineCurve from edge
    Handle(Geom_BSplineCurve) myCurve = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(edge, pFirst, pLast));

    // Now create a TopoDS_Edge from my curve 
    TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge(myCurve);
    Handle(AIS_Shape) anAisEdge2;
    anAisEdge2 = new AIS_Shape(edge2);
    anAisEdge2->SetColor(Quantity_NOC_RED);
    anAisEdge2->SetWidth(2.0);
    myOccView->getContext()->Display(anAisEdge2);

    eIter.Next();

}

If I check separately the display on screen of anAisEdge and anAisEdge2 I obtain two different results. I don't understand why.
In the image in attach  on top the first display while down the second one.

Attachments: 
Forum supervisor's picture

Dear Gabriele,

 

The difference in your first and second cases is due initialization of BSplineCurve instead of TrimmedCurve here :

Handle(Geom_BSplineCurve) myCurve = Handle(Geom_BSplineCurve)::DownCast(BRep_Tool::Curve(edge, pFirst, pLast));

Please try :

Handle(Geom_TrimmedCurve) myCurve = Handle(Geom_TrimmedCurve)::DownCast(BRep_Tool::Curve(edge, pFirst, pLast));

or

Handle(Geom_Curve) myCurve = BRep_Tool::Curve(edge, pFirst, pLast);

 

One more remark.

These lines in your code perform section operation twice :

BRepAlgoAPI_Section ffsect( trimface, face, Standard_True);

ffsect.Approximation(Standard_True);

ffsect.Build();

 

Instead of that you should use :

BRepAlgoAPI_Section ffsect( trimface, face, Standard_False);
ffsect.Approximation(Standard_True);
ffsect.Build();

 

Best regards, FSR