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_OrientedEdge.hxx>
19 #include <BRepMesh_Vertex.hxx>
21 //=======================================================================
22 // Function: Constructor
24 //=======================================================================
25 BRepMeshData_PCurve::BRepMeshData_PCurve (
26 const IMeshData::IFacePtr& theDFace,
27 const TopAbs_Orientation theOrientation,
28 const Handle (NCollection_IncAllocator)& theAllocator)
29 : IMeshData_PCurve (theDFace, theOrientation),
30 myPoints2d (NCollection_StdAllocator<gp_Pnt2d>(theAllocator)),
31 myParameters (NCollection_StdAllocator<Standard_Real>(theAllocator)),
32 myIndices (NCollection_StdAllocator<Standard_Integer>(theAllocator))
36 //=======================================================================
37 // Function: Destructor
39 //=======================================================================
40 BRepMeshData_PCurve::~BRepMeshData_PCurve ()
44 //=======================================================================
45 // Function: InsertPoint
47 //=======================================================================
48 void BRepMeshData_PCurve::InsertPoint(
49 const Standard_Integer thePosition,
50 const gp_Pnt2d& thePoint,
51 const Standard_Real theParamOnPCurve)
53 myPoints2d .insert(myPoints2d .begin() + thePosition, thePoint);
54 myParameters.insert(myParameters.begin() + thePosition, theParamOnPCurve);
55 myIndices .insert(myIndices .begin() + thePosition, 0);
58 //=======================================================================
61 //=======================================================================
62 void BRepMeshData_PCurve::AddPoint (
63 const gp_Pnt2d& thePoint,
64 const Standard_Real theParamOnPCurve)
66 myPoints2d .push_back(thePoint);
67 myParameters.push_back(theParamOnPCurve);
68 myIndices .push_back(0);
71 //=======================================================================
74 //=======================================================================
75 gp_Pnt2d& BRepMeshData_PCurve::GetPoint (const Standard_Integer theIndex)
77 return myPoints2d[theIndex];
80 //=======================================================================
83 //=======================================================================
84 Standard_Integer& BRepMeshData_PCurve::GetIndex(const Standard_Integer theIndex)
86 return myIndices[theIndex];
89 //=======================================================================
90 // Function: GetParameter
92 //=======================================================================
93 Standard_Real& BRepMeshData_PCurve::GetParameter (const Standard_Integer theIndex)
95 return myParameters[theIndex];
98 //=======================================================================
99 // Function: ParameterNb
101 //=======================================================================
102 Standard_Integer BRepMeshData_PCurve::ParametersNb() const
104 return static_cast<Standard_Integer>(myParameters.size());
107 //=======================================================================
108 // Function: RemovePoint
110 //=======================================================================
111 void BRepMeshData_PCurve::RemovePoint (const Standard_Integer theIndex)
113 myPoints2d.erase(myPoints2d.begin() + theIndex);
114 myIndices .erase(myIndices .begin() + theIndex);
115 removeParameter (theIndex);
118 //=======================================================================
119 // Function: removeParameter
121 //=======================================================================
122 void BRepMeshData_PCurve::removeParameter (const Standard_Integer theIndex)
124 myParameters.erase(myParameters.begin() + theIndex);
127 //=======================================================================
130 //=======================================================================
131 void BRepMeshData_PCurve::Clear(const Standard_Boolean isKeepEndPoints)
133 if (!isKeepEndPoints)
136 myParameters.clear();
139 else if (ParametersNb() > 2)
141 myPoints2d .erase(myPoints2d .begin() + 1, myPoints2d .begin() + (myPoints2d .size() - 1));
142 myParameters.erase(myParameters.begin() + 1, myParameters.begin() + (myParameters.size() - 1));
143 myIndices .erase(myIndices .begin() + 1, myIndices .begin() + (myIndices .size() - 1));