1 // Created on: 1995-03-13
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Select3D_SensitiveCurve.hxx>
18 #include <Precision.hxx>
19 #include <TColgp_Array1OfPnt.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCurve,Select3D_SensitivePoly)
24 //==================================================
27 //==================================================
28 Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId,
29 const Handle(Geom_Curve)& theCurve,
30 const Standard_Integer theNbPnts)
31 : Select3D_SensitivePoly (theOwnerId, Standard_True, theNbPnts),
34 loadPoints (theCurve, theNbPnts);
35 SetSensitivityFactor (3);
38 //==================================================
41 //==================================================
42 Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId,
43 const Handle(TColgp_HArray1OfPnt)& thePoints)
44 : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True)
47 SetSensitivityFactor (3);
50 //==================================================
53 //==================================================
54 Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId,
55 const TColgp_Array1OfPnt& thePoints)
56 : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True)
58 SetSensitivityFactor (3);
61 //==================================================
62 // Function: loadPoints
64 //==================================================
65 void Select3D_SensitiveCurve::loadPoints (const Handle(Geom_Curve)& theCurve, const Standard_Integer theNbPnts)
67 Standard_Real aStep = (theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1);
68 Standard_Real aParam = theCurve->FirstParameter();
69 for (Standard_Integer aPntIdx = 0; aPntIdx < myPolyg.Size(); ++aPntIdx)
71 myPolyg.SetPnt (aPntIdx, theCurve->Value (aParam));
76 //=======================================================================
77 //function : GetConnected
79 //=======================================================================
80 Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected()
82 // Create a copy of this
83 Handle(Select3D_SensitiveEntity) aNewEntity;
84 // this was constructed using Handle(Geom_Curve)
85 if (!myCurve.IsNull())
87 aNewEntity = new Select3D_SensitiveCurve (myOwnerId, myCurve);
89 // this was constructed using TColgp_HArray1OfPnt
92 Standard_Integer aSize = myPolyg.Size();
93 Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt (1, aSize);
94 // Fill the array with points from mypolyg3d
95 for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex)
97 aPoints->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
99 aNewEntity = new Select3D_SensitiveCurve (myOwnerId, aPoints);