Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:29:10

0001 // Created on: 1995-03-13
0002 // Created by: Robert COUBLANC
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Select3D_SensitiveCurve_HeaderFile
0018 #define _Select3D_SensitiveCurve_HeaderFile
0019 
0020 #include <Geom_Curve.hxx>
0021 #include <Select3D_SensitivePoly.hxx>
0022 #include <gp_Pnt.hxx>
0023 #include <NCollection_Array1.hxx>
0024 #include <NCollection_HArray1.hxx>
0025 #include <SelectMgr_SelectingVolumeManager.hxx>
0026 
0027 //! A framework to define a sensitive 3D curve.
0028 //! In some cases this class can raise Standard_ConstructionError and
0029 //! Standard_OutOfRange exceptions. For more details see Select3D_SensitivePoly.
0030 class Select3D_SensitiveCurve : public Select3D_SensitivePoly
0031 {
0032   DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveCurve, Select3D_SensitivePoly)
0033 public:
0034   //! Constructs a sensitive curve object defined by the
0035   //! owner theOwnerId, the curve theCurve, and the
0036   //! maximum number of points on the curve: theNbPnts.
0037   Select3D_SensitiveCurve(const occ::handle<SelectMgr_EntityOwner>& theOwnerId,
0038                           const occ::handle<Geom_Curve>&            theCurve,
0039                           const int                                 theNbPnts = 17)
0040       : Select3D_SensitivePoly(theOwnerId, true, theNbPnts)
0041   {
0042     loadPoints(theCurve, theNbPnts);
0043     mySFactor = 3;
0044   }
0045 
0046   //! Constructs a sensitive curve object defined by the
0047   //! owner theOwnerId and the set of points ThePoints.
0048   Standard_EXPORT Select3D_SensitiveCurve(
0049     const occ::handle<SelectMgr_EntityOwner>&       theOwnerId,
0050     const occ::handle<NCollection_HArray1<gp_Pnt>>& thePoints);
0051 
0052   //! Creation of Sensitive Curve from Points.
0053   //!          Warning : This Method should disappear in the next version...
0054   Standard_EXPORT Select3D_SensitiveCurve(const occ::handle<SelectMgr_EntityOwner>& theOwnerId,
0055                                           const NCollection_Array1<gp_Pnt>&         thePoints);
0056 
0057   //! Returns the copy of this
0058   Standard_EXPORT occ::handle<Select3D_SensitiveEntity> GetConnected() override;
0059 
0060 private:
0061   void loadPoints(const occ::handle<Geom_Curve>& theCurve, const int theNbPnts)
0062   {
0063     const double aStep = (theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1);
0064     double       aParam = theCurve->FirstParameter();
0065     for (int aPntIdx = 0; aPntIdx < myPolyg.Size(); ++aPntIdx)
0066     {
0067       myPolyg.SetPnt(aPntIdx, theCurve->Value(aParam));
0068       aParam += aStep;
0069     }
0070   }
0071 };
0072 
0073 #endif // _Select3D_SensitiveCurve_HeaderFile