mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f9f5db1264 | ||
|
83bc18b4f0 | ||
|
1b7899d7de | ||
|
3ffdc52821 | ||
|
afd7551d88 | ||
|
c1a495689d | ||
|
765283765b |
@@ -89,9 +89,11 @@ public:
|
||||
//! @param theShape shape to be meshed.
|
||||
//! @param theLinDeflection linear deflection to be used for meshing.
|
||||
//! @param theAngDeflection angular deflection to be used for meshing.
|
||||
//! @param theTDOldBehavior tangential deflection behavior for default algorithm.
|
||||
Standard_EXPORT Handle(BRepMesh_DiscretRoot) Discret(const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLinDeflection,
|
||||
const Standard_Real theAngDeflection);
|
||||
const Standard_Real theAngDeflection,
|
||||
const Standard_Boolean theTDOldBehavior = Standard_True);
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -68,7 +68,8 @@ public:
|
||||
Relative(Standard_False),
|
||||
AdaptiveMin(Standard_False),
|
||||
InternalVerticesMode(Standard_True),
|
||||
ControlSurfaceDeflection(Standard_True)
|
||||
ControlSurfaceDeflection(Standard_True),
|
||||
TDOldBehavior(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -103,6 +104,10 @@ public:
|
||||
//! Prameter to check the deviation of triangulation and interior of
|
||||
//! the face
|
||||
Standard_Boolean ControlSurfaceDeflection;
|
||||
|
||||
//! Prameter to set tangential deflection behavior
|
||||
//! (old - for backward compatibility, may produce incorrect results in several cases)
|
||||
Standard_Boolean TDOldBehavior;
|
||||
};
|
||||
|
||||
public:
|
||||
|
@@ -84,7 +84,8 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theSh
|
||||
const Standard_Boolean isRelative,
|
||||
const Standard_Real theAngDeflection,
|
||||
const Standard_Boolean isInParallel,
|
||||
const Standard_Boolean adaptiveMin)
|
||||
const Standard_Boolean adaptiveMin,
|
||||
const Standard_Boolean theTdOldBehavior)
|
||||
: myMaxShapeSize(0.),
|
||||
myModified(Standard_False),
|
||||
myStatus(0)
|
||||
@@ -94,6 +95,7 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theSh
|
||||
myParameters.Angle = theAngDeflection;
|
||||
myParameters.InParallel = isInParallel;
|
||||
myParameters.AdaptiveMin = adaptiveMin;
|
||||
myParameters.TDOldBehavior = theTdOldBehavior;
|
||||
|
||||
myShape = theShape;
|
||||
Perform();
|
||||
@@ -262,7 +264,7 @@ void BRepMesh_IncrementalMesh::discretizeFreeEdges()
|
||||
BRepAdaptor_Curve aCurve(aEdge);
|
||||
GCPnts_TangentialDeflection aDiscret(aCurve, aCurve.FirstParameter(),
|
||||
aCurve.LastParameter(), myParameters.Angle, aEdgeDeflection, 2,
|
||||
Precision::PConfusion(), myParameters.MinSize);
|
||||
Precision::PConfusion(), myParameters.MinSize, myParameters.TDOldBehavior);
|
||||
|
||||
Standard_Integer aNodesNb = aDiscret.NbPoints();
|
||||
TColgp_Array1OfPnt aNodes (1, aNodesNb);
|
||||
@@ -572,6 +574,23 @@ Standard_Integer BRepMesh_IncrementalMesh::Discret(
|
||||
return 0; // no error
|
||||
}
|
||||
|
||||
Standard_Integer BRepMesh_IncrementalMesh::Discret(
|
||||
const TopoDS_Shape& theShape,
|
||||
const Standard_Real theDeflection,
|
||||
const Standard_Real theAngle,
|
||||
const Standard_Boolean theTdOldBehavior,
|
||||
BRepMesh_DiscretRoot* &theAlgo)
|
||||
{
|
||||
BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
|
||||
anAlgo->ChangeParameters().Deflection = theDeflection;
|
||||
anAlgo->ChangeParameters().Angle = theAngle;
|
||||
anAlgo->ChangeParameters().InParallel = IS_IN_PARALLEL;
|
||||
anAlgo->ChangeParameters().TDOldBehavior = theTdOldBehavior;
|
||||
anAlgo->SetShape(theShape);
|
||||
theAlgo = anAlgo;
|
||||
return 0; // no error
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsParallelDefault
|
||||
//purpose :
|
||||
|
@@ -57,7 +57,8 @@ public: //! @name mesher API
|
||||
const Standard_Boolean isRelative = Standard_False,
|
||||
const Standard_Real theAngDeflection = 0.5,
|
||||
const Standard_Boolean isInParallel = Standard_False,
|
||||
const Standard_Boolean adaptiveMin = Standard_False);
|
||||
const Standard_Boolean adaptiveMin = Standard_False,
|
||||
const Standard_Boolean theTdOldBehavior = Standard_True);
|
||||
|
||||
//! Constructor.
|
||||
//! Automatically calls method Perform.
|
||||
@@ -108,6 +109,19 @@ public: //! @name plugin API
|
||||
const Standard_Real theLinDeflection,
|
||||
const Standard_Real theAngDeflection,
|
||||
BRepMesh_DiscretRoot* &theAlgo);
|
||||
|
||||
//! Plugin interface for the Mesh Factories.
|
||||
//! Initializes meshing algorithm with the given parameters.
|
||||
//! @param theShape shape to be meshed.
|
||||
//! @param theLinDeflection linear deflection.
|
||||
//! @param theAngDeflection angular deflection.
|
||||
//! @param theTdOldBehavior angle comparison mode for tangential deflection
|
||||
//! @param[out] theAlgo pointer to initialized algorithm.
|
||||
Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape& theShape,
|
||||
const Standard_Real theLinDeflection,
|
||||
const Standard_Real theAngDeflection,
|
||||
const Standard_Boolean theTdOldBehavior,
|
||||
BRepMesh_DiscretRoot* &theAlgo);
|
||||
|
||||
//! Returns multi-threading usage flag set by default in
|
||||
//! Discret() static method (thus applied only to Mesh Factories).
|
||||
|
@@ -67,11 +67,26 @@ static void D2 (const Adaptor2d_Curve2d& C, const Standard_Real U,
|
||||
static Standard_Real EstimAngl(const gp_Pnt& P1, const gp_Pnt& Pm, const gp_Pnt& P2)
|
||||
{
|
||||
gp_Vec V1(P1, Pm), V2(Pm, P2);
|
||||
Standard_Real L = V1.Magnitude() * V2.Magnitude();
|
||||
Standard_Real L = Sqrt(V1.SquareMagnitude() * V2.SquareMagnitude());
|
||||
//
|
||||
if(L > gp::Resolution())
|
||||
{
|
||||
return V1.CrossMagnitude(V2)/L;
|
||||
return V1.Dot(V2) / L;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Real EstimAnglOld(const gp_Pnt& P1, const gp_Pnt& Pm, const gp_Pnt& P2)
|
||||
{
|
||||
gp_Vec V1(P1, Pm), V2(Pm, P2);
|
||||
Standard_Real L = Sqrt(V1.SquareMagnitude() * V2.SquareMagnitude());
|
||||
//
|
||||
if(L > gp::Resolution())
|
||||
{
|
||||
return V1.CrossMagnitude(V2) / L;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -75,21 +75,21 @@ public:
|
||||
|
||||
Standard_EXPORT GCPnts_TangentialDeflection();
|
||||
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor3d_Curve& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor3d_Curve& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor3d_Curve& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor3d_Curve& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor2d_Curve2d& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor2d_Curve2d& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor2d_Curve2d& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT GCPnts_TangentialDeflection(const Adaptor2d_Curve2d& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7);
|
||||
Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Real FirstParameter, const Standard_Real LastParameter, const Standard_Real AngularDeflection, const Standard_Real CurvatureDeflection, const Standard_Integer MinimumOfPoints = 2, const Standard_Real UTol = 1.0e-9, const Standard_Real theMinLen = 1.0e-7, const Standard_Boolean ACompOldBehavior = Standard_False);
|
||||
|
||||
//! Add point to already calculated points (or replace existing)
|
||||
//! Returns index of new added point
|
||||
@@ -110,6 +110,12 @@ public:
|
||||
{
|
||||
return points.Value (I);
|
||||
}
|
||||
|
||||
//! Returns if the old behavior for angle comparison (based on sin) or the new one (based on cos) should be used.
|
||||
Standard_Boolean ACompOldBehavior()
|
||||
{
|
||||
return aCompOldBehavior;
|
||||
}
|
||||
|
||||
//! Computes angular step for the arc using the given parameters.
|
||||
Standard_EXPORT static Standard_Real ArcAngularStep (const Standard_Real theRadius, const Standard_Real theLinearDeflection, const Standard_Real theAngularDeflection, const Standard_Real theMinLength);
|
||||
@@ -148,6 +154,7 @@ private:
|
||||
Standard_Real firstu;
|
||||
TColgp_SequenceOfPnt points;
|
||||
TColStd_SequenceOfReal parameters;
|
||||
Standard_Boolean aCompOldBehavior;
|
||||
};
|
||||
|
||||
#endif // _GCPnts_TangentialDeflection_HeaderFile
|
||||
|
@@ -42,7 +42,7 @@ void GCPnts_TangentialDeflection::EvaluateDu (
|
||||
Standard_Real Lc = N.CrossMagnitude (T);
|
||||
Standard_Real Ln = Lc/Lt;
|
||||
if (Ln > LTol) {
|
||||
Du = sqrt (8.0 * Max(curvatureDeflection, myMinLen) / Ln);
|
||||
Du = Sqrt (8.0 * Max(curvatureDeflection, myMinLen) / Ln);
|
||||
NotDone = Standard_False;
|
||||
}
|
||||
}
|
||||
@@ -60,10 +60,11 @@ GCPnts_TangentialDeflection::GCPnts_TangentialDeflection (
|
||||
const Standard_Real CurvatureDeflection,
|
||||
const Standard_Integer MinimumOfPoints,
|
||||
const Standard_Real UTol,
|
||||
const Standard_Real theMinLen)
|
||||
const Standard_Real theMinLen,
|
||||
const Standard_Boolean ACompOldBehavior)
|
||||
|
||||
{
|
||||
Initialize (C,AngularDeflection,CurvatureDeflection,MinimumOfPoints,UTol,theMinLen);
|
||||
Initialize (C,AngularDeflection,CurvatureDeflection,MinimumOfPoints,UTol,theMinLen, ACompOldBehavior);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +81,8 @@ GCPnts_TangentialDeflection::GCPnts_TangentialDeflection (
|
||||
const Standard_Real CurvatureDeflection,
|
||||
const Standard_Integer MinimumOfPoints,
|
||||
const Standard_Real UTol,
|
||||
const Standard_Real theMinLen)
|
||||
const Standard_Real theMinLen,
|
||||
const Standard_Boolean ACompOldBehavior)
|
||||
|
||||
{
|
||||
Initialize (C,
|
||||
@@ -89,7 +91,8 @@ GCPnts_TangentialDeflection::GCPnts_TangentialDeflection (
|
||||
AngularDeflection,
|
||||
CurvatureDeflection,
|
||||
MinimumOfPoints,
|
||||
UTol, theMinLen);
|
||||
UTol, theMinLen,
|
||||
ACompOldBehavior);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +108,8 @@ void GCPnts_TangentialDeflection::Initialize (
|
||||
const Standard_Real CurvatureDeflection,
|
||||
const Standard_Integer MinimumOfPoints,
|
||||
const Standard_Real UTol,
|
||||
const Standard_Real theMinLen)
|
||||
const Standard_Real theMinLen,
|
||||
const Standard_Boolean ACompOldBehavior)
|
||||
|
||||
{
|
||||
Initialize (C,
|
||||
@@ -114,7 +118,8 @@ void GCPnts_TangentialDeflection::Initialize (
|
||||
AngularDeflection,
|
||||
CurvatureDeflection,
|
||||
MinimumOfPoints,
|
||||
UTol, theMinLen);
|
||||
UTol, theMinLen,
|
||||
ACompOldBehavior);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,12 +136,14 @@ void GCPnts_TangentialDeflection::Initialize (
|
||||
const Standard_Real CurvatureDeflection,
|
||||
const Standard_Integer MinimumOfPoints,
|
||||
const Standard_Real UTol,
|
||||
const Standard_Real theMinLen)
|
||||
const Standard_Real theMinLen,
|
||||
const Standard_Boolean ACompOldBehavior)
|
||||
|
||||
{
|
||||
|
||||
Standard_ConstructionError_Raise_if (CurvatureDeflection <= Precision::Confusion () || AngularDeflection <= Precision::Angular (), "GCPnts_TangentialDeflection::Initialize - Zero Deflection")
|
||||
|
||||
aCompOldBehavior = ACompOldBehavior;
|
||||
parameters.Clear ();
|
||||
points .Clear ();
|
||||
if (FirstParameter < LastParameter) {
|
||||
@@ -195,9 +202,9 @@ void GCPnts_TangentialDeflection::PerformLinear (const TheCurve& C) {
|
||||
parameters.Append (firstu);
|
||||
points .Append (P);
|
||||
if (minNbPnts > 2) {
|
||||
Standard_Real Du = (lastu - firstu) / minNbPnts;
|
||||
Standard_Real Du = (lastu - firstu) / (minNbPnts - 1);
|
||||
Standard_Real U = firstu + Du;
|
||||
for (Standard_Integer i = 2; i <= minNbPnts; i++) {
|
||||
for (Standard_Integer i = 2; i < minNbPnts; i++) {
|
||||
D0 (C, U, P);
|
||||
parameters.Append (U);
|
||||
points .Append (P);
|
||||
@@ -287,18 +294,19 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
{
|
||||
//Si c'est une droite on verifie en calculant minNbPoints :
|
||||
Standard_Boolean IsLine = Standard_True;
|
||||
Standard_Boolean IsSequential = Standard_True;
|
||||
Standard_Integer NbPoints = (minNbPnts > 3) ? minNbPnts : 3;
|
||||
switch (C.GetType()) {
|
||||
case GeomAbs_BSplineCurve:
|
||||
{
|
||||
Handle_TheBSplineCurve BS = C.BSpline() ;
|
||||
NbPoints = Max(BS->Degree() + 1, NbPoints);
|
||||
NbPoints = Max(BS->NbPoles(), Max(BS->Degree() + 1, NbPoints));
|
||||
break;
|
||||
}
|
||||
case GeomAbs_BezierCurve:
|
||||
{
|
||||
Handle_TheBezierCurve BZ = C.Bezier();
|
||||
NbPoints = Max(BZ->Degree() + 1, NbPoints);
|
||||
NbPoints = Max(BZ->NbPoles(), Max(BZ->Degree() + 1, NbPoints));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -308,8 +316,8 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
for (i = 1; i <= NbInterv && IsLine; ++i)
|
||||
{
|
||||
// Avoid usage intervals out of [firstu, lastu].
|
||||
if ((Intervs(i+1) < firstu) ||
|
||||
(Intervs(i) > lastu))
|
||||
if ((Intervs(i+1) <= firstu) ||
|
||||
(Intervs(i) >= lastu))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -325,8 +333,8 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
Intervs(i + 1) = lastu;
|
||||
}
|
||||
|
||||
Standard_Real delta = (Intervs(i+1) - Intervs(i))/NbPoints;
|
||||
for (j = 1; j <= NbPoints && IsLine; ++j)
|
||||
Standard_Real delta = (Intervs(i+1) - Intervs(i))/(NbPoints-1);
|
||||
for (j = 1; j < NbPoints && IsLine; ++j)
|
||||
{
|
||||
param = Intervs(i) + j*delta;
|
||||
D0 (C, param, MiddlePoint);
|
||||
@@ -336,6 +344,13 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
{
|
||||
const Standard_Real aAngle = V2.CrossMagnitude(V1)/(L1*L2);
|
||||
IsLine = (aAngle < ATol);
|
||||
|
||||
// Check if points on line are subsequent
|
||||
if(IsLine && IsSequential)
|
||||
{
|
||||
gp_XYZ V3 = LastPoint.XYZ() - MiddlePoint.XYZ();
|
||||
IsSequential = (V3.Dot(V2) >= 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,7 +360,18 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
parameters.Clear();
|
||||
points .Clear();
|
||||
|
||||
const Standard_Integer oldMinNbPoints = minNbPnts;
|
||||
if(!IsSequential)
|
||||
{
|
||||
minNbPnts = NbPoints;
|
||||
}
|
||||
|
||||
PerformLinear(C);
|
||||
|
||||
if(!IsSequential)
|
||||
{
|
||||
minNbPnts = oldMinNbPoints;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -389,6 +415,7 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
Standard_Boolean MorePoints = Standard_True;
|
||||
Standard_Real U2 = firstu;
|
||||
Standard_Real AngleMax = angularDeflection * 0.5; //car on prend le point milieu
|
||||
Standard_Real MinLen2 = myMinLen * myMinLen;
|
||||
Standard_Integer aIdx[2] = {Intervs.Lower(), Intervs.Lower()}; // Indexes of intervals of U1 and U2, used to handle non-uniform case.
|
||||
Standard_Boolean isNeedToCheck = Standard_False;
|
||||
gp_Pnt aPrevPoint = points.Last();
|
||||
@@ -432,17 +459,17 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
|
||||
V1 = (CurrentPoint.XYZ() - aPrevPoint.XYZ()); //Critere de fleche
|
||||
V2 = (MiddlePoint.XYZ() - aPrevPoint.XYZ());
|
||||
L1 = V1.Modulus ();
|
||||
L1 = V1.SquareModulus ();
|
||||
|
||||
FCoef = (L1 > myMinLen) ?
|
||||
V1.CrossMagnitude(V2)/(L1*curvatureDeflection) : 0.0;
|
||||
FCoef = (L1 > MinLen2) ?
|
||||
V1.CrossMagnitude(V2)/(Sqrt(L1)*curvatureDeflection) : 0.0;
|
||||
|
||||
V1 = (CurrentPoint.XYZ() - MiddlePoint.XYZ()); //Critere d'angle
|
||||
L1 = V1.Modulus ();
|
||||
L2 = V2.Modulus ();
|
||||
if (L1 > myMinLen && L2 > myMinLen)
|
||||
L1 = V1.SquareModulus ();
|
||||
L2 = V2.SquareModulus ();
|
||||
if (L1 > MinLen2 && L2 > MinLen2)
|
||||
{
|
||||
Standard_Real angg = V1.CrossMagnitude(V2) / (L1 * L2);
|
||||
Standard_Real angg = V1.CrossMagnitude(V2) / Sqrt(L1 * L2);
|
||||
ACoef = angg / AngleMax;
|
||||
}
|
||||
else
|
||||
@@ -585,8 +612,10 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
}
|
||||
}
|
||||
//Additional check for intervals
|
||||
Standard_Real MinLen2 = myMinLen * myMinLen;
|
||||
Standard_Integer MaxNbp = 10 * Nbp;
|
||||
|
||||
const Standard_Real AngleMaxFixed = aCompOldBehavior ? AngleMax : Sqrt(1.0 - AngleMax * AngleMax);
|
||||
|
||||
for(i = 1; i < Nbp; ++i)
|
||||
{
|
||||
U1 = parameters(i);
|
||||
@@ -594,14 +623,16 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
// Check maximal deflection on interval;
|
||||
Standard_Real dmax = 0.;
|
||||
Standard_Real umax = 0.;
|
||||
Standard_Real amax = 0.;
|
||||
EstimDefl(C, U1, U2, dmax, umax);
|
||||
const gp_Pnt& P1 = points(i);
|
||||
const gp_Pnt& P2 = points(i+1);
|
||||
D0(C, umax, MiddlePoint);
|
||||
amax = EstimAngl(P1, MiddlePoint, P2);
|
||||
if(dmax > curvatureDeflection || amax > AngleMax)
|
||||
|
||||
Standard_Real amax = aCompOldBehavior ? EstimAnglOld(P1, MiddlePoint, P2) : EstimAngl(P1, MiddlePoint, P2);
|
||||
|
||||
if(dmax > curvatureDeflection || (aCompOldBehavior ? amax - AngleMaxFixed : AngleMaxFixed - amax) > ATol)
|
||||
{
|
||||
|
||||
if(umax - U1 > uTol && U2 - umax > uTol)
|
||||
{
|
||||
if (P1.SquareDistance(MiddlePoint) > MinLen2 && P2.SquareDistance(MiddlePoint) > MinLen2)
|
||||
@@ -638,7 +669,7 @@ void GCPnts_TangentialDeflection::EstimDefl (const TheCurve& C,
|
||||
Standard_Real reltol = Max(1.e-3, 2.*uTol/((Abs(U1) + Abs(U2))));
|
||||
//
|
||||
math_BrentMinimum anOptLoc(reltol, aNbIter, uTol);
|
||||
anOptLoc.Perform(aFunc, U1, (U1+U2)/2., U2);
|
||||
anOptLoc.Perform(aFunc, U1, (U1+U2)*0.5, U2);
|
||||
if(anOptLoc.IsDone())
|
||||
{
|
||||
MaxDefl = Sqrt(-anOptLoc.Minimum());
|
||||
|
@@ -1032,7 +1032,7 @@ static Standard_Integer crvtpoints (Draw_Interpretor& di, Standard_Integer n, co
|
||||
defl = Draw::Atof(a[3]);
|
||||
|
||||
if(n > 3)
|
||||
angle = Draw::Atof(a[4]);
|
||||
angle = Draw::Atof(a[4]) * M_PI / 180;
|
||||
|
||||
GCPnts_TangentialDeflection PntGen(aHCurve->Curve(), angle, defl, 2);
|
||||
|
||||
|
@@ -128,7 +128,8 @@ void IVtkOCC_ShapeMesher::meshShape()
|
||||
Handle(BRepMesh_DiscretRoot) anAlgo;
|
||||
anAlgo = BRepMesh_DiscretFactory::Get().Discret (anOcctShape,
|
||||
aDeflection,
|
||||
GetDeviationAngle());
|
||||
GetDeviationAngle(),
|
||||
GetTDOldBehavior());
|
||||
if (!anAlgo.IsNull())
|
||||
{
|
||||
anAlgo->Perform();
|
||||
@@ -455,12 +456,13 @@ static void FindLimits (const Adaptor3d_Curve& theCurve,
|
||||
//! @param [in] theU2 maximal curve parameter value
|
||||
//! @param [out] thePoints the container for generated polyline
|
||||
//================================================================
|
||||
static void DrawCurve (Adaptor3d_Curve& theCurve,
|
||||
const Standard_Real theDeflection,
|
||||
const Standard_Real theAngle,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
IVtk_Polyline& thePoints)
|
||||
static void DrawCurve (Adaptor3d_Curve& theCurve,
|
||||
const Standard_Real theDeflection,
|
||||
const Standard_Real theAngle,
|
||||
const Standard_Boolean theTDOldBehavior,
|
||||
const Standard_Real theU1,
|
||||
const Standard_Real theU2,
|
||||
IVtk_Polyline& thePoints)
|
||||
{
|
||||
switch (theCurve.GetType())
|
||||
{
|
||||
@@ -493,7 +495,7 @@ static void DrawCurve (Adaptor3d_Curve& theCurve,
|
||||
anU1 = Max(anU1, anU1);
|
||||
anU2 = Min(anU2, anU2);
|
||||
|
||||
GCPnts_TangentialDeflection anAlgo (theCurve, anU1, anU2, theAngle, theDeflection);
|
||||
GCPnts_TangentialDeflection anAlgo (theCurve, anU1, anU2, theAngle, theDeflection, theTDOldBehavior);
|
||||
NumberOfPoints = anAlgo.NbPoints();
|
||||
|
||||
if (NumberOfPoints > 0)
|
||||
@@ -766,7 +768,7 @@ void IVtkOCC_ShapeMesher::buildIsoLines (const Handle(BRepAdaptor_HSurface)& the
|
||||
if (aB2 - aB1 > Precision::Confusion())
|
||||
{
|
||||
IVtk_Polyline aPoints;
|
||||
DrawCurve (aGeomCurve, aDeflection, anAngle, aB1, aB2, aPoints);
|
||||
DrawCurve (aGeomCurve, aDeflection, anAngle, GetTDOldBehavior(), aB1, aB2, aPoints);
|
||||
thePolylines.Append (aPoints);
|
||||
}
|
||||
}
|
||||
@@ -784,7 +786,7 @@ void IVtkOCC_ShapeMesher::buildIsoLines (const Handle(BRepAdaptor_HSurface)& the
|
||||
if (aB2 - aB1>Precision::Confusion())
|
||||
{
|
||||
IVtk_Polyline aPoints;
|
||||
DrawCurve (anIso, aDeflection, anAngle, aB1, aB2, aPoints);
|
||||
DrawCurve (anIso, aDeflection, anAngle, GetTDOldBehavior(), aB1, aB2, aPoints);
|
||||
thePolylines.Append (aPoints);
|
||||
}
|
||||
}
|
||||
|
@@ -50,9 +50,11 @@ public:
|
||||
IVtkOCC_ShapeMesher (const Standard_Real& theDevCoeff = 0.0001,
|
||||
const Standard_Real& theDevAngle = 12.0 * M_PI / 180.0,
|
||||
const Standard_Integer theNbUIsos = 1,
|
||||
const Standard_Integer theNbVIsos = 1)
|
||||
const Standard_Integer theNbVIsos = 1,
|
||||
const Standard_Boolean theTDOldBehavior = Standard_True)
|
||||
: myDevCoeff (theDevCoeff),
|
||||
myDevAngle (theDevAngle),
|
||||
myTDOldBehavior(theTDOldBehavior),
|
||||
myDeflection (0.0)
|
||||
{
|
||||
myNbIsos[0] = theNbUIsos;
|
||||
@@ -85,6 +87,13 @@ public:
|
||||
return myDevAngle;
|
||||
}
|
||||
|
||||
//! Returns tangential deflection behavior used in the algorithm
|
||||
//! @return tangential deflection behavior
|
||||
Standard_Boolean GetTDOldBehavior() const
|
||||
{
|
||||
return myTDOldBehavior;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Executes the mesh generation algorithms. To be defined in implementation class.
|
||||
Standard_EXPORT virtual void internalBuild() Standard_OVERRIDE;
|
||||
@@ -186,6 +195,7 @@ private:
|
||||
Standard_Real myDevAngle;
|
||||
mutable Standard_Real myDeflection;
|
||||
Standard_Integer myNbIsos[2];
|
||||
Standard_Boolean myTDOldBehavior;
|
||||
};
|
||||
|
||||
#endif // __IVTKOCC_SHAPEMESHER_H__
|
||||
|
19
tests/bugs/modalg_7/bug30020
Normal file
19
tests/bugs/modalg_7/bug30020
Normal file
@@ -0,0 +1,19 @@
|
||||
puts "========"
|
||||
puts "0030020: Incorrect bspline visualization"
|
||||
puts "========\n"
|
||||
|
||||
set F [open $imagedir/pnts w]
|
||||
puts $F "3 3d"
|
||||
puts $F "0 0 0"
|
||||
puts $F "2 0 0"
|
||||
puts $F "1 0 0"
|
||||
close $F
|
||||
interpol c $imagedir/pnts
|
||||
file delete $imagedir/pnts
|
||||
|
||||
set out [crvtpoints r c 0.1 1]
|
||||
if {[lindex $out 3] != 3} {
|
||||
puts "Error: number of points is not equal to 3"
|
||||
}
|
||||
|
||||
checklength r -l 3
|
@@ -12,7 +12,7 @@ subshape a e 8
|
||||
mkcurve c a_8
|
||||
|
||||
set deflection 0.001
|
||||
set info [crvtpoints r c ${deflection} pi/6]
|
||||
set info [crvtpoints r c ${deflection} 30]
|
||||
|
||||
set str1 "Nb points +: +(\[-0-9.+eE\]+)\n"
|
||||
set str2 "Max defl: +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)"
|
||||
|
@@ -16,7 +16,7 @@ donly a_1
|
||||
fit
|
||||
|
||||
set deflection 1.
|
||||
set angular_deflection 0.349
|
||||
set angular_deflection 20
|
||||
set info [crvtpoints r c ${deflection} ${angular_deflection}]
|
||||
|
||||
set str1 "Nb points +: +(\[-0-9.+eE\]+)\n"
|
||||
|
@@ -12,7 +12,7 @@ restore [locate_data_file bug27108_Left.brep] a
|
||||
|
||||
explode a e
|
||||
mkcurve c a_1
|
||||
set bug_info [crvtpoints result c $bug27108_requested_deflection 20*pi/180]
|
||||
set bug_info [crvtpoints result c $bug27108_requested_deflection 20]
|
||||
|
||||
smallview
|
||||
donly c result
|
||||
|
Reference in New Issue
Block a user