0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BRepMeshData / BRepMeshData_Curve.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_Curve.hxx>
17#include <gp_Pnt.hxx>
18#include <BRepMesh_OrientedEdge.hxx>
19#include <BRepMesh_Vertex.hxx>
20
21//=======================================================================
22// Function: Constructor
23// Purpose :
24//=======================================================================
25BRepMeshData_Curve::BRepMeshData_Curve (const Handle (NCollection_IncAllocator)& theAllocator)
26: myPoints (NCollection_StdAllocator<gp_Pnt>(theAllocator)),
27 myParameters (NCollection_StdAllocator<Standard_Real>(theAllocator))
28{
29}
30
31//=======================================================================
32// Function: Destructor
33// Purpose :
34//=======================================================================
35BRepMeshData_Curve::~BRepMeshData_Curve ()
36{
37}
38
39//=======================================================================
40// Function: InsertPoint
41// Purpose :
42//=======================================================================
43void BRepMeshData_Curve::InsertPoint(
44 const Standard_Integer thePosition,
45 const gp_Pnt& thePoint,
46 const Standard_Real theParamOnPCurve)
47{
48 myPoints .insert(myPoints .begin() + thePosition, thePoint);
49 myParameters.insert(myParameters.begin() + thePosition, theParamOnPCurve);
50}
51
52//=======================================================================
53// Function: AddPoint
54// Purpose :
55//=======================================================================
56void BRepMeshData_Curve::AddPoint (
57 const gp_Pnt& thePoint,
58 const Standard_Real theParamOnPCurve)
59{
60 myPoints .push_back(thePoint);
61 myParameters.push_back(theParamOnPCurve);
62}
63
64//=======================================================================
65// Function: GetPoint
66// Purpose :
67//=======================================================================
68gp_Pnt& BRepMeshData_Curve::GetPoint (const Standard_Integer theIndex)
69{
70 return myPoints[theIndex];
71}
72
73//=======================================================================
74// Function: GetParameter
75// Purpose :
76//=======================================================================
77Standard_Real& BRepMeshData_Curve::GetParameter (const Standard_Integer theIndex)
78{
79 return myParameters[theIndex];
80}
81
82//=======================================================================
83// Function: ParameterNb
84// Purpose :
85//=======================================================================
86Standard_Integer BRepMeshData_Curve::ParametersNb() const
87{
88 return static_cast<Standard_Integer>(myParameters.size());
89}
90
91//=======================================================================
92// Function: RemovePoint
93// Purpose :
94//=======================================================================
95void BRepMeshData_Curve::RemovePoint (const Standard_Integer theIndex)
96{
97 myPoints.erase(myPoints.begin() + theIndex);
98 removeParameter (theIndex);
99}
100
101//=======================================================================
102// Function: removeParameter
103// Purpose :
104//=======================================================================
105void BRepMeshData_Curve::removeParameter (const Standard_Integer theIndex)
106{
107 myParameters.erase(myParameters.begin() + theIndex);
108}
109
110//=======================================================================
111// Function: Clear
112// Purpose :
113//=======================================================================
114void BRepMeshData_Curve::Clear(const Standard_Boolean isKeepEndPoints)
115{
116 if (!isKeepEndPoints)
117 {
118 myPoints .clear();
119 myParameters.clear();
120 }
121 else if (ParametersNb() > 2)
122 {
123 myPoints .erase(myPoints .begin() + 1, myPoints .begin() + (myPoints .size() - 1));
124 myParameters.erase(myParameters.begin() + 1, myParameters.begin() + (myParameters.size() - 1));
125 }
126}