|
|
|||
File indexing completed on 2026-10-21 09:57:41
0001 // Created on: 1995-03-06 0002 // Created by: Laurent PAINNOT 0003 // Copyright (c) 1995-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Poly_Connect_HeaderFile 0018 #define _Poly_Connect_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Integer.hxx> 0025 #include <NCollection_Array1.hxx> 0026 #include <TColStd_PackedMapOfInteger.hxx> 0027 #include <Standard_Boolean.hxx> 0028 class Poly_Triangulation; 0029 0030 //! Provides an algorithm to explore, inside a triangulation, the 0031 //! adjacency data for a node or a triangle. 0032 //! Adjacency data for a node consists of triangles which 0033 //! contain the node. 0034 //! Adjacency data for a triangle consists of: 0035 //! - the 3 adjacent triangles which share an edge of the triangle, 0036 //! - and the 3 nodes which are the other nodes of these adjacent triangles. 0037 //! Example 0038 //! Inside a triangulation, a triangle T 0039 //! has nodes n1, n2 and n3. 0040 //! It has adjacent triangles AT1, AT2 and AT3 where: 0041 //! - AT1 shares the nodes n2 and n3, 0042 //! - AT2 shares the nodes n3 and n1, 0043 //! - AT3 shares the nodes n1 and n2. 0044 //! It has adjacent nodes an1, an2 and an3 where: 0045 //! - an1 is the third node of AT1, 0046 //! - an2 is the third node of AT2, 0047 //! - an3 is the third node of AT3. 0048 //! So triangle AT1 is composed of nodes n2, n3 and an1. 0049 //! There are two ways of using this algorithm. 0050 //! - From a given node you can look for one triangle that 0051 //! passes through the node, then look for the triangles 0052 //! adjacent to this triangle, then the adjacent nodes. You 0053 //! can thus explore the triangulation step by step (functions 0054 //! Triangle, Triangles and Nodes). 0055 //! - From a given node you can look for all the triangles 0056 //! that pass through the node (iteration method, using the 0057 //! functions Initialize, More, Next and Value). 0058 //! A Connect object can be seen as a tool which analyzes a 0059 //! triangulation and translates it into a series of triangles. By 0060 //! doing this, it provides an interface with other tools and 0061 //! applications working on basic triangles, and which do not 0062 //! work directly with a Poly_Triangulation. 0063 class Poly_Connect 0064 { 0065 public: 0066 DEFINE_STANDARD_ALLOC 0067 0068 //! Constructs an uninitialized algorithm. 0069 Standard_EXPORT Poly_Connect(); 0070 0071 //! Constructs an algorithm to explore the adjacency data of 0072 //! nodes or triangles for the triangulation T. 0073 Standard_EXPORT Poly_Connect(const occ::handle<Poly_Triangulation>& theTriangulation); 0074 0075 //! Initialize the algorithm to explore the adjacency data of 0076 //! nodes or triangles for the triangulation theTriangulation. 0077 Standard_EXPORT void Load(const occ::handle<Poly_Triangulation>& theTriangulation); 0078 0079 //! Returns the triangulation analyzed by this tool. 0080 const occ::handle<Poly_Triangulation>& Triangulation() const { return myTriangulation; } 0081 0082 //! Returns the index of a triangle containing the node at 0083 //! index N in the nodes table specific to the triangulation analyzed by this tool 0084 int Triangle(const int N) const { return myTriangles(N); } 0085 0086 //! Returns in t1, t2 and t3, the indices of the 3 triangles 0087 //! adjacent to the triangle at index T in the triangles table 0088 //! specific to the triangulation analyzed by this tool. 0089 //! Warning 0090 //! Null indices are returned when there are fewer than 3 0091 //! adjacent triangles. 0092 void Triangles(const int T, int& t1, int& t2, int& t3) const 0093 { 0094 int index = 6 * (T - 1); 0095 t1 = myAdjacents(index + 1); 0096 t2 = myAdjacents(index + 2); 0097 t3 = myAdjacents(index + 3); 0098 } 0099 0100 //! Returns, in n1, n2 and n3, the indices of the 3 nodes 0101 //! adjacent to the triangle referenced at index T in the 0102 //! triangles table specific to the triangulation analyzed by this tool. 0103 //! Warning 0104 //! Null indices are returned when there are fewer than 3 adjacent nodes. 0105 void Nodes(const int T, int& n1, int& n2, int& n3) const 0106 { 0107 int index = 6 * (T - 1); 0108 n1 = myAdjacents(index + 4); 0109 n2 = myAdjacents(index + 5); 0110 n3 = myAdjacents(index + 6); 0111 } 0112 0113 public: 0114 //! Initializes an iterator to search for all the triangles 0115 //! containing the node referenced at index N in the nodes 0116 //! table, for the triangulation analyzed by this tool. 0117 //! The iterator is managed by the following functions: 0118 //! - More, which checks if there are still elements in the iterator 0119 //! - Next, which positions the iterator on the next element 0120 //! - Value, which returns the current element. 0121 //! The use of such an iterator provides direct access to the 0122 //! triangles around a particular node, i.e. it avoids iterating on 0123 //! all the component triangles of a triangulation. 0124 //! Example 0125 //! Poly_Connect C(Tr); 0126 //! for 0127 //! (C.Initialize(n1);C.More();C.Next()) 0128 //! { 0129 //! t = C.Value(); 0130 //! } 0131 Standard_EXPORT void Initialize(const int N); 0132 0133 //! Returns true if there is another element in the iterator 0134 //! defined with the function Initialize (i.e. if there is another 0135 //! triangle containing the given node). 0136 bool More() const { return mymore; } 0137 0138 //! Advances the iterator defined with the function Initialize to 0139 //! access the next triangle. 0140 //! Note: There is no action if the iterator is empty (i.e. if the 0141 //! function More returns false).- 0142 Standard_EXPORT void Next(); 0143 0144 //! Returns the index of the current triangle to which the 0145 //! iterator, defined with the function Initialize, points. This is 0146 //! an index in the triangles table specific to the triangulation 0147 //! analyzed by this tool 0148 int Value() const { return mytr; } 0149 0150 private: 0151 occ::handle<Poly_Triangulation> myTriangulation; 0152 NCollection_Array1<int> myTriangles; 0153 NCollection_Array1<int> myAdjacents; 0154 int mytr; 0155 int myfirst; 0156 int mynode; 0157 int myothernode; 0158 bool mysense; 0159 bool mymore; 0160 TColStd_PackedMapOfInteger myPassedTr; 0161 }; 0162 0163 #endif // _Poly_Connect_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|