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 | |
92efcf78 | 22 | IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCurve,Select3D_SensitivePoly) |
23 | ||
7fd59977 | 24 | //================================================== |
25 | // Function: Creation | |
26 | // Purpose : | |
27 | //================================================== | |
f751596e | 28 | Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
29 | const Handle(Geom_Curve)& theCurve, | |
30 | const Standard_Integer theNbPnts) | |
2157d6ac | 31 | : Select3D_SensitivePoly (theOwnerId, Standard_True, theNbPnts), |
f751596e | 32 | myCurve (theCurve) |
7fd59977 | 33 | { |
f751596e | 34 | loadPoints (theCurve, theNbPnts); |
3bf9a45f | 35 | SetSensitivityFactor (3); |
7fd59977 | 36 | } |
ac04d101 | 37 | |
7fd59977 | 38 | //================================================== |
39 | // Function: Creation | |
40 | // Purpose : | |
41 | //================================================== | |
f751596e | 42 | Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
43 | const Handle(TColgp_HArray1OfPnt)& thePoints) | |
2157d6ac | 44 | : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True) |
ac04d101 | 45 | |
7fd59977 | 46 | { |
3bf9a45f | 47 | SetSensitivityFactor (3); |
7fd59977 | 48 | } |
49 | ||
50 | //================================================== | |
f751596e | 51 | // Function: Creation |
7fd59977 | 52 | // Purpose : |
53 | //================================================== | |
f751596e | 54 | Select3D_SensitiveCurve::Select3D_SensitiveCurve (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
55 | const TColgp_Array1OfPnt& thePoints) | |
2157d6ac | 56 | : Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True) |
ac04d101 | 57 | { |
3bf9a45f | 58 | SetSensitivityFactor (3); |
7fd59977 | 59 | } |
60 | ||
7fd59977 | 61 | //================================================== |
f751596e | 62 | // Function: loadPoints |
7fd59977 | 63 | // Purpose : |
64 | //================================================== | |
f751596e | 65 | void Select3D_SensitiveCurve::loadPoints (const Handle(Geom_Curve)& theCurve, const Standard_Integer theNbPnts) |
7fd59977 | 66 | { |
f751596e | 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) | |
ceae62f0 | 70 | { |
f751596e | 71 | myPolyg.SetPnt (aPntIdx, theCurve->Value (aParam)); |
72 | aParam += aStep; | |
ceae62f0 | 73 | } |
7fd59977 | 74 | } |
75 | ||
ac04d101 SA |
76 | //======================================================================= |
77 | //function : GetConnected | |
aec37c15 | 78 | //purpose : |
79 | //======================================================================= | |
f751596e | 80 | Handle(Select3D_SensitiveEntity) Select3D_SensitiveCurve::GetConnected() |
ac04d101 | 81 | { |
aec37c15 | 82 | // Create a copy of this |
ac04d101 | 83 | Handle(Select3D_SensitiveEntity) aNewEntity; |
aec37c15 | 84 | // this was constructed using Handle(Geom_Curve) |
85 | if (!myCurve.IsNull()) | |
ac04d101 | 86 | { |
f751596e | 87 | aNewEntity = new Select3D_SensitiveCurve (myOwnerId, myCurve); |
ac04d101 SA |
88 | } |
89 | // this was constructed using TColgp_HArray1OfPnt | |
aec37c15 | 90 | else |
ac04d101 | 91 | { |
f751596e | 92 | Standard_Integer aSize = myPolyg.Size(); |
93 | Handle(TColgp_HArray1OfPnt) aPoints = new TColgp_HArray1OfPnt (1, aSize); | |
ac04d101 | 94 | // Fill the array with points from mypolyg3d |
aec37c15 | 95 | for (Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex) |
ac04d101 | 96 | { |
f751596e | 97 | aPoints->SetValue (anIndex, myPolyg.Pnt (anIndex-1)); |
ac04d101 | 98 | } |
f751596e | 99 | aNewEntity = new Select3D_SensitiveCurve (myOwnerId, aPoints); |
ac04d101 | 100 | } |
aec37c15 | 101 | |
ac04d101 | 102 | return aNewEntity; |
2157d6ac | 103 | } |