Brep Ruled (Creating brep from 2 surfaces) - order of the curves

// Sorting the surfaces by their y positions

var ySurfaces = brep.ConvertToSurfaces().ToList();
ySurfaces.Sort((surface1, surface2) =>
{
                surface1.Regen(1);
                surface2.Regen(1);
                return surface1.BoxMax.Y.CompareTo(surface2.BoxMax.Y);
});

// getting the end surfaces

var bottom = ySurfaces.First();
var top = ySurfaces.Last();
// below is the image for the end surfaces both are similar

// creating the brep from the surfaces

var createdSolid = Ruled(bottom, top);

// below is the image for createdSolid

top.Rotate(Math.PI, Vector3D.AxisX);

var newSolid = Ruled(bottom, top);

// below is the image for the newSolid

this is my opinion

I think the order of the curves might be different but i don't know how to correct the order.
i need some help
and i am using eyeshot 2023 version

0

Comments

4 comments
Date Votes
  • Please try the following on one of the two profiles:

    ICurve.Reverse() 

     

    0
  • // i tried to convert it to ICurve to reverse it
    var top = ySurfaces.Last();
     var topContour = top.GetContours(out int cpunt);
    foreach (var c in topContour)
     {
                    c.Reverse();
      }
    var region = new devDept.Eyeshot.Entities.Region(topContour);
      top = region.ConvertToSurface();

    // after this the surface created losses it's position and angle
    // below is the image of the surface after the reverse

    0
  • i also tried Surface.ReverseU() and Surface.ReverseV()
    it didn't fix the problem

    0
  • var bottom = ySurfaces.First().Clone() as Surface;
    var top = ySurfaces.Last().Clone() as Surface;
    var edgestop = top.ExtractEdges();
    var edgebottom = bottom.ExtractEdges();
    var topcomposite = new CompositeCurve(edgestop);
    var bottomcomposite = new CompositeCurve(edgebottom);
    bottomcomposite.Reverse();
    var bottomcurve = bottomcomposite as ICurve;
    var region2 = new Region(bottomcurve);
    bottom = region2.ConvertToSurface();
    edgestop = top.ExtractEdges();
    edgebottom = bottom.ExtractEdges();
    int sameindex = -1;
    double mindis = double.PositiveInfinity;
    for (int i = 0; i< edgebottom.Length;i++)
    {
        var dis = edgebottom[i].StartPoint.DistanceTo(edgestop[0].StartPoint);
        if ( dis < mindis)
        {
            mindis = dis;
            sameindex = i;
        }
    }
    if(sameindex > -1)
    {
        var newbottom = new List<ICurve>();
        for (int i = sameindex; i < edgebottom.Length; i++)
        {
            newbottom.Add(edgebottom[i]);
        }
        for (int i = 0; i < sameindex; i++)
        {
            newbottom.Add(edgebottom[i]);
        }
        edgebottom = newbottom.ToArray();
        bottomcomposite = new CompositeCurve(edgebottom);
        bottomcurve = bottomcomposite as ICurve;
        region2 = new Region(bottomcurve);
        bottom = region2.ConvertToSurface();

    }
    edgestop = top.ExtractEdges();
    edgebottom = bottom.ExtractEdges();
    var createdSolid = Brep.Ruled(bottom, top);

     

    this worked for me
    your suggestion of using ICurve.reverse was right
    it fixed the orientation after that the orders have to be fixed as you see in the code.
    Thanks you for your help

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post