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_Model.hxx>
18 #include <BRepMeshData_Face.hxx>
19 #include <BRepMeshData_Edge.hxx>
20 #include <BRepMesh_OrientedEdge.hxx>
21 #include <BRepMesh_Vertex.hxx>
22 #include <NCollection_IncAllocator.hxx>
24 //=======================================================================
25 // Function: Constructor
27 //=======================================================================
28 BRepMeshData_Model::BRepMeshData_Model (const TopoDS_Shape& theShape)
29 : IMeshData_Model (theShape),
31 myAllocator (new NCollection_IncAllocator (IMeshData::MEMORY_BLOCK_SIZE_HUGE)),
32 myDFaces (256, myAllocator),
33 myDEdges (256, myAllocator)
35 myAllocator->SetThreadSafe();
38 //=======================================================================
39 // Function: Destructor
41 //=======================================================================
42 BRepMeshData_Model::~BRepMeshData_Model ()
46 //=======================================================================
49 //=======================================================================
50 Standard_Integer BRepMeshData_Model::FacesNb () const
52 return myDFaces.Size ();
55 //=======================================================================
58 //=======================================================================
59 const IMeshData::IFaceHandle& BRepMeshData_Model::AddFace (const TopoDS_Face& theFace)
61 IMeshData::IFaceHandle aFace (new (myAllocator) BRepMeshData_Face (theFace, myAllocator));
62 myDFaces.Append (aFace);
63 return myDFaces (FacesNb () - 1);
66 //=======================================================================
69 //=======================================================================
70 const IMeshData::IFaceHandle& BRepMeshData_Model::GetFace (const Standard_Integer theIndex) const
72 return myDFaces (theIndex);
75 //=======================================================================
78 //=======================================================================
79 Standard_Integer BRepMeshData_Model::EdgesNb () const
81 return myDEdges.Size ();
84 //=======================================================================
87 //=======================================================================
88 const IMeshData::IEdgeHandle& BRepMeshData_Model::AddEdge (const TopoDS_Edge& theEdge)
90 IMeshData::IEdgeHandle aEdge (new (myAllocator) BRepMeshData_Edge (theEdge, myAllocator));
91 myDEdges.Append (aEdge);
92 return myDEdges (EdgesNb () - 1);
95 //=======================================================================
98 //=======================================================================
99 const IMeshData::IEdgeHandle& BRepMeshData_Model::GetEdge (const Standard_Integer theIndex) const
101 return myDEdges (theIndex);