public static CrossSectionSolid CreateConstantCrossSectionSolid(double[] buildDirection, double extrudeDistance, List <Vertex> layer3DAtStart, double sameTolerance, UnitType units) { //Since the start point may be along a negative direction, we have to add vectors instead of adding the extrudeDistance as is. var start = layer3DAtStart.First().Position.dotProduct(buildDirection); var endPoint = layer3DAtStart.First().Position.add(buildDirection.multiply(extrudeDistance)); var stepDistances = new Dictionary <int, double> { { 0, start }, { 1, endPoint.dotProduct(buildDirection) } }; var shape = new PolygonLight(MiscFunctions.Get2DProjectionPointsAsLight(layer3DAtStart, buildDirection)); if (shape.Area < 0) { shape = PolygonLight.Reverse(shape); } var layers2D = new Dictionary <int, List <PolygonLight> > { { 0, new List <PolygonLight> { shape } }, { 1, new List <PolygonLight> { shape } } }; return(new CrossSectionSolid(buildDirection, stepDistances, sameTolerance, layers2D, null, units)); }
private static PolygonLight GetPolygonFromFace(PolygonalFace face, Dictionary <int, PointLight> projectedPoints, bool forceToBePositive) { if (face.Vertices.Count != 3) { throw new Exception("This method was only developed with triangles in mind."); } //Make sure the polygon is ordered correctly (we already know this face is positive) var points = face.Vertices.Select(v => projectedPoints[v.IndexInList]).ToList(); var facePolygon = new PolygonLight(points); if (forceToBePositive && facePolygon.Area < 0) { facePolygon = PolygonLight.Reverse(facePolygon); } return(facePolygon); }