0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IMeshData / IMeshData_Edge.hxx
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#ifndef _IMeshData_Edge_HeaderFile
17#define _IMeshData_Edge_HeaderFile
18
19#include <IMeshData_TessellatedShape.hxx>
20#include <IMeshData_StatusOwner.hxx>
21#include <Standard_Type.hxx>
22#include <TopoDS_Edge.hxx>
23#include <TopoDS.hxx>
24#include <IMeshData_Curve.hxx>
25#include <IMeshData_PCurve.hxx>
26#include <IMeshData_Types.hxx>
27#include <BRep_Tool.hxx>
28
29class IMeshData_Face;
30
31//! Interface class representing discrete model of an edge.
32class IMeshData_Edge : public IMeshData_TessellatedShape, public IMeshData_StatusOwner
33{
34public:
35
36 //! Destructor.
37 Standard_EXPORT virtual ~IMeshData_Edge()
38 {
39 }
40
41 //! Returns TopoDS_Edge attached to model.
42 inline const TopoDS_Edge& GetEdge () const
43 {
44 return TopoDS::Edge (GetShape ());
45 }
46
47 //! Returns number of pcurves assigned to current edge.
48 Standard_EXPORT virtual Standard_Integer PCurvesNb () const = 0;
49
50 //! Adds discrete pcurve for the specifed discrete face.
51 Standard_EXPORT virtual const IMeshData::IPCurveHandle& AddPCurve (
52 const IMeshData::IFacePtr& theDFace,
53 const TopAbs_Orientation theOrientation) = 0;
54
55 //! Returns pcurve for the specified discrete face.
56 Standard_EXPORT virtual const IMeshData::IPCurveHandle& GetPCurve (
57 const IMeshData::IFacePtr& theDFace,
58 const TopAbs_Orientation theOrientation) const = 0;
59
60 //! Returns pcurve with the given index.
61 Standard_EXPORT virtual const IMeshData::IPCurveHandle& GetPCurve (
62 const Standard_Integer theIndex) const = 0;
63
64 //! Clears curve and all pcurves assigned to the edge from discretization.
65 inline void Clear(const Standard_Boolean isKeepEndPoints)
66 {
67 myCurve->Clear(isKeepEndPoints);
68 for (Standard_Integer aPCurveIt = 0; aPCurveIt < PCurvesNb(); ++aPCurveIt)
69 {
70 GetPCurve(aPCurveIt)->Clear(isKeepEndPoints);
71 }
72 }
73
74 //! Returns true in case if the edge is free one, i.e. it does not have pcurves.
75 inline Standard_Boolean IsFree () const
76 {
77 return (PCurvesNb () == 0);
78 }
79
80 //! Sets 3d curve associated with current edge.
81 inline void SetCurve (const IMeshData::ICurveHandle& theCurve)
82 {
83 myCurve = theCurve;
84 }
85
86 //! Returns 3d curve associated with current edge.
87 inline const IMeshData::ICurveHandle& GetCurve () const
88 {
89 return myCurve;
90 }
91
92 //! Gets value of angular deflection for the discrete model.
93 inline Standard_Real GetAngularDeflection () const
94 {
95 return myAngDeflection;
96 }
97
98 //! Sets value of angular deflection for the discrete model.
99 inline void SetAngularDeflection (const Standard_Real theValue)
100 {
101 myAngDeflection = theValue;
102 }
103
104 //! Returns same param flag.
105 //! By default equals to flag stored in topological shape.
106 inline Standard_Boolean GetSameParam () const
107 {
108 return mySameParam;
109 }
110
111 //! Updates same param flag.
112 inline void SetSameParam (const Standard_Boolean theValue)
113 {
114 mySameParam = theValue;
115 }
116
117 //! Returns same range flag.
118 //! By default equals to flag stored in topological shape.
119 inline Standard_Boolean GetSameRange () const
120 {
121 return mySameRange;
122 }
123
124 //! Updates same range flag.
125 inline void SetSameRange (const Standard_Boolean theValue)
126 {
127 mySameRange = theValue;
128 }
129
130 //! Returns degenerative flag.
131 //! By default equals to flag stored in topological shape.
132 inline Standard_Boolean GetDegenerated () const
133 {
134 return myDegenerated;
135 }
136
137 //! Updates degenerative flag.
138 inline void SetDegenerated (const Standard_Boolean theValue)
139 {
140 myDegenerated = theValue;
141 }
142
143 DEFINE_STANDARD_RTTI_INLINE(IMeshData_Edge, IMeshData_TessellatedShape)
144
145protected:
146
147 //! Constructor.
148 //! Initializes empty model.
149 Standard_EXPORT IMeshData_Edge (const TopoDS_Edge& theEdge)
150 : IMeshData_TessellatedShape(theEdge),
151 mySameParam (BRep_Tool::SameParameter(theEdge)),
152 mySameRange (BRep_Tool::SameRange (theEdge)),
153 myDegenerated(BRep_Tool::Degenerated (theEdge)),
154 myAngDeflection(RealLast())
155 {
156 }
157
158private:
159
160 Standard_Boolean mySameParam;
161 Standard_Boolean mySameRange;
162 Standard_Boolean myDegenerated;
163 Standard_Real myAngDeflection;
164 IMeshData::ICurveHandle myCurve;
165};
166
167#endif