mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-06 12:48:52 +08:00
Removed tight connections between data structures, auxiliary tools and algorithms in order to create extensible solution, easy for maintenance and improvements; Code is separated on several functional units responsible for specific operation for the sake of simplification of debugging and readability; Introduced new data structures enabling possibility to manipulate discrete model of particular entity (edge, wire, face) in order to perform computations locally instead of processing an entire model. The workflow of updated component can be divided on six parts: * Creation of model data structure: source TopoDS_Shape passed to algorithm is analyzed and exploded on faces and edges. For each topological entity corresponding reflection is created in data model. Note that underlying algorithms use data model as input and access it via common interface which allows user to create custom data model with necessary dependencies between particular entities; * Discretize edges 3D & 2D curves: 3D curve as well as associated set of 2D curves of each model edge is discretized in order to create coherent skeleton used as a base in faces meshing process. In case if some edge of source shape already contains polygonal data which suites specified parameters, it is extracted from shape and stored to the model as is. Each edge is processed separately, adjacency is not taken into account; * Heal discrete model: source TopoDS_Shape can contain problems, such as open-wire or self-intersections, introduced during design, exchange or modification of model. In addition, some problems like self-intersections can be introduced by roughly discretized edges. This stage is responsible for analysis of discrete model in order to detect and repair faced problems or refuse model’s part for further processing in case if problem cannot be solved; * Preprocess discrete model: defines actions specific for implemented approach to be performed before meshing of faces. By default, iterates over model faces and checks consistency of existing triangulations. Cleans topological faces and its adjacent edges from polygonal data in case of inconsistency or marks face of discrete model as not required for computation; * Discretize faces: represents core part performing mesh generation for particular face based on 2D discrete data related to processing face. Caches polygonal data associated with face’s edges in data model for further processing and stores generated mesh to TopoDS_Face; * Postprocess discrete model: defines actions specific for implemented approach to be performed after meshing of faces. By default, stores polygonal data obtained on previous stage to TopoDS_Edge objects of source model. Component is now spread over IMeshData, IMeshTools, BRepMeshData and BRepMesh units. <!break> 1. Extend "tricheck" DRAW-command in order to find degenerated triangles. 2. Class BRepMesh_FastDiscret::Parameters has been declared as deprecated. 3. NURBS range splitter: do not split intervals without necessity. Intervals are split only in case if it is impossible to compute normals directly on intervals. 4. Default value of IMeshTools_Parameters::MinSize has been changed. New value is equal to 0.1*Deflection. 5. Correction of test scripts: 1) perf mesh bug27119: requested deflection is increased from 1e-6 to 1e-5 to keep reasonable performance (but still reproducing original issue) 2) bugs mesh bug26692_1, 2: make snapshot of triangulation instead of wireframe (irrelevant) Correction in upgrade guide.
309 lines
11 KiB
C++
309 lines
11 KiB
C++
// Copyright (c) 2013 OPEN CASCADE SAS
|
|
//
|
|
// This file is part of Open CASCADE Technology software library.
|
|
//
|
|
// This library is free software; you can redistribute it and/or modify it under
|
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
// by the Free Software Foundation, with special exception defined in the file
|
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
// distribution for complete text of the license and disclaimer of any warranty.
|
|
//
|
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
// commercial license or contractual agreement.
|
|
|
|
#ifndef _BRepMesh_DataStructureOfDelaun_HeaderFile
|
|
#define _BRepMesh_DataStructureOfDelaun_HeaderFile
|
|
|
|
#include <Standard_Transient.hxx>
|
|
#include <BRepMesh_Triangle.hxx>
|
|
#include <BRepMesh_PairOfIndex.hxx>
|
|
#include <Standard_OStream.hxx>
|
|
#include <IMeshData_Types.hxx>
|
|
#include <BRepMesh_VertexTool.hxx>
|
|
|
|
class BRepMesh_Vertex;
|
|
class BRepMesh_Edge;
|
|
|
|
//! Describes the data structure necessary for the mesh algorithms in
|
|
//! two dimensions plane or on surface by meshing in UV space.
|
|
class BRepMesh_DataStructureOfDelaun : public Standard_Transient
|
|
{
|
|
public:
|
|
|
|
//! Constructor.
|
|
//! @param theAllocator memory allocator to be used by internal structures.
|
|
//! @param theReservedNodeSize presumed number of nodes in this mesh.
|
|
Standard_EXPORT BRepMesh_DataStructureOfDelaun(
|
|
const Handle(NCollection_IncAllocator)& theAllocator,
|
|
const Standard_Integer theReservedNodeSize = 100);
|
|
|
|
|
|
|
|
public: //! @name API for accessing mesh nodes.
|
|
|
|
//! Returns number of nodes.
|
|
inline Standard_Integer NbNodes() const
|
|
{
|
|
return myNodes->Extent();
|
|
}
|
|
|
|
|
|
//! Adds node to the mesh if it is not already in the mesh.
|
|
//! @param theNode node to be added to the mesh.
|
|
//! @param isForceAdd adds the given node to structure without
|
|
//! checking on coincidence with other nodes.
|
|
//! @return index of the node in the structure.
|
|
Standard_EXPORT Standard_Integer AddNode(
|
|
const BRepMesh_Vertex& theNode,
|
|
const Standard_Boolean isForceAdd = Standard_False);
|
|
|
|
//! Finds the index of the given node.
|
|
//! @param theNode node to find.
|
|
//! @return index of the given element of zero if node is not in the mesh.
|
|
Standard_Integer IndexOf(const BRepMesh_Vertex& theNode)
|
|
{
|
|
return myNodes->FindIndex(theNode);
|
|
}
|
|
|
|
//! Get node by the index.
|
|
//! @param theIndex index of a node.
|
|
//! @return node with the given index.
|
|
inline const BRepMesh_Vertex& GetNode(const Standard_Integer theIndex)
|
|
{
|
|
return myNodes->FindKey(theIndex);
|
|
}
|
|
|
|
//! Alias for GetNode.
|
|
const BRepMesh_Vertex& operator ()(const Standard_Integer theIndex)
|
|
{
|
|
return GetNode(theIndex);
|
|
}
|
|
|
|
//! Substitutes the node with the given index by new one.
|
|
//! @param theIndex index of node to be substituted.
|
|
//! @param theNewNode substituting node.
|
|
//! @return FALSE in case if new node is already in the structure, TRUE elsewhere.
|
|
Standard_EXPORT Standard_Boolean SubstituteNode(
|
|
const Standard_Integer theIndex,
|
|
const BRepMesh_Vertex& theNewNode);
|
|
|
|
//! Removes node from the mesh in case if it has no connected links
|
|
//! and its type is Free.
|
|
//! @param theIndex index of node to be removed.
|
|
//! @param isForce if TRUE node will be removed even if movability
|
|
//! is not Free.
|
|
void RemoveNode(const Standard_Integer theIndex,
|
|
const Standard_Boolean isForce = Standard_False)
|
|
{
|
|
if (isForce || myNodes->FindKey(theIndex).Movability() == BRepMesh_Free)
|
|
{
|
|
if (LinksConnectedTo(theIndex).Extent()==0)
|
|
myNodes->DeleteVertex(theIndex);
|
|
}
|
|
}
|
|
|
|
//! Get list of links attached to the node with the given index.
|
|
//! @param theIndex index of node whose links should be retrieved.
|
|
//! @return list of links attached to the node.
|
|
inline const IMeshData::ListOfInteger& LinksConnectedTo(
|
|
const Standard_Integer theIndex) const
|
|
{
|
|
return linksConnectedTo(theIndex);
|
|
}
|
|
|
|
|
|
public: //! @name API for accessing mesh links.
|
|
|
|
//! Returns number of links.
|
|
inline Standard_Integer NbLinks() const
|
|
{
|
|
return myLinks.Extent();
|
|
}
|
|
|
|
//! Adds link to the mesh if it is not already in the mesh.
|
|
//! @param theLink link to be added to the mesh.
|
|
//! @return index of the link in the structure.
|
|
Standard_EXPORT Standard_Integer AddLink(const BRepMesh_Edge& theLink);
|
|
|
|
//! Finds the index of the given link.
|
|
//! @param theLink link to find.
|
|
//! @return index of the given element of zero if link is not in the mesh.
|
|
Standard_Integer IndexOf(const BRepMesh_Edge& theLink) const
|
|
{
|
|
return myLinks.FindIndex(theLink);
|
|
}
|
|
|
|
//! Get link by the index.
|
|
//! @param theIndex index of a link.
|
|
//! @return link with the given index.
|
|
const BRepMesh_Edge& GetLink(const Standard_Integer theIndex)
|
|
{
|
|
return myLinks.FindKey(theIndex);
|
|
}
|
|
|
|
//! Returns map of indices of links registered in mesh.
|
|
inline const IMeshData::MapOfInteger& LinksOfDomain() const
|
|
{
|
|
return myLinksOfDomain;
|
|
}
|
|
|
|
//! Substitutes the link with the given index by new one.
|
|
//! @param theIndex index of link to be substituted.
|
|
//! @param theNewLink substituting link.
|
|
//! @return FALSE in case if new link is already in the structure, TRUE elsewhere.
|
|
Standard_EXPORT Standard_Boolean SubstituteLink(const Standard_Integer theIndex,
|
|
const BRepMesh_Edge& theNewLink);
|
|
|
|
//! Removes link from the mesh in case if it has no connected elements
|
|
//! and its type is Free.
|
|
//! @param theIndex index of link to be removed.
|
|
//! @param isForce if TRUE link will be removed even if movability
|
|
//! is not Free.
|
|
Standard_EXPORT void RemoveLink(const Standard_Integer theIndex,
|
|
const Standard_Boolean isForce = Standard_False);
|
|
|
|
//! Returns indices of elements conected to the link with the given index.
|
|
//! @param theLinkIndex index of link whose data should be retrieved.
|
|
//! @return indices of elements conected to the link.
|
|
const BRepMesh_PairOfIndex& ElementsConnectedTo(
|
|
const Standard_Integer theLinkIndex) const
|
|
{
|
|
return myLinks.FindFromIndex(theLinkIndex);
|
|
}
|
|
|
|
|
|
|
|
public: //! @name API for accessing mesh elements.
|
|
|
|
//! Returns number of links.
|
|
inline Standard_Integer NbElements() const
|
|
{
|
|
return myElements.Size();
|
|
}
|
|
|
|
//! Adds element to the mesh if it is not already in the mesh.
|
|
//! @param theElement element to be added to the mesh.
|
|
//! @return index of the element in the structure.
|
|
Standard_EXPORT Standard_Integer AddElement(const BRepMesh_Triangle& theElement);
|
|
|
|
//! Get element by the index.
|
|
//! @param theIndex index of an element.
|
|
//! @return element with the given index.
|
|
const BRepMesh_Triangle& GetElement(const Standard_Integer theIndex)
|
|
{
|
|
return myElements.ChangeValue(theIndex - 1);
|
|
}
|
|
|
|
//! Returns map of indices of elements registered in mesh.
|
|
inline const IMeshData::MapOfInteger& ElementsOfDomain() const
|
|
{
|
|
return myElementsOfDomain;
|
|
}
|
|
|
|
//! Substitutes the element with the given index by new one.
|
|
//! @param theIndex index of element to be substituted.
|
|
//! @param theNewLink substituting element.
|
|
//! @return FALSE in case if new element is already in the structure, TRUE elsewhere.
|
|
Standard_EXPORT Standard_Boolean SubstituteElement(const Standard_Integer theIndex,
|
|
const BRepMesh_Triangle& theNewElement);
|
|
|
|
//! Removes element from the mesh.
|
|
//! @param theIndex index of element to be removed.
|
|
Standard_EXPORT void RemoveElement(const Standard_Integer theIndex);
|
|
|
|
//! Returns indices of nodes forming the given element.
|
|
//! @param theElement element which nodes should be retrieved.
|
|
//! @param[out] theNodes nodes of the given element.
|
|
Standard_EXPORT void ElementNodes(
|
|
const BRepMesh_Triangle& theElement,
|
|
Standard_Integer (&theNodes)[3]);
|
|
|
|
Standard_EXPORT void Dump(Standard_CString theFileNameStr);
|
|
|
|
|
|
|
|
public: //! @name Auxilary API
|
|
|
|
//! Dumps information about this structure.
|
|
//! @param theStream stream to be used for dump.
|
|
Standard_EXPORT void Statistics(Standard_OStream& theStream) const;
|
|
|
|
//! Returns memory allocator used by the structure.
|
|
inline const Handle(NCollection_IncAllocator)& Allocator() const
|
|
{
|
|
return myAllocator;
|
|
}
|
|
|
|
//! Gives the data structure for initialization of cell size and tolerance.
|
|
inline const Handle(BRepMesh_VertexTool)& Data()
|
|
{
|
|
return myNodes;
|
|
}
|
|
|
|
//! Removes all elements.
|
|
Standard_EXPORT void ClearDomain();
|
|
|
|
//! Substitutes deleted items by the last one from corresponding map
|
|
//! to have only non-deleted elements, links or nodes in the structure.
|
|
void ClearDeleted()
|
|
{
|
|
clearDeletedLinks();
|
|
clearDeletedNodes();
|
|
}
|
|
|
|
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DataStructureOfDelaun, Standard_Transient)
|
|
|
|
private:
|
|
|
|
//! Get list of links attached to the node with the given index.
|
|
//! @param theIndex index of node whose links should be retrieved.
|
|
//! @return list of links attached to the node.
|
|
inline IMeshData::ListOfInteger& linksConnectedTo(
|
|
const Standard_Integer theIndex) const
|
|
{
|
|
return (IMeshData::ListOfInteger&)myNodeLinks.Find(theIndex);
|
|
}
|
|
|
|
//! Substitutes deleted links by the last one from corresponding map
|
|
//! to have only non-deleted links in the structure.
|
|
Standard_EXPORT void clearDeletedLinks();
|
|
|
|
//! Substitutes deleted nodes by the last one from corresponding map
|
|
//! to have only non-deleted nodes in the structure.
|
|
Standard_EXPORT void clearDeletedNodes();
|
|
|
|
//! Cleans dependent structures from the given link.
|
|
//! @param theIndex index of link in the data structure.
|
|
//! @param theLink reference to the link to avoid double accessing
|
|
//! to map of links.
|
|
void cleanLink(const Standard_Integer theIndex,
|
|
const BRepMesh_Edge& theLink);
|
|
|
|
//! Cleans dependent structures from the given element.
|
|
//! @param theIndex index of element in the data structure.
|
|
//! @param theElement reference to the element to avoid double accessing
|
|
//! to map of elements.
|
|
void cleanElement(const Standard_Integer theIndex,
|
|
const BRepMesh_Triangle& theElement);
|
|
|
|
//! Removes element index from the given pair. Used by cleanElement.
|
|
//! @param theIndex index of element to be removed.
|
|
//! @param thePair pair of elements to be cleaned.
|
|
void removeElementIndex(const Standard_Integer theIndex,
|
|
BRepMesh_PairOfIndex& thePair);
|
|
|
|
|
|
private:
|
|
|
|
Handle(NCollection_IncAllocator) myAllocator;
|
|
Handle(BRepMesh_VertexTool) myNodes;
|
|
IMeshData::DMapOfIntegerListOfInteger myNodeLinks;
|
|
IMeshData::IDMapOfLink myLinks;
|
|
IMeshData::ListOfInteger myDelLinks;
|
|
IMeshData::VectorOfElements myElements;
|
|
IMeshData::MapOfInteger myElementsOfDomain;
|
|
IMeshData::MapOfInteger myLinksOfDomain;
|
|
};
|
|
|
|
#endif
|