Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ class SeamEdgeAmplifier

// Define two pcurves of the seam-edge.
occ::handle<Geom2d_Curve> aPC1, aPC2;
double af, al;
double af, al, af1, al1;

aE.Orientation(TopAbs_FORWARD);
aPC1 = BRep_Tool::CurveOnSurface(aE, aF, af, al);
aPC1 = BRep_Tool::CurveOnSurface(aE, aF, af1, al1);

aE.Orientation(TopAbs_REVERSED);
aPC2 = BRep_Tool::CurveOnSurface(aE, aF, af, al);
Expand All @@ -224,7 +224,9 @@ class SeamEdgeAmplifier
}

// Select the correct pcurve of the seam-edge.
const gp_Pnt2d& aFPntOfPC1 = aPC1->Value(aPC1->FirstParameter());
// Use the edge's first parameter. A Geom2d_Line's FirstParameter() is -Precision::Infinite(),
// where a direction of (2e-16, -1) from rounding error gives an X far outside the U range.
const gp_Pnt2d aFPntOfPC1 = aPC1->Value(af1);

if (std::abs(aLPntOfIPC1.X() - aFPntOfPC1.X()) > Precision::Confusion())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#include <BRepPrimAPI_MakeRevol.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <Geom_Circle.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_Line.hxx>
#include <Geom2d_Line.hxx>
#include <IMeshData_Status.hxx>
#include <IMeshTools_Parameters.hxx>
#include <NCollection_Array1.hxx>
Expand Down Expand Up @@ -585,3 +588,72 @@ TEST(BRepMesh_IncrementalMeshTest, LocalizedSplinePeaksRespectDeflection)
EXPECT_LE(aMaxDistance, aParameters.Deflection);
}
}

// Regression test for issue #572: a conical face must be meshed when its seam pcurves are
// infinite lines whose direction is tilted by rounding error.
TEST(BRepMesh_IncrementalMeshTest, ConeWithTiltedSeamPCurves_IsTriangulated)
{
const double aVMin = -25.0 * std::sqrt(2.0);
const occ::handle<Geom_ConicalSurface> aCone =
new Geom_ConicalSurface(gp::XOY(), M_PI / 4.0, 36.4);
const gp_Pnt aTopPnt = aCone->Value(0.0, 0.0);
const gp_Pnt aBottomPnt = aCone->Value(0.0, aVMin);

int aReferenceTriangles = 0;
for (const double aTilt : {0.0, 2.0e-16, -2.0e-16})
{
SCOPED_TRACE(aTilt);
const TopoDS_Vertex aTopVertex = BRepBuilderAPI_MakeVertex(aTopPnt);
const TopoDS_Vertex aBottomVertex = BRepBuilderAPI_MakeVertex(aBottomPnt);
const TopoDS_Edge aTopEdge =
BRepBuilderAPI_MakeEdge(aCone->VIso(0.0), aTopVertex, aTopVertex, 0.0, 2.0 * M_PI);
const TopoDS_Edge aBottomEdge =
BRepBuilderAPI_MakeEdge(aCone->VIso(aVMin), aBottomVertex, aBottomVertex, 0.0, 2.0 * M_PI);
const TopoDS_Edge aSeamEdge =
BRepBuilderAPI_MakeEdge(new Geom_Line(aTopPnt, gp_Dir(gp_Vec(aTopPnt, aBottomPnt))),
aTopVertex,
aBottomVertex,
0.0,
-aVMin);

BRep_Builder aBuilder;
TopoDS_Face aFace;
aBuilder.MakeFace(aFace, aCone, Precision::Confusion());
aBuilder.UpdateEdge(aTopEdge,
new Geom2d_Line(gp_Pnt2d(0.0, 0.0), gp_Dir2d(1.0, 0.0)),
aFace,
Precision::Confusion());
aBuilder.UpdateEdge(aBottomEdge,
new Geom2d_Line(gp_Pnt2d(0.0, aVMin), gp_Dir2d(1.0, 0.0)),
aFace,
Precision::Confusion());
aBuilder.UpdateEdge(aSeamEdge,
new Geom2d_Line(gp_Pnt2d(0.0, 0.0), gp_Dir2d(aTilt, -1.0)),
new Geom2d_Line(gp_Pnt2d(2.0 * M_PI, 0.0), gp_Dir2d(aTilt, -1.0)),
aFace,
Precision::Confusion());

TopoDS_Wire aWire;
aBuilder.MakeWire(aWire);
aBuilder.Add(aWire, aTopEdge.Reversed());
aBuilder.Add(aWire, aSeamEdge);
aBuilder.Add(aWire, aBottomEdge);
aBuilder.Add(aWire, aSeamEdge.Reversed());
aBuilder.Add(aFace, aWire);

BRepMesh_IncrementalMesh aMesher(aFace, 0.01);
ASSERT_TRUE(aMesher.IsDone());
EXPECT_EQ(aMesher.GetStatusFlags(), IMeshData_NoError);

TopLoc_Location aLocation;
const occ::handle<Poly_Triangulation> aTriangulation =
BRep_Tool::Triangulation(aFace, aLocation);
ASSERT_FALSE(aTriangulation.IsNull());
if (aTilt == 0.0)
{
aReferenceTriangles = aTriangulation->NbTriangles();
EXPECT_GT(aReferenceTriangles, 0);
}
EXPECT_EQ(aTriangulation->NbTriangles(), aReferenceTriangles);
}
}
Loading