1 // Created on: 1993-06-01
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepMesh_SelectorOfDataStructureOfDelaun.hxx>
18 #include <BRepMesh_PairOfIndex.hxx>
20 //=======================================================================
21 //function : Default constructor
23 //=======================================================================
24 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun()
25 : myAllocator(new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE)),
26 myNodes (10, myAllocator),
27 myLinks (10, myAllocator),
28 myElements(10, myAllocator),
29 myFrontier(10, myAllocator)
33 //=======================================================================
34 //function : Constructor
36 //=======================================================================
37 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(
38 const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
39 : myAllocator(new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE)),
41 myNodes (10, myAllocator),
42 myLinks (10, myAllocator),
43 myElements(10, myAllocator),
44 myFrontier(10, myAllocator)
48 //=======================================================================
49 //function : Initialize
51 //=======================================================================
52 void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(
53 const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
62 //=======================================================================
63 //function : NeighboursOf(Node)
65 //=======================================================================
66 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
67 const BRepMesh_Vertex& theNode)
69 NeighboursOfNode(myMesh->IndexOf(theNode));
72 //=======================================================================
73 //function : NeighboursOfNode(NodeIndex)
75 //=======================================================================
76 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(
77 const Standard_Integer theNodeIndex)
79 BRepMesh::ListOfInteger::Iterator aLinkIt(
80 myMesh->LinksConnectedTo(theNodeIndex));
82 for (; aLinkIt.More(); aLinkIt.Next())
83 elementsOfLink(aLinkIt.Value());
86 //=======================================================================
87 //function : NeighboursOf(Link)
89 //=======================================================================
90 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
91 const BRepMesh_Edge& theLink)
93 NeighboursOfNode(theLink.FirstNode());
94 NeighboursOfNode(theLink.LastNode());
97 //=======================================================================
98 //function : NeighboursOfLink(LinkIndex)
100 //=======================================================================
101 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(
102 const Standard_Integer theLinkIndex)
104 NeighboursOf(myMesh->GetLink(theLinkIndex));
107 //=======================================================================
108 //function : NeighboursOf(Element)
110 //=======================================================================
111 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
112 const BRepMesh_Triangle& theElement)
114 Standard_Integer v[3];
115 myMesh->ElementNodes(theElement, v);
117 for (Standard_Integer i = 0; i < 3; ++i)
118 NeighboursOfNode(v[i]);
121 //=======================================================================
122 //function : NeighboursOfElement(ElementIndex)
124 //=======================================================================
125 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(
126 const Standard_Integer theElementIndex)
128 NeighboursOf(myMesh->GetElement(theElementIndex));
131 //=======================================================================
132 //function : NeighboursByEdgeOf(Element)
134 //=======================================================================
135 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(
136 const BRepMesh_Triangle& theElement)
138 Standard_Integer e[3];
139 Standard_Boolean o[3];
140 theElement.Edges(e, o);
142 for (Standard_Integer i = 0; i < 3; ++i)
143 elementsOfLink(e[i]);
146 //=======================================================================
147 //function : elementsOfLink
149 //=======================================================================
150 void BRepMesh_SelectorOfDataStructureOfDelaun::elementsOfLink(
151 const Standard_Integer theIndex)
153 const BRepMesh_PairOfIndex& aPair = myMesh->ElementsConnectedTo(theIndex);
154 for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; ++j)
155 myElements.Add(aPair.Index(j));