1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0025039: Improvement of code structure of general and supporting tools implemented in BRepMesh

Removed CDL declarations; Data collections are replaced by NCollections; Small code refactoring.
Remove definition of BRepMesh class. Code refactoring of BRepMesh_IncrementalMesh.
Function BRepMesh_Write storing BRepMesh_DataStructureOfDelaun to BRep file is added for debug needs.
Static method BRepMesh_GeomTool::IntLinLin has been added to eliminate code duplications in BRepMesh_Dealun and BRepMesh_CircleTool.
BRepMesh_CircleTool simplified method to find circumcircle.

Fix merging conflicts
Remove redundant function
Fix compilation warning on MacOS
Revert changes occurred during rebase
Resolved merging conflicts
Use parallel flag with BRepMesh_FastDiscret

Test cases for issue CR25039_2
This commit is contained in:
oan 2014-07-10 14:51:15 +04:00 committed by apn
parent b6c0b841ec
commit fc9b36d630
109 changed files with 5266 additions and 6602 deletions

View File

@ -80,6 +80,16 @@ const char* BRepTools_DumpLoc (void* theShapePtr)
Dumps shape or its location to cout.
- *theShapePtr* - a pointer to *TopoDS_Shape* variable.
The following function is provided by *TKMesh* toolkit:
~~~~~
const char* BRepMesh_Dump (void* theMeshHandlePtr, const char* theFileNameStr)
~~~~~
Stores mesh produced in parametric space to BREP file.
- *theMeshHandlePtr* - a pointer to *Handle(BRepMesh_DataStructureOfDelaun)* variable.
- *theFileNameStr* - name of file the mesh sould be stored to.
The following additional function is provided by *TKGeomBase* toolkit:
~~~~~
@ -119,6 +129,7 @@ For convenience it is possible to define aliases to commands in this window, for
>alias saveshape ? ({,,TKBRep}BRepTools_Write)
>alias dumpshape ? ({,,TKBRep}BRepTools_Dump)
>alias dumploc ? ({,,TKBRep}BRepTools_DumpLoc)
>alias dumpmesh ? ({,,TKMesh}BRepMesh_Dump)
>alias dumpgeom ? ({,,TKGeomBase}GeomTools_Dump)
~~~~~

View File

@ -44,147 +44,43 @@ uses Standard,
SortTools,
Plugin
is enumeration DegreeOfFreedom is
Free,
InVolume,
OnSurface,
OnCurve,
Fixed,
Frontier,
Deleted;
is
imported DegreeOfFreedom from BRepMesh;
imported Status from BRepMesh;
enumeration FactoryError is
FE_NOERROR,
FE_LIBRARYNOTFOUND,
FE_FUNCTIONNOTFOUND,
FE_CANNOTCREATEALGO
end FactoryError;
class Vertex;
class Edge;
imported Triangle from BRepMesh;
class ShapeTool;
class Circ;
deferred class DiscretRoot;
class DiscretFactory;
imported FactoryError from BRepMesh;
imported Vertex from BRepMesh;
imported Edge from BRepMesh;
imported Triangle from BRepMesh;
imported Circle from BRepMesh;
imported DiscretRoot from BRepMesh;
imported DiscretFactory from BRepMesh;
--
pointer PDiscretRoot to DiscretRoot from BRepMesh;
--
imported ShapeTool from BRepMesh;
imported Collections from BRepMesh;
imported Delaun 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;
imported VertexInspector from BRepMesh;
imported VertexCellFilter from BRepMesh;
imported VectorOfVertex from BRepMesh;
imported WireInterferenceChecker from BRepMesh;
imported EdgeChecker from BRepMesh;
imported FaceChecker from BRepMesh;
primitive PluginEntryType;
class ComparatorOfVertexOfDelaun;
class ComparatorOfIndexedVertexOfDelaun;
class SelectorOfDataStructureOfDelaun;
class DataStructureOfDelaun;
class CircleTool;
class VertexTool;
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 LinkHasherOfDataStructureOfDelaun instantiates MapHasher from TCollection
(Edge from BRepMesh);
class ElemHasherOfDataStructureOfDelaun instantiates MapHasher from TCollection
(Triangle from BRepMesh);
class DataMapOfIntegerListOfInteger instantiates DataMap from TCollection
(Integer from Standard, ListOfInteger from BRepMesh, MapIntegerHasher from TColStd);
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);
class ListOfVertex instantiates List from TCollection
(Vertex from BRepMesh);
class ListOfXY instantiates List from TCollection (XY from gp);
class DataMapOfIntegerListOfXY instantiates DataMap from TCollection
(Integer from Standard, ListOfXY from BRepMesh, MapIntegerHasher from TColStd);
class VertexHasher instantiates MapHasher from TCollection(Vertex from BRepMesh);
class IndexedMapOfVertex instantiates IndexedMap from TCollection
(Vertex from BRepMesh, VertexHasher from BRepMesh);
private class FastDiscretFace;
class FastDiscret;
class FaceAttribute;
class DataMapOfFaceAttribute instantiates DataMap from TCollection
(Face from TopoDS,
FaceAttribute from BRepMesh,
ShapeMapHasher from TopTools);
imported SelectorOfDataStructureOfDelaun from BRepMesh;
imported DataStructureOfDelaun from BRepMesh;
imported CircleTool from BRepMesh;
imported VertexTool from BRepMesh;
imported BiPoint from BRepMesh;
imported FastDiscretFace from BRepMesh;
imported FastDiscret from BRepMesh;
imported FaceAttribute from BRepMesh;
imported Classifier from BRepMesh;
imported ClassifierPtr; -- smart pointer on Classifier
imported WireChecker from BRepMesh;
imported IncrementalMesh from BRepMesh;
imported GeomTool from BRepMesh;
imported PairOfPolygon from BRepMesh;
---- classes moved from MeshShape
class GeomTool;
class DataMapOfIntegerPnt instantiates
DataMap from TCollection (Integer from Standard,
Pnt from gp,
MapIntegerHasher from TColStd);
class PairOfPolygon;
class DataMapOfShapePairOfPolygon instantiates
DataMap from TCollection(Shape from TopoDS,
PairOfPolygon from BRepMesh,
ShapeMapHasher from TopTools);
Mesh(S: Shape from TopoDS; d: Real from Standard);
---Purpose: call to incremental mesh.
end BRepMesh;

View File

@ -1,27 +0,0 @@
// Created on: 1996-08-07
// Created by: Laurent PAINNOT
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh.ixx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopoDS_Shape.hxx>
void BRepMesh::Mesh(const TopoDS_Shape& S,
const Standard_Real d)
{
BRepMesh_IncrementalMesh M(S, d);
}

View File

@ -1,21 +0,0 @@
// Created on: 2008-05-26
// Created by: Ekaterina SMIRNOVA
// Copyright (c) 2008-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_XYZ.hxx>
#include <gp_XY.hxx>
#include <NCollection_CellFilter.hxx>
#include <BRepMesh_CircleInspector.hxx>
typedef NCollection_CellFilter<BRepMesh_CircleInspector> BRepMesh_CellFilter;

View File

@ -1,54 +0,0 @@
-- Created on: 1993-08-09
-- Created by: Didier PIFFAULT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
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;

View File

@ -1,34 +0,0 @@
// Created on: 1993-08-09
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#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;
}

View File

@ -1,21 +0,0 @@
// Created on: 1993-08-09
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
inline const gp_XY& BRepMesh_Circ::Location() const
{ return location;}
inline const Standard_Real& BRepMesh_Circ::Radius() const
{ return radius;}

View File

@ -0,0 +1,77 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_Circle_HeaderFile
#define _BRepMesh_Circle_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <gp_XY.hxx>
//! Describes a 2d circle with a size of only 3 Standard_Real
//! numbers instead of gp who needs 7 Standard_Real numbers.
class BRepMesh_Circle
{
public:
DEFINE_STANDARD_ALLOC
//! Default constructor.
Standard_EXPORT BRepMesh_Circle()
{
}
//! Constructor.
//! \param theLocation location of a circle.
//! \param theRadius radius of a circle.
Standard_EXPORT BRepMesh_Circle(const gp_XY& theLocation,
const Standard_Real theRadius)
: myLocation(theLocation),
myRadius (theRadius)
{
}
//! Sets location of a circle.
//! \param theLocation location of a circle.
inline void SetLocation(const gp_XY& theLocation)
{
myLocation = theLocation;
}
//! Sets radius of a circle.
//! \param theRadius radius of a circle.
inline void SetRadius(const Standard_Real theRadius)
{
myRadius = theRadius;
}
//! Returns location of a circle.
inline const gp_XY& Location() const
{
return myLocation;
}
//! Returns radius of a circle.
inline const Standard_Real& Radius() const
{
return myRadius;
}
private:
gp_XY myLocation;
Standard_Real myRadius;
};
#endif

View File

@ -16,78 +16,89 @@
#ifndef BRepMesh_CircleInspector_Header
#define BRepMesh_CircleInspector_Header
#include <BRepMesh_Circ.hxx>
#include <BRepMesh_ListOfInteger.hxx>
#include <BRepMesh_Collections.hxx>
#include <BRepMesh_Circle.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
//=======================================================================
//! Auxilary class to find circles shot by the given point.
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)
//! Constructor.
//! \param theTolerance tolerance to be used for identification of shot circles.
//! \param theReservedSize size to be reserved for vector of circles.
//! \param theAllocator memory allocator to be used by internal collections.
Standard_EXPORT BRepMesh_CircleInspector(
const Standard_Real theTolerance,
const Standard_Integer theReservedSize,
const BRepMeshCol::Allocator& theAllocator)
: myTolerance(theTolerance*theTolerance),
myResIndices(theAllocator),
myCircles(theReservedSize)
{
myInitCircle.SetValue(theInd, theCircle);
}
void ClerResList()
//! Adds the circle to vector of circles at the given position.
//! \param theIndex position of circle in the vector.
//! \param theCircle circle to be added.
inline void Bind(const Standard_Integer theIndex,
const BRepMesh_Circle& theCircle)
{
myResInd.Clear();
myCircles.SetValue(theIndex, theCircle);
}
CircVector& MapOfCirc()
//! Resutns vector of registered circles.
inline BRepMeshCol::VectorOfCircle& Circles()
{
return myInitCircle;
return myCircles;
}
BRepMesh_Circ& GetCirc(Standard_Integer theInd)
//! Returns circle with the given index.
//! \param theIndex index of circle.
//! \return circle with the given index.
inline BRepMesh_Circle& Circle(const Standard_Integer theIndex)
{
return myInitCircle(theInd);
return myCircles(theIndex);
}
//! Set current node to be checked
void SetCurrent (const gp_XY& theCurCircle)
{
myCurrent = theCurCircle;
//! Set reference point to be checked.
//! \param thePoint bullet point.
inline void SetPoint(const gp_XY& thePoint)
{
myResIndices.Clear();
myPoint = thePoint;
}
//!Get result index of node
BRepMesh_ListOfInteger& GetCoincidentInd()
//! Returns list of circles shot by the reference point.
inline BRepMeshCol::ListOfInteger& GetShotCircles()
{
return myResInd;
return myResIndices;
}
//! Implementation of inspection method
NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget);
//! Performs inspection of a circle with the given index.
//! \param theTargetIndex index of a circle to be checked.
//! \return status of the check.
Standard_EXPORT NCollection_CellFilter_Action Inspect(
const Standard_Integer theTargetIndex);
static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
//! Checks indices for equlity.
Standard_EXPORT static Standard_Boolean IsEqual(
const Standard_Integer theIndex,
const Standard_Integer theTargetIndex)
{
return (theIdx == theTarget);
return (theIndex == theTargetIndex);
}
private:
Standard_Real myTol;
BRepMesh_ListOfInteger myResInd;
CircVector myInitCircle;
gp_XY myCurrent;
Standard_Real myTolerance;
BRepMeshCol::ListOfInteger myResIndices;
BRepMeshCol::VectorOfCircle myCircles;
gp_XY myPoint;
};
#endif

View File

@ -1,102 +0,0 @@
-- Created on: 1993-05-12
-- Created by: Didier PIFFAULT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
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;

View File

@ -14,46 +14,30 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_CircleTool.ixx>
#include <gp_XY.hxx>
#include <BRepMesh_CircleTool.hxx>
#include <BRepMesh_GeomTool.hxx>
#include <gp_Circ2d.hxx>
#include <Precision.hxx>
#include <BRepMesh_Circ.hxx>
#include <BRepMesh_Circle.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)
NCollection_CellFilter_Action BRepMesh_CircleInspector::Inspect(
const Standard_Integer theTargetIndex)
{
const BRepMesh_Circ& Circ = myInitCircle(theTarget);
Standard_Real R = Circ.Radius();
if(R < 0)
const BRepMesh_Circle& aCircle = myCircles(theTargetIndex);
Standard_Real aRadius = aCircle.Radius();
if(aRadius < 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);
const gp_XY& aLoc = aCircle.Location();
if ((myPoint - aLoc).SquareModulus() - (aRadius * aRadius) <= myTolerance)
myResIndices.Append(theTargetIndex);
return CellFilter_Keep;
}
@ -62,188 +46,106 @@ NCollection_CellFilter_Action BRepMesh_CircleInspector::Inspect (const Standard_
//function : BRepMesh_CircleTool
//purpose :
//=======================================================================
BRepMesh_CircleTool::BRepMesh_CircleTool(const BRepMesh_BaseAllocator& theAlloc)
: Tolerance(Precision::PConfusion()),
Allocator(theAlloc),
CellFilter(10, theAlloc),
Selector(Tolerance,64,theAlloc)
BRepMesh_CircleTool::BRepMesh_CircleTool(
const BRepMeshCol::Allocator& theAllocator)
: myTolerance (Precision::PConfusion() * Precision::PConfusion()),
myAllocator (theAllocator),
myCellFilter(10, theAllocator),
mySelector (myTolerance, 64, theAllocator)
{
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)
BRepMesh_CircleTool::BRepMesh_CircleTool(
const Standard_Integer theReservedSize,
const BRepMeshCol::Allocator& theAllocator)
: myTolerance (Precision::PConfusion() * Precision::PConfusion()),
myAllocator (theAllocator),
myCellFilter(10, theAllocator),
mySelector (myTolerance, Max(theReservedSize, 64), theAllocator)
{
Tolerance=Tolerance*Tolerance;
}
//=======================================================================
//function : Initialize
//function : bind
//purpose :
//=======================================================================
void BRepMesh_CircleTool::Initialize(const Standard_Integer /*nbComp*/)
void BRepMesh_CircleTool::bind(const Standard_Integer theIndex,
const gp_XY& theLocation,
const Standard_Real theRadius)
{
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);
BRepMesh_Circle aCirle(theLocation, theRadius);
//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());
Standard_Real aMaxX = Min(theLocation.X() + theRadius, myFaceMax.X());
Standard_Real aMinX = Max(theLocation.X() - theRadius, myFaceMin.X());
Standard_Real aMaxY = Min(theLocation.Y() + theRadius, myFaceMax.Y());
Standard_Real aMinY = Max(theLocation.Y() - theRadius, myFaceMin.Y());
gp_XY MinPnt(xMin,yMin);
gp_XY MaxPnt(xMax,yMax);
gp_XY aMinPnt(aMinX, aMinY);
gp_XY aMaxPnt(aMaxX, aMaxY);
CellFilter.Add(theIndex, MinPnt, MaxPnt);
Selector.Add(theIndex, aCir);
myCellFilter.Add(theIndex, aMinPnt, aMaxPnt);
mySelector.Bind(theIndex, aCirle);
}
//=======================================================================
//function : Add
//function : Bind
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_CircleTool::Add(const gp_XY& p1,
const gp_XY& p2,
const gp_XY& p3,
const Standard_Integer theIndex)
void BRepMesh_CircleTool::Bind(const Standard_Integer theIndex,
const gp_Circ2d& theCircle)
{
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;
gp_XY aCoord = theCircle.Location().Coord();
Standard_Real aRadius = theCircle.Radius();
bind(theIndex, aCoord, aRadius);
}
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;
//=======================================================================
//function : Bind
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_CircleTool::Bind(const Standard_Integer theIndex,
const gp_XY& thePoint1,
const gp_XY& thePoint2,
const gp_XY& thePoint3)
{
const Standard_Real aPrecision = Precision::PConfusion();
const Standard_Real aSqPrecision = aPrecision * aPrecision;
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;
const gp_XY aPoints[3] = { thePoint1, thePoint2, thePoint3 };
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;
gp_XY aNorm[3];
gp_XY aMidPnt[3];
for (Standard_Integer i = 0; i < 3; ++i)
{
const gp_XY& aPnt1 = aPoints[i];
const gp_XY& aPnt2 = aPoints[(i + 1) % 3];
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;
}
aMidPnt[i] = (aPnt1 + aPnt2) / 2.;
gp_XY aLink(aPnt2 - aPnt1);
if (aLink.SquareModulus() < aSqPrecision)
return Standard_False;
aNorm[i] = gp_XY(aLink.Y(), -aLink.X());
aNorm[i].Add(aMidPnt[i]);
}
gp_XY aVecO1O2 = pl21 - pl11;
Standard_Real aCrossD1D2 = pl12 ^ pl22;
Standard_Real theSinAngle = Abs(aCrossD1D2);
if (theSinAngle < gp::Resolution())
gp_XY aIntPnt;
Standard_Real aParam[2];
BRepMesh_GeomTool::IntFlag aIntFlag =
BRepMesh_GeomTool::IntLinLin(aMidPnt[0], aNorm[0],
aMidPnt[1], aNorm[1], aIntPnt, aParam);
if (aIntFlag != BRepMesh_GeomTool::Cross)
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);
Standard_Real aRadius = (aPoints[0] - aIntPnt).Modulus();
bind(theIndex, aIntPnt, aRadius);
return Standard_True;
}
@ -251,29 +153,30 @@ Standard_Boolean BRepMesh_CircleTool::Add(const gp_XY& p1,
//function : Delete
//purpose :
//=======================================================================
void BRepMesh_CircleTool::Delete(const Standard_Integer theIndex)
void BRepMesh_CircleTool::Delete(const Standard_Integer theIndex)
{
BRepMesh_Circ& Circ = Selector.GetCirc(theIndex);
if(Circ.Radius() > 0.) {
Circ.SetRadius(-1);
}
BRepMesh_Circle& aCircle = mySelector.Circle(theIndex);
if(aCircle.Radius() > 0.)
aCircle.SetRadius(-1);
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
BRepMesh_ListOfInteger& BRepMesh_CircleTool::Select(const gp_XY& thePnt)
BRepMeshCol::ListOfInteger& BRepMesh_CircleTool::Select(const gp_XY& thePoint)
{
Selector.ClerResList();
Selector.SetCurrent(thePnt);
CellFilter.Inspect (thePnt, Selector);
return Selector.GetCoincidentInd();
mySelector.SetPoint(thePoint);
myCellFilter.Inspect(thePoint, mySelector);
return mySelector.GetShotCircles();
}
void BRepMesh_CircleTool::MocAdd(const Standard_Integer theIndex)
//=======================================================================
//function : MocBind
//purpose :
//=======================================================================
void BRepMesh_CircleTool::MocBind(const Standard_Integer theIndex)
{
gp_XY nullPnt(0.,0.);
BRepMesh_Circ theNullCir(nullPnt, -1.);
Selector.Add(theIndex, theNullCir);
BRepMesh_Circle aNullCir(gp::Origin2d().Coord(), -1.);
mySelector.Bind(theIndex, aNullCir);
}

View File

@ -0,0 +1,132 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_CircleTool_HeaderFile
#define _BRepMesh_CircleTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Real.hxx>
#include <BRepMesh_CircleInspector.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <BRepMesh_Collections.hxx>
class gp_Circ2d;
//! Create sort and destroy the circles used in triangulation. <br>
class BRepMesh_CircleTool
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor.
//! \param theAllocator memory allocator to be used by internal structures.
Standard_EXPORT BRepMesh_CircleTool(const BRepMeshCol::Allocator& theAllocator);
//! Constructor.
//! \param theReservedSize size to be reserved for vector of circles.
//! \param theAllocator memory allocator to be used by internal structures.
Standard_EXPORT BRepMesh_CircleTool(const Standard_Integer theReservedSize,
const BRepMeshCol::Allocator& theAllocator);
//! Initializes the tool.
//! \param theReservedSize size to be reserved for vector of circles.
inline void Init(const Standard_Integer /*theReservedSize*/)
{
myTolerance = Precision::PConfusion() * Precision::PConfusion();
}
//! Sets new size for cell filter.
//! \param theSize cell size to be set for X and Y dimensions.
inline void SetCellSize(const Standard_Real theSize)
{
myCellFilter.Reset(theSize, myAllocator);
}
//! Sets new size for cell filter.
//! \param theSizeX cell size to be set for X dimension.
//! \param theSizeY cell size to be set for Y dimension.
inline void SetCellSize(const Standard_Real theSizeX,
const Standard_Real theSizeY)
{
Standard_Real aCellSize[2] = { theSizeX, theSizeY };
myCellFilter.Reset(aCellSize, myAllocator);
}
//! Sets limits of inspection area.
//! \param theMin bottom left corner of inspection area.
//! \param theMax top right corner of inspection area.
inline void SetMinMaxSize(const gp_XY& theMin,
const gp_XY& theMax)
{
myFaceMin = theMin;
myFaceMax = theMax;
}
//! Binds the circle to the tool.
//! \param theIndex index a circle should be bound with.
//! \param theCircle circle to be bound.
Standard_EXPORT void Bind(const Standard_Integer theIndex,
const gp_Circ2d& theCircle);
//! Computes circle on three points and bind it to the tool.
//! \param theIndex index a circle should be bound with.
//! \param thePoint1 first point.
//! \param thePoint2 second point.
//! \param thePoint3 third point.
//! \return FALSE in case of impossibility to build a circle
//! on the given points, TRUE elsewhere.
Standard_EXPORT Standard_Boolean Bind(const Standard_Integer theIndex,
const gp_XY& thePoint1,
const gp_XY& thePoint2,
const gp_XY& thePoint3);
//! Binds implicit zero circle.
//! \param theIndex index a zero circle should be bound with.
Standard_EXPORT void MocBind(const Standard_Integer theIndex);
//! Deletes a circle from the tool.
//! \param theIndex index of a circle to be removed.
Standard_EXPORT void Delete(const Standard_Integer theIndex);
//! Select the circles shot by the given point.
//! \param thePoint bullet point.
Standard_EXPORT BRepMeshCol::ListOfInteger& Select(const gp_XY& thePoint);
private:
//! Creates circle with the given parameters and binds it to the tool.
//! \param theIndex index a circle should be bound with.
//! \param theLocation location of a circle.
//! \param theRadius radius of a circle.
void bind(const Standard_Integer theIndex,
const gp_XY& theLocation,
const Standard_Real theRadius);
private:
Standard_Real myTolerance;
BRepMeshCol::Allocator myAllocator;
BRepMeshCol::CircleCellFilter myCellFilter;
BRepMesh_CircleInspector mySelector;
gp_XY myFaceMax;
gp_XY myFaceMin;
};
#endif

View File

@ -0,0 +1,144 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_Collections_HeaderFile
#define _BRepMesh_Collections_HeaderFile
#include <gp_Pnt.hxx>
#include <gp_XYZ.hxx>
#include <gp_XY.hxx>
#include <Bnd_B2d.hxx>
#include <Bnd_Box2d.hxx>
#include <Standard.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Map.hxx>
#include <NCollection_Vector.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_IndexedMap.hxx>
#include <NCollection_IndexedDataMap.hxx>
#include <NCollection_Array1.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_CellFilter.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_EBTree.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <BRepMesh_Edge.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_PairOfPolygon.hxx>
#include <BRepMesh_PairOfIndex.hxx>
#include <BRepMesh_Circle.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <vector>
class BRepMesh_Vertex;
class TopoDS_Shape;
class TopoDS_Face;
class TopoDS_Edge;
class TopoDS_Vertex;
class BRepMesh_FaceAttribute;
class Handle_BRepMesh_FaceAttribute;
class BRepMesh_VertexInspector;
class BRepMesh_CircleInspector;
class BRepMesh_Classifier;
class Poly_Triangulation;
//! Short names for collections
#define N_SEQUENCE NCollection_Sequence
#define N_VECTOR NCollection_Vector
#define N_ARRAY1 NCollection_Array1
#define N_LIST NCollection_List
#define N_MAP NCollection_Map
#define N_HANDLE NCollection_Handle
#define N_DATAMAP NCollection_DataMap
#define N_IMAP NCollection_IndexedMap
#define N_IDMAP NCollection_IndexedDataMap
#define N_CELLFILTER NCollection_CellFilter
namespace BRepMeshCol
{
//! Structure keeping parameters of segment.
struct Segment
{
gp_XY StartPnt;
gp_XY EndPnt;
};
//! Memory allocators
typedef Handle(NCollection_IncAllocator) Allocator;
//! Short names for hashers
typedef TopTools_ShapeMapHasher ShapeMapHasher;
//! Sequences
typedef N_SEQUENCE<Bnd_B2d> SequenceOfBndB2d;
typedef N_SEQUENCE<Standard_Integer> SequenceOfInteger;
typedef N_SEQUENCE<Standard_Real> SequenceOfReal;
//! Vectors
typedef N_VECTOR<BRepMesh_Vertex> VectorOfVertex;
typedef N_VECTOR<Standard_Integer> VectorOfInteger;
typedef N_VECTOR<BRepMesh_Circle> VectorOfCircle;
//! Trees
typedef NCollection_EBTree<Standard_Integer, Bnd_Box2d> BndBox2dTree;
typedef NCollection_UBTreeFiller<Standard_Integer, Bnd_Box2d> BndBox2dTreeFiller;
//! Arrays
typedef N_ARRAY1<BRepMesh_Vertex> Array1OfVertexOfDelaun;
typedef N_ARRAY1<Standard_Integer> Array1OfInteger;
typedef N_ARRAY1<Standard_Real> Array1OfReal;
typedef std::vector<Segment> Array1OfSegments;
//! Lists
typedef N_LIST<gp_XY> ListOfXY;
typedef N_LIST<BRepMesh_Vertex> ListOfVertex;
typedef N_LIST<Standard_Integer> ListOfInteger;
//! Maps
typedef N_MAP<Standard_Integer> MapOfInteger;
typedef N_MAP<Handle(Poly_Triangulation)> MapOfTriangulation;
typedef N_MAP<TopoDS_Shape, ShapeMapHasher> MapOfShape;
typedef N_DATAMAP<Standard_Integer, Standard_Integer> MapOfIntegerInteger;
typedef N_DATAMAP<TopoDS_Vertex, Standard_Integer, ShapeMapHasher> DMapOfVertexInteger;
typedef N_DATAMAP<TopoDS_Face, Handle_BRepMesh_FaceAttribute, ShapeMapHasher> DMapOfFaceAttribute;
typedef N_DATAMAP<TopoDS_Shape, BRepMesh_PairOfPolygon, ShapeMapHasher> DMapOfShapePairOfPolygon;
typedef N_DATAMAP<Standard_Integer, gp_Pnt> DMapOfIntegerPnt;
typedef N_DATAMAP<Standard_Integer, ListOfXY> DMapOfIntegerListOfXY;
typedef N_DATAMAP<Standard_Integer, ListOfInteger> DMapOfIntegerListOfInteger;
typedef N_DATAMAP<TopoDS_Edge, MapOfTriangulation, ShapeMapHasher> DMapOfEdgeListOfTriangulation;
typedef N_IMAP<Standard_Integer> IMapOfInteger;
typedef N_IMAP<Standard_Real> IMapOfReal;
typedef N_IMAP<BRepMesh_Triangle> IMapOfElement;
typedef N_IDMAP<BRepMesh_Edge, BRepMesh_PairOfIndex> IDMapOfLink;
//! CellFilters
typedef N_CELLFILTER<BRepMesh_CircleInspector> CircleCellFilter;
typedef N_CELLFILTER<BRepMesh_VertexInspector> VertexCellFilter;
//! Handles
typedef N_HANDLE<MapOfInteger> HMapOfInteger;
typedef N_HANDLE<BRepMesh_Classifier> HClassifier;
typedef N_HANDLE<BndBox2dTree> HBndBox2dTree;
typedef N_HANDLE<Array1OfSegments> HArray1OfSegments;
//! Other data structures
typedef std::pair<HArray1OfSegments, HBndBox2dTree> SegmentsTree;
typedef std::vector<SegmentsTree> Array1OfSegmentsTree;
};
#endif

View File

@ -1,49 +0,0 @@
-- Created on: 1994-04-05
-- Created by: Didier PIFFAULT
-- Copyright (c) 1994-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
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;

View File

@ -1,67 +0,0 @@
// Created on: 1994-04-05
// Created by: Didier PIFFAULT
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <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));
}

View File

@ -1,46 +0,0 @@
-- Created on: 1993-06-18
-- Created by: Didier PIFFAULT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
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)
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;
end ComparatorOfVertexOfDelaun;

View File

@ -1,62 +0,0 @@
// Created on: 1993-06-18
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_ComparatorOfVertexOfDelaun.ixx>
//=======================================================================
//function : BRepMesh_ComparatorOfVertexOfDelaun
//purpose :
//=======================================================================
BRepMesh_ComparatorOfVertexOfDelaun::BRepMesh_ComparatorOfVertexOfDelaun(const gp_XY& theDir)
: DirectionOfSort(theDir)
{}
//=======================================================================
//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);
}

View File

@ -1,265 +0,0 @@
-- Created on: 1993-03-17
-- Created by: Didier PIFFAULT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
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,
VertexTool 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 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 : VertexTool 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: mutable;
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&
Data (me: mutable) returns VertexTool from BRepMesh;
---Purpose: Give the data structure for cell size and
-- tolerance initialization.
---C++: return &
fields myNodes : VertexTool 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;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,319 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_DataStructureOfDelaun_HeaderFile
#define _BRepMesh_DataStructureOfDelaun_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <BRepMesh_VertexTool.hxx>
#include <Standard_Transient.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_PairOfIndex.hxx>
#include <Standard_OStream.hxx>
#include <BRepMesh_Collections.hxx>
class BRepMesh_Vertex;
class BRepMesh_VertexTool;
class BRepMesh_Edge;
//! Describes the data structure necessary for the mesh algorithms in
//! two dimensions plane or on surface by meshing in UV space.
class BRepMesh_DataStructureOfDelaun : public Standard_Transient
{
public:
//! Constructor.
//! \param theAllocator memory allocator to be used by internal structures.
//! \param theReservedNodeSize presumed number of nodes in this mesh.
Standard_EXPORT BRepMesh_DataStructureOfDelaun(
const BRepMeshCol::Allocator& theAllocator,
const Standard_Integer theReservedNodeSize = 100);
public: //! \name API for accessing mesh nodes.
//! Returns number of nodes.
inline Standard_Integer NbNodes() const
{
return myNodes.Extent();
}
//! Adds node to the mesh if it is not already in the mesh.
//! \param theNode node to be added to the mesh.
//! \return index of the node in the structure.
inline Standard_Integer AddNode(const BRepMesh_Vertex& theNode)
{
return myNodes.Add(theNode);
}
//! Finds the index of the given node.
//! \param theNode node to find.
//! \return index of the given element of zero if node is not in the mesh.
Standard_EXPORT Standard_Integer IndexOf(const BRepMesh_Vertex& theNode)
{
return myNodes.FindIndex(theNode);
}
//! Get node by the index.
//! \param theIndex index of a node.
//! \return node with the given index.
inline const BRepMesh_Vertex& GetNode(const Standard_Integer theIndex)
{
return myNodes.FindKey(theIndex);
}
//! Alias for GetNode.
const BRepMesh_Vertex& operator ()(const Standard_Integer theIndex)
{
return GetNode(theIndex);
}
//! Replaces nodes of mesh by the given ones.
//! \param theNewNodes nodes to be set instead of existing ones.
Standard_EXPORT void ReplaceNodes(const BRepMesh_VertexTool& theNewNodes)
{
if (theNewNodes.IsEmpty())
return;
myNodes = theNewNodes;
}
//! Substitutes the node with the given index by new one.
//! \param theIndex index of node to be substituted.
//! \param theNewNode substituting node.
//! \return FALSE in case if new node is already in the structure, TRUE elsewhere.
Standard_EXPORT Standard_Boolean SubstituteNode(
const Standard_Integer theIndex,
const BRepMesh_Vertex& theNewNode);
//! Removes node from the mesh in case if it has no connected links
//! and its type is Free.
//! \param theIndex index of node to be removed.
//! \param isForce if TRUE node will be removed even if movability
//! is not Free.
Standard_EXPORT void RemoveNode(const Standard_Integer theIndex,
const Standard_Boolean isForce = Standard_False)
{
if (isForce || myNodes.FindKey(theIndex).Movability() == BRepMesh_Free)
{
if (myNodes.FindFromIndex(theIndex).Extent()==0)
myNodes.Delete(theIndex);
}
}
//! Get list of links attached to the node with the given index.
//! \param theIndex index of node whose links should be retrieved.
//! \return list of links attached to the node.
inline const BRepMeshCol::ListOfInteger& LinksConnectedTo(
const Standard_Integer theIndex) const
{
return myNodes.FindFromIndex(theIndex);
}
public: //! \name API for accessing mesh links.
//! Returns number of links.
inline Standard_Integer NbLinks() const
{
return myLinks.Extent();
}
//! Adds link to the mesh if it is not already in the mesh.
//! \param theLink link to be added to the mesh.
//! \return index of the link in the structure.
Standard_EXPORT Standard_Integer AddLink(const BRepMesh_Edge& theLink);
//! Finds the index of the given link.
//! \param theLink link to find.
//! \return index of the given element of zero if link is not in the mesh.
Standard_EXPORT Standard_Integer IndexOf(const BRepMesh_Edge& theLink) const
{
return myLinks.FindIndex(theLink);
}
//! Get link by the index.
//! \param theIndex index of a link.
//! \return link with the given index.
Standard_EXPORT const BRepMesh_Edge& GetLink(const Standard_Integer theIndex)
{
return myLinks.FindKey(theIndex);
}
//! Returns map of indices of links registered in mesh.
inline const BRepMeshCol::MapOfInteger& LinksOfDomain() const
{
return myLinksOfDomain;
}
//! Substitutes the link with the given index by new one.
//! \param theIndex index of link to be substituted.
//! \param theNewLink substituting link.
//! \return FALSE in case if new link is already in the structure, TRUE elsewhere.
Standard_EXPORT Standard_Boolean SubstituteLink(const Standard_Integer theIndex,
const BRepMesh_Edge& theNewLink);
//! Removes link from the mesh in case if it has no connected elements
//! and its type is Free.
//! \param theIndex index of link to be removed.
//! \param isForce if TRUE link will be removed even if movability
//! is not Free.
Standard_EXPORT void RemoveLink(const Standard_Integer theIndex,
const Standard_Boolean isForce = Standard_False);
//! Returns indices of elements conected to the link with the given index.
//! \param theLinkIndex index of link whose data should be retrieved.
//! \return indices of elements conected to the link.
Standard_EXPORT const BRepMesh_PairOfIndex& ElementsConnectedTo(
const Standard_Integer theLinkIndex) const
{
return myLinks.FindFromIndex(theLinkIndex);
}
public: //! \name API for accessing mesh elements.
//! Returns number of links.
inline Standard_Integer NbElements() const
{
return myElements.Extent();
}
//! Adds element to the mesh if it is not already in the mesh.
//! \param theElement element to be added to the mesh.
//! \return index of the element in the structure.
Standard_EXPORT Standard_Integer AddElement(const BRepMesh_Triangle& theElement);
//! Finds the index of the given element.
//! \param theElement element to find.
//! \return index of the given element of zero if element is not in the mesh.
Standard_EXPORT Standard_Integer IndexOf(const BRepMesh_Triangle& theElement) const
{
return myElements.FindIndex(theElement);
}
//! Get element by the index.
//! \param theIndex index of an element.
//! \return element with the given index.
Standard_EXPORT const BRepMesh_Triangle& GetElement(const Standard_Integer theIndex)
{
return myElements.FindKey(theIndex);
}
//! Returns map of indices of elements registered in mesh.
inline const BRepMeshCol::MapOfInteger& ElementsOfDomain() const
{
return myElementsOfDomain;
}
//! Substitutes the element with the given index by new one.
//! \param theIndex index of element to be substituted.
//! \param theNewLink substituting element.
//! \return FALSE in case if new element is already in the structure, TRUE elsewhere.
Standard_EXPORT Standard_Boolean SubstituteElement(const Standard_Integer theIndex,
const BRepMesh_Triangle& theNewElement);
//! Removes element from the mesh.
//! \param theIndex index of element to be removed.
Standard_EXPORT void RemoveElement(const Standard_Integer theIndex);
//! Returns indices of nodes forming the given element.
//! \param theElement element which nodes should be retrieved.
//! \param[out] theNodes nodes of the given element.
Standard_EXPORT void ElementNodes(
const BRepMesh_Triangle& theElement,
Standard_Integer (&theNodes)[3]);
public: //! \name Auxilary API
//! Dumps information about this structure.
//! \param theStream stream to be used for dump.
Standard_EXPORT void Statistics(Standard_OStream& theStream) const;
//! Returns memory allocator used by the structure.
inline const BRepMeshCol::Allocator& Allocator() const
{
return myAllocator;
}
//! Gives the data structure for initialization of cell size and tolerance.
inline BRepMesh_VertexTool& Data()
{
return myNodes;
}
//! Removes all elements.
Standard_EXPORT void ClearDomain();
//! Substitutes deleted items by the last one from corresponding map
//! to have only non-deleted elements, links or nodes in the structure.
Standard_EXPORT void ClearDeleted()
{
clearDeletedLinks();
clearDeletedNodes();
}
DEFINE_STANDARD_RTTI(BRepMesh_DataStructureOfDelaun)
private:
//! Substitutes deleted links by the last one from corresponding map
//! to have only non-deleted links in the structure.
Standard_EXPORT void clearDeletedLinks();
//! Substitutes deleted nodes by the last one from corresponding map
//! to have only non-deleted nodes in the structure.
Standard_EXPORT void clearDeletedNodes();
//! Cleans dependent structures from the given link.
//! \param theIndex index of link in the data structure.
//! \param theLink reference to the link to avoid double accessing
//! to map of links.
void cleanLink(const Standard_Integer theIndex,
const BRepMesh_Edge& theLink);
//! Cleans dependent structures from the given element.
//! \param theIndex index of element in the data structure.
//! \param theElement reference to the element to avoid double accessing
//! to map of elements.
void cleanElement(const Standard_Integer theIndex,
const BRepMesh_Triangle& theElement);
//! Removes element index from the given pair. Used by cleanElement.
//! \param theIndex index of element to be removed.
//! \param thePair pair of elements to be cleaned.
void removeElementIndex(const Standard_Integer theIndex,
BRepMesh_PairOfIndex& thePair);
private:
BRepMesh_VertexTool myNodes;
BRepMeshCol::IDMapOfLink myLinks;
BRepMeshCol::ListOfInteger myDelLinks;
BRepMeshCol::IMapOfElement myElements;
BRepMeshCol::MapOfInteger myElementsOfDomain;
BRepMeshCol::MapOfInteger myLinksOfDomain;
BRepMeshCol::Allocator myAllocator;
};
DEFINE_STANDARD_HANDLE(BRepMesh_DataStructureOfDelaun,Standard_Transient)
#endif

View File

@ -1,6 +1,4 @@
// Created on: 2009-02-02
// Created by: Pavel TELKOV
// Copyright (c) 2009-2014 OPEN CASCADE SAS
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@ -13,12 +11,19 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef BRepMesh_ClassifierPtr_HeaderFile
#define BRepMesh_ClassifierPtr_HeaderFile
#include <NCollection_Handle.hxx>
#ifndef _BRepMesh_DegreeOfFreedom_HeaderFile
#define _BRepMesh_DegreeOfFreedom_HeaderFile
class BRepMesh_Classifier;
typedef NCollection_Handle<BRepMesh_Classifier> BRepMesh_ClassifierPtr;
enum BRepMesh_DegreeOfFreedom
{
BRepMesh_Free,
BRepMesh_InVolume,
BRepMesh_OnSurface,
BRepMesh_OnCurve,
BRepMesh_Fixed,
BRepMesh_Frontier,
BRepMesh_Deleted
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -18,22 +18,19 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <BRepMesh_CircleTool.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_Edge.hxx>
#include <BRepMesh_MapOfInteger.hxx>
#include <BRepMesh_MapOfIntegerInteger.hxx>
#include <BRepMesh_Collections.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <NCollection_Sequence.hxx>
#include <BRepMesh_WireInterferenceChecker.hxx>
#include <BRepMesh_GeomTool.hxx>
class Bnd_B2d;
class Bnd_Box2d;
class BRepMesh_Array1OfVertexOfDelaun;
class BRepMesh_Vertex;
class TColStd_Array1OfInteger;
class TColStd_SequenceOfInteger;
class TColStd_MapOfInteger;
//! Compute the Delaunay's triangulation with the algorithm of Watson.
class BRepMesh_Delaun
@ -43,52 +40,52 @@ public:
DEFINE_STANDARD_ALLOC
//! Creates the triangulation with an empty Mesh data structure.
Standard_EXPORT BRepMesh_Delaun (BRepMesh_Array1OfVertexOfDelaun& theVertices,
const Standard_Boolean isPositive = Standard_True);
Standard_EXPORT BRepMesh_Delaun (BRepMeshCol::Array1OfVertexOfDelaun& theVertices,
const Standard_Boolean isPositive = Standard_True);
//! Creates the triangulation with an existent Mesh data structure.
Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
BRepMesh_Array1OfVertexOfDelaun& theVertices,
BRepMeshCol::Array1OfVertexOfDelaun& theVertices,
const Standard_Boolean isPositive = Standard_True);
//! Creates the triangulation with an existant Mesh data structure.
Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
TColStd_Array1OfInteger& theVertexIndices,
BRepMeshCol::Array1OfInteger& theVertexIndices,
const Standard_Boolean isPositive = Standard_True);
//! Initializes the triangulation with an array of vertices.
Standard_EXPORT void Init (BRepMesh_Array1OfVertexOfDelaun& theVertices);
Standard_EXPORT void Init (BRepMeshCol::Array1OfVertexOfDelaun& theVertices);
//! Removes a vertex from the triangulation.
Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex);
//! Adds some vertices into the triangulation.
Standard_EXPORT void AddVertices (BRepMesh_Array1OfVertexOfDelaun& theVertices);
Standard_EXPORT void AddVertices (BRepMeshCol::Array1OfVertexOfDelaun& theVertices);
//! Modify mesh to use the edge.
//! @return True if done
Standard_EXPORT Standard_Boolean UseEdge (const Standard_Integer theEdge);
//! Gives the Mesh data structure.
const Handle(BRepMesh_DataStructureOfDelaun)& Result() const
inline const Handle(BRepMesh_DataStructureOfDelaun)& Result() const
{
return myMeshData;
}
//! Gives the list of frontier edges.
inline Handle(BRepMesh_MapOfInteger) Frontier() const
inline BRepMeshCol::HMapOfInteger Frontier() const
{
return getEdgesByType (BRepMesh_Frontier);
}
//! Gives the list of internal edges.
inline Handle(BRepMesh_MapOfInteger) InternalEdges() const
inline BRepMeshCol::HMapOfInteger InternalEdges() const
{
return getEdgesByType (BRepMesh_Fixed);
}
//! Gives the list of free edges used only one time
inline Handle(BRepMesh_MapOfInteger) FreeEdges() const
inline BRepMeshCol::HMapOfInteger FreeEdges() const
{
return getEdgesByType (BRepMesh_Free);
}
@ -127,31 +124,29 @@ private:
InsertBefore
};
typedef NCollection_DataMap<Standard_Integer, NCollection_Map<Standard_Integer> > DataMapOfMap;
typedef NCollection_Handle<NCollection_Map<Standard_Integer> > HandleOfMapOfInteger;
typedef NCollection_DataMap<Standard_Integer, BRepMeshCol::MapOfInteger> DataMapOfMap;
//! Add boundig box for edge defined by start & end point to
//! the given vector of bounding boxes for triangulation edges.
void fillBndBox (NCollection_Sequence<Bnd_B2d>& theBoxes,
void fillBndBox (BRepMeshCol::SequenceOfBndB2d& theBoxes,
const BRepMesh_Vertex& theV1,
const BRepMesh_Vertex& theV2);
//! Gives the list of edges with type defined by the input parameter.
//! If the given type is BRepMesh_Free returns list of edges
//! that have number of connected elements less or equal 1.
Handle(BRepMesh_MapOfInteger) getEdgesByType (const BRepMesh_DegreeOfFreedom theEdgeType) const;
BRepMeshCol::HMapOfInteger getEdgesByType (const BRepMesh_DegreeOfFreedom theEdgeType) const;
//! Create super mesh and run triangulation procedure.
void perform (Bnd_Box2d& theBndBox,
TColStd_Array1OfInteger& theVertexIndices);
void perform (Bnd_Box2d& theBndBox,
BRepMeshCol::Array1OfInteger& theVertexIndices);
//! Build the super mesh.
void superMesh (const Bnd_Box2d& theBox);
//! Computes the triangulation and adds the vertices,
//! edges and triangles to the Mesh data structure.
void compute (TColStd_Array1OfInteger& theVertexIndices);
void compute (BRepMeshCol::Array1OfInteger& theVertexIndices);
//! Adjust the mesh on the frontier.
void frontierAdjust();
@ -159,56 +154,56 @@ private:
//! Find left polygon of the given edge and call meshPolygon.
Standard_Boolean meshLeftPolygonOf (const Standard_Integer theEdgeIndex,
const Standard_Boolean isForward,
HandleOfMapOfInteger theSkipped = NULL);
BRepMeshCol::HMapOfInteger theSkipped = NULL);
//! Find next link starting from the given node and has maximum
//! angle respect the given reference link.
//! Each time the next link is found other neighbor links at the pivot
//! node are marked as leprous and will be excluded from consideration
//! next time until a hanging end is occured.
Standard_Integer findNextPolygonLink (const Standard_Integer& theFirstNode,
const Standard_Integer& thePivotNode,
const BRepMesh_Vertex& thePivotVertex,
const gp_Vec2d& theRefLinkDir,
const NCollection_Sequence<Bnd_B2d>& theBoxes,
const TColStd_SequenceOfInteger& thePolygon,
const HandleOfMapOfInteger theSkipped,
const Standard_Boolean& isSkipLeprous,
NCollection_Map<Standard_Integer>& theLeprousLinks,
NCollection_Map<Standard_Integer>& theDeadLinks,
Standard_Integer& theNextPivotNode,
gp_Vec2d& theNextLinkDir,
Bnd_B2d& theNextLinkBndBox);
Standard_Integer findNextPolygonLink (const Standard_Integer& theFirstNode,
const Standard_Integer& thePivotNode,
const BRepMesh_Vertex& thePivotVertex,
const gp_Vec2d& theRefLinkDir,
const BRepMeshCol::SequenceOfBndB2d& theBoxes,
const BRepMeshCol::SequenceOfInteger& thePolygon,
const BRepMeshCol::HMapOfInteger theSkipped,
const Standard_Boolean& isSkipLeprous,
BRepMeshCol::MapOfInteger& theLeprousLinks,
BRepMeshCol::MapOfInteger& theDeadLinks,
Standard_Integer& theNextPivotNode,
gp_Vec2d& theNextLinkDir,
Bnd_B2d& theNextLinkBndBox);
//! Check is the given link intersects the polygon boundaries.
//! Returns bounding box for the given link trough the theLinkBndBox parameter.
Standard_Boolean checkIntersection (const BRepMesh_Edge& theLink,
const TColStd_SequenceOfInteger& thePolygon,
const NCollection_Sequence<Bnd_B2d>& thePolyBoxes,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnEdge,
const Standard_Boolean isSkipLastEdge,
Bnd_B2d& theLinkBndBox) const;
Standard_Boolean checkIntersection (const BRepMesh_Edge& theLink,
const BRepMeshCol::SequenceOfInteger& thePolygon,
const BRepMeshCol::SequenceOfBndB2d& thePolyBoxes,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnEdge,
const Standard_Boolean isSkipLastEdge,
Bnd_B2d& theLinkBndBox) const;
//! Triangulatiion of a closed polygon described by the list
//! of indexes of its edges in the structure.
//! (negative index means reversed edge)
void meshPolygon (TColStd_SequenceOfInteger& thePolygon,
NCollection_Sequence<Bnd_B2d>& thePolyBoxes,
HandleOfMapOfInteger theSkipped = NULL);
void meshPolygon (BRepMeshCol::SequenceOfInteger& thePolygon,
BRepMeshCol::SequenceOfBndB2d& thePolyBoxes,
BRepMeshCol::HMapOfInteger theSkipped = NULL);
//! Triangulatiion of a closed simple polygon (polygon without glued edges and loops)
//! described by the list of indexes of its edges in the structure.
//! (negative index means reversed edge)
void meshSimplePolygon (TColStd_SequenceOfInteger& thePolygon,
NCollection_Sequence<Bnd_B2d>& thePolyBoxes);
void meshSimplePolygon (BRepMeshCol::SequenceOfInteger& thePolygon,
BRepMeshCol::SequenceOfBndB2d& thePolyBoxes);
//! Triangulation of closed polygon containing only three edges.
inline Standard_Boolean meshElementaryPolygon (const TColStd_SequenceOfInteger& thePolygon);
inline Standard_Boolean meshElementaryPolygon (const BRepMeshCol::SequenceOfInteger& thePolygon);
//! Creates the triangles beetween the given node and the given polyline.
void createTriangles (const Standard_Integer theVertexIndex,
BRepMesh_MapOfIntegerInteger& thePoly);
void createTriangles (const Standard_Integer theVertexIndex,
BRepMeshCol::MapOfIntegerInteger& thePoly);
//! Add a triangle based on the given oriented edges into mesh
inline void addTriangle (const Standard_Integer (&theEdgesId)[3],
@ -217,8 +212,8 @@ private:
//! Deletes the triangle with the given index and adds the free edges into the map.
//! When an edge is suppressed more than one time it is destroyed.
void deleteTriangle (const Standard_Integer theIndex,
BRepMesh_MapOfIntegerInteger& theLoopEdges);
void deleteTriangle (const Standard_Integer theIndex,
BRepMeshCol::MapOfIntegerInteger& theLoopEdges);
//! Returns start and end nodes of the given edge in respect to its orientation.
void getOrientedNodes (const BRepMesh_Edge& theEdge,
@ -227,21 +222,21 @@ private:
//! Processes loop within the given polygon formed by range of its
//! links specified by start and end link indices.
void processLoop (const Standard_Integer theLinkFrom,
const Standard_Integer theLinkTo,
const TColStd_SequenceOfInteger& thePolygon,
const NCollection_Sequence<Bnd_B2d>& thePolyBoxes);
void processLoop (const Standard_Integer theLinkFrom,
const Standard_Integer theLinkTo,
const BRepMeshCol::SequenceOfInteger& thePolygon,
const BRepMeshCol::SequenceOfBndB2d& thePolyBoxes);
//! Creates new link based on the given nodes and updates the given polygon.
Standard_Integer createAndReplacePolygonLink (const Standard_Integer theNodes[],
const gp_Pnt2d thePnts [],
const Standard_Integer theRootIndex,
const ReplaceFlag theReplaceFlag,
TColStd_SequenceOfInteger& thePolygon,
NCollection_Sequence<Bnd_B2d>& thePolyBoxes);
Standard_Integer createAndReplacePolygonLink (const Standard_Integer theNodes[],
const gp_Pnt2d thePnts [],
const Standard_Integer theRootIndex,
const ReplaceFlag theReplaceFlag,
BRepMeshCol::SequenceOfInteger& thePolygon,
BRepMeshCol::SequenceOfBndB2d& thePolyBoxes);
//! Creates the triangles on new nodes.
void createTrianglesOnNewVertices (TColStd_Array1OfInteger& theVertexIndices);
void createTrianglesOnNewVertices (BRepMeshCol::Array1OfInteger& theVertexIndices);
//! Cleanup mesh from the free triangles.
void cleanupMesh();
@ -257,35 +252,35 @@ private:
const Standard_Integer thePrevElementId);
//! Remove internal triangles from the given polygon.
void cleanupPolygon (const TColStd_SequenceOfInteger& thePolygon,
const NCollection_Sequence<Bnd_B2d>& thePolyBoxes);
void cleanupPolygon (const BRepMeshCol::SequenceOfInteger& thePolygon,
const BRepMeshCol::SequenceOfBndB2d& thePolyBoxes);
//! Checks is the given vertex lies inside the polygon.
Standard_Boolean isVertexInsidePolygon (const Standard_Integer& theVertexId,
const NCollection_Vector<Standard_Integer>& thePolygonVertices) const;
Standard_Boolean isVertexInsidePolygon (const Standard_Integer& theVertexId,
const BRepMeshCol::VectorOfInteger& thePolygonVertices) const;
//! Remove all triangles and edges that are placed inside the polygon or crossed it.
void killTrianglesAroundVertex (const Standard_Integer theZombieNodeId,
const NCollection_Vector<Standard_Integer>& thePolyVertices,
const NCollection_Map<Standard_Integer>& thePolyVerticesFindMap,
const TColStd_SequenceOfInteger& thePolygon,
const NCollection_Sequence<Bnd_B2d>& thePolyBoxes,
NCollection_Map<Standard_Integer>& theSurvivedLinks,
BRepMesh_MapOfIntegerInteger& theLoopEdges);
void killTrianglesAroundVertex (const Standard_Integer theZombieNodeId,
const BRepMeshCol::VectorOfInteger& thePolyVertices,
const BRepMeshCol::MapOfInteger& thePolyVerticesFindMap,
const BRepMeshCol::SequenceOfInteger& thePolygon,
const BRepMeshCol::SequenceOfBndB2d& thePolyBoxes,
BRepMeshCol::MapOfInteger& theSurvivedLinks,
BRepMeshCol::MapOfIntegerInteger& theLoopEdges);
//! Checks is the given link crosses the polygon boundary.
//! If yes, kills its triangles and checks neighbor links on boundary intersection. Does nothing elsewhere.
void killTrianglesOnIntersectingLinks (const Standard_Integer& theLinkToCheckId,
const BRepMesh_Edge& theLinkToCheck,
const Standard_Integer& theEndPoint,
const TColStd_SequenceOfInteger& thePolygon,
const NCollection_Sequence<Bnd_B2d>& thePolyBoxes,
NCollection_Map<Standard_Integer>& theSurvivedLinks,
BRepMesh_MapOfIntegerInteger& theLoopEdges);
void killTrianglesOnIntersectingLinks (const Standard_Integer& theLinkToCheckId,
const BRepMesh_Edge& theLinkToCheck,
const Standard_Integer& theEndPoint,
const BRepMeshCol::SequenceOfInteger& thePolygon,
const BRepMeshCol::SequenceOfBndB2d& thePolyBoxes,
BRepMeshCol::MapOfInteger& theSurvivedLinks,
BRepMeshCol::MapOfIntegerInteger& theLoopEdges);
//! Kill triangles bound to the given link.
void killLinkTriangles (const Standard_Integer& theLinkId,
BRepMesh_MapOfIntegerInteger& theLoopEdges);
void killLinkTriangles (const Standard_Integer& theLinkId,
BRepMeshCol::MapOfIntegerInteger& theLoopEdges);
//! Calculates distances between the given point and edges of triangle.
Standard_Real calculateDist (const gp_XY theVEdges[3],
@ -297,7 +292,7 @@ private:
Standard_Integer& theEdgeOn) const;
//! Checks intersection between the two segments.
BRepMesh_WireInterferenceChecker::IntFlag intSegSeg (
BRepMesh_GeomTool::IntFlag intSegSeg(
const BRepMesh_Edge& theEdge1,
const BRepMesh_Edge& theEdge2,
const Standard_Boolean isConsiderEndPointTouch,
@ -305,9 +300,9 @@ private:
gp_Pnt2d& theIntPnt) const;
//! Returns area of the loop of the given polygon defined by indices of its start and end links.
Standard_Real polyArea (const TColStd_SequenceOfInteger& thePolygon,
const Standard_Integer theStartIndex,
const Standard_Integer theEndIndex) const;
Standard_Real polyArea (const BRepMeshCol::SequenceOfInteger& thePolygon,
const Standard_Integer theStartIndex,
const Standard_Integer theEndIndex) const;
private:

View File

@ -1,114 +0,0 @@
-- Created on: 2008-04-10
-- Created by: Peter KURNEV <pkv@irinox>
-- Copyright (c) 2008-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class DiscretFactory from BRepMesh
---Purpose:
-- This class intended to setup / retrieve default triangulation algorithm.
-- Use BRepMesh_DiscretFactory::Get() static method to retrieve global Factory instance.
-- Use BRepMesh_DiscretFactory::Discret() method to retrieve meshing tool.
uses
DiscretRoot from BRepMesh,
FactoryError from BRepMesh,
PluginEntryType from BRepMesh,
AsciiString from TCollection,
MapOfAsciiString from TColStd,
Shape from TopoDS,
MapOfFunctions from Plugin
--raises
is
Create
returns DiscretFactory from BRepMesh
is protected;
---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretFactory();"
Get (myclass)
returns DiscretFactory from BRepMesh;
---C++: return &
---Purpose:
-- Returns the global factory instance.
Names (me)
returns MapOfAsciiString from TColStd;
---C++: return const &
---Purpose:
-- Returns the list of registered meshing algorithms.
SetDefaultName ( me : out;
theName : AsciiString from TCollection)
returns Boolean from Standard;
---Purpose:
-- Setup meshing algorithm by name.
-- Returns true if requested tool is available.
-- On fail Factory will continue to use previous algo.
DefaultName (me)
returns AsciiString from TCollection;
---C++: return const &
---Purpose:
-- Returns name for current meshing algorithm.
SetFunctionName ( me : out;
theFuncName : AsciiString from TCollection)
returns Boolean from Standard;
---Purpose:
-- Advanced function. Changes function name to retrieve from plugin.
-- Returns true if requested tool is available.
-- On fail Factory will continue to use previous algo.
SetDefault ( me : out;
theName : AsciiString from TCollection;
theFuncName : AsciiString from TCollection = "DISCRETALGO")
returns Boolean from Standard;
---Purpose:
-- Setup meshing algorithm that should be created by this Factory.
-- Returns true if requested tool is available.
-- On fail Factory will continue to use previous algo.
-- Call ::ErrorStatus() method to retrieve fault reason.
FunctionName (me)
returns AsciiString from TCollection;
---C++: return const &
---Purpose:
-- Returns function name that should be exported by plugin.
Discret (me : out;
theShape : Shape from TopoDS;
theDeflection : Real from Standard;
theAngle : Real from Standard)
returns DiscretRoot from BRepMesh;
---Purpose:
-- Returns triangulation algorithm instance.
ErrorStatus (me)
returns FactoryError from BRepMesh;
---Purpose:
-- Returns error status for last meshing algorithm switch.
Clear (me : out)
is protected;
fields
myPluginEntry : PluginEntryType from BRepMesh is protected;
myErrorStatus : FactoryError from BRepMesh is protected;
myNames : MapOfAsciiString from TColStd is protected;
myDefaultName : AsciiString from TCollection is protected;
myFunctionName : AsciiString from TCollection is protected;
myFactoryMethods : MapOfFunctions from Plugin is protected;
end DiscretFactory;

View File

@ -13,7 +13,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_DiscretFactory.ixx>
#include <BRepMesh_DiscretFactory.hxx>
#include <OSD_SharedLibrary.hxx>
#include <OSD_Function.hxx>
@ -52,13 +52,13 @@ namespace
//purpose :
//=======================================================================
BRepMesh_DiscretFactory::BRepMesh_DiscretFactory()
: myPluginEntry (NULL),
myErrorStatus (BRepMesh_FE_NOERROR),
myDefaultName (THE_FAST_DISCRET_MESH),
: myPluginEntry (NULL),
myErrorStatus (BRepMesh_FE_NOERROR),
myDefaultName (THE_FAST_DISCRET_MESH),
myFunctionName ("DISCRETALGO")
{
// register built-in meshing algorithms
myNames.Add (THE_FAST_DISCRET_MESH);
myNames.Add(THE_FAST_DISCRET_MESH);
}
//=======================================================================
@ -67,14 +67,14 @@ BRepMesh_DiscretFactory::BRepMesh_DiscretFactory()
//=======================================================================
BRepMesh_DiscretFactory::~BRepMesh_DiscretFactory()
{
Clear();
clear();
}
//=======================================================================
//function : ~
//function : clear
//purpose :
//=======================================================================
void BRepMesh_DiscretFactory::Clear()
void BRepMesh_DiscretFactory::clear()
{
// what should we do here? Unload dynamic libraries and reset plugins list?
}
@ -90,66 +90,13 @@ BRepMesh_DiscretFactory& BRepMesh_DiscretFactory::Get()
return THE_GLOBAL_FACTORY;
}
//=======================================================================
//function : ErrorStatus
//purpose :
//=======================================================================
BRepMesh_FactoryError BRepMesh_DiscretFactory::ErrorStatus() const
{
return myErrorStatus;
}
//=======================================================================
//function : Names
//purpose :
//=======================================================================
const TColStd_MapOfAsciiString& BRepMesh_DiscretFactory::Names() const
{
return myNames;
}
//=======================================================================
//function : SetDefaultName
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_DiscretFactory::SetDefaultName (const TCollection_AsciiString& theName)
{
return SetDefault (theName, myFunctionName);
}
//=======================================================================
//function : DefaultName
//purpose :
//=======================================================================
const TCollection_AsciiString& BRepMesh_DiscretFactory::DefaultName() const
{
return myDefaultName;
}
//=======================================================================
//function : SetFunctionName
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_DiscretFactory::SetFunctionName (const TCollection_AsciiString& theFuncName)
{
return SetDefault (myDefaultName, theFuncName);
}
//=======================================================================
//function : FunctionName
//purpose :
//=======================================================================
const TCollection_AsciiString& BRepMesh_DiscretFactory::FunctionName() const
{
return myFunctionName;
}
//=======================================================================
//function : SetDefault
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_DiscretFactory::SetDefault (const TCollection_AsciiString& theName,
const TCollection_AsciiString& theFuncName)
Standard_Boolean BRepMesh_DiscretFactory::SetDefault(
const TCollection_AsciiString& theName,
const TCollection_AsciiString& theFuncName)
{
myErrorStatus = BRepMesh_FE_NOERROR;
if (theName == THE_FAST_DISCRET_MESH)
@ -221,17 +168,19 @@ Standard_Boolean BRepMesh_DiscretFactory::SetDefault (const TCollection_AsciiStr
//function : Discret
//purpose :
//=======================================================================
Handle(BRepMesh_DiscretRoot) BRepMesh_DiscretFactory
::Discret (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle)
Handle(BRepMesh_DiscretRoot) BRepMesh_DiscretFactory::Discret(
const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle)
{
Handle(BRepMesh_DiscretRoot) aDiscretRoot;
BRepMesh_PDiscretRoot anInstancePtr = NULL;
if (myPluginEntry != NULL)
{
// use plugin
Standard_Integer anErr = myPluginEntry (theShape, theDeflection, theAngle, anInstancePtr);
Standard_Integer anErr = myPluginEntry (theShape,
theDeflection, theAngle, anInstancePtr);
if (anErr != 0 || anInstancePtr == NULL)
{
// can not create the algo specified - should never happens here
@ -242,7 +191,8 @@ Handle(BRepMesh_DiscretRoot) BRepMesh_DiscretFactory
else //if (myDefaultName == THE_FAST_DISCRET_MESH)
{
// use built-in
BRepMesh_IncrementalMesh::Discret (theShape, theDeflection, theAngle, anInstancePtr);
BRepMesh_IncrementalMesh::Discret (theShape,
theDeflection, theAngle, anInstancePtr);
}
// cover with handle

View File

@ -0,0 +1,118 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_DiscretFactory_HeaderFile
#define _BRepMesh_DiscretFactory_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <BRepMesh_PluginEntryType.hxx>
#include <BRepMesh_FactoryError.hxx>
#include <TColStd_MapOfAsciiString.hxx>
#include <TCollection_AsciiString.hxx>
#include <Plugin_MapOfFunctions.hxx>
#include <BRepMesh_DiscretRoot.hxx>
class TColStd_MapOfAsciiString;
class TCollection_AsciiString;
class BRepMesh_DiscretRoot;
class TopoDS_Shape;
//! This class intended to setup / retrieve default triangulation algorithm. <br>
//! Use BRepMesh_DiscretFactory::Get() static method to retrieve global Factory instance. <br>
//! Use BRepMesh_DiscretFactory::Discret() method to retrieve meshing tool. <br>
class BRepMesh_DiscretFactory
{
public:
DEFINE_STANDARD_ALLOC
//! Returns the global factory instance.
Standard_EXPORT static BRepMesh_DiscretFactory& Get();
//! Returns the list of registered meshing algorithms.
inline const TColStd_MapOfAsciiString& Names() const
{
return myNames;
}
//! Setup meshing algorithm by name. <br>
//! Returns TRUE if requested tool is available. <br>
//! On fail Factory will continue to use previous algo.
Standard_EXPORT Standard_Boolean SetDefaultName(const TCollection_AsciiString& theName)
{
return SetDefault(theName, myFunctionName);
}
//! Returns name for current meshing algorithm.
inline const TCollection_AsciiString& DefaultName() const
{
return myDefaultName;
}
//! Advanced function. Changes function name to retrieve from plugin. <br>
//! Returns TRUE if requested tool is available. <br>
//! On fail Factory will continue to use previous algo.
Standard_EXPORT Standard_Boolean SetFunctionName(const TCollection_AsciiString& theFuncName)
{
return SetDefault(myDefaultName, theFuncName);
}
//! Returns function name that should be exported by plugin.
inline const TCollection_AsciiString& FunctionName() const
{
return myFunctionName;
}
//! Returns error status for last meshing algorithm switch.
inline BRepMesh_FactoryError ErrorStatus() const
{
return myErrorStatus;
}
//! Setup meshing algorithm that should be created by this Factory. <br>
//! Returns TRUE if requested tool is available. <br>
//! On fail Factory will continue to use previous algo. <br>
//! Call ::ErrorStatus() method to retrieve fault reason.
Standard_EXPORT Standard_Boolean SetDefault(const TCollection_AsciiString& theName,
const TCollection_AsciiString& theFuncName = "DISCRETALGO");
//! Returns triangulation algorithm instance.
//! \param theShape shape to be meshed.
//! \param theLinDeflection linear deflection to be used for meshing.
//! \param theAngDeflection angular deflection to be used for meshing.
Standard_EXPORT Handle(BRepMesh_DiscretRoot) Discret(const TopoDS_Shape& theShape,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection);
protected:
//! Constructor
Standard_EXPORT BRepMesh_DiscretFactory();
//! Destructor
Standard_EXPORT virtual ~BRepMesh_DiscretFactory();
//! Clears factory data.
Standard_EXPORT void clear();
BRepMesh_PluginEntryType myPluginEntry;
BRepMesh_FactoryError myErrorStatus;
TColStd_MapOfAsciiString myNames;
TCollection_AsciiString myDefaultName;
TCollection_AsciiString myFunctionName;
Plugin_MapOfFunctions myFactoryMethods;
};
#endif

View File

@ -1,92 +0,0 @@
-- Created on: 2008-04-10
-- Created by: Peter KURNEV <pkv@irinox>
-- Copyright (c) 2008-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
deferred class DiscretRoot from BRepMesh
inherits Transient from Standard
---Purpose:
-- This is a common interface for meshing algorithms
-- instantiated by Mesh Factory and implemented by plugins.
uses
Shape from TopoDS
--raises
is
Initialize
returns DiscretRoot from BRepMesh;
SetDeflection ( me : mutable;
theDeflection : Real from Standard);
---Purpose:
-- Setup linear deflection.
---C++: alias "Standard_EXPORT virtual ~BRepMesh_DiscretRoot();"
Deflection (me)
returns Real from Standard;
---Purpose:
-- Returns linear deflection.
SetAngle ( me : mutable;
theAngle : Real from Standard);
---Purpose:
-- Setup angular deflection.
Angle (me)
returns Real from Standard;
---Purpose:
-- Returns angular deflection.
SetShape ( me : mutable;
theShape : Shape from TopoDS);
---Purpose:
-- Set the shape to triangulate.
Shape (me)
returns Shape from TopoDS;
---C++: return const &
Perform (me : mutable)
is deferred;
---Purpose:
-- Compute triangulation for set shape.
IsDone (me)
returns Boolean from Standard;
---Purpose:
-- Returns true if triangualtion was performed and has success.
--
-- Protected methods
--
SetDone (me : mutable)
is protected;
SetNotDone (me : mutable)
is protected;
Init (me : mutable)
is virtual protected;
fields
myDeflection : Real from Standard is protected;
myAngle : Real from Standard is protected;
myShape : Shape from TopoDS is protected;
myIsDone : Boolean from Standard is protected;
end DiscretRoot;

View File

@ -13,7 +13,10 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_DiscretRoot.ixx>
#include <BRepMesh_DiscretRoot.hxx>
IMPLEMENT_STANDARD_HANDLE (BRepMesh_DiscretRoot, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_DiscretRoot, Standard_Transient)
//=======================================================================
//function : BRepMesh_DiscretRoot
@ -21,10 +24,9 @@
//=======================================================================
BRepMesh_DiscretRoot::BRepMesh_DiscretRoot()
: myDeflection (0.001),
myAngle (0.1),
myIsDone (Standard_False)
myAngle (0.1),
myIsDone (Standard_False)
{
//
}
//=======================================================================
@ -36,91 +38,9 @@ BRepMesh_DiscretRoot::~BRepMesh_DiscretRoot()
}
//=======================================================================
//function : SetDeflection
//function : init
//purpose :
//=======================================================================
void BRepMesh_DiscretRoot::SetDeflection (const Standard_Real theDeflection)
void BRepMesh_DiscretRoot::init()
{
myDeflection = theDeflection;
}
//=======================================================================
//function : Deflection
//purpose :
//=======================================================================
Standard_Real BRepMesh_DiscretRoot::Deflection() const
{
return myDeflection;
}
//=======================================================================
//function : SetAngle
//purpose :
//=======================================================================
void BRepMesh_DiscretRoot::SetAngle (const Standard_Real theAngle)
{
myAngle = theAngle;
}
//=======================================================================
//function : Angle
//purpose :
//=======================================================================
Standard_Real BRepMesh_DiscretRoot::Angle() const
{
return myAngle;
}
//=======================================================================
//function : SetShape
//purpose :
//=======================================================================
void BRepMesh_DiscretRoot::SetShape (const TopoDS_Shape& theShape)
{
myShape = theShape;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& BRepMesh_DiscretRoot::Shape() const
{
return myShape;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_DiscretRoot::IsDone() const
{
return myIsDone;
}
//=======================================================================
//function : SetDone
//purpose :
//=======================================================================
void BRepMesh_DiscretRoot::SetDone()
{
myIsDone = Standard_True;
}
//=======================================================================
//function : SetNotDone
//purpose :
//=======================================================================
void BRepMesh_DiscretRoot::SetNotDone()
{
myIsDone = Standard_False;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BRepMesh_DiscretRoot::Init()
{
//
}

View File

@ -0,0 +1,105 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_DiscretRoot_HeaderFile
#define _BRepMesh_DiscretRoot_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <TopoDS_Shape.hxx>
#include <Standard_Transient.hxx>
//! This is a common interface for meshing algorithms
//! instantiated by Mesh Factory and implemented by plugins.
class BRepMesh_DiscretRoot : public Standard_Transient
{
public:
//! Destructor
Standard_EXPORT virtual ~BRepMesh_DiscretRoot();
//! Setup linear deflection.
inline void SetDeflection(const Standard_Real theDeflection)
{
myDeflection = theDeflection;
}
//! Returns linear deflection.
inline Standard_Real Deflection() const
{
return myDeflection;
}
//! Setup angular deflection.
inline void SetAngle(const Standard_Real theAngle)
{
myAngle = theAngle;
}
//! Returns angular deflection.
inline Standard_Real Angle() const
{
return myAngle;
}
//! Set the shape to triangulate.
inline void SetShape(const TopoDS_Shape& theShape)
{
myShape = theShape;
}
inline const TopoDS_Shape& Shape() const
{
return myShape;
}
//! Returns true if triangualtion was performed and has success.
inline Standard_Boolean IsDone() const
{
return myIsDone;
}
//! Compute triangulation for set shape.
Standard_EXPORT virtual void Perform() = 0;
DEFINE_STANDARD_RTTI(BRepMesh_DiscretRoot)
protected:
//! Constructor
Standard_EXPORT BRepMesh_DiscretRoot();
//! Sets IsDone flag.
inline void setDone()
{
myIsDone = Standard_True;
}
//! Clears IsDone flag.
inline void setNotDone()
{
myIsDone = Standard_False;
}
Standard_EXPORT virtual void init();
Standard_Real myDeflection;
Standard_Real myAngle;
TopoDS_Shape myShape;
Standard_Boolean myIsDone;
};
DEFINE_STANDARD_HANDLE(BRepMesh_DiscretRoot, Standard_Transient)
#endif

View File

@ -1,84 +0,0 @@
-- Created on: 1993-09-22
-- Created by: Didier PIFFAULT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Edge from BRepMesh
---Purpose:
uses Boolean from Standard,
Integer from Standard,
DegreeOfFreedom from BRepMesh
is Create
returns Edge from BRepMesh;
---C++: inline
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;
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 BRepMesh
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;
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;
fields myFirstNode : Integer from Standard;
myLastNode : Integer from Standard;
myMovability : DegreeOfFreedom from BRepMesh;
end Edge;

View File

@ -1,48 +0,0 @@
// Created on: 1993-09-23
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_Edge.ixx>
BRepMesh_Edge::BRepMesh_Edge(const Standard_Integer vDebut,
const Standard_Integer vFin,
const BRepMesh_DegreeOfFreedom canMove)
: myFirstNode(vDebut), myLastNode(vFin), myMovability(canMove)
{}
void BRepMesh_Edge::SetMovability(const BRepMesh_DegreeOfFreedom Move)
{
myMovability =Move;
}
Standard_Integer BRepMesh_Edge::HashCode(const Standard_Integer Upper)const
{
return ::HashCode(myFirstNode+myLastNode, Upper);
}
Standard_Boolean BRepMesh_Edge::IsEqual(const BRepMesh_Edge& Other)const
{
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
{
return (myFirstNode==Other.myFirstNode && myLastNode==Other.myLastNode);
}

View File

@ -0,0 +1,122 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_Edge_HeaderFile
#define _BRepMesh_Edge_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <BRepMesh_DegreeOfFreedom.hxx>
//! Light weighted structure representing link of the mesh.
class BRepMesh_Edge
{
public:
DEFINE_STANDARD_ALLOC
//! Default constructor.
Standard_EXPORT BRepMesh_Edge()
: myFirstNode (-1),
myLastNode (-1),
myMovability(BRepMesh_Deleted)
{
}
//! Contructs a link beetween two vertices.
Standard_EXPORT BRepMesh_Edge(const Standard_Integer theFirstNode,
const Standard_Integer theLastNode,
const BRepMesh_DegreeOfFreedom theMovability)
: myFirstNode (theFirstNode),
myLastNode (theLastNode),
myMovability(theMovability)
{
}
//! Returns index of first node of the Link.
inline Standard_Integer FirstNode() const
{
return myFirstNode;
}
//! Returns index of last node of the Link.
inline Standard_Integer LastNode() const
{
return myLastNode;
}
//! Returns movability flag of the Link.
inline BRepMesh_DegreeOfFreedom Movability() const
{
return myMovability;
}
//! Sets movability flag of the Link.
//! \param theMovability flag to be set.
inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
{
myMovability = theMovability;
}
//! Returns hash code for this edge.
//! \param theUpper upper index in the container.
//! \return hash code.
Standard_EXPORT Standard_Integer HashCode(const Standard_Integer theUpper) const
{
return ::HashCode(myFirstNode + myLastNode, theUpper);
}
//! Checks if the given edge and this one have the same orientation.
//! \param theOther edge to be checked against this one.
//! \retrun TRUE if edges have the same orientation, FALSE if not.
inline Standard_Boolean IsSameOrientation(const BRepMesh_Edge& theOther) const
{
return (myFirstNode == theOther.myFirstNode && myLastNode == theOther.myLastNode);
}
//! Checks for equality with another edge.
//! \param theOther edge to be checked against this one.
//! \return TRUE if equal, FALSE if not.
inline Standard_Boolean IsEqual(const BRepMesh_Edge& theOther) const
{
if (myMovability == BRepMesh_Deleted ||
theOther.myMovability == BRepMesh_Deleted)
{
return Standard_False;
}
return IsSameOrientation(theOther) ||
(myFirstNode == theOther.myLastNode && myLastNode == theOther.myFirstNode);
}
//! Alias for IsEqual.
Standard_Boolean operator ==(const BRepMesh_Edge& Other) const
{
return IsEqual(Other);
}
private:
Standard_Integer myFirstNode;
Standard_Integer myLastNode;
BRepMesh_DegreeOfFreedom myMovability;
};
inline Standard_Integer HashCode(const BRepMesh_Edge& theEdge,
const Standard_Integer theUpper)
{
return theEdge.HashCode(theUpper);
}
#endif

View File

@ -1,38 +0,0 @@
// Created on: 1993-09-23
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
inline BRepMesh_Edge::BRepMesh_Edge()
: myFirstNode(-1),
myLastNode(-1),
myMovability(BRepMesh_Deleted)
{
}
inline Standard_Integer BRepMesh_Edge::FirstNode()const
{
return myFirstNode;
}
inline Standard_Integer BRepMesh_Edge::LastNode()const
{
return myLastNode;
}
inline BRepMesh_DegreeOfFreedom BRepMesh_Edge::Movability()const
{
return myMovability;
}

View File

@ -1,81 +0,0 @@
-- Created on: 2008-10-31
-- Created by: EPA
-- Copyright (c) 2008-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class FaceAttribute from BRepMesh inherits TShared from MMgt
---Purpose: auxiliary class for FastDiscret and FastDiscretFace classes
uses
Real from Standard,
Address from Standard,
ClassifierPtr from BRepMesh
is
Create returns FaceAttribute from BRepMesh;
GetDefFace(me:mutable) returns Real;
---C++: return &
---C++: inline
GetUMin(me:mutable) returns Real;
---C++: return &
---C++: inline
GetVMin(me:mutable) returns Real;
---C++: return &
---C++: inline
GetUMax(me:mutable) returns Real;
---C++: return &
---C++: inline
GetVMax(me:mutable) returns Real;
---C++: return &
---C++: inline
GetDeltaX(me:mutable) returns Real;
---C++: return &
---C++: inline
GetDeltaY(me:mutable) returns Real;
---C++: return &
---C++: inline
GetMinX(me:mutable) returns Real;
---C++: return &
---C++: inline
GetMinY(me:mutable) returns Real;
---C++: return &
---C++: inline
GetClassifier(me:mutable) returns ClassifierPtr from BRepMesh;
---C++: return &
---C++: inline
fields
mydefface : Real from Standard;
myumin : Real from Standard;
myumax : Real from Standard;
myvmin : Real from Standard;
myvmax : Real from Standard;
mydeltaX : Real from Standard;
mydeltaY : Real from Standard;
myminX : Real from Standard;
myminY : Real from Standard;
myclassifier: ClassifierPtr from BRepMesh;
end FaceAttribute;

View File

@ -12,7 +12,10 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_FaceAttribute.ixx>
#include <BRepMesh_FaceAttribute.hxx>
IMPLEMENT_STANDARD_HANDLE (BRepMesh_FaceAttribute, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FaceAttribute, Standard_Transient)
//=======================================================================
//function : BRepMesh_FaceAttribute

View File

@ -0,0 +1,99 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_FaceAttribute_HeaderFile
#define _BRepMesh_FaceAttribute_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <BRepMesh_Collections.hxx>
#include <Standard_Transient.hxx>
//! auxiliary class for FastDiscret and FastDiscretFace classes <br>
class BRepMesh_FaceAttribute : public Standard_Transient
{
public:
Standard_EXPORT BRepMesh_FaceAttribute();
inline Standard_Real& GetDefFace()
{
return mydefface;
}
inline Standard_Real& GetUMin()
{
return myumin;
}
inline Standard_Real& GetVMin()
{
return myvmin;
}
inline Standard_Real& GetUMax()
{
return myumax;
}
inline Standard_Real& GetVMax()
{
return myvmax;
}
inline Standard_Real& GetDeltaX()
{
return mydeltaX;
}
inline Standard_Real& GetDeltaY()
{
return mydeltaY;
}
inline Standard_Real& GetMinX()
{
return myminX;
}
inline Standard_Real& GetMinY()
{
return myminY;
}
inline BRepMeshCol::HClassifier& GetClassifier()
{
return myclassifier;
}
DEFINE_STANDARD_RTTI(BRepMesh_FaceAttribute)
private:
Standard_Real mydefface;
Standard_Real myumin;
Standard_Real myumax;
Standard_Real myvmin;
Standard_Real myvmax;
Standard_Real mydeltaX;
Standard_Real mydeltaY;
Standard_Real myminX;
Standard_Real myminY;
BRepMeshCol::HClassifier myclassifier;
};
DEFINE_STANDARD_HANDLE(BRepMesh_FaceAttribute, Standard_Transient)
#endif

View File

@ -1,63 +0,0 @@
// Created by: Ekaterina SMIRNOVA
// Copyright (c) 2008-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
inline Standard_Real& BRepMesh_FaceAttribute::GetDefFace()
{
return mydefface;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetUMin()
{
return myumin;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetVMin()
{
return myvmin;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetUMax()
{
return myumax;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetVMax()
{
return myvmax;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetDeltaX()
{
return mydeltaX;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetDeltaY()
{
return mydeltaY;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetMinX()
{
return myminX;
}
inline Standard_Real& BRepMesh_FaceAttribute::GetMinY()
{
return myminY;
}
inline BRepMesh_ClassifierPtr& BRepMesh_FaceAttribute::GetClassifier()
{
return myclassifier;
}

View File

@ -18,6 +18,7 @@
#include <Standard.hxx>
#include <Standard_Mutex.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopLoc_Location.hxx>
@ -66,22 +67,20 @@ public:
aEdges.push_back(TopoDS::Edge(aEdgeIt.Current()));
BRepMesh_EdgeChecker aEdgeChecker(aFaceT, aFaceLoc, myMutex, myIsFailed);
#ifdef HAVE_TBB
if (myIsInParallel)
{
#ifdef HAVE_TBB
// check faces in parallel threads using TBB
tbb::parallel_for_each(aEdges.begin(), aEdges.end(), aEdgeChecker);
#else
// alternative parallelization not yet available
for (std::vector<TopoDS_Edge>::iterator it(aEdges.begin()); it != aEdges.end(); it++)
aEdgeChecker(*it);
#endif
}
else
{
#endif
for (std::vector<TopoDS_Edge>::iterator it(aEdges.begin()); it != aEdges.end(); it++)
aEdgeChecker(*it);
#ifdef HAVE_TBB
}
#endif
}
//! Returns status of the check.

View File

@ -1,4 +1,4 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@ -11,6 +11,16 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <NCollection_IncAllocator.hxx>
typedef Handle(NCollection_IncAllocator) BRepMesh_BaseAllocator;
#ifndef _BRepMesh_FactoryError_HeaderFile
#define _BRepMesh_FactoryError_HeaderFile
enum BRepMesh_FactoryError
{
BRepMesh_FE_NOERROR,
BRepMesh_FE_LIBRARYNOTFOUND,
BRepMesh_FE_FUNCTIONNOTFOUND,
BRepMesh_FE_CANNOTCREATEALGO
};
#endif

View File

@ -1,351 +0,0 @@
-- Created on: 1996-02-27
-- Created by: Laurent PAINNOT
-- Copyright (c) 1996-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class FastDiscret from BRepMesh inherits TShared from MMgt
---Purpose: Algorithm to mesh a shape with respect of the
-- frontier the deflection and by option the shared
-- components.
uses Boolean from Standard,
Integer from Standard,
Box from Bnd,
Real from Standard,
Shape from TopoDS,
Face from TopoDS,
Edge from TopoDS,
FaceAttribute from BRepMesh,
Vertex from TopoDS,
Triangle from BRepMesh,
Vertex from BRepMesh,
Edge from BRepMesh,
ListOfInteger from TColStd,
MapOfInteger from TColStd,
SequenceOfInteger from TColStd,
ListOfReal from TColStd,
IndexedMapOfInteger from TColStd,
SequenceOfPnt2d from TColgp,
Dir from gp,
Pnt from gp,
XY from gp,
Pnt2d from gp,
DataMapOfIntegerPnt from BRepMesh,
DataMapOfIntegerListOfXY from BRepMesh,
DataMapOfShapePairOfPolygon from BRepMesh,
Delaun from BRepMesh,
DataMapOfVertexInteger from BRepMesh,
DataStructureOfDelaun from BRepMesh,
ListOfVertex from BRepMesh,
MapOfShape from TopTools,
HSurface from BRepAdaptor,
ClassifierPtr from BRepMesh,
IndexedMapOfReal from TColStd,
Status from BRepMesh,
DataMapOfShapeReal from TopTools,
ListOfShape from TopTools,
Curve from Geom2d,
MapOfInteger from BRepMesh,
BaseAllocator from BRepMesh,
DataMapOfFaceAttribute from BRepMesh,
IndexedDataMapOfShapeListOfShape from TopTools,
MutexForShapeProvider from TopTools,
ShapeEnum from TopAbs
is
Create (defle : Real from Standard;
angle : Real from Standard;
B : Box from Bnd;
withShare : Boolean from Standard=Standard_True;
inshape : Boolean from Standard=Standard_False;
relative : Boolean from Standard=Standard_False;
shapetrigu : Boolean from Standard=Standard_False;
isInParallel: Boolean from Standard=Standard_False)
returns FastDiscret from BRepMesh;
Create (defle : Real from Standard;
shape : Shape from TopoDS;
B : Box from Bnd;
angle : Real from Standard;
withShare : Boolean from Standard=Standard_True;
inshape : Boolean from Standard=Standard_False;
relative : Boolean from Standard=Standard_False;
shapetrigu : Boolean from Standard=Standard_False;
isInParallel: Boolean from Standard=Standard_False)
---Purpose: if the boolean <relative> is True, the
-- deflection used for the polygonalisation of
-- each edge will be <defle> * Size of Edge.
-- the deflection used for the faces will be the maximum
-- deflection of their edges.
--
-- if <shapetrigu> is True, the triangulation, if exists
-- with a correct deflection, can be used to re-triangulate
-- the shape.
--
-- if <inshape> is True, the calculated
-- triangulation will be stored in the shape.
returns FastDiscret from BRepMesh;
Perform (me: mutable; shape: Shape from TopoDS) is static;
---Purpose: Build triangulation on the whole shape
Add (me: mutable; face: Face from TopoDS;
ancestor : IndexedDataMapOfShapeListOfShape from TopTools) is static;
---Purpose: Record a face for further processing.
Process (me; face: Face from TopoDS) is static;
---Purpose: Triangulate a face previously recorded for
-- processing by call to Add(). Can be executed in
-- parallel threads.
---C++: alias operator ()
CurrentFaceStatus(me)
returns Status from BRepMesh;
Add (me : mutable;
edge : Edge from TopoDS;
face : Face from TopoDS;
S : HSurface from BRepAdaptor;
C : Curve from Geom2d;
ancestor : IndexedDataMapOfShapeListOfShape from TopTools;
defedge: Real from Standard;
first : Real from Standard;
last : Real from Standard)
is static private;
Add (me : mutable;
theVert: Vertex from TopoDS;
face : Face from TopoDS;
S : HSurface from BRepAdaptor) is private;
Update (me: mutable;
Edge : Edge from TopoDS;
Face : Face from TopoDS;
C : Curve from Geom2d;
defedge: Real from Standard;
first : Real from Standard;
last : Real from Standard)
returns Boolean is private;
RelativeEdgeDeflection(myclass;
edge : Edge from TopoDS;
defle : Real from Standard;
dtotale : Real from Standard;
cdef : out Real from Standard)
---Purpose: Returns computed relative deflection for edge
returns Real from Standard;
BoxMaxDimension(myclass;
box : in Box from Bnd;
maxdim : out Real from Standard);
---Purpose: Returns the maximal dimension of Bnd_Box
InternalVertices
(me : mutable;
caro : HSurface from BRepAdaptor;
inter : in out ListOfVertex from BRepMesh;
defedge : Real from Standard;
classifier : ClassifierPtr from BRepMesh)
is static private;
Control (me : mutable;
caro : HSurface from BRepAdaptor;
defface : Real from Standard;
inter : in out ListOfVertex from BRepMesh;
badTri : in out ListOfInteger from TColStd;
nulTri : in out ListOfInteger from TColStd;
trigu : in out Delaun from BRepMesh;
isfirst : Boolean from Standard)
returns Real from Standard is static private;
AddInShape(me: mutable;
face : Face from TopoDS;
defedge: Real from Standard)
is static private;
SetParallel ( me : mutable;
theInParallel : Boolean from Standard);
---Purpose:
-- Request algorithm to launch in multiple threads
-- to improve performance (should be supported by plugin).
IsParallel (me)
returns Boolean from Standard;
---Purpose:
-- Returns the multi-threading usage flag.
CreateMutexesForSubShapes(me : mutable;
theShape : Shape from TopoDS;
theType : ShapeEnum from TopAbs);
---Purpose:
-- Creates mutexes for each sub-shape of type theType in theShape.
-- Used to avoid data races.
RemoveAllMutexes(me: mutable);
---Purpose:
-- Removes all created mutexes
-- Output :
NbTriangles(me)
---Purpose: Gives the number of built triangles.
returns Integer from Standard
is static;
Triangle (me;
Index : Integer from Standard)
---Purpose: Gives the triangle of <Index>.
---C++: return const &
returns Triangle from BRepMesh
is static;
NbEdges (me)
---Purpose: Gives the number of built Edges
returns Integer from Standard
is static;
Edge (me;
Index : Integer from Standard)
---Purpose: Gives the edge of index <Index>.
---C++: return const &
returns Edge from BRepMesh
is static;
NbVertices (me)
---Purpose: Gives the number of built Vertices.
returns Integer from Standard
is static;
Vertex (me;
Index : Integer from Standard)
---Purpose: Gives the vertex of <Index>.
---C++: return const &
returns Vertex from BRepMesh
is static;
Pnt (me;
Index : Integer from Standard)
---Purpose: Gives the location3d of the vertex of <Index>.
---C++: return const &
returns Pnt from gp
is static;
VerticesOfDomain
(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 BRepMesh)
---Purpose: Gives the list of indices of the edges
---C++: inline
is static;
TrianglesOfDomain(me; Indices: in out MapOfInteger from BRepMesh)
---Purpose: Gives the list of indices of the triangles
---C++: inline
is static;
NbPoint3d (me)
---Purpose: Gives the number of different location in 3d
-- space. It is different of the number of
-- vertices if there is more than one surface.
-- Even for one surface, the number can be different
-- if an edge is shared.
---C++: inline
returns Integer from Standard
is static;
Point3d (me;
Index : Integer from Standard)
---Purpose: Gives the 3d space location of the vertex <Index>.
---C++: return const &
---C++: inline
returns Pnt from gp
is static;
GetDeflection(me)
---Purpose: returns the deflection value.
---C++: inline
returns Real from Standard;
GetAngle(me)
---Purpose: returns the deflection value.
---C++: inline
returns Real from Standard;
WithShare(me)
---C++: inline
returns Boolean from Standard;
InShape(me)
---C++: inline
returns Boolean from Standard;
ShapeTrigu(me)
---C++: inline
returns Boolean from Standard;
GetFaceAttribute(me;
face : Face from TopoDS;
fattrib : in out FaceAttribute from BRepMesh)
---Purpose: returns the face deflection value.
returns Boolean from Standard;
RemoveFaceAttribute(me : mutable;
face : Face from TopoDS);
---Purpose: remove face attribute as useless to free locate memory
GetMapOfDefEdge(me)
---C++: return const &
---C++: inline
returns DataMapOfShapeReal from TopTools;
fields
myAngle : Real from Standard;
myDeflection : Real from Standard;
myDtotale : Real from Standard;
myWithShare : Boolean from Standard;
myInParallel : Boolean from Standard;
myVertices : DataMapOfVertexInteger from BRepMesh;
myEdges : DataMapOfShapePairOfPolygon from BRepMesh;
myInternaledges: DataMapOfShapePairOfPolygon from BRepMesh;
myNbLocat : Integer from Standard;
myLocation3d : DataMapOfIntegerPnt from BRepMesh;
myStructure : DataStructureOfDelaun from BRepMesh;
myMapattrib : DataMapOfFaceAttribute from BRepMesh;
myVemap : IndexedMapOfInteger from TColStd;
myLocation2d : DataMapOfIntegerListOfXY from BRepMesh;
myRelative : Boolean from Standard;
myShapetrigu : Boolean from Standard;
myInshape : Boolean from Standard;
myFacestate : Status from BRepMesh;
myMapdefle : DataMapOfShapeReal from TopTools;
myNottriangulated : ListOfShape from TopTools;
myAllocator : BaseAllocator from BRepMesh;
myMutexProvider: MutexForShapeProvider from TopTools;
end FastDiscret;

View File

@ -14,79 +14,60 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_FastDiscret.ixx>
#include <BRepMesh_FastDiscret.hxx>
#include <BRepMesh_WireChecker.hxx>
#include <BRepMesh_FastDiscretFace.hxx>
#include <BRepMesh_FaceAttribute.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_ClassifierPtr.hxx>
#include <BRepMesh_Classifier.hxx>
#include <BRepMesh_WireChecker.hxx>
#include <BRepMesh_GeomTool.hxx>
#include <BRepMesh_PairOfPolygon.hxx>
#include <BRepMesh_DataMapOfShapePairOfPolygon.hxx>
#include <BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon.hxx>
#include <Geom_Plane.hxx>
#include <GeomAbs_IsoType.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <TopAbs.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <Precision.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Connect.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Precision.hxx>
#include <BRepMesh_Classifier.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepTools.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <BRepTools.hxx>
#include <BRepBndLib.hxx>
#include <BndLib_Add3dCurve.hxx>
#include <BRep_Tool.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Precision.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColGeom2d_SequenceOfCurve.hxx>
#include <SortTools_ShellSortOfReal.hxx>
#include <TCollection_CompareOfReal.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom2d_Curve.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <ElSLib.hxx>
#include <Geom_Surface.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <BRepMesh_IndexedMapOfVertex.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <BRepMesh_ListOfXY.hxx>
#include <BRepMesh_ListIteratorOfListOfXY.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
//#include <TColStd_DataMapOfInteger.hxx>
#include <TColGeom2d_SequenceOfCurve.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <NCollection_IncAllocator.hxx>
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
#include <BRep_PointRepresentation.hxx>
#include <BRep_TVertex.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <SortTools_ShellSortOfReal.hxx>
#include <TCollection_CompareOfReal.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <vector>
@ -97,26 +78,8 @@
#define UVDEFLECTION 1.e-05
inline Standard_Real MaxFaceTol (const TopoDS_Face& theFace)
{
Standard_Real T, TMax = BRep_Tool::Tolerance(theFace);
TopExp_Explorer Ex;
for (Ex.Init(theFace,TopAbs_EDGE); Ex.More(); Ex.Next())
{
T = BRep_Tool::Tolerance(TopoDS::Edge(Ex.Current()));
if (T > TMax) TMax = T;
}
for (Ex.Init(theFace,TopAbs_VERTEX); Ex.More(); Ex.Next())
{
T = BRep_Tool::Tolerance(TopoDS::Vertex(Ex.Current()));
if (T > TMax) TMax = T;
}
return TMax;
}
IMPLEMENT_STANDARD_HANDLE (BRepMesh_FastDiscret, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FastDiscret, Standard_Transient)
//=======================================================================
//function : BRepMesh_FastDiscret
@ -141,7 +104,7 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
{
myAllocator = new NCollection_IncAllocator(64000);
if(myRelative)
BoxMaxDimension(theBox, myDtotale);
BRepMesh_ShapeTool::BoxMaxDimension(theBox, myDtotale);
}
//=======================================================================
@ -149,10 +112,10 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
//purpose :
//=======================================================================
BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
const TopoDS_Shape& theShape,
const Bnd_Box& theBox,
BRepMesh_FastDiscret::BRepMesh_FastDiscret(const TopoDS_Shape& theShape,
const Standard_Real theDefle,
const Standard_Real theAngl,
const Bnd_Box& theBox,
const Standard_Boolean theWithShare,
const Standard_Boolean theInshape,
const Standard_Boolean theRelative,
@ -169,7 +132,7 @@ BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
{
myAllocator = new NCollection_IncAllocator(64000);
if(myRelative)
BoxMaxDimension(theBox, myDtotale);
BRepMesh_ShapeTool::BoxMaxDimension(theBox, myDtotale);
Perform(theShape);
}
@ -191,52 +154,6 @@ Standard_Boolean BRepMesh_FastDiscret::IsParallel() const
return myInParallel;
}
//=======================================================================
//function : BoxMaxDimension
//purpose :
//=======================================================================
void BRepMesh_FastDiscret::BoxMaxDimension(const Bnd_Box& theBox, Standard_Real& theMaxDim)
{
if(theBox.IsVoid())
return;
Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
theBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
theMaxDim = TXmax-TXmin;
const Standard_Real dy = TYmax-TYmin;
const Standard_Real dz = TZmax-TZmin;
if (dy > theMaxDim) theMaxDim = dy;
if (dz > theMaxDim) theMaxDim = dz;
}
//=======================================================================
//function : RelativeEdgeDeflection
//purpose :
//=======================================================================
Standard_Real BRepMesh_FastDiscret::RelativeEdgeDeflection(const TopoDS_Edge& theEdge,
const Standard_Real theDefle,
const Standard_Real theDTotale,
Standard_Real& theDefCoef)
{
theDefCoef = 1.;
Standard_Real defedge = theDefle;
if(theEdge.IsNull())
return defedge;
Bnd_Box B;
BRepBndLib::Add(theEdge, B);
BoxMaxDimension(B, defedge);
// adjusted in relation to the total size:
theDefCoef = theDTotale/(2*defedge);
if (theDefCoef < 0.5) theDefCoef = 0.5;
if (theDefCoef > 2.) theDefCoef = 2.;
defedge = theDefCoef * defedge * theDefle;
return defedge;
}
//=======================================================================
//function : Perform(shape)
//purpose :
@ -253,24 +170,22 @@ void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& theShape)
aFaces.push_back(aF);
}
#ifdef HAVE_TBB
if (myInParallel)
{
#ifdef HAVE_TBB
CreateMutexesForSubShapes(theShape, TopAbs_EDGE);
// mesh faces in parallel threads using TBB
tbb::parallel_for_each (aFaces.begin(), aFaces.end(), *this);
#else
// alternative parallelization not yet available
for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
Process (*it);
#endif
RemoveAllMutexes();
}
else
{
#endif
for (std::vector<TopoDS_Face>::iterator it(aFaces.begin()); it != aFaces.end(); it++)
Process (*it);
#ifdef HAVE_TBB
}
#endif
}
@ -353,12 +268,12 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface,
Standard_Integer nbEdge = 0;
Standard_Real savangle = myAngle;
Standard_Real cdef;
Standard_Real maxdef = 2.* MaxFaceTol(theface);
Standard_Real maxdef = 2.* BRepMesh_ShapeTool::MaxFaceTolerance(theface);
defface = 0.;
if (!myRelative) defface = Max(myDeflection, maxdef);
TColStd_SequenceOfReal aFSeq, aLSeq;
BRepMeshCol::SequenceOfReal aFSeq, aLSeq;
TColGeom2d_SequenceOfCurve aCSeq;
TopTools_SequenceOfShape aShSeq;
@ -380,7 +295,9 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface,
defedge = P->Deflection();
}
else {
defedge = RelativeEdgeDeflection(edge, myDeflection, myDtotale, cdef);
defedge = BRepMesh_ShapeTool::RelativeEdgeDeflection(edge,
myDeflection, myDtotale, cdef);
myAngle = savangle * cdef;
}
defface = defface + defedge;
@ -497,7 +414,7 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface,
Standard_Integer nbVertices = myVemap.Extent();
const Standard_Real tolclass = Precision::PConfusion(); //0.03*Max(myumax-myumin, myvmax-myvmin);
BRepMesh_ClassifierPtr classifier = new BRepMesh_Classifier;
BRepMeshCol::HClassifier classifier = new BRepMesh_Classifier;
{
BRepMesh_WireChecker aDFaceChecker(face,
tolclass, myInternaledges, myVemap, myStructure,
@ -694,28 +611,19 @@ void BRepMesh_FastDiscret::Add(const TopoDS_Face& theface,
Nodes(i) = Pnt(index);
Nodes2d(i).SetXY(Vertex(index).Coord());
}
BRepMesh_ShapeTool::AddInFace(face, T);
// storage of triangulation in the BRep.
//TopLoc_Location loc = face.Location();
if (!loc.IsIdentity()) {
gp_Trsf tr = loc.Transformation();
tr.Invert();
for (i = Nodes.Lower(); i <= Nodes.Upper(); i++)
Nodes(i).Transform(tr);
}
BRep_Builder B;
B.UpdateFace(face, T);
BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon It(myInternaledges);
for (; It.More(); It.Next()) {
BRepMeshCol::DMapOfShapePairOfPolygon::Iterator It(myInternaledges);
for (; It.More(); It.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(It.Key());
const BRepMesh_PairOfPolygon& pair = It.Value();
const Handle(Poly_PolygonOnTriangulation)& NOD1 = pair.First();
const Handle(Poly_PolygonOnTriangulation)& NOD2 = pair.Last();
if ( NOD1 == NOD2 )
B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, T, loc);
BRepMesh_ShapeTool::UpdateEdge(aEdge, NOD1, T, loc);
else
B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, NOD2, T, loc);
BRepMesh_ShapeTool::UpdateEdge(aEdge, NOD1, NOD2, T, loc);
}
}
@ -906,8 +814,8 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
Handle(BRepMesh_FaceAttribute) aFaceAttribute;
GetFaceAttribute ( theFace, aFaceAttribute );
theUV = BRepMesh_FastDiscretFace::FindUV(pBegin, uvFirst,
ipf, theGFace, mindist, aFaceAttribute, myLocation2d);
theUV = BRepMesh_ShapeTool::FindUV(ipf, uvFirst,
pBegin, mindist, aFaceAttribute, theGFace, myLocation2d);
BRepMesh_Vertex vf(theUV, ipf, BRepMesh_Frontier);
Standard_Integer ivf = myStructure->AddNode(vf);
@ -940,8 +848,8 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
}
}
theUV = BRepMesh_FastDiscretFace::FindUV(pEnd, uvLast, ipl,
theGFace, mindist, aFaceAttribute, myLocation2d);
theUV = BRepMesh_ShapeTool::FindUV(ipl, uvLast,
pEnd, mindist, aFaceAttribute, theGFace, myLocation2d);
BRepMesh_Vertex vl(theUV, ipl, BRepMesh_Frontier);
Standard_Integer ivl= myStructure->AddNode(vl);
@ -1000,7 +908,7 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
if ( aCurveType == GeomAbs_Circle )
nbpmin = 4; //OCC287
BRepMesh_GeomTool GT(cons, wFirst, wLast, 0.5 * myAngle, otherdefedge, nbpmin);
BRepMesh_GeomTool GT(cons, wFirst, wLast, otherdefedge, 0.5 * myAngle, nbpmin);
if ( aCurveType == GeomAbs_BSplineCurve )
{
@ -1015,7 +923,7 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
const Standard_Real& anEndInt = anIntervals.Value( aIntIt + 1 );
BRepMesh_GeomTool aDetalizator( cons, aStartInt, anEndInt,
0.5 * myAngle, otherdefedge, nbpmin );
otherdefedge, 0.5 * myAngle, nbpmin );
Standard_Integer aNbAddNodes = aDetalizator.NbPoints();
for ( Standard_Integer aNodeIt = 1; aNodeIt <= aNbAddNodes; ++aNodeIt )
@ -1023,7 +931,7 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
Standard_Real aParam;
gp_Pnt aPoint3d;
gp_Pnt2d aPoint2d;
aDetalizator.Value( cons, theGFace, aNodeIt, aParam, aPoint3d, aPoint2d );
aDetalizator.Value( aNodeIt, theGFace, aParam, aPoint3d, aPoint2d );
GT.AddPoint( aPoint3d, aParam, Standard_False );
}
}
@ -1069,7 +977,7 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
TColStd_Array1OfReal aParamArray(1, nbnodes);
for (i = 1; i <= nbnodes; i++)
{
GT.Value(cons, theGFace, i, parf, P3d, uvf);
GT.Value(i, theGFace, parf, P3d, uvf);
aParamArray.SetValue(i, parf);
}
for (i = 1; i < nbnodes; i++)
@ -1103,7 +1011,7 @@ void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
for (i = 2; i < GT.NbPoints(); i++)
{
// Record 3d point
GT.Value(cons, theGFace, i, puv, P3d, uv);
GT.Value(i, theGFace, puv, P3d, uv);
myNbLocat++;
myLocation3d.Bind(myNbLocat, P3d);
NodInStruct(i) = myNbLocat;
@ -1304,7 +1212,7 @@ Standard_Boolean BRepMesh_FastDiscret::Update(const TopoDS_Edge& theEdg
const Standard_Real theLast)
{
TopLoc_Location Loc;
Handle(Poly_Triangulation) T, TNull;
Handle(Poly_Triangulation) T;
Handle(Poly_PolygonOnTriangulation) Poly, NullPoly;
Standard_Integer i = 1;
@ -1404,8 +1312,8 @@ Standard_Boolean BRepMesh_FastDiscret::Update(const TopoDS_Edge& theEdg
Handle(BRepMesh_FaceAttribute) aFaceAttribute;
GetFaceAttribute ( theFace, aFaceAttribute );
theUV = BRepMesh_FastDiscretFace::FindUV(pBegin, uvFirst, ipf,
gFace, mindist, aFaceAttribute, myLocation2d);
theUV = BRepMesh_ShapeTool::FindUV(ipf, uvFirst,
pBegin, mindist, aFaceAttribute, gFace, myLocation2d);
BRepMesh_Vertex vf(theUV,ipf,BRepMesh_Frontier);
iv1 = myStructure->AddNode(vf);
@ -1442,8 +1350,8 @@ Standard_Boolean BRepMesh_FastDiscret::Update(const TopoDS_Edge& theEdg
}
}
NewNodInStruct(nbnodes) = ipl;
theUV = BRepMesh_FastDiscretFace::FindUV(pEnd, uvLast, ipl,
gFace, mindist, aFaceAttribute, myLocation2d);
theUV = BRepMesh_ShapeTool::FindUV(ipl, uvLast,
pEnd, mindist, aFaceAttribute, gFace, myLocation2d);
BRepMesh_Vertex vl(theUV,ipl,BRepMesh_Frontier);
@ -1589,16 +1497,14 @@ Standard_Boolean BRepMesh_FastDiscret::Update(const TopoDS_Edge& theEdg
}
else
{
BRep_Builder B;
B.UpdateEdge(theEdge,NullPoly,T,Loc);
B.UpdateFace(theFace,TNull);
BRepMesh_ShapeTool::NullifyEdge(theEdge, T, Loc);
BRepMesh_ShapeTool::NullifyFace(theFace);
}
}
else if (!T.IsNull() && !T->HasUVNodes())
{
BRep_Builder B;
B.UpdateEdge(theEdge,NullPoly,T,Loc);
B.UpdateFace(theFace,TNull);
BRepMesh_ShapeTool::NullifyEdge(theEdge, T, Loc);
BRepMesh_ShapeTool::NullifyFace(theFace);
}
}
while (!Poly.IsNull());
@ -1682,15 +1588,15 @@ const gp_Pnt& BRepMesh_FastDiscret::Pnt(const Standard_Integer Index) const
//purpose :
//=======================================================================
void BRepMesh_FastDiscret::VerticesOfDomain(BRepMesh_MapOfInteger& Indices) const
void BRepMesh_FastDiscret::VerticesOfDomain(BRepMeshCol::MapOfInteger& Indices) const
{
Indices.Clear();
// recuperate from the map of edges.
const BRepMesh_MapOfInteger& edmap = myStructure->LinkOfDomain();
const BRepMeshCol::MapOfInteger& edmap = myStructure->LinksOfDomain();
// iterator on edges.
BRepMesh_MapOfInteger::Iterator iter(edmap);
BRepMeshCol::MapOfInteger::Iterator iter(edmap);
Standard_Integer ind_edge;
for (iter.Reset(); iter.More(); iter.Next()) {

View File

@ -0,0 +1,289 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_FastDiscret_HeaderFile
#define _BRepMesh_FastDiscret_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <BRepMesh_Status.hxx>
#include <TopTools_DataMapOfShapeReal.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MutexForShapeProvider.hxx>
#include <Standard_Transient.hxx>
#include <Handle_BRepAdaptor_HSurface.hxx>
#include <Handle_Geom2d_Curve.hxx>
#include <BRepMesh_Delaun.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_FaceAttribute.hxx>
#include <BRepMesh_Collections.hxx>
class BRepMesh_DataStructureOfDelaun;
class Bnd_Box;
class TopoDS_Shape;
class TopoDS_Face;
class TopTools_IndexedDataMapOfShapeListOfShape;
class TopoDS_Edge;
class BRepAdaptor_HSurface;
class Geom2d_Curve;
class TopoDS_Vertex;
class BRepMesh_Edge;
class BRepMesh_Vertex;
class gp_Pnt;
class BRepMesh_FaceAttribute;
class TopTools_DataMapOfShapeReal;
//! Algorithm to mesh a shape with respect of the <br>
//! frontier the deflection and by option the shared <br>
//! components. <br>
class BRepMesh_FastDiscret : public Standard_Transient
{
public:
Standard_EXPORT BRepMesh_FastDiscret(const Standard_Real defle,
const Standard_Real angle,
const Bnd_Box& B,
const Standard_Boolean withShare = Standard_True,
const Standard_Boolean inshape = Standard_False,
const Standard_Boolean relative = Standard_False,
const Standard_Boolean shapetrigu = Standard_False,
const Standard_Boolean isInParallel = Standard_False);
//! if the boolean <relative> is True, the <br>
//! deflection used for the polygonalisation of <br>
//! each edge will be <defle> * Size of Edge. <br>
//! the deflection used for the faces will be the maximum <br>
//! deflection of their edges. <br>
//! <br>
//! if <shapetrigu> is True, the triangulation, if exists <br>
//! with a correct deflection, can be used to re-triangulate <br>
//! the shape. <br>
//! <br>
//! if <inshape> is True, the calculated <br>
//! triangulation will be stored in the shape. <br>
Standard_EXPORT BRepMesh_FastDiscret(const TopoDS_Shape& shape,
const Standard_Real defle,
const Standard_Real angle,
const Bnd_Box& B,
const Standard_Boolean withShare = Standard_True,
const Standard_Boolean inshape = Standard_False,
const Standard_Boolean relative = Standard_False,
const Standard_Boolean shapetrigu = Standard_False,
const Standard_Boolean isInParallel = Standard_False);
//! Build triangulation on the whole shape <br>
Standard_EXPORT void Perform(const TopoDS_Shape& shape);
//! Record a face for further processing. <br>
Standard_EXPORT void Add(const TopoDS_Face& face,
const TopTools_IndexedDataMapOfShapeListOfShape& ancestor) ;
//! Triangulate a face previously recorded for <br>
//! processing by call to Add(). Can be executed in <br>
//! parallel threads. <br>
Standard_EXPORT void Process(const TopoDS_Face& face) const;
void operator ()(const TopoDS_Face& face) const
{
Process(face);
}
Standard_EXPORT BRepMesh_Status CurrentFaceStatus() const;
//! Request algorithm to launch in multiple threads <br>
//! to improve performance (should be supported by plugin). <br>
Standard_EXPORT void SetParallel(const Standard_Boolean theInParallel);
//! Returns the multi-threading usage flag. <br>
Standard_EXPORT Standard_Boolean IsParallel() const;
//! Creates mutexes for each sub-shape of type theType in theShape. <br>
//! Used to avoid data races. <br>
Standard_EXPORT void CreateMutexesForSubShapes(const TopoDS_Shape& theShape,
const TopAbs_ShapeEnum theType);
//! Removes all created mutexes <br>
Standard_EXPORT void RemoveAllMutexes();
//! Gives the number of built triangles. <br>
Standard_EXPORT Standard_Integer NbTriangles() const;
//! Gives the triangle of <Index>. <br>
Standard_EXPORT const BRepMesh_Triangle& Triangle(const Standard_Integer Index) const;
//! Gives the number of built Edges <br>
Standard_EXPORT Standard_Integer NbEdges() const;
//! Gives the edge of index <Index>. <br>
Standard_EXPORT const BRepMesh_Edge& Edge(const Standard_Integer Index) const;
//! Gives the number of built Vertices. <br>
Standard_EXPORT Standard_Integer NbVertices() const;
//! Gives the vertex of <Index>. <br>
Standard_EXPORT const BRepMesh_Vertex& Vertex(const Standard_Integer Index) const;
//! Gives the nodes of triangle with the given index.
Standard_EXPORT void TriangleNodes(const Standard_Integer theIndex,
Standard_Integer (&theNodes)[3]) const
{
myStructure->ElementNodes(Triangle(theIndex), theNodes);
}
//! Gives the location3d of the vertex of <Index>. <br>
Standard_EXPORT const gp_Pnt& Pnt(const Standard_Integer Index) const;
//! Gives the list of indices of the vertices <br>
Standard_EXPORT void VerticesOfDomain(BRepMeshCol::MapOfInteger& Indices) const;
//! Gives the list of indices of the edges <br>
inline void EdgesOfDomain(BRepMeshCol::MapOfInteger& Indices) const
{
Indices = myStructure->LinksOfDomain();
}
//! Gives the list of indices of the triangles <br>
inline void TrianglesOfDomain(BRepMeshCol::MapOfInteger& Indices) const
{
Indices = myStructure->ElementsOfDomain();
}
//! Gives the number of different location in 3d space.
//! It is different of the number of vertices if there
//! is more than one surface. <br>
//! Even for one surface, the number can be different
//! if an edge is shared. <br>
inline Standard_Integer NbPoint3d() const
{
return myNbLocat;
}
//! Gives the 3d space location of the vertex <Index>. <br>
inline const gp_Pnt& Point3d(const Standard_Integer Index) const
{
return myLocation3d(Index);
}
//! returns the deflection value. <br>
inline Standard_Real GetDeflection() const
{
return myDeflection;
}
//! returns the deflection value. <br>
inline Standard_Real GetAngle() const
{
return myAngle;
}
inline Standard_Boolean WithShare() const
{
return myWithShare;
}
inline Standard_Boolean InShape() const
{
return myInshape;
}
inline Standard_Boolean ShapeTrigu() const
{
return myShapetrigu;
}
//! returns the face deflection value. <br>
Standard_EXPORT Standard_Boolean GetFaceAttribute(const TopoDS_Face& face,Handle(BRepMesh_FaceAttribute)& fattrib) const;
//! remove face attribute as useless to free locate memory <br>
Standard_EXPORT void RemoveFaceAttribute(const TopoDS_Face& face);
inline const TopTools_DataMapOfShapeReal& GetMapOfDefEdge() const
{
return myMapdefle;
}
DEFINE_STANDARD_RTTI(BRepMesh_FastDiscret)
private:
void Add(const TopoDS_Edge& edge,
const TopoDS_Face& face,
const Handle(BRepAdaptor_HSurface)& S,
const Handle(Geom2d_Curve)& C,
const TopTools_IndexedDataMapOfShapeListOfShape& ancestor,
const Standard_Real defedge,
const Standard_Real first,
const Standard_Real last);
void Add(const TopoDS_Vertex& theVert,
const TopoDS_Face& face,
const Handle(BRepAdaptor_HSurface)& S);
Standard_Boolean Update(const TopoDS_Edge& Edge,
const TopoDS_Face& Face,
const Handle(Geom2d_Curve)& C,
const Standard_Real defedge,
const Standard_Real first,
const Standard_Real last);
void InternalVertices(const Handle(BRepAdaptor_HSurface)& caro,
BRepMeshCol::ListOfVertex& inter,
const Standard_Real defedge,
const BRepMeshCol::HClassifier& classifier);
Standard_Real Control(const Handle(BRepAdaptor_HSurface)& caro,
const Standard_Real defface,
BRepMeshCol::ListOfVertex& inter,
BRepMeshCol::ListOfInteger& badTri,
BRepMeshCol::ListOfInteger& nulTri,
BRepMesh_Delaun& trigu,
const Standard_Boolean isfirst);
void AddInShape(const TopoDS_Face& face,
const Standard_Real defedge);
private:
Standard_Real myAngle;
Standard_Real myDeflection;
Standard_Real myDtotale;
Standard_Boolean myWithShare;
Standard_Boolean myInParallel;
BRepMeshCol::DMapOfVertexInteger myVertices;
BRepMeshCol::DMapOfShapePairOfPolygon myEdges;
BRepMeshCol::DMapOfShapePairOfPolygon myInternaledges;
Standard_Integer myNbLocat;
BRepMeshCol::DMapOfIntegerPnt myLocation3d;
Handle_BRepMesh_DataStructureOfDelaun myStructure;
BRepMeshCol::DMapOfFaceAttribute myMapattrib;
TColStd_IndexedMapOfInteger myVemap;
BRepMeshCol::DMapOfIntegerListOfXY myLocation2d;
Standard_Boolean myRelative;
Standard_Boolean myShapetrigu;
Standard_Boolean myInshape;
BRepMesh_Status myFacestate;
TopTools_DataMapOfShapeReal myMapdefle;
TopTools_ListOfShape myNottriangulated;
BRepMeshCol::Allocator myAllocator;
TopTools_MutexForShapeProvider myMutexProvider;
};
DEFINE_STANDARD_HANDLE(BRepMesh_FastDiscret, Standard_Transient)
#endif

View File

@ -1,116 +0,0 @@
// Created on: 2003-09-26
// Created by: Open CASCADE Support
// Copyright (c) 2003-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_DataStructureOfDelaun.hxx>
//=======================================================================
//function : GetDeflection
//purpose :
//=======================================================================
inline Standard_Real BRepMesh_FastDiscret::GetDeflection() const
{
return myDeflection;
}
//=======================================================================
//function : GetAngle
//purpose :
//=======================================================================
inline Standard_Real BRepMesh_FastDiscret::GetAngle() const
{
return myAngle;
}
//=======================================================================
//function : GetMapOfDefEdge
//purpose :
//=======================================================================
inline const TopTools_DataMapOfShapeReal& BRepMesh_FastDiscret::GetMapOfDefEdge() const
{
return myMapdefle;
}
//=======================================================================
//function : EdgesOfDomain
//purpose :
//=======================================================================
inline void BRepMesh_FastDiscret::EdgesOfDomain(BRepMesh_MapOfInteger& Indices) const
{
Indices = myStructure->LinkOfDomain();
}
//=======================================================================
//function : TrianglesOfDomain
//purpose :
//=======================================================================
inline void BRepMesh_FastDiscret::TrianglesOfDomain(BRepMesh_MapOfInteger& Indices) const
{
Indices = myStructure->ElemOfDomain();
}
//=======================================================================
//function : NbPoint3d
//purpose :
//=======================================================================
inline Standard_Integer BRepMesh_FastDiscret::NbPoint3d() const
{
return myNbLocat;
}
//=======================================================================
//function : Point3d
//purpose :
//=======================================================================
inline const gp_Pnt& BRepMesh_FastDiscret::Point3d(const Standard_Integer Index) const
{
return myLocation3d(Index);
}
//=======================================================================
//function : WithShare
//purpose :
//=======================================================================
inline Standard_Boolean BRepMesh_FastDiscret::WithShare() const
{
return myWithShare;
}
//=======================================================================
//function : InShape
//purpose :
//=======================================================================
inline Standard_Boolean BRepMesh_FastDiscret::InShape() const
{
return myInshape;
}
//=======================================================================
//function : ShapeTrigu
//purpose :
//=======================================================================
inline Standard_Boolean BRepMesh_FastDiscret::ShapeTrigu() const
{
return myShapetrigu;
}

View File

@ -1,170 +0,0 @@
-- Created on: 2008-10-28
-- Copyright (c) 2008-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
private class FastDiscretFace from BRepMesh inherits TShared from MMgt
---Purpose: Algorithm to mesh a face with respect of the
-- frontier the deflection and by option the shared
-- components.
uses Boolean from Standard,
Integer from Standard,
Real from Standard,
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
Pnt from gp,
Pnt2d from gp,
XY from gp,
HSurface from BRepAdaptor,
Delaun from BRepMesh,
DataStructureOfDelaun from BRepMesh,
DataMapOfVertexInteger from BRepMesh,
DataMapOfIntegerListOfXY from BRepMesh,
DataMapOfShapeReal from TopTools,
MutexForShapeProvider from TopTools,
ListOfVertex from BRepMesh,
ClassifierPtr from BRepMesh,
Triangle from BRepMesh,
Edge from BRepMesh,
Vertex from BRepMesh,
FaceAttribute from BRepMesh,
ListOfInteger from TColStd,
BaseAllocator from BRepMesh,
DataMapOfIntegerPnt from BRepMesh,
IndexedMapOfInteger from TColStd,
IndexedMapOfReal from TColStd,
DataMapOfShapePairOfPolygon from BRepMesh,
Triangulation from Poly,
Location from TopLoc
is
Create (theAngle : Real from Standard;
theWithShare : Boolean from Standard=Standard_True)
returns FastDiscretFace from BRepMesh;
Add (me : mutable;
theFace : Face from TopoDS;
theAttrib : FaceAttribute from BRepMesh;
theMapDefle : DataMapOfShapeReal from TopTools;
theMutexProvider : MutexForShapeProvider from TopTools)
is static;
Add (me : mutable;
theVert : Vertex from TopoDS;
theFace : Face from TopoDS;
theSFace : HSurface from BRepAdaptor) is private;
RestoreStructureFromTriangulation
(me: mutable;
theEdge : Edge from TopoDS;
theFace : Face from TopoDS;
theSurf : HSurface from BRepAdaptor;
theTrigu : Triangulation from Poly;
theDefEdge : Real from Standard;
theLoc : Location from TopLoc;
theMutexProvider: MutexForShapeProvider from TopTools)
returns Boolean from Standard is protected;
InternalVertices (me : mutable;
theCaro : HSurface from BRepAdaptor;
theInternalV : in out ListOfVertex from BRepMesh;
theDefFace : Real from Standard;
theClassifier : ClassifierPtr from BRepMesh)
is static private;
Control (me : mutable;
theCaro : HSurface from BRepAdaptor;
theDefFace : Real from Standard;
theInternalV : in out ListOfVertex from BRepMesh;
theBadTriangles : in out ListOfInteger from TColStd;
theNulTriangles : in out ListOfInteger from TColStd;
theTrigu : in out Delaun from BRepMesh;
theIsFirst : Boolean from Standard)
returns Real from Standard is static;
FindUV (myclass;
theV : Vertex from TopoDS;
theXY : Pnt2d from gp;
theIp : Integer from Standard;
theSFace : HSurface from BRepAdaptor;
theMinDist : Real from Standard;
theFaceAttribute: FaceAttribute from BRepMesh;
theLocation2dMap: in out DataMapOfIntegerListOfXY from BRepMesh)
returns XY from gp;
AddInShape (me: mutable;
theFace : Face from TopoDS;
theDefFace: Real from Standard;
theMutexProvider: MutexForShapeProvider from TopTools)
is static private;
-- Output :
Triangle (me;
theIndex : Integer from Standard)
---Purpose: Gives the triangle of <Index>.
---C++: return const &
returns Triangle from BRepMesh
is static;
Edge (me;
theIndex : Integer from Standard)
---Purpose: Gives the edge of index <Index>.
---C++: return const &
returns Edge from BRepMesh
is static;
Vertex (me;
theIndex : Integer from Standard)
---Purpose: Gives the vertex of <Index>.
---C++: return const &
returns Vertex from BRepMesh
is static;
Pnt (me;
theIndex : Integer from Standard)
---Purpose: Gives the location3d of the vertex of <Index>.
---C++: return const &
returns Pnt from gp
is static;
fields
myAngle : Real from Standard;
myWithShare : Boolean from Standard;
myVertices : DataMapOfVertexInteger from BRepMesh;
myInternaledges : DataMapOfShapePairOfPolygon from BRepMesh;
myNbLocat : Integer from Standard;
myLocation3d : DataMapOfIntegerPnt from BRepMesh;
myStructure : DataStructureOfDelaun from BRepMesh;
myListver : ListOfVertex from BRepMesh;
myVemap : IndexedMapOfInteger from TColStd;
myLocation2d : DataMapOfIntegerListOfXY from BRepMesh;
myAttrib : FaceAttribute from BRepMesh;
myInternalVerticesMode : Boolean from Standard; --mode to accounting internal vertices
myUParam : IndexedMapOfReal from TColStd;
myVParam : IndexedMapOfReal from TColStd;
myAllocator : BaseAllocator from BRepMesh;
end FastDiscretFace;

View File

@ -12,47 +12,55 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_FastDiscretFace.ixx>
#include <BRepMesh_FastDiscretFace.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepMesh_GeomTool.hxx>
#include <BRepMesh_ListOfXY.hxx>
#include <BRepMesh_Array1OfVertexOfDelaun.hxx>
#include <BRepMesh_ListIteratorOfListOfVertex.hxx>
#include <BRepMesh_ListIteratorOfListOfXY.hxx>
#include <BRepMesh_PairOfPolygon.hxx>
#include <BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon.hxx>
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
#include <BRepMesh_ClassifierPtr.hxx>
#include <BRepMesh_Classifier.hxx>
#include <BRep_Builder.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <BRep_ListIteratorOfListOfPointRepresentation.hxx>
#include <BRep_PointRepresentation.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Surface.hxx>
#include <ElSLib.hxx>
#include <GeomLib.hxx>
#include <Geom_Surface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <SortTools_ShellSortOfReal.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <TCollection_CompareOfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TopTools_DataMapOfShapeReal.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <NCollection_Map.hxx>
#include <Geom_BSplineSurface.hxx>
#include <GeomLib.hxx>
#include <Bnd_Box2d.hxx>
#define UVDEFLECTION 1.e-05
IMPLEMENT_STANDARD_HANDLE (BRepMesh_FastDiscretFace, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_FastDiscretFace, Standard_Transient)
static Standard_Real FUN_CalcAverageDUV(TColStd_Array1OfReal& P, const Standard_Integer PLen)
{
Standard_Integer i, j, n = 0;
@ -169,7 +177,8 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
const TopoDS_Edge& edge = TopoDS::Edge(ex.Value());
if(edge.IsNull())
continue;
RestoreStructureFromTriangulation(edge, face, gFace, aFaceTrigu, theMapDefle(edge), loc, theMutexProvider);
RestoreStructureFromTriangulation(edge, face, gFace, aFaceTrigu,
theMapDefle(edge), loc, theMutexProvider);
}
}
@ -195,7 +204,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
Standard_Real deltaX = myAttrib->GetDeltaX();
Standard_Real deltaY = myAttrib->GetDeltaY();
TColStd_Array1OfInteger tabvert_corr(1, nbVertices);
BRepMeshCol::Array1OfInteger tabvert_corr(1, nbVertices);
gp_Pnt2d p2d;
// Check the necessity to fill the map of parameters
@ -222,7 +231,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
res.SetCoord((p2d.X() - umin ) / deltaX,
(p2d.Y() - vmin ) / deltaY);
BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
const BRepMesh_ListOfInteger& alist = myStructure->GetNodeList(i);
const BRepMeshCol::ListOfInteger& alist = myStructure->LinksConnectedTo(i);
aMoveNodes.Add(v_new, alist);
tabvert_corr(i) = i;
}
@ -230,7 +239,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
Standard_Boolean rajout;
BRepMesh_ClassifierPtr& classifier = theAttrib->GetClassifier();
BRepMeshCol::HClassifier& classifier = theAttrib->GetClassifier();
switch (thetype)
{
@ -248,7 +257,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
Standard_Integer nbLinks = myStructure->NbLinks();
for( i = 1; i <= nbLinks; i++ )
{
if( myStructure->ElemConnectedTo(i).Extent() < 1 )
if( myStructure->ElementsConnectedTo(i).Extent() < 1 )
{
BRepMesh_Edge& anEdge = (BRepMesh_Edge&)trigu.GetEdge(i);
if ( anEdge.Movability() == BRepMesh_Deleted )
@ -263,8 +272,8 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
isaline = ((umax-umin) < UVDEFLECTION) || ((vmax-vmin) < UVDEFLECTION);
Standard_Real aDef = -1;
if (!isaline && myStructure->ElemOfDomain().Extent() > 0) {
TColStd_ListOfInteger badTri, nulTri;
if (!isaline && myStructure->ElementsOfDomain().Extent() > 0) {
BRepMeshCol::ListOfInteger badTri, nulTri;
if(!rajout)
{
@ -292,15 +301,15 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
InternalVertices(gFace, myListver, theAttrib->GetDefFace(), classifier);
if (myListver.Extent() > 0) {
BRepMesh_Array1OfVertexOfDelaun verttab(1, myListver.Extent());
BRepMesh_ListIteratorOfListOfVertex itVer(myListver);
BRepMeshCol::Array1OfVertexOfDelaun verttab(1, myListver.Extent());
BRepMeshCol::ListOfVertex::Iterator itVer(myListver);
ipn = 1;
for (; itVer.More(); itVer.Next())
verttab(ipn++) = itVer.Value();
trigu.AddVertices(verttab);
}
//control internal points
BRepMesh_ListOfVertex vvlist;
BRepMeshCol::ListOfVertex vvlist;
aDef = Control(gFace, theAttrib->GetDefFace(), vvlist, badTri, nulTri, trigu, Standard_False);
myListver.Append(vvlist);
}
@ -316,7 +325,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
gp_XY res;
res.SetCoord(p2d.X() * deltaX + umin, p2d.Y() * deltaY + vmin);
BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
const BRepMesh_ListOfInteger& alist = myStructure->GetNodeList(i);
const BRepMeshCol::ListOfInteger& alist = myStructure->LinksConnectedTo(i);
aMoveNodes.Add(v_new, alist);
}
myStructure->ReplaceNodes(aMoveNodes);
@ -326,9 +335,7 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace
}
catch(Standard_Failure)
{
BRep_Builder B;
Handle(Poly_Triangulation) TNull;
B.UpdateFace(theFace,TNull);
BRepMesh_ShapeTool::NullifyFace(theFace);
}
#endif // DEB_MESH
myStructure.Nullify();
@ -418,7 +425,9 @@ Standard_Boolean BRepMesh_FastDiscretFace::RestoreStructureFromTriangulation
if (mindist < BRep_Tool::Tolerance(pBegin) ||
mindist < BRep_Tool::Tolerance(pEnd) ) mindist = theDefEdge;
anUV = FindUV(pBegin, uvFirst, ipf, theSurf, mindist, myAttrib, myLocation2d);
anUV = BRepMesh_ShapeTool::FindUV(ipf, uvFirst,
pBegin, mindist, myAttrib, theSurf, myLocation2d);
Standard_Integer iv1, isv1;
BRepMesh_Vertex vf(anUV, ipf, BRepMesh_Frontier);
iv1 = myStructure->AddNode(vf);
@ -459,7 +468,9 @@ Standard_Boolean BRepMesh_FastDiscretFace::RestoreStructureFromTriangulation
}
}
anUV = FindUV(pEnd, uvLast, ipl, theSurf, mindist, myAttrib, myLocation2d);
anUV = BRepMesh_ShapeTool::FindUV(ipl, uvLast,
pEnd, mindist, myAttrib, theSurf, myLocation2d);
BRepMesh_Vertex vl(anUV, ipl, BRepMesh_Frontier);
Standard_Integer isvl;
@ -538,13 +549,13 @@ Standard_Boolean BRepMesh_FastDiscretFace::RestoreStructureFromTriangulation
//purpose :
//=======================================================================
static void filterParameters(const TColStd_IndexedMapOfReal& theParams,
const Standard_Real theMinDist,
const Standard_Real theFilterDist,
TColStd_SequenceOfReal& theResult)
static void filterParameters(const BRepMeshCol::IMapOfReal& theParams,
const Standard_Real theMinDist,
const Standard_Real theFilterDist,
BRepMeshCol::SequenceOfReal& theResult)
{
// Sort sequence of parameters
TColStd_SequenceOfReal aParamTmp;
BRepMeshCol::SequenceOfReal aParamTmp;
Standard_Integer aParamLength = 1;
const Standard_Integer anInitLen = theParams.Extent();
@ -633,9 +644,9 @@ static void filterParameters(const TColStd_IndexedMapOfReal& theParams,
}
void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurface)& theCaro,
BRepMesh_ListOfVertex& theInternalV,
BRepMeshCol::ListOfVertex& theInternalV,
const Standard_Real theDefFace,
const BRepMesh_ClassifierPtr& theClassifier)
const BRepMeshCol::HClassifier& theClassifier)
{
BRepMesh_Vertex newV;
gp_Pnt2d p2d;
@ -779,7 +790,7 @@ void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurfac
Standard_Real pp, pasu, pasv;
Standard_Real r = T.MinorRadius(), R = T.MajorRadius();
TColStd_SequenceOfReal ParamU, ParamV;
BRepMeshCol::SequenceOfReal ParamU, ParamV;
Standard_Real Du, Dv;//, pasu, pasv;
Dv = Max(1.0e0 - (theDefFace/r),0.0e0) ;
@ -913,7 +924,7 @@ void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurfac
Standard_Real aDuMaxLim = 0.1*(umax-umin);
Standard_Real ddu = Min(aDuMaxLim,Max(0.005*(umax-umin),2.*uRes));
TColStd_SequenceOfReal ParamU;
BRepMeshCol::SequenceOfReal ParamU;
filterParameters(myUParam,aMinDu,ddu,ParamU);
Standard_Integer ParamULength = ParamU.Length();
@ -923,7 +934,7 @@ void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurfac
Standard_Real aDvMaxLim = 0.1*(vmax-vmin);
Standard_Real ddv = Min(aDvMaxLim,Max(0.005*(vmax-vmin),2.*vRes));
TColStd_SequenceOfReal ParamV;
BRepMeshCol::SequenceOfReal ParamV;
filterParameters(myVParam,aMinDv,ddv,ParamV);
Standard_Integer ParamVLength = ParamV.Length();
@ -1052,7 +1063,7 @@ void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurfac
Standard_Integer i, j, nbpointsU = 10, nbpointsV = 10;
Adaptor3d_IsoCurve tabu[11], tabv[11];
TColStd_SequenceOfReal ParamU, ParamV;
BRepMeshCol::SequenceOfReal ParamU, ParamV;
Standard_Real u, v, du, dv;
Standard_Integer iu, iv;
Standard_Real f, l;
@ -1123,7 +1134,7 @@ void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurfac
ParamV.InsertAfter(1, (vmax+vmin)*0.5);
}
TColStd_SequenceOfReal InsertV, InsertU;
BRepMeshCol::SequenceOfReal InsertV, InsertU;
gp_Pnt P1;
Adaptor3d_IsoCurve IsoV;
@ -1193,9 +1204,9 @@ typedef NCollection_Map<BRepMesh_Couple> BRepMesh_MapOfCouple;
//=======================================================================
Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurface)& theCaro,
const Standard_Real theDefFace,
BRepMesh_ListOfVertex& theInternalV,
TColStd_ListOfInteger& theBadTriangles,
TColStd_ListOfInteger& theNulTriangles,
BRepMeshCol::ListOfVertex& theInternalV,
BRepMeshCol::ListOfInteger& theBadTriangles,
BRepMeshCol::ListOfInteger& theNulTriangles,
BRepMesh_Delaun& theTrigu,
const Standard_Boolean theIsFirst)
{
@ -1214,7 +1225,7 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
// Create map of links to skip already processed
Standard_Integer nbtriangles;
nbtriangles = myStructure->ElemOfDomain().Extent();
nbtriangles = myStructure->ElementsOfDomain().Extent();
if (nbtriangles <= 0) return -1.0;
BRepMesh_MapOfCouple theCouples(3*nbtriangles);
@ -1241,7 +1252,7 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
}
NCollection_DataMap<Standard_Integer,gp_Dir> aNorMap;
NCollection_DataMap<Standard_Integer,Standard_Integer> aStatMap;
BRepMeshCol::MapOfIntegerInteger aStatMap;
// Perform refinement passes
for (; pass <= nbPasses && nbInserted && !allDegenerated; pass++)
@ -1258,12 +1269,12 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
caninsert = (myWithShare || pass < nbPasses);
// Read mesh size
nbtriangles = myStructure->ElemOfDomain().Extent();
nbtriangles = myStructure->ElementsOfDomain().Extent();
if (nbtriangles <= 0) break;
// Iterate on current triangles
BRepMesh_MapOfInteger::Iterator triDom;
const BRepMesh_MapOfInteger& TriMap = myStructure->ElemOfDomain();
BRepMeshCol::MapOfInteger::Iterator triDom;
const BRepMeshCol::MapOfInteger& TriMap = myStructure->ElementsOfDomain();
triDom.Initialize(TriMap);
Standard_Integer aNbPnt = 0;
Standard_Real umin = myAttrib->GetUMin();
@ -1276,33 +1287,20 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
const BRepMesh_Triangle& curTri=Triangle(TriId);
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;
curTri.Edges(e1, e2, e3, o1, o2, o3);
const BRepMesh_Edge& edg1=Edge(e1);
const BRepMesh_Edge& edg2=Edge(e2);
const BRepMesh_Edge& edg3=Edge(e3);
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();
}
else {
v1=edg1.LastNode();
v2=edg1.FirstNode();
}
if (o2)
v3=edg2.LastNode();
else
v3=edg2.FirstNode();
Standard_Integer v[3];
myStructure->ElementNodes(curTri, v);
const BRepMesh_Vertex& vert1=Vertex(v1);
const BRepMesh_Vertex& vert2=Vertex(v2);
const BRepMesh_Vertex& vert3=Vertex(v3);
Standard_Integer e[3];
Standard_Boolean o[3];
curTri.Edges(e, o);
Standard_Boolean m1 = (Edge(e[0]).Movability() == BRepMesh_Frontier);
Standard_Boolean m2 = (Edge(e[1]).Movability() == BRepMesh_Frontier);
Standard_Boolean m3 = (Edge(e[2]).Movability() == BRepMesh_Frontier);
const BRepMesh_Vertex& vert1=Vertex(v[0]);
const BRepMesh_Vertex& vert2=Vertex(v[1]);
const BRepMesh_Vertex& vert3=Vertex(v[2]);
const gp_XYZ& p1=myLocation3d(vert1.Location3d()).Coord();
const gp_XYZ& p2=myLocation3d(vert2.Location3d()).Coord();
@ -1372,7 +1370,7 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
if (!m2) // Not a boundary
{
// Check if this link was already processed
if (v2 < v3) { nf = v2; nl = v3; } else { nf = v3; nl = v2; }
if (v[1] < v[2]) { nf = v[1]; nl = v[2]; } else { nf = v[2]; nl = v[1]; }
if (theCouples.Add(BRepMesh_Couple(nf,nl)))
{
// Check deflection on edge 1
@ -1402,7 +1400,7 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
if (!m3) // Not a boundary
{
// Check if this link was already processed
if (v1 < v3) { nf = v1; nl = v3; } else { nf = v3; nl = v1; }
if (v[0] < v[2]) { nf = v[0]; nl = v[2]; } else { nf = v[2]; nl = v[0]; }
if (theCouples.Add(BRepMesh_Couple(nf,nl)))
{
// Check deflection on edge 2
@ -1432,7 +1430,7 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
if (!m1) // Not a boundary
{
// Check if this link was already processed
if (v1 < v2) { nf = v1; nl = v2; } else { nf = v2; nl = v1; }
if (v[0] < v[1]) { nf = v[0]; nl = v[1]; } else { nf = v[1]; nl = v[0]; }
if (theCouples.Add(BRepMesh_Couple(nf,nl)))
{
// Check deflection on edge 3
@ -1464,34 +1462,34 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
{
gp_Dir N1(0,0,1), N2(0,0,1), N3(0,0,1);
Standard_Integer aSt1, aSt2, aSt3;
if(aNorMap.IsBound(v1)) {
aSt1 = aStatMap.Find(v1);
N1 =aNorMap.Find(v1);
if(aNorMap.IsBound(v[0])) {
aSt1 = aStatMap.Find(v[0]);
N1 =aNorMap.Find(v[0]);
}
else {
aSt1 = GeomLib::NormEstim(BSpl, gp_Pnt2d(xy1), Precision::Confusion(), N1);
aStatMap.Bind(v1,aSt1);
aNorMap.Bind(v1,N1);
aStatMap.Bind(v[0],aSt1);
aNorMap.Bind(v[0],N1);
}
if(aNorMap.IsBound(v2)) {
aSt2 = aStatMap.Find(v2);
N2 = aNorMap.Find(v2);
if(aNorMap.IsBound(v[1])) {
aSt2 = aStatMap.Find(v[1]);
N2 = aNorMap.Find(v[1]);
}
else {
aSt2 = GeomLib::NormEstim(BSpl, gp_Pnt2d(xy2), Precision::Confusion(), N2);
aStatMap.Bind(v2,aSt2);
aNorMap.Bind(v2,N2);
aStatMap.Bind(v[1],aSt2);
aNorMap.Bind(v[1],N2);
}
if(aNorMap.IsBound(v3)) {
aSt3 = aStatMap.Find(v3);
N3 = aNorMap.Find(v3);
if(aNorMap.IsBound(v[2])) {
aSt3 = aStatMap.Find(v[2]);
N3 = aNorMap.Find(v[2]);
}
else {
aSt3 = GeomLib::NormEstim(BSpl, gp_Pnt2d(xy3), Precision::Confusion(), N3);
aStatMap.Bind(v3,aSt3);
aNorMap.Bind(v3,N3.XYZ());
aStatMap.Bind(v[2],aSt3);
aNorMap.Bind(v[2],N3.XYZ());
}
Standard_Real anAngle1 = N2.Angle(N1);
@ -1508,8 +1506,8 @@ Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurfac
if (!theIsFirst && theInternalV.Extent() > 0)
{
BRepMesh_Array1OfVertexOfDelaun verttab(1, theInternalV.Extent());
BRepMesh_ListIteratorOfListOfVertex itVer(theInternalV);
BRepMeshCol::Array1OfVertexOfDelaun verttab(1, theInternalV.Extent());
BRepMeshCol::ListOfVertex::Iterator itVer(theInternalV);
Standard_Integer ipn = 1;
for (; itVer.More(); itVer.Next())
verttab(ipn++) = itVer.Value();
@ -1532,63 +1530,42 @@ void BRepMesh_FastDiscretFace::AddInShape(const TopoDS_Face& theFace,
const Standard_Real theDefFace,
const TopTools_MutexForShapeProvider& theMutexProvider)
{
// gp_Pnt Pt;
BRep_Builder B;
TopLoc_Location loc = theFace.Location();
Handle(Poly_Triangulation) TOld = BRep_Tool::Triangulation(theFace, loc);
Handle(Poly_Triangulation) TNull;
Handle(Poly_PolygonOnTriangulation) NullPoly;
B.UpdateFace(theFace,TNull);
BRepMesh_ShapeTool::NullifyFace(theFace);
try{
BRepMesh_MapOfInteger::Iterator it;
BRepMeshCol::MapOfInteger::Iterator it;
Standard_Integer e1, e2, e3, nTri;
Standard_Integer v1, v2, v3, iv1, iv2, iv3;
Standard_Integer i, index;
Standard_Boolean o1, o2, o3;
TopAbs_Orientation orFace = theFace.Orientation();
const BRepMesh_MapOfInteger& TriMap = myStructure->ElemOfDomain();
const BRepMeshCol::MapOfInteger& TriMap = myStructure->ElementsOfDomain();
it.Initialize(TriMap);
nTri = TriMap.Extent();
Standard_Integer nTri = TriMap.Extent();
if (nTri != 0) {
Poly_Array1OfTriangle Tri(1, nTri);
i = 1;
for (; it.More(); it.Next()) {
myStructure->GetElement(it.Key()).Edges(e1, e2, e3, o1, o2, o3);
for (; it.More(); it.Next())
{
const BRepMesh_Triangle& aCurElem = myStructure->GetElement(it.Key());
Standard_Integer v[3];
myStructure->ElementNodes(aCurElem, v);
const BRepMesh_Edge& ve1=myStructure->GetLink(e1);
const BRepMesh_Edge& ve2=myStructure->GetLink(e2);
if (o1) {
v1=ve1.FirstNode();
}
else {
v1=ve1.LastNode();
}
if (o2)
{
v2=ve2.FirstNode();
v3=ve2.LastNode();
}
else
{
v3=ve2.FirstNode();
v2=ve2.LastNode();
}
iv1 = myVemap.FindIndex(v1);
if (iv1 == 0) iv1 = myVemap.Add(v1);
iv2 = myVemap.FindIndex(v2);
if (iv2 == 0) iv2 = myVemap.Add(v2);
iv3 = myVemap.FindIndex(v3);
if (iv3 == 0) iv3 = myVemap.Add(v3);
Standard_Integer iv1, iv2, iv3;
iv1 = myVemap.FindIndex(v[0]);
if (iv1 == 0) iv1 = myVemap.Add(v[0]);
iv2 = myVemap.FindIndex(v[1]);
if (iv2 == 0) iv2 = myVemap.Add(v[1]);
iv3 = myVemap.FindIndex(v[2]);
if (iv3 == 0) iv3 = myVemap.Add(v[2]);
if (orFace == TopAbs_REVERSED) Tri(i++).Set(iv1, iv3, iv2);
else Tri(i++).Set(iv1, iv2, iv3);
@ -1608,22 +1585,13 @@ void BRepMesh_FastDiscretFace::AddInShape(const TopoDS_Face& theFace,
}
T->Deflection(theDefFace);
// storage of triangulation in BRep.
BRep_Builder B1;
//TopLoc_Location loc = theFace.Location();
if (!loc.IsIdentity()) {
gp_Trsf tr = loc.Transformation();
tr.Invert();
for (i = Nodes.Lower(); i <= Nodes.Upper(); i++)
Nodes(i).Transform(tr);
}
B1.UpdateFace(theFace, T);
BRepMesh_ShapeTool::AddInFace(theFace, T);
// implement polygons on triangulation in the face:
BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon It(myInternaledges);
BRepMeshCol::DMapOfShapePairOfPolygon::Iterator It(myInternaledges);
for (; It.More(); It.Next()) {
const TopoDS_Edge& aEdge = TopoDS::Edge(It.Key());
const BRepMesh_PairOfPolygon& pair = It.Value();
const Handle(Poly_PolygonOnTriangulation)& NOD1 = pair.First();
const Handle(Poly_PolygonOnTriangulation)& NOD2 = pair.Last();
@ -1633,12 +1601,12 @@ void BRepMesh_FastDiscretFace::AddInShape(const TopoDS_Face& theFace,
Standard_Mutex::Sentry aSentry (aMutex);
if ( NOD1 == NOD2 ) {
B.UpdateEdge(TopoDS::Edge(It.Key()), NullPoly, TOld,loc);
B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, T, loc);
BRepMesh_ShapeTool::NullifyEdge(aEdge, TOld, loc);
BRepMesh_ShapeTool::UpdateEdge(aEdge, NOD1, T, loc);
}
else {
B.UpdateEdge(TopoDS::Edge(It.Key()), NullPoly, TOld,loc);
B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, NOD2, T, loc);
BRepMesh_ShapeTool::NullifyEdge(aEdge, TOld, loc);
BRepMesh_ShapeTool::UpdateEdge(aEdge, NOD1, NOD2, T, loc);
}
}
}
@ -1702,80 +1670,6 @@ const gp_Pnt& BRepMesh_FastDiscretFace::Pnt(const Standard_Integer Index) const
return myLocation3d(myStructure->GetNode(Index).Location3d());
}
//=======================================================================
//function : FindUV
//purpose :
//=======================================================================
gp_XY BRepMesh_FastDiscretFace::FindUV(const TopoDS_Vertex& theV,
const gp_Pnt2d& theXY,
const Standard_Integer theIp,
const Handle(BRepAdaptor_HSurface)& theSFace,
const Standard_Real theMinDist,
const Handle(BRepMesh_FaceAttribute)& theFaceAttribute,
BRepMesh_DataMapOfIntegerListOfXY& theLocation2dMap)
{
gp_XY anUV;
if (theLocation2dMap.IsBound(theIp))
{
BRepMesh_ListOfXY& L = theLocation2dMap.ChangeFind(theIp);
anUV = L.First();
if (L.Extent() != 1)
{
BRepMesh_ListIteratorOfListOfXY it(L);
it.Next();
Standard_Real dd, dmin = theXY.Distance(gp_Pnt2d(anUV));
for (; it.More(); it.Next())
{
dd = theXY.Distance(gp_Pnt2d(it.Value()));
if (dd < dmin)
{
anUV = it.Value();
dmin = dd;
}
}
}
const Standard_Real tol = Min(2. * BRep_Tool::Tolerance(theV), theMinDist);
Standard_Real aDiffU, aDiffV;
if ( theFaceAttribute.IsNull() )
{
aDiffU = theSFace->LastUParameter() - theSFace->FirstUParameter();
aDiffV = theSFace->LastVParameter() - theSFace->FirstVParameter();
}
else
{
aDiffU = theFaceAttribute->GetUMax() - theFaceAttribute->GetUMin();
aDiffV = theFaceAttribute->GetVMax() - theFaceAttribute->GetVMin();
}
const Standard_Real Utol2d = .5 * aDiffU;
const Standard_Real Vtol2d = .5 * aDiffV;
const gp_Pnt p1 = theSFace->Value(anUV.X(), anUV.Y());
const gp_Pnt p2 = theSFace->Value(theXY.X(), theXY.Y());
if (Abs(anUV.X() - theXY.X()) > Utol2d ||
Abs(anUV.Y() - theXY.Y()) > Vtol2d ||
!p1.IsEqual(p2, tol))
{
anUV = theXY.Coord();
L.Append(anUV);
}
}
else
{
anUV = theXY.Coord();
BRepMesh_ListOfXY L;
L.Append(anUV);
theLocation2dMap.Bind(theIp, L);
}
return anUV;
}
static Standard_Boolean GetVertexParameters(const TopoDS_Vertex& theVert,
const TopoDS_Face& theFace,
gp_Pnt2d& thePoint)
@ -1822,7 +1716,9 @@ void BRepMesh_FastDiscretFace::Add(const TopoDS_Vertex& theVert,
}
Standard_Real mindist = BRep_Tool::Tolerance(theVert);
// gp_Pnt2d uvXY = BRep_Tool::Parameters(theVert,theFace);
gp_XY anUV = FindUV(theVert, uvXY, indVert, thegFace, mindist, myAttrib, myLocation2d);
gp_XY anUV = BRepMesh_ShapeTool::FindUV(indVert, uvXY,
theVert, mindist, myAttrib, thegFace, myLocation2d);
BRepMesh_Vertex vf(anUV, indVert, BRepMesh_Fixed);
Standard_Integer ivff = myStructure->AddNode(vf);
Standard_Integer isvf = myVemap.FindIndex(ivff);

View File

@ -0,0 +1,127 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_FastDiscretFace_HeaderFile
#define _BRepMesh_FastDiscretFace_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <BRepMesh_FastDiscretFace.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_Collections.hxx>
#include <BRepMesh_FaceAttribute.hxx>
#include <Standard_Transient.hxx>
#include <TopTools_MutexForShapeProvider.hxx>
#include <Handle_BRepAdaptor_HSurface.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <BRepMesh_Delaun.hxx>
#include <BRepMesh_Triangle.hxx>
class BRepMesh_DataStructureOfDelaun;
class BRepMesh_FaceAttribute;
class TopoDS_Face;
class TopTools_DataMapOfShapeReal;
class TopoDS_Vertex;
class BRepAdaptor_HSurface;
class TopoDS_Edge;
class Poly_Triangulation;
class TopLoc_Location;
class gp_XY;
class gp_Pnt2d;
class BRepMesh_Edge;
class BRepMesh_Vertex;
class gp_Pnt;
//! Algorithm to mesh a face with respect of the frontier
//! the deflection and by option the shared components. <br>
class BRepMesh_FastDiscretFace : public Standard_Transient
{
public:
Standard_EXPORT BRepMesh_FastDiscretFace(const Standard_Real theAngle,
const Standard_Boolean theWithShare = Standard_True);
Standard_EXPORT void Add(const TopoDS_Face& theFace,
const Handle(BRepMesh_FaceAttribute)& theAttrib,
const TopTools_DataMapOfShapeReal& theMapDefle,
const TopTools_MutexForShapeProvider& theMutexProvider);
Standard_EXPORT Standard_Real Control(const Handle(BRepAdaptor_HSurface)& theCaro,
const Standard_Real theDefFace,
BRepMeshCol::ListOfVertex& theInternalV,
BRepMeshCol::ListOfInteger& theBadTriangles,
BRepMeshCol::ListOfInteger& theNulTriangles,
BRepMesh_Delaun& theTrigu,
const Standard_Boolean theIsFirst);
//! Gives the triangle of <Index>. <br>
Standard_EXPORT const BRepMesh_Triangle& Triangle(const Standard_Integer theIndex) const;
//! Gives the edge of index <Index>. <br>
Standard_EXPORT const BRepMesh_Edge& Edge(const Standard_Integer theIndex) const;
//! Gives the vertex of <Index>. <br>
Standard_EXPORT const BRepMesh_Vertex& Vertex(const Standard_Integer theIndex) const;
//! Gives the location3d of the vertex of <Index>. <br>
Standard_EXPORT const gp_Pnt& Pnt(const Standard_Integer theIndex) const;
DEFINE_STANDARD_RTTI(BRepMesh_FastDiscretFace)
protected:
Standard_Boolean RestoreStructureFromTriangulation(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace,
const Handle(BRepAdaptor_HSurface)& theSurf,
const Handle(Poly_Triangulation)& theTrigu,
const Standard_Real theDefEdge,
const TopLoc_Location& theLoc,
const TopTools_MutexForShapeProvider& theMutexProvider);
private:
void Add(const TopoDS_Vertex& theVert,
const TopoDS_Face& theFace,
const Handle(BRepAdaptor_HSurface)& theSFace);
void InternalVertices(const Handle(BRepAdaptor_HSurface)& theCaro,
BRepMeshCol::ListOfVertex& theInternalV,
const Standard_Real theDefFace,
const BRepMeshCol::HClassifier& theClassifier);
void AddInShape(const TopoDS_Face& theFace,
const Standard_Real theDefFace,
const TopTools_MutexForShapeProvider& theMutexProvider);
private:
Standard_Real myAngle;
Standard_Boolean myWithShare;
BRepMeshCol::DMapOfVertexInteger myVertices;
BRepMeshCol::DMapOfShapePairOfPolygon myInternaledges;
Standard_Integer myNbLocat;
BRepMeshCol::DMapOfIntegerPnt myLocation3d;
Handle_BRepMesh_DataStructureOfDelaun myStructure;
BRepMeshCol::ListOfVertex myListver;
BRepMeshCol::IMapOfInteger myVemap;
BRepMeshCol::DMapOfIntegerListOfXY myLocation2d;
Handle_BRepMesh_FaceAttribute myAttrib;
Standard_Boolean myInternalVerticesMode;
BRepMeshCol::IMapOfReal myUParam;
BRepMeshCol::IMapOfReal myVParam;
BRepMeshCol::Allocator myAllocator;
};
DEFINE_STANDARD_HANDLE (BRepMesh_FastDiscretFace, Standard_Transient)
#endif

View File

@ -1,75 +0,0 @@
-- Created on: 1993-09-29
-- Created by: Isabelle GRIGNON
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class GeomTool from BRepMesh
---Purpose:
uses
Pnt from gp,
Vec from gp,
Dir from gp,
Pnt2d from gp,
IsoType from GeomAbs,
TangentialDeflection from GCPnts,
Curve from BRepAdaptor,
HSurface from BRepAdaptor
is
Create (C : in out Curve from BRepAdaptor;
Ufirst,Ulast,AngDefl, Deflection : Real;
nbpointsmin: Integer = 2)
returns GeomTool;
Create (S : HSurface from BRepAdaptor;
ParamIso : Real;
Type : IsoType from GeomAbs;
Ufirst,Ulast,AngDefl,Deflection : Real;
nbpointsmin: Integer = 2) returns GeomTool;
AddPoint(me : in out; thePnt : in Pnt from gp;
theParam : in Real;
theIsReplace : in Boolean = Standard_True)
returns Integer from Standard;
---Purpose: Add point to already calculated points (or replace existing)
-- Returns index of new added point
-- or founded with parametric tolerance (replaced if theIsReplace is true)
NbPoints(me) returns Integer from Standard;
Value(me; IsoParam : Real ; Index : Integer ;
W : out Real; P : out Pnt from gp; UV : out Pnt2d from gp);
Value(me;C : Curve from BRepAdaptor;
S : HSurface from BRepAdaptor;
Index : Integer from Standard;
W : out Real; P : out Pnt from gp; UV : out Pnt2d from gp);
D0(myclass; F : HSurface from BRepAdaptor;U,V : Real; P : out Pnt);
Normal(myclass; F : HSurface from BRepAdaptor;U,V : Real ; P : out Pnt from gp;
Nor : out Dir from gp)
returns Boolean from Standard;
---Purpose: return false if the normal can not be computed
fields
pnts : TangentialDeflection from GCPnts;
parametric : IsoType from GeomAbs;
end GeomTool;

View File

@ -14,103 +14,323 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_GeomTool.ixx>
#include <BRepMesh_GeomTool.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <TopAbs_Orientation.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <CSLib.hxx>
#include <Precision.hxx>
#include <Adaptor3d_IsoCurve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <Geom2d_Curve.hxx>
#include <BRep_Tool.hxx>
BRepMesh_GeomTool::BRepMesh_GeomTool(BRepAdaptor_Curve& C,
const Standard_Real Ufirst,
const Standard_Real Ulast,
const Standard_Real AngDefl,
const Standard_Real Deflection,
const Standard_Integer nbpmin) :
pnts(C,Ufirst,Ulast,AngDefl,Deflection, nbpmin),
// pnts(C,Deflection,Ufirst,Ulast),
parametric(GeomAbs_NoneIso)
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_GeomTool::BRepMesh_GeomTool(
const BRepAdaptor_Curve& theCurve,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection,
const Standard_Integer theMinPointsNb)
: myEdge(&theCurve.Edge()),
myIsoType(GeomAbs_NoneIso)
{
}
//
BRepMesh_GeomTool::BRepMesh_GeomTool(const Handle(BRepAdaptor_HSurface)& S,
const Standard_Real ParamIso,
const GeomAbs_IsoType Type,
const Standard_Real Ufirst,
const Standard_Real Ulast,
const Standard_Real AngDefl,
const Standard_Real Deflection,
const Standard_Integer nbpmin) :
parametric(Type)
{
Adaptor3d_IsoCurve Iso(S, Type,ParamIso,Ufirst,Ulast);
pnts.Initialize(Iso,Ufirst,Ulast,AngDefl,Deflection, nbpmin);
// pnts.Initialize(Iso,Deflection,Ufirst,Ulast);
myDiscretTool.Initialize(theCurve, theFirstParam, theLastParam,
theAngDeflection, theLinDeflection, theMinPointsNb);
}
Standard_Integer BRepMesh_GeomTool::AddPoint(const gp_Pnt& thePnt,
const Standard_Real theParam,
const Standard_Boolean theIsReplace)
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_GeomTool::BRepMesh_GeomTool(
const Handle(BRepAdaptor_HSurface)& theSurface,
const GeomAbs_IsoType theIsoType,
const Standard_Real theParamIso,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection,
const Standard_Integer theMinPointsNb)
: myEdge(NULL),
myIsoType(theIsoType)
{
return pnts.AddPoint(thePnt, theParam, theIsReplace);
Adaptor3d_IsoCurve aIso(theSurface, theIsoType, theParamIso,
theFirstParam, theLastParam);
myDiscretTool.Initialize(aIso, theFirstParam, theLastParam,
theAngDeflection, theLinDeflection, theMinPointsNb);
}
Standard_Integer BRepMesh_GeomTool::NbPoints() const {
return pnts.NbPoints();
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_GeomTool::Value(
const Standard_Integer theIndex,
const Handle(BRepAdaptor_HSurface)& theSurface,
Standard_Real& theParam,
gp_Pnt& thePoint,
gp_Pnt2d& theUV) const
{
if (theIndex < 1 || theIndex > NbPoints())
return Standard_False;
if (myEdge == NULL)
return Standard_False;
thePoint = myDiscretTool.Value(theIndex);
theParam = myDiscretTool.Parameter(theIndex);
const TopoDS_Face& aFace = ((BRepAdaptor_Surface*)&(theSurface->Surface()))->Face();
Standard_Real aFirst, aLast;
Handle(Geom2d_Curve) aCurve =
BRep_Tool::CurveOnSurface(*myEdge, aFace, aFirst, aLast);
aCurve->D0(theParam, theUV);
return Standard_True;
}
void BRepMesh_GeomTool::Value(const Standard_Real IsoParam,
const Standard_Integer Index,
Standard_Real& W, gp_Pnt& P, gp_Pnt2d& UV) const
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_GeomTool::Value(const Standard_Integer theIndex,
const Standard_Real theIsoParam,
Standard_Real& theParam,
gp_Pnt& thePoint,
gp_Pnt2d& theUV) const
{
P = pnts.Value(Index);
W = pnts.Parameter(Index);
if (parametric == GeomAbs_IsoU) {
UV.SetCoord(IsoParam,W);
}
else {
UV.SetCoord(W,IsoParam);
if (theIndex < 1 || theIndex > NbPoints())
return Standard_False;
thePoint = myDiscretTool.Value(theIndex);
theParam = myDiscretTool.Parameter(theIndex);
if (myIsoType == GeomAbs_IsoU)
theUV.SetCoord(theIsoParam, theParam);
else
theUV.SetCoord(theParam, theIsoParam);
return Standard_True;
}
//=======================================================================
//function : Normal
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_GeomTool::Normal(
const Handle(BRepAdaptor_HSurface)& theSurface,
const Standard_Real theParamU,
const Standard_Real theParamV,
gp_Pnt& thePoint,
gp_Dir& theNormal)
{
Standard_Boolean isOK = Standard_True;
gp_Vec aD1U, aD1V;
theSurface->D1(theParamU, theParamV, thePoint, aD1U, aD1V);
CSLib_DerivativeStatus aStatus;
CSLib::Normal(aD1U, aD1V, Precision::Angular(), aStatus, theNormal);
if (aStatus != CSLib_Done)
{
gp_Vec aD2U,aD2V,aD2UV;
theSurface->D2(theParamU, theParamV, thePoint, aD1U, aD1V, aD2U, aD2V, aD2UV);
CSLib_NormalStatus aNormalStatus;
CSLib::Normal(aD1U, aD1V, aD2U, aD2V, aD2UV, Precision::Angular(),
isOK, aNormalStatus, theNormal);
}
if (!isOK)
return Standard_False;
const TopoDS_Face& aFace = ((BRepAdaptor_Surface*)&(theSurface->Surface()))->Face();
TopAbs_Orientation aOri = aFace.Orientation();
if (aOri == TopAbs_REVERSED)
theNormal.Reverse();
return Standard_True;
}
void BRepMesh_GeomTool::Value(const BRepAdaptor_Curve& C,
const Handle(BRepAdaptor_HSurface)& S,
const Standard_Integer Index,
Standard_Real& W, gp_Pnt& P, gp_Pnt2d& UV) const
//=============================================================================
//function : IntLinLin
//purpose :
//=============================================================================
BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntLinLin(
const gp_XY& theStartPnt1,
const gp_XY& theEndPnt1,
const gp_XY& theStartPnt2,
const gp_XY& theEndPnt2,
gp_XY& theIntPnt,
Standard_Real (&theParamOnSegment)[2])
{
P = pnts.Value(Index);
W = pnts.Parameter(Index);
BRepMesh_ShapeTool::Parameters(C.Edge(), ((BRepAdaptor_Surface*)&(S->Surface()))->Face(), W, UV);
gp_XY aVec1 = theEndPnt1 - theStartPnt1;
gp_XY aVec2 = theEndPnt2 - theStartPnt2;
gp_XY aVecO1O2 = theStartPnt2 - theStartPnt1;
Standard_Real aCrossD1D2 = aVec1 ^ aVec2;
Standard_Real aCrossD1D3 = aVecO1O2 ^ aVec2;
const Standard_Real aPrec = gp::Resolution();
// Are edgegs codirectional
if ( Abs( aCrossD1D2 ) < aPrec )
{
// Just a parallel case?
if( Abs( aCrossD1D3 ) < aPrec )
return BRepMesh_GeomTool::Same;
else
return BRepMesh_GeomTool::NoIntersection;
}
theParamOnSegment[0] = aCrossD1D3 / aCrossD1D2;
theIntPnt = theStartPnt1 + theParamOnSegment[0] * aVec1;
Standard_Real aCrossD2D3 = aVecO1O2 ^ aVec1;
theParamOnSegment[1] = aCrossD2D3 / aCrossD1D2;
return BRepMesh_GeomTool::Cross;
}
void BRepMesh_GeomTool::D0(const Handle(BRepAdaptor_HSurface)& S,const Standard_Real U,
const Standard_Real V,gp_Pnt& P)
//=============================================================================
//function : IntSegSeg
//purpose :
//=============================================================================
BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(
const gp_XY& theStartPnt1,
const gp_XY& theEndPnt1,
const gp_XY& theStartPnt2,
const gp_XY& theEndPnt2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnSegment,
gp_Pnt2d& theIntPnt)
{
S->D0(U,V,P);
}
Standard_Integer aPointHash[] = {
classifyPoint(theStartPnt1, theEndPnt1, theStartPnt2),
classifyPoint(theStartPnt1, theEndPnt1, theEndPnt2 ),
classifyPoint(theStartPnt2, theEndPnt2, theStartPnt1),
classifyPoint(theStartPnt2, theEndPnt2, theEndPnt1 )
};
Standard_Boolean BRepMesh_GeomTool::Normal(const Handle(BRepAdaptor_HSurface)& S,
const Standard_Real U,
const Standard_Real V,
gp_Pnt& P,
gp_Dir& Nor)
{
Standard_Boolean OK = Standard_True;
gp_Vec D1U,D1V;
CSLib_DerivativeStatus Status;
S->D1(U,V,P,D1U,D1V);
CSLib::Normal(D1U,D1V,Standard_Real(Precision::Angular()),Status,Nor);
if (Status!= CSLib_Done) {
gp_Vec D2U,D2V,D2UV;
S->D2(U,V,P,D1U,D1V,D2U,D2V,D2UV);
CSLib_NormalStatus NStat;
CSLib::Normal(D1U,D1V,D2U,D2V,D2UV,Precision::Angular(),OK,NStat,Nor);
// Consider case when edges have shared vertex
if ( isConsiderEndPointTouch )
{
if ( aPointHash[0] < 0 || aPointHash[1] < 0 )
return BRepMesh_GeomTool::EndPointTouch;
}
if (OK) {
if (BRepMesh_ShapeTool::Orientation(((BRepAdaptor_Surface*)&(S->Surface()))->Face()) == TopAbs_REVERSED) Nor.Reverse();
Standard_Integer aPosHash =
aPointHash[0] + aPointHash[1] + aPointHash[2] + aPointHash[3];
/*=========================================*/
/* 1) hash code == 1:
0+
/
0 1/ 0
+======+==========+
2) hash code == 2:
0 1 1 0
a) +----+========+---+
0 1 1 0
b) +-------+===+=====+
*/
/*=========================================*/
if ( aPosHash == 1 )
{
if (isConsiderPointOnSegment)
{
if (aPointHash[0] == 1)
theIntPnt = theStartPnt1;
else if (aPointHash[1] == 1)
theIntPnt = theEndPnt1;
else if (aPointHash[2] == 1)
theIntPnt = theStartPnt2;
else
theIntPnt = theEndPnt2;
return BRepMesh_GeomTool::PointOnSegment;
}
return BRepMesh_GeomTool::NoIntersection;
}
return OK;
else if ( aPosHash == 2 )
return BRepMesh_GeomTool::Glued;
Standard_Real aParam[2];
IntFlag aIntFlag = IntLinLin(theStartPnt1, theEndPnt1,
theStartPnt2, theEndPnt2, theIntPnt.ChangeCoord(), aParam);
if (aIntFlag == BRepMesh_GeomTool::NoIntersection)
return BRepMesh_GeomTool::NoIntersection;
if (aIntFlag == BRepMesh_GeomTool::Same)
{
if ( aPosHash < -2 )
return BRepMesh_GeomTool::Same;
else if ( aPosHash == -1 )
return BRepMesh_GeomTool::Glued;
return BRepMesh_GeomTool::NoIntersection;
}
// Cross
// Intersection is out of segments ranges
const Standard_Real aPrec = Precision::PConfusion();
const Standard_Real aEndPrec = 1 - aPrec;
for (Standard_Integer i = 0; i < 2; ++i)
{
if( aParam[i] < aPrec || aParam[i] > aEndPrec )
return BRepMesh_GeomTool::NoIntersection;
}
return BRepMesh_GeomTool::Cross;
}
//=============================================================================
//function : classifyPoint
//purpose :
//=============================================================================
Standard_Integer BRepMesh_GeomTool::classifyPoint(
const gp_XY& thePoint1,
const gp_XY& thePoint2,
const gp_XY& thePointToCheck)
{
gp_XY aP1 = thePoint2 - thePoint1;
gp_XY aP2 = thePointToCheck - thePoint1;
const Standard_Real aPrec = Precision::PConfusion();
const Standard_Real aSqPrec = aPrec * aPrec;
Standard_Real aDist = Abs(aP1 ^ aP2);
if (aDist > aPrec)
{
aDist = (aDist * aDist) / aP1.SquareModulus();
if (aDist > aSqPrec)
return 0; //out
}
gp_XY aMult = aP1.Multiplied(aP2);
if ( aMult.X() < 0.0 || aMult.Y() < 0.0 )
return 0; //out
if (aP1.SquareModulus() < aP2.SquareModulus())
return 0; //out
if (thePointToCheck.IsEqual(thePoint1, aPrec) ||
thePointToCheck.IsEqual(thePoint2, aPrec))
{
return -1; //coinsides with an end point
}
return 1;
}

View File

@ -0,0 +1,203 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_GeomTool_HeaderFile
#define _BRepMesh_GeomTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <GeomAbs_IsoType.hxx>
#include <Handle_BRepAdaptor_HSurface.hxx>
#include <TopoDS_Edge.hxx>
class BRepAdaptor_Curve;
class BRepAdaptor_HSurface;
class gp_Pnt;
class gp_Pnt2d;
class gp_Dir;
//! Tool class intended to obtain parameters based on shape geometry.
class BRepMesh_GeomTool
{
public:
//! Enumerates states of segments intersection check.
enum IntFlag
{
NoIntersection,
Cross,
EndPointTouch,
PointOnSegment,
Glued,
Same
};
public:
DEFINE_STANDARD_ALLOC
//! Constructor.
//! Initiates discretization of the given geometric curve.
//! \param theCurve curve to be discretized.
//! \param theFirstParam first parameter of the curve.
//! \param theLastParam last parameter of the curve.
//! \param theLinDeflection linear deflection.
//! \param theAngDeflection angular deflection.
//! \param theMinPointsNb minimum nuber of points to be produced.
Standard_EXPORT BRepMesh_GeomTool(const BRepAdaptor_Curve& theCurve,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection,
const Standard_Integer theMinPointsNb = 2);
//! Constructor.
//! Initiates discretization of geometric curve corresponding
//! to iso curve of the given surface.
//! \param theSurface surface the iso curve to be taken from.
//! \param theIsoType type of iso curve to be used, U or V.
//! \param theParamIso parameter on the surface specifying the iso curve.
//! \param theFirstParam first parameter of the curve.
//! \param theLastParam last parameter of the curve.
//! \param theLinDeflection linear deflection.
//! \param theAngDeflection angular deflection.
//! \param theMinPointsNb minimum nuber of points to be produced.
Standard_EXPORT BRepMesh_GeomTool(const Handle(BRepAdaptor_HSurface)& theSurface,
const GeomAbs_IsoType theIsoType,
const Standard_Real theParamIso,
const Standard_Real theFirstParam,
const Standard_Real theLastParam,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection,
const Standard_Integer theMinPointsNb = 2);
//! Adds point to already calculated points (or replaces existing).
//! \param thePoint point to be added.
//! \param theParam parameter on the curve corresponding to the given point.
//! \param theIsReplace if TRUE replaces existing point lying within
//! parameteric tolerance of the given point.
//! \return index of new added point or found with parametric tolerance
inline Standard_Integer AddPoint(const gp_Pnt& thePoint,
const Standard_Real theParam,
const Standard_Boolean theIsReplace = Standard_True)
{
return myDiscretTool.AddPoint(thePoint, theParam, theIsReplace);
}
//! Returns number of discretization points.
inline Standard_Integer NbPoints() const
{
return myDiscretTool.NbPoints();
}
//! Gets parameters of discretization point with the given index.
//! \param theIndex index of discretization point.
//! \param theIsoParam parameter on surface to be used as second coordinate
//! of resulting 2d point.
//! \param theParam[out] parameter of the point on the iso curve.
//! \param thePoint[out] discretization point.
//! \param theUV[out] discretization point in parametric space of the surface.
//! \return TRUE on success, FALSE elsewhere.
Standard_EXPORT Standard_Boolean Value(const Standard_Integer theIndex,
const Standard_Real theIsoParam,
Standard_Real& theParam,
gp_Pnt& thePoint,
gp_Pnt2d& theUV) const;
//! Gets parameters of discretization point with the given index.
//! \param theIndex index of discretization point.
//! \param theSurface surface the curve is lying onto.
//! \param theParam[out] parameter of the point on the curve.
//! \param thePoint[out] discretization point.
//! \param theUV[out] discretization point in parametric space of the surface.
//! \return TRUE on success, FALSE elsewhere.
Standard_EXPORT Standard_Boolean Value(const Standard_Integer theIndex,
const Handle(BRepAdaptor_HSurface)& theSurface,
Standard_Real& theParam,
gp_Pnt& thePoint,
gp_Pnt2d& theUV) const;
public: //! \name static API
//! \param theSurface surface the nomal should be found for.
//! \param theParamU U parameter in parametric space of the surface.
//! \param theParamV V parameter in parametric space of the surface.
//! \param[out] thePoint 3d point corresponding to the given parameters.
//! \param[out] theNormal normal vector at the point specified by the parameters.
//! \return FALSE if the normal can not be computed, TRUE elsewhere.
static Standard_Boolean Normal(const Handle(BRepAdaptor_HSurface)& theSurface,
const Standard_Real theParamU,
const Standard_Real theParamV,
gp_Pnt& thePoint,
gp_Dir& theNormal);
//! Checks intersection between two lines defined by two points.
//! \param theStartPnt1 start point of first line.
//! \param theEndPnt1 end point of first line.
//! \param theStartPnt2 start point of second line.
//! \param theEndPnt2 end point of second line.
//! \param[out] theIntPnt point of intersection.
//! \param[out] theParamOnSegment parameters of intersection point
//! corresponding to first and second segment.
//! \return status of intersection check.
static IntFlag IntLinLin(const gp_XY& theStartPnt1,
const gp_XY& theEndPnt1,
const gp_XY& theStartPnt2,
const gp_XY& theEndPnt2,
gp_XY& theIntPnt,
Standard_Real (&theParamOnSegment)[2]);
//! Checks intersection between the two segments.
//! Checks that intersection point lies within ranges of both segments.
//! \param theStartPnt1 start point of first segment.
//! \param theEndPnt1 end point of first segment.
//! \param theStartPnt2 start point of second segment.
//! \param theEndPnt2 end point of second segment.
//! \param isConsiderEndPointTouch if TRUE EndPointTouch status will be
//! returned in case if segments are touching by end points, if FALSE
//! returns NoIntersection flag.
//! \param isConsiderPointOnSegment if TRUE PointOnSegment status will be
//! returned in case if end point of one segment lies onto another one,
//! if FALSE returns NoIntersection flag.
//! \param[out] theIntPnt point of intersection.
//! \return status of intersection check.
static IntFlag IntSegSeg(const gp_XY& theStartPnt1,
const gp_XY& theEndPnt1,
const gp_XY& theStartPnt2,
const gp_XY& theEndPnt2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnSegment,
gp_Pnt2d& theIntPnt);
private:
//! Classifies the point in case of coincidence of two vectors.
//! \param thePoint1 the start point of a segment (base point).
//! \param thePoint2 the end point of a segment.
//! \param thePointToCheck the point to classify.
//! \return zero value if point is out of segment and non zero value
//! if point is between the first and the second point of segment.
static Standard_Integer classifyPoint (const gp_XY& thePoint1,
const gp_XY& thePoint2,
const gp_XY& thePointToCheck);
private:
const TopoDS_Edge* myEdge;
GCPnts_TangentialDeflection myDiscretTool;
GeomAbs_IsoType myIsoType;
};
#endif

View File

@ -16,11 +16,12 @@
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepMesh.hxx>
#include <Precision.hxx>
#include <Standard_Mutex.hxx>
#include <BRepMesh_FaceChecker.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <BRepMesh_Edge.hxx>
#include <BRepMesh_Triangle.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <BRepMesh_FastDiscretFace.hxx>
#include <BRepMesh_PluginMacro.hxx>
#include <Bnd_Box.hxx>
@ -30,25 +31,26 @@
#include <BRepLib.hxx>
#include <BRepBndLib.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <Precision.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MutexForShapeProvider.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopTools_HArray1OfShape.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Standard_Mutex.hxx>
#include <BRepMesh_FaceChecker.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#ifdef HAVE_TBB
// paralleling using Intel TBB
@ -65,6 +67,79 @@ namespace
IMPLEMENT_STANDARD_HANDLE (BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
//=======================================================================
//function : Default constructor
//purpose :
//=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
: myRelative (Standard_False),
myInParallel (Standard_False)
{
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle,
const Standard_Boolean theRelative,
const Standard_Boolean theInParallel)
: myRelative (theRelative),
myInParallel(theInParallel)
{
myDeflection = theDeflection;
myAngle = theAngle;
myShape = theShape;
Perform();
}
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
{
}
//=======================================================================
//function : init
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::init()
{
myStatus = 0;
myModified = Standard_False;
myEdgeDeflection.Clear();
mySharedFaces.Clear();
myFaces.clear();
setDone();
if (!isCorrectPolyData())
BRepTools::Clean(myShape);
Bnd_Box aBox;
BRepBndLib::Add(myShape, aBox, Standard_False);
if (aBox.IsVoid())
{
// Nothing to mesh.
myMesher.Nullify();
return;
}
BRepMesh_ShapeTool::BoxMaxDimension(aBox, myMaxShapeSize);
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, mySharedFaces);
myMesher = new BRepMesh_FastDiscret(myDeflection, myAngle, aBox,
Standard_True, Standard_True, myRelative, Standard_True, myInParallel);
}
//=======================================================================
//function : isCorrectPolyData
//purpose :
@ -74,167 +149,26 @@ Standard_Boolean BRepMesh_IncrementalMesh::isCorrectPolyData()
collectFaces();
BRepMesh_FaceChecker aFaceChecker(myInParallel);
#ifdef HAVE_TBB
if (myInParallel)
{
#ifdef HAVE_TBB
// check faces in parallel threads using TBB
tbb::parallel_for_each(myFaces.begin(), myFaces.end(), aFaceChecker);
#else
// alternative parallelization not yet available
for (std::vector<TopoDS_Face>::iterator it(myFaces.begin()); it != myFaces.end(); it++)
aFaceChecker(*it);
#endif
}
else
{
for (std::vector<TopoDS_Face>::iterator it(myFaces.begin()); it != myFaces.end(); it++)
aFaceChecker(*it);
#endif
std::vector<TopoDS_Face>::iterator aFaceIt = myFaces.begin();
for (; aFaceIt != myFaces.end(); aFaceIt++)
aFaceChecker(*aFaceIt);
#ifdef HAVE_TBB
}
#endif
return aFaceChecker.IsValid();
}
//=======================================================================
//function : BRepMesh_IncrementalMesh
//purpose :
//=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
: myRelative (Standard_False),
myInParallel (Standard_False)
{
Init();
}
//=======================================================================
//function : BRepMesh_IncrementalMesh
//purpose :
//=======================================================================
BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Boolean theRelative,
const Standard_Real theAngle,
const Standard_Boolean theInParallel)
: myRelative (theRelative),
myInParallel (theInParallel)
{
Init();
myDeflection = theDeflection;
myAngle = theAngle;
myShape = theShape;
//
Perform();
}
//=======================================================================
//function : ~
//purpose :
//=======================================================================
BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
{
}
//=======================================================================
//function : SetParallel
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::SetParallel (const Standard_Boolean theInParallel)
{
myInParallel = theInParallel;
}
//=======================================================================
//function : IsParallel
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::IsParallel() const
{
return myInParallel;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Init()
{
myStatus = 0;
myModified = Standard_False;
mymapedge.Clear();
myancestors.Clear();
myFaces.clear();
}
//=======================================================================
//function : SetRelative
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::SetRelative(const Standard_Boolean theFlag)
{
myRelative = theFlag;
}
//=======================================================================
//function : Relative
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::Relative()const
{
return myRelative;
}
//=======================================================================
//function : IsModified
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::IsModified() const
{
return myModified;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Perform()
{
Init();
if (!isCorrectPolyData())
BRepTools::Clean(myShape);
Bnd_Box aBox;
//
SetDone();
//
BRepBndLib::Add(myShape, aBox);
myBox = aBox;
//
if (!myMesh.IsNull()) {
myMesh.Nullify();
}
//
myMesh = new BRepMesh_FastDiscret(myDeflection,
myAngle,
aBox,
Standard_True,
Standard_True,
myRelative,
Standard_True,
myInParallel);
//
Update(myShape);
}
//=======================================================================
//function : GetStatus
//purpose :
//=======================================================================
Standard_Integer BRepMesh_IncrementalMesh::GetStatusFlags() const
{
return myStatus;
}
//=======================================================================
//function : collectFaces
//purpose :
@ -267,301 +201,288 @@ void BRepMesh_IncrementalMesh::collectFaces()
}
//=======================================================================
//function : Update(shape)
//purpose : Builds the incremental mesh of the shape
//function : Perform
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Update(const TopoDS_Shape& S)
void BRepMesh_IncrementalMesh::Perform()
{
myModified = Standard_False;
TopExp_Explorer ex;
init();
//AGV 080407: Since version 6.2.0 there would be exception without this check
if (myBox.IsVoid())
if (myMesher.IsNull())
return;
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, myancestors);
BRepMesh_FastDiscret::BoxMaxDimension(myBox, mydtotale);
for (ex.Init(S, TopAbs_EDGE); ex.More(); ex.Next()) {
if(BRep_Tool::IsGeometric(TopoDS::Edge(ex.Current()))) {
Update(TopoDS::Edge(ex.Current()));
}
update();
}
//=======================================================================
//function : update()
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::update()
{
// Update edges data
TopExp_Explorer aExplorer(myShape, TopAbs_EDGE);
for (; aExplorer.More(); aExplorer.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current());
if(!BRep_Tool::IsGeometric(aEdge))
continue;
update(aEdge);
}
// get list of faces
// Update faces data
std::vector<TopoDS_Face>::iterator aFaceIt(myFaces.begin());
for (; aFaceIt != myFaces.end(); aFaceIt++)
Update(*aFaceIt);
update(*aFaceIt);
// Mesh faces
#ifdef HAVE_TBB
if (myInParallel)
{
#ifdef HAVE_TBB
myMesh->CreateMutexesForSubShapes(S, TopAbs_EDGE);
// mesh faces in parallel threads using TBB
tbb::parallel_for_each (myFaces.begin(), myFaces.end(), *myMesh.operator->());
#else
// alternative parallelization not yet available
for (std::vector<TopoDS_Face>::iterator it(myFaces.begin()); it != myFaces.end(); it++)
myMesh->Process (*it);
#endif
myMesh->RemoveAllMutexes();
myMesher->CreateMutexesForSubShapes(myShape, TopAbs_EDGE);
tbb::parallel_for_each(myFaces.begin(), myFaces.end(), *myMesher);
myMesher->RemoveAllMutexes();
}
else
{
for (std::vector<TopoDS_Face>::iterator it(myFaces.begin()); it != myFaces.end(); it++)
myMesh->Process (*it);
#endif
for (aFaceIt = myFaces.begin(); aFaceIt != myFaces.end(); aFaceIt++)
myMesher->Process(*aFaceIt);
#ifdef HAVE_TBB
}
#endif
// maillage des edges non contenues dans les faces :
Standard_Real f, l, defedge;
Standard_Integer i, nbNodes;
TopLoc_Location L;
Standard_Real cdef = 1.;
ex.Init(S ,TopAbs_EDGE, TopAbs_FACE);
discretizeFreeEdges();
}
while (ex.More()) {
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
if(!BRep_Tool::IsGeometric(E)) {
ex.Next();
//=======================================================================
//function : discretizeFreeEdges
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::discretizeFreeEdges()
{
TopExp_Explorer aExplorer(myShape ,TopAbs_EDGE, TopAbs_FACE);
for (; aExplorer.More(); aExplorer.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current());
if(!BRep_Tool::IsGeometric(aEdge))
continue;
}
if (myRelative)
defedge = BRepMesh_FastDiscret::RelativeEdgeDeflection(E, myDeflection,
mydtotale, cdef);
else
defedge = myDeflection;
Handle(Poly_Polygon3D) P3D = BRep_Tool::Polygon3D(E, L);
Standard_Boolean maill = Standard_False;
if (P3D.IsNull()) {
maill = Standard_True;
}
else if (P3D->Deflection() > 1.1*defedge) {
maill = Standard_True;
}
if (maill) {
BRepAdaptor_Curve C(E);
f = C.FirstParameter();
l = C.LastParameter();
GCPnts_TangentialDeflection TD(C, f, l, myAngle, defedge, 2);
nbNodes = TD.NbPoints();
TColgp_Array1OfPnt Nodes(1, nbNodes);
TColStd_Array1OfReal UVNodes(1, nbNodes);
for ( i = 1; i <= nbNodes; i++) {
Nodes(i) = TD.Value(i);
UVNodes(i) = TD.Parameter(i);
}
BRep_Builder B;
Handle(Poly_Polygon3D) P = new Poly_Polygon3D(Nodes, UVNodes);
P->Deflection(myDeflection);
B.UpdateEdge(E, P);
}
TopLoc_Location aLoc;
Standard_Real aEdgeDeflection = edgeDeflection(aEdge);
Handle(Poly_Polygon3D) aPoly3D = BRep_Tool::Polygon3D(aEdge, aLoc);
if (!aPoly3D.IsNull() && aPoly3D->Deflection() < 1.1 * aEdgeDeflection)
continue;
ex.Next();
BRepAdaptor_Curve aCurve(aEdge);
GCPnts_TangentialDeflection aDiscret(aCurve, aCurve.FirstParameter(),
aCurve.LastParameter(), myAngle, aEdgeDeflection, 2);
Standard_Integer aNodesNb = aDiscret.NbPoints();
TColgp_Array1OfPnt aNodes (1, aNodesNb);
TColStd_Array1OfReal aUVNodes(1, aNodesNb);
for (Standard_Integer i = 1; i <= aNodesNb; ++i)
{
aNodes (i) = aDiscret.Value(i);
aUVNodes(i) = aDiscret.Parameter(i);
}
aPoly3D = new Poly_Polygon3D(aNodes, aUVNodes);
aPoly3D->Deflection(myDeflection);
BRep_Builder aBuilder;
aBuilder.UpdateEdge(aEdge, aPoly3D);
}
}
//=======================================================================
//function : Update(edge)
//purpose : Locate a correct discretisation if it exists
// Set no one otherwise
//function : edgeDeflection
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Update(const TopoDS_Edge& E)
Standard_Real BRepMesh_IncrementalMesh::edgeDeflection(
const TopoDS_Edge& theEdge)
{
TopLoc_Location l;
Standard_Integer i = 1;
Handle(Poly_Triangulation) T, TNull;
Handle(Poly_PolygonOnTriangulation) Poly, NullPoly;
Standard_Boolean found = Standard_False;
Standard_Real defedge = Precision::Confusion();
Standard_Real cdef = 1.;
BRep_Builder B;
Standard_Boolean defined = Standard_False;
do {
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l, i);
i++;
if (!T.IsNull() && !Poly.IsNull())
{
if (!defined)
{
if (myRelative)
defedge = BRepMesh_FastDiscret::RelativeEdgeDeflection(E, myDeflection,
mydtotale, cdef);
else
defedge = myDeflection;
if (myEdgeDeflection.IsBound(theEdge))
return myEdgeDeflection(theEdge);
mymapedge.Bind(E, defedge);
defined = Standard_True;
}
if (Poly->Deflection() <= 1.1 * defedge)
{
found = Standard_True;
}
else
{
myModified = Standard_True;
B.UpdateEdge(E, NullPoly, T, l);
}
}
} while (!Poly.IsNull());
if (!found) myMap.Add(E);
}
//=======================================================================
//function : Update(face)
//purpose : If the face is not correctly triangulated, or if one of its
// edges is to be discretisated correctly, the triangulation
// of this face is built.
//=======================================================================
void BRepMesh_IncrementalMesh::Update(const TopoDS_Face& F)
{
TopLoc_Location l;
Handle(Geom_Surface) SS = BRep_Tool::Surface(F, l);
if (SS.IsNull()) return;
//Standard_Integer i;
Standard_Boolean WillBeTriangulated = Standard_False;
Handle(Poly_Triangulation) T, TNull;
T = BRep_Tool::Triangulation(F, l);
Handle(Poly_PolygonOnTriangulation) Poly, NullPoly;
BRep_Builder B;
TopExp_Explorer ex;
Standard_Real defedge, defface, cdef = 1.;
Standard_Integer nbEdge = 0;
if (myRelative) {
defface = 0.;
for (ex.Init(F, TopAbs_EDGE); ex.More(); ex.Next()) {
const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
nbEdge++;
if (mymapedge.IsBound(edge)) {
defedge = mymapedge(edge);
}
else
defedge = BRepMesh_FastDiscret::RelativeEdgeDeflection(edge, myDeflection, mydtotale, cdef);
defface = defface + defedge;
}
if (nbEdge != 0) defface = defface / nbEdge;
else defface = myDeflection;
Standard_Real aEdgeDeflection;
if (myRelative)
{
Standard_Real aScale;
aEdgeDeflection = BRepMesh_ShapeTool::RelativeEdgeDeflection(theEdge,
myDeflection, myMaxShapeSize, aScale);
}
else
defface = myDeflection;
aEdgeDeflection = myDeflection;
if (!T.IsNull())
myEdgeDeflection.Bind(theEdge, aEdgeDeflection);
return aEdgeDeflection;
}
//=======================================================================
//function : faceDeflection
//purpose :
//=======================================================================
Standard_Real BRepMesh_IncrementalMesh::faceDeflection(
const TopoDS_Face& theFace)
{
if (!myRelative)
return myDeflection;
Standard_Integer aEdgesNb = 0;
Standard_Real aFaceDeflection = 0.;
TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
for (; aEdgeIt.More(); aEdgeIt.Next(), ++aEdgesNb)
{
if (T->Deflection() <= 1.1 * defface)
{
for (ex.Init(F, TopAbs_EDGE); ex.More(); ex.Next())
{
const TopoDS_Shape& anEdge = ex.Current();
Poly = BRep_Tool::PolygonOnTriangulation(TopoDS::Edge(anEdge), T, l);
const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
aFaceDeflection += edgeDeflection(aEdge);
}
if (Poly.IsNull() || myMap.Contains(anEdge))
{
// Triangulation is built but edge hasn't representation on it.
WillBeTriangulated = Standard_True;
break;
}
}
}
else
return (aEdgesNb == 0) ? myDeflection : (aFaceDeflection / aEdgesNb);
}
//=======================================================================
//function : update(edge)
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::update(const TopoDS_Edge& theEdge)
{
Standard_Integer aPolyIndex = 1;
Standard_Real aEdgeDeflection = edgeDeflection(theEdge);
Handle(Poly_PolygonOnTriangulation) aPolygon;
do
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTriangulation;
BRep_Tool::PolygonOnTriangulation(theEdge, aPolygon,
aTriangulation, aLoc, aPolyIndex++);
if (!aTriangulation.IsNull() && !aPolygon.IsNull())
{
WillBeTriangulated = Standard_True;
if (aPolygon->Deflection() < 1.1 * aEdgeDeflection)
continue;
myModified = Standard_True;
BRepMesh_ShapeTool::NullifyEdge(theEdge, aTriangulation, aLoc);
}
if (!myEmptyEdges.IsBound(theEdge))
myEmptyEdges.Bind(theEdge, BRepMeshCol::MapOfTriangulation());
myEmptyEdges(theEdge).Add(aTriangulation);
}
while (!aPolygon.IsNull());
}
//=======================================================================
//function : isToBeMeshed
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed(
const TopoDS_Face& theFace,
const Standard_Boolean isWithCheck)
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTriangulation =
BRep_Tool::Triangulation(theFace, aLoc);
if (aTriangulation.IsNull())
return Standard_True;
if (isWithCheck)
{
Standard_Real aFaceDeflection = faceDeflection(theFace);
if (aTriangulation->Deflection() < 1.1 * aFaceDeflection)
{
Standard_Boolean isEdgesConsistent = Standard_True;
TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
for (; aEdgeIt.More() && isEdgesConsistent; aEdgeIt.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
if (!myEmptyEdges.IsBound(aEdge))
continue;
isEdgesConsistent &= myEmptyEdges(aEdge).Contains(aTriangulation);
}
if (isEdgesConsistent)
return Standard_False;
}
}
if (WillBeTriangulated || T.IsNull()) {
myModified = Standard_True;
if (!T.IsNull()) {
for (ex.Init(F, TopAbs_EDGE); ex.More(); ex.Next()) {
B.UpdateEdge(TopoDS::Edge(ex.Current()), NullPoly, T, l);
myMap.Remove(ex.Current());
}
B.UpdateFace(F, TNull);
}
myMesh->Add(F, myancestors);
myStatus |= (Standard_Integer)(myMesh->CurrentFaceStatus());
if (myMesh->CurrentFaceStatus() == BRepMesh_ReMesh) {
#ifdef DEB_MESH
cout << " face remaillee + finement que prevu."<< endl;
#endif
// Nullify edges
TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
for (; aEdgeIt.More(); aEdgeIt.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
BRepMesh_ShapeTool::NullifyEdge(aEdge, aTriangulation, aLoc);
}
Standard_Integer index;
TopTools_MapOfShape MShape;
MShape.Add(F);
BRepMesh_ShapeTool::NullifyFace(theFace);
return Standard_True;
}
TopoDS_Iterator ex(F),ex2;
for (; ex.More(); ex.Next()) {
const TopoDS_Shape& aWire = ex.Value();
if (aWire.ShapeType() != TopAbs_WIRE)
continue;
TopoDS_Iterator exW(aWire);
for(; exW.More(); exW.Next()) {
const TopoDS_Edge& edge = TopoDS::Edge(exW.Value());
index = myancestors.FindIndex(edge);
if (index != 0) {
const TopTools_ListOfShape& L = myancestors.FindFromKey(edge);
//=======================================================================
//function : update(face)
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::update(const TopoDS_Face& theFace)
{
if (!toBeMeshed(theFace, Standard_True))
return;
TopTools_ListIteratorOfListOfShape it(L);
myModified = Standard_True;
myMesher->Add(theFace, mySharedFaces);
for (; it.More(); it.Next()) {
TopoDS_Face F2 = TopoDS::Face(it.Value());
if (!MShape.Contains(F2)) {
MShape.Add(F2);
T = BRep_Tool::Triangulation(F2, l);
if (!T.IsNull()) {
#ifdef DEB_MESH
cout <<"triangulation a refaire" <<endl;
#endif
for (ex2.Initialize(F2); ex2.More(); ex2.Next()) {
const TopoDS_Shape& aWire2 = ex2.Value();
if (aWire2.ShapeType() != TopAbs_WIRE)
continue;
TopoDS_Iterator exW2(aWire2);
for(; exW2.More(); exW2.Next()) {
TopoDS_Edge E2 = TopoDS::Edge(exW2.Value());
B.UpdateEdge(E2, NullPoly, T, l);
}
}
B.UpdateFace(F2, TNull);
myMesh->Add(F2, myancestors);
}
}
}
}
}
}
BRepMesh_Status aStatus = myMesher->CurrentFaceStatus();
myStatus |= (Standard_Integer)aStatus;
if (aStatus != BRepMesh_ReMesh)
return;
BRepMeshCol::MapOfShape aUsedFaces;
aUsedFaces.Add(theFace);
TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
for (; aEdgeIt.More(); aEdgeIt.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
if (mySharedFaces.FindIndex(aEdge) == 0)
continue;
const TopTools_ListOfShape& aSharedFaces = mySharedFaces.FindFromKey(aEdge);
TopTools_ListIteratorOfListOfShape aSharedFaceIt(aSharedFaces);
for (; aSharedFaceIt.More(); aSharedFaceIt.Next())
{
const TopoDS_Face& aFace = TopoDS::Face(aSharedFaceIt.Value());
if (aUsedFaces.Contains(aFace))
continue;
aUsedFaces.Add(aFace);
toBeMeshed(aFace, Standard_False);
myMesher->Add(aFace, mySharedFaces);
myStatus |= (Standard_Integer)myMesher->CurrentFaceStatus();
}
}
}
//=======================================================================
//function : Discret
//purpose :
//=======================================================================
Standard_Integer BRepMesh_IncrementalMesh::Discret (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle,
BRepMesh_PDiscretRoot& theAlgo)
Standard_Integer BRepMesh_IncrementalMesh::Discret(
const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle,
BRepMesh_PDiscretRoot& theAlgo)
{
BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
anAlgo->SetDeflection (theDeflection);
anAlgo->SetAngle (theAngle);
anAlgo->SetShape (theShape);
anAlgo->SetParallel (IS_IN_PARALLEL);
anAlgo->SetDeflection(theDeflection);
anAlgo->SetAngle (theAngle);
anAlgo->SetShape (theShape);
anAlgo->SetParallel (IS_IN_PARALLEL);
theAlgo = anAlgo;
return 0; // no error
}
@ -584,7 +505,8 @@ Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault()
//function : Discret
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::SetParallelDefault (const Standard_Boolean theInParallel)
void BRepMesh_IncrementalMesh::SetParallelDefault(
const Standard_Boolean theInParallel)
{
IS_IN_PARALLEL = theInParallel;
}

View File

@ -17,119 +17,186 @@
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Handle_BRepMesh_FastDiscret.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_DataMapOfShapeReal.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Bnd_Box.hxx>
#include <BRepMesh_DiscretRoot.hxx>
#include <BRepMesh_PDiscretRoot.hxx>
#include <Handle_Poly_Triangulation.hxx>
#include <BRepMesh_Collections.hxx>
#include <vector>
class BRepMesh_FastDiscret;
class Poly_Triangulation;
class TopoDS_Shape;
class TopoDS_Edge;
class TopoDS_Face;
//! Builds the mesh of a shape with respect of their <br>
//! correctly triangulated parts <br>
//! <br>
class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot {
//! Builds the mesh of a shape with respect of their
//! correctly triangulated parts
class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot
{
public: //! \name mesher API
public:
Standard_EXPORT BRepMesh_IncrementalMesh();
//! Default constructor
Standard_EXPORT BRepMesh_IncrementalMesh();
//! Destructor
Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();
//! If the boolean flag <isRelative> is TRUE, the <br>
//! deflection used for the polygonalisation of <br>
//! each edge will be <theLinDeflection> * Size of Edge. <br>
//! the deflection used for the faces will be the maximum <br>
//! deflection of their edges. <br>
Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
const Standard_Real theLinDeflection,
const Standard_Boolean isRelative = Standard_False,
const Standard_Real theAngDeflection = 0.5,
const Standard_Boolean isInParallel = Standard_False);
Standard_EXPORT void SetRelative(const Standard_Boolean theFlag);
Standard_EXPORT Standard_Boolean Relative() const;
Standard_EXPORT virtual void Perform();
//! Constructor.
//! Automatically calls method Perform.
//! \param theShape shape to be meshed.
//! \param theLinDeflection linear deflection.
//! \param theAngDeflection angular deflection.
//! \paarm isRelative if TRUE deflection used for discretization of
//! each edge will be <theLinDeflection> * <size of edge>. Deflection
//! used for the faces will be the maximum deflection of their edges.
//! \param isInParallel if TRUE shape will be meshed in parallel.
Standard_EXPORT BRepMesh_IncrementalMesh(
const TopoDS_Shape& theShape,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection = 0.5,
const Standard_Boolean isRelative = Standard_False,
const Standard_Boolean isInParallel = Standard_False);
//! Builds the incremental mesh of the shape <br>
Standard_EXPORT void Update(const TopoDS_Shape& theShape);
//! Performs meshing ot the shape.
Standard_EXPORT virtual void Perform();
Standard_EXPORT Standard_Boolean IsModified() const;
public: //! \name accessing to parameters.
//! Enables using relative deflection.
//! \param isRelative if TRUE deflection used for discretization of
//! each edge will be <theLinDeflection> * <size of edge>. Deflection
//! used for the faces will be the maximum deflection of their edges.
inline void SetRelative(const Standard_Boolean isRelative)
{
myRelative = isRelative;
}
Standard_EXPORT Standard_Integer GetStatusFlags() const;
//! Returns relative deflection flag.
inline Standard_Boolean IsRelative() const
{
return myRelative;
}
//! Request algorithm to launch in multiple threads to improve performance. <br>
Standard_EXPORT void SetParallel(const Standard_Boolean isInParallel);
//! Returns modified flag.
inline Standard_Boolean IsModified() const
{
return myModified;
}
//! Returns the multi-threading usage flag. <br>
Standard_EXPORT Standard_Boolean IsParallel() const;
//! Returns accumulated status flags faced during meshing.
inline Standard_Integer GetStatusFlags() const
{
return myStatus;
}
//! Plugin interface for the Mesh Factories. <br>
//! Request algorithm to launch in multiple threads to improve performance.
inline void SetParallel(const Standard_Boolean isInParallel)
{
myInParallel = isInParallel;
}
//! Returns the multi-threading usage flag.
inline Standard_Boolean IsParallel() const
{
return myInParallel;
}
public: //! \name plugin API
//! Plugin interface for the Mesh Factories.
//! Initializes meshing algorithm with the given parameters.
//! \param theShape shape to be meshed.
//! \param theLinDeflection linear deflection.
//! \param theAngDeflection angular deflection.
//! \param[out] theAlgo pointer to initialized algorithm.
Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape& theShape,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection,
BRepMesh_PDiscretRoot& theAlgo);
//! Returns multi-threading usage flag set by default in <br>
//! Discret() static method (thus applied only to Mesh Factories). <br>
//! Returns multi-threading usage flag set by default in
//! Discret() static method (thus applied only to Mesh Factories).
Standard_EXPORT static Standard_Boolean IsParallelDefault();
//! Setup multi-threading usage flag set by default in <br>
//! Discret() static method (thus applied only to Mesh Factories). <br>
Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel) ;
//! Setup multi-threading usage flag set by default in
//! Discret() static method (thus applied only to Mesh Factories).
Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel);
DEFINE_STANDARD_RTTI(BRepMesh_IncrementalMesh)
protected:
Standard_EXPORT virtual void Init();
Standard_EXPORT virtual void init();
private:
//! Checks is the shape to be meshed has correct poly data,
//! i.e. PolygonOnTriangulation of particular edge connected
//! to the same Triangulation data structure as stored inside
//! a parent face.
//! \return TRUE on success, FALSE in case of inconsistencies.
Standard_Boolean isCorrectPolyData();
//! Builds the incremental mesh for the shape.
void update();
//! Checks triangulation of the given face for consistency
//! with the chosen tolerance. If some edge of face has no
//! discrete representation triangulation will be calculated.
//! \param theFace face to be checked.
void update(const TopoDS_Face& theFace);
//! Checks discretization of the given edge for consistency
//! with the chosen tolerance.
//! \param theEdge edge to be checked.
void update(const TopoDS_Edge& theEdge);
//! Collects faces suitable for meshing.
Standard_EXPORT void collectFaces();
void collectFaces();
//! Discretizes edges that have no associations with faces.
void discretizeFreeEdges();
//! Returns deflection of the given edge.
//! \param theEdge edge which tolerance should be taken.
Standard_Real edgeDeflection(const TopoDS_Edge& theEdge);
//! Returns deflection of the given face.
//! If relative flag is set, calculates relative deflection of the face
//! as an average value of relative deflection regarding face's edges.
//! Returns value of deflection set by user elsewhere.
Standard_Real faceDeflection(const TopoDS_Face& theFace);
//! Prepares the given face for meshing.
//! Nullifies triangulation of face and polygons of face's edges.
//! \param theFace face to be checked.
//! \param isWithCheck if TRUE, checks parameters of triangulation
//! existing in face. If its deflection satisfies the given value and
//! each edge of face has polygon corresponded to this triangulation,
//! method return FALSE.
//! \return TRUE in case if the given face should be meshed.
Standard_Boolean toBeMeshed(const TopoDS_Face& theFace,
const Standard_Boolean isWithCheck);
protected:
Standard_Boolean myRelative;
Standard_Boolean myInParallel;
TopTools_MapOfShape myMap;
Handle_BRepMesh_FastDiscret myMesh;
Standard_Boolean myModified;
TopTools_DataMapOfShapeReal mymapedge;
TopTools_IndexedDataMapOfShapeListOfShape myancestors;
Standard_Real mydtotale;
Bnd_Box myBox;
Standard_Integer myStatus;
std::vector<TopoDS_Face> myFaces;
private:
//! Checks is the shape to be meshed has correct poly data, <br>
//! i.e. PolygonOnTriangulation of particular edge connected <br>
//! to the same Triangulation data structure as stored inside <br>
//! a parent face. <br>
Standard_Boolean isCorrectPolyData();
//! Locate a correct discretisation if it exists <br>
//! Set no one otherwise <br>
void Update(const TopoDS_Edge& theEdge);
//! If the face is not correctly triangulated, or if one <br>
//! of its edges is to be discretisated correctly, the <br>
//! triangulation of this face is built. <br>
void Update(const TopoDS_Face& theFace);
Standard_Boolean myRelative;
Standard_Boolean myInParallel;
BRepMeshCol::DMapOfEdgeListOfTriangulation myEmptyEdges;
Handle(BRepMesh_FastDiscret) myMesher;
Standard_Boolean myModified;
TopTools_DataMapOfShapeReal myEdgeDeflection;
TopTools_IndexedDataMapOfShapeListOfShape mySharedFaces;
Standard_Real myMaxShapeSize;
Standard_Integer myStatus;
std::vector<TopoDS_Face> myFaces;
};
DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)
// other Inline functions and methods (like "C++: function call" methods)
#endif

View File

@ -1,16 +0,0 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <NCollection_List.hxx>
typedef NCollection_List<Standard_Integer> BRepMesh_ListOfInteger;

View File

@ -1,23 +0,0 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef BRepMesh_MapOfInteger_HeaderFile
#define BRepMesh_MapOfInteger_HeaderFile
#include <NCollection_Map.hxx>
#include <NCollection_Handle.hxx>
typedef NCollection_Map<Standard_Integer> BRepMesh_MapOfInteger;
typedef NCollection_Handle<BRepMesh_MapOfInteger> Handle(BRepMesh_MapOfInteger);
#endif

View File

@ -1,22 +0,0 @@
// Created on: 2009-01-30
// Created by: Pavel DURANDIN (pdn)
// Copyright (c) 2009-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef BRepMesh_MapOfIntegerInteger_HeaderFile
#define BRepMesh_MapOfIntegerInteger_HeaderFile
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Standard_Integer, Standard_Integer> BRepMesh_MapOfIntegerInteger;
#endif

View File

@ -13,103 +13,117 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
/*
* 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>
//! This class represents a pair of integer indices to store
//! element indices connected to link. It is restricted to
//! store more than two indices in it.
class BRepMesh_PairOfIndex
{
public:
BRepMesh_PairOfIndex()
{ myIndx1 = myIndx2 = -1; }
BRepMesh_PairOfIndex(const BRepMesh_PairOfIndex& theOther)
//! Default constructor
Standard_EXPORT BRepMesh_PairOfIndex()
{
myIndx1 = theOther.myIndx1;
myIndx2 = theOther.myIndx2;
Clear();
}
//! Clear indices
//! Clears indices.
void Clear()
{
myIndx1 = myIndx2 = -1;
myIndex[0] = myIndex[1] = -1;
}
//! append index (store first of last index of pair)
void Append(const Standard_Integer theIndx)
//! Appends index to the pair.
inline void Append(const Standard_Integer theIndex)
{
if ( myIndx1 < 0 )
myIndx1 = theIndx;
if (myIndex[0] < 0)
myIndex[0] = theIndex;
else
{
if ( myIndx2 >= 0 )
Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
myIndx2 = theIndx;
if (myIndex[1] >= 0)
Standard_OutOfRange::Raise("BRepMesh_PairOfIndex::Append, more than two index to store");
myIndex[1] = theIndex;
}
}
//! prepend index (store first index)
void Prepend(const Standard_Integer theIndx)
//! Prepends index to the pair.
inline void Prepend(const Standard_Integer theIndex)
{
if ( myIndx2 >= 0 )
if (myIndex[1] >= 0)
Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
myIndx2 = myIndx1;
myIndx1 = theIndx;
myIndex[1] = myIndex[0];
myIndex[1] = theIndex;
}
//! returns is pair not initialized by index
Standard_Boolean IsEmpty() const
//! Returns is pair is empty.
inline Standard_Boolean IsEmpty() const
{
return (myIndx1 < 0 /*optimisation && myIndx2 < 0*/);
// Check only first index. It is impossible to update
// second index if the first one is empty.
return (myIndex[0] < 0);
}
//! returns numner of initialized indeces
Standard_Integer Extent() const
//! Returns number of initialized indeces.
inline Standard_Integer Extent() const
{
return (myIndx1 < 0 ? 0 : (myIndx2 < 0 ? 1 : 2));
return (myIndex[0] < 0 ? 0 : (myIndex[1] < 0 ? 1 : 2));
}
//! returns first index from pair
Standard_Integer FirstIndex() const
//! Returns first index of pair.
inline Standard_Integer FirstIndex() const
{
return myIndx1;
return myIndex[0];
}
//! returns last index
Standard_Integer LastIndex() const
//! Returns last index of pair
inline Standard_Integer LastIndex() const
{
return (myIndx2 < 0 ? myIndx1 : myIndx2);
return (myIndex[1] < 0 ? myIndex[0] : myIndex[1]);
}
Standard_Integer Index(const Standard_Integer theNum) const
//! Returns index corresponding to the given position in the pair.
//! \param thePairPos position of index in the pair (1 or 2).
inline Standard_Integer Index(const Standard_Integer thePairPos) const
{
return (theNum == 1 ? myIndx1 : myIndx2 /*(theNum == 2 ? myIndx2 : -1 )*/);
if (thePairPos != 1 && thePairPos != 2)
Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Index, requested index is out of range");
return myIndex[thePairPos - 1];
}
void SetIndex(const Standard_Integer theNum,
const Standard_Integer theIndex)
//! Sets index corresponding to the given position in the pair.
//! \param thePairPos position of index in the pair (1 or 2).
//! \param theIndex index to be stored.
inline void SetIndex(const Standard_Integer thePairPos,
const Standard_Integer theIndex)
{
theNum == 1 ? myIndx1 = theIndex : myIndx2 = theIndex;
if (thePairPos != 1 && thePairPos != 2)
Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::SetIndex, requested index is out of range");
myIndex[thePairPos - 1] = theIndex;
}
//! remove indicated
void RemoveIndex (const Standard_Integer theNum)
//! Remove index from the given position.
//! \param thePairPos position of index in the pair (1 or 2).
inline void RemoveIndex(const Standard_Integer thePairPos)
{
if ( theNum == 1 )
myIndx1 = myIndx2;
myIndx2 = -1;
if (thePairPos != 1 && thePairPos != 2)
Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::RemoveIndex, requested index is out of range");
if ( thePairPos == 1 )
myIndex[0] = myIndex[1];
myIndex[1] = -1;
}
//! fields
private:
Standard_Integer myIndx1;
Standard_Integer myIndx2;
Standard_Integer myIndex[2];
};
#endif

View File

@ -1,53 +0,0 @@
-- Created on: 2009-01-26
-- Created by: Pavel TELKOV
-- Copyright (c) 2009-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class PairOfPolygon from BRepMesh
---Purpose:
uses
PolygonOnTriangulation from Poly
is
Create
---Purpose: Create empty pair with null fileds
returns PairOfPolygon from BRepMesh;
Clear(me: out);
---Purpose: Clear pair handles
Prepend (me: out; thePoly: PolygonOnTriangulation from Poly);
--- Initialise first polygon on triangulation
Append (me: out; thePoly: PolygonOnTriangulation from Poly);
--- Initialise first or last polygon on triangulation
First(me)
---Purpose: Returns first polygon on triangulation
---C++: return const &
---C++: inline
returns PolygonOnTriangulation from Poly;
Last(me)
---Purpose: Returns last polygon on triangulation
---C++: return const &
---C++: inline
returns PolygonOnTriangulation from Poly;
fields
myFirst : PolygonOnTriangulation from Poly;
myLast : PolygonOnTriangulation from Poly;
end PairOfPolygon;

View File

@ -1,62 +0,0 @@
// Created on: 2009-01-26
// Created by: Pavel TELKOV
// Copyright (c) 2009-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_PairOfPolygon.ixx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_PairOfPolygon::BRepMesh_PairOfPolygon()
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BRepMesh_PairOfPolygon::Clear()
{
myFirst.Nullify();
myLast.Nullify();
}
//=======================================================================
//function : Prepend
//purpose :
//=======================================================================
void BRepMesh_PairOfPolygon::Prepend
( const Handle(Poly_PolygonOnTriangulation)& theItem )
{
myFirst = theItem;
if (myLast.IsNull())
myLast = theItem;
}
//=======================================================================
//function : Append
//purpose :
//=======================================================================
void BRepMesh_PairOfPolygon::Append
( const Handle(Poly_PolygonOnTriangulation)& theItem )
{
if (myFirst.IsNull())
myFirst = theItem;
myLast = theItem;
}

View File

@ -0,0 +1,82 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_PairOfPolygon_HeaderFile
#define _BRepMesh_PairOfPolygon_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <Handle_Poly_PolygonOnTriangulation.hxx>
class Poly_PolygonOnTriangulation;
class BRepMesh_PairOfPolygon
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor. Creates empty pair with null fileds.
Standard_EXPORT BRepMesh_PairOfPolygon()
{
}
//! Clears pair handles.
inline void Clear()
{
myFirst.Nullify();
myLast.Nullify();
}
//! Sets the first element of the pair.
//! If last element is empty, also assignes the given polygon to it.
//! \param thePolygon plygon to be set.
inline void Prepend(const Handle(Poly_PolygonOnTriangulation)& thePolygon)
{
myFirst = thePolygon;
if (myLast.IsNull())
myLast = thePolygon;
}
//! Sets the last element of the pair.
//! If first element is empty, also assignes the given polygon to it.
//! \param thePolygon plygon to be set.
inline void Append(const Handle(Poly_PolygonOnTriangulation)& thePolygon)
{
if (myFirst.IsNull())
myFirst = thePolygon;
myLast = thePolygon;
}
//! Returns first polygon on triangulation.
inline const Handle_Poly_PolygonOnTriangulation& First() const
{
return myFirst;
}
//! Returns last polygon on triangulation.
inline const Handle_Poly_PolygonOnTriangulation& Last() const
{
return myLast;
}
private:
Handle_Poly_PolygonOnTriangulation myFirst;
Handle_Poly_PolygonOnTriangulation myLast;
};
#endif

View File

@ -1,34 +0,0 @@
// Created on: 2009-01-26
// Created by: Pavel TELKOV
// Copyright (c) 2009-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//=======================================================================
//function : First
//purpose :
//=======================================================================
inline const Handle(Poly_PolygonOnTriangulation)& BRepMesh_PairOfPolygon::First() const
{
return myFirst;
}
//=======================================================================
//function : Last
//purpose :
//=======================================================================
inline const Handle(Poly_PolygonOnTriangulation)& BRepMesh_PairOfPolygon::Last() const
{
return myLast;
}

View File

@ -21,8 +21,8 @@ class BRepMesh_DiscretRoot;
//! Type definition for plugin exported function
typedef Standard_Integer (*BRepMesh_PluginEntryType) (const TopoDS_Shape& theShape,
const Standard_Real theDeflection,
const Standard_Real theAngle,
const Standard_Real theLinDeflection,
const Standard_Real theAngDeflection,
BRepMesh_DiscretRoot*& theMeshAlgoInstance);
#endif //_BRepMesh_PluginEntryType_HeaderFile
#endif

View File

@ -16,20 +16,22 @@
#ifndef BRepMesh_PluginMacro_HeaderFile
#define BRepMesh_PluginMacro_HeaderFile
#define DISCRETPLUGIN(name) \
extern "C" {Standard_EXPORT Standard_Integer DISCRETALGO(const TopoDS_Shape& ,\
const Standard_Real,\
const Standard_Real,\
BRepMesh_PDiscretRoot& );} \
Standard_Integer DISCRETALGO(const TopoDS_Shape& theShape,\
const Standard_Real theDeflection,\
const Standard_Real theAngle,\
BRepMesh_PDiscretRoot& theAlgo) { \
return name::Discret(theShape,\
theDeflection,\
theAngle,\
theAlgo);} \
\
#define DISCRETPLUGIN(name) \
extern "C" { \
Standard_EXPORT Standard_Integer DISCRETALGO(const TopoDS_Shape& , \
const Standard_Real, \
const Standard_Real, \
BRepMesh_PDiscretRoot& ); \
} \
\
Standard_Integer DISCRETALGO(const TopoDS_Shape& theShape, \
const Standard_Real theLinDeflection, \
const Standard_Real theAngDeflection, \
BRepMesh_PDiscretRoot& theAlgo) \
{ \
return name::Discret(theShape, theLinDeflection, \
theAngDeflection, theAlgo); \
} \
\
#endif

View File

@ -1,110 +0,0 @@
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
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;

View File

@ -14,32 +14,43 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_SelectorOfDataStructureOfDelaun.ixx>
#include <BRepMesh_SelectorOfDataStructureOfDelaun.hxx>
#include <BRepMesh_PairOfIndex.hxx>
//=======================================================================
//function : BRepMesh_SelectorOfDataStructureOfDelaun
//function : Default constructor
//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)
: myNodes (10, new NCollection_IncAllocator),
myLinks (10, new NCollection_IncAllocator),
myElements(10, new NCollection_IncAllocator),
myFrontier(10, new NCollection_IncAllocator)
{
myMesh=theMesh;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
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())
{
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(
const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
{
myMesh = theMesh;
myNodes.Clear();
myLinks.Clear();
myElements.Clear();
@ -47,121 +58,97 @@ void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(const Handle(BRepMesh
}
//=======================================================================
//function : NeighboursOfNode
//function : NeighboursOf(Node)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Vertex& theNode)
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
const BRepMesh_Vertex& theNode)
{
NeighboursOfNode(myMesh->IndexOf(theNode));
}
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(const Standard_Integer indexNode)
//=======================================================================
//function : NeighboursOfNode(NodeIndex)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(
const Standard_Integer theNodeIndex)
{
BRepMesh_ListOfInteger::Iterator itL(myMesh->LinkNeighboursOf(indexNode));
BRepMeshCol::ListOfInteger::Iterator aLinkIt(
myMesh->LinksConnectedTo(theNodeIndex));
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));
}
for (; aLinkIt.More(); aLinkIt.Next())
elementsOfLink(aLinkIt.Value());
}
//=======================================================================
//function : NeighboursOfLink
//function : NeighboursOf(Link)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Edge& theLink)
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
const BRepMesh_Edge& theLink)
{
NeighboursOfNode(theLink.FirstNode());
NeighboursOfNode(theLink.LastNode());
}
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(const Standard_Integer indexLink)
//=======================================================================
//function : NeighboursOfLink(LinkIndex)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(
const Standard_Integer theLinkIndex)
{
NeighboursOf(myMesh->GetLink(indexLink));
NeighboursOf(myMesh->GetLink(theLinkIndex));
}
//=======================================================================
//function : NeighboursOfElement
//purpose : by edge and by vertices
//function : NeighboursOf(Element)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Triangle& theElem)
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
const BRepMesh_Triangle& theElement)
{
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);
}
Standard_Integer v[3];
myMesh->ElementNodes(theElement, v);
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(const Standard_Integer indexElem)
{
NeighboursOf(myMesh->GetElement(indexElem));
for (Standard_Integer i = 0; i < 3; ++i)
NeighboursOfNode(v[i]);
}
//=======================================================================
//function : NeighboursByEdgeOf
//purpose : Neighbours Of an element only by edge
//function : NeighboursOfElement(ElementIndex)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(const BRepMesh_Triangle& theElem)
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(
const Standard_Integer theElementIndex)
{
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));
}
NeighboursOf(myMesh->GetElement(theElementIndex));
}
//=======================================================================
//function : NeighboursOfSelector
//function : NeighboursByEdgeOf(Element)
//purpose :
//=======================================================================
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_SelectorOfDataStructureOfDelaun& /*theSelector*/)
{}
void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(
const BRepMesh_Triangle& theElement)
{
Standard_Integer e[3];
Standard_Boolean o[3];
theElement.Edges(e, o);
for (Standard_Integer i = 0; i < 3; ++i)
elementsOfLink(e[i]);
}
//=======================================================================
//function : AddNeighbours
//function : elementsOfLink
//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;}
void BRepMesh_SelectorOfDataStructureOfDelaun::elementsOfLink(
const Standard_Integer theIndex)
{
const BRepMesh_PairOfIndex& aPair = myMesh->ElementsConnectedTo(theIndex);
for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; ++j)
myElements.Add(aPair.Index(j));
}

View File

@ -0,0 +1,114 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_SelectorOfDataStructureOfDelaun_HeaderFile
#define _BRepMesh_SelectorOfDataStructureOfDelaun_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_Collections.hxx>
#include <Standard_Integer.hxx>
#include <BRepMesh_Triangle.hxx>
class BRepMesh_Vertex;
class BRepMesh_Edge;
//! Describes a selector and an iterator on a
//! selector of components of a mesh.
class BRepMesh_SelectorOfDataStructureOfDelaun
{
public:
DEFINE_STANDARD_ALLOC
//! Default constructor.
Standard_EXPORT BRepMesh_SelectorOfDataStructureOfDelaun();
//! Constructor.
//! Initializes selector by the mesh.
Standard_EXPORT BRepMesh_SelectorOfDataStructureOfDelaun(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh);
//! Initializes selector by the mesh.
Standard_EXPORT void Initialize(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh);
//! Selects all neighboring elements of the given node.
Standard_EXPORT void NeighboursOf(const BRepMesh_Vertex& theNode);
//! Selects all neighboring elements of node with the given index.
Standard_EXPORT void NeighboursOfNode(const Standard_Integer theNodeIndex);
//! Selects all neighboring elements of the given link.
Standard_EXPORT void NeighboursOf(const BRepMesh_Edge& theLink);
//! Selects all neighboring elements of link with the given index.
Standard_EXPORT void NeighboursOfLink(const Standard_Integer theLinkIndex);
//! Selects all neighboring elements of the given element.
Standard_EXPORT void NeighboursOf(const BRepMesh_Triangle& theElement);
//! Selects all neighboring elements by nodes of the given element.
Standard_EXPORT void NeighboursOfElement(const Standard_Integer theElementIndex);
//! Selects all neighboring elements by links of the given element.
Standard_EXPORT void NeighboursByEdgeOf(const BRepMesh_Triangle& theElement);
//! Adds a level of neighbours by edge to the selector.
inline void NeighboursOf(const BRepMesh_SelectorOfDataStructureOfDelaun& /*theSelector*/)
{
}
//! Adds a level of neighbours by edge the selector.
inline void AddNeighbours()
{
}
//! Returns selected nodes.
inline const BRepMeshCol::MapOfInteger& Nodes() const
{
return myNodes;
}
//! Returns selected links.
inline const BRepMeshCol::MapOfInteger& Links() const
{
return myLinks;
}
//! Returns selected elements.
inline const BRepMeshCol::MapOfInteger& Elements() const
{
return myElements;
}
//! Gives the list of incices of frontier links.
inline const BRepMeshCol::MapOfInteger& FrontierLinks() const
{
return myFrontier;
}
private:
//! Collects elements connected to link with the given index.
void elementsOfLink(const Standard_Integer theIndex);
private:
Handle(BRepMesh_DataStructureOfDelaun) myMesh;
BRepMeshCol::MapOfInteger myNodes;
BRepMeshCol::MapOfInteger myLinks;
BRepMeshCol::MapOfInteger myElements;
BRepMeshCol::MapOfInteger myFrontier;
};
#endif

View File

@ -1,174 +0,0 @@
-- Created on: 1993-09-30
-- Created by: Isabelle GRIGNON
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class ShapeTool from BRepMesh
---Purpose:
uses Shape from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Vertex from TopoDS,
Explorer from TopExp,
Pnt2d from gp,
Pnt from gp,
Box from Bnd,
Curve from BRepAdaptor,
Orientation from TopAbs,
Triangulation from Poly,
HArray1OfInteger from TColStd
raises NoSuchObject from Standard
is
Create returns ShapeTool ;
Init(me : in out ; S : Shape from TopoDS)
---C++: inline
is static;
MoreFace(me: in out ) returns Boolean from Standard
---C++: inline
is static;
NextFace(me : in out)
---C++: inline
is static;
CurrentFace( me : in out) returns Face from TopoDS
---C++:return const &
---C++: inline
is static;
Init(me : in out ; F: Face from TopoDS)
---C++: inline
is static;
MoreEdge(me: in out ) returns Boolean from Standard
---C++: inline
is static;
NextEdge(me : in out)
---C++: inline
is static;
CurrentEdge(me : in out)
---C++: return const &
---C++: inline
returns Edge from TopoDS
is static;
Init(me : in out ; E : Edge from TopoDS)
---C++: inline
is static;
MoreInternalVertex(me: in out ) returns Boolean from Standard
is static;
NextInternalVertex(me : in out)
---C++: inline
is static;
CurrentInternalVertex( me : in out) returns Vertex from TopoDS
---C++: return const &
---C++: inline
is static;
Orientation(myclass; F :Face from TopoDS )
---C++: inline
returns Orientation from TopAbs;
Orientation(myclass; E : Edge from TopoDS )
---C++: inline
returns Orientation from TopAbs;
Bound(myclass; F :Face from TopoDS )
returns Box from Bnd;
Bound(myclass; E : Edge from TopoDS )
returns Box from Bnd;
FirstVertex(myclass; E : Edge from TopoDS )
returns Vertex from TopoDS
raises NoSuchObject;
--if there is not first vertex (semi-infinite edge)
LastVertex(myclass; E : Edge from TopoDS)
returns Vertex from TopoDS
raises NoSuchObject;
--if there is not last vertex (semi-infinite edge)
Vertices(myclass; E : Edge from TopoDS;
Vfirst, Vlast : out Vertex from TopoDS);
---Purpose: If there is not First or Last vertex (infinite or
-- semi-infinite edge) return null shapes.
Range(myclass; E : Edge from TopoDS;
F : Face from TopoDS;
wFirst, wLast : in out Real from Standard);
---C++: inline
UVPoints(myclass; E : Edge from TopoDS;
F : Face from TopoDS;
uvFirst, uvLast : out Pnt2d from gp);
---C++: inline
Degenerated(myclass; E : Edge from TopoDS)
---C++: inline
returns Boolean from Standard;
Tolerance(myclass; V : Vertex from TopoDS)
---C++: inline
returns Real from Standard;
Parameter(myclass; V : Vertex from TopoDS;
E : Edge from TopoDS;
F : Face from TopoDS) returns Real from Standard;
---C++: inline
Parameters (myclass;
E : Edge from TopoDS;
F : Face from TopoDS;
W : Real;
UV : out Pnt2d);
Locate (myclass;
C : Curve from BRepAdaptor;
W : in Real; WFound : in out Real;
p3d : Pnt from gp;
UV : out Pnt2d);
Pnt(myclass; V : Vertex from TopoDS)
---C++: inline
returns Pnt from gp;
AddInFace(myclass;
F : Face from TopoDS;
T : in out Triangulation from Poly);
fields
theFIterator : Explorer from TopExp;
theEIterator : Explorer from TopExp;
theVIterator : Explorer from TopExp;
end ShapeTool;

View File

@ -12,135 +12,263 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_ShapeTool.ixx>
#include <Geom2d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <Bnd_Box.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepBndLib.hxx>
#include <Extrema_POnCurv.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <TopExp.hxx>
#include <Precision.hxx>
#include <gp_Trsf.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Poly_Triangulation.hxx>
#include <BRep_Builder.hxx>
Standard_Integer debug=0;
namespace {
//! Auxilary struct to take a tolerance of edge.
struct EdgeTolerance
{
static Standard_Real Get(const TopoDS_Shape& theEdge)
{
return BRep_Tool::Tolerance(TopoDS::Edge(theEdge));
}
};
BRepMesh_ShapeTool::BRepMesh_ShapeTool() {}
//! Auxilary struct to take a tolerance of vertex.
struct VertexTolerance
{
static Standard_Real Get(const TopoDS_Shape& theVertex)
{
return BRep_Tool::Tolerance(TopoDS::Vertex(theVertex));
}
};
Standard_Boolean BRepMesh_ShapeTool::MoreInternalVertex()
{
while (theVIterator.More()) {
if (theVIterator.Current().Orientation() == TopAbs_INTERNAL)
return Standard_True;
theVIterator.Next();
//! Returns maximum tolerance of face element of the specified type.
template<TopAbs_ShapeEnum ShapeType, class ToleranceExtractor>
Standard_Real MaxTolerance(const TopoDS_Face& theFace)
{
Standard_Real aMaxTolerance = RealFirst();
TopExp_Explorer aExplorer(theFace, ShapeType);
for (; aExplorer.More(); aExplorer.Next())
{
Standard_Real aTolerance = ToleranceExtractor::Get(aExplorer.Current());
if (aTolerance > aMaxTolerance)
aMaxTolerance = aTolerance;
}
return aMaxTolerance;
}
return Standard_False;
}
TopoDS_Vertex BRepMesh_ShapeTool::FirstVertex(const TopoDS_Edge& E)
//=======================================================================
//function : BoxMaxDimension
//purpose :
//=======================================================================
Standard_Real BRepMesh_ShapeTool::MaxFaceTolerance(const TopoDS_Face& theFace)
{
TopExp_Explorer Ex(E,TopAbs_VERTEX);
while (Ex.More()) {
if (Ex.Current().Orientation() == TopAbs_FORWARD)
return TopoDS::Vertex(Ex.Current());
Ex.Next();
Standard_Real aMaxTolerance = BRep_Tool::Tolerance(theFace);
Standard_Real aTolerance = Max(
MaxTolerance<TopAbs_EDGE, EdgeTolerance >(theFace),
MaxTolerance<TopAbs_VERTEX, VertexTolerance>(theFace));
return Max(aMaxTolerance, aTolerance);
}
//=======================================================================
//function : BoxMaxDimension
//purpose :
//=======================================================================
void BRepMesh_ShapeTool::BoxMaxDimension(const Bnd_Box& theBox,
Standard_Real& theMaxDimension)
{
if(theBox.IsVoid())
return;
Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ;
theBox.Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ);
theMaxDimension = Max(aMaxX - aMinX, Max(aMaxY - aMinY, aMaxZ - aMinZ));
}
//=======================================================================
//function : RelativeEdgeDeflection
//purpose :
//=======================================================================
Standard_Real BRepMesh_ShapeTool::RelativeEdgeDeflection(
const TopoDS_Edge& theEdge,
const Standard_Real theDeflection,
const Standard_Real theMaxShapeSize,
Standard_Real& theAdjustmentCoefficient)
{
theAdjustmentCoefficient = 1.;
Standard_Real aDefEdge = theDeflection;
if(theEdge.IsNull())
return aDefEdge;
Bnd_Box aBox;
BRepBndLib::Add(theEdge, aBox);
BoxMaxDimension(aBox, aDefEdge);
// Adjust resulting value in relation to the total size
theAdjustmentCoefficient = theMaxShapeSize / (2 * aDefEdge);
if (theAdjustmentCoefficient < 0.5)
theAdjustmentCoefficient = 0.5;
else if (theAdjustmentCoefficient > 2.)
theAdjustmentCoefficient = 2.;
return (theAdjustmentCoefficient * aDefEdge * theDeflection);
}
//=======================================================================
//function : FindUV
//purpose :
//=======================================================================
gp_XY BRepMesh_ShapeTool::FindUV(
const Standard_Integer theIndexOfPnt3d,
const gp_Pnt2d& thePnt2d,
const TopoDS_Vertex& theVertex,
const Standard_Real theMinDistance,
const Handle(BRepMesh_FaceAttribute)& theFaceAttribute,
const Handle(BRepAdaptor_HSurface)& theSurface,
BRepMeshCol::DMapOfIntegerListOfXY& theLocation2dMap)
{
const gp_XY& aPnt2d = thePnt2d.Coord();
if (!theLocation2dMap.IsBound(theIndexOfPnt3d))
{
BRepMeshCol::ListOfXY aPoints2d;
aPoints2d.Append(aPnt2d);
theLocation2dMap.Bind(theIndexOfPnt3d, aPoints2d);
return aPnt2d;
}
Standard_NoSuchObject::Raise("non existent first vertex");
return TopoDS_Vertex();
}
TopoDS_Vertex BRepMesh_ShapeTool::LastVertex(const TopoDS_Edge& E)
{
TopExp_Explorer Ex(E,TopAbs_VERTEX);
while (Ex.More()) {
if (Ex.Current().Orientation() == TopAbs_REVERSED)
return TopoDS::Vertex(Ex.Current());
Ex.Next();
}
Standard_NoSuchObject::Raise("non existent last vertex");
return TopoDS_Vertex();
}
BRepMeshCol::ListOfXY& aPoints2d =
theLocation2dMap.ChangeFind(theIndexOfPnt3d);
void BRepMesh_ShapeTool::Vertices(const TopoDS_Edge& E,
TopoDS_Vertex& Vfirst,
TopoDS_Vertex& Vlast)
{
TopExp::Vertices(E, Vfirst, Vlast);
}
// Find the most closest 2d point to the given one.
gp_XY aUV;
Standard_Real aMinDist = RealLast();
BRepMeshCol::ListOfXY::Iterator aPoint2dIt(aPoints2d);
for (; aPoint2dIt.More(); aPoint2dIt.Next())
{
const gp_XY& aCurPnt2d = aPoint2dIt.Value();
Bnd_Box BRepMesh_ShapeTool::Bound(const TopoDS_Face& F)
{
Bnd_Box Bf;
BRepBndLib::Add(F, Bf);
return Bf;
}
Bnd_Box BRepMesh_ShapeTool::Bound(const TopoDS_Edge& E)
{
Bnd_Box Be;
BRepBndLib::Add(E, Be);
return Be;
}
void BRepMesh_ShapeTool::Parameters(const TopoDS_Edge& E,
const TopoDS_Face& F,
const Standard_Real W,
gp_Pnt2d& UV)
{
Standard_Real a,b;
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,a,b);
C->D0(W,UV);
}
void BRepMesh_ShapeTool::Locate(const BRepAdaptor_Curve& C,
const Standard_Real W,
Standard_Real& wFound,
const gp_Pnt& p3d,
gp_Pnt2d& UV)
{
gp_Pnt plocal(p3d.Transformed(C.Trsf().Inverted()));
Extrema_LocateExtPC
pcos(plocal, C.CurveOnSurface(), W, Precision::PConfusion());
if (pcos.IsDone()) {
wFound=pcos.Point().Parameter();
C.CurveOnSurface().GetCurve()->D0(wFound, UV);
if (debug!=0) {
if (pcos.SquareDistance()>(4.* C.Tolerance()* C.Tolerance())) {
cout << " ShapeTool :LocateExtPCOnS Done but (Distance "<<
sqrt(pcos.SquareDistance()) << ")(Tolerance "<<C.Tolerance()<<")" << endl;
cout << " W given : "<< W<< " W calculated : "<<
wFound << endl;
}
else if (debug>1) {
cout << " ShapeTool : LocateExtPCOnS OK ! "<<endl;
cout << " W given : "<< W<< " W calculated : "<<
wFound << endl;
}
Standard_Real aDist = (aPnt2d - aCurPnt2d).Modulus();
if (aDist < aMinDist)
{
aUV = aCurPnt2d;
aMinDist = aDist;
}
}
else {
wFound=W;
if (debug!=0)
cout << " ShapeTool : LocateExtPCOnS Not Done ! " << endl;
C.CurveOnSurface().GetCurve()->D0(W, UV);
const Standard_Real aTolerance =
Min(2. * BRep_Tool::Tolerance(theVertex), theMinDistance);
// Get face limits
Standard_Real aDiffU, aDiffV;
if (theFaceAttribute.IsNull())
{
aDiffU = theSurface->LastUParameter() - theSurface->FirstUParameter();
aDiffV = theSurface->LastVParameter() - theSurface->FirstVParameter();
}
else
{
aDiffU = theFaceAttribute->GetUMax() - theFaceAttribute->GetUMin();
aDiffV = theFaceAttribute->GetVMax() - theFaceAttribute->GetVMin();
}
const Standard_Real Utol2d = .5 * aDiffU;
const Standard_Real Vtol2d = .5 * aDiffV;
const gp_Pnt aPnt1 = theSurface->Value( aUV.X(), aUV.Y());
const gp_Pnt aPnt2 = theSurface->Value(aPnt2d.X(), aPnt2d.Y());
//! If selected point is too far from the given one in parametric space
//! or their positions in 3d are different, add the given point as unique.
if (Abs(aUV.X() - aPnt2d.X()) > Utol2d ||
Abs(aUV.Y() - aPnt2d.Y()) > Vtol2d ||
!aPnt1.IsEqual(aPnt2, aTolerance))
{
aUV = aPnt2d;
aPoints2d.Append(aUV);
}
return aUV;
}
void BRepMesh_ShapeTool::AddInFace(const TopoDS_Face& F,
Handle(Poly_Triangulation)& T)
//=======================================================================
//function : AddInFace
//purpose :
//=======================================================================
void BRepMesh_ShapeTool::AddInFace(
const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTriangulation)
{
static BRep_Builder B1;
TColgp_Array1OfPnt& Nodes = T->ChangeNodes();
gp_Trsf tr = F.Location().Transformation();
tr.Invert();
for (Standard_Integer i = Nodes.Lower(); i <= Nodes.Upper(); i++)
Nodes(i).Transform(tr);
B1.UpdateFace(F, T);
const TopLoc_Location& aLoc = theFace.Location();
if (!aLoc.IsIdentity())
{
gp_Trsf aTrsf = aLoc.Transformation();
aTrsf.Invert();
TColgp_Array1OfPnt& aNodes = theTriangulation->ChangeNodes();
for (Standard_Integer i = aNodes.Lower(); i <= aNodes.Upper(); ++i)
aNodes(i).Transform(aTrsf);
}
BRep_Builder aBuilder;
aBuilder.UpdateFace(theFace, theTriangulation);
}
//=======================================================================
//function : NullifyFace
//purpose :
//=======================================================================
void BRepMesh_ShapeTool::NullifyFace(const TopoDS_Face& theFace)
{
BRep_Builder aBuilder;
aBuilder.UpdateFace(theFace, Handle(Poly_Triangulation)());
}
//=======================================================================
//function : NullifyEdge
//purpose :
//=======================================================================
void BRepMesh_ShapeTool::NullifyEdge(
const TopoDS_Edge& theEdge,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLocation)
{
UpdateEdge(theEdge, Handle(Poly_PolygonOnTriangulation)(),
theTriangulation, theLocation);
}
//=======================================================================
//function : UpdateEdge
//purpose :
//=======================================================================
void BRepMesh_ShapeTool::UpdateEdge(
const TopoDS_Edge& theEdge,
const Handle(Poly_PolygonOnTriangulation)& thePolygon,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLocation)
{
BRep_Builder aBuilder;
aBuilder.UpdateEdge(theEdge, thePolygon, theTriangulation, theLocation);
}
//=======================================================================
//function : UpdateEdge
//purpose :
//=======================================================================
void BRepMesh_ShapeTool::UpdateEdge(
const TopoDS_Edge& theEdge,
const Handle(Poly_PolygonOnTriangulation)& thePolygon1,
const Handle(Poly_PolygonOnTriangulation)& thePolygon2,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLocation)
{
BRep_Builder aBuilder;
aBuilder.UpdateEdge(theEdge, thePolygon1, thePolygon2,
theTriangulation, theLocation);
}

View File

@ -0,0 +1,142 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_ShapeTool_HeaderFile
#define _BRepMesh_ShapeTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <Handle_BRepAdaptor_HSurface.hxx>
#include <BRepMesh_FaceAttribute.hxx>
#include <BRepMesh_Collections.hxx>
#include <Handle_Poly_Triangulation.hxx>
class TopoDS_Face;
class TopoDS_Edge;
class Bnd_Box;
class TopoDS_Vertex;
class gp_XY;
class gp_Pnt2d;
class BRepMesh_ShapeTool
{
public:
DEFINE_STANDARD_ALLOC
//! Returns maximum tolerance of the given face.
//! Considers tolerances of edges and vertices contained in the given face.
Standard_EXPORT static Standard_Real MaxFaceTolerance(
const TopoDS_Face& theFace);
//! Gets the maximum dimension of the given bounding box.
//! If the given bounding box is void leaves the resulting value unchanged.
//! \param theBox bounding box to be processed.
//! \param theMaxDimension maximum dimension of the given box.
Standard_EXPORT static void BoxMaxDimension(const Bnd_Box& theBox,
Standard_Real& theMaxDimension);
//! Returns relative deflection for edge with respect to shape size.
//! \param theEdge edge for which relative deflection should be computed.
//! \param theDeflection absolute deflection.
//! \param theMaxShapeSize maximum size of a shape.
//! \param theAdjustmentCoefficient coefficient of adjustment between maximum
//! size of shape and calculated relative deflection.
//! \return relative deflection for the edge.
Standard_EXPORT static Standard_Real RelativeEdgeDeflection(
const TopoDS_Edge& theEdge,
const Standard_Real theDeflection,
const Standard_Real theMaxShapeSize,
Standard_Real& theAdjustmentCoefficient);
//! Checks 2d representations of 3d point with the
//! given index for equality to avoid duplications.
//! \param theIndexOfPnt3d index of 3d point with which 2d
//! representation should be associated.
//! \param thePnt2d 2d representation of the point with the
//! given index.
//! \param theVertex vertex corresponded to 3d point with the
//! given index. Used to extract vertex tolerance in 3d space.
//! \param theMinDistance minimum distance between vertices
//! regarding which they could be treated as distinct ones.
//! This value is defined by mesher using parameters given by
//! user in connection with shape metrics.
//! \param theFaceAttribute attributes contining data calculated
//! according to face geomtry and define limits of face in parametric
//! space. If defined, will be used instead of surface parameter.
//! \param theSurface surface within which parametric space
//! the 2d point is defined. Supposed to be used in case if face
//! attributes are not defined by the moment of method invocation.
//! \param theLocation2dMap map of 2d representations of 3d points.
//! \return given 2d point in case if 3d poind does not alredy have
//! the similar representation, otherwice 2d point corresponding to
//! existing representation will be returned.
Standard_EXPORT static gp_XY FindUV(
const Standard_Integer theIndexOfPnt3d,
const gp_Pnt2d& thePnt2d,
const TopoDS_Vertex& theVertex,
const Standard_Real theMinDistance,
const Handle(BRepMesh_FaceAttribute)& theFaceAttribute,
const Handle(BRepAdaptor_HSurface)& theSurface,
BRepMeshCol::DMapOfIntegerListOfXY& theLocation2dMap);
//! Stores the given triangulation into the given face.
//! \param theFace face to be updated by triangulation.
//! \param theTriangulation triangulation to be stored into the face.
Standard_EXPORT static void AddInFace(
const TopoDS_Face& theFace,
Handle(Poly_Triangulation)& theTriangulation);
//! Nullifies triangulation stored in the face.
//! \param theFace face to be updated by null triangulation.
Standard_EXPORT static void NullifyFace(const TopoDS_Face& theFace);
//! Nullifies polygon on triangulation stored in the edge.
//! \param theEdge edge to be updated by null polygon.
//! \param theTriangulation triangulation the given edge is associated to.
//! \param theLocation face location.
Standard_EXPORT static void NullifyEdge(
const TopoDS_Edge& theEdge,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLocation);
//! Updates the given edge by the given tessellated representation.
//! \param theEdge edge to be updated.
//! \param thePolygon tessellated representation of the edge to be stored.
//! \param theTriangulation triangulation the given edge is associated to.
//! \param theLocation face location.
Standard_EXPORT static void UpdateEdge(
const TopoDS_Edge& theEdge,
const Handle(Poly_PolygonOnTriangulation)& thePolygon,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLocation);
//! Updates the given seam edge by the given tessellated representations.
//! \param theEdge edge to be updated.
//! \param thePolygon1 tessellated representation corresponding to
//! forward direction of the seam edge.
//! \param thePolygon2 tessellated representation corresponding to
//! reversed direction of the seam edge.
//! \param theTriangulation triangulation the given edge is associated to.
//! \param theLocation face location.
Standard_EXPORT static void UpdateEdge(
const TopoDS_Edge& theEdge,
const Handle(Poly_PolygonOnTriangulation)& thePolygon1,
const Handle(Poly_PolygonOnTriangulation)& thePolygon2,
const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLocation);
};
#endif

View File

@ -1,131 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
inline void BRepMesh_ShapeTool::Init(const TopoDS_Shape& S)
{
theFIterator.Init(S, TopAbs_FACE);
}
inline Standard_Boolean BRepMesh_ShapeTool::MoreFace()
{
return theFIterator.More();
}
inline void BRepMesh_ShapeTool::NextFace()
{
theFIterator.Next();
}
inline const TopoDS_Face& BRepMesh_ShapeTool:: CurrentFace()
{
return TopoDS::Face(theFIterator.Current());
}
inline void BRepMesh_ShapeTool::Init(const TopoDS_Face& F)
{
theEIterator.Init(F,TopAbs_EDGE);
}
inline Standard_Boolean BRepMesh_ShapeTool::MoreEdge()
{
return theEIterator.More();
}
inline void BRepMesh_ShapeTool::NextEdge()
{
theEIterator.Next();
}
inline const TopoDS_Edge& BRepMesh_ShapeTool::CurrentEdge()
{
return TopoDS::Edge(theEIterator.Current());
}
inline void BRepMesh_ShapeTool::Init(const TopoDS_Edge& E)
{
theVIterator.Init(E,TopAbs_VERTEX);
}
inline void BRepMesh_ShapeTool::NextInternalVertex()
{
theVIterator.Next();
}
inline const TopoDS_Vertex& BRepMesh_ShapeTool::CurrentInternalVertex()
{
return TopoDS::Vertex(theVIterator.Current());
}
inline TopAbs_Orientation BRepMesh_ShapeTool::Orientation(
const TopoDS_Edge& E)
{
return E.Orientation();
}
inline TopAbs_Orientation BRepMesh_ShapeTool::Orientation(
const TopoDS_Face& F)
{
return F.Orientation();
}
inline void BRepMesh_ShapeTool::Range(const TopoDS_Edge& E,
const TopoDS_Face& F,
Standard_Real& wFirst,
Standard_Real& wLast)
{
BRep_Tool::Range(E, F, wFirst, wLast);
}
inline void BRepMesh_ShapeTool::UVPoints(const TopoDS_Edge& E,
const TopoDS_Face& F,
gp_Pnt2d& uvFirst,
gp_Pnt2d& uvLast)
{
BRep_Tool::UVPoints(E, F, uvFirst, uvLast);
}
inline Standard_Boolean BRepMesh_ShapeTool::Degenerated(const TopoDS_Edge& E)
{
return BRep_Tool::Degenerated(E);
}
inline Standard_Real BRepMesh_ShapeTool::Tolerance(const TopoDS_Vertex& V)
{
return BRep_Tool::Tolerance(V);
}
inline Standard_Real BRepMesh_ShapeTool::Parameter(const TopoDS_Vertex& V,
const TopoDS_Edge& E,
const TopoDS_Face& F)
{
return BRep_Tool::Parameter(V,E,F);
}
inline gp_Pnt BRepMesh_ShapeTool::Pnt(const TopoDS_Vertex& V)
{
return BRep_Tool::Pnt(V);
}

View File

@ -1,144 +0,0 @@
// Created on: 1993-09-23
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_Triangle.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_Triangle::BRepMesh_Triangle()
: myEdge1(0),
myEdge2(0),
myEdge3(0),
myOrientation1(Standard_False),
myOrientation2(Standard_False),
myOrientation3(Standard_False),
myMovability(BRepMesh_Free)
{
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_Triangle::BRepMesh_Triangle (const Standard_Integer theEdge1,
const Standard_Integer theEdge2,
const Standard_Integer theEdge3,
const Standard_Boolean theOrientation1,
const Standard_Boolean theOrientation2,
const Standard_Boolean theOrientation3,
const BRepMesh_DegreeOfFreedom isCanMove)
: myEdge1(theEdge1),
myEdge2(theEdge2),
myEdge3(theEdge3),
myOrientation1(theOrientation1),
myOrientation2(theOrientation2),
myOrientation3(theOrientation3),
myMovability(isCanMove)
{
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepMesh_Triangle::Initialize(const Standard_Integer theEdge1,
const Standard_Integer theEdge2,
const Standard_Integer theEdge3,
const Standard_Boolean theOrientation1,
const Standard_Boolean theOrientation2,
const Standard_Boolean theOrientation3,
const BRepMesh_DegreeOfFreedom isCanMove)
{
myEdge1 = theEdge1;
myEdge2 = theEdge2;
myEdge3 = theEdge3;
myOrientation1 = theOrientation1;
myOrientation2 = theOrientation2;
myOrientation3 = theOrientation3;
myMovability = isCanMove;
}
//=======================================================================
//function : Edges
//purpose :
//=======================================================================
void BRepMesh_Triangle::Edges(Standard_Integer& theEdge1,
Standard_Integer& theEdge2,
Standard_Integer& theEdge3,
Standard_Boolean& theOrientation1,
Standard_Boolean& theOrientation2,
Standard_Boolean& theOrientation3) const
{
theEdge1 = myEdge1;
theEdge2 = myEdge2;
theEdge3 = myEdge3;
theOrientation1 = myOrientation1;
theOrientation2 = myOrientation2;
theOrientation3 = myOrientation3;
}
//=======================================================================
//function : SetMovability
//purpose :
//=======================================================================
void BRepMesh_Triangle::SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
{
myMovability = theMovability;
}
//=======================================================================
//function : HashCode
//purpose :
//=======================================================================
Standard_Integer BRepMesh_Triangle::HashCode(const Standard_Integer theUpper)const
{
return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper);
}
//=======================================================================
//function : IsEqual
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_Triangle::IsEqual(const BRepMesh_Triangle& theOther) const
{
if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
return Standard_False;
if (myEdge1 == theOther.myEdge1 &&
myEdge2 == theOther.myEdge2 &&
myEdge3 == theOther.myEdge3)
{
return Standard_True;
}
if (myEdge1 == theOther.myEdge2 &&
myEdge2 == theOther.myEdge3 &&
myEdge3 == theOther.myEdge1)
{
return Standard_True;
}
if (myEdge1 == theOther.myEdge3 &&
myEdge2 == theOther.myEdge1 &&
myEdge3 == theOther.myEdge2)
{
return Standard_True;
}
return Standard_False;
}

View File

@ -23,49 +23,125 @@
#include <BRepMesh_DegreeOfFreedom.hxx>
class BRepMesh_Triangle {
//! Light weighted structure representing triangle
//! of mesh consisting of oriented links.
class BRepMesh_Triangle
{
public:
DEFINE_STANDARD_ALLOC
//! Default constructor.
Standard_EXPORT BRepMesh_Triangle()
: myEdge1(0),
myEdge2(0),
myEdge3(0),
myOrientation1(Standard_False),
myOrientation2(Standard_False),
myOrientation3(Standard_False),
myMovability (BRepMesh_Free)
{
}
//! Constructor.
//! \param theEdges array of edges of triangle.
//! \param theOrientations array of edge's orientations.
//! \param theMovability movability of triangle.
Standard_EXPORT BRepMesh_Triangle(
const Standard_Integer (&theEdges)[3],
const Standard_Boolean (&theOrientations)[3],
const BRepMesh_DegreeOfFreedom theMovability)
{
Initialize(theEdges, theOrientations, theMovability);
}
Standard_EXPORT BRepMesh_Triangle();
//! Initializes the triangle by the given parameters.
//! \param theEdges array of edges of triangle.
//! \param theOrientations array of edge's orientations.
//! \param theMovability movability of triangle.
inline void Initialize(
const Standard_Integer (&theEdges)[3],
const Standard_Boolean (&theOrientations)[3],
const BRepMesh_DegreeOfFreedom theMovability)
{
myEdge1 = theEdges[0];
myEdge2 = theEdges[1];
myEdge3 = theEdges[2];
myOrientation1 = theOrientations[0];
myOrientation2 = theOrientations[1];
myOrientation3 = theOrientations[2];
myMovability = theMovability;
}
Standard_EXPORT BRepMesh_Triangle(const Standard_Integer theEdge1,
const Standard_Integer theEdge2,
const Standard_Integer theEdge3,
const Standard_Boolean theOrientation1,
const Standard_Boolean theOrientation2,
const Standard_Boolean theOrientation3,
const BRepMesh_DegreeOfFreedom isCanMove);
Standard_EXPORT void Initialize(const Standard_Integer theEdge1,
const Standard_Integer theEdge2,
const Standard_Integer theEdge3,
const Standard_Boolean theOrientation1,
const Standard_Boolean theOrientation2,
const Standard_Boolean theOrientation3,
const BRepMesh_DegreeOfFreedom isCanMove) ;
Standard_EXPORT void Edges(Standard_Integer& theEdge1,
Standard_Integer& theEdge2,
Standard_Integer& theEdge3,
Standard_Boolean& theOrientation1,
Standard_Boolean& theOrientation2,
Standard_Boolean& theOrientation3) const;
//! Gets edges with orientations composing the triangle.
//! \param[out] theEdges array edges are stored to.
//! \param[out] theOrientations array orientations are stored to.
inline void Edges(Standard_Integer (&theEdges)[3],
Standard_Boolean (&theOrientations)[3]) const
{
theEdges[0] = myEdge1;
theEdges[1] = myEdge2;
theEdges[2] = myEdge3;
theOrientations[0] = myOrientation1;
theOrientations[1] = myOrientation2;
theOrientations[2] = myOrientation3;
}
//! Returns movability of the triangle.
inline BRepMesh_DegreeOfFreedom Movability() const
{
return myMovability;
}
Standard_EXPORT void SetMovability(const BRepMesh_DegreeOfFreedom theMovability) ;
//! Sets movability of the triangle.
inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
{
myMovability = theMovability;
}
Standard_EXPORT Standard_Integer HashCode(const Standard_Integer theUpper) const;
//! Returns hash code for this triangle.
//! \param theUpper upper index in the container.
//! \return hash code.
Standard_EXPORT Standard_Integer HashCode(const Standard_Integer theUpper) const
{
return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper);
}
Standard_EXPORT Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const;
//! Checks for equality with another triangle.
//! \param theOther triangle to be checked against this one.
//! \return TRUE if equal, FALSE if not.
Standard_EXPORT Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const
{
if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
return Standard_False;
if (myEdge1 == theOther.myEdge1 &&
myEdge2 == theOther.myEdge2 &&
myEdge3 == theOther.myEdge3)
{
return Standard_True;
}
if (myEdge1 == theOther.myEdge2 &&
myEdge2 == theOther.myEdge3 &&
myEdge3 == theOther.myEdge1)
{
return Standard_True;
}
if (myEdge1 == theOther.myEdge3 &&
myEdge2 == theOther.myEdge1 &&
myEdge3 == theOther.myEdge2)
{
return Standard_True;
}
return Standard_False;
}
Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const
//! Alias for IsEqual.
Standard_EXPORT Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const
{
return IsEqual(theOther);
}
@ -81,9 +157,8 @@ private:
BRepMesh_DegreeOfFreedom myMovability;
};
// Inline functions
inline Standard_Integer HashCode(const BRepMesh_Triangle& theTriangle,
const Standard_Integer theUpper)
const Standard_Integer theUpper)
{
return theTriangle.HashCode(theUpper);
}

View File

@ -1,24 +0,0 @@
// Created on: 2011-06-01
// Created by: Oleg AGASHIN
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_VectorOfVertex_HeaderFile
#define _BRepMesh_VectorOfVertex_HeaderFile
#include <BRepMesh_Vertex.hxx>
#include <NCollection_Vector.hxx>
typedef NCollection_Vector<BRepMesh_Vertex> BRepMesh_VectorOfVertex;
#endif

View File

@ -1,89 +0,0 @@
-- Created on: 1993-09-22
-- Created by: Didier PIFFAULT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Vertex from BRepMesh
---Purpose:
uses Boolean from Standard,
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;

View File

@ -1,66 +0,0 @@
// Created on: 1993-09-23
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_Vertex.ixx>
#include <Precision.hxx>
BRepMesh_Vertex::BRepMesh_Vertex()
: myLocation(0), myMovability(BRepMesh_Free)
{}
BRepMesh_Vertex::BRepMesh_Vertex(const gp_XY& UV,
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 BRepMesh_DegreeOfFreedom Move)
: myUV(U, V), myLocation(0), myMovability(Move)
{}
void BRepMesh_Vertex::Initialize(const gp_XY& UV,
const Standard_Integer Locat3d,
const BRepMesh_DegreeOfFreedom Move)
{
myUV=UV;
myLocation=Locat3d;
myMovability=Move;
}
void BRepMesh_Vertex::SetMovability(const BRepMesh_DegreeOfFreedom Move)
{
myMovability=Move;
}
//=======================================================================
//function : HashCode IsEqual
//purpose : Services for Map
//=======================================================================
Standard_Integer BRepMesh_Vertex::HashCode(const Standard_Integer Upper)const
{
return ::HashCode (Floor(1e5*myUV.X())*Floor(1e5*myUV.Y()), Upper);
}
Standard_Boolean BRepMesh_Vertex::IsEqual(const BRepMesh_Vertex& Other)const
{
if (myMovability!=BRepMesh_Deleted && Other.myMovability!=BRepMesh_Deleted)
return (myUV.IsEqual(Other.myUV, Precision::PConfusion()));
return Standard_False;
}

View File

@ -0,0 +1,140 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_Vertex_HeaderFile
#define _BRepMesh_Vertex_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <gp_XY.hxx>
#include <BRepMesh_DegreeOfFreedom.hxx>
//! Light weighted structure representing vertex
//! of the mesh in parametric space. Vertex could be
//! associated with 3d point stored in external map.
class BRepMesh_Vertex
{
public:
DEFINE_STANDARD_ALLOC
//! Default constructor
Standard_EXPORT BRepMesh_Vertex()
: myLocation3d(0),
myMovability(BRepMesh_Free)
{
}
//! Creates vertex associated with point in 3d space.
//! \param theUV position of vertex in parametric space.
//! \param theLocation3d index of 3d point to be associated with vertex.
//! \param theMovability movability of the vertex.
Standard_EXPORT BRepMesh_Vertex(const gp_XY& theUV,
const Standard_Integer theLocation3d,
const BRepMesh_DegreeOfFreedom theMovability)
{
Initialize(theUV, theLocation3d, theMovability);
}
//! Creates vertex without association with point in 3d space.
//! \param theU U position of vertex in parametric space.
//! \param theV V position of vertex in parametric space.
//! \param theMovability movability of the vertex.
Standard_EXPORT BRepMesh_Vertex(const Standard_Real theU,
const Standard_Real theV,
const BRepMesh_DegreeOfFreedom theMovability)
: myUV(theU, theV),
myLocation3d(0),
myMovability(theMovability)
{}
//! Initializes vertex associated with point in 3d space.
//! \param theUV position of vertex in parametric space.
//! \param theLocation3d index of 3d point to be associated with vertex.
//! \param theMovability movability of the vertex.
inline void Initialize(const gp_XY& theUV,
const Standard_Integer theLocation3d,
const BRepMesh_DegreeOfFreedom theMovability)
{
myUV = theUV;
myLocation3d = theLocation3d;
myMovability = theMovability;
}
//! Returns position of the vertex in parametric space.
inline const gp_XY& Coord() const
{
return myUV;
}
//! Returns index of 3d point associated with the vertex.
inline Standard_Integer Location3d() const
{
return myLocation3d;
}
//! Returns movability of the vertex.
inline BRepMesh_DegreeOfFreedom Movability() const
{
return myMovability;
}
//! Sets movability of the vertex.
inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
{
myMovability = theMovability;
}
//! Returns hash code for this vertex.
//! \param theUpper upper index in the container.
//! \return hash code.
Standard_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const
{
return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), Upper);
}
//! Checks for equality with another vertex.
//! \param theOther vertex to be checked against this one.
//! \return TRUE if equal, FALSE if not.
Standard_EXPORT Standard_Boolean IsEqual(const BRepMesh_Vertex& theOther) const
{
if (myMovability != BRepMesh_Deleted ||
theOther.myMovability != BRepMesh_Deleted)
{
return Standard_False;
}
return (myUV.IsEqual(theOther.myUV, Precision::PConfusion()));
}
//! Alias for IsEqual.
Standard_EXPORT Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const
{
return IsEqual(Other);
}
private:
gp_XY myUV;
Standard_Integer myLocation3d;
BRepMesh_DegreeOfFreedom myMovability;
};
inline Standard_Integer HashCode(const BRepMesh_Vertex& me, const Standard_Integer Upper)
{
return me.HashCode(Upper);
}
#endif

View File

@ -1,30 +0,0 @@
// Created on: 1993-09-23
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
inline const gp_XY& BRepMesh_Vertex::Coord()const
{
return myUV;
}
inline Standard_Integer BRepMesh_Vertex::Location3d()const
{
return myLocation;
}
inline BRepMesh_DegreeOfFreedom BRepMesh_Vertex::Movability()const
{
return myMovability;
}

View File

@ -1,26 +0,0 @@
// Created on: 2011-06-02
// Created by: Oleg AGASHIN
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_VertexCellFilter_HeaderFile
#define _BRepMesh_VertexCellFilter_HeaderFile
#include <gp_XYZ.hxx>
#include <gp_XY.hxx>
#include <NCollection_CellFilter.hxx>
#include <BRepMesh_VertexInspector.hxx>
typedef NCollection_CellFilter<BRepMesh_VertexInspector> BRepMesh_VertexCellFilter;
#endif

View File

@ -1,111 +0,0 @@
// Created on: 2011-06-01
// Created by: Oleg AGASHIN
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_XY.hxx>
#include <Precision.hxx>
#include <BRepMesh_VertexInspector.hxx>
#include <BRepMesh_Vertex.hxx>
//=======================================================================
//function : BRepMesh_VertexInspector
//purpose : Constructor
//=======================================================================
BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
const BRepMesh_BaseAllocator& theAlloc)
: myTol(0,1),
myResInd(theAlloc),
myVertices(nbComp),
myDelNodes(theAlloc)
{
SetTolerance( Precision::Confusion() );
}
BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
const Standard_Real aTol,
const BRepMesh_BaseAllocator& theAlloc)
: myTol(0,1),
myResInd(theAlloc),
myVertices(nbComp),
myDelNodes(theAlloc)
{
SetTolerance( aTol );
}
BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
const Standard_Real aTolX,
const Standard_Real aTolY,
const BRepMesh_BaseAllocator& theAlloc)
: myTol(0,1),
myResInd(theAlloc),
myVertices(nbComp),
myDelNodes(theAlloc)
{
SetTolerance( aTolX, aTolY );
}
//=======================================================================
//function : Inspect
//purpose :
//
//=======================================================================
NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect (const Standard_Integer theTarget)
{
const BRepMesh_Vertex& aVertex = myVertices(theTarget-1);
if( aVertex.Movability() == BRepMesh_Deleted )
{
myDelNodes.Append(theTarget);
return CellFilter_Purge;
}
const gp_XY& aPos = aVertex.Coord();
Standard_Real dx,dy;
dx = myCurrent.X() - aPos.X();
dy = myCurrent.Y() - aPos.Y();
Standard_Boolean inTol;
if ( myTol(1) == 0. )
{
inTol = (dx*dx + dy*dy) <= myTol(0);
}
else
{
inTol = ( (dx*dx) <= myTol(0) ) &&
( (dy*dy) <= myTol(1) );
}
if ( inTol )
myResInd.Append(theTarget);
return CellFilter_Keep;
}
//=======================================================================
//function : Add
//purpose :
//
//=======================================================================
Standard_Integer BRepMesh_VertexInspector::Add(const BRepMesh_Vertex& theVertex)
{
if( myDelNodes.IsEmpty() )
{
myVertices.Append(theVertex);
return myVertices.Length();
}
Standard_Integer aNodeIndex = myDelNodes.First();
myVertices(aNodeIndex-1) = theVertex;
myDelNodes.RemoveFirst();
return aNodeIndex;
}

View File

@ -16,111 +16,138 @@
#ifndef _BRepMesh_VertexInspector_HeaderFile
#define _BRepMesh_VertexInspector_HeaderFile
#include <BRepMesh_ListOfInteger.hxx>
#include <Precision.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <BRepMesh_Collections.hxx>
#include <NCollection_CellFilter.hxx>
#include <BRepMesh_Vertex.hxx>
#include <BRepMesh_VectorOfVertex.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <BRepMesh_BaseAllocator.hxx>
//=======================================================================
//! The class to find in the coincidence points
//=======================================================================
//! Class intended for fast searching of the coincidence points.
class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
{
public:
typedef Standard_Integer Target;
//! Constructor; remembers tolerance and collector data structure.
//! theTol can be Real or Array1OfReal with two elements which describe
//! tolerance for each dimension.
BRepMesh_VertexInspector (const Standard_Integer nbComp,
const BRepMesh_BaseAllocator& theAlloc);
BRepMesh_VertexInspector (const Standard_Integer nbComp,
const Standard_Real theTol,
const BRepMesh_BaseAllocator& theAlloc);
BRepMesh_VertexInspector (const Standard_Integer nbComp,
const Standard_Real aTolX,
const Standard_Real aTolY,
const BRepMesh_BaseAllocator& theAlloc);
Standard_Integer Add(const BRepMesh_Vertex& theVertex);
void SetTolerance(const Standard_Real theTol)
//! Constructor.
//! \param theReservedSize size to be reserved for vector of vertices.
//! \param theAllocator memory allocator to be used by internal collections.
Standard_EXPORT BRepMesh_VertexInspector (
const Standard_Integer theReservedSize,
const BRepMeshCol::Allocator& theAllocator)
: myResIndices(theAllocator),
myVertices (theReservedSize),
myDelNodes (theAllocator)
{
myTol(0) = theTol*theTol;
myTol(1) = 0.;
SetTolerance( Precision::Confusion() );
}
//! Registers the given vertex.
//! \param theVertex vertex to be registered.
Standard_EXPORT Standard_Integer Add(const BRepMesh_Vertex& theVertex)
{
if( myDelNodes.IsEmpty() )
{
myVertices.Append(theVertex);
return myVertices.Length();
}
Standard_Integer aNodeIndex = myDelNodes.First();
myVertices(aNodeIndex - 1) = theVertex;
myDelNodes.RemoveFirst();
return aNodeIndex;
}
void SetTolerance(const Standard_Real theTolX, const Standard_Real theTolY)
//! Sets the tolerance to be used for identification of
//! coincident vertices equal for both dimensions.
inline void SetTolerance(const Standard_Real theTolerance)
{
myTol(0) = theTolX*theTolX;
myTol(1) = theTolY*theTolY;
myTolerance[0] = theTolerance * theTolerance;
myTolerance[1] = 0.;
}
void Clear()
//! Sets the tolerance to be used for identification of
//! coincident vertices.
//! \param theToleranceX tolerance for X dimension.
//! \param theToleranceY tolerance for Y dimension.
inline void SetTolerance(const Standard_Real theToleranceX,
const Standard_Real theToleranceY)
{
myTolerance[0] = theToleranceX * theToleranceX;
myTolerance[1] = theToleranceY * theToleranceY;
}
//! Clear inspector's internal data structures.
inline void Clear()
{
myVertices.Clear();
myDelNodes.Clear();
}
void Delete(const Standard_Integer theIndex)
//! Deletes vertex with the given index.
//! \param theIndex index of vertex to be removed.
inline void Delete(const Standard_Integer theIndex)
{
myVertices(theIndex-1).SetMovability(BRepMesh_Deleted);
myVertices(theIndex - 1).SetMovability(BRepMesh_Deleted);
myDelNodes.Append(theIndex);
}
Standard_Integer GetNbVertices() const
//! Returns number of registered vertices.
inline Standard_Integer NbVertices() const
{
return myVertices.Length();
}
BRepMesh_Vertex& GetVertex(Standard_Integer theInd)
//! Returns vertex with the given index.
inline BRepMesh_Vertex& GetVertex(Standard_Integer theIndex)
{
return myVertices(theInd-1);
return myVertices(theIndex - 1);
}
//! Set current node to be checked
void SetCurrent (const gp_XY& theCurVertex, const Standard_Boolean)
//! Set reference point to be checked.
inline void SetPoint(const gp_XY& thePoint)
{
myResInd.Clear();
myCurrent = theCurVertex;
myResIndices.Clear();
myPoint = thePoint;
}
//!Get result index of node
const Standard_Integer GetCoincidentInd() const
//! Returns index of point coinciding with regerence one.
inline const Standard_Integer GetCoincidentPoint() const
{
if ( myResInd.Size() > 0 )
if ( myResIndices.Size() > 0 )
{
return myResInd.First();
return myResIndices.First();
}
return 0;
}
const BRepMesh_ListOfInteger& GetListOfDelNodes() const
//! Returns list with indexes of vertices that have movability attribute
//! equal to BRepMesh_Deleted and can be replaced with another node.
inline const BRepMeshCol::ListOfInteger& GetListOfDelPoints() const
{
return myDelNodes;
}
//! Implementation of inspection method
NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget);
//! Performs inspection of a point with the given index.
//! \param theTargetIndex index of a circle to be checked.
//! \return status of the check.
Standard_EXPORT NCollection_CellFilter_Action Inspect(const Standard_Integer theTargetIndex);
static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
//! Checks indices for equlity.
Standard_EXPORT static Standard_Boolean IsEqual(const Standard_Integer theIndex,
const Standard_Integer theTargetIndex)
{
return (theIdx == theTarget);
return (theIndex == theTargetIndex);
}
private:
TColStd_Array1OfReal myTol;
BRepMesh_ListOfInteger myResInd;
BRepMesh_VectorOfVertex myVertices;
BRepMesh_ListOfInteger myDelNodes;
gp_XY myCurrent;
Standard_Real myTolerance[2];
BRepMeshCol::ListOfInteger myResIndices;
BRepMeshCol::VectorOfVertex myVertices;
BRepMeshCol::ListOfInteger myDelNodes;
gp_XY myPoint;
};
#endif

View File

@ -1,140 +0,0 @@
-- Created on: 2011-06-02
-- Created by: Oleg AGASHIN
-- Copyright (c) 2011-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class VertexTool from BRepMesh
---Purpose: Describes the data structure necessary for the
-- mesh algorithm and contains the vertices in UV space.
uses Boolean from Standard,
Integer from Standard,
Real from Standard,
XY from gp,
ListOfInteger from BRepMesh,
VertexCellFilter from BRepMesh,
VertexInspector from BRepMesh,
BaseAllocator from BRepMesh,
Vertex from BRepMesh,
DataMapOfIntegerListOfInteger from BRepMesh,
Array1OfReal from TColStd
is Create (theAlloc : in BaseAllocator from BRepMesh)
returns VertexTool from BRepMesh;
Create (nbComp : in Integer from Standard;
theAlloc : in BaseAllocator from BRepMesh)
---Purpose: Constructs a VertexTool with an evaluation of the
-- number of vertices.
returns VertexTool from BRepMesh;
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;
SetTolerance(me : in out;
theTol : in Real from Standard)
---Purpose: Sets new size for cellfilter.
is static;
SetTolerance(me : in out;
theTolX : in Real from Standard;
theTolY : in Real from Standard)
---Purpose: Sets new size for cellfilter.
is static;
Add (me : in out;
theVertex: in Vertex from BRepMesh;
theParams: in ListOfInteger from BRepMesh)
---Purpose: Adds a vertex to the tool.
returns Integer from Standard is static;
Add (me : in out;
theVertex: in Vertex from BRepMesh)
---Purpose: Adds a vertex to the tool.
returns Integer from Standard is static;
Delete (me : in out; theIndex : Integer from Standard)
---Purpose: Deletes a vertex from the tool.
is static;
FindFromIndex (me; theIndex : Integer from Standard)
---Purpose: Returns data assigned to theIndex.
---C++: alias operator()
---C++: return &
returns ListOfInteger from BRepMesh is static;
FindKey (me: out; theIndex: Integer from Standard)
---Purpose: Selects the vertex by theIndex.
---C++: return const &
returns Vertex from BRepMesh is static;
FindIndex (me: out;
theVertex: Vertex from BRepMesh)
---Purpose: Returns an index of theVertex.
returns Integer from Standard is static;
Extent (me)
---Purpose: Returns a number of vertices.
returns Integer from Standard is static;
IsEmpty (me)
---Purpose: Returns True when the map contains no keys.
returns Boolean from Standard is static;
Substitute(me: in out; Index: Integer from Standard;
theVertex: Vertex from BRepMesh;
theData : ListOfInteger from BRepMesh)
---Purpose: Substitutes vertex with Index on
-- theVertex with attributes theData.
is static;
RemoveLast(me: out)
---Purpose: Remove last node from the structure.
is static;
GetListOfDelNodes(me)
---Purpose: Returns the list with indexes of
-- vertices that have Movability attribute
-- equal to BRepMesh_Deleted and can be
-- replaced with another node.
---C++: return const &
returns ListOfInteger from BRepMesh
is static;
ExpandPoint(me: in out;
thePnt: in XY from gp;
theMinPnt: out XY from gp;
theMaxPnt: out XY from gp)
is static private;
Statistics(me; S: in out OStream from Standard)
---Purpose: Prints statistics.
is static;
fields myAllocator : BaseAllocator from BRepMesh;
myCellFilter : VertexCellFilter from BRepMesh;
mySelector : VertexInspector from BRepMesh;
myLinksMap : DataMapOfIntegerListOfInteger from BRepMesh;
myTol : Array1OfReal from TColStd;
end CircleTool;

View File

@ -13,87 +13,58 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_VertexTool.ixx>
#include <BRepMesh_VertexTool.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <Precision.hxx>
#include <BRepMesh_Vertex.hxx>
#include <BRepMesh_VertexInspector.hxx>
#include <BRepMesh_BaseAllocator.hxx>
//=======================================================================
//function : BRepMesh_VertexTool
//function : Inspect
//purpose :
//=======================================================================
BRepMesh_VertexTool::BRepMesh_VertexTool(const BRepMesh_BaseAllocator& theAlloc)
: myAllocator(theAlloc),
myCellFilter(0., myAllocator),
mySelector(64,myAllocator),
myTol(0,1)
NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect(
const Standard_Integer theTarget)
{
SetCellSize ( Precision::Confusion()+0.05*Precision::Confusion() );
SetTolerance( Precision::Confusion(), Precision::Confusion() );
}
//=======================================================================
//function : BRepMesh_VertexTool
//purpose :
//=======================================================================
BRepMesh_VertexTool::BRepMesh_VertexTool(const Standard_Integer nbComp,
const BRepMesh_BaseAllocator& theAlloc)
: myAllocator(theAlloc),
myCellFilter(0., myAllocator),
mySelector(Max(nbComp,64),myAllocator),
myTol(0,1)
{
SetCellSize ( Precision::Confusion()+0.05*Precision::Confusion() );
SetTolerance( Precision::Confusion(), Precision::Confusion() );
}
//=======================================================================
//function : SetCellSize
//purpose :
//=======================================================================
void BRepMesh_VertexTool::SetCellSize(const Standard_Real theSize)
{
myCellFilter.Reset(theSize, myAllocator);
mySelector.Clear();
}
//=======================================================================
//function : SetCellSize
//purpose :
//=======================================================================
void BRepMesh_VertexTool::SetCellSize(const Standard_Real theXSize,
const Standard_Real theYSize)
{
Standard_Real aCellSize[2];
aCellSize[0] = theXSize;
aCellSize[1] = theYSize;
const BRepMesh_Vertex& aVertex = myVertices(theTarget - 1);
if(aVertex.Movability() == BRepMesh_Deleted)
{
myDelNodes.Append(theTarget);
return CellFilter_Purge;
}
myCellFilter.Reset(aCellSize, myAllocator);
mySelector.Clear();
gp_XY aVec = (myPoint - aVertex.Coord());
Standard_Boolean inTol;
if (Abs(myTolerance[1]) < Precision::Confusion())
{
inTol = aVec.SquareModulus() < myTolerance[0];
}
else
{
inTol = ((aVec.X() * aVec.X()) < myTolerance[0]) &&
((aVec.Y() * aVec.Y()) < myTolerance[1]);
}
if (inTol)
myResIndices.Append(theTarget);
return CellFilter_Keep;
}
//=======================================================================
//function : SetTolerance
//function : BRepMesh_VertexTool
//purpose :
//=======================================================================
void BRepMesh_VertexTool::SetTolerance(const Standard_Real theTol)
BRepMesh_VertexTool::BRepMesh_VertexTool(
const Standard_Integer theReservedSize,
const BRepMeshCol::Allocator& theAllocator)
: myAllocator (theAllocator),
myCellFilter(0., myAllocator),
mySelector (Max(theReservedSize, 64),myAllocator)
{
mySelector.SetTolerance( theTol );
myTol(0) = theTol;
myTol(1) = theTol;
}
//=======================================================================
//function : SetTolerance
//purpose :
//=======================================================================
void BRepMesh_VertexTool::SetTolerance(const Standard_Real theTolX, const Standard_Real theTolY)
{
mySelector.SetTolerance( theTolX, theTolY );
myTol(0) = theTolX;
myTol(1) = theTolY;
const Standard_Real aTol = Precision::Confusion();
SetCellSize ( aTol + 0.05 * aTol );
SetTolerance( aTol, aTol );
}
//=======================================================================
@ -102,145 +73,76 @@ void BRepMesh_VertexTool::SetTolerance(const Standard_Real theTolX, const Standa
//=======================================================================
Standard_Integer BRepMesh_VertexTool::Add(const BRepMesh_Vertex& theVertex)
{
Standard_Integer anIndex = FindIndex(theVertex);
if ( anIndex == 0 )
Standard_Integer aIndex = FindIndex(theVertex);
if (aIndex == 0)
{
BRepMesh_ListOfInteger thelist(myAllocator);
anIndex = Add(theVertex, thelist);
BRepMeshCol::ListOfInteger aParams(myAllocator);
aIndex = Add(theVertex, aParams);
}
return anIndex;
return aIndex;
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
Standard_Integer BRepMesh_VertexTool::Add(const BRepMesh_Vertex& theVertex,
const BRepMesh_ListOfInteger& theParams)
Standard_Integer BRepMesh_VertexTool::Add(
const BRepMesh_Vertex& theVertex,
const BRepMeshCol::ListOfInteger& theParams)
{
Standard_Integer anIndex = mySelector.Add(theVertex);
myLinksMap.Bind(anIndex, theParams);
Standard_Integer aIndex = mySelector.Add(theVertex);
myLinksMap.Bind(aIndex, theParams);
gp_XY aMinPnt, aMaxPnt;
ExpandPoint(theVertex.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Add(anIndex, aMinPnt, aMaxPnt);
return anIndex;
expandPoint(theVertex.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Add(aIndex, aMinPnt, aMaxPnt);
return aIndex;
}
//=======================================================================
//function : Delete
//purpose :
//=======================================================================
void BRepMesh_VertexTool::Delete(const Standard_Integer theIndex)
void BRepMesh_VertexTool::Delete(const Standard_Integer theIndex)
{
BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
gp_XY aMinPnt, aMaxPnt;
ExpandPoint(aV.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Remove (theIndex, aMinPnt, aMaxPnt);
expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Remove(theIndex, aMinPnt, aMaxPnt);
mySelector.Delete(theIndex);
}
//=======================================================================
//function : RemoveLast
//purpose :
//=======================================================================
void BRepMesh_VertexTool::RemoveLast()
{
Standard_Integer aIndex = mySelector.GetNbVertices();
Delete( aIndex );
}
//=======================================================================
//function : GetListOfDelNodes
//purpose :
//=======================================================================
const BRepMesh_ListOfInteger& BRepMesh_VertexTool::GetListOfDelNodes() const
{
return mySelector.GetListOfDelNodes();
}
//=======================================================================
//function : FindIndex
//purpose :
//=======================================================================
Standard_Integer BRepMesh_VertexTool::FindIndex(const BRepMesh_Vertex& theVertex)
{
mySelector.SetCurrent(theVertex.Coord(),Standard_False);
myCellFilter.Inspect (theVertex.Coord(), mySelector);
return mySelector.GetCoincidentInd();
}
//=======================================================================
//function : FindKey
//purpose :
//=======================================================================
const BRepMesh_Vertex& BRepMesh_VertexTool::FindKey(const Standard_Integer theIndex)
{
return mySelector.GetVertex(theIndex);
}
//=======================================================================
//function : Substitute
//purpose :
//=======================================================================
void BRepMesh_VertexTool::Substitute(const Standard_Integer Index,
const BRepMesh_Vertex& theVertex,
const BRepMesh_ListOfInteger& theData)
void BRepMesh_VertexTool::Substitute(
const Standard_Integer theIndex,
const BRepMesh_Vertex& theVertex,
const BRepMeshCol::ListOfInteger& theData)
{
BRepMesh_Vertex& aV = mySelector.GetVertex(Index);
BRepMesh_Vertex& aV = mySelector.GetVertex(theIndex);
gp_XY aMinPnt, aMaxPnt;
ExpandPoint(aV.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Remove (Index, aMinPnt, aMaxPnt);
expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Remove(theIndex, aMinPnt, aMaxPnt);
aV = theVertex;
ExpandPoint(aV.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Add(Index, aMinPnt, aMaxPnt);
FindFromIndex(Index) = theData;
}
//=======================================================================
//function : Extent
//purpose :
//=======================================================================
Standard_Integer BRepMesh_VertexTool::Extent() const
{
return mySelector.GetNbVertices();
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_VertexTool::IsEmpty() const
{
return mySelector.GetNbVertices() == 0;
}
//=======================================================================
//function : FindFromIndex
//purpose :
//=======================================================================
BRepMesh_ListOfInteger& BRepMesh_VertexTool::FindFromIndex(const Standard_Integer theIndex) const
{
return (BRepMesh_ListOfInteger&) myLinksMap.Find(theIndex);
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BRepMesh_VertexTool::ExpandPoint(const gp_XY& thePnt, gp_XY& theMinPnt, gp_XY& theMaxPnt)
{
theMinPnt.SetX(thePnt.X() - myTol(0));
theMinPnt.SetY(thePnt.Y() - myTol(1));
theMaxPnt.SetX(thePnt.X() + myTol(0));
theMaxPnt.SetY(thePnt.Y() + myTol(1));
expandPoint(aV.Coord(), aMinPnt, aMaxPnt);
myCellFilter.Add(theIndex, aMinPnt, aMaxPnt);
FindFromIndex(theIndex) = theData;
}
//=======================================================================
//function : Statistics
//purpose :
//=======================================================================
void BRepMesh_VertexTool::Statistics(Standard_OStream& S) const
void BRepMesh_VertexTool::Statistics(Standard_OStream& theStream) const
{
S <<"\nStructure Statistics\n---------------\n\n";
S <<"This structure has "<<mySelector.GetNbVertices()<<" Nodes\n\n";
theStream << "\nStructure Statistics\n---------------\n\n";
theStream << "This structure has " << mySelector.NbVertices() << " Nodes\n\n";
}

View File

@ -0,0 +1,183 @@
// Copyright (c) 2013 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_VertexTool_HeaderFile
#define _BRepMesh_VertexTool_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <BRepMesh_VertexInspector.hxx>
#include <BRepMesh_Collections.hxx>
#include <Standard_OStream.hxx>
#include <gp_XYZ.hxx>
#include <gp_XY.hxx>
class BRepMesh_Vertex;
//! Describes data structure intended to keep mesh nodes
//! defined in UV space and implements functionality
//! providing their uniqueness regarding thir position.
class BRepMesh_VertexTool
{
public:
DEFINE_STANDARD_ALLOC
//! Constructor.
//! \param theReservedSize size to be reserved for vector of vertices.
//! \param theAllocator memory allocator to be used by internal collections.
Standard_EXPORT BRepMesh_VertexTool(const Standard_Integer theReservedSize,
const BRepMeshCol::Allocator& theAllocator);
//! Sets new size of cell for cellfilter equal in both directions.
Standard_EXPORT void SetCellSize(const Standard_Real theSize)
{
myCellFilter.Reset(theSize, myAllocator);
mySelector.Clear();
}
//! Sets new size of cell for cellfilter.
//! \param theSizeX size for X dimension.
//! \param theSizeY size for Y dimension.
Standard_EXPORT void SetCellSize(const Standard_Real theSizeX,
const Standard_Real theSizeY)
{
Standard_Real aCellSize[2] = { theSizeX, theSizeY };
myCellFilter.Reset(aCellSize, myAllocator);
mySelector.Clear();
}
//! Sets the tolerance to be used for identification of
//! coincident vertices equal for both dimensions.
Standard_EXPORT void SetTolerance(const Standard_Real theTolerance)
{
mySelector.SetTolerance( theTolerance );
myTolerance[0] = theTolerance;
myTolerance[1] = theTolerance;
}
//! Sets the tolerance to be used for identification of
//! coincident vertices.
//! \param theToleranceX tolerance for X dimension.
//! \param theToleranceY tolerance for Y dimension.
Standard_EXPORT void SetTolerance(const Standard_Real theToleranceX,
const Standard_Real theToleranceY)
{
mySelector.SetTolerance( theToleranceX, theToleranceY );
myTolerance[0] = theToleranceX;
myTolerance[1] = theToleranceY;
}
//! Adds vertex with empty data to the tool.
Standard_EXPORT Standard_Integer Add(const BRepMesh_Vertex& theVertex);
//! Adds vertex with associated data to the tool.
//! \param theVertex vertex to be added.
//! \param theParams data associated with the vertex.
Standard_EXPORT Standard_Integer Add(const BRepMesh_Vertex& theVertex,
const BRepMeshCol::ListOfInteger& theParams);
//! Deletes vertex with the given index from the tool.
Standard_EXPORT void Delete(const Standard_Integer theIndex);
//! Returns data assigned to link with the given index.
//! \param theIndex index of link which data should be returned.
//! \return attached data.
inline BRepMeshCol::ListOfInteger& FindFromIndex(const Standard_Integer theIndex) const
{
return (BRepMeshCol::ListOfInteger&)myLinksMap.Find(theIndex);
}
//! Alias for FindFromIndex.
BRepMeshCol::ListOfInteger& operator()(const Standard_Integer theIndex) const
{
return FindFromIndex(theIndex);
}
//! Returns vertex by the given index.
inline const BRepMesh_Vertex& FindKey(const Standard_Integer theIndex)
{
return mySelector.GetVertex(theIndex);
}
//! Returns index of the given vertex.
Standard_EXPORT Standard_Integer FindIndex(const BRepMesh_Vertex& theVertex)
{
mySelector.SetPoint(theVertex.Coord());
myCellFilter.Inspect (theVertex.Coord(), mySelector);
return mySelector.GetCoincidentPoint();
}
//! Returns a number of vertices.
inline Standard_Integer Extent() const
{
return mySelector.NbVertices();
}
//! Returns True when the map contains no keys. <br>
inline Standard_Boolean IsEmpty() const
{
return (Extent() == 0);
}
//! Substitutes vertex with the given by the given vertex with attributes.
//! \param theIndex index of vertex to be substituted.
//! \param theVertex replacement vertex.
//! \param theData data associated to the vertex.
Standard_EXPORT void Substitute(const Standard_Integer theIndex,
const BRepMesh_Vertex& theVertex,
const BRepMeshCol::ListOfInteger& theData);
//! Remove last node from the structure.
inline void RemoveLast()
{
Delete(Extent());
}
//! Returns the list with indexes of vertices that have movability attribute
//! equal to BRepMesh_Deleted and can be replaced with another node.
inline const BRepMeshCol::ListOfInteger& GetListOfDelNodes() const
{
return mySelector.GetListOfDelPoints();
}
//! Prints statistics.
Standard_EXPORT void Statistics(Standard_OStream& theStream) const;
private:
//! Expands the given point according to specified tolerance.
//! \param thePoint point to be expanded.
//! \param[out] theMinPoint bottom left corner of area defined by expanded point.
//! \param[out] theMaxPoint top right corner of area defined by expanded point.
inline void expandPoint(const gp_XY& thePoint,
gp_XY& theMinPoint,
gp_XY& theMaxPoint)
{
theMinPoint.SetX(thePoint.X() - myTolerance[0]);
theMinPoint.SetY(thePoint.Y() - myTolerance[1]);
theMaxPoint.SetX(thePoint.X() + myTolerance[0]);
theMaxPoint.SetY(thePoint.Y() + myTolerance[1]);
}
private:
BRepMeshCol::Allocator myAllocator;
BRepMeshCol::VertexCellFilter myCellFilter;
BRepMesh_VertexInspector mySelector;
BRepMeshCol::DMapOfIntegerListOfInteger myLinksMap;
Standard_Real myTolerance[2];
};
#endif

View File

@ -25,7 +25,6 @@
#include <TopoDS_Iterator.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <BRepMesh_PairOfPolygon.hxx>
#include <BRepMesh_DataMapOfShapePairOfPolygon.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
@ -108,7 +107,7 @@ void BRepMesh_WireChecker::BndBox2dTreeSelector::SetSkippedIndex(
//function : Indices
//purpose :
//=======================================================================
const BRepMesh_WireChecker::ArrayOfInteger&
const BRepMeshCol::Array1OfInteger&
BRepMesh_WireChecker::BndBox2dTreeSelector::Indices() const
{
return myIndices;
@ -130,7 +129,7 @@ Standard_Integer BRepMesh_WireChecker::BndBox2dTreeSelector::IndicesNb() const
BRepMesh_WireChecker::BRepMesh_WireChecker(
const TopoDS_Face& theFace,
const Standard_Real theTolUV,
const BRepMesh_DataMapOfShapePairOfPolygon& theEdges,
const BRepMeshCol::DMapOfShapePairOfPolygon& theEdges,
const TColStd_IndexedMapOfInteger& theVertexMap,
const Handle(BRepMesh_DataStructureOfDelaun)& theStructure,
const Standard_Real theUmin,
@ -183,7 +182,7 @@ BRepMesh_WireChecker::BRepMesh_WireChecker(
//function : ReCompute
//purpose :
//=======================================================================
void BRepMesh_WireChecker::ReCompute(BRepMesh_ClassifierPtr& theClassifier)
void BRepMesh_WireChecker::ReCompute(BRepMeshCol::HClassifier& theClassifier)
{
if (theClassifier.IsNull())
return;
@ -197,7 +196,7 @@ void BRepMesh_WireChecker::ReCompute(BRepMesh_ClassifierPtr& theClassifier)
const Standard_Integer aNbWires = aDWires.size();
std::vector<SegmentsTree> aWiresBiPoints(aNbWires);
BRepMeshCol::Array1OfSegmentsTree aWiresBiPoints(aNbWires);
fillSegmentsTree(aDWires, aWiresBiPoints);
#ifdef HAVE_TBB
@ -360,8 +359,8 @@ Standard_Boolean BRepMesh_WireChecker::collectDiscretizedWires(
//purpose :
//=======================================================================
void BRepMesh_WireChecker::fillSegmentsTree(
const SeqOfDWires& theDWires,
std::vector<SegmentsTree>& theWiresSegmentsTree)
const SeqOfDWires& theDWires,
BRepMeshCol::Array1OfSegmentsTree& theWiresSegmentsTree)
{
const Standard_Integer aNbWires = theDWires.size();
for (Standard_Integer aWireIt = 0; aWireIt < aNbWires; ++aWireIt)
@ -369,9 +368,13 @@ void BRepMesh_WireChecker::fillSegmentsTree(
const SeqOfPnt2d& aWire = theDWires[aWireIt];
const Standard_Integer aWireLen = aWire.Size();
HArrayOfSegments aWireSegments = new ArrayOfSegments(aWireLen);
HBndBox2dTree aBndBoxTree = new BndBox2dTree;
BndBox2dTreeFiller aBndBoxTreeFiller(*aBndBoxTree);
BRepMeshCol::HArray1OfSegments aWireSegments =
new BRepMeshCol::Array1OfSegments(aWireLen);
BRepMeshCol::HBndBox2dTree aBndBoxTree =
new BRepMeshCol::BndBox2dTree;
BRepMeshCol::BndBox2dTreeFiller aBndBoxTreeFiller(*aBndBoxTree);
Standard_Real x1 = 0., y1 = 0., aXstart = 0., aYstart = 0.;
for (Standard_Integer aPntIt = 0; aPntIt <= aWireLen; ++aPntIt)
@ -402,7 +405,7 @@ void BRepMesh_WireChecker::fillSegmentsTree(
gp_Pnt2d aEndPnt(x2, y2);
const Standard_Integer aPointId = aPntIt - 1;
Segment& aSegment = aWireSegments->at(aPointId);
BRepMeshCol::Segment& aSegment = aWireSegments->at(aPointId);
aSegment.StartPnt = aStartPnt.XY();
aSegment.EndPnt = aEndPnt.XY();
@ -416,7 +419,7 @@ void BRepMesh_WireChecker::fillSegmentsTree(
}
aBndBoxTreeFiller.Fill();
SegmentsTree& aSegmentsTree = theWiresSegmentsTree[aWireIt];
BRepMeshCol::SegmentsTree& aSegmentsTree = theWiresSegmentsTree[aWireIt];
aSegmentsTree.first = aWireSegments;
aSegmentsTree.second = aBndBoxTree;
}

View File

@ -20,15 +20,8 @@
#include <Standard.hxx>
#include <TopoDS_Face.hxx>
#include <BRepMesh_Status.hxx>
#include <Handle_BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_ClassifierPtr.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_List.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_EBTree.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_Array1.hxx>
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_Collections.hxx>
#include <TopoDS_Edge.hxx>
#include <Bnd_Box2d.hxx>
#include <gp_Pnt2d.hxx>
@ -38,7 +31,6 @@
class BRepMesh_DataMapOfShapePairOfPolygon;
class TColStd_IndexedMapOfInteger;
class BRepMesh_DataStructureOfDelaun;
//! Auxilary class intended to check correctness of discretized face.
//! In particular, checks boundaries of discretized face for self
@ -47,26 +39,11 @@ class BRepMesh_WireChecker
{
public:
//! Structure keeping parameters of segment.
struct Segment
{
gp_XY StartPnt;
gp_XY EndPnt;
};
typedef NCollection_EBTree<Standard_Integer, Bnd_Box2d> BndBox2dTree;
typedef NCollection_UBTreeFiller<Standard_Integer, Bnd_Box2d> BndBox2dTreeFiller;
typedef NCollection_Array1<Standard_Integer> ArrayOfInteger;
typedef std::vector<Segment> ArrayOfSegments;
typedef NCollection_Handle<ArrayOfSegments> HArrayOfSegments;
typedef NCollection_Handle<BndBox2dTree> HBndBox2dTree;
typedef std::pair<HArrayOfSegments, HBndBox2dTree> SegmentsTree;
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
//! Note that instance of selector can be used only once due to
//! unextentable array of indices.
class BndBox2dTreeSelector : public BndBox2dTree::Selector
class BndBox2dTreeSelector : public BRepMeshCol::BndBox2dTree::Selector
{
public:
Standard_EXPORT BndBox2dTreeSelector(const Standard_Integer theReservedSize);
@ -76,14 +53,14 @@ public:
Standard_EXPORT void Clear();
Standard_EXPORT void SetBox(const Bnd_Box2d& theBox2D);
Standard_EXPORT void SetSkippedIndex(const Standard_Integer theIndex);
Standard_EXPORT const ArrayOfInteger& Indices() const;
Standard_EXPORT const BRepMeshCol::Array1OfInteger& Indices() const;
Standard_EXPORT Standard_Integer IndicesNb() const;
protected:
Bnd_Box2d myBox2D;
Standard_Integer mySkippedIndex;
ArrayOfInteger myIndices;
Standard_Integer myIndicesNb;
Bnd_Box2d myBox2D;
Standard_Integer mySkippedIndex;
BRepMeshCol::Array1OfInteger myIndices;
Standard_Integer myIndicesNb;
};
private:
@ -110,7 +87,7 @@ public:
Standard_EXPORT BRepMesh_WireChecker(
const TopoDS_Face& theFace,
const Standard_Real theTolUV,
const BRepMesh_DataMapOfShapePairOfPolygon& theEdges,
const BRepMeshCol::DMapOfShapePairOfPolygon& theEdges,
const TColStd_IndexedMapOfInteger& theVertexMap,
const Handle(BRepMesh_DataStructureOfDelaun)& theStructure,
const Standard_Real theUmin,
@ -121,7 +98,7 @@ public:
//! Recompute data using parameters passed in constructor.
//! \param[out] theClassifier Classifier to be updated using calculated data.
Standard_EXPORT void ReCompute(BRepMesh_ClassifierPtr& theClassifier);
Standard_EXPORT void ReCompute(BRepMeshCol::HClassifier& theClassifier);
//! Returns status of the check.
inline BRepMesh_Status Status() const
@ -141,8 +118,8 @@ private:
//! \param theWiresSegmentsTree Array of segments with corresponding
//! bounding boxes trees to be filled.
void fillSegmentsTree(
const SeqOfDWires& theDWires,
std::vector<SegmentsTree>& theWiresSegmentsTree);
const SeqOfDWires& theDWires,
BRepMeshCol::Array1OfSegmentsTree& theWiresSegmentsTree);
//! Assignment operator.
void operator =(BRepMesh_WireChecker& /*theOther*/)
@ -152,7 +129,7 @@ private:
private:
const Standard_Real myTolUV;
const BRepMesh_DataMapOfShapePairOfPolygon& myEdges;
const BRepMeshCol::DMapOfShapePairOfPolygon& myEdges;
const TColStd_IndexedMapOfInteger& myVertexMap;
const Handle(BRepMesh_DataStructureOfDelaun)& myStructure;
const Standard_Real myUmin;

View File

@ -14,6 +14,7 @@
// commercial license or contractual agreement.
#include <BRepMesh_WireInterferenceChecker.hxx>
#include <BRepMesh_GeomTool.hxx>
#include <Precision.hxx>
// TODO: remove this variable after implementation of LoopChecker2d.
@ -25,9 +26,9 @@ static const Standard_Real MIN_LOOP_S = 2 * M_PI * 2.E-5;
//purpose :
//=======================================================================
BRepMesh_WireInterferenceChecker::BRepMesh_WireInterferenceChecker(
const std::vector<BRepMesh_WireChecker::SegmentsTree>& theWires,
BRepMesh_Status* theStatus,
Standard_Mutex* theMutex)
const std::vector<BRepMeshCol::SegmentsTree>& theWires,
BRepMesh_Status* theStatus,
Standard_Mutex* theMutex)
: myWires(&theWires.front()),
myWiresNb(theWires.size()),
myStatus(theStatus),
@ -70,9 +71,9 @@ void BRepMesh_WireInterferenceChecker::operator ()(
if (*myStatus == BRepMesh_SelfIntersectingWire)
return;
const BRepMesh_WireChecker::SegmentsTree& aWireSegTree1 = myWires[theWireId];
const BRepMesh_WireChecker::Segment* aWireSegments1 = &aWireSegTree1.first->front();
const BRepMesh_WireChecker::HBndBox2dTree& aWireBoxTree1 = aWireSegTree1.second;
const BRepMeshCol::SegmentsTree& aWireSegTree1 = myWires[theWireId];
const BRepMeshCol::Segment* aWireSegments1 = &aWireSegTree1.first->front();
const BRepMeshCol::HBndBox2dTree& aWireBoxTree1 = aWireSegTree1.second;
const Standard_Integer aWireLen1 = aWireSegTree1.first->size();
for (Standard_Integer aWireIt = theWireId; aWireIt < myWiresNb; ++aWireIt)
@ -84,11 +85,11 @@ void BRepMesh_WireInterferenceChecker::operator ()(
#endif
const Standard_Boolean isSelfIntCheck = (aWireIt == theWireId);
const BRepMesh_WireChecker::SegmentsTree& aWireSegTree2 =
const BRepMeshCol::SegmentsTree& aWireSegTree2 =
isSelfIntCheck ? aWireSegTree1 : myWires[aWireIt];
const BRepMesh_WireChecker::Segment* aWireSegments2 = &aWireSegTree2.first->front();
const BRepMesh_WireChecker::HBndBox2dTree& aWireBoxTree2 = aWireSegTree2.second;
const BRepMeshCol::Segment* aWireSegments2 = &aWireSegTree2.first->front();
const BRepMeshCol::HBndBox2dTree& aWireBoxTree2 = aWireSegTree2.second;
BRepMesh_WireChecker::BndBox2dTreeSelector aSelector(aWireSegTree2.first->size());
for (Standard_Integer aSegmentId1 = 0; aSegmentId1 < aWireLen1; ++aSegmentId1)
@ -107,8 +108,8 @@ void BRepMesh_WireInterferenceChecker::operator ()(
if (aWireBoxTree2->Select(aSelector) == 0)
continue;
const BRepMesh_WireChecker::Segment& aSegment1 = aWireSegments1[aSegmentId1];
const BRepMesh_WireChecker::ArrayOfInteger& aSelected = aSelector.Indices();
const BRepMeshCol::Segment& aSegment1 = aWireSegments1[aSegmentId1];
const BRepMeshCol::Array1OfInteger& aSelected = aSelector.Indices();
const Standard_Integer aSelectedNb = aSelector.IndicesNb();
for (Standard_Integer aBndIt = 0; aBndIt < aSelectedNb; ++aBndIt)
{
@ -119,16 +120,16 @@ void BRepMesh_WireInterferenceChecker::operator ()(
#endif
const Standard_Integer aSegmentId2 = aSelected(aBndIt);
const BRepMesh_WireChecker::Segment& aSegment2 = aWireSegments2[aSegmentId2];
const BRepMeshCol::Segment& aSegment2 = aWireSegments2[aSegmentId2];
gp_Pnt2d aIntPnt;
BRepMesh_WireInterferenceChecker::IntFlag aIntStatus = Intersect(
BRepMesh_GeomTool::IntFlag aIntStatus = BRepMesh_GeomTool::IntSegSeg(
aSegment1.StartPnt, aSegment1.EndPnt,
aSegment2.StartPnt, aSegment2.EndPnt,
Standard_False, Standard_False,
aIntPnt);
if (aIntStatus == Cross)
if (aIntStatus == BRepMesh_GeomTool::Cross)
{
// TODO: remove this block after implementation of LoopChecker2d.
if (isSelfIntCheck)
@ -138,7 +139,7 @@ void BRepMesh_WireInterferenceChecker::operator ()(
const gp_XY& aRefPnt = aIntPnt.Coord();
for (Standard_Integer i = aSegmentId1; i < aSegmentId2; ++i)
{
const BRepMesh_WireChecker::Segment& aSeg = aWireSegments1[i];
const BRepMeshCol::Segment& aSeg = aWireSegments1[i];
gp_XY aCurVec = aSeg.EndPnt - aRefPnt;
if (aCurVec.SquareModulus() < gp::Resolution())
@ -164,182 +165,3 @@ void BRepMesh_WireInterferenceChecker::operator ()(
}
}
}
//=============================================================================
//function : Intersect
//purpose :
//=============================================================================
BRepMesh_WireInterferenceChecker::IntFlag
BRepMesh_WireInterferenceChecker::Intersect(
const gp_XY& theStartPnt1,
const gp_XY& theEndPnt1,
const gp_XY& theStartPnt2,
const gp_XY& theEndPnt2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnSegment,
gp_Pnt2d& theIntPnt)
{
Standard_Integer aPointHash[] = {
classifyPoint(theStartPnt1, theEndPnt1, theStartPnt2),
classifyPoint(theStartPnt1, theEndPnt1, theEndPnt2 ),
classifyPoint(theStartPnt2, theEndPnt2, theStartPnt1),
classifyPoint(theStartPnt2, theEndPnt2, theEndPnt1 )
};
// Consider case when edges have shared vertex
if ( isConsiderEndPointTouch )
{
if ( aPointHash[0] < 0 || aPointHash[1] < 0 )
return BRepMesh_WireInterferenceChecker::EndPointTouch;
}
Standard_Integer aPosHash =
aPointHash[0] + aPointHash[1] + aPointHash[2] + aPointHash[3];
/*=========================================*/
/* 1) hash code == 1:
0+
/
0 1/ 0
+======+==========+
2) hash code == 2:
0 1 1 0
a) +----+========+---+
0 1 1 0
b) +-------+===+=====+
*/
/*=========================================*/
if ( aPosHash == 1 )
{
if (isConsiderPointOnSegment)
{
if (aPointHash[0] == 1)
theIntPnt = theStartPnt1;
else if (aPointHash[1] == 1)
theIntPnt = theEndPnt1;
else if (aPointHash[2] == 1)
theIntPnt = theStartPnt2;
else
theIntPnt = theEndPnt2;
return BRepMesh_WireInterferenceChecker::PointOnSegment;
}
return BRepMesh_WireInterferenceChecker::NoIntersection;
}
else if ( aPosHash == 2 )
return BRepMesh_WireInterferenceChecker::Glued;
gp_XY aVec1 = theEndPnt1 - theStartPnt1;
gp_XY aVec2 = theEndPnt2 - theStartPnt2;
gp_XY aVecStartPoints = theStartPnt2 - theStartPnt1;
Standard_Real aCrossD1D2 = aVec1 ^ aVec2;
Standard_Real aCrossD1D3 = aVecStartPoints ^ aVec2;
const Standard_Real aPrec = Precision::PConfusion();
// Are edgegs codirectional
if ( Abs( aCrossD1D2 ) < aPrec )
{
// Just a parallel case?
if( Abs( aCrossD1D3 ) < aPrec )
{
/*=========================================*/
/* Here the following cases are possible:
1) hash code == -4:
-1 -1
+=================+
-1 -1
2) hash code == -2:
0 -1 0
+--------+========+
-1
3) hash code == -1:
0 1 -1
+--------+========+
-1
4) hash code == 0:
0 0 0 0
+------+ +=======+
0 0 0 0
*/
/*=========================================*/
if ( aPosHash < -2 )
return BRepMesh_WireInterferenceChecker::Same;
else if ( aPosHash == -1 )
return BRepMesh_WireInterferenceChecker::Glued;
return BRepMesh_WireInterferenceChecker::NoIntersection;
}
else
return BRepMesh_WireInterferenceChecker::NoIntersection;
}
Standard_Real aPar = aCrossD1D3 / aCrossD1D2;
const Standard_Real aEndPrec = 1 - aPrec;
// Intersection is out of first segment range
if( aPar < aPrec || aPar > aEndPrec )
return BRepMesh_WireInterferenceChecker::NoIntersection;
Standard_Real aCrossD2D3 = aVecStartPoints.Reversed() ^ aVec1;
aPar = aCrossD2D3 / -aCrossD1D2;
// Intersection is out of second segment range
if( aPar < aPrec || aPar > aEndPrec )
return BRepMesh_WireInterferenceChecker::NoIntersection;
theIntPnt = theStartPnt2 + aPar * aVec2;
return BRepMesh_WireInterferenceChecker::Cross;
}
//=============================================================================
//function : classifyPoint
//purpose :
//=============================================================================
Standard_Integer BRepMesh_WireInterferenceChecker::classifyPoint(
const gp_XY& thePoint1,
const gp_XY& thePoint2,
const gp_XY& thePointToCheck)
{
gp_XY aP1 = thePoint2 - thePoint1;
gp_XY aP2 = thePointToCheck - thePoint1;
const Standard_Real aPrec = Precision::PConfusion();
const Standard_Real aSqPrec = aPrec * aPrec;
Standard_Real aDist = Abs(aP1 ^ aP2);
if (aDist > aPrec)
{
aDist = (aDist * aDist) / aP1.SquareModulus();
if (aDist > aSqPrec)
return 0; //out
}
gp_XY aMult = aP1.Multiplied(aP2);
if ( aMult.X() < 0.0 || aMult.Y() < 0.0 )
return 0; //out
if (aP1.SquareModulus() < aP2.SquareModulus())
return 0; //out
if (thePointToCheck.IsEqual(thePoint1, aPrec) ||
thePointToCheck.IsEqual(thePoint2, aPrec))
{
return -1; //coinsides with an end point
}
return 1;
}

View File

@ -49,9 +49,9 @@ public:
//! \param theStatus shared flag to set status of the check.
//! \param theMutex shared mutex for parallel processing.
BRepMesh_WireInterferenceChecker(
const std::vector<BRepMesh_WireChecker::SegmentsTree>& theWires,
BRepMesh_Status* theStatus,
Standard_Mutex* theMutex);
const std::vector<BRepMeshCol::SegmentsTree>& theWires,
BRepMesh_Status* theStatus,
Standard_Mutex* theMutex);
//! Checker's body.
//! \param theWireRange range of wires to be checked.
@ -69,27 +69,6 @@ public:
//! \param theWireId Id of discretized wire to be checked.
void operator ()(const Standard_Integer& theWireId) const;
//! Checks intersection between the two segments.
//! \param theStartPnt1 start point of first segment.
//! \param theEndPnt1 end point of first segment.
//! \param theStartPnt2 start point of second segment.
//! \param theEndPnt2 end point of second segment.
//! \param isConsiderEndPointTouch if TRUE EndPointTouch status will be
//! returned in case if segments are touching by end points, if FALSE
//! returns NoIntersection flag.
//! \param isConsiderPointOnSegment if TRUE PointOnSegment status will be
//! returned in case if end point of one segment lies onto another one,
//! if FALSE returns NoIntersection flag.
//! \param[out] theIntPnt point of intersection.
//! \return status of intersection check.
static IntFlag Intersect(const gp_XY& theStartPnt1,
const gp_XY& theEndPnt1,
const gp_XY& theStartPnt2,
const gp_XY& theEndPnt2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnSegment,
gp_Pnt2d& theIntPnt);
private:
//! Classifies the point in case of coincidence of two vectors.
@ -102,12 +81,12 @@ private:
const gp_XY& thePoint2,
const gp_XY& thePointToCheck);
private:
const BRepMesh_WireChecker::SegmentsTree* myWires;
Standard_Integer myWiresNb;
BRepMesh_Status* myStatus;
const BRepMeshCol::SegmentsTree* myWires;
Standard_Integer myWiresNb;
BRepMesh_Status* myStatus;
#ifdef HAVE_TBB
Standard_Mutex* myMutex;
Standard_Mutex* myMutex;
#endif
};

View File

@ -1,31 +1,50 @@
BRepMesh_PluginEntryType.hxx
BRepMesh_PluginMacro.hxx
BRepMesh_DegreeOfFreedom.hxx
BRepMesh_FactoryError.hxx
BRepMesh_Vertex.hxx
BRepMesh_Edge.hxx
BRepMesh_Triangle.hxx
BRepMesh_Triangle.cxx
BRepMesh_Circle.hxx
BRepMesh_Classifier.hxx
BRepMesh_Classifier.cxx
BRepMesh_ClassifierPtr.hxx
BRepMesh_WireInterferenceChecker.hxx
BRepMesh_WireInterferenceChecker.cxx
BRepMesh_WireChecker.hxx
BRepMesh_WireChecker.cxx
BRepMesh_CellFilter.hxx
BRepMesh_DiscretRoot.hxx
BRepMesh_DiscretRoot.cxx
BRepMesh_DiscretFactory.hxx
BRepMesh_DiscretFactory.cxx
BRepMesh_Collections.hxx
BRepMesh_DataStructureOfDelaun.hxx
BRepMesh_DataStructureOfDelaun.cxx
BRepMesh_CircleTool.hxx
BRepMesh_CircleTool.cxx
BRepMesh_VertexTool.hxx
BRepMesh_VertexTool.cxx
BRepMesh_ShapeTool.hxx
BRepMesh_ShapeTool.cxx
BRepMesh_Delaun.hxx
BRepMesh_Delaun.cxx
BRepMesh_CircleInspector.hxx
BRepMesh_MapOfIntegerInteger.hxx
BRepMesh_MapOfInteger.hxx
BRepMesh_ListOfInteger.hxx
BRepMesh_BaseAllocator.hxx
BRepMesh_PairOfIndex.hxx
BRepMesh_Status.hxx
BRepMesh_CMPLRS.edl
BRepMesh_VertexCellFilter.hxx
BRepMesh_VertexInspector.hxx
BRepMesh_VertexInspector.cxx
BRepMesh_VectorOfVertex.hxx
BRepMesh_EdgeChecker.hxx
BRepMesh_FaceChecker.hxx
BRepMesh_SelectorOfDataStructureOfDelaun.hxx
BRepMesh_SelectorOfDataStructureOfDelaun.cxx
BRepMesh_FastDiscretFace.hxx
BRepMesh_FastDiscretFace.cxx
BRepMesh_FastDiscret.hxx
BRepMesh_FastDiscret.cxx
BRepMesh_FaceAttribute.hxx
BRepMesh_FaceAttribute.cxx
BRepMesh_IncrementalMesh.hxx
BRepMesh_IncrementalMesh.cxx
BRepMesh_GeomTool.hxx
BRepMesh_GeomTool.cxx
BRepMesh_PairOfPolygon.hxx
EXTERNLIB

View File

@ -842,7 +842,7 @@ void DBRep_DrawableShape::DisplayHiddenLines(Draw_Display& dis)
if (!strcmp(dout.GetType(id),"PERS")) focal = dout.Focal(id);
Standard_Real Ang,Def;
HLRBRep::PolyHLRAngleAndDeflection(myAng,Ang,Def);
BRepMesh_IncrementalMesh MESH(myShape,Def,Standard_True,Ang);
BRepMesh_IncrementalMesh MESH(myShape, Def, Ang, Standard_True);
Standard_Boolean recompute = Standard_True;
// find if the view must be recomputed
DBRep_ListIteratorOfListOfHideData it(myHidData);

View File

@ -1,3 +1,5 @@
MeshTest_PluginCommands.cxx
MeshTest_CheckTopology.cxx
MeshTest_CheckTopology.hxx
MeshTest_DrawableMesh.cxx
MeshTest_DrawableMesh.hxx

View File

@ -26,9 +26,7 @@ uses
is
class DrawableMesh;
---Purpose: Provides a mesh object inherited from Drawable3d
-- to draw a triangulation.
imported DrawableMesh from MeshTest;
Commands(DI : in out Interpretor from Draw);
---Purpose: Defines meshing commands

View File

@ -42,7 +42,6 @@
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_Delaun.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <BRepMesh_Array1OfVertexOfDelaun.hxx>
#include <BRepMesh_Vertex.hxx>
#include <BRepMesh_Edge.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
@ -141,7 +140,7 @@ static Standard_Integer incrementalmesh(Draw_Interpretor& di, Standard_Integer n
di << "Incremental Mesh, multi-threading "
<< (isInParallel ? "ON\n" : "OFF\n");
BRepMesh_IncrementalMesh MESH(aShape, aDeflection, Standard_False, 0.5, isInParallel);
BRepMesh_IncrementalMesh MESH(aShape, aDeflection, 0.5, Standard_False, isInParallel);
Standard_Integer statusFlags = MESH.GetStatusFlags();
di << "Meshing statuses: ";
@ -564,9 +563,9 @@ static Standard_Integer vertices (Draw_Interpretor&, Standard_Integer n, const c
// the faces
for (ex.Init(S,TopAbs_FACE);ex.More();ex.Next()) {
BRepMesh_MapOfInteger vtx;
BRepMeshCol::MapOfInteger vtx;
M->VerticesOfDomain(vtx);
for (BRepMesh_MapOfInteger::Iterator it(vtx); it.More(); it.Next())
for (BRepMeshCol::MapOfInteger::Iterator it(vtx); it.More(); it.Next())
vseq.Append(it.Key());
}

View File

@ -1,82 +0,0 @@
-- Created on: 1994-08-03
-- Created by: Modeling
-- Copyright (c) 1994-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class DrawableMesh from MeshTest inherits Drawable3D from Draw
---Purpose: A drawable mesh. It contains a sequence of
-- highlighted edges and highlighted vertices.
uses
Display from Draw,
Interpretor from Draw,
Shape from TopoDS,
FastDiscret from BRepMesh,
SequenceOfInteger from TColStd
is
Create returns DrawableMesh from MeshTest;
Create(S : Shape from TopoDS; Deflect : Real;
Partage : Boolean; InShape: Boolean from Standard= Standard_False)
returns DrawableMesh from MeshTest;
Create(Tr: FastDiscret from BRepMesh)
returns DrawableMesh from MeshTest;
AddInShape(me: mutable; inshape: Boolean)
is static;
Add(me : mutable; S : Shape from TopoDS)
is static;
Edges(me : mutable) returns SequenceOfInteger from TColStd
---C++: return &
is static;
Vertices(me : mutable) returns SequenceOfInteger from TColStd
---C++: return &
is static;
Triangles(me : mutable) returns SequenceOfInteger from TColStd
---C++: return &
is static;
DrawOn(me; dis : in out Display from Draw);
Copy(me) returns Drawable3D from Draw
is redefined;
Dump(me; S : in out OStream)
is redefined;
Whatis(me; S : in out Interpretor from Draw)
is redefined;
Mesh(me) returns FastDiscret from BRepMesh
is static;
fields
myMesh : FastDiscret from BRepMesh;
myDeflection : Real;
myEdges : SequenceOfInteger from TColStd;
myVertices : SequenceOfInteger from TColStd;
myTriangles : SequenceOfInteger from TColStd;
myinshape : Boolean from Standard;
end DrawableMesh;

View File

@ -14,7 +14,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MeshTest_DrawableMesh.ixx>
#include <MeshTest_DrawableMesh.hxx>
#include <TopoDS.hxx>
#include <Draw.hxx>
#include <Draw_ColorKind.hxx>
@ -29,6 +29,9 @@
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshTest_DrawableMesh, Draw_Drawable3D)
IMPLEMENT_STANDARD_RTTIEXT(MeshTest_DrawableMesh, Draw_Drawable3D)
//=======================================================================
//function : MeshTest_DrawableMesh
//purpose :
@ -53,7 +56,7 @@ myDeflection(Deflect), myinshape(inshape)
Bnd_Box B;
BRepBndLib::Add(S, B);
myMesh = new BRepMesh_FastDiscret(Deflect, S, B, 0.5, Partage, inshape);
myMesh = new BRepMesh_FastDiscret(S, Deflect, 0.5, B, Partage, inshape);
}
@ -80,7 +83,7 @@ void MeshTest_DrawableMesh::Add(const TopoDS_Shape& S)
BRepBndLib::Add(S, B);
if (myMesh.IsNull())
myMesh=new BRepMesh_FastDiscret(myDeflection, S, B, 0.5, myinshape);
myMesh=new BRepMesh_FastDiscret(S, myDeflection, 0.5, B, myinshape);
else
myMesh->Perform(S);
}

View File

@ -0,0 +1,78 @@
// Copyright (c) 2013-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _MeshTest_DrawableMesh_HeaderFile
#define _MeshTest_DrawableMesh_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <BRepMesh_FastDiscret.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Draw_Drawable3D.hxx>
#include <Handle_Draw_Drawable3D.hxx>
#include <Standard_OStream.hxx>
#include <Draw_Interpretor.hxx>
class TopoDS_Shape;
class TColStd_SequenceOfInteger;
class Draw_Display;
class Draw_Drawable3D;
//! A drawable mesh.
//! Provides a mesh object inherited from Drawable3d to draw a triangulation.
//! It contains a sequence of highlighted edges and highlighted vertices. <br>
class MeshTest_DrawableMesh : public Draw_Drawable3D
{
public:
Standard_EXPORT MeshTest_DrawableMesh();
Standard_EXPORT MeshTest_DrawableMesh(const TopoDS_Shape& S,const Standard_Real Deflect,const Standard_Boolean Partage,const Standard_Boolean InShape = Standard_False);
Standard_EXPORT MeshTest_DrawableMesh(const Handle(BRepMesh_FastDiscret)& Tr);
Standard_EXPORT void AddInShape(const Standard_Boolean inshape) ;
Standard_EXPORT void Add(const TopoDS_Shape& S) ;
Standard_EXPORT TColStd_SequenceOfInteger& Edges() ;
Standard_EXPORT TColStd_SequenceOfInteger& Vertices() ;
Standard_EXPORT TColStd_SequenceOfInteger& Triangles() ;
Standard_EXPORT void DrawOn(Draw_Display& dis) const;
Standard_EXPORT virtual Handle_Draw_Drawable3D Copy() const;
Standard_EXPORT virtual void Dump(Standard_OStream& S) const;
Standard_EXPORT virtual void Whatis(Draw_Interpretor& S) const;
Standard_EXPORT Handle(BRepMesh_FastDiscret) Mesh() const;
DEFINE_STANDARD_RTTI(MeshTest_DrawableMesh)
private:
Handle(BRepMesh_FastDiscret) myMesh;
Standard_Real myDeflection;
TColStd_SequenceOfInteger myEdges;
TColStd_SequenceOfInteger myVertices;
TColStd_SequenceOfInteger myTriangles;
Standard_Boolean myinshape;
};
DEFINE_STANDARD_HANDLE(MeshTest_DrawableMesh, Draw_Drawable3D)
#endif

View File

@ -1348,7 +1348,7 @@ static Standard_Integer OCC369(Draw_Interpretor& di, Standard_Integer argc, cons
if(aShape.IsNull()) {di << "OCC369 FAULTY. Entry shape is NULL \n"; return 0;}
// 3. Build mesh
BRepMesh_IncrementalMesh aMesh(aShape, 0.2, Standard_True, M_PI/6);
BRepMesh_IncrementalMesh aMesh(aShape, 0.2, M_PI/6, Standard_True);
}
catch (Standard_Failure) {di << "OCC369 Exception \n" ;return 0;}
@ -3194,7 +3194,7 @@ Standard_Integer OCC14376(Draw_Interpretor& di, Standard_Integer argc, const cha
}
di<<"deflection="<< aDeflection << "\n";
BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, Standard_False, M_PI/9.);
BRepMesh_IncrementalMesh aIMesh(aShape, aDeflection, M_PI/9., Standard_False);
TopLoc_Location aLocation;
Handle(Poly_Triangulation) aTriang = BRep_Tool::Triangulation(TopoDS::Face(aShape), aLocation);

View File

@ -1,3 +1,5 @@
StdPrs_ToolShadedShape.hxx
StdPrs_ToolShadedShape.cxx
StdPrs_HLRShape.hxx
StdPrs_HLRShape.cxx
StdPrs_Point.hxx

View File

@ -53,7 +53,7 @@ is
class ToolVertex;
class ToolRFace;
class HLRToolShape;
class ToolShadedShape;
imported ToolShadedShape from StdPrs;
class ShadedShape;
class PoleCurve;

View File

@ -66,7 +66,7 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
const Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
Standard_Real def = rel? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation();
BRepMesh_IncrementalMesh mesh(aShape, def, rel, aDrawer->HLRAngle());
BRepMesh_IncrementalMesh mesh(aShape, def, aDrawer->HLRAngle(), rel);
Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(aShape);

View File

@ -41,6 +41,8 @@
#include <StdPrs_ToolShadedShape.hxx>
#include <StdPrs_WFShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
@ -132,11 +134,11 @@ namespace
// Precision for compare square distances
const Standard_Real aPreci = Precision::SquareConfusion();
StdPrs_ToolShadedShape aShapeTool;
for (aShapeTool.Init (theShape); aShapeTool.MoreFace(); aShapeTool.NextFace())
TopExp_Explorer aFaceIt(theShape, TopAbs_FACE);
for (; aFaceIt.More(); aFaceIt.Next())
{
const TopoDS_Face& aFace = aShapeTool.CurrentFace();
aT = aShapeTool.Triangulation (aFace, aLoc);
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
aT = StdPrs_ToolShadedShape::Triangulation (aFace, aLoc);
if (!aT.IsNull())
{
aNbTriangles += aT->NbTriangles();
@ -151,10 +153,10 @@ namespace
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (aNbVertices, 3 * aNbTriangles,
Standard_True, Standard_False, theHasTexels);
Standard_Real aUmin (0.0), aUmax (0.0), aVmin (0.0), aVmax (0.0), dUmax (0.0), dVmax (0.0);
for (aShapeTool.Init (theShape); aShapeTool.MoreFace(); aShapeTool.NextFace())
for (aFaceIt.Init (theShape, TopAbs_FACE); aFaceIt.More(); aFaceIt.Next())
{
const TopoDS_Face& aFace = aShapeTool.CurrentFace();
aT = aShapeTool.Triangulation (aFace, aLoc);
const TopoDS_Face& aFace = TopoDS::Face(aFaceIt.Current());
aT = StdPrs_ToolShadedShape::Triangulation (aFace, aLoc);
if (aT.IsNull())
{
continue;
@ -165,7 +167,7 @@ namespace
const TColgp_Array1OfPnt& aNodes = aT->Nodes();
const TColgp_Array1OfPnt2d& aUVNodes = aT->UVNodes();
TColgp_Array1OfDir aNormals (aNodes.Lower(), aNodes.Upper());
aShapeTool.Normal (aFace, aPolyConnect, aNormals);
StdPrs_ToolShadedShape::Normal (aFace, aPolyConnect, aNormals);
if (theHasTexels)
{
@ -201,7 +203,7 @@ namespace
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if (aShapeTool.Orientation (aFace) == TopAbs_REVERSED)
if (aFace.Orientation() == TopAbs_REVERSED)
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}

View File

@ -1,40 +0,0 @@
-- Created on: 1993-10-27
-- Created by: Jean-Louis FRENKEL
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class ToolShadedShape from StdPrs inherits ShapeTool from BRepMesh
uses
Shape from TopoDS,
Face from TopoDS,
Array1OfDir from TColgp,
Connect from Poly,
Triangulation from Poly,
Location from TopLoc
is
IsClosed (myclass; theShape : Shape from TopoDS) returns Boolean from Standard;
---Purpose: Checks back faces visibility for specified shape (to activate back-face culling).
-- @return true if shape is closed Solid or compound of closed Solids.
Triangulation(myclass; aFace: Face from TopoDS;
loc : out Location from TopLoc)
returns Triangulation from Poly;
Normal(myclass; aFace: Face from TopoDS;
PC : in out Connect from Poly;
Nor : out Array1OfDir from TColgp);
end ToolShadedShape from StdPrs;

View File

@ -14,7 +14,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <StdPrs_ToolShadedShape.ixx>
#include <StdPrs_ToolShadedShape.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
@ -31,6 +31,9 @@
#include <TopLoc_Location.hxx>
#include <TShort_HArray1OfShortReal.hxx>
#include <TShort_Array1OfShortReal.hxx>
#include <TColgp_Array1OfDir.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
namespace
{

Some files were not shown because too many files have changed in this diff Show More