Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-03-13 |
2 | // Created by: Robert COUBLANC | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
f751596e | 17 | #include <Select3D_SensitiveCurve.hxx> |
7fd59977 | 18 | #include <Precision.hxx> |
f751596e | 19 | #include <TColgp_Array1OfPnt.hxx> |
7fd59977 | 20 | |
ac04d101 | 21 | |
7fd59977 | 22 | //================================================== |
23 | // Function: Creation | |
24 | // Purpose : | |
25 | //================================================== | |
f751596e | 26 | Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
27 | const Handle(Geom_Curve)& theCurve, | |
28 | const Standard_Integer theNbPnts) | |
2157d6ac | 29 | : Select3D_SensitivePoly (theOwnerId, Standard_True, theNbPnts), |
f751596e | 30 | myCurve (theCurve) |
7fd59977 | 31 | { |
f751596e | 32 | loadPoints (theCurve, theNbPnts); |
3bf9a45f | 33 | SetSensitivityFactor (3); |
7fd59977 | 34 | } |
ac04d101 | 35 | |
7fd59977 | 36 | //================================================== |
37 | // Function: Creation | |
38 | // Purpose : | |
39 | //================================================== | |
f751596e | 40 | Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
41 | const Handle(TColgp_HArray1OfPnt)& thePoints) | |
2157d6ac | 42 | : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True) |
ac04d101 | 43 | |
7fd59977 | 44 | { |
3bf9a45f | 45 | SetSensitivityFactor (3); |
7fd59977 | 46 | } |
47 | ||
48 | //================================================== | |
f751596e | 49 | // Function: Creation |
7fd59977 | 50 | // Purpose : |
51 | //================================================== | |
f751596e | 52 | Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
53 | const TColgp_Array1OfPnt& thePoints) | |
2157d6ac | 54 | : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True) |
ac04d101 | 55 | { |
3bf9a45f | 56 | SetSensitivityFactor (3); |
7fd59977 | 57 | } |
58 | ||
7fd59977 | 59 | //================================================== |
f751596e | 60 | // Function: loadPoints |
7fd59977 | 61 | // Purpose : |
62 | //================================================== | |
f751596e | 63 | void Select3D_SensitiveCurve::loadPoints (const Handle(Geom_Curve)& theCurve, const Standard_Integer theNbPnts) |
7fd59977 | 64 | { |
f751596e | 65 | Standard_Real aStep = (theCurve->LastParameter() - theCurve->FirstParameter()) / (theNbPnts - 1); |
66 | Standard_Real aParam = theCurve->FirstParameter(); | |
67 | for (Standard_Integer aPntIdx = 0; aPntIdx < myPolyg.Size(); ++aPntIdx) | |
ceae62f0 | 68 | { |
f751596e | 69 | myPolyg.SetPnt (aPntIdx, theCurve->Value (aParam)); |
70 | aParam += aStep; | |
ceae62f0 | 71 | } |
7fd59977 | 72 | } |
73 | ||
ac04d101 SA |
74 | //======================================================================= |
75 | //function : GetConnected | |
aec37c15 | 76 | //purpose : |
77 | //======================================================================= | |
f751596e | 78 | Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected() |
ac04d101 | 79 | { |
aec37c15 | 80 | // Create a copy of this |
ac04d101 | 81 | Handle(Select3D_SensitiveEntity) aNewEntity; |
aec37c15 | 82 | // this was constructed using Handle(Geom_Curve) |
83 | if (!myCurve.IsNull()) | |
ac04d101 | 84 | { |
f751596e | 85 | aNewEntity = new Select3D_SensitiveCurve (myOwnerId, myCurve); |
ac04d101 SA |
86 | } |
87 | // this was constructed using TColgp_HArray1OfPnt | |
aec37c15 | 88 | else |
ac04d101 | 89 | { |
f751596e | 90 | Standard_Integer aSize = myPolyg.Size(); |
91 | Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt (1, aSize); | |
ac04d101 | 92 | // Fill the array with points from mypolyg3d |
aec37c15 | 93 | for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex) |
ac04d101 | 94 | { |
f751596e | 95 | aPoints->SetValue (anIndex, myPolyg.Pnt (anIndex-1)); |
ac04d101 | 96 | } |
f751596e | 97 | aNewEntity = new Select3D_SensitiveCurve (myOwnerId, aPoints); |
ac04d101 | 98 | } |
aec37c15 | 99 | |
ac04d101 | 100 | return aNewEntity; |
2157d6ac | 101 | } |