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

0025926: 3D offset in mode "Complete" with Join type "Intersection"

3D offset algorithm extension for degenerate (colliding) cases.
This commit is contained in:
emv
2015-06-04 10:53:22 +03:00
parent 1ed0e5502e
commit 999dacb4d0
4 changed files with 2974 additions and 2084 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -49,8 +49,8 @@
//=======================================================================
BRepOffset_Inter3d::BRepOffset_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes,
const TopAbs_State Side ,
const Standard_Real Tol)
const TopAbs_State Side ,
const Standard_Real Tol)
:myAsDes(AsDes),
mySide(Side),
myTol(Tol)
@@ -64,8 +64,8 @@ myTol(Tol)
//=======================================================================
static void ExtentEdge(const TopoDS_Face& /*F*/,
const TopoDS_Edge& E,
TopoDS_Edge& NE)
const TopoDS_Edge& E,
TopoDS_Edge& NE)
{
TopoDS_Shape aLocalShape = E.EmptyCopied();
NE = TopoDS::Edge(aLocalShape);
@@ -99,9 +99,9 @@ static void ExtentEdge(const TopoDS_Face& /*F*/,
//=======================================================================
static void SelectEdge (const TopoDS_Face& /*F*/,
const TopoDS_Face& /*EF*/,
const TopoDS_Edge& E,
TopTools_ListOfShape& LInt)
const TopoDS_Face& /*EF*/,
const TopoDS_Edge& E,
TopTools_ListOfShape& LInt)
{
//------------------------------------------------------------
// Proofing on the intersections on periodical faces
@@ -145,14 +145,14 @@ static void SelectEdge (const TopoDS_Face& /*F*/,
anExt.Perform(PFirst);
if (anExt.IsDone()) {
for (i = 1; i <= anExt.NbExt(); i++) {
if (anExt.IsMin(i)) {
const gp_Pnt &aPMin = anExt.Point(i).Value();
if (anExt.IsMin(i)) {
const gp_Pnt &aPMin = anExt.Point(i).Value();
aSqrDist1 = PFirst.SquareDistance(aPMin);
isMinFound = Standard_True;
aSqrDist1 = PFirst.SquareDistance(aPMin);
isMinFound = Standard_True;
break;
}
break;
}
}
}
if (!isMinFound) {
@@ -167,14 +167,14 @@ static void SelectEdge (const TopoDS_Face& /*F*/,
anExt.Perform(PLast);
if (anExt.IsDone()) {
for (i = 1; i <= anExt.NbExt(); i++) {
if (anExt.IsMin(i)) {
const gp_Pnt &aPMin = anExt.Point(i).Value();
if (anExt.IsMin(i)) {
const gp_Pnt &aPMin = anExt.Point(i).Value();
aSqrDist2 = PLast.SquareDistance(aPMin);
isMinFound = Standard_True;
aSqrDist2 = PLast.SquareDistance(aPMin);
isMinFound = Standard_True;
break;
}
break;
}
}
}
if (!isMinFound) {
@@ -207,7 +207,7 @@ static void SelectEdge (const TopoDS_Face& /*F*/,
//=======================================================================
void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
const BRepAlgo_Image& InitOffsetFace)
const BRepAlgo_Image& InitOffsetFace)
{
//---------------------------------------------------------------
// Calculate the intersections of offset faces
@@ -250,8 +250,8 @@ void BRepOffset_Inter3d::CompletInt(const TopTools_ListOfShape& SetOfFaces,
//=======================================================================
void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
const TopoDS_Face& F2,
const BRepAlgo_Image& InitOffsetFace)
const TopoDS_Face& F2,
const BRepAlgo_Image& InitOffsetFace)
{
TopTools_ListOfShape LInt1, LInt2;
TopoDS_Edge NullEdge;
@@ -261,9 +261,9 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
const TopoDS_Shape& InitF1 = InitOffsetFace.ImageFrom(F1);
const TopoDS_Shape& InitF2 = InitOffsetFace.ImageFrom(F2);
Standard_Boolean InterPipes = (InitF2.ShapeType() == TopAbs_EDGE &&
InitF1.ShapeType() == TopAbs_EDGE );
InitF1.ShapeType() == TopAbs_EDGE );
Standard_Boolean InterFaces = (InitF1.ShapeType() == TopAbs_FACE &&
InitF2.ShapeType() == TopAbs_FACE);
InitF2.ShapeType() == TopAbs_FACE);
TopTools_ListOfShape LE,LV;
LInt1.Clear(); LInt2.Clear();
if (BRepOffset_Tool::HasCommonShapes(F1,F2,LE,LV) ||
@@ -273,38 +273,44 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
//-------------------------------------------------
if ( LE.IsEmpty() && !LV.IsEmpty()) {
if (InterPipes) {
//----------------------
// tubes share a vertex.
//----------------------
const TopoDS_Edge& EE1 = TopoDS::Edge(InitF1);
const TopoDS_Edge& EE2 = TopoDS::Edge(InitF2);
TopoDS_Vertex VE1[2],VE2[2];
TopExp::Vertices(EE1,VE1[0],VE1[1]);
TopExp::Vertices(EE2,VE2[0],VE2[1]);
TopoDS_Vertex V;
for (Standard_Integer i = 0 ; i < 2; i++) {
for (Standard_Integer j = 0 ; j < 2; j++) {
if (VE1[i].IsSame(VE2[j])) {
V = VE1[i];
}
}
}
if (!InitOffsetFace.HasImage(V)) { //no sphere
BRepOffset_Tool::PipeInter(F1,F2,LInt1,LInt2,mySide);
}
//----------------------
// tubes share a vertex.
//----------------------
const TopoDS_Edge& EE1 = TopoDS::Edge(InitF1);
const TopoDS_Edge& EE2 = TopoDS::Edge(InitF2);
TopoDS_Vertex VE1[2],VE2[2];
TopExp::Vertices(EE1,VE1[0],VE1[1]);
TopExp::Vertices(EE2,VE2[0],VE2[1]);
TopoDS_Vertex V;
for (Standard_Integer i = 0 ; i < 2; i++) {
for (Standard_Integer j = 0 ; j < 2; j++) {
if (VE1[i].IsSame(VE2[j])) {
V = VE1[i];
}
}
}
if (!InitOffsetFace.HasImage(V)) { //no sphere
BRepOffset_Tool::PipeInter(F1,F2,LInt1,LInt2,mySide);
}
}
else {
//--------------------------------------------------------
// Intersection having only common vertices
// and supports having common edges.
// UNSUFFICIENT, but a larger criterion shakes too
// many sections.
//--------------------------------------------------------
if (InterFaces &&
BRepOffset_Tool::HasCommonShapes(TopoDS::Face(InitF1),
TopoDS::Face(InitF2),LE,LV))
if (!LE.IsEmpty())
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
//--------------------------------------------------------
// Intersection having only common vertices
// and supports having common edges.
// UNSUFFICIENT, but a larger criterion shakes too
// many sections.
//--------------------------------------------------------
if (InterFaces) {
if (BRepOffset_Tool::HasCommonShapes(TopoDS::Face(InitF1),
TopoDS::Face(InitF2),LE,LV)) {
if (!LE.IsEmpty()) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
}
}
else {
BRepOffset_Tool::Inter3D(F1,F2,LInt1,LInt2,mySide,NullEdge);
}
}
}
}
}
@@ -350,13 +356,13 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
//-----------------------------------------------------------
const TopTools_ListOfShape& Anc = Analyse.Ancestors(E);
if (Anc.Extent() == 2) {
F1 = TopoDS::Face(InitOffsetFace.Image(Anc.First()).First());
F2 = TopoDS::Face(InitOffsetFace.Image(Anc.Last ()).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,E,Standard_True);
Store (F1,F2,LInt1,LInt2);
}
}
F1 = TopoDS::Face(InitOffsetFace.Image(Anc.First()).First());
F2 = TopoDS::Face(InitOffsetFace.Image(Anc.Last ()).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,E,Standard_True);
Store (F1,F2,LInt1,LInt2);
}
}
}
}
//---------------------------------------------------------------------
@@ -378,84 +384,84 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
const TopTools_ListOfShape& AncE1 = Analyse.Ancestors(E1);
for (Standard_Integer i = 0; i < 2; i++) {
if (!InitOffsetFace.HasImage(V[i])) {
//-----------------------------
// the vertex has no sphere.
//-----------------------------
const TopTools_ListOfShape& Anc = Analyse.Ancestors(V[i]);
TopTools_ListOfShape TangOnV;
Analyse.TangentEdges(E1,V[i],TangOnV);
TopTools_MapOfShape MTEV;
for (it.Initialize(TangOnV); it.More(); it.Next()) {
MTEV.Add(it.Value());
}
for (it.Initialize(Anc); it.More(); it.Next()) {
const TopoDS_Edge& E2 = TopoDS::Edge(it.Value());
if (!InitOffsetFace.HasImage(V[i])) {
//-----------------------------
// the vertex has no sphere.
//-----------------------------
const TopTools_ListOfShape& Anc = Analyse.Ancestors(V[i]);
TopTools_ListOfShape TangOnV;
Analyse.TangentEdges(E1,V[i],TangOnV);
TopTools_MapOfShape MTEV;
for (it.Initialize(TangOnV); it.More(); it.Next()) {
MTEV.Add(it.Value());
}
for (it.Initialize(Anc); it.More(); it.Next()) {
const TopoDS_Edge& E2 = TopoDS::Edge(it.Value());
// Modified by skv - Fri Jan 16 16:27:54 2004 OCC4455 Begin
// if (E1.IsSame(E2) || MTEV.Contains(E2)) continue;
Standard_Boolean isToSkip = Standard_False;
// if (E1.IsSame(E2) || MTEV.Contains(E2)) continue;
Standard_Boolean isToSkip = Standard_False;
if (!E1.IsSame(E2)) {
const BRepOffset_ListOfInterval& aL = Analyse.Type(E2);
if (!E1.IsSame(E2)) {
const BRepOffset_ListOfInterval& aL = Analyse.Type(E2);
isToSkip = (MTEV.Contains(E2) &&
(aL.IsEmpty() ||
(!aL.IsEmpty() && aL.First().Type() != OT)));
}
isToSkip = (MTEV.Contains(E2) &&
(aL.IsEmpty() ||
(!aL.IsEmpty() && aL.First().Type() != OT)));
}
if (E1.IsSame(E2) || isToSkip)
continue;
if (E1.IsSame(E2) || isToSkip)
continue;
// Modified by skv - Fri Jan 16 16:27:54 2004 OCC4455 End
if (InitOffsetFace.HasImage(E2)) {
//-----------------------------
// E2 generated a tube.
//-----------------------------
F2 = TopoDS::Face(InitOffsetFace.Image(E2).First());
if (!IsDone(F1,F2)) {
//---------------------------------------------------------------------
// Intersection tube/tube if the edges are not tangent (AFINIR).
//----------------------------------------------------------------------
BRepOffset_Tool::PipeInter (F1,F2,LInt1,LInt2,mySide);
Store (F1,F2,LInt1,LInt2);
}
}
else {
//-------------------------------------------------------
// Intersection of the tube of E1 with faces //
// to face containing E2 if they are not tangent
// to the tube or if E2 is not a tangent edge.
//-------------------------------------------------------
const BRepOffset_ListOfInterval& L = Analyse.Type(E2);
if (!L.IsEmpty() && L.First().Type() == BRepOffset_Tangent) {
continue;
}
const TopTools_ListOfShape& AncE2 = Analyse.Ancestors(E2);
Standard_Boolean TangentFaces = Standard_False;
if (AncE2.Extent() == 2) {
TopoDS_Face InitF2 = TopoDS::Face(AncE2.First ());
TangentFaces = (InitF2.IsSame(AncE1.First()) ||
InitF2.IsSame(AncE1.Last()));
if (!TangentFaces) {
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
Store (F1,F2,LInt1,LInt2);
}
}
InitF2 = TopoDS::Face(AncE2.Last ());
TangentFaces = (InitF2.IsSame(AncE1.First()) ||
InitF2.IsSame(AncE1.Last()));
if (!TangentFaces) {
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
Store (F1,F2,LInt1,LInt2);
}
}
}
}
}
}
if (InitOffsetFace.HasImage(E2)) {
//-----------------------------
// E2 generated a tube.
//-----------------------------
F2 = TopoDS::Face(InitOffsetFace.Image(E2).First());
if (!IsDone(F1,F2)) {
//---------------------------------------------------------------------
// Intersection tube/tube if the edges are not tangent (AFINIR).
//----------------------------------------------------------------------
BRepOffset_Tool::PipeInter (F1,F2,LInt1,LInt2,mySide);
Store (F1,F2,LInt1,LInt2);
}
}
else {
//-------------------------------------------------------
// Intersection of the tube of E1 with faces //
// to face containing E2 if they are not tangent
// to the tube or if E2 is not a tangent edge.
//-------------------------------------------------------
const BRepOffset_ListOfInterval& L = Analyse.Type(E2);
if (!L.IsEmpty() && L.First().Type() == BRepOffset_Tangent) {
continue;
}
const TopTools_ListOfShape& AncE2 = Analyse.Ancestors(E2);
Standard_Boolean TangentFaces = Standard_False;
if (AncE2.Extent() == 2) {
TopoDS_Face InitF2 = TopoDS::Face(AncE2.First ());
TangentFaces = (InitF2.IsSame(AncE1.First()) ||
InitF2.IsSame(AncE1.Last()));
if (!TangentFaces) {
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
Store (F1,F2,LInt1,LInt2);
}
}
InitF2 = TopoDS::Face(AncE2.Last ());
TangentFaces = (InitF2.IsSame(AncE1.First()) ||
InitF2.IsSame(AncE1.Last()));
if (!TangentFaces) {
F2 = TopoDS::Face(InitOffsetFace.Image(InitF2).First());
if (!IsDone(F1,F2)) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
Store (F1,F2,LInt1,LInt2);
}
}
}
}
}
}
}
}
}
@@ -491,87 +497,87 @@ void BRepOffset_Inter3d::ConnexIntByInt
if (!L.IsEmpty()) {
BRepOffset_Type OT = L.First().Type();
if (OT == BRepOffset_Convex || OT == BRepOffset_Concave) {
if (OT == BRepOffset_Concave) CurSide = TopAbs_IN;
else CurSide = TopAbs_OUT;
//-----------------------------------------------------------
// edge is of the proper type, return adjacent faces.
//-----------------------------------------------------------
const TopTools_ListOfShape& Anc = Analyse.Ancestors(E);
if (Anc.Extent() != 2) continue;
F1 = TopoDS::Face(Anc.First());
F2 = TopoDS::Face(Anc.Last ());
OF1 = TopoDS::Face(MapSF(F1).Face()); OF2 = TopoDS::Face(MapSF(F2).Face());
if (!MES.IsBound(OF1)) {
Standard_Boolean enlargeU = Standard_True;
Standard_Boolean enlargeVfirst = Standard_True, enlargeVlast = Standard_True;
BRepOffset_Tool::CheckBounds( F1, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
BRepOffset_Tool::EnLargeFace(OF1,NF1,Standard_True,Standard_True,enlargeU,enlargeVfirst,enlargeVlast);
MES.Bind(OF1,NF1);
}
else {
NF1 = TopoDS::Face(MES(OF1));
}
if (!MES.IsBound(OF2)) {
Standard_Boolean enlargeU = Standard_True;
Standard_Boolean enlargeVfirst = Standard_True, enlargeVlast = Standard_True;
BRepOffset_Tool::CheckBounds( F2, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
BRepOffset_Tool::EnLargeFace(OF2,NF2,Standard_True,Standard_True,enlargeU,enlargeVfirst,enlargeVlast);
MES.Bind(OF2,NF2);
}
else {
NF2 = TopoDS::Face(MES(OF2));
}
if (!IsDone(NF1,NF2)) {
TopTools_ListOfShape LInt1,LInt2;
BRepOffset_Tool::Inter3D (NF1,NF2,LInt1,LInt2,CurSide,E,Standard_True);
if (LInt1.Extent() > 1)
{
// intersection is in seceral edges (free sewing)
SelectEdge( NF1, NF2, E, LInt1 );
SelectEdge( NF1, NF2, E, LInt2 );
}
SetDone(NF1,NF2);
if (!LInt1.IsEmpty()) {
Store (NF1,NF2,LInt1,LInt2);
TopoDS_Compound C;
B.MakeCompound(C);
for (it.Initialize(LInt1) ; it.More(); it.Next()) {
B.Add(C,it.Value());
}
Build.Bind(E,C);
}
else {
Failed.Append(E);
}
} else { // IsDone(NF1,NF2)
// Modified by skv - Fri Dec 26 12:20:13 2003 OCC4455 Begin
const TopTools_ListOfShape &aLInt1 = myAsDes->Descendant(NF1);
const TopTools_ListOfShape &aLInt2 = myAsDes->Descendant(NF2);
if (OT == BRepOffset_Concave) CurSide = TopAbs_IN;
else CurSide = TopAbs_OUT;
//-----------------------------------------------------------
// edge is of the proper type, return adjacent faces.
//-----------------------------------------------------------
const TopTools_ListOfShape& Anc = Analyse.Ancestors(E);
if (Anc.Extent() != 2) continue;
F1 = TopoDS::Face(Anc.First());
F2 = TopoDS::Face(Anc.Last ());
OF1 = TopoDS::Face(MapSF(F1).Face()); OF2 = TopoDS::Face(MapSF(F2).Face());
if (!MES.IsBound(OF1)) {
Standard_Boolean enlargeU = Standard_True;
Standard_Boolean enlargeVfirst = Standard_True, enlargeVlast = Standard_True;
BRepOffset_Tool::CheckBounds( F1, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
BRepOffset_Tool::EnLargeFace(OF1,NF1,Standard_True,Standard_True,enlargeU,enlargeVfirst,enlargeVlast);
MES.Bind(OF1,NF1);
}
else {
NF1 = TopoDS::Face(MES(OF1));
}
if (!MES.IsBound(OF2)) {
Standard_Boolean enlargeU = Standard_True;
Standard_Boolean enlargeVfirst = Standard_True, enlargeVlast = Standard_True;
BRepOffset_Tool::CheckBounds( F2, Analyse, enlargeU, enlargeVfirst, enlargeVlast );
BRepOffset_Tool::EnLargeFace(OF2,NF2,Standard_True,Standard_True,enlargeU,enlargeVfirst,enlargeVlast);
MES.Bind(OF2,NF2);
}
else {
NF2 = TopoDS::Face(MES(OF2));
}
if (!IsDone(NF1,NF2)) {
TopTools_ListOfShape LInt1,LInt2;
BRepOffset_Tool::Inter3D (NF1,NF2,LInt1,LInt2,CurSide,E,Standard_True);
if (LInt1.Extent() > 1)
{
// intersection is in seceral edges (free sewing)
SelectEdge( NF1, NF2, E, LInt1 );
SelectEdge( NF1, NF2, E, LInt2 );
}
SetDone(NF1,NF2);
if (!LInt1.IsEmpty()) {
Store (NF1,NF2,LInt1,LInt2);
TopoDS_Compound C;
B.MakeCompound(C);
for (it.Initialize(LInt1) ; it.More(); it.Next()) {
B.Add(C,it.Value());
}
Build.Bind(E,C);
}
else {
Failed.Append(E);
}
} else { // IsDone(NF1,NF2)
// Modified by skv - Fri Dec 26 12:20:13 2003 OCC4455 Begin
const TopTools_ListOfShape &aLInt1 = myAsDes->Descendant(NF1);
const TopTools_ListOfShape &aLInt2 = myAsDes->Descendant(NF2);
if (!aLInt1.IsEmpty()) {
TopoDS_Compound C;
TopTools_ListIteratorOfListOfShape anIt2;
if (!aLInt1.IsEmpty()) {
TopoDS_Compound C;
TopTools_ListIteratorOfListOfShape anIt2;
B.MakeCompound(C);
B.MakeCompound(C);
for (it.Initialize(aLInt1) ; it.More(); it.Next()) {
const TopoDS_Shape &anE1 = it.Value();
for (it.Initialize(aLInt1) ; it.More(); it.Next()) {
const TopoDS_Shape &anE1 = it.Value();
for (anIt2.Initialize(aLInt2) ; anIt2.More(); anIt2.Next()) {
const TopoDS_Shape &anE2 = anIt2.Value();
for (anIt2.Initialize(aLInt2) ; anIt2.More(); anIt2.Next()) {
const TopoDS_Shape &anE2 = anIt2.Value();
if (anE1.IsSame(anE2))
B.Add(C, anE1);
}
}
Build.Bind(E,C);
}
else {
Failed.Append(E);
}
}
// Modified by skv - Fri Dec 26 12:20:14 2003 OCC4455 End
}
if (anE1.IsSame(anE2))
B.Add(C, anE1);
}
}
Build.Bind(E,C);
}
else {
Failed.Append(E);
}
}
// Modified by skv - Fri Dec 26 12:20:14 2003 OCC4455 End
}
}
}
}
@@ -616,48 +622,48 @@ void BRepOffset_Inter3d::ContextIntByInt
else WCF = CF;
for (exp.Init(CF.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
exp.More(); exp.Next()) {
exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
if (!Analyse.HasAncestor(E)) {
//----------------------------------------------------------------
// the edges of faces of context that are not in the initial shape
// can appear in the result.
//----------------------------------------------------------------
if (!ExtentContext) {
myAsDes->Add(CF,E);
myNewEdges.Add(E);
}
else {
if (!MES.IsBound(E)) {
TopoDS_Edge NE;
Standard_Real f,l,Tol;
BRep_Tool::Range(E,f,l);
Tol = BRep_Tool::Tolerance(E);
ExtentEdge(CF,E,NE);
TopoDS_Vertex V1,V2;
TopExp::Vertices(E,V1,V2);
NE.Orientation(TopAbs_FORWARD);
myAsDes->Add(NE,V1.Oriented(TopAbs_REVERSED));
myAsDes->Add(NE,V2.Oriented(TopAbs_FORWARD));
TopoDS_Shape aLocalShape = V1.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),f,NE,Tol);
aLocalShape = V2.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),l,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V1.Oriented(TopAbs_INTERNAL)),f,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V2.Oriented(TopAbs_INTERNAL)),l,NE,Tol);
NE.Orientation(E.Orientation());
myAsDes->Add(CF,NE);
myNewEdges.Add(NE);
MES.Bind(E,NE);
}
else {
TopoDS_Shape NE = MES(E);
TopoDS_Shape aLocalShape = NE.Oriented(E.Orientation());
myAsDes->Add(CF,aLocalShape);
// myAsDes->Add(CF,NE.Oriented(E.Orientation()));
}
}
continue;
//----------------------------------------------------------------
// the edges of faces of context that are not in the initial shape
// can appear in the result.
//----------------------------------------------------------------
if (!ExtentContext) {
myAsDes->Add(CF,E);
myNewEdges.Add(E);
}
else {
if (!MES.IsBound(E)) {
TopoDS_Edge NE;
Standard_Real f,l,Tol;
BRep_Tool::Range(E,f,l);
Tol = BRep_Tool::Tolerance(E);
ExtentEdge(CF,E,NE);
TopoDS_Vertex V1,V2;
TopExp::Vertices(E,V1,V2);
NE.Orientation(TopAbs_FORWARD);
myAsDes->Add(NE,V1.Oriented(TopAbs_REVERSED));
myAsDes->Add(NE,V2.Oriented(TopAbs_FORWARD));
TopoDS_Shape aLocalShape = V1.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),f,NE,Tol);
aLocalShape = V2.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),l,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V1.Oriented(TopAbs_INTERNAL)),f,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V2.Oriented(TopAbs_INTERNAL)),l,NE,Tol);
NE.Orientation(E.Orientation());
myAsDes->Add(CF,NE);
myNewEdges.Add(NE);
MES.Bind(E,NE);
}
else {
TopoDS_Shape NE = MES(E);
TopoDS_Shape aLocalShape = NE.Oriented(E.Orientation());
myAsDes->Add(CF,aLocalShape);
// myAsDes->Add(CF,NE.Oriented(E.Orientation()));
}
}
continue;
}
const TopTools_ListOfShape& Anc = Analyse.Ancestors(E);
const TopoDS_Face& F = TopoDS::Face(Anc.First());
@@ -666,34 +672,34 @@ void BRepOffset_Inter3d::ContextIntByInt
OE = TopoDS::Edge(aLocalShape);
// OE = TopoDS::Edge(MapSF(F).Generated(E));
if (!MES.IsBound(OF)) {
BRepOffset_Tool::EnLargeFace(OF,NF,1,1);
MES.Bind(OF,NF);
BRepOffset_Tool::EnLargeFace(OF,NF,1,1);
MES.Bind(OF,NF);
}
else {
NF = TopoDS::Face(MES(OF));
NF = TopoDS::Face(MES(OF));
}
if (!IsDone(NF,CF)) {
TopTools_ListOfShape LInt1,LInt2;
TopTools_ListOfShape LOE;
LOE.Append(OE);
BRepOffset_Tool::Inter3D (WCF,NF,LInt1,LInt2,Side,E,Standard_True);
SetDone(NF,CF);
if (!LInt1.IsEmpty()) {
Store (CF,NF,LInt1,LInt2);
if (LInt1.Extent() == 1) {
Build.Bind(E,LInt1.First());
}
else {
B.MakeCompound(C);
for (it.Initialize(LInt1) ; it.More(); it.Next()) {
B.Add(C,it.Value());
}
Build.Bind(E,C);
}
}
else {
Failed.Append(E);
}
TopTools_ListOfShape LInt1,LInt2;
TopTools_ListOfShape LOE;
LOE.Append(OE);
BRepOffset_Tool::Inter3D (WCF,NF,LInt1,LInt2,Side,E,Standard_True);
SetDone(NF,CF);
if (!LInt1.IsEmpty()) {
Store (CF,NF,LInt1,LInt2);
if (LInt1.Extent() == 1) {
Build.Bind(E,LInt1.First());
}
else {
B.MakeCompound(C);
for (it.Initialize(LInt1) ; it.More(); it.Next()) {
B.Add(C,it.Value());
}
Build.Bind(E,C);
}
}
else {
Failed.Append(E);
}
}
}
}
@@ -705,10 +711,10 @@ void BRepOffset_Inter3d::ContextIntByInt
//=======================================================================
void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& ContextFaces,
const Standard_Boolean InSide,
const BRepOffset_Analyse& Analyse,
const BRepAlgo_Image& InitOffsetFace,
BRepAlgo_Image& InitOffsetEdge)
const Standard_Boolean InSide,
const BRepOffset_Analyse& Analyse,
const BRepAlgo_Image& InitOffsetFace,
BRepAlgo_Image& InitOffsetEdge)
{
TopTools_ListOfShape LInt1,LInt2;
@@ -728,39 +734,39 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
for (j = 1; j <= ContextFaces.Extent(); j++) {
const TopoDS_Face& CF = TopoDS::Face(ContextFaces(j));
for (exp.Init(CF.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
exp.More(); exp.Next()) {
exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
if (!Analyse.HasAncestor(E)) {
if (InSide)
myAsDes->Add(CF,E);
else {
TopoDS_Edge NE;
if (!InitOffsetEdge.HasImage(E)) {
Standard_Real f,l,Tol;
BRep_Tool::Range(E,f,l);
Tol = BRep_Tool::Tolerance(E);
ExtentEdge(CF,E,NE);
TopoDS_Vertex V1,V2;
TopExp::Vertices(E,V1,V2);
NE.Orientation(TopAbs_FORWARD);
myAsDes->Add(NE,V1.Oriented(TopAbs_REVERSED));
myAsDes->Add(NE,V2.Oriented(TopAbs_FORWARD));
TopoDS_Shape aLocalShape = V1.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),f,NE,Tol);
aLocalShape = V2.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),l,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V1.Oriented(TopAbs_INTERNAL)),f,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V2.Oriented(TopAbs_INTERNAL)),l,NE,Tol);
NE.Orientation(E.Orientation());
myAsDes->Add(CF,NE);
InitOffsetEdge.Bind(E,NE);
}
else {
NE = TopoDS::Edge(InitOffsetEdge.Image(E).First());
myAsDes->Add(CF,NE.Oriented(E.Orientation()));
}
}
continue;
if (InSide)
myAsDes->Add(CF,E);
else {
TopoDS_Edge NE;
if (!InitOffsetEdge.HasImage(E)) {
Standard_Real f,l,Tol;
BRep_Tool::Range(E,f,l);
Tol = BRep_Tool::Tolerance(E);
ExtentEdge(CF,E,NE);
TopoDS_Vertex V1,V2;
TopExp::Vertices(E,V1,V2);
NE.Orientation(TopAbs_FORWARD);
myAsDes->Add(NE,V1.Oriented(TopAbs_REVERSED));
myAsDes->Add(NE,V2.Oriented(TopAbs_FORWARD));
TopoDS_Shape aLocalShape = V1.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),f,NE,Tol);
aLocalShape = V2.Oriented(TopAbs_INTERNAL);
B.UpdateVertex(TopoDS::Vertex(aLocalShape),l,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V1.Oriented(TopAbs_INTERNAL)),f,NE,Tol);
// B.UpdateVertex(TopoDS::Vertex(V2.Oriented(TopAbs_INTERNAL)),l,NE,Tol);
NE.Orientation(E.Orientation());
myAsDes->Add(CF,NE);
InitOffsetEdge.Bind(E,NE);
}
else {
NE = TopoDS::Edge(InitOffsetEdge.Image(E).First());
myAsDes->Add(CF,NE.Oriented(E.Orientation()));
}
}
continue;
}
OE.Nullify();
//---------------------------------------------------
@@ -787,11 +793,11 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
//--------------------------------------------------
// MAJ of OE on cap CF.
//--------------------------------------------------
// TopTools_ListOfShape LOE; LOE.Append(OE);
// TopTools_ListOfShape LOE; LOE.Append(OE);
// BRepOffset_Tool::TryProject(CF,OF1,LOE,LInt1,LInt2,mySide);
// LInt2.Clear();
// StoreInter3d(CF,OF1,myTouched,NewEdges,InterDone,myAsDes,
// LInt1,LInt2);
// LInt1,LInt2);
LInt1.Clear(); LInt1.Append(OE);
LInt2.Clear();
TopAbs_Orientation O1,O2;
@@ -807,18 +813,18 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
TopoDS_Vertex V[2];
TopExp::Vertices (E,V[0],V[1]);
for (Standard_Integer i = 0; i < 2; i++) {
if (!MV.Add(V[i])) continue;
OF1.Nullify();
const TopTools_ListOfShape& LE = Analyse.Ancestors(V[i]);
TopTools_ListIteratorOfListOfShape itLE(LE);
for ( ; itLE.More(); itLE.Next()) {
const TopoDS_Edge& EV = TopoDS::Edge(itLE.Value());
if (InitOffsetFace.HasImage(EV)) {
//-------------------------------------------------
// OF1 parallel face generated by an ancester edge of V[i].
//-------------------------------------------------
OF1 = TopoDS::Face(InitOffsetFace.Image(EV).First());
OE = TopoDS::Edge(InitOffsetEdge.Image(V[i]).First());
if (!MV.Add(V[i])) continue;
OF1.Nullify();
const TopTools_ListOfShape& LE = Analyse.Ancestors(V[i]);
TopTools_ListIteratorOfListOfShape itLE(LE);
for ( ; itLE.More(); itLE.Next()) {
const TopoDS_Edge& EV = TopoDS::Edge(itLE.Value());
if (InitOffsetFace.HasImage(EV)) {
//-------------------------------------------------
// OF1 parallel face generated by an ancester edge of V[i].
//-------------------------------------------------
OF1 = TopoDS::Face(InitOffsetFace.Image(EV).First());
OE = TopoDS::Edge(InitOffsetEdge.Image(V[i]).First());
{
//Check if OE has pcurve in CF and OF1
@@ -834,64 +840,64 @@ void BRepOffset_Inter3d::ContextIntByArc(const TopTools_IndexedMapOfShape& Conte
}
}
//--------------------------------------------------
// MAj of OE on cap CF.
//--------------------------------------------------
// LOE.Clear(); LOE.Append(OE);
// BRepOffset_Tool::TryProject(CF,OF1,LOE,LInt1,LInt2,mySide);
// LInt2.Clear();
// StoreInter3d(CF,OF1,myTouched,NewEdges,InterDone,myAsDes,
// LInt1,LInt2);
LInt1.Clear(); LInt1.Append(OE);
LInt2.Clear();
TopAbs_Orientation O1,O2;
BRepOffset_Tool::OrientSection(OE,CF,OF1,O1,O2);
// if (mySide == TopAbs_OUT);
O1 = TopAbs::Reverse(O1);
LInt1.First().Orientation(O1);
Store(CF,OF1,LInt1,LInt2);
}
}
//--------------------------------------------------
// MAj of OE on cap CF.
//--------------------------------------------------
// LOE.Clear(); LOE.Append(OE);
// BRepOffset_Tool::TryProject(CF,OF1,LOE,LInt1,LInt2,mySide);
// LInt2.Clear();
// StoreInter3d(CF,OF1,myTouched,NewEdges,InterDone,myAsDes,
// LInt1,LInt2);
LInt1.Clear(); LInt1.Append(OE);
LInt2.Clear();
TopAbs_Orientation O1,O2;
BRepOffset_Tool::OrientSection(OE,CF,OF1,O1,O2);
// if (mySide == TopAbs_OUT);
O1 = TopAbs::Reverse(O1);
LInt1.First().Orientation(O1);
Store(CF,OF1,LInt1,LInt2);
}
}
}
}
for (exp.Init(CF.Oriented(TopAbs_FORWARD),TopAbs_VERTEX);
exp.More(); exp.Next()) {
exp.More(); exp.Next()) {
const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current());
if (!Analyse.HasAncestor(V)) {
continue;
continue;
}
const TopTools_ListOfShape& LE = Analyse.Ancestors(V);
TopTools_ListIteratorOfListOfShape itLE(LE);
for (; itLE.More(); itLE.Next()) {
const TopoDS_Edge& EV = TopoDS::Edge(itLE.Value());
const TopTools_ListOfShape& LF = Analyse.Ancestors(EV);
TopTools_ListIteratorOfListOfShape itLF(LF);
for ( ; itLF.More(); itLF.Next()) {
const TopoDS_Face& FEV = TopoDS::Face(itLF.Value());
//-------------------------------------------------
// OF1 parallel face generated by uneFace ancestor of V[i].
//-------------------------------------------------
OF1 = TopoDS::Face(InitOffsetFace.Image(FEV).First());
if (!IsDone(OF1,CF)) {
//-------------------------------------------------------
// Find if one of edges of OF1 has no trace in CF.
//-------------------------------------------------------
TopTools_ListOfShape LOE;
TopExp_Explorer exp2(OF1.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
for ( ;exp2.More(); exp2.Next()) {
LOE.Append(exp2.Current());
}
BRepOffset_Tool::TryProject(CF,OF1,LOE,LInt1,LInt2,mySide,myTol);
//-------------------------------------------------------
// If no trace try intersection.
//-------------------------------------------------------
if (LInt1.IsEmpty()) {
BRepOffset_Tool::Inter3D (CF,OF1,LInt1,LInt2,mySide,NullEdge);
}
Store (CF,OF1,LInt1,LInt2);
}
}
const TopoDS_Edge& EV = TopoDS::Edge(itLE.Value());
const TopTools_ListOfShape& LF = Analyse.Ancestors(EV);
TopTools_ListIteratorOfListOfShape itLF(LF);
for ( ; itLF.More(); itLF.Next()) {
const TopoDS_Face& FEV = TopoDS::Face(itLF.Value());
//-------------------------------------------------
// OF1 parallel face generated by uneFace ancestor of V[i].
//-------------------------------------------------
OF1 = TopoDS::Face(InitOffsetFace.Image(FEV).First());
if (!IsDone(OF1,CF)) {
//-------------------------------------------------------
// Find if one of edges of OF1 has no trace in CF.
//-------------------------------------------------------
TopTools_ListOfShape LOE;
TopExp_Explorer exp2(OF1.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
for ( ;exp2.More(); exp2.Next()) {
LOE.Append(exp2.Current());
}
BRepOffset_Tool::TryProject(CF,OF1,LOE,LInt1,LInt2,mySide,myTol);
//-------------------------------------------------------
// If no trace try intersection.
//-------------------------------------------------------
if (LInt1.IsEmpty()) {
BRepOffset_Tool::Inter3D (CF,OF1,LInt1,LInt2,mySide,NullEdge);
}
Store (CF,OF1,LInt1,LInt2);
}
}
}
}
}
@@ -913,7 +919,7 @@ void BRepOffset_Inter3d::AddCommonEdges(const TopTools_ListOfShape&)
//=======================================================================
void BRepOffset_Inter3d::SetDone(const TopoDS_Face& F1,
const TopoDS_Face& F2)
const TopoDS_Face& F2)
{
if (!myDone.IsBound(F1)) {
TopTools_ListOfShape empty;
@@ -934,7 +940,7 @@ void BRepOffset_Inter3d::SetDone(const TopoDS_Face& F1,
//=======================================================================
Standard_Boolean BRepOffset_Inter3d::IsDone(const TopoDS_Face& F1,
const TopoDS_Face& F2)
const TopoDS_Face& F2)
const
{
if (myDone.IsBound(F1)) {
@@ -987,9 +993,9 @@ TopTools_IndexedMapOfShape& BRepOffset_Inter3d::NewEdges()
//=======================================================================
void BRepOffset_Inter3d::Store(const TopoDS_Face& F1,
const TopoDS_Face& F2,
const TopTools_ListOfShape& LInt1,
const TopTools_ListOfShape& LInt2)
const TopoDS_Face& F2,
const TopTools_ListOfShape& LInt1,
const TopTools_ListOfShape& LInt2)
{
if (!LInt1.IsEmpty()) {
myTouched.Add(F1);

View File

@@ -19,7 +19,7 @@
class MakeOffset from BRepOffset
---Purpose:
---Purpose:
uses
Image from BRepAlgo,
@@ -36,7 +36,9 @@ uses
Edge from TopoDS,
MapOfShape from TopTools,
IndexedMapOfShape from TopTools,
ListOfShape from TopTools,
ListOfShape from TopTools,
DataMapOfShapeShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
MakeLoops from BRepOffset
is
@@ -45,38 +47,38 @@ is
Create ( S : Shape from TopoDS;
Offset : Real from Standard;
Tol : Real from Standard;
Mode : Mode from BRepOffset = BRepOffset_Skin;
Intersection : Boolean from Standard = Standard_False;
SelfInter : Boolean from Standard = Standard_False;
Tol : Real from Standard;
Mode : Mode from BRepOffset = BRepOffset_Skin;
Intersection : Boolean from Standard = Standard_False;
SelfInter : Boolean from Standard = Standard_False;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Thickening : Boolean from Standard = Standard_False)
returns MakeOffset from BRepOffset;
Thickening : Boolean from Standard = Standard_False)
returns MakeOffset from BRepOffset;
---Category: Initialization.
Initialize (me : in out;
S : Shape from TopoDS;
S : Shape from TopoDS;
Offset : Real from Standard;
Tol : Real from Standard;
Mode : Mode from BRepOffset = BRepOffset_Skin;
Intersection : Boolean from Standard = Standard_False;
SelfInter : Boolean from Standard = Standard_False;
Tol : Real from Standard;
Mode : Mode from BRepOffset = BRepOffset_Skin;
Intersection : Boolean from Standard = Standard_False;
SelfInter : Boolean from Standard = Standard_False;
Join : JoinType from GeomAbs = GeomAbs_Arc;
Thickening : Boolean from Standard = Standard_False)
Thickening : Boolean from Standard = Standard_False)
is static;
Clear (me : in out)
is static;
AddFace (me : in out; F : Face from TopoDS) is static;
---Purpose: Add Closing Faces, <F> has to be in the initial
-- shape S.
---Purpose: Add Closing Faces, <F> has to be in the initial
-- shape S.
SetOffsetOnFace (me : in out;
F : Face from TopoDS;
Off : Real from Standard) is static;
---Purpose: set the offset <Off> on the Face <F>
F : Face from TopoDS;
Off : Real from Standard) is static;
---Purpose: set the offset <Off> on the Face <F>
---Category: Computation.
@@ -88,7 +90,7 @@ is
---Category: Querying.
GetAnalyse(me)
---C++: return const &
---C++: return const &
returns Analyse from BRepOffset
is static;
@@ -96,18 +98,18 @@ is
is static;
Shape (me)
---C++: return const &
---C++: return const &
returns Shape from TopoDS
is static;
Error (me) returns Error from BRepOffset;
---Purpose: returns information if IsDone() = FALSE.
---Purpose: returns information if IsDone() = FALSE.
OffsetFacesFromShapes (me)
---Purpose: Returns <Image> containing links between initials
-- shapes and offset faces.
---C++: return const &
---Purpose: Returns <Image> containing links between initials
-- shapes and offset faces.
---C++: return const &
returns Image from BRepAlgo
is static;
@@ -115,24 +117,24 @@ is
-- Query offset join type.
GetJoinType(me)
---Purpose: Returns myJoin.
---Purpose: Returns myJoin.
returns JoinType from GeomAbs
is static;
-- Add methods for supporting history.
OffsetEdgesFromShapes (me)
---Purpose: Returns <Image> containing links between initials
-- shapes and offset edges.
---C++: return const &
---Purpose: Returns <Image> containing links between initials
-- shapes and offset edges.
---C++: return const &
returns Image from BRepAlgo
is static;
-- Modified by skv - Tue Mar 15 16:17:37 2005 End
ClosingFaces (me)
---Purpose: Returns the list of closing faces stores by AddFace
---C++: return const &
---Purpose: Returns the list of closing faces stores by AddFace
---C++: return const &
returns IndexedMapOfShape from TopTools
is static;
@@ -143,18 +145,30 @@ is
BuildOffsetByInter ( me : in out )
is static private;
BuildSplitsOfFaces (me:in out;
theLF : ListOfShape from TopTools;
theAsDes : AsDes from BRepAlgo;
theOrMap : out IndexedDataMapOfShapeListOfShape from TopTools;
theImage : out Image from BRepAlgo;
theLFail : out ListOfShape from TopTools;
bLimited : Boolean from Standard)
is static private;
---Purpose:
-- Building splits of the offset faces by the section curves
-- between the neighboring faces.
SelfInter (me : in out ;
Modif : in out MapOfShape from TopTools)
is static private;
Modif : in out MapOfShape from TopTools)
is static private;
Intersection3D (me : in out;
Inter : in out Inter3d from BRepOffset)
is static private;
Inter : in out Inter3d from BRepOffset)
is static private;
Intersection2D ( me : in out ;
Modif : IndexedMapOfShape from TopTools;
NewEdges : IndexedMapOfShape from TopTools)
NewEdges : IndexedMapOfShape from TopTools)
is static private;
MakeLoops ( me : in out ;
@@ -174,7 +188,7 @@ is
SelectShells (me : in out)
is static private;
EncodeRegularity( me : in out)
is static private;
@@ -182,19 +196,19 @@ is
is static private;
ToContext (me : in out;
MapSF : in out DataMapOfShapeOffset from BRepOffset)
is static private;
MapSF : in out DataMapOfShapeOffset from BRepOffset)
is static private;
UpdateFaceOffset (me: in out)
---Purpose: Private method use to update the map face<->offset
---Purpose: Private method use to update the map face<->offset
is static private;
CorrectConicalFaces (me: in out)
---Purpose: Private method used to correct degenerated edges on conical faces
---Purpose: Private method used to correct degenerated edges on conical faces
is static private;
MakeMissingWalls (me: in out)
---Purpose: Private method used to build walls for thickening the shell
---Purpose: Private method used to build walls for thickening the shell
is static private;
fields
@@ -211,7 +225,7 @@ fields
myFaceOffset : DataMapOfShapeReal from TopTools;
myFaces : IndexedMapOfShape from TopTools;
myAnalyse : Analyse from BRepOffset;
myAnalyse : Analyse from BRepOffset;
myOffsetShape : Shape from TopoDS; -- Result
myInitOffsetFace : Image from BRepAlgo;

File diff suppressed because it is too large Load Diff