|
|
|||
File indexing completed on 2026-07-23 09:18:40
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 <TColStd_Array1OfInteger.hxx> 0025 #include <TColStd_PackedMapOfInteger.hxx> 0026 #include <Standard_Integer.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 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 Handle(Poly_Triangulation)& theTriangulation); 0078 0079 //! Returns the triangulation analyzed by this tool. 0080 const 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 Standard_Integer Triangle(const Standard_Integer 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 Standard_Integer T, 0093 Standard_Integer& t1, 0094 Standard_Integer& t2, 0095 Standard_Integer& t3) const 0096 { 0097 Standard_Integer index = 6 * (T - 1); 0098 t1 = myAdjacents(index + 1); 0099 t2 = myAdjacents(index + 2); 0100 t3 = myAdjacents(index + 3); 0101 } 0102 0103 //! Returns, in n1, n2 and n3, the indices of the 3 nodes 0104 //! adjacent to the triangle referenced at index T in the 0105 //! triangles table specific to the triangulation analyzed by this tool. 0106 //! Warning 0107 //! Null indices are returned when there are fewer than 3 adjacent nodes. 0108 void Nodes(const Standard_Integer T, 0109 Standard_Integer& n1, 0110 Standard_Integer& n2, 0111 Standard_Integer& n3) const 0112 { 0113 Standard_Integer index = 6 * (T - 1); 0114 n1 = myAdjacents(index + 4); 0115 n2 = myAdjacents(index + 5); 0116 n3 = myAdjacents(index + 6); 0117 } 0118 0119 public: 0120 //! Initializes an iterator to search for all the triangles 0121 //! containing the node referenced at index N in the nodes 0122 //! table, for the triangulation analyzed by this tool. 0123 //! The iterator is managed by the following functions: 0124 //! - More, which checks if there are still elements in the iterator 0125 //! - Next, which positions the iterator on the next element 0126 //! - Value, which returns the current element. 0127 //! The use of such an iterator provides direct access to the 0128 //! triangles around a particular node, i.e. it avoids iterating on 0129 //! all the component triangles of a triangulation. 0130 //! Example 0131 //! Poly_Connect C(Tr); 0132 //! for 0133 //! (C.Initialize(n1);C.More();C.Next()) 0134 //! { 0135 //! t = C.Value(); 0136 //! } 0137 Standard_EXPORT void Initialize(const Standard_Integer N); 0138 0139 //! Returns true if there is another element in the iterator 0140 //! defined with the function Initialize (i.e. if there is another 0141 //! triangle containing the given node). 0142 Standard_Boolean More() const { return mymore; } 0143 0144 //! Advances the iterator defined with the function Initialize to 0145 //! access the next triangle. 0146 //! Note: There is no action if the iterator is empty (i.e. if the 0147 //! function More returns false).- 0148 Standard_EXPORT void Next(); 0149 0150 //! Returns the index of the current triangle to which the 0151 //! iterator, defined with the function Initialize, points. This is 0152 //! an index in the triangles table specific to the triangulation 0153 //! analyzed by this tool 0154 Standard_Integer Value() const { return mytr; } 0155 0156 private: 0157 Handle(Poly_Triangulation) myTriangulation; 0158 TColStd_Array1OfInteger myTriangles; 0159 TColStd_Array1OfInteger myAdjacents; 0160 Standard_Integer mytr; 0161 Standard_Integer myfirst; 0162 Standard_Integer mynode; 0163 Standard_Integer myothernode; 0164 Standard_Boolean mysense; 0165 Standard_Boolean mymore; 0166 TColStd_PackedMapOfInteger myPassedTr; 0167 }; 0168 0169 #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 |
|