Torus and CurveonSurface to get (u,v) parameter

here's the problem i am facing

made a torus with BRepPrimAPI_MakeTorus()

now, i need to go around the torus's bdry (4 edges, 2 of them being identical location wise but used in opposite direction) and get (u,v) parameters from parameters on the curves. For that, i use BRep_Tool::CurveOnSurface in order to get the proper curve and then i just give the parameter on the curve to get the (u,v) parameter (using method D0).

the problem is that it's getting the wrong curve, instead of getting the curve that goes from v=0 to 2pi at u=0, it's getting the other one (u=2pi). it's either that or the edges are given in the wrong order. I go from wire to edge to get the edges on the torus.

anybody has any experience with this?

Method I use works for everything except torus which is doubly periodic; cylinder, sphere, cone are ok (but those are periodic in just one direction).

sergey zaritchny's picture

Hi Ugo,
You may find some example of correct *_MakeTorus API using in file BRepTest_PrimitiveCommands.cxx.

Ugo Capeto's picture

All i am saying is that if you look at a full torus (360 in both directions), there's 2 edges, both are used twice by the face.

Now, if you explore wire, then explore the 4 edges of said wire and then get the 2d curve corresponding to each of the 4 edges, the order is not correct. Basically, i am trying to get a discrete (segmented) representation of the torus' boundary following the bounding edges in the parameter space.

When you go around a full torus, you typically get edge1 used in reverse dir, then edge2 used in forward dir, then edge1 again used in forward dir and then edge2 used in reverse dir. that completes the loop. unfortunately, when you go through the associated curves, the order is not correct. you need the 2d curve to get the (u,v) parameter given a parameter on the edge.

i've used this method for pretty much all types of faces. it works except for a full torus.

Ugo Capeto's picture

So, if go along edge1 in reverse, the (u,v) values i get are (6.28,3.14) to (0,3.14)
then i go along edge2 in forward, so at parameter -3.14 on the edge (range is -3.14 to 3.14), i get (6.28,-3.14) which is wrong.

I should have gotten (0,3.14).

this means the curve i am getting is the one at u=6.28, not the one at u=0.