0030286: Cover polygonal HLR algorithm by regression tests
[occt.git] / src / AppDef / AppDef_MultiLine.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15// Lpa, le 3/12/91
16
7fd59977 17#include <AppDef_Array1OfMultiPointConstraint.hxx>
42cf5bc1 18#include <AppDef_MultiLine.hxx>
19#include <AppDef_MultiPointConstraint.hxx>
7fd59977 20#include <Standard_ConstructionError.hxx>
42cf5bc1 21#include <Standard_DimensionError.hxx>
22#include <Standard_OutOfRange.hxx>
7fd59977 23
24AppDef_MultiLine::AppDef_MultiLine(){}
25
26
27AppDef_MultiLine::AppDef_MultiLine (const Standard_Integer NbMult)
28{
9775fa61 29 if (NbMult < 0 ) throw Standard_ConstructionError();
7fd59977 30
31 tabMult = new AppDef_HArray1OfMultiPointConstraint (1, NbMult);
32}
33
34
35AppDef_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
45AppDef_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
58AppDef_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
71Standard_Integer AppDef_MultiLine::NbMultiPoints () const {
72 return tabMult->Length();
73}
74
75
76Standard_Integer AppDef_MultiLine::NbPoints() const {
77 return tabMult->Value(1).NbPoints() + tabMult->Value(1).NbPoints2d();
78}
79
80
81void AppDef_MultiLine::SetValue (const Standard_Integer Index,
82 const AppDef_MultiPointConstraint& MPoint) {
83 if ((Index <= 0) || (Index > tabMult->Length())) {
9775fa61 84 throw Standard_OutOfRange();
7fd59977 85 }
86 tabMult->SetValue(Index, MPoint);
87}
88
89AppDef_MultiPointConstraint AppDef_MultiLine::Value (const Standard_Integer Index) const
90{
91 if ((Index <= 0) || (Index > tabMult->Length())) {
9775fa61 92 throw Standard_OutOfRange();
7fd59977 93 }
94 return tabMult->Value(Index);
95}
96
97
98void 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}