From: bugmaster Date: Thu, 12 Jul 2018 13:33:52 +0000 (+0300) Subject: Updated source files from path X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=bdab029260fb42b8e0289f3d6459ad29023f9002;p=occt-copy.git Updated source files from path --- diff --git a/adm/UDLIST b/adm/UDLIST index 39ffb0ba8a..42d740c06a 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -105,6 +105,7 @@ n BRepIntCurveSurface n BRepLib n BRepMAT2d n BRepMesh +n BRepMeshData n BRepOffset n BRepOffsetAPI n BRepPrim @@ -141,6 +142,8 @@ n HLRTopoBRep n HLRAppli n Hatch n HatchGen +n IMeshData +n IMeshTools n IntCurve n IntCurveSurface n IntCurvesFace diff --git a/src/AIS/AIS_RubberBand.cxx b/src/AIS/AIS_RubberBand.cxx index 1d7f1ab9d1..eddf06c280 100644 --- a/src/AIS/AIS_RubberBand.cxx +++ b/src/AIS/AIS_RubberBand.cxx @@ -296,13 +296,13 @@ Standard_Boolean AIS_RubberBand::fillTriangles() Handle(BRepMesh_DataStructureOfDelaun) aMeshStructure = new BRepMesh_DataStructureOfDelaun(anAllocator); Standard_Integer aPtsLower = myPoints.Lower(); Standard_Integer aPtsUpper = myPoints.Upper(); - BRepMesh::Array1OfInteger anIndexes (0, myPoints.Length() - 1); + IMeshData::VectorOfInteger anIndexes (myPoints.Length(), anAllocator); for (Standard_Integer aPtIdx = aPtsLower; aPtIdx <= aPtsUpper; ++aPtIdx) { gp_XY aP ((Standard_Real)myPoints.Value (aPtIdx).x(), (Standard_Real)myPoints.Value (aPtIdx).y()); BRepMesh_Vertex aVertex (aP, aPtIdx, BRepMesh_Frontier); - anIndexes.ChangeValue (aPtIdx - aPtsLower) = aMeshStructure->AddNode (aVertex); + anIndexes.Append (aMeshStructure->AddNode (aVertex)); } Standard_Real aPtSum = 0; @@ -325,7 +325,7 @@ Standard_Boolean AIS_RubberBand::fillTriangles() } BRepMesh_Delaun aTriangulation (aMeshStructure, anIndexes); - const BRepMesh::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain(); + const IMeshData::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain(); if (aTriangles.Extent() < 1) return Standard_False; @@ -338,7 +338,7 @@ Standard_Boolean AIS_RubberBand::fillTriangles() } Standard_Integer aVertexIndex = 1; - BRepMesh::MapOfInteger::Iterator aTriangleIt (aTriangles); + IMeshData::IteratorOfMapOfInteger aTriangleIt (aTriangles); for (; aTriangleIt.More(); aTriangleIt.Next()) { const Standard_Integer aTriangleId = aTriangleIt.Key(); diff --git a/src/BRepMesh/BRepMesh_CircleInspector.hxx b/src/BRepMesh/BRepMesh_CircleInspector.hxx index 509f376826..c55d243286 100644 --- a/src/BRepMesh/BRepMesh_CircleInspector.hxx +++ b/src/BRepMesh/BRepMesh_CircleInspector.hxx @@ -16,7 +16,7 @@ #ifndef BRepMesh_CircleInspector_Header #define BRepMesh_CircleInspector_Header -#include +#include #include #include #include @@ -39,7 +39,7 @@ public: const Handle(NCollection_IncAllocator)& theAllocator) : myTolerance(theTolerance*theTolerance), myResIndices(theAllocator), - myCircles(theReservedSize) + myCircles(theReservedSize, theAllocator) { } @@ -53,7 +53,7 @@ public: } //! Resutns vector of registered circles. - inline const BRepMesh::VectorOfCircle& Circles() const + inline const IMeshData::VectorOfCircle& Circles() const { return myCircles; } @@ -75,7 +75,7 @@ public: } //! Returns list of circles shot by the reference point. - inline BRepMesh::ListOfInteger& GetShotCircles() + inline IMeshData::ListOfInteger& GetShotCircles() { return myResIndices; } @@ -83,8 +83,23 @@ public: //! Performs inspection of a circle with the given index. //! @param theTargetIndex index of a circle to be checked. //! @return status of the check. - Standard_EXPORT NCollection_CellFilter_Action Inspect( - const Standard_Integer theTargetIndex); + inline NCollection_CellFilter_Action Inspect( + const Standard_Integer theTargetIndex) + { + BRepMesh_Circle& aCircle = myCircles(theTargetIndex); + const Standard_Real& aRadius = aCircle.Radius(); + if (aRadius < 0.) + return CellFilter_Purge; + + gp_XY& aLoc = const_cast(aCircle.Location()); + + const Standard_Real aDX = myPoint.ChangeCoord(1) - aLoc.ChangeCoord(1); + const Standard_Real aDY = myPoint.ChangeCoord(2) - aLoc.ChangeCoord(2); + if ((aDX * aDX + aDY * aDY) - (aRadius * aRadius) <= myTolerance) + myResIndices.Append(theTargetIndex); + + return CellFilter_Keep; + } //! Checks indices for equlity. static Standard_Boolean IsEqual( @@ -95,10 +110,10 @@ public: } private: - Standard_Real myTolerance; - BRepMesh::ListOfInteger myResIndices; - BRepMesh::VectorOfCircle myCircles; - gp_XY myPoint; + Standard_Real myTolerance; + IMeshData::ListOfInteger myResIndices; + IMeshData::VectorOfCircle myCircles; + gp_XY myPoint; }; #endif diff --git a/src/BRepMesh/BRepMesh_CircleTool.cxx b/src/BRepMesh/BRepMesh_CircleTool.cxx index e0f76003d9..109016c1f7 100644 --- a/src/BRepMesh/BRepMesh_CircleTool.cxx +++ b/src/BRepMesh/BRepMesh_CircleTool.cxx @@ -21,27 +21,6 @@ #include #include -//======================================================================= -//function : Inspect -//purpose : -//======================================================================= -NCollection_CellFilter_Action BRepMesh_CircleInspector::Inspect( - const Standard_Integer theTargetIndex) -{ - const BRepMesh_Circle& aCircle = myCircles(theTargetIndex); - Standard_Real aRadius = aCircle.Radius(); - if(aRadius < 0.) - return CellFilter_Purge; - - const gp_XY& aLoc = aCircle.Location(); - - if ((myPoint - aLoc).SquareModulus() - (aRadius * aRadius) <= myTolerance) - myResIndices.Append(theTargetIndex); - - return CellFilter_Keep; -} - - //======================================================================= //function : BRepMesh_CircleTool //purpose : @@ -117,42 +96,43 @@ Standard_Boolean BRepMesh_CircleTool::MakeCircle(const gp_XY& thePoint1, static const Standard_Real aPrecision = Precision::PConfusion(); static const Standard_Real aSqPrecision = aPrecision * aPrecision; - if ((thePoint1 - thePoint3).SquareModulus() < aSqPrecision) - return Standard_False; - - gp_XY aLink1(thePoint2 - thePoint1); + gp_XY aLink1(const_cast(thePoint3).ChangeCoord(1) - const_cast(thePoint2).ChangeCoord(1), + const_cast(thePoint2).ChangeCoord(2) - const_cast(thePoint3).ChangeCoord(2)); if (aLink1.SquareModulus() < aSqPrecision) return Standard_False; - gp_XY aLink2(thePoint3 - thePoint2); + gp_XY aLink2(const_cast(thePoint1).ChangeCoord(1) - const_cast(thePoint3).ChangeCoord(1), + const_cast(thePoint3).ChangeCoord(2) - const_cast(thePoint1).ChangeCoord(2)); if (aLink2.SquareModulus() < aSqPrecision) return Standard_False; - gp_XY aMidPnt1 = (thePoint1 + thePoint2) / 2.; - gp_XY aNorm1 = gp_XY(aLink1.Y(), -aLink1.X()); - aNorm1.Add(aMidPnt1); - - if (aLink2.SquareModulus() < aSqPrecision) + gp_XY aLink3(const_cast(thePoint2).ChangeCoord(1) - const_cast(thePoint1).ChangeCoord(1), + const_cast(thePoint1).ChangeCoord(2) - const_cast(thePoint2).ChangeCoord(2)); + if (aLink3.SquareModulus() < aSqPrecision) return Standard_False; - gp_XY aMidPnt2 = (thePoint2 + thePoint3) / 2.; - gp_XY aNorm2 = gp_XY(aLink2.Y(), -aLink2.X()); - aNorm2.Add(aMidPnt2); + const Standard_Real aD = 2 * (const_cast(thePoint1).ChangeCoord(1) * aLink1.Y() + + const_cast(thePoint2).ChangeCoord(1) * aLink2.Y() + + const_cast(thePoint3).ChangeCoord(1) * aLink3.Y()); - gp_XY aIntPnt; - Standard_Real aParam[2]; - BRepMesh_GeomTool::IntFlag aIntFlag = - BRepMesh_GeomTool::IntLinLin(aMidPnt1, aNorm1, - aMidPnt2, aNorm2, aIntPnt, aParam); - - if (aIntFlag != BRepMesh_GeomTool::Cross) + if (Abs(aD) < gp::Resolution()) return Standard_False; - theLocation = aIntPnt; + const Standard_Real aInvD = 1. / aD; + const Standard_Real aSqMod1 = thePoint1.SquareModulus(); + const Standard_Real aSqMod2 = thePoint2.SquareModulus(); + const Standard_Real aSqMod3 = thePoint3.SquareModulus(); + theLocation.ChangeCoord(1) = (aSqMod1 * aLink1.Y() + + aSqMod2 * aLink2.Y() + + aSqMod3 * aLink3.Y()) * aInvD; + + theLocation.ChangeCoord(2) = (aSqMod1 * aLink1.X() + + aSqMod2 * aLink2.X() + + aSqMod3 * aLink3.X()) * aInvD; - theRadius = Sqrt(Max(Max((thePoint1 - aIntPnt).SquareModulus(), - (thePoint2 - aIntPnt).SquareModulus()), - (thePoint3 - aIntPnt).SquareModulus())) + 2 * RealEpsilon(); + theRadius = Sqrt(Max(Max((thePoint1 - theLocation).SquareModulus(), + (thePoint2 - theLocation).SquareModulus()), + (thePoint3 - theLocation).SquareModulus())) + 2 * RealEpsilon(); return Standard_True; } @@ -190,7 +170,7 @@ void BRepMesh_CircleTool::Delete(const Standard_Integer theIndex) //function : Select //purpose : //======================================================================= -BRepMesh::ListOfInteger& BRepMesh_CircleTool::Select(const gp_XY& thePoint) +IMeshData::ListOfInteger& BRepMesh_CircleTool::Select(const gp_XY& thePoint) { mySelector.SetPoint(thePoint); myCellFilter.Inspect(thePoint, mySelector); diff --git a/src/BRepMesh/BRepMesh_CircleTool.hxx b/src/BRepMesh/BRepMesh_CircleTool.hxx index a81e739b63..21427afa49 100644 --- a/src/BRepMesh/BRepMesh_CircleTool.hxx +++ b/src/BRepMesh/BRepMesh_CircleTool.hxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include class gp_Circ2d; @@ -125,7 +125,7 @@ public: //! Select the circles shot by the given point. //! @param thePoint bullet point. - Standard_EXPORT BRepMesh::ListOfInteger& Select(const gp_XY& thePoint); + Standard_EXPORT IMeshData::ListOfInteger& Select(const gp_XY& thePoint); private: @@ -141,7 +141,7 @@ private: Standard_Real myTolerance; Handle(NCollection_IncAllocator) myAllocator; - BRepMesh::CircleCellFilter myCellFilter; + IMeshData::CircleCellFilter myCellFilter; BRepMesh_CircleInspector mySelector; gp_XY myFaceMax; gp_XY myFaceMin; diff --git a/src/BRepMesh/BRepMesh_Classifier.cxx b/src/BRepMesh/BRepMesh_Classifier.cxx index 09545b49ed..3173b8fbed 100644 --- a/src/BRepMesh/BRepMesh_Classifier.cxx +++ b/src/BRepMesh/BRepMesh_Classifier.cxx @@ -1,7 +1,6 @@ -// Created on: 1997-06-26 -// Created by: Laurent PAINNOT -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Created on: 2016-07-07 +// Copyright (c) 2016 OPEN CASCADE SAS +// Created by: Oleg AGASHIN // // This file is part of Open CASCADE Technology software library. // @@ -29,6 +28,14 @@ BRepMesh_Classifier::BRepMesh_Classifier() { } +//======================================================================= +//function : Destructor +//purpose : +//======================================================================= +BRepMesh_Classifier::~BRepMesh_Classifier() +{ +} + //======================================================================= //function : Perform //purpose : @@ -38,19 +45,23 @@ TopAbs_State BRepMesh_Classifier::Perform(const gp_Pnt2d& thePoint) const Standard_Boolean isOut = Standard_False; Standard_Integer aNb = myTabClass.Length(); - for (Standard_Integer i = 1; i <= aNb; i++) + for (Standard_Integer i = 0; i < aNb; i++) { - Standard_Integer aCur = ((CSLib_Class2d*)myTabClass(i))->SiDans(thePoint); + const Standard_Integer aCur = myTabClass(i)->SiDans(thePoint); if (aCur == 0) { // Point is ON, but mark it as OUT isOut = Standard_True; } else + { isOut = myTabOrient(i) ? (aCur == -1) : (aCur == 1); + } if (isOut) + { return TopAbs_OUT; + } } return TopAbs_IN; @@ -61,23 +72,23 @@ TopAbs_State BRepMesh_Classifier::Perform(const gp_Pnt2d& thePoint) const //purpose : //======================================================================= void BRepMesh_Classifier::RegisterWire( - const NCollection_Sequence& theWire, - const Standard_Real theTolUV, - const Standard_Real theUmin, - const Standard_Real theUmax, - const Standard_Real theVmin, - const Standard_Real theVmax) + const NCollection_Sequence& theWire, + const std::pair& theTolUV, + const std::pair& theRangeU, + const std::pair& theRangeV) { const Standard_Integer aNbPnts = theWire.Length(); if (aNbPnts < 2) + { return; + } // Accumulate angle TColgp_Array1OfPnt2d aPClass(1, aNbPnts); Standard_Real anAngle = 0.0; - gp_Pnt2d p1 = theWire(1), p2 = theWire(2), p3; - aPClass(1) = p1; - aPClass(2) = p2; + const gp_Pnt2d *p1 = theWire(1), *p2 = theWire(2), *p3; + aPClass(1) = *p1; + aPClass(2) = *p2; const Standard_Real aAngTol = Precision::Angular(); const Standard_Real aSqConfusion = @@ -88,15 +99,15 @@ void BRepMesh_Classifier::RegisterWire( Standard_Integer ii = i + 2; if (ii > aNbPnts) { - p3 = aPClass(ii - aNbPnts); + p3 = &aPClass(ii - aNbPnts); } else { p3 = theWire.Value(ii); - aPClass(ii) = p3; + aPClass(ii) = *p3; } - gp_Vec2d A(p1,p2), B(p2,p3); + const gp_Vec2d A(*p1,*p2), B(*p2,*p3); if (A.SquareMagnitude() > aSqConfusion && B.SquareMagnitude() > aSqConfusion) { @@ -115,27 +126,10 @@ void BRepMesh_Classifier::RegisterWire( if (Abs(anAngle) < aAngTol) anAngle = 0.0; - myTabClass.Append( (void *)new CSLib_Class2d(aPClass, - theTolUV, theTolUV, theUmin, theVmin, theUmax, theVmax) ); - myTabOrient.Append( !(anAngle < 0.0) ); -} - -//======================================================================= -//function : Destroy -//purpose : -//======================================================================= -void BRepMesh_Classifier::Destroy() -{ - Standard_Integer aNb = myTabClass.Length(); - for (Standard_Integer i = 1; i <= aNb; i++) - { - if (myTabClass(i)) - { - delete ((CSLib_Class2d*)myTabClass(i)); - myTabClass(i) = NULL; - } - } + myTabClass.Append(std::shared_ptr(new CSLib_Class2d( + aPClass, theTolUV.first, theTolUV.second, + theRangeU.first, theRangeV.first, + theRangeU.second, theRangeV.second))); - myTabClass.Clear(); - myTabOrient.Clear(); + myTabOrient.Append( !(anAngle < 0.0) ); } diff --git a/src/BRepMesh/BRepMesh_Classifier.hxx b/src/BRepMesh/BRepMesh_Classifier.hxx index 4a87b84b61..871a9f4c39 100644 --- a/src/BRepMesh/BRepMesh_Classifier.hxx +++ b/src/BRepMesh/BRepMesh_Classifier.hxx @@ -1,7 +1,6 @@ -// Created on: 2014-06-03 +// Created on: 2016-07-07 +// Copyright (c) 2016 OPEN CASCADE SAS // Created by: Oleg AGASHIN -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -18,38 +17,30 @@ #define _BRepMesh_Classifier_HeaderFile #include -#include #include -#include -#include #include -#include -#include +#include -//! Auxilary class contains information about correctness of discretized -//! face and used for classification of points regarding face internals. -class BRepMesh_Classifier +#include + +class gp_Pnt2d; +class CSLib_Class2d; + +//! Auxilary class intended for classification of points +//! regarding internals of discrete face. +class BRepMesh_Classifier : public Standard_Transient { public: - DEFINE_STANDARD_ALLOC - //! Constructor. Standard_EXPORT BRepMesh_Classifier(); //! Destructor. - Standard_EXPORT virtual ~BRepMesh_Classifier() - { - Destroy(); - } - - //! Method is called on destruction. - //! Clears internal data structures. - Standard_EXPORT void Destroy(); + Standard_EXPORT virtual ~BRepMesh_Classifier(); //! Performs classification of the given point regarding to face internals. //! @param thePoint Point in parametric space to be classified. - //! @return + //! @return TopAbs_IN if point lies within face boundaries and TopAbs_OUT elsewhere. Standard_EXPORT TopAbs_State Perform(const gp_Pnt2d& thePoint) const; //! Registers wire specified by sequence of points for @@ -61,17 +52,17 @@ public: //! @param theVmin Lower V boundary of the face in parametric space. //! @param theVmax Upper V boundary of the face in parametric space. Standard_EXPORT void RegisterWire( - const NCollection_Sequence& theWire, - const Standard_Real theTolUV, - const Standard_Real theUmin, - const Standard_Real theUmax, - const Standard_Real theVmin, - const Standard_Real theVmax); + const NCollection_Sequence& theWire, + const std::pair& theTolUV, + const std::pair& theRangeU, + const std::pair& theRangeV); + + DEFINE_STANDARD_RTTI_INLINE (BRepMesh_Classifier, Standard_Transient) private: - BRepTopAdaptor_SeqOfPtr myTabClass; - TColStd_SequenceOfBoolean myTabOrient; + NCollection_Vector > myTabClass; + IMeshData::VectorOfBoolean myTabOrient; }; #endif diff --git a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx index b7d2adb1e0..4906412a44 100644 --- a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx +++ b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.cxx @@ -15,18 +15,15 @@ // commercial license or contractual agreement. #include -#include #include #include +#include #include #include #include #include - -IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_DataStructureOfDelaun,Standard_Transient) - //======================================================================= //function : BRepMesh_DataStructureOfDelaun //purpose : @@ -39,9 +36,7 @@ BRepMesh_DataStructureOfDelaun::BRepMesh_DataStructureOfDelaun( myNodeLinks (theReservedNodeSize * 3, myAllocator), myLinks (theReservedNodeSize * 3, myAllocator), myDelLinks (myAllocator), - myElements (theReservedNodeSize * 2, myAllocator), - myElementsOfDomain(theReservedNodeSize * 2, myAllocator), - myLinksOfDomain (theReservedNodeSize * 2, myAllocator) + myElements (theReservedNodeSize * 2, myAllocator) { } @@ -55,7 +50,7 @@ Standard_Integer BRepMesh_DataStructureOfDelaun::AddNode( { const Standard_Integer aNodeId = myNodes->Add(theNode, isForceAdd); if (!myNodeLinks.IsBound(aNodeId)) - myNodeLinks.Bind(aNodeId, BRepMesh::ListOfInteger(myAllocator)); + myNodeLinks.Bind(aNodeId, IMeshData::ListOfInteger(myAllocator)); return aNodeId; } @@ -174,8 +169,8 @@ void BRepMesh_DataStructureOfDelaun::cleanLink( const Standard_Integer aNodeId = (i == 0) ? theLink.FirstNode() : theLink.LastNode(); - BRepMesh::ListOfInteger& aLinkList = linksConnectedTo(aNodeId); - BRepMesh::ListOfInteger::Iterator aLinkIt(aLinkList); + IMeshData::ListOfInteger& aLinkList = linksConnectedTo(aNodeId); + IMeshData::ListOfInteger::Iterator aLinkIt(aLinkList); for(; aLinkIt.More(); aLinkIt.Next()) { if (aLinkIt.Value() == theIndex) @@ -194,16 +189,11 @@ void BRepMesh_DataStructureOfDelaun::cleanLink( Standard_Integer BRepMesh_DataStructureOfDelaun::AddElement( const BRepMesh_Triangle& theElement) { - Standard_Integer aElementIndex = IndexOf(theElement); - if (aElementIndex > 0) - return aElementIndex; - - aElementIndex = myElements.Add(theElement); + myElements.Append(theElement); + Standard_Integer aElementIndex = myElements.Size(); myElementsOfDomain.Add(aElementIndex); - Standard_Integer e[3]; - Standard_Boolean o[3]; - theElement.Edges(e, o); + const Standard_Integer (&e)[3] = theElement.myEdges; for (Standard_Integer i = 0; i < 3; ++i) myLinks(e[i]).Append(aElementIndex); @@ -237,10 +227,7 @@ void BRepMesh_DataStructureOfDelaun::cleanElement( if (theElement.Movability() != BRepMesh_Free) return; - Standard_Integer e[3]; - Standard_Boolean o[3]; - theElement.Edges(e, o); - + const Standard_Integer(&e)[3] = theElement.myEdges; for (Standard_Integer i = 0; i < 3; ++i) removeElementIndex(theIndex, myLinks(e[i])); } @@ -274,20 +261,15 @@ Standard_Boolean BRepMesh_DataStructureOfDelaun::SubstituteElement( const BRepMesh_Triangle& aElement = GetElement(theIndex); if (aElement.Movability() == BRepMesh_Deleted) { - myElements.Substitute(theIndex, theNewElement); + myElements(theIndex) = theNewElement; return Standard_True; } - if (IndexOf(theNewElement) != 0) - return Standard_False; - cleanElement(theIndex, aElement); // Warning: here new element and old element should have different Hash code - myElements.Substitute(theIndex, theNewElement); + myElements(theIndex) = theNewElement; - Standard_Integer e[3]; - Standard_Boolean o[3]; - theNewElement.Edges(e, o); + const Standard_Integer(&e)[3] = theNewElement.myEdges; for (Standard_Integer i = 0; i < 3; ++i) myLinks(e[i]).Append(theIndex); @@ -302,9 +284,8 @@ void BRepMesh_DataStructureOfDelaun::ElementNodes( const BRepMesh_Triangle& theElement, Standard_Integer (&theNodes)[3]) { - Standard_Integer e[3]; - Standard_Boolean o[3]; - theElement.Edges(e, o); + const Standard_Integer(&e)[3] = theElement.myEdges; + const Standard_Boolean(&o)[3] = theElement.myOrientations; const BRepMesh_Edge& aLink1 = GetLink(e[0]); if (o[0]) @@ -331,16 +312,14 @@ void BRepMesh_DataStructureOfDelaun::ElementNodes( //======================================================================= void BRepMesh_DataStructureOfDelaun::ClearDomain() { - BRepMesh::MapOfInteger aFreeEdges; - BRepMesh::MapOfInteger::Iterator aElementIt(myElementsOfDomain); + IMeshData::MapOfInteger aFreeEdges; + IMeshData::IteratorOfMapOfInteger aElementIt(myElementsOfDomain); for (; aElementIt.More(); aElementIt.Next()) { const Standard_Integer aElementId = aElementIt.Key(); BRepMesh_Triangle& aElement = (BRepMesh_Triangle&)GetElement(aElementId); - Standard_Integer e[3]; - Standard_Boolean o[3]; - aElement.Edges(e, o); + const Standard_Integer(&e)[3] = aElement.myEdges; for (Standard_Integer i = 0; i < 3; ++i) aFreeEdges.Add(e[i]); @@ -350,7 +329,7 @@ void BRepMesh_DataStructureOfDelaun::ClearDomain() } myElementsOfDomain.Clear(); - BRepMesh::MapOfInteger::Iterator aEdgeIt(aFreeEdges); + IMeshData::IteratorOfMapOfInteger aEdgeIt(aFreeEdges); for (; aEdgeIt.More(); aEdgeIt.Next()) RemoveLink(aEdgeIt.Key()); } @@ -390,7 +369,7 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedLinks() --aLastLiveItem; const Standard_Integer aLastLiveItemId = aLastLiveItem + 1; - BRepMesh::ListOfInteger::Iterator aLinkIt; + IMeshData::ListOfInteger::Iterator aLinkIt; // update link references for (Standard_Integer i = 0; i < 2; ++i) { @@ -411,10 +390,9 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedLinks() // update elements references for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; ++j) { - const BRepMesh_Triangle& aElement = GetElement(aPair.Index(j)); - Standard_Integer e[3]; Standard_Boolean o[3]; + const BRepMesh_Triangle& aElement = GetElement(aPair.Index(j)); aElement.Edges(e, o); for (Standard_Integer i = 0; i < 3; ++i) { @@ -425,8 +403,7 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedLinks() } } - myElements.Substitute(aLinkIt.Value(), - BRepMesh_Triangle(e, o, aElement.Movability())); + myElements(aLinkIt.Value()) = BRepMesh_Triangle(e, o, aElement.Movability()); } } } @@ -437,8 +414,8 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedLinks() //======================================================================= void BRepMesh_DataStructureOfDelaun::clearDeletedNodes() { - BRepMesh::ListOfInteger& aDelNodes = - (BRepMesh::ListOfInteger&)myNodes->GetListOfDelNodes(); + IMeshData::ListOfInteger& aDelNodes = + (IMeshData::ListOfInteger&)myNodes->GetListOfDelNodes(); Standard_Integer aLastLiveItem = NbNodes(); while (!aDelNodes.IsEmpty()) @@ -459,7 +436,7 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedNodes() continue; BRepMesh_Vertex aNode = GetNode(aLastLiveItem); - BRepMesh::ListOfInteger& aLinkList = linksConnectedTo(aLastLiveItem); + IMeshData::ListOfInteger& aLinkList = linksConnectedTo(aLastLiveItem); myNodes->RemoveLast(); --aLastLiveItem; @@ -468,7 +445,7 @@ void BRepMesh_DataStructureOfDelaun::clearDeletedNodes() myNodeLinks.ChangeFind(aDelItem) = aLinkList; const Standard_Integer aLastLiveItemId = aLastLiveItem + 1; - BRepMesh::ListOfInteger::Iterator aLinkIt(aLinkList); + IMeshData::ListOfInteger::Iterator aLinkIt(aLinkList); for (; aLinkIt.More(); aLinkIt.Next()) { const Standard_Integer aLinkId = aLinkIt.Value(); @@ -502,7 +479,7 @@ void BRepMesh_DataStructureOfDelaun::Statistics(Standard_OStream& theStream) con theStream << "\n Deleted links : " << myDelLinks.Extent() << endl; theStream << "\n\n Map of elements : \n"; - myElements.Statistics(theStream); + theStream << "\n Elements : " << myElements.Size() << endl; } //======================================================================= @@ -521,7 +498,7 @@ Standard_CString BRepMesh_Dump(void* theMeshHandlePtr, return "Error: file name or mesh data is null"; } - Handle(BRepMesh_DataStructureOfDelaun) aMeshData = + Handle(BRepMesh_DataStructureOfDelaun) aMeshData = *(Handle(BRepMesh_DataStructureOfDelaun)*)theMeshHandlePtr; if (aMeshData.IsNull()) @@ -547,10 +524,10 @@ Standard_CString BRepMesh_Dump(void* theMeshHandlePtr, } else { - BRepMesh::MapOfInteger::Iterator aLinksIt(aMeshData->LinksOfDomain()); + IMeshData::IteratorOfMapOfInteger aLinksIt(aMeshData->LinksOfDomain()); for (; aLinksIt.More(); aLinksIt.Next()) { - const BRepMesh_Edge& aLink = aMeshData->GetLink(aLinksIt.Value()); + const BRepMesh_Edge& aLink = aMeshData->GetLink(aLinksIt.Key()); gp_Pnt aPnt[2]; for (Standard_Integer i = 0; i < 2; ++i) { @@ -578,3 +555,9 @@ Standard_CString BRepMesh_Dump(void* theMeshHandlePtr, return theFileNameStr; } + +void BRepMesh_DataStructureOfDelaun::Dump(Standard_CString theFileNameStr) +{ + Handle(BRepMesh_DataStructureOfDelaun) aMeshData (this); + BRepMesh_Dump((void*)&aMeshData, theFileNameStr); +} diff --git a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.hxx b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.hxx index 60b98f230b..1c600ef690 100644 --- a/src/BRepMesh/BRepMesh_DataStructureOfDelaun.hxx +++ b/src/BRepMesh/BRepMesh_DataStructureOfDelaun.hxx @@ -14,17 +14,14 @@ #ifndef _BRepMesh_DataStructureOfDelaun_HeaderFile #define _BRepMesh_DataStructureOfDelaun_HeaderFile -#include -#include -#include #include #include #include #include -#include +#include +#include class BRepMesh_Vertex; -class BRepMesh_VertexTool; class BRepMesh_Edge; //! Describes the data structure necessary for the mesh algorithms in @@ -108,7 +105,7 @@ public: //! @name API for accessing mesh nodes. //! 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 BRepMesh::ListOfInteger& LinksConnectedTo( + inline const IMeshData::ListOfInteger& LinksConnectedTo( const Standard_Integer theIndex) const { return linksConnectedTo(theIndex); @@ -145,7 +142,7 @@ public: //! @name API for accessing mesh links. } //! Returns map of indices of links registered in mesh. - inline const BRepMesh::MapOfInteger& LinksOfDomain() const + inline const IMeshData::MapOfInteger& LinksOfDomain() const { return myLinksOfDomain; } @@ -181,7 +178,7 @@ public: //! @name API for accessing mesh elements. //! Returns number of links. inline Standard_Integer NbElements() const { - return myElements.Extent(); + return myElements.Size(); } //! Adds element to the mesh if it is not already in the mesh. @@ -189,24 +186,16 @@ public: //! @name API for accessing mesh elements. //! @return index of the element in the structure. Standard_EXPORT Standard_Integer AddElement(const BRepMesh_Triangle& theElement); - //! Finds the index of the given element. - //! @param theElement element to find. - //! @return index of the given element of zero if element is not in the mesh. - Standard_Integer IndexOf(const BRepMesh_Triangle& theElement) const - { - return myElements.FindIndex(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.FindKey(theIndex); + return myElements.ChangeValue(theIndex - 1); } //! Returns map of indices of elements registered in mesh. - inline const BRepMesh::MapOfInteger& ElementsOfDomain() const + inline const IMeshData::MapOfInteger& ElementsOfDomain() const { return myElementsOfDomain; } @@ -229,6 +218,8 @@ public: //! @name API for accessing mesh elements. const BRepMesh_Triangle& theElement, Standard_Integer (&theNodes)[3]); + Standard_EXPORT void Dump(Standard_CString theFileNameStr); + public: //! @name Auxilary API @@ -244,7 +235,7 @@ public: //! @name Auxilary API } //! Gives the data structure for initialization of cell size and tolerance. - inline BRepMesh::HVertexTool& Data() + inline const Handle(BRepMesh_VertexTool)& Data() { return myNodes; } @@ -260,17 +251,17 @@ public: //! @name Auxilary API clearDeletedNodes(); } - DEFINE_STANDARD_RTTIEXT(BRepMesh_DataStructureOfDelaun,Standard_Transient) + 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 BRepMesh::ListOfInteger& linksConnectedTo( + inline IMeshData::ListOfInteger& linksConnectedTo( const Standard_Integer theIndex) const { - return (BRepMesh::ListOfInteger&)myNodeLinks.Find(theIndex); + return (IMeshData::ListOfInteger&)myNodeLinks.Find(theIndex); } //! Substitutes deleted links by the last one from corresponding map @@ -305,15 +296,13 @@ private: private: Handle(NCollection_IncAllocator) myAllocator; - BRepMesh::HVertexTool myNodes; - BRepMesh::DMapOfIntegerListOfInteger myNodeLinks; - BRepMesh::IDMapOfLink myLinks; - BRepMesh::ListOfInteger myDelLinks; - BRepMesh::IMapOfElement myElements; - BRepMesh::MapOfInteger myElementsOfDomain; - BRepMesh::MapOfInteger myLinksOfDomain; + Handle(BRepMesh_VertexTool) myNodes; + IMeshData::DMapOfIntegerListOfInteger myNodeLinks; + IMeshData::IDMapOfLink myLinks; + IMeshData::ListOfInteger myDelLinks; + IMeshData::VectorOfElements myElements; + IMeshData::MapOfInteger myElementsOfDomain; + IMeshData::MapOfInteger myLinksOfDomain; }; -DEFINE_STANDARD_HANDLE(BRepMesh_DataStructureOfDelaun,Standard_Transient) - #endif diff --git a/src/BRepMesh/BRepMesh_Delaun.cxx b/src/BRepMesh/BRepMesh_Delaun.cxx index 62ff759122..6c808505e5 100644 --- a/src/BRepMesh/BRepMesh_Delaun.cxx +++ b/src/BRepMesh/BRepMesh_Delaun.cxx @@ -82,14 +82,14 @@ namespace { //function : BRepMesh_Delaun //purpose : Creates the triangulation with an empty Mesh data structure //======================================================================= -BRepMesh_Delaun::BRepMesh_Delaun(BRepMesh::Array1OfVertexOfDelaun& theVertices) +BRepMesh_Delaun::BRepMesh_Delaun(IMeshData::Array1OfVertexOfDelaun& theVertices) : myCircles (theVertices.Length(), new NCollection_IncAllocator( - BRepMesh::MEMORY_BLOCK_SIZE_HUGE)) + IMeshData::MEMORY_BLOCK_SIZE_HUGE)) { if ( theVertices.Length() > 2 ) { myMeshData = new BRepMesh_DataStructureOfDelaun( - new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE), + new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE), theVertices.Length() ); Init( theVertices ); } @@ -100,8 +100,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(BRepMesh::Array1OfVertexOfDelaun& theVertices) //purpose : Creates the triangulation with and existent Mesh data structure //======================================================================= BRepMesh_Delaun::BRepMesh_Delaun( - const Handle( BRepMesh_DataStructureOfDelaun )& theOldMesh, - BRepMesh::Array1OfVertexOfDelaun& theVertices) + const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh, + IMeshData::Array1OfVertexOfDelaun& theVertices) : myMeshData( theOldMesh ), myCircles ( theVertices.Length(), theOldMesh->Allocator() ) { @@ -114,8 +114,8 @@ BRepMesh_Delaun::BRepMesh_Delaun( //purpose : Creates the triangulation with and existent Mesh data structure //======================================================================= BRepMesh_Delaun::BRepMesh_Delaun( - const Handle( BRepMesh_DataStructureOfDelaun )& theOldMesh, - BRepMesh::Array1OfInteger& theVertexIndices) + const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh, + IMeshData::VectorOfInteger& theVertexIndices) : myMeshData( theOldMesh ), myCircles ( theVertexIndices.Length(), theOldMesh->Allocator() ) { @@ -135,18 +135,18 @@ BRepMesh_Delaun::BRepMesh_Delaun( //function : Init //purpose : Initializes the triangulation with an Array of Vertex //======================================================================= -void BRepMesh_Delaun::Init(BRepMesh::Array1OfVertexOfDelaun& theVertices) +void BRepMesh_Delaun::Init(IMeshData::Array1OfVertexOfDelaun& theVertices) { Bnd_Box2d aBox; Standard_Integer aLowerIdx = theVertices.Lower(); Standard_Integer anUpperIdx = theVertices.Upper(); - BRepMesh::Array1OfInteger aVertexIndexes( aLowerIdx, anUpperIdx ); + IMeshData::VectorOfInteger aVertexIndexes(theVertices.Size()); Standard_Integer anIndex = aLowerIdx; for ( ; anIndex <= anUpperIdx; ++anIndex ) { aBox.Add( gp_Pnt2d( theVertices( anIndex ).Coord() ) ); - aVertexIndexes( anIndex ) = myMeshData->AddNode( theVertices( anIndex ) ); + aVertexIndexes.Append(myMeshData->AddNode( theVertices( anIndex ) )); } perform( aBox, aVertexIndexes ); @@ -156,8 +156,8 @@ void BRepMesh_Delaun::Init(BRepMesh::Array1OfVertexOfDelaun& theVertices) //function : perform //purpose : Create super mesh and run triangulation procedure //======================================================================= -void BRepMesh_Delaun::perform(Bnd_Box2d& theBndBox, - BRepMesh::Array1OfInteger& theVertexIndexes) +void BRepMesh_Delaun::perform(Bnd_Box2d& theBndBox, + IMeshData::VectorOfInteger& theVertexIndexes) { theBndBox.Enlarge( Precision ); superMesh( theBndBox ); @@ -226,15 +226,15 @@ void BRepMesh_Delaun::superMesh( const Bnd_Box2d& theBox ) // edges into the map. // When an edge is suppressed more than one time it is destroyed. //======================================================================= -void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex, - BRepMesh::MapOfIntegerInteger& theLoopEdges ) +void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex, + IMeshData::MapOfIntegerInteger& theLoopEdges ) { myCircles.Delete( theIndex ); - Standard_Integer e[3]; - Standard_Boolean o[3]; - GetTriangle( theIndex ).Edges( e, o ); - + const BRepMesh_Triangle& aElement = GetTriangle(theIndex); + const Standard_Integer(&e)[3] = aElement.myEdges; + const Standard_Boolean(&o)[3] = aElement.myOrientations; + myMeshData->RemoveElement( theIndex ); for ( Standard_Integer i = 0; i < 3; ++i ) @@ -252,13 +252,11 @@ void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex, //purpose : Computes the triangulation and add the vertices edges and // triangles to the Mesh data structure //======================================================================= -void BRepMesh_Delaun::compute(BRepMesh::Array1OfInteger& theVertexIndexes) +void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes) { // Insertion of edges of super triangles in the list of free edges: - BRepMesh::MapOfIntegerInteger aLoopEdges(10, myMeshData->Allocator()); - Standard_Integer e[3]; - Standard_Boolean o[3]; - mySupTrian.Edges( e, o ); + IMeshData::MapOfIntegerInteger aLoopEdges(10, myMeshData->Allocator()); + const Standard_Integer(&e)[3] = mySupTrian.myEdges; aLoopEdges.Bind( e[0], Standard_True ); aLoopEdges.Bind( e[1], Standard_True ); @@ -280,13 +278,13 @@ void BRepMesh_Delaun::compute(BRepMesh::Array1OfInteger& theVertexIndexes) aSelector.NeighboursOfNode( mySupVert[aSupVertId] ); aLoopEdges.Clear(); - BRepMesh::MapOfInteger::Iterator aFreeTriangles( aSelector.Elements() ); + IMeshData::IteratorOfMapOfInteger aFreeTriangles( aSelector.Elements() ); for ( ; aFreeTriangles.More(); aFreeTriangles.Next() ) deleteTriangle( aFreeTriangles.Key(), aLoopEdges ); // All edges that remain free are removed from aLoopEdges; // only the boundary edges of the triangulation remain there - BRepMesh::MapOfIntegerInteger::Iterator aFreeEdges( aLoopEdges ); + IMeshData::MapOfIntegerInteger::Iterator aFreeEdges( aLoopEdges ); for ( ; aFreeEdges.More(); aFreeEdges.Next() ) { if ( myMeshData->ElementsConnectedTo( aFreeEdges.Key() ).IsEmpty() ) @@ -302,19 +300,19 @@ void BRepMesh_Delaun::compute(BRepMesh::Array1OfInteger& theVertexIndexes) //function : createTriangles //purpose : Creates the triangles beetween the node and the polyline. //======================================================================= -void BRepMesh_Delaun::createTriangles(const Standard_Integer theVertexIndex, - BRepMesh::MapOfIntegerInteger& thePoly) +void BRepMesh_Delaun::createTriangles(const Standard_Integer theVertexIndex, + IMeshData::MapOfIntegerInteger& thePoly) { - BRepMesh::ListOfInteger aLoopEdges, anExternalEdges; + IMeshData::ListOfInteger aLoopEdges, anExternalEdges; const gp_XY& aVertexCoord = myMeshData->GetNode( theVertexIndex ).Coord(); - BRepMesh::MapOfIntegerInteger::Iterator anEdges( thePoly ); + IMeshData::MapOfIntegerInteger::Iterator anEdges( thePoly ); for ( ; anEdges.More(); anEdges.Next() ) { Standard_Integer anEdgeId = anEdges.Key(); const BRepMesh_Edge& anEdge = GetEdge( anEdgeId ); - const Standard_Boolean isPositive = thePoly (anEdgeId) != 0; + Standard_Boolean isPositive = thePoly( anEdgeId ) != 0; Standard_Integer aNodes[3]; if ( isPositive ) @@ -424,10 +422,10 @@ void BRepMesh_Delaun::createTriangles(const Standard_Integer theVertexIn //purpose : Creation of triangles from the new nodes //======================================================================= void BRepMesh_Delaun::createTrianglesOnNewVertices( - BRepMesh::Array1OfInteger& theVertexIndexes) + IMeshData::VectorOfInteger& theVertexIndexes) { Handle(NCollection_IncAllocator) aAllocator = - new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE); + new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); Standard_Real aTolU, aTolV; myMeshData->Data()->GetTolerance(aTolU, aTolV); @@ -441,16 +439,16 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices( for( ; anIndex <= anUpper; ++anIndex ) { aAllocator->Reset(Standard_False); - BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator); + IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator); Standard_Integer aVertexIdx = theVertexIndexes( anIndex ); const BRepMesh_Vertex& aVertex = GetVertex( aVertexIdx ); // Iterator in the list of indexes of circles containing the node - BRepMesh::ListOfInteger& aCirclesList = myCircles.Select( aVertex.Coord() ); + IMeshData::ListOfInteger& aCirclesList = myCircles.Select( aVertex.Coord() ); Standard_Integer onEgdeId = 0, aTriangleId = 0; - BRepMesh::ListOfInteger::Iterator aCircleIt( aCirclesList ); + IMeshData::ListOfInteger::Iterator aCircleIt( aCirclesList ); for ( ; aCircleIt.More(); aCircleIt.Next() ) { // To add a node in the mesh it is necessary to check conditions: @@ -484,12 +482,11 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices( while ( isModify && !aCirclesList.IsEmpty() ) { isModify = Standard_False; - BRepMesh::ListOfInteger::Iterator aCircleIt1( aCirclesList ); + IMeshData::ListOfInteger::Iterator aCircleIt1( aCirclesList ); for ( ; aCircleIt1.More(); aCircleIt1.Next() ) { - Standard_Integer e[3]; - Standard_Boolean o[3]; - GetTriangle( aCircleIt1.Value() ).Edges( e, o ); + const BRepMesh_Triangle& aElement = GetTriangle(aCircleIt1.Value()); + const Standard_Integer(&e)[3] = aElement.myEdges; if ( aLoopEdges.IsBound( e[0] ) || aLoopEdges.IsBound( e[1] ) || @@ -521,13 +518,11 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices( //======================================================================= void BRepMesh_Delaun::insertInternalEdges() { - BRepMesh::HMapOfInteger anInternalEdges = InternalEdges(); + Handle(IMeshData::MapOfInteger) anInternalEdges = InternalEdges();; // Destruction of triancles intersecting internal edges // and their replacement by makeshift triangles - Standard_Integer e[3]; - Standard_Boolean o[3]; - BRepMesh::MapOfInteger::Iterator anInernalEdgesIt( *anInternalEdges ); + IMeshData::IteratorOfMapOfInteger anInernalEdgesIt( *anInternalEdges ); for ( ; anInernalEdgesIt.More(); anInernalEdgesIt.Next() ) { const Standard_Integer aLinkIndex = anInernalEdgesIt.Key(); @@ -537,7 +532,10 @@ void BRepMesh_Delaun::insertInternalEdges() Standard_Boolean isGo[2] = { Standard_True, Standard_True }; for (Standard_Integer aTriangleIt = 1; aTriangleIt <= aPair.Extent(); ++aTriangleIt) { - GetTriangle(aPair.Index(aTriangleIt)).Edges(e, o); + const BRepMesh_Triangle& aElement = GetTriangle(aPair.Index(aTriangleIt)); + const Standard_Integer(&e)[3] = aElement.myEdges; + const Standard_Boolean(&o)[3] = aElement.myOrientations; + for (Standard_Integer i = 0; i < 3; ++i) { if (e[i] == aLinkIndex) @@ -586,9 +584,8 @@ Standard_Boolean BRepMesh_Delaun::isBoundToFrontier( if ( aTriId < 0 || aTriId == thePrevElementId ) continue; - Standard_Integer anEdges[3]; - Standard_Boolean anEdgesOri[3]; - GetTriangle( aTriId ).Edges( anEdges, anEdgesOri ); + const BRepMesh_Triangle& aElement = GetTriangle(aTriId); + const Standard_Integer(&anEdges)[3] = aElement.myEdges; for ( Standard_Integer anEdgeIt = 0; anEdgeIt < 3; ++anEdgeIt ) { @@ -623,16 +620,16 @@ Standard_Boolean BRepMesh_Delaun::isBoundToFrontier( void BRepMesh_Delaun::cleanupMesh() { Handle(NCollection_IncAllocator) aAllocator = - new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE); + new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); for(;;) { aAllocator->Reset(Standard_False); - BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator); - BRepMesh::MapOfInteger aDelTriangles(10, aAllocator); + IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator); + IMeshData::MapOfInteger aDelTriangles; - BRepMesh::HMapOfInteger aFreeEdges = FreeEdges(); - BRepMesh::MapOfInteger::Iterator aFreeEdgesIt( *aFreeEdges ); + Handle(IMeshData::MapOfInteger) aFreeEdges = FreeEdges(); + IMeshData::IteratorOfMapOfInteger aFreeEdgesIt( *aFreeEdges ); for ( ; aFreeEdgesIt.More(); aFreeEdgesIt.Next() ) { const Standard_Integer& aFreeEdgeId = aFreeEdgesIt.Key(); @@ -651,9 +648,8 @@ void BRepMesh_Delaun::cleanupMesh() Standard_Integer aTriId = aPair.FirstIndex(); // Check that the connected triangle is not surrounded by another triangles - Standard_Integer anEdges[3]; - Standard_Boolean anEdgesOri[3]; - GetTriangle( aTriId ).Edges( anEdges, anEdgesOri ); + const BRepMesh_Triangle& aElement = GetTriangle(aTriId); + const Standard_Integer(&anEdges)[3] = aElement.myEdges; Standard_Boolean isCanNotBeRemoved = Standard_True; for ( Standard_Integer aCurEdgeIdx = 0; aCurEdgeIdx < 3; ++aCurEdgeIdx ) @@ -694,7 +690,7 @@ void BRepMesh_Delaun::cleanupMesh() // Destruction of triangles : Standard_Integer aDeletedTrianglesNb = 0; - BRepMesh::MapOfInteger::Iterator aDelTrianglesIt( aDelTriangles ); + IMeshData::IteratorOfMapOfInteger aDelTrianglesIt( aDelTriangles ); for ( ; aDelTrianglesIt.More(); aDelTrianglesIt.Next() ) { deleteTriangle( aDelTrianglesIt.Key(), aLoopEdges ); @@ -702,7 +698,7 @@ void BRepMesh_Delaun::cleanupMesh() } // Destruction of remaining hanging edges - BRepMesh::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); + IMeshData::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); for ( ; aLoopEdgesIt.More(); aLoopEdgesIt.Next() ) { if ( myMeshData->ElementsConnectedTo( aLoopEdgesIt.Key() ).IsEmpty() ) @@ -720,15 +716,14 @@ void BRepMesh_Delaun::cleanupMesh() //======================================================================= void BRepMesh_Delaun::frontierAdjust() { - BRepMesh::HMapOfInteger aFrontier = Frontier(); + Handle(IMeshData::MapOfInteger) aFrontier = Frontier(); Handle(NCollection_IncAllocator) aAllocator = - new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE); + new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); - BRepMesh::VectorOfInteger aFailedFrontiers(256, aAllocator); - BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator); - BRepMesh::HMapOfInteger aIntFrontierEdges = - new BRepMesh::MapOfInteger(10, aAllocator); + IMeshData::VectorOfInteger aFailedFrontiers(256, aAllocator); + IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator); + Handle(IMeshData::MapOfInteger) aIntFrontierEdges = new IMeshData::MapOfInteger; for ( Standard_Integer aPass = 1; aPass <= 2; ++aPass ) { @@ -736,7 +731,7 @@ void BRepMesh_Delaun::frontierAdjust() // 2 pass): find external triangles on boundary edges appeared // during triangles replacement. - BRepMesh::MapOfInteger::Iterator aFrontierIt( *aFrontier ); + IMeshData::IteratorOfMapOfInteger aFrontierIt( *aFrontier ); for ( ; aFrontierIt.More(); aFrontierIt.Next() ) { Standard_Integer aFrontierId = aFrontierIt.Key(); @@ -748,9 +743,9 @@ void BRepMesh_Delaun::frontierAdjust() if( aPriorElemId < 0 ) continue; - Standard_Integer e[3]; - Standard_Boolean o[3]; - GetTriangle( aPriorElemId ).Edges( e, o ); + const BRepMesh_Triangle& aElement = GetTriangle(aPriorElemId); + const Standard_Integer(&e)[3] = aElement.myEdges; + const Standard_Boolean(&o)[3] = aElement.myOrientations; Standard_Boolean isTriangleFound = Standard_False; for ( Standard_Integer n = 0; n < 3; ++n ) @@ -770,7 +765,7 @@ void BRepMesh_Delaun::frontierAdjust() } // destrucrion of remaining hanging edges : - BRepMesh::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); + IMeshData::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); for ( ; aLoopEdgesIt.More(); aLoopEdgesIt.Next() ) { Standard_Integer aLoopEdgeId = aLoopEdgesIt.Key(); @@ -801,7 +796,7 @@ void BRepMesh_Delaun::frontierAdjust() // situation when frontier edge has a triangle at a right side, but its free // links cross another frontieres and meshLeftPolygonOf itself can't collect // a closed polygon. - BRepMesh::VectorOfInteger::Iterator aFailedFrontiersIt( aFailedFrontiers ); + IMeshData::VectorOfInteger::Iterator aFailedFrontiersIt( aFailedFrontiers ); for ( ; aFailedFrontiersIt.More(); aFailedFrontiersIt.Next() ) { Standard_Integer aFrontierId = aFailedFrontiersIt.Value(); @@ -817,9 +812,9 @@ void BRepMesh_Delaun::frontierAdjust() //purpose : Add boundig box for edge defined by start & end point to // the given vector of bounding boxes for triangulation edges //======================================================================= -void BRepMesh_Delaun::fillBndBox(BRepMesh::SequenceOfBndB2d& theBoxes, - const BRepMesh_Vertex& theV1, - const BRepMesh_Vertex& theV2) +void BRepMesh_Delaun::fillBndBox(IMeshData::SequenceOfBndB2d& theBoxes, + const BRepMesh_Vertex& theV1, + const BRepMesh_Vertex& theV2) { Bnd_B2d aBox; UpdateBndBox(theV1.Coord(), theV2.Coord(), aBox); @@ -831,16 +826,16 @@ void BRepMesh_Delaun::fillBndBox(BRepMesh::SequenceOfBndB2d& theBoxes, //purpose : Collect the polygon at the left of the given edge (material side) //======================================================================= Standard_Boolean BRepMesh_Delaun::meshLeftPolygonOf( - const Standard_Integer theStartEdgeId, - const Standard_Boolean isForward, - BRepMesh::HMapOfInteger theSkipped ) + const Standard_Integer theStartEdgeId, + const Standard_Boolean isForward, + Handle(IMeshData::MapOfInteger) theSkipped) { if ( !theSkipped.IsNull() && theSkipped->Contains( theStartEdgeId ) ) return Standard_True; const BRepMesh_Edge& aRefEdge = GetEdge( theStartEdgeId ); - BRepMesh::SequenceOfInteger aPolygon; + IMeshData::SequenceOfInteger aPolygon; Standard_Integer aStartNode, aPivotNode; if ( isForward ) { @@ -868,14 +863,14 @@ Standard_Boolean BRepMesh_Delaun::meshLeftPolygonOf( // Auxilary structures. // Bounding boxes of polygon links to be used for preliminary // analysis of intersections - BRepMesh::SequenceOfBndB2d aBoxes; + IMeshData::SequenceOfBndB2d aBoxes; fillBndBox( aBoxes, aStartEdgeVertexS, aPivotVertex ); // Hanging ends - BRepMesh::MapOfInteger aDeadLinks; + IMeshData::MapOfInteger aDeadLinks; // Links are temporarily excluded from consideration - BRepMesh::MapOfInteger aLeprousLinks; + IMeshData::MapOfInteger aLeprousLinks; aLeprousLinks.Add( theStartEdgeId ); Standard_Boolean isSkipLeprous = Standard_True; @@ -960,26 +955,26 @@ Standard_Boolean BRepMesh_Delaun::meshLeftPolygonOf( // consideration next time until a hanging end is occured. //======================================================================= Standard_Integer BRepMesh_Delaun::findNextPolygonLink( - const Standard_Integer& theFirstNode, - const Standard_Integer& thePivotNode, - const BRepMesh_Vertex& thePivotVertex, - const gp_Vec2d& theRefLinkDir, - const BRepMesh::SequenceOfBndB2d& theBoxes, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::HMapOfInteger theSkipped, - const Standard_Boolean& isSkipLeprous, - BRepMesh::MapOfInteger& theLeprousLinks, - BRepMesh::MapOfInteger& theDeadLinks, - Standard_Integer& theNextPivotNode, - gp_Vec2d& theNextLinkDir, - Bnd_B2d& theNextLinkBndBox ) + const Standard_Integer& theFirstNode, + const Standard_Integer& thePivotNode, + const BRepMesh_Vertex& thePivotVertex, + const gp_Vec2d& theRefLinkDir, + const IMeshData::SequenceOfBndB2d& theBoxes, + const IMeshData::SequenceOfInteger& thePolygon, + const Handle(IMeshData::MapOfInteger) theSkipped, + const Standard_Boolean& isSkipLeprous, + IMeshData::MapOfInteger& theLeprousLinks, + IMeshData::MapOfInteger& theDeadLinks, + Standard_Integer& theNextPivotNode, + gp_Vec2d& theNextLinkDir, + Bnd_B2d& theNextLinkBndBox ) { // Find the next link having the greatest angle // respect to a direction of a reference one Standard_Real aMaxAngle = RealFirst(); Standard_Integer aNextLinkId = 0; - BRepMesh::ListOfInteger::Iterator aLinkIt( myMeshData->LinksConnectedTo( thePivotNode ) ); + IMeshData::ListOfInteger::Iterator aLinkIt( myMeshData->LinksConnectedTo( thePivotNode ) ); for ( ; aLinkIt.More(); aLinkIt.Next() ) { const Standard_Integer& aNeighbourLinkInfo = aLinkIt.Value(); @@ -1069,13 +1064,13 @@ Standard_Integer BRepMesh_Delaun::findNextPolygonLink( // parameter. //======================================================================= Standard_Boolean BRepMesh_Delaun::checkIntersection( - const BRepMesh_Edge& theLink, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes, - const Standard_Boolean isConsiderEndPointTouch, - const Standard_Boolean isConsiderPointOnEdge, - const Standard_Boolean isSkipLastEdge, - Bnd_B2d& theLinkBndBox ) const + const BRepMesh_Edge& theLink, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes, + const Standard_Boolean isConsiderEndPointTouch, + const Standard_Boolean isConsiderPointOnEdge, + const Standard_Boolean isSkipLastEdge, + Bnd_B2d& theLinkBndBox ) const { UpdateBndBox(GetVertex(theLink.FirstNode()).Coord(), GetVertex(theLink.LastNode()).Coord(), theLinkBndBox); @@ -1101,7 +1096,7 @@ Standard_Boolean BRepMesh_Delaun::checkIntersection( continue; gp_Pnt2d anIntPnt; - BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( theLink, aPolyLink, + BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( theLink, aPolyLink, isConsiderEndPointTouch, isConsiderPointOnEdge, anIntPnt ); if ( aIntFlag != BRepMesh_GeomTool::NoIntersection ) @@ -1117,17 +1112,10 @@ Standard_Boolean BRepMesh_Delaun::checkIntersection( //function : addTriangle //purpose : Add a triangle based on the given oriented edges into mesh //======================================================================= -void BRepMesh_Delaun::addTriangle( const Standard_Integer (&theEdgesId)[3], - const Standard_Boolean (&theEdgesOri)[3], - const Standard_Integer (&theNodesId)[3]) +inline void BRepMesh_Delaun::addTriangle( const Standard_Integer (&theEdgesId)[3], + const Standard_Boolean (&theEdgesOri)[3], + const Standard_Integer (&theNodesId)[3] ) { - for (Standard_Integer i = 0; i < 3; ++i) - { - const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo(theEdgesId[i]); - if (aPair.Extent() == 2) - // it is forbidden to have more than two triangles connected to the same link - return; - } Standard_Integer aNewTriangleId = myMeshData->AddElement(BRepMesh_Triangle(theEdgesId, theEdgesOri, BRepMesh_Free)); @@ -1146,20 +1134,20 @@ void BRepMesh_Delaun::addTriangle( const Standard_Integer (&theEdgesId)[3], //function : cleanupPolygon //purpose : Remove internal triangles from the given polygon //======================================================================= -void BRepMesh_Delaun::cleanupPolygon(const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes ) +void BRepMesh_Delaun::cleanupPolygon(const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes ) { Standard_Integer aPolyLen = thePolygon.Length(); if ( aPolyLen < 3 ) return; Handle(NCollection_IncAllocator) aAllocator = - new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE); + new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE); - BRepMesh::MapOfIntegerInteger aLoopEdges(10, aAllocator); - BRepMesh::MapOfInteger anIgnoredEdges(10, aAllocator); - BRepMesh::MapOfInteger aPolyVerticesFindMap(10, aAllocator); - BRepMesh::VectorOfInteger aPolyVertices(256, aAllocator); + IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator); + IMeshData::MapOfInteger anIgnoredEdges; + IMeshData::MapOfInteger aPolyVerticesFindMap; + IMeshData::VectorOfInteger aPolyVertices(256, aAllocator); // Collect boundary vertices of the polygon for ( Standard_Integer aPolyIt = 1; aPolyIt <= aPolyLen; ++aPolyIt ) { @@ -1178,9 +1166,9 @@ void BRepMesh_Delaun::cleanupPolygon(const BRepMesh::SequenceOfInteger& thePolyg if ( anElemId < 0 ) continue; - Standard_Integer anEdges[3]; - Standard_Boolean anEdgesOri[3]; - GetTriangle( anElemId ).Edges(anEdges, anEdgesOri); + const BRepMesh_Triangle& aElement = GetTriangle(anElemId); + const Standard_Integer(&anEdges)[3] = aElement.myEdges; + const Standard_Boolean(&anEdgesOri)[3] = aElement.myOrientations; Standard_Integer isTriangleFound = Standard_False; for ( Standard_Integer anEdgeIt = 0; anEdgeIt < 3; ++anEdgeIt ) @@ -1225,7 +1213,7 @@ void BRepMesh_Delaun::cleanupPolygon(const BRepMesh::SequenceOfInteger& thePolyg if ( aPolyVertices.First() != aPolyVertices.Last() ) aPolyVertices.Append( aPolyVertices.First() ); - BRepMesh::MapOfInteger aSurvivedLinks( anIgnoredEdges ); + IMeshData::MapOfInteger aSurvivedLinks( anIgnoredEdges ); Standard_Integer aPolyVertIt = 0; Standard_Integer anUniqueVerticesNum = aPolyVertices.Length() - 1; @@ -1236,7 +1224,7 @@ void BRepMesh_Delaun::cleanupPolygon(const BRepMesh::SequenceOfInteger& thePolyg thePolyBoxes, aSurvivedLinks, aLoopEdges ); } - BRepMesh::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); + IMeshData::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); for ( ; aLoopEdgesIt.More(); aLoopEdgesIt.Next() ) { const Standard_Integer& aLoopEdgeId = aLoopEdgesIt.Key(); @@ -1254,19 +1242,19 @@ void BRepMesh_Delaun::cleanupPolygon(const BRepMesh::SequenceOfInteger& thePolyg // inside the polygon or crossed it. //======================================================================= void BRepMesh_Delaun::killTrianglesAroundVertex( - const Standard_Integer theZombieNodeId, - const BRepMesh::VectorOfInteger& thePolyVertices, - const BRepMesh::MapOfInteger& thePolyVerticesFindMap, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::MapOfInteger& theSurvivedLinks, - BRepMesh::MapOfIntegerInteger& theLoopEdges ) + const Standard_Integer theZombieNodeId, + const IMeshData::VectorOfInteger& thePolyVertices, + const IMeshData::MapOfInteger& thePolyVerticesFindMap, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes, + IMeshData::MapOfInteger& theSurvivedLinks, + IMeshData::MapOfIntegerInteger& theLoopEdges ) { - BRepMesh::ListOfInteger::Iterator aNeighborsIt = + IMeshData::ListOfInteger::Iterator aNeighborsIt = myMeshData->LinksConnectedTo( theZombieNodeId ); // Try to infect neighbor nodes - BRepMesh::VectorOfInteger aVictimNodes; + IMeshData::VectorOfInteger aVictimNodes; for ( ; aNeighborsIt.More(); aNeighborsIt.Next() ) { const Standard_Integer& aNeighborLinkId = aNeighborsIt.Value(); @@ -1324,7 +1312,7 @@ void BRepMesh_Delaun::killTrianglesAroundVertex( } // Go and do your job! - BRepMesh::VectorOfInteger::Iterator aVictimIt( aVictimNodes ); + IMeshData::VectorOfInteger::Iterator aVictimIt( aVictimNodes ); for ( ; aVictimIt.More(); aVictimIt.Next() ) { killTrianglesAroundVertex( aVictimIt.Value(), thePolyVertices, @@ -1338,8 +1326,8 @@ void BRepMesh_Delaun::killTrianglesAroundVertex( //purpose : Checks is the given vertex lies inside the polygon //======================================================================= Standard_Boolean BRepMesh_Delaun::isVertexInsidePolygon( - const Standard_Integer& theVertexId, - const BRepMesh::VectorOfInteger& thePolygonVertices ) const + const Standard_Integer& theVertexId, + const IMeshData::VectorOfInteger& thePolygonVertices ) const { Standard_Integer aPolyLen = thePolygonVertices.Length(); if ( aPolyLen < 3 ) @@ -1379,13 +1367,13 @@ Standard_Boolean BRepMesh_Delaun::isVertexInsidePolygon( // boundary intersection. Does nothing elsewhere. //======================================================================= void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( - const Standard_Integer& theLinkToCheckId, - const BRepMesh_Edge& theLinkToCheck, - const Standard_Integer& theEndPoint, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::MapOfInteger& theSurvivedLinks, - BRepMesh::MapOfIntegerInteger& theLoopEdges ) + const Standard_Integer& theLinkToCheckId, + const BRepMesh_Edge& theLinkToCheck, + const Standard_Integer& theEndPoint, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes, + IMeshData::MapOfInteger& theSurvivedLinks, + IMeshData::MapOfIntegerInteger& theLoopEdges ) { if ( theSurvivedLinks.Contains( theLinkToCheckId ) ) return; @@ -1403,7 +1391,7 @@ void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( killLinkTriangles( theLinkToCheckId, theLoopEdges ); - BRepMesh::ListOfInteger::Iterator aNeighborsIt( + IMeshData::ListOfInteger::Iterator aNeighborsIt( myMeshData->LinksConnectedTo(theEndPoint)); for ( ; aNeighborsIt.More(); aNeighborsIt.Next() ) @@ -1425,8 +1413,8 @@ void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( //purpose : Kill triangles bound to the given link. //======================================================================= void BRepMesh_Delaun::killLinkTriangles( - const Standard_Integer& theLinkId, - BRepMesh::MapOfIntegerInteger& theLoopEdges ) + const Standard_Integer& theLinkId, + IMeshData::MapOfIntegerInteger& theLoopEdges ) { const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo( theLinkId ); @@ -1468,17 +1456,17 @@ void BRepMesh_Delaun::getOrientedNodes(const BRepMesh_Edge& theEdge, //purpose : Processes loop within the given polygon formed by range of // its links specified by start and end link indices. //======================================================================= -void BRepMesh_Delaun::processLoop(const Standard_Integer theLinkFrom, - const Standard_Integer theLinkTo, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes) +void BRepMesh_Delaun::processLoop(const Standard_Integer theLinkFrom, + const Standard_Integer theLinkTo, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes) { Standard_Integer aNbOfLinksInLoop = theLinkTo - theLinkFrom - 1; if ( aNbOfLinksInLoop < 3 ) return; - BRepMesh::SequenceOfInteger aPolygon; - BRepMesh::SequenceOfBndB2d aPolyBoxes; + IMeshData::SequenceOfInteger aPolygon; + IMeshData::SequenceOfBndB2d aPolyBoxes; for ( ; aNbOfLinksInLoop > 0; --aNbOfLinksInLoop ) { Standard_Integer aLoopLinkIndex = theLinkFrom + aNbOfLinksInLoop; @@ -1496,10 +1484,10 @@ void BRepMesh_Delaun::processLoop(const Standard_Integer theLinkFrom Standard_Integer BRepMesh_Delaun::createAndReplacePolygonLink( const Standard_Integer *theNodes, const gp_Pnt2d *thePnts, - const Standard_Integer theRootIndex, - const ReplaceFlag theReplaceFlag, - BRepMesh::SequenceOfInteger& thePolygon, - BRepMesh::SequenceOfBndB2d& thePolyBoxes ) + const Standard_Integer theRootIndex, + const ReplaceFlag theReplaceFlag, + IMeshData::SequenceOfInteger& thePolygon, + IMeshData::SequenceOfBndB2d& thePolyBoxes ) { Standard_Integer aNewEdgeId = myMeshData->AddLink( BRepMesh_Edge( @@ -1533,9 +1521,9 @@ Standard_Integer BRepMesh_Delaun::createAndReplacePolygonLink( //function : meshPolygon //purpose : //======================================================================= -void BRepMesh_Delaun::meshPolygon(BRepMesh::SequenceOfInteger& thePolygon, - BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::HMapOfInteger theSkipped ) +void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon, + IMeshData::SequenceOfBndB2d& thePolyBoxes, + Handle(IMeshData::MapOfInteger) theSkipped) { // Check is the source polygon elementary if ( meshElementaryPolygon( thePolygon ) ) @@ -1582,7 +1570,7 @@ void BRepMesh_Delaun::meshPolygon(BRepMesh::SequenceOfInteger& thePolygon, }; gp_Pnt2d anIntPnt; - BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( *aCurEdge, *aNextEdge, + BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( *aCurEdge, *aNextEdge, Standard_False, Standard_True, anIntPnt ); if ( aIntFlag == BRepMesh_GeomTool::NoIntersection ) @@ -1749,14 +1737,14 @@ void BRepMesh_Delaun::meshPolygon(BRepMesh::SequenceOfInteger& thePolygon, } } - BRepMesh::SequenceOfInteger* aPolygon1 = &thePolygon; - BRepMesh::SequenceOfBndB2d* aPolyBoxes1 = &thePolyBoxes; + IMeshData::SequenceOfInteger* aPolygon1 = &thePolygon; + IMeshData::SequenceOfBndB2d* aPolyBoxes1 = &thePolyBoxes; - BRepMesh::HSequenceOfInteger aPolygon2 = new BRepMesh::SequenceOfInteger; - BRepMesh::HSequenceOfBndB2d aPolyBoxes2 = new BRepMesh::SequenceOfBndB2d; + Handle(IMeshData::SequenceOfInteger) aPolygon2 = new IMeshData::SequenceOfInteger; + Handle(IMeshData::SequenceOfBndB2d) aPolyBoxes2 = new IMeshData::SequenceOfBndB2d; - NCollection_Sequence aPolyStack; - NCollection_Sequence aPolyBoxStack; + NCollection_Sequence aPolyStack; + NCollection_Sequence aPolyBoxStack; for (;;) { decomposeSimplePolygon(*aPolygon1, *aPolyBoxes1, *aPolygon2, *aPolyBoxes2); @@ -1765,8 +1753,8 @@ void BRepMesh_Delaun::meshPolygon(BRepMesh::SequenceOfInteger& thePolygon, aPolyStack.Append(aPolygon2); aPolyBoxStack.Append(aPolyBoxes2); - aPolygon2 = new BRepMesh::SequenceOfInteger; - aPolyBoxes2 = new BRepMesh::SequenceOfBndB2d; + aPolygon2 = new IMeshData::SequenceOfInteger; + aPolyBoxes2 = new IMeshData::SequenceOfBndB2d; } if (aPolygon1->IsEmpty()) @@ -1791,7 +1779,7 @@ void BRepMesh_Delaun::meshPolygon(BRepMesh::SequenceOfInteger& thePolygon, //purpose : Triangulation of closed polygon containing only three edges. //======================================================================= inline Standard_Boolean BRepMesh_Delaun::meshElementaryPolygon( - const BRepMesh::SequenceOfInteger& thePolygon) + const IMeshData::SequenceOfInteger& thePolygon) { Standard_Integer aPolyLen = thePolygon.Length(); if ( aPolyLen < 3 ) @@ -1831,10 +1819,10 @@ inline Standard_Boolean BRepMesh_Delaun::meshElementaryPolygon( //purpose : //======================================================================= void BRepMesh_Delaun::decomposeSimplePolygon( - BRepMesh::SequenceOfInteger& thePolygon, - BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::SequenceOfInteger& thePolygonCut, - BRepMesh::SequenceOfBndB2d& thePolyBoxesCut) + IMeshData::SequenceOfInteger& thePolygon, + IMeshData::SequenceOfBndB2d& thePolyBoxes, + IMeshData::SequenceOfInteger& thePolygonCut, + IMeshData::SequenceOfBndB2d& thePolyBoxesCut) { // Check is the given polygon elementary if ( meshElementaryPolygon( thePolygon ) ) @@ -1926,7 +1914,7 @@ void BRepMesh_Delaun::decomposeSimplePolygon( // intersection is possible... gp_Pnt2d anIntPnt; - BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( aCheckLink, aPolyLink, + BRepMesh_GeomTool::IntFlag aIntFlag = intSegSeg( aCheckLink, aPolyLink, Standard_False, Standard_False, anIntPnt ); if( aIntFlag != BRepMesh_GeomTool::NoIntersection ) @@ -2018,17 +2006,17 @@ void BRepMesh_Delaun::RemoveVertex( const BRepMesh_Vertex& theVertex ) BRepMesh_SelectorOfDataStructureOfDelaun aSelector( myMeshData ); aSelector.NeighboursOf( theVertex ); - BRepMesh::MapOfIntegerInteger aLoopEdges;//( 10, myMeshData->Allocator() ); + IMeshData::MapOfIntegerInteger aLoopEdges;//( 10, myMeshData->Allocator() ); // Loop on triangles to be destroyed : - BRepMesh::MapOfInteger::Iterator aTriangleIt( aSelector.Elements() ); + IMeshData::IteratorOfMapOfInteger aTriangleIt( aSelector.Elements() ); for ( ; aTriangleIt.More(); aTriangleIt.Next() ) deleteTriangle( aTriangleIt.Key(), aLoopEdges ); - BRepMesh::SequenceOfBndB2d aBoxes; - BRepMesh::SequenceOfInteger aPolygon; + IMeshData::SequenceOfBndB2d aBoxes; + IMeshData::SequenceOfInteger aPolygon; Standard_Integer aLoopEdgesCount = aLoopEdges.Extent(); - BRepMesh::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); + IMeshData::MapOfIntegerInteger::Iterator aLoopEdgesIt( aLoopEdges ); if ( aLoopEdgesIt.More() ) { @@ -2038,7 +2026,7 @@ void BRepMesh_Delaun::RemoveVertex( const BRepMesh_Vertex& theVertex ) Standard_Integer aPivotNode = anEdge.LastNode(); Standard_Integer anEdgeId = aLoopEdgesIt.Key(); - Standard_Boolean isPositive = (aLoopEdges (anEdgeId) != 0); + Standard_Boolean isPositive = aLoopEdges( anEdgeId ) != 0; if ( !isPositive ) { Standard_Integer aTmp; @@ -2058,7 +2046,7 @@ void BRepMesh_Delaun::RemoveVertex( const BRepMesh_Vertex& theVertex ) aLastNode = aFirstNode; while ( aPivotNode != aLastNode ) { - BRepMesh::ListOfInteger::Iterator aLinkIt( myMeshData->LinksConnectedTo( aPivotNode ) ); + IMeshData::ListOfInteger::Iterator aLinkIt( myMeshData->LinksConnectedTo( aPivotNode ) ); for ( ; aLinkIt.More(); aLinkIt.Next() ) { if ( aLinkIt.Value() != anEdgeId && @@ -2099,19 +2087,13 @@ void BRepMesh_Delaun::RemoveVertex( const BRepMesh_Vertex& theVertex ) //function : AddVertices //purpose : Adds some vertices in the triangulation. //======================================================================= -void BRepMesh_Delaun::AddVertices(BRepMesh::Array1OfVertexOfDelaun& theVertices) +void BRepMesh_Delaun::AddVertices(IMeshData::VectorOfInteger& theVertices) { - std::make_heap(theVertices.begin(), theVertices.end(), ComparatorOfVertexOfDelaun()); - std::sort_heap(theVertices.begin(), theVertices.end(), ComparatorOfVertexOfDelaun()); - - Standard_Integer aLower = theVertices.Lower(); - Standard_Integer anUpper = theVertices.Upper(); - - BRepMesh::Array1OfInteger aVertexIndexes( aLower, anUpper ); - for ( Standard_Integer i = aLower; i <= anUpper; ++i ) - aVertexIndexes(i) = myMeshData->AddNode( theVertices(i) ); + ComparatorOfIndexedVertexOfDelaun aCmp(myMeshData); + std::make_heap(theVertices.begin(), theVertices.end(), aCmp); + std::sort_heap(theVertices.begin(), theVertices.end(), aCmp); - createTrianglesOnNewVertices( aVertexIndexes ); + createTrianglesOnNewVertices(theVertices); } //======================================================================= @@ -2206,12 +2188,12 @@ Standard_Boolean BRepMesh_Delaun::UseEdge( const Standard_Integer /*theIndex*/ ) //function : getEdgesByType //purpose : Gives the list of edges with type defined by input parameter //======================================================================= -BRepMesh::HMapOfInteger BRepMesh_Delaun::getEdgesByType( +Handle(IMeshData::MapOfInteger) BRepMesh_Delaun::getEdgesByType( const BRepMesh_DegreeOfFreedom theEdgeType ) const { Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator; - BRepMesh::HMapOfInteger aResult = new BRepMesh::MapOfInteger(1, anAlloc); - BRepMesh::MapOfInteger::Iterator anEdgeIt( myMeshData->LinksOfDomain() ); + Handle(IMeshData::MapOfInteger) aResult = new IMeshData::MapOfInteger; + IMeshData::IteratorOfMapOfInteger anEdgeIt( myMeshData->LinksOfDomain() ); for ( ; anEdgeIt.More(); anEdgeIt.Next() ) { @@ -2274,12 +2256,10 @@ Standard_Boolean BRepMesh_Delaun::Contains( const Standard_Integer theTriangleId { theEdgeOn = 0; - Standard_Integer e[3]; - Standard_Boolean o[3]; Standard_Integer p[3]; const BRepMesh_Triangle& aElement = GetTriangle( theTriangleId ); - aElement.Edges(e, o); + const Standard_Integer(&e)[3] = aElement.myEdges; const BRepMesh_Edge* anEdges[3] = { &GetEdge( e[0] ), &GetEdge( e[1] ), @@ -2329,7 +2309,7 @@ Standard_Boolean BRepMesh_Delaun::Contains( const Standard_Integer theTriangleId //function : intSegSeg //purpose : Checks intersection between the two segments. //============================================================================= -BRepMesh_GeomTool::IntFlag BRepMesh_Delaun::intSegSeg( +BRepMesh_GeomTool::IntFlag BRepMesh_Delaun::intSegSeg( const BRepMesh_Edge& theEdg1, const BRepMesh_Edge& theEdg2, const Standard_Boolean isConsiderEndPointTouch, @@ -2351,9 +2331,9 @@ BRepMesh_GeomTool::IntFlag BRepMesh_Delaun::intSegSeg( //purpose : Returns area of the loop of the given polygon defined by indices // of its start and end links. //============================================================================= -Standard_Real BRepMesh_Delaun::polyArea(const BRepMesh::SequenceOfInteger& thePolygon, - const Standard_Integer theStartIndex, - const Standard_Integer theEndIndex) const +Standard_Real BRepMesh_Delaun::polyArea(const IMeshData::SequenceOfInteger& thePolygon, + const Standard_Integer theStartIndex, + const Standard_Integer theEndIndex) const { Standard_Real aArea = 0.0; Standard_Integer aPolyLen = thePolygon.Length(); @@ -2406,9 +2386,9 @@ Standard_CString BRepMesh_DumpPoly(void* thePolygon, return "Error: file name or polygon data is null"; } - BRepMesh::SequenceOfInteger& aPolygon = *(BRepMesh::SequenceOfInteger*)thePolygon; + IMeshData::SequenceOfInteger& aPolygon = *(IMeshData::SequenceOfInteger*)thePolygon; - Handle(BRepMesh_DataStructureOfDelaun) aMeshData = + Handle(BRepMesh_DataStructureOfDelaun) aMeshData = *(Handle(BRepMesh_DataStructureOfDelaun)*)theMeshHandlePtr; if (aMeshData.IsNull()) @@ -2422,7 +2402,7 @@ Standard_CString BRepMesh_DumpPoly(void* thePolygon, { OCC_CATCH_SIGNALS - BRepMesh::SequenceOfInteger::Iterator aLinksIt(aPolygon); + IMeshData::SequenceOfInteger::Iterator aLinksIt(aPolygon); for (; aLinksIt.More(); aLinksIt.Next()) { const BRepMesh_Edge& aLink = aMeshData->GetLink(Abs(aLinksIt.Value())); diff --git a/src/BRepMesh/BRepMesh_Delaun.hxx b/src/BRepMesh/BRepMesh_Delaun.hxx index e8fcba595e..7ce77e1e2e 100755 --- a/src/BRepMesh/BRepMesh_Delaun.hxx +++ b/src/BRepMesh/BRepMesh_Delaun.hxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,24 +42,24 @@ public: DEFINE_STANDARD_ALLOC //! Creates the triangulation with an empty Mesh data structure. - Standard_EXPORT BRepMesh_Delaun (BRepMesh::Array1OfVertexOfDelaun& theVertices); + Standard_EXPORT BRepMesh_Delaun (IMeshData::Array1OfVertexOfDelaun& theVertices); //! Creates the triangulation with an existent Mesh data structure. Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh, - BRepMesh::Array1OfVertexOfDelaun& theVertices); + IMeshData::Array1OfVertexOfDelaun& theVertices); //! Creates the triangulation with an existant Mesh data structure. Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh, - BRepMesh::Array1OfInteger& theVertexIndices); + IMeshData::VectorOfInteger& theVertexIndices); //! Initializes the triangulation with an array of vertices. - Standard_EXPORT void Init (BRepMesh::Array1OfVertexOfDelaun& theVertices); + Standard_EXPORT void Init (IMeshData::Array1OfVertexOfDelaun& theVertices); //! Removes a vertex from the triangulation. Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex); //! Adds some vertices into the triangulation. - Standard_EXPORT void AddVertices (BRepMesh::Array1OfVertexOfDelaun& theVertices); + Standard_EXPORT void AddVertices (IMeshData::VectorOfInteger& theVerticesIndices); //! Modify mesh to use the edge. //! @return True if done @@ -72,19 +72,19 @@ public: } //! Gives the list of frontier edges. - inline BRepMesh::HMapOfInteger Frontier() const + inline Handle(IMeshData::MapOfInteger) Frontier() const { return getEdgesByType (BRepMesh_Frontier); } //! Gives the list of internal edges. - inline BRepMesh::HMapOfInteger InternalEdges() const + inline Handle(IMeshData::MapOfInteger) InternalEdges() const { return getEdgesByType (BRepMesh_Fixed); } //! Gives the list of free edges used only one time - inline BRepMesh::HMapOfInteger FreeEdges() const + inline Handle(IMeshData::MapOfInteger) FreeEdges() const { return getEdgesByType (BRepMesh_Free); } @@ -131,74 +131,74 @@ private: InsertBefore }; - typedef NCollection_DataMap DataMapOfMap; + typedef NCollection_DataMap DataMapOfMap; //! Add boundig box for edge defined by start & end point to //! the given vector of bounding boxes for triangulation edges. - void fillBndBox (BRepMesh::SequenceOfBndB2d& theBoxes, + void fillBndBox (IMeshData::SequenceOfBndB2d& theBoxes, const BRepMesh_Vertex& theV1, const BRepMesh_Vertex& theV2); //! Gives the list of edges with type defined by the input parameter. //! If the given type is BRepMesh_Free returns list of edges //! that have number of connected elements less or equal 1. - BRepMesh::HMapOfInteger getEdgesByType (const BRepMesh_DegreeOfFreedom theEdgeType) const; + Handle(IMeshData::MapOfInteger) getEdgesByType (const BRepMesh_DegreeOfFreedom theEdgeType) const; //! Create super mesh and run triangulation procedure. void perform (Bnd_Box2d& theBndBox, - BRepMesh::Array1OfInteger& theVertexIndices); + IMeshData::VectorOfInteger& theVertexIndices); //! Build the super mesh. void superMesh (const Bnd_Box2d& theBox); //! Computes the triangulation and adds the vertices, //! edges and triangles to the Mesh data structure. - void compute (BRepMesh::Array1OfInteger& theVertexIndices); + void compute (IMeshData::VectorOfInteger& theVertexIndices); //! Adjust the mesh on the frontier. void frontierAdjust(); //! Find left polygon of the given edge and call meshPolygon. Standard_Boolean meshLeftPolygonOf( - const Standard_Integer theEdgeIndex, - const Standard_Boolean isForward, - BRepMesh::HMapOfInteger theSkipped = NULL); + const Standard_Integer theEdgeIndex, + const Standard_Boolean isForward, + Handle(IMeshData::MapOfInteger) theSkipped = NULL); //! Find next link starting from the given node and has maximum //! angle respect the given reference link. //! Each time the next link is found other neighbor links at the pivot //! node are marked as leprous and will be excluded from consideration //! next time until a hanging end is occured. - Standard_Integer findNextPolygonLink (const Standard_Integer& theFirstNode, - const Standard_Integer& thePivotNode, - const BRepMesh_Vertex& thePivotVertex, - const gp_Vec2d& theRefLinkDir, - const BRepMesh::SequenceOfBndB2d& theBoxes, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::HMapOfInteger theSkipped, - const Standard_Boolean& isSkipLeprous, - BRepMesh::MapOfInteger& theLeprousLinks, - BRepMesh::MapOfInteger& theDeadLinks, - Standard_Integer& theNextPivotNode, - gp_Vec2d& theNextLinkDir, - Bnd_B2d& theNextLinkBndBox); + Standard_Integer findNextPolygonLink (const Standard_Integer& theFirstNode, + const Standard_Integer& thePivotNode, + const BRepMesh_Vertex& thePivotVertex, + const gp_Vec2d& theRefLinkDir, + const IMeshData::SequenceOfBndB2d& theBoxes, + const IMeshData::SequenceOfInteger& thePolygon, + const Handle(IMeshData::MapOfInteger) theSkipped, + const Standard_Boolean& isSkipLeprous, + IMeshData::MapOfInteger& theLeprousLinks, + IMeshData::MapOfInteger& theDeadLinks, + Standard_Integer& theNextPivotNode, + gp_Vec2d& theNextLinkDir, + Bnd_B2d& theNextLinkBndBox); //! Check is the given link intersects the polygon boundaries. //! Returns bounding box for the given link trough the theLinkBndBox parameter. - Standard_Boolean checkIntersection (const BRepMesh_Edge& theLink, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes, - const Standard_Boolean isConsiderEndPointTouch, - const Standard_Boolean isConsiderPointOnEdge, - const Standard_Boolean isSkipLastEdge, - Bnd_B2d& theLinkBndBox) const; + Standard_Boolean checkIntersection (const BRepMesh_Edge& theLink, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes, + const Standard_Boolean isConsiderEndPointTouch, + const Standard_Boolean isConsiderPointOnEdge, + const Standard_Boolean isSkipLastEdge, + Bnd_B2d& theLinkBndBox) const; //! Triangulatiion of a closed polygon described by the list //! of indexes of its edges in the structure. //! (negative index means reversed edge) - void meshPolygon (BRepMesh::SequenceOfInteger& thePolygon, - BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::HMapOfInteger theSkipped = NULL); + void meshPolygon (IMeshData::SequenceOfInteger& thePolygon, + IMeshData::SequenceOfBndB2d& thePolyBoxes, + Handle(IMeshData::MapOfInteger) theSkipped = NULL); //! Decomposes the given closed simple polygon (polygon without glued edges //! and loops) on two simpler ones by adding new link at the most thin part @@ -210,27 +210,27 @@ private: //! @param thePolygonCut product of decomposition of source polygon (second part of decomposition). //! @param thePolyBoxesCut bounding boxes corresponded to resulting polygon's links. void decomposeSimplePolygon ( - BRepMesh::SequenceOfInteger& thePolygon, - BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::SequenceOfInteger& thePolygonCut, - BRepMesh::SequenceOfBndB2d& thePolyBoxesCut); + IMeshData::SequenceOfInteger& thePolygon, + IMeshData::SequenceOfBndB2d& thePolyBoxes, + IMeshData::SequenceOfInteger& thePolygonCut, + IMeshData::SequenceOfBndB2d& thePolyBoxesCut); //! Triangulation of closed polygon containing only three edges. - inline Standard_Boolean meshElementaryPolygon (const BRepMesh::SequenceOfInteger& thePolygon); + inline Standard_Boolean meshElementaryPolygon (const IMeshData::SequenceOfInteger& thePolygon); //! Creates the triangles beetween the given node and the given polyline. void createTriangles (const Standard_Integer theVertexIndex, - BRepMesh::MapOfIntegerInteger& thePoly); + IMeshData::MapOfIntegerInteger& thePoly); //! Add a triangle based on the given oriented edges into mesh - void addTriangle (const Standard_Integer (&theEdgesId)[3], - const Standard_Boolean (&theEdgesOri)[3], - const Standard_Integer (&theNodesId)[3]); + inline void addTriangle (const Standard_Integer (&theEdgesId)[3], + const Standard_Boolean (&theEdgesOri)[3], + const Standard_Integer (&theNodesId)[3]); //! Deletes the triangle with the given index and adds the free edges into the map. //! When an edge is suppressed more than one time it is destroyed. void deleteTriangle (const Standard_Integer theIndex, - BRepMesh::MapOfIntegerInteger& theLoopEdges); + IMeshData::MapOfIntegerInteger& theLoopEdges); //! Returns start and end nodes of the given edge in respect to its orientation. void getOrientedNodes (const BRepMesh_Edge& theEdge, @@ -239,21 +239,21 @@ private: //! Processes loop within the given polygon formed by range of its //! links specified by start and end link indices. - void processLoop (const Standard_Integer theLinkFrom, - const Standard_Integer theLinkTo, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes); + void processLoop (const Standard_Integer theLinkFrom, + const Standard_Integer theLinkTo, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes); //! Creates new link based on the given nodes and updates the given polygon. - Standard_Integer createAndReplacePolygonLink (const Standard_Integer theNodes[], - const gp_Pnt2d thePnts [], - const Standard_Integer theRootIndex, - const ReplaceFlag theReplaceFlag, - BRepMesh::SequenceOfInteger& thePolygon, - BRepMesh::SequenceOfBndB2d& thePolyBoxes); + Standard_Integer createAndReplacePolygonLink (const Standard_Integer theNodes[], + const gp_Pnt2d thePnts [], + const Standard_Integer theRootIndex, + const ReplaceFlag theReplaceFlag, + IMeshData::SequenceOfInteger& thePolygon, + IMeshData::SequenceOfBndB2d& thePolyBoxes); //! Creates the triangles on new nodes. - void createTrianglesOnNewVertices (BRepMesh::Array1OfInteger& theVertexIndices); + void createTrianglesOnNewVertices (IMeshData::VectorOfInteger& theVertexIndices); //! Cleanup mesh from the free triangles. void cleanupMesh(); @@ -269,35 +269,35 @@ private: const Standard_Integer thePrevElementId); //! Remove internal triangles from the given polygon. - void cleanupPolygon (const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes); + void cleanupPolygon (const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes); //! Checks is the given vertex lies inside the polygon. - Standard_Boolean isVertexInsidePolygon (const Standard_Integer& theVertexId, - const BRepMesh::VectorOfInteger& thePolygonVertices) const; + Standard_Boolean isVertexInsidePolygon (const Standard_Integer& theVertexId, + const IMeshData::VectorOfInteger& thePolygonVertices) const; //! Remove all triangles and edges that are placed inside the polygon or crossed it. - void killTrianglesAroundVertex (const Standard_Integer theZombieNodeId, - const BRepMesh::VectorOfInteger& thePolyVertices, - const BRepMesh::MapOfInteger& thePolyVerticesFindMap, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::MapOfInteger& theSurvivedLinks, - BRepMesh::MapOfIntegerInteger& theLoopEdges); + void killTrianglesAroundVertex (const Standard_Integer theZombieNodeId, + const IMeshData::VectorOfInteger& thePolyVertices, + const IMeshData::MapOfInteger& thePolyVerticesFindMap, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes, + IMeshData::MapOfInteger& theSurvivedLinks, + IMeshData::MapOfIntegerInteger& theLoopEdges); //! Checks is the given link crosses the polygon boundary. //! If yes, kills its triangles and checks neighbor links on boundary intersection. Does nothing elsewhere. - void killTrianglesOnIntersectingLinks (const Standard_Integer& theLinkToCheckId, - const BRepMesh_Edge& theLinkToCheck, - const Standard_Integer& theEndPoint, - const BRepMesh::SequenceOfInteger& thePolygon, - const BRepMesh::SequenceOfBndB2d& thePolyBoxes, - BRepMesh::MapOfInteger& theSurvivedLinks, - BRepMesh::MapOfIntegerInteger& theLoopEdges); + void killTrianglesOnIntersectingLinks (const Standard_Integer& theLinkToCheckId, + const BRepMesh_Edge& theLinkToCheck, + const Standard_Integer& theEndPoint, + const IMeshData::SequenceOfInteger& thePolygon, + const IMeshData::SequenceOfBndB2d& thePolyBoxes, + IMeshData::MapOfInteger& theSurvivedLinks, + IMeshData::MapOfIntegerInteger& theLoopEdges); //! Kill triangles bound to the given link. - void killLinkTriangles (const Standard_Integer& theLinkId, - BRepMesh::MapOfIntegerInteger& theLoopEdges); + void killLinkTriangles (const Standard_Integer& theLinkId, + IMeshData::MapOfIntegerInteger& theLoopEdges); //! Calculates distances between the given point and edges of triangle. Standard_Real calculateDist (const gp_XY theVEdges[3], @@ -316,9 +316,9 @@ private: gp_Pnt2d& theIntPnt) const; //! Returns area of the loop of the given polygon defined by indices of its start and end links. - Standard_Real polyArea (const BRepMesh::SequenceOfInteger& thePolygon, - const Standard_Integer theStartIndex, - const Standard_Integer theEndIndex) const; + Standard_Real polyArea (const IMeshData::SequenceOfInteger& thePolygon, + const Standard_Integer theStartIndex, + const Standard_Integer theEndIndex) const; //! Performs insertion of internal edges into mesh. void insertInternalEdges(); diff --git a/src/BRepMesh/BRepMesh_Edge.hxx b/src/BRepMesh/BRepMesh_Edge.hxx index 0eb80ddd42..70cc60365f 100644 --- a/src/BRepMesh/BRepMesh_Edge.hxx +++ b/src/BRepMesh/BRepMesh_Edge.hxx @@ -76,7 +76,7 @@ public: } //! Alias for IsEqual. - Standard_Boolean operator ==(const BRepMesh_Edge& Other) const + inline Standard_Boolean operator ==(const BRepMesh_Edge& Other) const { return IsEqual(Other); } diff --git a/src/BRepMesh/BRepMesh_EdgeParameterProvider.hxx b/src/BRepMesh/BRepMesh_EdgeParameterProvider.hxx index 7f735f7fce..64610fef1e 100644 --- a/src/BRepMesh/BRepMesh_EdgeParameterProvider.hxx +++ b/src/BRepMesh/BRepMesh_EdgeParameterProvider.hxx @@ -16,44 +16,138 @@ #ifndef _BRepMesh_EdgeParameterProvider_HeaderFile #define _BRepMesh_EdgeParameterProvider_HeaderFile +#include +#include +#include +#include #include #include #include #include #include +#include +#include +#include +#include class gp_Pnt; class TopoDS_Edge; class TopoDS_Face; -#include //! Auxiliary class provides correct parameters //! on curve regarding SameParameter flag. -class BRepMesh_EdgeParameterProvider +template +class BRepMesh_EdgeParameterProvider : public Standard_Transient { public: DEFINE_STANDARD_ALLOC + //! Constructor. Initializes empty provider. + BRepMesh_EdgeParameterProvider() + { + } + //! Constructor. //! @param theEdge edge which parameters should be processed. //! @param theFace face the parametric values are defined for. //! @param theParameters parameters corresponded to discretization points. BRepMesh_EdgeParameterProvider( - const TopoDS_Edge& theEdge, - const TopoDS_Face& theFace, - const Handle(TColStd_HArray1OfReal)& theParameters); + const IMeshData::IEdgeHandle& theEdge, + const TopAbs_Orientation theOrientation, + const IMeshData::IFaceHandle& theFace, + const ParametersCollection& theParameters) + { + Init(theEdge, theOrientation, theFace, theParameters); + } + + //! Initialized provider by the given data. + void Init ( + const IMeshData::IEdgeHandle& theEdge, + const TopAbs_Orientation theOrientation, + const IMeshData::IFaceHandle& theFace, + const ParametersCollection& theParameters) + { + myParameters = theParameters; + myIsSameParam = theEdge->GetSameParam(); + myScale = 1.; + + // Extract actual parametric values + const TopoDS_Edge aEdge = TopoDS::Edge(theEdge->GetEdge().Oriented(theOrientation)); + + myCurveAdaptor.Initialize(aEdge, theFace->GetFace()); + if (myIsSameParam) + { + return; + } + + myFirstParam = myCurveAdaptor.FirstParameter(); + const Standard_Real aLastParam = myCurveAdaptor.LastParameter(); + + myFoundParam = myCurParam = myFirstParam; + + // Extract parameters stored in polygon + myOldFirstParam = myParameters->Value(myParameters->Lower()); + const Standard_Real aOldLastParam = myParameters->Value(myParameters->Upper()); + + // Calculate scale factor between actual and stored parameters + if ((myOldFirstParam != myFirstParam || aOldLastParam != aLastParam) && + myOldFirstParam != aOldLastParam) + { + myScale = (aLastParam - myFirstParam) / (aOldLastParam - myOldFirstParam); + } + + myProjector.Initialize(myCurveAdaptor, myCurveAdaptor.FirstParameter(), + myCurveAdaptor.LastParameter(),Precision::PConfusion()); + } //! Returns parameter according to SameParameter flag of the edge. //! If SameParameter is TRUE returns value from parameters w/o changes, //! elsewhere scales initial parameter and tries to determine resulting //! value using projection of the corresponded 3D point on PCurve. Standard_Real Parameter(const Standard_Integer theIndex, - const gp_Pnt& thePoint3d); + const gp_Pnt& thePoint3d) const + { + if (myIsSameParam) + { + return myParameters->Value(theIndex); + } + + // Use scaled + const Standard_Real aParam = myParameters->Value(theIndex); + + const Standard_Real aPrevParam = myCurParam; + myCurParam = myFirstParam + myScale * (aParam - myOldFirstParam); + + const Standard_Real aPrevFoundParam = myFoundParam; + myFoundParam += (myCurParam - aPrevParam); + + myProjector.Perform(thePoint3d, myFoundParam); + if (myProjector.IsDone()) + { + const Standard_Real aFoundParam = myProjector.Point().Parameter(); + if ((aPrevFoundParam < myFoundParam && aPrevFoundParam < aFoundParam) || + (aPrevFoundParam > myFoundParam && aPrevFoundParam > aFoundParam)) + { + // Rude protection against case when amplified parameter goes before + // previous one due to period or other reason occurred in projector. + // Using parameter returned by projector as is can produce self-intersections. + myFoundParam = aFoundParam; + } + } + + return myFoundParam; + } + + //! Returns pcurve used to compute parameters. + const Handle(Adaptor2d_HCurve2d)& GetPCurve() const + { + return myCurveAdaptor.CurveOnSurface().GetCurve(); + } private: - Handle(TColStd_HArray1OfReal) myParameters; + ParametersCollection myParameters; Standard_Boolean myIsSameParam; Standard_Real myFirstParam; @@ -61,11 +155,12 @@ private: Standard_Real myOldFirstParam; Standard_Real myScale; - Standard_Real myCurParam; - Standard_Real myFoundParam; + mutable Standard_Real myCurParam; + mutable Standard_Real myFoundParam; BRepAdaptor_Curve myCurveAdaptor; - Extrema_LocateExtPC myProjector; + + mutable Extrema_LocateExtPC myProjector; }; #endif diff --git a/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.cxx b/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.cxx index 5fbb1bba33..5e2748042d 100644 --- a/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.cxx +++ b/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.cxx @@ -1,6 +1,6 @@ -// Created on: 2014-08-13 +// Created on: 2016-04-19 +// Copyright (c) 2016 OPEN CASCADE SAS // Created by: Oleg AGASHIN -// Copyright (c) 2011-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -14,48 +14,60 @@ // commercial license or contractual agreement. #include -#include -#include -#include #include +#include +#include +#include +#include +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= +BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor ( + const IMeshData::IEdgeHandle& theEdge, + const IMeshData::IFaceHandle& theFace) +{ + Handle (Poly_Triangulation) aTriangulation = + BRep_Tool::Triangulation (theFace->GetFace(), myLoc); + + Handle (Poly_PolygonOnTriangulation) aPolygon = + BRep_Tool::PolygonOnTriangulation (theEdge->GetEdge(), aTriangulation, myLoc); -IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_EdgeTessellationExtractor,BRepMesh_IEdgeTool) + myNodes = &aTriangulation->Nodes (); + myIndices = &aPolygon->Nodes (); + myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ()); +} //======================================================================= //function : Constructor //purpose : //======================================================================= -BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor( - const TopoDS_Edge& theEdge, - const Handle(Geom2dAdaptor_HCurve)& thePCurve, - const TopoDS_Face& theFace, - const Handle(Poly_Triangulation)& theTriangulation, - const Handle(Poly_PolygonOnTriangulation)& thePolygon, - const TopLoc_Location& theLocation) - : myProvider(theEdge, theFace, thePolygon->Parameters()), - myPCurve(thePCurve), - myNodes(theTriangulation->Nodes()), - myIndices(thePolygon->Nodes()), - myLoc(theLocation) +BRepMesh_EdgeTessellationExtractor::~BRepMesh_EdgeTessellationExtractor () { } +//======================================================================= +//function : NbPoints +//purpose : +//======================================================================= +Standard_Integer BRepMesh_EdgeTessellationExtractor::PointsNb () const +{ + return myIndices->Size (); +} + //======================================================================= //function : Value //purpose : //======================================================================= -Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value( +Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value ( const Standard_Integer theIndex, - Standard_Real& theParameter, gp_Pnt& thePoint, - gp_Pnt2d& theUV) + Standard_Real& theParameter) const { - const gp_Pnt& theRefPnt = myNodes(myIndices(theIndex)); - thePoint = BRepMesh_ShapeTool::UseLocation(theRefPnt, myLoc); - - theParameter = myProvider.Parameter(theIndex, thePoint); - theUV = myPCurve->Value(theParameter); + const gp_Pnt& theRefPnt = (*myNodes) ((*myIndices) (theIndex)); + thePoint = BRepMesh_ShapeTool::UseLocation (theRefPnt, myLoc); + theParameter = myProvider.Parameter (theIndex, thePoint); return Standard_True; } diff --git a/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.hxx b/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.hxx index d7f20a6146..8ce07f590f 100644 --- a/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.hxx +++ b/src/BRepMesh/BRepMesh_EdgeTessellationExtractor.hxx @@ -1,6 +1,6 @@ -// Created on: 2014-08-13 +// Created on: 2016-04-19 +// Copyright (c) 2016 OPEN CASCADE SAS // Created by: Oleg AGASHIN -// Copyright (c) 2011-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -16,72 +16,48 @@ #ifndef _BRepMesh_EdgeTessellationExtractor_HeaderFile #define _BRepMesh_EdgeTessellationExtractor_HeaderFile -#include -#include -#include +#include +#include #include -#include #include #include - -class Poly_Triangulation; -class Poly_PolygonOnTriangulation; -class TopoDS_Edge; -class TopoDS_Face; -class Geom2dAdaptor_HCurve; +#include //! Auxiliary class implements functionality retrieving tessellated //! representation of an edge stored in polygon. -class BRepMesh_EdgeTessellationExtractor : public BRepMesh_IEdgeTool +class BRepMesh_EdgeTessellationExtractor : public IMeshTools_CurveTessellator { public: //! Constructor. - //! Initializes extractor. - BRepMesh_EdgeTessellationExtractor( - const TopoDS_Edge& theEdge, - const Handle(Geom2dAdaptor_HCurve)& thePCurve, - const TopoDS_Face& theFace, - const Handle(Poly_Triangulation)& theTriangulation, - const Handle(Poly_PolygonOnTriangulation)& thePolygon, - const TopLoc_Location& theLocation); + Standard_EXPORT BRepMesh_EdgeTessellationExtractor ( + const IMeshData::IEdgeHandle& theEdge, + const IMeshData::IFaceHandle& theFace); + + //! Destructor. + Standard_EXPORT virtual ~BRepMesh_EdgeTessellationExtractor (); - //! Returns number of dicretization points. - virtual Standard_Integer NbPoints() const Standard_OVERRIDE - { - return myIndices.Length(); - } + //! Returns number of tessellation points. + Standard_EXPORT virtual Standard_Integer PointsNb () const Standard_OVERRIDE; //! Returns parameters of solution with the given index. //! @param theIndex index of tessellation point. //! @param theParameter parameters on PCurve corresponded to the solution. //! @param thePoint tessellation point. - //! @param theUV coordinates of tessellation point in parametric space of face. //! @return True in case of valid result, false elewhere. - virtual Standard_Boolean Value( + Standard_EXPORT virtual Standard_Boolean Value ( const Standard_Integer theIndex, - Standard_Real& theParameter, gp_Pnt& thePoint, - gp_Pnt2d& theUV) Standard_OVERRIDE; + Standard_Real& theParameter) const Standard_OVERRIDE; - DEFINE_STANDARD_RTTIEXT(BRepMesh_EdgeTessellationExtractor,BRepMesh_IEdgeTool) + DEFINE_STANDARD_RTTI_INLINE(BRepMesh_EdgeTessellationExtractor, IMeshTools_CurveTessellator) private: - //! Assignment operator. - void operator =(const BRepMesh_EdgeTessellationExtractor& /*theOther*/) - { - } - -private: - - BRepMesh_EdgeParameterProvider myProvider; - Handle(Geom2dAdaptor_HCurve) myPCurve; - const TColgp_Array1OfPnt& myNodes; - const TColStd_Array1OfInteger& myIndices; - const TopLoc_Location myLoc; + BRepMesh_EdgeParameterProvider myProvider; + const TColgp_Array1OfPnt* myNodes; + const TColStd_Array1OfInteger* myIndices; + TopLoc_Location myLoc; }; -DEFINE_STANDARD_HANDLE(BRepMesh_EdgeTessellationExtractor, BRepMesh_IEdgeTool) - -#endif +#endif \ No newline at end of file diff --git a/src/BRepMesh/BRepMesh_GeomTool.cxx b/src/BRepMesh/BRepMesh_GeomTool.cxx index 16c34331b2..1d4f671c47 100644 --- a/src/BRepMesh/BRepMesh_GeomTool.cxx +++ b/src/BRepMesh/BRepMesh_GeomTool.cxx @@ -76,8 +76,10 @@ BRepMesh_GeomTool::BRepMesh_GeomTool( //======================================================================= Standard_Boolean BRepMesh_GeomTool::Value( const Standard_Integer theIndex, + const Handle(BRepAdaptor_HSurface)& theSurface, Standard_Real& theParam, - gp_Pnt& thePoint) const + gp_Pnt& thePoint, + gp_Pnt2d& theUV) const { if (theIndex < 1 || theIndex > NbPoints()) return Standard_False; @@ -88,6 +90,14 @@ Standard_Boolean BRepMesh_GeomTool::Value( thePoint = myDiscretTool.Value(theIndex); theParam = myDiscretTool.Parameter(theIndex); + const TopoDS_Face& aFace = ((BRepAdaptor_Surface*)&(theSurface->Surface()))->Face(); + + Standard_Real aFirst, aLast; + Handle(Geom2d_Curve) aCurve = + BRep_Tool::CurveOnSurface(*myEdge, aFace, aFirst, aLast); + + aCurve->D0(theParam, theUV); + return Standard_True; } @@ -95,11 +105,12 @@ Standard_Boolean BRepMesh_GeomTool::Value( //function : Value //purpose : //======================================================================= -Standard_Boolean BRepMesh_GeomTool::Value(const Standard_Integer theIndex, - const Standard_Real theIsoParam, - Standard_Real& theParam, - gp_Pnt& thePoint, - gp_Pnt2d& theUV) const +Standard_Boolean BRepMesh_GeomTool::Value( + const Standard_Integer theIndex, + const Standard_Real theIsoParam, + Standard_Real& theParam, + gp_Pnt& thePoint, + gp_Pnt2d& theUV) const { if (theIndex < 1 || theIndex > NbPoints()) return Standard_False; @@ -286,7 +297,7 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg( const Standard_Real aEndPrec = 1 - aPrec; for (Standard_Integer i = 0; i < 2; ++i) { - if( aParam[i] < aPrec || aParam[i] > aEndPrec ) + if(aParam[i] < aPrec || aParam[i] > aEndPrec ) return BRepMesh_GeomTool::NoIntersection; } diff --git a/src/BRepMesh/BRepMesh_GeomTool.hxx b/src/BRepMesh/BRepMesh_GeomTool.hxx index 047cb188c0..a1d73d7d8f 100644 --- a/src/BRepMesh/BRepMesh_GeomTool.hxx +++ b/src/BRepMesh/BRepMesh_GeomTool.hxx @@ -60,13 +60,14 @@ public: //! @param theLinDeflection linear deflection. //! @param theAngDeflection angular deflection. //! @param theMinPointsNb minimum nuber of points to be produced. - Standard_EXPORT BRepMesh_GeomTool(const BRepAdaptor_Curve& theCurve, - const Standard_Real theFirstParam, - const Standard_Real theLastParam, - const Standard_Real theLinDeflection, - const Standard_Real theAngDeflection, - const Standard_Integer theMinPointsNb = 2, - const Standard_Real theMinSize = Precision::Confusion()); + Standard_EXPORT BRepMesh_GeomTool( + const BRepAdaptor_Curve& theCurve, + const Standard_Real theFirstParam, + const Standard_Real theLastParam, + const Standard_Real theLinDeflection, + const Standard_Real theAngDeflection, + const Standard_Integer theMinPointsNb = 2, + const Standard_Real theMinSize = Precision::Confusion()); //! Constructor. //! Initiates discretization of geometric curve corresponding @@ -79,15 +80,16 @@ public: //! @param theLinDeflection linear deflection. //! @param theAngDeflection angular deflection. //! @param theMinPointsNb minimum nuber of points to be produced. - Standard_EXPORT BRepMesh_GeomTool(const Handle(BRepAdaptor_HSurface)& theSurface, - const GeomAbs_IsoType theIsoType, - const Standard_Real theParamIso, - const Standard_Real theFirstParam, - const Standard_Real theLastParam, - const Standard_Real theLinDeflection, - const Standard_Real theAngDeflection, - const Standard_Integer theMinPointsNb = 2, - const Standard_Real theMinSize = Precision::Confusion()); + Standard_EXPORT BRepMesh_GeomTool( + const Handle(BRepAdaptor_HSurface)& theSurface, + const GeomAbs_IsoType theIsoType, + const Standard_Real theParamIso, + const Standard_Real theFirstParam, + const Standard_Real theLastParam, + const Standard_Real theLinDeflection, + const Standard_Real theAngDeflection, + const Standard_Integer theMinPointsNb = 2, + const Standard_Real theMinSize = Precision::Confusion()); //! Adds point to already calculated points (or replaces existing). //! @param thePoint point to be added. @@ -124,12 +126,16 @@ public: //! Gets parameters of discretization point with the given index. //! @param theIndex index of discretization point. + //! @param theSurface surface the curve is lying onto. //! @param theParam[out] parameter of the point on the curve. //! @param thePoint[out] discretization point. + //! @param theUV[out] discretization point in parametric space of the surface. //! @return TRUE on success, FALSE elsewhere. Standard_EXPORT Standard_Boolean Value(const Standard_Integer theIndex, + const Handle(BRepAdaptor_HSurface)& theSurface, Standard_Real& theParam, - gp_Pnt& thePoint) const; + gp_Pnt& thePoint, + gp_Pnt2d& theUV) const; public: //! @name static API @@ -188,6 +194,22 @@ public: //! @name static API const Standard_Boolean isConsiderPointOnSegment, gp_Pnt2d& theIntPnt); + //! Compute deflection of the given segment. + Standard_EXPORT static Standard_Real SquareDeflectionOfSegment( + const gp_Pnt& theFirstPoint, + const gp_Pnt& theLastPoint, + const gp_Pnt& theMidPoint) + { + // 23.03.2010 skl for OCC21645 - change precision for comparison + if (theFirstPoint.SquareDistance(theLastPoint) > Precision::SquareConfusion()) + { + gp_Lin aLin(theFirstPoint, gp_Dir(gp_Vec(theFirstPoint, theLastPoint))); + return aLin.SquareDistance(theMidPoint); + } + + return theFirstPoint.SquareDistance(theMidPoint); + } + private: //! Classifies the point in case of coincidence of two vectors. diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx index 70278be259..5e161cd3d9 100644 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx @@ -15,46 +15,12 @@ // commercial license or contractual agreement. #include - -#include -#include -#include - -#include -#include +#include +#include #include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot) +#include +#include +#include namespace { @@ -63,15 +29,13 @@ namespace static Standard_Boolean IS_IN_PARALLEL = Standard_False; } - //======================================================================= //function : Default constructor //purpose : //======================================================================= BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh() -: myMaxShapeSize(0.), - myModified(Standard_False), - myStatus(0) +: myModified(Standard_False), + myStatus(IMeshData_NoError) { } @@ -83,17 +47,14 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theSh const Standard_Real theLinDeflection, const Standard_Boolean isRelative, const Standard_Real theAngDeflection, - const Standard_Boolean isInParallel, - const Standard_Boolean adaptiveMin) -: myMaxShapeSize(0.), - myModified(Standard_False), - myStatus(0) + const Standard_Boolean isInParallel) +: myModified(Standard_False), + myStatus(IMeshData_NoError) { myParameters.Deflection = theLinDeflection; myParameters.Relative = isRelative; myParameters.Angle = theAngDeflection; myParameters.InParallel = isInParallel; - myParameters.AdaptiveMin = adaptiveMin; myShape = theShape; Perform(); @@ -103,12 +64,12 @@ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theSh //function : Constructor //purpose : //======================================================================= -BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape, - const BRepMesh_FastDiscret::Parameters& theParameters) +BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( + const TopoDS_Shape& theShape, + const IMeshTools_Parameters& theParameters) : myParameters(theParameters) { - myShape = theShape; - + myShape = theShape; Perform(); } @@ -120,437 +81,33 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh() { } -//======================================================================= -//function : clear -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::clear() -{ - // the allocator will be alive while the structures are alive - Handle(NCollection_BaseAllocator) anAlloc = - new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE); - myEdges.Clear(anAlloc); - myEdgeDeflection.Clear(anAlloc); - myFaces.Clear(); - myMesh.Nullify(); -} - -//======================================================================= -//function : init -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::init() -{ - myStatus = 0; - myModified = Standard_False; - - setDone(); - clear(); - - collectFaces(); - - Bnd_Box aBox; - if ( myParameters.Relative ) - { - BRepBndLib::Add(myShape, aBox, Standard_False); - - if (aBox.IsVoid()) - { - // Nothing to mesh. - return; - } - - BRepMesh_ShapeTool::BoxMaxDimension(aBox, myMaxShapeSize); - } - - myMesh = new BRepMesh_FastDiscret (aBox, myParameters); - - myMesh->InitSharedFaces(myShape); -} - -//======================================================================= -//function : collectFaces -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::collectFaces() -{ - Handle(NCollection_IncAllocator) anAlloc = new NCollection_IncAllocator; - TopTools_ListOfShape aFaceList(anAlloc); - BRepLib::ReverseSortFaces(myShape, aFaceList); - TColStd_MapOfTransient aTFaceMap(1, anAlloc); - - // make array of faces suitable for processing (excluding faces without surface) - TopLoc_Location aDummyLoc; - TopTools_ListIteratorOfListOfShape aFaceIter(aFaceList); - for (; aFaceIter.More(); aFaceIter.Next()) - { - const TopoDS_Face& aFace = TopoDS::Face(aFaceIter.Value()); - const Handle(TopoDS_TShape)& aTFace = aFace.TShape(); - if (!aTFaceMap.Add (aTFace)) - continue; // already processed - - const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(aFace, aDummyLoc); - if (aSurf.IsNull()) - continue; - - myFaces.Append(aFace); - } -} - //======================================================================= //function : Perform //purpose : //======================================================================= void BRepMesh_IncrementalMesh::Perform() { - init(); - - if (myMesh.IsNull()) - return; - - update(); -} - -//======================================================================= -//function : update() -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::update() -{ - // Update edges data - TopExp_Explorer aExplorer(myShape, TopAbs_EDGE); - for (; aExplorer.More(); aExplorer.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current()); - if(!BRep_Tool::IsGeometric(aEdge)) - continue; - - update(aEdge); - } - - // Update faces data - NCollection_Vector::Iterator aFaceIt(myFaces); - for (; aFaceIt.More(); aFaceIt.Next()) - update(aFaceIt.Value()); - - // Mesh faces - OSD_Parallel::ForEach(myFaces.begin(), myFaces.end(), *myMesh, !myParameters.InParallel); - - commit(); - clear(); -} - -//======================================================================= -//function : discretizeFreeEdges -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::discretizeFreeEdges() -{ - TopExp_Explorer aExplorer(myShape ,TopAbs_EDGE, TopAbs_FACE); - for (; aExplorer.More(); aExplorer.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current()); - if(!BRep_Tool::IsGeometric(aEdge)) - continue; - - TopLoc_Location aLoc; - Standard_Real aEdgeDeflection = edgeDeflection(aEdge); - Handle(Poly_Polygon3D) aPoly3D = BRep_Tool::Polygon3D(aEdge, aLoc); - if (!aPoly3D.IsNull() && aPoly3D->Deflection() < 1.1 * aEdgeDeflection) - continue; - - BRepAdaptor_Curve aCurve(aEdge); - GCPnts_TangentialDeflection aDiscret(aCurve, aCurve.FirstParameter(), - aCurve.LastParameter(), myParameters.Angle, aEdgeDeflection, 2, - Precision::PConfusion(), myParameters.MinSize); - - Standard_Integer aNodesNb = aDiscret.NbPoints(); - TColgp_Array1OfPnt aNodes (1, aNodesNb); - TColStd_Array1OfReal aUVNodes(1, aNodesNb); - for (Standard_Integer i = 1; i <= aNodesNb; ++i) - { - aNodes (i) = aDiscret.Value(i); - aUVNodes(i) = aDiscret.Parameter(i); - } - - aPoly3D = new Poly_Polygon3D(aNodes, aUVNodes); - aPoly3D->Deflection(myParameters.Deflection); - - BRep_Builder aBuilder; - aBuilder.UpdateEdge(aEdge, aPoly3D); - } -} - -//======================================================================= -//function : edgeDeflection -//purpose : -//======================================================================= -Standard_Real BRepMesh_IncrementalMesh::edgeDeflection( - const TopoDS_Edge& theEdge) -{ - const Standard_Real* pDef = myEdgeDeflection.Seek(theEdge); - if (pDef) - return *pDef; - - Standard_Real aEdgeDeflection; - if ( myParameters.Relative ) - { - Standard_Real aScale; - aEdgeDeflection = BRepMesh_ShapeTool::RelativeEdgeDeflection(theEdge, - myParameters.Deflection, myMaxShapeSize, aScale); - } - else - aEdgeDeflection = myParameters.Deflection; - - myEdgeDeflection.Bind(theEdge, aEdgeDeflection); - return aEdgeDeflection; -} - -//======================================================================= -//function : faceDeflection -//purpose : -//======================================================================= -Standard_Real BRepMesh_IncrementalMesh::faceDeflection( - const TopoDS_Face& theFace) -{ - if ( !myParameters.Relative ) - return myParameters.Deflection; + Handle(BRepMesh_Context) aContext = new BRepMesh_Context; + aContext->SetShape(Shape()); + aContext->ChangeParameters() = myParameters; + aContext->ChangeParameters().CleanModel = Standard_False; - Standard_Integer aEdgesNb = 0; - Standard_Real aFaceDeflection = 0.; + BRepMesh_MeshBuilder aIncMesh(aContext); + aIncMesh.Perform(); - TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE); - for (; aEdgeIt.More(); aEdgeIt.Next(), ++aEdgesNb) + myStatus = IMeshData_NoError; + const Handle(IMeshData_Model)& aModel = aContext->GetModel(); + for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt) { - const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current()); - aFaceDeflection += edgeDeflection(aEdge); - } - - return (aEdgesNb == 0) ? myParameters.Deflection : (aFaceDeflection / aEdgesNb); -} - -//======================================================================= -//function : update(edge) -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::update(const TopoDS_Edge& theEdge) -{ - if (!myEdges.IsBound(theEdge)) - myEdges.Bind(theEdge, BRepMesh::DMapOfTriangulationBool(3, myEdges.Allocator())); - - Standard_Real aEdgeDeflection = edgeDeflection(theEdge); - // Check that triangulation relies to face of the given shape. - const TopTools_IndexedDataMapOfShapeListOfShape& aMapOfSharedFaces = - myMesh->SharedFaces(); - - const TopTools_ListOfShape& aSharedFaces = - aMapOfSharedFaces.FindFromKey(theEdge); - - TopTools_ListIteratorOfListOfShape aSharedFaceIt(aSharedFaces); - for (; aSharedFaceIt.More(); aSharedFaceIt.Next()) - { - TopLoc_Location aLoc; - const TopoDS_Face& aFace = TopoDS::Face(aSharedFaceIt.Value()); - const Handle(Poly_Triangulation)& aFaceTriangulation = - BRep_Tool::Triangulation(aFace, aLoc); - - if (aFaceTriangulation.IsNull()) - continue; - - Standard_Boolean isConsistent = Standard_False; - const Handle(Poly_PolygonOnTriangulation)& aPolygon = - BRep_Tool::PolygonOnTriangulation(theEdge, aFaceTriangulation, aLoc); - - if (!aPolygon.IsNull()) - { - isConsistent = aPolygon->Deflection() < 1.1 * aEdgeDeflection && - aPolygon->HasParameters(); - - if (!isConsistent) - { - myModified = Standard_True; - BRepMesh_ShapeTool::NullifyEdge(theEdge, aFaceTriangulation, aLoc); - } - } + const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt); + myStatus |= aDFace->GetStatusMask(); - myEdges(theEdge).Bind(aFaceTriangulation, isConsistent); - } -} - -//======================================================================= -//function : isToBeMeshed -//purpose : -//======================================================================= -Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed( - const TopoDS_Face& theFace, - const Standard_Boolean isWithCheck) -{ - TopLoc_Location aLoc; - const Handle(Poly_Triangulation)& aTriangulation = - BRep_Tool::Triangulation(theFace, aLoc); - - if (aTriangulation.IsNull()) - return Standard_True; - - if (isWithCheck) - { - Standard_Real aFaceDeflection = faceDeflection(theFace); - if (aTriangulation->Deflection() < 1.1 * aFaceDeflection) + for (Standard_Integer aWireIt = 0; aWireIt < aDFace->WiresNb(); ++aWireIt) { - Standard_Boolean isEdgesConsistent = Standard_True; - TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE); - for (; aEdgeIt.More() && isEdgesConsistent; aEdgeIt.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current()); - if (!myEdges.IsBound(aEdge)) - continue; - - BRepMesh::DMapOfTriangulationBool& aTriMap = myEdges(aEdge); - isEdgesConsistent &= aTriMap.IsBound(aTriangulation) && - aTriMap(aTriangulation); - } - - if (isEdgesConsistent) - { - // #25080: check that indices of links forming triangles are in range. - Standard_Boolean isTriangulationConsistent = Standard_True; - const Standard_Integer aNodesNb = aTriangulation->NbNodes(); - const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles(); - Standard_Integer i = aTriangles.Lower(); - for (; i <= aTriangles.Upper() && isTriangulationConsistent; ++i) - { - const Poly_Triangle& aTriangle = aTriangles(i); - Standard_Integer n[3]; - aTriangle.Get(n[0], n[1], n[2]); - for (Standard_Integer j = 0; j < 3 && isTriangulationConsistent; ++j) - isTriangulationConsistent = (n[j] >= 1 && n[j] <= aNodesNb); - } - - if (isTriangulationConsistent) - return Standard_False; - } + const IMeshData::IWireHandle& aDWire = aDFace->GetWire(aWireIt); + myStatus |= aDWire->GetStatusMask(); } } - - // Nullify edges - TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE); - for (; aEdgeIt.More(); aEdgeIt.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current()); - BRepMesh_ShapeTool::NullifyEdge(aEdge, aTriangulation, aLoc); - } - - BRepMesh_ShapeTool::NullifyFace(theFace); - return Standard_True; -} - -//======================================================================= -//function : update(face) -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::update(const TopoDS_Face& theFace) -{ - if (!toBeMeshed(theFace, Standard_True)) - return; - - myModified = Standard_True; - Standard_Integer aStatus = myMesh->Add(theFace); - - myStatus |= aStatus; - if (aStatus != BRepMesh_ReMesh) - return; - - BRepMesh::MapOfShape aUsedFaces; - aUsedFaces.Add(theFace); - - const TopTools_IndexedDataMapOfShapeListOfShape& aMapOfSharedFaces = - myMesh->SharedFaces(); - - TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE); - for (; aEdgeIt.More(); aEdgeIt.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current()); - if (aMapOfSharedFaces.FindIndex(aEdge) == 0) - continue; - - const TopTools_ListOfShape& aSharedFaces = aMapOfSharedFaces.FindFromKey(aEdge); - TopTools_ListIteratorOfListOfShape aSharedFaceIt(aSharedFaces); - for (; aSharedFaceIt.More(); aSharedFaceIt.Next()) - { - const TopoDS_Face& aFace = TopoDS::Face(aSharedFaceIt.Value()); - if (aUsedFaces.Contains(aFace)) - continue; - - aUsedFaces.Add(aFace); - toBeMeshed(aFace, Standard_False); - - myStatus |= myMesh->Add(aFace); - } - } -} - -//======================================================================= -//function : commit -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::commit() -{ - NCollection_Vector::Iterator aFaceIt(myFaces); - for (; aFaceIt.More(); aFaceIt.Next()) - commitEdges(aFaceIt.Value()); - - discretizeFreeEdges(); -} - -//======================================================================= -//function : commitEdges -//purpose : -//======================================================================= -void BRepMesh_IncrementalMesh::commitEdges(const TopoDS_Face& theFace) -{ - TopoDS_Face aFace = theFace; - aFace.Orientation(TopAbs_FORWARD); - - Handle(BRepMesh_FaceAttribute) aFaceAttribute; - if (!myMesh->GetFaceAttribute(aFace, aFaceAttribute)) - return; - - if (!aFaceAttribute->IsValid()) - { - myStatus |= aFaceAttribute->GetStatus(); - return; - } - - TopLoc_Location aLoc; - Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc); - - if (aTriangulation.IsNull()) - return; - - try - { - OCC_CATCH_SIGNALS - - // Store discretization of edges - BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = aFaceAttribute->ChangeInternalEdges(); - BRepMesh::DMapOfShapePairOfPolygon::Iterator aEdgeIt(*aInternalEdges); - for (; aEdgeIt.More(); aEdgeIt.Next()) - { - const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Key()); - const BRepMesh_PairOfPolygon& aPolyPair = aEdgeIt.Value(); - const Handle(Poly_PolygonOnTriangulation)& aPolygon1 = aPolyPair.First(); - const Handle(Poly_PolygonOnTriangulation)& aPolygon2 = aPolyPair.Last(); - - if (aPolygon1 == aPolygon2) - BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aTriangulation, aLoc); - else - BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aPolygon2, aTriangulation, aLoc); - } - } - catch (Standard_Failure) - { - myStatus |= BRepMesh_Failure; - } } //======================================================================= @@ -567,7 +124,7 @@ Standard_Integer BRepMesh_IncrementalMesh::Discret( anAlgo->ChangeParameters().Deflection = theDeflection; anAlgo->ChangeParameters().Angle = theAngle; anAlgo->ChangeParameters().InParallel = IS_IN_PARALLEL; - anAlgo->SetShape (theShape); + anAlgo->SetShape (theShape); theAlgo = anAlgo; return 0; // no error } diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.hxx b/src/BRepMesh/BRepMesh_IncrementalMesh.hxx index 5e7d4f3bdc..8f26f2a52c 100644 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.hxx +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.hxx @@ -14,21 +14,8 @@ #ifndef _BRepMesh_IncrementalMesh_HeaderFile #define _BRepMesh_IncrementalMesh_HeaderFile -#include -#include - -#include -#include -#include #include -#include - -#include - -class Poly_Triangulation; -class TopoDS_Shape; -class TopoDS_Edge; -class TopoDS_Face; +#include //! Builds the mesh of a shape with respect of their //! correctly triangulated parts @@ -56,15 +43,14 @@ public: //! @name mesher API const Standard_Real theLinDeflection, const Standard_Boolean isRelative = Standard_False, const Standard_Real theAngDeflection = 0.5, - const Standard_Boolean isInParallel = Standard_False, - const Standard_Boolean adaptiveMin = Standard_False); + const Standard_Boolean isInParallel = Standard_False); //! Constructor. //! Automatically calls method Perform. //! @param theShape shape to be meshed. //! @param theParameters - parameters of meshing - Standard_EXPORT BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape, - const BRepMesh_FastDiscret::Parameters& theParameters); + Standard_EXPORT BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape, + const IMeshTools_Parameters& theParameters); //! Performs meshing ot the shape. Standard_EXPORT virtual void Perform() Standard_OVERRIDE; @@ -72,13 +58,13 @@ public: //! @name mesher API public: //! @name accessing to parameters. //! Returns meshing parameters - inline const BRepMesh_FastDiscret::Parameters& Parameters() const + inline const IMeshTools_Parameters& Parameters() const { return myParameters; } //! Returns modifiable meshing parameters - inline BRepMesh_FastDiscret::Parameters& ChangeParameters() + inline IMeshTools_Parameters& ChangeParameters() { return myParameters; } @@ -117,78 +103,13 @@ public: //! @name plugin API //! Discret() static method (thus applied only to Mesh Factories). Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel); - DEFINE_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot) + DEFINE_STANDARD_RTTI_INLINE(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot) protected: - Standard_EXPORT virtual void init() Standard_OVERRIDE; - -private: - - //! Builds the incremental mesh for the shape. - void update(); - - //! Checks triangulation of the given face for consistency - //! with the chosen tolerance. If some edge of face has no - //! discrete representation triangulation will be calculated. - //! @param theFace face to be checked. - void update(const TopoDS_Face& theFace); - - //! Checks discretization of the given edge for consistency - //! with the chosen tolerance. - //! @param theEdge edge to be checked. - void update(const TopoDS_Edge& theEdge); - - //! Collects faces suitable for meshing. - void collectFaces(); - - //! Discretizes edges that have no associations with faces. - void discretizeFreeEdges(); - - //! Returns deflection of the given edge. - //! @param theEdge edge which tolerance should be taken. - Standard_Real edgeDeflection(const TopoDS_Edge& theEdge); - - //! Returns deflection of the given face. - //! If relative flag is set, calculates relative deflection of the face - //! as an average value of relative deflection regarding face's edges. - //! Returns value of deflection set by user elsewhere. - Standard_Real faceDeflection(const TopoDS_Face& theFace); - - //! Prepares the given face for meshing. - //! Nullifies triangulation of face and polygons of face's edges. - //! @param theFace face to be checked. - //! @param isWithCheck if TRUE, checks parameters of triangulation - //! existing in face. If its deflection satisfies the given value and - //! each edge of face has polygon corresponded to this triangulation, - //! method return FALSE. - //! @return TRUE in case if the given face should be meshed. - Standard_Boolean toBeMeshed(const TopoDS_Face& theFace, - const Standard_Boolean isWithCheck); - - //! Stores mesh to the shape. - void commit(); - - //! Stores mesh of internal edges to the face. - void commitEdges(const TopoDS_Face& theFace); - - //! Clears internal data structures. - void clear(); - -protected: - - BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges; - Handle(BRepMesh_FastDiscret) myMesh; - TopTools_DataMapOfShapeReal myEdgeDeflection; - NCollection_Vector myFaces; - - BRepMesh_FastDiscret::Parameters myParameters; - - Standard_Real myMaxShapeSize; - Standard_Boolean myModified; - Standard_Integer myStatus; + IMeshTools_Parameters myParameters; + Standard_Boolean myModified; + Standard_Integer myStatus; }; -DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot) - #endif diff --git a/src/BRepMesh/BRepMesh_OrientedEdge.hxx b/src/BRepMesh/BRepMesh_OrientedEdge.hxx index 6f9f154e0b..94b8fc3731 100644 --- a/src/BRepMesh/BRepMesh_OrientedEdge.hxx +++ b/src/BRepMesh/BRepMesh_OrientedEdge.hxx @@ -35,8 +35,8 @@ public: //! Constructs a link between two vertices. BRepMesh_OrientedEdge( - const Standard_Integer theFirstNode, - const Standard_Integer theLastNode) + const Standard_Integer theFirstNode, + const Standard_Integer theLastNode) : myFirstNode(theFirstNode), myLastNode(theLastNode) { @@ -57,7 +57,7 @@ public: //! Returns hash code for this edge. //! @param theUpper upper index in the container. //! @return hash code. - Standard_Integer HashCode(const Standard_Integer theUpper) const + inline Standard_Integer HashCode(const Standard_Integer theUpper) const { return ::HashCode(myFirstNode + myLastNode, theUpper); } @@ -71,7 +71,7 @@ public: } //! Alias for IsEqual. - Standard_Boolean operator ==(const BRepMesh_OrientedEdge& Other) const + inline Standard_Boolean operator ==(const BRepMesh_OrientedEdge& Other) const { return IsEqual(Other); } diff --git a/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx b/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx index 03217709ea..dd323f29eb 100644 --- a/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx +++ b/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx @@ -16,17 +16,13 @@ #include #include +#include //======================================================================= //function : Default constructor //purpose : //======================================================================= BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun() -: myAllocator(new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE)), - myNodes (10, myAllocator), - myLinks (10, myAllocator), - myElements(10, myAllocator), - myFrontier(10, myAllocator) { } @@ -36,12 +32,7 @@ BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDela //======================================================================= BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun( const Handle(BRepMesh_DataStructureOfDelaun)& theMesh) -: myAllocator(new NCollection_IncAllocator(BRepMesh::MEMORY_BLOCK_SIZE_HUGE)), - myMesh (theMesh), - myNodes (10, myAllocator), - myLinks (10, myAllocator), - myElements(10, myAllocator), - myFrontier(10, myAllocator) + : myMesh(theMesh) { } @@ -76,7 +67,7 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf( void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode( const Standard_Integer theNodeIndex) { - BRepMesh::ListOfInteger::Iterator aLinkIt( + IMeshData::ListOfInteger::Iterator aLinkIt( myMesh->LinksConnectedTo(theNodeIndex)); for (; aLinkIt.More(); aLinkIt.Next()) @@ -135,10 +126,7 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement( void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf( const BRepMesh_Triangle& theElement) { - Standard_Integer e[3]; - Standard_Boolean o[3]; - theElement.Edges(e, o); - + const Standard_Integer(&e)[3] = theElement.myEdges; for (Standard_Integer i = 0; i < 3; ++i) elementsOfLink(e[i]); } diff --git a/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.hxx b/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.hxx index 65847ad557..2d1cc4684c 100644 --- a/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.hxx +++ b/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.hxx @@ -14,25 +14,20 @@ #ifndef _BRepMesh_SelectorOfDataStructureOfDelaun_HeaderFile #define _BRepMesh_SelectorOfDataStructureOfDelaun_HeaderFile -#include -#include -#include +#include #include -#include -#include #include +#include class BRepMesh_Vertex; class BRepMesh_Edge; //! Describes a selector and an iterator on a //! selector of components of a mesh. -class BRepMesh_SelectorOfDataStructureOfDelaun +class BRepMesh_SelectorOfDataStructureOfDelaun : public Standard_Transient { public: - DEFINE_STANDARD_ALLOC - //! Default constructor. Standard_EXPORT BRepMesh_SelectorOfDataStructureOfDelaun(); @@ -75,41 +70,42 @@ public: } //! Returns selected nodes. - inline const BRepMesh::MapOfInteger& Nodes() const + inline const IMeshData::MapOfInteger& Nodes() const { return myNodes; } //! Returns selected links. - inline const BRepMesh::MapOfInteger& Links() const + inline const IMeshData::MapOfInteger& Links() const { return myLinks; } //! Returns selected elements. - inline const BRepMesh::MapOfInteger& Elements() const + inline const IMeshData::MapOfInteger& Elements() const { return myElements; } //! Gives the list of incices of frontier links. - inline const BRepMesh::MapOfInteger& FrontierLinks() const + inline const IMeshData::MapOfInteger& FrontierLinks() const { return myFrontier; } + DEFINE_STANDARD_RTTI_INLINE(BRepMesh_SelectorOfDataStructureOfDelaun, Standard_Transient) + private: //! Collects elements connected to link with the given index. void elementsOfLink(const Standard_Integer theIndex); private: - Handle(NCollection_IncAllocator) myAllocator; Handle(BRepMesh_DataStructureOfDelaun) myMesh; - BRepMesh::MapOfInteger myNodes; - BRepMesh::MapOfInteger myLinks; - BRepMesh::MapOfInteger myElements; - BRepMesh::MapOfInteger myFrontier; + IMeshData::MapOfInteger myNodes; + IMeshData::MapOfInteger myLinks; + IMeshData::MapOfInteger myElements; + IMeshData::MapOfInteger myFrontier; }; #endif diff --git a/src/BRepMesh/BRepMesh_ShapeTool.cxx b/src/BRepMesh/BRepMesh_ShapeTool.cxx index ebd837bd7a..e5443aa4a4 100644 --- a/src/BRepMesh/BRepMesh_ShapeTool.cxx +++ b/src/BRepMesh/BRepMesh_ShapeTool.cxx @@ -1,5 +1,6 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Created on: 2016-04-19 +// Copyright (c) 2016 OPEN CASCADE SAS +// Created by: Oleg AGASHIN // // This file is part of Open CASCADE Technology software library. // @@ -13,21 +14,20 @@ // commercial license or contractual agreement. #include - -#include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include -#include -#include +#include #include -#include +#include #include +#include +#include -namespace { +namespace +{ //! Auxilary struct to take a tolerance of edge. struct EdgeTolerance { @@ -64,7 +64,7 @@ namespace { } //======================================================================= -//function : BoxMaxDimension +//function : MaxFaceTolerance //purpose : //======================================================================= Standard_Real BRepMesh_ShapeTool::MaxFaceTolerance(const TopoDS_Face& theFace) @@ -72,7 +72,7 @@ Standard_Real BRepMesh_ShapeTool::MaxFaceTolerance(const TopoDS_Face& theFace) Standard_Real aMaxTolerance = BRep_Tool::Tolerance(theFace); Standard_Real aTolerance = Max( - MaxTolerance(theFace), + MaxTolerance(theFace), MaxTolerance(theFace)); return Max(aMaxTolerance, aTolerance); @@ -85,7 +85,7 @@ Standard_Real BRepMesh_ShapeTool::MaxFaceTolerance(const TopoDS_Face& theFace) void BRepMesh_ShapeTool::BoxMaxDimension(const Bnd_Box& theBox, Standard_Real& theMaxDimension) { - if(theBox.IsVoid()) + if (theBox.IsVoid()) return; Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ; @@ -95,98 +95,102 @@ void BRepMesh_ShapeTool::BoxMaxDimension(const Bnd_Box& theBox, } //======================================================================= -//function : RelativeEdgeDeflection +//function : CheckAndUpdateFlags //purpose : //======================================================================= -Standard_Real BRepMesh_ShapeTool::RelativeEdgeDeflection( - const TopoDS_Edge& theEdge, - const Standard_Real theDeflection, - const Standard_Real theMaxShapeSize, - Standard_Real& theAdjustmentCoefficient) +void BRepMesh_ShapeTool::CheckAndUpdateFlags ( + const IMeshData::IEdgeHandle& theEdge, + const IMeshData::IPCurveHandle& thePCurve) { - theAdjustmentCoefficient = 1.; - Standard_Real aDefEdge = theDeflection; - if(theEdge.IsNull()) - return aDefEdge; - - Bnd_Box aBox; - BRepBndLib::Add(theEdge, aBox, Standard_False); - BoxMaxDimension(aBox, aDefEdge); - - // Adjust resulting value in relation to the total size - theAdjustmentCoefficient = theMaxShapeSize / (2 * aDefEdge); - if (theAdjustmentCoefficient < 0.5) - theAdjustmentCoefficient = 0.5; - else if (theAdjustmentCoefficient > 2.) - theAdjustmentCoefficient = 2.; - - return (theAdjustmentCoefficient * aDefEdge * theDeflection); -} - -//======================================================================= -//function : FindUV -//purpose : -//======================================================================= -gp_XY BRepMesh_ShapeTool::FindUV( - const Standard_Integer theIndexOfPnt3d, - const gp_Pnt2d& thePnt2d, - const Standard_Real theMinDistance, - const Handle(BRepMesh_FaceAttribute)& theFaceAttribute) -{ - const gp_XY& aPnt2d = thePnt2d.Coord(); - BRepMesh::HDMapOfIntegerListOfXY& aLocation2D = - theFaceAttribute->ChangeLocation2D(); - - if (!aLocation2D->IsBound(theIndexOfPnt3d)) + if (!theEdge->GetSameParam () && + !theEdge->GetSameRange () && + theEdge->GetDegenerated ()) { - BRepMesh::ListOfXY aPoints2d; - aPoints2d.Append(aPnt2d); - aLocation2D->Bind(theIndexOfPnt3d, aPoints2d); - return aPnt2d; + // Nothing to do worse. + return; } - BRepMesh::ListOfXY& aPoints2d = aLocation2D->ChangeFind(theIndexOfPnt3d); + const TopoDS_Edge& aEdge = theEdge->GetEdge (); + const TopoDS_Face& aFace = thePCurve->GetFace ().lock ()->GetFace (); - // Find the most closest 2d point to the given one. - gp_XY aUV; - Standard_Real aMinDist = RealLast(); - BRepMesh::ListOfXY::Iterator aPoint2dIt(aPoints2d); - for (; aPoint2dIt.More(); aPoint2dIt.Next()) + Handle (Geom_Curve) aCurve; + Standard_Real aFirstParam, aLastParam; + Range (aEdge, aCurve, aFirstParam, aLastParam); + if (aCurve.IsNull()) { - const gp_XY& aCurPnt2d = aPoint2dIt.Value(); + theEdge->SetDegenerated(Standard_True); + return; + } - Standard_Real aDist = (aPnt2d - aCurPnt2d).Modulus(); - if (aDist < aMinDist) + BRepAdaptor_Curve aCurveOnSurf(aEdge, aFace); + if (theEdge->GetSameParam () || theEdge->GetSameRange ()) + { + if (theEdge->GetSameRange ()) { - aUV = aCurPnt2d; - aMinDist = aDist; + const Standard_Real aDiffFirst = aCurveOnSurf.FirstParameter () - aFirstParam; + const Standard_Real aDiffLast = aCurveOnSurf.LastParameter () - aLastParam; + theEdge->SetSameRange ( + Abs (aDiffFirst) < Precision::PConfusion () && + Abs (aDiffLast ) < Precision::PConfusion ()); + + if (!theEdge->GetSameRange()) + { + theEdge->SetSameParam(Standard_False); + } } } - const Standard_Real aTolerance = theMinDistance; - - // Get face limits - Standard_Real aDiffU = theFaceAttribute->GetUMax() - theFaceAttribute->GetUMin(); - Standard_Real aDiffV = theFaceAttribute->GetVMax() - theFaceAttribute->GetVMin(); - - const Standard_Real Utol2d = .5 * aDiffU; - const Standard_Real Vtol2d = .5 * aDiffV; - - const Handle(BRepAdaptor_HSurface)& aSurface = theFaceAttribute->Surface(); - const gp_Pnt aPnt1 = aSurface->Value(aUV.X(), aUV.Y()); - const gp_Pnt aPnt2 = aSurface->Value(aPnt2d.X(), aPnt2d.Y()); - - //! If selected point is too far from the given one in parametric space - //! or their positions in 3d are different, add the given point as unique. - if (Abs(aUV.X() - aPnt2d.X()) > Utol2d || - Abs(aUV.Y() - aPnt2d.Y()) > Vtol2d || - !aPnt1.IsEqual(aPnt2, aTolerance)) + if (!theEdge->GetDegenerated ()/* || theEdge->GetSameParam ()*/) { - aUV = aPnt2d; - aPoints2d.Append(aUV); - } + TopoDS_Vertex aStartVertex, aEndVertex; + TopExp::Vertices (aEdge, aStartVertex, aEndVertex); + if (aStartVertex.IsNull() || aEndVertex.IsNull()) + { + theEdge->SetDegenerated(Standard_True); + return; + } - return aUV; + if (aStartVertex.IsSame(aEndVertex)) + { + const Standard_Integer aPointsNb = 20; + const Standard_Real aVertexTolerance = BRep_Tool::Tolerance (aStartVertex); + const Standard_Real aDu = (aLastParam - aFirstParam) / aPointsNb; + //const Standard_Real aEdgeTolerance = BRep_Tool::Tolerance (aEdge); + //const Standard_Real aSqEdgeTolerance = aEdgeTolerance * aEdgeTolerance; + + gp_Pnt aPrevPnt; + aCurve->D0 (aFirstParam, aPrevPnt); + + Standard_Real aLength = 0.0; + for (Standard_Integer i = 1; i <= aPointsNb; ++i) + { + const Standard_Real aParameter = aFirstParam + i * aDu; + // Calculation of the length of the edge in 3D + // in order to check degenerativity + gp_Pnt aPnt; + aCurve->D0 (aParameter, aPnt); + aLength += aPrevPnt.Distance (aPnt); + + //if (theEdge->GetSameParam ()) + //{ + // // Check that points taken at the 3d and pcurve using + // // same parameter are within tolerance of an edge. + // gp_Pnt aPntOnSurf; + // aCurveOnSurf.D0 (aParameter, aPntOnSurf); + // theEdge->SetSameParam (aPnt.SquareDistance (aPntOnSurf) < aSqEdgeTolerance); + //} + + if (aLength > aVertexTolerance /*&& !theEdge->GetSameParam()*/) + { + break; + } + + aPrevPnt = aPnt; + } + + theEdge->SetDegenerated (aLength < aVertexTolerance); + } + } } //======================================================================= @@ -204,7 +208,7 @@ void BRepMesh_ShapeTool::AddInFace( aTrsf.Invert(); TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes(); - for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i) + for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i) aNodes(i).Transform(aTrsf); } @@ -212,117 +216,157 @@ void BRepMesh_ShapeTool::AddInFace( aBuilder.UpdateFace(theFace, theTriangulation); } + //======================================================================= //function : NullifyFace //purpose : //======================================================================= -void BRepMesh_ShapeTool::NullifyFace(const TopoDS_Face& theFace) +void BRepMesh_ShapeTool::NullifyFace (const TopoDS_Face& theFace) { BRep_Builder aBuilder; - aBuilder.UpdateFace(theFace, Handle(Poly_Triangulation)()); + aBuilder.UpdateFace (theFace, Handle (Poly_Triangulation)()); } //======================================================================= //function : NullifyEdge //purpose : //======================================================================= -void BRepMesh_ShapeTool::NullifyEdge( - const TopoDS_Edge& theEdge, - const Handle(Poly_Triangulation)& theTriangulation, - const TopLoc_Location& theLocation) +void BRepMesh_ShapeTool::NullifyEdge ( + const TopoDS_Edge& theEdge, + const Handle (Poly_Triangulation)& theTriangulation, + const TopLoc_Location& theLocation) { - UpdateEdge(theEdge, Handle(Poly_PolygonOnTriangulation)(), + UpdateEdge (theEdge, Handle (Poly_PolygonOnTriangulation)(), theTriangulation, theLocation); } +//======================================================================= +//function : NullifyEdge +//purpose : +//======================================================================= +void BRepMesh_ShapeTool::NullifyEdge ( + const TopoDS_Edge& theEdge, + const TopLoc_Location& theLocation) +{ + BRep_Builder aBuilder; + aBuilder.UpdateEdge (theEdge, Handle (Poly_Polygon3D)(), theLocation); +} + //======================================================================= //function : UpdateEdge //purpose : //======================================================================= -void BRepMesh_ShapeTool::UpdateEdge( - const TopoDS_Edge& theEdge, - const Handle(Poly_PolygonOnTriangulation)& thePolygon, - const Handle(Poly_Triangulation)& theTriangulation, - const TopLoc_Location& theLocation) +void BRepMesh_ShapeTool::UpdateEdge ( + const TopoDS_Edge& theEdge, + const Handle (Poly_PolygonOnTriangulation)& thePolygon, + const Handle (Poly_Triangulation)& theTriangulation, + const TopLoc_Location& theLocation) { BRep_Builder aBuilder; - aBuilder.UpdateEdge(theEdge, thePolygon, theTriangulation, theLocation); + aBuilder.UpdateEdge (theEdge, thePolygon, theTriangulation, theLocation); } //======================================================================= //function : UpdateEdge //purpose : //======================================================================= -void BRepMesh_ShapeTool::UpdateEdge( - const TopoDS_Edge& theEdge, - const Handle(Poly_PolygonOnTriangulation)& thePolygon1, - const Handle(Poly_PolygonOnTriangulation)& thePolygon2, - const Handle(Poly_Triangulation)& theTriangulation, - const TopLoc_Location& theLocation) +void BRepMesh_ShapeTool::UpdateEdge ( + const TopoDS_Edge& theEdge, + const Handle (Poly_PolygonOnTriangulation)& thePolygon1, + const Handle (Poly_PolygonOnTriangulation)& thePolygon2, + const Handle (Poly_Triangulation)& theTriangulation, + const TopLoc_Location& theLocation) { BRep_Builder aBuilder; - aBuilder.UpdateEdge(theEdge, thePolygon1, thePolygon2, + aBuilder.UpdateEdge (theEdge, thePolygon1, thePolygon2, theTriangulation, theLocation); } +//======================================================================= +//function : UpdateEdge +//purpose : +//======================================================================= +void BRepMesh_ShapeTool::UpdateEdge( + const TopoDS_Edge& theEdge, + const Handle(Poly_Polygon3D)& thePolygon) +{ + BRep_Builder aBuilder; + aBuilder.UpdateEdge(theEdge, thePolygon); +} + //======================================================================= //function : UseLocation //purpose : //======================================================================= -gp_Pnt BRepMesh_ShapeTool::UseLocation(const gp_Pnt& thePnt, - const TopLoc_Location& theLoc) +gp_Pnt BRepMesh_ShapeTool::UseLocation ( + const gp_Pnt& thePnt, + const TopLoc_Location& theLoc) { if (theLoc.IsIdentity()) + { return thePnt; + } - return thePnt.Transformed(theLoc.Transformation()); + return thePnt.Transformed (theLoc.Transformation ()); } //======================================================================= -//function : IsDegenerated +//function : UVPoints //purpose : //======================================================================= -Standard_Boolean BRepMesh_ShapeTool::IsDegenerated( - const TopoDS_Edge& theEdge, - const TopoDS_Face& theFace) +Standard_Boolean BRepMesh_ShapeTool::UVPoints ( + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + gp_Pnt2d& theFirstPoint2d, + gp_Pnt2d& theLastPoint2d, + const Standard_Boolean isConsiderOrientation) { - // Get vertices - TopoDS_Vertex pBegin, pEnd; - TopExp::Vertices(theEdge, pBegin, pEnd); - if (pBegin.IsNull() || pEnd.IsNull()) - return Standard_True; - - if (BRep_Tool::Degenerated(theEdge)) - return Standard_True; - if (!pBegin.IsSame(pEnd)) + Handle (Geom2d_Curve) aCurve2d; + Standard_Real aFirstParam, aLastParam; + if (!Range(theEdge, theFace, aCurve2d, aFirstParam, aLastParam, isConsiderOrientation)) + { return Standard_False; + } - Standard_Real wFirst, wLast; - BRep_Tool::Range(theEdge, theFace, wFirst, wLast); - - // calculation of the length of the edge in 3D - Standard_Real longueur = 0.0; - Standard_Real du = (wLast - wFirst) * 0.05; - gp_Pnt P1, P2; - BRepAdaptor_Curve BC(theEdge); - BC.D0(wFirst, P1); - Standard_Real tolV = BRep_Tool::Tolerance(pBegin); - Standard_Real tolV2 = 1.2 * tolV; - - for (Standard_Integer l = 1; l <= 20; ++l) - { - BC.D0(wFirst + l * du, P2); - longueur += P1.Distance(P2); + aCurve2d->D0 (aFirstParam, theFirstPoint2d); + aCurve2d->D0 (aLastParam, theLastPoint2d); + return Standard_True; +} - if (longueur > tolV2) - break; +//======================================================================= +//function : Range +//purpose : +//======================================================================= +Standard_Boolean BRepMesh_ShapeTool::Range ( + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + Handle (Geom2d_Curve)& thePCurve, + Standard_Real& theFirstParam, + Standard_Real& theLastParam, + const Standard_Boolean isConsiderOrientation) +{ - P1 = P2; - } + ShapeAnalysis_Edge aEdge; + return aEdge.PCurve (theEdge, theFace, thePCurve, + theFirstParam, theLastParam, + isConsiderOrientation); +} - if (longueur < tolV2) - return Standard_True; +//======================================================================= +//function : Range +//purpose : +//======================================================================= +Standard_Boolean BRepMesh_ShapeTool::Range ( + const TopoDS_Edge& theEdge, + Handle (Geom_Curve)& theCurve, + Standard_Real& theFirstParam, + Standard_Real& theLastParam, + const Standard_Boolean isConsiderOrientation) +{ - return Standard_False; + ShapeAnalysis_Edge aEdge; + return aEdge.Curve3d (theEdge, theCurve, + theFirstParam, theLastParam, + isConsiderOrientation); } diff --git a/src/BRepMesh/BRepMesh_ShapeTool.hxx b/src/BRepMesh/BRepMesh_ShapeTool.hxx index e1883d7746..d257d612d0 100644 --- a/src/BRepMesh/BRepMesh_ShapeTool.hxx +++ b/src/BRepMesh/BRepMesh_ShapeTool.hxx @@ -1,4 +1,6 @@ -// Copyright (c) 2013 OPEN CASCADE SAS +// Created on: 2016-04-19 +// Copyright (c) 2016 OPEN CASCADE SAS +// Created by: Oleg AGASHIN // // This file is part of Open CASCADE Technology software library. // @@ -11,31 +13,29 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #ifndef _BRepMesh_ShapeTool_HeaderFile #define _BRepMesh_ShapeTool_HeaderFile -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -class Poly_Triangulation; +class Geom_Curve; +class Geom2d_Curve; +class Poly_Polygon3D; class TopoDS_Face; class TopoDS_Edge; class Bnd_Box; -class TopoDS_Vertex; -class gp_XY; -class gp_Pnt2d; -class BRepMesh_ShapeTool +//! Auxiliary class providing functionality to compute, +//! retrieve and store data to TopoDS and model shape. +class BRepMesh_ShapeTool : public Standard_Transient { public: - DEFINE_STANDARD_ALLOC - //! Returns maximum tolerance of the given face. //! Considers tolerances of edges and vertices contained in the given face. Standard_EXPORT static Standard_Real MaxFaceTolerance( @@ -48,39 +48,15 @@ public: Standard_EXPORT static void BoxMaxDimension(const Bnd_Box& theBox, Standard_Real& theMaxDimension); - //! Returns relative deflection for edge with respect to shape size. - //! @param theEdge edge for which relative deflection should be computed. - //! @param theDeflection absolute deflection. - //! @param theMaxShapeSize maximum size of a shape. - //! @param theAdjustmentCoefficient coefficient of adjustment between maximum - //! size of shape and calculated relative deflection. - //! @return relative deflection for the edge. - Standard_EXPORT static Standard_Real RelativeEdgeDeflection( - const TopoDS_Edge& theEdge, - const Standard_Real theDeflection, - const Standard_Real theMaxShapeSize, - Standard_Real& theAdjustmentCoefficient); - - //! Checks 2d representations of 3d point with the - //! given index for equality to avoid duplications. - //! @param theIndexOfPnt3d index of 3d point with which 2d - //! representation should be associated. - //! @param thePnt2d 2d representation of the point with the - //! given index. - //! @param theMinDistance minimum distance between vertices - //! regarding which they could be treated as distinct ones. - //! @param theFaceAttribute attributes contining data calculated - //! according to face geomtry and define limits of face in parametric - //! space. If defined, will be used instead of surface parameter. - //! @param theLocation2dMap map of 2d representations of 3d points. - //! @return given 2d point in case if 3d poind does not alredy have - //! the similar representation, otherwice 2d point corresponding to - //! existing representation will be returned. - Standard_EXPORT static gp_XY FindUV( - const Standard_Integer theIndexOfPnt3d, - const gp_Pnt2d& thePnt2d, - const Standard_Real theMinDistance, - const Handle(BRepMesh_FaceAttribute)& theFaceAttribute); + //! Checks same parameter, same range and degenerativity attributes + //! using geometrical data of the given edge and updates edge model + //! by computed parameters in case of worst case - it can drop flags + //! same parameter and same range to False but never to True if it is + //! already set to False. In contrary, it can also drop degenerated + //! flag to True, but never to False if it is already set to True. + Standard_EXPORT static void CheckAndUpdateFlags ( + const IMeshData::IEdgeHandle& theEdge, + const IMeshData::IPCurveHandle& thePCurve); //! Stores the given triangulation into the given face. //! @param theFace face to be updated by triangulation. @@ -91,27 +67,41 @@ public: //! Nullifies triangulation stored in the face. //! @param theFace face to be updated by null triangulation. - Standard_EXPORT static void NullifyFace(const TopoDS_Face& theFace); + Standard_EXPORT static void NullifyFace (const TopoDS_Face& theFace); //! Nullifies polygon on triangulation stored in the edge. //! @param theEdge edge to be updated by null polygon. //! @param theTriangulation triangulation the given edge is associated to. //! @param theLocation face location. - Standard_EXPORT static void NullifyEdge( - const TopoDS_Edge& theEdge, - const Handle(Poly_Triangulation)& theTriangulation, - const TopLoc_Location& theLocation); + Standard_EXPORT static void NullifyEdge ( + const TopoDS_Edge& theEdge, + const Handle (Poly_Triangulation)& theTriangulation, + const TopLoc_Location& theLocation); + + //! Nullifies 3d polygon stored in the edge. + //! @param theEdge edge to be updated by null polygon. + //! @param theLocation face location. + Standard_EXPORT static void NullifyEdge ( + const TopoDS_Edge& theEdge, + const TopLoc_Location& theLocation); //! Updates the given edge by the given tessellated representation. //! @param theEdge edge to be updated. //! @param thePolygon tessellated representation of the edge to be stored. //! @param theTriangulation triangulation the given edge is associated to. //! @param theLocation face location. + Standard_EXPORT static void UpdateEdge ( + const TopoDS_Edge& theEdge, + const Handle (Poly_PolygonOnTriangulation)& thePolygon, + const Handle (Poly_Triangulation)& theTriangulation, + const TopLoc_Location& theLocation); + + //! Updates the given edge by the given tessellated representation. + //! @param theEdge edge to be updated. + //! @param thePolygon tessellated representation of the edge to be stored. Standard_EXPORT static void UpdateEdge( - const TopoDS_Edge& theEdge, - const Handle(Poly_PolygonOnTriangulation)& thePolygon, - const Handle(Poly_Triangulation)& theTriangulation, - const TopLoc_Location& theLocation); + const TopoDS_Edge& theEdge, + const Handle(Poly_Polygon3D)& thePolygon); //! Updates the given seam edge by the given tessellated representations. //! @param theEdge edge to be updated. @@ -121,27 +111,46 @@ public: //! reversed direction of the seam edge. //! @param theTriangulation triangulation the given edge is associated to. //! @param theLocation face location. - Standard_EXPORT static void UpdateEdge( - const TopoDS_Edge& theEdge, - const Handle(Poly_PolygonOnTriangulation)& thePolygon1, - const Handle(Poly_PolygonOnTriangulation)& thePolygon2, - const Handle(Poly_Triangulation)& theTriangulation, - const TopLoc_Location& theLocation); + Standard_EXPORT static void UpdateEdge ( + const TopoDS_Edge& theEdge, + const Handle (Poly_PolygonOnTriangulation)& thePolygon1, + const Handle (Poly_PolygonOnTriangulation)& thePolygon2, + const Handle (Poly_Triangulation)& theTriangulation, + const TopLoc_Location& theLocation); //! Applies location to the given point and return result. //! @param thePnt point to be transformed. //! @param theLoc location to be applied. - Standard_EXPORT static gp_Pnt UseLocation(const gp_Pnt& thePnt, - const TopLoc_Location& theLoc); - - //! Checks is the given edge degenerated. - //! Checks geometrical parameters in case if IsDegenerated flag is not set. - //! @param theEdge edge to be checked. - //! @param theFace face within which parametric space edge will be checked - //! for geometrical degenerativity. - Standard_EXPORT static Standard_Boolean IsDegenerated( - const TopoDS_Edge& theEdge, - const TopoDS_Face& theFace); + Standard_EXPORT static gp_Pnt UseLocation ( + const gp_Pnt& thePnt, + const TopLoc_Location& theLoc); + + //! Gets the strict UV locations of the extremities of the edge using pcurve. + Standard_EXPORT static Standard_Boolean UVPoints ( + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + gp_Pnt2d& theFirstPoint2d, + gp_Pnt2d& theLastPoint2d, + const Standard_Boolean isConsiderOrientation = Standard_False); + + //! Gets the parametric range of the given edge on the given face. + Standard_EXPORT static Standard_Boolean Range ( + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + Handle (Geom2d_Curve)& thePCurve, + Standard_Real& theFirstParam, + Standard_Real& theLastParam, + const Standard_Boolean isConsiderOrientation = Standard_False); + + //! Gets the 3d range of the given edge. + Standard_EXPORT static Standard_Boolean Range ( + const TopoDS_Edge& theEdge, + Handle (Geom_Curve)& theCurve, + Standard_Real& theFirstParam, + Standard_Real& theLastParam, + const Standard_Boolean isConsiderOrientation = Standard_False); + + DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ShapeTool, Standard_Transient) }; -#endif +#endif \ No newline at end of file diff --git a/src/BRepMesh/BRepMesh_Triangle.hxx b/src/BRepMesh/BRepMesh_Triangle.hxx index f6a5bac399..3c70c1a157 100644 --- a/src/BRepMesh/BRepMesh_Triangle.hxx +++ b/src/BRepMesh/BRepMesh_Triangle.hxx @@ -34,14 +34,14 @@ public: //! Default constructor. BRepMesh_Triangle() - : myEdge1(0), - myEdge2(0), - myEdge3(0), - myOrientation1(Standard_False), - myOrientation2(Standard_False), - myOrientation3(Standard_False), - myMovability (BRepMesh_Free) + : myMovability (BRepMesh_Free) { + myEdges[0] = 0; + myEdges[1] = 0; + myEdges[2] = 0; + myOrientations[0] = Standard_False; + myOrientations[1] = Standard_False; + myOrientations[2] = Standard_False; } //! Constructor. @@ -65,12 +65,8 @@ public: const Standard_Boolean (&theOrientations)[3], const BRepMesh_DegreeOfFreedom theMovability) { - myEdge1 = theEdges[0]; - myEdge2 = theEdges[1]; - myEdge3 = theEdges[2]; - myOrientation1 = theOrientations[0]; - myOrientation2 = theOrientations[1]; - myOrientation3 = theOrientations[2]; + memcpy(myEdges, theEdges, sizeof(theEdges)); + memcpy(myOrientations, theOrientations, sizeof(theOrientations)); myMovability = theMovability; } @@ -80,12 +76,8 @@ public: inline void Edges(Standard_Integer (&theEdges)[3], Standard_Boolean (&theOrientations)[3]) const { - theEdges[0] = myEdge1; - theEdges[1] = myEdge2; - theEdges[2] = myEdge3; - theOrientations[0] = myOrientation1; - theOrientations[1] = myOrientation2; - theOrientations[2] = myOrientation3; + memcpy(theEdges, myEdges, sizeof(myEdges)); + memcpy(theOrientations, myOrientations, sizeof(myOrientations)); } //! Returns movability of the triangle. @@ -103,36 +95,36 @@ public: //! Returns hash code for this triangle. //! @param theUpper upper index in the container. //! @return hash code. - Standard_Integer HashCode(const Standard_Integer theUpper) const + inline Standard_Integer HashCode(const Standard_Integer theUpper) const { - return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper); + return ::HashCode(myEdges[0] + myEdges[1] + myEdges[2], theUpper); } //! Checks for equality with another triangle. //! @param theOther triangle to be checked against this one. //! @return TRUE if equal, FALSE if not. - Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const + inline Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const { if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted) return Standard_False; - if (myEdge1 == theOther.myEdge1 && - myEdge2 == theOther.myEdge2 && - myEdge3 == theOther.myEdge3) + if (myEdges[0] == theOther.myEdges[0] && + myEdges[1] == theOther.myEdges[1] && + myEdges[2] == theOther.myEdges[2]) { return Standard_True; } - if (myEdge1 == theOther.myEdge2 && - myEdge2 == theOther.myEdge3 && - myEdge3 == theOther.myEdge1) + if (myEdges[0] == theOther.myEdges[1] && + myEdges[1] == theOther.myEdges[2] && + myEdges[2] == theOther.myEdges[0]) { return Standard_True; } - if (myEdge1 == theOther.myEdge3 && - myEdge2 == theOther.myEdge1 && - myEdge3 == theOther.myEdge2) + if (myEdges[0] == theOther.myEdges[2] && + myEdges[1] == theOther.myEdges[0] && + myEdges[2] == theOther.myEdges[1]) { return Standard_True; } @@ -141,19 +133,13 @@ public: } //! Alias for IsEqual. - Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const + inline Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const { return IsEqual(theOther); } -private: - - Standard_Integer myEdge1; - Standard_Integer myEdge2; - Standard_Integer myEdge3; - Standard_Boolean myOrientation1; - Standard_Boolean myOrientation2; - Standard_Boolean myOrientation3; + Standard_Integer myEdges[3]; + Standard_Boolean myOrientations[3]; BRepMesh_DegreeOfFreedom myMovability; }; diff --git a/src/BRepMesh/BRepMesh_Vertex.hxx b/src/BRepMesh/BRepMesh_Vertex.hxx index 7cb7d72346..4618e5f71f 100644 --- a/src/BRepMesh/BRepMesh_Vertex.hxx +++ b/src/BRepMesh/BRepMesh_Vertex.hxx @@ -20,6 +20,7 @@ #include #include #include +#include //! Light weighted structure representing vertex //! of the mesh in parametric space. Vertex could be @@ -106,7 +107,7 @@ public: //! Returns hash code for this vertex. //! @param theUpper upper index in the container. //! @return hash code. - Standard_Integer HashCode(const Standard_Integer Upper) const + inline Standard_Integer HashCode(const Standard_Integer Upper) const { return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), Upper); } @@ -114,7 +115,7 @@ public: //! Checks for equality with another vertex. //! @param theOther vertex to be checked against this one. //! @return TRUE if equal, FALSE if not. - Standard_Boolean IsEqual(const BRepMesh_Vertex& theOther) const + inline Standard_Boolean IsEqual(const BRepMesh_Vertex& theOther) const { if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted) @@ -126,7 +127,7 @@ public: } //! Alias for IsEqual. - Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const + inline Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const { return IsEqual(Other); } diff --git a/src/BRepMesh/BRepMesh_VertexInspector.hxx b/src/BRepMesh/BRepMesh_VertexInspector.hxx index 3b22160ec6..dfd51ae926 100644 --- a/src/BRepMesh/BRepMesh_VertexInspector.hxx +++ b/src/BRepMesh/BRepMesh_VertexInspector.hxx @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -31,13 +31,14 @@ public: //! Constructor. //! @param theAllocator memory allocator to be used by internal collections. - BRepMesh_VertexInspector ( + BRepMesh_VertexInspector( const Handle(NCollection_IncAllocator)& theAllocator) - : myResIndices(theAllocator), - myVertices (new BRepMesh::VectorOfVertex), - myDelNodes (theAllocator) + : myIndex(0), + myMinSqDist(RealLast()), + myVertices(new IMeshData::VectorOfVertex), + myDelNodes(theAllocator) { - SetTolerance( Precision::Confusion() ); + SetTolerance(Precision::Confusion()); } //! Registers the given vertex. @@ -106,35 +107,32 @@ public: //! Set reference point to be checked. inline void SetPoint(const gp_XY& thePoint) { - myResIndices.Clear(); - myPoint = thePoint; + myIndex = 0; + myMinSqDist = RealLast(); + myPoint = thePoint; } //! Returns index of point coinciding with regerence one. inline Standard_Integer GetCoincidentPoint() const { - if ( myResIndices.Size() > 0 ) - { - return myResIndices.First(); - } - return 0; + return myIndex; } //! Returns list with indexes of vertices that have movability attribute //! equal to BRepMesh_Deleted and can be replaced with another node. - inline const BRepMesh::ListOfInteger& GetListOfDelPoints() const + inline const IMeshData::ListOfInteger& GetListOfDelPoints() const { return myDelNodes; } //! Returns set of mesh vertices. - inline const BRepMesh::HVectorOfVertex& Vertices() const + inline const Handle(IMeshData::VectorOfVertex)& Vertices() const { return myVertices; } //! Returns set of mesh vertices for modification. - inline BRepMesh::HVectorOfVertex& ChangeVertices() + inline Handle(IMeshData::VectorOfVertex)& ChangeVertices() { return myVertices; } @@ -153,11 +151,12 @@ public: private: - Standard_Real myTolerance[2]; - BRepMesh::ListOfInteger myResIndices; - BRepMesh::HVectorOfVertex myVertices; - BRepMesh::ListOfInteger myDelNodes; - gp_XY myPoint; + Standard_Integer myIndex; + Standard_Real myMinSqDist; + Standard_Real myTolerance[2]; + Handle(IMeshData::VectorOfVertex) myVertices; + IMeshData::ListOfInteger myDelNodes; + gp_XY myPoint; }; #endif diff --git a/src/BRepMesh/BRepMesh_VertexTool.cxx b/src/BRepMesh/BRepMesh_VertexTool.cxx index ecad73c435..8401803e08 100644 --- a/src/BRepMesh/BRepMesh_VertexTool.cxx +++ b/src/BRepMesh/BRepMesh_VertexTool.cxx @@ -14,11 +14,7 @@ // commercial license or contractual agreement. #include -#include -#include #include -#include -#include //======================================================================= //function : Inspect @@ -45,8 +41,16 @@ NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect( inTol = ((aVec.X() * aVec.X()) < myTolerance[0]) && ((aVec.Y() * aVec.Y()) < myTolerance[1]); } + if (inTol) - myResIndices.Append(theTarget); + { + const Standard_Real aSqDist = aVec.SquareModulus(); + if (aSqDist < myMinSqDist) + { + myMinSqDist = aSqDist; + myIndex = theTarget; + } + } return CellFilter_Keep; } diff --git a/src/BRepMesh/BRepMesh_VertexTool.hxx b/src/BRepMesh/BRepMesh_VertexTool.hxx index b18b3e6179..f1c28512c5 100644 --- a/src/BRepMesh/BRepMesh_VertexTool.hxx +++ b/src/BRepMesh/BRepMesh_VertexTool.hxx @@ -15,26 +15,21 @@ #define _BRepMesh_VertexTool_HeaderFile #include -#include -#include -#include +#include #include -#include #include -#include #include +#include class BRepMesh_Vertex; //! Describes data structure intended to keep mesh nodes //! defined in UV space and implements functionality -//! providing their uniqueness regarding thir position. -class BRepMesh_VertexTool +//! providing their uniqueness regarding their position. +class BRepMesh_VertexTool : public Standard_Transient { public: - DEFINE_STANDARD_ALLOC - //! Constructor. //! @param theAllocator memory allocator to be used by internal collections. Standard_EXPORT BRepMesh_VertexTool( @@ -104,13 +99,13 @@ public: Standard_EXPORT void Delete(const Standard_Integer theIndex); //! Returns set of mesh vertices. - inline const BRepMesh::HVectorOfVertex& Vertices() const + inline const Handle(IMeshData::VectorOfVertex)& Vertices() const { return mySelector.Vertices(); } //! Returns set of mesh vertices. - inline BRepMesh::HVectorOfVertex& ChangeVertices() + inline Handle(IMeshData::VectorOfVertex)& ChangeVertices() { return mySelector.ChangeVertices(); } @@ -155,7 +150,7 @@ public: //! Returns the list with indexes of vertices that have movability attribute //! equal to BRepMesh_Deleted and can be replaced with another node. - inline const BRepMesh::ListOfInteger& GetListOfDelNodes() const + inline const IMeshData::ListOfInteger& GetListOfDelNodes() const { return mySelector.GetListOfDelPoints(); } @@ -163,6 +158,8 @@ public: //! Prints statistics. Standard_EXPORT void Statistics(Standard_OStream& theStream) const; + DEFINE_STANDARD_RTTI_INLINE(BRepMesh_VertexTool, Standard_Transient) + private: //! Expands the given point according to specified tolerance. @@ -181,10 +178,10 @@ private: private: - Handle(NCollection_IncAllocator) myAllocator; - BRepMesh::VertexCellFilter myCellFilter; - BRepMesh_VertexInspector mySelector; - Standard_Real myTolerance[2]; + Handle(NCollection_IncAllocator) myAllocator; + IMeshData::VertexCellFilter myCellFilter; + BRepMesh_VertexInspector mySelector; + Standard_Real myTolerance[2]; }; #endif diff --git a/src/BRepMesh/FILES b/src/BRepMesh/FILES index ec39094842..4e4045fc6f 100755 --- a/src/BRepMesh/FILES +++ b/src/BRepMesh/FILES @@ -1,55 +1,84 @@ -BRepMesh.hxx +BRepMesh_BaseMeshAlgo.cxx +BRepMesh_BaseMeshAlgo.hxx +BRepMesh_BoundaryParamsRangeSplitter.hxx BRepMesh_Circle.hxx BRepMesh_CircleInspector.hxx BRepMesh_CircleTool.cxx BRepMesh_CircleTool.hxx BRepMesh_Classifier.cxx BRepMesh_Classifier.hxx +BRepMesh_ConeRangeSplitter.hxx +BRepMesh_Context.cxx +BRepMesh_Context.hxx +BRepMesh_CurveTessellator.cxx +BRepMesh_CurveTessellator.hxx +BRepMesh_CylinderRangeSplitter.hxx BRepMesh_DataStructureOfDelaun.cxx BRepMesh_DataStructureOfDelaun.hxx +BRepMesh_DefaultRangeSplitter.hxx +BRepMesh_Deflection.cxx +BRepMesh_Deflection.hxx BRepMesh_DegreeOfFreedom.hxx BRepMesh_Delaun.cxx BRepMesh_Delaun.hxx -BRepMesh_DiscretFactory.cxx +BRepMesh_DelaunayBaseMeshAlgo.cxx +BRepMesh_DelaunayBaseMeshAlgo.hxx +BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx +BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx BRepMesh_DiscretFactory.hxx -BRepMesh_DiscretRoot.cxx +BRepMesh_DiscretFactory.cxx BRepMesh_DiscretRoot.hxx +BRepMesh_DiscretRoot.cxx BRepMesh_Edge.hxx -BRepMesh_EdgeParameterProvider.cxx +BRepMesh_EdgeDiscret.cxx +BRepMesh_EdgeDiscret.hxx BRepMesh_EdgeParameterProvider.hxx BRepMesh_EdgeTessellationExtractor.cxx BRepMesh_EdgeTessellationExtractor.hxx -BRepMesh_EdgeTessellator.cxx -BRepMesh_EdgeTessellator.hxx -BRepMesh_FaceAttribute.cxx -BRepMesh_FaceAttribute.hxx +BRepMesh_FaceChecker.cxx +BRepMesh_FaceChecker.hxx +BRepMesh_FaceDiscret.cxx +BRepMesh_FaceDiscret.hxx BRepMesh_FactoryError.hxx -BRepMesh_FastDiscret.cxx -BRepMesh_FastDiscret.hxx -BRepMesh_FastDiscretFace.cxx -BRepMesh_FastDiscretFace.hxx BRepMesh_GeomTool.cxx BRepMesh_GeomTool.hxx -BRepMesh_IEdgeTool.cxx -BRepMesh_IEdgeTool.hxx +BRepMesh_IncAllocator.hxx BRepMesh_IncrementalMesh.cxx BRepMesh_IncrementalMesh.hxx +BRepMesh_MeshAlgoFactory.cxx +BRepMesh_MeshAlgoFactory.hxx +BRepMesh_MeshBuilder.cxx +BRepMesh_MeshBuilder.hxx +BRepMesh_MeshTool.cxx +BRepMesh_MeshTool.hxx +BRepMesh_ModelBuilder.cxx +BRepMesh_ModelBuilder.hxx +BRepMesh_ModelHealer.cxx +BRepMesh_ModelHealer.hxx +BRepMesh_ModelPostProcessor.cxx +BRepMesh_ModelPostProcessor.hxx +BRepMesh_ModelPreProcessor.cxx +BRepMesh_ModelPreProcessor.hxx +BRepMesh_NodeInsertionMeshAlgo.hxx +BRepMesh_NURBSRangeSplitter.cxx +BRepMesh_NURBSRangeSplitter.hxx BRepMesh_OrientedEdge.hxx BRepMesh_PairOfIndex.hxx -BRepMesh_PairOfPolygon.hxx BRepMesh_PluginEntryType.hxx BRepMesh_PluginMacro.hxx BRepMesh_SelectorOfDataStructureOfDelaun.cxx BRepMesh_SelectorOfDataStructureOfDelaun.hxx +BRepMesh_ShapeExplorer.cxx +BRepMesh_ShapeExplorer.hxx BRepMesh_ShapeTool.cxx BRepMesh_ShapeTool.hxx -BRepMesh_Status.hxx -BRepMesh_Triangle.hxx +BRepMesh_ShapeVisitor.cxx +BRepMesh_ShapeVisitor.hxx +BRepMesh_SphereRangeSplitter.hxx +BRepMesh_TorusRangeSplitter.hxx +BRepMesh_UVParamRangeSplitter.hxx BRepMesh_Vertex.hxx BRepMesh_VertexInspector.hxx BRepMesh_VertexTool.cxx BRepMesh_VertexTool.hxx -BRepMesh_WireChecker.cxx -BRepMesh_WireChecker.hxx -BRepMesh_WireInterferenceChecker.cxx -BRepMesh_WireInterferenceChecker.hxx +BRepMesh_Triangle.hxx diff --git a/src/DBRep/DBRep_DrawableShape.cxx b/src/DBRep/DBRep_DrawableShape.cxx index 22df8ddb50..f300abe294 100644 --- a/src/DBRep/DBRep_DrawableShape.cxx +++ b/src/DBRep/DBRep_DrawableShape.cxx @@ -840,7 +840,7 @@ void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis) if (!strcmp(dout.GetType(id),"PERS")) focal = dout.Focal(id); Standard_Real Ang,Def; HLRBRep::PolyHLRAngleAndDeflection(myAng,Ang,Def); - BRepMesh_FastDiscret::Parameters aMeshParams; + IMeshTools_Parameters aMeshParams; aMeshParams.Relative = Standard_True; aMeshParams.Deflection = Def; aMeshParams.Angle = Ang; diff --git a/src/MeshTest/MeshTest.cxx b/src/MeshTest/MeshTest.cxx index 9ee7595246..f9b70dc94c 100644 --- a/src/MeshTest/MeshTest.cxx +++ b/src/MeshTest/MeshTest.cxx @@ -28,8 +28,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -80,6 +80,8 @@ #include #include #include +#include +#include #include //epa Memory leaks test @@ -147,7 +149,6 @@ options:\n\ Standard_Boolean isInParallel = Standard_False; Standard_Boolean isIntVertices = Standard_True; Standard_Boolean isControlSurDef = Standard_True; - Standard_Boolean isAdaptiveMin = Standard_False; if (nbarg > 3) { @@ -167,8 +168,6 @@ options:\n\ isIntVertices = Standard_False; else if (aOpt == "-surf_def_off") isControlSurDef = Standard_False; - else if (aOpt == "-adaptive") - isAdaptiveMin = Standard_True; else if (i < nbarg) { Standard_Real aVal = Draw::Atof(argv[i++]); @@ -185,7 +184,7 @@ options:\n\ di << "Incremental Mesh, multi-threading " << (isInParallel ? "ON" : "OFF") << "\n"; - BRepMesh_FastDiscret::Parameters aMeshParams; + IMeshTools_Parameters aMeshParams; aMeshParams.Deflection = aLinDeflection; aMeshParams.Angle = aAngDeflection; aMeshParams.Relative = isRelative; @@ -193,37 +192,56 @@ options:\n\ aMeshParams.MinSize = aMinSize; aMeshParams.InternalVerticesMode = isIntVertices; aMeshParams.ControlSurfaceDeflection = isControlSurDef; - aMeshParams.AdaptiveMin = isAdaptiveMin; + OSD_Timer aTimer; + aTimer.Start(); BRepMesh_IncrementalMesh aMesher (aShape, aMeshParams); + aTimer.Stop(); + aTimer.Show(); di << "Meshing statuses: "; - Standard_Integer statusFlags = aMesher.GetStatusFlags(); - if( !statusFlags ) + const Standard_Integer aStatus = aMesher.GetStatusFlags(); + if (!aStatus) { di << "NoError"; } else { Standard_Integer i; - for( i = 0; i < 4; i++ ) + for (i = 0; i < 8; i++) { - if( (statusFlags >> i) & (Standard_Integer)1 ) + Standard_Integer aFlag = aStatus & (1 << i); + if (aFlag) { - switch(i+1) + switch ((IMeshData_Status) aFlag) { - case 1: - di << "OpenWire "; - break; - case 2: - di << "SelfIntersectingWire "; - break; - case 3: - di << "Failure "; - break; - case 4: - di << "ReMesh "; - break; + case IMeshData_OpenWire: + di << "OpenWire "; + break; + case IMeshData_SelfIntersectingWire: + di << "SelfIntersectingWire "; + break; + case IMeshData_Failure: + di << "Failure "; + break; + case IMeshData_ReMesh: + di << "ReMesh "; + break; + case IMeshData_UnorientedWire: + di << "UnorientedWire "; + break; + case IMeshData_TooFewPoints: + di << "TooFewPoints "; + break; + case IMeshData_Outdated: + di << "Outdated "; + break; + case IMeshData_Reused: + di << "Reused "; + break; + case IMeshData_NoError: + default: + break; } } } @@ -415,12 +433,10 @@ static Standard_Integer fastdiscret(Draw_Interpretor& di, Standard_Integer nbarg const Standard_Real d = Draw::Atof(argv[2]); - Bnd_Box B; - BRepBndLib::Add(S,B); - BRepMesh_FastDiscret::Parameters aParams; + IMeshTools_Parameters aParams; aParams.Deflection = d; aParams.Angle = 0.5; - BRepMesh_FastDiscret MESH(B,aParams); + BRepMesh_IncrementalMesh MESH(S,aParams); //Standard_Integer NbIterations = MESH.NbIterations(); //if (nbarg > 4) NbIterations = Draw::Atoi(argv[4]); @@ -438,7 +454,7 @@ static Standard_Integer fastdiscret(Draw_Interpretor& di, Standard_Integer nbarg for (ex.Init(S, TopAbs_FACE); ex.More(); ex.Next()) aBuilder.UpdateFace(TopoDS::Face(ex.Current()),T); - MESH.Perform(S); + MESH.Perform(); TopoDS_Compound aCompGood, aCompFailed, aCompViolating; diff --git a/src/MeshTest/MeshTest_Debug.cxx b/src/MeshTest/MeshTest_Debug.cxx index 43a3594857..8a32609868 100644 --- a/src/MeshTest/MeshTest_Debug.cxx +++ b/src/MeshTest/MeshTest_Debug.cxx @@ -13,13 +13,16 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include #include #include #include #include #include #include +#include +#include +#include +#include // This file defines global functions not declared in any public header, // intended for use from debugger prompt (Command Window in Visual Studio) @@ -28,15 +31,14 @@ //function : MeshTest_DrawLinks //purpose : Draw links from mesh data structure of type BRepMesh_FaceAttribute //======================================================================= -Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* theFaceAttr) +Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* theDataStruct) { - if (theNameStr == 0 || theFaceAttr == 0) + if (theNameStr == 0 || theDataStruct == 0) { return "Error: name or face attribute is null"; } try { - const Handle(BRepMesh_FaceAttribute)& aFaceAttr = *(Handle(BRepMesh_FaceAttribute)*)theFaceAttr; - const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = aFaceAttr->ChangeStructure(); + const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = *(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct; if (aMeshData.IsNull()) return "Null mesh data structure"; Standard_Integer nbLinks = aMeshData->NbLinks(); @@ -51,9 +53,9 @@ Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* the Standard_Integer n2 = aLink.LastNode(); const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n1); const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n2); - const gp_Pnt& aP1 = aFaceAttr->GetPoint(aV1); - const gp_Pnt& aP2 = aFaceAttr->GetPoint(aV2); - Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(aP1, aP2, Draw_bleu); + Handle(Draw_Segment3D) aSeg = new Draw_Segment3D(gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0), + gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0), + Draw_bleu); Draw::Set((aName + "_" + i).ToCString(), aSeg); } return theNameStr; @@ -68,16 +70,16 @@ Standard_EXPORT const char* MeshTest_DrawLinks(const char* theNameStr, void* the //function : MeshTest_DrawTriangles //purpose : Draw triangles from mesh data structure of type BRepMesh_FaceAttribute //======================================================================= -Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* theFaceAttr) +Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* theDataStruct) { - if (theNameStr == 0 || theFaceAttr == 0) + if (theNameStr == 0 || theDataStruct == 0) { return "Error: name or face attribute is null"; } try { - const Handle(BRepMesh_FaceAttribute)& aFaceAttr = - *(Handle(BRepMesh_FaceAttribute)*)theFaceAttr; - const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = aFaceAttr->ChangeStructure(); + const Handle(BRepMesh_DataStructureOfDelaun)& aMeshData = + *(Handle(BRepMesh_DataStructureOfDelaun)*)theDataStruct; + if (aMeshData.IsNull()) return "Null mesh data structure"; Standard_Integer nbElem = aMeshData->NbElements(); @@ -93,8 +95,10 @@ Standard_EXPORT const char* MeshTest_DrawTriangles(const char* theNameStr, void* const BRepMesh_Vertex& aV1 = aMeshData->GetNode(n[0]); const BRepMesh_Vertex& aV2 = aMeshData->GetNode(n[1]); const BRepMesh_Vertex& aV3 = aMeshData->GetNode(n[2]); - gp_Pnt aP[4] = { aFaceAttr->GetPoint(aV1), aFaceAttr->GetPoint(aV2), - aFaceAttr->GetPoint(aV3), aFaceAttr->GetPoint(aV1) }; + gp_Pnt aP[4] = { gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0), + gp_Pnt(aV2.Coord().X(), aV2.Coord().Y(), 0), + gp_Pnt(aV3.Coord().X(), aV3.Coord().Y(), 0), + gp_Pnt(aV1.Coord().X(), aV1.Coord().Y(), 0) }; TColgp_Array1OfPnt aPnts(aP[0], 1, 4); Handle(Poly_Polygon3D) aPoly = new Poly_Polygon3D(aPnts); Handle(DrawTrSurf_Polygon3D) aDPoly = new DrawTrSurf_Polygon3D(aPoly); diff --git a/src/MeshTest/MeshTest_DrawableMesh.cxx b/src/MeshTest/MeshTest_DrawableMesh.cxx index 5385c51e55..9b2d0f3234 100644 --- a/src/MeshTest/MeshTest_DrawableMesh.cxx +++ b/src/MeshTest/MeshTest_DrawableMesh.cxx @@ -29,7 +29,7 @@ #include #include #include - +#include IMPLEMENT_STANDARD_RTTIEXT(MeshTest_DrawableMesh,Draw_Drawable3D) diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index f432ca06c0..9cbd998c92 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -1245,6 +1245,7 @@ static Standard_Integer OCC22 (Draw_Interpretor& di, Standard_Integer argc, cons #include #include +#include //======================================================================= //function : OCC24 @@ -1309,7 +1310,7 @@ static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, cons if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;} // 3. Build mesh - BRepMesh_FastDiscret::Parameters aMeshParams; + IMeshTools_Parameters aMeshParams; aMeshParams.Relative = Standard_True; aMeshParams.Deflection = 0.2; aMeshParams.Angle = M_PI / 6; diff --git a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx index 87f7a473f0..93ba4ab854 100644 --- a/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx +++ b/src/SelectMgr/SelectMgr_TriangularFrustumSet.cxx @@ -37,11 +37,11 @@ void SelectMgr_TriangularFrustumSet::Build (const TColgp_Array1OfPnt2d& thePoint Handle(BRepMesh_DataStructureOfDelaun) aMeshStructure = new BRepMesh_DataStructureOfDelaun(anAllocator); Standard_Integer aPtsLower = thePoints.Lower(); Standard_Integer aPtsUpper = thePoints.Upper(); - BRepMesh::Array1OfInteger anIndexes (0, thePoints.Length() - 1); + IMeshData::VectorOfInteger anIndexes(aPtsUpper - aPtsLower, anAllocator); for (Standard_Integer aPtIdx = aPtsLower; aPtIdx <= aPtsUpper; ++aPtIdx) { - BRepMesh_Vertex aVertex (thePoints.Value (aPtIdx).XY(), aPtIdx, BRepMesh_Frontier); - anIndexes.ChangeValue (aPtIdx - aPtsLower) = aMeshStructure->AddNode (aVertex); + BRepMesh_Vertex aVertex(thePoints.Value(aPtIdx).XY(), aPtIdx, BRepMesh_Frontier); + anIndexes.Append(aMeshStructure->AddNode(aVertex)); } Standard_Real aPtSum = 0; @@ -64,11 +64,11 @@ void SelectMgr_TriangularFrustumSet::Build (const TColgp_Array1OfPnt2d& thePoint } BRepMesh_Delaun aTriangulation (aMeshStructure, anIndexes); - const BRepMesh::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain(); + const IMeshData::MapOfInteger& aTriangles = aMeshStructure->ElementsOfDomain(); if (aTriangles.Extent() < 1) return; - BRepMesh::MapOfInteger::Iterator aTriangleIt (aTriangles); + IMeshData::IteratorOfMapOfInteger aTriangleIt (aTriangles); for (; aTriangleIt.More(); aTriangleIt.Next()) { const Standard_Integer aTriangleId = aTriangleIt.Key(); diff --git a/src/StdPrs/StdPrs_HLRPolyShape.cxx b/src/StdPrs/StdPrs_HLRPolyShape.cxx index 4ade3a16cf..e3f6a5cd89 100644 --- a/src/StdPrs/StdPrs_HLRPolyShape.cxx +++ b/src/StdPrs/StdPrs_HLRPolyShape.cxx @@ -68,7 +68,7 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, { const Standard_Boolean aRel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE; Standard_Real aDef = aRel ? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation(); - BRepMesh_FastDiscret::Parameters aMeshParams; + IMeshTools_Parameters aMeshParams; aMeshParams.Relative = aRel; aMeshParams.Angle = aDrawer->HLRAngle(); aMeshParams.Deflection = aDef; diff --git a/src/TKMesh/EXTERNLIB b/src/TKMesh/EXTERNLIB index 97605066fa..c428c62550 100755 --- a/src/TKMesh/EXTERNLIB +++ b/src/TKMesh/EXTERNLIB @@ -1,9 +1,8 @@ -TKBRep -TKMath TKernel -TKG2d -TKG3d -TKGeomBase +TKMath +TKBRep TKTopAlgo -TKGeomAlgo -CSF_TBB +TKShHealing +TKGeomBase +TKG3d +TKG2d diff --git a/src/TKMesh/PACKAGES b/src/TKMesh/PACKAGES index 0ce38247e0..d5379def2f 100755 --- a/src/TKMesh/PACKAGES +++ b/src/TKMesh/PACKAGES @@ -1 +1,4 @@ +IMeshData +IMeshTools +BRepMeshData BRepMesh