1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// File: ShapeFix_FreeBounds.cxx
// Created: Wed Sep 16 17:27:59 1998
// Author: Roman LYGIN <rln@nnov.matra-dtv.fr>
// Pavel DURANDIN <pdn@nnov.matra-dtv.fr>
// 25.12.98 pdn: renaming methods GetWires and GetEdges to GetClosedWires
// and GetOpenWires respectively
#include <ShapeFix_FreeBounds.ixx>
#include <BRep_Builder.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <ShapeExtend_Explorer.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
//=======================================================================
//function : ShapeFix_FreeBounds
//purpose :
//=======================================================================
ShapeFix_FreeBounds::ShapeFix_FreeBounds() {}
//=======================================================================
//function : ShapeFix_FreeBounds
//purpose :
//=======================================================================
ShapeFix_FreeBounds::ShapeFix_FreeBounds(const TopoDS_Shape& shape,
const Standard_Real sewtoler,
const Standard_Real closetoler,
const Standard_Boolean splitclosed,
const Standard_Boolean splitopen) :
myShared (Standard_False), mySewToler (sewtoler), myCloseToler (closetoler),
mySplitClosed (splitclosed), mySplitOpen (splitopen)
{
myShape = shape;
Perform();
}
//=======================================================================
//function : ShapeFix_FreeBounds
//purpose :
//=======================================================================
ShapeFix_FreeBounds::ShapeFix_FreeBounds(const TopoDS_Shape& shape,
const Standard_Real closetoler,
const Standard_Boolean splitclosed,
const Standard_Boolean splitopen):
myShared (Standard_True), mySewToler (0.), myCloseToler (closetoler),
mySplitClosed (splitclosed), mySplitOpen (splitopen)
{
myShape = shape;
Perform();
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_FreeBounds::Perform()
{
ShapeAnalysis_FreeBounds safb;
if (myShared)
safb = ShapeAnalysis_FreeBounds (myShape, mySplitClosed, mySplitOpen);
else
safb = ShapeAnalysis_FreeBounds (myShape, mySewToler, mySplitClosed, mySplitOpen);
myWires = safb.GetClosedWires();
myEdges = safb.GetOpenWires();
if (myCloseToler > mySewToler) {
ShapeExtend_Explorer see;
Handle(TopTools_HSequenceOfShape) newwires,
open = see.SeqFromCompound (myEdges,
Standard_False);
TopTools_DataMapOfShapeShape vertices;
ShapeAnalysis_FreeBounds::ConnectWiresToWires (open, myCloseToler, myShared,
newwires, vertices);
myEdges.Nullify();
ShapeAnalysis_FreeBounds::DispatchWires (newwires, myWires, myEdges);
for( TopExp_Explorer exp (myShape, TopAbs_EDGE); exp.More(); exp.Next()) {
TopoDS_Edge Edge = TopoDS::Edge(exp.Current());
for( TopoDS_Iterator iter (Edge); iter.More(); iter.Next()) {
TopoDS_Vertex V = TopoDS::Vertex (iter.Value());
BRep_Builder B;
TopoDS_Vertex newV;
if( vertices.IsBound(V)) {
newV = TopoDS::Vertex (vertices.Find(V));
newV.Orientation(V.Orientation());
B.Remove(Edge, V);
B.Add(Edge, newV);
}
}
}
}
return Standard_True;
}
|