Modeling - Refactor BRepClass and FaceClassifier Implementation (#1167)

- Migrated `TopClass_FaceClassifier` / `TopClass_Classifier2d` implementations to `.pxx` and updated BRepClass/Geom2dHatch wrappers to use them (removing `_0.cxx` generator glue).
- Updated BRep class helper headers to use header inlines instead of separate `.lxx` files, and added/rewired passive/face classifier implementations.
- Extended `NCollection_DynamicArray` / `NCollection_KDTree` APIs (insert helpers, callback-based range query) and added GTests for the new vector insert operations.
This commit is contained in:
Pasukhin Dmitry
2026-03-23 18:15:04 +00:00
committed by GitHub
parent 519036936b
commit 4ec89df6f5
42 changed files with 1233 additions and 959 deletions
@@ -125,6 +125,19 @@ CSLib_Class2d::CSLib_Class2d(const NCollection_Sequence<gp_Pnt2d>& thePnts2d,
//=================================================================================================
CSLib_Class2d::CSLib_Class2d(const NCollection_Vector<gp_Pnt2d>& thePnts2d,
const double theTolU,
const double theTolV,
const double theUMin,
const double theVMin,
const double theUMax,
const double theVMax)
{
init(thePnts2d, theTolU, theTolV, theUMin, theVMin, theUMax, theVMax);
}
//=================================================================================================
CSLib_Class2d::Result CSLib_Class2d::SiDans(const gp_Pnt2d& thePoint) const
{
if (myPointsCount == 0)
@@ -22,6 +22,7 @@
#include <gp_Pnt2d.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_Vector.hxx>
class gp_Pnt2d;
@@ -90,6 +91,25 @@ public:
double theUMax,
double theVMax);
//! Constructs a 2D classifier from a vector of polygon vertices.
//!
//! Same as the array constructor but accepts a vector for convenience.
//!
//! @param[in] thePnts2d Vector of polygon vertices (minimum 3 points required)
//! @param[in] theTolU Tolerance in U direction for boundary detection
//! @param[in] theTolV Tolerance in V direction for boundary detection
//! @param[in] theUMin Minimum U bound of the polygon domain
//! @param[in] theVMin Minimum V bound of the polygon domain
//! @param[in] theUMax Maximum U bound of the polygon domain
//! @param[in] theVMax Maximum V bound of the polygon domain
Standard_EXPORT CSLib_Class2d(const NCollection_Vector<gp_Pnt2d>& thePnts2d,
double theTolU,
double theTolV,
double theUMin,
double theVMin,
double theUMax,
double theVMax);
//! Move constructor.
CSLib_Class2d(CSLib_Class2d&& theOther) noexcept
: myPnts2dX(std::move(theOther.myPnts2dX)),
@@ -644,4 +644,158 @@ TEST(NCollection_VectorTest, SetValue_ReplacesExisting)
EXPECT_EQ(10, aVector(0).myA);
EXPECT_EQ(200, aVector(1).myA);
EXPECT_EQ(30, aVector(2).myA);
}
TEST(NCollection_VectorTest, InsertAfter_Middle)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(20);
aVector.Append(30);
aVector.Append(40);
// Insert 99 after index 1 (after 20): [10, 20, 99, 30, 40]
aVector.InsertAfter(1, 99);
EXPECT_EQ(5, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(20, aVector(1));
EXPECT_EQ(99, aVector(2));
EXPECT_EQ(30, aVector(3));
EXPECT_EQ(40, aVector(4));
}
TEST(NCollection_VectorTest, InsertAfter_First)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(20);
aVector.Append(30);
// Insert 99 after index 0 (after 10): [10, 99, 20, 30]
aVector.InsertAfter(0, 99);
EXPECT_EQ(4, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(99, aVector(1));
EXPECT_EQ(20, aVector(2));
EXPECT_EQ(30, aVector(3));
}
TEST(NCollection_VectorTest, InsertAfter_Last)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(20);
aVector.Append(30);
// Insert 99 after last index (after 30): [10, 20, 30, 99]
aVector.InsertAfter(2, 99);
EXPECT_EQ(4, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(20, aVector(1));
EXPECT_EQ(30, aVector(2));
EXPECT_EQ(99, aVector(3));
}
TEST(NCollection_VectorTest, InsertAfter_SingleElement)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
// Insert 99 after index 0: [10, 99]
aVector.InsertAfter(0, 99);
EXPECT_EQ(2, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(99, aVector(1));
}
TEST(NCollection_VectorTest, InsertBefore_Middle)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(20);
aVector.Append(30);
aVector.Append(40);
// Insert 99 before index 2 (before 30): [10, 20, 99, 30, 40]
aVector.InsertBefore(2, 99);
EXPECT_EQ(5, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(20, aVector(1));
EXPECT_EQ(99, aVector(2));
EXPECT_EQ(30, aVector(3));
EXPECT_EQ(40, aVector(4));
}
TEST(NCollection_VectorTest, InsertBefore_First)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(20);
aVector.Append(30);
// Insert 99 before index 0: [99, 10, 20, 30]
aVector.InsertBefore(0, 99);
EXPECT_EQ(4, aVector.Length());
EXPECT_EQ(99, aVector(0));
EXPECT_EQ(10, aVector(1));
EXPECT_EQ(20, aVector(2));
EXPECT_EQ(30, aVector(3));
}
TEST(NCollection_VectorTest, InsertBefore_Last)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(20);
aVector.Append(30);
// Insert 99 before last index (before 30): [10, 20, 99, 30]
aVector.InsertBefore(2, 99);
EXPECT_EQ(4, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(20, aVector(1));
EXPECT_EQ(99, aVector(2));
EXPECT_EQ(30, aVector(3));
}
TEST(NCollection_VectorTest, InsertAfter_MoveSemantics)
{
NCollection_Vector<VecMoveOnlyType> aVector;
aVector.EmplaceAppend(10);
aVector.EmplaceAppend(20);
aVector.EmplaceAppend(30);
// Move-insert 99 after index 1: [10, 20, 99, 30]
aVector.InsertAfter(1, VecMoveOnlyType(99));
EXPECT_EQ(4, aVector.Length());
EXPECT_EQ(10, aVector(0).myValue);
EXPECT_EQ(20, aVector(1).myValue);
EXPECT_EQ(99, aVector(2).myValue);
EXPECT_EQ(30, aVector(3).myValue);
}
TEST(NCollection_VectorTest, InsertAfter_MultipleInserts)
{
NCollection_Vector<int> aVector;
aVector.Append(10);
aVector.Append(40);
// Insert 20 after 10: [10, 20, 40]
aVector.InsertAfter(0, 20);
// Insert 30 after 20: [10, 20, 30, 40]
aVector.InsertAfter(1, 30);
EXPECT_EQ(4, aVector.Length());
EXPECT_EQ(10, aVector(0));
EXPECT_EQ(20, aVector(1));
EXPECT_EQ(30, aVector(2));
EXPECT_EQ(40, aVector(3));
}
@@ -27,7 +27,9 @@
#include <StdFail_NotDone.hxx>
#include <NCollection_IndexedIterator.hxx>
#include <cstring>
#include <locale>
#include <type_traits>
#include <vector>
//! Class NCollection_DynamicArray (dynamic array of objects)
@@ -234,14 +236,73 @@ public: //! @name public methods
return *aPnt;
}
//! Insert a value after the element at theIndex, shifting subsequent elements right.
//! @param theIndex index after which to insert (must be in [0, Length()-1])
//! @param theValue value to insert
//! @return reference to the inserted element
reference InsertAfter(const int theIndex, const TheItemType& theValue)
{
Standard_OutOfRange_Raise_if(theIndex < 0 || static_cast<size_t>(theIndex) >= myUsedSize,
"NCollection_DynamicArray::InsertAfter: index out of range");
// Grow by one element at the end.
Appended();
// Shift elements [theIndex+1 .. myUsedSize-2] right by one position.
for (size_t i = myUsedSize - 1; i > static_cast<size_t>(theIndex) + 1; --i)
at(i) = std::move(at(i - 1));
at(static_cast<size_t>(theIndex) + 1) = theValue;
return at(static_cast<size_t>(theIndex) + 1);
}
//! Insert a value after the element at theIndex (move version).
reference InsertAfter(const int theIndex, TheItemType&& theValue)
{
Standard_OutOfRange_Raise_if(theIndex < 0 || static_cast<size_t>(theIndex) >= myUsedSize,
"NCollection_DynamicArray::InsertAfter: index out of range");
Appended();
for (size_t i = myUsedSize - 1; i > static_cast<size_t>(theIndex) + 1; --i)
at(i) = std::move(at(i - 1));
at(static_cast<size_t>(theIndex) + 1) = std::forward<TheItemType>(theValue);
return at(static_cast<size_t>(theIndex) + 1);
}
//! Insert a value before the element at theIndex, shifting it and subsequent elements right.
//! @param theIndex index before which to insert (must be in [0, Length()-1])
//! @param theValue value to insert
//! @return reference to the inserted element
reference InsertBefore(const int theIndex, const TheItemType& theValue)
{
Standard_OutOfRange_Raise_if(theIndex < 0 || static_cast<size_t>(theIndex) >= myUsedSize,
"NCollection_DynamicArray::InsertBefore: index out of range");
Appended();
for (size_t i = myUsedSize - 1; i > static_cast<size_t>(theIndex); --i)
at(i) = std::move(at(i - 1));
at(static_cast<size_t>(theIndex)) = theValue;
return at(static_cast<size_t>(theIndex));
}
//! Insert a value before the element at theIndex (move version).
reference InsertBefore(const int theIndex, TheItemType&& theValue)
{
Standard_OutOfRange_Raise_if(theIndex < 0 || static_cast<size_t>(theIndex) >= myUsedSize,
"NCollection_DynamicArray::InsertBefore: index out of range");
Appended();
for (size_t i = myUsedSize - 1; i > static_cast<size_t>(theIndex); --i)
at(i) = std::move(at(i - 1));
at(static_cast<size_t>(theIndex)) = std::forward<TheItemType>(theValue);
return at(static_cast<size_t>(theIndex));
}
void EraseLast()
{
if (myUsedSize == 0)
{
return;
}
TheItemType* aLastElem = &ChangeLast();
myAlloc.destroy(aLastElem);
if constexpr (!std::is_trivially_destructible_v<TheItemType>)
{
TheItemType* aLastElem = &ChangeLast();
myAlloc.destroy(aLastElem);
}
myUsedSize--;
}
@@ -299,7 +360,10 @@ public: //! @name public methods
pointer aPnt = &at(anIndex);
if (isExisting)
{
myAlloc.destroy(aPnt);
if constexpr (!std::is_trivially_destructible_v<TheItemType>)
{
myAlloc.destroy(aPnt);
}
}
myAlloc.construct(aPnt, std::forward<Args>(theArgs)...);
return *aPnt;
@@ -364,7 +428,10 @@ public: //! @name public methods
pointer aPnt = &at(anIndex);
if (isExisting)
{
myAlloc.destroy(aPnt);
if constexpr (!std::is_trivially_destructible_v<TheItemType>)
{
myAlloc.destroy(aPnt);
}
}
myAlloc.construct(aPnt, theValue);
return *aPnt;
@@ -392,7 +459,10 @@ public: //! @name public methods
pointer aPnt = &at(anIndex);
if (isExisting)
{
myAlloc.destroy(aPnt);
if constexpr (!std::is_trivially_destructible_v<TheItemType>)
{
myAlloc.destroy(aPnt);
}
}
myAlloc.construct(aPnt, std::forward<TheItemType>(theValue));
return *aPnt;
@@ -400,14 +470,19 @@ public: //! @name public methods
void Clear(const bool theReleaseMemory = false)
{
size_t aUsedSize = 0;
for (size_t aBlockInd = 0; aBlockInd < myContainer.Size(); aBlockInd++)
{
TheItemType* aCurStart = getArray()[aBlockInd];
for (size_t anElemInd = 0; anElemInd < myInternalSize && aUsedSize < myUsedSize;
anElemInd++, aUsedSize++)
if constexpr (!std::is_trivially_destructible_v<TheItemType>)
{
aCurStart[anElemInd].~TheItemType();
const size_t aBlockStart = aBlockInd * myInternalSize;
const size_t aCount = (myUsedSize > aBlockStart + myInternalSize)
? myInternalSize
: (myUsedSize > aBlockStart ? myUsedSize - aBlockStart : 0);
for (size_t anElemInd = 0; anElemInd < aCount; anElemInd++)
{
aCurStart[anElemInd].~TheItemType();
}
}
if (theReleaseMemory)
myAlloc.deallocate(aCurStart, myInternalSize);
@@ -456,11 +531,21 @@ protected:
{
TheItemType* aCurStart = getArray()[aBlockInd];
TheItemType* aNewBlock = myAlloc.allocate(myInternalSize);
for (size_t anElemInd = 0; anElemInd < myInternalSize && aUsedSize < myUsedSize;
anElemInd++, aUsedSize++)
if constexpr (std::is_trivially_copyable_v<TheItemType>)
{
pointer aPnt = &aNewBlock[anElemInd];
myAlloc.construct(aPnt, aCurStart[anElemInd]);
const size_t aCount =
(myUsedSize - aUsedSize < myInternalSize) ? myUsedSize - aUsedSize : myInternalSize;
std::memcpy(aNewBlock, aCurStart, aCount * sizeof(TheItemType));
aUsedSize += aCount;
}
else
{
for (size_t anElemInd = 0; anElemInd < myInternalSize && aUsedSize < myUsedSize;
anElemInd++, aUsedSize++)
{
pointer aPnt = &aNewBlock[anElemInd];
myAlloc.construct(aPnt, aCurStart[anElemInd]);
}
}
getArray()[aBlockInd] = aNewBlock;
}
@@ -368,6 +368,24 @@ public:
return aResult;
}
//! Calls theFunctor for each point within theRadius of theQuery.
//! Zero-allocation alternative to RangeSearch - avoids DynamicArray overhead.
//! Indices passed to theFunctor are 1-based (same convention as RangeSearch).
//! @tparam Functor callable with signature void(size_t theIndex)
//! @param[in] theQuery query point
//! @param[in] theRadius search radius
//! @param[in] theFunctor callback invoked for each found 1-based index
template <typename Functor>
void ForEachInRange(const ThePointType& theQuery, double theRadius, Functor theFunctor) const
{
if (IsEmpty() || theRadius < 0.0)
{
return;
}
const double aRadiusSq = theRadius * theRadius;
forEachInRangeRecursive(theQuery, aRadiusSq, 1, static_cast<int>(mySize), 0, theFunctor);
}
//! Finds all points within the axis-aligned bounding box [theMin, theMax].
//! @param[in] theMin minimum corner of the box
//! @param[in] theMax maximum corner of the box
@@ -925,6 +943,64 @@ private:
}
}
//! Recursive range search (sphere) with callback - zero-allocation variant.
template <typename Functor>
void forEachInRangeRecursive(const ThePointType& theQuery,
double theRadiusSq,
int theLo,
int theHi,
int theDepth,
Functor& theFunctor) const
{
if (theLo > theHi)
{
return;
}
if (theHi - theLo + 1 <= THE_LEAF_SIZE)
{
for (int i = theLo; i <= theHi; ++i)
{
const size_t anIdx = myIndices.Value(i);
const double aSqDist = squareDistance(theQuery, myPoints.Value(static_cast<int>(anIdx)));
if (aSqDist <= theRadiusSq)
{
theFunctor(anIdx);
}
}
return;
}
const int aMid = (theLo + theHi) / 2;
const size_t aNodeIndex = myIndices.Value(aMid);
const ThePointType& aNodePoint = myPoints.Value(static_cast<int>(aNodeIndex));
const double aSqDist = squareDistance(theQuery, aNodePoint);
if (aSqDist <= theRadiusSq)
{
theFunctor(aNodeIndex);
}
if (theLo == theHi)
{
return;
}
const int aAxis = theDepth % TheDimension;
const double aDiff = theQuery.Coord(aAxis + 1) - aNodePoint.Coord(aAxis + 1);
if (aDiff <= 0.0)
{
forEachInRangeRecursive(theQuery, theRadiusSq, theLo, aMid - 1, theDepth + 1, theFunctor);
if (aDiff * aDiff <= theRadiusSq)
{
forEachInRangeRecursive(theQuery, theRadiusSq, aMid + 1, theHi, theDepth + 1, theFunctor);
}
}
else
{
forEachInRangeRecursive(theQuery, theRadiusSq, aMid + 1, theHi, theDepth + 1, theFunctor);
if (aDiff * aDiff <= theRadiusSq)
{
forEachInRangeRecursive(theQuery, theRadiusSq, theLo, aMid - 1, theDepth + 1, theFunctor);
}
}
}
//! Recursive box search (AABB) with leaf buckets.
void boxSearchRecursive(const ThePointType& theMin,
const ThePointType& theMax,
@@ -19,6 +19,7 @@
#include <BRepFill_PipeShell.hxx>
#include <BRepFill_TransitionStyle.hxx>
#include <TopoDS_Shape.hxx>
#include <TopExp_Explorer.hxx>
#include <NCollection_List.hxx>
#include <BOPAlgo_Tools.hxx>
#include <BRepLib_FindSurface.hxx>
@@ -456,8 +457,7 @@ void BRepFill_AdvancedEvolved::Perform(const TopoDS_Wire& theSpine,
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> aMFLids;
TopExp::MapShapes(myTopBottom, TopAbs_FACE, aMFLids);
TopExp_Explorer anExp(myResult, TopAbs_FACE);
for (; anExp.More(); anExp.Next())
for (TopExp_Explorer anExp(myResult, TopAbs_FACE); anExp.More(); anExp.Next())
{
BRep_Builder aBB;
if (aShell.IsNull())
@@ -2,15 +2,15 @@
set(OCCT_Geom2dHatch_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_Geom2dHatch_FILES
Geom2dHatch_Classifier.cxx
Geom2dHatch_Classifier.hxx
Geom2dHatch_Classifier_0.cxx
Geom2dHatch_Element.cxx
Geom2dHatch_Element.hxx
Geom2dHatch_Elements.cxx
Geom2dHatch_Elements.hxx
Geom2dHatch_FClass2dOfClassifier.cxx
Geom2dHatch_FClass2dOfClassifier.hxx
Geom2dHatch_FClass2dOfClassifier_0.cxx
Geom2dHatch_Hatcher.cxx
Geom2dHatch_Hatcher.hxx
Geom2dHatch_Hatcher.lxx
@@ -0,0 +1,82 @@
// Created on: 1994-02-03
// Created by: Jean Marc LACHAUME
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <Geom2dHatch_Classifier.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Elements.hxx>
#include <Geom2dHatch_FClass2dOfClassifier.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <Standard_DomainError.hxx>
#include <TopClass_FaceClassifier.pxx>
#include <gp_Pnt2d.hxx>
//=================================================================================================
Geom2dHatch_Classifier::Geom2dHatch_Classifier()
: myEdgeParameter(0.0),
rejected(false),
nowires(true)
{
}
//=================================================================================================
Geom2dHatch_Classifier::Geom2dHatch_Classifier(Geom2dHatch_Elements& F,
const gp_Pnt2d& P,
const double Tol)
: myEdgeParameter(0.0),
rejected(false),
nowires(true)
{
Perform(F, P, Tol);
}
//=================================================================================================
void Geom2dHatch_Classifier::Perform(Geom2dHatch_Elements& F, const gp_Pnt2d& P, const double Tol)
{
TopClass_FaceClassifier::Perform(rejected,
nowires,
myClassifier,
myEdge,
myPosition,
myEdgeParameter,
F,
P,
Tol);
}
//=================================================================================================
TopAbs_State Geom2dHatch_Classifier::State() const
{
return TopClass_FaceClassifier::State(rejected, nowires, myClassifier);
}
//=================================================================================================
const Geom2dAdaptor_Curve& Geom2dHatch_Classifier::Edge() const
{
return TopClass_FaceClassifier::Edge(rejected, myEdge);
}
//=================================================================================================
double Geom2dHatch_Classifier::EdgeParameter() const
{
return TopClass_FaceClassifier::EdgeParameter(rejected, myEdgeParameter);
}
@@ -54,11 +54,11 @@ public:
//! Returns True when the state was computed by a
//! rejection. The state is OUT.
bool Rejected() const;
bool Rejected() const { return rejected; }
//! Returns True if the face contains no wire.
//! The state is IN.
bool NoWires() const;
bool NoWires() const { return nowires; }
//! Returns the Edge used to determine the
//! classification. When the State is ON this is the
@@ -71,7 +71,7 @@ public:
//! Returns the position of the point on the edge
//! returned by Edge.
IntRes2d_Position Position() const;
IntRes2d_Position Position() const { return myPosition; }
protected:
Geom2dHatch_FClass2dOfClassifier myClassifier;
@@ -82,28 +82,4 @@ protected:
bool nowires;
};
#define TheFaceExplorer Geom2dHatch_Elements
#define TheFaceExplorer_hxx <Geom2dHatch_Elements.hxx>
#define TheEdge Geom2dAdaptor_Curve
#define TheEdge_hxx <Geom2dAdaptor_Curve.hxx>
#define TheIntersection2d Geom2dHatch_Intersector
#define TheIntersection2d_hxx <Geom2dHatch_Intersector.hxx>
#define TopClass_FClass2d Geom2dHatch_FClass2dOfClassifier
#define TopClass_FClass2d_hxx <Geom2dHatch_FClass2dOfClassifier.hxx>
#define TopClass_FaceClassifier Geom2dHatch_Classifier
#define TopClass_FaceClassifier_hxx <Geom2dHatch_Classifier.hxx>
#include <TopClass_FaceClassifier.lxx>
#undef TheFaceExplorer
#undef TheFaceExplorer_hxx
#undef TheEdge
#undef TheEdge_hxx
#undef TheIntersection2d
#undef TheIntersection2d_hxx
#undef TopClass_FClass2d
#undef TopClass_FClass2d_hxx
#undef TopClass_FaceClassifier
#undef TopClass_FaceClassifier_hxx
#endif // _Geom2dHatch_Classifier_HeaderFile
@@ -1,36 +0,0 @@
// Created on: 1994-02-03
// Created by: Jean Marc LACHAUME
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <Geom2dHatch_Classifier.hxx>
#include <Standard_DomainError.hxx>
#include <Geom2dHatch_Elements.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <Geom2dHatch_FClass2dOfClassifier.hxx>
#include <gp_Pnt2d.hxx>
#define TheFaceExplorer Geom2dHatch_Elements
#define TheFaceExplorer_hxx <Geom2dHatch_Elements.hxx>
#define TheEdge Geom2dAdaptor_Curve
#define TheEdge_hxx <Geom2dAdaptor_Curve.hxx>
#define TheIntersection2d Geom2dHatch_Intersector
#define TheIntersection2d_hxx <Geom2dHatch_Intersector.hxx>
#define TopClass_FClass2d Geom2dHatch_FClass2dOfClassifier
#define TopClass_FClass2d_hxx <Geom2dHatch_FClass2dOfClassifier.hxx>
#define TopClass_FaceClassifier Geom2dHatch_Classifier
#define TopClass_FaceClassifier_hxx <Geom2dHatch_Classifier.hxx>
#include <TopClass_FaceClassifier.gxx>
@@ -0,0 +1,74 @@
// Created on: 1994-02-03
// Created by: Jean Marc LACHAUME
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <Geom2dHatch_FClass2dOfClassifier.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <Standard_DomainError.hxx>
#include <TopClass_Classifier2d.pxx>
#include <gp_Lin2d.hxx>
//=================================================================================================
Geom2dHatch_FClass2dOfClassifier::Geom2dHatch_FClass2dOfClassifier()
: myIsSet(false),
myFirstCompare(true),
myFirstTrans(true),
myParam(0.0),
myTolerance(0.0),
myClosest(0),
myState(TopAbs_UNKNOWN),
myIsHeadOrEnd(false)
{
}
//=================================================================================================
void Geom2dHatch_FClass2dOfClassifier::Reset(const gp_Lin2d& L, const double P, const double Tol)
{
TopClass_Classifier2d::Reset(myLin,
myParam,
myTolerance,
myState,
myFirstCompare,
myFirstTrans,
myClosest,
myIsSet,
myIsHeadOrEnd,
L,
P,
Tol);
}
//=================================================================================================
void Geom2dHatch_FClass2dOfClassifier::Compare(const Geom2dAdaptor_Curve& E,
const TopAbs_Orientation Or)
{
TopClass_Classifier2d::Compare(myClosest,
myIntersector,
myLin,
myParam,
myTolerance,
myState,
myFirstCompare,
myFirstTrans,
myTrans,
myIsHeadOrEnd,
E,
Or);
}
@@ -51,24 +51,24 @@ public:
Standard_EXPORT void Compare(const Geom2dAdaptor_Curve& E, const TopAbs_Orientation Or);
//! Returns the current value of the parameter.
double Parameter() const;
double Parameter() const { return myParam; }
//! Returns the intersecting algorithm.
Geom2dHatch_Intersector& Intersector();
Geom2dHatch_Intersector& Intersector() { return myIntersector; }
//! Returns 0 if the last compared edge had no
//! relevant intersection. Else returns the index of
//! this intersection in the last intersection
//! algorithm.
int ClosestIntersection() const;
int ClosestIntersection() const { return myClosest; }
//! Returns the current state of the point.
TopAbs_State State() const;
TopAbs_State State() const { return myState; }
//! Returns the true if the closest intersection point
//! represents head or end of the edge. Returns false
//! otherwise.
bool IsHeadOrEnd() const;
bool IsHeadOrEnd() const { return myIsHeadOrEnd; }
private:
bool myIsSet;
@@ -84,20 +84,4 @@ private:
bool myIsHeadOrEnd;
};
#define TheEdge Geom2dAdaptor_Curve
#define TheEdge_hxx <Geom2dAdaptor_Curve.hxx>
#define TheIntersector Geom2dHatch_Intersector
#define TheIntersector_hxx <Geom2dHatch_Intersector.hxx>
#define TopClass_Classifier2d Geom2dHatch_FClass2dOfClassifier
#define TopClass_Classifier2d_hxx <Geom2dHatch_FClass2dOfClassifier.hxx>
#include <TopClass_Classifier2d.lxx>
#undef TheEdge
#undef TheEdge_hxx
#undef TheIntersector
#undef TheIntersector_hxx
#undef TopClass_Classifier2d
#undef TopClass_Classifier2d_hxx
#endif // _Geom2dHatch_FClass2dOfClassifier_HeaderFile
@@ -1,30 +0,0 @@
// Created on: 1994-02-03
// Created by: Jean Marc LACHAUME
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <Geom2dHatch_FClass2dOfClassifier.hxx>
#include <Standard_DomainError.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <gp_Lin2d.hxx>
#define TheEdge Geom2dAdaptor_Curve
#define TheEdge_hxx <Geom2dAdaptor_Curve.hxx>
#define TheIntersector Geom2dHatch_Intersector
#define TheIntersector_hxx <Geom2dHatch_Intersector.hxx>
#define TopClass_Classifier2d Geom2dHatch_FClass2dOfClassifier
#define TopClass_Classifier2d_hxx <Geom2dHatch_FClass2dOfClassifier.hxx>
#include <TopClass_Classifier2d.gxx>
@@ -2,8 +2,6 @@
set(OCCT_TopClass_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TopClass_FILES
TopClass_Classifier2d.gxx
TopClass_Classifier2d.lxx
TopClass_FaceClassifier.gxx
TopClass_FaceClassifier.lxx
TopClass_Classifier2d.pxx
TopClass_FaceClassifier.pxx
)
@@ -1,244 +0,0 @@
// Created on: 1992-11-17
// Created by: Laurent BUCHARD
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
// Modified: Mon May 13 15:20:43 1996
//-- Reinitialisation des transitions complexes
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <gp_Vec2d.hxx>
//=================================================================================================
TopClass_Classifier2d::TopClass_Classifier2d()
: myIsSet(false),
myFirstCompare(true),
myFirstTrans(true),
myParam(0.0),
myTolerance(0.0),
myClosest(0),
myState(TopAbs_UNKNOWN), // skv OCC12627
myIsHeadOrEnd(false) // skv OCC12627
{
}
//=================================================================================================
void TopClass_Classifier2d::Reset(const gp_Lin2d& L, const double P, const double Tol)
{
myLin = L;
myParam = P;
myTolerance = Tol;
myState = TopAbs_UNKNOWN;
myFirstCompare = true;
myFirstTrans = true;
myClosest = 0;
myIsSet = true;
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
myIsHeadOrEnd = false;
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
}
//=================================================================================================
void TopClass_Classifier2d::Compare(const TheEdge& E, const TopAbs_Orientation Or)
{
// intersect the edge and the segment
myClosest = 0;
myIntersector.Perform(myLin, myParam, myTolerance, E);
if (!myIntersector.IsDone())
return;
if ((myIntersector.NbPoints() == 0) && (myIntersector.NbSegments() == 0))
return;
// find the closest point
int iPoint, iSegment, nbPoints, nbSegments;
const IntRes2d_IntersectionPoint* PClosest = NULL;
double dMin = RealLast();
nbPoints = myIntersector.NbPoints();
for (iPoint = 1; iPoint <= nbPoints; iPoint++)
{
const IntRes2d_IntersectionPoint& PInter = myIntersector.Point(iPoint);
// test for ON
if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head)
{
myClosest = iPoint;
myState = TopAbs_ON;
return;
}
double paramfirst = PInter.ParamOnFirst();
if (paramfirst < dMin)
{
myClosest = iPoint;
PClosest = &PInter;
dMin = paramfirst;
}
}
// for the segments we only test the first point
nbSegments = myIntersector.NbSegments();
for (iSegment = 1; iSegment <= nbSegments; iSegment++)
{
const IntRes2d_IntersectionSegment& SegInter = myIntersector.Segment(iSegment);
const IntRes2d_IntersectionPoint& PInter = SegInter.FirstPoint();
if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head)
{
myClosest = nbPoints + iSegment + iSegment - 1;
myState = TopAbs_ON;
return;
}
double paramfirst = PInter.ParamOnFirst();
if (paramfirst < dMin)
{
myClosest = nbPoints + iSegment + iSegment - 1;
PClosest = &PInter;
dMin = paramfirst;
}
}
// if no point was found return
if (myClosest == 0)
return;
// if the Edge is INTERNAL or EXTERNAL, no problem
if (Or == TopAbs_INTERNAL)
{
myState = TopAbs_IN;
return;
}
else if (Or == TopAbs_EXTERNAL)
{
myState = TopAbs_OUT;
return;
}
if (!myFirstCompare)
{
bool b = (dMin > myParam);
if (b)
{
// dMin > myParam : le point le plus proche (dMin) trouve dans CETTE
// intersection ligne,arete n'est pas le plus proche
// de TOUS les points d'intersection avec les autres aretes (myParam).
return;
}
}
// process the closest point PClosest, found at dMin on line.
myFirstCompare = false;
if (myParam > dMin)
{ //-- lbr le 13 mai 96
myFirstTrans = true;
}
myParam = dMin;
const IntRes2d_Transition& T2 = PClosest->TransitionOfSecond();
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
// bool isHeadorEnd = (T2.PositionOnCurve() == IntRes2d_Head) ||
// (T2.PositionOnCurve() == IntRes2d_End);
myIsHeadOrEnd = (T2.PositionOnCurve() == IntRes2d_Head) || (T2.PositionOnCurve() == IntRes2d_End);
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
// transition on the segment
TopAbs_Orientation SegTrans = TopAbs_FORWARD;
const IntRes2d_Transition& T1 = PClosest->TransitionOfFirst();
switch (T1.TransitionType())
{
case IntRes2d_In:
if (Or == TopAbs_REVERSED)
SegTrans = TopAbs_REVERSED;
else
SegTrans = TopAbs_FORWARD;
break;
case IntRes2d_Out:
if (Or == TopAbs_REVERSED)
SegTrans = TopAbs_FORWARD;
else
SegTrans = TopAbs_REVERSED;
break;
case IntRes2d_Touch:
switch (T1.Situation())
{
case IntRes2d_Inside:
if (Or == TopAbs_REVERSED)
SegTrans = TopAbs_EXTERNAL;
else
SegTrans = TopAbs_INTERNAL;
break;
case IntRes2d_Outside:
if (Or == TopAbs_REVERSED)
SegTrans = TopAbs_INTERNAL;
else
SegTrans = TopAbs_EXTERNAL;
break;
case IntRes2d_Unknown:
return;
}
break;
case IntRes2d_Undecided:
return;
}
// are we inside the Edge ?
// const IntRes2d_Transition& T2 = PClosest->TransitionOfSecond();
if (!myIsHeadOrEnd)
{
// PClosest is inside the edge
switch (SegTrans)
{
case TopAbs_FORWARD:
case TopAbs_EXTERNAL:
myState = TopAbs_OUT;
break;
case TopAbs_REVERSED:
case TopAbs_INTERNAL:
myState = TopAbs_IN;
break;
}
}
else
{
// PClosest is Head or End of the edge : update the complex transition
gp_Dir2d Tang2d, Norm2d;
double Curv;
myIntersector.LocalGeometry(E, PClosest->ParamOnSecond(), Tang2d, Norm2d, Curv);
gp_Dir Tang(Tang2d.X(), Tang2d.Y(), 0.);
gp_Dir Norm(Norm2d.X(), Norm2d.Y(), 0.);
if (myFirstTrans)
{
gp_Dir D(myLin.Direction().X(), myLin.Direction().Y(), 0.);
myTrans.Reset(D);
myFirstTrans = false;
}
TopAbs_Orientation Ort;
if (T2.PositionOnCurve() == IntRes2d_Head)
Ort = TopAbs_FORWARD;
else
Ort = TopAbs_REVERSED;
myTrans.Compare(RealEpsilon(), Tang, Norm, Curv, SegTrans, Ort);
myState = myTrans.StateBefore();
}
}
@@ -1,56 +0,0 @@
// Created on: 1992-11-17
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627
//=================================================================================================
inline double TopClass_Classifier2d::Parameter() const
{
return myParam;
}
//=================================================================================================
inline TheIntersector& TopClass_Classifier2d::Intersector()
{
return myIntersector;
}
//=================================================================================================
inline int TopClass_Classifier2d::ClosestIntersection() const
{
return myClosest;
}
//=================================================================================================
inline TopAbs_State TopClass_Classifier2d::State() const
{
return myState;
}
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
//=================================================================================================
inline bool TopClass_Classifier2d::IsHeadOrEnd() const
{
return myIsHeadOrEnd;
}
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
@@ -0,0 +1,227 @@
// Created on: 1992-11-17
// Created by: Laurent BUCHARD
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <Standard_Real.hxx>
#include <TopTrans_CurveTransition.hxx>
#include <gp_Dir.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Vec2d.hxx>
namespace TopClass_Classifier2d
{
//=================================================================================================
inline void Reset(gp_Lin2d& theLin,
double& theParam,
double& theTolerance,
TopAbs_State& theState,
bool& theFirstCompare,
bool& theFirstTrans,
int& theClosest,
bool& theIsSet,
bool& theIsHeadOrEnd,
const gp_Lin2d& theL,
const double theP,
const double theTol)
{
theLin = theL;
theParam = theP;
theTolerance = theTol;
theState = TopAbs_UNKNOWN;
theFirstCompare = true;
theFirstTrans = true;
theClosest = 0;
theIsSet = true;
theIsHeadOrEnd = false;
}
//=================================================================================================
template <typename TheEdge, typename TheIntersector>
inline void Compare(int& theClosest,
TheIntersector& theIntersector,
const gp_Lin2d& theLin,
double& theParam,
const double theTolerance,
TopAbs_State& theState,
bool& theFirstCompare,
bool& theFirstTrans,
TopTrans_CurveTransition& theTrans,
bool& theIsHeadOrEnd,
const TheEdge& theEdge,
const TopAbs_Orientation theOr)
{
// Intersect the edge and the segment.
theClosest = 0;
theIntersector.Perform(theLin, theParam, theTolerance, theEdge);
if (!theIntersector.IsDone())
return;
if ((theIntersector.NbPoints() == 0) && (theIntersector.NbSegments() == 0))
return;
// Find the closest point.
int aPoint, aSegment, aNbPoints, aNbSegments;
const IntRes2d_IntersectionPoint* aPClosest = nullptr;
double aDMin = RealLast();
aNbPoints = theIntersector.NbPoints();
for (aPoint = 1; aPoint <= aNbPoints; aPoint++)
{
const IntRes2d_IntersectionPoint& aPInter = theIntersector.Point(aPoint);
// Test for ON.
if (aPInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head)
{
theClosest = aPoint;
theState = TopAbs_ON;
return;
}
const double aParamFirst = aPInter.ParamOnFirst();
if (aParamFirst < aDMin)
{
theClosest = aPoint;
aPClosest = &aPInter;
aDMin = aParamFirst;
}
}
// For the segments we only test the first point.
aNbSegments = theIntersector.NbSegments();
for (aSegment = 1; aSegment <= aNbSegments; aSegment++)
{
const IntRes2d_IntersectionSegment& aSegInter = theIntersector.Segment(aSegment);
const IntRes2d_IntersectionPoint& aPInter = aSegInter.FirstPoint();
if (aPInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head)
{
theClosest = aNbPoints + aSegment + aSegment - 1;
theState = TopAbs_ON;
return;
}
const double aParamFirst = aPInter.ParamOnFirst();
if (aParamFirst < aDMin)
{
theClosest = aNbPoints + aSegment + aSegment - 1;
aPClosest = &aPInter;
aDMin = aParamFirst;
}
}
// If no point was found return.
if (theClosest == 0)
return;
// If the edge is INTERNAL or EXTERNAL, no problem.
if (theOr == TopAbs_INTERNAL)
{
theState = TopAbs_IN;
return;
}
else if (theOr == TopAbs_EXTERNAL)
{
theState = TopAbs_OUT;
return;
}
if (!theFirstCompare)
{
if (aDMin > theParam)
return;
}
// Process the closest point aPClosest, found at aDMin on line.
theFirstCompare = false;
if (theParam > aDMin)
theFirstTrans = true;
theParam = aDMin;
const IntRes2d_Transition& aT2 = aPClosest->TransitionOfSecond();
theIsHeadOrEnd =
(aT2.PositionOnCurve() == IntRes2d_Head) || (aT2.PositionOnCurve() == IntRes2d_End);
// Transition on the segment.
TopAbs_Orientation aSegTrans = TopAbs_FORWARD;
const IntRes2d_Transition& aT1 = aPClosest->TransitionOfFirst();
switch (aT1.TransitionType())
{
case IntRes2d_In:
aSegTrans = (theOr == TopAbs_REVERSED) ? TopAbs_REVERSED : TopAbs_FORWARD;
break;
case IntRes2d_Out:
aSegTrans = (theOr == TopAbs_REVERSED) ? TopAbs_FORWARD : TopAbs_REVERSED;
break;
case IntRes2d_Touch:
switch (aT1.Situation())
{
case IntRes2d_Inside:
aSegTrans = (theOr == TopAbs_REVERSED) ? TopAbs_EXTERNAL : TopAbs_INTERNAL;
break;
case IntRes2d_Outside:
aSegTrans = (theOr == TopAbs_REVERSED) ? TopAbs_INTERNAL : TopAbs_EXTERNAL;
break;
case IntRes2d_Unknown:
return;
}
break;
case IntRes2d_Undecided:
return;
}
// Are we inside the edge?
if (!theIsHeadOrEnd)
{
// aPClosest is inside the edge.
switch (aSegTrans)
{
case TopAbs_FORWARD:
case TopAbs_EXTERNAL:
theState = TopAbs_OUT;
break;
case TopAbs_REVERSED:
case TopAbs_INTERNAL:
theState = TopAbs_IN;
break;
}
}
else
{
// aPClosest is Head or End of the edge: update the complex transition.
gp_Dir2d aTang2d, aNorm2d;
double aCurv;
theIntersector.LocalGeometry(theEdge, aPClosest->ParamOnSecond(), aTang2d, aNorm2d, aCurv);
gp_Dir aTang(aTang2d.X(), aTang2d.Y(), 0.);
gp_Dir aNorm(aNorm2d.X(), aNorm2d.Y(), 0.);
if (theFirstTrans)
{
gp_Dir aDir(theLin.Direction().X(), theLin.Direction().Y(), 0.);
theTrans.Reset(aDir);
theFirstTrans = false;
}
const TopAbs_Orientation aOrt =
(aT2.PositionOnCurve() == IntRes2d_Head) ? TopAbs_FORWARD : TopAbs_REVERSED;
theTrans.Compare(RealEpsilon(), aTang, aNorm, aCurv, aSegTrans, aOrt);
theState = theTrans.StateBefore();
}
}
} // namespace TopClass_Classifier2d
@@ -1,180 +0,0 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
// Modified by skv - Thu Jul 13 18:00:34 2006 OCC12627
// The method Perform is totally rewroted.
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
//=================================================================================================
TopClass_FaceClassifier::TopClass_FaceClassifier()
: myEdgeParameter(0.0),
rejected(false),
nowires(true)
{
}
//=================================================================================================
TopClass_FaceClassifier::TopClass_FaceClassifier(TheFaceExplorer& FExp,
const gp_Pnt2d& P,
const double Tol)
: myEdgeParameter(0.0),
rejected(false),
nowires(true)
{
Perform(FExp, P, Tol);
}
//=================================================================================================
void TopClass_FaceClassifier::Perform(TheFaceExplorer& Fexp, const gp_Pnt2d& P, const double Tol)
{
gp_Pnt2d aPoint(P);
bool aResOfPointCheck = false;
while (aResOfPointCheck == false)
{
aResOfPointCheck = Fexp.CheckPoint(aPoint);
}
// Test for rejection.
rejected = Fexp.Reject(aPoint);
if (rejected)
return;
gp_Lin2d aLine;
double aParam;
bool IsValidSegment = Fexp.Segment(aPoint, aLine, aParam);
TheEdge anEdge;
TopAbs_Orientation anEdgeOri;
int aClosestInd;
IntRes2d_IntersectionPoint aPInter;
TopAbs_State aState = TopAbs_UNKNOWN;
bool IsWReject;
bool IsEReject;
nowires = true;
while (IsValidSegment)
{
myClassifier.Reset(aLine, aParam, Tol);
for (Fexp.InitWires(); Fexp.MoreWires(); Fexp.NextWire())
{
nowires = false;
IsWReject = Fexp.RejectWire(aLine, myClassifier.Parameter());
if (!IsWReject)
{
// test this wire
for (Fexp.InitEdges(); Fexp.MoreEdges(); Fexp.NextEdge())
{
IsEReject = Fexp.RejectEdge(aLine, myClassifier.Parameter());
if (!IsEReject)
{
// test this edge
Fexp.CurrentEdge(anEdge, anEdgeOri);
if (anEdgeOri == TopAbs_FORWARD || anEdgeOri == TopAbs_REVERSED)
{
myClassifier.Compare(anEdge, anEdgeOri);
aClosestInd = myClassifier.ClosestIntersection();
if (aClosestInd != 0)
{
// save the closest edge
TheIntersection2d& anIntersector = myClassifier.Intersector();
int aNbPnts = anIntersector.NbPoints();
myEdge = anEdge;
if (aClosestInd <= aNbPnts)
{
aPInter = anIntersector.Point(aClosestInd);
}
else
{
aClosestInd -= aNbPnts;
if (aClosestInd & 1)
{
aPInter = anIntersector.Segment((aClosestInd + 1) / 2).FirstPoint();
}
else
{
aPInter = anIntersector.Segment((aClosestInd + 1) / 2).LastPoint();
}
}
myPosition = aPInter.TransitionOfSecond().PositionOnCurve();
myEdgeParameter = aPInter.ParamOnSecond();
}
// if we are ON, we stop
aState = myClassifier.State();
if (aState == TopAbs_ON)
return;
}
}
}
// if we are out of the wire we stop
aState = myClassifier.State();
if (aState == TopAbs_OUT)
return;
}
}
if (!myClassifier.IsHeadOrEnd() && aState != TopAbs_UNKNOWN)
break;
// Bad case for classification. Trying to get another segment.
IsValidSegment = Fexp.OtherSegment(aPoint, aLine, aParam);
}
}
//=================================================================================================
TopAbs_State TopClass_FaceClassifier::State() const
{
if (rejected)
return TopAbs_OUT;
else if (nowires)
return TopAbs_IN;
else
return myClassifier.State();
}
//=================================================================================================
const TheEdge& TopClass_FaceClassifier::Edge() const
{
Standard_DomainError_Raise_if(rejected, "TopClass_FaceClassifier::Edge:rejected");
return myEdge;
}
//=================================================================================================
double TopClass_FaceClassifier::EdgeParameter() const
{
Standard_DomainError_Raise_if(rejected, "TopClass_FaceClassifier::EdgeParameter:rejected");
return myEdgeParameter;
}
@@ -1,38 +0,0 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include TheFaceExplorer_hxx
//=================================================================================================
inline bool TopClass_FaceClassifier::Rejected() const
{
return rejected;
}
//=================================================================================================
inline bool TopClass_FaceClassifier::NoWires() const
{
return nowires;
}
//=================================================================================================
inline IntRes2d_Position TopClass_FaceClassifier::Position() const
{
return myPosition;
}
@@ -0,0 +1,178 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_Position.hxx>
#include <Standard_DomainError.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Pnt2d.hxx>
namespace TopClass_FaceClassifier
{
//=================================================================================================
template <typename TheFaceExplorer, typename TheEdge, typename FClass2d>
inline void Perform(bool& theRejected,
bool& theNoWires,
FClass2d& theClassifier,
TheEdge& theEdge,
IntRes2d_Position& thePosition,
double& theEdgeParameter,
TheFaceExplorer& theFexp,
const gp_Pnt2d& theP,
const double theTol)
{
gp_Pnt2d aPoint(theP);
bool aResOfPointCheck = false;
while (aResOfPointCheck == false)
{
aResOfPointCheck = theFexp.CheckPoint(aPoint);
}
// Test for rejection.
theRejected = theFexp.Reject(aPoint);
if (theRejected)
return;
gp_Lin2d aLine;
double aParam;
bool aIsValidSegment = theFexp.Segment(aPoint, aLine, aParam);
TheEdge anEdge;
TopAbs_Orientation anEdgeOri;
int aClosestInd;
IntRes2d_IntersectionPoint aPInter;
TopAbs_State aState = TopAbs_UNKNOWN;
bool aIsWReject;
bool aIsEReject;
theNoWires = true;
while (aIsValidSegment)
{
theClassifier.Reset(aLine, aParam, theTol);
for (theFexp.InitWires(); theFexp.MoreWires(); theFexp.NextWire())
{
theNoWires = false;
aIsWReject = theFexp.RejectWire(aLine, theClassifier.Parameter());
if (!aIsWReject)
{
// Test this wire.
for (theFexp.InitEdges(); theFexp.MoreEdges(); theFexp.NextEdge())
{
aIsEReject = theFexp.RejectEdge(aLine, theClassifier.Parameter());
if (!aIsEReject)
{
// Test this edge.
theFexp.CurrentEdge(anEdge, anEdgeOri);
if (anEdgeOri == TopAbs_FORWARD || anEdgeOri == TopAbs_REVERSED)
{
theClassifier.Compare(anEdge, anEdgeOri);
aClosestInd = theClassifier.ClosestIntersection();
if (aClosestInd != 0)
{
// Save the closest edge.
auto& anIntersector = theClassifier.Intersector();
int aNbPnts = anIntersector.NbPoints();
theEdge = anEdge;
if (aClosestInd <= aNbPnts)
{
aPInter = anIntersector.Point(aClosestInd);
}
else
{
aClosestInd -= aNbPnts;
if (aClosestInd & 1)
{
aPInter = anIntersector.Segment((aClosestInd + 1) / 2).FirstPoint();
}
else
{
aPInter = anIntersector.Segment((aClosestInd + 1) / 2).LastPoint();
}
}
thePosition = aPInter.TransitionOfSecond().PositionOnCurve();
theEdgeParameter = aPInter.ParamOnSecond();
}
// If we are ON, we stop.
aState = theClassifier.State();
if (aState == TopAbs_ON)
return;
}
}
}
// If we are out of the wire we stop.
aState = theClassifier.State();
if (aState == TopAbs_OUT)
return;
}
}
if (!theClassifier.IsHeadOrEnd() && aState != TopAbs_UNKNOWN)
break;
// Bad case for classification. Trying to get another segment.
aIsValidSegment = theFexp.OtherSegment(aPoint, aLine, aParam);
}
}
//=================================================================================================
template <typename FClass2d>
inline TopAbs_State State(const bool theRejected,
const bool theNoWires,
const FClass2d& theClassifier)
{
if (theRejected)
return TopAbs_OUT;
else if (theNoWires)
return TopAbs_IN;
else
return theClassifier.State();
}
//=================================================================================================
template <typename TheEdge>
inline const TheEdge& Edge([[maybe_unused]] const bool theRejected, const TheEdge& theEdge)
{
Standard_DomainError_Raise_if(theRejected, "TopClass_FaceClassifier::Edge : rejected");
return theEdge;
}
//=================================================================================================
inline double EdgeParameter([[maybe_unused]] const bool theRejected, const double theEdgeParameter)
{
Standard_DomainError_Raise_if(theRejected, "TopClass_FaceClassifier::EdgeParameter : rejected");
return theEdgeParameter;
}
} // namespace TopClass_FaceClassifier
@@ -700,13 +700,42 @@ BRepCheck_Status BRepCheck_Edge::CheckPolygonOnTriangulation(const TopoDS_Edge&
{
NCollection_List<occ::handle<BRep_CurveRepresentation>>& aListOfCR =
(*((occ::handle<BRep_TEdge>*)&theEdge.TShape()))->ChangeCurves();
NCollection_List<occ::handle<BRep_CurveRepresentation>>::Iterator anITCR(aListOfCR);
bool aHasPolygonOnTriangulation = false;
bool aHasCurve3D = false;
for (NCollection_List<occ::handle<BRep_CurveRepresentation>>::Iterator anITCR(aListOfCR);
anITCR.More();
anITCR.Next())
{
const occ::handle<BRep_CurveRepresentation>& aCR = anITCR.Value();
if (aCR->IsPolygonOnTriangulation())
{
aHasPolygonOnTriangulation = true;
}
if (aCR->IsCurve3D() && !aCR->Curve3D().IsNull())
{
aHasCurve3D = true;
}
if (aHasPolygonOnTriangulation && aHasCurve3D)
{
break;
}
}
if (!aHasPolygonOnTriangulation || !aHasCurve3D)
{
return BRepCheck_NoError;
}
BRepAdaptor_Curve aBC;
aBC.Initialize(theEdge);
if (!aBC.Is3DCurve())
{
return BRepCheck_NoError;
}
NCollection_List<occ::handle<BRep_CurveRepresentation>>::Iterator anITCR(aListOfCR);
while (anITCR.More())
{
@@ -41,12 +41,14 @@ public:
Standard_EXPORT BRepClass_Edge(const TopoDS_Edge& E, const TopoDS_Face& F);
//! Returns the current Edge
TopoDS_Edge& Edge();
const TopoDS_Edge& Edge() const;
TopoDS_Edge& Edge() { return myEdge; }
const TopoDS_Edge& Edge() const { return myEdge; }
//! Returns the Face for the current Edge
TopoDS_Face& Face();
const TopoDS_Face& Face() const;
TopoDS_Face& Face() { return myFace; }
const TopoDS_Face& Face() const { return myFace; }
//! Returns the next Edge
const TopoDS_Edge& NextEdge() const { return myNextEdge; }
@@ -80,6 +82,4 @@ private:
bool myUseBndBox;
};
#include <BRepClass_Edge.lxx>
#endif // _BRepClass_Edge_HeaderFile
@@ -1,43 +0,0 @@
// Created on: 1992-11-19
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
//=================================================================================================
inline TopoDS_Edge& BRepClass_Edge::Edge()
{
return myEdge;
}
//=================================================================================================
inline const TopoDS_Edge& BRepClass_Edge::Edge() const
{
return myEdge;
}
//=================================================================================================
inline TopoDS_Face& BRepClass_Edge::Face()
{
return myFace;
}
//=================================================================================================
inline const TopoDS_Face& BRepClass_Edge::Face() const
{
return myFace;
}
@@ -0,0 +1,73 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <BRepClass_FClass2dOfFClassifier.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepClass_Intersector.hxx>
#include <Standard_DomainError.hxx>
#include <TopClass_Classifier2d.pxx>
#include <gp_Lin2d.hxx>
//=================================================================================================
BRepClass_FClass2dOfFClassifier::BRepClass_FClass2dOfFClassifier()
: myIsSet(false),
myFirstCompare(true),
myFirstTrans(true),
myParam(0.0),
myTolerance(0.0),
myClosest(0),
myState(TopAbs_UNKNOWN),
myIsHeadOrEnd(false)
{
}
//=================================================================================================
void BRepClass_FClass2dOfFClassifier::Reset(const gp_Lin2d& L, const double P, const double Tol)
{
TopClass_Classifier2d::Reset(myLin,
myParam,
myTolerance,
myState,
myFirstCompare,
myFirstTrans,
myClosest,
myIsSet,
myIsHeadOrEnd,
L,
P,
Tol);
}
//=================================================================================================
void BRepClass_FClass2dOfFClassifier::Compare(const BRepClass_Edge& E, const TopAbs_Orientation Or)
{
TopClass_Classifier2d::Compare(myClosest,
myIntersector,
myLin,
myParam,
myTolerance,
myState,
myFirstCompare,
myFirstTrans,
myTrans,
myIsHeadOrEnd,
E,
Or);
}
@@ -50,24 +50,24 @@ public:
Standard_EXPORT void Compare(const BRepClass_Edge& E, const TopAbs_Orientation Or);
//! Returns the current value of the parameter.
double Parameter() const;
double Parameter() const { return myParam; }
//! Returns the intersecting algorithm.
BRepClass_Intersector& Intersector();
BRepClass_Intersector& Intersector() { return myIntersector; }
//! Returns 0 if the last compared edge had no
//! relevant intersection. Else returns the index of
//! this intersection in the last intersection
//! algorithm.
int ClosestIntersection() const;
int ClosestIntersection() const { return myClosest; }
//! Returns the current state of the point.
TopAbs_State State() const;
TopAbs_State State() const { return myState; }
//! Returns the true if the closest intersection point
//! represents head or end of the edge. Returns false
//! otherwise.
bool IsHeadOrEnd() const;
bool IsHeadOrEnd() const { return myIsHeadOrEnd; }
private:
bool myIsSet;
@@ -83,20 +83,4 @@ private:
bool myIsHeadOrEnd;
};
#define TheEdge BRepClass_Edge
#define TheEdge_hxx <BRepClass_Edge.hxx>
#define TheIntersector BRepClass_Intersector
#define TheIntersector_hxx <BRepClass_Intersector.hxx>
#define TopClass_Classifier2d BRepClass_FClass2dOfFClassifier
#define TopClass_Classifier2d_hxx <BRepClass_FClass2dOfFClassifier.hxx>
#include <TopClass_Classifier2d.lxx>
#undef TheEdge
#undef TheEdge_hxx
#undef TheIntersector
#undef TheIntersector_hxx
#undef TopClass_Classifier2d
#undef TopClass_Classifier2d_hxx
#endif // _BRepClass_FClass2dOfFClassifier_HeaderFile
@@ -1,30 +0,0 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <BRepClass_FClass2dOfFClassifier.hxx>
#include <Standard_DomainError.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepClass_Intersector.hxx>
#include <gp_Lin2d.hxx>
#define TheEdge BRepClass_Edge
#define TheEdge_hxx <BRepClass_Edge.hxx>
#define TheIntersector BRepClass_Intersector
#define TheIntersector_hxx <BRepClass_Intersector.hxx>
#define TopClass_Classifier2d BRepClass_FClass2dOfFClassifier
#define TopClass_Classifier2d_hxx <BRepClass_FClass2dOfFClassifier.hxx>
#include <TopClass_Classifier2d.gxx>
@@ -0,0 +1,82 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <BRepClass_FClassifier.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepClass_FClass2dOfFClassifier.hxx>
#include <BRepClass_FaceExplorer.hxx>
#include <BRepClass_Intersector.hxx>
#include <Standard_DomainError.hxx>
#include <TopClass_FaceClassifier.pxx>
#include <gp_Pnt2d.hxx>
//=================================================================================================
BRepClass_FClassifier::BRepClass_FClassifier()
: myEdgeParameter(0.0),
rejected(false),
nowires(true)
{
}
//=================================================================================================
BRepClass_FClassifier::BRepClass_FClassifier(BRepClass_FaceExplorer& F,
const gp_Pnt2d& P,
const double Tol)
: myEdgeParameter(0.0),
rejected(false),
nowires(true)
{
Perform(F, P, Tol);
}
//=================================================================================================
void BRepClass_FClassifier::Perform(BRepClass_FaceExplorer& F, const gp_Pnt2d& P, const double Tol)
{
TopClass_FaceClassifier::Perform(rejected,
nowires,
myClassifier,
myEdge,
myPosition,
myEdgeParameter,
F,
P,
Tol);
}
//=================================================================================================
TopAbs_State BRepClass_FClassifier::State() const
{
return TopClass_FaceClassifier::State(rejected, nowires, myClassifier);
}
//=================================================================================================
const BRepClass_Edge& BRepClass_FClassifier::Edge() const
{
return TopClass_FaceClassifier::Edge(rejected, myEdge);
}
//=================================================================================================
double BRepClass_FClassifier::EdgeParameter() const
{
return TopClass_FaceClassifier::EdgeParameter(rejected, myEdgeParameter);
}
@@ -54,11 +54,11 @@ public:
//! Returns True when the state was computed by a
//! rejection. The state is OUT.
bool Rejected() const;
bool Rejected() const { return rejected; }
//! Returns True if the face contains no wire. The
//! state is IN.
bool NoWires() const;
bool NoWires() const { return nowires; }
//! Returns the Edge used to determine the
//! classification. When the State is ON this is the
@@ -71,7 +71,7 @@ public:
//! Returns the position of the point on the edge
//! returned by Edge.
IntRes2d_Position Position() const;
IntRes2d_Position Position() const { return myPosition; }
protected:
BRepClass_FClass2dOfFClassifier myClassifier;
@@ -82,28 +82,4 @@ protected:
bool nowires;
};
#define TheFaceExplorer BRepClass_FaceExplorer
#define TheFaceExplorer_hxx <BRepClass_FaceExplorer.hxx>
#define TheEdge BRepClass_Edge
#define TheEdge_hxx <BRepClass_Edge.hxx>
#define TheIntersection2d BRepClass_Intersector
#define TheIntersection2d_hxx <BRepClass_Intersector.hxx>
#define TopClass_FClass2d BRepClass_FClass2dOfFClassifier
#define TopClass_FClass2d_hxx <BRepClass_FClass2dOfFClassifier.hxx>
#define TopClass_FaceClassifier BRepClass_FClassifier
#define TopClass_FaceClassifier_hxx <BRepClass_FClassifier.hxx>
#include <TopClass_FaceClassifier.lxx>
#undef TheFaceExplorer
#undef TheFaceExplorer_hxx
#undef TheEdge
#undef TheEdge_hxx
#undef TheIntersection2d
#undef TheIntersection2d_hxx
#undef TopClass_FClass2d
#undef TopClass_FClass2d_hxx
#undef TopClass_FaceClassifier
#undef TopClass_FaceClassifier_hxx
#endif // _BRepClass_FClassifier_HeaderFile
@@ -1,36 +0,0 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <BRepClass_FClassifier.hxx>
#include <Standard_DomainError.hxx>
#include <BRepClass_FaceExplorer.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepClass_Intersector.hxx>
#include <BRepClass_FClass2dOfFClassifier.hxx>
#include <gp_Pnt2d.hxx>
#define TheFaceExplorer BRepClass_FaceExplorer
#define TheFaceExplorer_hxx <BRepClass_FaceExplorer.hxx>
#define TheEdge BRepClass_Edge
#define TheEdge_hxx <BRepClass_Edge.hxx>
#define TheIntersection2d BRepClass_Intersector
#define TheIntersection2d_hxx <BRepClass_Intersector.hxx>
#define TopClass_FClass2d BRepClass_FClass2dOfFClassifier
#define TopClass_FClass2d_hxx <BRepClass_FClass2dOfFClassifier.hxx>
#define TopClass_FaceClassifier BRepClass_FClassifier
#define TopClass_FaceClassifier_hxx <BRepClass_FClassifier.hxx>
#include <TopClass_FaceClassifier.gxx>
@@ -65,10 +65,10 @@ public:
Standard_EXPORT void InitWires();
//! Returns True if there is a current wire.
bool MoreWires() const;
bool MoreWires() const { return myWExplorer.More(); }
//! Sets the explorer to the next wire.
void NextWire();
void NextWire() { myWExplorer.Next(); }
//! Returns True if the wire bounding volume does not
//! intersect the segment.
@@ -79,10 +79,10 @@ public:
Standard_EXPORT void InitEdges();
//! Returns True if there is a current edge.
bool MoreEdges() const;
bool MoreEdges() const { return myEExplorer.More(); }
//! Sets the explorer to the next edge.
void NextEdge();
void NextEdge() { myEExplorer.Next(); }
//! Returns True if the edge bounding volume does not
//! intersect the segment.
@@ -127,6 +127,4 @@ private:
double myVMax;
};
#include <BRepClass_FaceExplorer.lxx>
#endif // _BRepClass_FaceExplorer_HeaderFile
@@ -1,43 +0,0 @@
// Created on: 1993-01-25
// Created by: Remi LEQUETTE
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
//=================================================================================================
inline bool BRepClass_FaceExplorer::MoreWires() const
{
return myWExplorer.More();
}
//=================================================================================================
inline void BRepClass_FaceExplorer::NextWire()
{
myWExplorer.Next();
}
//=================================================================================================
inline bool BRepClass_FaceExplorer::MoreEdges() const
{
return myEExplorer.More();
}
//=================================================================================================
inline void BRepClass_FaceExplorer::NextEdge()
{
myEExplorer.Next();
}
@@ -0,0 +1,73 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <BRepClass_FacePassiveClassifier.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepClass_Intersector.hxx>
#include <Standard_DomainError.hxx>
#include <TopClass_Classifier2d.pxx>
#include <gp_Lin2d.hxx>
//=================================================================================================
BRepClass_FacePassiveClassifier::BRepClass_FacePassiveClassifier()
: myIsSet(false),
myFirstCompare(true),
myFirstTrans(true),
myParam(0.0),
myTolerance(0.0),
myClosest(0),
myState(TopAbs_UNKNOWN),
myIsHeadOrEnd(false)
{
}
//=================================================================================================
void BRepClass_FacePassiveClassifier::Reset(const gp_Lin2d& L, const double P, const double Tol)
{
TopClass_Classifier2d::Reset(myLin,
myParam,
myTolerance,
myState,
myFirstCompare,
myFirstTrans,
myClosest,
myIsSet,
myIsHeadOrEnd,
L,
P,
Tol);
}
//=================================================================================================
void BRepClass_FacePassiveClassifier::Compare(const BRepClass_Edge& E, const TopAbs_Orientation Or)
{
TopClass_Classifier2d::Compare(myClosest,
myIntersector,
myLin,
myParam,
myTolerance,
myState,
myFirstCompare,
myFirstTrans,
myTrans,
myIsHeadOrEnd,
E,
Or);
}
@@ -51,24 +51,24 @@ public:
Standard_EXPORT void Compare(const BRepClass_Edge& E, const TopAbs_Orientation Or);
//! Returns the current value of the parameter.
double Parameter() const;
double Parameter() const { return myParam; }
//! Returns the intersecting algorithm.
BRepClass_Intersector& Intersector();
BRepClass_Intersector& Intersector() { return myIntersector; }
//! Returns 0 if the last compared edge had no
//! relevant intersection. Else returns the index of
//! this intersection in the last intersection
//! algorithm.
int ClosestIntersection() const;
int ClosestIntersection() const { return myClosest; }
//! Returns the current state of the point.
TopAbs_State State() const;
TopAbs_State State() const { return myState; }
//! Returns the true if the closest intersection point
//! represents head or end of the edge. Returns false
//! otherwise.
bool IsHeadOrEnd() const;
bool IsHeadOrEnd() const { return myIsHeadOrEnd; }
private:
bool myIsSet;
@@ -84,20 +84,4 @@ private:
bool myIsHeadOrEnd;
};
#define TheEdge BRepClass_Edge
#define TheEdge_hxx <BRepClass_Edge.hxx>
#define TheIntersector BRepClass_Intersector
#define TheIntersector_hxx <BRepClass_Intersector.hxx>
#define TopClass_Classifier2d BRepClass_FacePassiveClassifier
#define TopClass_Classifier2d_hxx <BRepClass_FacePassiveClassifier.hxx>
#include <TopClass_Classifier2d.lxx>
#undef TheEdge
#undef TheEdge_hxx
#undef TheIntersector
#undef TheIntersector_hxx
#undef TopClass_Classifier2d
#undef TopClass_Classifier2d_hxx
#endif // _BRepClass_FacePassiveClassifier_HeaderFile
@@ -1,30 +0,0 @@
// Created on: 1992-11-18
// Created by: Remi LEQUETTE
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
#include <BRepClass_FacePassiveClassifier.hxx>
#include <Standard_DomainError.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepClass_Intersector.hxx>
#include <gp_Lin2d.hxx>
#define TheEdge BRepClass_Edge
#define TheEdge_hxx <BRepClass_Edge.hxx>
#define TheIntersector BRepClass_Intersector
#define TheIntersector_hxx <BRepClass_Intersector.hxx>
#define TopClass_Classifier2d BRepClass_FacePassiveClassifier
#define TopClass_Classifier2d_hxx <BRepClass_FacePassiveClassifier.hxx>
#include <TopClass_Classifier2d.gxx>
@@ -4,18 +4,16 @@ set(OCCT_BRepClass_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_BRepClass_FILES
BRepClass_Edge.cxx
BRepClass_Edge.hxx
BRepClass_Edge.lxx
BRepClass_FaceClassifier.cxx
BRepClass_FaceClassifier.hxx
BRepClass_FaceExplorer.cxx
BRepClass_FaceExplorer.hxx
BRepClass_FaceExplorer.lxx
BRepClass_FacePassiveClassifier.cxx
BRepClass_FacePassiveClassifier.hxx
BRepClass_FacePassiveClassifier_0.cxx
BRepClass_FClass2dOfFClassifier.cxx
BRepClass_FClass2dOfFClassifier.hxx
BRepClass_FClass2dOfFClassifier_0.cxx
BRepClass_FClassifier.cxx
BRepClass_FClassifier.hxx
BRepClass_FClassifier_0.cxx
BRepClass_Intersector.cxx
BRepClass_Intersector.hxx
)
@@ -82,15 +82,16 @@ bool BRepClass3d_SolidExplorer::FindAPointInTheFace(const TopoDS_Face& _face,
TopoDS_Face face = _face;
face.Orientation(TopAbs_FORWARD);
TopExp_Explorer faceexplorer;
BRepAdaptor_Curve2d c;
gp_Vec2d T;
gp_Pnt2d P;
gp_Vec2d T;
gp_Pnt2d P;
for (faceexplorer.Init(face, TopAbs_EDGE); faceexplorer.More(); faceexplorer.Next())
for (TopExp_Explorer faceexplorer(face, TopAbs_EDGE); faceexplorer.More(); faceexplorer.Next())
{
TopoDS_Edge Edge = TopoDS::Edge(faceexplorer.Current());
c.Initialize(Edge, face);
TopoDS_Edge Edge = TopoDS::Edge(faceexplorer.Current());
BRepAdaptor_Curve2d c(Edge, face);
if (c.Curve().IsNull())
continue;
c.D1((c.LastParameter() - c.FirstParameter()) * param_ + c.FirstParameter(), P, T);
double x = T.X();
@@ -30,6 +30,7 @@
#include <Standard_Integer.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <Bnd_Box.hxx>
#include <BRepExtrema_ExtPC.hxx>
#include <BRepExtrema_ExtPF.hxx>
@@ -33,9 +33,9 @@ public:
Standard_EXPORT BRepTopAdaptor_HVertex(const TopoDS_Vertex& Vtx,
const occ::handle<BRepAdaptor_Curve2d>& Curve);
const TopoDS_Vertex& Vertex() const;
const TopoDS_Vertex& Vertex() const { return myVtx; }
TopoDS_Vertex& ChangeVertex();
TopoDS_Vertex& ChangeVertex() { return myVtx; }
Standard_EXPORT gp_Pnt2d Value() override;
@@ -55,6 +55,4 @@ private:
occ::handle<BRepAdaptor_Curve2d> myCurve;
};
#include <BRepTopAdaptor_HVertex.lxx>
#endif // _BRepTopAdaptor_HVertex_HeaderFile
@@ -1,23 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 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.
inline const TopoDS_Vertex& BRepTopAdaptor_HVertex::Vertex() const
{
return myVtx;
}
inline TopoDS_Vertex& BRepTopAdaptor_HVertex::ChangeVertex()
{
return myVtx;
}
@@ -7,7 +7,6 @@ set(OCCT_BRepTopAdaptor_FILES
BRepTopAdaptor_FClass2d.hxx
BRepTopAdaptor_HVertex.cxx
BRepTopAdaptor_HVertex.hxx
BRepTopAdaptor_HVertex.lxx
BRepTopAdaptor_Tool.cxx
BRepTopAdaptor_Tool.hxx
@@ -54,7 +54,7 @@ public:
//! true if the orientation of the modified
//! face changes in the shells which contain it.
//! Here, <RevFace> will return true if the
//! -- gp_Trsf is negative.
//! - gp_Trsf is negative.
Standard_EXPORT bool NewSurface(const TopoDS_Face& F,
occ::handle<Geom_Surface>& S,
TopLoc_Location& L,
@@ -54,7 +54,7 @@ public:
//! true if the orientation of the modified
//! face changes in the shells which contain it.
//! Here, <RevFace> will return true if the
//! -- gp_Trsf is negative.
//! - gp_Trsf is negative.
Standard_EXPORT bool NewSurface(const TopoDS_Face& F,
occ::handle<Geom_Surface>& S,
TopLoc_Location& L,