1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-16 10:54:53 +03:00
occt/src/BRepMesh/BRepMesh_GeomTool.hxx
msv 8109385697 0027362: Meshing performance
1) BRepMesh_FastDiscretFace.cxx:
- exclude planes from procedure of inserting internal points.
- localize declaration of the container aNewVertices in each method where it is needed.
- correct the logic of the method insertInternalVerticesOther, so that to separate the processes of removing extra points and addition of new points in different cycles, thus making the code more clear and in addition stable.
- insert useful output of intermediate mesh to a file in control() method for debug purposes (with definition DEBUG_MESH).

2) Add global functions MeshTest_DrawTriangles and MeshTest_DrawLinks to draw mesh data in debug session.

3) BRepMesh_FastDiscret:
- in the method Add calculations of deflections have been simplified for non-relative mode.
- replace the attribute MinDist with Deflection in EdgeAttributes structure. Correct its computation so that later to store this value as deflection of the polygon.

4) Make protection against exception in the method BRepMesh_Delaun::addTriangle() when an added triangle creates a third connection of a mesh edge.

5) BRepMesh_EdgeTessellator.cxx, BRepMesh_EdgeTessellationExtractor.cxx: use Geom2dAdaptor_Curve in order to use b-spline cache while computing value on a curve.

6) In BndLib_Box2dCurve::PerformBSpline, avoid creating new b-spline in case of requested parameter range differ from natural bounds insignificantly.

7) In GeomAdaptor classes, postpone building of cache till the time of its actual usage. So, creation of an adapter to compute intervals of continuity does not lead to creation of internal cache.

8) In the methods BRepAdaptor_Curve::Bezier and BSpline do not call Transformed() if transformation is identity.

9) In the classes Geom_BSplineCurve, Geom_BSplineSurface, Geom_BezierCurve, Geom_BezierSurface, Geom2d_BSplineCurve, Geom2d_BezierCurve change the method Pole() to return the point by const reference.

10) In CPnts_AbscissaPoint.cxx, compute derivative by D1 instead of DN to make use of b-spline cache.

11) Change test cases to actual state:
  - Number of triangles/nodes can grow due to more accurate work with deflection of edges. Now the edge is tessellated using its own tolerance instead of maximal tolerance of all shapes in the face.
  - Accept new numbers of mesh errors (free links, free nodes) for really bad shapes.
  - Correct the test "bugs/mesh/bug25612" to produce stable result.
  - Disable redundant checks in test cases bug25378* (lower limit for computation time).

- Speed up iso-lines computation for offset of bspline surfaces. For that use adaptor instead of original surface in evaluator of approximation.
- Add output of polylines for debug of insertInternalVerticesOther().

Reference data in test case bugs\moddata_2\bug453_3 have been changed to be close to expected theoretical values. This makes the test give stable result on different platforms.
2016-07-07 14:24:39 +03:00

211 lines
9.5 KiB
C++

// 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 <TopoDS_Edge.hxx>
#include <Precision.hxx>
class BRepAdaptor_Curve;
class BRepAdaptor_HSurface;
class gp_Pnt;
class gp_Pnt2d;
class gp_Dir;
//! Tool class accumulating common geometrical functions as well as
//! functionality using shape geometry to produce data necessary for
//! tessellation.
//! General aim is to calculate discretization points for the given
//! curve or iso curve of surface according to the specified parameters.
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,
const Standard_Real theMinSize = Precision::Confusion());
//! 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,
const Standard_Real theMinSize = Precision::Confusion());
//! 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 theParam[out] parameter of the point on the curve.
//! @param thePoint[out] discretization point.
//! @return TRUE on success, FALSE elsewhere.
Standard_EXPORT Standard_Boolean Value(const Standard_Integer theIndex,
Standard_Real& theParam,
gp_Pnt& thePoint) const;
public: //! @name static API
//! Computes normal to the given surface at the specified
//! position in parametric space.
//! @param theSurface surface the normal 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.
Standard_EXPORT 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.
Standard_EXPORT 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.
Standard_EXPORT 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