0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BRepMeshData / BRepMeshData_Model.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_Model.hxx>
95c882e9 17
7bd071ed 18#include <BRepMeshData_Face.hxx>
19#include <BRepMeshData_Edge.hxx>
7bd071ed 20#include <BRepMesh_OrientedEdge.hxx>
21#include <BRepMesh_Vertex.hxx>
95c882e9 22#include <NCollection_IncAllocator.hxx>
7bd071ed 23
24//=======================================================================
25// Function: Constructor
26// Purpose :
27//=======================================================================
28BRepMeshData_Model::BRepMeshData_Model (const TopoDS_Shape& theShape)
29 : IMeshData_Model (theShape),
30 myMaxSize (0.),
95c882e9 31 myAllocator (new NCollection_IncAllocator (IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
7bd071ed 32 myDFaces (256, myAllocator),
33 myDEdges (256, myAllocator)
34{
95c882e9 35 myAllocator->SetThreadSafe();
7bd071ed 36}
37
38//=======================================================================
39// Function: Destructor
40// Purpose :
41//=======================================================================
42BRepMeshData_Model::~BRepMeshData_Model ()
43{
44}
45
46//=======================================================================
47// Function: FacesNb
48// Purpose :
49//=======================================================================
50Standard_Integer BRepMeshData_Model::FacesNb () const
51{
52 return myDFaces.Size ();
53}
54
55//=======================================================================
56// Function: AddFace
57// Purpose :
58//=======================================================================
59const IMeshData::IFaceHandle& BRepMeshData_Model::AddFace (const TopoDS_Face& theFace)
60{
61 IMeshData::IFaceHandle aFace (new (myAllocator) BRepMeshData_Face (theFace, myAllocator));
62 myDFaces.Append (aFace);
63 return myDFaces (FacesNb () - 1);
64}
65
66//=======================================================================
67// Function: GetFace
68// Purpose :
69//=======================================================================
70const IMeshData::IFaceHandle& BRepMeshData_Model::GetFace (const Standard_Integer theIndex) const
71{
72 return myDFaces (theIndex);
73}
74
75//=======================================================================
76// Function: EdgesNb
77// Purpose :
78//=======================================================================
79Standard_Integer BRepMeshData_Model::EdgesNb () const
80{
81 return myDEdges.Size ();
82}
83
84//=======================================================================
85// Function: AddEdge
86// Purpose :
87//=======================================================================
88const IMeshData::IEdgeHandle& BRepMeshData_Model::AddEdge (const TopoDS_Edge& theEdge)
89{
90 IMeshData::IEdgeHandle aEdge (new (myAllocator) BRepMeshData_Edge (theEdge, myAllocator));
91 myDEdges.Append (aEdge);
92 return myDEdges (EdgesNb () - 1);
93}
94
95//=======================================================================
96// Function: GetEdge
97// Purpose :
98//=======================================================================
99const IMeshData::IEdgeHandle& BRepMeshData_Model::GetEdge (const Standard_Integer theIndex) const
100{
101 return myDEdges (theIndex);
102}