package BRepMesh
---Purpose: Instantiated package for the class of packages
- -- MeshAlgo, and so on ...
---Level : Advanced.
-- All methods of all classes will be advanced.
GCPnts,
BRepAdaptor,
BRepTopAdaptor,
- MeshDS,
- MeshAlgo,
TCollection,
MMgt,
TopoDS,
Geom2d,
GeomAbs,
GeomAdaptor,
- TopLoc
+ TopLoc,
+ SortTools
-is
+is enumeration DegreeOfFreedom is
+ Free,
+ InVolume,
+ OnSurface,
+ OnCurve,
+ Fixed,
+ Frontier,
+ Deleted;
enumeration Status is
---Purpose: Discribes the wires discretisation.
OpenWire,
SelfIntersectingWire,
Failure,
- ReMesh
+ ReMesh
end Status;
enumeration FactoryError is
class Triangle;
class ShapeTool;
-
+
+ class Circ;
+
deferred class DiscretRoot;
class DiscretFactory;
--
pointer PDiscretRoot to DiscretRoot from BRepMesh;
--
-
- class Delaun instantiates Delaunay from MeshAlgo(Vertex from BRepMesh,
- Edge from BRepMesh,
- Triangle from BRepMesh);
+ imported MapOfIntegerInteger from BRepMesh;
+ imported MapOfInteger from BRepMesh;
+ imported ListOfInteger from BRepMesh;
+ imported BaseAllocator from BRepMesh;
+ imported PairOfIndex from BRepMesh;
+ imported CircleInspector from BRepMesh;
+ imported CellFilter from BRepMesh;
+
+ class ComparatorOfVertexOfDelaun;
+ class ComparatorOfIndexedVertexOfDelaun;
+ class SelectorOfDataStructureOfDelaun;
+ class Delaun;
+ class DataStructureOfDelaun;
+ class CircleTool;
+
+ class Array1OfVertexOfDelaun instantiates Array1 from TCollection
+ (Vertex from BRepMesh);
+
+ class HArray1OfVertexOfDelaun instantiates HArray1 from TCollection
+ (Vertex from BRepMesh, Array1OfVertexOfDelaun);
+
+ class HeapSortVertexOfDelaun instantiates HeapSort from SortTools
+ (Vertex from BRepMesh, Array1OfVertexOfDelaun,
+ ComparatorOfVertexOfDelaun from BRepMesh);
+
+ class HeapSortIndexedVertexOfDelaun instantiates HeapSort from SortTools
+ (Integer, Array1OfInteger from TColStd,
+ ComparatorOfIndexedVertexOfDelaun from BRepMesh);
+
+ class NodeHasherOfDataStructureOfDelaun instantiates MapHasher from TCollection
+ (Vertex from BRepMesh);
+ class LinkHasherOfDataStructureOfDelaun instantiates MapHasher from TCollection
+ (Edge from BRepMesh);
+ class ElemHasherOfDataStructureOfDelaun instantiates MapHasher from TCollection
+ (Triangle from BRepMesh);
+
+ class IDMapOfNodeOfDataStructureOfDelaun instantiates IndexedDataMap from TCollection
+ (Vertex from BRepMesh,
+ ListOfInteger from BRepMesh,
+ NodeHasherOfDataStructureOfDelaun);
+
+ class IDMapOfLinkOfDataStructureOfDelaun instantiates IndexedDataMap from TCollection
+ (Edge from BRepMesh,
+ PairOfIndex from BRepMesh,
+ LinkHasherOfDataStructureOfDelaun);
+
+ class IMapOfElementOfDataStructureOfDelaun instantiates IndexedMap from TCollection
+ (Triangle from BRepMesh,
+ ElemHasherOfDataStructureOfDelaun);
class DataMapOfVertexInteger instantiates DataMap from TCollection
(Vertex from TopoDS, Integer from Standard, ShapeMapHasher from TopTools);
--- /dev/null
+#include <NCollection_IncAllocator.hxx>
+
+typedef Handle_NCollection_IncAllocator BRepMesh_BaseAllocator;
--- /dev/null
+// File: BRepMesh_CellFilter.hxx
+// Created: May 26 16:40:53 2008
+// Author: Ekaterina SMIRNOVA
+// Copyright: Open CASCADE SAS 2008
+
+
+#include <gp_XYZ.hxx>
+#include <gp_XY.hxx>
+#include <NCollection_CellFilter.hxx>
+#include <BRepMesh_CircleInspector.hxx>
+
+typedef NCollection_CellFilter<BRepMesh_CircleInspector> BRepMesh_CellFilter;
--- /dev/null
+-- File: BRepMesh_Circ.cdl
+-- Created: Mon Aug 9 16:31:05 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993
+
+
+class Circ from BRepMesh
+
+ ---Purpose: Describes a 2d circle with a size of only 3
+ -- Standard Real numbers instead of gp who needs 7
+ -- Standard Real numbers.
+
+ uses Real from Standard,
+ XY from gp
+
+
+ is Create returns Circ from BRepMesh;
+
+ Create (loc : XY from gp; rad : Real from Standard)
+ returns Circ from BRepMesh;
+
+ SetLocation(me : in out; loc : XY from gp)
+ is static;
+
+ SetRadius (me : in out; rad : Real from Standard)
+ is static;
+
+ Location (me)
+ ---C++: return const &
+ ---C++: inline
+ returns XY from gp
+ is static;
+
+ Radius (me)
+ ---C++: return const &
+ ---C++: inline
+ returns Real from Standard
+ is static;
+
+
+fields location : XY from gp;
+ radius : Real from Standard;
+
+end Circ;
--- /dev/null
+// File: BRepMesh_Circ.cxx
+// Created: Mon Aug 9 17:48:36 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+#include <BRepMesh_Circ.hxx>
+
+BRepMesh_Circ::BRepMesh_Circ()
+{}
+
+BRepMesh_Circ::BRepMesh_Circ(const gp_XY& loc, const Standard_Real rad)
+: location(loc), radius(rad)
+{}
+
+void BRepMesh_Circ::SetLocation(const gp_XY& loc)
+{
+ location=loc;
+}
+
+void BRepMesh_Circ::SetRadius(const Standard_Real rad)
+{
+ radius=rad;
+}
--- /dev/null
+// File: BRepMesh_Circ.lxx
+// Created: Mon Aug 9 17:46:36 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+inline const gp_XY& BRepMesh_Circ::Location() const
+{ return location;}
+
+inline const Standard_Real& BRepMesh_Circ::Radius() const
+{ return radius;}
--- /dev/null
+// File: BRepMesh_CircleInspector.hxx
+// Created: May 26 16:40:53 2008
+// Author: Ekaterina SMIRNOVA
+// Copyright: Open CASCADE SAS 2008
+
+
+#ifndef BRepMesh_CircleInspector_Header
+#define BRepMesh_CircleInspector_Header
+
+#include <BRepMesh_Circ.hxx>
+
+#include <BRepMesh_ListOfInteger.hxx>
+#include <Precision.hxx>
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
+
+#include <NCollection_CellFilter.hxx>
+#include <NCollection_Vector.hxx>
+
+typedef NCollection_Vector<BRepMesh_Circ> CircVector;
+
+//=======================================================================
+//! The class to find in the coincidence points
+//=======================================================================
+
+class BRepMesh_CircleInspector : public NCollection_CellFilter_InspectorXY
+{
+public:
+ typedef Standard_Integer Target;
+ //! Constructor; remembers tolerance and collector data structure.
+ //! All the found points are put in the map and excluded from further
+ //! consideration.
+ BRepMesh_CircleInspector (Standard_Real theTol,
+ Standard_Integer nbComp,
+ const BRepMesh_BaseAllocator& theAlloc);
+
+ void Add(Standard_Integer theInd,const BRepMesh_Circ& theCircle)
+ {
+ myInitCircle.SetValue(theInd, theCircle);
+ }
+
+ void ClerResList()
+ {
+ myResInd.Clear();
+ }
+
+ CircVector& MapOfCirc()
+ {
+ return myInitCircle;
+ }
+
+ BRepMesh_Circ& GetCirc(Standard_Integer theInd)
+ {
+ return myInitCircle(theInd);
+ }
+
+ //! Set current node to be checked
+ void SetCurrent (const gp_XY& theCurCircle)
+ {
+ myCurrent = theCurCircle;
+ }
+
+ //!Get result index of node
+ BRepMesh_ListOfInteger& GetCoincidentInd()
+ {
+ return myResInd;
+ }
+
+ //! Implementation of inspection method
+ NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget);
+
+ static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
+ {
+ return (theIdx == theTarget);
+ }
+
+private:
+ Standard_Real myTol;
+ BRepMesh_ListOfInteger myResInd;
+ CircVector myInitCircle;
+ gp_XY myCurrent;
+};
+
+#endif
--- /dev/null
+-- File: BRepMesh_CircleTool.cdl
+-- Created: Wed May 12 09:30:49 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993
+
+
+class CircleTool from BRepMesh
+
+ ---Purpose: Create sort and destroy the circles used in
+ -- triangulation.
+
+ uses Boolean from Standard,
+ Integer from Standard,
+ Real from Standard,
+ XY from gp,
+ Circ2d from gp,
+ ListOfInteger from BRepMesh,
+ CellFilter from BRepMesh,
+ CircleInspector from BRepMesh,
+ BaseAllocator from BRepMesh
+
+ is Create (theAlloc : in BaseAllocator from BRepMesh)
+ returns CircleTool from BRepMesh;
+
+
+ Create (numberOfComponents : in Integer from Standard;
+ theAlloc : in BaseAllocator from BRepMesh)
+ ---Purpose: Constructs a CircleTool with the maximal dimension
+ -- of the occuped space and an evaluation of the
+ -- number of circles.
+ returns CircleTool from BRepMesh;
+
+ Initialize (me : in out;
+ numberOfComponents : in Integer from Standard)
+ ---Purpose: Constructs a CircleTool with the maximal dimension
+ -- of the occuped space and an evaluation of the
+ -- number of circles.
+ is static;
+
+ SetCellSize(me : in out;
+ theSize : in Real from Standard)
+ ---Purpose: Sets new size for cellfilter
+ is static;
+
+ SetCellSize(me : in out;
+ theXSize : in Real from Standard;
+ theYSize : in Real from Standard)
+ ---Purpose: Sets new size for cellfilter
+ is static;
+
+ SetMinMaxSize(me : in out;
+ theMin : in XY from gp;
+ theMax : in XY from gp)
+ ---Purpose: Sets min and max size for circle
+ is static;
+
+ Add (me : in out;
+ theCirc : in Circ2d from gp;
+ theIndex : in Integer from Standard)
+ ---Purpose: Adds and binds circle to the tool.
+ is static;
+
+
+ Add (me : in out;
+ p1, p2, p3 : in XY from gp;
+ theIndex : in Integer from Standard)
+ ---Purpose: Computes adds and binds circle to the tool.
+ returns Boolean from Standard is static;
+
+ MocAdd (me : in out;
+ theIndex : in Integer from Standard);
+ ---Purpose: Adds implicit zero circle
+
+
+ Delete (me : in out; theIndex : Integer from Standard)
+ ---Purpose: Deletes a circle from the tool.
+ is static;
+
+
+ Select (me : in out; thePnt : XY from gp)
+ ---Purpose: Select the circles which contains thePnt.
+ ---C++: return &
+ returns ListOfInteger from BRepMesh is static;
+
+ fields Tolerance : Real from Standard;
+ Allocator : BaseAllocator from BRepMesh;
+ CellFilter : CellFilter from BRepMesh;
+ Selector : CircleInspector from BRepMesh;
+ FaceMax : XY from gp;
+ FaceMin : XY from gp;
+
+end CircleTool;
--- /dev/null
+// File: BRepMesh_CircleTool.cxx
+// Created: Tue Jun 15 19:10:25 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+#include <BRepMesh_CircleTool.ixx>
+#include <gp_XY.hxx>
+#include <Precision.hxx>
+#include <BRepMesh_Circ.hxx>
+#include <BRepMesh_CircleInspector.hxx>
+#include <BRepMesh_BaseAllocator.hxx>
+
+
+//=======================================================================
+//function : BRepMesh_CircleInspector
+//purpose : Constructor
+//
+//=======================================================================
+
+BRepMesh_CircleInspector::BRepMesh_CircleInspector (Standard_Real theTol,
+ Standard_Integer nbComp,
+ const BRepMesh_BaseAllocator& theAlloc)
+ : myTol(theTol*theTol),
+ myResInd(theAlloc),
+ myInitCircle(nbComp)
+{
+ // myTol = theTol*theTol;
+}
+
+//=======================================================================
+//function : Inspect
+//purpose :
+//
+//=======================================================================
+NCollection_CellFilter_Action BRepMesh_CircleInspector::Inspect (const Standard_Integer theTarget)
+{
+ const BRepMesh_Circ& Circ = myInitCircle(theTarget);
+ Standard_Real R = Circ.Radius();
+ if(R < 0)
+ return CellFilter_Purge;
+ Standard_Real dx,dy;
+ const gp_XY& aLoc=Circ.Location();
+ dx=myCurrent.X()-aLoc.X();
+ dy=myCurrent.Y()-aLoc.Y();
+ if ((dx*dx+dy*dy)-(R*R) <= myTol)
+ myResInd.Append(theTarget);
+ return CellFilter_Keep;
+}
+
+
+//=======================================================================
+//function : BRepMesh_CircleTool
+//purpose :
+//=======================================================================
+BRepMesh_CircleTool::BRepMesh_CircleTool(const BRepMesh_BaseAllocator& theAlloc)
+: Tolerance(Precision::PConfusion()),
+Allocator(theAlloc),
+CellFilter(10, theAlloc),
+Selector(Tolerance,64,theAlloc)
+{
+ Tolerance=Tolerance*Tolerance;
+}
+
+//=======================================================================
+//function : BRepMesh_CircleTool
+//purpose :
+//=======================================================================
+BRepMesh_CircleTool::BRepMesh_CircleTool(const Standard_Integer nbComp,
+ const BRepMesh_BaseAllocator& theAlloc)
+ : Tolerance(Precision::PConfusion()),
+ Allocator(theAlloc),
+ CellFilter(10, theAlloc),
+ Selector(Tolerance,Max(nbComp,64),theAlloc)
+{
+ Tolerance=Tolerance*Tolerance;
+}
+
+
+//=======================================================================
+//function : Initialize
+//purpose :
+//=======================================================================
+void BRepMesh_CircleTool::Initialize(const Standard_Integer /*nbComp*/)
+{
+ Tolerance=Precision::PConfusion();
+ Tolerance=Tolerance*Tolerance;
+}
+
+void BRepMesh_CircleTool::SetCellSize(const Standard_Real theSize)
+{
+ CellFilter.Reset(theSize, Allocator);
+}
+
+void BRepMesh_CircleTool::SetCellSize(const Standard_Real theXSize,
+ const Standard_Real theYSize)
+{
+ Standard_Real aCellSize[2];
+ aCellSize[0] = theXSize;
+ aCellSize[1] = theYSize;
+
+ CellFilter.Reset(aCellSize, Allocator);
+}
+
+
+void BRepMesh_CircleTool::SetMinMaxSize(const gp_XY& theMin,
+ const gp_XY& theMax)
+{
+ FaceMin = theMin;
+ FaceMax = theMax;
+}
+
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+void BRepMesh_CircleTool::Add(const gp_Circ2d& theCirc,
+ const Standard_Integer theIndex)
+{
+ gp_XY aCoord(theCirc.Location().Coord());
+ Standard_Real R = theCirc.Radius();
+ BRepMesh_Circ aCir(aCoord, R);
+
+ //compute coords
+ Standard_Real xMax=Min(aCoord.X()+R,FaceMax.X());
+ Standard_Real xMin=Max(aCoord.X()-R,FaceMin.X());
+ Standard_Real yMax=Min(aCoord.Y()+R,FaceMax.Y());
+ Standard_Real yMin=Max(aCoord.Y()-R,FaceMin.Y());
+
+ gp_XY MinPnt(xMin,yMin);
+ gp_XY MaxPnt(xMax,yMax);
+
+ CellFilter.Add(theIndex, MinPnt, MaxPnt);
+ Selector.Add(theIndex, aCir);
+}
+
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_CircleTool::Add(const gp_XY& p1,
+ const gp_XY& p2,
+ const gp_XY& p3,
+ const Standard_Integer theIndex)
+{
+ gp_XY m1((p1.X()+p2.X())/2., (p1.Y()+p2.Y())/2.);
+ gp_XY m2((p2.X()+p3.X())/2., (p2.Y()+p3.Y())/2.);
+ gp_XY m3((p3.X()+p1.X())/2., (p3.Y()+p1.Y())/2.);
+ Standard_Real dx=m1.X()-m2.X();
+ Standard_Real dy=m1.Y()-m2.Y();
+ Standard_Real d12=(dx*dx)+(dy*dy);
+ dx=m2.X()-m3.X();
+ dy=m2.Y()-m3.Y();
+ Standard_Real d23=(dx*dx)+(dy*dy);
+ dx=m3.X()-m1.X();
+ dy=m3.Y()-m1.Y();
+ Standard_Real d31=(dx*dx)+(dy*dy);
+ gp_XY pl11, pl12, pl21, pl22;
+
+ if (d12>d23 && d12>d31) {
+ dy=p2.Y()-p1.Y();
+ dx=p1.X()-p2.X();
+ if (dy!=0. || dx!=0.) {
+ pl11 = m1;
+ pl12 = gp_XY(dy, dx);
+ }
+ else return Standard_False;
+
+ dy=p3.Y()-p2.Y();
+ dx=p2.X()-p3.X();
+ if (dy!=0. || dx!=0.) {
+ pl21 = m2;
+ pl22 = gp_XY(dy, dx);
+ }
+ else return Standard_False;
+ }
+ else {
+ if (d23>d31) {
+ dy=p3.Y()-p2.Y();
+ dx=p2.X()-p3.X();
+ if (dy!=0. || dx!=0.) {
+ pl11 = m2;
+ pl12 = gp_XY(dy, dx);
+ }
+ else return Standard_False;
+
+ dy=p1.Y()-p3.Y();
+ dx=p3.X()-p1.X();
+ if (dy!=0. || dx!=0.) {
+ pl21 = m3;
+ pl22 = gp_XY(dy, dx);
+ }
+ else return Standard_False;
+ }
+ else {
+ dy=p1.Y()-p3.Y();
+ dx=p3.X()-p1.X();
+ if (dy!=0. || dx!=0.) {
+ pl11 = m3;
+ pl12 = gp_XY(dy, dx);
+ }
+ else return Standard_False;
+
+ dy=p2.Y()-p1.Y();
+ dx=p1.X()-p2.X();
+ if (dy!=0. || dx!=0.) {
+ pl21 = m1;
+ pl22 = gp_XY(dy, dx);
+ }
+ else return Standard_False;
+ }
+ }
+
+ gp_XY aVecO1O2 = pl21 - pl11;
+ Standard_Real aCrossD1D2 = pl12 ^ pl22;
+ Standard_Real theSinAngle = Abs(aCrossD1D2);
+ if (theSinAngle < gp::Resolution())
+ return Standard_False;
+ Standard_Real theParam1 = (aVecO1O2 ^ pl22) / aCrossD1D2;
+ gp_XY pInt = pl11+pl12*theParam1;
+ dx=p1.X()-pInt.X();
+ dy=p1.Y()-pInt.Y();
+ Standard_Real R = Sqrt(dx*dx+dy*dy);
+ BRepMesh_Circ aCir(pInt, R);
+
+ //compute coords
+ Standard_Real xMax=Min(pInt.X()+R,FaceMax.X());
+ Standard_Real xMin=Max(pInt.X()-R,FaceMin.X());
+ Standard_Real yMax=Min(pInt.Y()+R,FaceMax.Y());
+ Standard_Real yMin=Max(pInt.Y()-R,FaceMin.Y());
+
+ gp_XY MinPnt(xMin,yMin);
+ gp_XY MaxPnt(xMax,yMax);
+
+ CellFilter.Add(theIndex, MinPnt, MaxPnt);
+
+ Selector.Add(theIndex, aCir);
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Delete
+//purpose :
+//=======================================================================
+void BRepMesh_CircleTool::Delete(const Standard_Integer theIndex)
+{
+ BRepMesh_Circ& Circ = Selector.GetCirc(theIndex);
+ if(Circ.Radius() > 0.) {
+ Circ.SetRadius(-1);
+ }
+}
+
+//=======================================================================
+//function : Select
+//purpose :
+//=======================================================================
+BRepMesh_ListOfInteger& BRepMesh_CircleTool::Select(const gp_XY& thePnt)
+{
+ Selector.ClerResList();
+ Selector.SetCurrent(thePnt);
+ CellFilter.Inspect (thePnt, Selector);
+ return Selector.GetCoincidentInd();
+}
+
+void BRepMesh_CircleTool::MocAdd(const Standard_Integer theIndex)
+{
+ gp_XY nullPnt(0.,0.);
+ BRepMesh_Circ theNullCir(nullPnt, -1.);
+ Selector.Add(theIndex, theNullCir);
+}
--- /dev/null
+-- File: BRepMesh_ComparatorOfIndexedVertex.cdl
+-- Created: Tue Apr 5 11:45:18 1994
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1994
+
+
+class ComparatorOfIndexedVertexOfDelaun from BRepMesh
+
+ ---Purpose: Sort two point in a given direction.
+
+
+ uses Boolean from Standard,
+ XY from gp,
+ DataStructureOfDelaun from BRepMesh
+
+ is Create (theDir : XY from gp;
+ TheTol : Real from Standard;
+ HDS : DataStructureOfDelaun from BRepMesh)
+ returns ComparatorOfIndexedVertexOfDelaun;
+
+
+ IsLower (me; Left, Right: Integer)
+ ---Purpose: returns True if <Left> is lower than <Right>
+ returns Boolean from Standard;
+
+ IsGreater (me; Left, Right: Integer)
+ ---Purpose: returns True if <Left> is greater than <Right>
+ returns Boolean from Standard;
+
+ IsEqual(me; Left, Right: Integer)
+ ---Purpose: returns True when <Right> and <Left> are equal.
+ returns Boolean from Standard;
+
+
+ fields IndexedStructure : DataStructureOfDelaun from BRepMesh;
+ DirectionOfSort : XY from gp;
+ Tolerance : Real from Standard;
+
+end ComparatorOfIndexedVertexOfDelaun;
--- /dev/null
+// File: BRepMesh_ComparatorOfIndexedVertexOfDelaun.cxx
+// Created: Tue Apr 5 11:50:40 1994
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+#include <BRepMesh_ComparatorOfIndexedVertexOfDelaun.ixx>
+#include <BRepMesh_Vertex.hxx>
+
+//=======================================================================
+//function : BRepMesh_ComparatorOfIndexedVertexOfDelaun
+//purpose :
+//=======================================================================
+
+BRepMesh_ComparatorOfIndexedVertexOfDelaun::BRepMesh_ComparatorOfIndexedVertexOfDelaun
+(const gp_XY& theDir,
+ const Standard_Real theTol,
+ const Handle(BRepMesh_DataStructureOfDelaun)& HDS)
+ : IndexedStructure(HDS),DirectionOfSort(theDir), Tolerance(theTol)
+{}
+
+//=======================================================================
+//function : IsLower
+//purpose :
+//=======================================================================
+
+Standard_Boolean BRepMesh_ComparatorOfIndexedVertexOfDelaun::IsLower
+(const Standard_Integer Left, const Standard_Integer Right) const
+{
+ return ((IndexedStructure->GetNode(Left).Coord()*DirectionOfSort) <
+ (IndexedStructure->GetNode(Right).Coord()*DirectionOfSort));
+}
+
+//=======================================================================
+//function : IsGreater
+//purpose :
+//=======================================================================
+
+Standard_Boolean BRepMesh_ComparatorOfIndexedVertexOfDelaun::IsGreater
+(const Standard_Integer Left, const Standard_Integer Right) const
+{
+ return ((IndexedStructure->GetNode(Left).Coord()*DirectionOfSort) >
+ (IndexedStructure->GetNode(Right).Coord()*DirectionOfSort));
+}
+
+//=======================================================================
+//function : IsEqual
+//purpose :
+//=======================================================================
+
+Standard_Boolean BRepMesh_ComparatorOfIndexedVertexOfDelaun::IsEqual
+(const Standard_Integer Left, const Standard_Integer Right) const
+{
+ return (IndexedStructure->GetNode(Left).Coord().IsEqual
+ (IndexedStructure->GetNode(Right).Coord(), Tolerance));
+}
+
--- /dev/null
+-- File: BRepMesh_ComparatorOfVertexOfDelaun.cdl
+-- Created: Fri Jun 18 13:46:14 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993
+
+
+class ComparatorOfVertexOfDelaun from BRepMesh
+
+ ---Purpose: Sort two point in a given direction.
+
+
+ uses Boolean from Standard,
+ Vertex from BRepMesh,
+ XY from gp
+
+
+ is Create (theDir : XY from gp; TheTol: Real from Standard)
+ returns ComparatorOfVertexOfDelaun;
+
+
+ IsLower (me; Left, Right: Vertex from BRepMesh)
+ ---Purpose: returns True if <Left> is lower than <Right>
+ returns Boolean from Standard;
+
+ IsGreater (me; Left, Right: Vertex from BRepMesh)
+ ---Purpose: returns True if <Left> is greater than <Right>
+ returns Boolean from Standard;
+
+ IsEqual(me; Left, Right: Vertex from BRepMesh)
+ ---Purpose: returns True when <Right> and <Left> are equal.
+ returns Boolean from Standard;
+
+
+fields DirectionOfSort : XY from gp;
+ Tolerance : Real from Standard;
+
+end ComparatorOfVertexOfDelaun;
--- /dev/null
+// File: BRepMesh_ComparatorOfVertexOfDelaun.cxx
+// Created: Fri Jun 18 17:04:44 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+#include <BRepMesh_ComparatorOfVertexOfDelaun.ixx>
+
+//=======================================================================
+//function : BRepMesh_ComparatorOfVertexOfDelaun
+//purpose :
+//=======================================================================
+
+BRepMesh_ComparatorOfVertexOfDelaun::BRepMesh_ComparatorOfVertexOfDelaun(const gp_XY& theDir,
+ const Standard_Real theTol)
+ : DirectionOfSort(theDir), Tolerance(theTol)
+{}
+
+//=======================================================================
+//function : IsLower
+//purpose :
+//=======================================================================
+
+Standard_Boolean BRepMesh_ComparatorOfVertexOfDelaun::IsLower(const BRepMesh_Vertex& Left,
+ const BRepMesh_Vertex& Right) const
+{
+ return (Left.Coord()*DirectionOfSort) <
+ (Right.Coord()*DirectionOfSort);
+}
+
+//=======================================================================
+//function : IsGreater
+//purpose :
+//=======================================================================
+
+Standard_Boolean BRepMesh_ComparatorOfVertexOfDelaun::IsGreater(const BRepMesh_Vertex& Left,
+ const BRepMesh_Vertex& Right) const
+{
+ return (Left.Coord()*DirectionOfSort) >
+ (Right.Coord()*DirectionOfSort);
+}
+
+//=======================================================================
+//function : IsEqual
+//purpose :
+//=======================================================================
+
+Standard_Boolean BRepMesh_ComparatorOfVertexOfDelaun::IsEqual(const BRepMesh_Vertex& Left,
+ const BRepMesh_Vertex& Right) const
+{
+ return Left.IsEqual(Right);
+}
+
--- /dev/null
+-- File: BRepMesh_DataStructureOfDelaun.cdl
+-- Created: Wed Mar 17 11:20:52 1993
+-- Author: Didier PIFFAULT
+-- <dpf@phylox>
+---Copyright: Matra Datavision 1993
+
+
+class DataStructureOfDelaun from BRepMesh inherits TShared from MMgt
+
+ ---Purpose: Describes the data structure necessary for the
+ -- mesh algorithms in two dimensions plane or on
+ -- surface by meshing in UV space.
+
+
+ uses Integer from Standard,
+ ListOfInteger from BRepMesh,
+ MapOfInteger from BRepMesh,
+ PairOfIndex from BRepMesh,
+ Box from Bnd,
+ BoundSortBox from Bnd,
+ BaseAllocator from BRepMesh,
+ NodeHasherOfDataStructureOfDelaun from BRepMesh,
+ LinkHasherOfDataStructureOfDelaun from BRepMesh,
+ ElemHasherOfDataStructureOfDelaun from BRepMesh,
+ IDMapOfNodeOfDataStructureOfDelaun from BRepMesh,
+ IDMapOfLinkOfDataStructureOfDelaun from BRepMesh,
+ IMapOfElementOfDataStructureOfDelaun from BRepMesh,
+ SelectorOfDataStructureOfDelaun from BRepMesh,
+ Vertex from BRepMesh,
+ Edge from BRepMesh,
+ Triangle from BRepMesh
+
+ is Create (theAllocator: BaseAllocator from BRepMesh;
+ NodeNumber : Integer from Standard = 100)
+ ---Purpose: <NodeNumber> is just an evaluation of the
+ -- presumed number of nodes in this mesh. The
+ -- Mesh data structure will be automatically
+ -- redimensioned if necessary.
+ returns mutable DataStructureOfDelaun from BRepMesh ;
+
+ AddNode (me : mutable ;
+ theNode : Vertex from BRepMesh)
+ returns Integer from Standard
+ ---Purpose: Adds a node to the mesh if the node is not
+ -- already in the Mesh. Returns the index of the
+ -- node in the structure.
+ is static;
+
+ GetNode (me : mutable;
+ Index : Integer from Standard)
+ returns Vertex from BRepMesh
+ ---Purpose: Get the value of node <Index>.
+ ---C++: return const &
+ ---C++: alias operator ()
+ is static;
+
+ GetNodeList (me : mutable;
+ Index : Integer from Standard)
+ returns ListOfInteger from BRepMesh
+ ---Purpose: Get the list of node <Index>.
+ ---C++: return const &
+ is static;
+
+ ForceRemoveNode (me : mutable;
+ Index : Integer from Standard)
+ ---Purpose: Removes the node of index <index> from the mesh.
+ is static;
+
+ ForceRemoveLink (me : mutable;
+ Index : Integer from Standard)
+ ---Purpose: Removes the link of index <index> from the mesh.
+ is static;
+
+ ReplaceNodes (me : mutable;
+ NewNodes : IDMapOfNodeOfDataStructureOfDelaun from BRepMesh)
+ ---Purpose: Removes the all nodes and sets new map of
+ -- nodes from the mesh.
+ -- For internal use only.
+ is static;
+
+ RemoveNode (me : mutable;
+ Index : Integer from Standard)
+ ---Purpose: Removes the node of index <index> from the mesh.
+ is static;
+
+ MoveNode (me : mutable ;
+ Index : Integer from Standard;
+ newNode : Vertex from BRepMesh)
+ ---Purpose: Changes the UV value of node of index <Index> by
+ -- <newNode>. Returns false if <newnode> is already in
+ -- the structure.
+ returns Boolean from Standard is static;
+
+ NbNodes (me)
+ returns Integer from Standard
+ ---Purpose: Gives the number of nodes in this mesh.
+ is static;
+
+
+ AddLink (me : mutable;
+ theLink : Edge from BRepMesh)
+ returns Integer from Standard
+ ---Purpose: Adds a Link to the mesh if the Link is not
+ -- already in the structure. Returns the index of
+ -- the link in the structure.
+ is static;
+
+ GetLink (me : mutable;
+ Index : Integer from Standard)
+ returns Edge from BRepMesh
+ ---Purpose: Get the value of Link <Index>.
+ ---C++: return const &
+ is static;
+
+ RemoveLink (me : mutable;
+ Index : Integer from Standard)
+ ---Purpose: Removes the Link of index <Index> from the
+ -- mesh.
+ is static;
+
+ SubstituteLink (me : mutable ;
+ Index : Integer from Standard;
+ newLink : Edge from BRepMesh)
+ ---Purpose: Substitutes the Link of index <Index> by
+ -- <newLink> clear the connectivity.
+ returns Boolean from Standard is static;
+
+ NbLinks (me)
+ returns Integer from Standard
+ ---Purpose: Gives the number of elements in this mesh.
+ is static;
+
+
+ AddElement (me : mutable;
+ theElement : Triangle from BRepMesh)
+ returns Integer from Standard
+ ---Purpose: Adds an element to the mesh if it is not
+ -- already in the Mesh. Returns the index of the
+ -- element in the structure.
+ is static;
+
+ GetElement (me : mutable;
+ Index : Integer from Standard)
+ returns Triangle from BRepMesh
+ ---Purpose: Get the value of Element <Index>.
+ ---C++: return const &
+ is static;
+
+ RemoveElement (me : mutable;
+ Index : Integer from Standard)
+ ---Purpose: Removes the element of index <Index> in the mesh.
+ is static;
+
+ SubstituteElement (me : mutable ;
+ Index : Integer from Standard;
+ newElement : Triangle from BRepMesh)
+ ---Purpose: Substitutes the element of index <Index> by
+ -- <newElement>. The links connectivity is updated.
+ returns Boolean from Standard is static;
+
+ NbElements (me)
+ returns Integer from Standard
+ ---Purpose: Gives the number of elements in this mesh.
+ is static;
+
+
+ ClearDomain (me : mutable)
+ ---Purpose: Removes all elements
+ is static;
+
+
+ IndexOf (me;
+ aNode : Vertex from BRepMesh)
+ ---Purpose: Finds the index of the node. Returns 0 if the
+ -- node is not in the mesh.
+ returns Integer from Standard;
+
+ IndexOf (me;
+ aLink : Edge from BRepMesh)
+ ---Purpose: Finds the index of the Link. Returns 0 if the
+ -- Link is not in the mesh.
+ returns Integer from Standard;
+
+ IndexOf (me;
+ anElement : Triangle from BRepMesh)
+ ---Purpose: Finds the index of the Element. Returns 0 if
+ -- the Element is not in the mesh.
+ returns Integer from Standard;
+
+
+ LinkNeighboursOf (me;
+ theNode : in Integer from Standard)
+ returns ListOfInteger from BRepMesh
+ ---C++: return const &
+ ---Purpose: Gives the list of Link's indices handling the
+ -- node <theNode>.
+ is static;
+
+
+ ElemConnectedTo (me;
+ theLink : in Integer from Standard)
+ returns PairOfIndex from BRepMesh
+ ---C++: return const &
+ ---Purpose: Gives the element's indices conected
+ -- to <theLink>.
+ is static;
+
+ ElemOfDomain (me)
+ returns MapOfInteger from BRepMesh
+ ---C++: return const &
+ ---Purpose: Gives the list of element's indices
+ is static;
+
+
+ LinkOfDomain (me)
+ returns MapOfInteger from BRepMesh
+ ---C++: return const &
+ ---Purpose: Gives the list of link's indices
+ is static;
+
+
+ ClearDeleted (me : mutable)
+ ---Purpose: This method substitute the deleted items by
+ -- the last in Indexed Data Maps to have only
+ -- non-deleted elements, links or nodes in the
+ -- structure.
+ is static;
+
+
+ -- Internal methods :
+
+ ClearElement (me : mutable;
+ Index : Integer from Standard;
+ theElem : Triangle from BRepMesh)
+ ---Purpose: Deletes the element of index <Index> in
+ -- the mesh. Used by RemoveElement.
+ is static private;
+
+ Statistics (me;
+ flot : in out OStream from Standard)
+ ---Purpose: Give informations on map.
+ is static;
+
+ Allocator (me) returns BaseAllocator from BRepMesh;
+ ---C++: return const&
+
+
+ fields myNodes : IDMapOfNodeOfDataStructureOfDelaun from BRepMesh;
+ myDelNodes : ListOfInteger from BRepMesh;
+ myLinks : IDMapOfLinkOfDataStructureOfDelaun from BRepMesh;
+ myDelLinks : ListOfInteger from BRepMesh;
+ myElements : IMapOfElementOfDataStructureOfDelaun from BRepMesh;
+ --myDelElements : ListOfInteger from BRepMesh;
+ myElemOfDomain : MapOfInteger from BRepMesh;
+ myLinkOfDomain : MapOfInteger from BRepMesh;
+ myAllocator : BaseAllocator from BRepMesh;
+end DataStructureOfDelaun;
--- /dev/null
+// File: BRepMesh_DataStructureOfDelaun.cxx
+// Created: Tue May 11 16:01:57 1993
+// Author: Didier PIFFAULT
+// <dpf@nonox>
+
+#include <BRepMesh_DataStructureOfDelaun.ixx>
+
+//=======================================================================
+//function : BRepMesh_DataStructureOfDelaun
+//purpose :
+//=======================================================================
+BRepMesh_DataStructureOfDelaun::BRepMesh_DataStructureOfDelaun(const BRepMesh_BaseAllocator& theAlloc,
+ const Standard_Integer NodeNumber)
+ : myNodes(NodeNumber+3),
+ myDelNodes(theAlloc),
+ myLinks(NodeNumber*3),
+ myDelLinks(theAlloc),
+ myElements(NodeNumber*2),
+ // Not_Debuged_Yet myDelElements(theAlloc),
+ myElemOfDomain(NodeNumber*2,theAlloc),
+ myLinkOfDomain(NodeNumber*2,theAlloc)
+{
+ myAllocator = theAlloc;
+}
+
+//=======================================================================
+//function : AddNode
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::AddNode(const BRepMesh_Vertex& theNode)
+{
+ Standard_Integer NodeIndex=myNodes.FindIndex(theNode);
+ if (NodeIndex>0 && !myDelNodes.IsEmpty()) {
+ if (myNodes.FindKey(NodeIndex).Movability()==BRepMesh_Deleted)
+ NodeIndex=0;
+ }
+ if (NodeIndex<=0) {
+ BRepMesh_ListOfInteger thelist(myAllocator);
+ if (!myDelNodes.IsEmpty()) {
+ NodeIndex=myDelNodes.First();
+ myNodes.Substitute(NodeIndex, theNode, thelist);
+ myDelNodes.RemoveFirst();
+ }
+ else {
+ NodeIndex=myNodes.Add(theNode, thelist);
+ }
+ }
+ return NodeIndex;
+}
+
+//=======================================================================
+//function : GetNode
+//purpose :
+//=======================================================================
+const BRepMesh_Vertex& BRepMesh_DataStructureOfDelaun::GetNode(const Standard_Integer Index)
+{
+ return myNodes.FindKey(Index);
+}
+
+//=======================================================================
+//function : GetNodeList
+//purpose :
+//=======================================================================
+const BRepMesh_ListOfInteger& BRepMesh_DataStructureOfDelaun::GetNodeList(const Standard_Integer Index)
+{
+ return myNodes.FindFromIndex(Index);
+}
+
+//=======================================================================
+//function : ForceRemoveNode
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::ForceRemoveNode(const Standard_Integer Index)
+{
+ //Warning, the static cast from const& to & is called for
+ //performance reasons. This is applicable only in case if later
+ //modification of element (field movability) does not influent on
+ //has calculation.
+ BRepMesh_Vertex& vref=(BRepMesh_Vertex&)myNodes.FindKey(Index);
+ if ( myNodes.FindFromIndex(Index).Extent()==0) {
+ vref.SetMovability(BRepMesh_Deleted);
+ myDelNodes.Append(Index);
+ }
+}
+
+//=======================================================================
+//function : ReplaceNodes
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::ReplaceNodes(const BRepMesh_IDMapOfNodeOfDataStructureOfDelaun& NewNodes)
+{
+ if (NewNodes.IsEmpty() || NewNodes.Extent() != myNodes.Extent())
+ return;
+ /*for (Standard_Integer i = 1; i <= myNodes.Extent(); i++)
+ ForceRemoveNode(i);*/
+
+ myNodes.Assign(NewNodes);
+}
+
+//=======================================================================
+//function : ForceRemoveLink
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::ForceRemoveLink(const Standard_Integer Index)
+{
+ //Warning, the static cast from const& to & is called for
+ //performance reasons. This is applicable only in case if later
+ //modification of element (field movability) does not influent on
+ //has calculation.
+ BRepMesh_Edge& lref=(BRepMesh_Edge&)myLinks.FindKey(Index);
+ if (lref.Movability()!=BRepMesh_Deleted) {
+ if (myLinks.FindFromIndex(Index).Extent()==0) {
+ BRepMesh_ListOfInteger::Iterator tit;
+ BRepMesh_ListOfInteger& aList1 = myNodes(lref.FirstNode());
+ for(tit.Init(aList1); tit.More(); tit.Next()){
+ if (tit.Value()==Index) {
+ aList1.Remove(tit);
+ break;
+ }
+ }
+
+ BRepMesh_ListOfInteger& aList2 = myNodes(lref.LastNode());
+ for(tit.Init(aList2); tit.More(); tit.Next()){
+ if (tit.Value()==Index) {
+ aList2.Remove(tit);
+ break;
+ }
+ }
+ myLinkOfDomain.Remove(Index);
+ lref.SetMovability(BRepMesh_Deleted);
+ myDelLinks.Append(Index);
+ }
+ }
+}
+
+//=======================================================================
+//function : RemoveNode
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::RemoveNode(const Standard_Integer Index)
+{
+ //Warning, the static cast from const& to & is called for
+ //performance reasons. This is applicable only in case if later
+ //modification of element (field movability) does not influent on
+ //has calculation.
+ BRepMesh_Vertex& vref=(BRepMesh_Vertex&)myNodes.FindKey(Index);
+ if (vref.Movability()==BRepMesh_Free &&
+ myNodes.FindFromIndex(Index).Extent()==0) {
+ vref.SetMovability(BRepMesh_Deleted);
+ myDelNodes.Append(Index);
+ }
+}
+
+//=======================================================================
+//function : MoveNode
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_DataStructureOfDelaun::MoveNode(const Standard_Integer Index,
+ const BRepMesh_Vertex& newNode)
+{
+ if (myNodes.FindIndex(newNode)==0) {
+ BRepMesh_Vertex vref(myNodes.FindKey(Index));
+ const BRepMesh_ListOfInteger& refLink=myNodes(Index);
+ vref.SetMovability(BRepMesh_Deleted);
+ myNodes.Substitute(Index, vref, refLink);
+ myNodes.Substitute(Index, newNode, refLink);
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : NbNodes
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::NbNodes()const
+{
+ return myNodes.Extent();
+}
+
+//=======================================================================
+//function : AddLink
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::AddLink(const BRepMesh_Edge& theLink)
+{
+ Standard_Integer LinkIndex=myLinks.FindIndex(theLink);
+ if (LinkIndex<=0) {
+ BRepMesh_PairOfIndex aPair;
+ if (!myDelLinks.IsEmpty()) {
+ LinkIndex=myDelLinks.First();
+ myLinks.Substitute(LinkIndex, theLink, aPair);
+ myDelLinks.RemoveFirst();
+ }
+ else {
+ LinkIndex=myLinks.Add(theLink, aPair);
+ }
+ myNodes(theLink.FirstNode()).Append(Abs(LinkIndex));
+ myNodes(theLink.LastNode()).Append(Abs(LinkIndex));
+ myLinkOfDomain.Add(LinkIndex);
+ }
+ else if (!theLink.SameOrientation(myLinks.FindKey(LinkIndex)))
+ LinkIndex=-LinkIndex;
+
+ return LinkIndex;
+}
+
+//=======================================================================
+//function : GetLink
+//purpose :
+//=======================================================================
+const BRepMesh_Edge& BRepMesh_DataStructureOfDelaun::GetLink(const Standard_Integer Index)
+{
+ return myLinks.FindKey(Index);
+}
+
+//=======================================================================
+//function : RemoveLink
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::RemoveLink(const Standard_Integer Index)
+{
+ //Warning, the static cast from const& to & is called for
+ //performance reasons. This is applicable only in case if later
+ //modification of element (field movability) does not influent on
+ //has calculation.
+ BRepMesh_Edge& lref=(BRepMesh_Edge&)myLinks.FindKey(Index);
+ if (lref.Movability()!=BRepMesh_Deleted) {
+ if (lref.Movability()==BRepMesh_Free &&
+ myLinks.FindFromIndex(Index).Extent()==0) {
+ BRepMesh_ListOfInteger::Iterator tit;
+ BRepMesh_ListOfInteger& aList1 = myNodes(lref.FirstNode());
+ for(tit.Init(aList1); tit.More(); tit.Next()){
+ if (tit.Value()==Index) {
+ aList1.Remove(tit);
+ break;
+ }
+ }
+ BRepMesh_ListOfInteger& aList2 = myNodes(lref.LastNode());
+ for(tit.Init(aList2); tit.More(); tit.Next()){
+ if (tit.Value()==Index) {
+ aList2.Remove(tit);
+ break;
+ }
+ }
+ myLinkOfDomain.Remove(Index);
+ lref.SetMovability(BRepMesh_Deleted);
+ myDelLinks.Append(Index);
+ }
+ }
+}
+
+//=======================================================================
+//function : SubstituteLink
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_DataStructureOfDelaun::SubstituteLink(const Standard_Integer Index,
+ const BRepMesh_Edge& newLink)
+{
+ //BRepMesh_ListOfInteger thelist(myAllocator);
+ BRepMesh_PairOfIndex aPair;
+ BRepMesh_Edge lref=myLinks.FindKey(Index);
+ if (lref.Movability()==BRepMesh_Deleted)
+ myLinks.Substitute(Index, newLink, aPair);
+ else {
+ if (myLinks.FindIndex(newLink)!=0)
+ return Standard_False;
+
+ lref.SetMovability(BRepMesh_Deleted);
+ myLinks.Substitute(Index, lref, aPair);
+
+ BRepMesh_ListOfInteger::Iterator tit;
+ for(tit.Init(myNodes(lref.FirstNode())); tit.More(); tit.Next()){
+ if (tit.Value()==Index) {
+ myNodes(lref.FirstNode()).Remove(tit);
+ break;
+ }
+ }
+ for(tit.Init(myNodes(lref.LastNode())); tit.More(); tit.Next()){
+ if (tit.Value()==Index) {
+ myNodes(lref.LastNode()).Remove(tit);
+ break;
+ }
+ }
+ myLinks.Substitute(Index, newLink, aPair);
+ myNodes(newLink.FirstNode()).Append(Abs(Index));
+ myNodes(newLink.LastNode()).Append(Abs(Index));
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : NbLinks
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::NbLinks()const
+{
+ return myLinks.Extent();
+}
+
+//=======================================================================
+//function : AddElement
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::AddElement(const BRepMesh_Triangle& theElement)
+{
+ Standard_Integer ElemIndex=myElements.FindIndex(theElement);
+
+ if (ElemIndex<=0) {
+ /* Not_Debuged_Yet
+ if (!myDelElements.IsEmpty()) {
+ ElemIndex=myDelElements.First();
+ myElements.Substitute(ElemIndex, theElement);
+ myDelElements.RemoveFirst();
+ }
+ else */
+ ElemIndex=myElements.Add(theElement);
+
+ myElemOfDomain.Add(ElemIndex);
+
+ Standard_Integer ed1, ed2, ed3;
+ Standard_Boolean or1, or2, or3;
+ theElement.Edges(ed1, ed2, ed3, or1, or2, or3);
+ myLinks(ed1).Append(ElemIndex);
+ myLinks(ed2).Append(ElemIndex);
+ myLinks(ed3).Append(ElemIndex);
+ }
+
+ return ElemIndex;
+}
+
+//=======================================================================
+//function : GetElement
+//purpose :
+//=======================================================================
+const BRepMesh_Triangle& BRepMesh_DataStructureOfDelaun::GetElement(const Standard_Integer Index)
+{
+ return myElements.FindKey(Index);
+}
+
+//=======================================================================
+//function : RemoveElement
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::RemoveElement(const Standard_Integer Index)
+{
+ //Warning, the static cast from const& to & is called for
+ //performance reasons. This is applicable only in case if later
+ //modification of element (field movability) does not influent on
+ //has calculation.
+ BRepMesh_Triangle& lelem=(BRepMesh_Triangle&)myElements.FindKey(Index);
+ if (lelem.Movability()!=BRepMesh_Deleted) {
+ ClearElement(Index, lelem);
+ lelem.SetMovability(BRepMesh_Deleted);
+ // Not_Debuged_Yet myDelElements.Append(Index);
+ myElemOfDomain.Remove(Index);
+ }
+}
+
+static void removeElementIndex(BRepMesh_PairOfIndex& thePair,
+ const Standard_Integer Index)
+{
+ for(Standard_Integer i = 1, n = thePair.Extent(); i <= n; i++) {
+ if (thePair.Index(i)==Index) {
+ thePair.RemoveIndex(i);
+ break;
+ }
+ }
+}
+
+void BRepMesh_DataStructureOfDelaun::ClearElement(const Standard_Integer Index,
+ const BRepMesh_Triangle& theElem)
+{
+ if (theElem.Movability()==BRepMesh_Free) {
+ Standard_Integer ed1, ed2, ed3;
+ Standard_Boolean or1, or2, or3;
+ theElem.Edges(ed1, ed2, ed3, or1, or2, or3);
+ removeElementIndex(myLinks(ed1),Index);
+ removeElementIndex(myLinks(ed2),Index);
+ removeElementIndex(myLinks(ed3),Index);
+ }
+}
+
+//=======================================================================
+//function : SubstituteElement
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_DataStructureOfDelaun::SubstituteElement
+(const Standard_Integer Index, const BRepMesh_Triangle& newElement)
+{
+ const BRepMesh_Triangle& lelem=myElements.FindKey(Index);
+ if (lelem.Movability()==BRepMesh_Deleted)
+ myElements.Substitute(Index, newElement);
+ else {
+ if (myElements.FindIndex(newElement)==0) {
+ ClearElement(Index, lelem);
+ // Warning: here new element and old element should have different Hash code
+ myElements.Substitute(Index, newElement);
+
+ Standard_Integer ed1, ed2, ed3;
+ Standard_Boolean or1, or2, or3;
+ newElement.Edges(ed1, ed2, ed3, or1, or2, or3);
+ myLinks(ed1).Append(Index);
+ myLinks(ed2).Append(Index);
+ myLinks(ed3).Append(Index);
+ }
+ else return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ClearDomain
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::ClearDomain()
+{
+ BRepMesh_MapOfInteger freeEdges;
+ Standard_Integer ed1, ed2, ed3;
+ Standard_Boolean or1, or2, or3;
+ BRepMesh_MapOfInteger::Iterator itDom(myElemOfDomain);
+ //Warning, the static cast from const& to & is called for
+ //performance reasons. This is applicable only in case if later
+ //modification of element (field movability) does not influent on
+ //has calculation.
+ for (;itDom.More(); itDom.Next()) {
+ BRepMesh_Triangle& lelem=(BRepMesh_Triangle&)myElements.FindKey(itDom.Key());
+ lelem.Edges(ed1, ed2, ed3, or1, or2, or3);
+ freeEdges.Add(ed1);
+ freeEdges.Add(ed2);
+ freeEdges.Add(ed3);
+ ClearElement(itDom.Key(), lelem);
+ lelem.SetMovability(BRepMesh_Deleted);
+ // Not_Debuged_Yet myDelElements.Append(itDom.Key());
+ }
+ myElemOfDomain.Clear();
+ BRepMesh_MapOfInteger::Iterator edgeIt(freeEdges);
+ for (; edgeIt.More(); edgeIt.Next())
+ RemoveLink(edgeIt.Key());
+}
+
+//=======================================================================
+//function : NbElements
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::NbElements()const
+{
+ return myElements.Extent();
+}
+
+//=======================================================================
+//function : IndexOf
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::IndexOf(const BRepMesh_Vertex& aNode)const
+{
+ return myNodes.FindIndex(aNode);
+}
+
+//=======================================================================
+//function : IndexOf
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::IndexOf(const BRepMesh_Edge& aLink)const
+{
+ return myLinks.FindIndex(aLink);
+}
+
+//=======================================================================
+//function : IndexOf
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_DataStructureOfDelaun::IndexOf(const BRepMesh_Triangle& anElement)const
+{
+ return myElements.FindIndex(anElement);
+}
+
+//=======================================================================
+//function : LinkNeighboursOf
+//purpose :
+//=======================================================================
+const BRepMesh_ListOfInteger& BRepMesh_DataStructureOfDelaun::LinkNeighboursOf
+(const Standard_Integer theNode)const
+{
+ return myNodes.FindFromIndex(theNode);
+}
+
+//=======================================================================
+//function : ElemConnectedTo
+//purpose :
+//=======================================================================
+const BRepMesh_PairOfIndex& BRepMesh_DataStructureOfDelaun::ElemConnectedTo
+(const Standard_Integer theLink)const
+{
+ return myLinks.FindFromIndex(theLink);
+}
+
+//=======================================================================
+//function : ElemOfDomain
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_DataStructureOfDelaun::ElemOfDomain () const
+{
+ return myElemOfDomain;
+}
+
+//=======================================================================
+//function : LinkOfDomain
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_DataStructureOfDelaun::LinkOfDomain () const
+{
+ return myLinkOfDomain;
+}
+
+//=======================================================================
+//function : ClearDeleted
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::ClearDeleted()
+{
+
+ // Traitement des Elements
+
+ Standard_Integer IndexDelItem;
+
+ Standard_Integer lastNonDelItem=myElements.Extent();
+ /* // Not_Debuged_Yet
+ while (!myDelElements.IsEmpty()) {
+ while (lastNonDelItem>0) {
+ if (myElements.FindKey(lastNonDelItem).Movability()!=BRepMesh_Deleted)
+ break;
+ myElements.RemoveLast();
+ lastNonDelItem--;
+ }
+
+ IndexDelItem=myDelElements.First();
+ myDelElements.RemoveFirst();
+
+ if (IndexDelItem<lastNonDelItem) {
+ BRepMesh_Triangle eItem=myElements.FindKey(lastNonDelItem);
+ myElements.RemoveLast();
+ myElements.Substitute(IndexDelItem, eItem);
+ myElemOfDomain.Remove(lastNonDelItem);
+ myElemOfDomain.Add(IndexDelItem);
+ lastNonDelItem--;
+
+ Standard_Integer ed[3], ied;
+ Standard_Boolean orient[3];
+ eItem.Edges(ed[0], ed[1], ed[2], orient[0], orient[1], orient[2]);
+ BRepMesh_ListOfInteger::Iterator itList;
+ for (ied=0; ied<3; ied++) {
+ BRepMesh_PairOfIndex& aPair = myLinks(ed[ied]);
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
+ if (aPair.Index(j)==(lastNonDelItem+1)) {
+ aPair.SetIndex(j,IndexDelItem);
+ break;
+ }
+ }
+ }
+ }
+ */
+
+ // Traitement des Links
+
+ lastNonDelItem=myLinks.Extent();
+
+ while (!myDelLinks.IsEmpty()) {
+ while (lastNonDelItem>0) {
+ if (myLinks.FindKey(lastNonDelItem).Movability()!=BRepMesh_Deleted)
+ break;
+ myLinks.RemoveLast();
+ lastNonDelItem--;
+ }
+
+ IndexDelItem=myDelLinks.First();
+ myDelLinks.RemoveFirst();
+
+ if (IndexDelItem<lastNonDelItem) {
+ BRepMesh_Edge lItem=myLinks.FindKey(lastNonDelItem);
+ BRepMesh_PairOfIndex Data(myLinks(lastNonDelItem));
+ myLinks.RemoveLast();
+ myLinks.Substitute(IndexDelItem, lItem, Data);
+ myLinkOfDomain.Remove(lastNonDelItem);
+ myLinkOfDomain.Add(IndexDelItem);
+ lastNonDelItem--;
+
+ Standard_Integer iv[2], ivx;
+ iv[0]=lItem.FirstNode();
+ iv[1]=lItem.LastNode();
+
+ BRepMesh_ListOfInteger::Iterator itLis;
+ for (ivx=0; ivx<2; ivx++) {
+ for (itLis.Init(myNodes(iv[ivx]));
+ itLis.More(); itLis.Next()) {
+ if (itLis.Value()==(lastNonDelItem+1)) {
+ itLis.ChangeValue()=IndexDelItem;
+ break;
+ }
+ }
+ }
+ for(Standard_Integer j = 1, jn = Data.Extent(); j <= jn; j++) {
+ const BRepMesh_Triangle& Elem=myElements.FindKey(Data.Index(j));
+
+ Standard_Integer el[3], iel;
+ Standard_Boolean orl[3];
+ Elem.Edges(el[0], el[1], el[2], orl[0], orl[1], orl[2]);
+ for (iel=0; iel<3; iel++) {
+ if (el[iel]==lastNonDelItem+1) {
+ el[iel]=IndexDelItem;
+ break;
+ }
+ }
+ myElements.Substitute(itLis.Value(),
+ BRepMesh_Triangle(el[0], el[1], el[2],
+ orl[0], orl[1], orl[2],
+ Elem.Movability() ));
+ }
+ }
+ }
+
+
+ // Traitement des Nodes :
+
+ lastNonDelItem=myNodes.Extent();
+
+ while (!myDelNodes.IsEmpty()) {
+ while (lastNonDelItem>0) {
+ if (myNodes.FindKey(lastNonDelItem).Movability()!=BRepMesh_Deleted)
+ break;
+ myNodes.RemoveLast();
+ lastNonDelItem--;
+ }
+ IndexDelItem=myDelNodes.First();
+ myDelNodes.RemoveFirst();
+
+ if (IndexDelItem<lastNonDelItem) {
+ BRepMesh_Vertex nItem=myNodes.FindKey(lastNonDelItem);
+ BRepMesh_ListOfInteger Data;
+ Data.Append(myNodes(lastNonDelItem));
+ myNodes.RemoveLast();
+ lastNonDelItem--;
+ myNodes.Substitute(IndexDelItem, nItem, Data);
+
+ BRepMesh_ListOfInteger::Iterator itLi;
+ for (itLi.Init(Data); itLi.More(); itLi.Next()) {
+ const BRepMesh_Edge& li=myLinks.FindKey(itLi.Value());
+ BRepMesh_PairOfIndex conx(myLinks(itLi.Value()));
+ Standard_Integer iv1=li.FirstNode();
+ Standard_Integer iv2=li.LastNode();
+ if (iv1==lastNonDelItem+1) iv1=IndexDelItem;
+ else if (iv2==lastNonDelItem+1) iv2=IndexDelItem;
+
+ myLinks.Substitute(itLi.Value(),
+ BRepMesh_Edge(iv1, iv2, li.Movability()), conx);
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : Statistics
+//purpose :
+//=======================================================================
+void BRepMesh_DataStructureOfDelaun::Statistics(Standard_OStream& S) const
+{
+ S << " Map de nodes : \n";
+ myNodes.Statistics(S);
+ S << "\n Deleted nodes : " << myDelNodes.Extent() << endl;
+
+ S << "\n\n Map de Links : \n";
+ myLinks.Statistics(S);
+ S << "\n Deleted links : " << myDelLinks.Extent() << endl;
+
+ S << "\n\n Map d elements : \n";
+ myElements.Statistics(S);
+ // Not_Debuged_Yet S << "\n Deleted elements : " << myDelElements.Extent() << endl;
+}
+
+//=======================================================================
+//function : Allocator()
+//purpose :
+//=======================================================================
+const BRepMesh_BaseAllocator& BRepMesh_DataStructureOfDelaun::Allocator() const
+{
+ return myAllocator;
+}
--- /dev/null
+-- File: BRepMesh_Delaun.cdl
+-- Created: Tue May 11 17:19:19 1993
+-- Author: Didier PIFFAULT
+-- <dpf@nonox>
+---Copyright: Matra Datavision 1993, 1994
+
+
+class Delaun from BRepMesh
+
+ ---Purpose: Compute the Delaunay's triangulation with the
+ -- algorithm of Watson.
+
+
+ uses Integer from Standard,
+ SequenceOfInteger from TColStd,
+ Array1OfInteger from TColStd,
+ Box2d from Bnd,
+ CircleTool from BRepMesh,
+ MapOfInteger from BRepMesh,
+ DataStructureOfDelaun from BRepMesh,
+ MapOfIntegerInteger from BRepMesh,
+ Vertex from BRepMesh,
+ Edge from BRepMesh,
+ Triangle from BRepMesh,
+ ComparatorOfVertexOfDelaun from BRepMesh,
+ ComparatorOfIndexedVertexOfDelaun from BRepMesh,
+ Array1OfVertexOfDelaun from BRepMesh,
+ HArray1OfVertexOfDelaun from BRepMesh,
+ HeapSortVertexOfDelaun from BRepMesh,
+ HeapSortIndexedVertexOfDelaun from BRepMesh
+
+
+ is
+ -- Interface :
+
+ Create (Vertices : in out Array1OfVertexOfDelaun from BRepMesh;
+ ZPositive : in Boolean from Standard=Standard_True)
+ ---Purpose: Creates the triangulation with an empty Mesh
+ -- data structure.
+ returns Delaun from BRepMesh;
+
+
+ Create (OldMesh : mutable DataStructureOfDelaun from BRepMesh;
+ Vertices : in out Array1OfVertexOfDelaun from BRepMesh;
+ ZPositive : in Boolean from Standard=Standard_True)
+ ---Purpose: Creates the triangulation with and existant
+ -- Mesh data structure.
+ returns Delaun from BRepMesh;
+
+
+ Create (OldMesh : mutable DataStructureOfDelaun from BRepMesh;
+ VertexIndices : in out Array1OfInteger from TColStd;
+ ZPositive : in Boolean from Standard=Standard_True)
+ ---Purpose: Creates the triangulation with and existant
+ -- Mesh data structure.
+ returns Delaun from BRepMesh;
+
+
+ AddVertex (me : in out;
+ theVertex : in Vertex from BRepMesh);
+ ---Purpose: Adds a new vertex in the triangulation.
+
+
+ RemoveVertex (me : in out;
+ theVertex : in Vertex from BRepMesh);
+ ---Purpose: Removes a vertex in the triangulation.
+
+
+ AddVertices (me : in out;
+ Vertices : in out Array1OfVertexOfDelaun from BRepMesh);
+ ---Purpose: Adds some vertices in the triangulation.
+
+
+ RevertDiagonal (me : in out;
+ theEdge : in Integer from Standard)
+ ---Purpose: Substitutes the Edge beetween to triangles by the
+ -- other diagonal of the quadrilatere if it is
+ -- possible (convex polygon). Return True if done.
+ returns Boolean from Standard;
+
+
+ UseEdge (me : in out;
+ theEdge : in Integer from Standard)
+ ---Purpose: Modify mesh to use the edge. Return True if done.
+ returns Boolean from Standard;
+
+
+ SmoothMesh (me : in out;
+ Epsilon : in Real from Standard);
+ ---Purpose: Smooths the mesh in 2d space. The method is to
+ -- move the free and OnSurface vertices at the
+ -- barycentre of their polygon.
+
+
+ Result (me)
+ ---C++: return const &
+ ---Purpose: Gives the Mesh data structure.
+ returns DataStructureOfDelaun from BRepMesh;
+
+
+ Frontier (me : in out)
+ ---Purpose: Gives the list of frontier edges
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh;
+
+
+ InternalEdges (me : in out)
+ ---Purpose: Gives the list of internal edges
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh;
+
+
+ FreeEdges (me : in out)
+ ---Purpose: Gives the list of free edges used only one time
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh;
+
+
+ GetVertex (me;
+ vIndex : in Integer from Standard)
+ ---C++: return const &
+ ---C++: inline
+ returns Vertex from BRepMesh;
+
+
+ GetEdge (me;
+ eIndex : in Integer from Standard)
+ ---C++: return const &
+ ---C++: inline
+ returns Edge from BRepMesh;
+
+
+ GetTriangle (me;
+ tIndex : in Integer from Standard)
+ ---C++: return const &
+ ---C++: inline
+ returns Triangle from BRepMesh;
+
+
+ -- Implementation :
+
+ Init (me : in out;
+ Vertices : in out Array1OfVertexOfDelaun from BRepMesh);
+ ---Purpose: Initializes the triangulation with an Array of
+ -- Vertex.
+
+ Compute (me : in out;
+ VertexIndices : in out Array1OfInteger from TColStd);
+ ---Purpose: Computes the triangulation and add the vertices
+ -- edges and triangles to the Mesh data structure.
+
+ ReCompute (me : in out;
+ VertexIndices : in out Array1OfInteger from TColStd);
+ ---Purpose: Clear the existing triangles and recomputes
+ -- the triangulation .
+
+ SuperMesh (me : in out;
+ theBox : Box2d from Bnd);
+ ---Purpose: Build the super mesh .
+
+
+ FrontierAdjust (me : in out)
+ ---Purpose: Adjust the mesh on the frontier.
+ is private;
+
+
+ MeshLeftPolygonOf (me : in out;
+ EdgeIndex : Integer from Standard;
+ EdgeSens : Boolean from Standard)
+ ---Purpose: Find left polygon of the edge and call MeshPolygon.
+ is private;
+
+
+ MeshPolygon (me : in out;
+ Polygon : in out SequenceOfInteger from TColStd)
+ ---Purpose: Mesh closed polygon.
+ is private;
+
+
+ CreateTriangles(me : in out;
+ vertexIndex : Integer from Standard;
+ --vertex : in Vertex from BRepMesh;
+ freeEdges: out MapOfIntegerInteger from BRepMesh)
+ ---Purpose: Creates the triangles beetween the node
+ -- <Vertex> and the polyline <freeEdges>.
+ is private;
+
+
+ DeleteTriangle (me : in out;
+ TrianIndex : Integer from Standard;
+ freeEdges : out MapOfIntegerInteger from BRepMesh)
+ ---Purpose: Deletes the triangle of index <TrianIndex> and
+ -- add the free edges to the map.
+ -- When an edge is suppressed more than one time
+ -- it is destroyed.
+ is private;
+
+
+ Contains (me;
+ TrianIndex : Integer from Standard;
+ theVertex : in Vertex from BRepMesh;
+ edgeOn : out Integer from Standard)
+ ---Purpose: Test if triangle of index <TrianIndex>
+ -- contains geometricaly <theVertex>. If <EdgeOn>
+ -- is != 0 then theVertex is on Edge of index
+ -- <edgeOn>.
+ returns Boolean from Standard;
+
+ TriangleContaining
+ (me : in out;
+ theVertex : in Vertex from BRepMesh)
+ ---Purpose: Gives the index of triangle containing
+ -- geometricaly <theVertex>.
+ returns Integer from Standard;
+
+
+ fields MeshData : DataStructureOfDelaun from BRepMesh;
+ PositiveOrientation : Boolean from Standard;
+ tCircles : CircleTool from BRepMesh;
+ supVert1 : Integer from Standard;
+ supVert2 : Integer from Standard;
+ supVert3 : Integer from Standard;
+ supTrian : Triangle from BRepMesh;
+ mapEdges : MapOfInteger from BRepMesh;
+
+
+end Delaun;
--- /dev/null
+// File: BRepMesh_Delaun.cxx
+// Created: Wed May 12 08:58:20 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+#include <BRepMesh_Delaun.ixx>
+#include <gp_XY.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec2d.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <Precision.hxx>
+#include <Bnd_Box2d.hxx>
+#include <gp.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <BRepMesh_MapOfIntegerInteger.hxx>
+#include <BRepMesh_HeapSortIndexedVertexOfDelaun.hxx>
+#include <BRepMesh_ComparatorOfIndexedVertexOfDelaun.hxx>
+#include <BRepMesh_HeapSortIndexedVertexOfDelaun.hxx>
+#include <BRepMesh_SelectorOfDataStructureOfDelaun.hxx>
+#include <BRepMesh_HeapSortVertexOfDelaun.hxx>
+#include <BRepMesh_ComparatorOfVertexOfDelaun.hxx>
+
+typedef TColStd_ListIteratorOfListOfInteger IteratorOnListOfInteger;
+typedef TColStd_ListOfInteger ListOfInteger;
+
+#define EPSEPS Precision::PConfusion()*Precision::PConfusion()
+
+const gp_XY SortingDirection(M_SQRT1_2, M_SQRT1_2);
+
+//#define TRIANGULATION_MESURE
+
+#ifdef TRIANGULATION_MESURE
+#include <OSD_Chronometer.hxx>
+#include <NCollection_IncAllocator.hxx>
+static OSD_Chronometer ChroTrigu;
+static OSD_Chronometer ChroSearch;
+static OSD_Chronometer ChroDelete;
+static OSD_Chronometer ChroDelTri;
+static OSD_Chronometer ChroDelCir;
+static OSD_Chronometer ChroCreate;
+static OSD_Chronometer ChroFront;
+Standard_EXPORT Standard_Boolean Triangulation_Chrono;
+#endif
+
+//#define TRIANGULATION_DEBUG
+
+#ifdef TRIANGULATION_DEBUG
+Standard_IMPORT Standard_Integer Triangulation_Trace;
+#endif
+
+
+//=======================================================================
+//function : BRepMesh_Delaun
+//purpose :
+//=======================================================================
+BRepMesh_Delaun::BRepMesh_Delaun
+(BRepMesh_Array1OfVertexOfDelaun& Vertices, const Standard_Boolean ZPositive)
+: PositiveOrientation(ZPositive), tCircles(Vertices.Length(),new NCollection_IncAllocator())
+{
+ if (Vertices.Length()>2) {
+ MeshData=new BRepMesh_DataStructureOfDelaun(new NCollection_IncAllocator(),Vertices.Length());
+ Init(Vertices);
+ }
+}
+
+//=======================================================================
+//function : BRepMesh_Delaun
+//purpose :
+//=======================================================================
+BRepMesh_Delaun::BRepMesh_Delaun
+(const Handle(BRepMesh_DataStructureOfDelaun)& OldMesh,
+ BRepMesh_Array1OfVertexOfDelaun& Vertices,
+ const Standard_Boolean ZPositive)
+ : PositiveOrientation(ZPositive), tCircles(Vertices.Length(),OldMesh->Allocator())
+{
+ MeshData=OldMesh;
+ if (Vertices.Length()>2)
+ Init(Vertices);
+}
+
+
+//=======================================================================
+//function : Init
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::Init(BRepMesh_Array1OfVertexOfDelaun& Vertices)
+{
+ Bnd_Box2d theBox;
+ TColStd_Array1OfInteger vertexIndices(Vertices.Lower(), Vertices.Upper());
+ Standard_Integer niver;
+
+ for (niver=Vertices.Lower(); niver<=Vertices.Upper(); niver++) {
+ theBox.Add(gp_Pnt2d(Vertices(niver).Coord()));
+ vertexIndices(niver)=MeshData->AddNode(Vertices(niver));
+ }
+
+ theBox.Enlarge(Precision::PConfusion());
+ SuperMesh(theBox);
+
+ BRepMesh_HeapSortIndexedVertexOfDelaun::Sort
+ (vertexIndices,
+ BRepMesh_ComparatorOfIndexedVertexOfDelaun(SortingDirection,
+ Precision::PConfusion(),
+ MeshData));
+
+ Compute(vertexIndices);
+}
+
+
+//=======================================================================
+//function : BRepMesh_Delaun
+//purpose :
+//=======================================================================
+BRepMesh_Delaun::BRepMesh_Delaun
+(const Handle(BRepMesh_DataStructureOfDelaun)& OldMesh,
+ TColStd_Array1OfInteger& VertexIndices,
+ const Standard_Boolean ZPositive)
+ : PositiveOrientation(ZPositive), tCircles(VertexIndices.Length(),OldMesh->Allocator())
+{
+ MeshData=OldMesh;
+ if (VertexIndices.Length()>2) {
+ Bnd_Box2d theBox;
+ Standard_Integer niver;
+ for (niver=VertexIndices.Lower(); niver<=VertexIndices.Upper(); niver++) {
+ theBox.Add(gp_Pnt2d(GetVertex(VertexIndices(niver)).Coord()));
+ }
+
+ theBox.Enlarge(Precision::PConfusion());
+ SuperMesh(theBox);
+
+ BRepMesh_HeapSortIndexedVertexOfDelaun::Sort
+ (VertexIndices,
+ BRepMesh_ComparatorOfIndexedVertexOfDelaun(SortingDirection,
+ Precision::PConfusion(),
+ MeshData));
+
+ Compute(VertexIndices);
+ }
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::Compute (TColStd_Array1OfInteger& VertexIndices)
+{
+ // Insertion of edges of super triangles in the list of free edges:
+ BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
+ Standard_Integer e1, e2, e3;
+ Standard_Boolean o1, o2, o3;
+ supTrian.Edges(e1, e2, e3, o1, o2, o3);
+ loopEdges.Bind(e1, Standard_True);
+ loopEdges.Bind(e2, Standard_True);
+ loopEdges.Bind(e3, Standard_True);
+
+ if (VertexIndices.Length()>0) {
+
+ // Creation of 3 trianglers with the node and the edges of the super triangle:
+ Standard_Integer iVert=VertexIndices.Lower();
+ CreateTriangles(VertexIndices(iVert), loopEdges);
+
+ // Insertion of nodes :
+ Standard_Boolean modif=Standard_True;
+ Standard_Integer edgeOn, triPerce;
+
+ Standard_Integer aVertIdx;
+ for (iVert++; iVert<=VertexIndices.Upper(); iVert++) {
+ aVertIdx = VertexIndices(iVert);
+ const BRepMesh_Vertex& refToVert=GetVertex(aVertIdx);
+ loopEdges.Clear();
+
+ // List of indices of circles containing the node :
+ BRepMesh_ListOfInteger& cirL=tCircles.Select(refToVert.Coord());
+ BRepMesh_ListOfInteger::Iterator itT(cirL);
+
+ edgeOn=0;
+ triPerce=0;
+
+ for (; itT.More(); itT.Next()) {
+
+ // To add a node in the mesh it is necessary to check to conditions
+ // - the node should be located on the border of the mesh and in an existing triangle
+ // - all adjacent triangles should belong to a component connected with this triangle
+ if (Contains(itT.Value(), refToVert, edgeOn)) {
+ triPerce=itT.Value();
+ cirL.Remove(itT);
+ break;
+ }
+ }
+
+ if (triPerce>0) {
+ DeleteTriangle(triPerce, loopEdges);
+
+ modif=Standard_True;
+ while (modif && !cirL.IsEmpty()) {
+ modif=Standard_False;
+ BRepMesh_ListOfInteger::Iterator itT1(cirL);
+ for (; itT1.More(); itT1.Next()) {
+ GetTriangle(itT1.Value()).Edges(e1,e2,e3,o1,o2,o3);
+ if (loopEdges.IsBound(e1) ||
+ loopEdges.IsBound(e2) ||
+ loopEdges.IsBound(e3)) {
+ modif=Standard_True;
+ DeleteTriangle(itT1.Value(), loopEdges);
+ cirL.Remove(itT1);
+ break;
+ }
+ }
+ }
+
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0) {
+ cout << " creation triangle avec le vertex: ";
+ cout << refToVert.Coord().X() << " " << refToVert.Coord().Y() << endl;
+ }
+#endif
+ // Creation of triangles with the current node
+ // and free edges and removal of these edges from the list of free edges
+ CreateTriangles(aVertIdx, loopEdges);
+
+ }
+ }
+
+ // check that internal edges are not crossed by triangles
+ BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
+
+ // destruction of triancles intersecting internal edges
+ // and their replacement by makeshift triangles
+ Standard_Integer nbc;
+
+ itFr.Reset();
+ for (; itFr.More(); itFr.Next()) {
+ nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
+ if (nbc == 0) {
+ MeshLeftPolygonOf(itFr.Key(), Standard_True);
+ MeshLeftPolygonOf(itFr.Key(), Standard_False);
+ }
+ }
+
+ // adjustment of meshes to boundary edges
+ FrontierAdjust();
+
+ }
+
+ // destruction of triangles containing a top of the super triangle
+ BRepMesh_SelectorOfDataStructureOfDelaun select(MeshData);
+ select.NeighboursOfNode(supVert1);
+ select.NeighboursOfNode(supVert2);
+ select.NeighboursOfNode(supVert3);
+ BRepMesh_MapOfInteger::Iterator trs(select.Elements());
+ loopEdges.Clear();
+ for (;trs.More(); trs.Next()) {
+ DeleteTriangle(trs.Key(), loopEdges);
+ }
+
+ // all edges that remain free are removed from loopEdges;
+ // only the boundary edges of the triangulation remain in loopEdges
+ BRepMesh_MapOfIntegerInteger::Iterator itLEd(loopEdges);
+ for (; itLEd.More(); itLEd.Next()) {
+ if (MeshData->ElemConnectedTo(itLEd.Key()).IsEmpty())
+ MeshData->RemoveLink(itLEd.Key());
+ }
+
+ //the tops of the super triangle are destroyed
+ MeshData->RemoveNode(supVert1);
+ MeshData->RemoveNode(supVert2);
+ MeshData->RemoveNode(supVert3);
+
+}
+
+//=======================================================================
+//function : ReCompute
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::ReCompute (TColStd_Array1OfInteger& VertexIndices)
+{
+ MeshData->ClearDomain();
+
+ // Initialisation du CircleTool :
+ tCircles.Initialize(VertexIndices.Length());
+
+ if (VertexIndices.Length()>2)
+ Compute(VertexIndices);
+}
+
+
+//=======================================================================
+//function : FrontierAdjust
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::FrontierAdjust()
+{
+ Standard_Integer e1, e2, e3;
+ Standard_Boolean o1, o2, o3;
+ BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
+ BRepMesh_ListOfInteger::Iterator itconx;
+ ListOfInteger tril;
+
+ // find external triangles on boundary edges
+ BRepMesh_MapOfInteger::Iterator itFr(Frontier());
+ for (; itFr.More(); itFr.Next()) {
+ const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
+ const BRepMesh_Triangle& trc=GetTriangle(aPair.Index(j));
+ trc.Edges(e1,e2,e3,o1,o2,o3);
+ if ((itFr.Key()==e1 && !o1) ||
+ (itFr.Key()==e2 && !o2) ||
+ (itFr.Key()==e3 && !o3)) {
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0) {
+ cout << "---> destruction du triangle " << aPair.Index(j) << endl;
+ }
+#endif
+ tril.Append(aPair.Index(j));
+ }
+ }
+ }
+
+ // destruction of external triangles on boundary edges
+ for (; !tril.IsEmpty(); tril.RemoveFirst()) {
+ DeleteTriangle(tril.First(), loopEdges);
+ }
+
+ // destrucrion of remaining hanging edges :
+ BRepMesh_MapOfIntegerInteger::Iterator itFE(loopEdges);
+
+ for (; itFE.More(); itFE.Next()) {
+ if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+ MeshData->RemoveLink(itFE.Key());
+ }
+
+ // destruction of triangles crossing the boundary edges and
+ // their replacement by makeshift triangles
+ itFr.Reset();
+ for (; itFr.More(); itFr.Next()) {
+ if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) {
+ MeshLeftPolygonOf(itFr.Key(), Standard_True);
+ }
+ }
+
+ // After this processing there sometimes remain triangles outside boundaries.
+ // Destruction of these triangles :
+ Standard_Integer nbFront;
+
+ // For each edge with only one connection
+ // If one of its tops already passes two boundary edges,
+ // the connected triangle is outside of the contour
+ Standard_Boolean again = Standard_True;
+
+ while (again) {
+ tril.Clear();
+ loopEdges.Clear();
+
+ for (itFr.Initialize(FreeEdges()); itFr.More(); itFr.Next()) {
+ const BRepMesh_Edge& edg=GetEdge(itFr.Key());
+ if (edg.Movability()!=BRepMesh_Frontier) {
+ nbFront=0;
+ if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty())
+ loopEdges.Bind(itFr.Key(), Standard_True);
+ else {
+ for (itconx.Init(MeshData->LinkNeighboursOf(edg.FirstNode()));
+ itconx.More(); itconx.Next()) {
+ if (GetEdge(itconx.Value()).Movability()==BRepMesh_Frontier) {
+ nbFront++;
+ if (nbFront>1) break;
+ }
+ }
+ if (nbFront==2) {
+ const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
+ const Standard_Integer elemId = aPair.Index(j);
+ GetTriangle(elemId).Edges(e1, e2, e3, o1, o2, o3);
+ if (GetEdge(e1).Movability()==BRepMesh_Free &&
+ GetEdge(e2).Movability()==BRepMesh_Free &&
+ GetEdge(e3).Movability()==BRepMesh_Free) {
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0) {
+ cout << " ----> destruction du triangle" << elemId <<endl;
+ }
+#endif
+ tril.Append(elemId);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Destruction des triangles :
+ Standard_Integer kk = 0;
+ for (; !tril.IsEmpty(); tril.RemoveFirst()) {
+ DeleteTriangle(tril.First(), loopEdges);
+ kk++;
+ }
+
+ // destruction of remaining hanging edges
+ for (itFE.Initialize(loopEdges); itFE.More(); itFE.Next()) {
+ if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+ MeshData->RemoveLink(itFE.Key());
+ }
+
+ if (kk == 0) break;
+ }
+
+ // find external triangles on boundary edges
+ // because in comlex curved boundaries external triangles can appear
+ // after "mesh left polygon"
+ for (itFr.Initialize(Frontier()); itFr.More(); itFr.Next()) {
+ const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(itFr.Key());
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
+ const BRepMesh_Triangle& trc=GetTriangle(aPair.Index(j));
+ trc.Edges(e1,e2,e3,o1,o2,o3);
+ if ((itFr.Key()==e1 && !o1) ||
+ (itFr.Key()==e2 && !o2) ||
+ (itFr.Key()==e3 && !o3)) {
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0) {
+ cout << "---> destruction du triangle " << aPair.Index(j) << endl;
+ }
+#endif
+ tril.Append(aPair.Index(j));
+ }
+ }
+ }
+
+ // destruction of external triangles on boundary edges
+ for (; !tril.IsEmpty(); tril.RemoveFirst()) {
+ DeleteTriangle(tril.First(), loopEdges);
+ }
+
+ for (itFE.Initialize(loopEdges); itFE.More(); itFE.Next()) {
+ if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+ MeshData->RemoveLink(itFE.Key());
+ }
+
+
+ // in some cases there remain unused boundaries check
+ for (itFr.Initialize(Frontier()); itFr.More(); itFr.Next()) {
+ if (MeshData->ElemConnectedTo(itFr.Key()).IsEmpty()) {
+ MeshLeftPolygonOf(itFr.Key(), Standard_True);
+ }
+ }
+}
+
+
+//=======================================================================
+//function : MeshLeftPolygonOf
+//purpose : Triangulation of the polygon to the left of <indexEdg>.(material side)
+//=======================================================================
+void BRepMesh_Delaun::MeshLeftPolygonOf(const Standard_Integer indexEdg,
+ const Standard_Boolean forwdEdg)
+{
+ const BRepMesh_Edge& edg=GetEdge(indexEdg);
+ TColStd_SequenceOfInteger polyg;
+ BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
+ TColStd_MapOfInteger usedEdges;
+
+ // Find the polygon
+ usedEdges.Add(indexEdg);
+ Standard_Integer debut, prem, pivo;
+#ifndef DEB
+ Standard_Integer ders =0, oth =0;
+#else
+ Standard_Integer ders, oth;
+#endif
+ if (forwdEdg) {
+ polyg.Append(indexEdg);
+ prem=edg.FirstNode();
+ pivo=edg.LastNode();
+ }
+ else {
+ polyg.Append(-indexEdg);
+ prem=edg.LastNode();
+ pivo=edg.FirstNode();
+ }
+ debut=prem;
+ const BRepMesh_Vertex& debEd=GetVertex(debut);
+ const BRepMesh_Vertex& finEd=GetVertex(pivo);
+
+ // Check the presence of the previous edge <indexEdg> :
+ BRepMesh_ListOfInteger::Iterator itLiVer(MeshData->LinkNeighboursOf(prem));
+ for (; itLiVer.More(); itLiVer.Next()) {
+ oth=0;
+ if (itLiVer.Value()!=indexEdg) {
+ const BRepMesh_Edge& nedg=GetEdge(itLiVer.Value());
+ oth=nedg.LastNode();
+ if (oth==prem) oth=nedg.FirstNode();
+ break;
+ }
+ }
+ if (oth==0) {
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0)
+ cout << " MeshLeftPolygonOf : Aucun chemin Edge précédente !" << endl;
+#endif
+ return;
+ }
+
+
+ gp_XY vedge(finEd.Coord());
+ vedge.Subtract(debEd.Coord());
+ gp_XY ved1(vedge);
+ gp_XY ved2;
+ Standard_Integer curEdg=indexEdg, e1, e2, e3;
+ Standard_Boolean o1, o2, o3;
+
+ // Find the nearest to <indexEdg> closed polygon :
+ Standard_Boolean InMesh, notInters;
+ Standard_Integer nextedge;
+ Standard_Real ang, angref;
+ gp_XY vpivo, vedcur, voth;
+
+ while (pivo!=debut) {
+ nextedge=0;
+ if (PositiveOrientation) angref=RealFirst();
+ else angref=RealLast();
+ const BRepMesh_Vertex& vertPivo=GetVertex(pivo);
+ vpivo=vertPivo.Coord();
+ vpivo.Subtract(debEd.Coord());
+
+ itLiVer.Init(MeshData->LinkNeighboursOf(pivo));
+
+ // Find the next edge with the greatest angle with <indexEdg>
+ // and non intersecting <indexEdg> :
+
+ for (; itLiVer.More(); itLiVer.Next()) {
+ if (itLiVer.Value()!=curEdg) {
+ notInters=Standard_True;
+ const BRepMesh_Edge& nedg=GetEdge(itLiVer.Value());
+
+ InMesh=Standard_True;
+ if (nedg.Movability()==BRepMesh_Free) {
+ if (MeshData->ElemConnectedTo(itLiVer.Value()).IsEmpty())
+ InMesh=Standard_False;
+ }
+
+ if (InMesh) {
+ oth=nedg.FirstNode();
+ if (oth==pivo) oth=nedg.LastNode();
+
+ vedcur=GetVertex(oth).Coord();
+ vedcur.Subtract(vertPivo.Coord());
+ if (vedcur.Modulus() >= gp::Resolution() &&
+ ved1.Modulus() >= gp::Resolution()) {
+ if (prem!=debut && oth!=debut) {
+ voth=GetVertex(oth).Coord();
+ voth.Subtract(debEd.Coord());
+ if ((vedge^vpivo)*(vedge^voth)<0.) {
+ voth=vertPivo.Coord();
+ voth.Subtract(finEd.Coord());
+ if ((vedcur^vpivo)*(vedcur^voth)<0.)
+ notInters=Standard_False;
+ }
+ }
+
+ if (notInters) {
+ ang=gp_Vec2d(ved1).Angle(gp_Vec2d(vedcur));
+
+ if ((PositiveOrientation && ang>angref) ||
+ (!PositiveOrientation && ang<angref)) {
+ angref=ang;
+ ved2=vedcur;
+ if (nedg.FirstNode()==pivo) nextedge=itLiVer.Value();
+ else nextedge=-itLiVer.Value();
+ ders=oth;
+
+ //epa: Find correct closing not direct to
+ // link but with maximal angle
+ // otherwise, polygon greater that expected is found
+ //if (ders==debut) break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (nextedge!=0) {
+ if (Abs(nextedge)!=indexEdg && Abs(nextedge)!=curEdg) {
+ curEdg=Abs(nextedge);
+
+ if (!usedEdges.Add(curEdg)) {
+
+ //if this edge has already been added to the polygon,
+ //there is a risk of looping (attention to open contours)
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0)
+ cout << " MeshLeftPolygonOf : pas de fermeture du polygone !"
+ << endl;
+#endif
+
+ // all edges of the boundary contour are removed from the polygon
+ curEdg=Abs(polyg(polyg.Length()));
+ while (GetEdge(curEdg).Movability()==BRepMesh_Frontier){
+ polyg.Remove(polyg.Length());
+ if (polyg.Length()<=0) break;
+ curEdg=Abs(polyg(polyg.Length()));
+ }
+ return;
+ }
+
+ polyg.Append(nextedge);
+
+ Standard_Boolean forw=nextedge>0;
+ const BRepMesh_PairOfIndex& aPair = MeshData->ElemConnectedTo(curEdg);
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) {
+ const Standard_Integer elemId = aPair.Index(j);
+ GetTriangle(elemId).Edges(e1,e2,e3,o1,o2,o3);
+ if ((e1==curEdg && o1==forw) ||
+ (e2==curEdg && o2==forw) ||
+ (e3==curEdg && o3==forw)) {
+ DeleteTriangle(elemId, loopEdges);
+ break;
+ }
+ }
+ }
+ }
+ else {
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0)
+ cout << " MeshLeftPolygonOf : Pas de suivante !" << endl;
+#endif
+ return;
+ }
+ prem=pivo;
+ pivo=ders;
+ ved1=ved2;
+ }
+
+
+ // Destruction of unused free edges :
+ BRepMesh_MapOfIntegerInteger::Iterator itFE(loopEdges);
+
+ for (; itFE.More(); itFE.Next()) {
+ if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+ MeshData->RemoveLink(itFE.Key());
+ }
+
+ MeshPolygon(polyg);
+}
+
+
+//=======================================================================
+//function : MeshPolygon
+//purpose : Triangulatiion of a closed polygon described by the list of indexes of
+// its edges in the structure. (negative index == reversed)
+//=======================================================================
+void BRepMesh_Delaun::MeshPolygon (TColStd_SequenceOfInteger& poly)
+{
+ Standard_Integer vert, vert1, vert2, vert3 =0, tri;
+
+ if (poly.Length()==3) {
+ tri=MeshData->AddElement(BRepMesh_Triangle(Abs(poly(1)),Abs(poly(2)),Abs(poly(3)),
+ poly(1)>0, poly(2)>0, poly(3)>0,
+ BRepMesh_Free));
+ tCircles.MocAdd(tri);
+ const BRepMesh_Edge& edg1=GetEdge(Abs(poly(1)));
+ const BRepMesh_Edge& edg2=GetEdge(Abs(poly(2)));
+ if (poly(1)>0) {
+ vert1=edg1.FirstNode();
+ vert2=edg1.LastNode();
+ }
+ else {
+ vert1=edg1.LastNode();
+ vert2=edg1.FirstNode();
+ }
+ if (poly(2)>0)
+ vert3=edg2.LastNode();
+ else
+ vert3=edg2.FirstNode();
+
+ if (!tCircles.Add(GetVertex(vert1).Coord(),
+ GetVertex(vert2).Coord(),
+ GetVertex(vert3).Coord(),
+ tri)) {
+ MeshData->RemoveElement(tri);
+ }
+ }
+
+ else if (poly.Length()>3) {
+ const BRepMesh_Edge& edg=GetEdge(Abs(poly(1)));
+ Standard_Real distmin=RealLast();
+ Standard_Integer ip, used =0;
+
+ if (poly(1)>0) {
+ vert1=edg.FirstNode();
+ vert2=edg.LastNode();
+ }
+ else {
+ vert1=edg.LastNode();
+ vert2=edg.FirstNode();
+ }
+ gp_XY vedg(GetVertex(vert2).Coord()-
+ GetVertex(vert1).Coord());
+ Standard_Real modul=vedg.Modulus();
+ if (modul>0.) {
+ vedg.SetCoord(vedg.X()/modul, vedg.Y()/modul);
+
+ for (ip=3; ip<=poly.Length(); ip++) {
+ const BRepMesh_Edge& nedg=GetEdge(Abs(poly(ip)));
+ if (poly(ip)>0) vert=nedg.FirstNode();
+ else vert=nedg.LastNode();
+ gp_XY vep(GetVertex(vert).Coord()-GetVertex(vert2).Coord());
+
+ Standard_Real dist=vedg^vep;
+ if (Abs(dist)>Precision::PConfusion()) {
+ if ((dist>0. && PositiveOrientation) ||
+ (dist<0. && !PositiveOrientation)) {
+ if (Abs(dist)<distmin) {
+ distmin=dist;
+ vert3=vert;
+ used=ip;
+ }
+ }
+ }
+ }
+ }
+
+ Standard_Integer ne2, ne3;
+ if (distmin<RealLast()) {
+ ne2=MeshData->AddLink(BRepMesh_Edge(vert2, vert3, BRepMesh_Free));
+ ne3=MeshData->AddLink(BRepMesh_Edge(vert3, vert1, BRepMesh_Free));
+ tri=MeshData->AddElement(BRepMesh_Triangle(Abs(poly(1)), Abs(ne2), Abs(ne3),
+ (poly(1)>0), (ne2>0), (ne3>0),
+ BRepMesh_Free));
+
+ if (!tCircles.Add(GetVertex(vert1).Coord(),
+ GetVertex(vert2).Coord(),
+ GetVertex(vert3).Coord(),
+ tri)) {
+ MeshData->RemoveElement(tri);
+ }
+
+ if (used<poly.Length()) {
+ TColStd_SequenceOfInteger suitePoly;
+ poly.Split(used, suitePoly);
+ suitePoly.Prepend(-ne3);
+ MeshPolygon(suitePoly);
+ }
+ else
+ poly.Remove(poly.Length());
+
+ if (used>3) {
+ poly.SetValue(1, -ne2);
+ MeshPolygon(poly);
+ }
+ }
+ else {
+#ifdef TRIANGULATION_DEBUG
+ if (Triangulation_Trace>0) {
+ cout << " MeshPolygon : aucune possibilité !" << endl;
+ if (Triangulation_Trace==5) {
+ cout << " MeshPolygon : ";
+ for (vert=1; vert<=poly.Length(); vert++)
+ cout << poly(vert) << " ";
+ cout<<endl;
+ }
+ }
+#endif
+ }
+ }
+}
+
+//=======================================================================
+//function : SuperMesh
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::SuperMesh (const Bnd_Box2d& theBox)
+{
+ Standard_Real xMin, yMin, xMax, yMax;
+ theBox.Get(xMin, yMin, xMax, yMax);
+ Standard_Real deltax=xMax-xMin;
+ Standard_Real deltay=yMax-yMin;
+
+ Standard_Real deltaMin=Min(deltax, deltay);
+ Standard_Real deltaMax=Max(deltax, deltay);
+ Standard_Real delta=deltax+deltay;
+ tCircles.SetMinMaxSize(gp_XY(xMin, yMin), gp_XY(xMax, yMax));
+
+ Standard_Integer koeff = 2;
+ if(MeshData->NbNodes()>100)
+ koeff = 5;
+ else if(MeshData->NbNodes()>1000)
+ koeff = 7;
+
+ tCircles.SetCellSize(deltax/koeff, deltay/koeff);
+
+ supVert1=MeshData->AddNode(BRepMesh_Vertex((xMin+xMax)/2, yMax+deltaMax, BRepMesh_Free));
+ supVert2=MeshData->AddNode(BRepMesh_Vertex(xMin-delta, yMin-deltaMin, BRepMesh_Free));
+ supVert3=MeshData->AddNode(BRepMesh_Vertex(xMax+delta, yMin-deltaMin, BRepMesh_Free));
+
+ Standard_Integer niver;
+ if (!PositiveOrientation) {
+ niver=supVert2;
+ supVert2=supVert3;
+ supVert3=niver;
+ }
+
+ Standard_Integer
+ ed1=MeshData->AddLink(BRepMesh_Edge(supVert1,supVert2,BRepMesh_Free));
+ Standard_Integer
+ ed2=MeshData->AddLink(BRepMesh_Edge(supVert2,supVert3,BRepMesh_Free));
+ Standard_Integer
+ ed3=MeshData->AddLink(BRepMesh_Edge(supVert3,supVert1,BRepMesh_Free));
+ supTrian=BRepMesh_Triangle(Abs(ed1), Abs(ed2), Abs(ed3),
+ (ed1>0), (ed2>0), (ed3>0), BRepMesh_Free);
+}
+
+
+//=======================================================================
+//function : CreateTriangles
+//purpose : Creation of triangles from the current node and free edges
+// and deletion of these edges in the list :
+//=======================================================================
+void BRepMesh_Delaun::CreateTriangles (const Standard_Integer theVertexIndex,
+ BRepMesh_MapOfIntegerInteger& theEdges)
+{
+ BRepMesh_MapOfIntegerInteger::Iterator itFE(theEdges);
+ Standard_Real z12, z23, modul;
+ Standard_Integer ne1, ne3, nt;
+ gp_XY vl1, vl2, vl3;
+ ListOfInteger EdgLoop, EdgOK, EdgExter;
+
+ const gp_XY& VertexCoord = MeshData->GetNode(theVertexIndex).Coord();
+ for (; itFE.More(); itFE.Next()) {
+ const BRepMesh_Edge& edg=GetEdge(itFE.Key());
+ Standard_Integer deb=edg.FirstNode();
+ Standard_Integer fin=edg.LastNode();
+ Standard_Boolean sens=(Standard_Boolean)theEdges(itFE.Key());
+ if (!sens) {
+ nt=deb;
+ deb=fin;
+ fin=nt;
+ }
+
+ const BRepMesh_Vertex& debVert=GetVertex(deb);
+ const BRepMesh_Vertex& finVert=GetVertex(fin);
+
+ vl1=debVert.Coord();
+ vl1.Subtract(VertexCoord);
+ vl2=finVert.Coord();
+ vl2.Subtract(debVert.Coord());
+ // vl3=theVertex.Coord();
+ vl3=VertexCoord;
+ vl3.Subtract(finVert.Coord());
+
+ z12=z23=0.;
+ modul=vl2.Modulus();
+ if (modul>Precision::PConfusion()) {
+ vl2.SetCoord(vl2.X()/modul, vl2.Y()/modul);
+ z12=vl1^vl2;
+ z23=vl2^vl3;
+ }
+
+ if (Abs(z12)>=Precision::PConfusion() &&
+ Abs(z23)>=Precision::PConfusion()) {
+ Standard_Boolean sensOK;
+ if (PositiveOrientation) sensOK=(z12>0. && z23>0.);
+ else sensOK=(z12<0. && z23<0.);
+ if (sensOK) {
+ ne1=MeshData->AddLink(BRepMesh_Edge(theVertexIndex, deb, BRepMesh_Free));
+ ne3=MeshData->AddLink(BRepMesh_Edge(fin, theVertexIndex, BRepMesh_Free));
+ nt=MeshData->AddElement(BRepMesh_Triangle(Abs(ne1), itFE.Key(), Abs(ne3),
+ (ne1>0), sens, (ne3>0),
+ BRepMesh_Free));
+
+ if (!tCircles.Add(VertexCoord,
+ debVert.Coord(),
+ finVert.Coord(), nt))
+ MeshData->RemoveElement(nt);
+ }
+ else {
+
+ if (sens) EdgLoop.Append(itFE.Key());
+ else EdgLoop.Append(-itFE.Key());
+ if (vl1.SquareModulus()>vl3.SquareModulus()) {
+ ne1=MeshData->AddLink(BRepMesh_Edge(theVertexIndex, deb, BRepMesh_Free));
+ EdgExter.Append(Abs(ne1));
+ }
+ else{
+ ne3=MeshData->AddLink(BRepMesh_Edge(fin, theVertexIndex, BRepMesh_Free));
+ EdgExter.Append(Abs(ne3));
+ }
+ }
+ }
+#ifdef TRIANGULATION_DEBUG
+ else {
+ if (Triangulation_Trace>0)
+ cout << " CreateTriangles : produit vectoriel trop petit !" << endl;
+ }
+#endif
+ }
+ theEdges.Clear();
+ while (!EdgExter.IsEmpty()) {
+ const BRepMesh_PairOfIndex& conx = MeshData->ElemConnectedTo(Abs(EdgExter.First()));
+ if (!conx.IsEmpty())
+ DeleteTriangle(conx.FirstIndex(), theEdges);
+ EdgExter.RemoveFirst();
+ }
+
+ for (itFE.Initialize(theEdges); itFE.More(); itFE.Next()) {
+ if (MeshData->ElemConnectedTo(itFE.Key()).IsEmpty())
+ MeshData->RemoveLink(itFE.Key());
+ }
+
+ while (!EdgLoop.IsEmpty()) {
+ if (GetEdge(Abs(EdgLoop.First())).Movability()!=BRepMesh_Deleted) {
+ MeshLeftPolygonOf(Abs(EdgLoop.First()), (EdgLoop.First()>0));
+ }
+ EdgLoop.RemoveFirst();
+ }
+}
+
+//=======================================================================
+//function : DeleteTriangle
+//purpose : The concerned triangles are deleted and the freed edges are added in
+// <loopEdges>. If an edge is added twice, it does not exist and
+// it is necessary to destroy it. This corresponds to the destruction of two
+// connected triangles.
+//=======================================================================
+
+void BRepMesh_Delaun::DeleteTriangle (const Standard_Integer tIndex,
+ BRepMesh_MapOfIntegerInteger& fEdges)
+{
+ tCircles.Delete(tIndex);
+
+ Standard_Integer fe1, fe2, fe3;
+ Standard_Boolean or1, or2, or3;
+ GetTriangle(tIndex).Edges(fe1, fe2, fe3, or1, or2, or3);
+ MeshData->RemoveElement(tIndex);
+
+ if (!fEdges.Bind(fe1, or1)) {
+ fEdges.UnBind(fe1);
+ MeshData->RemoveLink(fe1);
+ }
+ if (!fEdges.Bind(fe2, or2)) {
+ fEdges.UnBind(fe2);
+ MeshData->RemoveLink(fe2);
+ }
+ if (!fEdges.Bind(fe3, or3)) {
+ fEdges.UnBind(fe3);
+ MeshData->RemoveLink(fe3);
+ }
+
+}
+
+
+//=======================================================================
+//function : AddVertex
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::AddVertex(const BRepMesh_Vertex& theVert)
+{
+ Standard_Integer nv = MeshData->AddNode(theVert);
+
+ // Iterator in the list of indexes of circles containing the node :
+ BRepMesh_ListOfInteger& cirL=tCircles.Select(theVert.Coord());
+
+ Standard_Integer edgon=0;
+ Standard_Integer triPer=0;
+ Standard_Integer e1, e2, e3;
+ Standard_Boolean o1, o2, o3;
+
+ BRepMesh_ListOfInteger::Iterator itT(cirL);
+ for (; itT.More(); itT.Next()) {
+
+ // To add a node in the mesh it is necessary to check conditions:
+ // - the node should be within the boundaries of the mesh and so in an existing triangle
+ // - all adjacent triangles should belong to a component connected with this triangle
+ if (Contains(itT.Value(), theVert, edgon)) {
+ if (edgon==0) {
+ triPer=itT.Value();
+ cirL.Remove(itT);
+ break;
+ }
+ else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
+ triPer=itT.Value();
+ cirL.Remove(itT);
+ break;
+ }
+ }
+ }
+
+ if (triPer>0) {
+
+ BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
+ DeleteTriangle(triPer, loopEdges);
+
+ Standard_Boolean modif=Standard_True;
+ while (modif && !cirL.IsEmpty()) {
+ modif=Standard_False;
+ BRepMesh_ListOfInteger::Iterator itT1(cirL);
+ for (; itT1.More(); itT1.Next()) {
+ GetTriangle(itT.Value()).Edges(e1,e2,e3,o1,o2,o3);
+ if (loopEdges.IsBound(e1) ||
+ loopEdges.IsBound(e2) ||
+ loopEdges.IsBound(e3)) {
+ modif=Standard_True;
+ DeleteTriangle(itT1.Value(), loopEdges);
+ cirL.Remove(itT1);
+ break;
+ }
+ }
+ }
+
+ // Creation of triangles with the current node and free edges
+ // and removal of these edges from the list of free edges
+ CreateTriangles(nv, loopEdges);
+
+ // Check that internal edges are not crossed by the triangles
+ BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
+
+ // Destruction of triangles crossing internal edges and
+ // their replacement by makeshift triangles
+ Standard_Integer nbc;
+ itFr.Reset();
+ for (; itFr.More(); itFr.Next()) {
+ nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
+ if (nbc == 0) {
+ MeshLeftPolygonOf(itFr.Key(), Standard_True);
+ MeshLeftPolygonOf(itFr.Key(), Standard_False);
+ }
+ }
+
+ FrontierAdjust();
+
+ }
+
+}
+
+//=======================================================================
+//function : RemoveVertex
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::RemoveVertex(const BRepMesh_Vertex& theVert)
+{
+ BRepMesh_SelectorOfDataStructureOfDelaun select(MeshData);
+ select.NeighboursOf(theVert);
+
+ BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
+
+ // Loop on triangles to be destroyed :
+ BRepMesh_MapOfInteger::Iterator trs(select.Elements());
+ for (;trs.More(); trs.Next()) {
+ DeleteTriangle(trs.Key(), loopEdges);
+ }
+
+ TColStd_SequenceOfInteger polyg;
+ Standard_Integer iv;
+ Standard_Integer nbLi=loopEdges.Extent();
+ BRepMesh_MapOfIntegerInteger::Iterator itFE(loopEdges);
+
+ if (itFE.More()) {
+ const BRepMesh_Edge& edg=GetEdge(itFE.Key());
+ Standard_Integer deb=edg.FirstNode();
+ Standard_Integer fin;
+ Standard_Integer pivo=edg.LastNode();
+ Standard_Integer iseg=itFE.Key();
+ Standard_Boolean sens=(Standard_Boolean)loopEdges(iseg);
+ if (!sens) {
+ iv=deb;
+ deb=pivo;
+ pivo=iv;
+ polyg.Append(-iseg);
+ }
+ else {
+ polyg.Append(iseg);
+ }
+ loopEdges.UnBind(iseg);
+ fin=deb;
+ BRepMesh_ListOfInteger::Iterator itLiV;
+ Standard_Integer vcur;
+ while (pivo!=fin) {
+ itLiV.Init(MeshData->LinkNeighboursOf(pivo));
+ for (; itLiV.More(); itLiV.Next()) {
+ if (itLiV.Value()!=iseg && loopEdges.IsBound(itLiV.Value())) {
+ iseg=itLiV.Value();
+ const BRepMesh_Edge& edg1=GetEdge(iseg);
+ vcur=edg1.LastNode();
+ if (vcur!=pivo) {
+ vcur=edg1.FirstNode();
+ polyg.Append(-iseg);
+ }
+ else
+ polyg.Append(iseg);
+ pivo=vcur;
+ loopEdges.UnBind(iseg);
+ break;
+ }
+ }
+ if (nbLi<=0) break;
+ nbLi--;
+ }
+ MeshPolygon(polyg);
+ }
+}
+
+
+//=======================================================================
+//function : AddVertices
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::AddVertices(BRepMesh_Array1OfVertexOfDelaun& vertices)
+{
+ BRepMesh_HeapSortVertexOfDelaun::Sort
+ (vertices,
+ BRepMesh_ComparatorOfVertexOfDelaun(SortingDirection, Precision::PConfusion()));
+
+ BRepMesh_MapOfIntegerInteger loopEdges(10,MeshData->Allocator());
+ Standard_Boolean modif=Standard_True;
+ Standard_Integer edgon, triPer;
+ Standard_Integer e1, e2, e3;
+ Standard_Boolean o1, o2, o3;
+
+ Standard_Integer niver;
+ Standard_Integer aIdxVert;
+ for (niver=vertices.Lower(); niver<=vertices.Upper(); niver++) {
+ aIdxVert = MeshData->AddNode(vertices(niver));
+
+ // Iterator in the list of indexes of circles containing the node
+ BRepMesh_ListOfInteger& cirL=tCircles.Select(vertices(niver).Coord());
+
+ edgon=0;
+ triPer=0;
+
+ BRepMesh_ListOfInteger::Iterator itT(cirL);
+ for (; itT.More(); itT.Next()) {
+
+ // To add a node in the mesh it is necessary to check conditions:
+ // - the node should be within the boundaries of the mesh and so in an existing triangle
+ // - all adjacent triangles should belong to a component connected with this triangle
+ if (Contains(itT.Value(), vertices(niver), edgon)) {
+ if (edgon==0) {
+ triPer=itT.Value();
+ cirL.Remove(itT);
+ break;
+ }
+ else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
+ triPer=itT.Value();
+ cirL.Remove(itT);
+ break;
+ }
+ }
+ }
+
+ if (triPer>0) {
+ DeleteTriangle(triPer, loopEdges);
+
+ modif=Standard_True;
+ while (modif && !cirL.IsEmpty()) {
+ modif=Standard_False;
+ BRepMesh_ListOfInteger::Iterator itT1(cirL);
+ for (; itT1.More(); itT1.Next()) {
+ GetTriangle(itT1.Value()).Edges(e1,e2,e3,o1,o2,o3);
+ if (loopEdges.IsBound(e1) ||
+ loopEdges.IsBound(e2) ||
+ loopEdges.IsBound(e3)) {
+ modif=Standard_True;
+ DeleteTriangle(itT1.Value(), loopEdges);
+ cirL.Remove(itT1);
+ break;
+ }
+ }
+ }
+
+ // Creation of triangles with the current node and free edges
+ // and removal of these edges from the list of free edges
+ CreateTriangles(aIdxVert, loopEdges);
+ }
+ }
+
+ // Check that internal edges are not crossed by triangles
+ BRepMesh_MapOfInteger::Iterator itFr(InternalEdges());
+
+ // Destruction of triangles crossing internal edges
+ //and their replacement by makeshift triangles
+ Standard_Integer nbc;
+ itFr.Reset();
+ for (; itFr.More(); itFr.Next()) {
+ nbc = MeshData->ElemConnectedTo(itFr.Key()).Extent();
+ if (nbc == 0) {
+ MeshLeftPolygonOf(itFr.Key(), Standard_True);
+ MeshLeftPolygonOf(itFr.Key(), Standard_False);
+ }
+ }
+
+ // Adjustment of meshes to boundary edges
+ FrontierAdjust();
+}
+
+
+//=======================================================================
+//function : RevertDiagonal
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_Delaun::RevertDiagonal(const Standard_Integer ind)
+{
+ const BRepMesh_PairOfIndex& elConx = MeshData->ElemConnectedTo(ind);
+ const BRepMesh_Edge& lEdge = GetEdge(ind);
+ if (elConx.Extent()==2 && lEdge.Movability()==BRepMesh_Free) {
+ Standard_Integer t1(elConx.FirstIndex());
+ Standard_Integer t2(elConx.LastIndex());
+
+ Standard_Integer e1t1, e2t1, e3t1, e1t2, e2t2, e3t2 ;
+ Standard_Boolean o1t1, o2t1, o3t1, o1t2, o2t2, o3t2;
+#ifndef DEB
+ Standard_Integer ed13=0, ed23=0, ed14=0, ed24=0, v1, v2, v3=0, v4=0, vc1;
+ Standard_Boolean oindt1=Standard_False, or13=Standard_False,
+ or23=Standard_False, or14=Standard_False, or24=Standard_False, orien;
+#else
+ Standard_Integer ed13, ed23, ed14, ed24, v1, v2, v3, v4, vc1;
+ Standard_Boolean oindt1, or13, or23, or14, or24, orien;
+#endif
+ GetTriangle(t1).Edges(e1t1, e2t1, e3t1, o1t1, o2t1, o3t1);
+ GetTriangle(t2).Edges(e1t2, e2t2, e3t2, o1t2, o2t2, o3t2);
+
+ v1=lEdge.FirstNode(); v2=lEdge.LastNode();
+ if (e1t1==ind) {
+ if (o2t1) v3 =GetEdge(e2t1).LastNode();
+ else v3 =GetEdge(e2t1).FirstNode();
+ ed13=e3t1; ed23=e2t1;
+ or13=o3t1; or23=o2t1;
+ oindt1=o1t1;
+ }
+ else if (e2t1==ind) {
+ if (o3t1) v3 =GetEdge(e3t1).LastNode();
+ else v3 =GetEdge(e3t1).FirstNode();
+ ed13=e1t1; ed23=e3t1;
+ or13=o1t1; or23=o3t1;
+ oindt1=o2t1;
+ }
+ else if (e3t1==ind) {
+ if (o1t1) v3 =GetEdge(e1t1).LastNode();
+ else v3 =GetEdge(e1t1).FirstNode();
+ ed13=e2t1; ed23=e1t1;
+ or13=o2t1; or23=o1t1;
+ oindt1=o3t1;
+ }
+ if (e1t2==ind) {
+ if (o2t2) v4 =GetEdge(e2t2).LastNode();
+ else v4 =GetEdge(e2t2).FirstNode();
+ ed14=e2t2; ed24=e3t2;
+ or14=o2t2; or24=o3t2;
+ }
+ else if (e2t2==ind) {
+ if (o3t2) v4 =GetEdge(e3t2).LastNode();
+ else v4 =GetEdge(e3t2).FirstNode();
+ ed14=e3t2; ed24=e1t2;
+ or14=o3t2; or24=o1t2;
+ }
+ else if (e3t2==ind) {
+ if (o1t2) v4 =GetEdge(e1t2).LastNode();
+ else v4 =GetEdge(e1t2).FirstNode();
+ ed14=e1t2; ed24=e2t2;
+ or14=o1t2; or24=o2t2;
+ }
+ if (!oindt1) {
+ vc1=v3; v3=v4; v4=vc1;
+ vc1=ed13; ed13=ed24; ed24=vc1;
+ orien =or13; or13=or24; or24=orien ;
+ vc1=ed14; ed14=ed23; ed23=vc1;
+ orien =or14; or14=or23; or23=orien ;
+ }
+ const BRepMesh_Vertex& vert1 = GetVertex(v1);
+ const BRepMesh_Vertex& vert2 = GetVertex(v2);
+ const BRepMesh_Vertex& vert3 = GetVertex(v3);
+ const BRepMesh_Vertex& vert4 = GetVertex(v4);
+
+ gp_XY ved13(vert1.Coord()); ved13.Subtract(vert3.Coord());
+ gp_XY ved14(vert4.Coord()); ved14.Subtract(vert1.Coord());
+ gp_XY ved23(vert3.Coord()); ved23.Subtract(vert2.Coord());
+ gp_XY ved24(vert2.Coord()); ved24.Subtract(vert4.Coord());
+
+ Standard_Real z13, z24, modul;
+ z13=z24=0.;
+ modul=ved13.Modulus();
+ if (modul>Precision::PConfusion()) {
+ ved13.SetCoord(ved13.X()/modul, ved13.Y()/modul);
+ z13=ved13^ved14;
+ }
+ modul=ved24.Modulus();
+ if (modul>Precision::PConfusion()) {
+ ved24.SetCoord(ved24.X()/modul, ved24.Y()/modul);
+ z24=ved24^ved23;
+ }
+
+ if (Abs(z13)>=Precision::PConfusion()&&Abs(z24)>=Precision::PConfusion()) {
+ if ((z13>0. && z24>0.) || (z13<0. && z24<0.)) {
+ tCircles.Delete(t1);
+ tCircles.Delete(t2);
+ if (!tCircles.Add(vert4.Coord(), vert2.Coord(), vert3.Coord(), t1) &&
+ !tCircles.Add(vert3.Coord(), vert1.Coord(), vert4.Coord(), t2)) {
+ Standard_Integer newd=ind;
+ BRepMesh_Edge newEdg=BRepMesh_Edge(v3, v4, BRepMesh_Free);
+ if (!MeshData->SubstituteLink(newd, newEdg)) {
+ newd=MeshData->IndexOf(newEdg);
+ MeshData->RemoveLink(ind);
+ }
+ MeshData->SubstituteElement(t1, BRepMesh_Triangle(ed24, ed23, newd,
+ or24, or23, Standard_True,
+ BRepMesh_Free));
+ MeshData->SubstituteElement(t2, BRepMesh_Triangle(ed13, ed14, newd,
+ or13, or14, Standard_False,
+ BRepMesh_Free));
+ return Standard_True;
+ }
+ else {
+ if (oindt1) {
+ tCircles.Add(vert1.Coord(), vert2.Coord(), vert3.Coord(), t1);
+ tCircles.Add(vert2.Coord(), vert1.Coord(), vert4.Coord(), t2);
+ }
+ else {
+ tCircles.Add(vert1.Coord(), vert2.Coord(), vert3.Coord(), t2);
+ tCircles.Add(vert2.Coord(), vert1.Coord(), vert4.Coord(), t1);
+ }
+ }
+ }
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : UseEdge
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_Delaun::UseEdge(const Standard_Integer ind)
+{
+ const BRepMesh_PairOfIndex& elConx=MeshData->ElemConnectedTo(ind);
+ if (elConx.Extent()==0) {
+ const BRepMesh_Edge& lEdge = GetEdge(ind);
+ Standard_Integer vdeb, pivo, othV, leftEdge, rightEdge;
+ vdeb=lEdge.FirstNode();
+ pivo=lEdge.LastNode();
+ const BRepMesh_ListOfInteger& neigVDeb = MeshData->LinkNeighboursOf(vdeb);
+ const BRepMesh_ListOfInteger& neigPivo = MeshData->LinkNeighboursOf(pivo);
+ if (neigVDeb.Extent()>0 && neigPivo.Extent()>0) {
+ const BRepMesh_Vertex& vertDeb=GetVertex(vdeb);
+ const BRepMesh_Vertex& vertPivo=GetVertex(pivo);
+
+ gp_XY vedcur;
+ gp_XY vedge(vertPivo.Coord());
+ vedge.Subtract(vertDeb.Coord());
+
+ BRepMesh_ListOfInteger::Iterator itNeig(neigPivo);
+#ifndef DEB
+ Standard_Real ang =0.;
+#else
+ Standard_Real ang;
+#endif
+ Standard_Real angMin=RealLast();
+ Standard_Real angMax=RealFirst();
+ Standard_Boolean InMesh;
+ leftEdge=rightEdge=0;
+
+ for (; itNeig.More(); itNeig.Next()) {
+ if (itNeig.Value()!=ind) {
+ const BRepMesh_Edge& nedg=GetEdge(itNeig.Value());
+
+ InMesh=Standard_True;
+ if (nedg.Movability()==BRepMesh_Free) {
+ if (MeshData->ElemConnectedTo(itNeig.Value()).IsEmpty())
+ InMesh=Standard_False;
+ }
+
+ if (InMesh) {
+ othV=nedg.FirstNode();
+ if (othV==pivo) othV=nedg.LastNode();
+
+ vedcur=GetVertex(othV).Coord();
+ vedcur.Subtract(vertPivo.Coord());
+
+ ang=gp_Vec2d(vedge).Angle(gp_Vec2d(vedcur));
+ }
+ if (ang>angMax) {
+ angMax=ang;
+ leftEdge=itNeig.Value();
+ }
+ if (ang<angMin) {
+ angMin=ang;
+ rightEdge=itNeig.Value();
+ }
+ }
+ }
+ if (leftEdge>0) {
+ if (leftEdge==rightEdge) {
+ }
+ else {
+ }
+ }
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : SmoothMesh
+//purpose :
+//=======================================================================
+void BRepMesh_Delaun::SmoothMesh(const Standard_Real Epsilon)
+{
+ Standard_Integer baryVert, polyVert, nbPolyVert;
+ Standard_Real uSom, vSom, newU, newV;
+ Standard_Integer nbVert=MeshData->NbNodes();
+ BRepMesh_ListOfInteger::Iterator itNeig;
+
+ uSom=vSom=0;
+ for (baryVert=1; baryVert<=nbVert; baryVert++) {
+ const BRepMesh_Vertex& curVert=GetVertex(baryVert);
+ if (curVert.Movability()==BRepMesh_Free) {
+ const BRepMesh_ListOfInteger& neighEdg=MeshData->LinkNeighboursOf(baryVert);
+ if (neighEdg.Extent()>2) {
+ nbPolyVert=0;
+ for (itNeig.Init(neighEdg); itNeig.More(); itNeig.Next()) {
+ const BRepMesh_Edge& nedg=GetEdge(itNeig.Value());
+ polyVert=nedg.FirstNode();
+ if (polyVert==baryVert) polyVert=nedg.LastNode();
+ nbPolyVert++;
+ const gp_XY& pVal = GetVertex(polyVert).Coord();
+ uSom+=pVal.X();
+ vSom+=pVal.Y();
+ }
+ if (nbPolyVert>2) {
+ newU=uSom/(Standard_Real)nbPolyVert;
+ newV=vSom/(Standard_Real)nbPolyVert;
+ if (!curVert.Coord().IsEqual(gp_XY(newU, newV), Epsilon)) {
+ BRepMesh_Vertex newVert(newU, newV, curVert.Movability());
+ MeshData->MoveNode(baryVert, newVert);
+ }
+ }
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : Result
+//purpose :
+//=======================================================================
+const Handle(BRepMesh_DataStructureOfDelaun)& BRepMesh_Delaun::Result()const
+{
+ return MeshData;
+}
+
+//=======================================================================
+//function : Frontier
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_Delaun::Frontier ()
+{
+ BRepMesh_MapOfInteger::Iterator triDom(MeshData->LinkOfDomain());
+
+ mapEdges.Clear();
+ for (; triDom.More(); triDom.Next()) {
+ if (GetEdge(triDom.Key()).Movability()==BRepMesh_Frontier) {
+ mapEdges.Add(triDom.Key());
+ }
+ }
+ return mapEdges;
+}
+
+//=======================================================================
+//function : InternalEdges
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_Delaun::InternalEdges ()
+{
+ BRepMesh_MapOfInteger::Iterator triDom(MeshData->LinkOfDomain());
+
+ mapEdges.Clear();
+ for (; triDom.More(); triDom.Next()) {
+ if (GetEdge(triDom.Key()).Movability()==BRepMesh_Fixed) {
+ mapEdges.Add(triDom.Key());
+ }
+ }
+ return mapEdges;
+}
+
+//=======================================================================
+//function : FreeEdges
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_Delaun::FreeEdges ()
+{
+ BRepMesh_MapOfInteger::Iterator triDom(MeshData->LinkOfDomain());
+
+ mapEdges.Clear();
+ for (; triDom.More(); triDom.Next()) {
+ if (MeshData->ElemConnectedTo(triDom.Key()).Extent()<=1) {
+ mapEdges.Add(triDom.Key());
+ }
+ }
+ return mapEdges;
+}
+
+
+//=======================================================================
+//function : Contains
+//purpose :
+//=======================================================================
+Standard_Boolean BRepMesh_Delaun::Contains(const Standard_Integer tri,
+ const BRepMesh_Vertex& vert,
+ Standard_Integer& edgOn)const
+{
+ edgOn=0;
+ Standard_Integer e1, e2, e3, p1, p2, p3;
+ Standard_Boolean o1, o2, o3;
+ GetTriangle(tri).Edges(e1, e2, e3, o1, o2, o3);
+ const BRepMesh_Edge& edg1=GetEdge(e1);
+ const BRepMesh_Edge& edg2=GetEdge(e2);
+ const BRepMesh_Edge& edg3=GetEdge(e3);
+ if (o1) {
+ p1=edg1.FirstNode();
+ p2=edg1.LastNode();
+ }
+ else {
+ p2=edg1.FirstNode();
+ p1=edg1.LastNode();
+ }
+ if (o3) p3=edg3.FirstNode();
+ else p3=edg3.LastNode();
+
+ const gp_XY& P1=GetVertex(p1).Coord();
+ const gp_XY& P2=GetVertex(p2).Coord();
+ const gp_XY& P3=GetVertex(p3).Coord();
+ gp_XY E1(P2); E1.Subtract(P1);
+ gp_XY E2(P3); E2.Subtract(P2);
+ gp_XY E3(P1); E3.Subtract(P3);
+
+ Standard_Real mode1=E1.SquareModulus();
+ //Standard_Real dist=Sqrt(mode1);
+ if (mode1<=EPSEPS) return Standard_False;
+ Standard_Real v1=E1^(vert.Coord()-P1);
+ Standard_Real distMin=(v1*v1)/mode1;
+ edgOn=e1;
+
+ Standard_Real mode2=E2.SquareModulus();
+ Standard_Real dist;
+ //dist=Sqrt(mode2);
+ if (mode2<=EPSEPS) return Standard_False;
+ Standard_Real v2=E2^(vert.Coord()-P2);
+ dist=(v2*v2)/mode2;
+ if (dist<distMin) {
+ edgOn=e2;
+ distMin=dist;
+ }
+
+ Standard_Real mode3=E3.SquareModulus();
+ //dist=Sqrt(mode3);
+ if (mode3<=EPSEPS) return Standard_False;
+ Standard_Real v3=E3^(vert.Coord()-P3);
+ dist=(v3*v3)/mode3;
+ if (dist<distMin) {
+ edgOn=e3;
+ distMin=dist;
+ }
+
+ if (distMin>EPSEPS) {
+ Standard_Integer edf=edgOn;
+ edgOn=0;
+ if (edf==e1 && edg1.Movability()!=BRepMesh_Free) {
+ if (v1<(mode1/5.)) edgOn=e1;
+ }
+ else if (edf==e2 && edg2.Movability()!=BRepMesh_Free) {
+ if (v2<(mode2/5.)) edgOn=e2;
+ }
+ else if (edf==e3 && edg3.Movability()!=BRepMesh_Free) {
+ if (v3<(mode3/5.)) edgOn=e3;
+ }
+ }
+
+ return (v1+v2+v3!=0. &&((v1>=0. && v2>=0. && v3>=0.) ||
+ (v1<=0. && v2<=0. && v3<=0.)));
+}
+
+//=======================================================================
+//function : TriangleContaining
+//purpose :
+//=======================================================================
+Standard_Integer BRepMesh_Delaun::TriangleContaining(const BRepMesh_Vertex& vert)
+{
+ const BRepMesh_ListOfInteger& cirL=tCircles.Select(vert.Coord());
+
+ BRepMesh_ListOfInteger::Iterator itT(cirL);
+ Standard_Integer triPer=0;
+ Standard_Integer edgon=0;
+ for (; itT.More(); itT.Next()) {
+ if (Contains(itT.Value(), vert, edgon)) {
+ if (edgon==0) {
+ triPer=itT.Value();
+ break;
+ }
+ else if (GetEdge(edgon).Movability()==BRepMesh_Free) {
+ triPer=itT.Value();
+ break;
+ }
+ }
+ }
+ return triPer;
+}
--- /dev/null
+// File: BRepMesh_Delaun.lxx
+// Created: Thu Aug 19 10:52:01 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+
+#include <BRepMesh_DataStructureOfDelaun.hxx>
+
+inline const BRepMesh_Vertex& BRepMesh_Delaun::GetVertex
+(const Standard_Integer vIndex) const
+{
+ return MeshData->GetNode(vIndex);
+}
+
+
+inline const BRepMesh_Edge& BRepMesh_Delaun::GetEdge
+(const Standard_Integer eIndex) const
+{
+ return MeshData->GetLink(eIndex);
+}
+
+
+inline const BRepMesh_Triangle& BRepMesh_Delaun::GetTriangle
+(const Standard_Integer tIndex) const
+{
+ return MeshData->GetElement(tIndex);
+}
--- File: BRepMesh_Edge.cdl
--- Created: Wed Sep 22 18:07:31 1993
--- Author: Didier PIFFAULT
--- <dpf@zerox>
----Copyright: Matra Datavision 1993
+-- File: BRepMesh_Edge.cdl
+-- Created: Wed Sep 22 18:07:31 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993
class Edge from BRepMesh
- ---Purpose:
+ ---Purpose:
uses Boolean from Standard,
- Integer from Standard,
- DegreeOfFreedom from MeshDS
+ Integer from Standard,
+ DegreeOfFreedom from BRepMesh
-is Create (vDebut : Integer from Standard;
- vFin : Integer from Standard;
- canMove : DegreeOfFreedom from MeshDS)
- ---Purpose: Contructs a link beetween to vertices.
- returns Edge from BRepMesh;
+is Create (vDebut : Integer from Standard;
+ vFin : Integer from Standard;
+ canMove : DegreeOfFreedom from BRepMesh)
+ ---Purpose: Contructs a link beetween to vertices.
+ returns Edge from BRepMesh;
- FirstNode (me)
- ---Purpose: Give the index of first node of the Link.
- ---C++: inline
- returns Integer from Standard
- is static;
+ FirstNode (me)
+ ---Purpose: Give the index of first node of the Link.
+ ---C++: inline
+ returns Integer from Standard
+ is static;
- LastNode (me)
- ---Purpose: Give the index of Last node of the Link.
- ---C++: inline
- returns Integer from Standard
- is static;
+ LastNode (me)
+ ---Purpose: Give the index of Last node of the Link.
+ ---C++: inline
+ returns Integer from Standard
+ is static;
- Movability (me)
- ---C++: inline
- returns DegreeOfFreedom from MeshDS
- is static;
+ Movability (me)
+ ---C++: inline
+ returns DegreeOfFreedom from BRepMesh
+ is static;
- SetMovability (me : in out;
- Move : DegreeOfFreedom from MeshDS)
- is static;
+ SetMovability (me : in out;
+ Move : DegreeOfFreedom from BRepMesh)
+ is static;
- HashCode (me;
- Upper : Integer from Standard)
- returns Integer from Standard
- ---C++: function call
- is static;
+ HashCode (me;
+ Upper : Integer from Standard)
+ returns Integer from Standard
+ ---C++: function call
+ is static;
- SameOrientation(me; Other : Edge from BRepMesh)
- returns Boolean from Standard
- is static;
+ SameOrientation(me; Other : Edge from BRepMesh)
+ returns Boolean from Standard
+ is static;
- IsEqual (me; Other : Edge from BRepMesh)
- returns Boolean from Standard
- ---C++: alias operator ==
- is static;
+ IsEqual (me; Other : Edge from BRepMesh)
+ returns Boolean from Standard
+ ---C++: alias operator ==
+ is static;
-fields myFirstNode : Integer from Standard;
- myLastNode : Integer from Standard;
- myMovability : DegreeOfFreedom from MeshDS;
+ fields myFirstNode : Integer from Standard;
+ myLastNode : Integer from Standard;
+ myMovability : DegreeOfFreedom from BRepMesh;
-end Edge;
+ end Edge;
-// File: BRepMesh_Edge.cxx
-// Created: Thu Sep 23 13:39:58 1993
-// Author: Didier PIFFAULT
-// <dpf@zerox>
-
+// File: BRepMesh_Edge.cxx
+// Created: Thu Sep 23 13:39:58 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
#include <BRepMesh_Edge.ixx>
-
+
BRepMesh_Edge::BRepMesh_Edge(const Standard_Integer vDebut,
- const Standard_Integer vFin,
- const MeshDS_DegreeOfFreedom canMove)
- : myFirstNode(vDebut), myLastNode(vFin), myMovability(canMove)
+ const Standard_Integer vFin,
+ const BRepMesh_DegreeOfFreedom canMove)
+ : myFirstNode(vDebut), myLastNode(vFin), myMovability(canMove)
{}
-void BRepMesh_Edge::SetMovability(const MeshDS_DegreeOfFreedom Move)
+void BRepMesh_Edge::SetMovability(const BRepMesh_DegreeOfFreedom Move)
{
myMovability =Move;
}
Standard_Boolean BRepMesh_Edge::IsEqual(const BRepMesh_Edge& Other)const
{
- if (myMovability==MeshDS_Deleted || Other.myMovability==MeshDS_Deleted)
+ if (myMovability==BRepMesh_Deleted || Other.myMovability==BRepMesh_Deleted)
return Standard_False;
return (myFirstNode==Other.myFirstNode && myLastNode==Other.myLastNode) ||
(myFirstNode==Other.myLastNode && myLastNode==Other.myFirstNode);
Standard_Boolean BRepMesh_Edge::SameOrientation
- (const BRepMesh_Edge& Other)const
+(const BRepMesh_Edge& Other)const
{
return (myFirstNode==Other.myFirstNode && myLastNode==Other.myLastNode);
}
-// File: BRepMesh_Edge.lxx
-// Created: Thu Sep 23 13:44:34 1993
-// Author: Didier PIFFAULT
-// <dpf@zerox>
+// File: BRepMesh_Edge.lxx
+// Created: Thu Sep 23 13:44:34 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
inline Standard_Integer BRepMesh_Edge::FirstNode()const
{
return myLastNode;
}
-inline MeshDS_DegreeOfFreedom BRepMesh_Edge::Movability()const
+inline BRepMesh_DegreeOfFreedom BRepMesh_Edge::Movability()const
{
return myMovability;
}
DataMapOfShapeReal from TopTools,
ListOfShape from TopTools,
Curve from Geom2d,
- MapOfInteger from MeshDS,
- BaseAllocator from MeshDS,
+ MapOfInteger from BRepMesh,
+ BaseAllocator from BRepMesh,
DataMapOfFaceAttribute from BRepMesh
is static;
VerticesOfDomain
- (me; Indices : in out MapOfInteger from MeshDS)
+ (me; Indices : in out MapOfInteger from BRepMesh)
---Purpose: Gives the list of indices of the vertices
is static;
EdgesOfDomain
- (me; Indices : in out MapOfInteger from MeshDS)
+ (me; Indices : in out MapOfInteger from BRepMesh)
---Purpose: Gives the list of indices of the edges
---C++: inline
is static;
- TrianglesOfDomain(me; Indices: in out MapOfInteger from MeshDS)
+ TrianglesOfDomain(me; Indices: in out MapOfInteger from BRepMesh)
---Purpose: Gives the list of indices of the triangles
---C++: inline
is static;
myFacestate : Status from BRepMesh;
myMapdefle : DataMapOfShapeReal from TopTools;
myNottriangulated : ListOfShape from TopTools;
- myAllocator : BaseAllocator from MeshDS;
+ myAllocator : BaseAllocator from BRepMesh;
end FastDiscret;
myVertices.Bind(pBegin, ipf);
}
theUV = BRepMesh_FastDiscretFace::FindUV(pBegin, uvFirst, ipf, theGFace, mindist, myLocation2d);
- BRepMesh_Vertex vf(theUV, ipf, MeshDS_Frontier);
+ BRepMesh_Vertex vf(theUV, ipf, BRepMesh_Frontier);
Standard_Integer ivf = myStructure->AddNode(vf);
// Process last vertex
}
}
theUV = BRepMesh_FastDiscretFace::FindUV(pEnd, uvLast, ipl, theGFace, mindist, myLocation2d);
- BRepMesh_Vertex vl(theUV, ipl, MeshDS_Frontier);
+ BRepMesh_Vertex vl(theUV, ipl, BRepMesh_Frontier);
Standard_Integer ivl= myStructure->AddNode(vl);
Standard_Integer isvf = myVemap.FindIndex(ivf);
myLocation3d.Bind(myNbLocat, P3d);
NodInStruct(i) = myNbLocat;
// Record 2d point
- v2.Initialize(uv.Coord(), myNbLocat, MeshDS_OnCurve);
+ v2.Initialize(uv.Coord(), myNbLocat, BRepMesh_OnCurve);
iv2=myStructure->AddNode(v2);
Standard_Integer isv = myVemap.FindIndex(iv2);
Param(i) = puv;
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2, ivf, BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, BRepMesh_Fixed));
ivf = iv2;
}
}
if (ivf != ivl) {
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(ivl, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl, ivf, BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, BRepMesh_Fixed));
}
{
const Standard_Real puv = Par->Value(i);
theC2d->D0(puv, uv);
- v2.Initialize(uv.Coord(), NOD(i), MeshDS_OnCurve);
+ v2.Initialize(uv.Coord(), NOD(i), BRepMesh_OnCurve);
iv2 = myStructure->AddNode(v2);
Standard_Integer isv = myVemap.FindIndex(iv2);
PPar(i) = puv;
if (orEdge==TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2, ivf, BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, BRepMesh_Fixed));
ivf = iv2;
}
pcos.Perform(P3d, wCurFound);
if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
theC2d->D0(wCurFound, uv);
- v2.Initialize(uv.Coord(), NOD(i), MeshDS_OnCurve);
+ v2.Initialize(uv.Coord(), NOD(i), BRepMesh_OnCurve);
iv2 = myStructure->AddNode(v2);
Standard_Integer isv = myVemap.FindIndex(iv2);
PPar(i) = wCurFound;
if (orEdge==TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2, ivf, BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, BRepMesh_Fixed));
ivf = iv2;
}
if (ivf != ivl) {
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(ivl, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl, ivf, BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, BRepMesh_Fixed));
}
}
}
}
NewNodInStruct(1) = ipf;
theUV = BRepMesh_FastDiscretFace::FindUV(pBegin, uvFirst, ipf, gFace, mindist, myLocation2d);
- BRepMesh_Vertex vf(theUV,ipf,MeshDS_Frontier);
+ BRepMesh_Vertex vf(theUV,ipf,BRepMesh_Frontier);
iv1 = myStructure->AddNode(vf);
isv1 = myVemap.FindIndex(iv1);
if (isv1 == 0) isv1 = myVemap.Add(iv1);
}
NewNodInStruct(nbnodes) = ipl;
theUV = BRepMesh_FastDiscretFace::FindUV(pEnd, uvLast, ipl, gFace, mindist, myLocation2d);
- BRepMesh_Vertex vl(theUV,ipl,MeshDS_Frontier);
+ BRepMesh_Vertex vl(theUV,ipl,BRepMesh_Frontier);
ivl = myStructure->AddNode(vl);
isvl = myVemap.FindIndex(ivl);
NewNodInStruct(i) = myNbLocat;
// Record 2d point
uv = theC2d->Value(Param->Value(i));
- v.Initialize(uv.Coord(), myNbLocat, MeshDS_Frontier);
+ v.Initialize(uv.Coord(), myNbLocat, BRepMesh_Frontier);
iv2 = myStructure->AddNode(v);
isv = myVemap.FindIndex(iv2);
if (isv == 0) isv = myVemap.Add(iv2);
//add links
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2,iv1,BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,BRepMesh_Fixed));
iv1 = iv2;
}
// last point
if (iv1 != ivl) {
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl,iv1,BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,BRepMesh_Fixed));
}
pcos.Perform(P3d, wCurFound);
if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
theC2d->D0(wCurFound, uv);
- v.Initialize(uv.Coord(), myNbLocat, MeshDS_Frontier);
+ v.Initialize(uv.Coord(), myNbLocat, BRepMesh_Frontier);
iv2 = myStructure->AddNode(v);
isv = myVemap.FindIndex(iv2);
if (isv == 0) isv = myVemap.Add(iv2);
//add links
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2,iv1,BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,BRepMesh_Fixed));
iv1 = iv2;
}
// last point
if (iv1 != ivl) {
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl,iv1,BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,BRepMesh_Fixed));
}
}
//purpose :
//=======================================================================
-void BRepMesh_FastDiscret::VerticesOfDomain(MeshDS_MapOfInteger& Indices) const
+void BRepMesh_FastDiscret::VerticesOfDomain(BRepMesh_MapOfInteger& Indices) const
{
Indices.Clear();
// recuperate from the map of edges.
- const MeshDS_MapOfInteger& edmap = myStructure->LinkOfDomain();
+ const BRepMesh_MapOfInteger& edmap = myStructure->LinkOfDomain();
// iterator on edges.
- MeshDS_MapOfInteger::Iterator iter(edmap);
+ BRepMesh_MapOfInteger::Iterator iter(edmap);
Standard_Integer ind_edge;
for (iter.Reset(); iter.More(); iter.Next()) {
//purpose :
//=======================================================================
-inline void BRepMesh_FastDiscret::EdgesOfDomain(MeshDS_MapOfInteger& Indices) const
+inline void BRepMesh_FastDiscret::EdgesOfDomain(BRepMesh_MapOfInteger& Indices) const
{
Indices = myStructure->LinkOfDomain();
}
//purpose :
//=======================================================================
-inline void BRepMesh_FastDiscret::TrianglesOfDomain(MeshDS_MapOfInteger& Indices) const
+inline void BRepMesh_FastDiscret::TrianglesOfDomain(BRepMesh_MapOfInteger& Indices) const
{
Indices = myStructure->ElemOfDomain();
}
Vertex from BRepMesh,
FaceAttribute from BRepMesh,
ListOfInteger from TColStd,
- BaseAllocator from MeshDS,
+ BaseAllocator from BRepMesh,
DataMapOfIntegerPnt from BRepMesh,
IndexedMapOfInteger from TColStd,
IndexedMapOfReal from TColStd,
myInternalVerticesMode : Boolean from Standard; --mode to accounting internal vertices
myUParam : IndexedMapOfReal from TColStd;
myVParam : IndexedMapOfReal from TColStd;
- myAllocator : BaseAllocator from MeshDS;
+ myAllocator : BaseAllocator from BRepMesh;
end FastDiscretFace;
res.SetCoord((p2d.X()-(myAttrib->GetMinX()))/(myAttrib->GetDeltaX()),
(p2d.Y()-(myAttrib->GetMinY()))/(myAttrib->GetDeltaY()));
BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
- const MeshDS_ListOfInteger& alist = myStructure->GetNodeList(i);
+ const BRepMesh_ListOfInteger& alist = myStructure->GetNodeList(i);
aMoveNodes.Add(v_new,alist);
tabvert_corr(i) = i;
}
if(myStructure->ElemConnectedTo(i).Extent() < 1)
{
BRepMesh_Edge& anEdge = (BRepMesh_Edge&)trigu.GetEdge(i);
- if(anEdge.Movability()==MeshDS_Deleted)
+ if(anEdge.Movability()==BRepMesh_Deleted)
continue;
- anEdge.SetMovability(MeshDS_Free);
+ anEdge.SetMovability(BRepMesh_Free);
myStructure->RemoveLink(i);
}
}
gp_XY res;
res.SetCoord(p2d.X()*deltaX+umin,p2d.Y()*deltaY+vmin);
BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
- const MeshDS_ListOfInteger& alist = myStructure->GetNodeList(i);
+ const BRepMesh_ListOfInteger& alist = myStructure->GetNodeList(i);
aMoveNodes.Add(v_new,alist);
}
myStructure->ReplaceNodes(aMoveNodes);
anUV = FindUV(pBegin, uvFirst, ipf, theSurf, mindist, myLocation2d);
Standard_Integer iv1, isv1;
- BRepMesh_Vertex vf(anUV, ipf, MeshDS_Frontier);
+ BRepMesh_Vertex vf(anUV, ipf, BRepMesh_Frontier);
iv1 = myStructure->AddNode(vf);
isv1 = myVemap.FindIndex(iv1);
if (isv1 == 0)
}
anUV = FindUV(pEnd, uvLast, ipl, theSurf, mindist, myLocation2d);
- BRepMesh_Vertex vl(anUV, ipl, MeshDS_Frontier);
+ BRepMesh_Vertex vl(anUV, ipl, BRepMesh_Frontier);
Standard_Integer isvl;
ivl = myStructure->AddNode(vl);
anUV = UVNodes(Indices(i)).Coord();
Standard_Integer iv2, isv;
- v.Initialize(anUV, myNbLocat, MeshDS_Frontier);
+ v.Initialize(anUV, myNbLocat, BRepMesh_Frontier);
iv2 = myStructure->AddNode(v);
isv = myVemap.FindIndex(iv2);
if (isv == 0)
//add links
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2,iv1,BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,BRepMesh_Fixed));
iv1 = iv2;
}
// last point
if (iv1 != ivl) {
if (orEdge == TopAbs_FORWARD)
- myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,BRepMesh_Frontier));
else if (orEdge == TopAbs_REVERSED)
- myStructure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl,iv1,BRepMesh_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,BRepMesh_Fixed));
}
Handle(Poly_PolygonOnTriangulation) P1 =
myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((U-umin)/deltaX, (V-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
myLocation3d.Bind(myNbLocat, P1);
// Record 2d point
p2d.SetCoord((U1-umin)/deltaX, (v-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
myLocation3d.Bind(myNbLocat, P1);
// Record 2d point
p2d.SetCoord((u-umin)/deltaX, (v-vmin)/deltaY);
- newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ newV.Initialize(p2d.XY(), myNbLocat, BRepMesh_Free);
theInternalV.Append(newV);
}
}
if (nbtriangles <= 0) break;
// Iterate on current triangles
- MeshDS_MapOfInteger::Iterator triDom;
- const MeshDS_MapOfInteger& TriMap = myStructure->ElemOfDomain();
+ BRepMesh_MapOfInteger::Iterator triDom;
+ const BRepMesh_MapOfInteger& TriMap = myStructure->ElemOfDomain();
triDom.Initialize(TriMap);
Standard_Integer aNbPnt = 0;
Standard_Real umin = myAttrib->GetUMin();
{
Standard_Integer TriId = triDom.Key();
const BRepMesh_Triangle& curTri=Triangle(TriId);
- if (curTri.Movability()==MeshDS_Deleted) continue;
+ if (curTri.Movability()==BRepMesh_Deleted) continue;
Standard_Boolean o1, o2, o3;
Standard_Integer v1 = 0, v2 = 0, v3 = 0, e1 = 0, e2 = 0, e3 = 0;
const BRepMesh_Edge& edg2=Edge(e2);
const BRepMesh_Edge& edg3=Edge(e3);
- Standard_Boolean m1 = (edg1.Movability() == MeshDS_Frontier);
- Standard_Boolean m2 = (edg2.Movability() == MeshDS_Frontier);
- Standard_Boolean m3 = (edg3.Movability() == MeshDS_Frontier);
+ Standard_Boolean m1 = (edg1.Movability() == BRepMesh_Frontier);
+ Standard_Boolean m2 = (edg2.Movability() == BRepMesh_Frontier);
+ Standard_Boolean m3 = (edg3.Movability() == BRepMesh_Frontier);
if (o1) {
v1=edg1.FirstNode();
v2=edg1.LastNode();
myNbLocat++;
myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ InsVertex.Initialize(mi2d,myNbLocat,BRepMesh_Free);
theInternalV.Append(InsVertex);
}
theBadTriangles.Append(TriId);
myNbLocat++;
myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ InsVertex.Initialize(mi2d,myNbLocat,BRepMesh_Free);
theInternalV.Append(InsVertex);
}
theBadTriangles.Append(TriId);
myNbLocat++;
myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ InsVertex.Initialize(mi2d,myNbLocat,BRepMesh_Free);
theInternalV.Append(InsVertex);
}
theBadTriangles.Append(TriId);
myNbLocat++;
myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ InsVertex.Initialize(mi2d,myNbLocat,BRepMesh_Free);
theInternalV.Append(InsVertex);
}
theBadTriangles.Append(TriId);
theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ InsVertex.Initialize(mi2d,myNbLocat,BRepMesh_Free);
theInternalV.Append(InsVertex);
theBadTriangles.Append(TriId);
}
theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ InsVertex.Initialize(mi2d,myNbLocat,BRepMesh_Free);
theInternalV.Append(InsVertex);
theBadTriangles.Append(TriId);
}
B.UpdateFace(theFace,TNull);
try{
- MeshDS_MapOfInteger::Iterator it;
+ BRepMesh_MapOfInteger::Iterator it;
Standard_Integer e1, e2, e3, nTri;
Standard_Integer v1, v2, v3, iv1, iv2, iv3;
Standard_Boolean o1, o2, o3;
TopAbs_Orientation orFace = theFace.Orientation();
- const MeshDS_MapOfInteger& TriMap = myStructure->ElemOfDomain();
+ const BRepMesh_MapOfInteger& TriMap = myStructure->ElemOfDomain();
it.Initialize(TriMap);
nTri = TriMap.Extent();
Standard_Real mindist = BRep_Tool::Tolerance(theVert);
// gp_Pnt2d uvXY = BRep_Tool::Parameters(theVert,theFace);
gp_XY anUV = FindUV(theVert, uvXY, indVert, thegFace, mindist, myLocation2d);
- BRepMesh_Vertex vf(anUV, indVert, MeshDS_Fixed);
+ BRepMesh_Vertex vf(anUV, indVert, BRepMesh_Fixed);
Standard_Integer ivff = myStructure->AddNode(vf);
Standard_Integer isvf = myVemap.FindIndex(ivff);
if (isvf == 0) isvf = myVemap.Add(ivff);
--- /dev/null
+#include <NCollection_List.hxx>
+
+typedef NCollection_List<Standard_Integer> BRepMesh_ListOfInteger;
--- /dev/null
+#include <NCollection_Map.hxx>
+
+typedef NCollection_Map<Standard_Integer> BRepMesh_MapOfInteger;
--- /dev/null
+// File: BRepMesh_MapOfIntegerInteger.hxx
+// Created: Fri Jan 30 15:15:17 2009
+// Author: Pavel DURANDIN (pdn)
+// Copyright: Open CASCADE 2009
+
+#ifndef BRepMesh_MapOfIntegerInteger_HeaderFile
+#define BRepMesh_MapOfIntegerInteger_HeaderFile
+
+#include <NCollection_DataMap.hxx>
+typedef NCollection_DataMap<Standard_Integer, Standard_Integer> BRepMesh_MapOfIntegerInteger;
+
+#endif
--- /dev/null
+// File: BRepMesh_PairOfIndex.hxx
+// Created: 29.01.09 15:55:25
+// Author: Pavel TELKOV
+// Copyright: Open CASCADE 2009
+
+/*
+* Purpose: This class represent pair of integer indices
+* It is restricted to store more than two indices in it
+* This pair uses to store element indices connected to link
+*/
+
+#ifndef BRepMesh_PairOfIndex_HeaderFile
+#define BRepMesh_PairOfIndex_HeaderFile
+
+#include <Standard_OutOfRange.hxx>
+
+class BRepMesh_PairOfIndex
+{
+public:
+ BRepMesh_PairOfIndex()
+ { myIndx1 = myIndx2 = -1; }
+
+ BRepMesh_PairOfIndex(const BRepMesh_PairOfIndex& theOther)
+ {
+ myIndx1 = theOther.myIndx1;
+ myIndx1 = theOther.myIndx2;
+ }
+
+ //! Clear indices
+ void Clear()
+ {
+ myIndx1 = myIndx2 = -1;
+ }
+
+ //! append index (store first of last index of pair)
+ void Append(const Standard_Integer theIndx)
+ {
+ if ( myIndx1 < 0 )
+ myIndx1 = theIndx;
+ else
+ {
+ if ( myIndx2 >= 0 )
+ Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
+ myIndx2 = theIndx;
+ }
+ }
+
+ //! prepend index (store first index)
+ void Prepend(const Standard_Integer theIndx)
+ {
+ if ( myIndx2 >= 0 )
+ Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
+ myIndx2 = myIndx1;
+ myIndx1 = theIndx;
+ }
+
+ //! returns is pair not initialized by index
+ Standard_Boolean IsEmpty() const
+ {
+ return (myIndx1 < 0 /*optimisation && myIndx2 < 0*/);
+ }
+
+ //! returns numner of initialized indeces
+ Standard_Integer Extent() const
+ {
+ return (myIndx1 < 0 ? 0 : (myIndx2 < 0 ? 1 : 2));
+ }
+
+ //! returns first index from pair
+ Standard_Integer FirstIndex() const
+ {
+ return myIndx1;
+ }
+
+ //! returns last index
+ Standard_Integer LastIndex() const
+ {
+ return (myIndx2 < 0 ? myIndx1 : myIndx2);
+ }
+
+ Standard_Integer Index(const Standard_Integer theNum) const
+ {
+ return (theNum == 1 ? myIndx1 : myIndx2 /*(theNum == 2 ? myIndx2 : -1 )*/);
+ }
+
+ void SetIndex(const Standard_Integer theNum,
+ const Standard_Integer theIndex)
+ {
+ theNum == 1 ? myIndx1 = theIndex : myIndx2 = theIndex;
+ }
+
+ //! remove indicated
+ void RemoveIndex (const Standard_Integer theNum)
+ {
+ if ( theNum == 1 )
+ myIndx1 = myIndx2;
+ myIndx2 = -1;
+ }
+ //! fields
+private:
+ Standard_Integer myIndx1;
+ Standard_Integer myIndx2;
+};
+
+#endif
--- /dev/null
+class SelectorOfDataStructureOfDelaun from BRepMesh
+
+ ---Purpose: Describes a selector and an Iterator on a
+ -- selector of components of a Mesh.
+
+ uses Integer from Standard,
+ Box from Bnd,
+ MapOfInteger from BRepMesh,
+ DataStructureOfDelaun from BRepMesh,
+ Vertex from BRepMesh,
+ Edge from BRepMesh,
+ Triangle from BRepMesh
+
+is Create returns SelectorOfDataStructureOfDelaun from BRepMesh;
+
+ Create (theMesh : DataStructureOfDelaun from BRepMesh)
+ returns SelectorOfDataStructureOfDelaun from BRepMesh;
+
+ Initialize (me : in out;
+ theMesh :DataStructureOfDelaun from BRepMesh)
+ is static;
+
+
+ NeighboursOf(me : in out;
+ theNode : in Vertex from BRepMesh)
+ is static;
+
+ NeighboursOfNode(me : in out;
+ indexNode : in Integer from Standard)
+ is static;
+
+
+ NeighboursOf(me : in out;
+ theLink : in Edge from BRepMesh)
+ is static;
+
+ NeighboursOfLink(me : in out;
+ indexLink : in Integer from Standard)
+ is static;
+
+
+ NeighboursOf(me : in out;
+ theElem : in Triangle from BRepMesh)
+ is static;
+
+ NeighboursOfElement(me : in out;
+ indexElem : in Integer from Standard)
+ ---Purpose: All Neighbours Of the Element. By
+ -- edge or by vertices.
+ is static;
+
+
+ NeighboursByEdgeOf (me : in out;
+ theElem : in Triangle from BRepMesh)
+ ---Purpose: Neighbours by edge Of the Element.
+ is static;
+
+
+ NeighboursOf(me : in out;
+ theSelector : in SelectorOfDataStructureOfDelaun from BRepMesh)
+ ---Purpose: Adds a level of Neighbours by edge
+ -- to the selector <theSelector>.
+ is static;
+
+
+ AddNeighbours(me : in out)
+ ---Purpose: Adds a level of Neighbours by edge
+ -- to the selector <me>.
+ is static;
+
+
+ Nodes (me)
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh is static;
+
+ Links (me)
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh is static;
+
+ Elements (me)
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh is static;
+
+ FrontierLinks(me)
+ ---Purpose: Gives the list of links incices
+ -- frontier of the selector <me>.
+ ---C++: return const &
+ returns MapOfInteger from BRepMesh is static;
+
+
+ fields myMesh :DataStructureOfDelaun from BRepMesh;
+ myNodes : MapOfInteger from BRepMesh;
+ myLinks : MapOfInteger from BRepMesh;
+ myElements : MapOfInteger from BRepMesh;
+ myFrontier : MapOfInteger from BRepMesh;
+
+end SelectorOfDataStructureOfDelaun;
--- /dev/null
+// File: BRepMesh_SelectorOfDataStructureOfDelaun.cxx
+// Created: Tue Jun 1 11:20:51 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
+
+#include <BRepMesh_SelectorOfDataStructureOfDelaun.ixx>
+#include <BRepMesh_PairOfIndex.hxx>
+
+//=======================================================================
+//function : BRepMesh_SelectorOfDataStructureOfDelaun
+//purpose :
+//=======================================================================
+BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun()
+: myNodes(10, new NCollection_IncAllocator),
+myLinks(10, new NCollection_IncAllocator),
+myElements(10, new NCollection_IncAllocator),
+myFrontier(10, new NCollection_IncAllocator)
+
+{}
+
+BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
+: myMesh(theMesh),
+myNodes(10, myMesh->Allocator()),
+myLinks(10, myMesh->Allocator()),
+myElements(10, myMesh->Allocator()),
+myFrontier(10, myMesh->Allocator())
+{}
+
+void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
+{
+ myMesh=theMesh;
+ myNodes.Clear();
+ myLinks.Clear();
+ myElements.Clear();
+ myFrontier.Clear();
+}
+
+//=======================================================================
+//function : NeighboursOfNode
+//purpose :
+//=======================================================================
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Vertex& theNode)
+{
+ NeighboursOfNode(myMesh->IndexOf(theNode));
+}
+
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(const Standard_Integer indexNode)
+{
+ BRepMesh_ListOfInteger::Iterator itL(myMesh->LinkNeighboursOf(indexNode));
+
+ for (; itL.More(); itL.Next()) {
+ const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(itL.Value());
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
+ myElements.Add(aPair.Index(j));
+ }
+}
+
+//=======================================================================
+//function : NeighboursOfLink
+//purpose :
+//=======================================================================
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Edge& theLink)
+{
+ NeighboursOfNode(theLink.FirstNode());
+ NeighboursOfNode(theLink.LastNode());
+}
+
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(const Standard_Integer indexLink)
+{
+ NeighboursOf(myMesh->GetLink(indexLink));
+}
+
+//=======================================================================
+//function : NeighboursOfElement
+//purpose : by edge and by vertices
+//=======================================================================
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Triangle& theElem)
+{
+ Standard_Integer v1, v2, v3, ev;
+ Standard_Boolean o1, o2, o3;
+ theElem.Edges(v1, v3, ev, o1, o2, o3);
+ v2=myMesh->GetLink(v1).LastNode();
+ v1=myMesh->GetLink(v1).FirstNode();
+ ev=myMesh->GetLink(v3).LastNode();
+ if (v1!=ev && v2!=ev) v3=ev;
+ else v3=myMesh->GetLink(v3).FirstNode();
+ NeighboursOfNode(v1);
+ NeighboursOfNode(v2);
+ NeighboursOfNode(v3);
+}
+
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(const Standard_Integer indexElem)
+{
+ NeighboursOf(myMesh->GetElement(indexElem));
+}
+
+//=======================================================================
+//function : NeighboursByEdgeOf
+//purpose : Neighbours Of an element only by edge
+//=======================================================================
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(const BRepMesh_Triangle& theElem)
+{
+ Standard_Integer e[3], iEd;
+ Standard_Boolean o1, o2, o3;
+ theElem.Edges(e[0], e[1], e[2], o1, o2, o3);
+
+ for (iEd=0; iEd<3; iEd++) {
+ const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(e[iEd]);
+ for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
+ myElements.Add(aPair.Index(j));
+ }
+}
+
+
+//=======================================================================
+//function : NeighboursOfSelector
+//purpose :
+//=======================================================================
+void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_SelectorOfDataStructureOfDelaun& /*theSelector*/)
+{}
+
+//=======================================================================
+//function : AddNeighbours
+//purpose :
+//=======================================================================
+void BRepMesh_SelectorOfDataStructureOfDelaun::AddNeighbours()
+{}
+
+//=======================================================================
+//function : Nodes
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Nodes()const
+{return myNodes;}
+
+//=======================================================================
+//function : Links
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Links()const
+{return myLinks;}
+
+//=======================================================================
+//function : Elements
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Elements()const
+{return myElements;}
+
+//=======================================================================
+//function : FrontierLinks
+//purpose :
+//=======================================================================
+const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::FrontierLinks()const
+{return myFrontier;}
+
--- File: BRepMesh_Triangle.cdl
--- Created: Wed Sep 22 18:11:52 1993
--- Author: Didier PIFFAULT
--- <dpf@zerox>
----Copyright: Matra Datavision 1993
+-- File: BRepMesh_Triangle.cdl
+-- Created: Wed Sep 22 18:11:52 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993
class Triangle from BRepMesh
- ---Purpose:
+ ---Purpose:
uses Boolean from Standard,
- Integer from Standard,
- DegreeOfFreedom from MeshDS
-
+ Integer from Standard,
+ DegreeOfFreedom from BRepMesh
-is Create returns Triangle from BRepMesh;
+is Create returns Triangle from BRepMesh;
- Create (e1, e2, e3 : Integer from Standard;
- o1, o2, o3 : Boolean from Standard;
- canMove : DegreeOfFreedom from MeshDS)
- returns Triangle from BRepMesh;
-
- Initialize (me : in out;
- e1, e2, e3 : Integer from Standard;
- o1, o2, o3 : Boolean from Standard;
- canMove : DegreeOfFreedom from MeshDS)
- is static;
-
-
- Edges (me;
- e1, e2, e3 : out Integer from Standard;
- o1, o2, o3 : out Boolean from Standard)
- is static;
+ Create (e1, e2, e3 : Integer from Standard;
+ o1, o2, o3 : Boolean from Standard;
+ canMove : DegreeOfFreedom from BRepMesh)
+ returns Triangle from BRepMesh;
- Movability (me)
- ---C++: inline
- returns DegreeOfFreedom from MeshDS
- is static;
+ Initialize (me : in out;
+ e1, e2, e3 : Integer from Standard;
+ o1, o2, o3 : Boolean from Standard;
+ canMove : DegreeOfFreedom from BRepMesh)
+ is static;
- SetMovability (me : in out;
- Move : DegreeOfFreedom from MeshDS)
- is static;
+ Edges (me;
+ e1, e2, e3 : out Integer from Standard;
+ o1, o2, o3 : out Boolean from Standard)
+ is static;
- HashCode (me;
- Upper : Integer from Standard)
- returns Integer from Standard
- ---C++: function call
- is static;
+ Movability (me)
+ ---C++: inline
+ returns DegreeOfFreedom from BRepMesh
+ is static;
- IsEqual (me; Other : Triangle from BRepMesh)
- returns Boolean from Standard
- ---C++: alias operator ==
- is static;
+ SetMovability (me : in out;
+ Move : DegreeOfFreedom from BRepMesh)
+ is static;
-fields Edge1 : Integer from Standard;
- Orientation1 : Boolean from Standard;
- Edge2 : Integer from Standard;
- Orientation2 : Boolean from Standard;
- Edge3 : Integer from Standard;
- Orientation3 : Boolean from Standard;
- myMovability : DegreeOfFreedom from MeshDS;
+ HashCode (me;
+ Upper : Integer from Standard)
+ returns Integer from Standard
+ ---C++: function call
+ is static;
+
+
+ IsEqual (me; Other : Triangle from BRepMesh)
+ returns Boolean from Standard
+ ---C++: alias operator ==
+ is static;
+
+
+ fields Edge1 : Integer from Standard;
+ Orientation1 : Boolean from Standard;
+ Edge2 : Integer from Standard;
+ Orientation2 : Boolean from Standard;
+ Edge3 : Integer from Standard;
+ Orientation3 : Boolean from Standard;
+ myMovability : DegreeOfFreedom from BRepMesh;
end Triangle;
-// File: BRepMesh_Triangle.cxx
-// Created: Thu Sep 23 13:10:58 1993
-// Author: Didier PIFFAULT
-// <dpf@zerox>
+// File: BRepMesh_Triangle.cxx
+// Created: Thu Sep 23 13:10:58 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
#include <BRepMesh_Triangle.ixx>
-
+
BRepMesh_Triangle::BRepMesh_Triangle()
- : Edge1(0), Edge2(0), Edge3(0), myMovability(MeshDS_Free)
+: Edge1(0), Edge2(0), Edge3(0), myMovability(BRepMesh_Free)
{}
BRepMesh_Triangle::BRepMesh_Triangle (const Standard_Integer e1,
- const Standard_Integer e2,
- const Standard_Integer e3,
- const Standard_Boolean o1,
- const Standard_Boolean o2,
- const Standard_Boolean o3,
- const MeshDS_DegreeOfFreedom canMove)
- : Edge1(e1), Orientation1(o1),Edge2(e2), Orientation2(o2),
- Edge3(e3), Orientation3(o3),
- myMovability(canMove)
+ const Standard_Integer e2,
+ const Standard_Integer e3,
+ const Standard_Boolean o1,
+ const Standard_Boolean o2,
+ const Standard_Boolean o3,
+ const BRepMesh_DegreeOfFreedom canMove)
+ : Edge1(e1), Orientation1(o1),Edge2(e2), Orientation2(o2),
+ Edge3(e3), Orientation3(o3),
+ myMovability(canMove)
{}
void BRepMesh_Triangle::Initialize(const Standard_Integer e1,
- const Standard_Integer e2,
- const Standard_Integer e3,
- const Standard_Boolean o1,
- const Standard_Boolean o2,
- const Standard_Boolean o3,
- const MeshDS_DegreeOfFreedom canMove)
+ const Standard_Integer e2,
+ const Standard_Integer e3,
+ const Standard_Boolean o1,
+ const Standard_Boolean o2,
+ const Standard_Boolean o3,
+ const BRepMesh_DegreeOfFreedom canMove)
{
Edge1 =e1;
Edge2 =e2;
}
void BRepMesh_Triangle::Edges(Standard_Integer& e1,
- Standard_Integer& e2,
- Standard_Integer& e3,
- Standard_Boolean& o1,
- Standard_Boolean& o2,
- Standard_Boolean& o3)const
+ Standard_Integer& e2,
+ Standard_Integer& e3,
+ Standard_Boolean& o1,
+ Standard_Boolean& o2,
+ Standard_Boolean& o3)const
{
e1=Edge1;
e2=Edge2;
o3=Orientation3;
}
-void BRepMesh_Triangle::SetMovability(const MeshDS_DegreeOfFreedom Move)
+void BRepMesh_Triangle::SetMovability(const BRepMesh_DegreeOfFreedom Move)
{
myMovability =Move;
}
Standard_Integer BRepMesh_Triangle::HashCode
- (const Standard_Integer Upper)const
+(const Standard_Integer Upper)const
{
return ::HashCode(Edge1+Edge2+Edge3, Upper);
}
Standard_Boolean BRepMesh_Triangle::IsEqual
- (const BRepMesh_Triangle& Other)const
+(const BRepMesh_Triangle& Other)const
{
- if (myMovability==MeshDS_Deleted || Other.myMovability==MeshDS_Deleted)
+ if (myMovability==BRepMesh_Deleted || Other.myMovability==BRepMesh_Deleted)
return Standard_False;
if (Edge1==Other.Edge1 && Edge2==Other.Edge2 && Edge3==Other.Edge3)
return Standard_True;
-// File: BRepMesh_Triangle.lxx
-// Created: Thu Sep 23 13:14:07 1993
-// Author: Didier PIFFAULT
-// <dpf@zerox>
+// File: BRepMesh_Triangle.lxx
+// Created: Thu Sep 23 13:14:07 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
-inline MeshDS_DegreeOfFreedom BRepMesh_Triangle::Movability()const
+inline BRepMesh_DegreeOfFreedom BRepMesh_Triangle::Movability()const
{
return myMovability;
}
--- File: BRepMesh_Vertex.cdl
--- Created: Wed Sep 22 18:04:35 1993
--- Author: Didier PIFFAULT
--- <dpf@zerox>
----Copyright: Matra Datavision 1993
+-- File: BRepMesh_Vertex.cdl
+-- Created: Wed Sep 22 18:04:35 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993
class Vertex from BRepMesh
- ---Purpose:
+ ---Purpose:
uses Boolean from Standard,
- Integer from Standard,
- Real from Standard,
- XY from gp,
- DegreeOfFreedom from MeshDS
-
-
-is Create returns Vertex from BRepMesh;
-
- Create (UV : in XY from gp;
- Locat3d : in Integer from Standard;
- Move : in DegreeOfFreedom from MeshDS)
- returns Vertex from BRepMesh;
-
-
- Create (U, V : Real from Standard;
- Move : in DegreeOfFreedom from MeshDS)
- ---Purpose: For MeshAlgo.
- returns Vertex from BRepMesh;
-
-
- Initialize (me : in out;
- UV : in XY from gp;
- Locat3d : in Integer from Standard;
- Move : in DegreeOfFreedom from MeshDS)
- is static;
-
-
- Coord (me)
- returns XY from gp
- ---C++: return const &
- ---C++: inline
- is static;
-
-
- Location3d (me)
- returns Integer from Standard
- ---C++: inline
- is static;
-
-
- Movability (me)
- returns DegreeOfFreedom from MeshDS
- ---C++: inline
- is static;
-
- SetMovability (me : in out;
- Move : DegreeOfFreedom from MeshDS)
- is static;
-
-
- HashCode (me;
- Upper : Integer from Standard)
- returns Integer from Standard
- ---C++: function call
- is static;
-
-
- IsEqual (me; Other : Vertex from BRepMesh)
- returns Boolean from Standard
- ---C++: alias operator ==
- is static;
-
-
-fields myUV : XY from gp;
- myLocation : Integer from Standard;
- myMovability : DegreeOfFreedom from MeshDS;
+ Integer from Standard,
+ Real from Standard,
+ XY from gp,
+ DegreeOfFreedom from BRepMesh
+
+
+is Create returns Vertex from BRepMesh;
+
+ Create (UV : in XY from gp;
+ Locat3d : in Integer from Standard;
+ Move : in DegreeOfFreedom from BRepMesh)
+ returns Vertex from BRepMesh;
+
+
+ Create (U, V : Real from Standard;
+ Move : in DegreeOfFreedom from BRepMesh)
+ returns Vertex from BRepMesh;
+
+
+ Initialize (me : in out;
+ UV : in XY from gp;
+ Locat3d : in Integer from Standard;
+ Move : in DegreeOfFreedom from BRepMesh)
+ is static;
+
+
+ Coord (me)
+ returns XY from gp
+ ---C++: return const &
+ ---C++: inline
+ is static;
+
+
+ Location3d (me)
+ returns Integer from Standard
+ ---C++: inline
+ is static;
+
+
+ Movability (me)
+ returns DegreeOfFreedom from BRepMesh
+ ---C++: inline
+ is static;
+
+ SetMovability (me : in out;
+ Move : DegreeOfFreedom from BRepMesh)
+ is static;
+
+
+ HashCode (me;
+ Upper : Integer from Standard)
+ returns Integer from Standard
+ ---C++: function call
+ is static;
+
+
+ IsEqual (me; Other : Vertex from BRepMesh)
+ returns Boolean from Standard
+ ---C++: alias operator ==
+ is static;
+
+
+ fields myUV : XY from gp;
+ myLocation : Integer from Standard;
+ myMovability : DegreeOfFreedom from BRepMesh;
end Vertex;
-// File: BRepMesh_Vertex.cxx
-// Created: Thu Sep 23 12:46:51 1993
-// Author: Didier PIFFAULT
-// <dpf@zerox>
+// File: BRepMesh_Vertex.cxx
+// Created: Thu Sep 23 12:46:51 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
#include <BRepMesh_Vertex.ixx>
#include <Precision.hxx>
BRepMesh_Vertex::BRepMesh_Vertex()
- : myLocation(0), myMovability(MeshDS_Free)
+: myLocation(0), myMovability(BRepMesh_Free)
{}
BRepMesh_Vertex::BRepMesh_Vertex(const gp_XY& UV,
- const Standard_Integer Locat3d,
- const MeshDS_DegreeOfFreedom Move)
- : myUV(UV), myLocation(Locat3d), myMovability(Move)
+ const Standard_Integer Locat3d,
+ const BRepMesh_DegreeOfFreedom Move)
+ : myUV(UV), myLocation(Locat3d), myMovability(Move)
{}
BRepMesh_Vertex::BRepMesh_Vertex(const Standard_Real U,
- const Standard_Real V,
- const MeshDS_DegreeOfFreedom Move)
- : myUV(U, V), myLocation(0), myMovability(Move)
+ const Standard_Real V,
+ const BRepMesh_DegreeOfFreedom Move)
+ : myUV(U, V), myLocation(0), myMovability(Move)
{}
void BRepMesh_Vertex::Initialize(const gp_XY& UV,
- const Standard_Integer Locat3d,
- const MeshDS_DegreeOfFreedom Move)
+ const Standard_Integer Locat3d,
+ const BRepMesh_DegreeOfFreedom Move)
{
myUV=UV;
myLocation=Locat3d;
myMovability=Move;
}
-void BRepMesh_Vertex::SetMovability(const MeshDS_DegreeOfFreedom Move)
+void BRepMesh_Vertex::SetMovability(const BRepMesh_DegreeOfFreedom Move)
{
myMovability=Move;
}
Standard_Boolean BRepMesh_Vertex::IsEqual(const BRepMesh_Vertex& Other)const
{
- if (myMovability!=MeshDS_Deleted && Other.myMovability!=MeshDS_Deleted)
+ if (myMovability!=BRepMesh_Deleted && Other.myMovability!=BRepMesh_Deleted)
return (myUV.IsEqual(Other.myUV, Precision::PConfusion()));
return Standard_False;
}
-// File: BRepMesh_Vertex.lxx
-// Created: Thu Sep 23 12:49:00 1993
-// Author: Didier PIFFAULT
-// <dpf@zerox>
+// File: BRepMesh_Vertex.lxx
+// Created: Thu Sep 23 12:49:00 1993
+// Author: Didier PIFFAULT
+// <dpf@zerox>
inline const gp_XY& BRepMesh_Vertex::Coord()const
{
return myLocation;
}
-inline MeshDS_DegreeOfFreedom BRepMesh_Vertex::Movability()const
+inline BRepMesh_DegreeOfFreedom BRepMesh_Vertex::Movability()const
{
return myMovability;
}
BRepMesh_PluginMacro.hxx
BRepMesh_ClassifierPtr.hxx
+BRepMesh_CellFilter.hxx
+BRepMesh_CircleInspector.hxx
+BRepMesh_MapOfIntegerInteger.hxx
+BRepMesh_MapOfInteger.hxx
+BRepMesh_ListOfInteger.hxx
+BRepMesh_BaseAllocator.hxx
+BRepMesh_PairOfIndex.hxx
EXTERNLIB
if (S1.IsNull() || S2.IsNull()) return 1;
IntPoly_ShapeSection SECTION(S1,S2);
-// char name[100];
+ // char name[100];
BRep_Builder B;
TopoDS_Compound C;
B.MakeCompound(C);
Handle(Geom_Plane) pl = Handle(Geom_Plane)::DownCast(Surf);
if (!pl.IsNull()) {
IntPoly_PlaneSection SECTION(S,pl->Pln());
-// char name[100];
+ // char name[100];
BRep_Builder B;
TopoDS_Compound C;
B.MakeCompound(C);
class BRepMesh_Couple
{
- public:
+public:
BRepMesh_Couple() { myI1 = myI2 = 0; }
BRepMesh_Couple(const Standard_Integer I1,
- const Standard_Integer I2)
+ const Standard_Integer I2)
{ myI1 = I1; myI2 = I2; }
Standard_Integer myI1;
const BRepMesh_Couple& other)
{
if (one.myI1 == other.myI1 &&
- one.myI2 == other.myI2) return Standard_True;
+ one.myI2 == other.myI2) return Standard_True;
else return Standard_False;
}
}
static void MeshStats(const TopoDS_Shape& theSape,
- Standard_Integer& theNbTri,
- Standard_Integer& theNbEdges,
- Standard_Integer& theNbNodes)
+ Standard_Integer& theNbTri,
+ Standard_Integer& theNbEdges,
+ Standard_Integer& theNbNodes)
{
theNbTri = 0;
theNbEdges = 0;
//count number of links
Poly_Array1OfTriangle& Trian = T->ChangeTriangles();
for(Standard_Integer i = 1; i<=Trian.Length();i++) {
- Standard_Integer v1, v2, v3;
+ Standard_Integer v1, v2, v3;
Trian(i).Get(v1,v2,v3);
- AddLink(aMap, v1, v2);
- AddLink(aMap, v2, v3);
- AddLink(aMap, v3, v1);
+ AddLink(aMap, v1, v2);
+ AddLink(aMap, v2, v3);
+ AddLink(aMap, v3, v1);
}
theNbEdges+=aMap.Extent();
// passe de verification du maillage.
/*Standard_Integer nbc;
for (Standard_Integer iLi=1; iLi<= DM->Mesh()->NbEdges(); iLi++) {
- const BRepMesh_Edge& ed=DM->Mesh()->Edge(iLi);
- if (ed.Movability()!=MeshDS_Deleted) {
- nbc=struc->ElemConnectedTo(iLi).Extent();
- if (nbc != 1 && nbc != 2) di <<"ERROR MAILLAGE Edge no "<< iLi<<"\n";
- }
+ const BRepMesh_Edge& ed=DM->Mesh()->Edge(iLi);
+ if (ed.Movability()!=BRepMesh_Deleted) {
+ nbc=struc->ElemConnectedTo(iLi).Extent();
+ if (nbc != 1 && nbc != 2) di <<"ERROR MAILLAGE Edge no "<< iLi<<"\n";
+ }
}*/
Bnd_Box bobo;
-
+
for (Standard_Integer lepnt=1; lepnt<DM->Mesh()->NbPoint3d(); lepnt++) {
bobo.Add(DM->Mesh()->Point3d(lepnt));
}
/*Standard_Integer smooth(Draw_Interpretor&, Standard_Integer n, const char** a)
{
- if (n < 2) return 1;
- Handle(MeshTest_DrawableMesh) D =
- Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(a[1]));
- if (D.IsNull()) return 1;
- Handle(BRepMesh_DataStructureOfDelaun) struc=
- D->Mesh()->Result();
- BRepMesh_Array1OfVertexOfDelaun toto(1,1);
- BRepMesh_Delaun trial(struc,
- toto,
- Standard_True);
- trial.SmoothMesh(0.1);
- Draw::Repaint();
- return 0;
+if (n < 2) return 1;
+Handle(MeshTest_DrawableMesh) D =
+Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(a[1]));
+if (D.IsNull()) return 1;
+Handle(BRepMesh_DataStructureOfDelaun) struc=
+D->Mesh()->Result();
+BRepMesh_Array1OfVertexOfDelaun toto(1,1);
+BRepMesh_Delaun trial(struc,
+toto,
+Standard_True);
+trial.SmoothMesh(0.1);
+Draw::Repaint();
+return 0;
}
*/
//purpose :
//=======================================================================
- /*static Standard_Integer edges (Draw_Interpretor&, Standard_Integer n, const char** a)
+/*static Standard_Integer edges (Draw_Interpretor&, Standard_Integer n, const char** a)
{
- if (n < 3) return 1;
-
- Handle(MeshTest_DrawableMesh) D =
- Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(a[1]));
- if (D.IsNull()) return 1;
- TopoDS_Shape S = DBRep::Get(a[2]);
- if (S.IsNull()) return 1;
+if (n < 3) return 1;
+
+Handle(MeshTest_DrawableMesh) D =
+Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(a[1]));
+if (D.IsNull()) return 1;
+TopoDS_Shape S = DBRep::Get(a[2]);
+if (S.IsNull()) return 1;
+
+TopExp_Explorer ex;
+TColStd_SequenceOfInteger& eseq = D->Edges();
+Handle(BRepMesh_FastDiscret) M = D->Mesh();
+Handle(BRepMesh_DataStructureOfDelaun) DS = M->Result();
+Standard_Integer e1, e2, e3, iTri;
+Standard_Boolean o1, o2, o3;
+
+// the faces
+for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) {
+const BRepMesh_MapOfInteger& elems = DS->ElemOfDomain();
+BRepMesh_MapOfInteger::Iterator it;
+for (it.Initialize(elems); it.More(); it.Next()) {
+iTri = it.Key();
+const BRepMesh_Triangle& triang = M->Triangle(iTri);
+if (triang.Movability()!=BRepMesh_Deleted) {
+triang.Edges(e1, e2, e3, o1, o2, o3);
+eseq.Append(e1);
+eseq.Append(e2);
+eseq.Append(e3);
+}
+}
+}
- TopExp_Explorer ex;
- TColStd_SequenceOfInteger& eseq = D->Edges();
- Handle(BRepMesh_FastDiscret) M = D->Mesh();
- Handle(BRepMesh_DataStructureOfDelaun) DS = M->Result();
- Standard_Integer e1, e2, e3, iTri;
- Standard_Boolean o1, o2, o3;
+// the edges
+//for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE);ex.More();ex.Next()) {
+//}
- // the faces
- for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) {
- const MeshDS_MapOfInteger& elems = DS->ElemOfDomain();
- MeshDS_MapOfInteger::Iterator it;
- for (it.Initialize(elems); it.More(); it.Next()) {
- iTri = it.Key();
- const BRepMesh_Triangle& triang = M->Triangle(iTri);
- if (triang.Movability()!=MeshDS_Deleted) {
- triang.Edges(e1, e2, e3, o1, o2, o3);
- eseq.Append(e1);
- eseq.Append(e2);
- eseq.Append(e3);
- }
- }
- }
-
- // the edges
- //for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE);ex.More();ex.Next()) {
- //}
-
- Draw::Repaint();
- return 0;
+Draw::Repaint();
+return 0;
}
*/
TopExp_Explorer ex;
TColStd_SequenceOfInteger& vseq = D->Vertices();
Handle(BRepMesh_FastDiscret) M = D->Mesh();
-
+
// the faces
for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) {
- MeshDS_MapOfInteger vtx;
+ BRepMesh_MapOfInteger vtx;
M->VerticesOfDomain(vtx);
- for (MeshDS_MapOfInteger::Iterator it(vtx); it.More(); it.Next())
+ for (BRepMesh_MapOfInteger::Iterator it(vtx); it.More(); it.Next())
vseq.Append(it.Key());
}
-
+
// the edges
//for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE);ex.More();ex.Next()) {
//}
-
+
Draw::Repaint();
return 0;
}
e = -e;
j = 1;
while (j <= eseq.Length()) {
- if (eseq(j) == e)
- eseq.Remove(j);
- else
- j++;
+ if (eseq(j) == e)
+ eseq.Remove(j);
+ else
+ j++;
}
}
else
eseq.Clear();
}
-
+
Draw::Repaint();
return 0;
}
v = -v;
j = 1;
while (j <= vseq.Length()) {
- if (vseq(j) == v)
- vseq.Remove(v);
- else
- j++;
+ if (vseq(j) == v)
+ vseq.Remove(v);
+ else
+ j++;
}
}
else
v = -v;
j = 1;
while (j <= tseq.Length()) {
- if (tseq(j) == v)
- tseq.Remove(v);
- else
- j++;
+ if (tseq(j) == v)
+ tseq.Remove(v);
+ else
+ j++;
}
}
else
//purpose :
//=======================================================================
-static void printdegree(MeshDS_DegreeOfFreedom dof, Draw_Interpretor& di)
+static void printdegree(BRepMesh_DegreeOfFreedom dof, Draw_Interpretor& di)
{
switch (dof) {
- case MeshDS_InVolume :
- di << "InVolume";
- break;
- case MeshDS_OnSurface :
- di << "OnSurface";
- break;
- case MeshDS_OnCurve :
- di << "OnCurve";
- break;
- case MeshDS_Fixed :
- di << "Fixed";
- break;
- case MeshDS_Frontier :
- di << "Frontier";
- break;
- case MeshDS_Deleted :
- di << "Deleted";
- break;
- case MeshDS_Free :
- di << "Free";
- break;
+case BRepMesh_InVolume :
+ di << "InVolume";
+ break;
+case BRepMesh_OnSurface :
+ di << "OnSurface";
+ break;
+case BRepMesh_OnCurve :
+ di << "OnCurve";
+ break;
+case BRepMesh_Fixed :
+ di << "Fixed";
+ break;
+case BRepMesh_Frontier :
+ di << "Frontier";
+ break;
+case BRepMesh_Deleted :
+ di << "Deleted";
+ break;
+case BRepMesh_Free :
+ di << "Free";
+ break;
}
}
/*
Standard_Integer dumpvertex(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if (argc < 2) return 1;
+if (argc < 2) return 1;
- Handle(MeshTest_DrawableMesh) D =
- Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
- if (D.IsNull()) return 1;
-
- Handle(BRepMesh_DataStructureOfDelaun) struc = D->Mesh()->Result();
+Handle(MeshTest_DrawableMesh) D =
+Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
+if (D.IsNull()) return 1;
- Standard_Integer in=1;
- if (argc>=3) {
- in=atoi(argv[2]);
- in=Max(1,in);
- }
- Standard_Integer nbn=in;
- if (argc>=4) {
- nbn=atoi(argv[3]);
- nbn=Min(nbn,struc->NbNodes());
- }
+Handle(BRepMesh_DataStructureOfDelaun) struc = D->Mesh()->Result();
- for (; in<=nbn; in++) {
- BRepMesh_Vertex nod=struc->GetNode(in);
- di<<"(node "<<in<<" (uv "<<nod.Coord().X()
- <<" "<<nod.Coord().Y()<<") (3d "
- <<nod.Location3d()<<") ";
- printdegree(nod.Movability(), di);
- di<<" (edgeconex";
- MeshDS_ListOfInteger::Iterator tati(struc->LinkNeighboursOf(in));
- for (; tati.More(); tati.Next()) di<<" "<<tati.Value();
- di << "))\n";
- }
- di <<"\n";
- return 0;
+Standard_Integer in=1;
+if (argc>=3) {
+in=atoi(argv[2]);
+in=Max(1,in);
+}
+Standard_Integer nbn=in;
+if (argc>=4) {
+nbn=atoi(argv[3]);
+nbn=Min(nbn,struc->NbNodes());
+}
+
+for (; in<=nbn; in++) {
+BRepMesh_Vertex nod=struc->GetNode(in);
+di<<"(node "<<in<<" (uv "<<nod.Coord().X()
+<<" "<<nod.Coord().Y()<<") (3d "
+<<nod.Location3d()<<") ";
+printdegree(nod.Movability(), di);
+di<<" (edgeconex";
+BRepMesh_ListOfInteger::Iterator tati(struc->LinkNeighboursOf(in));
+for (; tati.More(); tati.Next()) di<<" "<<tati.Value();
+di << "))\n";
+}
+di <<"\n";
+return 0;
}
//=======================================================================
Standard_Integer dumpedge(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if (argc < 2) return 1;
+if (argc < 2) return 1;
- Handle(MeshTest_DrawableMesh) D =
- Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
- if (D.IsNull()) return 1;
-
- Handle(BRepMesh_DataStructureOfDelaun) struc=D->Mesh()->Result();
- Standard_Integer il=1;
- if (argc>=3) {
- il=atoi(argv[2]);
- il=Max(1, il);
- }
- Standard_Integer nbl=il;
- if (argc>=4) {
- nbl=atoi(argv[3]);
- nbl=Min(nbl, struc->NbLinks());
- }
+Handle(MeshTest_DrawableMesh) D =
+Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
+if (D.IsNull()) return 1;
- for (; il<=nbl; il++) {
- BRepMesh_Edge edg=struc->GetLink(il);
- di << "(edge "<<il<<" ("<<edg.FirstNode()<<" "<<edg.LastNode()
- <<" ";
- printdegree(edg.Movability(), di);
- di<<") (triconex";
- const MeshDS_PairOfIndex& pair = struc->ElemConnectedTo(il);
- for (Standard_Integer j = 1, jn = pair.Extent(); j <= jn; j++)
- di<<" "<<pair.Index(j);
- di << "))\n";
- }
- di <<"\n";
- return 0;
+Handle(BRepMesh_DataStructureOfDelaun) struc=D->Mesh()->Result();
+Standard_Integer il=1;
+if (argc>=3) {
+il=atoi(argv[2]);
+il=Max(1, il);
+}
+Standard_Integer nbl=il;
+if (argc>=4) {
+nbl=atoi(argv[3]);
+nbl=Min(nbl, struc->NbLinks());
+}
+
+for (; il<=nbl; il++) {
+BRepMesh_Edge edg=struc->GetLink(il);
+di << "(edge "<<il<<" ("<<edg.FirstNode()<<" "<<edg.LastNode()
+<<" ";
+printdegree(edg.Movability(), di);
+di<<") (triconex";
+const BRepMesh_PairOfIndex& pair = struc->ElemConnectedTo(il);
+for (Standard_Integer j = 1, jn = pair.Extent(); j <= jn; j++)
+di<<" "<<pair.Index(j);
+di << "))\n";
+}
+di <<"\n";
+return 0;
}
//=======================================================================
Standard_Integer dumptriangle(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
- if (argc < 2) return 1;
+if (argc < 2) return 1;
- Handle(MeshTest_DrawableMesh) D =
- Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
- if (D.IsNull()) return 1;
-
- Handle(BRepMesh_DataStructureOfDelaun) struc=D->Mesh()->Result();
- Standard_Integer ie=1;
- if (argc>=3) {
- ie=atoi(argv[2]);
- ie=Max(1, ie);
- }
- Standard_Integer nbe=ie;
- if (argc>=4) {
- nbe=atoi(argv[3]);
- nbe=Min(nbe, struc->NbElements());
- }
+Handle(MeshTest_DrawableMesh) D =
+Handle(MeshTest_DrawableMesh)::DownCast(Draw::Get(argv[1]));
+if (D.IsNull()) return 1;
- Standard_Integer e1, e2, e3;
- Standard_Boolean o1, o2, o3;
-
- for (; ie<=nbe; ie++) {
- BRepMesh_Triangle tri=struc->GetElement(ie);
- tri.Edges(e1, e2, e3, o1, o2, o3);
- if (o1) e1=-e1;
- if (o2) e2=-e2;
- if (o3) e3=-e3;
- di<<" (maille "<<ie<<" (links "<<e1<<" "
- <<e2<<" "<<e3<<")";
- printdegree(tri.Movability(), di);
- di<<")\n";
- }
- di << "\n";
- return 0;
+Handle(BRepMesh_DataStructureOfDelaun) struc=D->Mesh()->Result();
+Standard_Integer ie=1;
+if (argc>=3) {
+ie=atoi(argv[2]);
+ie=Max(1, ie);
+}
+Standard_Integer nbe=ie;
+if (argc>=4) {
+nbe=atoi(argv[3]);
+nbe=Min(nbe, struc->NbElements());
+}
+
+Standard_Integer e1, e2, e3;
+Standard_Boolean o1, o2, o3;
+
+for (; ie<=nbe; ie++) {
+BRepMesh_Triangle tri=struc->GetElement(ie);
+tri.Edges(e1, e2, e3, o1, o2, o3);
+if (o1) e1=-e1;
+if (o2) e2=-e2;
+if (o3) e3=-e3;
+di<<" (maille "<<ie<<" (links "<<e1<<" "
+<<e2<<" "<<e3<<")";
+printdegree(tri.Movability(), di);
+di<<")\n";
+}
+di << "\n";
+return 0;
}
*/
chPointValid.Show(pointvalid); chIsos.Show(isos); chPointsOnIsos.Show(pointsisos);
if (tot > 0.00001) {
- di <<"temps total de maillage: "<<tot <<" seconds"<< "\n";
- di <<"dont: "<< "\n";
- di <<"discretisation des edges: "<<edges <<" seconds---> "<< 100*edges/tot <<" %"<<"\n";
- di <<"maillage des edges: "<<mailledges <<" seconds---> "<< 100*mailledges/tot <<" %"<<"\n";
- di <<"controle et points internes: "<<etuinter <<" seconds---> "<< 100*etuinter/tot <<" %"<<"\n";
- di <<"derniers controles: "<<lastcontrol<<" seconds---> "<< 100*lastcontrol/tot<<" %"<<"\n";
- di <<"stockage dans la S.D. "<<stock <<" seconds---> "<< 100*stock/tot <<" %"<<"\n";
- di << "\n";
- di <<"et plus precisement: "<<"\n";
- di <<"Add 11ere partie : "<<add11 <<" seconds---> "<<100*add11/tot <<" %"<<"\n";
- di <<"Add 12ere partie : "<<add12 <<" seconds---> "<<100*add12/tot <<" %"<<"\n";
- di <<"Add 2eme partie : "<<add2 <<" seconds---> "<<100*add2/tot <<" %"<<"\n";
- di <<"Update : "<<upda <<" seconds---> "<<100*upda/tot <<" %"<<"\n";
- di <<"AddPoint : "<<addp <<" seconds---> "<<100*addp/tot <<" %"<<"\n";
- di <<"UniformDeflection "<<unif <<" seconds---> "<<100*unif/tot <<" %"<<"\n";
- di <<"Controle : "<<contr <<" seconds---> "<<100*contr/tot <<" %"<<"\n";
- di <<"Points Internes: "<<inter <<" seconds---> "<<100*inter/tot <<" %"<<"\n";
- di <<"calcul des isos et du, dv: "<<isos <<" seconds---> "<<100*isos/tot <<" %"<<"\n";
- di <<"calcul des points sur isos: "<<pointsisos<<" seconds---> "<<100*pointsisos/tot <<" %"<<"\n";
- di <<"IsPointValid: "<<pointvalid<<" seconds---> "<<100*pointvalid/tot <<" %"<<"\n";
- di << "\n";
-
-
- di <<"nombre d'appels de controle apres points internes : "<< NbControls << "\n";
- di <<"nombre de points sur restrictions : "<< D0Edges << "\n";
- di <<"nombre de points calcules par UniformDeflection : "<< D0Unif << "\n";
- di <<"nombre de points calcules dans InternalVertices : "<< D0Internal << "\n";
- di <<"nombre de points calcules dans Control : "<< D0Control << "\n";
- if (nbnodes-D0Edges != 0) {
- Standard_Real ratio = (Standard_Real)(D0Internal+D0Control)/ (Standard_Real)(nbnodes-D0Edges);
- di <<"---> Ratio: (D0Internal+D0Control) / (nbNodes-nbOnEdges) : "<< ratio << "\n";
- }
+ di <<"temps total de maillage: "<<tot <<" seconds"<< "\n";
+ di <<"dont: "<< "\n";
+ di <<"discretisation des edges: "<<edges <<" seconds---> "<< 100*edges/tot <<" %"<<"\n";
+ di <<"maillage des edges: "<<mailledges <<" seconds---> "<< 100*mailledges/tot <<" %"<<"\n";
+ di <<"controle et points internes: "<<etuinter <<" seconds---> "<< 100*etuinter/tot <<" %"<<"\n";
+ di <<"derniers controles: "<<lastcontrol<<" seconds---> "<< 100*lastcontrol/tot<<" %"<<"\n";
+ di <<"stockage dans la S.D. "<<stock <<" seconds---> "<< 100*stock/tot <<" %"<<"\n";
+ di << "\n";
+ di <<"et plus precisement: "<<"\n";
+ di <<"Add 11ere partie : "<<add11 <<" seconds---> "<<100*add11/tot <<" %"<<"\n";
+ di <<"Add 12ere partie : "<<add12 <<" seconds---> "<<100*add12/tot <<" %"<<"\n";
+ di <<"Add 2eme partie : "<<add2 <<" seconds---> "<<100*add2/tot <<" %"<<"\n";
+ di <<"Update : "<<upda <<" seconds---> "<<100*upda/tot <<" %"<<"\n";
+ di <<"AddPoint : "<<addp <<" seconds---> "<<100*addp/tot <<" %"<<"\n";
+ di <<"UniformDeflection "<<unif <<" seconds---> "<<100*unif/tot <<" %"<<"\n";
+ di <<"Controle : "<<contr <<" seconds---> "<<100*contr/tot <<" %"<<"\n";
+ di <<"Points Internes: "<<inter <<" seconds---> "<<100*inter/tot <<" %"<<"\n";
+ di <<"calcul des isos et du, dv: "<<isos <<" seconds---> "<<100*isos/tot <<" %"<<"\n";
+ di <<"calcul des points sur isos: "<<pointsisos<<" seconds---> "<<100*pointsisos/tot <<" %"<<"\n";
+ di <<"IsPointValid: "<<pointvalid<<" seconds---> "<<100*pointvalid/tot <<" %"<<"\n";
+ di << "\n";
+
+
+ di <<"nombre d'appels de controle apres points internes : "<< NbControls << "\n";
+ di <<"nombre de points sur restrictions : "<< D0Edges << "\n";
+ di <<"nombre de points calcules par UniformDeflection : "<< D0Unif << "\n";
+ di <<"nombre de points calcules dans InternalVertices : "<< D0Internal << "\n";
+ di <<"nombre de points calcules dans Control : "<< D0Control << "\n";
+ if (nbnodes-D0Edges != 0) {
+ Standard_Real ratio = (Standard_Real)(D0Internal+D0Control)/ (Standard_Real)(nbnodes-D0Edges);
+ di <<"---> Ratio: (D0Internal+D0Control) / (nbNodes-nbOnEdges) : "<< ratio << "\n";
+ }
- di << "\n";
+ di << "\n";
- chTotal.Reset(); chAddPoint.Reset(); chUnif.Reset();
- chControl.Reset(); chInternal.Reset();
- chEdges.Reset(); chMaillEdges.Reset();
- chEtuInter.Reset(); chLastControl.Reset();
- chStock.Reset();
- chAdd11.Reset(); chAdd12.Reset(); chAdd2.Reset(); chUpdate.Reset();
- chPointValid.Reset(); chIsos.Reset(); chPointsOnIsos.Reset();
+ chTotal.Reset(); chAddPoint.Reset(); chUnif.Reset();
+ chControl.Reset(); chInternal.Reset();
+ chEdges.Reset(); chMaillEdges.Reset();
+ chEtuInter.Reset(); chLastControl.Reset();
+ chStock.Reset();
+ chAdd11.Reset(); chAdd12.Reset(); chAdd2.Reset(); chUpdate.Reset();
+ chPointValid.Reset(); chIsos.Reset(); chPointsOnIsos.Reset();
}
#endif
Standard_Integer i, n1, n2, n3;
gp_Pnt2d mitri, v1, v2, v3, mi2d1, mi2d2, mi2d3;
gp_XYZ vecEd1, vecEd2, vecEd3;
-// Standard_Real dipo, dm, dv, d1, d2, d3, defle;
+ // Standard_Real dipo, dm, dv, d1, d2, d3, defle;
Standard_Real dipo, dv, d1, d2, d3, defle;
Handle(Geom_Surface) S;
Standard_Integer nbface = 0;
S = BRep_Tool::Surface(F, L);
for(i = 1; i <= triangles.Length(); i++) {
- if (F.Orientation() == TopAbs_REVERSED)
- triangles(i).Get(n1,n3,n2);
- else
- triangles(i).Get(n1,n2,n3);
-
- const gp_XY& xy1 = Nodes2d(n1).XY();
- const gp_XY& xy2 = Nodes2d(n2).XY();
- const gp_XY& xy3 = Nodes2d(n3).XY();
-
- mi2d1.SetCoord((xy2.X()+xy3.X())*0.5,
- (xy2.Y()+xy3.Y())*0.5);
- mi2d2.SetCoord((xy1.X()+xy3.X())*0.5,
- (xy1.Y()+xy3.Y())*0.5);
- mi2d3.SetCoord((xy1.X()+xy2.X())*0.5,
- (xy1.Y()+xy2.Y())*0.5);
-
- gp_XYZ p1 = Nodes(n1).Transformed(L.Transformation()).XYZ();
- gp_XYZ p2 = Nodes(n2).Transformed(L.Transformation()).XYZ();
- gp_XYZ p3 = Nodes(n3).Transformed(L.Transformation()).XYZ();
-
- vecEd1=p2-p1;
- vecEd2=p3-p2;
- vecEd3=p1-p3;
- d1=vecEd1.SquareModulus();
- d2=vecEd2.SquareModulus();
- d3=vecEd3.SquareModulus();
-
- if (d1!=0. && d2!=0. && d3!=0.) {
- gp_XYZ equa(vecEd1^vecEd2);
- dv=equa.Modulus();
- if (dv>0.) {
- equa.SetCoord(equa.X()/dv, equa.Y()/dv, equa.Z()/dv);
- dipo=equa*p1;
-
-
- mitri.SetCoord(ONETHIRD*(xy1.X()+xy2.X()+xy3.X()),
- ONETHIRD*(xy1.Y()+xy2.Y()+xy3.Y()));
- v1.SetCoord(ONETHIRD*mi2d1.X()+TWOTHIRD*xy1.X(),
- ONETHIRD*mi2d1.Y()+TWOTHIRD*xy1.Y());
- v2.SetCoord(ONETHIRD*mi2d2.X()+TWOTHIRD*xy2.X(),
- ONETHIRD*mi2d2.Y()+TWOTHIRD*xy2.Y());
- v3.SetCoord(ONETHIRD*mi2d3.X()+TWOTHIRD*xy3.X(),
- ONETHIRD*mi2d3.Y()+TWOTHIRD*xy3.Y());
-
- S->D0(mi2d1.X(), mi2d1.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- S->D0(mi2d2.X(), mi2d2.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- S->D0(mi2d3.X(), mi2d3.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- S->D0(v1.X(), v1.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- S->D0(v2.X(), v2.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- S->D0(v3.X(), v3.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- S->D0(mitri.X(), mitri.Y(), PP);
- PP = PP.Transformed(L.Transformation());
- defle = Abs((equa*PP.XYZ())-dipo);
- deflemax = Max(deflemax, defle);
- deflemin = Min(deflemin, defle);
-
- if (defle > defstock) {
- di <<"face "<< nbface <<" deflection = " << defle <<" pour "<<defstock <<" stockee."<<"\n";
- }
- }
- }
+ if (F.Orientation() == TopAbs_REVERSED)
+ triangles(i).Get(n1,n3,n2);
+ else
+ triangles(i).Get(n1,n2,n3);
+
+ const gp_XY& xy1 = Nodes2d(n1).XY();
+ const gp_XY& xy2 = Nodes2d(n2).XY();
+ const gp_XY& xy3 = Nodes2d(n3).XY();
+
+ mi2d1.SetCoord((xy2.X()+xy3.X())*0.5,
+ (xy2.Y()+xy3.Y())*0.5);
+ mi2d2.SetCoord((xy1.X()+xy3.X())*0.5,
+ (xy1.Y()+xy3.Y())*0.5);
+ mi2d3.SetCoord((xy1.X()+xy2.X())*0.5,
+ (xy1.Y()+xy2.Y())*0.5);
+
+ gp_XYZ p1 = Nodes(n1).Transformed(L.Transformation()).XYZ();
+ gp_XYZ p2 = Nodes(n2).Transformed(L.Transformation()).XYZ();
+ gp_XYZ p3 = Nodes(n3).Transformed(L.Transformation()).XYZ();
+
+ vecEd1=p2-p1;
+ vecEd2=p3-p2;
+ vecEd3=p1-p3;
+ d1=vecEd1.SquareModulus();
+ d2=vecEd2.SquareModulus();
+ d3=vecEd3.SquareModulus();
+
+ if (d1!=0. && d2!=0. && d3!=0.) {
+ gp_XYZ equa(vecEd1^vecEd2);
+ dv=equa.Modulus();
+ if (dv>0.) {
+ equa.SetCoord(equa.X()/dv, equa.Y()/dv, equa.Z()/dv);
+ dipo=equa*p1;
+
+
+ mitri.SetCoord(ONETHIRD*(xy1.X()+xy2.X()+xy3.X()),
+ ONETHIRD*(xy1.Y()+xy2.Y()+xy3.Y()));
+ v1.SetCoord(ONETHIRD*mi2d1.X()+TWOTHIRD*xy1.X(),
+ ONETHIRD*mi2d1.Y()+TWOTHIRD*xy1.Y());
+ v2.SetCoord(ONETHIRD*mi2d2.X()+TWOTHIRD*xy2.X(),
+ ONETHIRD*mi2d2.Y()+TWOTHIRD*xy2.Y());
+ v3.SetCoord(ONETHIRD*mi2d3.X()+TWOTHIRD*xy3.X(),
+ ONETHIRD*mi2d3.Y()+TWOTHIRD*xy3.Y());
+
+ S->D0(mi2d1.X(), mi2d1.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ S->D0(mi2d2.X(), mi2d2.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ S->D0(mi2d3.X(), mi2d3.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ S->D0(v1.X(), v1.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ S->D0(v2.X(), v2.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ S->D0(v3.X(), v3.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ S->D0(mitri.X(), mitri.Y(), PP);
+ PP = PP.Transformed(L.Transformation());
+ defle = Abs((equa*PP.XYZ())-dipo);
+ deflemax = Max(deflemax, defle);
+ deflemin = Min(deflemin, defle);
+
+ if (defle > defstock) {
+ di <<"face "<< nbface <<" deflection = " << defle <<" pour "<<defstock <<" stockee."<<"\n";
+ }
+ }
+ }
}
if (!quiet) {
- di <<"face "<< nbface<<", deflemin = "<< deflemin<<", deflemax = "<<deflemax<<"\n";
+ di <<"face "<< nbface<<", deflemin = "<< deflemin<<", deflemax = "<<deflemax<<"\n";
}
}
if (n != 2) return 1;
TopoDS_Shape aLocalShape = DBRep::Get(a[1]);
TopoDS_Face F = TopoDS::Face(aLocalShape);
-// TopoDS_Face F = TopoDS::Face(DBRep::Get(a[1]));
+ // TopoDS_Face F = TopoDS::Face(DBRep::Get(a[1]));
if (F.IsNull()) return 1;
Handle(Poly_Triangulation) T;
TopLoc_Location L;
// Build the connect tool
Poly_Connect pc(T);
-
+
Standard_Integer i,j, nFree, nInternal, nbTriangles = T->NbTriangles();
Standard_Integer t[3];
-
+
// count the free edges
nFree = 0;
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
for (j = 0; j < 3; j++)
- if (t[j] == 0) nFree++;
+ if (t[j] == 0) nFree++;
}
-
+
// allocate the arrays
TColStd_Array1OfInteger Free(1,2*nFree);
nInternal = (3*nbTriangles - nFree) / 2;
TColStd_Array1OfInteger Internal(0,2*nInternal);
-
+
Standard_Integer fr = 1, in = 1;
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer nodes[3];
pc.Triangles(i,t[0],t[1],t[2]);
triangles(i).Get(nodes[0],nodes[1],nodes[2]);
for (j = 0; j < 3; j++) {
- Standard_Integer k = (j+1) % 3;
- if (t[j] == 0) {
- Free(fr) = nodes[j];
- Free(fr+1) = nodes[k];
- fr += 2;
- }
- // internal edge if this triangle has a lower index than the adjacent
- else if (i < t[j]) {
- Internal(in) = nodes[j];
- Internal(in+1) = nodes[k];
- in += 2;
- }
+ Standard_Integer k = (j+1) % 3;
+ if (t[j] == 0) {
+ Free(fr) = nodes[j];
+ Free(fr+1) = nodes[k];
+ fr += 2;
+ }
+ // internal edge if this triangle has a lower index than the adjacent
+ else if (i < t[j]) {
+ Internal(in) = nodes[j];
+ Internal(in+1) = nodes[k];
+ in += 2;
+ }
}
}
-
+
// Display the edges
if (T->HasUVNodes()) {
const TColgp_Array1OfPnt2d& Nodes2d = T->UVNodes();
Standard_Integer nn;
nn = Free.Length() / 2;
for (i = 1; i <= nn; i++) {
- Seg = new Draw_Segment2D(Nodes2d(Free(2*i-1)),
- Nodes2d(Free(2*i)),
- Draw_rouge);
- dout << Seg;
+ Seg = new Draw_Segment2D(Nodes2d(Free(2*i-1)),
+ Nodes2d(Free(2*i)),
+ Draw_rouge);
+ dout << Seg;
}
-
+
// internal edges
-
+
nn = nInternal;
for (i = 1; i <= nn; i++) {
- Seg = new Draw_Segment2D(Nodes2d(Internal(2*i-1)),
- Nodes2d(Internal(2*i)),
- Draw_bleu);
- dout << Seg;
+ Seg = new Draw_Segment2D(Nodes2d(Internal(2*i-1)),
+ Nodes2d(Internal(2*i)),
+ Draw_bleu);
+ dout << Seg;
}
}
dout.Flush();
Standard_Real x, y, z;
Standard_Integer n1, n2, n3;
Standard_Integer k1, k2, k3;
-
+
char ffile[100];
-
+
if (nbarg == 3) {
strcpy(ffile, argv[2]);
strcat(ffile, ".obj");
nbface++;
TopoDS_Face F = TopoDS::Face(ex.Current());
Handle(Poly_Triangulation) Tr = BRep_Tool::Triangulation(F, L);
-
+
if (!Tr.IsNull()) {
nbNodes = Tr->NbNodes();
const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
-
+
// les noeuds.
for (i = 1; i <= nbNodes; i++) {
- gp_Pnt Pnt = Nodes(i).Transformed(L.Transformation());
- x = Pnt.X();
- y = Pnt.Y();
- z = Pnt.Z();
- fprintf(outfile, "%s %f %f %f\n", "v", x, y, z);
+ gp_Pnt Pnt = Nodes(i).Transformed(L.Transformation());
+ x = Pnt.X();
+ y = Pnt.Y();
+ z = Pnt.Z();
+ fprintf(outfile, "%s %f %f %f\n", "v", x, y, z);
}
-
+
fprintf(outfile, "\n%s %d\n\n", "# number of vertex", nbNodes);
-
-
+
+
// les normales.
-
+
if (Tr->HasUVNodes()) {
- const TColgp_Array1OfPnt2d& UVNodes = Tr->UVNodes();
- BRepAdaptor_Surface BS(F, Standard_False);
-
- for (i = 1; i <= nbNodes; i++) {
- U = UVNodes(i).X();
- V = UVNodes(i).Y();
-
- BS.D1(U,V,P,D1U,D1V);
- CSLib::Normal(D1U,D1V,Precision::Angular(),Status,Nor);
- if (Status != CSLib_Done) {
- BS.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
- CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,Precision::Angular(),OK,NStat,Nor);
- }
- if (F.Orientation() == TopAbs_REVERSED) Nor.Reverse();
-
- fprintf(outfile, "%s %f %f %f\n", "vn", Nor.X(), Nor.Y(), Nor.Z());
- }
-
- fprintf(outfile, "\n%s %d\n\n", "# number of vertex normals", nbNodes);
+ const TColgp_Array1OfPnt2d& UVNodes = Tr->UVNodes();
+ BRepAdaptor_Surface BS(F, Standard_False);
+
+ for (i = 1; i <= nbNodes; i++) {
+ U = UVNodes(i).X();
+ V = UVNodes(i).Y();
+
+ BS.D1(U,V,P,D1U,D1V);
+ CSLib::Normal(D1U,D1V,Precision::Angular(),Status,Nor);
+ if (Status != CSLib_Done) {
+ BS.D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
+ CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,Precision::Angular(),OK,NStat,Nor);
+ }
+ if (F.Orientation() == TopAbs_REVERSED) Nor.Reverse();
+
+ fprintf(outfile, "%s %f %f %f\n", "vn", Nor.X(), Nor.Y(), Nor.Z());
+ }
+
+ fprintf(outfile, "\n%s %d\n\n", "# number of vertex normals", nbNodes);
}
-
+
fprintf(outfile, "%s %d\n", "s", nbface);
-
+
// les triangles.
Standard_Integer nbTriangles = Tr->NbTriangles();
const Poly_Array1OfTriangle& triangles = Tr->Triangles();
-
-
+
+
for (i = 1; i <= nbTriangles; i++) {
- if (F.Orientation() == TopAbs_REVERSED)
- triangles(i).Get(n1, n3, n2);
- else
- triangles(i).Get(n1, n2, n3);
- k1 = n1+totalnodes;
- k2 = n2+totalnodes;
- k3 = n3+totalnodes;
- fprintf(outfile, "%s %d%s%d %d%s%d %d%s%d\n", "fo", k1,"//", k1, k2,"//", k2, k3,"//", k3);
+ if (F.Orientation() == TopAbs_REVERSED)
+ triangles(i).Get(n1, n3, n2);
+ else
+ triangles(i).Get(n1, n2, n3);
+ k1 = n1+totalnodes;
+ k2 = n2+totalnodes;
+ k3 = n3+totalnodes;
+ fprintf(outfile, "%s %d%s%d %d%s%d %d%s%d\n", "fo", k1,"//", k1, k2,"//", k2, k3,"//", k3);
}
nbpolygons += nbTriangles;
totalnodes += nbNodes;
-
+
fprintf(outfile, "\n%s %d\n", "# number of smooth groups", nbface);
fprintf(outfile, "\n%s %d\n", "# number of polygons", nbpolygons);
-
+
}
}
Standard_Integer onetriangulation(Draw_Interpretor&, Standard_Integer nbarg, const char** argv)
{
-/*
+ /*
if (nbarg < 2) return 1;
TopoDS_Shape S = DBRep::Get(argv[1]);
if (S.IsNull()) return 1;
-
+
Handle(Poly_Triangulation) TFinale;
char name[100];
Standard_Integer nbshell = 0;
TopExp_Explorer ex, exs, ex2;
-
+
for (ex.Init(S, TopAbs_SHELL); ex.More(); ex.Next()) {
- nbshell++;
- TopoDS_Shell Sh = TopoDS::Shell(ex.Current());
-
- for (exs.Init(Sh, TopAbs_Face); exs.More(); exs.Next()) {
- TopoDS_Face F = TopoDS::Face(exs.Current());
- Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
-
- for (ex2.Init(F, TopAbs_EDGE); ex2.More(); ex2.Next()) {
- TopoDS_Edge edge = TopoDS::Edge(ex2.Current());
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
- const Poly_Array1OfTriangle& triangles = T->Triangles();
-
- if (mapedges.IsBound(edge)) {
- const TColStd_ListOfTransient& L = edges.Find(edge);
- const Handle(Poly_PolygonOnTriangulation)& P =
- *(Handle(Poly_PolygonOnTriangulation)*)&(L.First());
- const TColStd_Array1OfInteger& NOD = P->Nodes();
-
- }
- }
- }
-
- sprintf(name, "%s_%i", "tr", nbshell);
- DrawTrSurf::Set(name, TFinale);
+ nbshell++;
+ TopoDS_Shell Sh = TopoDS::Shell(ex.Current());
+
+ for (exs.Init(Sh, TopAbs_Face); exs.More(); exs.Next()) {
+ TopoDS_Face F = TopoDS::Face(exs.Current());
+ Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
+
+ for (ex2.Init(F, TopAbs_EDGE); ex2.More(); ex2.Next()) {
+ TopoDS_Edge edge = TopoDS::Edge(ex2.Current());
+ const TColgp_Array1OfPnt& Nodes = T->Nodes();
+ const Poly_Array1OfTriangle& triangles = T->Triangles();
+ if (mapedges.IsBound(edge)) {
+ const TColStd_ListOfTransient& L = edges.Find(edge);
+ const Handle(Poly_PolygonOnTriangulation)& P =
+ *(Handle(Poly_PolygonOnTriangulation)*)&(L.First());
+ const TColStd_Array1OfInteger& NOD = P->Nodes();
+
+ }
+ }
}
-*/
+ sprintf(name, "%s_%i", "tr", nbshell);
+ DrawTrSurf::Set(name, TFinale);
+
+ }
+
+ */
return 0;
}
math_Vector GaussP(1, NbPoints), GaussW(1, NbPoints);
math_Vector TheWeights(1, NbPoints), VBParam(1, NbPoints);
math_Matrix VB(1, Deg+1, 1, NbPoints);
-
+
math::GaussPoints(NbPoints, GaussP);
-
+
Standard_Integer i, j, classe = Deg+1, cl1 = Deg;
-
+
// calcul et mise en ordre des parametres et des poids:
for (i = 1; i <= NbPoints; i++) {
- if (i <= (NbPoints+1)/2) {
- VBParam(NbPoints-i+1) = 0.5*(1 + GaussP(i));
- }
- else {
- VBParam(i-(NbPoints+1)/2) = 0.5*(1 + GaussP(i));
- }
+ if (i <= (NbPoints+1)/2) {
+ VBParam(NbPoints-i+1) = 0.5*(1 + GaussP(i));
+ }
+ else {
+ VBParam(i-(NbPoints+1)/2) = 0.5*(1 + GaussP(i));
+ }
}
-
-
+
+
// Calcul du VB (Valeur des fonctions de Bernstein):
for (i = 1; i <= classe; i++) {
- for (j = 1; j <= NbPoints; j++) {
- VB(i,j)=PLib::Binomial(cl1,i-1)*Pow((1-VBParam(j)),classe-i)*Pow(VBParam(j),i-1);
- }
+ for (j = 1; j <= NbPoints; j++) {
+ VB(i,j)=PLib::Binomial(cl1,i-1)*Pow((1-VBParam(j)),classe-i)*Pow(VBParam(j),i-1);
+ }
}
-
-
+
+
for (i = 1; i <= classe; i++) {
- for (j = 1; j <= NbPoints; j++) {
- di<< VB(i, j) << ", ";
- }
+ for (j = 1; j <= NbPoints; j++) {
+ di<< VB(i, j) << ", ";
+ }
}
di << "\n" << "\n";
}
Standard_Integer extrema(Draw_Interpretor& di, Standard_Integer nbarg, const char** argv)
{
-
-
+
+
Handle(Geom_Curve) C = DrawTrSurf::GetCurve(argv[1]);
Standard_Real X, Y, Z, U0;
//=======================================================================
- void MeshTest::Commands(Draw_Interpretor& theCommands)
+void MeshTest::Commands(Draw_Interpretor& theCommands)
//=======================================================================
{
Draw::Commands(theCommands);
const char* g;
g = "Mesh Commands";
-
+
theCommands.Add("shpsec","shpsec result shape shape",__FILE__, shapesection, g);
theCommands.Add("plnsec","plnsec result shape plane",__FILE__, planesection, g);
theCommands.Add("incmesh","incmesh shape deflection",__FILE__, incrementalmesh, g);
#include <Draw_Color.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <Standard_RangeError.hxx>
-#include <MeshDS_DegreeOfFreedom.hxx>
+#include <BRepMesh_DegreeOfFreedom.hxx>
#include <BRepMesh_Edge.hxx>
#include <BRepMesh_Vertex.hxx>
#include <BRepMesh_Triangle.hxx>
//=======================================================================
MeshTest_DrawableMesh::MeshTest_DrawableMesh() :
- myDeflection(1.), myinshape(Standard_False)
+myDeflection(1.), myinshape(Standard_False)
{
}
//=======================================================================
MeshTest_DrawableMesh::MeshTest_DrawableMesh(const TopoDS_Shape& S,
- const Standard_Real Deflect,
- const Standard_Boolean Partage,
- const Standard_Boolean inshape) :
- myDeflection(Deflect), myinshape(inshape)
+ const Standard_Real Deflect,
+ const Standard_Boolean Partage,
+ const Standard_Boolean inshape) :
+myDeflection(Deflect), myinshape(inshape)
{
Bnd_Box B;
BRepBndLib::Add(S, B);
-
+
myMesh = new BRepMesh_FastDiscret(Deflect, S, B, 0.5, Partage, inshape);
}
//=======================================================================
MeshTest_DrawableMesh::MeshTest_DrawableMesh(const Handle(BRepMesh_FastDiscret)& Tr):
- myDeflection(1.0)
+myDeflection(1.0)
{
- myMesh = Tr;
+ myMesh = Tr;
}
/* Handle(BRepMesh_DataStructureOfDelaun) struc = myMesh->Result();
Standard_Integer nbc;
D.SetColor(Draw_vert);
-
+
for (Standard_Integer iLi=1; iLi<=myMesh->NbEdges(); iLi++) {
- const BRepMesh_Edge& ed=myMesh->Edge(iLi);
- if (ed.Movability()!=MeshDS_Deleted) {
- nbc=struc->ElemConnectedTo(iLi).Extent();
- if (nbc<=0) D.SetColor(Draw_bleu);
- else if (nbc==1) D.SetColor(Draw_jaune);
- else if (nbc==2) D.SetColor(Draw_vert);
- else D.SetColor(Draw_corail);
- D.MoveTo(myMesh->Pnt(ed.FirstNode()));
- D.DrawTo(myMesh->Pnt(ed.LastNode()));
- }
+ const BRepMesh_Edge& ed=myMesh->Edge(iLi);
+ if (ed.Movability()!=BRepMesh_Deleted) {
+ nbc=struc->ElemConnectedTo(iLi).Extent();
+ if (nbc<=0) D.SetColor(Draw_bleu);
+ else if (nbc==1) D.SetColor(Draw_jaune);
+ else if (nbc==2) D.SetColor(Draw_vert);
+ else D.SetColor(Draw_corail);
+ D.MoveTo(myMesh->Pnt(ed.FirstNode()));
+ D.DrawTo(myMesh->Pnt(ed.LastNode()));
+ }
}
Standard_Boolean o1, o2, o3;
for (i = 1; i <= myTriangles.Length(); i++) {
- const BRepMesh_Triangle& tri=struc->GetElement(myTriangles(i));
- tri.Edges(e1, e2, e3, o1, o2, o3);
- const BRepMesh_Edge& ed1=myMesh->Edge(e1);
- if (ed1.Movability()!=MeshDS_Deleted) {
- D.MoveTo(myMesh->Pnt(ed1.FirstNode()));
- D.DrawTo(myMesh->Pnt(ed1.LastNode()));
- }
- const BRepMesh_Edge& ed2=myMesh->Edge(e2);
- if (ed2.Movability()!=MeshDS_Deleted) {
- D.MoveTo(myMesh->Pnt(ed2.FirstNode()));
- D.DrawTo(myMesh->Pnt(ed2.LastNode()));
- }
- const BRepMesh_Edge& ed3=myMesh->Edge(e3);
- if (ed3.Movability()!=MeshDS_Deleted) {
- D.MoveTo(myMesh->Pnt(ed3.FirstNode()));
- D.DrawTo(myMesh->Pnt(ed3.LastNode()));
- }
+ const BRepMesh_Triangle& tri=struc->GetElement(myTriangles(i));
+ tri.Edges(e1, e2, e3, o1, o2, o3);
+ const BRepMesh_Edge& ed1=myMesh->Edge(e1);
+ if (ed1.Movability()!=BRepMesh_Deleted) {
+ D.MoveTo(myMesh->Pnt(ed1.FirstNode()));
+ D.DrawTo(myMesh->Pnt(ed1.LastNode()));
+ }
+ const BRepMesh_Edge& ed2=myMesh->Edge(e2);
+ if (ed2.Movability()!=BRepMesh_Deleted) {
+ D.MoveTo(myMesh->Pnt(ed2.FirstNode()));
+ D.DrawTo(myMesh->Pnt(ed2.LastNode()));
+ }
+ const BRepMesh_Edge& ed3=myMesh->Edge(e3);
+ if (ed3.Movability()!=BRepMesh_Deleted) {
+ D.MoveTo(myMesh->Pnt(ed3.FirstNode()));
+ D.DrawTo(myMesh->Pnt(ed3.LastNode()));
+ }
}
// highlighted edges
D.SetColor(Draw_rouge);
for (i = 1; i <= myEdges.Length(); i++) {
- const BRepMesh_Edge& ed=myMesh->Edge(myEdges(i));
- if (ed.Movability()!=MeshDS_Deleted) {
- D.MoveTo(myMesh->Pnt(ed.FirstNode()));
- D.DrawTo(myMesh->Pnt(ed.LastNode()));
- }
+ const BRepMesh_Edge& ed=myMesh->Edge(myEdges(i));
+ if (ed.Movability()!=BRepMesh_Deleted) {
+ D.MoveTo(myMesh->Pnt(ed.FirstNode()));
+ D.DrawTo(myMesh->Pnt(ed.LastNode()));
+ }
}
// highlighted vertices
for (i = 1; i <= myVertices.Length(); i++) {
- D.DrawMarker(myMesh->Pnt(myVertices(i)),Draw_Losange);
+ D.DrawMarker(myMesh->Pnt(myVertices(i)),Draw_Losange);
}
*/
//purpose :
//=======================================================================
-static void printdegree(MeshDS_DegreeOfFreedom dof)
+static void printdegree(BRepMesh_DegreeOfFreedom dof)
{
switch (dof) {
- case MeshDS_InVolume :
+ case BRepMesh_InVolume :
cout << "InVolume";
break;
- case MeshDS_OnSurface :
+ case BRepMesh_OnSurface :
cout << "OnSurface";
break;
- case MeshDS_OnCurve :
+ case BRepMesh_OnCurve :
cout << "OnCurve";
break;
- case MeshDS_Fixed :
+ case BRepMesh_Fixed :
cout << "Fixed";
break;
- case MeshDS_Frontier :
+ case BRepMesh_Frontier :
cout << "Frontier";
break;
- case MeshDS_Deleted :
+ case BRepMesh_Deleted :
cout << "Deleted";
break;
- case MeshDS_Free :
+ case BRepMesh_Free :
cout << "Free";
break;
}
void MeshTest_DrawableMesh::Dump(Standard_OStream& S) const
{
// Should be reimplemented
-
+
/*Handle(BRepMesh_DataStructureOfDelaun) struc=myMesh->Result();
Standard_Integer e1, e2, e3;
Standard_Boolean o1, o2, o3;
Standard_Integer nbn=struc->NbNodes();
Standard_Integer nbl=struc->NbLinks();
Standard_Integer nbe=struc->NbElements();
-
+
for (in=1; in<=nbn; in++) {
- BRepMesh_Vertex nod=struc->GetNode(in);
- S<<"(node "<<in<<" (uv "<<nod.Coord().X()<<" "
- <<nod.Coord().Y()<<") (3d "
- <<nod.Location3d()<<") ";
- printdegree(nod.Movability());
- S<<" (edgeconex";
- MeshDS_ListOfInteger::Iterator tati(struc->LinkNeighboursOf(in));
- for (; tati.More(); tati.Next()) S<<" "<<tati.Value();
- S << "))\n";
+ BRepMesh_Vertex nod=struc->GetNode(in);
+ S<<"(node "<<in<<" (uv "<<nod.Coord().X()<<" "
+ <<nod.Coord().Y()<<") (3d "
+ <<nod.Location3d()<<") ";
+ printdegree(nod.Movability());
+ S<<" (edgeconex";
+ BRepMesh_ListOfInteger::Iterator tati(struc->LinkNeighboursOf(in));
+ for (; tati.More(); tati.Next()) S<<" "<<tati.Value();
+ S << "))\n";
}
S <<endl;
for (il=1; il<=nbl; il++) {
- BRepMesh_Edge edg=struc->GetLink(il);
- S << "(edge "<<il<<" ("<<edg.FirstNode()<<" "<<edg.LastNode()
- <<" ";
- printdegree(edg.Movability());
- S<<") (triconex";
- const MeshDS_PairOfIndex& pair = struc->ElemConnectedTo(il);
- for (Standard_Integer j = 1, jn = pair.Extent(); j <= jn; j++)
- S<<" "<<pair.Index(j);
- S << "))\n";
+ BRepMesh_Edge edg=struc->GetLink(il);
+ S << "(edge "<<il<<" ("<<edg.FirstNode()<<" "<<edg.LastNode()
+ <<" ";
+ printdegree(edg.Movability());
+ S<<") (triconex";
+ const BRepMesh_PairOfIndex& pair = struc->ElemConnectedTo(il);
+ for (Standard_Integer j = 1, jn = pair.Extent(); j <= jn; j++)
+ S<<" "<<pair.Index(j);
+ S << "))\n";
}
S <<endl;
for (ie=1; ie<=nbe; ie++) {
- BRepMesh_Triangle tri=struc->GetElement(ie);
- tri.Edges(e1, e2, e3, o1, o2, o3);
- if (!o1) e1=-e1;
- if (!o2) e2=-e2;
- if (!o3) e3=-e3;
- S<<" (maille "<<ie<<" (links "<<e1<<" "
- <<e2<<" "<<e3<<")";
- printdegree(tri.Movability());
- S<<")\n";
+ BRepMesh_Triangle tri=struc->GetElement(ie);
+ tri.Edges(e1, e2, e3, o1, o2, o3);
+ if (!o1) e1=-e1;
+ if (!o2) e2=-e2;
+ if (!o3) e3=-e3;
+ S<<" (maille "<<ie<<" (links "<<e1<<" "
+ <<e2<<" "<<e3<<")";
+ printdegree(tri.Movability());
+ S<<")\n";
}
S << endl;
*/
-MeshDS
BRepMesh
-MeshAlgo
IntPoly