1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

...

20 Commits

Author SHA1 Message Date
dpasukhi
7eaedf4374 0033808: Coding - FreeType Use unsigned point and contour indexing in FT_Outline
Changes to auto instead of specific type
2025-04-30 15:13:50 +01:00
astromko
9c84b526cd 0032964: Modeling Algorithms - 2d Offset sometimes 'split' straight edges
Implemented avoiding force cut of an edge in case of simple edge (that contains just 1 curve).
2024-11-08 10:52:32 +00:00
astromko
17d27a772d 0033648: Modeling Algorithms - Bad partition result
Removed unnecessary tolerance increase for Line\Line intersection.
Tolerance increasing logic for some specific curve types
  was added with #26619.
Original fix had no test for Line/Line case and
  theoretically was added as a possible issue.
After research Line/Line case doesn't need a special tolerance case.
2024-09-04 15:58:18 +01:00
jfa
1827edbc9a A fix by mzernova for OCCT bugs 33664 and 33755 (Salome issues 42465 and 42518 2024-08-01 11:50:57 +01:00
jfa
5b07844437 [bos #42181] Fatal error in Fuse selection NCollection_DataMap::Find 2024-06-14 13:32:10 +01:00
jfa
194470979b [bug #33591] Modeling Algorithms - Regression: old surface is not removed after translation or rotation with geometry copying 2024-06-04 14:37:16 +01:00
jfa
3c11628f2c Return to BREP format version 1 for shapes export 2024-06-03 15:20:56 +01:00
akaftasev
a37b4a1a21 0033615: Modeling Algorithms - Partition algorithm creates unexpected vertices
This problem occurs because of obtaining 2 ALines which share same vertex on the seam edge.
There should be 2 different vertices with same(or almost the same) 3d parameters, but
with different UV parameters because of periodic surface.
Current fix allows to avoid the same vertices on seam edge and also checks the next vertex.
2024-05-14 15:04:40 +01:00
jfa
3ef40fb0e8 Set servicepack version to 1 2024-04-19 11:44:05 +01:00
astromko
f274e56f03 0033394: Modeling Algorithms - Wrong usage of BRepClass_FaceClassifier with 3d tolerance
Fixed a found error from CR3394 branch.
2024-04-18 18:34:54 +01:00
astromko
99509f37f8 0033394: Modeling Algorithms - Wrong usage of BRepClass_FaceClassifier with 3d tolerance
Added the function Tolerance2d().
Now 2d-tolerance is used instead of 3d-tolerance where it's necessary.
2024-04-18 18:34:34 +01:00
astromko
bb43d0cc19 0033591: Modeling Algorithms - Regression: old surface is not removed after translation or rotation with geometry copying
In order to avoid the problem we should always perform the commands in the "if (IsNewCur)" block after NewCurve() function even if NewCurve() returns a null-curve.
Added additional condition for this purpose..
2024-04-18 18:23:21 +01:00
astromko
1e5dd88f50 0033367: Modeling Algorithms - Normal projection or BOP problem [Regression]
Fixed passing of an incorrect curve into GeomAdaptor::MakeCurve() function.
2024-03-25 13:54:59 +00:00
dpasukhi
55a0d816cd 0033555: Foundation Classes - DEBUG macro leads to compile error
Removed incorrect parameter call when DEBUG macro is active
2024-03-19 16:50:00 +00:00
jfa
909976ae2e 0033433: Shape Healing - Implement a new mode to keep initial types of curves. With all additional fixes from CR753-SALOME-PATCH. 2024-03-19 16:45:10 +00:00
jfa
2fd591b3bb Fixed Salome compilation problem on Windows by M.Bernhard 2024-02-09 12:29:15 +00:00
jfa
c84a97e12f SALOME_37951_SIGSEGV_MakeVertexInsideFace Fixed exceptions with loading null curve and using out of range index. By K.Leontev. 2024-01-04 18:24:47 +00:00
jfa
2261172c3b Do not rebuild wire if there are no necessary changes 2024-01-04 18:24:33 +00:00
jfa
d1c95bea02 OCCT integration request 33328 2024-01-04 18:24:24 +00:00
jfa
353bd8f46d Now proximity depends on the shapes order 2024-01-04 18:11:39 +00:00
51 changed files with 778 additions and 154 deletions

View File

@@ -26,7 +26,7 @@ endif()
if (MSVC)
# suppress C26812 on VS2019/C++20 (prefer 'enum class' over 'enum')
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise /wd\"26812\"")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise /wd26812")
# suppress warning on using portable non-secure functions in favor of non-portable secure ones
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
else()

View File

@@ -72,8 +72,11 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
const Standard_Boolean wasSelected = theOwner->IsSelected();
const Standard_Boolean toSelect = theOwner->Select (theSelScheme, isDetected);
if (toSelect && !wasSelected)
if (!wasSelected || !myResultMap.IsBound(theOwner))
{
if (!toSelect)
return AIS_SS_NotDone;
AIS_NListOfEntityOwner::Iterator aListIter;
myresult.Append (theOwner, aListIter);
myResultMap.Bind (theOwner, aListIter);
@@ -81,11 +84,6 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
return AIS_SS_Added;
}
if (!toSelect && !wasSelected)
{
return AIS_SS_NotDone;
}
AIS_NListOfEntityOwner::Iterator aListIter = myResultMap.Find (theOwner);
if (myIterator == aListIter)
{

View File

@@ -341,12 +341,8 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
GeomAbs_CurveType aType1 = aBAC1.GetType();
GeomAbs_CurveType aType2 = aBAC2.GetType();
//
bAnalytical = (((aType1 == GeomAbs_Line) &&
(aType2 == GeomAbs_Line ||
aType2 == GeomAbs_Circle)) ||
((aType2 == GeomAbs_Line) &&
(aType1 == GeomAbs_Line ||
aType1 == GeomAbs_Circle)));
bAnalytical = (aType1 == GeomAbs_Line && aType2 == GeomAbs_Circle) ||
(aType1 == GeomAbs_Circle && aType2 == GeomAbs_Line);
}
//
for (i=1; i<=aNbCPrts; ++i) {
@@ -443,7 +439,7 @@ void BOPAlgo_PaveFiller::PerformEE(const Message_ProgressRange& theRange)
Standard_Real aTolVnew = BRep_Tool::Tolerance(aVnew);
if (bAnalytical) {
// increase tolerance for Line/Line intersection, but do not update
// increase tolerance for Line/Circle intersection, but do not update
// the vertex till its intersection with some other shape
Standard_Real aTolMin = (BRepAdaptor_Curve(aE1).GetType() == GeomAbs_Line) ?
(aCR1.Last() - aCR1.First()) / 2. : (aCR2.Last() - aCR2.First()) / 2.;

View File

@@ -19,6 +19,7 @@
#include <BRep_CurveOnClosedSurface.hxx>
#include <BRep_CurveOnSurface.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_Polygon3D.hxx>
#include <BRep_PolygonOnSurface.hxx>
#include <BRep_PolygonOnTriangulation.hxx>
@@ -26,6 +27,7 @@
#include <BRep_TFace.hxx>
#include <BRep_Tool.hxx>
#include <BRep_TVertex.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <ElSLib.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
@@ -61,7 +63,6 @@
#include <TopoDS_Vertex.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <BRep_GCurve.hxx>
//modified by NIZNHY-PKV Fri Oct 17 14:13:29 2008f
static
@@ -1672,3 +1673,13 @@ Standard_Real BRep_Tool::MaxTolerance (const TopoDS_Shape& theShape,
return aTol;
}
//=======================================================================
//function : Tolerance2d
//purpose :
//=======================================================================
Standard_Real BRep_Tool::Tolerance2d(const TopoDS_Face& theFace, const Standard_Real theTolerance)
{
BRepAdaptor_Surface aAdaptorSurface(theFace);
return Max(aAdaptorSurface.UResolution(theTolerance), aAdaptorSurface.VResolution(theTolerance));
}

View File

@@ -297,6 +297,11 @@ public:
//@param theSubShape - Search subshape, only Face, Edge or Vertex are supported.
Standard_EXPORT static Standard_Real MaxTolerance (const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theSubShape);
//! Returns the 2d tolerance.
//@param theFace - the input face to find 2d tolerance
//@param theTolerance - the input tolerance to calculate 2d tolerance.
Standard_EXPORT static Standard_Real Tolerance2d(const TopoDS_Face& theFace, const Standard_Real theTolerance);
};
#endif // _BRep_Tool_HeaderFile

View File

@@ -76,7 +76,10 @@ void BRepAdaptor_Curve2d::Initialize(const TopoDS_Edge& E,
myFace = F;
Standard_Real pf,pl;
const Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(E,F,pf,pl);
Geom2dAdaptor_Curve::Load(PC,pf,pl);
if (PC)
{
Geom2dAdaptor_Curve::Load(PC,pf,pl);
}
}
//=======================================================================

View File

@@ -333,7 +333,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams()
Only2d = Standard_True;
if(Only2d && Only3d) {
BRepLib_MakeEdge MKed(GeomAdaptor::MakeCurve(hcur->Curve()),
BRepLib_MakeEdge MKed(GeomAdaptor::MakeCurve(*hcur),
Udeb, Ufin);
prj = MKed.Edge();
BB.UpdateEdge(TopoDS::Edge(prj),
@@ -369,7 +369,7 @@ void BRepAlgo_NormalProjection::SetDefaultParams()
if(!Only3d) PCur2d = appr.Curve2d();
if(Only2d) {
BRepLib_MakeEdge MKed(GeomAdaptor::MakeCurve(hcur->Curve()),
BRepLib_MakeEdge MKed(GeomAdaptor::MakeCurve(*hcur),
Udeb, Ufin);
prj = MKed.Edge();
}

View File

@@ -492,10 +492,9 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
#ifdef OCCT_DEBUG
if (BRepCheck_Trace(0) > 1) {
TopTools_DataMapIteratorOfDataMapOfShapeInteger itt(MapOfShapeOrientation);
Standard_Integer upper = MapOfShapeOrientation.NbBuckets();
std::cout << "La map shape Orientation :" << std::endl;
for (; itt.More(); itt.Next()) {
PrintShape(itt.Key(), upper);
PrintShape(itt.Key());
}
std::cout << std::endl;
}
@@ -716,7 +715,7 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
if (BRepCheck_Trace(0) > 3)
{
std::cout << "Fref : " ;
PrintShape(Fref, MapOfShapeOrientation.NbBuckets());
PrintShape(Fref);
}
#endif
@@ -766,7 +765,7 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
if (BRepCheck_Trace(0) > 3)
{
std::cout << " Fcur : " ;
PrintShape(Fcur, MapOfShapeOrientation.NbBuckets());
PrintShape(Fcur);
}
#endif
for (edFcur.Init(Fcur, TopAbs_EDGE); edFcur.More(); edFcur.Next())
@@ -794,7 +793,7 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
Fcur.Orientation(orf);
std::cout << " Error : this face has been already examined " << std::endl;
std::cout << " Impossible to return it ";
PrintShape(Fcur, MapOfShapeOrientation.NbBuckets());
PrintShape(Fcur);
}
#endif
return myOstat;
@@ -809,7 +808,7 @@ BRepCheck_Status BRepCheck_Shell::Orientation(const Standard_Boolean Update)
orf = (TopAbs_Orientation)MapOfShapeOrientation.Find(Fcur);
Fcur.Orientation(orf);
std::cout << " Resulting Fcur is returned : " ;
PrintShape(Fcur, MapOfShapeOrientation.NbBuckets());
PrintShape(Fcur);
}
#endif

View File

@@ -441,7 +441,6 @@ static void PERFORM_C0(const TopoDS_Edge& S1, const TopoDS_Edge& S2,
gp_Pnt P1, Pt;
Standard_Integer i, ii;
BRepClass_FaceClassifier classifier;
for (i = 1; i <= arrInter.Length(); i++)
{
const Standard_Real aParameter = arrInter(i);
@@ -772,7 +771,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Vertex& theS1,
Standard_Real U, V;
gp_Pnt Pt, P1 = BRep_Tool::Pnt(theS1);
BRepClass_FaceClassifier classifier;
const Standard_Real tol = BRep_Tool::Tolerance(theS2);
const Standard_Real tol2d = BRep_Tool::Tolerance2d(theS2, BRep_Tool::Tolerance(theS2));
for (i = 1; i <= NbExtrema; i++)
{
@@ -784,7 +783,7 @@ void BRepExtrema_DistanceSS::Perform(const TopoDS_Vertex& theS1,
// Check if the parameter does not correspond to a vertex
Ext.Parameter(i, U, V);
const gp_Pnt2d PUV(U, V);
classifier.Perform(theS2, PUV, tol);
classifier.Perform(theS2, PUV, tol2d);
if (classifier.State() == TopAbs_IN)
{
if (myDstRef > Dstmin)
@@ -922,7 +921,7 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Edge& theS1, const TopoDS_Fac
if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps))
{
Standard_Real U, V;
const Standard_Real tol = BRep_Tool::Tolerance(theS2);
const Standard_Real tol2d = BRep_Tool::Tolerance2d(theS2, BRep_Tool::Tolerance(theS2));
gp_Pnt Pt1, Pt2;
const Standard_Real epsP = Precision::PConfusion();
@@ -941,7 +940,7 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Edge& theS1, const TopoDS_Fac
{
Ext.ParameterOnFace(i, U, V);
const gp_Pnt2d PUV(U, V);
classifier.Perform(theS2, PUV, tol);
classifier.Perform(theS2, PUV, tol2d);
if (classifier.State() == TopAbs_IN)
{
if (myDstRef > Dstmin)
@@ -974,7 +973,7 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Edge& theS1, const TopoDS_Fac
gp_Pnt Pt;
Standard_Real U, V;
const Standard_Real tol = BRep_Tool::Tolerance(theS2);
const Standard_Real tol2d = BRep_Tool::Tolerance2d(theS2, BRep_Tool::Tolerance(theS2));
Standard_Integer i;
for (i = 1; i <= arrInter.Length(); i++)
@@ -1007,7 +1006,7 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Edge& theS1, const TopoDS_Fac
// Check if the parameter does not correspond to a vertex
ExtPF.Parameter(ii, U, V);
const gp_Pnt2d PUV(U, V);
classifier.Perform(theS2, PUV, tol);
classifier.Perform(theS2, PUV, tol2d);
if (classifier.State() == TopAbs_IN)
{
if (myDstRef > Dstmin)
@@ -1062,8 +1061,8 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Face& theS1,
Dstmin = sqrt(Dstmin);
if ((Dstmin < myDstRef - myEps) || (fabs(Dstmin - myDstRef) < myEps))
{
const Standard_Real tol1 = BRep_Tool::Tolerance(theS1);
const Standard_Real tol2 = BRep_Tool::Tolerance(theS2);
const Standard_Real tol2d1 = BRep_Tool::Tolerance2d(theS1, BRep_Tool::Tolerance(theS1));
const Standard_Real tol2d2 = BRep_Tool::Tolerance2d(theS2, BRep_Tool::Tolerance(theS2));
gp_Pnt Pt1, Pt2;
gp_Pnt2d PUV;
@@ -1081,12 +1080,12 @@ void BRepExtrema_DistanceSS::Perform (const TopoDS_Face& theS1,
// Check if the parameter does not correspond to a vertex
Ext.ParameterOnFace1(i, U1, V1);
PUV.SetCoord(U1, V1);
classifier.Perform(theS1, PUV, tol1);
classifier.Perform(theS1, PUV, tol2d1);
if (classifier.State() == TopAbs_IN)
{
Ext.ParameterOnFace2(i, U2, V2);
PUV.SetCoord(U2, V2);
classifier.Perform(theS2, PUV, tol2);
classifier.Perform(theS2, PUV, tol2d2);
if (classifier.State() == TopAbs_IN)
{
if (myDstRef > Dstmin)

View File

@@ -89,7 +89,7 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
{
// Exploration of points and classification
BRepClass_FaceClassifier classifier;
const Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
const Standard_Real Tol2d2 = BRep_Tool::Tolerance2d(F2, BRep_Tool::Tolerance(F2));
Extrema_POnSurf P1, P2;
Standard_Integer i;
@@ -98,13 +98,14 @@ void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
myExtSS.Points(i, P1, P2);
P1.Parameter(U1, U2);
const gp_Pnt2d Puv1(U1, U2);
classifier.Perform(F1, Puv1, Tol1);
const Standard_Real Tol2d1 = BRep_Tool::Tolerance2d(F1, Tol1);
classifier.Perform(F1, Puv1, Tol2d1);
const TopAbs_State state1 = classifier.State();
if (state1 == TopAbs_ON || state1 == TopAbs_IN)
{
P2.Parameter(U1, U2);
const gp_Pnt2d Puv2(U1, U2);
classifier.Perform(F2, Puv2, Tol2);
classifier.Perform(F2, Puv2, Tol2d2);
const TopAbs_State state2 = classifier.State();
if (state2 == TopAbs_ON || state2 == TopAbs_IN)
{

View File

@@ -85,12 +85,12 @@ void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Fac
{
BRepClass_FaceClassifier classifier;
Standard_Real U1, U2;
const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
const Standard_Real Tol2d = BRep_Tool::Tolerance2d(TheFace, BRep_Tool::Tolerance(TheFace));
for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++)
{
myExtPS.Point(i).Parameter(U1, U2);
const gp_Pnt2d Puv(U1, U2);
classifier.Perform(TheFace, Puv, Tol);
classifier.Perform(TheFace, Puv, Tol2d);
const TopAbs_State state = classifier.State();
if(state == TopAbs_ON || state == TopAbs_IN)
{

View File

@@ -512,7 +512,7 @@ void BRepExtrema_ProximityValueTool::Perform (Standard_Real& theTolerance)
if (!myIsInitS1 || !myIsInitS2 || (myShapeType1 != myShapeType2))
return;
//get vertices on shapes with refining a coarser mesh if it's needed
// get vertices on shapes with refining a coarser mesh if it's needed
if (!getShapesAdditionalVertices())
return;
@@ -530,37 +530,11 @@ void BRepExtrema_ProximityValueTool::Perform (Standard_Real& theTolerance)
if (aProximityDist1 < 0.)
return;
// max(min) dist from the 2nd shape to t he 1st one
BVH_Vec3d aP2_1, aP2_2;
ProxPnt_Status aPointStatus2_1 = ProxPnt_Status::ProxPnt_Status_UNKNOWN;
ProxPnt_Status aPointStatus2_2 = ProxPnt_Status::ProxPnt_Status_UNKNOWN;
Standard_Real aProximityDist2 = computeProximityDist (mySet2, myNbSamples2, myAddVertices2, myAddStatus2,
mySet1,
myShapeList2, myShapeList1,
aP2_2, aP2_1,
aPointStatus2_2, aPointStatus2_1);
if (aProximityDist2 < 0.)
return;
// min dist of the two max(min) dists
if (aProximityDist1 < aProximityDist2)
{
myDistance = aProximityDist1;
myPnt1.SetCoord(aP1_1.x(), aP1_1.y(), aP1_1.z());
myPnt2.SetCoord(aP1_2.x(), aP1_2.y(), aP1_2.z());
myPntStatus1 = aPointStatus1_1;
myPntStatus2 = aPointStatus1_2;
}
else
{
myDistance = aProximityDist2;
myPnt1.SetCoord(aP2_1.x(), aP2_1.y(), aP2_1.z());
myPnt2.SetCoord(aP2_2.x(), aP2_2.y(), aP2_2.z());
myPntStatus1 = aPointStatus2_1;
myPntStatus2 = aPointStatus2_2;
}
myDistance = aProximityDist1;
myPnt1.SetCoord(aP1_1.x(), aP1_1.y(), aP1_1.z());
myPnt2.SetCoord(aP1_2.x(), aP1_2.y(), aP1_2.z());
myPntStatus1 = aPointStatus1_1;
myPntStatus2 = aPointStatus1_2;
myIsDone = Standard_True;
theTolerance = myDistance;

View File

@@ -1198,7 +1198,9 @@ void BRepFill_OffsetWire::PrepareSpine()
// Cut
TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
// Modified by Sergey KHROMOV - Thu Nov 16 17:29:29 2000 Begin
if (nbEdges == 2 && nbResEdges == 0)
Handle(BRep_TEdge) TEdge = Handle(BRep_TEdge)::DownCast(E.TShape());
const Standard_Integer aNumCurvesInEdge = TEdge->Curves().Size();
if (nbEdges == 2 && nbResEdges == 0 && aNumCurvesInEdge > 1)
ForcedCut = 1;
// Modified by Sergey KHROMOV - Thu Nov 16 17:29:33 2000 End
nbResEdges = CutEdge (TopoDS::Edge(aLocalShape), mySpine, ForcedCut, Cuts);

View File

@@ -273,18 +273,26 @@ BRepLib_MakeFace::BRepLib_MakeFace(const TopoDS_Wire& W,
aB.MakeWire (aW);
TopoDS_Wire aWForw = W;
Standard_Boolean hasDegenerated = Standard_False;
aWForw.Orientation (TopAbs_FORWARD);
TopoDS_Iterator anIter (aWForw);
for (; anIter.More(); anIter.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge (anIter.Value());
if (!BRep_Tool::Degenerated (aE))
if (BRep_Tool::Degenerated (aE))
hasDegenerated = Standard_True;
else
aB.Add (aW, aE);
}
aW.Orientation (W.Orientation()); // return to original orient
aW.Closed (W.Closed());
if (hasDegenerated) {
aW.Orientation (W.Orientation()); // return to original orient
aW.Closed (W.Closed());
}
else {
aW = W;
}
}
else
{

View File

@@ -42,9 +42,12 @@
#include <Geom2d_Circle.hxx>
#include <Geom2dAPI_Interpolate.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Message.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
#include <ShapeFix_Wire.hxx>
#include <ShapeFix_Edge.hxx>
#include <DBRep.hxx>
#include <DBRep_DrawableShape.hxx>
@@ -271,6 +274,149 @@ static Standard_Integer wire(Draw_Interpretor& di, Standard_Integer n, const cha
return 0;
}
//=======================================================================
// strongwire
//=======================================================================
static Standard_Integer strongwire(Draw_Interpretor&, Standard_Integer theArgC, const char** theArgV)
{
enum StrongWireMode {
StrongWireMode_FixTolerance = 1,
StrongWireMode_Approximation = 2,
StrongWireMode_KeepCurveType = 3
};
BRep_Builder aB;
TopoDS_Wire aWire;
aB.MakeWire(aWire);
if (theArgC < 3)
return 1;
// Tolerance
double aTolerance = Precision::Confusion();
// mode
StrongWireMode aMode = StrongWireMode_KeepCurveType;
// add edges
for (Standard_Integer anArgIter = 2; anArgIter < theArgC; anArgIter++)
{
TCollection_AsciiString aParam(theArgV[anArgIter]);
if (aParam == "-t")
{
anArgIter++;
if (anArgIter < theArgC)
aTolerance = Draw::Atof(theArgV[anArgIter]);
}
else if (aParam == "-m")
{
anArgIter++;
if (anArgIter < theArgC)
{
if (aParam == "keepType" || Draw::Atoi(theArgV[anArgIter]) == 1)
{
aMode = StrongWireMode_KeepCurveType;
continue;
}
else if (aParam == "approx" || Draw::Atoi(theArgV[anArgIter]) == 2)
{
aMode = StrongWireMode_Approximation;
continue;
}
else if (aParam == "fixTol" || Draw::Atoi(theArgV[anArgIter]) == 3)
{
aMode = StrongWireMode_FixTolerance;
continue;
}
}
}
else
{
TopoDS_Shape aShape = DBRep::Get(theArgV[anArgIter]);
if (aShape.IsNull())
Standard_NullObject::Raise("Shape for wire construction is null");
if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE)
{
TopExp_Explorer anExp(aShape, TopAbs_EDGE);
for (; anExp.More(); anExp.Next())
aB.Add(aWire, TopoDS::Edge(anExp.Current()));
}
else
Standard_TypeMismatch::Raise("Shape for wire construction is neither an edge nor a wire");
}
}
// fix edges order
Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire;
aFW->Load(aWire);
aFW->FixReorder();
if (aFW->StatusReorder(ShapeExtend_FAIL1))
{
Message::SendFail() << "Error: Wire construction failed: several loops detected";
return 1;
}
else if (aFW->StatusReorder(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed";
return 1;
}
bool isClosed = false;
Handle(ShapeAnalysis_Wire) aSaw = aFW->Analyzer();
if (aSaw->CheckGap3d(1)) // between last and first edges
{
Standard_Real aDist = aSaw->MinDistance3d();
if (aDist < aTolerance)
isClosed = true;
}
aFW->ClosedWireMode() = isClosed;
aFW->FixConnected(aTolerance);
if (aFW->StatusConnected(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed: cannot build connected wire";
return 1;
}
if (aMode == StrongWireMode_KeepCurveType)
{
aFW->FixCurves();
if (aFW->StatusCurves(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed: cannot rebuild curves through new points";
return 1;
}
}
else if (aFW->StatusConnected(ShapeExtend_DONE3))
{
if (aMode != StrongWireMode_Approximation)
aFW->SetPrecision(aTolerance);
aFW->FixGapsByRangesMode() = Standard_True;
if (aFW->FixGaps3d())
{
Handle(ShapeExtend_WireData) sbwd = aFW->WireData();
Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge;
for (Standard_Integer anIdx = 1; anIdx <= sbwd->NbEdges(); anIdx++)
{
TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(anIdx));
aFe->FixVertexTolerance(aEdge);
aFe->FixSameParameter(aEdge);
}
}
else if (aFW->StatusGaps3d(ShapeExtend_FAIL))
{
Message::SendFail() << "Wire construction failed: cannot fix 3d gaps";
return 1;
}
}
aWire = aFW->WireAPIMake();
DBRep::Set(theArgV[1], aWire);
return 0;
}
//=======================================================================
// mkedge
//=======================================================================
@@ -1997,6 +2143,10 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands)
"wire wirename [-unsorted] e1/w1 [e2/w2 ...]",__FILE__,
wire,g);
theCommands.Add("strongwire",
"strongwire wirename e1/w1 [e2/w2 ...] [-t tol] [-m mode(keepType/1 | approx/2 | fixTol/3)]", __FILE__,
strongwire, g);
theCommands.Add("profile",
"profile, no args to get help",__FILE__,
profile,g);

View File

@@ -263,7 +263,7 @@ public:
const Message_ProgressRange& theProgress = Message_ProgressRange())
{
Write (theShape, theStream, Standard_True, Standard_False,
TopTools_FormatVersion_CURRENT, theProgress);
TopTools_FormatVersion_VERSION_1, theProgress);
}
//! Writes the shape to the stream in an ASCII format of specified version.
@@ -297,7 +297,7 @@ public:
const Message_ProgressRange& theProgress = Message_ProgressRange())
{
return Write (theShape, theFile, Standard_True, Standard_False,
TopTools_FormatVersion_CURRENT, theProgress);
TopTools_FormatVersion_VERSION_1, theProgress);
}
//! Writes the shape to the file in an ASCII format of specified version.

View File

@@ -630,7 +630,7 @@ void BRepTools_Modifier::FillNewCurveInfo(const TopTools_IndexedDataMapOfShapeLi
{
const TopoDS_Edge& anE = TopoDS::Edge(theMEF.FindKey(i));
Standard_Boolean IsNewCur = M->NewCurve(anE, aCurve, aLocation, aToler);
if (IsNewCur)
if (IsNewCur || M->IsKind("BRepTools_TrsfModification"))
{
aNCinfo.myCurve = aCurve;
aNCinfo.myLoc = aLocation;

View File

@@ -307,10 +307,10 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve
{
Standard_Real f,l;
C = BRep_Tool::Curve(E,L,f,l);
if (C.IsNull())
{
return Standard_False;
}
//if (C.IsNull())
//{
// return Standard_False;
//}
Tol = BRep_Tool::Tolerance(E);
Tol *= Abs(myTrsf.ScaleFactor());

View File

@@ -530,6 +530,7 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
Standard_Boolean isLast = Standard_False;
Standard_Real aPrevParam = aParameter;
Standard_Boolean isToReCheckBound = Standard_True;
for(; !isLast; aParameter += aStep)
{
IntSurf_PntOn2S aPOn2S;
@@ -647,6 +648,13 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine,
{// Strictly equal!!!
break;
}
else if (isToReCheckBound)
{
aPrevLPoint = aRPT;
aPrevParam = aParameter;
isToReCheckBound = Standard_False;
continue;
}
}
aPrePointExist = IntPatch_SPntNone;

View File

@@ -52,13 +52,19 @@
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepTools.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <GC_MakeArcOfEllipse.hxx>
#include <GC_MakeLine.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dConvert.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom_SphericalSurface.hxx>
@@ -68,7 +74,10 @@
#include <GeomAdaptor_Curve.hxx>
#include <GeomAPI.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomConvert_CompCurveToBSplineCurve.hxx>
#include <gp_Elips.hxx>
#include <gp_Pln.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_SequenceOfIntersectionPoint.hxx>
#include <Message_Msg.hxx>
@@ -230,6 +239,7 @@ void ShapeFix_Wire::ClearStatuses()
myStatusReorder = emptyStatus;
myStatusSmall = emptyStatus;
myStatusConnected = emptyStatus;
myStatusCurves = emptyStatus;
myStatusEdgeCurves = emptyStatus;
myStatusDegenerated = emptyStatus;
myStatusSelfIntersection = emptyStatus;
@@ -512,6 +522,23 @@ Standard_Boolean ShapeFix_Wire::FixConnected (const Standard_Real prec)
return StatusConnected ( ShapeExtend_DONE );
}
//=======================================================================
//function : FixCurves
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Wire::FixCurves()
{
myStatusCurves = ShapeExtend::EncodeStatus(ShapeExtend_OK);
if (!IsLoaded()) return Standard_False;
for (Standard_Integer anIdx = NbEdges(); anIdx > 0; anIdx--) {
FixCurves(anIdx);
myStatusCurves |= myLastFixStatus;
}
return StatusCurves(ShapeExtend_DONE);
}
//=======================================================================
//function : FixEdgeCurves
//purpose :
@@ -1299,6 +1326,194 @@ Standard_Boolean ShapeFix_Wire::FixConnected (const Standard_Integer num,
return Standard_True;
}
//=======================================================================
//function : FixCurves
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Wire::FixCurves(const Standard_Integer theIdx)
{
// assume fix curves step should be after fix vertices
myLastFixStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK);
if (!IsLoaded() || NbEdges() <= 0)
return Standard_False;
// action: replacing curves in edges
Handle(ShapeExtend_WireData) anSbwd = WireData();
Standard_Integer anIdx = (theIdx > 0 ? theIdx : anSbwd->NbEdges());
TopoDS_Edge anEdge = anSbwd->Edge(anIdx);
Standard_Real aPrec = BRep_Tool::Tolerance(anEdge);
ShapeAnalysis_Edge aSae;
ShapeAnalysis_Wire aSaw;
Handle(Geom_Curve) aCurve3d;
Standard_Real aCurBounds[3];
Standard_Boolean IsReversed = Standard_False;
aSae.Curve3d(anEdge, aCurve3d, aCurBounds[0], aCurBounds[2], IsReversed);
aCurBounds[1] = (aCurBounds[0] + aCurBounds[2]) / 2;
gp_Pnt anEnds[3];
anEnds[0] = BRep_Tool::Pnt(aSae.FirstVertex(anEdge));
aCurve3d->D0(aCurBounds[1], anEnds[1]);
anEnds[2] = BRep_Tool::Pnt(aSae.LastVertex(anEdge));
gp_Pnt aGeomEnds[2];
aCurve3d->D0(aCurBounds[0], aGeomEnds[0]);
aCurve3d->D0(aCurBounds[2], aGeomEnds[1]);
Standard_Real aGap0 = Min(anEnds[0].Distance(aGeomEnds[0]), anEnds[0].Distance(aGeomEnds[1]));
Standard_Real aGap2 = Min(anEnds[2].Distance(aGeomEnds[0]), anEnds[2].Distance(aGeomEnds[1]));
if (Max (aGap0, aGap2) < Precision::Confusion()) // nothing to do
return true;
if (aCurve3d->IsKind(STANDARD_TYPE(Geom_Circle))) {
Standard_Real anOldR = Handle(Geom_Circle)::DownCast(aCurve3d)->Circ().Radius();
gp_Vec anArcNorm = gp_Vec(anEnds[2], anEnds[0]) / 2;
gp_Pnt aCenter(anEnds[0].XYZ() - anArcNorm.XYZ());
int aSign = anEnds[1].Distance(aCenter) > anOldR ? 1 : -1; // for arc length > PI
Standard_Real aD = anOldR*anOldR - anArcNorm.SquareMagnitude();
aD = abs(aD) < Precision::Confusion() ? 0. : aD;
Standard_Real anArcR = anOldR + aSign * sqrt(aD);
gp_Ax2 aNormal(aCenter, anArcNorm);
Handle(Geom_Circle) anArc = new Geom_Circle(aNormal, anArcR);
GeomAPI_ProjectPointOnCurve projector(anEnds[1], anArc);
anEnds[1] = projector.NearestPoint();
GC_MakeArcOfCircle arc(anEnds[0], anEnds[1], anEnds[2]);
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(arc.Value()).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
/// aaajfa: BEGIN - to provide elliptic edge FORWARD orientation
gp_Pnt tmpPnt = anEnds[0];
anEnds[0] = anEnds[2];
anEnds[2] = tmpPnt;
/// aaajfa: END - to provide elliptic edge FORWARD orientation
Handle(Geom_Ellipse) anOld = Handle(Geom_Ellipse)::DownCast(aCurve3d);
Handle(Geom_Plane) aPln = new Geom_Plane(anEnds[0], gp_Vec(anEnds[2], anEnds[0]).Crossed(gp_Vec(anEnds[1], anEnds[0])));
GeomAPI_ProjectPointOnSurf aProjector(anOld->Elips().Location(), aPln);
gp_Pnt anOrigin = aProjector.NearestPoint();
aProjector.Init(anOld->Elips().Location().XYZ() + anOld->Elips().XAxis().Direction().XYZ(), aPln);
gp_Ax2 anAx(anOrigin, aPln->Axis().Direction(), aProjector.NearestPoint().XYZ() - anOrigin.XYZ());
// compute angle
Standard_Real aRec = DBL_MAX;
Standard_Real anAngle = 0.;
Standard_Integer aSplNum = 10;
for (Standard_Integer anIdxI = -aSplNum; anIdxI < aSplNum; ++anIdxI)
{
Handle(Geom_Ellipse) anEll = new Geom_Ellipse(anAx, anOld->MajorRadius(), anOld->MinorRadius());
Standard_Real anAnglei = aPrec*anIdxI / anEll->MajorRadius() / aSplNum;
anEll->Rotate(anAx.Axis(), anAnglei);
GeomAPI_ProjectPointOnCurve aProjector1(anEnds[0], anEll);
Standard_Real aDist = 0.;
for (Standard_Integer anIdxJ = 0; anIdxJ < 2; ++anIdxJ)
{
aProjector1.Perform(anEnds[anIdxJ *2]);
aDist += std::fmin (aProjector1.Distance(1), aProjector1.Distance(2));
}
if (aDist < aRec)
{
aRec = aDist;
anAngle = anAnglei;
}
}
gp_Elips aTemp(anAx, anOld->MajorRadius(), anOld->MinorRadius());
aTemp.Rotate(anAx.Axis(), anAngle);
// compute shift
gp_Vec aX = aTemp.XAxis().Direction();
gp_Vec aY = aTemp.YAxis().Direction();
gp_Pnt2d aP1((anEnds[0].XYZ() - anOrigin.XYZ()).Dot(aX.XYZ()), (anEnds[0].XYZ() - anOrigin.XYZ()).Dot(aY.XYZ()));
gp_Pnt2d aP2((anEnds[2].XYZ() - anOrigin.XYZ()).Dot(aX.XYZ()), (anEnds[2].XYZ() - anOrigin.XYZ()).Dot(aY.XYZ()));
// x = ky + p linear equation
// where (x, y) shift point,
// k, p constant coefficients
Standard_Real k = 1, p = 0;
Standard_Real R = anOld->MajorRadius();
Standard_Real r = anOld->MinorRadius();
k = (R / r) * (R / r) *
(aP1.Y() - aP2.Y()) / (aP2.X() - aP1.X());
p = -(1. / 2) * (R / r) * (R / r) *
(aP1.Y()*aP1.Y() - aP2.Y()*aP2.Y()) / (aP2.X() - aP1.X()) + aP1.X() / 2 + aP2.X() / 2;
// ax^2 + bx + c = 0 square equation
// a, b, c constant coefficients
Standard_Real a = 0., b = 0., c = 0.;
a = R*R + k*k*r*r;
b = 2 * (k*p*r*r - k*aP1.X()*r*r - aP1.Y()*R*R);
c = aP1.X()*aP1.X()*r*r +
aP1.Y()*aP1.Y()*R*R -
r*r*R*R +
p*p*r*r - 2 * aP1.X()*p*r*r;
Standard_Real y1 = (-b - sqrt(b*b - 4 * a*c)) / 2 / a;
Standard_Real y2 = (-b + sqrt(b*b - 4 * a*c)) / 2 / a;
Standard_Real x1 = k*y1 + p;
Standard_Real x2 = k*y2 + p;
gp_Pnt anOri = anOld->Location();
if (x1*x1 + y1*y1 < x2*x2 + y2*y2)
anOri = anOri.XYZ() + aX.XYZ()*x1 + aY.XYZ()*y1;
else
anOri = anOri.XYZ() + aX.XYZ()*x2 + aY.XYZ()*y2;
aTemp.SetLocation(anOri);
GC_MakeArcOfEllipse anArc(aTemp, anEnds[2], anEnds[0], true);
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(anArc.Value()).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_Line)))
{
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(anEnds[0], anEnds[2]).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)))
{
Handle(Geom_BSplineCurve) anOld = Handle(Geom_BSplineCurve)::DownCast(aCurve3d);
if (anOld->Pole(1).Distance(aGeomEnds[0]) > Precision::Confusion() ||
anOld->Pole(anOld->NbPoles()).Distance(aGeomEnds[1]) > Precision::Confusion()) {
// FAIL1 means we cannot fix Bezier or B-Spline curve
// because its ends do not correspond to first and last poles
// (i.e. it is a piece of entire curve)
myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
return false;
}
Handle(Geom_Geometry) aNewG = anOld->Copy();
Handle(Geom_BSplineCurve) aNewC = Handle(Geom_BSplineCurve)::DownCast(aNewG);
int p = anEnds[0].Distance(aGeomEnds[0]) < anEnds[1].Distance(aGeomEnds[0]) ? 0 : 2;
aNewC->SetPole(1, anEnds[p]);
aNewC->SetPole(anOld->NbPoles(), anEnds[2-p]);
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(aNewC).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
else if (aCurve3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)))
{
Handle(Geom_BezierCurve) anOld = Handle(Geom_BezierCurve)::DownCast(aCurve3d);
if (anOld->Pole(1).Distance(aGeomEnds[0]) > Precision::Confusion() ||
anOld->Pole(anOld->NbPoles()).Distance(aGeomEnds[1]) > Precision::Confusion()) {
// FAIL1 means we cannot fix Bezier or B-Spline curve
// because its ends do not correspond to first and last poles
// (i.e. it is a piece of entire curve)
myLastFixStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
return false;
}
Handle(Geom_Geometry) aNewG = anOld->Copy();
Handle(Geom_BezierCurve) aNewC = Handle(Geom_BezierCurve)::DownCast(aNewG);
int p = anEnds[0].Distance(aGeomEnds[0]) < anEnds[1].Distance(aGeomEnds[0]) ? 0 : 2;
aNewC->SetPole(1, anEnds[p]);
aNewC->SetPole(anOld->NbPoles(), anEnds[2-p]);
TopoDS_Edge aNewEdge = BRepBuilderAPI_MakeEdge(aNewC).Edge();
anSbwd->Set(aNewEdge, theIdx);
return true;
}
return true;
}
//=======================================================================
//function : FixSeam

View File

@@ -277,6 +277,7 @@ public:
//! flag ClosedMode is True
//! If <prec> is -1 then MaxTolerance() is taken.
Standard_EXPORT Standard_Boolean FixConnected (const Standard_Real prec = -1.0);
Standard_EXPORT Standard_Boolean FixCurves();
//! Groups the fixes dealing with 3d and pcurves of the edges.
//! The order of the fixes and the default behaviour are:
@@ -346,6 +347,7 @@ public:
//! Tests with starting preci or, if given greater, <prec>
//! If <prec> is -1 then MaxTolerance() is taken.
Standard_EXPORT Standard_Boolean FixConnected (const Standard_Integer num, const Standard_Real prec);
Standard_EXPORT Standard_Boolean FixCurves(const Standard_Integer num);
//! Fixes a seam edge
//! A Seam edge has two pcurves, one for forward. one for reversed
@@ -412,6 +414,8 @@ public:
Standard_Boolean StatusConnected (const ShapeExtend_Status status) const;
Standard_Boolean StatusCurves (const ShapeExtend_Status status) const;
Standard_Boolean StatusEdgeCurves (const ShapeExtend_Status status) const;
Standard_Boolean StatusDegenerated (const ShapeExtend_Status status) const;
@@ -497,6 +501,7 @@ protected:
Standard_Integer myStatusReorder;
Standard_Integer myStatusSmall;
Standard_Integer myStatusConnected;
Standard_Integer myStatusCurves;
Standard_Integer myStatusEdgeCurves;
Standard_Integer myStatusDegenerated;
Standard_Integer myStatusClosed;

View File

@@ -447,6 +447,16 @@ inline Standard_Boolean ShapeFix_Wire::StatusConnected(const ShapeExtend_Status
return ShapeExtend::DecodeStatus ( myStatusConnected, status );
}
//=======================================================================
//function : StatusCurves
//purpose :
//=======================================================================
inline Standard_Boolean ShapeFix_Wire::StatusCurves(const ShapeExtend_Status status) const
{
return ShapeExtend::DecodeStatus ( myStatusCurves, status );
}
//=======================================================================
//function : StatusEdgeCurves
//purpose :

View File

@@ -442,8 +442,10 @@ static Standard_Boolean FindCoordBounds(const TopTools_SequenceOfShape& theFaces
if (aPairSeq.Length() == 2)
theMinCoord = aPairSeq(2).first - thePeriod;
else
else if (aPairSeq.Length() > 0)
theMinCoord = aPairSeq(1).first;
else
return Standard_False;
theMaxCoord = aPairSeq(1).second;
return Standard_True;
@@ -1228,6 +1230,13 @@ static Standard_Boolean getCylinder(Handle(Geom_Surface)& theInSurface,
Handle(Geom_SurfaceOfRevolution) aRS =
Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface);
Handle(Geom_Curve) aBasis = aRS->BasisCurve();
while (aBasis->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) aTc =
Handle(Geom_TrimmedCurve)::DownCast(aBasis);
aBasis = aTc->BasisCurve();
}
if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis);
gp_Dir aDir = aRS->Direction();
@@ -1247,6 +1256,13 @@ static Standard_Boolean getCylinder(Handle(Geom_Surface)& theInSurface,
Handle(Geom_SurfaceOfLinearExtrusion) aLES =
Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface);
Handle(Geom_Curve) aBasis = aLES->BasisCurve();
while (aBasis->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) aTc =
Handle(Geom_TrimmedCurve)::DownCast(aBasis);
aBasis = aTc->BasisCurve();
}
if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) {
Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis);
gp_Dir aDir = aLES->Direction();

View File

@@ -43,6 +43,7 @@
//! - "beta..." or "rc..." for beta releases or release candidates
//! - "project..." for version containing project-specific fixes
//#define OCC_VERSION_DEVELOPMENT "dev"
#define OCC_VERSION_SERVICEPACK 1
// Derived (manually): version as real and string (major.minor)
#define OCC_VERSION 7.8

View File

@@ -457,7 +457,7 @@ Standard_Boolean StdPrs_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
for (short aContour = 0, aStartIndex = 0; aContour < anOutline->n_contours; ++aContour)
{
const FT_Vector* aPntList = &anOutline->points[aStartIndex];
const char* aTags = &anOutline->tags[aStartIndex];
const auto* aTags = &anOutline->tags[aStartIndex];
const short anEndIndex = anOutline->contours[aContour];
const short aPntsNb = (anEndIndex - aStartIndex) + 1;
aStartIndex = anEndIndex + 1;

View File

@@ -64,6 +64,12 @@
#define BVH_PRIMITIVE_LIMIT 800000
// The following flag can be used to enable optimization of cone/cylinder selection
// Unfortunately, this optimization is not stable and may lead to incorrect selection
// in some cases. It is disabled by default.
//#define OPTIMIZE_CONE_CYLINDER_SELECTION
//==================================================
// function: PreBuildBVH
// purpose : Pre-builds BVH tree for heavyweight
@@ -561,29 +567,14 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape
}
}
#ifdef OPTIMIZE_CONE_CYLINDER_SELECTION
//=======================================================================
//function : getCylinderHeight
//function : getCylinderCircles
//purpose :
//=======================================================================
static Standard_Real getCylinderHeight (const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLoc)
static NCollection_Sequence<gp_Circ> getCylinderCircles (const TopoDS_Face& theHollowCylinder)
{
Bnd_Box aBox;
gp_Trsf aScaleTrsf;
aScaleTrsf.SetScaleFactor (theLoc.Transformation().ScaleFactor());
theTriangulation->MinMax (aBox, aScaleTrsf);
return aBox.CornerMax().Z() - aBox.CornerMin().Z();
}
//=======================================================================
//function : isCylinderOrCone
//purpose :
//=======================================================================
static Standard_Boolean isCylinderOrCone (const TopoDS_Face& theHollowCylinder, const gp_Pnt& theLocation, gp_Dir& theDirection)
{
Standard_Integer aCirclesNb = 0;
Standard_Boolean isCylinder = Standard_False;
gp_Pnt aPos;
NCollection_Sequence<gp_Circ> aCircles;
TopExp_Explorer anEdgeExp;
for (anEdgeExp.Init (theHollowCylinder, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next())
@@ -594,23 +585,13 @@ static Standard_Boolean isCylinderOrCone (const TopoDS_Face& theHollowCylinder,
if (anAdaptor.GetType() == GeomAbs_Circle
&& BRep_Tool::IsClosed (anEdge))
{
aCirclesNb++;
isCylinder = Standard_True;
if (aCirclesNb == 2)
{
// Reverse the direction of the cylinder, relevant if the cylinder was created as a prism
if (aPos.IsEqual (theLocation, Precision::Confusion()))
{
theDirection.Reverse();
}
return Standard_True;
}
aPos = anAdaptor.Circle().Location().XYZ();
aCircles.Append (anAdaptor.Circle());
}
}
return isCylinder;
return aCircles;
}
#endif /*OPTIMIZE_CONE_CYLINDER_SELECTION*/
//=======================================================================
//function : GetSensitiveEntityForFace
@@ -656,31 +637,35 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_
return Standard_True;
}
}
#ifdef OPTIMIZE_CONE_CYLINDER_SELECTION
else if (Handle(Geom_ConicalSurface) aGeomCone = Handle(Geom_ConicalSurface)::DownCast (aSurf))
{
gp_Dir aDummyDir;
if (isCylinderOrCone (theFace, gp_Pnt(), aDummyDir))
NCollection_Sequence<gp_Circ> aCircles = getCylinderCircles (theFace);
if (aCircles.Size() > 0)
{
const gp_Cone aCone = BRepAdaptor_Surface (theFace).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = getCylinderHeight (aTriangulation, aLoc);
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp::XOY());
Standard_Real aRad1;
Standard_Real aRad2;
if (aRad1 == 0.0)
Standard_Real aHeight;
if (aCircles.Size() == 1)
{
aRad2 = Tan (aCone.SemiAngle()) * aHeight;
aRad1 = 0.0;
aRad2 = aCircles.First().Radius();
aHeight = aRad2 * Tan (aCone.SemiAngle());
aTrsf.SetTransformation (aCone.Position(), gp::XOY());
}
else
{
const Standard_Real aTriangleHeight = (aCone.SemiAngle() > 0.0)
? aRad1 / Tan (aCone.SemiAngle())
: aRad1 / Tan (Abs (aCone.SemiAngle())) - aHeight;
aRad2 = (aCone.SemiAngle() > 0.0)
? aRad1 * (aTriangleHeight + aHeight) / aTriangleHeight
: aRad1 * aTriangleHeight / (aTriangleHeight + aHeight);
aRad1 = aCircles.First().Radius();
aRad2 = aCircles.Last().Radius();
aHeight = aCircles.First().Location().Distance (aCircles.Last().Location());
const gp_Pnt aPos = aCircles.First().Location();
const gp_Dir aDirection (aCircles.Last().Location().XYZ() - aPos.XYZ());
aTrsf.SetTransformation (gp_Ax3(aPos, aDirection), gp::XOY());
}
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad1, aRad2, aHeight, aTrsf, true);
@@ -690,24 +675,25 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_
}
else if (Handle(Geom_CylindricalSurface) aGeomCyl = Handle(Geom_CylindricalSurface)::DownCast (aSurf))
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (theFace).Cylinder();
gp_Ax3 aPos = aCyl.Position();
gp_Dir aDirection = aPos.Direction();
if (isCylinderOrCone (theFace, aPos.Location(), aDirection))
NCollection_Sequence<gp_Circ> aCircles = getCylinderCircles (theFace);
if (aCircles.Size() == 2)
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (theFace).Cylinder();
const Standard_Real aRad = aCyl.Radius();
const Standard_Real aHeight = getCylinderHeight (aTriangulation, aLoc);
const gp_Pnt aPos = aCircles.First().Location();
const gp_Dir aDirection (aCircles.Last().Location().XYZ() - aPos.XYZ());
const Standard_Real aHeight = aPos.Distance (aCircles.Last().Location());
gp_Trsf aTrsf;
aPos.SetDirection (aDirection);
aTrsf.SetTransformation (aPos, gp::XOY());
aTrsf.SetTransformation (gp_Ax3 (aPos, aDirection), gp::XOY());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad, aRad, aHeight, aTrsf, true);
theSensitiveList.Append (aSensSCyl);
return Standard_True;
}
}
#endif /*OPTIMIZE_CONE_CYLINDER_SELECTION*/
else if (Handle(Geom_Plane) aGeomPlane = Handle(Geom_Plane)::DownCast (aSurf))
{
TopTools_IndexedMapOfShape aSubfacesMap;

View File

@@ -33,6 +33,6 @@ Number of shapes in .*
"
checknbshapes result -ref $NbShapesRef
checkmaxtol result -ref 2.0849512334752456e-05
checkmaxtol result -ref 0.00013340609302644948
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -33,7 +33,7 @@ Number of shapes in .*
checknbshapes result -ref $NbShapesRef
checkmaxtol result -ref 2.0849512334752456e-05
checkmaxtol result -ref 0.00013340609302644948
checkview -display result -2d -path ${imagedir}/${test_image}_axo.png

View File

@@ -33,7 +33,7 @@ Number of shapes in .*
checknbshapes result -ref $NbShapesRef
checkmaxtol result -ref 2.0849512334752456e-05
checkmaxtol result -ref 0.00013340609302644948
checkview -display result -2d -path ${imagedir}/${test_image}_axo.png

View File

@@ -32,7 +32,7 @@ Number of shapes in .*
"
checknbshapes result -ref $NbShapesRef
checkmaxtol result -ref 2.0849512334752456e-05
checkmaxtol result -ref 0.00013340609302644948
checkview -display result -2d -path ${imagedir}/${test_image}_axo.png

View File

@@ -33,7 +33,7 @@ Number of shapes in .*
checknbshapes result -ref $NbShapesRef
checkmaxtol result -ref 2.0849512334752456e-05
checkmaxtol result -ref 0.00013340609302644948
checkview -display result -2d -path ${imagedir}/${test_image}_axo.png

View File

@@ -17,7 +17,7 @@ if [catch { openoffset resoffset a 5 5 i } ] {
checkshape result
checksection result
checknbshapes result -vertex 4 -edge 3 -wire 1 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 0 -shape 8
checknbshapes result -vertex 3 -edge 2 -wire 1 -face 0 -shell 0 -solid 0 -compsolid 0 -compound 0 -shape 6
}
smallview

View File

@@ -1,3 +1,5 @@
puts "TODO ALL: Error: Degenerated edge is not found"
puts "========"
puts "0029807: Impossible to cut cone from prism"
puts "========"

View File

@@ -31,10 +31,10 @@ regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+)
set h1_Time [expr ${h1_Hours}*60.*60. + ${h1_Minutes}*60. + ${h1_Seconds} ]
set h2_Time [expr ${h2_Hours}*60.*60. + ${h2_Minutes}*60. + ${h2_Seconds} ]
if { ${h1_Time} > 0.1 } {
if { ${h1_Time} > 0.4 } {
puts "Error: Section of simple BSpline surfaces_1 is performed too slow"
}
if { ${h2_Time} > 0.1 } {
if { ${h2_Time} > 0.4 } {
puts "Error: Section of simple BSpline surfaces_2 is performed too slow"
}

View File

@@ -0,0 +1,14 @@
puts "============="
puts "0032964: Modeling Algorithms - 2d Offset sometimes 'split' straight edges"
puts "============="
pload MODELING
vertex p1 -90 40 0
vertex p2 40 40 0
vertex p3 40 -90 0
edge e1 p1 p2
edge e2 p2 p3
wire w1 e1 e2
openoffset oo w1 1 40
checknbshapes oo_1 -vertex 3 -edge 2 -wire 1 -shape 6
checkview -display oo_1 -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "==============================================================="
puts "0033367: Modeling Algorithms - Normal projection or BOP problem"
puts "==============================================================="
puts ""
pload MODELING
restore [locate_data_file bug33367_1.brep] sou
restore [locate_data_file bug33367_2.brep] des
checkshape sou
checkshape des
nproject prj sou des
checknbshapes prj -vertex 2 -edge 2 -compound 1 -shape 5
baddobjects des
baddtools prj
bfillds
bbuild res
checkshape res

View File

@@ -0,0 +1,14 @@
puts "========================"
puts "0033394: Modeling Algorithms - Wrong usage of BRepClass_FaceClassifier with 3d tolerance"
puts "========================"
puts ""
pload MODELING
restore [locate_data_file bug33394.brep] fb
vertex vert 1016.3915670000133 17180 -5689.3758362036951
distmini aa fb vert
set tolerance [checkmaxtol aa]
if { [dval aa_val] > ${tolerance} } {
puts "Error: The distance should be 0"
}

View File

@@ -0,0 +1,29 @@
puts "========================"
puts "0033591: Modeling Algorithms - Regression: old surface is not removed after translation or rotation with geometry copying"
puts "========================"
puts ""
pload MODELING
pcylinder Cylinder_1 80 200
pcylinder Cylinder_2 60 200
psphere Sphere_1 80
psphere Sphere_2 60
trotate Sphere_1 0 0 0 0 1 0 90 -copy
trotate Sphere_2 0 0 0 0 1 0 90 -copy
ttranslate Sphere_1 0 0 200 -copy
ttranslate Sphere_2 0 0 200 -copy
bfuse Fuse_1 Sphere_1 Cylinder_1
bfuse Fuse_2 Cylinder_2 Sphere_2
bclear
baddobjects Fuse_1 Fuse_2
bfillds
bbuild Partition_1
explode Partition_1
plane pln_1 0 0 200
mkface Plane_1 pln_1 -100 100 -100 100
bclear
baddobjects Partition_1_2
baddtools Plane_1
bfillds
bbuild res
checkshape res

View File

@@ -0,0 +1,22 @@
puts "================================"
puts "0033615: Modeling Algorithms - Partition algorithm creates unexpected vertices"
puts "================================"
puts ""
plane plane -5 0 4 -1 0 0
pcone cone plane 3 1 10
pcylinder cylinder 10 20
explode cylinder f
explode cone f
don cylinder_1 cone_1
axo;fit
bclearobjects
bcleartools
baddobjects cone_1
baddtools cylinder_1
bfillds
bbuild result
checknbshapes result -vertex 5 -edge 8 -wire 5 -face 4
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,26 @@
puts "==================================================="
puts "0033648: Modeling Algorithms - Bad partition result"
puts "==================================================="
puts ""
pload MODELING
restore [locate_data_file bug33648_1.brep] s1
restore [locate_data_file bug33648_2.brep] s2
baddobjects s1 s2
bfillds
bbuild result
checkprops result -s 87.2813
checknbshapes result -vertex 58 -edge 97 -wire 44 -face 44 -shell 4 -solid 4 -compsolid 0 -compound 2 -shape 253
set expected_MaxTolerance 0.05
regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance
if { $MaxTolerance > $expected_MaxTolerance } {
puts "Error : too big tolerance for the shape (should be less than $expected_MaxTolerance, now $MaxTolerance)"
}
vinit
vdisplay result
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png

View File

@@ -26,3 +26,4 @@
026 checkshape
027 split_number
028 split_two_numbers
029 wire_fix_curves

View File

@@ -0,0 +1,16 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
circle c1 0 0 0 15
circle c2 0 0 0 15
trim c1 c1 0 pi
trim c2 c2 pi 2*pi
translate c1 0 0 0.00000005
translate c2 0 0 -0.00000005
mkedge c1 c1
mkedge c2 c2
strongwire result c1 c2
checkshape result
whatis result

View File

@@ -0,0 +1,16 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
ellipse e1 0 0 0 25 15
ellipse e2 0 0 0 25 15
trim e1 e1 0 pi
trim e2 e2 pi 2*pi
translate e1 0 0 0.00000005
translate e2 0 0 -0.00000005
mkedge e1 e1
mkedge e2 e2
strongwire result e1 e2
checkshape result
whatis result

View File

@@ -0,0 +1,24 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
point px 100 0 0
point py 0 100 0
point pz 0 0 100
vertex vx px
vertex vy py
edge exy vx vy
gcarc arc cir py pz px
# Here we have an error during automatic grid execution with test and testgrid:
# Tcl Exception: EMPTY
# But in line-by-line entering or script sourcing mode this line doesn't produce any error
mkedge earc arc
strongwire result exy earc
whatis result

View File

@@ -0,0 +1,25 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
point p1 0 0 0
point p2 100 0 0
point p4 100 110 0
gcarc arc cir p1 p2 p4
# Here we have an error during automatic grid execution with test and testgrid:
# Tcl Exception: EMPTY
# But in line-by-line entering or script sourcing mode this line doesn't produce any error
mkedge arc1 arc
mkedge arc2 arc
tmirror arc2 0 0 0 -110 100 0 -copy
ttranslate arc2 0 0 0.003 -copy
strongwire result arc1 arc2 -t 0.01 -m keepType
checkshape result
whatis result

View File

@@ -0,0 +1,14 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
bsplinecurve c1 3 2 -1.0 4 1.0 4 0 0 0 1 1 4 0 1 2 4 0 1 3 0 0 1
bsplinecurve c2 3 2 -1.0 4 1.0 4 0 0 0 1 1 -4 0 1 2 -4 0 1 3 0 0 1
translate c1 0 0 0.00000005
translate c2 0 0 -0.00000005
mkedge c1 c1
mkedge c2 c2
strongwire result c1 c2
checkshape result
whatis result

View File

@@ -0,0 +1,17 @@
#############################################################
## Fix wire algo
## moves a curve of invalid wire to make it valid
#############################################################
vertex v1 0 0 0
vertex v2 100 0 0
vertex v3 50 100 0
edge e1 v1 v2
edge e2 v2 v3
edge e3 v3 v1
strongwire result e1 e2 e3
checkshape result
whatis result

View File

@@ -17,7 +17,7 @@ fit
regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} [bopcurves b1_5 b2_2 -2d] full Toler NbCurv
if { ${Toler} > 0.0004} {
if { ${Toler} > 0.002} {
puts "Error: bad tolerance of result"
}

View File

@@ -18,7 +18,7 @@ fit
regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} [bopcurves b1_5 b2_2 -2d] full Toler NbCurv
if { ${Toler} > 8e-7} {
if { ${Toler} > 8e-6} {
puts "Error: bad tolerance of result"
}

View File

@@ -17,7 +17,7 @@ fit
regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} [bopcurves b1_5 f2 -2d] full Toler NbCurv
if { ${Toler} > 8e-7} {
if { ${Toler} > 8e-6} {
puts "Error: bad tolerance of result"
}

View File

@@ -55,6 +55,6 @@ fit
checksection result -r 0
checkmaxtol result -min_tol 2.0e-7
checknbshapes result -edge 3 -vertex 3
checknbshapes result -edge 2 -vertex 2
checkview -screenshot -2d -path ${imagedir}/${test_image}.png