|
|
|||
File indexing completed on 2026-09-22 08:57:17
0001 // Copyright (c) 2013 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _BRepMesh_DataStructureOfDelaun_HeaderFile 0015 #define _BRepMesh_DataStructureOfDelaun_HeaderFile 0016 0017 #include <Standard_Transient.hxx> 0018 #include <BRepMesh_VertexTool.hxx> 0019 0020 class BRepMesh_Edge; 0021 0022 //! Describes the data structure necessary for the mesh algorithms in 0023 //! two dimensions plane or on surface by meshing in UV space. 0024 class BRepMesh_DataStructureOfDelaun : public Standard_Transient 0025 { 0026 public: 0027 //! Constructor. 0028 //! @param theAllocator memory allocator to be used by internal structures. 0029 //! @param theReservedNodeSize presumed number of nodes in this mesh. 0030 Standard_EXPORT BRepMesh_DataStructureOfDelaun( 0031 const occ::handle<NCollection_IncAllocator>& theAllocator, 0032 const int theReservedNodeSize = 100); 0033 0034 public: //! @name API for accessing mesh nodes. 0035 //! Returns number of nodes. 0036 int NbNodes() const { return myNodes->Extent(); } 0037 0038 //! Adds node to the mesh if it is not already in the mesh. 0039 //! @param theNode node to be added to the mesh. 0040 //! @param isForceAdd adds the given node to structure without 0041 //! checking on coincidence with other nodes. 0042 //! @return index of the node in the structure. 0043 Standard_EXPORT int AddNode(const BRepMesh_Vertex& theNode, const bool isForceAdd = false); 0044 0045 //! Finds the index of the given node. 0046 //! @param theNode node to find. 0047 //! @return index of the given element of zero if node is not in the mesh. 0048 int IndexOf(const BRepMesh_Vertex& theNode) { return myNodes->FindIndex(theNode); } 0049 0050 //! Get node by the index. 0051 //! @param theIndex index of a node. 0052 //! @return node with the given index. 0053 const BRepMesh_Vertex& GetNode(const int theIndex) { return myNodes->FindKey(theIndex); } 0054 0055 //! Alias for GetNode. 0056 const BRepMesh_Vertex& operator()(const int theIndex) { return GetNode(theIndex); } 0057 0058 //! Substitutes the node with the given index by new one. 0059 //! @param theIndex index of node to be substituted. 0060 //! @param theNewNode substituting node. 0061 //! @return FALSE in case if new node is already in the structure, TRUE elsewhere. 0062 Standard_EXPORT bool SubstituteNode(const int theIndex, const BRepMesh_Vertex& theNewNode); 0063 0064 //! Removes node from the mesh in case if it has no connected links 0065 //! and its type is Free. 0066 //! @param theIndex index of node to be removed. 0067 //! @param isForce if TRUE node will be removed even if movability 0068 //! is not Free. 0069 void RemoveNode(const int theIndex, const bool isForce = false) 0070 { 0071 if (isForce || myNodes->FindKey(theIndex).Movability() == BRepMesh_Free) 0072 { 0073 if (LinksConnectedTo(theIndex).Extent() == 0) 0074 myNodes->DeleteVertex(theIndex); 0075 } 0076 } 0077 0078 //! Get list of links attached to the node with the given index. 0079 //! @param theIndex index of node whose links should be retrieved. 0080 //! @return list of links attached to the node. 0081 const IMeshData::ListOfInteger& LinksConnectedTo(const int theIndex) const 0082 { 0083 return linksConnectedTo(theIndex); 0084 } 0085 0086 public: //! @name API for accessing mesh links. 0087 //! Returns number of links. 0088 int NbLinks() const { return myLinks.Extent(); } 0089 0090 //! Adds link to the mesh if it is not already in the mesh. 0091 //! @param theLink link to be added to the mesh. 0092 //! @return index of the link in the structure. 0093 Standard_EXPORT int AddLink(const BRepMesh_Edge& theLink); 0094 0095 //! Finds the index of the given link. 0096 //! @param theLink link to find. 0097 //! @return index of the given element of zero if link is not in the mesh. 0098 int IndexOf(const BRepMesh_Edge& theLink) const { return myLinks.FindIndex(theLink); } 0099 0100 //! Get link by the index. 0101 //! @param theIndex index of a link. 0102 //! @return link with the given index. 0103 const BRepMesh_Edge& GetLink(const int theIndex) { return myLinks.FindKey(theIndex); } 0104 0105 //! Returns map of indices of links registered in mesh. 0106 const IMeshData::MapOfInteger& LinksOfDomain() const { return myLinksOfDomain; } 0107 0108 //! Substitutes the link with the given index by new one. 0109 //! @param theIndex index of link to be substituted. 0110 //! @param theNewLink substituting link. 0111 //! @return FALSE in case if new link is already in the structure, TRUE elsewhere. 0112 Standard_EXPORT bool SubstituteLink(const int theIndex, const BRepMesh_Edge& theNewLink); 0113 0114 //! Removes link from the mesh in case if it has no connected elements 0115 //! and its type is Free. 0116 //! @param theIndex index of link to be removed. 0117 //! @param isForce if TRUE link will be removed even if movability 0118 //! is not Free. 0119 Standard_EXPORT void RemoveLink(const int theIndex, const bool isForce = false); 0120 0121 //! Returns indices of elements connected to the link with the given index. 0122 //! @param theLinkIndex index of link whose data should be retrieved. 0123 //! @return indices of elements connected to the link. 0124 const BRepMesh_PairOfIndex& ElementsConnectedTo(const int theLinkIndex) const 0125 { 0126 return myLinks.FindFromIndex(theLinkIndex); 0127 } 0128 0129 public: //! @name API for accessing mesh elements. 0130 //! Returns number of links. 0131 int NbElements() const { return myElements.Length(); } 0132 0133 //! Adds element to the mesh if it is not already in the mesh. 0134 //! @param theElement element to be added to the mesh. 0135 //! @return index of the element in the structure. 0136 Standard_EXPORT int AddElement(const BRepMesh_Triangle& theElement); 0137 0138 //! Get element by the index. 0139 //! @param theIndex index of an element. 0140 //! @return element with the given index. 0141 const BRepMesh_Triangle& GetElement(const int theIndex) 0142 { 0143 return myElements.ChangeValue(theIndex - 1); 0144 } 0145 0146 //! Returns map of indices of elements registered in mesh. 0147 const IMeshData::MapOfInteger& ElementsOfDomain() const { return myElementsOfDomain; } 0148 0149 //! Substitutes the element with the given index by new one. 0150 //! @param theIndex index of element to be substituted. 0151 //! @param theNewLink substituting element. 0152 //! @return FALSE in case if new element is already in the structure, TRUE elsewhere. 0153 Standard_EXPORT bool SubstituteElement(const int theIndex, 0154 const BRepMesh_Triangle& theNewElement); 0155 0156 //! Removes element from the mesh. 0157 //! @param theIndex index of element to be removed. 0158 Standard_EXPORT void RemoveElement(const int theIndex); 0159 0160 //! Returns indices of nodes forming the given element. 0161 //! @param theElement element which nodes should be retrieved. 0162 //! @param[out] theNodes nodes of the given element. 0163 Standard_EXPORT void ElementNodes(const BRepMesh_Triangle& theElement, int (&theNodes)[3]); 0164 0165 Standard_EXPORT void Dump(const char* theFileNameStr); 0166 0167 public: //! @name Auxiliary API 0168 //! Returns memory allocator used by the structure. 0169 const occ::handle<NCollection_IncAllocator>& Allocator() const { return myAllocator; } 0170 0171 //! Gives the data structure for initialization of cell size and tolerance. 0172 const occ::handle<BRepMesh_VertexTool>& Data() { return myNodes; } 0173 0174 //! Removes all elements. 0175 Standard_EXPORT void ClearDomain(); 0176 0177 //! Substitutes deleted items by the last one from corresponding map 0178 //! to have only non-deleted elements, links or nodes in the structure. 0179 void ClearDeleted() 0180 { 0181 clearDeletedLinks(); 0182 clearDeletedNodes(); 0183 } 0184 0185 DEFINE_STANDARD_RTTIEXT(BRepMesh_DataStructureOfDelaun, Standard_Transient) 0186 0187 private: 0188 //! Get list of links attached to the node with the given index. 0189 //! @param theIndex index of node whose links should be retrieved. 0190 //! @return list of links attached to the node. 0191 IMeshData::ListOfInteger& linksConnectedTo(const int theIndex) const 0192 { 0193 return (IMeshData::ListOfInteger&)myNodeLinks.Find(theIndex); 0194 } 0195 0196 //! Substitutes deleted links by the last one from corresponding map 0197 //! to have only non-deleted links in the structure. 0198 Standard_EXPORT void clearDeletedLinks(); 0199 0200 //! Substitutes deleted nodes by the last one from corresponding map 0201 //! to have only non-deleted nodes in the structure. 0202 Standard_EXPORT void clearDeletedNodes(); 0203 0204 //! Cleans dependent structures from the given link. 0205 //! @param theIndex index of link in the data structure. 0206 //! @param theLink reference to the link to avoid double accessing 0207 //! to map of links. 0208 void cleanLink(const int theIndex, const BRepMesh_Edge& theLink); 0209 0210 //! Cleans dependent structures from the given element. 0211 //! @param theIndex index of element in the data structure. 0212 //! @param theElement reference to the element to avoid double accessing 0213 //! to map of elements. 0214 void cleanElement(const int theIndex, const BRepMesh_Triangle& theElement); 0215 0216 //! Removes element index from the given pair. Used by cleanElement. 0217 //! @param theIndex index of element to be removed. 0218 //! @param thePair pair of elements to be cleaned. 0219 void removeElementIndex(const int theIndex, BRepMesh_PairOfIndex& thePair); 0220 0221 private: 0222 occ::handle<NCollection_IncAllocator> myAllocator; 0223 occ::handle<BRepMesh_VertexTool> myNodes; 0224 IMeshData::DMapOfIntegerListOfInteger myNodeLinks; 0225 IMeshData::IDMapOfLink myLinks; 0226 IMeshData::ListOfInteger myDelLinks; 0227 IMeshData::VectorOfElements myElements; 0228 IMeshData::MapOfInteger myElementsOfDomain; 0229 IMeshData::MapOfInteger myLinksOfDomain; 0230 }; 0231 0232 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|