0026106: BRepMesh - revision of data model
[occt.git] / src / IMeshData / IMeshData_Types.hxx
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_Types_HeaderFile
17 #define _IMeshData_Types_HeaderFile
18
19 #include <NCollection_DataMap.hxx>
20 #include <NCollection_Vector.hxx>
21 #include <NCollection_Sequence.hxx>
22 #include <NCollection_List.hxx>
23 #include <NCollection_Shared.hxx>
24 #include <TopTools_ShapeMapHasher.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <NCollection_DefineAlloc.hxx>
27 #include <NCollection_StdAllocator.hxx>
28 #include <IMeshData_ParametersListArrayAdaptor.hxx>
29 #include <TColStd_PackedMapOfInteger.hxx>
30 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
31 #include <Precision.hxx>
32 #include <NCollection_EBTree.hxx>
33 #include <Bnd_Box2d.hxx>
34 #include <NCollection_CellFilter.hxx>
35 #include <NCollection_IndexedDataMap.hxx>
36 #include <NCollection_UBTreeFiller.hxx>
37 #include <NCollection_IndexedMap.hxx>
38 #include <BRepMesh_OrientedEdge.hxx>
39 #include <BRepMesh_Vertex.hxx>
40 #include <Bnd_B2d.hxx>
41 #include <BRepMesh_Circle.hxx>
42 #include <BRepMesh_Triangle.hxx>
43 #include <BRepMesh_PairOfIndex.hxx>
44 #include <BRepMesh_Edge.hxx>
45
46 #include <memory>
47 #include <queue>
48 #include <list>
49
50 class IMeshData_Shape;
51 class IMeshData_Face;
52 class IMeshData_Wire;
53 class IMeshData_Edge;
54 class IMeshData_Curve;
55 class IMeshData_PCurve;
56 class IMeshData_Model;
57 class BRepMesh_VertexInspector;
58 class BRepMesh_CircleInspector;
59
60 #define DEFINE_INC_ALLOC                      \
61   DEFINE_NCOLLECTION_ALLOC                    \
62   void operator delete (void* /*theAddress*/) \
63   {                                           \
64     /*it's inc allocator, nothing to do*/     \
65   }
66
67 namespace IMeshData
68 {
69   //! Default size for memory block allocated by IncAllocator. 
70   /**
71   * The idea here is that blocks of the given size are returned to the system
72   * rather than retained in the malloc heap, at least on WIN32 and WIN64 platforms.
73   */
74 #ifdef _WIN64
75   const size_t MEMORY_BLOCK_SIZE_HUGE = 1024 * 1024;
76 #else
77   const size_t MEMORY_BLOCK_SIZE_HUGE = 512 * 1024;
78 #endif
79
80   typedef IMeshData_Edge* IEdgePtr;
81   typedef IMeshData_Face* IFacePtr;
82
83   typedef Handle(IMeshData_Edge)   IEdgeHandle;
84   typedef Handle(IMeshData_Wire)   IWireHandle;
85   typedef Handle(IMeshData_Face)   IFaceHandle;
86   typedef Handle(IMeshData_Curve)  ICurveHandle;
87   typedef Handle(IMeshData_PCurve) IPCurveHandle;
88
89   typedef IMeshData_ParametersListArrayAdaptor<ICurveHandle> ICurveArrayAdaptor;
90   typedef Handle(ICurveArrayAdaptor)   ICurveArrayAdaptorHandle;
91
92   typedef NCollection_Shared<NCollection_EBTree<Standard_Integer, Bnd_Box2d> > BndBox2dTree;
93   typedef NCollection_UBTreeFiller<Standard_Integer, Bnd_Box2d>                BndBox2dTreeFiller;
94
95   // Vectors
96   typedef NCollection_Shared<NCollection_Vector<IFaceHandle> >          VectorOfIFaceHandles;
97   typedef NCollection_Shared<NCollection_Vector<IWireHandle> >          VectorOfIWireHandles;
98   typedef NCollection_Shared<NCollection_Vector<IEdgeHandle> >          VectorOfIEdgeHandles;
99   typedef NCollection_Shared<NCollection_Vector<IPCurveHandle> >        VectorOfIPCurveHandles;
100   typedef NCollection_Shared<NCollection_Vector<IEdgePtr> >             VectorOfIEdgePtrs;
101   typedef NCollection_Shared<NCollection_Vector<Standard_Boolean> >     VectorOfBoolean;
102   typedef NCollection_Shared<NCollection_Vector<Standard_Integer> >     VectorOfInteger;
103   typedef NCollection_Shared<NCollection_Vector<TopAbs_Orientation> >   VectorOfOrientation;
104   typedef NCollection_Shared<NCollection_Vector<BRepMesh_Triangle> >    VectorOfElements;
105   typedef NCollection_Shared<NCollection_Vector<BRepMesh_Circle> >      VectorOfCircle;
106
107   typedef NCollection_Shared<NCollection_Array1<BRepMesh_Vertex> > Array1OfVertexOfDelaun;
108   typedef NCollection_Shared<NCollection_Vector<BRepMesh_Vertex> > VectorOfVertex;
109
110   // Sequences
111   typedef NCollection_Shared<NCollection_Sequence<Bnd_B2d> >          SequenceOfBndB2d;
112   typedef NCollection_Shared<NCollection_Sequence<Standard_Integer> > SequenceOfInteger;
113   typedef NCollection_Shared<NCollection_Sequence<Standard_Real> >    SequenceOfReal;
114
115   namespace Model
116   {
117     typedef std::deque<gp_Pnt, NCollection_StdAllocator<gp_Pnt> >                     SequenceOfPnt;
118     typedef std::deque<gp_Pnt2d, NCollection_StdAllocator<gp_Pnt2d> >                 SequenceOfPnt2d;
119     typedef std::deque<Standard_Real, NCollection_StdAllocator<Standard_Real> >       SequenceOfReal;
120     typedef std::deque<Standard_Integer, NCollection_StdAllocator<Standard_Integer> > SequenceOfInteger;
121   }
122
123   // Lists
124   typedef NCollection_Shared<NCollection_List<Standard_Integer> > ListOfInteger;
125   typedef NCollection_Shared<NCollection_List<gp_Pnt2d> >         ListOfPnt2d;
126   typedef NCollection_Shared<NCollection_List<IPCurveHandle> >    ListOfIPCurves;
127
128   typedef NCollection_Shared<TColStd_PackedMapOfInteger> MapOfInteger;
129   typedef TColStd_MapIteratorOfPackedMapOfInteger        IteratorOfMapOfInteger;
130
131   typedef NCollection_CellFilter<BRepMesh_CircleInspector> CircleCellFilter;
132   typedef NCollection_CellFilter<BRepMesh_VertexInspector> VertexCellFilter;
133
134   // Data Maps
135   template<typename Type>
136   struct WeakEqual
137   {
138     static Standard_Boolean IsEqual(const Type* theFirst,
139                                     const Type* theSecond)
140     {
141       return (theFirst == theSecond);
142     }
143
144     static Standard_Integer HashCode(const Type* thePtr, Standard_Integer theUpper)
145     {
146       return ::HashCode(thePtr, theUpper);
147     }
148   };
149
150   typedef NCollection_Shared<NCollection_DataMap<TopoDS_Shape, Standard_Integer, TopTools_ShapeMapHasher> >     DMapOfShapeInteger;
151   typedef NCollection_Shared<NCollection_DataMap<IFacePtr, ListOfInteger, WeakEqual<IMeshData_Face> > >         DMapOfIFacePtrsListOfInteger;
152   typedef NCollection_Shared<NCollection_Map<IEdgePtr, WeakEqual<IMeshData_Edge> > >                            MapOfIEdgePtr;
153   typedef NCollection_Shared<NCollection_Map<IFacePtr, WeakEqual<IMeshData_Face> > >                            MapOfIFacePtr;
154   typedef NCollection_Shared<NCollection_Map<BRepMesh_OrientedEdge> >                                           MapOfOrientedEdges;
155   typedef NCollection_Shared<NCollection_Map<Standard_Real> >                                                   MapOfReal;
156   typedef NCollection_Shared<NCollection_IndexedDataMap<IFacePtr, ListOfIPCurves, WeakEqual<IMeshData_Face> > > IDMapOfIFacePtrsListOfIPCurves;
157   typedef NCollection_Shared<NCollection_DataMap<IFacePtr, Handle(MapOfIEdgePtr), WeakEqual<IMeshData_Face> > > DMapOfIFacePtrsMapOfIEdgePtrs;
158   typedef NCollection_Shared<NCollection_IndexedDataMap<BRepMesh_Edge, BRepMesh_PairOfIndex> >                  IDMapOfLink;
159   typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, ListOfInteger> >                             DMapOfIntegerListOfInteger;
160   typedef NCollection_Shared<NCollection_DataMap<Standard_Integer, Standard_Integer> >                          MapOfIntegerInteger;
161   typedef NCollection_Shared<NCollection_IndexedMap<Standard_Real> >                                            IMapOfReal;
162
163   typedef NCollection_Shared<NCollection_Array1<Standard_Integer> >                                             Array1OfInteger;
164 }
165
166 #endif