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