GCPnts_AbscissaType.hxx
GCPnts_DeflectionType.hxx
GCPnts_QuasiUniformAbscissa.cxx
-GCPnts_QuasiUniformAbscissa.pxx
GCPnts_QuasiUniformAbscissa.hxx
GCPnts_QuasiUniformDeflection.cxx
GCPnts_QuasiUniformDeflection.pxx
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//#include <GCPnts_QuasiUniformAbscissa.ixx>
-
-#include <StdFail_NotDone.hxx>
-#include <Standard_DomainError.hxx>
-#include <Standard_OutOfRange.hxx>
-#include <Standard_ConstructionError.hxx>
#include <GCPnts_QuasiUniformAbscissa.hxx>
+
+#include <GCPnts_TCurveTypes.hxx>
#include <GCPnts_UniformAbscissa.hxx>
-#include <Adaptor3d_Curve.hxx>
-#include <Adaptor2d_Curve2d.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
+#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array1OfPnt.hxx>
-#include <gp_Pnt.hxx>
-
-#ifdef OCCT_DEBUG
-//#include <DrawTrSurf.hxx>
-
-//static Standard_Integer compteur = 0;
-#endif
//=======================================================================
//function : GCPnts_QuasiUniformAbscissa
-//purpose :
+//purpose :
//=======================================================================
-
-GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa ()
- :myDone(Standard_False),
- myNbPoints(0)
+GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa()
+: myDone (Standard_False),
+ myNbPoints (0)
{
+ //
}
-#include <Geom_BezierCurve.hxx>
-#include <Geom_BSplineCurve.hxx>
-
-#define TheCurve Adaptor3d_Curve
-#define Handle_TheBezierCurve Handle(Geom_BezierCurve)
-#define Handle_TheBSplineCurve Handle(Geom_BSplineCurve)
-#define TheArray1OfPnt TColgp_Array1OfPnt
-#define ThePnt gp_Pnt
+//=======================================================================
+//function : GCPnts_QuasiUniformAbscissa
+//purpose :
+//=======================================================================
+GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints)
+: myDone (Standard_False),
+ myNbPoints (0)
+{
+ Initialize (theC, theNbPoints);
+}
-#include "GCPnts_QuasiUniformAbscissa.pxx"
+//=======================================================================
+//function : GCPnts_QuasiUniformAbscissa
+//purpose :
+//=======================================================================
+GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1,
+ const Standard_Real theU2)
+: myDone (Standard_False),
+ myNbPoints (0)
+{
+ Initialize (theC, theNbPoints, theU1, theU2);
+}
-#undef TheCurve
-#undef Handle_TheBezierCurve
-#undef Handle_TheBSplineCurve
-#undef TheArray1OfPnt
-#undef ThePnt
+//=======================================================================
+//function : GCPnts_QuasiUniformAbscissa
+//purpose :
+//=======================================================================
+GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints)
+: myDone (Standard_False),
+ myNbPoints (0)
+{
+ Initialize (theC, theNbPoints);
+}
-#include <Geom2d_BezierCurve.hxx>
-#include <Geom2d_BSplineCurve.hxx>
+//=======================================================================
+//function : GCPnts_QuasiUniformAbscissa
+//purpose :
+//=======================================================================
+GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1,
+ const Standard_Real theU2)
+: myDone (Standard_False),
+ myNbPoints (0)
+{
+ Initialize (theC, theNbPoints, theU1, theU2);
+}
-#define TheCurve Adaptor2d_Curve2d
-#define Handle_TheBezierCurve Handle(Geom2d_BezierCurve)
-#define Handle_TheBSplineCurve Handle(Geom2d_BSplineCurve)
-#define TheArray1OfPnt TColgp_Array1OfPnt2d
-#define ThePnt gp_Pnt2d
+//=======================================================================
+//function : Initialize
+//purpose :
+//=======================================================================
+void GCPnts_QuasiUniformAbscissa::Initialize (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints)
+{
+ Initialize (theC, theNbPoints, theC.FirstParameter(), theC.LastParameter());
+}
-#include "GCPnts_QuasiUniformAbscissa.pxx"
+//=======================================================================
+//function : Initialize
+//purpose :
+//=======================================================================
+void GCPnts_QuasiUniformAbscissa::Initialize (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints)
+{
+ Initialize (theC, theNbPoints, theC.FirstParameter(), theC.LastParameter());
+}
+//=======================================================================
+//function : Initialize
+//purpose :
+//=======================================================================
+void GCPnts_QuasiUniformAbscissa::Initialize (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1,
+ const Standard_Real theU2)
+{
+ initialize (theC, theNbPoints, theU1, theU2);
+}
+//=======================================================================
+//function : Initialize
+//purpose :
+//=======================================================================
+void GCPnts_QuasiUniformAbscissa::Initialize (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1,
+ const Standard_Real theU2)
+{
+ initialize (theC, theNbPoints, theU1, theU2);
+}
+//=======================================================================
+//function : initialize
+//purpose :
+//=======================================================================
+template<class TheCurve>
+void GCPnts_QuasiUniformAbscissa::initialize (const TheCurve& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1,
+ const Standard_Real theU2)
+{
+ if (theC.GetType() != GeomAbs_BezierCurve
+ && theC.GetType() != GeomAbs_BSplineCurve)
+ {
+ GCPnts_UniformAbscissa aUA (theC, theNbPoints, theU1, theU2);
+ myDone = aUA.IsDone();
+ myNbPoints = aUA.NbPoints();
+ myParams = new TColStd_HArray1OfReal (1, myNbPoints);
+ for (Standard_Integer aPntIter = 1 ; aPntIter <= myNbPoints; ++aPntIter)
+ {
+ myParams->SetValue (aPntIter, aUA.Parameter (aPntIter));
+ }
+ return;
+ }
+
+ Standard_ConstructionError_Raise_if (theNbPoints <= 1, "GCPnts_QuasiUniformAbscissa::Initialize(), number of points should be >= 2");
+
+ // evaluate the approximative length of the 3dCurve
+ myNbPoints = theNbPoints;
+ Standard_Real aLength = 0.0;
+ const Standard_Real dU = (theU2 - theU1) / (2 * theNbPoints - 1);
+
+ TColgp_Array1OfPnt2d aLP (1, 2 * theNbPoints); // table Length <-> Param
+ typename GCPnts_TCurveTypes<TheCurve>::Point aP1, aP2;
+ aP1 = theC.Value (theU1);
+
+ // On additionne toutes les distances
+ for (Standard_Integer i = 0; i < 2 * theNbPoints; ++i)
+ {
+ aP2 = theC.Value (theU1 + i * dU);
+ const Standard_Real aDist = aP1.Distance (aP2);
+ aLength += aDist;
+ aLP(i+1) = gp_Pnt2d (aLength, theU1 + (i * dU));
+ aP1 = aP2;
+ }
+
+ // On cherche a mettre NbPoints dans la curve.
+ // on met les points environ a Length/NbPoints.
+ if (IsEqual (aLength, 0.0))
+ { //use usual analytical grid
+ Standard_Real aStep = (theU2 - theU1) / (theNbPoints - 1);
+ myParams = new TColStd_HArray1OfReal (1, theNbPoints);
+ myParams->SetValue (1, theU1);
+ for (Standard_Integer i = 2; i < theNbPoints; ++i)
+ {
+ myParams->SetValue (i, theU1 + aStep * (i - 1));
+ }
+ }
+ else
+ {
+ const Standard_Real aDCorde = aLength / (theNbPoints - 1);
+ Standard_Real aCorde = aDCorde;
+ Standard_Integer anIndex = 1;
+ myParams = new TColStd_HArray1OfReal (1, theNbPoints);
+ myParams->SetValue (1, theU1);
+ for (Standard_Integer i = 2; i < theNbPoints; ++i)
+ {
+ while (aLP (anIndex).X() < aCorde)
+ {
+ ++anIndex;
+ }
+ Standard_Real anAlpha = (aCorde - aLP(anIndex - 1).X()) / (aLP (anIndex).X() - aLP (anIndex-1).X());
+ Standard_Real aU = aLP (anIndex - 1).Y() + anAlpha * (aLP (anIndex).Y() - aLP (anIndex-1).Y());
+ myParams->SetValue (i, aU);
+ aCorde = i * aDCorde;
+ }
+ }
+
+ myParams->SetValue (theNbPoints, theU2);
+ myDone = Standard_True;
+}
#include <StdFail_NotDone.hxx>
#include <TColStd_HArray1OfReal.hxx>
-class Standard_DomainError;
-class Standard_ConstructionError;
-class Standard_OutOfRange;
-class StdFail_NotDone;
class Adaptor3d_Curve;
class Adaptor2d_Curve2d;
//! This class provides an algorithm to compute a uniform abscissa
-//! distribution of points on a curve, i.e. a sequence of
-//! equidistant points. The distance between two
-//! consecutive points is measured along the curve.
-//! The distribution is defined:
-//! - either by the curvilinear distance between two consecutive points
-//! - or by a number of points.
+//! distribution of points on a curve, i.e. a sequence of equidistant points.
+//! The distance between two consecutive points is measured along the curve.
+//!
+//! The distribution is defined by a number of points.
class GCPnts_QuasiUniformAbscissa
{
public:
DEFINE_STANDARD_ALLOC
-
- //! Constructs an empty algorithm. To define the problem
- //! to be solved, use the function Initialize.
+ //! Constructs an empty algorithm.
+ //! To define the problem to be solved, use the function Initialize.
Standard_EXPORT GCPnts_QuasiUniformAbscissa();
-
+
//! Computes a uniform abscissa distribution of points
- //! - on the curve C where Abscissa is the curvilinear distance between
+ //! - on the curve where Abscissa is the curvilinear distance between
//! two consecutive points of the distribution.
- Standard_EXPORT GCPnts_QuasiUniformAbscissa(const Adaptor3d_Curve& C, const Standard_Integer NbPoints);
-
+ Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints);
+
//! Computes a uniform abscissa distribution of points
- //! on the part of curve C limited by the two parameter values U1 and U2,
+ //! on the part of curve limited by the two parameter values theU1 and theU2,
//! where Abscissa is the curvilinear distance between
//! two consecutive points of the distribution.
//! The first point of the distribution is either the origin of
- //! curve C or the point of parameter U1. The following
- //! points are computed such that the curvilinear
+ //! curve or the point of parameter theU1.
+ //! The following points are computed such that the curvilinear
//! distance between two consecutive points is equal to Abscissa.
//! The last point of the distribution is either the end
- //! point of curve C or the point of parameter U2.
+ //! point of curve or the point of parameter theU2.
//! However the curvilinear distance between this last
- //! point and the point just preceding it in the distribution
- //! is, of course, generally not equal to Abscissa.
- //! Use the function IsDone to verify that the
- //! computation was successful, the function NbPoints
- //! to obtain the number of points of the computed
- //! distribution, and the function Parameter to read the
- //! parameter of each point.
+ //! point and the point just preceding it in the distribution is,
+ //! of course, generally not equal to Abscissa.
+ //! Use the function IsDone() to verify that the computation was successful,
+ //! the function NbPoints() to obtain the number of points of the computed distribution,
+ //! and the function Parameter() to read the parameter of each point.
+ //!
//! Warning
- //! The roles of U1 and U2 are inverted if U1 > U2 .
+ //! The roles of theU1 and theU2 are inverted if theU1 > theU2.
//! Warning
- //! C is an adapted curve, that is, an object which is an
- //! interface between:
+ //! theC is an adapted curve, that is, an object which is an interface between:
//! - the services provided by either a 2D curve from
- //! the package Geom2d (in the case of an
- //! Adaptor2d_Curve2d curve) or a 3D curve from
- //! the package Geom (in the case of an Adaptor3d_Curve curve),
+ //! the package Geom2d (in the case of an Adaptor2d_Curve2d curve)
+ //! or a 3D curve from the package Geom (in the case of an Adaptor3d_Curve curve),
//! - and those required on the curve by the computation algorithm.
- Standard_EXPORT GCPnts_QuasiUniformAbscissa(const Adaptor3d_Curve& C, const Standard_Integer NbPoints, const Standard_Real U1, const Standard_Real U2);
-
- //! Initialize the algorithms with <C>, <NbPoints> and
- Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Integer NbPoints);
-
- //! Initialize the algorithms with <C>, <Abscissa>, <U1>,
- //! <U2>.
- Standard_EXPORT void Initialize (const Adaptor3d_Curve& C, const Standard_Integer NbPoints, const Standard_Real U1, const Standard_Real U2);
-
- //! Computes a uniform abscissa distribution of points on
- //! the Curve2d <C>.
- //! <NbPoints> defines the nomber of desired points.
- Standard_EXPORT GCPnts_QuasiUniformAbscissa(const Adaptor2d_Curve2d& C, const Standard_Integer NbPoints);
-
- //! Computes a Uniform abscissa distribution of points
- //! on a part of the Curve2d <C>.
- Standard_EXPORT GCPnts_QuasiUniformAbscissa(const Adaptor2d_Curve2d& C, const Standard_Integer NbPoints, const Standard_Real U1, const Standard_Real U2);
-
- //! Initialize the algorithms with <C>, <NbPoints> and
- Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Integer NbPoints);
-
- //! Initialize the algorithms with <C>, <Abscissa>, <U1>,
- //! <U2>.
- Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& C, const Standard_Integer NbPoints, const Standard_Real U1, const Standard_Real U2);
+ //! @param theC [in] input 3D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ //! @param theU1 [in] first parameter on curve
+ //! @param theU2 [in] last parameter on curve
+ Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1, const Standard_Real theU2);
+
+ //! Initialize the algorithms with 3D curve and target number of points.
+ //! @param theC [in] input 3D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints);
+
+ //! Initialize the algorithms with 3D curve, target number of points and curve parameter range.
+ //! @param theC [in] input 3D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ //! @param theU1 [in] first parameter on curve
+ //! @param theU2 [in] last parameter on curve
+ Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1, const Standard_Real theU2);
+
+ //! Computes a uniform abscissa distribution of points on the 2D curve.
+ //! @param theC [in] input 2D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints);
+
+ //! Computes a Uniform abscissa distribution of points on a part of the 2D curve.
+ //! @param theC [in] input 2D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ //! @param theU1 [in] first parameter on curve
+ //! @param theU2 [in] last parameter on curve
+ Standard_EXPORT GCPnts_QuasiUniformAbscissa (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1, const Standard_Real theU2);
+
+ //! Initialize the algorithms with 2D curve and target number of points.
+ //! @param theC [in] input 2D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints);
+ //! Initialize the algorithms with 2D curve, target number of points and curve parameter range.
+ //! @param theC [in] input 2D curve
+ //! @param theNbPoints [in] defines the number of desired points
+ //! @param theU1 [in] first parameter on curve
+ //! @param theU2 [in] last parameter on curve
+ Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1, const Standard_Real theU2);
+
//! Returns true if the computation was successful.
//! IsDone is a protection against:
//! - non-convergence of the algorithm
return myParams->Value (Index);
}
+private:
+
+ //! This function divides given curve on the several parts with equal length.
+ //! It returns array of parameters in the control points.
+ template<class TheCurve>
+ void initialize (const TheCurve& theC,
+ const Standard_Integer theNbPoints,
+ const Standard_Real theU1, const Standard_Real theU2);
+
private:
Standard_Boolean myDone;
Standard_Integer myNbPoints;
+++ /dev/null
-// Created on: 1996-08-22
-// Created by: Stagiaire Mary FABIEN
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : GCPnts_QuasiUniformAbscissa
-//purpose :
-//=======================================================================
-
-GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa(const TheCurve& C,
- const Standard_Integer NbPoints)
-{
- Initialize(C, NbPoints);
-}
-
-//=======================================================================
-//function : GCPnts_QuasiUniformAbscissa
-//purpose :
-//=======================================================================
-
-GCPnts_QuasiUniformAbscissa::GCPnts_QuasiUniformAbscissa(const TheCurve& C,
- const Standard_Integer NbPoints,
- const Standard_Real U1,
- const Standard_Real U2)
-{
- Initialize(C, NbPoints, U1, U2);
-}
-
-//=======================================================================
-//function : Initialize
-//purpose :
-//=======================================================================
-
-void GCPnts_QuasiUniformAbscissa::Initialize(const TheCurve& C,
- const Standard_Integer NbPoints)
-{
- Initialize(C, NbPoints, C.FirstParameter(),
- C.LastParameter());
-}
-
-
-//=======================================================================
-//function : Initialize
-//purpose : This function divides given curve on the several parts with
-// equal length. It returns array of parameters in the
-// control points.
-//=======================================================================
-void GCPnts_QuasiUniformAbscissa::Initialize(const TheCurve& C,
- const Standard_Integer NbPoints,
- const Standard_Real U1,
- const Standard_Real U2)
-{
- Standard_Integer i;
- if ((C.GetType() != GeomAbs_BezierCurve) && (C.GetType() != GeomAbs_BSplineCurve))
- {
- GCPnts_UniformAbscissa UA(C,NbPoints,U1,U2);
- myDone = UA.IsDone();
- myNbPoints = UA.NbPoints();
- myParams = new TColStd_HArray1OfReal(1,myNbPoints);
- for( i = 1 ; i <= myNbPoints ; i++ )
- myParams->SetValue(i,UA.Parameter(i));
-#ifdef OCCT_DEBUG
-
-// char name [100];
-// for( i = 1 ; i <= NbPoints ; i++ ) {
-// sprintf(name,"%s_%d","pnt2d",i+(compteur++));
-// DrawTrSurf::Set(name,C->Value(UA.Parameter(i)));
-// }
-#endif
- }
- else
- {
- Standard_ConstructionError_Raise_if (NbPoints <= 1,
- "GCPnts_QuasiUniformAbscissa::Initialize() - number of points should be >= 2");
-
-// evaluate the approximative length of the 3dCurve
- myNbPoints = NbPoints;
- Standard_Real Length = 0.;
- Standard_Real Dist, dU = (U2 - U1) / ( 2*NbPoints - 1);
-
- TColgp_Array1OfPnt2d LP(1,2*NbPoints); // tableau Longueur <-> Param
- ThePnt P1, P2;
- P1 = C.Value(U1);
-
-// On additionne toutes les distances
- for ( i = 0; i < 2*NbPoints ; i++) {
- P2 = C.Value(U1 + i*dU);
- Dist = P1.Distance(P2);
- Length += Dist;
- LP(i+1) = gp_Pnt2d( Length, U1 + (i*dU));
- P1 = P2;
- }
-
-// On cherche a mettre NbPoints dans la curve.
-// on met les points environ a Length/NbPoints.
-
- if(IsEqual(Length, 0.0))
- {//use usual analytical grid
- Standard_Real aStep = (U2 - U1) / (NbPoints - 1);
- myParams = new TColStd_HArray1OfReal(1,NbPoints);
- myParams->SetValue(1,U1);
- for ( i = 2; i < NbPoints; i++)
- {
- myParams->SetValue(i, U1 + aStep*(i-1));
- }
- }
- else
- {
- Standard_Real DCorde = Length / ( NbPoints - 1);
- Standard_Real Corde = DCorde;
- Standard_Integer Index = 1;
- Standard_Real U, Alpha;
- myParams = new TColStd_HArray1OfReal(1,NbPoints);
- myParams->SetValue(1,U1);
- for ( i = 2; i < NbPoints; i++)
- {
- while ( LP(Index).X() < Corde) Index ++;
- Alpha = (Corde - LP(Index-1).X()) / (LP(Index).X() - LP(Index-1).X());
- U = LP(Index-1).Y() + Alpha * ( LP(Index).Y() - LP(Index-1).Y());
- myParams->SetValue(i,U);
- Corde = i*DCorde;
- }
- }
-
- myParams->SetValue(NbPoints,U2);
- myDone = Standard_True;
- }
-}
-