Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/ApproxInt_KnotTools.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 <Approx_ParametrizationType.hxx>
0018 #include <NCollection_List.hxx>
0019 #include <NCollection_LocalArray.hxx>
0020 #include <NCollection_Sequence.hxx>
0021 #include <NCollection_Vector.hxx>
0022 #include <Standard_Boolean.hxx>
0023 #include <Standard_DefineAlloc.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <Standard_Macro.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <TColStd_Array1OfReal.hxx>
0028 #include <TColgp_Array1OfPnt.hxx>
0029 #include <TColgp_Array1OfPnt2d.hxx>
0030 #include <math_Vector.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
0039 //! into bspline curve.
0040 //!
0041 //! Short description of algorithm:
0042 //! 1) Build discrete curvature on points set.
0043 //! 2) According to special rules build draft knots sequence.
0044 //! 3) Filter draft sequence to build output sequence.
0045 //!
0046 //! For more details look at:
0047 //! Anshuman Razdan - Knot Placement for B-Spline curve Approximation.
0048 class ApproxInt_KnotTools
0049 {
0050 public:
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(const NCollection_LocalArray<Standard_Real>& theCoords,
0076                                              const Standard_Integer                       theDim,
0077                                              const math_Vector&                           thePars,
0078                                              TColStd_Array1OfReal&                        theCurv,
0079                                              Standard_Real& theMaxCurv);
0080 
0081   //! Defines preferable parametrization type for theWL
0082   Standard_EXPORT static Approx_ParametrizationType DefineParType(
0083     const Handle(IntPatch_WLine)& theWL,
0084     const Standard_Integer        theFpar,
0085     const Standard_Integer        theLpar,
0086     const Standard_Boolean        theApproxXYZ,
0087     const Standard_Boolean        theApproxU1V1,
0088     const Standard_Boolean        theApproxU2V2);
0089 
0090 private:
0091   //! Compute indices of knots:
0092   //!
0093   //! I: Build discrete curvature in points set,
0094   //! using outer product of two vectors.
0095   //!
0096   //! II: Put knots in points which has extremity on discrete curvature.
0097   //!
0098   //! III: Put knots in monotone intervals of curvature.
0099   //!
0100   //! IV: Put additional knots near extrema points.
0101   static void ComputeKnotInds(const NCollection_LocalArray<Standard_Real>& theCoords,
0102                               const Standard_Integer                       theDim,
0103                               const math_Vector&                           thePars,
0104                               NCollection_Sequence<Standard_Integer>&      theInds);
0105 
0106   //! Insert knots before index I.
0107   //!
0108   //! I: Check curvature change:
0109   //! if ( maxCurvature / minCurvature ) of current interval greater than
0110   //! threshold value, then stop and use upper index as knot.
0111   //!
0112   //! II: Check midpoint criteria:
0113   //! If exist point between two knot indices with angle greater than
0114   //! threshold value, then stop and put this index as knot.
0115   static Standard_Boolean InsKnotBefI(const Standard_Integer                       theI,
0116                                       const TColStd_Array1OfReal&                  theCurv,
0117                                       const NCollection_LocalArray<Standard_Real>& theCoords,
0118                                       const Standard_Integer                       theDim,
0119                                       NCollection_Sequence<Standard_Integer>&      theInds,
0120                                       const Standard_Boolean                       ChkCurv);
0121 
0122   //! Perform knots filtration.
0123   //!
0124   //! I: Filter too big number of points per knot interval.
0125   //!
0126   //! II: Filter points with too small amount of points per knot interval.
0127   //!
0128   //! III: Fill Last Knot.
0129   static void FilterKnots(NCollection_Sequence<Standard_Integer>& theInds,
0130                           const Standard_Integer                  theMinNbPnts,
0131                           NCollection_Vector<Standard_Integer>&   theLKnots);
0132 };
0133 
0134 #endif