0030777: Visualization - Incorrect selection/highlighting of clipped objects
[occt.git] / src / BRepMeshData / BRepMeshData_PCurve.cxx
CommitLineData
7bd071ed 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_OrientedEdge.hxx>
19#include <BRepMesh_Vertex.hxx>
20
21//=======================================================================
22// Function: Constructor
23// Purpose :
24//=======================================================================
25BRepMeshData_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))
33{
34}
35
36//=======================================================================
37// Function: Destructor
38// Purpose :
39//=======================================================================
40BRepMeshData_PCurve::~BRepMeshData_PCurve ()
41{
42}
43
44//=======================================================================
45// Function: InsertPoint
46// Purpose :
47//=======================================================================
48void BRepMeshData_PCurve::InsertPoint(
49 const Standard_Integer thePosition,
50 const gp_Pnt2d& thePoint,
51 const Standard_Real theParamOnPCurve)
52{
53 myPoints2d .insert(myPoints2d .begin() + thePosition, thePoint);
54 myParameters.insert(myParameters.begin() + thePosition, theParamOnPCurve);
55 myIndices .insert(myIndices .begin() + thePosition, 0);
56}
57
58//=======================================================================
59// Function: AddPoint
60// Purpose :
61//=======================================================================
62void BRepMeshData_PCurve::AddPoint (
63 const gp_Pnt2d& thePoint,
64 const Standard_Real theParamOnPCurve)
65{
66 myPoints2d .push_back(thePoint);
67 myParameters.push_back(theParamOnPCurve);
68 myIndices .push_back(0);
69}
70
71//=======================================================================
72// Function: GetPoint
73// Purpose :
74//=======================================================================
75gp_Pnt2d& BRepMeshData_PCurve::GetPoint (const Standard_Integer theIndex)
76{
77 return myPoints2d[theIndex];
78}
79
80//=======================================================================
81// Function: GetIndex
82// Purpose :
83//=======================================================================
84Standard_Integer& BRepMeshData_PCurve::GetIndex(const Standard_Integer theIndex)
85{
86 return myIndices[theIndex];
87}
88
89//=======================================================================
90// Function: GetParameter
91// Purpose :
92//=======================================================================
93Standard_Real& BRepMeshData_PCurve::GetParameter (const Standard_Integer theIndex)
94{
95 return myParameters[theIndex];
96}
97
98//=======================================================================
99// Function: ParameterNb
100// Purpose :
101//=======================================================================
102Standard_Integer BRepMeshData_PCurve::ParametersNb() const
103{
104 return static_cast<Standard_Integer>(myParameters.size());
105}
106
107//=======================================================================
108// Function: RemovePoint
109// Purpose :
110//=======================================================================
111void BRepMeshData_PCurve::RemovePoint (const Standard_Integer theIndex)
112{
113 myPoints2d.erase(myPoints2d.begin() + theIndex);
114 myIndices .erase(myIndices .begin() + theIndex);
115 removeParameter (theIndex);
116}
117
118//=======================================================================
119// Function: removeParameter
120// Purpose :
121//=======================================================================
122void BRepMeshData_PCurve::removeParameter (const Standard_Integer theIndex)
123{
124 myParameters.erase(myParameters.begin() + theIndex);
125}
126
127//=======================================================================
128// Function: Clear
129// Purpose :
130//=======================================================================
131void BRepMeshData_PCurve::Clear(const Standard_Boolean isKeepEndPoints)
132{
133 if (!isKeepEndPoints)
134 {
135 myPoints2d .clear();
136 myParameters.clear();
137 myIndices .clear();
138 }
139 else if (ParametersNb() > 2)
140 {
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));
144 }
145}