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

Compare commits

..

1 Commits

8 changed files with 62 additions and 136 deletions

View File

@@ -2691,62 +2691,7 @@ static IntPatch_ImpImpIntersection::IntStatus
if ((aRangeS1.Delta() > aMaxV1Range) || (aRangeS2.Delta() > aMaxV2Range)) if ((aRangeS1.Delta() > aMaxV1Range) || (aRangeS2.Delta() > aMaxV2Range))
return IntPatch_ImpImpIntersection::IntStatus_InfiniteSectionCurve; return IntPatch_ImpImpIntersection::IntStatus_InfiniteSectionCurve;
} }
//
Standard_Boolean isGoodIntersection = Standard_False;
Standard_Real anOptdu = 0.;
do
{
//Checking parameters of cylinders in order to define "good intersection"
//"Good intersection" means that axes of cylinders are almost perpendicular and
// one radius is much smaller than the other and small cylinder is "inside" big one.
const Standard_Real aToMuchCoeff = 3.;
const Standard_Real aCritAngle = M_PI / 18.; // 10 degree
Standard_Real anR1 = theCyl1.Radius();
Standard_Real anR2 = theCyl2.Radius();
Standard_Real anRmin = 0., anRmax = 0.;
//Radius criterion
if (anR1 > aToMuchCoeff * anR2)
{
anRmax = anR1; anRmin = anR2;
}
else if (anR2 > aToMuchCoeff * anR1)
{
anRmax = anR2; anRmin = anR1;
}
else
{
break;
}
//Angle criterion
const gp_Ax1& anAx1 = theCyl1.Axis();
const gp_Ax1& anAx2 = theCyl2.Axis();
if (!anAx1.IsNormal(anAx2, aCritAngle))
{
break;
}
//Placement criterion
gp_Lin anL1(anAx1), anL2(anAx2);
Standard_Real aDist = anL1.Distance(anL2);
if (aDist > anRmax / 2.)
{
break;
}
isGoodIntersection = Standard_True;
//Estimation of "optimal" du
//Relative deflection, absolut deflection is Rmin*aDeflection
Standard_Real aDeflection = 0.001;
Standard_Integer aNbP = 3;
if (anRmin * aDeflection > 1.e-3)
{
Standard_Real anAngle = 1.0e0 - aDeflection;
anAngle = 2.0e0 * ACos(anAngle);
aNbP = (Standard_Integer)(2. * M_PI / anAngle) + 1;
}
anOptdu = 2. * M_PI_2 / (Standard_Real)(aNbP - 1);
} while (0);
//
const ComputationMethods::stCoeffsValue &anEquationCoeffs = theBW.SICoeffs(); const ComputationMethods::stCoeffsValue &anEquationCoeffs = theBW.SICoeffs();
const IntSurf_Quadric& aQuad1 = theBW.GetQSurface(1); const IntSurf_Quadric& aQuad1 = theBW.GetQSurface(1);
const IntSurf_Quadric& aQuad2 = theBW.GetQSurface(2); const IntSurf_Quadric& aQuad2 = theBW.GetQSurface(2);
@@ -2754,26 +2699,14 @@ static IntPatch_ImpImpIntersection::IntStatus
const Standard_Real aTol2D = theBW.Get2dTolerance(); const Standard_Real aTol2D = theBW.Get2dTolerance();
const Standard_Real aTol3D = theBW.Get3dTolerance(); const Standard_Real aTol3D = theBW.Get3dTolerance();
const Standard_Real aPeriod = 2.0*M_PI; const Standard_Real aPeriod = 2.0*M_PI;
Standard_Integer aNbMaxPoints = 1000; const Standard_Integer aNbMaxPoints = 2000;
Standard_Integer aNbMinPoints = 200; const Standard_Integer aNbMinPoints = 200;
Standard_Real du; const Standard_Integer aNbPoints = Min(Max(aNbMinPoints,
if (isGoodIntersection) RealToInt(20.0*theCyl1.Radius())), aNbMaxPoints);
{ const Standard_Real aStepMin = aTol2D,
du = anOptdu;
aNbMaxPoints = 200;
aNbMinPoints = 50;
}
else
{
du = 2. * M_PI / aNbMaxPoints;
}
Standard_Integer aNbPts = Min(RealToInt((aUSurf1l - aUSurf1f) / du) + 1,
RealToInt(20.0*theCyl1.Radius()));
const Standard_Integer aNbPoints = Min(Max(aNbMinPoints, aNbPts), aNbMaxPoints);
const Standard_Real aStepMin = Max(aTol2D, Precision::PConfusion()),
aStepMax = (aUSurf1l - aUSurf1f > M_PI / 100.0) ? aStepMax = (aUSurf1l - aUSurf1f > M_PI / 100.0) ?
(aUSurf1l - aUSurf1f) / IntToReal(aNbPoints) : aUSurf1l - aUSurf1f; (aUSurf1l - aUSurf1f) / IntToReal(aNbPoints) :
aUSurf1l - aUSurf1f;
//The main idea of the algorithm is to change U1-parameter //The main idea of the algorithm is to change U1-parameter
//(U-parameter of theCyl1) from aU1f to aU1l with some step //(U-parameter of theCyl1) from aU1f to aU1l with some step
@@ -3346,16 +3279,6 @@ static IntPatch_ImpImpIntersection::IntStatus
aMinUexp = Min(aMinUexp, anUexpect[i]); aMinUexp = Min(aMinUexp, anUexpect[i]);
continue; continue;
} }
//
if (isGoodIntersection)
{
//Use constant step
anUexpect[i] += aStepMax;
aMinUexp = Min(aMinUexp, anUexpect[i]);
continue;
}
//
Standard_Real aStepTmp = aStepMax; Standard_Real aStepTmp = aStepMax;

View File

@@ -97,9 +97,25 @@ namespace
return aPoly; return aPoly;
} }
//! Add new solid
virtual void AddSolid() Standard_OVERRIDE
{
Handle(Poly_Triangulation) aCurrentTri = GetTriangulation();
myTriangulationList.Append(aCurrentTri);
myNodes.Clear();
myTriangles.Clear();
}
NCollection_Sequence<Handle(Poly_Triangulation)> GetTriangulationList()
{
return myTriangulationList;
}
private: private:
NCollection_Vector<gp_XYZ> myNodes; NCollection_Vector<gp_XYZ> myNodes;
NCollection_Vector<Poly_Triangle> myTriangles; NCollection_Vector<Poly_Triangle> myTriangles;
NCollection_Sequence<Handle(Poly_Triangulation)> myTriangulationList;
}; };
} }
@@ -118,6 +134,17 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const Standard_CString theFile,
return aReader.GetTriangulation(); return aReader.GetTriangulation();
} }
//=============================================================================
//function : ReadFile
//purpose :
//=============================================================================
void RWStl::ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList)
{
Reader aReader;
aReader.Read(theFile, Handle(Message_ProgressIndicator)(), true);
theTriangList = aReader.GetTriangulationList();
}
//============================================================================= //=============================================================================
//function : ReadFile //function : ReadFile
//purpose : //purpose :

View File

@@ -50,6 +50,8 @@ public:
Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile, Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)()); const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
Standard_EXPORT static void ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList);
//! Read triangulation from a binary STL file //! Read triangulation from a binary STL file
//! In case of error, returns Null handle. //! In case of error, returns Null handle.
Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath, Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,

View File

@@ -126,7 +126,8 @@ namespace
//============================================================================== //==============================================================================
Standard_Boolean RWStl_Reader::Read (const char* theFile, Standard_Boolean RWStl_Reader::Read (const char* theFile,
const Handle(Message_ProgressIndicator)& theProgress) const Handle(Message_ProgressIndicator)& theProgress,
bool IsMultiSolid)
{ {
std::filebuf aBuf; std::filebuf aBuf;
OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary); OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
@@ -165,6 +166,8 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile,
} }
} }
aStream >> std::ws; // skip any white spaces aStream >> std::ws; // skip any white spaces
if (IsMultiSolid)
AddSolid();
} }
return ! aStream.fail(); return ! aStream.fail();
} }

View File

@@ -39,7 +39,8 @@ public:
//! Format is recognized automatically by analysis of the file header. //! Format is recognized automatically by analysis of the file header.
//! Returns true if success, false on error or user break. //! Returns true if success, false on error or user break.
Standard_EXPORT Standard_Boolean Read (const char* theFile, Standard_EXPORT Standard_Boolean Read (const char* theFile,
const Handle(Message_ProgressIndicator)& theProgress); const Handle(Message_ProgressIndicator)& theProgress,
bool IsMultiSolid = false);
//! Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200). //! Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200).
//! The function attempts to put back the read symbols to the stream which thus must support ungetc(). //! The function attempts to put back the read symbols to the stream which thus must support ungetc().
@@ -74,6 +75,8 @@ public:
//! Should create new triangle built on specified nodes in the target model. //! Should create new triangle built on specified nodes in the target model.
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0; virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0;
virtual void AddSolid() = 0;
}; };
#endif #endif

View File

@@ -411,6 +411,22 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI,
{ {
aFilePath = theArgVec[anArgIter]; aFilePath = theArgVec[anArgIter];
} }
else if (theArgc == 4 && strcmp("multi", theArgv[3]) == 0)
{
NCollection_Sequence<Handle(Poly_Triangulation)> theTriangList;
RWStl::ReadFile(theArgv[2], theTriangList);
BRep_Builder aB;
TopoDS_Compound aCmp;
aB.MakeCompound(aCmp);
for (int i = 1; i <= theTriangList.Length(); i++)
{
TopoDS_Face aFace;
aB.MakeFace(aFace);
aB.UpdateFace(aFace, theTriangList(i));
aB.Add(aCmp, aFace);
}
DBRep::Set(theArgv[1], aCmp);
}
else else
{ {
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";

View File

@@ -1,48 +0,0 @@
puts "========="
puts "0031552: Modeling Algorithms - Bad performance of intersection of cylindrical surfaces"
puts "========="
puts ""
cpulimit 200
cylinder s1 0 557.800010681152 0 0 0 1 0 1 0 347.850006103516
trim s1 s1 3.2385 6.28319 -39.957 39.957
cylinder s2 5.45639675193397 189.209310035068 0 -0.254420004160252 0.96709382248213 0 0.96709382248213 0.254420004160252 0 88.5
trim s2 s2 6.19592 6.37045 0 10.0002
dchrono z reset
dchrono z start
set ic 1
while { $ic <= 100 } {
intersect res s1 s2
incr ic
}
dchrono z stop counter Bug31552
set che [whatis res]
set ind [string first "3d curve" $che]
if {${ind} >= 0} {
puts "Error: only one curve"
}
set che [whatis res_1]
set ind [string first "3d curve" $che]
if {${ind} < 0} {
puts "Error no first curve"
}
set che [whatis res_2]
set ind [string first "3d curve" $che]
if {${ind} < 0} {
puts "Error no second curve"
}
smallview AXON
don res_1 res_2
fit
checkview -screenshot -2d -path ${imagedir}/${test_image}.png

View File

@@ -6,7 +6,7 @@ puts ""
# Very slow boolean cut operations on cylinders # Very slow boolean cut operations on cylinders
################################################# #################################################
set ExpTol 3.05e-07 set ExpTol 3.32e-07
set GoodNbCurv 4 set GoodNbCurv 4