Coding - Refactoring BOPDS (#1007)

- Modernized C++ code using range-based for loops, structured bindings, and initializer lists
- Improved parameter and variable naming throughout the codebase for clarity
- Added parameterized constructors for `BOPDS_Pave` and `BOPDS_IndexRange` classes
This commit is contained in:
Dmitrii Kulikov
2026-01-21 14:12:18 +00:00
committed by GitHub
parent 36e781813e
commit 20956a5f29
8 changed files with 1190 additions and 1505 deletions
File diff suppressed because it is too large Load Diff
+72 -29
View File
@@ -251,8 +251,9 @@ public:
//! Selector
//! Returns the indices of alone vertices
//! for the face with index theIndex
Standard_EXPORT void AloneVertices(const int theF, NCollection_List<int>& theLI) const;
//! for the face with index @p theFaceIndex
Standard_EXPORT void AloneVertices(const int theFaceIndex,
NCollection_List<int>& theVertexList) const;
//! Refine the state On for the all faces having
//! state information
@@ -264,25 +265,25 @@ public:
Standard_EXPORT void RefineFaceInfoIn();
//! Returns information about ON/IN sub-shapes of the given faces.
//! @param theFaceIndex1 the index of the first face
//! @param theFaceIndex2 the index of the second face
//! @param theMVOnIn the indices of ON/IN vertices from both faces
//! @param theMVCommon the indices of common vertices for both faces
//! @param thePBOnIn all On/In pave blocks from both faces
//! @param theCommonPB the common pave blocks (that are shared by both faces).
//! @param theCommonPaveBlocks the common pave blocks (that are shared by both faces).
Standard_EXPORT void SubShapesOnIn(
const int theNF1,
const int theNF2,
const int theFaceIndex1,
const int theFaceIndex2,
NCollection_Map<int>& theMVOnIn,
NCollection_Map<int>& theMVCommon,
NCollection_IndexedMap<occ::handle<BOPDS_PaveBlock>>& thePBOnIn,
NCollection_Map<occ::handle<BOPDS_PaveBlock>>& theCommonPB) const;
NCollection_Map<occ::handle<BOPDS_PaveBlock>>& theCommonPaveBlocks) const;
//! Returns the indices of edges that are shared
//! for the faces with indices theF1, theF2
//!
//! same domain shapes
Standard_EXPORT void SharedEdges(const int theF1,
const int theF2,
NCollection_List<int>& theLI,
//! for the faces with indices @p theFaceIndex1 and @p theFaceIndex2.
Standard_EXPORT void SharedEdges(const int theFaceIndex1,
const int theFaceIndex2,
NCollection_List<int>& theEdgeList,
const occ::handle<NCollection_BaseAllocator>& theAllocator);
//! Selector
@@ -302,6 +303,10 @@ public:
//! interferences
Standard_EXPORT bool HasShapeSD(const int theIndex, int& theIndexSD) const;
//! Returns the index of same domain shape for the shape
//! with index @p theIndex. If there is no same domain shape, returns @p theIndex itself.
Standard_EXPORT int GetSameDomainIndex(const int theIndex) const;
//! Selector/Modifier
//! Returns the collection of interferences Vertex/Vertex
NCollection_Vector<BOPDS_InterfVV>& InterfVV();
@@ -362,18 +367,18 @@ public:
bool HasInterf(const int theI1, const int theI2) const;
//! Query
//! Returns true if the shape with index theI1 is interfered
//! Returns true if the shape with index theIndex1 is interfered
//! with
//! any sub-shape of the shape with index theI2 (theFlag=true)
//! all sub-shapes of the shape with index theI2 (theFlag=false)
Standard_EXPORT bool HasInterfShapeSubShapes(const int theI1,
const int theI2,
const bool theFlag = true) const;
//! any sub-shape of the shape with index theIndex2 (theAnyInterference=true)
//! all sub-shapes of the shape with index theIndex2 (theAnyInterference=false)
Standard_EXPORT bool HasInterfShapeSubShapes(const int theIndex1,
const int theIndex2,
const bool theAnyInterference = true) const;
//! Query
//! Returns true if the shapes with indices theI1, theI2
//! Returns true if the shapes with indices theIndex1, theIndex2
//! have interferred sub-shapes
Standard_EXPORT bool HasInterfSubShapes(const int theI1, const int theI2) const;
Standard_EXPORT bool HasInterfSubShapes(const int theIndex1, const int theIndex2) const;
//! Selector
//! Returns the table of interferences
@@ -383,7 +388,9 @@ public:
Standard_EXPORT void Dump() const;
Standard_EXPORT bool IsSubShape(const int theI1, const int theI2);
//! Returns true if the shape with index @p theCandidate is a sub-shape
//! of the shape with index @p theParent
Standard_EXPORT bool IsSubShape(const int theCandidate, const int theParent);
//! Fills theLP with sorted paves
//! of the shape with index theIndex
@@ -416,23 +423,59 @@ public:
Bnd_Box& theBox,
const bool theCheckInverted = true);
protected:
private:
//! Initializes the pave blocks for the shape with index theIndex
Standard_EXPORT void InitPaveBlocks(const int theIndex);
void InitPaveBlocks(const int theIndex);
//! Initializes the state of face with index theIndex
Standard_EXPORT void InitFaceInfo(const int theIndex);
void InitFaceInfo(const int theIndex);
//! Initializes the FaceInfo structure for face with index theIndex with elements
//! having IN state for the face
Standard_EXPORT void InitFaceInfoIn(const int theIndex);
void InitFaceInfoIn(const int theIndex);
Standard_EXPORT void InitShape(const int theIndex, const TopoDS_Shape& theS);
void InitShape(const int theIndex, const TopoDS_Shape& theS);
Standard_EXPORT bool CheckCoincidence(const occ::handle<BOPDS_PaveBlock>& thePB1,
const occ::handle<BOPDS_PaveBlock>& thePB2,
const double theFuzz);
bool CheckCoincidence(const occ::handle<BOPDS_PaveBlock>& thePB1,
const occ::handle<BOPDS_PaveBlock>& thePB2,
const double theFuzz);
//! Prepares vertices, updates their bounding boxes.
//! @param theAdditionalTolerance The additional tolerance to be added to the
//! gaps of the bounding boxes.
//! @return The number of vertices processed.
int prepareVertices(const double theAdditionalTolerance);
//! Prepares edges, updates their bounding boxes,
//! sets degenerated flag for degenerated edges, creates start/end vertices for infinite edges.
//! @param theAdditionalTolerance The additional tolerance to be added to the
//! gaps of the bounding boxes.
//! @return The number of edges processed.
int prepareEdges(const double theAdditionalTolerance);
//! Prepares faces, updates their bounding boxes and sub-shapes.
//! Initially, subshapes of the faces are wires. They will be updated to
//! contain edges and vertices.
//! @param theAdditionalTolerance The additional tolerance to be added to the
//! gaps of the bounding boxes.
//! @return The number of faces processed.
int prepareFaces(const double theAdditionalTolerance);
//! Prepares solids, updates their bounding boxes and sub-shapes.
//! Initially, subshapes of the solids are shells. They will be updated to
//! contain faces and edges.
//! @param theAdditionalTolerance The additional tolerance to be added to the
//! gaps of the bounding boxes.
//! @return The number of solids processed.
int prepareSolids();
//! Prepares the Vertex-Edge connection map.
//! For the index of each vertex in the data structure,
//! finds all edges sharing this vertex and
//! stores the indices of these edges in a map.
void buildVertexEdgeMap();
private:
occ::handle<NCollection_BaseAllocator> myAllocator;
NCollection_List<TopoDS_Shape> myArguments;
int myNbShapes;
@@ -31,6 +31,9 @@ public:
//! Empty constructor
BOPDS_IndexRange();
//! Constructor with initial indices
BOPDS_IndexRange(const int theI1, const int theI2);
//! Modifier
//! Sets the first index <theI1> of the range
void SetFirst(const int theI1);
@@ -22,6 +22,14 @@ inline BOPDS_IndexRange::BOPDS_IndexRange()
//=================================================================================================
inline BOPDS_IndexRange::BOPDS_IndexRange(const int theI1, const int theI2)
: myFirst(theI1),
myLast(theI2)
{
}
//=================================================================================================
inline void BOPDS_IndexRange::SetFirst(const int aFirst)
{
myFirst = aFirst;
@@ -21,6 +21,8 @@
#include <BOPDS_Curve.hxx>
#include <BOPDS_Point.hxx>
#include <optional>
/**
* The class BOPDS_Interf stores the information about
* the interference between two shapes.
@@ -164,7 +166,14 @@ public:
* the index
* @return true if the interference has index of new shape
*/
bool HasIndexNew() const { return (myIndexNew + 1) != 0; }
bool HasIndexNew() const { return myIndexNew != -1; }
//! Returns the index of new shape.
//! If the index is not set, returns std::nullopt.
std::optional<int> GetIndexNew() const
{
return myIndexNew != -1 ? std::optional<int>(myIndexNew) : std::nullopt;
}
//
protected:
@@ -32,6 +32,9 @@ public:
//! Empty constructor
BOPDS_Pave();
//! Constructor with index and parameter
BOPDS_Pave(const int theIndex, const double theParameter);
//! Modifier
//! Sets the index of vertex <theIndex>
void SetIndex(const int theIndex);
@@ -15,9 +15,16 @@
//=================================================================================================
inline BOPDS_Pave::BOPDS_Pave()
: myIndex(-1),
myParameter(99.)
{
}
//==============================================================================================
inline BOPDS_Pave::BOPDS_Pave(const int theIndex, const double theParameter)
: myIndex(theIndex),
myParameter(theParameter)
{
myIndex = -1;
myParameter = 99.;
}
//=================================================================================================
@@ -67,8 +74,5 @@ inline bool BOPDS_Pave::IsLess(const BOPDS_Pave& theOther) const
inline bool BOPDS_Pave::IsEqual(const BOPDS_Pave& theOther) const
{
bool bFlag;
//
bFlag = ((myIndex == theOther.myIndex) && (myParameter == theOther.myParameter));
return bFlag;
return myIndex == theOther.myIndex && myParameter == theOther.myParameter;
}
@@ -252,10 +252,8 @@ int IntTools_Tools::SplitCurve(const IntTools_Curve& IC, NCollection_Sequence<In
double IntTools_Tools::IntermediatePoint(const double aFirst, const double aLast)
{
// define parameter division number as 10*e^(-M_PI) = 0.43213918
const double PAR_T = 0.43213918;
double aParm;
aParm = (1. - PAR_T) * aFirst + PAR_T * aLast;
return aParm;
constexpr double PAR_T = 0.43213918;
return (1. - PAR_T) * aFirst + PAR_T * aLast;
}
//=================================================================================================