0032781: Coding - get rid of unused headers [BRepCheck to ChFiKPart]
[occt.git] / src / BRepMeshData / BRepMeshData_PCurve.cxx
1 // Created on: 2016-04-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <BRepMeshData_PCurve.hxx>
17 #include <gp_Pnt2d.hxx>
18 #include <BRepMesh_Vertex.hxx>
19 #include <Standard_OutOfRange.hxx>
20
21 IMPLEMENT_STANDARD_RTTIEXT(BRepMeshData_PCurve, IMeshData_PCurve)
22
23 //=======================================================================
24 // Function: Constructor
25 // Purpose : 
26 //=======================================================================
27 BRepMeshData_PCurve::BRepMeshData_PCurve (
28   const IMeshData::IFacePtr&               theDFace,
29   const TopAbs_Orientation                 theOrientation,
30   const Handle (NCollection_IncAllocator)& theAllocator)
31   : IMeshData_PCurve (theDFace, theOrientation),
32     myPoints2d   (NCollection_StdAllocator<gp_Pnt2d>(theAllocator)),
33     myParameters (NCollection_StdAllocator<Standard_Real>(theAllocator)),
34     myIndices    (NCollection_StdAllocator<Standard_Integer>(theAllocator))
35 {
36 }
37
38 //=======================================================================
39 // Function: Destructor
40 // Purpose : 
41 //=======================================================================
42 BRepMeshData_PCurve::~BRepMeshData_PCurve ()
43 {
44 }
45
46 //=======================================================================
47 // Function: InsertPoint
48 // Purpose : 
49 //=======================================================================
50 void BRepMeshData_PCurve::InsertPoint(
51   const Standard_Integer thePosition,
52   const gp_Pnt2d&        thePoint,
53   const Standard_Real    theParamOnPCurve)
54 {
55   myPoints2d  .insert(myPoints2d  .begin() + thePosition, thePoint);
56   myParameters.insert(myParameters.begin() + thePosition, theParamOnPCurve);
57   myIndices   .insert(myIndices   .begin() + thePosition, 0);
58 }
59
60 //=======================================================================
61 // Function: AddPoint
62 // Purpose : 
63 //=======================================================================
64 void BRepMeshData_PCurve::AddPoint (
65   const gp_Pnt2d&     thePoint,
66   const Standard_Real theParamOnPCurve)
67 {
68   myPoints2d  .push_back(thePoint);
69   myParameters.push_back(theParamOnPCurve);
70   myIndices   .push_back(0);
71 }
72
73 //=======================================================================
74 // Function: GetPoint
75 // Purpose : 
76 //=======================================================================
77 gp_Pnt2d& BRepMeshData_PCurve::GetPoint (const Standard_Integer theIndex)
78 {
79   Standard_OutOfRange_Raise_if (
80     theIndex < 0 || theIndex >= static_cast<Standard_Integer>(myPoints2d.size()),
81     "BRepMeshData_PCurve::GetPoint");
82   return myPoints2d[theIndex];
83 }
84
85 //=======================================================================
86 // Function: GetIndex
87 // Purpose : 
88 //=======================================================================
89 Standard_Integer& BRepMeshData_PCurve::GetIndex(const Standard_Integer theIndex)
90 {
91   Standard_OutOfRange_Raise_if (
92     theIndex < 0 || theIndex >= static_cast<Standard_Integer>(myIndices.size()),
93     "BRepMeshData_PCurve::GetIndex");
94   return myIndices[theIndex];
95 }
96
97 //=======================================================================
98 // Function: GetParameter
99 // Purpose : 
100 //=======================================================================
101 Standard_Real& BRepMeshData_PCurve::GetParameter (const Standard_Integer theIndex)
102 {
103   Standard_OutOfRange_Raise_if (
104     theIndex < 0 || theIndex >= ParametersNb(),
105     "BRepMeshData_PCurve::GetParameter");
106   return myParameters[theIndex];
107 }
108
109 //=======================================================================
110 // Function: ParameterNb
111 // Purpose : 
112 //=======================================================================
113 Standard_Integer BRepMeshData_PCurve::ParametersNb() const
114 {
115   return static_cast<Standard_Integer>(myParameters.size());
116 }
117
118 //=======================================================================
119 // Function: RemovePoint
120 // Purpose : 
121 //=======================================================================
122 void BRepMeshData_PCurve::RemovePoint (const Standard_Integer theIndex)
123 {
124   myPoints2d.erase(myPoints2d.begin() + theIndex);
125   myIndices .erase(myIndices .begin() + theIndex);
126   removeParameter (theIndex);
127 }
128
129 //=======================================================================
130 // Function: removeParameter
131 // Purpose : 
132 //=======================================================================
133 void BRepMeshData_PCurve::removeParameter (const Standard_Integer theIndex)
134 {
135   myParameters.erase(myParameters.begin() + theIndex);
136 }
137
138 //=======================================================================
139 // Function: Clear
140 // Purpose : 
141 //=======================================================================
142 void BRepMeshData_PCurve::Clear(const Standard_Boolean isKeepEndPoints)
143 {
144   if (!isKeepEndPoints)
145   {
146     myPoints2d  .clear();
147     myParameters.clear();
148     myIndices   .clear();
149   }
150   else if (ParametersNb() > 2)
151   {
152     myPoints2d  .erase(myPoints2d  .begin() + 1, myPoints2d  .begin() + (myPoints2d  .size() - 1));
153     myParameters.erase(myParameters.begin() + 1, myParameters.begin() + (myParameters.size() - 1));
154     myIndices   .erase(myIndices   .begin() + 1, myIndices   .begin() + (myIndices   .size() - 1));
155   }
156 }