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

Compare commits

..

2 Commits

Author SHA1 Message Date
nmanchen
570e4767e6 Merge branch 'master' into CR28720 2022-12-02 05:42:52 +03:00
nmanchen
5c3adda3e9 CR28720: Modeling Algorithms - HLRBrep_PolyAlgo crash with specific shape
1 link update for each new segment
2022-11-17 07:06:13 +03:00
4 changed files with 444 additions and 504 deletions

View File

@@ -37,7 +37,9 @@ Draft_FaceInfo::Draft_FaceInfo (const Handle(Geom_Surface)& S,\
const Standard_Boolean HasNewGeometry):
myNewGeom(HasNewGeometry)
{
myGeom = S;
Handle(Geom_RectangularTrimmedSurface) T = Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
if (!T.IsNull()) myGeom = T->BasisSurface();
else myGeom = S;
}

View File

@@ -481,7 +481,7 @@ Standard_Boolean Draft_Modification::Propagate ()
Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation()));
const Handle(Standard_Type)& typs = S->DynamicType();
if (/*typs == STANDARD_TYPE(Geom_CylindricalSurface) ||*/
if (typs == STANDARD_TYPE(Geom_CylindricalSurface) ||
typs == STANDARD_TYPE(Geom_ConicalSurface)) {
Standard_Real umin,umax,vmin,vmax;
BRepTools::UVBounds(F,umin,umax,vmin,vmax);
@@ -1062,11 +1062,7 @@ void Draft_Modification::Perform ()
//Find the first curve to glue
TColGeom_SequenceOfCurve Candidates;
if (S1->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface) ||
S1->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface) ||
S1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface) &&
Handle(Geom_RectangularTrimmedSurface)::DownCast(S1)->BasisSurface()->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface) ||
S1->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface) &&
Handle(Geom_RectangularTrimmedSurface)::DownCast(S1)->BasisSurface()->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface))
S1->DynamicType() == STANDARD_TYPE(Geom_ConicalSurface))
{
for (i = 1; i <= i2s.NbLines(); i++)
{

View File

@@ -20,7 +20,7 @@
#include <Standard_Stream.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(HLRAlgo_PolyInternalData, Standard_Transient)
#ifdef OCCT_DEBUG
static Standard_Integer HLRAlgo_PolyInternalData_TRACE = Standard_False;
@@ -44,9 +44,9 @@ HLRAlgo_PolyInternalData::HLRAlgo_PolyInternalData
{
Standard_Integer i;
myMxPISeg = 2 + (3 * nbTri + nbNod) / 2;
myTData = new HLRAlgo_HArray1OfTData(0,myMxTData);
myPISeg = new HLRAlgo_HArray1OfPISeg(0,myMxPISeg);
myPINod = new HLRAlgo_HArray1OfPINod(0,myMxPINod);
myTData = new HLRAlgo_HArray1OfTData(0, myMxTData);
myPISeg = new HLRAlgo_HArray1OfPISeg(0, myMxPISeg);
myPINod = new HLRAlgo_HArray1OfPINod(0, myMxPINod);
HLRAlgo_Array1OfPINod& PINod = myPINod->ChangeArray1();
Handle(HLRAlgo_PolyInternalNode)* NN = &(PINod.ChangeValue(1));
@@ -61,28 +61,32 @@ HLRAlgo_PolyInternalData::HLRAlgo_PolyInternalData
//function : UpdateLinks
//purpose :
//=======================================================================
void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
void HLRAlgo_PolyInternalData::UpdateLinks(HLRAlgo_Array1OfTData& theTData,
HLRAlgo_Array1OfPISeg& thePISeg,
HLRAlgo_Array1OfPINod& thePINod)
{
Standard_Integer n1,n2;
Standard_Integer find,iiii,icsv = 0;
Standard_Integer n1, n2;
Standard_Integer find, iiii, icsv = 0;
HLRAlgo_PolyInternalSegment* aSegIndices = NULL;
Standard_Boolean newSeg = Standard_False;
for (Standard_Integer i = 1; i <= myNbTData; i++)
{
HLRAlgo_TriangleData* TD = &theTData.ChangeValue (i);
HLRAlgo_TriangleData* TD = &theTData.ChangeValue(i);
HLRAlgo_PolyInternalNode::NodeIndices& A1 = thePINod.ChangeValue(TD->Node1)->Indices();
HLRAlgo_PolyInternalNode::NodeIndices& A2 = thePINod.ChangeValue(TD->Node2)->Indices();
HLRAlgo_PolyInternalNode::NodeIndices& A3 = thePINod.ChangeValue(TD->Node3)->Indices();
bool notFound = true;
if (notFound)
{
n1 = TD->Node1;
n2 = TD->Node2;
newSeg = Standard_False;
if (A1.NdSg == 0 && A2.NdSg == 0) {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
A1.NdSg = myNbPISeg;
@@ -94,7 +98,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
find = 0;
while (iiii != 0 && find == 0) {
aSegIndices = &thePISeg.ChangeValue (iiii);
aSegIndices = &thePISeg.ChangeValue(iiii);
if (aSegIndices->LstSg1 == n1) {
if (aSegIndices->LstSg2 == n2) find = iiii;
else iiii = aSegIndices->NxtSg1;
@@ -107,6 +111,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (find == 0) {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
if (icsv == 1) aSegIndices->NxtSg1 = myNbPISeg;
@@ -115,6 +120,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
else aSegIndices->Conex2 = i;
}
else {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
A1.NdSg = myNbPISeg;
@@ -124,7 +130,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
if (iiii != 0) {
while (iiii != 0) {
aSegIndices = &thePISeg.ChangeValue (iiii);
aSegIndices = &thePISeg.ChangeValue(iiii);
if (aSegIndices->LstSg1 == n2) { icsv = 1; iiii = aSegIndices->NxtSg1; }
else { icsv = 2; iiii = aSegIndices->NxtSg2; }
}
@@ -135,7 +141,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (newSeg) {
aSegIndices = &thePISeg.ChangeValue (myNbPISeg);
aSegIndices = &thePISeg.ChangeValue(myNbPISeg);
aSegIndices->LstSg1 = n1;
aSegIndices->LstSg2 = n2;
aSegIndices->Conex1 = i;
@@ -145,11 +151,13 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (notFound)
{
n1 = TD->Node2;
n2 = TD->Node3;
newSeg = Standard_False;
if (A2.NdSg == 0 && A3.NdSg == 0) {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
A2.NdSg = myNbPISeg;
@@ -161,7 +169,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
find = 0;
while (iiii != 0 && find == 0) {
aSegIndices = &thePISeg.ChangeValue (iiii);
aSegIndices = &thePISeg.ChangeValue(iiii);
if (aSegIndices->LstSg1 == n1) {
if (aSegIndices->LstSg2 == n2) find = iiii;
else iiii = aSegIndices->NxtSg1;
@@ -174,6 +182,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (find == 0) {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
if (icsv == 1) aSegIndices->NxtSg1 = myNbPISeg;
@@ -182,6 +191,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
else aSegIndices->Conex2 = i;
}
else {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
A2.NdSg = myNbPISeg;
@@ -191,7 +201,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
if (iiii != 0) {
while (iiii != 0) {
aSegIndices = &thePISeg.ChangeValue (iiii);
aSegIndices = &thePISeg.ChangeValue(iiii);
if (aSegIndices->LstSg1 == n2) { icsv = 1; iiii = aSegIndices->NxtSg1; }
else { icsv = 2; iiii = aSegIndices->NxtSg2; }
}
@@ -202,7 +212,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (newSeg) {
aSegIndices = &thePISeg.ChangeValue (myNbPISeg);
aSegIndices = &thePISeg.ChangeValue(myNbPISeg);
aSegIndices->LstSg1 = n1;
aSegIndices->LstSg2 = n2;
aSegIndices->Conex1 = i;
@@ -212,11 +222,13 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (notFound)
{
n1 = TD->Node3;
n2 = TD->Node1;
newSeg = Standard_False;
if (A3.NdSg == 0 && A1.NdSg == 0) {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
A3.NdSg = myNbPISeg;
@@ -228,7 +240,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
find = 0;
while (iiii != 0 && find == 0) {
aSegIndices = &thePISeg.ChangeValue (iiii);
aSegIndices = &thePISeg.ChangeValue(iiii);
if (aSegIndices->LstSg1 == n1) {
if (aSegIndices->LstSg2 == n2) find = iiii;
else iiii = aSegIndices->NxtSg1;
@@ -241,6 +253,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (find == 0) {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
if (icsv == 1) aSegIndices->NxtSg1 = myNbPISeg;
@@ -249,6 +262,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
else aSegIndices->Conex2 = i;
}
else {
notFound = false;
newSeg = Standard_True;
myNbPISeg++;
A3.NdSg = myNbPISeg;
@@ -258,7 +272,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
if (iiii != 0) {
while (iiii != 0) {
aSegIndices = &thePISeg.ChangeValue (iiii);
aSegIndices = &thePISeg.ChangeValue(iiii);
if (aSegIndices->LstSg1 == n2) { icsv = 1; iiii = aSegIndices->NxtSg1; }
else { icsv = 2; iiii = aSegIndices->NxtSg2; }
}
@@ -269,7 +283,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
}
}
if (newSeg) {
aSegIndices = &thePISeg.ChangeValue (myNbPISeg);
aSegIndices = &thePISeg.ChangeValue(myNbPISeg);
aSegIndices->LstSg1 = n1;
aSegIndices->LstSg2 = n2;
aSegIndices->Conex1 = i;
@@ -285,7 +299,7 @@ void HLRAlgo_PolyInternalData::UpdateLinks (HLRAlgo_Array1OfTData& theTData,
//function : AddNode
//purpose :
//=======================================================================
Standard_Integer HLRAlgo_PolyInternalData::AddNode (HLRAlgo_PolyInternalNode::NodeData& theNod1RValues,
Standard_Integer HLRAlgo_PolyInternalData::AddNode(HLRAlgo_PolyInternalNode::NodeData& theNod1RValues,
HLRAlgo_PolyInternalNode::NodeData& theNod2RValues,
HLRAlgo_Array1OfPINod*& thePINod1,
HLRAlgo_Array1OfPINod*& thePINod2,
@@ -295,7 +309,7 @@ Standard_Integer HLRAlgo_PolyInternalData::AddNode (HLRAlgo_PolyInternalNode::No
const Standard_Real theZ3)
{
Standard_Real coef2 = 1 - theCoef1;
IncPINod (thePINod1, thePINod2);
IncPINod(thePINod1, thePINod2);
Standard_Integer ip3 = myNbPINod;
Handle(HLRAlgo_PolyInternalNode)& pip3 = thePINod1->ChangeValue(ip3);
pip3 = new HLRAlgo_PolyInternalNode();
@@ -303,7 +317,7 @@ Standard_Integer HLRAlgo_PolyInternalData::AddNode (HLRAlgo_PolyInternalNode::No
HLRAlgo_PolyInternalNode::NodeIndices& aNodeIndices = pip3->Indices();
aNodeIndices.NdSg = 0;
aNodeIndices.Flag = 0;
Nod3RValues.Point = gp_XYZ (theX3, theY3, theZ3);
Nod3RValues.Point = gp_XYZ(theX3, theY3, theZ3);
Nod3RValues.UV = coef2 * theNod1RValues.UV + theCoef1 * theNod2RValues.UV;
Nod3RValues.Scal = theNod1RValues.Scal * coef2 + theNod2RValues.Scal * theCoef1;
const gp_XYZ aXYZ = coef2 * theNod1RValues.Normal + theCoef1 * theNod2RValues.Normal;
@@ -328,7 +342,7 @@ Standard_Integer HLRAlgo_PolyInternalData::AddNode (HLRAlgo_PolyInternalNode::No
//=======================================================================
void
HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
HLRAlgo_PolyInternalData::UpdateLinks(const Standard_Integer ip1,
const Standard_Integer ip2,
const Standard_Integer ip3,
HLRAlgo_Array1OfTData*& TData1,
@@ -336,21 +350,21 @@ HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
HLRAlgo_Array1OfPISeg*& PISeg1,
HLRAlgo_Array1OfPISeg*& PISeg2,
HLRAlgo_Array1OfPINod*& PINod1,
HLRAlgo_Array1OfPINod*& )
HLRAlgo_Array1OfPINod*&)
{
Standard_Integer find,iiii,iisv,icsv,iip2 =0,cnx1 =0,cnx2 =0;
Standard_Integer find, iiii, iisv, icsv, iip2 = 0, cnx1 = 0, cnx2 = 0;
HLRAlgo_PolyInternalSegment* aSegIndices = NULL;
HLRAlgo_PolyInternalSegment* aSegIndices2 = NULL;
find = 0;
iisv = 0;
icsv = 0;
IncPISeg(PISeg1,PISeg2);
IncPISeg(PISeg1,PISeg2);
IncPISeg(PISeg1,PISeg2);
IncPISeg(PISeg1, PISeg2);
IncPISeg(PISeg1, PISeg2);
IncPISeg(PISeg1, PISeg2);
myNbPISeg--;
myNbPISeg--;
IncTData(TData1,TData2);
IncTData(TData1,TData2);
IncTData(TData1, TData2);
IncTData(TData1, TData2);
myNbTData--;
myNbTData--;
HLRAlgo_PolyInternalNode::NodeIndices* aNodIndices1 =
@@ -420,8 +434,8 @@ HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
aSegIndices2->Conex2 = cnx2;
aNodIndices3.NdSg = find;
Standard_Integer iOld,iNew,iTr,skip,ip4,itpk[2];
Standard_Integer n1,n2,n3,nOld[3],nNew[3],New[4];
Standard_Integer iOld, iNew, iTr, skip, ip4, itpk[2];
Standard_Integer n1, n2, n3, nOld[3], nNew[3], New[4];
New[0] = cnx1;
New[2] = myNbTData + 1;
if (cnx2 == 0) {
@@ -518,10 +532,10 @@ HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
}
for (iTr = 0; iTr <= 3; iTr++) {
iNew = New [iTr];
iNew = New[iTr];
if (iTr < 2) skip = iTr;
else skip = iTr - 2;
iOld = New [skip];
iOld = New[skip];
ip4 = itpk[skip];
if (iNew != 0) {
HLRAlgo_TriangleData& aTriangle2 = TData1->ChangeValue(iNew);
@@ -619,7 +633,7 @@ HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
//purpose :
//=======================================================================
void HLRAlgo_PolyInternalData::Dump () const
void HLRAlgo_PolyInternalData::Dump() const
{
Standard_Integer i;//,i1,i2,i3;
HLRAlgo_Array1OfTData* TData = &myTData->ChangeArray1();
@@ -632,9 +646,9 @@ void HLRAlgo_PolyInternalData::Dump () const
HLRAlgo_PolyInternalNode::NodeData& Nod1RValues = (*pi)->Data();
std::cout << "Node " << std::setw(6) << i << " : ";
std::cout << std::setw(6) << aNodIndices1.NdSg;
std::cout << std::setw(20)<< Nod1RValues.Point.X();
std::cout << std::setw(20)<< Nod1RValues.Point.Y();
std::cout << std::setw(20)<< Nod1RValues.Point.Z();
std::cout << std::setw(20) << Nod1RValues.Point.X();
std::cout << std::setw(20) << Nod1RValues.Point.Y();
std::cout << std::setw(20) << Nod1RValues.Point.Z();
std::cout << std::endl;
}
@@ -673,12 +687,12 @@ void HLRAlgo_PolyInternalData::IncTData(
if (HLRAlgo_PolyInternalData_TRACE)
std::cout << "HLRAlgo_PolyInternalData::IncTData : " << myMxTData << std::endl;
#endif
Standard_Integer i,j,k;
Standard_Integer i, j, k;
j = myMxTData;
k = 2 * j;
Handle(HLRAlgo_HArray1OfTData) NwTData =
new HLRAlgo_HArray1OfTData(0,k);
new HLRAlgo_HArray1OfTData(0, k);
HLRAlgo_Array1OfTData& oTData = myTData->ChangeArray1();
HLRAlgo_Array1OfTData& nTData = NwTData->ChangeArray1();
@@ -712,11 +726,11 @@ void HLRAlgo_PolyInternalData::IncPISeg(
if (HLRAlgo_PolyInternalData_TRACE)
std::cout << "HLRAlgo_PolyInternalData::IncPISeg : " << myMxPISeg << std::endl;
#endif
Standard_Integer i,j,k;
Standard_Integer i, j, k;
j = myMxPISeg;
k = 2 * j;
Handle(HLRAlgo_HArray1OfPISeg) NwPISeg =
new HLRAlgo_HArray1OfPISeg(0,k);
new HLRAlgo_HArray1OfPISeg(0, k);
HLRAlgo_Array1OfPISeg& oPISeg = myPISeg->ChangeArray1();
HLRAlgo_Array1OfPISeg& nPISeg = NwPISeg->ChangeArray1();
@@ -741,7 +755,7 @@ void HLRAlgo_PolyInternalData::IncPISeg(
//function : IncPINod
//purpose :
//=======================================================================
void HLRAlgo_PolyInternalData::IncPINod (HLRAlgo_Array1OfPINod*& PINod1,
void HLRAlgo_PolyInternalData::IncPINod(HLRAlgo_Array1OfPINod*& PINod1,
HLRAlgo_Array1OfPINod*& PINod2)
{
if (myNbPINod >= myMxPINod)
@@ -750,10 +764,10 @@ void HLRAlgo_PolyInternalData::IncPINod (HLRAlgo_Array1OfPINod*& PINod1,
if (HLRAlgo_PolyInternalData_TRACE)
std::cout << "HLRAlgo_PolyInternalData::IncPINod : " << myMxPINod << std::endl;
#endif
Standard_Integer i,j,k;
Standard_Integer i, j, k;
j = myMxPINod;
k = 2 * j;
Handle(HLRAlgo_HArray1OfPINod) NwPINod = new HLRAlgo_HArray1OfPINod(0,k);
Handle(HLRAlgo_HArray1OfPINod) NwPINod = new HLRAlgo_HArray1OfPINod(0, k);
HLRAlgo_Array1OfPINod& oPINod = myPINod->ChangeArray1();
HLRAlgo_Array1OfPINod& nPINod = NwPINod->ChangeArray1();
Handle(HLRAlgo_PolyInternalNode)* ON = &(oPINod.ChangeValue(1));

View File

@@ -1,72 +0,0 @@
puts "================"
puts "0032857: Problem when finding the intersection between a new face made after a draft and the inner face of body"
puts "================"
puts ""
# Script reproducing the problematic draft case in FreeCAD issue #2497
#Category: Modeling
#Title: OCCT Tutorial pocketed ring
pload MODELING VISUALIZATION
# Set basic dimensions. Problems appear when inner_rad < pocket_center.
dset height 10
dset inner_rad 39
dset outer_rad 50
dset pocket_center 40
dset pocket_rad 20
dset pocket_depth 5
# Construct base profile (the "my_ring")
puts "Constructing my_ring..."
circle c_inner 0 0 0 0 0 1 inner_rad
circle c_outer 0 0 0 0 0 1 outer_rad
mkedge e_inner c_inner
mkedge e_outer c_outer
wire w_inner e_inner
wire w_outer e_outer
plane p0
mkface my_ring_inner_base p0 w_inner
mkface my_ring_outer_base p0 w_outer
prism my_ring_inner my_ring_inner_base 0 0 height
prism my_ring_outer my_ring_outer_base 0 0 height
bcut my_ring my_ring_outer my_ring_inner
# Make the pocket
puts "Constructing pocket..."
circle pocket_base pocket_center 0 0 0 0 1 pocket_rad
mkedge pocket_base pocket_base
wire pocket_base pocket_base
mkface pocket_base p0 pocket_base
prism my_pocket pocket_base 0 0 pocket_depth
# Make the cut
puts "Making the cut"
bcut slotted_ring my_ring my_pocket
explode slotted_ring F
# Make the draft
puts "Drafting the face"
# Found face by trial and error: slotted_ring_3
# Perform the draft
depouille slotted_ring_with_draft slotted_ring 0 0 -1 slotted_ring_3 44 0 1 0 0 0 1
#checking result
checkshape slotted_ring_with_draft
checknbshapes slotted_ring_with_draft -shape 48 -vertex 12 -edge 18 -face 7 -wire 8
checkprops slotted_ring_with_draft -s 11466.5 -v 28662.9
puts "Showing result..."
# Display result
checkview -display slotted_ring_with_draft -2d -path ${imagedir}/${test_image}.png