1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
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>
24 AppDef_MultiLine::AppDef_MultiLine(){}
27 AppDef_MultiLine::AppDef_MultiLine (const Standard_Integer NbMult)
29 if (NbMult < 0 ) Standard_ConstructionError::Raise();
31 tabMult = new AppDef_HArray1OfMultiPointConstraint (1, NbMult);
35 AppDef_MultiLine::AppDef_MultiLine (const AppDef_Array1OfMultiPointConstraint& tabMultiP)
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));
45 AppDef_MultiLine::AppDef_MultiLine (const TColgp_Array1OfPnt& tabP3d)
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);
58 AppDef_MultiLine::AppDef_MultiLine (const TColgp_Array1OfPnt2d& tabP2d)
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);
71 Standard_Integer AppDef_MultiLine::NbMultiPoints () const {
72 return tabMult->Length();
76 Standard_Integer AppDef_MultiLine::NbPoints() const {
77 return tabMult->Value(1).NbPoints() + tabMult->Value(1).NbPoints2d();
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();
86 tabMult->SetValue(Index, MPoint);
89 AppDef_MultiPointConstraint AppDef_MultiLine::Value (const Standard_Integer Index) const
91 if ((Index <= 0) || (Index > tabMult->Length())) {
92 Standard_OutOfRange::Raise();
94 return tabMult->Value(Index);
98 void AppDef_MultiLine::Dump(Standard_OStream& o) const
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;