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

Compare commits

...

3 Commits

Author SHA1 Message Date
emv
e98d4b30fc 0032307: Modeling Algorithms - Empty result of offset operation in mode "Complete" Joint type "Intersection"
Make sure the vertices created by pairwise intersection of edges connected in the same vertex are unified correctly.
2021-04-20 11:04:44 +03:00
mpv
fd696d1577 0032299: Application Framework - Loading OCAF document saved with earlier version fails when using OCCT 7.5.1
Keeping information about the file start instead of calling tellg. This fixes problem with not-seekable streams used for XML files reading and improves performance of XML files reading (about 10%), since tellg is quite long operation.
2021-04-15 09:22:37 +03:00
emv
9329610771 0032088: Modeling Algorithms - Empty result of offset operation in mode "Complete" join type "Intersection"
Mark inverted edges located inside loops of invalid edges as invalid as well.
2021-04-06 20:59:58 +03:00
15 changed files with 315 additions and 31 deletions

View File

@@ -64,6 +64,7 @@
#include <gp_Pnt.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntTools_Tools.hxx>
#include <Precision.hxx>
#include <TColGeom2d_SequenceOfCurve.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
@@ -278,6 +279,14 @@ static void Store(const TopoDS_Edge& theEdge,
Handle(BRepAlgo_AsDes) theAsDes2d,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV)
{
// Update vertices
TopTools_ListIteratorOfListOfShape aIt(theLV);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Vertex& aV = TopoDS::Vertex(aIt.Value());
BRep_Builder().UpdateVertex(aV, theTol);
}
// Get vertices already added to the edge and check the distances to the new ones
const TopTools_ListOfShape& aLVEx = theAsDes2d->Descendant(theEdge);
if (!IsToUpdate && aLVEx.IsEmpty()) {
if (theLV.Extent()) theAsDes2d->Add(theEdge, theLV);
@@ -285,21 +294,23 @@ static void Store(const TopoDS_Edge& theEdge,
}
//
GeomAPI_ProjectPointOnCurve aProjPC;
Standard_Real aTolE = 0.0;
if (IsToUpdate) {
Standard_Real aT1, aT2;
const Handle(Geom_Curve)& aC = BRep_Tool::Curve(theEdge, aT1, aT2);
aProjPC.Init(aC, aT1, aT2);
aTolE = BRep_Tool::Tolerance(theEdge);
}
//
TopTools_MapOfShape aMV;
TopTools_ListIteratorOfListOfShape aIt(theLV);
for (; aIt.More(); aIt.Next()) {
for (aIt.Init(theLV); aIt.More(); aIt.Next()) {
const TopoDS_Vertex& aV = TopoDS::Vertex(aIt.Value());
if (!aMV.Add(aV)) {
continue;
}
//
const gp_Pnt& aP = BRep_Tool::Pnt(aV);
const Standard_Real aTol = BRep_Tool::Tolerance(aV);
//
TopTools_ListOfShape aLVC;
TopTools_ListIteratorOfListOfShape aItEx(aLVEx);
@@ -309,7 +320,8 @@ static void Store(const TopoDS_Edge& theEdge,
break;
}
const gp_Pnt& aPEx = BRep_Tool::Pnt(aVEx);
if (aP.IsEqual(aPEx, theTol)) {
const Standard_Real aTolVEx = BRep_Tool::Tolerance(aVEx);
if (aP.IsEqual(aPEx, aTol + aTolVEx)) {
aLVC.Append(aVEx);
}
}
@@ -325,16 +337,13 @@ static void Store(const TopoDS_Edge& theEdge,
continue;
}
//
if (aProjPC.LowerDistance() > theTol) {
if (aProjPC.LowerDistance() > aTol + aTolE) {
continue;
}
//
Standard_Real aT = aProjPC.LowerDistanceParameter();
TopoDS_Shape aLocalShape = aV.Oriented(TopAbs_INTERNAL);
BRep_Builder().UpdateVertex(TopoDS::Vertex(aLocalShape), aT, theEdge, theTol);
}
else {
BRep_Builder().UpdateVertex(aV, theTol);
BRep_Builder().UpdateVertex(TopoDS::Vertex(aLocalShape), aT, theEdge, aTol);
}
//
if (aLVC.Extent()) {
@@ -672,7 +681,7 @@ static void RefEdgeInter(const TopoDS_Face& F,
return;
Standard_Real f[3],l[3];
Standard_Real TolDub = 1.e-7;
Standard_Real TolDub = 1.e-7, TolLL = 0.0;
Standard_Integer i;
//BRep_Tool::Range(E1, f[1], l[1]);
@@ -689,9 +698,6 @@ static void RefEdgeInter(const TopoDS_Face& F,
BRepLib::BuildCurve3d(E1);
BRepLib::BuildCurve3d(E2);
Standard_Real TolSum = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
TolSum = Max( TolSum, 1.e-5 );
TColgp_SequenceOfPnt ResPoints;
TColStd_SequenceOfReal ResParamsOnE1, ResParamsOnE2;
gp_Pnt DegPoint;
@@ -721,11 +727,19 @@ static void RefEdgeInter(const TopoDS_Face& F,
(GAC2.GetType() == GeomAbs_Line))
{
// Just quickly check if lines coincide
if (GAC1.Line().Direction().IsParallel (GAC2.Line().Direction(), 1.e-8))
Standard_Real anAngle = Abs(GAC1.Line().Direction().Angle(GAC2.Line().Direction()));
if (anAngle <= 1.e-8 || M_PI - anAngle <= 1.e-8)
{
theCoincide = Standard_True;
return;
}
else
{
// Take into account the intersection range of line-line intersection
// (the smaller angle between curves, the bigger range)
TolLL = IntTools_Tools::ComputeIntRange(TolDub, TolDub, anAngle);
TolLL = Min (TolLL, 1.e-5);
}
}
Geom2dInt_GInter Inter2d( GAC1, GAC2, TolDub, TolDub );
@@ -943,10 +957,12 @@ static void RefEdgeInter(const TopoDS_Face& F,
else
theImageVV.Bind (theVref.Oriented(TopAbs_FORWARD), aNewVertex);
}
////-----------------------------------------------------
Standard_Real TolStore = BRep_Tool::Tolerance(E1) + BRep_Tool::Tolerance(E2);
TolStore = Max (TolStore, Tol);
// Compare to Line-Line tolerance
TolStore = Max (TolStore, TolLL);
Store (E1,E2,LV1,LV2,TolStore,AsDes, aDMVV);
}
}

View File

@@ -195,6 +195,12 @@ static
BRepOffset_DataMapOfShapeMapOfShape& theLocValidEdges,
BRepOffset_DataMapOfShapeMapOfShape& theNeutralEdges);
static
void MakeInvertedEdgesInvalid(const TopTools_ListOfShape& theLFOffset,
const TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopTools_MapOfShape& theInvertedEdges,
TopTools_IndexedMapOfShape& theInvEdges);
static
void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
const TopTools_IndexedMapOfShape& theInvEdges,
@@ -1030,6 +1036,10 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
FindInvalidEdges (aLFDone, theFImages, theFacesOrigins, theAnalyse,
theInvEdges, theValidEdges, aDMFMIE, aDMFMVE, aDMFMNE);
// Additional step to mark inverted edges located inside loops
// of invalid edges as invalid as well
MakeInvertedEdgesInvalid(aLFDone, theFImages, theInvertedEdges, theInvEdges);
#ifdef OFFSET_DEBUG
// show invalid edges
TopoDS_Compound aCEInv1;
@@ -2180,6 +2190,82 @@ void FindInvalidEdges (const TopTools_ListOfShape& theLFOffset,
}
}
//=======================================================================
//function : MakeInvertedEdgesInvalid
//purpose : Makes inverted edges located inside loop of invalid edges, invalid as well
//=======================================================================
void MakeInvertedEdgesInvalid(const TopTools_ListOfShape& theLFOffset,
const TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopTools_MapOfShape& theInvertedEdges,
TopTools_IndexedMapOfShape& theInvEdges)
{
if (theInvEdges.IsEmpty() || theInvertedEdges.IsEmpty())
return;
// Map all invalid edges
TopoDS_Compound aCBEInv;
BRep_Builder().MakeCompound(aCBEInv);
for (Standard_Integer i = 1; i <= theInvEdges.Extent(); ++i)
{
BRep_Builder().Add(aCBEInv, theInvEdges(i));
}
// Make loops of invalid edges
TopTools_ListOfShape aLCB;
BOPTools_AlgoTools::MakeConnexityBlocks(aCBEInv, TopAbs_VERTEX, TopAbs_EDGE, aLCB);
// Analyze each loop on closeness and use only closed ones
TopTools_DataMapOfShapeShape aDMVCB;
for (TopTools_ListOfShape::Iterator itLCB(aLCB); itLCB.More(); itLCB.Next())
{
const TopoDS_Shape& aCB = itLCB.Value();
TopTools_IndexedDataMapOfShapeListOfShape aDMVE;
TopExp::MapShapesAndAncestors(aCB, TopAbs_VERTEX, TopAbs_EDGE, aDMVE);
Standard_Boolean isClosed = Standard_True;
for (Standard_Integer iV = 1; iV <= aDMVE.Extent(); ++iV)
{
if (aDMVE(iV).Extent() != 2)
{
isClosed = Standard_False;
break;
}
}
if (!isClosed)
continue;
// Bind loop to each vertex of the loop
for (Standard_Integer iV = 1; iV <= aDMVE.Extent(); ++iV)
{
aDMVCB.Bind(aDMVE.FindKey(iV), aCB);
}
}
// Check if any inverted edges of offset faces are locked inside the loops of invalid edges.
// Make such edges invalid as well.
for (TopTools_ListOfShape::Iterator itLF(theLFOffset); itLF.More(); itLF.Next())
{
const TopTools_ListOfShape& aLFIm = theFImages.FindFromKey(itLF.Value());
for (TopTools_ListOfShape::Iterator itLFIm(aLFIm); itLFIm.More(); itLFIm.Next())
{
for (TopExp_Explorer expE(itLFIm.Value(), TopAbs_EDGE); expE.More(); expE.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge(expE.Current());
if (!theInvEdges.Contains(aE) && theInvertedEdges.Contains(aE))
{
const TopoDS_Shape* pCB1 = aDMVCB.Seek (TopExp::FirstVertex(aE));
const TopoDS_Shape* pCB2 = aDMVCB.Seek (TopExp::LastVertex(aE));
if (pCB1 && pCB2 && pCB1->IsSame(*pCB2))
{
theInvEdges.Add(aE);
}
}
}
}
}
}
//=======================================================================
//function : FindInvalidFaces
//purpose : Looking for the invalid faces by analyzing their invalid edges

View File

@@ -55,13 +55,14 @@ inline
#endif
LDOM_XmlReader::RecordType ReadRecord (LDOM_XmlReader& aReader,
Standard_IStream& theIStream,
LDOM_OSStream& aData)
LDOM_OSStream& aData,
Standard_Boolean& theDocStart)
{
#ifdef LDOM_PARSER_TRACE
static aCounter = 0;
++ aCounter;
#endif
const LDOM_XmlReader::RecordType aType = aReader.ReadRecord (theIStream, aData);
const LDOM_XmlReader::RecordType aType = aReader.ReadRecord (theIStream, aData, theDocStart);
#ifdef LDOM_PARSER_TRACE
static FILE * ff = NULL;
TCollection_AsciiString aTraceFileName;
@@ -172,11 +173,13 @@ Standard_Boolean LDOMParser::ParseDocument (std::istream& theIStream, const Stan
Standard_Boolean isDoctype = Standard_False;
Standard_Boolean isInsertFictRootElement = Standard_False;
Standard_Boolean aDocStart = Standard_True;
for(;;) {
LDOM_XmlReader::RecordType aType = (theWithoutRoot && !isInsertFictRootElement ?
LDOM_XmlReader::XML_START_ELEMENT :
ReadRecord (*myReader, theIStream, myCurrentData));
ReadRecord (*myReader, theIStream, myCurrentData, aDocStart));
switch (aType) {
case LDOM_XmlReader::XML_HEADER:
if (isDoctype || isElement) {
@@ -234,7 +237,7 @@ Standard_Boolean LDOMParser::ParseDocument (std::istream& theIStream, const Stan
myError = "User abort at startElement()";
break;
}
isError = ParseElement (theIStream);
isError = ParseElement (theIStream, aDocStart);
if (isError) break;
continue;
}
@@ -266,7 +269,7 @@ Standard_Boolean LDOMParser::ParseDocument (std::istream& theIStream, const Stan
//purpose : parse one element, given the type of its XML presentation
//=======================================================================
Standard_Boolean LDOMParser::ParseElement (Standard_IStream& theIStream)
Standard_Boolean LDOMParser::ParseElement (Standard_IStream& theIStream, Standard_Boolean& theDocStart)
{
Standard_Boolean isError = Standard_False;
const LDOM_BasicElement * aParent = &myReader->GetElement();
@@ -275,7 +278,7 @@ Standard_Boolean LDOMParser::ParseElement (Standard_IStream& theIStream)
LDOM_Node::NodeType aLocType;
LDOMBasicString aTextValue;
char *aTextStr;
LDOM_XmlReader::RecordType aType = ReadRecord (* myReader, theIStream, myCurrentData);
LDOM_XmlReader::RecordType aType = ReadRecord (* myReader, theIStream, myCurrentData, theDocStart);
switch (aType) {
case LDOM_XmlReader::XML_UNKNOWN:
isError = Standard_True;
@@ -300,7 +303,7 @@ Standard_Boolean LDOMParser::ParseElement (Standard_IStream& theIStream)
myError = "User abort at startElement()";
break;
}
isError = ParseElement (theIStream);
isError = ParseElement (theIStream, theDocStart);
break;
case LDOM_XmlReader::XML_END_ELEMENT:
{

View File

@@ -86,7 +86,7 @@ class LDOMParser
// ---------- PRIVATE METHODS ----------
Standard_Boolean ParseDocument (Standard_IStream& theIStream, const Standard_Boolean theWithoutRoot = Standard_False);
Standard_Boolean ParseElement (Standard_IStream& theIStream);
Standard_Boolean ParseElement (Standard_IStream& theIStream, Standard_Boolean& theDocStart);
// ---------- PRIVATE (PROHIBITED) METHODS ----------

View File

@@ -84,7 +84,8 @@ LDOM_XmlReader::LDOM_XmlReader (
//=======================================================================
LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStream,
LDOM_OSStream& theData)
LDOM_OSStream& theData,
Standard_Boolean& theDocStart)
{
theData.Clear();
myError.Clear();
@@ -93,7 +94,6 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
LDOMBasicString anAttrName, anAttrValue;
char anAttDelimiter = '\0';
Standard_Boolean aHasRead = Standard_False;
Standard_Boolean isFileStart = !myEOF && theIStream.tellg() == std::iostream::pos_type(0);
for(;;) {
// Check if the current file buffer is exhausted
@@ -155,9 +155,9 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
myBuffer[aBytesRest + aNBytes] = '\0';
}
}
if (isFileStart)
if (theDocStart && !myEOF)
{
isFileStart = Standard_False;
theDocStart = Standard_False;
// check for BOM block
Standard_Utf8UChar aFirstChar = Standard_Utf8UChar(myPtr[0]);
switch(aFirstChar) {

View File

@@ -53,17 +53,19 @@ class LDOM_XmlReader
// Constructor - takes a file descriptor for input
// Constructor - takes an std::istream for input
RecordType ReadRecord (Standard_IStream& theIStream, LDOM_OSStream& theData);
RecordType ReadRecord (Standard_IStream& theIStream,
LDOM_OSStream& theData,
Standard_Boolean& theDocStart);
// reading a markup or other element of XML format
LDOM_BasicElement& GetElement () const { return * myElement; }
LDOM_BasicElement& GetElement() const { return * myElement; }
// get the last element retrieved from the stream
void CreateElement (const char *theName, const Standard_Integer theLen);
static Standard_Boolean getInteger (LDOMBasicString& theValue,
const char * theStart,
const char * theEnd);
static Standard_Boolean getInteger (LDOMBasicString& theValue,
const char * theStart,
const char * theEnd);
// try convert string theStart to LDOM_AsciiInteger, return False on success
// Returns the byte order mask defined at the start of a stream

View File

@@ -0,0 +1,34 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_trimmed.brep] s
set ref_values { { 23829.6 171246 13 13 } \
{ 25781.5 196049 14 14 } \
{ 27762.8 222816 14 14 } \
{ 29808.5 251596 12 12 } \
{ 31919.5 282455 12 12 } \
{ 34088.4 315454 12 12 } \
{ 36315.3 350651 12 12 } \
{ 38600 388104 12 12 } \
{ 40942.8 427870 12 12 } \
{ 43343.5 470009 12 12 } \
{ 45802.1 514577 12 12 } \
{ 48318.6 561632 12 12 } \
{ 50893.1 611233 12 12 } \
{ 53525.6 663438 12 12 } \
{ 56215.9 718304 12 12 } \
{ 58964.3 775889 12 12 } \
{ 61770.5 836251 12 12 } \
{ 64634.7 899449 12 12 } \
{ 67556.9 965540 12 12 } \
{ 70537 1.03458e+06 12 12 } }
perform_offset_increasing s 1 20 1 $ref_values
copy r5 result
copy r5_unif result_unif
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 5
offsetperform result
checkprops result -s 3.47344e+06 -v 4.06389e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 962 -face 962 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 8
offsetperform result
checkprops result -s 3.35577e+06 -v 5.12413e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 755 -face 755 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 10
offsetperform result
checkprops result -s 3.1312e+06 -v 5.77267e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 492 -face 492 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 11
offsetperform result
checkprops result -s 2.75287e+06 -v 6.08747e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 234 -face 234 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 13
offsetperform result
checkprops result -s 2.84681e+06 -v 6.64723e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 234 -face 234 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032088: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" join type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32088_input.brep] s
offsetparameter 1e-7 c i r
offsetload s 15
offsetperform result
checkprops result -s 2.7281e+06 -v 7.20465e+07
unifysamedom result_unif result
checknbshapes result_unif -wire 104 -face 104 -shell 1 -solid 1
checkview -display result_unif -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,17 @@
puts "============================================================================================="
puts "0032307: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" Joint type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32307.brep] s
offsetparameter 1e-7 c i r
offsetload s 20
offsetperform result
checkprops result -s 1.29992e+07 -v 8.09132e+08
# number of shapes should not change
checknbshapes result -ref [nbshapes s]
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,24 @@
puts "============================================================================================="
puts "0032307: Modeling Algorithms - Empty result of offset operation in mode \"Complete\" Joint type \"Intersection\""
puts "============================================================================================="
puts ""
restore [locate_data_file bug32307.brep] s
offsetparameter 1e-7 c i r
offsetload s 0
foreach f [explode s f] {
mksurface surf $f
regexp {Axis :([-0-9.+eE]*), ([-0-9.+eE]*), ([-0-9.+eE]*)} [dump surf] full x y z
if {abs($z) > 1.e-7 || (abs($y) < 1.e-7 && abs($x) > 1.e-7)} {
offsetonface $f 20
}
}
offsetperform result
checkprops result -s 1.20298e+07 -v 7.1394e+08
# number of shapes should not change
checknbshapes result -ref [nbshapes s]
checkview -display result -2d -path ${imagedir}/${test_image}.png