Modeling Algorithms - Refactor IntCurveSurface and HLRBRep intersection packages (#912)

Modernized curve/surface intersection algorithms by replacing preprocessor-based
generic programming (.gxx macros) with C++ templates (.pxx headers):

IntCurveSurface package (TKGeomAlgo):
- Introduced IntCurveSurface_Inter.pxx with callback-based template functions
  for intersection algorithms, replacing IntCurveSurface_Inter.gxx
- Created IntCurveSurface_InterUtils.pxx with utility template functions for
  surface decomposition, UV clamping, and quadric intersection handling
- Added IntCurveSurface_PolygonUtils.pxx for polygon construction utilities
- Added IntCurveSurface_PolyhedronUtils.pxx for polyhedron construction utilities
- Added IntCurveSurface_QuadricCurveExactInterUtils.pxx for exact quadric
  intersection computations
- Converted standalone implementation files from macro instantiation (_0.cxx)
  to direct template usage (.cxx)
- Removed obsolete .gxx and .lxx files

HLRBRep package (TKHLR):
- Updated HLRBRep_InterCSurf to use new IntCurveSurface template utilities
- Converted HLRBRep polygon, polyhedron, and intersection classes to use
  modern template instantiation pattern
- Removed legacy macro-based instantiation files (_0.cxx)

This refactoring improves code maintainability, enables better IDE support
and debugging, and aligns with modern C++ practices while preserving
the existing API and functionality.
This commit is contained in:
Pasukhin Dmitry
2025-12-15 20:38:53 +00:00
committed by GitHub
parent 6571d532bf
commit fff55ee5fc
39 changed files with 6384 additions and 4347 deletions

View File

@@ -3,8 +3,8 @@ set(OCCT_IntCurveSurface_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_IntCurveSurface_FILES
IntCurveSurface_HInter.hxx
IntCurveSurface_HInter_0.cxx
IntCurveSurface_Inter.gxx
IntCurveSurface_HInter.cxx
IntCurveSurface_Inter.pxx
IntCurveSurface_Intersection.cxx
IntCurveSurface_Intersection.hxx
IntCurveSurface_IntersectionPoint.cxx
@@ -12,12 +12,10 @@ set(OCCT_IntCurveSurface_FILES
IntCurveSurface_IntersectionPoint.lxx
IntCurveSurface_IntersectionSegment.cxx
IntCurveSurface_IntersectionSegment.hxx
IntCurveSurface_Polygon.gxx
IntCurveSurface_PolygonTool.lxx
IntCurveSurface_Polyhedron.gxx
IntCurveSurface_Polyhedron.lxx
IntCurveSurface_PolyhedronTool.lxx
IntCurveSurface_QuadricCurveExactInter.gxx
IntCurveSurface_InterUtils.pxx
IntCurveSurface_PolygonUtils.pxx
IntCurveSurface_PolyhedronUtils.pxx
IntCurveSurface_QuadricCurveExactInterUtils.pxx
IntCurveSurface_SequenceOfPnt.hxx
IntCurveSurface_SequenceOfSeg.hxx
IntCurveSurface_TheCSFunctionOfHInter.hxx
@@ -29,16 +27,16 @@ set(OCCT_IntCurveSurface_FILES
IntCurveSurface_TheInterferenceOfHInter.hxx
IntCurveSurface_TheInterferenceOfHInter_0.cxx
IntCurveSurface_ThePolygonOfHInter.hxx
IntCurveSurface_ThePolygonOfHInter_0.cxx
IntCurveSurface_ThePolygonOfHInter.cxx
IntCurveSurface_ThePolygonToolOfHInter.hxx
IntCurveSurface_ThePolygonToolOfHInter_0.cxx
IntCurveSurface_ThePolygonToolOfHInter.cxx
IntCurveSurface_ThePolyhedronOfHInter.hxx
IntCurveSurface_ThePolyhedronOfHInter_0.cxx
IntCurveSurface_ThePolyhedronOfHInter.cxx
IntCurveSurface_ThePolyhedronToolOfHInter.hxx
IntCurveSurface_ThePolyhedronToolOfHInter_0.cxx
IntCurveSurface_ThePolyhedronToolOfHInter.cxx
IntCurveSurface_TheQuadCurvExactHInter.hxx
IntCurveSurface_TheQuadCurvExactHInter_0.cxx
IntCurveSurface_TheQuadCurvExactHInter.cxx
IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx
IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter_0.cxx
IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.cxx
IntCurveSurface_TransitionOnCurve.hxx
)

View File

@@ -0,0 +1,584 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_HInter.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <Bnd_Box.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Lin.hxx>
#include <gp_Parab.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <IntCurveSurface_TheCSFunctionOfHInter.hxx>
#include <IntCurveSurface_TheExactHInter.hxx>
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <IntCurveSurface_TheInterferenceOfHInter.hxx>
#include <IntCurveSurface_ThePolygonOfHInter.hxx>
#include <IntCurveSurface_ThePolygonToolOfHInter.hxx>
#include <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <IntCurveSurface_ThePolyhedronToolOfHInter.hxx>
#include <IntCurveSurface_TheQuadCurvExactHInter.hxx>
#include <IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#include "IntCurveSurface_Inter.pxx"
// Type aliases for readability
using TheCurve = Handle(Adaptor3d_Curve);
using TheCurveTool = IntCurveSurface_TheHCurveTool;
using TheSurface = Handle(Adaptor3d_Surface);
using TheSurfaceTool = Adaptor3d_HSurfaceTool;
using ThePolygon = IntCurveSurface_ThePolygonOfHInter;
using ThePolyhedron = IntCurveSurface_ThePolyhedronOfHInter;
using TheInterference = IntCurveSurface_TheInterferenceOfHInter;
using TheCSFunction = IntCurveSurface_TheCSFunctionOfHInter;
using TheExactInter = IntCurveSurface_TheExactHInter;
using TheQuadCurvExactInter = IntCurveSurface_TheQuadCurvExactHInter;
//==================================================================================================
IntCurveSurface_HInter::IntCurveSurface_HInter() {}
//==================================================================================================
void IntCurveSurface_HInter::DoSurface(const TheSurface& surface,
const Standard_Real u0,
const Standard_Real u1,
const Standard_Real v0,
const Standard_Real v1,
TColgp_Array2OfPnt& pntsOnSurface,
Bnd_Box& boxSurface,
Standard_Real& gap)
{
IntCurveSurface_InterUtils::DoSurface<TheSurface, TheSurfaceTool>(surface,
u0,
u1,
v0,
v1,
pntsOnSurface,
boxSurface,
gap);
}
//==================================================================================================
void IntCurveSurface_HInter::DoNewBounds(const TheSurface& surface,
const Standard_Real u0,
const Standard_Real u1,
const Standard_Real v0,
const Standard_Real v1,
const TColgp_Array2OfPnt& pntsOnSurface,
const TColStd_Array1OfReal& X,
const TColStd_Array1OfReal& Y,
const TColStd_Array1OfReal& Z,
TColStd_Array1OfReal& Bounds)
{
IntCurveSurface_InterUtils::DoNewBounds<TheSurface, TheSurfaceTool>(surface,
u0,
u1,
v0,
v1,
pntsOnSurface,
X,
Y,
Z,
Bounds);
}
//==================================================================================================
void IntCurveSurface_HInter::Perform(const TheCurve& curve, const TheSurface& surface)
{
IntCurveSurface_InterImpl::Perform<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool>(
curve,
surface,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c,
const TheSurface& s,
Standard_Real u0,
Standard_Real v0,
Standard_Real u1,
Standard_Real v1) { this->Perform(c, s, u0, v0, u1, v1); });
}
//==================================================================================================
void IntCurveSurface_HInter::Perform(const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::
PerformBounds<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon>(
curve,
surface,
U1,
V1,
U2,
V2,
[this](const auto& conic,
const TheCurve& c,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->PerformConicSurf(conic, c, s, u1, v1, u2, v2); },
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, u1, v1, u2, v2); },
[this](const TheCurve& c, const TheSurface& s) { this->InternalPerformCurveQuadric(c, s); });
}
//==================================================================================================
void IntCurveSurface_HInter::Perform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface)
{
IntCurveSurface_InterImpl::
PerformPolygon<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon, ThePolyhedron>(
curve,
polygon,
surface,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c, const ThePolygon& p, const TheSurface& s, const ThePolyhedron& ph) {
this->Perform(c, p, s, ph);
});
}
//==================================================================================================
void IntCurveSurface_HInter::Perform(const TheCurve& curve,
const TheSurface& surface,
const ThePolyhedron& polyhedron)
{
IntCurveSurface_InterImpl::PerformPolyhedron<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
curve,
surface,
polyhedron,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c, const ThePolygon& p, const TheSurface& s, const ThePolyhedron& ph) {
this->Perform(c, p, s, ph);
});
}
//==================================================================================================
void IntCurveSurface_HInter::Perform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron)
{
IntCurveSurface_InterImpl::PerformPolygonPolyhedron<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
curve,
polygon,
surface,
polyhedron,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); });
}
//==================================================================================================
void IntCurveSurface_HInter::Perform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron,
Bnd_BoundSortBox& BndBSB)
{
IntCurveSurface_InterImpl::PerformPolygonPolyhedronBSB<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
curve,
polygon,
surface,
polyhedron,
BndBSB,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2,
Bnd_BoundSortBox& bsb) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2, bsb); });
}
//==================================================================================================
void IntCurveSurface_HInter::InternalPerform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron,
const Standard_Real u0,
const Standard_Real v0,
const Standard_Real u1,
const Standard_Real v1,
Bnd_BoundSortBox& BSB)
{
IntCurveSurface_InterImpl::InternalPerformBSB<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron,
TheInterference,
TheCSFunction,
TheExactInter>(
curve,
polygon,
surface,
polyhedron,
u0,
v0,
u1,
v1,
BSB,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void IntCurveSurface_HInter::InternalPerform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron,
const Standard_Real u0,
const Standard_Real v0,
const Standard_Real u1,
const Standard_Real v1)
{
IntCurveSurface_InterImpl::InternalPerform<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron,
TheInterference,
TheCSFunction,
TheExactInter>(
curve,
polygon,
surface,
polyhedron,
u0,
v0,
u1,
v1,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void IntCurveSurface_HInter::InternalPerformCurveQuadric(const TheCurve& curve,
const TheSurface& surface)
{
IntCurveSurface_InterImpl::InternalPerformCurveQuadric<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
TheQuadCurvExactInter>(
curve,
surface,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void IntCurveSurface_HInter::InternalPerform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::InternalPerformPolygonBounds<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron,
TheQuadCurvExactInter>(
curve,
polygon,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); },
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void IntCurveSurface_HInter::PerformConicSurf(const gp_Lin& Line,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::PerformConicSurfLine<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
Line,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); },
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void IntCurveSurface_HInter::PerformConicSurf(const gp_Circ& Circle,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::
PerformConicSurfCircle<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon>(
Circle,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, u1, v1, u2, v2); });
}
//==================================================================================================
void IntCurveSurface_HInter::PerformConicSurf(const gp_Elips& Ellipse,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::
PerformConicSurfEllipse<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon>(
Ellipse,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, u1, v1, u2, v2); });
}
//==================================================================================================
void IntCurveSurface_HInter::PerformConicSurf(const gp_Parab& Parab,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::PerformConicSurfParabola<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
Parab,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); });
}
//==================================================================================================
void IntCurveSurface_HInter::PerformConicSurf(const gp_Hypr& Hypr,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::PerformConicSurfHyperbola<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
Hypr,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); });
}
//==================================================================================================
void IntCurveSurface_HInter::AppendIntAna(const TheCurve& curve,
const TheSurface& surface,
const IntAna_IntConicQuad& intana_ConicQuad)
{
IntCurveSurface_InterImpl::AppendIntAna<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool>(
curve,
surface,
intana_ConicQuad,
myIsParallel,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void IntCurveSurface_HInter::AppendPoint(const TheCurve& curve,
const Standard_Real lw,
const TheSurface& surface,
const Standard_Real su,
const Standard_Real sv)
{
IntCurveSurface_IntersectionPoint aPoint;
if (IntCurveSurface_InterUtils::
ComputeAppendPoint<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool>(curve,
lw,
surface,
su,
sv,
aPoint))
{
Append(aPoint);
}
}
//==================================================================================================
void IntCurveSurface_HInter::AppendSegment(const TheCurve&,
const Standard_Real,
const Standard_Real,
const TheSurface&)
{
// Not implemented
}

View File

@@ -1,75 +0,0 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_HInter.hxx>
#include <Adaptor3d_Curve.hxx>
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <IntCurveSurface_ThePolygonOfHInter.hxx>
#include <IntCurveSurface_ThePolygonToolOfHInter.hxx>
#include <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <IntCurveSurface_ThePolyhedronToolOfHInter.hxx>
#include <IntCurveSurface_TheInterferenceOfHInter.hxx>
#include <IntCurveSurface_TheCSFunctionOfHInter.hxx>
#include <IntCurveSurface_TheExactHInter.hxx>
#include <IntCurveSurface_TheQuadCurvExactHInter.hxx>
#include <IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Parab.hxx>
#include <gp_Hypr.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <Bnd_Box.hxx>
#define TheCurve Handle(Adaptor3d_Curve)
#define TheCurve_hxx <Adaptor3d_Curve.hxx>
#define TheCurveTool IntCurveSurface_TheHCurveTool
#define TheCurveTool_hxx <IntCurveSurface_TheHCurveTool.hxx>
#define TheSurface Handle(Adaptor3d_Surface)
#define TheSurface_hxx <Adaptor3d_Surface.hxx>
#define TheSurfaceTool Adaptor3d_HSurfaceTool
#define TheSurfaceTool_hxx <Adaptor3d_HSurfaceTool.hxx>
#define IntCurveSurface_ThePolygon IntCurveSurface_ThePolygonOfHInter
#define IntCurveSurface_ThePolygon_hxx <IntCurveSurface_ThePolygonOfHInter.hxx>
#define IntCurveSurface_ThePolygonTool IntCurveSurface_ThePolygonToolOfHInter
#define IntCurveSurface_ThePolygonTool_hxx <IntCurveSurface_ThePolygonToolOfHInter.hxx>
#define IntCurveSurface_ThePolyhedron IntCurveSurface_ThePolyhedronOfHInter
#define IntCurveSurface_ThePolyhedron_hxx <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#define IntCurveSurface_ThePolyhedronTool IntCurveSurface_ThePolyhedronToolOfHInter
#define IntCurveSurface_ThePolyhedronTool_hxx <IntCurveSurface_ThePolyhedronToolOfHInter.hxx>
#define IntCurveSurface_TheInterference IntCurveSurface_TheInterferenceOfHInter
#define IntCurveSurface_TheInterference_hxx <IntCurveSurface_TheInterferenceOfHInter.hxx>
#define IntCurveSurface_TheCSFunction IntCurveSurface_TheCSFunctionOfHInter
#define IntCurveSurface_TheCSFunction_hxx <IntCurveSurface_TheCSFunctionOfHInter.hxx>
#define IntCurveSurface_TheExactInter IntCurveSurface_TheExactHInter
#define IntCurveSurface_TheExactInter_hxx <IntCurveSurface_TheExactHInter.hxx>
#define IntCurveSurface_TheQuadCurvExactInter IntCurveSurface_TheQuadCurvExactHInter
#define IntCurveSurface_TheQuadCurvExactInter_hxx <IntCurveSurface_TheQuadCurvExactHInter.hxx>
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter \
IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter_hxx \
<IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter \
IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter_hxx \
<IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#define IntCurveSurface_Inter IntCurveSurface_HInter
#define IntCurveSurface_Inter_hxx <IntCurveSurface_HInter.hxx>
#include <IntCurveSurface_Inter.gxx>

View File

@@ -0,0 +1,971 @@
// 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.
#ifndef IntCurveSurface_Inter_PXX
#define IntCurveSurface_Inter_PXX
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Adaptor3d_TopolTool.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <Bnd_Box.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_Shape.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Lin.hxx>
#include <gp_Parab.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <IntCurveSurface_IntersectionPoint.hxx>
#include <Intf_Tool.hxx>
#include <math_FunctionSetRoot.hxx>
#include <NCollection_Vector.hxx>
#include <Precision.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include "IntCurveSurface_InterUtils.pxx"
namespace IntCurveSurface_InterImpl
{
constexpr double THE_TOLTANGENCY = 0.00000001;
constexpr double THE_TOLERANCE_ANGULAIRE = 1.e-12;
constexpr double THE_TOLERANCE = 0.00000001;
constexpr int THE_NBSAMPLESONCIRCLE = 32;
constexpr int THE_NBSAMPLESONELLIPSE = 32;
constexpr int THE_NBSAMPLESONPARAB = 16;
constexpr int THE_NBSAMPLESONHYPR = 32;
//! Perform intersection decomposing surface by C2 intervals.
//! @tparam CurveType The curve type
//! @tparam CurveTool The curve tool class
//! @tparam SurfaceType The surface type
//! @tparam SurfaceTool The surface tool class
//! @tparam PerformBoundsFunc Callback type for Perform with bounds
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename ResetFunc,
typename PerformBoundsFunc>
void Perform(const CurveType& theCurve,
const SurfaceType& theSurface,
bool& theDone,
ResetFunc theReset,
PerformBoundsFunc thePerformBounds)
{
theReset();
theDone = true;
NCollection_Vector<IntCurveSurface_InterUtils::UVBounds> aIntervals;
IntCurveSurface_InterUtils::DecomposeSurfaceIntervals<SurfaceType, SurfaceTool>(theSurface,
aIntervals);
for (const IntCurveSurface_InterUtils::UVBounds& aBounds : aIntervals)
{
thePerformBounds(theCurve, theSurface, aBounds.U0, aBounds.V0, aBounds.U1, aBounds.V1);
}
}
//! Perform intersection with given UV bounds.
//! @tparam CurveType The curve type
//! @tparam CurveTool The curve tool class
//! @tparam SurfaceType The surface type
//! @tparam SurfaceTool The surface tool class
//! @tparam PolygonType The polygon type
//! @tparam PerformConicFunc Callback for conic surface intersection
//! @tparam InternalPerformFunc Callback for internal perform
//! @tparam InternalPerformQuadricFunc Callback for quadric perform
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PerformConicFunc,
typename InternalPerformFunc,
typename InternalPerformQuadricFunc>
void PerformBounds(const CurveType& theCurve,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
PerformConicFunc thePerformConic,
InternalPerformFunc theInternalPerform,
InternalPerformQuadricFunc theInternalPerformQuadric)
{
// Protection from double type overflow (bug26525).
Standard_Real UU1 = theU1, UU2 = theU2, VV1 = theV1, VV2 = theV2;
IntCurveSurface_InterUtils::ClampUVParameters(UU1, UU2, VV1, VV2);
GeomAbs_CurveType aCurveType = CurveTool::GetType(theCurve);
switch (aCurveType)
{
case GeomAbs_Line:
thePerformConic(CurveTool::Line(theCurve), theCurve, theSurface, UU1, VV1, UU2, VV2);
break;
case GeomAbs_Circle:
thePerformConic(CurveTool::Circle(theCurve), theCurve, theSurface, UU1, VV1, UU2, VV2);
break;
case GeomAbs_Ellipse:
thePerformConic(CurveTool::Ellipse(theCurve), theCurve, theSurface, UU1, VV1, UU2, VV2);
break;
case GeomAbs_Parabola:
thePerformConic(CurveTool::Parabola(theCurve), theCurve, theSurface, UU1, VV1, UU2, VV2);
break;
case GeomAbs_Hyperbola:
thePerformConic(CurveTool::Hyperbola(theCurve), theCurve, theSurface, UU1, VV1, UU2, VV2);
break;
default: {
Standard_Integer nbIntervalsOnCurve = CurveTool::NbIntervals(theCurve, GeomAbs_C2);
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
if ((aSurfaceType != GeomAbs_Plane) && (aSurfaceType != GeomAbs_Cylinder)
&& (aSurfaceType != GeomAbs_Cone) && (aSurfaceType != GeomAbs_Sphere))
{
if (nbIntervalsOnCurve > 1)
{
TColStd_Array1OfReal TabW(1, nbIntervalsOnCurve + 1);
CurveTool::Intervals(theCurve, TabW, GeomAbs_C2);
for (Standard_Integer i = 1; i <= nbIntervalsOnCurve; i++)
{
Standard_Real u1 = TabW.Value(i);
Standard_Real u2 = TabW.Value(i + 1);
Handle(TColStd_HArray1OfReal) aPars;
Standard_Real defl = 0.1;
Standard_Integer NbMin = 10;
CurveTool::SamplePars(theCurve, u1, u2, defl, NbMin, aPars);
PolygonType polygon(theCurve, aPars->Array1());
theInternalPerform(theCurve, polygon, theSurface, UU1, VV1, UU2, VV2);
}
}
else
{
Standard_Real u1 = CurveTool::FirstParameter(theCurve);
Standard_Real u2 = CurveTool::LastParameter(theCurve);
Handle(TColStd_HArray1OfReal) aPars;
Standard_Real defl = 0.1;
Standard_Integer NbMin = 10;
CurveTool::SamplePars(theCurve, u1, u2, defl, NbMin, aPars);
PolygonType polygon(theCurve, aPars->Array1());
theInternalPerform(theCurve, polygon, theSurface, UU1, VV1, UU2, VV2);
}
}
else
{
theInternalPerformQuadric(theCurve, theSurface);
}
}
}
}
//! Perform with polygon, creating polyhedron internally.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename ResetFunc,
typename PerformPolyFunc>
void PerformPolygon(const CurveType& theCurve,
const PolygonType& thePolygon,
const SurfaceType& theSurface,
bool& theDone,
ResetFunc theReset,
PerformPolyFunc thePerformPoly)
{
theReset();
theDone = true;
Standard_Real u1 = SurfaceTool::FirstUParameter(theSurface);
Standard_Real v1 = SurfaceTool::FirstVParameter(theSurface);
Standard_Real u2 = SurfaceTool::LastUParameter(theSurface);
Standard_Real v2 = SurfaceTool::LastVParameter(theSurface);
Standard_Integer nbsu = SurfaceTool::NbSamplesU(theSurface, u1, u2);
Standard_Integer nbsv = SurfaceTool::NbSamplesV(theSurface, v1, v2);
if (nbsu > 40)
nbsu = 40;
if (nbsv > 40)
nbsv = 40;
PolyhedronType polyhedron(theSurface, nbsu, nbsv, u1, v1, u2, v2);
thePerformPoly(theCurve, thePolygon, theSurface, polyhedron);
}
//! Perform with polyhedron, creating polygon internally.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename ResetFunc,
typename PerformPolyFunc>
void PerformPolyhedron(const CurveType& theCurve,
const SurfaceType& theSurface,
const PolyhedronType& thePolyhedron,
bool& theDone,
ResetFunc theReset,
PerformPolyFunc thePerformPoly)
{
theReset();
theDone = true;
Standard_Real u1 = CurveTool::FirstParameter(theCurve);
Standard_Real u2 = CurveTool::LastParameter(theCurve);
PolygonType polygon(theCurve, CurveTool::NbSamples(theCurve, u1, u2));
thePerformPoly(theCurve, polygon, theSurface, thePolyhedron);
}
//! Perform with both polygon and polyhedron provided.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename ResetFunc,
typename InternalPerformFunc>
void PerformPolygonPolyhedron(const CurveType& theCurve,
const PolygonType& thePolygon,
const SurfaceType& theSurface,
const PolyhedronType& thePolyhedron,
bool& theDone,
ResetFunc theReset,
InternalPerformFunc theInternalPerform)
{
theReset();
theDone = true;
Standard_Real u1 = SurfaceTool::FirstUParameter(theSurface);
Standard_Real v1 = SurfaceTool::FirstVParameter(theSurface);
Standard_Real u2 = SurfaceTool::LastUParameter(theSurface);
Standard_Real v2 = SurfaceTool::LastVParameter(theSurface);
theInternalPerform(theCurve, thePolygon, theSurface, thePolyhedron, u1, v1, u2, v2);
}
//! Perform with polygon, polyhedron and bounding sort box.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename ResetFunc,
typename InternalPerformBSBFunc>
void PerformPolygonPolyhedronBSB(const CurveType& theCurve,
const PolygonType& thePolygon,
const SurfaceType& theSurface,
const PolyhedronType& thePolyhedron,
Bnd_BoundSortBox& theBSB,
bool& theDone,
ResetFunc theReset,
InternalPerformBSBFunc theInternalPerform)
{
theReset();
theDone = true;
Standard_Real u1 = SurfaceTool::FirstUParameter(theSurface);
Standard_Real v1 = SurfaceTool::FirstVParameter(theSurface);
Standard_Real u2 = SurfaceTool::LastUParameter(theSurface);
Standard_Real v2 = SurfaceTool::LastVParameter(theSurface);
theInternalPerform(theCurve, thePolygon, theSurface, thePolyhedron, u1, v1, u2, v2, theBSB);
}
//! Internal perform with interference from BSB.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename InterferenceType,
typename CSFunctionType,
typename ExactInterType,
typename AppendFunc>
void InternalPerformBSB(const CurveType& theCurve,
const PolygonType& thePolygon,
const SurfaceType& theSurface,
const PolyhedronType& thePolyhedron,
const Standard_Real theU0,
const Standard_Real theV0,
const Standard_Real theU1,
const Standard_Real theV1,
Bnd_BoundSortBox& theBSB,
AppendFunc theAppend)
{
InterferenceType interference(thePolygon, thePolyhedron, theBSB);
CSFunctionType theicsfunction(theSurface, theCurve);
ExactInterType intersectionExacte(theicsfunction, THE_TOLTANGENCY);
math_FunctionSetRoot rsnld(intersectionExacte.Function());
Standard_Real winf = thePolygon.InfParameter();
Standard_Real wsup = thePolygon.SupParameter();
IntCurveSurface_InterUtils::SortedStartPoints aStartPoints;
IntCurveSurface_InterUtils::
CollectInterferencePoints<InterferenceType, PolyhedronType, PolygonType>(interference,
thePolyhedron,
thePolygon,
aStartPoints);
IntCurveSurface_InterUtils::SortStartPoints(aStartPoints);
NCollection_Vector<IntCurveSurface_IntersectionPoint> aResultPoints;
IntCurveSurface_InterUtils::
ProcessSortedPoints<ExactInterType, CurveType, CurveTool, SurfaceType, SurfaceTool>(
intersectionExacte,
rsnld,
aStartPoints,
theU0,
theU1,
theV0,
theV1,
winf,
wsup,
theCurve,
theSurface,
aResultPoints);
for (const IntCurveSurface_IntersectionPoint& aPoint : aResultPoints)
{
theAppend(aPoint);
}
}
//! Internal perform without BSB.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename InterferenceType,
typename CSFunctionType,
typename ExactInterType,
typename AppendFunc>
void InternalPerform(const CurveType& theCurve,
const PolygonType& thePolygon,
const SurfaceType& theSurface,
const PolyhedronType& thePolyhedron,
const Standard_Real theU0,
const Standard_Real theV0,
const Standard_Real theU1,
const Standard_Real theV1,
AppendFunc theAppend)
{
InterferenceType interference(thePolygon, thePolyhedron);
CSFunctionType theicsfunction(theSurface, theCurve);
ExactInterType intersectionExacte(theicsfunction, THE_TOLTANGENCY);
math_FunctionSetRoot rsnld(intersectionExacte.Function());
Standard_Real winf = thePolygon.InfParameter();
Standard_Real wsup = thePolygon.SupParameter();
IntCurveSurface_InterUtils::SortedStartPoints aStartPoints;
IntCurveSurface_InterUtils::
CollectInterferencePoints<InterferenceType, PolyhedronType, PolygonType>(interference,
thePolyhedron,
thePolygon,
aStartPoints);
IntCurveSurface_InterUtils::SortStartPoints(aStartPoints);
NCollection_Vector<IntCurveSurface_IntersectionPoint> aResultPoints;
IntCurveSurface_InterUtils::
ProcessSortedPoints<ExactInterType, CurveType, CurveTool, SurfaceType, SurfaceTool>(
intersectionExacte,
rsnld,
aStartPoints,
theU0,
theU1,
theV0,
theV1,
winf,
wsup,
theCurve,
theSurface,
aResultPoints);
for (const IntCurveSurface_IntersectionPoint& aPoint : aResultPoints)
{
theAppend(aPoint);
}
}
//! Internal perform for curve-quadric intersection.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename QuadCurvExactInterType,
typename AppendFunc>
void InternalPerformCurveQuadric(const CurveType& theCurve,
const SurfaceType& theSurface,
AppendFunc theAppend)
{
NCollection_Vector<IntCurveSurface_IntersectionPoint> aPoints;
IntCurveSurface_InterUtils::
PerformCurveQuadric<QuadCurvExactInterType, CurveType, CurveTool, SurfaceType, SurfaceTool>(
theCurve,
theSurface,
aPoints);
for (const IntCurveSurface_IntersectionPoint& aPoint : aPoints)
{
theAppend(aPoint);
}
}
//! Internal perform with polygon and UV bounds, creating polyhedron as needed.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename QuadCurvExactInterType,
typename InternalPerformPolyFunc,
typename AppendFunc>
void InternalPerformPolygonBounds(const CurveType& theCurve,
const PolygonType& thePolygon,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
InternalPerformPolyFunc theInternalPerformPoly,
AppendFunc theAppend)
{
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
if ((aSurfaceType != GeomAbs_Plane) && (aSurfaceType != GeomAbs_Cylinder)
&& (aSurfaceType != GeomAbs_Cone) && (aSurfaceType != GeomAbs_Sphere))
{
if (aSurfaceType != GeomAbs_BSplineSurface)
{
Standard_Integer nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2);
Standard_Integer nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2);
if (nbsu > 40)
nbsu = 40;
if (nbsv > 40)
nbsv = 40;
PolyhedronType polyhedron(theSurface, nbsu, nbsv, theU1, theV1, theU2, theV2);
theInternalPerformPoly(theCurve,
thePolygon,
theSurface,
polyhedron,
theU1,
theV1,
theU2,
theV2);
}
else
{
Handle(Adaptor3d_Surface) aS = SurfaceTool::UTrim(theSurface, theU1, theU2, 1.e-9);
aS = aS->VTrim(theV1, theV2, 1.e-9);
Handle(Adaptor3d_TopolTool) aTopTool = new Adaptor3d_TopolTool(aS);
Standard_Real defl = 0.1;
aTopTool->SamplePnts(defl, 10, 10);
Standard_Integer nbpu = aTopTool->NbSamplesU();
Standard_Integer nbpv = aTopTool->NbSamplesV();
TColStd_Array1OfReal Upars(1, nbpu), Vpars(1, nbpv);
aTopTool->UParameters(Upars);
aTopTool->VParameters(Vpars);
PolyhedronType polyhedron(theSurface, Upars, Vpars);
theInternalPerformPoly(theCurve,
thePolygon,
theSurface,
polyhedron,
theU1,
theV1,
theU2,
theV2);
}
}
else
{
InternalPerformCurveQuadric<CurveType,
CurveTool,
SurfaceType,
SurfaceTool,
QuadCurvExactInterType>(theCurve, theSurface, theAppend);
}
}
//! Perform conic (line) surface intersection.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename AppendIntAnaFunc,
typename InternalPerformPolyFunc,
typename AppendFunc>
void PerformConicSurfLine(const gp_Lin& theLine,
const CurveType& theCurve,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
AppendIntAnaFunc theAppendIntAna,
InternalPerformPolyFunc theInternalPerformPoly,
AppendFunc theAppend)
{
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
Standard_Boolean isAnaProcessed = Standard_True;
switch (aSurfaceType)
{
case GeomAbs_Plane: {
IntAna_IntConicQuad LinPlane(theLine,
SurfaceTool::Plane(theSurface),
THE_TOLERANCE_ANGULAIRE);
theAppendIntAna(theCurve, theSurface, LinPlane);
break;
}
case GeomAbs_Cylinder: {
IntAna_IntConicQuad LinCylinder(theLine, SurfaceTool::Cylinder(theSurface));
theAppendIntAna(theCurve, theSurface, LinCylinder);
break;
}
case GeomAbs_Sphere: {
IntAna_IntConicQuad LinSphere(theLine, SurfaceTool::Sphere(theSurface));
theAppendIntAna(theCurve, theSurface, LinSphere);
break;
}
case GeomAbs_Torus: {
NCollection_Vector<IntCurveSurface_IntersectionPoint> aPoints;
if (IntCurveSurface_InterUtils::
ProcessLinTorus<CurveType, CurveTool, SurfaceType, SurfaceTool>(theLine,
theCurve,
theSurface,
aPoints))
{
for (const IntCurveSurface_IntersectionPoint& aPoint : aPoints)
{
theAppend(aPoint);
}
}
else
isAnaProcessed = Standard_False;
break;
}
case GeomAbs_Cone: {
constexpr Standard_Real correction = 1.E+5 * Precision::Angular();
gp_Cone cn = SurfaceTool::Cone(theSurface);
if (std::abs(cn.SemiAngle()) < M_PI / 2.0 - correction)
{
IntAna_IntConicQuad LinCone(theLine, cn);
theAppendIntAna(theCurve, theSurface, LinCone);
}
else
isAnaProcessed = Standard_False;
break;
}
default:
isAnaProcessed = Standard_False;
}
if (!isAnaProcessed)
{
Standard_Integer nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2);
Standard_Integer nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2);
Standard_Boolean U1inf = Precision::IsInfinite(theU1);
Standard_Boolean U2inf = Precision::IsInfinite(theU2);
Standard_Boolean V1inf = Precision::IsInfinite(theV1);
Standard_Boolean V2inf = Precision::IsInfinite(theV2);
Standard_Real U1new = theU1, U2new = theU2, V1new = theV1, V2new = theV2;
Standard_Boolean NoIntersection = Standard_False;
if (U1inf || U2inf || V1inf || V2inf)
{
if (aSurfaceType == GeomAbs_SurfaceOfExtrusion)
{
IntCurveSurface_InterUtils::EstLimForInfExtr<SurfaceType, SurfaceTool>(theLine,
theSurface,
Standard_False,
nbsu,
U1inf,
U2inf,
V1inf,
V2inf,
U1new,
U2new,
V1new,
V2new,
NoIntersection);
}
else if (aSurfaceType == GeomAbs_SurfaceOfRevolution)
{
IntCurveSurface_InterUtils::EstLimForInfRevl<SurfaceType, SurfaceTool>(theLine,
theSurface,
U1inf,
U2inf,
V1inf,
V2inf,
U1new,
U2new,
V1new,
V2new,
NoIntersection);
}
else if (aSurfaceType == GeomAbs_OffsetSurface)
{
IntCurveSurface_InterUtils::EstLimForInfOffs<SurfaceType, SurfaceTool>(theLine,
theSurface,
nbsu,
U1inf,
U2inf,
V1inf,
V2inf,
U1new,
U2new,
V1new,
V2new,
NoIntersection);
}
else
{
IntCurveSurface_InterUtils::EstLimForInfSurf(U1new, U2new, V1new, V2new);
}
}
if (NoIntersection)
return;
if (nbsu < 20)
nbsu = 20;
if (nbsv < 20)
nbsv = 20;
PolyhedronType polyhedron(theSurface, nbsu, nbsv, U1new, V1new, U2new, V2new);
Intf_Tool bndTool;
Bnd_Box boxLine;
bndTool.LinBox(theLine, polyhedron.Bounding(), boxLine);
for (Standard_Integer nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++)
{
Standard_Real pinf = bndTool.BeginParam(nbseg);
Standard_Real psup = bndTool.EndParam(nbseg);
if ((psup - pinf) < 1e-10)
{
pinf -= 1e-10;
psup += 1e-10;
}
PolygonType polygon(theCurve, pinf, psup, 2);
theInternalPerformPoly(theCurve, polygon, theSurface, polyhedron, U1new, V1new, U2new, V2new);
}
}
}
//! Perform conic (circle) surface intersection.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename AppendIntAnaFunc,
typename InternalPerformFunc>
void PerformConicSurfCircle(const gp_Circ& theCircle,
const CurveType& theCurve,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
AppendIntAnaFunc theAppendIntAna,
InternalPerformFunc theInternalPerform)
{
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
switch (aSurfaceType)
{
case GeomAbs_Plane: {
IntAna_IntConicQuad CircPlane(theCircle,
SurfaceTool::Plane(theSurface),
THE_TOLERANCE_ANGULAIRE,
THE_TOLERANCE);
theAppendIntAna(theCurve, theSurface, CircPlane);
break;
}
case GeomAbs_Cylinder: {
IntAna_IntConicQuad CircCylinder(theCircle, SurfaceTool::Cylinder(theSurface));
theAppendIntAna(theCurve, theSurface, CircCylinder);
break;
}
case GeomAbs_Cone: {
IntAna_IntConicQuad CircCone(theCircle, SurfaceTool::Cone(theSurface));
theAppendIntAna(theCurve, theSurface, CircCone);
break;
}
case GeomAbs_Sphere: {
IntAna_IntConicQuad CircSphere(theCircle, SurfaceTool::Sphere(theSurface));
theAppendIntAna(theCurve, theSurface, CircSphere);
break;
}
default: {
PolygonType polygon(theCurve, THE_NBSAMPLESONCIRCLE);
theInternalPerform(theCurve, polygon, theSurface, theU1, theV1, theU2, theV2);
}
}
}
//! Perform conic (ellipse) surface intersection.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename AppendIntAnaFunc,
typename InternalPerformFunc>
void PerformConicSurfEllipse(const gp_Elips& theEllipse,
const CurveType& theCurve,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
AppendIntAnaFunc theAppendIntAna,
InternalPerformFunc theInternalPerform)
{
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
switch (aSurfaceType)
{
case GeomAbs_Plane: {
IntAna_IntConicQuad EllipsePlane(theEllipse,
SurfaceTool::Plane(theSurface),
THE_TOLERANCE_ANGULAIRE,
THE_TOLERANCE);
theAppendIntAna(theCurve, theSurface, EllipsePlane);
break;
}
case GeomAbs_Cylinder: {
IntAna_IntConicQuad EllipseCylinder(theEllipse, SurfaceTool::Cylinder(theSurface));
theAppendIntAna(theCurve, theSurface, EllipseCylinder);
break;
}
case GeomAbs_Cone: {
IntAna_IntConicQuad EllipseCone(theEllipse, SurfaceTool::Cone(theSurface));
theAppendIntAna(theCurve, theSurface, EllipseCone);
break;
}
case GeomAbs_Sphere: {
IntAna_IntConicQuad EllipseSphere(theEllipse, SurfaceTool::Sphere(theSurface));
theAppendIntAna(theCurve, theSurface, EllipseSphere);
break;
}
default: {
PolygonType polygon(theCurve, THE_NBSAMPLESONELLIPSE);
theInternalPerform(theCurve, polygon, theSurface, theU1, theV1, theU2, theV2);
}
}
}
//! Perform conic (parabola) surface intersection.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename AppendIntAnaFunc,
typename InternalPerformPolyFunc>
void PerformConicSurfParabola(const gp_Parab& theParab,
const CurveType& theCurve,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
AppendIntAnaFunc theAppendIntAna,
InternalPerformPolyFunc theInternalPerformPoly)
{
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
switch (aSurfaceType)
{
case GeomAbs_Plane: {
IntAna_IntConicQuad ParabPlane(theParab,
SurfaceTool::Plane(theSurface),
THE_TOLERANCE_ANGULAIRE);
theAppendIntAna(theCurve, theSurface, ParabPlane);
break;
}
case GeomAbs_Cylinder: {
IntAna_IntConicQuad ParabCylinder(theParab, SurfaceTool::Cylinder(theSurface));
theAppendIntAna(theCurve, theSurface, ParabCylinder);
break;
}
case GeomAbs_Cone: {
IntAna_IntConicQuad ParabCone(theParab, SurfaceTool::Cone(theSurface));
theAppendIntAna(theCurve, theSurface, ParabCone);
break;
}
case GeomAbs_Sphere: {
IntAna_IntConicQuad ParabSphere(theParab, SurfaceTool::Sphere(theSurface));
theAppendIntAna(theCurve, theSurface, ParabSphere);
break;
}
default: {
Standard_Integer nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2);
Standard_Integer nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2);
if (nbsu > 40)
nbsu = 40;
if (nbsv > 40)
nbsv = 40;
PolyhedronType polyhedron(theSurface, nbsu, nbsv, theU1, theV1, theU2, theV2);
Intf_Tool bndTool;
Bnd_Box boxParab;
bndTool.ParabBox(theParab, polyhedron.Bounding(), boxParab);
for (Standard_Integer nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++)
{
PolygonType polygon(theCurve,
bndTool.BeginParam(nbseg),
bndTool.EndParam(nbseg),
THE_NBSAMPLESONPARAB);
theInternalPerformPoly(theCurve,
polygon,
theSurface,
polyhedron,
theU1,
theV1,
theU2,
theV2);
}
}
}
}
//! Perform conic (hyperbola) surface intersection.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename PolygonType,
typename PolyhedronType,
typename AppendIntAnaFunc,
typename InternalPerformPolyFunc>
void PerformConicSurfHyperbola(const gp_Hypr& theHypr,
const CurveType& theCurve,
const SurfaceType& theSurface,
const Standard_Real theU1,
const Standard_Real theV1,
const Standard_Real theU2,
const Standard_Real theV2,
AppendIntAnaFunc theAppendIntAna,
InternalPerformPolyFunc theInternalPerformPoly)
{
GeomAbs_SurfaceType aSurfaceType = SurfaceTool::GetType(theSurface);
switch (aSurfaceType)
{
case GeomAbs_Plane: {
IntAna_IntConicQuad HyprPlane(theHypr,
SurfaceTool::Plane(theSurface),
THE_TOLERANCE_ANGULAIRE);
theAppendIntAna(theCurve, theSurface, HyprPlane);
break;
}
case GeomAbs_Cylinder: {
IntAna_IntConicQuad HyprCylinder(theHypr, SurfaceTool::Cylinder(theSurface));
theAppendIntAna(theCurve, theSurface, HyprCylinder);
break;
}
case GeomAbs_Cone: {
IntAna_IntConicQuad HyprCone(theHypr, SurfaceTool::Cone(theSurface));
theAppendIntAna(theCurve, theSurface, HyprCone);
break;
}
case GeomAbs_Sphere: {
IntAna_IntConicQuad HyprSphere(theHypr, SurfaceTool::Sphere(theSurface));
theAppendIntAna(theCurve, theSurface, HyprSphere);
break;
}
default: {
Standard_Integer nbsu = SurfaceTool::NbSamplesU(theSurface, theU1, theU2);
Standard_Integer nbsv = SurfaceTool::NbSamplesV(theSurface, theV1, theV2);
if (nbsu > 40)
nbsu = 40;
if (nbsv > 40)
nbsv = 40;
PolyhedronType polyhedron(theSurface, nbsu, nbsv, theU1, theV1, theU2, theV2);
Intf_Tool bndTool;
Bnd_Box boxHypr;
bndTool.HyprBox(theHypr, polyhedron.Bounding(), boxHypr);
for (Standard_Integer nbseg = 1; nbseg <= bndTool.NbSegments(); nbseg++)
{
PolygonType polygon(theCurve,
bndTool.BeginParam(nbseg),
bndTool.EndParam(nbseg),
THE_NBSAMPLESONHYPR);
theInternalPerformPoly(theCurve,
polygon,
theSurface,
polyhedron,
theU1,
theV1,
theU2,
theV2);
}
}
}
}
//! Append analytical intersection results.
template <typename CurveType,
typename CurveTool,
typename SurfaceType,
typename SurfaceTool,
typename AppendFunc>
void AppendIntAna(const CurveType& theCurve,
const SurfaceType& theSurface,
const IntAna_IntConicQuad& theIntAna,
bool& theIsParallel,
AppendFunc theAppend)
{
Standard_Boolean aIsParallel = Standard_False;
NCollection_Vector<IntCurveSurface_IntersectionPoint> aPoints;
if (IntCurveSurface_InterUtils::ProcessIntAna<CurveType, CurveTool, SurfaceType, SurfaceTool>(
theCurve,
theSurface,
theIntAna,
aIsParallel,
aPoints))
{
if (aIsParallel)
{
theIsParallel = true;
}
else
{
for (const IntCurveSurface_IntersectionPoint& aPoint : aPoints)
{
theAppend(aPoint);
}
}
}
}
} // namespace IntCurveSurface_InterImpl
#endif // IntCurveSurface_Inter_PXX

File diff suppressed because it is too large Load Diff

View File

@@ -1,263 +0,0 @@
// Created on: 1992-10-12
// Created by: Laurent BUCHARD
// Copyright (c) 1992-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 <Standard_ConstructionError.hxx>
#include <Bnd_Box.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
//======================================================================
//== On echantillonne sur le Domain de la Curve NbPts Points
//== a parametres constants.
//==
//== On estime la fleche maximum en prenant la distance maxi entre la
//== droite Curve.Value(X(i))-->Curve.Value(X(i+1))
//== et le point Curve.Value(X(i+1/2))
//======================================================================
IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C, const Standard_Integer tNbPts)
: ThePnts(1, (tNbPts < 5) ? 5 : tNbPts)
{
Standard_Integer NbPts = (tNbPts < 5) ? 5 : tNbPts;
NbPntIn = NbPts;
Binf = TheCurveTool::FirstParameter(C);
Bsup = TheCurveTool::LastParameter(C);
Init(C);
}
IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Integer tNbPts)
: ThePnts(1, (tNbPts < 5) ? 5 : tNbPts),
Binf(U1),
Bsup(U2)
{
Standard_Integer NbPts = (tNbPts < 5) ? 5 : tNbPts;
NbPntIn = NbPts;
Init(C);
}
//=================================================================================================
IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C,
const TColStd_Array1OfReal& Upars)
: ThePnts(1, Upars.Length()),
Binf(Upars(Upars.Lower())),
Bsup(Upars(Upars.Upper()))
{
// ddout << "IntCurveSurface_Polygon::IntCurveSurface_Polygon" << endl;
Standard_Integer NbPts = Upars.Length();
// ddout << "NbPts :" << NbPts << endl;
NbPntIn = NbPts;
Init(C, Upars);
}
void IntCurveSurface_Polygon::Init(const TheCurve& C)
{
Standard_Real u = Binf;
Standard_Real u1 = Bsup;
Standard_Real du = (u1 - u) / (Standard_Real)(NbPntIn - 1);
Standard_Integer i = 1;
gp_Pnt P;
do
{
TheCurveTool::D0(C, u, P);
TheBnd.Add(P);
ThePnts.SetValue(i, P);
u += du;
i++;
} while (i <= NbPntIn);
//-----------------------------------------------------
//--- Calcul d un majorant de fleche approche
//---
TheDeflection = 0.0;
if (NbPntIn > 3)
{
i = 1;
u = Binf;
u += du * 0.5;
do
{
gp_Pnt Pm = TheCurveTool::Value(C, u);
gp_Pnt P1 = ThePnts.Value(i);
gp_Pnt P2 = ThePnts.Value(i + 1);
gp_Lin L(P1, gp_Dir(gp_Vec(P1, P2)));
Standard_Real t = L.Distance(Pm);
if (t > TheDeflection)
{
TheDeflection = t;
}
u += du;
i++;
} while (i < NbPntIn);
TheBnd.Enlarge(1.5 * TheDeflection);
}
else
{
TheBnd.Enlarge(1e-10);
}
ClosedPolygon = Standard_False;
}
//=================================================================================================
void IntCurveSurface_Polygon::Init(const TheCurve& C, const TColStd_Array1OfReal& Upars)
{
// ddout << "IntCurveSurface_Polygon::Init" << endl;
Standard_Real u = Binf;
Standard_Integer i = 1, i0 = Upars.Lower() - 1;
gp_Pnt P;
myParams = new TColStd_HArray1OfReal(1, Upars.Length());
do
{
// ddout << "-------------Parameter : " << i << " " << Upars(i+i0) << endl;
myParams->SetValue(i, Upars(i + i0));
TheCurveTool::D0(C, Upars(i + i0), P);
// ddout << "P : " << P.X() << " " << P.Y() << " " << P.Z() << endl;
TheBnd.Add(P);
ThePnts.SetValue(i, P);
i++;
} while (i <= NbPntIn);
//-----------------------------------------------------
//--- Calcul d un majorant de fleche approche
//---
TheDeflection = 0.0;
if (NbPntIn > 3)
{
i = 1;
// ddout << "Deflection estimation" << endl;
do
{
u = 0.5 * (Upars(i0 + i) + Upars(i0 + i + 1));
// ddout << "===========Parameter : " << i << " " << u << endl;
gp_Pnt Pm = TheCurveTool::Value(C, u);
// ddout << "Pm : " << Pm.X() << " " << Pm.Y() << " " << Pm.Z() << endl;
gp_Pnt P1 = ThePnts.Value(i);
// ddout << "P1 : " << P1.X() << " " << P1.Y() << " " << P1.Z() << endl;
gp_Pnt P2 = ThePnts.Value(i + 1);
// ddout << "P2 : " << P2.X() << " " << P2.Y() << " " << P2.Z() << endl;
gp_Lin L(P1, gp_Dir(gp_Vec(P1, P2)));
Standard_Real t = L.Distance(Pm);
// ddout << "Distance " << t << endl;
if (t > TheDeflection)
{
TheDeflection = t;
}
i++;
} while (i < NbPntIn);
// ddout << " TheDeflection = " << TheDeflection << endl;
TheBnd.Enlarge(1.5 * TheDeflection);
}
else
{
TheBnd.Enlarge(1e-10);
}
ClosedPolygon = Standard_False;
}
//=================================================================================================
Standard_Real IntCurveSurface_Polygon::ApproxParamOnCurve(const Standard_Integer TheIndex,
const Standard_Real TheParamOnLine) const
{
// ddout << "IntCurveSurface_Polygon::ApproxParamOnCurve" << endl;
if (TheParamOnLine < 0.0 || TheParamOnLine > 1.0)
{
#ifdef OCCT_DEBUG
std::cout << " ParamOnLine = " << TheParamOnLine << " avec Index = " << TheIndex
<< " dans IntCurveSurface_Polygon::ApproxParamOnCurve" << std::endl;
#endif
return (Binf + (TheParamOnLine * (Bsup - Binf)) / (Standard_Real)(NbPntIn - 1));
}
Standard_Integer Index = TheIndex;
Standard_Real ParamOnLine = TheParamOnLine;
#ifdef OCCT_DEBUG
if (Index > NbPntIn)
{
std::cout << "OutOfRange Polygon::ApproxParamOnCurve " << std::endl;
}
#endif
if ((Index == NbPntIn) && (ParamOnLine == 0.0))
{
Index--;
ParamOnLine = 1.0;
}
Standard_Real du, u;
if (myParams.IsNull())
{
du = (Bsup - Binf) / (Standard_Real)(NbPntIn - 1);
u = Binf + du * (Standard_Real)(Index - 1);
}
else
{
du = myParams->Value(Index + 1) - myParams->Value(Index);
u = myParams->Value(Index);
}
u += du * ParamOnLine;
return (u);
}
//=================================================================================================
void IntCurveSurface_Polygon::Dump(void) const
{
#if 0
static Standard_Integer Compteur=0;
char tamp[100];
Compteur++;
Sprintf(tamp,"Poly%d",Compteur);
std::cout<<" @@@@@@@@@@@ F i c h i e r : "<<tamp<<" @@@@@@@@@@"<<std::endl;
FILE *fp;
fp=fopen(tamp,"w");
if(fp==NULL) {
std::cout<<"PolyGonGen::Erreur en Ouverture Fichier"<<tamp<<std::endl;
return;
}
fprintf(fp,"\n#Discretisation de : %f ---> %f \n",Binf,Bsup);
fprintf(fp,"\npol %d %d %f",Compteur,NbPntIn,TheDeflection);
gp_Pnt p1,p2;
for (Standard_Integer iObje=1; iObje<=NbSegments(); iObje++) {
p1=BeginOfSeg(iObje);
fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y());
}
p1=EndOfSeg(NbSegments());
fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y());
fprintf(fp,"\ndispol %d\n#\n",Compteur);
fclose(fp);
#endif
}
//======================================================================
//======================================================================

View File

@@ -1,58 +0,0 @@
// Created on: 1993-06-03
// Created by: Laurent BUCHARD
// 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 ThePolygon_hxx
//=================================================================
inline const TheBoundingBox& IntCurveSurface_PolygonTool::Bounding(const ThePolygon& thePolygon)
{
return thePolygon.Bounding();
}
//=================================================================
inline Standard_Real IntCurveSurface_PolygonTool::DeflectionOverEstimation(
const ThePolygon& thePolygon)
{
return thePolygon.DeflectionOverEstimation();
}
//=================================================================
inline Standard_Boolean IntCurveSurface_PolygonTool::Closed(const ThePolygon& thePolygon)
{
return thePolygon.Closed();
}
//=================================================================
inline Standard_Integer IntCurveSurface_PolygonTool::NbSegments(const ThePolygon& thePolygon)
{
return thePolygon.NbSegments();
}
//=================================================================
inline const ThePoint& IntCurveSurface_PolygonTool::BeginOfSeg(const ThePolygon& thePolygon,
const Standard_Integer Index)
{
return thePolygon.BeginOfSeg(Index);
}
//=================================================================
inline const ThePoint& IntCurveSurface_PolygonTool::EndOfSeg(const ThePolygon& thePolygon,
const Standard_Integer Index)
{
return thePolygon.EndOfSeg(Index);
}
//=================================================================

View File

@@ -0,0 +1,206 @@
// Copyright (c) 2025 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 IntCurveSurface_PolygonUtils_pxx_HeaderFile
#define IntCurveSurface_PolygonUtils_pxx_HeaderFile
#include <Bnd_Box.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
//! Utility functions for polygon discretization of curves.
//! These template functions implement the core logic previously in IntCurveSurface_Polygon.gxx.
namespace IntCurveSurface_PolygonUtils
{
//! Initialize polygon with uniform parameter sampling.
//! Samples theNbPntIn points along the curve from theBinf to theBsup with equal parameter spacing.
//! Computes the bounding box and estimates the maximum deflection.
//! @tparam CurveType Type of curve (e.g., Handle(Adaptor3d_Curve) or gp_Lin)
//! @tparam CurveTool Tool class providing curve operations (D0, Value, FirstParameter, etc.)
//! @param[in] theCurve The curve to discretize
//! @param[in] theBinf First parameter value
//! @param[in] theBsup Last parameter value
//! @param[in] theNbPntIn Number of sample points
//! @param[in,out] thePnts Array to store sampled points (must be pre-allocated)
//! @param[in,out] theBnd Bounding box to update
//! @param[out] theDeflection Estimated maximum deflection
template <typename CurveType, typename CurveTool>
void InitUniform(const CurveType& theCurve,
const double theBinf,
const double theBsup,
const int theNbPntIn,
TColgp_Array1OfPnt& thePnts,
Bnd_Box& theBnd,
double& theDeflection)
{
const double du = (theBsup - theBinf) / static_cast<double>(theNbPntIn - 1);
double u = theBinf;
gp_Pnt P;
for (int i = 1; i <= theNbPntIn; ++i)
{
CurveTool::D0(theCurve, u, P);
theBnd.Add(P);
thePnts.SetValue(i, P);
u += du;
}
// Calculate deflection estimate by measuring distance from midpoints to chord lines
theDeflection = 0.0;
if (theNbPntIn > 3)
{
u = theBinf + du * 0.5;
for (int i = 1; i < theNbPntIn; ++i)
{
const gp_Pnt Pm = CurveTool::Value(theCurve, u);
const gp_Pnt& P1 = thePnts.Value(i);
const gp_Pnt& P2 = thePnts.Value(i + 1);
const gp_Lin L(P1, gp_Dir(gp_Vec(P1, P2)));
const double t = L.Distance(Pm);
if (t > theDeflection)
{
theDeflection = t;
}
u += du;
}
theBnd.Enlarge(1.5 * theDeflection);
}
else
{
theBnd.Enlarge(1e-10);
}
}
//! Initialize polygon with explicit parameter array.
//! Samples points at the specified parameter values and stores them for later lookup.
//! @tparam CurveType Type of curve (e.g., Handle(Adaptor3d_Curve) or gp_Lin)
//! @tparam CurveTool Tool class providing curve operations
//! @param[in] theCurve The curve to discretize
//! @param[in] theUpars Array of parameter values
//! @param[in] theNbPntIn Number of sample points
//! @param[in,out] thePnts Array to store sampled points (must be pre-allocated)
//! @param[in,out] theBnd Bounding box to update
//! @param[out] theDeflection Estimated maximum deflection
//! @param[out] theParams Handle to store copy of parameters (created internally)
template <typename CurveType, typename CurveTool>
void InitWithParams(const CurveType& theCurve,
const TColStd_Array1OfReal& theUpars,
const int theNbPntIn,
TColgp_Array1OfPnt& thePnts,
Bnd_Box& theBnd,
double& theDeflection,
Handle(TColStd_HArray1OfReal)& theParams)
{
theParams = new TColStd_HArray1OfReal(1, theUpars.Length());
const int i0 = theUpars.Lower() - 1;
gp_Pnt P;
for (int i = 1; i <= theNbPntIn; ++i)
{
theParams->SetValue(i, theUpars(i + i0));
CurveTool::D0(theCurve, theUpars(i + i0), P);
theBnd.Add(P);
thePnts.SetValue(i, P);
}
// Calculate deflection estimate
theDeflection = 0.0;
if (theNbPntIn > 3)
{
for (int i = 1; i < theNbPntIn; ++i)
{
const double u = 0.5 * (theUpars(i0 + i) + theUpars(i0 + i + 1));
const gp_Pnt Pm = CurveTool::Value(theCurve, u);
const gp_Pnt& P1 = thePnts.Value(i);
const gp_Pnt& P2 = thePnts.Value(i + 1);
const gp_Lin L(P1, gp_Dir(gp_Vec(P1, P2)));
const double t = L.Distance(Pm);
if (t > theDeflection)
{
theDeflection = t;
}
}
theBnd.Enlarge(1.5 * theDeflection);
}
else
{
theBnd.Enlarge(1e-10);
}
}
//! Compute approximate parameter on curve for a given polygon segment and position.
//! This is a non-template function as it only operates on stored data.
//! @param[in] theIndex Segment index (1-based)
//! @param[in] theParamOnLine Position along segment [0,1]
//! @param[in] theBinf First parameter of polygon range
//! @param[in] theBsup Last parameter of polygon range
//! @param[in] theNbPntIn Number of points in polygon
//! @param[in] theParams Optional explicit parameter array (may be null for uniform)
//! @return Approximate parameter value on the curve
inline double ApproxParamOnCurve(int theIndex,
double theParamOnLine,
const double theBinf,
const double theBsup,
const int theNbPntIn,
const Handle(TColStd_HArray1OfReal)& theParams)
{
if (theParamOnLine < 0.0 || theParamOnLine > 1.0)
{
#ifdef OCCT_DEBUG
std::cout << " ParamOnLine = " << theParamOnLine << " avec Index = " << theIndex
<< " dans IntCurveSurface_Polygon::ApproxParamOnCurve" << std::endl;
#endif
return theBinf + (theParamOnLine * (theBsup - theBinf)) / static_cast<double>(theNbPntIn - 1);
}
int Index = theIndex;
double ParamOnLine = theParamOnLine;
#ifdef OCCT_DEBUG
if (Index > theNbPntIn)
{
std::cout << "OutOfRange Polygon::ApproxParamOnCurve " << std::endl;
}
#endif
if ((Index == theNbPntIn) && (ParamOnLine == 0.0))
{
Index--;
ParamOnLine = 1.0;
}
double du, u;
if (theParams.IsNull())
{
du = (theBsup - theBinf) / static_cast<double>(theNbPntIn - 1);
u = theBinf + du * static_cast<double>(Index - 1);
}
else
{
du = theParams->Value(Index + 1) - theParams->Value(Index);
u = theParams->Value(Index);
}
u += du * ParamOnLine;
return u;
}
} // namespace IntCurveSurface_PolygonUtils
#endif // IntCurveSurface_PolygonUtils_pxx_HeaderFile

View File

@@ -1,951 +0,0 @@
// Created on: 1993-02-03
// Created by: Laurent BUCHARD
// 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 <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Lin.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <Bnd_Array1OfBox.hxx>
#include <Standard_ConstructionError.hxx>
#include <stdio.h>
#define CHECKBOUNDS 0
//-----------------------------------------------------
#define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
//=================================================================================================
IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron(const ThePSurface& Surface,
const Standard_Integer nbdU,
const Standard_Integer nbdV,
const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2)
: nbdeltaU((nbdU < 3) ? 3 : nbdU),
nbdeltaV((nbdV < 3) ? 3 : nbdV),
TheDeflection(Epsilon(100.)),
C_MyPnts(NULL),
C_MyU(NULL),
C_MyV(NULL),
C_MyIsOnBounds(NULL)
{
Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
gp_Pnt* CMyPnts = new gp_Pnt[t];
C_MyPnts = (void*)CMyPnts;
Standard_Real* CMyU = new Standard_Real[t];
C_MyU = (void*)CMyU;
Standard_Real* CMyV = new Standard_Real[t];
C_MyV = (void*)CMyV;
// Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
Standard_Boolean* CMyIsOnBounds = new Standard_Boolean[t];
C_MyIsOnBounds = (void*)CMyIsOnBounds;
// Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
Init(Surface, u1, v1, u2, v2);
}
//=================================================================================================
IntCurveSurface_Polyhedron::IntCurveSurface_Polyhedron(const ThePSurface& Surface,
const TColStd_Array1OfReal& Upars,
const TColStd_Array1OfReal& Vpars)
: nbdeltaU(Upars.Length() - 1),
nbdeltaV(Vpars.Length() - 1),
TheDeflection(Epsilon(100.)),
C_MyPnts(NULL),
C_MyU(NULL),
C_MyV(NULL),
C_MyIsOnBounds(NULL)
{
Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
gp_Pnt* CMyPnts = new gp_Pnt[t];
C_MyPnts = (void*)CMyPnts;
Standard_Real* CMyU = new Standard_Real[t];
C_MyU = (void*)CMyU;
Standard_Real* CMyV = new Standard_Real[t];
C_MyV = (void*)CMyV;
// Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
Standard_Boolean* CMyIsOnBounds = new Standard_Boolean[t];
C_MyIsOnBounds = (void*)CMyIsOnBounds;
// Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
Init(Surface, Upars, Vpars);
}
void IntCurveSurface_Polyhedron::Destroy()
{
//-- printf("\n IntCurveSurface_Polyhedron::Destroy\n");
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
if (C_MyPnts)
delete[] CMyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
if (C_MyU)
delete[] CMyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
if (C_MyV)
delete[] CMyV;
// Modified by Sergey KHROMOV - Fri Dec 7 12:03:46 2001 Begin
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
if (C_MyIsOnBounds)
delete[] CMyIsOnBounds;
// Modified by Sergey KHROMOV - Fri Dec 7 12:03:47 2001 End
C_MyPnts = C_MyU = C_MyV = C_MyIsOnBounds = NULL;
}
//=================================================================================================
void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
const Standard_Real U0,
const Standard_Real V0,
const Standard_Real U1,
const Standard_Real V1)
{
// #define DEBUGDUMP
Standard_Integer i1, i2;
Standard_Real U, V;
Standard_Real U1mU0sNbdeltaU = (U1 - U0) / (Standard_Real)nbdeltaU;
Standard_Real V1mV0sNbdeltaV = (V1 - V0) / (Standard_Real)nbdeltaV;
gp_Pnt TP;
Standard_Integer Index = 1;
//-- --------------------------------------------------
//-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
//-- V est la colonne
//-- U est la ligne
//-- --------------------------------------------------
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
for (i1 = 0, U = U0; i1 <= nbdeltaU; i1++, U += U1mU0sNbdeltaU)
{
for (i2 = 0, V = V0; i2 <= nbdeltaV; i2++, V += V1mV0sNbdeltaV)
{
ThePSurfaceTool::D0(Surface, U, V, TP);
//-- Point(TP,i1, i2,U,V);
CMyPnts[Index] = TP;
CMyU[Index] = U;
CMyV[Index] = V;
// Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU || i2 == 0 || i2 == nbdeltaV);
// Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
TheBnd.Add(TP);
Index++;
}
}
//-- Calcul de la deflection Triangle <-> Point milieu
Standard_Real tol = 0.0;
Standard_Integer nbtriangles = NbTriangles();
for (i1 = 1; i1 <= nbtriangles; i1++)
{
Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
if (tol1 > tol)
tol = tol1;
}
//-- Calcul de la deflection Bord <-> Point milieu
DeflectionOverEstimation(tol * 1.2);
FillBounding();
// Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
Standard_Real aDeflection;
TheBorderDeflection = RealFirst();
// Compute the deflection on the lower bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Compute the deflection on the upper bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Compute the deflection on the lower bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Compute the deflection on the upper bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
#ifdef OCCT_DEBUG_DUMP
Dump();
#endif
}
//=================================================================================================
void IntCurveSurface_Polyhedron::Init(const ThePSurface& Surface,
const TColStd_Array1OfReal& Upars,
const TColStd_Array1OfReal& Vpars)
{
// #define DEBUGDUMP
Standard_Integer i1, i2;
Standard_Real U, V;
gp_Pnt TP;
Standard_Integer Index = 1;
//-- --------------------------------------------------
//-- Index varie de 1 -> (nbdu+1)*(nbdv+1)
//-- V est la colonne
//-- U est la ligne
//-- --------------------------------------------------
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
Standard_Integer i0 = Upars.Lower(), j0 = Vpars.Lower();
for (i1 = 0; i1 <= nbdeltaU; i1++)
{
U = Upars(i1 + i0);
for (i2 = 0; i2 <= nbdeltaV; i2++)
{
V = Vpars(i2 + j0);
ThePSurfaceTool::D0(Surface, U, V, TP);
//-- Point(TP,i1, i2,U,V);
CMyPnts[Index] = TP;
CMyU[Index] = U;
CMyV[Index] = V;
// Modified by Sergey KHROMOV - Fri Dec 7 12:07:51 2001
CMyIsOnBounds[Index] = (i1 == 0 || i1 == nbdeltaU || i2 == 0 || i2 == nbdeltaV);
// Modified by Sergey KHROMOV - Fri Dec 7 12:07:52 2001
TheBnd.Add(TP);
Index++;
}
}
//-- Calcul de la deflection Triangle <-> Point milieu
Standard_Real tol = 0.0;
Standard_Integer nbtriangles = NbTriangles();
for (i1 = 1; i1 <= nbtriangles; i1++)
{
Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
if (tol1 > tol)
tol = tol1;
}
//-- Calcul de la deflection Bord <-> Point milieu
DeflectionOverEstimation(tol * 1.2);
FillBounding();
// Modified by Sergey KHROMOV - Fri Dec 7 11:23:33 2001 Begin
Standard_Real aDeflection;
TheBorderDeflection = RealFirst();
Standard_Real U0 = Upars(i0);
Standard_Real V0 = Vpars(j0);
Standard_Real U1 = Upars(Upars.Upper());
Standard_Real V1 = Vpars(Vpars.Upper());
// Compute the deflection on the lower bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Compute the deflection on the upper bound (U-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Compute the deflection on the lower bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Compute the deflection on the upper bound (V-isoline) of the surface.
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
// Modified by Sergey KHROMOV - Fri Dec 7 11:23:34 2001 End
#ifdef OCCT_DEBUG_DUMP
Dump();
#endif
}
//=================================================================================================
Standard_Real IntCurveSurface_Polyhedron::DeflectionOnTriangle(const ThePSurface& Surface,
const Standard_Integer Triang) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
//-- Calcul de l equation du plan
Standard_Real u1, v1, u2, v2, u3, v3;
gp_Pnt P1, P2, P3;
P1 = Point(i1, u1, v1);
P2 = Point(i2, u2, v2);
P3 = Point(i3, u3, v3);
if (P1.SquareDistance(P2) <= LONGUEUR_MINI_EDGE_TRIANGLE)
return (0);
if (P1.SquareDistance(P3) <= LONGUEUR_MINI_EDGE_TRIANGLE)
return (0);
if (P2.SquareDistance(P3) <= LONGUEUR_MINI_EDGE_TRIANGLE)
return (0);
gp_XYZ XYZ1 = P2.XYZ() - P1.XYZ();
gp_XYZ XYZ2 = P3.XYZ() - P2.XYZ();
gp_XYZ XYZ3 = P1.XYZ() - P3.XYZ();
gp_Vec NormalVector((XYZ1 ^ XYZ2) + (XYZ2 ^ XYZ3) + (XYZ3 ^ XYZ1));
Standard_Real aNormLen = NormalVector.Magnitude();
if (aNormLen < gp::Resolution())
{
return 0.;
}
//
NormalVector.Divide(aNormLen);
//-- Standard_Real PolarDistance = NormalVector * P1.XYZ();
//-- Calcul du point u,v au centre du triangle
Standard_Real u = (u1 + u2 + u3) / 3.0;
Standard_Real v = (v1 + v2 + v3) / 3.0;
gp_Pnt P = ThePSurfaceTool::Value(Surface, u, v);
gp_Vec P1P(P1, P);
return (std::abs(P1P.Dot(NormalVector)));
}
//=================================================================================================
void IntCurveSurface_Polyhedron::Parameters(const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V) const
{
#if CHECKBOUNDS
if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
{
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
Standard_Real* CMyU = (Standard_Real*)C_MyU;
U = CMyU[Index];
Standard_Real* CMyV = (Standard_Real*)C_MyV;
V = CMyV[Index];
}
//=================================================================================================
void IntCurveSurface_Polyhedron::DeflectionOverEstimation(const Standard_Real flec)
{
if (flec < 0.0001)
{
TheDeflection = 0.0001;
TheBnd.Enlarge(0.0001);
}
else
{
TheDeflection = flec;
TheBnd.Enlarge(flec);
}
}
//=================================================================================================
Standard_Real IntCurveSurface_Polyhedron::DeflectionOverEstimation() const
{
return TheDeflection;
}
//=================================================================================================
const Bnd_Box& IntCurveSurface_Polyhedron::Bounding() const
{
return TheBnd;
}
//=================================================================================================
void IntCurveSurface_Polyhedron::FillBounding()
{
TheComponentsBnd = new Bnd_HArray1OfBox(1, NbTriangles());
Bnd_Box Boite;
Standard_Integer np1, np2, np3;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer iTri = 1; iTri <= nbtriangles; iTri++)
{
Triangle(iTri, np1, np2, np3);
gp_Pnt p1(Point(np1));
gp_Pnt p2(Point(np2));
gp_Pnt p3(Point(np3));
Boite.SetVoid();
if (p1.SquareDistance(p2) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
if (p1.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
if (p2.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
Boite.Add(p1);
Boite.Add(p2);
Boite.Add(p3);
Boite.Enlarge(TheDeflection);
}
}
}
Boite.Enlarge(TheDeflection);
TheComponentsBnd->SetValue(iTri, Boite);
}
}
//=================================================================================================
const Handle(Bnd_HArray1OfBox)& IntCurveSurface_Polyhedron::ComponentsBounding() const
{
return TheComponentsBnd;
}
//=================================================================================================
Standard_Integer IntCurveSurface_Polyhedron::NbTriangles() const
{
return nbdeltaU * nbdeltaV * 2;
}
//=================================================================================================
Standard_Integer IntCurveSurface_Polyhedron::NbPoints() const
{
return (nbdeltaU + 1) * (nbdeltaV + 1);
}
//=================================================================================================
Standard_Integer IntCurveSurface_Polyhedron::TriConnex(const Standard_Integer Triang,
const Standard_Integer Pivot,
const Standard_Integer Pedge,
Standard_Integer& TriCon,
Standard_Integer& OtherP) const
{
Standard_Integer Pivotm1 = Pivot - 1;
Standard_Integer nbdeltaVp1 = nbdeltaV + 1;
Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
// Pivot position in the MaTriangle :
Standard_Integer ligP = Pivotm1 / nbdeltaVp1;
Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
// Point sur Edge position in the MaTriangle and edge typ :
Standard_Integer ligE = 0, colE = 0, typE = 0;
if (Pedge != 0)
{
ligE = (Pedge - 1) / nbdeltaVp1;
colE = (Pedge - 1) - (ligE * nbdeltaVp1);
// Horizontal
if (ligP == ligE)
typE = 1;
// Vertical
else if (colP == colE)
typE = 2;
// Oblique
else
typE = 3;
}
else
{
typE = 0;
}
// Triangle position General case :
Standard_Integer linT = 0, colT = 0;
Standard_Integer linO = 0, colO = 0;
Standard_Integer t = 0, tt = 0;
if (Triang != 0)
{
t = (Triang - 1) / (nbdeltaVm2);
tt = (Triang - 1) - t * nbdeltaVm2;
linT = 1 + t;
colT = 1 + tt;
if (typE == 0)
{
if (ligP == linT)
{
ligE = ligP - 1;
colE = colP - 1;
typE = 3;
}
else
{
if (colT == ligP + ligP)
{
ligE = ligP;
colE = colP - 1;
typE = 1;
}
else
{
ligE = ligP + 1;
colE = colP + 1;
typE = 3;
}
}
}
switch (typE)
{
case 1: // Horizontal
if (linT == ligP)
{
linT++;
linO = ligP + 1;
colO = (colP > colE) ? colP : colE; //--colO=Max(colP, colE);
}
else
{
linT--;
linO = ligP - 1;
colO = (colP < colE) ? colP : colE; //--colO=Min(colP, colE);
}
break;
case 2: // Vertical
if (colT == (colP + colP))
{
colT++;
linO = (ligP > ligE) ? ligP : ligE; //--linO=Max(ligP, ligE);
colO = colP + 1;
}
else
{
colT--;
linO = (ligP < ligE) ? ligP : ligE; //--linO=Min(ligP, ligE);
colO = colP - 1;
}
break;
case 3: // Oblique
if ((colT & 1) == 0)
{
colT--;
linO = (ligP > ligE) ? ligP : ligE; //--linO=Max(ligP, ligE);
colO = (colP < colE) ? colP : colE; //--colO=Min(colP, colE);
}
else
{
colT++;
linO = (ligP < ligE) ? ligP : ligE; //--linO=Min(ligP, ligE);
colO = (colP > colE) ? colP : colE; //--colO=Max(colP, colE);
}
break;
}
}
else
{
// Unknown Triangle position :
if (Pedge == 0)
{
// Unknown edge :
linT = (1 > ligP) ? 1 : ligP; //--linT=Max(1, ligP);
colT = (1 > (colP + colP)) ? 1 : (colP + colP); //--colT=Max(1, colP+colP);
if (ligP == 0)
linO = ligP + 1;
else
linO = ligP - 1;
colO = colP;
}
else
{
// Known edge We take the left or down connectivity :
switch (typE)
{
case 1: // Horizontal
linT = ligP + 1;
colT = (colP > colE) ? colP : colE; //--colT=Max(colP,colE);
colT += colT;
linO = ligP + 1;
colO = (colP > colE) ? colP : colE; //--colO=Max(colP,colE);
break;
case 2: // Vertical
linT = (ligP > ligE) ? ligP : ligE; //--linT=Max(ligP, ligE);
colT = colP + colP;
linO = (ligP < ligE) ? ligP : ligE; //--linO=Min(ligP, ligE);
colO = colP - 1;
break;
case 3: // Oblique
linT = (ligP > ligE) ? ligP : ligE; //--linT=Max(ligP, ligE);
colT = colP + colE;
linO = (ligP > ligE) ? ligP : ligE; //--linO=Max(ligP, ligE);
colO = (colP < colE) ? colP : colE; //--colO=Min(colP, colE);
break;
}
}
}
TriCon = (linT - 1) * nbdeltaVm2 + colT;
if (linT < 1)
{
linO = 0;
colO = colP + colP - colE;
if (colO < 0)
{
colO = 0;
linO = 1;
}
else if (colO > nbdeltaV)
{
colO = nbdeltaV;
linO = 1;
}
TriCon = 0;
}
else if (linT > nbdeltaU)
{
linO = nbdeltaU;
colO = colP + colP - colE;
if (colO < 0)
{
colO = 0;
linO = nbdeltaU - 1;
}
else if (colO > nbdeltaV)
{
colO = nbdeltaV;
linO = nbdeltaU - 1;
}
TriCon = 0;
}
if (colT < 1)
{
colO = 0;
linO = ligP + ligP - ligE;
if (linO < 0)
{
linO = 0;
colO = 1;
}
else if (linO > nbdeltaU)
{
linO = nbdeltaU;
colO = 1;
}
TriCon = 0;
}
else if (colT > nbdeltaV)
{
colO = nbdeltaV;
linO = ligP + ligP - ligE;
if (linO < 0)
{
linO = 0;
colO = nbdeltaV - 1;
}
else if (linO > nbdeltaU)
{
linO = nbdeltaU;
colO = nbdeltaV - 1;
}
TriCon = 0;
}
OtherP = linO * nbdeltaVp1 + colO + 1;
return TriCon;
}
//=================================================================================================
void IntCurveSurface_Polyhedron::PlaneEquation(const Standard_Integer Triang,
gp_XYZ& NormalVector,
Standard_Real& PolarDistance) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
//-- gp_XYZ v1=Point(i2).XYZ()-Point(i1).XYZ();
//-- gp_XYZ v2=Point(i3).XYZ()-Point(i2).XYZ();
//-- gp_XYZ v3=Point(i1).XYZ()-Point(i3).XYZ();
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
gp_XYZ v1 = Pointi2 - Pointi1;
gp_XYZ v2 = Pointi3 - Pointi2;
gp_XYZ v3 = Pointi1 - Pointi3;
if (v1.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
if (v2.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
if (v3.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
NormalVector = (v1 ^ v2) + (v2 ^ v3) + (v3 ^ v1);
Standard_Real aNormLen = NormalVector.Modulus();
if (aNormLen < gp::Resolution())
{
PolarDistance = 0.;
}
else
{
NormalVector.Divide(aNormLen);
PolarDistance = NormalVector * Point(i1).XYZ();
}
}
//=================================================================================================
Standard_Boolean IntCurveSurface_Polyhedron::Contain(const Standard_Integer Triang,
const gp_Pnt& ThePnt) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
gp_XYZ v1 = (Pointi2 - Pointi1) ^ (ThePnt.XYZ() - Pointi1);
gp_XYZ v2 = (Pointi3 - Pointi2) ^ (ThePnt.XYZ() - Pointi2);
gp_XYZ v3 = (Pointi1 - Pointi3) ^ (ThePnt.XYZ() - Pointi3);
if (v1 * v2 >= 0. && v2 * v3 >= 0. && v3 * v1 >= 0.)
return Standard_True;
else
return Standard_False;
}
//=================================================================================================
void IntCurveSurface_Polyhedron::Dump() const {}
//=================================================================================================
void IntCurveSurface_Polyhedron::Size(Standard_Integer& nbdu, Standard_Integer& nbdv) const
{
nbdu = nbdeltaU;
nbdv = nbdeltaV;
}
//=================================================================================================
void IntCurveSurface_Polyhedron::Triangle(const Standard_Integer Index,
Standard_Integer& P1,
Standard_Integer& P2,
Standard_Integer& P3) const
{
Standard_Integer line = 1 + ((Index - 1) / (nbdeltaV * 2));
Standard_Integer colon = 1 + ((Index - 1) % (nbdeltaV * 2));
Standard_Integer colpnt = (colon + 1) / 2;
// General formula = (line-1)*(nbdeltaV+1)+colpnt
// Position of P1 = MesXYZ(line,colpnt);
P1 = (line - 1) * (nbdeltaV + 1) + colpnt;
// Position of P2= MesXYZ(line+1,colpnt+((colon-1)%2));
P2 = line * (nbdeltaV + 1) + colpnt + ((colon - 1) % 2);
// Position of P3= MesXYZ(line+(colon%2),colpnt+1);
P3 = (line - 1 + (colon % 2)) * (nbdeltaV + 1) + colpnt + 1;
}
//=======================================================================
// function : Point
//=======================================================================
const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V) const
{
#if CHECKBOUNDS
if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
{
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
U = CMyU[Index];
V = CMyV[Index];
return CMyPnts[Index];
}
//=======================================================================
// function : Point
//=======================================================================
const gp_Pnt& IntCurveSurface_Polyhedron::Point(const Standard_Integer Index) const
{
#if CHECKBOUNDS
if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
{
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
return CMyPnts[Index];
}
//=======================================================================
// function : Point
//=======================================================================
// void IntCurveSurface_Polyhedron::Point (const gp_Pnt& p,
// const Standard_Integer lig,
// const Standard_Integer col,
// const Standard_Real u,
// const Standard_Real v)
void IntCurveSurface_Polyhedron::Point(const gp_Pnt&,
const Standard_Integer,
const Standard_Integer,
const Standard_Real,
const Standard_Real)
{
printf("\n IntCurveSurface_Polyhedron::Point : Ne dois pas etre appelle\n");
}
//=======================================================================
// function : Point
//=======================================================================
void IntCurveSurface_Polyhedron::Point(const Standard_Integer Index, gp_Pnt& P) const
{
#if CHECKBOUNDS
if (Index < 0 || Index > ((nbdeltaU + 1) * (nbdeltaV + 1)))
{
printf("\n Erreur IntCurveSurface_Polyhedron::Parameters\n");
}
#endif
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
P = CMyPnts[Index];
}
// Modified by Sergey KHROMOV - Fri Dec 7 10:12:47 2001 Begin
//=======================================================================
// function : IsOnBound
// purpose : This method returns true if the edge based on points with
// indices Index1 and Index2 represents a boundary edge.
//=======================================================================
Standard_Boolean IntCurveSurface_Polyhedron::IsOnBound(const Standard_Integer Index1,
const Standard_Integer Index2) const
{
#if CHECKBOUNDS
if (Index1 < 0 || Index1 > ((nbdeltaU + 1) * (nbdeltaV + 1)))
{
printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
}
if (Index2 < 0 || Index2 > ((nbdeltaU + 1) * (nbdeltaV + 1)))
{
printf("\n Erreur IntCurveSurface_Polyhedron::IsOnBound\n");
}
#endif
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
Standard_Integer aDiff = std::abs(Index1 - Index2);
Standard_Integer i;
// Check if points are neighbour ones.
if (aDiff != 1 && aDiff != nbdeltaV + 1)
return Standard_False;
for (i = 0; i <= nbdeltaU; i++)
{
if ((Index1 == 1 + i * (nbdeltaV + 1)) && (Index2 == Index1 - 1))
return Standard_False;
if ((Index1 == (1 + i) * (nbdeltaV + 1)) && (Index2 == Index1 + 1))
return Standard_False;
}
return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
}
//=======================================================================
// function : ComputeBorderDeflection
// purpose : This method computes and returns a deflection of isoline
// of given parameter on Surface.
//=======================================================================
Standard_Real IntCurveSurface_Polyhedron::ComputeBorderDeflection(
const ThePSurface& Surface,
const Standard_Real Parameter,
const Standard_Real PMin,
const Standard_Real PMax,
const Standard_Boolean isUIso) const
{
Standard_Integer aNbSamples;
Standard_Integer i;
if (isUIso)
aNbSamples = nbdeltaV;
else
aNbSamples = nbdeltaU;
Standard_Real aDelta = (PMax - PMin) / aNbSamples;
Standard_Real aPar = PMin;
Standard_Real aDeflection = RealFirst();
gp_XYZ aP1;
gp_XYZ aP2;
gp_XYZ aPMid;
gp_XYZ aPParMid;
for (i = 0; i <= aNbSamples; i++, aPar += aDelta)
{
if (isUIso)
{
aP1 = ThePSurfaceTool::Value(Surface, Parameter, aPar).XYZ();
aP2 = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta).XYZ();
aPParMid = ThePSurfaceTool::Value(Surface, Parameter, aPar + aDelta / 2.).XYZ();
}
else
{
aP1 = ThePSurfaceTool::Value(Surface, aPar, Parameter).XYZ();
aP2 = ThePSurfaceTool::Value(Surface, aPar + aDelta, Parameter).XYZ();
aPParMid = ThePSurfaceTool::Value(Surface, aPar + aDelta / 2., Parameter).XYZ();
}
aPMid = (aP2 + aP1) / 2.;
Standard_Real aDist = (aPMid - aPParMid).Modulus();
if (aDist > aDeflection)
aDeflection = aDist;
}
return aDeflection;
}
// Modified by Sergey KHROMOV - Fri Dec 7 11:21:52 2001 End

View File

@@ -1,24 +0,0 @@
// Created on: 2001-12-07
// Created by: Sergey KHROMOV
// Copyright (c) 2001-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 : GetBorderDeflection
// purpose : This method returns a border deflection.
//=======================================================================
inline Standard_Real IntCurveSurface_Polyhedron::GetBorderDeflection() const
{
return TheBorderDeflection;
}

View File

@@ -1,89 +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 ThePolyhedron_hxx
inline const Bnd_Box& IntCurveSurface_PolyhedronTool::Bounding(const ThePolyhedron& thePolyh)
{
return thePolyh.Bounding();
}
inline const Handle(Bnd_HArray1OfBox)& IntCurveSurface_PolyhedronTool::ComponentsBounding(
const ThePolyhedron& thePolyh)
{
return thePolyh.ComponentsBounding();
}
inline Standard_Real IntCurveSurface_PolyhedronTool::DeflectionOverEstimation(
const ThePolyhedron& thePolyh)
{
return thePolyh.DeflectionOverEstimation();
}
inline Standard_Integer IntCurveSurface_PolyhedronTool::NbTriangles(const ThePolyhedron& thePolyh)
{
return thePolyh.NbTriangles();
}
inline void IntCurveSurface_PolyhedronTool::Triangle(const ThePolyhedron& thePolyh,
const Standard_Integer Index,
Standard_Integer& P1,
Standard_Integer& P2,
Standard_Integer& P3)
{
thePolyh.Triangle(Index, P1, P2, P3);
}
inline const gp_Pnt& IntCurveSurface_PolyhedronTool::Point(const ThePolyhedron& thePolyh,
const Standard_Integer Index)
{
return thePolyh.Point(Index);
}
inline Standard_Integer IntCurveSurface_PolyhedronTool::TriConnex(const ThePolyhedron& thePolyh,
const Standard_Integer Triang,
const Standard_Integer Pivot,
const Standard_Integer Pedge,
Standard_Integer& TriCon,
Standard_Integer& OtherP)
{
return thePolyh.TriConnex(Triang, Pivot, Pedge, TriCon, OtherP);
}
// Modified by Sergey KHROMOV - Fri Dec 7 13:47:07 2001 Begin
//=======================================================================
// function : IsOnBound
// purpose : This method returns true if the edge based on points with
// indices Index1 and Index2 represents a boundary edge.
//=======================================================================
inline Standard_Boolean IntCurveSurface_PolyhedronTool::IsOnBound(const ThePolyhedron& thePolyh,
const Standard_Integer Index1,
const Standard_Integer Index2)
{
return thePolyh.IsOnBound(Index1, Index2);
}
//=======================================================================
// function : GetBorderDeflection
// purpose : This method returns a border deflection of the polyhedron.
//=======================================================================
inline Standard_Real IntCurveSurface_PolyhedronTool::GetBorderDeflection(
const ThePolyhedron& thePolyh)
{
return thePolyh.GetBorderDeflection();
}
// Modified by Sergey KHROMOV - Fri Dec 7 13:46:56 2001 End

View File

@@ -0,0 +1,239 @@
// Copyright (c) 2025 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 IntCurveSurface_PolyhedronUtils_pxx_HeaderFile
#define IntCurveSurface_PolyhedronUtils_pxx_HeaderFile
#include <Bnd_Box.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
#include <Standard_Real.hxx>
#include <TColStd_Array1OfReal.hxx>
//! Utility functions for polyhedron discretization of surfaces.
//! These template functions implement the core logic previously in IntCurveSurface_Polyhedron.gxx.
namespace IntCurveSurface_PolyhedronUtils
{
//! Minimum edge length for valid triangles.
constexpr double THE_MIN_EDGE_LENGTH_SQUARED = 1e-15;
//! Initialize polyhedron with uniform UV sampling.
//! @tparam SurfaceType Type of surface (e.g., Handle(Adaptor3d_Surface))
//! @tparam SurfaceTool Tool class providing surface operations (D0, Value)
//! @param[in] theSurface The surface to discretize
//! @param[in] theU0 First U parameter
//! @param[in] theV0 First V parameter
//! @param[in] theU1 Last U parameter
//! @param[in] theV1 Last V parameter
//! @param[in] theNbDeltaU Number of U subdivisions
//! @param[in] theNbDeltaV Number of V subdivisions
//! @param[out] thePnts Array of sampled points (cast to gp_Pnt*)
//! @param[out] theU Array of U parameters (cast to double*)
//! @param[out] theV Array of V parameters (cast to double*)
//! @param[out] theIsOnBounds Array of boundary flags (cast to bool*)
//! @param[in,out] theBnd Bounding box to update
template <typename SurfaceType, typename SurfaceTool>
void InitUniform(const SurfaceType& theSurface,
const double theU0,
const double theV0,
const double theU1,
const double theV1,
const int theNbDeltaU,
const int theNbDeltaV,
gp_Pnt* thePnts,
double* theU,
double* theV,
Standard_Boolean* theIsOnBounds,
Bnd_Box& theBnd)
{
const double dU = (theU1 - theU0) / static_cast<double>(theNbDeltaU);
const double dV = (theV1 - theV0) / static_cast<double>(theNbDeltaV);
int Index = 1;
double U = theU0;
for (int i1 = 0; i1 <= theNbDeltaU; ++i1, U += dU)
{
double V = theV0;
for (int i2 = 0; i2 <= theNbDeltaV; ++i2, V += dV)
{
gp_Pnt TP;
SurfaceTool::D0(theSurface, U, V, TP);
thePnts[Index] = TP;
theU[Index] = U;
theV[Index] = V;
theIsOnBounds[Index] = (i1 == 0 || i1 == theNbDeltaU || i2 == 0 || i2 == theNbDeltaV);
theBnd.Add(TP);
++Index;
}
}
}
//! Initialize polyhedron with explicit UV parameter arrays.
//! @tparam SurfaceType Type of surface
//! @tparam SurfaceTool Tool class providing surface operations
//! @param[in] theSurface The surface to discretize
//! @param[in] theUpars Array of U parameters
//! @param[in] theVpars Array of V parameters
//! @param[in] theNbDeltaU Number of U subdivisions
//! @param[in] theNbDeltaV Number of V subdivisions
//! @param[out] thePnts Array of sampled points
//! @param[out] theU Array of U parameters
//! @param[out] theV Array of V parameters
//! @param[out] theIsOnBounds Array of boundary flags
//! @param[in,out] theBnd Bounding box to update
template <typename SurfaceType, typename SurfaceTool>
void InitWithParams(const SurfaceType& theSurface,
const TColStd_Array1OfReal& theUpars,
const TColStd_Array1OfReal& theVpars,
const int theNbDeltaU,
const int theNbDeltaV,
gp_Pnt* thePnts,
double* theU,
double* theV,
Standard_Boolean* theIsOnBounds,
Bnd_Box& theBnd)
{
const int i0 = theUpars.Lower();
const int j0 = theVpars.Lower();
int Index = 1;
for (int i1 = 0; i1 <= theNbDeltaU; ++i1)
{
const double U = theUpars(i1 + i0);
for (int i2 = 0; i2 <= theNbDeltaV; ++i2)
{
const double V = theVpars(i2 + j0);
gp_Pnt TP;
SurfaceTool::D0(theSurface, U, V, TP);
thePnts[Index] = TP;
theU[Index] = U;
theV[Index] = V;
theIsOnBounds[Index] = (i1 == 0 || i1 == theNbDeltaU || i2 == 0 || i2 == theNbDeltaV);
theBnd.Add(TP);
++Index;
}
}
}
//! Calculate deflection on a single triangle.
//! @tparam SurfaceType Type of surface
//! @tparam SurfaceTool Tool class providing surface operations
//! @param[in] theSurface The surface
//! @param[in] theP1 First vertex point
//! @param[in] theP2 Second vertex point
//! @param[in] theP3 Third vertex point
//! @param[in] theU1 U parameter at first vertex
//! @param[in] theV1 V parameter at first vertex
//! @param[in] theU2 U parameter at second vertex
//! @param[in] theV2 V parameter at second vertex
//! @param[in] theU3 U parameter at third vertex
//! @param[in] theV3 V parameter at third vertex
//! @return Deflection value (distance from triangle center to surface)
template <typename SurfaceType, typename SurfaceTool>
double DeflectionOnTriangle(const SurfaceType& theSurface,
const gp_Pnt& theP1,
const gp_Pnt& theP2,
const gp_Pnt& theP3,
const double theU1,
const double theV1,
const double theU2,
const double theV2,
const double theU3,
const double theV3)
{
// Check for degenerate triangles
if (theP1.SquareDistance(theP2) <= THE_MIN_EDGE_LENGTH_SQUARED)
return 0.0;
if (theP1.SquareDistance(theP3) <= THE_MIN_EDGE_LENGTH_SQUARED)
return 0.0;
if (theP2.SquareDistance(theP3) <= THE_MIN_EDGE_LENGTH_SQUARED)
return 0.0;
// Compute normal vector
const gp_XYZ XYZ1 = theP2.XYZ() - theP1.XYZ();
const gp_XYZ XYZ2 = theP3.XYZ() - theP2.XYZ();
const gp_XYZ XYZ3 = theP1.XYZ() - theP3.XYZ();
gp_Vec NormalVector((XYZ1 ^ XYZ2) + (XYZ2 ^ XYZ3) + (XYZ3 ^ XYZ1));
const double aNormLen = NormalVector.Magnitude();
if (aNormLen < gp::Resolution())
return 0.0;
NormalVector.Divide(aNormLen);
// Calculate center point on surface
const double u = (theU1 + theU2 + theU3) / 3.0;
const double v = (theV1 + theV2 + theV3) / 3.0;
const gp_Pnt P = SurfaceTool::Value(theSurface, u, v);
// Return distance from center to triangle plane
const gp_Vec P1P(theP1, P);
return std::abs(P1P.Dot(NormalVector));
}
//! Compute border deflection for a boundary isoline.
//! @tparam SurfaceType Type of surface
//! @tparam SurfaceTool Tool class providing surface operations
//! @param[in] theSurface The surface
//! @param[in] theParameter Fixed parameter value (U or V depending on isUIso)
//! @param[in] thePMin Start of varying parameter range
//! @param[in] thePMax End of varying parameter range
//! @param[in] theIsUIso True if this is a U-isoline, false for V-isoline
//! @param[in] theNbSamples Number of samples along the boundary
//! @return Maximum deflection along the border
template <typename SurfaceType, typename SurfaceTool>
double ComputeBorderDeflection(const SurfaceType& theSurface,
const double theParameter,
const double thePMin,
const double thePMax,
const bool theIsUIso,
const int theNbSamples)
{
const double aDelta = (thePMax - thePMin) / theNbSamples;
double aPar = thePMin;
double aDeflection = RealFirst();
for (int i = 0; i <= theNbSamples; ++i, aPar += aDelta)
{
gp_XYZ aP1, aP2, aPParMid;
if (theIsUIso)
{
aP1 = SurfaceTool::Value(theSurface, theParameter, aPar).XYZ();
aP2 = SurfaceTool::Value(theSurface, theParameter, aPar + aDelta).XYZ();
aPParMid = SurfaceTool::Value(theSurface, theParameter, aPar + aDelta / 2.0).XYZ();
}
else
{
aP1 = SurfaceTool::Value(theSurface, aPar, theParameter).XYZ();
aP2 = SurfaceTool::Value(theSurface, aPar + aDelta, theParameter).XYZ();
aPParMid = SurfaceTool::Value(theSurface, aPar + aDelta / 2.0, theParameter).XYZ();
}
const gp_XYZ aPMid = (aP2 + aP1) / 2.0;
const double aDist = (aPMid - aPParMid).Modulus();
if (aDist > aDeflection)
aDeflection = aDist;
}
return aDeflection;
}
} // namespace IntCurveSurface_PolyhedronUtils
#endif // IntCurveSurface_PolyhedronUtils_pxx_HeaderFile

View File

@@ -1,150 +0,0 @@
// Created on: 1993-08-18
// Created by: Laurent BUCHARD
// 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.
// Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001
#include <TColStd_SequenceOfReal.hxx>
#include <math_FunctionAllRoots.hxx>
#include <math_FunctionSample.hxx>
#include <IntSurf_Quadric.hxx>
#include <GeomAbs_SurfaceType.hxx>
#define EPSX 0.00000000000001
#define EPSDIST 0.00000001
#define EPSNUL 0.00000001
//=================================================================================================
IntCurveSurface_QuadricCurveExactInter::IntCurveSurface_QuadricCurveExactInter(const TheSurface& S,
const TheCurve& C)
: nbpnts(-1),
nbintv(-1)
{
GeomAbs_SurfaceType QuadricType = TheSurfaceTool::GetType(S);
IntSurf_Quadric Quadric;
switch (QuadricType)
{
case GeomAbs_Plane: {
Quadric.SetValue(TheSurfaceTool::Plane(S));
break;
}
case GeomAbs_Cylinder: {
Quadric.SetValue(TheSurfaceTool::Cylinder(S));
break;
}
case GeomAbs_Cone: {
Quadric.SetValue(TheSurfaceTool::Cone(S));
break;
}
case GeomAbs_Sphere: {
Quadric.SetValue(TheSurfaceTool::Sphere(S));
break;
}
default: {
// cout<<" Probleme Sur le Type de Surface dans IntCurveSurface_Inter::InternalPerform
// "<<endl;
break;
}
}
// Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 Begin
Standard_Integer nbIntervals = TheCurveTool::NbIntervals(C, GeomAbs_C1);
TColStd_Array1OfReal anIntervals(1, nbIntervals + 1);
Standard_Integer ii;
TheCurveTool::Intervals(C, anIntervals, GeomAbs_C1);
for (ii = 1; ii <= nbIntervals; ii++)
{
Standard_Real U1 = anIntervals.Value(ii);
Standard_Real U2 = anIntervals.Value(ii + 1);
math_FunctionSample Sample(U1, U2, TheCurveTool::NbSamples(C, U1, U2));
IntCurveSurface_TheQuadCurvFunc Function(Quadric, C);
math_FunctionAllRoots Roots(Function, Sample, EPSX, EPSDIST, EPSNUL);
if (Roots.IsDone())
{
Standard_Integer nbp = Roots.NbPoints();
Standard_Integer nbi = Roots.NbIntervals();
Standard_Integer i;
for (i = 1; i <= nbp; i++)
{
pnts.Append(Roots.GetPoint(i));
//-- cout<<" QuadricCurveExactInter : Roots("<<i<<") = "<<Roots.GetPoint(i)<<endl;
}
Standard_Real a, b;
for (i = 1; i <= nbi; i++)
{
Roots.GetInterval(i, a, b);
// cout<<" QuadricCurveExactInter : RootsSeg("<<i<<") = "<<a<<" , "<<b<<endl;
intv.Append(a);
intv.Append(b);
}
}
else
{
break;
}
}
if (ii > nbIntervals)
{
nbpnts = pnts.Length();
nbintv = intv.Length() / 2;
}
// Modified by skv - Wed Jun 16 17:36:47 2004 OCC6001 End
}
//=================================================================================================
Standard_Boolean IntCurveSurface_QuadricCurveExactInter::IsDone() const
{
return (nbpnts != -1);
}
//=================================================================================================
Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbRoots() const
{
return (nbpnts);
}
//=================================================================================================
Standard_Integer IntCurveSurface_QuadricCurveExactInter::NbIntervals() const
{
return (nbintv);
}
//=================================================================================================
Standard_Real IntCurveSurface_QuadricCurveExactInter::Root(const Standard_Integer Index) const
{
return (pnts(Index));
}
//=================================================================================================
void IntCurveSurface_QuadricCurveExactInter::Intervals(const Standard_Integer Index,
Standard_Real& a,
Standard_Real& b) const
{
Standard_Integer Index2 = Index + Index - 1;
a = intv(Index2);
b = intv(Index2 + 1);
}

View File

@@ -0,0 +1,134 @@
// 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.
#ifndef IntCurveSurface_QuadricCurveExactInterUtils_HeaderFile
#define IntCurveSurface_QuadricCurveExactInterUtils_HeaderFile
#include <GeomAbs_SurfaceType.hxx>
#include <IntSurf_Quadric.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <math_FunctionAllRoots.hxx>
#include <math_FunctionSample.hxx>
namespace IntCurveSurface_QuadricCurveExactInterUtils
{
//! Tolerance values for root finding
constexpr double EPSX = 0.00000000000001;
constexpr double EPSDIST = 0.00000001;
constexpr double EPSNUL = 0.00000001;
//! Performs intersection of a curve with a quadric surface.
//! @tparam SurfaceType The surface type (Handle(Adaptor3d_Surface) or Standard_Address)
//! @tparam SurfaceTool The surface tool class
//! @tparam CurveType The curve type (Handle(Adaptor3d_Curve) or gp_Lin)
//! @tparam CurveTool The curve tool class
//! @tparam QuadCurvFuncType The quadric curve function class
//! @param theSurface [in] The quadric surface
//! @param theCurve [in] The curve to intersect
//! @param thePnts [out] Sequence of intersection parameter values (roots)
//! @param theIntv [out] Sequence of interval boundaries (pairs of start/end)
//! @param theNbPnts [out] Number of intersection points (-1 if failed)
//! @param theNbIntv [out] Number of intersection intervals (-1 if failed)
template <typename SurfaceType,
typename SurfaceTool,
typename CurveType,
typename CurveTool,
typename QuadCurvFuncType>
void PerformIntersection(const SurfaceType& theSurface,
const CurveType& theCurve,
TColStd_SequenceOfReal& thePnts,
TColStd_SequenceOfReal& theIntv,
int& theNbPnts,
int& theNbIntv)
{
theNbPnts = -1;
theNbIntv = -1;
GeomAbs_SurfaceType aQuadricType = SurfaceTool::GetType(theSurface);
IntSurf_Quadric aQuadric;
switch (aQuadricType)
{
case GeomAbs_Plane: {
aQuadric.SetValue(SurfaceTool::Plane(theSurface));
break;
}
case GeomAbs_Cylinder: {
aQuadric.SetValue(SurfaceTool::Cylinder(theSurface));
break;
}
case GeomAbs_Cone: {
aQuadric.SetValue(SurfaceTool::Cone(theSurface));
break;
}
case GeomAbs_Sphere: {
aQuadric.SetValue(SurfaceTool::Sphere(theSurface));
break;
}
default: {
break;
}
}
int aNbIntervals = CurveTool::NbIntervals(theCurve, GeomAbs_C1);
TColStd_Array1OfReal anIntervals(1, aNbIntervals + 1);
int ii;
CurveTool::Intervals(theCurve, anIntervals, GeomAbs_C1);
for (ii = 1; ii <= aNbIntervals; ii++)
{
double U1 = anIntervals.Value(ii);
double U2 = anIntervals.Value(ii + 1);
math_FunctionSample aSample(U1, U2, CurveTool::NbSamples(theCurve, U1, U2));
QuadCurvFuncType aFunction(aQuadric, theCurve);
math_FunctionAllRoots aRoots(aFunction, aSample, EPSX, EPSDIST, EPSNUL);
if (aRoots.IsDone())
{
int aNbPoints = aRoots.NbPoints();
int aNbRootIntv = aRoots.NbIntervals();
for (int i = 1; i <= aNbPoints; i++)
{
thePnts.Append(aRoots.GetPoint(i));
}
double a, b;
for (int i = 1; i <= aNbRootIntv; i++)
{
aRoots.GetInterval(i, a, b);
theIntv.Append(a);
theIntv.Append(b);
}
}
else
{
break;
}
}
if (ii > aNbIntervals)
{
theNbPnts = thePnts.Length();
theNbIntv = theIntv.Length() / 2;
}
}
} // namespace IntCurveSurface_QuadricCurveExactInterUtils
#endif // IntCurveSurface_QuadricCurveExactInterUtils_HeaderFile

View File

@@ -0,0 +1,143 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_ThePolygonOfHInter.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#include "IntCurveSurface_PolygonUtils.pxx"
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <Standard_OutOfRange.hxx>
//==================================================================================================
IntCurveSurface_ThePolygonOfHInter::IntCurveSurface_ThePolygonOfHInter(
const Handle(Adaptor3d_Curve)& Curve,
const Standard_Integer NbPnt)
: ThePnts(1, (NbPnt < 5) ? 5 : NbPnt),
ClosedPolygon(Standard_False)
{
NbPntIn = (NbPnt < 5) ? 5 : NbPnt;
Binf = IntCurveSurface_TheHCurveTool::FirstParameter(Curve);
Bsup = IntCurveSurface_TheHCurveTool::LastParameter(Curve);
Init(Curve);
}
//==================================================================================================
IntCurveSurface_ThePolygonOfHInter::IntCurveSurface_ThePolygonOfHInter(
const Handle(Adaptor3d_Curve)& Curve,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Integer NbPnt)
: ThePnts(1, (NbPnt < 5) ? 5 : NbPnt),
ClosedPolygon(Standard_False),
Binf(U1),
Bsup(U2)
{
NbPntIn = (NbPnt < 5) ? 5 : NbPnt;
Init(Curve);
}
//==================================================================================================
IntCurveSurface_ThePolygonOfHInter::IntCurveSurface_ThePolygonOfHInter(
const Handle(Adaptor3d_Curve)& Curve,
const TColStd_Array1OfReal& Upars)
: ThePnts(1, Upars.Length()),
ClosedPolygon(Standard_False),
Binf(Upars(Upars.Lower())),
Bsup(Upars(Upars.Upper()))
{
NbPntIn = Upars.Length();
Init(Curve, Upars);
}
//==================================================================================================
void IntCurveSurface_ThePolygonOfHInter::Init(const Handle(Adaptor3d_Curve)& Curve)
{
IntCurveSurface_PolygonUtils::InitUniform<Handle(Adaptor3d_Curve), IntCurveSurface_TheHCurveTool>(
Curve,
Binf,
Bsup,
NbPntIn,
ThePnts,
TheBnd,
TheDeflection);
ClosedPolygon = Standard_False;
}
//==================================================================================================
void IntCurveSurface_ThePolygonOfHInter::Init(const Handle(Adaptor3d_Curve)& Curve,
const TColStd_Array1OfReal& Upars)
{
IntCurveSurface_PolygonUtils::InitWithParams<Handle(Adaptor3d_Curve),
IntCurveSurface_TheHCurveTool>(Curve,
Upars,
NbPntIn,
ThePnts,
TheBnd,
TheDeflection,
myParams);
ClosedPolygon = Standard_False;
}
//==================================================================================================
Standard_Real IntCurveSurface_ThePolygonOfHInter::ApproxParamOnCurve(
const Standard_Integer Index,
const Standard_Real ParamOnLine) const
{
return IntCurveSurface_PolygonUtils::ApproxParamOnCurve(Index,
ParamOnLine,
Binf,
Bsup,
NbPntIn,
myParams);
}
//==================================================================================================
void IntCurveSurface_ThePolygonOfHInter::Dump() const
{
#if 0
static Standard_Integer Compteur=0;
char tamp[100];
Compteur++;
Sprintf(tamp,"Poly%d",Compteur);
std::cout<<" @@@@@@@@@@@ F i c h i e r : "<<tamp<<" @@@@@@@@@@"<<std::endl;
FILE *fp;
fp=fopen(tamp,"w");
if(fp==NULL) {
std::cout<<"PolyGonGen::Erreur en Ouverture Fichier"<<tamp<<std::endl;
return;
}
fprintf(fp,"\n#Discretisation de : %f ---> %f \n",Binf,Bsup);
fprintf(fp,"\npol %d %d %f",Compteur,NbPntIn,TheDeflection);
gp_Pnt p1,p2;
for (Standard_Integer iObje=1; iObje<=NbSegments(); iObje++) {
p1=BeginOfSeg(iObje);
fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y());
}
p1=EndOfSeg(NbSegments());
fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y());
fprintf(fp,"\ndispol %d\n#\n",Compteur);
fclose(fp);
#endif
}

View File

@@ -1,31 +0,0 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_ThePolygonOfHInter.hxx>
#include <Standard_OutOfRange.hxx>
#include <Adaptor3d_Curve.hxx>
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#define TheCurve Handle(Adaptor3d_Curve)
#define TheCurve_hxx <Adaptor3d_Curve.hxx>
#define TheCurveTool IntCurveSurface_TheHCurveTool
#define TheCurveTool_hxx <IntCurveSurface_TheHCurveTool.hxx>
#define IntCurveSurface_Polygon IntCurveSurface_ThePolygonOfHInter
#define IntCurveSurface_Polygon_hxx <IntCurveSurface_ThePolygonOfHInter.hxx>
#include <IntCurveSurface_Polygon.gxx>

View File

@@ -20,11 +20,9 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
class Standard_OutOfRange;
class gp_Pnt;
class IntCurveSurface_ThePolygonOfHInter;
class Bnd_Box;
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#include <IntCurveSurface_ThePolygonOfHInter.hxx>
class IntCurveSurface_ThePolygonToolOfHInter
{
@@ -32,47 +30,42 @@ public:
DEFINE_STANDARD_ALLOC
//! Give the bounding box of the polygon.
static const Bnd_Box& Bounding(const IntCurveSurface_ThePolygonOfHInter& thePolygon);
static const Bnd_Box& Bounding(const IntCurveSurface_ThePolygonOfHInter& thePolygon)
{
return thePolygon.Bounding();
}
static Standard_Real DeflectionOverEstimation(
const IntCurveSurface_ThePolygonOfHInter& thePolygon);
const IntCurveSurface_ThePolygonOfHInter& thePolygon)
{
return thePolygon.DeflectionOverEstimation();
}
static Standard_Boolean Closed(const IntCurveSurface_ThePolygonOfHInter& thePolygon);
static Standard_Boolean Closed(const IntCurveSurface_ThePolygonOfHInter& thePolygon)
{
return thePolygon.Closed();
}
static Standard_Integer NbSegments(const IntCurveSurface_ThePolygonOfHInter& thePolygon);
static Standard_Integer NbSegments(const IntCurveSurface_ThePolygonOfHInter& thePolygon)
{
return thePolygon.NbSegments();
}
//! Give the point of range Index in the Polygon.
static const gp_Pnt& BeginOfSeg(const IntCurveSurface_ThePolygonOfHInter& thePolygon,
const Standard_Integer Index);
const Standard_Integer Index)
{
return thePolygon.BeginOfSeg(Index);
}
//! Give the point of range Index in the Polygon.
static const gp_Pnt& EndOfSeg(const IntCurveSurface_ThePolygonOfHInter& thePolygon,
const Standard_Integer Index);
const Standard_Integer Index)
{
return thePolygon.EndOfSeg(Index);
}
Standard_EXPORT static void Dump(const IntCurveSurface_ThePolygonOfHInter& thePolygon);
protected:
private:
};
#define ThePoint gp_Pnt
#define ThePoint_hxx <gp_Pnt.hxx>
#define ThePolygon IntCurveSurface_ThePolygonOfHInter
#define ThePolygon_hxx <IntCurveSurface_ThePolygonOfHInter.hxx>
#define TheBoundingBox Bnd_Box
#define TheBoundingBox_hxx <Bnd_Box.hxx>
#define IntCurveSurface_PolygonTool IntCurveSurface_ThePolygonToolOfHInter
#define IntCurveSurface_PolygonTool_hxx <IntCurveSurface_ThePolygonToolOfHInter.hxx>
#include <IntCurveSurface_PolygonTool.lxx>
#undef ThePoint
#undef ThePoint_hxx
#undef ThePolygon
#undef ThePolygon_hxx
#undef TheBoundingBox
#undef TheBoundingBox_hxx
#undef IntCurveSurface_PolygonTool
#undef IntCurveSurface_PolygonTool_hxx
#endif // _IntCurveSurface_ThePolygonToolOfHInter_HeaderFile

View File

@@ -0,0 +1,786 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Bnd_Array1OfBox.hxx>
#include <Bnd_Box.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
#include <Standard_OutOfRange.hxx>
#include "IntCurveSurface_PolyhedronUtils.pxx"
#define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
//==================================================================================================
IntCurveSurface_ThePolyhedronOfHInter::IntCurveSurface_ThePolyhedronOfHInter(
const Handle(Adaptor3d_Surface)& Surface,
const Standard_Integer nbdU,
const Standard_Integer nbdV,
const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2)
: nbdeltaU((nbdU < 3) ? 3 : nbdU),
nbdeltaV((nbdV < 3) ? 3 : nbdV),
TheDeflection(Epsilon(100.)),
C_MyPnts(NULL),
C_MyU(NULL),
C_MyV(NULL),
C_MyIsOnBounds(NULL)
{
Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
C_MyPnts = new gp_Pnt[t];
C_MyU = new Standard_Real[t];
C_MyV = new Standard_Real[t];
C_MyIsOnBounds = new Standard_Boolean[t];
Init(Surface, u1, v1, u2, v2);
}
//==================================================================================================
IntCurveSurface_ThePolyhedronOfHInter::IntCurveSurface_ThePolyhedronOfHInter(
const Handle(Adaptor3d_Surface)& Surface,
const TColStd_Array1OfReal& Upars,
const TColStd_Array1OfReal& Vpars)
: nbdeltaU(Upars.Length() - 1),
nbdeltaV(Vpars.Length() - 1),
TheDeflection(Epsilon(100.)),
C_MyPnts(NULL),
C_MyU(NULL),
C_MyV(NULL),
C_MyIsOnBounds(NULL)
{
Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
C_MyPnts = new gp_Pnt[t];
C_MyU = new Standard_Real[t];
C_MyV = new Standard_Real[t];
C_MyIsOnBounds = new Standard_Boolean[t];
Init(Surface, Upars, Vpars);
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Destroy()
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
if (C_MyPnts)
delete[] CMyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
if (C_MyU)
delete[] CMyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
if (C_MyV)
delete[] CMyV;
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
if (C_MyIsOnBounds)
delete[] CMyIsOnBounds;
C_MyPnts = C_MyU = C_MyV = C_MyIsOnBounds = NULL;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Init(const Handle(Adaptor3d_Surface)& Surface,
const Standard_Real U0,
const Standard_Real V0,
const Standard_Real U1,
const Standard_Real V1)
{
IntCurveSurface_PolyhedronUtils::InitUniform<Handle(Adaptor3d_Surface), Adaptor3d_HSurfaceTool>(
Surface,
U0,
V0,
U1,
V1,
nbdeltaU,
nbdeltaV,
(gp_Pnt*)C_MyPnts,
(Standard_Real*)C_MyU,
(Standard_Real*)C_MyV,
(Standard_Boolean*)C_MyIsOnBounds,
TheBnd);
// Calculate triangle deflections
Standard_Real tol = 0.0;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer i1 = 1; i1 <= nbtriangles; i1++)
{
Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
if (tol1 > tol)
tol = tol1;
}
DeflectionOverEstimation(tol * 1.2);
FillBounding();
// Compute border deflection
TheBorderDeflection = RealFirst();
Standard_Real aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Init(const Handle(Adaptor3d_Surface)& Surface,
const TColStd_Array1OfReal& Upars,
const TColStd_Array1OfReal& Vpars)
{
IntCurveSurface_PolyhedronUtils::InitWithParams<Handle(Adaptor3d_Surface),
Adaptor3d_HSurfaceTool>(
Surface,
Upars,
Vpars,
nbdeltaU,
nbdeltaV,
(gp_Pnt*)C_MyPnts,
(Standard_Real*)C_MyU,
(Standard_Real*)C_MyV,
(Standard_Boolean*)C_MyIsOnBounds,
TheBnd);
// Calculate triangle deflections
Standard_Real tol = 0.0;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer i1 = 1; i1 <= nbtriangles; i1++)
{
Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
if (tol1 > tol)
tol = tol1;
}
DeflectionOverEstimation(tol * 1.2);
FillBounding();
// Compute border deflection
TheBorderDeflection = RealFirst();
Standard_Integer i0 = Upars.Lower();
Standard_Integer j0 = Vpars.Lower();
Standard_Real U0 = Upars(i0);
Standard_Real V0 = Vpars(j0);
Standard_Real U1 = Upars(Upars.Upper());
Standard_Real V1 = Vpars(Vpars.Upper());
Standard_Real aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
}
//==================================================================================================
Standard_Real IntCurveSurface_ThePolyhedronOfHInter::DeflectionOnTriangle(
const Handle(Adaptor3d_Surface)& Surface,
const Standard_Integer Triang) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
Standard_Real u1, v1, u2, v2, u3, v3;
gp_Pnt P1 = Point(i1, u1, v1);
gp_Pnt P2 = Point(i2, u2, v2);
gp_Pnt P3 = Point(i3, u3, v3);
return IntCurveSurface_PolyhedronUtils::DeflectionOnTriangle<
Handle(Adaptor3d_Surface),
Adaptor3d_HSurfaceTool>(Surface, P1, P2, P3, u1, v1, u2, v2, u3, v3);
}
//==================================================================================================
Standard_Real IntCurveSurface_ThePolyhedronOfHInter::ComputeBorderDeflection(
const Handle(Adaptor3d_Surface)& Surface,
const Standard_Real Parameter,
const Standard_Real PMin,
const Standard_Real PMax,
const Standard_Boolean isUIso) const
{
Standard_Integer aNbSamples = isUIso ? nbdeltaV : nbdeltaU;
return IntCurveSurface_PolyhedronUtils::ComputeBorderDeflection<Handle(Adaptor3d_Surface),
Adaptor3d_HSurfaceTool>(
Surface,
Parameter,
PMin,
PMax,
isUIso,
aNbSamples);
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Parameters(const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V) const
{
Standard_Real* CMyU = (Standard_Real*)C_MyU;
U = CMyU[Index];
Standard_Real* CMyV = (Standard_Real*)C_MyV;
V = CMyV[Index];
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::DeflectionOverEstimation(const Standard_Real flec)
{
if (flec < 0.0001)
{
TheDeflection = 0.0001;
TheBnd.Enlarge(0.0001);
}
else
{
TheDeflection = flec;
TheBnd.Enlarge(flec);
}
}
//==================================================================================================
Standard_Real IntCurveSurface_ThePolyhedronOfHInter::DeflectionOverEstimation() const
{
return TheDeflection;
}
//==================================================================================================
const Bnd_Box& IntCurveSurface_ThePolyhedronOfHInter::Bounding() const
{
return TheBnd;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::FillBounding()
{
TheComponentsBnd = new Bnd_HArray1OfBox(1, NbTriangles());
Bnd_Box Boite;
Standard_Integer np1, np2, np3;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer iTri = 1; iTri <= nbtriangles; iTri++)
{
Triangle(iTri, np1, np2, np3);
gp_Pnt p1(Point(np1));
gp_Pnt p2(Point(np2));
gp_Pnt p3(Point(np3));
Boite.SetVoid();
if (p1.SquareDistance(p2) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
if (p1.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
if (p2.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
Boite.Add(p1);
Boite.Add(p2);
Boite.Add(p3);
Boite.Enlarge(TheDeflection);
}
}
}
Boite.Enlarge(TheDeflection);
TheComponentsBnd->SetValue(iTri, Boite);
}
}
//==================================================================================================
const Handle(Bnd_HArray1OfBox)& IntCurveSurface_ThePolyhedronOfHInter::ComponentsBounding() const
{
return TheComponentsBnd;
}
//==================================================================================================
Standard_Integer IntCurveSurface_ThePolyhedronOfHInter::NbTriangles() const
{
return nbdeltaU * nbdeltaV * 2;
}
//==================================================================================================
Standard_Integer IntCurveSurface_ThePolyhedronOfHInter::NbPoints() const
{
return (nbdeltaU + 1) * (nbdeltaV + 1);
}
//==================================================================================================
Standard_Integer IntCurveSurface_ThePolyhedronOfHInter::TriConnex(const Standard_Integer Triang,
const Standard_Integer Pivot,
const Standard_Integer Pedge,
Standard_Integer& TriCon,
Standard_Integer& OtherP) const
{
Standard_Integer Pivotm1 = Pivot - 1;
Standard_Integer nbdeltaVp1 = nbdeltaV + 1;
Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
Standard_Integer ligP = Pivotm1 / nbdeltaVp1;
Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
Standard_Integer ligE = 0, colE = 0, typE = 0;
if (Pedge != 0)
{
ligE = (Pedge - 1) / nbdeltaVp1;
colE = (Pedge - 1) - (ligE * nbdeltaVp1);
if (ligP == ligE)
typE = 1;
else if (colP == colE)
typE = 2;
else
typE = 3;
}
Standard_Integer linT = 0, colT = 0;
Standard_Integer linO = 0, colO = 0;
Standard_Integer t = 0, tt = 0;
if (Triang != 0)
{
t = (Triang - 1) / nbdeltaVm2;
tt = (Triang - 1) - t * nbdeltaVm2;
linT = 1 + t;
colT = 1 + tt;
if (typE == 0)
{
if (ligP == linT)
{
ligE = ligP - 1;
colE = colP - 1;
typE = 3;
}
else
{
if (colT == ligP + ligP)
{
ligE = ligP;
colE = colP - 1;
typE = 1;
}
else
{
ligE = ligP + 1;
colE = colP + 1;
typE = 3;
}
}
}
switch (typE)
{
case 1:
if (linT == ligP)
{
linT++;
linO = ligP + 1;
colO = (colP > colE) ? colP : colE;
}
else
{
linT--;
linO = ligP - 1;
colO = (colP < colE) ? colP : colE;
}
break;
case 2:
if (colT == (colP + colP))
{
colT++;
linO = (ligP > ligE) ? ligP : ligE;
colO = colP + 1;
}
else
{
colT--;
linO = (ligP < ligE) ? ligP : ligE;
colO = colP - 1;
}
break;
case 3:
if ((colT & 1) == 0)
{
colT--;
linO = (ligP > ligE) ? ligP : ligE;
colO = (colP < colE) ? colP : colE;
}
else
{
colT++;
linO = (ligP < ligE) ? ligP : ligE;
colO = (colP > colE) ? colP : colE;
}
break;
}
}
else
{
if (Pedge == 0)
{
linT = (1 > ligP) ? 1 : ligP;
colT = (1 > (colP + colP)) ? 1 : (colP + colP);
if (ligP == 0)
linO = ligP + 1;
else
linO = ligP - 1;
colO = colP;
}
else
{
switch (typE)
{
case 1:
linT = ligP + 1;
colT = (colP > colE) ? colP : colE;
colT += colT;
linO = ligP + 1;
colO = (colP > colE) ? colP : colE;
break;
case 2:
linT = (ligP > ligE) ? ligP : ligE;
colT = colP + colP;
linO = (ligP < ligE) ? ligP : ligE;
colO = colP - 1;
break;
case 3:
linT = (ligP > ligE) ? ligP : ligE;
colT = colP + colE;
linO = (ligP > ligE) ? ligP : ligE;
colO = (colP < colE) ? colP : colE;
break;
}
}
}
TriCon = (linT - 1) * nbdeltaVm2 + colT;
if (linT < 1)
{
linO = 0;
colO = colP + colP - colE;
if (colO < 0)
{
colO = 0;
linO = 1;
}
else if (colO > nbdeltaV)
{
colO = nbdeltaV;
linO = 1;
}
TriCon = 0;
}
else if (linT > nbdeltaU)
{
linO = nbdeltaU;
colO = colP + colP - colE;
if (colO < 0)
{
colO = 0;
linO = nbdeltaU - 1;
}
else if (colO > nbdeltaV)
{
colO = nbdeltaV;
linO = nbdeltaU - 1;
}
TriCon = 0;
}
if (colT < 1)
{
colO = 0;
linO = ligP + ligP - ligE;
if (linO < 0)
{
linO = 0;
colO = 1;
}
else if (linO > nbdeltaU)
{
linO = nbdeltaU;
colO = 1;
}
TriCon = 0;
}
else if (colT > nbdeltaV)
{
colO = nbdeltaV;
linO = ligP + ligP - ligE;
if (linO < 0)
{
linO = 0;
colO = nbdeltaV - 1;
}
else if (linO > nbdeltaU)
{
linO = nbdeltaU;
colO = nbdeltaV - 1;
}
TriCon = 0;
}
OtherP = linO * nbdeltaVp1 + colO + 1;
return TriCon;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::PlaneEquation(const Standard_Integer Triang,
gp_XYZ& NormalVector,
Standard_Real& PolarDistance) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
gp_XYZ v1 = Pointi2 - Pointi1;
gp_XYZ v2 = Pointi3 - Pointi2;
gp_XYZ v3 = Pointi1 - Pointi3;
if (v1.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
if (v2.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
if (v3.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
NormalVector = (v1 ^ v2) + (v2 ^ v3) + (v3 ^ v1);
Standard_Real aNormLen = NormalVector.Modulus();
if (aNormLen < gp::Resolution())
{
PolarDistance = 0.;
}
else
{
NormalVector.Divide(aNormLen);
PolarDistance = NormalVector * Point(i1).XYZ();
}
}
//==================================================================================================
Standard_Boolean IntCurveSurface_ThePolyhedronOfHInter::Contain(const Standard_Integer Triang,
const gp_Pnt& ThePnt) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
gp_XYZ v1 = (Pointi2 - Pointi1) ^ (ThePnt.XYZ() - Pointi1);
gp_XYZ v2 = (Pointi3 - Pointi2) ^ (ThePnt.XYZ() - Pointi2);
gp_XYZ v3 = (Pointi1 - Pointi3) ^ (ThePnt.XYZ() - Pointi3);
if (v1 * v2 >= 0. && v2 * v3 >= 0. && v3 * v1 >= 0.)
return Standard_True;
else
return Standard_False;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Dump() const {}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Size(Standard_Integer& nbdu,
Standard_Integer& nbdv) const
{
nbdu = nbdeltaU;
nbdv = nbdeltaV;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Triangle(const Standard_Integer Index,
Standard_Integer& P1,
Standard_Integer& P2,
Standard_Integer& P3) const
{
Standard_Integer line = 1 + ((Index - 1) / (nbdeltaV * 2));
Standard_Integer colon = 1 + ((Index - 1) % (nbdeltaV * 2));
Standard_Integer colpnt = (colon + 1) / 2;
P1 = (line - 1) * (nbdeltaV + 1) + colpnt;
P2 = line * (nbdeltaV + 1) + colpnt + ((colon - 1) % 2);
P3 = (line - 1 + (colon % 2)) * (nbdeltaV + 1) + colpnt + 1;
}
//==================================================================================================
const gp_Pnt& IntCurveSurface_ThePolyhedronOfHInter::Point(const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V) const
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
U = CMyU[Index];
V = CMyV[Index];
return CMyPnts[Index];
}
//==================================================================================================
const gp_Pnt& IntCurveSurface_ThePolyhedronOfHInter::Point(const Standard_Integer Index) const
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
return CMyPnts[Index];
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Point(const gp_Pnt&,
const Standard_Integer,
const Standard_Integer,
const Standard_Real,
const Standard_Real)
{
// Should not be called
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::Point(const Standard_Integer Index, gp_Pnt& P) const
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
P = CMyPnts[Index];
}
//==================================================================================================
Standard_Boolean IntCurveSurface_ThePolyhedronOfHInter::IsOnBound(
const Standard_Integer Index1,
const Standard_Integer Index2) const
{
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
Standard_Integer aDiff = std::abs(Index1 - Index2);
if (aDiff != 1 && aDiff != nbdeltaV + 1)
return Standard_False;
for (Standard_Integer i = 0; i <= nbdeltaU; i++)
{
if ((Index1 == 1 + i * (nbdeltaV + 1)) && (Index2 == Index1 - 1))
return Standard_False;
if ((Index1 == (1 + i) * (nbdeltaV + 1)) && (Index2 == Index1 + 1))
return Standard_False;
}
return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::UMinSingularity(const Standard_Boolean Sing)
{
UMinSingular = Sing;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::UMaxSingularity(const Standard_Boolean Sing)
{
UMaxSingular = Sing;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::VMinSingularity(const Standard_Boolean Sing)
{
VMinSingular = Sing;
}
//==================================================================================================
void IntCurveSurface_ThePolyhedronOfHInter::VMaxSingularity(const Standard_Boolean Sing)
{
VMaxSingular = Sing;
}
//==================================================================================================
Standard_Boolean IntCurveSurface_ThePolyhedronOfHInter::HasUMinSingularity() const
{
return UMinSingular;
}
//==================================================================================================
Standard_Boolean IntCurveSurface_ThePolyhedronOfHInter::HasUMaxSingularity() const
{
return UMaxSingular;
}
//==================================================================================================
Standard_Boolean IntCurveSurface_ThePolyhedronOfHInter::HasVMinSingularity() const
{
return VMinSingular;
}
//==================================================================================================
Standard_Boolean IntCurveSurface_ThePolyhedronOfHInter::HasVMaxSingularity() const
{
return VMaxSingular;
}

View File

@@ -148,7 +148,7 @@ public:
const Standard_Integer Index2) const;
//! This method returns a border deflection.
Standard_Real GetBorderDeflection() const;
Standard_Real GetBorderDeflection() const { return TheBorderDeflection; }
Standard_EXPORT void Dump() const;
@@ -188,20 +188,4 @@ private:
Standard_Address C_MyIsOnBounds;
};
#define ThePSurface Handle(Adaptor3d_Surface)
#define ThePSurface_hxx <Adaptor3d_Surface.hxx>
#define ThePSurfaceTool Adaptor3d_HSurfaceTool
#define ThePSurfaceTool_hxx <Adaptor3d_HSurfaceTool.hxx>
#define IntCurveSurface_Polyhedron IntCurveSurface_ThePolyhedronOfHInter
#define IntCurveSurface_Polyhedron_hxx <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <IntCurveSurface_Polyhedron.lxx>
#undef ThePSurface
#undef ThePSurface_hxx
#undef ThePSurfaceTool
#undef ThePSurfaceTool_hxx
#undef IntCurveSurface_Polyhedron
#undef IntCurveSurface_Polyhedron_hxx
#endif // _IntCurveSurface_ThePolyhedronOfHInter_HeaderFile

View File

@@ -1,32 +0,0 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <Standard_OutOfRange.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <gp_Pnt.hxx>
#include <Bnd_Box.hxx>
#include <gp_XYZ.hxx>
#define ThePSurface Handle(Adaptor3d_Surface)
#define ThePSurface_hxx <Adaptor3d_Surface.hxx>
#define ThePSurfaceTool Adaptor3d_HSurfaceTool
#define ThePSurfaceTool_hxx <Adaptor3d_HSurfaceTool.hxx>
#define IntCurveSurface_Polyhedron IntCurveSurface_ThePolyhedronOfHInter
#define IntCurveSurface_Polyhedron_hxx <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <IntCurveSurface_Polyhedron.gxx>

View File

@@ -21,12 +21,10 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_HArray1OfBox.hxx>
#include <Standard_Integer.hxx>
class Standard_OutOfRange;
class IntCurveSurface_ThePolyhedronOfHInter;
class Bnd_Box;
class gp_Pnt;
#include <gp_Pnt.hxx>
#include <IntCurveSurface_ThePolyhedronOfHInter.hxx>
class IntCurveSurface_ThePolyhedronToolOfHInter
{
@@ -34,19 +32,31 @@ public:
DEFINE_STANDARD_ALLOC
//! Give the bounding box of the PolyhedronTool.
static const Bnd_Box& Bounding(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh);
static const Bnd_Box& Bounding(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh)
{
return thePolyh.Bounding();
}
//! Give the array of boxes. The box <n> corresponding
//! to the triangle <n>.
static const Handle(Bnd_HArray1OfBox)& ComponentsBounding(
const IntCurveSurface_ThePolyhedronOfHInter& thePolyh);
const IntCurveSurface_ThePolyhedronOfHInter& thePolyh)
{
return thePolyh.ComponentsBounding();
}
//! Give the tolerance of the polygon.
static Standard_Real DeflectionOverEstimation(
const IntCurveSurface_ThePolyhedronOfHInter& thePolyh);
const IntCurveSurface_ThePolyhedronOfHInter& thePolyh)
{
return thePolyh.DeflectionOverEstimation();
}
//! Give the number of triangles in this polyhedral surface.
static Standard_Integer NbTriangles(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh);
static Standard_Integer NbTriangles(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh)
{
return thePolyh.NbTriangles();
}
//! Give the indices of the 3 points of the triangle of
//! address Index in the PolyhedronTool.
@@ -54,11 +64,17 @@ public:
const Standard_Integer Index,
Standard_Integer& P1,
Standard_Integer& P2,
Standard_Integer& P3);
Standard_Integer& P3)
{
thePolyh.Triangle(Index, P1, P2, P3);
}
//! Give the point of index i in the polyhedral surface.
static const gp_Pnt& Point(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh,
const Standard_Integer Index);
const Standard_Integer Index)
{
return thePolyh.Point(Index);
}
//! Give the address Tricon of the triangle connexe to
//! the triangle of address Triang by the edge Pivot Pedge
@@ -71,7 +87,10 @@ public:
const Standard_Integer Pivot,
const Standard_Integer Pedge,
Standard_Integer& TriCon,
Standard_Integer& OtherP);
Standard_Integer& OtherP)
{
return thePolyh.TriConnex(Triang, Pivot, Pedge, TriCon, OtherP);
}
//! This method returns true if the edge based on points with
//! indices Index1 and Index2 represents a boundary edge. It is
@@ -79,27 +98,18 @@ public:
//! this edge.
static Standard_Boolean IsOnBound(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh,
const Standard_Integer Index1,
const Standard_Integer Index2);
const Standard_Integer Index2)
{
return thePolyh.IsOnBound(Index1, Index2);
}
//! This method returns a border deflection of the polyhedron.
static Standard_Real GetBorderDeflection(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh);
static Standard_Real GetBorderDeflection(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh)
{
return thePolyh.GetBorderDeflection();
}
Standard_EXPORT static void Dump(const IntCurveSurface_ThePolyhedronOfHInter& thePolyh);
protected:
private:
};
#define ThePolyhedron IntCurveSurface_ThePolyhedronOfHInter
#define ThePolyhedron_hxx <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#define IntCurveSurface_PolyhedronTool IntCurveSurface_ThePolyhedronToolOfHInter
#define IntCurveSurface_PolyhedronTool_hxx <IntCurveSurface_ThePolyhedronToolOfHInter.hxx>
#include <IntCurveSurface_PolyhedronTool.lxx>
#undef ThePolyhedron
#undef ThePolyhedron_hxx
#undef IntCurveSurface_PolyhedronTool
#undef IntCurveSurface_PolyhedronTool_hxx
#endif // _IntCurveSurface_ThePolyhedronToolOfHInter_HeaderFile

View File

@@ -0,0 +1,80 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_TheQuadCurvExactHInter.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <Adaptor3d_Surface.hxx>
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#include "IntCurveSurface_QuadricCurveExactInterUtils.pxx"
//==================================================================================================
IntCurveSurface_TheQuadCurvExactHInter::IntCurveSurface_TheQuadCurvExactHInter(
const Handle(Adaptor3d_Surface)& S,
const Handle(Adaptor3d_Curve)& C)
: nbpnts(-1),
nbintv(-1)
{
IntCurveSurface_QuadricCurveExactInterUtils::PerformIntersection<
Handle(Adaptor3d_Surface),
Adaptor3d_HSurfaceTool,
Handle(Adaptor3d_Curve),
IntCurveSurface_TheHCurveTool,
IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter>(S, C, pnts, intv, nbpnts, nbintv);
}
//==================================================================================================
Standard_Boolean IntCurveSurface_TheQuadCurvExactHInter::IsDone() const
{
return (nbpnts != -1);
}
//==================================================================================================
Standard_Integer IntCurveSurface_TheQuadCurvExactHInter::NbRoots() const
{
return nbpnts;
}
//==================================================================================================
Standard_Integer IntCurveSurface_TheQuadCurvExactHInter::NbIntervals() const
{
return nbintv;
}
//==================================================================================================
Standard_Real IntCurveSurface_TheQuadCurvExactHInter::Root(const Standard_Integer Index) const
{
return pnts(Index);
}
//==================================================================================================
void IntCurveSurface_TheQuadCurvExactHInter::Intervals(const Standard_Integer Index,
Standard_Real& a,
Standard_Real& b) const
{
Standard_Integer Index2 = Index + Index - 1;
a = intv(Index2);
b = intv(Index2 + 1);
}

View File

@@ -1,38 +0,0 @@
// Created on: 1993-04-07
// Created by: Laurent BUCHARD
// 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 <IntCurveSurface_TheQuadCurvExactHInter.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Adaptor3d_HSurfaceTool.hxx>
#include <Adaptor3d_Curve.hxx>
#include <IntCurveSurface_TheHCurveTool.hxx>
#include <IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#define TheSurface Handle(Adaptor3d_Surface)
#define TheSurface_hxx <Adaptor3d_Surface.hxx>
#define TheSurfaceTool Adaptor3d_HSurfaceTool
#define TheSurfaceTool_hxx <Adaptor3d_HSurfaceTool.hxx>
#define TheCurve Handle(Adaptor3d_Curve)
#define TheCurve_hxx <Adaptor3d_Curve.hxx>
#define TheCurveTool IntCurveSurface_TheHCurveTool
#define TheCurveTool_hxx <IntCurveSurface_TheHCurveTool.hxx>
#define IntCurveSurface_TheQuadCurvFunc IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter
#define IntCurveSurface_TheQuadCurvFunc_hxx \
<IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactHInter.hxx>
#define IntCurveSurface_QuadricCurveExactInter IntCurveSurface_TheQuadCurvExactHInter
#define IntCurveSurface_QuadricCurveExactInter_hxx <IntCurveSurface_TheQuadCurvExactHInter.hxx>
#include <IntCurveSurface_QuadricCurveExactInter.gxx>

View File

@@ -61,7 +61,7 @@ set(OCCT_HLRBRep_FILES
HLRBRep_IntConicCurveOfCInter.hxx
HLRBRep_IntConicCurveOfCInter_0.cxx
HLRBRep_InterCSurf.hxx
HLRBRep_InterCSurf_0.cxx
HLRBRep_InterCSurf.cxx
HLRBRep_InternalAlgo.cxx
HLRBRep_InternalAlgo.hxx
HLRBRep_Intersector.cxx
@@ -115,17 +115,17 @@ set(OCCT_HLRBRep_FILES
HLRBRep_ThePolygon2dOfTheIntPCurvePCurveOfCInter.hxx
HLRBRep_ThePolygon2dOfTheIntPCurvePCurveOfCInter_0.cxx
HLRBRep_ThePolygonOfInterCSurf.hxx
HLRBRep_ThePolygonOfInterCSurf_0.cxx
HLRBRep_ThePolygonOfInterCSurf.cxx
HLRBRep_ThePolygonToolOfInterCSurf.hxx
HLRBRep_ThePolygonToolOfInterCSurf_0.cxx
HLRBRep_ThePolyhedronOfInterCSurf.hxx
HLRBRep_ThePolyhedronOfInterCSurf_0.cxx
HLRBRep_ThePolyhedronOfInterCSurf.cxx
HLRBRep_ThePolyhedronToolOfInterCSurf.hxx
HLRBRep_ThePolyhedronToolOfInterCSurf_0.cxx
HLRBRep_TheProjPCurOfCInter.hxx
HLRBRep_TheProjPCurOfCInter_0.cxx
HLRBRep_TheQuadCurvExactInterCSurf.hxx
HLRBRep_TheQuadCurvExactInterCSurf_0.cxx
HLRBRep_TheQuadCurvExactInterCSurf.cxx
HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx
HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf_0.cxx
HLRBRep_VertexList.cxx

View File

@@ -0,0 +1,583 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_InterCSurf.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <Bnd_Box.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
#include <gp_Lin.hxx>
#include <gp_Parab.hxx>
#include <HLRBRep_LineTool.hxx>
#include <HLRBRep_SurfaceTool.hxx>
#include <HLRBRep_TheCSFunctionOfInterCSurf.hxx>
#include <HLRBRep_TheExactInterCSurf.hxx>
#include <HLRBRep_TheInterferenceOfInterCSurf.hxx>
#include <HLRBRep_ThePolygonOfInterCSurf.hxx>
#include <HLRBRep_ThePolygonToolOfInterCSurf.hxx>
#include <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#include <HLRBRep_ThePolyhedronToolOfInterCSurf.hxx>
#include <HLRBRep_TheQuadCurvExactInterCSurf.hxx>
#include <HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#include <IntAna_IntConicQuad.hxx>
#include "../../TKGeomAlgo/IntCurveSurface/IntCurveSurface_Inter.pxx"
// Type aliases for readability
using TheCurve = gp_Lin;
using TheCurveTool = HLRBRep_LineTool;
using TheSurface = Standard_Address;
using TheSurfaceTool = HLRBRep_SurfaceTool;
using ThePolygon = HLRBRep_ThePolygonOfInterCSurf;
using ThePolyhedron = HLRBRep_ThePolyhedronOfInterCSurf;
using TheInterference = HLRBRep_TheInterferenceOfInterCSurf;
using TheCSFunction = HLRBRep_TheCSFunctionOfInterCSurf;
using TheExactInter = HLRBRep_TheExactInterCSurf;
using TheQuadCurvExactInter = HLRBRep_TheQuadCurvExactInterCSurf;
//==================================================================================================
HLRBRep_InterCSurf::HLRBRep_InterCSurf() {}
//==================================================================================================
void HLRBRep_InterCSurf::DoSurface(const TheSurface& surface,
const Standard_Real u0,
const Standard_Real u1,
const Standard_Real v0,
const Standard_Real v1,
TColgp_Array2OfPnt& pntsOnSurface,
Bnd_Box& boxSurface,
Standard_Real& gap)
{
IntCurveSurface_InterUtils::DoSurface<TheSurface, TheSurfaceTool>(surface,
u0,
u1,
v0,
v1,
pntsOnSurface,
boxSurface,
gap);
}
//==================================================================================================
void HLRBRep_InterCSurf::DoNewBounds(const TheSurface& surface,
const Standard_Real u0,
const Standard_Real u1,
const Standard_Real v0,
const Standard_Real v1,
const TColgp_Array2OfPnt& pntsOnSurface,
const TColStd_Array1OfReal& X,
const TColStd_Array1OfReal& Y,
const TColStd_Array1OfReal& Z,
TColStd_Array1OfReal& Bounds)
{
IntCurveSurface_InterUtils::DoNewBounds<TheSurface, TheSurfaceTool>(surface,
u0,
u1,
v0,
v1,
pntsOnSurface,
X,
Y,
Z,
Bounds);
}
//==================================================================================================
void HLRBRep_InterCSurf::Perform(const TheCurve& curve, const TheSurface& surface)
{
IntCurveSurface_InterImpl::Perform<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool>(
curve,
surface,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c,
const TheSurface& s,
Standard_Real u0,
Standard_Real v0,
Standard_Real u1,
Standard_Real v1) { this->Perform(c, s, u0, v0, u1, v1); });
}
//==================================================================================================
void HLRBRep_InterCSurf::Perform(const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::
PerformBounds<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon>(
curve,
surface,
U1,
V1,
U2,
V2,
[this](const auto& conic,
const TheCurve& c,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->PerformConicSurf(conic, c, s, u1, v1, u2, v2); },
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, u1, v1, u2, v2); },
[this](const TheCurve& c, const TheSurface& s) { this->InternalPerformCurveQuadric(c, s); });
}
//==================================================================================================
void HLRBRep_InterCSurf::Perform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface)
{
IntCurveSurface_InterImpl::
PerformPolygon<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon, ThePolyhedron>(
curve,
polygon,
surface,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c, const ThePolygon& p, const TheSurface& s, const ThePolyhedron& ph) {
this->Perform(c, p, s, ph);
});
}
//==================================================================================================
void HLRBRep_InterCSurf::Perform(const TheCurve& curve,
const TheSurface& surface,
const ThePolyhedron& polyhedron)
{
IntCurveSurface_InterImpl::PerformPolyhedron<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
curve,
surface,
polyhedron,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c, const ThePolygon& p, const TheSurface& s, const ThePolyhedron& ph) {
this->Perform(c, p, s, ph);
});
}
//==================================================================================================
void HLRBRep_InterCSurf::Perform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron)
{
IntCurveSurface_InterImpl::PerformPolygonPolyhedron<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
curve,
polygon,
surface,
polyhedron,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); });
}
//==================================================================================================
void HLRBRep_InterCSurf::Perform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron,
Bnd_BoundSortBox& BndBSB)
{
IntCurveSurface_InterImpl::PerformPolygonPolyhedronBSB<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
curve,
polygon,
surface,
polyhedron,
BndBSB,
done,
[this]() { this->ResetFields(); },
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2,
Bnd_BoundSortBox& bsb) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2, bsb); });
}
//==================================================================================================
void HLRBRep_InterCSurf::InternalPerform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron,
const Standard_Real u0,
const Standard_Real v0,
const Standard_Real u1,
const Standard_Real v1,
Bnd_BoundSortBox& BSB)
{
IntCurveSurface_InterImpl::InternalPerformBSB<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron,
TheInterference,
TheCSFunction,
TheExactInter>(
curve,
polygon,
surface,
polyhedron,
u0,
v0,
u1,
v1,
BSB,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void HLRBRep_InterCSurf::InternalPerform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const ThePolyhedron& polyhedron,
const Standard_Real u0,
const Standard_Real v0,
const Standard_Real u1,
const Standard_Real v1)
{
IntCurveSurface_InterImpl::InternalPerform<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron,
TheInterference,
TheCSFunction,
TheExactInter>(
curve,
polygon,
surface,
polyhedron,
u0,
v0,
u1,
v1,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void HLRBRep_InterCSurf::InternalPerformCurveQuadric(const TheCurve& curve,
const TheSurface& surface)
{
IntCurveSurface_InterImpl::InternalPerformCurveQuadric<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
TheQuadCurvExactInter>(
curve,
surface,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void HLRBRep_InterCSurf::InternalPerform(const TheCurve& curve,
const ThePolygon& polygon,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::InternalPerformPolygonBounds<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron,
TheQuadCurvExactInter>(
curve,
polygon,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); },
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void HLRBRep_InterCSurf::PerformConicSurf(const gp_Lin& Line,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::PerformConicSurfLine<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
Line,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); },
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void HLRBRep_InterCSurf::PerformConicSurf(const gp_Circ& Circle,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::
PerformConicSurfCircle<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon>(
Circle,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, u1, v1, u2, v2); });
}
//==================================================================================================
void HLRBRep_InterCSurf::PerformConicSurf(const gp_Elips& Ellipse,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::
PerformConicSurfEllipse<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool, ThePolygon>(
Ellipse,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, u1, v1, u2, v2); });
}
//==================================================================================================
void HLRBRep_InterCSurf::PerformConicSurf(const gp_Parab& Parab,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::PerformConicSurfParabola<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
Parab,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); });
}
//==================================================================================================
void HLRBRep_InterCSurf::PerformConicSurf(const gp_Hypr& Hypr,
const TheCurve& curve,
const TheSurface& surface,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2)
{
IntCurveSurface_InterImpl::PerformConicSurfHyperbola<TheCurve,
TheCurveTool,
TheSurface,
TheSurfaceTool,
ThePolygon,
ThePolyhedron>(
Hypr,
curve,
surface,
U1,
V1,
U2,
V2,
[this](const TheCurve& c, const TheSurface& s, const IntAna_IntConicQuad& ana) {
this->AppendIntAna(c, s, ana);
},
[this](const TheCurve& c,
const ThePolygon& p,
const TheSurface& s,
const ThePolyhedron& ph,
Standard_Real u1,
Standard_Real v1,
Standard_Real u2,
Standard_Real v2) { this->InternalPerform(c, p, s, ph, u1, v1, u2, v2); });
}
//==================================================================================================
void HLRBRep_InterCSurf::AppendIntAna(const TheCurve& curve,
const TheSurface& surface,
const IntAna_IntConicQuad& intana_ConicQuad)
{
IntCurveSurface_InterImpl::AppendIntAna<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool>(
curve,
surface,
intana_ConicQuad,
myIsParallel,
[this](const IntCurveSurface_IntersectionPoint& pt) { this->Append(pt); });
}
//==================================================================================================
void HLRBRep_InterCSurf::AppendPoint(const TheCurve& curve,
const Standard_Real lw,
const TheSurface& surface,
const Standard_Real su,
const Standard_Real sv)
{
IntCurveSurface_IntersectionPoint aPoint;
if (IntCurveSurface_InterUtils::
ComputeAppendPoint<TheCurve, TheCurveTool, TheSurface, TheSurfaceTool>(curve,
lw,
surface,
su,
sv,
aPoint))
{
Append(aPoint);
}
}
//==================================================================================================
void HLRBRep_InterCSurf::AppendSegment(const TheCurve&,
const Standard_Real,
const Standard_Real,
const TheSurface&)
{
// Not implemented
}

View File

@@ -1,73 +0,0 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_InterCSurf.hxx>
#include <gp_Lin.hxx>
#include <HLRBRep_LineTool.hxx>
#include <HLRBRep_SurfaceTool.hxx>
#include <HLRBRep_ThePolygonOfInterCSurf.hxx>
#include <HLRBRep_ThePolygonToolOfInterCSurf.hxx>
#include <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#include <HLRBRep_ThePolyhedronToolOfInterCSurf.hxx>
#include <HLRBRep_TheInterferenceOfInterCSurf.hxx>
#include <HLRBRep_TheCSFunctionOfInterCSurf.hxx>
#include <HLRBRep_TheExactInterCSurf.hxx>
#include <HLRBRep_TheQuadCurvExactInterCSurf.hxx>
#include <HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#include <Bnd_BoundSortBox.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Parab.hxx>
#include <gp_Hypr.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <Bnd_Box.hxx>
#define TheCurve gp_Lin
#define TheCurve_hxx <gp_Lin.hxx>
#define TheCurveTool HLRBRep_LineTool
#define TheCurveTool_hxx <HLRBRep_LineTool.hxx>
#define TheSurface Standard_Address
#define TheSurface_hxx <Standard_Address.hxx>
#define TheSurfaceTool HLRBRep_SurfaceTool
#define TheSurfaceTool_hxx <HLRBRep_SurfaceTool.hxx>
#define IntCurveSurface_ThePolygon HLRBRep_ThePolygonOfInterCSurf
#define IntCurveSurface_ThePolygon_hxx <HLRBRep_ThePolygonOfInterCSurf.hxx>
#define IntCurveSurface_ThePolygonTool HLRBRep_ThePolygonToolOfInterCSurf
#define IntCurveSurface_ThePolygonTool_hxx <HLRBRep_ThePolygonToolOfInterCSurf.hxx>
#define IntCurveSurface_ThePolyhedron HLRBRep_ThePolyhedronOfInterCSurf
#define IntCurveSurface_ThePolyhedron_hxx <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#define IntCurveSurface_ThePolyhedronTool HLRBRep_ThePolyhedronToolOfInterCSurf
#define IntCurveSurface_ThePolyhedronTool_hxx <HLRBRep_ThePolyhedronToolOfInterCSurf.hxx>
#define IntCurveSurface_TheInterference HLRBRep_TheInterferenceOfInterCSurf
#define IntCurveSurface_TheInterference_hxx <HLRBRep_TheInterferenceOfInterCSurf.hxx>
#define IntCurveSurface_TheCSFunction HLRBRep_TheCSFunctionOfInterCSurf
#define IntCurveSurface_TheCSFunction_hxx <HLRBRep_TheCSFunctionOfInterCSurf.hxx>
#define IntCurveSurface_TheExactInter HLRBRep_TheExactInterCSurf
#define IntCurveSurface_TheExactInter_hxx <HLRBRep_TheExactInterCSurf.hxx>
#define IntCurveSurface_TheQuadCurvExactInter HLRBRep_TheQuadCurvExactInterCSurf
#define IntCurveSurface_TheQuadCurvExactInter_hxx <HLRBRep_TheQuadCurvExactInterCSurf.hxx>
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter \
HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter_hxx \
<HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter \
HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf
#define IntCurveSurface_TheQuadCurvFuncOfTheQuadCurvExactInter_hxx \
<HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#define IntCurveSurface_Inter HLRBRep_InterCSurf
#define IntCurveSurface_Inter_hxx <HLRBRep_InterCSurf.hxx>
#include <IntCurveSurface_Inter.gxx>

View File

@@ -0,0 +1,137 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_ThePolygonOfInterCSurf.hxx>
#include <Bnd_Box.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
#include <HLRBRep_LineTool.hxx>
#include "../../TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolygonUtils.pxx"
#include <Standard_OutOfRange.hxx>
//==================================================================================================
HLRBRep_ThePolygonOfInterCSurf::HLRBRep_ThePolygonOfInterCSurf(const gp_Lin& Curve,
const Standard_Integer NbPnt)
: ThePnts(1, (NbPnt < 5) ? 5 : NbPnt),
ClosedPolygon(Standard_False)
{
NbPntIn = (NbPnt < 5) ? 5 : NbPnt;
Binf = HLRBRep_LineTool::FirstParameter(Curve);
Bsup = HLRBRep_LineTool::LastParameter(Curve);
Init(Curve);
}
//==================================================================================================
HLRBRep_ThePolygonOfInterCSurf::HLRBRep_ThePolygonOfInterCSurf(const gp_Lin& Curve,
const Standard_Real U1,
const Standard_Real U2,
const Standard_Integer NbPnt)
: ThePnts(1, (NbPnt < 5) ? 5 : NbPnt),
ClosedPolygon(Standard_False),
Binf(U1),
Bsup(U2)
{
NbPntIn = (NbPnt < 5) ? 5 : NbPnt;
Init(Curve);
}
//==================================================================================================
HLRBRep_ThePolygonOfInterCSurf::HLRBRep_ThePolygonOfInterCSurf(const gp_Lin& Curve,
const TColStd_Array1OfReal& Upars)
: ThePnts(1, Upars.Length()),
ClosedPolygon(Standard_False),
Binf(Upars(Upars.Lower())),
Bsup(Upars(Upars.Upper()))
{
NbPntIn = Upars.Length();
Init(Curve, Upars);
}
//==================================================================================================
void HLRBRep_ThePolygonOfInterCSurf::Init(const gp_Lin& Curve)
{
IntCurveSurface_PolygonUtils::InitUniform<gp_Lin, HLRBRep_LineTool>(Curve,
Binf,
Bsup,
NbPntIn,
ThePnts,
TheBnd,
TheDeflection);
ClosedPolygon = Standard_False;
}
//==================================================================================================
void HLRBRep_ThePolygonOfInterCSurf::Init(const gp_Lin& Curve, const TColStd_Array1OfReal& Upars)
{
IntCurveSurface_PolygonUtils::InitWithParams<gp_Lin, HLRBRep_LineTool>(Curve,
Upars,
NbPntIn,
ThePnts,
TheBnd,
TheDeflection,
myParams);
ClosedPolygon = Standard_False;
}
//==================================================================================================
Standard_Real HLRBRep_ThePolygonOfInterCSurf::ApproxParamOnCurve(
const Standard_Integer Index,
const Standard_Real ParamOnLine) const
{
return IntCurveSurface_PolygonUtils::ApproxParamOnCurve(Index,
ParamOnLine,
Binf,
Bsup,
NbPntIn,
myParams);
}
//==================================================================================================
void HLRBRep_ThePolygonOfInterCSurf::Dump() const
{
#if 0
static Standard_Integer Compteur=0;
char tamp[100];
Compteur++;
Sprintf(tamp,"Poly%d",Compteur);
std::cout<<" @@@@@@@@@@@ F i c h i e r : "<<tamp<<" @@@@@@@@@@"<<std::endl;
FILE *fp;
fp=fopen(tamp,"w");
if(fp==NULL) {
std::cout<<"PolyGonGen::Erreur en Ouverture Fichier"<<tamp<<std::endl;
return;
}
fprintf(fp,"\n#Discretisation de : %f ---> %f \n",Binf,Bsup);
fprintf(fp,"\npol %d %d %f",Compteur,NbPntIn,TheDeflection);
gp_Pnt p1,p2;
for (Standard_Integer iObje=1; iObje<=NbSegments(); iObje++) {
p1=BeginOfSeg(iObje);
fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y());
}
p1=EndOfSeg(NbSegments());
fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y());
fprintf(fp,"\ndispol %d\n#\n",Compteur);
fclose(fp);
#endif
}

View File

@@ -1,31 +0,0 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_ThePolygonOfInterCSurf.hxx>
#include <Standard_OutOfRange.hxx>
#include <gp_Lin.hxx>
#include <HLRBRep_LineTool.hxx>
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#define TheCurve gp_Lin
#define TheCurve_hxx <gp_Lin.hxx>
#define TheCurveTool HLRBRep_LineTool
#define TheCurveTool_hxx <HLRBRep_LineTool.hxx>
#define IntCurveSurface_Polygon HLRBRep_ThePolygonOfInterCSurf
#define IntCurveSurface_Polygon_hxx <HLRBRep_ThePolygonOfInterCSurf.hxx>
#include <IntCurveSurface_Polygon.gxx>

View File

@@ -19,14 +19,10 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
class Standard_OutOfRange;
class gp_Pnt;
class HLRBRep_ThePolygonOfInterCSurf;
class Bnd_Box;
#include <Bnd_Box.hxx>
#include <gp_Pnt.hxx>
#include <HLRBRep_ThePolygonOfInterCSurf.hxx>
class HLRBRep_ThePolygonToolOfInterCSurf
{
@@ -34,46 +30,41 @@ public:
DEFINE_STANDARD_ALLOC
//! Give the bounding box of the polygon.
static const Bnd_Box& Bounding(const HLRBRep_ThePolygonOfInterCSurf& thePolygon);
static const Bnd_Box& Bounding(const HLRBRep_ThePolygonOfInterCSurf& thePolygon)
{
return thePolygon.Bounding();
}
static Standard_Real DeflectionOverEstimation(const HLRBRep_ThePolygonOfInterCSurf& thePolygon);
static Standard_Real DeflectionOverEstimation(const HLRBRep_ThePolygonOfInterCSurf& thePolygon)
{
return thePolygon.DeflectionOverEstimation();
}
static Standard_Boolean Closed(const HLRBRep_ThePolygonOfInterCSurf& thePolygon);
static Standard_Boolean Closed(const HLRBRep_ThePolygonOfInterCSurf& thePolygon)
{
return thePolygon.Closed();
}
static Standard_Integer NbSegments(const HLRBRep_ThePolygonOfInterCSurf& thePolygon);
static Standard_Integer NbSegments(const HLRBRep_ThePolygonOfInterCSurf& thePolygon)
{
return thePolygon.NbSegments();
}
//! Give the point of range Index in the Polygon.
static const gp_Pnt& BeginOfSeg(const HLRBRep_ThePolygonOfInterCSurf& thePolygon,
const Standard_Integer Index);
const Standard_Integer Index)
{
return thePolygon.BeginOfSeg(Index);
}
//! Give the point of range Index in the Polygon.
static const gp_Pnt& EndOfSeg(const HLRBRep_ThePolygonOfInterCSurf& thePolygon,
const Standard_Integer Index);
const Standard_Integer Index)
{
return thePolygon.EndOfSeg(Index);
}
Standard_EXPORT static void Dump(const HLRBRep_ThePolygonOfInterCSurf& thePolygon);
protected:
private:
};
#define ThePoint gp_Pnt
#define ThePoint_hxx <gp_Pnt.hxx>
#define ThePolygon HLRBRep_ThePolygonOfInterCSurf
#define ThePolygon_hxx <HLRBRep_ThePolygonOfInterCSurf.hxx>
#define TheBoundingBox Bnd_Box
#define TheBoundingBox_hxx <Bnd_Box.hxx>
#define IntCurveSurface_PolygonTool HLRBRep_ThePolygonToolOfInterCSurf
#define IntCurveSurface_PolygonTool_hxx <HLRBRep_ThePolygonToolOfInterCSurf.hxx>
#include <IntCurveSurface_PolygonTool.lxx>
#undef ThePoint
#undef ThePoint_hxx
#undef ThePolygon
#undef ThePolygon_hxx
#undef TheBoundingBox
#undef TheBoundingBox_hxx
#undef IntCurveSurface_PolygonTool
#undef IntCurveSurface_PolygonTool_hxx
#endif // _HLRBRep_ThePolygonToolOfInterCSurf_HeaderFile

View File

@@ -0,0 +1,781 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#include <Bnd_Array1OfBox.hxx>
#include <Bnd_Box.hxx>
#include <gp.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
#include <HLRBRep_SurfaceTool.hxx>
#include <Standard_OutOfRange.hxx>
#include "../../TKGeomAlgo/IntCurveSurface/IntCurveSurface_PolyhedronUtils.pxx"
#define LONGUEUR_MINI_EDGE_TRIANGLE 1e-15
//==================================================================================================
HLRBRep_ThePolyhedronOfInterCSurf::HLRBRep_ThePolyhedronOfInterCSurf(
const Standard_Address& Surface,
const Standard_Integer nbdU,
const Standard_Integer nbdV,
const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2)
: nbdeltaU((nbdU < 3) ? 3 : nbdU),
nbdeltaV((nbdV < 3) ? 3 : nbdV),
TheDeflection(Epsilon(100.)),
C_MyPnts(NULL),
C_MyU(NULL),
C_MyV(NULL),
C_MyIsOnBounds(NULL)
{
Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
C_MyPnts = new gp_Pnt[t];
C_MyU = new Standard_Real[t];
C_MyV = new Standard_Real[t];
C_MyIsOnBounds = new Standard_Boolean[t];
Init(Surface, u1, v1, u2, v2);
}
//==================================================================================================
HLRBRep_ThePolyhedronOfInterCSurf::HLRBRep_ThePolyhedronOfInterCSurf(
const Standard_Address& Surface,
const TColStd_Array1OfReal& Upars,
const TColStd_Array1OfReal& Vpars)
: nbdeltaU(Upars.Length() - 1),
nbdeltaV(Vpars.Length() - 1),
TheDeflection(Epsilon(100.)),
C_MyPnts(NULL),
C_MyU(NULL),
C_MyV(NULL),
C_MyIsOnBounds(NULL)
{
Standard_Integer t = (nbdeltaU + 1) * (nbdeltaV + 1) + 1;
C_MyPnts = new gp_Pnt[t];
C_MyU = new Standard_Real[t];
C_MyV = new Standard_Real[t];
C_MyIsOnBounds = new Standard_Boolean[t];
Init(Surface, Upars, Vpars);
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Destroy()
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
if (C_MyPnts)
delete[] CMyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
if (C_MyU)
delete[] CMyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
if (C_MyV)
delete[] CMyV;
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
if (C_MyIsOnBounds)
delete[] CMyIsOnBounds;
C_MyPnts = C_MyU = C_MyV = C_MyIsOnBounds = NULL;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Init(const Standard_Address& Surface,
const Standard_Real U0,
const Standard_Real V0,
const Standard_Real U1,
const Standard_Real V1)
{
IntCurveSurface_PolyhedronUtils::InitUniform<Standard_Address, HLRBRep_SurfaceTool>(
Surface,
U0,
V0,
U1,
V1,
nbdeltaU,
nbdeltaV,
(gp_Pnt*)C_MyPnts,
(Standard_Real*)C_MyU,
(Standard_Real*)C_MyV,
(Standard_Boolean*)C_MyIsOnBounds,
TheBnd);
// Calculate triangle deflections
Standard_Real tol = 0.0;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer i1 = 1; i1 <= nbtriangles; i1++)
{
Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
if (tol1 > tol)
tol = tol1;
}
DeflectionOverEstimation(tol * 1.2);
FillBounding();
// Compute border deflection
TheBorderDeflection = RealFirst();
Standard_Real aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Init(const Standard_Address& Surface,
const TColStd_Array1OfReal& Upars,
const TColStd_Array1OfReal& Vpars)
{
IntCurveSurface_PolyhedronUtils::InitWithParams<Standard_Address, HLRBRep_SurfaceTool>(
Surface,
Upars,
Vpars,
nbdeltaU,
nbdeltaV,
(gp_Pnt*)C_MyPnts,
(Standard_Real*)C_MyU,
(Standard_Real*)C_MyV,
(Standard_Boolean*)C_MyIsOnBounds,
TheBnd);
// Calculate triangle deflections
Standard_Real tol = 0.0;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer i1 = 1; i1 <= nbtriangles; i1++)
{
Standard_Real tol1 = DeflectionOnTriangle(Surface, i1);
if (tol1 > tol)
tol = tol1;
}
DeflectionOverEstimation(tol * 1.2);
FillBounding();
// Compute border deflection
TheBorderDeflection = RealFirst();
Standard_Integer i0 = Upars.Lower();
Standard_Integer j0 = Vpars.Lower();
Standard_Real U0 = Upars(i0);
Standard_Real V0 = Vpars(j0);
Standard_Real U1 = Upars(Upars.Upper());
Standard_Real V1 = Vpars(Vpars.Upper());
Standard_Real aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U0, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, U1, V0, V1, Standard_True);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V0, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
aDeflection = ComputeBorderDeflection(Surface, V1, U0, U1, Standard_False);
if (aDeflection > TheBorderDeflection)
TheBorderDeflection = aDeflection;
}
//==================================================================================================
Standard_Real HLRBRep_ThePolyhedronOfInterCSurf::DeflectionOnTriangle(
const Standard_Address& Surface,
const Standard_Integer Triang) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
Standard_Real u1, v1, u2, v2, u3, v3;
gp_Pnt P1 = Point(i1, u1, v1);
gp_Pnt P2 = Point(i2, u2, v2);
gp_Pnt P3 = Point(i3, u3, v3);
return IntCurveSurface_PolyhedronUtils::DeflectionOnTriangle<
Standard_Address,
HLRBRep_SurfaceTool>(Surface, P1, P2, P3, u1, v1, u2, v2, u3, v3);
}
//==================================================================================================
Standard_Real HLRBRep_ThePolyhedronOfInterCSurf::ComputeBorderDeflection(
const Standard_Address& Surface,
const Standard_Real Parameter,
const Standard_Real PMin,
const Standard_Real PMax,
const Standard_Boolean isUIso) const
{
Standard_Integer aNbSamples = isUIso ? nbdeltaV : nbdeltaU;
return IntCurveSurface_PolyhedronUtils::ComputeBorderDeflection<Standard_Address,
HLRBRep_SurfaceTool>(Surface,
Parameter,
PMin,
PMax,
isUIso,
aNbSamples);
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Parameters(const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V) const
{
Standard_Real* CMyU = (Standard_Real*)C_MyU;
U = CMyU[Index];
Standard_Real* CMyV = (Standard_Real*)C_MyV;
V = CMyV[Index];
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::DeflectionOverEstimation(const Standard_Real flec)
{
if (flec < 0.0001)
{
TheDeflection = 0.0001;
TheBnd.Enlarge(0.0001);
}
else
{
TheDeflection = flec;
TheBnd.Enlarge(flec);
}
}
//==================================================================================================
Standard_Real HLRBRep_ThePolyhedronOfInterCSurf::DeflectionOverEstimation() const
{
return TheDeflection;
}
//==================================================================================================
const Bnd_Box& HLRBRep_ThePolyhedronOfInterCSurf::Bounding() const
{
return TheBnd;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::FillBounding()
{
TheComponentsBnd = new Bnd_HArray1OfBox(1, NbTriangles());
Bnd_Box Boite;
Standard_Integer np1, np2, np3;
Standard_Integer nbtriangles = NbTriangles();
for (Standard_Integer iTri = 1; iTri <= nbtriangles; iTri++)
{
Triangle(iTri, np1, np2, np3);
gp_Pnt p1(Point(np1));
gp_Pnt p2(Point(np2));
gp_Pnt p3(Point(np3));
Boite.SetVoid();
if (p1.SquareDistance(p2) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
if (p1.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
if (p2.SquareDistance(p3) > LONGUEUR_MINI_EDGE_TRIANGLE)
{
Boite.Add(p1);
Boite.Add(p2);
Boite.Add(p3);
Boite.Enlarge(TheDeflection);
}
}
}
Boite.Enlarge(TheDeflection);
TheComponentsBnd->SetValue(iTri, Boite);
}
}
//==================================================================================================
const Handle(Bnd_HArray1OfBox)& HLRBRep_ThePolyhedronOfInterCSurf::ComponentsBounding() const
{
return TheComponentsBnd;
}
//==================================================================================================
Standard_Integer HLRBRep_ThePolyhedronOfInterCSurf::NbTriangles() const
{
return nbdeltaU * nbdeltaV * 2;
}
//==================================================================================================
Standard_Integer HLRBRep_ThePolyhedronOfInterCSurf::NbPoints() const
{
return (nbdeltaU + 1) * (nbdeltaV + 1);
}
//==================================================================================================
Standard_Integer HLRBRep_ThePolyhedronOfInterCSurf::TriConnex(const Standard_Integer Triang,
const Standard_Integer Pivot,
const Standard_Integer Pedge,
Standard_Integer& TriCon,
Standard_Integer& OtherP) const
{
Standard_Integer Pivotm1 = Pivot - 1;
Standard_Integer nbdeltaVp1 = nbdeltaV + 1;
Standard_Integer nbdeltaVm2 = nbdeltaV + nbdeltaV;
Standard_Integer ligP = Pivotm1 / nbdeltaVp1;
Standard_Integer colP = Pivotm1 - ligP * nbdeltaVp1;
Standard_Integer ligE = 0, colE = 0, typE = 0;
if (Pedge != 0)
{
ligE = (Pedge - 1) / nbdeltaVp1;
colE = (Pedge - 1) - (ligE * nbdeltaVp1);
if (ligP == ligE)
typE = 1;
else if (colP == colE)
typE = 2;
else
typE = 3;
}
Standard_Integer linT = 0, colT = 0;
Standard_Integer linO = 0, colO = 0;
Standard_Integer t = 0, tt = 0;
if (Triang != 0)
{
t = (Triang - 1) / nbdeltaVm2;
tt = (Triang - 1) - t * nbdeltaVm2;
linT = 1 + t;
colT = 1 + tt;
if (typE == 0)
{
if (ligP == linT)
{
ligE = ligP - 1;
colE = colP - 1;
typE = 3;
}
else
{
if (colT == ligP + ligP)
{
ligE = ligP;
colE = colP - 1;
typE = 1;
}
else
{
ligE = ligP + 1;
colE = colP + 1;
typE = 3;
}
}
}
switch (typE)
{
case 1:
if (linT == ligP)
{
linT++;
linO = ligP + 1;
colO = (colP > colE) ? colP : colE;
}
else
{
linT--;
linO = ligP - 1;
colO = (colP < colE) ? colP : colE;
}
break;
case 2:
if (colT == (colP + colP))
{
colT++;
linO = (ligP > ligE) ? ligP : ligE;
colO = colP + 1;
}
else
{
colT--;
linO = (ligP < ligE) ? ligP : ligE;
colO = colP - 1;
}
break;
case 3:
if ((colT & 1) == 0)
{
colT--;
linO = (ligP > ligE) ? ligP : ligE;
colO = (colP < colE) ? colP : colE;
}
else
{
colT++;
linO = (ligP < ligE) ? ligP : ligE;
colO = (colP > colE) ? colP : colE;
}
break;
}
}
else
{
if (Pedge == 0)
{
linT = (1 > ligP) ? 1 : ligP;
colT = (1 > (colP + colP)) ? 1 : (colP + colP);
if (ligP == 0)
linO = ligP + 1;
else
linO = ligP - 1;
colO = colP;
}
else
{
switch (typE)
{
case 1:
linT = ligP + 1;
colT = (colP > colE) ? colP : colE;
colT += colT;
linO = ligP + 1;
colO = (colP > colE) ? colP : colE;
break;
case 2:
linT = (ligP > ligE) ? ligP : ligE;
colT = colP + colP;
linO = (ligP < ligE) ? ligP : ligE;
colO = colP - 1;
break;
case 3:
linT = (ligP > ligE) ? ligP : ligE;
colT = colP + colE;
linO = (ligP > ligE) ? ligP : ligE;
colO = (colP < colE) ? colP : colE;
break;
}
}
}
TriCon = (linT - 1) * nbdeltaVm2 + colT;
if (linT < 1)
{
linO = 0;
colO = colP + colP - colE;
if (colO < 0)
{
colO = 0;
linO = 1;
}
else if (colO > nbdeltaV)
{
colO = nbdeltaV;
linO = 1;
}
TriCon = 0;
}
else if (linT > nbdeltaU)
{
linO = nbdeltaU;
colO = colP + colP - colE;
if (colO < 0)
{
colO = 0;
linO = nbdeltaU - 1;
}
else if (colO > nbdeltaV)
{
colO = nbdeltaV;
linO = nbdeltaU - 1;
}
TriCon = 0;
}
if (colT < 1)
{
colO = 0;
linO = ligP + ligP - ligE;
if (linO < 0)
{
linO = 0;
colO = 1;
}
else if (linO > nbdeltaU)
{
linO = nbdeltaU;
colO = 1;
}
TriCon = 0;
}
else if (colT > nbdeltaV)
{
colO = nbdeltaV;
linO = ligP + ligP - ligE;
if (linO < 0)
{
linO = 0;
colO = nbdeltaV - 1;
}
else if (linO > nbdeltaU)
{
linO = nbdeltaU;
colO = nbdeltaV - 1;
}
TriCon = 0;
}
OtherP = linO * nbdeltaVp1 + colO + 1;
return TriCon;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::PlaneEquation(const Standard_Integer Triang,
gp_XYZ& NormalVector,
Standard_Real& PolarDistance) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
gp_XYZ v1 = Pointi2 - Pointi1;
gp_XYZ v2 = Pointi3 - Pointi2;
gp_XYZ v3 = Pointi1 - Pointi3;
if (v1.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
if (v2.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
if (v3.SquareModulus() <= LONGUEUR_MINI_EDGE_TRIANGLE)
{
NormalVector.SetCoord(1.0, 0.0, 0.0);
return;
}
NormalVector = (v1 ^ v2) + (v2 ^ v3) + (v3 ^ v1);
Standard_Real aNormLen = NormalVector.Modulus();
if (aNormLen < gp::Resolution())
{
PolarDistance = 0.;
}
else
{
NormalVector.Divide(aNormLen);
PolarDistance = NormalVector * Point(i1).XYZ();
}
}
//==================================================================================================
Standard_Boolean HLRBRep_ThePolyhedronOfInterCSurf::Contain(const Standard_Integer Triang,
const gp_Pnt& ThePnt) const
{
Standard_Integer i1, i2, i3;
Triangle(Triang, i1, i2, i3);
gp_XYZ Pointi1(Point(i1).XYZ());
gp_XYZ Pointi2(Point(i2).XYZ());
gp_XYZ Pointi3(Point(i3).XYZ());
gp_XYZ v1 = (Pointi2 - Pointi1) ^ (ThePnt.XYZ() - Pointi1);
gp_XYZ v2 = (Pointi3 - Pointi2) ^ (ThePnt.XYZ() - Pointi2);
gp_XYZ v3 = (Pointi1 - Pointi3) ^ (ThePnt.XYZ() - Pointi3);
if (v1 * v2 >= 0. && v2 * v3 >= 0. && v3 * v1 >= 0.)
return Standard_True;
else
return Standard_False;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Dump() const {}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Size(Standard_Integer& nbdu, Standard_Integer& nbdv) const
{
nbdu = nbdeltaU;
nbdv = nbdeltaV;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Triangle(const Standard_Integer Index,
Standard_Integer& P1,
Standard_Integer& P2,
Standard_Integer& P3) const
{
Standard_Integer line = 1 + ((Index - 1) / (nbdeltaV * 2));
Standard_Integer colon = 1 + ((Index - 1) % (nbdeltaV * 2));
Standard_Integer colpnt = (colon + 1) / 2;
P1 = (line - 1) * (nbdeltaV + 1) + colpnt;
P2 = line * (nbdeltaV + 1) + colpnt + ((colon - 1) % 2);
P3 = (line - 1 + (colon % 2)) * (nbdeltaV + 1) + colpnt + 1;
}
//==================================================================================================
const gp_Pnt& HLRBRep_ThePolyhedronOfInterCSurf::Point(const Standard_Integer Index,
Standard_Real& U,
Standard_Real& V) const
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
Standard_Real* CMyU = (Standard_Real*)C_MyU;
Standard_Real* CMyV = (Standard_Real*)C_MyV;
U = CMyU[Index];
V = CMyV[Index];
return CMyPnts[Index];
}
//==================================================================================================
const gp_Pnt& HLRBRep_ThePolyhedronOfInterCSurf::Point(const Standard_Integer Index) const
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
return CMyPnts[Index];
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Point(const gp_Pnt&,
const Standard_Integer,
const Standard_Integer,
const Standard_Real,
const Standard_Real)
{
// Should not be called
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::Point(const Standard_Integer Index, gp_Pnt& P) const
{
gp_Pnt* CMyPnts = (gp_Pnt*)C_MyPnts;
P = CMyPnts[Index];
}
//==================================================================================================
Standard_Boolean HLRBRep_ThePolyhedronOfInterCSurf::IsOnBound(const Standard_Integer Index1,
const Standard_Integer Index2) const
{
Standard_Boolean* CMyIsOnBounds = (Standard_Boolean*)C_MyIsOnBounds;
Standard_Integer aDiff = std::abs(Index1 - Index2);
if (aDiff != 1 && aDiff != nbdeltaV + 1)
return Standard_False;
for (Standard_Integer i = 0; i <= nbdeltaU; i++)
{
if ((Index1 == 1 + i * (nbdeltaV + 1)) && (Index2 == Index1 - 1))
return Standard_False;
if ((Index1 == (1 + i) * (nbdeltaV + 1)) && (Index2 == Index1 + 1))
return Standard_False;
}
return (CMyIsOnBounds[Index1] && CMyIsOnBounds[Index2]);
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::UMinSingularity(const Standard_Boolean Sing)
{
UMinSingular = Sing;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::UMaxSingularity(const Standard_Boolean Sing)
{
UMaxSingular = Sing;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::VMinSingularity(const Standard_Boolean Sing)
{
VMinSingular = Sing;
}
//==================================================================================================
void HLRBRep_ThePolyhedronOfInterCSurf::VMaxSingularity(const Standard_Boolean Sing)
{
VMaxSingular = Sing;
}
//==================================================================================================
Standard_Boolean HLRBRep_ThePolyhedronOfInterCSurf::HasUMinSingularity() const
{
return UMinSingular;
}
//==================================================================================================
Standard_Boolean HLRBRep_ThePolyhedronOfInterCSurf::HasUMaxSingularity() const
{
return UMaxSingular;
}
//==================================================================================================
Standard_Boolean HLRBRep_ThePolyhedronOfInterCSurf::HasVMinSingularity() const
{
return VMinSingular;
}
//==================================================================================================
Standard_Boolean HLRBRep_ThePolyhedronOfInterCSurf::HasVMaxSingularity() const
{
return VMaxSingular;
}

View File

@@ -155,7 +155,7 @@ public:
const Standard_Integer Index2) const;
//! This method returns a border deflection.
Standard_Real GetBorderDeflection() const;
Standard_Real GetBorderDeflection() const { return TheBorderDeflection; }
Standard_EXPORT void Dump() const;
@@ -196,20 +196,4 @@ private:
Standard_Address C_MyIsOnBounds;
};
#define ThePSurface Standard_Address
#define ThePSurface_hxx <Standard_Address.hxx>
#define ThePSurfaceTool HLRBRep_SurfaceTool
#define ThePSurfaceTool_hxx <HLRBRep_SurfaceTool.hxx>
#define IntCurveSurface_Polyhedron HLRBRep_ThePolyhedronOfInterCSurf
#define IntCurveSurface_Polyhedron_hxx <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#include <IntCurveSurface_Polyhedron.lxx>
#undef ThePSurface
#undef ThePSurface_hxx
#undef ThePSurfaceTool
#undef ThePSurfaceTool_hxx
#undef IntCurveSurface_Polyhedron
#undef IntCurveSurface_Polyhedron_hxx
#endif // _HLRBRep_ThePolyhedronOfInterCSurf_HeaderFile

View File

@@ -1,31 +0,0 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#include <Standard_OutOfRange.hxx>
#include <HLRBRep_SurfaceTool.hxx>
#include <gp_Pnt.hxx>
#include <Bnd_Box.hxx>
#include <gp_XYZ.hxx>
#define ThePSurface Standard_Address
#define ThePSurface_hxx <Standard_Address.hxx>
#define ThePSurfaceTool HLRBRep_SurfaceTool
#define ThePSurfaceTool_hxx <HLRBRep_SurfaceTool.hxx>
#define IntCurveSurface_Polyhedron HLRBRep_ThePolyhedronOfInterCSurf
#define IntCurveSurface_Polyhedron_hxx <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#include <IntCurveSurface_Polyhedron.gxx>

View File

@@ -21,14 +21,10 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_HArray1OfBox.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
class Standard_OutOfRange;
class HLRBRep_ThePolyhedronOfInterCSurf;
class Bnd_Box;
class gp_Pnt;
#include <gp_Pnt.hxx>
#include <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
class HLRBRep_ThePolyhedronToolOfInterCSurf
{
@@ -36,18 +32,30 @@ public:
DEFINE_STANDARD_ALLOC
//! Give the bounding box of the PolyhedronTool.
static const Bnd_Box& Bounding(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh);
static const Bnd_Box& Bounding(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh)
{
return thePolyh.Bounding();
}
//! Give the array of boxes. The box <n> corresponding
//! to the triangle <n>.
static const Handle(Bnd_HArray1OfBox)& ComponentsBounding(
const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh);
const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh)
{
return thePolyh.ComponentsBounding();
}
//! Give the tolerance of the polygon.
static Standard_Real DeflectionOverEstimation(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh);
static Standard_Real DeflectionOverEstimation(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh)
{
return thePolyh.DeflectionOverEstimation();
}
//! Give the number of triangles in this polyhedral surface.
static Standard_Integer NbTriangles(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh);
static Standard_Integer NbTriangles(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh)
{
return thePolyh.NbTriangles();
}
//! Give the indices of the 3 points of the triangle of
//! address Index in the PolyhedronTool.
@@ -55,11 +63,17 @@ public:
const Standard_Integer Index,
Standard_Integer& P1,
Standard_Integer& P2,
Standard_Integer& P3);
Standard_Integer& P3)
{
thePolyh.Triangle(Index, P1, P2, P3);
}
//! Give the point of index i in the polyhedral surface.
static const gp_Pnt& Point(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh,
const Standard_Integer Index);
const Standard_Integer Index)
{
return thePolyh.Point(Index);
}
//! Give the address Tricon of the triangle connexe to
//! the triangle of address Triang by the edge Pivot Pedge
@@ -72,31 +86,28 @@ public:
const Standard_Integer Pivot,
const Standard_Integer Pedge,
Standard_Integer& TriCon,
Standard_Integer& OtherP);
Standard_Integer& OtherP)
{
return thePolyh.TriConnex(Triang, Pivot, Pedge, TriCon, OtherP);
}
//! This method returns true if the edge based on points with
//! indices Index1 and Index2 represents a boundary edge.
//! It is necessary to take into account the boundary deflection for this edge.
static Standard_Boolean IsOnBound(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh,
const Standard_Integer Index1,
const Standard_Integer Index2);
const Standard_Integer Index2)
{
return thePolyh.IsOnBound(Index1, Index2);
}
//! This method returns a border deflection of the polyhedron.
static Standard_Real GetBorderDeflection(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh);
static Standard_Real GetBorderDeflection(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh)
{
return thePolyh.GetBorderDeflection();
}
Standard_EXPORT static void Dump(const HLRBRep_ThePolyhedronOfInterCSurf& thePolyh);
};
#define ThePolyhedron HLRBRep_ThePolyhedronOfInterCSurf
#define ThePolyhedron_hxx <HLRBRep_ThePolyhedronOfInterCSurf.hxx>
#define IntCurveSurface_PolyhedronTool HLRBRep_ThePolyhedronToolOfInterCSurf
#define IntCurveSurface_PolyhedronTool_hxx <HLRBRep_ThePolyhedronToolOfInterCSurf.hxx>
#include <IntCurveSurface_PolyhedronTool.lxx>
#undef ThePolyhedron
#undef ThePolyhedron_hxx
#undef IntCurveSurface_PolyhedronTool
#undef IntCurveSurface_PolyhedronTool_hxx
#endif // _HLRBRep_ThePolyhedronToolOfInterCSurf_HeaderFile

View File

@@ -0,0 +1,78 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_TheQuadCurvExactInterCSurf.hxx>
#include <gp_Lin.hxx>
#include <HLRBRep_LineTool.hxx>
#include <HLRBRep_SurfaceTool.hxx>
#include <HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#include "../../TKGeomAlgo/IntCurveSurface/IntCurveSurface_QuadricCurveExactInterUtils.pxx"
//==================================================================================================
HLRBRep_TheQuadCurvExactInterCSurf::HLRBRep_TheQuadCurvExactInterCSurf(const Standard_Address& S,
const gp_Lin& C)
: nbpnts(-1),
nbintv(-1)
{
IntCurveSurface_QuadricCurveExactInterUtils::PerformIntersection<
Standard_Address,
HLRBRep_SurfaceTool,
gp_Lin,
HLRBRep_LineTool,
HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf>(S, C, pnts, intv, nbpnts, nbintv);
}
//==================================================================================================
Standard_Boolean HLRBRep_TheQuadCurvExactInterCSurf::IsDone() const
{
return (nbpnts != -1);
}
//==================================================================================================
Standard_Integer HLRBRep_TheQuadCurvExactInterCSurf::NbRoots() const
{
return nbpnts;
}
//==================================================================================================
Standard_Integer HLRBRep_TheQuadCurvExactInterCSurf::NbIntervals() const
{
return nbintv;
}
//==================================================================================================
Standard_Real HLRBRep_TheQuadCurvExactInterCSurf::Root(const Standard_Integer Index) const
{
return pnts(Index);
}
//==================================================================================================
void HLRBRep_TheQuadCurvExactInterCSurf::Intervals(const Standard_Integer Index,
Standard_Real& a,
Standard_Real& b) const
{
Standard_Integer Index2 = Index + Index - 1;
a = intv(Index2);
b = intv(Index2 + 1);
}

View File

@@ -1,37 +0,0 @@
// Created on: 1992-10-14
// Created by: Christophe MARION
// Copyright (c) 1992-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 <HLRBRep_TheQuadCurvExactInterCSurf.hxx>
#include <HLRBRep_SurfaceTool.hxx>
#include <gp_Lin.hxx>
#include <HLRBRep_LineTool.hxx>
#include <HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#define TheSurface Standard_Address
#define TheSurface_hxx <Standard_Address.hxx>
#define TheSurfaceTool HLRBRep_SurfaceTool
#define TheSurfaceTool_hxx <HLRBRep_SurfaceTool.hxx>
#define TheCurve gp_Lin
#define TheCurve_hxx <gp_Lin.hxx>
#define TheCurveTool HLRBRep_LineTool
#define TheCurveTool_hxx <HLRBRep_LineTool.hxx>
#define IntCurveSurface_TheQuadCurvFunc HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf
#define IntCurveSurface_TheQuadCurvFunc_hxx \
<HLRBRep_TheQuadCurvFuncOfTheQuadCurvExactInterCSurf.hxx>
#define IntCurveSurface_QuadricCurveExactInter HLRBRep_TheQuadCurvExactInterCSurf
#define IntCurveSurface_QuadricCurveExactInter_hxx <HLRBRep_TheQuadCurvExactInterCSurf.hxx>
#include <IntCurveSurface_QuadricCurveExactInter.gxx>