1 // Created on: 2016-04-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BRepMeshData_PCurve.hxx>
17 #include <gp_Pnt2d.hxx>
18 #include <BRepMesh_Vertex.hxx>
19 #include <Standard_OutOfRange.hxx>
21 IMPLEMENT_STANDARD_RTTIEXT(BRepMeshData_PCurve, IMeshData_PCurve)
23 //=======================================================================
24 // Function: Constructor
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))
38 //=======================================================================
39 // Function: Destructor
41 //=======================================================================
42 BRepMeshData_PCurve::~BRepMeshData_PCurve ()
46 //=======================================================================
47 // Function: InsertPoint
49 //=======================================================================
50 void BRepMeshData_PCurve::InsertPoint(
51 const Standard_Integer thePosition,
52 const gp_Pnt2d& thePoint,
53 const Standard_Real theParamOnPCurve)
55 myPoints2d .insert(myPoints2d .begin() + thePosition, thePoint);
56 myParameters.insert(myParameters.begin() + thePosition, theParamOnPCurve);
57 myIndices .insert(myIndices .begin() + thePosition, 0);
60 //=======================================================================
63 //=======================================================================
64 void BRepMeshData_PCurve::AddPoint (
65 const gp_Pnt2d& thePoint,
66 const Standard_Real theParamOnPCurve)
68 myPoints2d .push_back(thePoint);
69 myParameters.push_back(theParamOnPCurve);
70 myIndices .push_back(0);
73 //=======================================================================
76 //=======================================================================
77 gp_Pnt2d& BRepMeshData_PCurve::GetPoint (const Standard_Integer theIndex)
79 Standard_OutOfRange_Raise_if (
80 theIndex < 0 || theIndex >= static_cast<Standard_Integer>(myPoints2d.size()),
81 "BRepMeshData_PCurve::GetPoint");
82 return myPoints2d[theIndex];
85 //=======================================================================
88 //=======================================================================
89 Standard_Integer& BRepMeshData_PCurve::GetIndex(const Standard_Integer theIndex)
91 Standard_OutOfRange_Raise_if (
92 theIndex < 0 || theIndex >= static_cast<Standard_Integer>(myIndices.size()),
93 "BRepMeshData_PCurve::GetIndex");
94 return myIndices[theIndex];
97 //=======================================================================
98 // Function: GetParameter
100 //=======================================================================
101 Standard_Real& BRepMeshData_PCurve::GetParameter (const Standard_Integer theIndex)
103 Standard_OutOfRange_Raise_if (
104 theIndex < 0 || theIndex >= ParametersNb(),
105 "BRepMeshData_PCurve::GetParameter");
106 return myParameters[theIndex];
109 //=======================================================================
110 // Function: ParameterNb
112 //=======================================================================
113 Standard_Integer BRepMeshData_PCurve::ParametersNb() const
115 return static_cast<Standard_Integer>(myParameters.size());
118 //=======================================================================
119 // Function: RemovePoint
121 //=======================================================================
122 void BRepMeshData_PCurve::RemovePoint (const Standard_Integer theIndex)
124 myPoints2d.erase(myPoints2d.begin() + theIndex);
125 myIndices .erase(myIndices .begin() + theIndex);
126 removeParameter (theIndex);
129 //=======================================================================
130 // Function: removeParameter
132 //=======================================================================
133 void BRepMeshData_PCurve::removeParameter (const Standard_Integer theIndex)
135 myParameters.erase(myParameters.begin() + theIndex);
138 //=======================================================================
141 //=======================================================================
142 void BRepMeshData_PCurve::Clear(const Standard_Boolean isKeepEndPoints)
144 if (!isKeepEndPoints)
147 myParameters.clear();
150 else if (ParametersNb() > 2)
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));