Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:58

0001 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _ApproxInt_KnotTools_HeaderFile
0015 #define _ApproxInt_KnotTools_HeaderFile
0016 
0017 #include <Standard_DefineAlloc.hxx>
0018 #include <Standard_Macro.hxx>
0019 #include <Standard_Boolean.hxx>
0020 #include <Standard_Real.hxx>
0021 #include <Standard_Integer.hxx>
0022 #include <TColgp_Array1OfPnt2d.hxx>
0023 #include <NCollection_Sequence.hxx>
0024 #include <NCollection_List.hxx>
0025 #include <math_Vector.hxx>
0026 #include <TColgp_Array1OfPnt.hxx>
0027 #include <TColStd_Array1OfReal.hxx>
0028 #include <NCollection_LocalArray.hxx>
0029 #include <NCollection_Vector.hxx>
0030 #include <Approx_ParametrizationType.hxx>
0031 
0032 class IntPatch_WLine;
0033 
0034 // Corresponds for debug information output.
0035 // Debug information is also printed when OCCT_DEBUG defined.
0036 //#define APPROXINT_KNOTTOOLS_DEBUG
0037 
0038 //! This class intended to build knots sequence on discrete set of points for further approximation into bspline curve.
0039 //!
0040 //! Short description of algorithm:
0041 //! 1) Build discrete curvature on points set.
0042 //! 2) According to special rules build draft knots sequence.
0043 //! 3) Filter draft sequence to build output sequence.
0044 //!
0045 //! For more details look at:
0046 //! Anshuman Razdan - Knot Placement for B-Spline curve Approximation.
0047 class ApproxInt_KnotTools
0048 {
0049 public:
0050 
0051   DEFINE_STANDARD_ALLOC
0052 
0053   //! Main function to build optimal knot sequence.
0054   //! At least one set from (thePntsXYZ, thePntsU1V1, thePntsU2V2) should exist.
0055   //! @param thePntsXYZ - Set of 3d points.
0056   //! @param thePntsU1V1 - Set of 2d points.
0057   //! @param thePntsU2V2 - Set of 2d points.
0058   //! @param thePars - Expected parameters associated with set.
0059   //! @param theApproxXYZ - Flag, existence of 3d set.
0060   //! @param theApproxU1V1 - Flag existence of first 2d set.
0061   //! @param theApproxU2V2 - Flag existence of second 2d set.
0062   //! @param theMinNbPnts - Minimal number of points per knot interval.
0063   //! @param theKnots - output knots sequence.
0064   Standard_EXPORT static void BuildKnots(const TColgp_Array1OfPnt& thePntsXYZ,
0065                                          const TColgp_Array1OfPnt2d& thePntsU1V1,
0066                                          const TColgp_Array1OfPnt2d& thePntsU2V2,
0067                                          const math_Vector& thePars,
0068                                          const Standard_Boolean theApproxXYZ,
0069                                          const Standard_Boolean theApproxU1V1,
0070                                          const Standard_Boolean theApproxU2V2,
0071                                          const Standard_Integer theMinNbPnts,
0072                                          NCollection_Vector<Standard_Integer>& theKnots);
0073 
0074   //! Builds discrete curvature
0075   Standard_EXPORT static void BuildCurvature(
0076     const NCollection_LocalArray<Standard_Real>& theCoords,
0077     const Standard_Integer theDim,
0078     const math_Vector& thePars,
0079     TColStd_Array1OfReal& theCurv,
0080     Standard_Real& theMaxCurv);
0081 
0082   //! Defines preferable parametrization type for theWL 
0083   Standard_EXPORT static Approx_ParametrizationType DefineParType(const Handle(IntPatch_WLine)& theWL,
0084     const Standard_Integer theFpar, const Standard_Integer theLpar,
0085     const Standard_Boolean theApproxXYZ,
0086     const Standard_Boolean theApproxU1V1,
0087     const Standard_Boolean theApproxU2V2);
0088 
0089 
0090 private:
0091 
0092   //! Compute indices of knots:
0093   //!
0094   //! I: Build discrete curvature in points set,
0095   //! using outer product of two vectors.
0096   //!
0097   //! II: Put knots in points which has extremity on discrete curvature.
0098   //!
0099   //! III: Put knots in monotone intervals of curvature.
0100   //!
0101   //! IV: Put additional knots near extrema points.
0102   static void ComputeKnotInds(const NCollection_LocalArray<Standard_Real>& theCoords,
0103                               const Standard_Integer theDim,
0104                               const math_Vector& thePars,
0105                               NCollection_Sequence<Standard_Integer>& theInds);
0106 
0107   //! Insert knots before index I.
0108   //!
0109   //! I: Check curvature change:
0110   //! if ( maxCurvature / minCurvature ) of current interval greater than 
0111   //! threshold value, then stop and use upper index as knot.
0112   //!
0113   //! II: Check midpoint criteria:
0114   //! If exist point between two knot indices with angle greater than
0115   //! threshold value, then stop and put this index as knot.
0116   static Standard_Boolean InsKnotBefI(const Standard_Integer theI,
0117                                       const TColStd_Array1OfReal& theCurv,
0118                                       const NCollection_LocalArray<Standard_Real>& theCoords,
0119                                       const Standard_Integer theDim, 
0120                                       NCollection_Sequence<Standard_Integer>& theInds,
0121                                       const Standard_Boolean ChkCurv);
0122 
0123   //! Perform knots filtration.
0124   //!
0125   //! I: Filter too big number of points per knot interval.
0126   //!
0127   //! II: Filter points with too small amount of points per knot interval.
0128   //!
0129   //! III: Fill Last Knot.
0130   static void FilterKnots(NCollection_Sequence<Standard_Integer>& theInds, 
0131                           const Standard_Integer theMinNbPnts,
0132                           NCollection_Vector<Standard_Integer>& theLKnots);
0133 };
0134 
0135 #endif