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 : myNodes (10, new NCollection_IncAllocator),
26 myLinks (10, new NCollection_IncAllocator),
27 myElements(10, new NCollection_IncAllocator),
28 myFrontier(10, new NCollection_IncAllocator)
32 //=======================================================================
33 //function : Constructor
35 //=======================================================================
36 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(
37 const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
39 myNodes (10, myMesh->Allocator()),
40 myLinks (10, myMesh->Allocator()),
41 myElements(10, myMesh->Allocator()),
42 myFrontier(10, myMesh->Allocator())
46 //=======================================================================
47 //function : Initialize
49 //=======================================================================
50 void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(
51 const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
60 //=======================================================================
61 //function : NeighboursOf(Node)
63 //=======================================================================
64 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
65 const BRepMesh_Vertex& theNode)
67 NeighboursOfNode(myMesh->IndexOf(theNode));
70 //=======================================================================
71 //function : NeighboursOfNode(NodeIndex)
73 //=======================================================================
74 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(
75 const Standard_Integer theNodeIndex)
77 BRepMeshCol::ListOfInteger::Iterator aLinkIt(
78 myMesh->LinksConnectedTo(theNodeIndex));
80 for (; aLinkIt.More(); aLinkIt.Next())
81 elementsOfLink(aLinkIt.Value());
84 //=======================================================================
85 //function : NeighboursOf(Link)
87 //=======================================================================
88 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
89 const BRepMesh_Edge& theLink)
91 NeighboursOfNode(theLink.FirstNode());
92 NeighboursOfNode(theLink.LastNode());
95 //=======================================================================
96 //function : NeighboursOfLink(LinkIndex)
98 //=======================================================================
99 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(
100 const Standard_Integer theLinkIndex)
102 NeighboursOf(myMesh->GetLink(theLinkIndex));
105 //=======================================================================
106 //function : NeighboursOf(Element)
108 //=======================================================================
109 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
110 const BRepMesh_Triangle& theElement)
112 Standard_Integer v[3];
113 myMesh->ElementNodes(theElement, v);
115 for (Standard_Integer i = 0; i < 3; ++i)
116 NeighboursOfNode(v[i]);
119 //=======================================================================
120 //function : NeighboursOfElement(ElementIndex)
122 //=======================================================================
123 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(
124 const Standard_Integer theElementIndex)
126 NeighboursOf(myMesh->GetElement(theElementIndex));
129 //=======================================================================
130 //function : NeighboursByEdgeOf(Element)
132 //=======================================================================
133 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(
134 const BRepMesh_Triangle& theElement)
136 Standard_Integer e[3];
137 Standard_Boolean o[3];
138 theElement.Edges(e, o);
140 for (Standard_Integer i = 0; i < 3; ++i)
141 elementsOfLink(e[i]);
144 //=======================================================================
145 //function : elementsOfLink
147 //=======================================================================
148 void BRepMesh_SelectorOfDataStructureOfDelaun::elementsOfLink(
149 const Standard_Integer theIndex)
151 const BRepMesh_PairOfIndex& aPair = myMesh->ElementsConnectedTo(theIndex);
152 for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; ++j)
153 myElements.Add(aPair.Index(j));