| 1 | // Copyright (c) 1995-1999 Matra Datavision |
| 2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 3 | // |
| 4 | // This file is part of Open CASCADE Technology software library. |
| 5 | // |
| 6 | // This library is free software; you can redistribute it and/or modify it under |
| 7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 8 | // by the Free Software Foundation, with special exception defined in the file |
| 9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 10 | // distribution for complete text of the license and disclaimer of any warranty. |
| 11 | // |
| 12 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 13 | // commercial license or contractual agreement. |
| 14 | |
| 15 | // Lpa, le 3/12/91 |
| 16 | |
| 17 | #include <AppDef_Array1OfMultiPointConstraint.hxx> |
| 18 | #include <AppDef_MultiLine.hxx> |
| 19 | #include <AppDef_MultiPointConstraint.hxx> |
| 20 | #include <Standard_ConstructionError.hxx> |
| 21 | #include <Standard_DimensionError.hxx> |
| 22 | #include <Standard_OutOfRange.hxx> |
| 23 | |
| 24 | AppDef_MultiLine::AppDef_MultiLine(){} |
| 25 | |
| 26 | |
| 27 | AppDef_MultiLine::AppDef_MultiLine (const Standard_Integer NbMult) |
| 28 | { |
| 29 | if (NbMult < 0 ) Standard_ConstructionError::Raise(); |
| 30 | |
| 31 | tabMult = new AppDef_HArray1OfMultiPointConstraint (1, NbMult); |
| 32 | } |
| 33 | |
| 34 | |
| 35 | AppDef_MultiLine::AppDef_MultiLine (const AppDef_Array1OfMultiPointConstraint& tabMultiP) |
| 36 | { |
| 37 | tabMult = new AppDef_HArray1OfMultiPointConstraint (1, tabMultiP.Length()); |
| 38 | Standard_Integer i, Lower = tabMultiP.Lower(); |
| 39 | for (i = 1; i <= tabMultiP.Length(); i++) { |
| 40 | tabMult->SetValue(i, tabMultiP.Value(Lower+i-1)); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | |
| 45 | AppDef_MultiLine::AppDef_MultiLine (const TColgp_Array1OfPnt& tabP3d) |
| 46 | { |
| 47 | tabMult = new AppDef_HArray1OfMultiPointConstraint (1, tabP3d.Length()); |
| 48 | Standard_Integer i, Lower = tabP3d.Lower(); |
| 49 | for (i = 1; i <= tabP3d.Length(); i++) { |
| 50 | AppDef_MultiPointConstraint MP(1, 0); |
| 51 | MP.SetPoint(1, tabP3d(Lower+i-1)); |
| 52 | tabMult->SetValue(i, MP); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |
| 58 | AppDef_MultiLine::AppDef_MultiLine (const TColgp_Array1OfPnt2d& tabP2d) |
| 59 | { |
| 60 | tabMult = new AppDef_HArray1OfMultiPointConstraint (1, tabP2d.Length()); |
| 61 | Standard_Integer i, Lower = tabP2d.Lower(); |
| 62 | for (i = 1; i <= tabP2d.Length(); i++) { |
| 63 | AppDef_MultiPointConstraint MP(0, 1); |
| 64 | MP.SetPoint2d(1, tabP2d(Lower+i-1)); |
| 65 | tabMult->SetValue(i, MP); |
| 66 | } |
| 67 | |
| 68 | } |
| 69 | |
| 70 | |
| 71 | Standard_Integer AppDef_MultiLine::NbMultiPoints () const { |
| 72 | return tabMult->Length(); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | Standard_Integer AppDef_MultiLine::NbPoints() const { |
| 77 | return tabMult->Value(1).NbPoints() + tabMult->Value(1).NbPoints2d(); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | void AppDef_MultiLine::SetValue (const Standard_Integer Index, |
| 82 | const AppDef_MultiPointConstraint& MPoint) { |
| 83 | if ((Index <= 0) || (Index > tabMult->Length())) { |
| 84 | Standard_OutOfRange::Raise(); |
| 85 | } |
| 86 | tabMult->SetValue(Index, MPoint); |
| 87 | } |
| 88 | |
| 89 | AppDef_MultiPointConstraint AppDef_MultiLine::Value (const Standard_Integer Index) const |
| 90 | { |
| 91 | if ((Index <= 0) || (Index > tabMult->Length())) { |
| 92 | Standard_OutOfRange::Raise(); |
| 93 | } |
| 94 | return tabMult->Value(Index); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | void AppDef_MultiLine::Dump(Standard_OStream& o) const |
| 99 | { |
| 100 | o << "AppDef_MultiLine dump:" << endl; |
| 101 | // AppDef_MultiPointConstraint MP = tabMult->Value(1); |
| 102 | o << "It contains " << tabMult->Length() << " MultiPointConstraint"<< endl; |
| 103 | // o << MP->NbPoints() << " 3d and " << MP->NbPoints2d() << endl; |
| 104 | } |