1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0032241: Mesh - wrong shading display of thrusections [regression since OCCT 7.4.0]

0032422: Mesh - Weird rendering
0029641: Mesher produce 'bad' result for extruded spline with given deviation coefficient

Added method BRepMesh_NURBSRangeSplitter::getUndefinedInterval() intended to compute checkpoint parameters for those NURBS surfaces which have no intervals at all. In this case number of poles is used to produce artificial regular grid which can be refined further. Add at least one midpoint for surfaces with one interval and only two poles.

Added BRepMesh_ExtrusionRangeSplitter and BRepMesh_UndefinedRangeSplitter derivatives from BRepMesh_NURBSRangeSplitter intended to handle special cases of extrusion surfaces and general surfaces with undefined parameters.
This commit is contained in:
oan
2022-09-09 11:29:38 +03:00
committed by smoskvin
parent f3573fb54b
commit c4ea4ca3d1
54 changed files with 392 additions and 64 deletions

View File

@@ -0,0 +1,45 @@
// Created on: 2022-09-07
// Copyright (c) 2022 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// 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_ExtrusionRangeSplitter.hxx>
//=======================================================================
// Function: getUndefinedIntervalNb
// Purpose :
//=======================================================================
Standard_Integer BRepMesh_ExtrusionRangeSplitter::getUndefinedIntervalNb(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean /*isU*/,
const GeomAbs_Shape theContinuity) const
{
// Here we need just a regular grid along dimension with no
// geometrical data regarding intervals like extrusion surface.
const Handle(Adaptor3d_Curve) aCurve = theSurface->BasisCurve();
Standard_Integer aIntervalsNb = aCurve->NbIntervals(theContinuity);
if (aIntervalsNb == 1)
{
const GeomAbs_CurveType aCurveType = aCurve->GetType();
const Standard_Boolean isBSplineCurve =
aCurveType == GeomAbs_BezierCurve ||
aCurveType == GeomAbs_BSplineCurve;
if (isBSplineCurve)
{
aIntervalsNb = aCurve->NbPoles() - 1;
}
}
return aIntervalsNb;
}

View File

@@ -0,0 +1,45 @@
// Created on: 2022-09-07
// Copyright (c) 2022 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// 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_ExtrusionRangeSplitter_HeaderFile
#define _BRepMesh_ExtrusionRangeSplitter_HeaderFile
#include <BRepMesh_NURBSRangeSplitter.hxx>
//! Auxiliary class analysing extrusion surface in order to generate internal nodes.
class BRepMesh_ExtrusionRangeSplitter : public BRepMesh_NURBSRangeSplitter
{
public:
//! Constructor.
BRepMesh_ExtrusionRangeSplitter()
{
}
//! Destructor.
virtual ~BRepMesh_ExtrusionRangeSplitter()
{
}
protected:
//! Returns number of intervals computed using available geometrical parameters.
Standard_EXPORT virtual Standard_Integer getUndefinedIntervalNb(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean isU,
const GeomAbs_Shape theContinuity) const Standard_OVERRIDE;
};
#endif

View File

@@ -21,6 +21,8 @@
#include <BRepMesh_DelaunayBaseMeshAlgo.hxx>
#include <BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx>
#include <BRepMesh_BoundaryParamsRangeSplitter.hxx>
#include <BRepMesh_ExtrusionRangeSplitter.hxx>
#include <BRepMesh_UndefinedRangeSplitter.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_MeshAlgoFactory, IMeshTools_MeshAlgoFactory)
@@ -98,7 +100,18 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo(
return new DeflectionControlMeshAlgo<BRepMesh_BoundaryParamsRangeSplitter>::Type;
break;
default:
case GeomAbs_SurfaceOfExtrusion:
return new DeflectionControlMeshAlgo<BRepMesh_ExtrusionRangeSplitter>::Type;
break;
case GeomAbs_BezierSurface:
case GeomAbs_BSplineSurface:
return new DeflectionControlMeshAlgo<BRepMesh_NURBSRangeSplitter>::Type;
break;
case GeomAbs_OffsetSurface:
case GeomAbs_OtherSurface:
default:
return new DeflectionControlMeshAlgo<BRepMesh_UndefinedRangeSplitter>::Type;
}
}

View File

@@ -392,27 +392,73 @@ Handle(IMeshData::ListOfPnt2d) BRepMesh_NURBSRangeSplitter::GenerateSurfaceNodes
return aNodes;
}
//=======================================================================
// Function: getUndefinedIntervalNb
// Purpose :
//=======================================================================
Standard_Integer BRepMesh_NURBSRangeSplitter::getUndefinedIntervalNb(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean isU,
const GeomAbs_Shape /*theContinuity*/) const
{
return (isU ? theSurface->NbUPoles() : theSurface->NbVPoles()) - 1;
}
//=======================================================================
// Function: getUndefinedInterval
// Purpose :
//=======================================================================
void BRepMesh_NURBSRangeSplitter::getUndefinedInterval(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean isU,
const GeomAbs_Shape theContinuity,
const std::pair<Standard_Real, Standard_Real>& theRange,
TColStd_Array1OfReal& theIntervals) const
{
Standard_Integer aIntervalsNb = isU ?
theSurface->NbUIntervals(theContinuity) :
theSurface->NbVIntervals(theContinuity);
if (aIntervalsNb == 1)
{
aIntervalsNb = getUndefinedIntervalNb(theSurface, isU, theContinuity);
if (aIntervalsNb > 1)
{
theIntervals = TColStd_Array1OfReal(1, aIntervalsNb - 1);
const Standard_Real aDiff = (theRange.second - theRange.first) / aIntervalsNb;
for (Standard_Integer i = theIntervals.Lower(); i <= theIntervals.Upper(); ++i)
{
theIntervals.SetValue(i, theRange.first + i * aDiff);
}
}
}
if (theIntervals.IsEmpty())
{
theIntervals = TColStd_Array1OfReal(1, aIntervalsNb + 1);
if (isU)
{
theSurface->UIntervals(theIntervals, theContinuity);
}
else
{
theSurface->VIntervals(theIntervals, theContinuity);
}
}
}
//=======================================================================
// Function: initParameters
// Purpose :
//=======================================================================
Standard_Boolean BRepMesh_NURBSRangeSplitter::initParameters() const
{
const GeomAbs_Shape aContinuity = GeomAbs_CN;
const Handle(BRepAdaptor_Surface)& aSurface = GetSurface();
const GeomAbs_Shape aContinuity = GeomAbs_CN;
const std::pair<Standard_Integer, Standard_Integer> aIntervalsNb(
aSurface->NbUIntervals(aContinuity),
aSurface->NbVIntervals(aContinuity)
);
TColStd_Array1OfReal aIntervals[2] = {
TColStd_Array1OfReal(1, aIntervalsNb.first + 1),
TColStd_Array1OfReal(1, aIntervalsNb.second + 1)
};
aSurface->UIntervals(aIntervals[0], aContinuity);
aSurface->VIntervals(aIntervals[1], aContinuity);
TColStd_Array1OfReal aIntervals[2];
getUndefinedInterval(aSurface, Standard_True, aContinuity, GetRangeU(), aIntervals[0]);
getUndefinedInterval(aSurface, Standard_False, aContinuity, GetRangeV(), aIntervals[1]);
const Standard_Boolean isSplitIntervals = toSplitIntervals (aSurface->Surface().Surface(), aIntervals);

View File

@@ -49,7 +49,21 @@ protected:
//! Initializes U and V parameters lists using CN continuity intervals.
Standard_EXPORT virtual Standard_Boolean initParameters() const;
//! Returns number of intervals computed using available geometrical parameters.
Standard_EXPORT virtual Standard_Integer getUndefinedIntervalNb(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean isU,
const GeomAbs_Shape theContinuity) const;
private:
//! Tries to compute intervals even for cases with no intervals
//! at all using available geometrical parameters.
void getUndefinedInterval(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean isU,
const GeomAbs_Shape theContinuity,
const std::pair<Standard_Real, Standard_Real>& theRange,
TColStd_Array1OfReal& theIntervals) const;
//! Computes parameters of filter and applies it to the source parameters.
Handle(IMeshData::SequenceOfReal) computeGrainAndFilterParameters(

View File

@@ -0,0 +1,28 @@
// Created on: 2022-09-07
// Copyright (c) 2022 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// 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_UndefinedRangeSplitter.hxx>
//=======================================================================
// Function: getUndefinedIntervalNb
// Purpose :
//=======================================================================
Standard_Integer BRepMesh_UndefinedRangeSplitter::getUndefinedIntervalNb(
const Handle(Adaptor3d_Surface)& /*theSurface*/,
const Standard_Boolean /*isU*/,
const GeomAbs_Shape /*theContinuity*/) const
{
return 1;
}

View File

@@ -0,0 +1,46 @@
// Created on: 2022-09-07
// Copyright (c) 2022 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// 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_UndefinedRangeSplitter_HeaderFile
#define _BRepMesh_UndefinedRangeSplitter_HeaderFile
#include <BRepMesh_NURBSRangeSplitter.hxx>
//! Auxiliary class provides safe value for surfaces that looks like NURBS
//! but has no poles or other characteristics.
class BRepMesh_UndefinedRangeSplitter : public BRepMesh_NURBSRangeSplitter
{
public:
//! Constructor.
BRepMesh_UndefinedRangeSplitter()
{
}
//! Destructor.
virtual ~BRepMesh_UndefinedRangeSplitter()
{
}
protected:
//! Returns number of intervals computed using available geometrical parameters.
Standard_EXPORT virtual Standard_Integer getUndefinedIntervalNb(
const Handle(Adaptor3d_Surface)& theSurface,
const Standard_Boolean isU,
const GeomAbs_Shape theContinuity) const Standard_OVERRIDE;
};
#endif

View File

@@ -40,6 +40,8 @@ BRepMesh_EdgeDiscret.hxx
BRepMesh_EdgeParameterProvider.hxx
BRepMesh_EdgeTessellationExtractor.cxx
BRepMesh_EdgeTessellationExtractor.hxx
BRepMesh_ExtrusionRangeSplitter.cxx
BRepMesh_ExtrusionRangeSplitter.hxx
BRepMesh_FaceChecker.cxx
BRepMesh_FaceChecker.hxx
BRepMesh_FaceDiscret.cxx
@@ -80,6 +82,8 @@ BRepMesh_SphereRangeSplitter.hxx
BRepMesh_TorusRangeSplitter.cxx
BRepMesh_TorusRangeSplitter.hxx
BRepMesh_Triangle.hxx
BRepMesh_UndefinedRangeSplitter.cxx
BRepMesh_UndefinedRangeSplitter.hxx
BRepMesh_UVParamRangeSplitter.hxx
BRepMesh_Vertex.hxx
BRepMesh_VertexInspector.hxx