Skip to content

Make3D.MakePipe fails when using a straight path #295

@niempi2

Description

@niempi2

The following piece of code uses Make3D.MakePipe-method, but fails with GeoVectorException
Looking at source it seems like it fails on line 1011 of Make3D.cs in which an attempt to calculate normal with two vectors pointing to same direction is made. It looks like the code assumes that the path is curved and fails if it is just straight line or the start and end point to same direction.

public static class CadabilityMakePipeDemo
{
   
    public static void Main()
    {
        // Example usage:
        Project project = Project.CreateSimpleProject();
        double width = 10.0;
        double height = 5.0;
        double depth = 20.0;
        IGeoObject pipeObject = CreateRectAndMakePipe(project, width, height, depth);

    }

    /// <summary>
    /// Creates a rectangle in the XY plane at the origin and sweeps it along +Z using Make3D.MakePipe.
    /// </summary>
    public static IGeoObject CreateRectAndMakePipe(Project project, double width, double height, double depth)
    {

        GeoPoint p0 = new GeoPoint(0, 0, 0);
        GeoPoint p1 = new GeoPoint(width, 0, 0);
        GeoPoint p2 = new GeoPoint(width, height, 0);
        GeoPoint p3 = new GeoPoint(0, height, 0);
        Line l0 = Line.Construct(); l0.StartPoint = p0; l0.EndPoint = p1;
        Line l1 = Line.Construct(); l1.StartPoint = p1; l1.EndPoint = p2;
        Line l2 = Line.Construct(); l2.StartPoint = p2; l2.EndPoint = p3;
        Line l3 = Line.Construct(); l3.StartPoint = p3; l3.EndPoint = p0;
        Path rectPath = Path.Construct();
        rectPath.Add(l0);
        rectPath.Add(l1);
        rectPath.Add(l2);
        rectPath.Add(l3);
        Face profileFace = Make3D.MakeFace(rectPath, project);   
        Line axis = Line.Construct();
        axis.StartPoint = new GeoPoint(0, 0, 0);
        axis.EndPoint = new GeoPoint(0, 0, depth);
        Path alongPath = Path.Construct();
        alongPath.Add(axis);    
        IGeoObject swept = Make3D.MakePipe(profileFace, alongPath, project);
        return swept;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions