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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
// File: TopoDSToStep_MakeFacetedBrep.cxx
// Created: Fri Jul 23 17:40:38 1993
// Author: Martine LANGLOIS
// <mla@mastox>
#include <TopoDSToStep_MakeFacetedBrep.ixx>
#include <StdFail_NotDone.hxx>
#include <StepShape_TopologicalRepresentationItem.hxx>
#include <TopoDSToStep.hxx>
#include <TopoDSToStep_Builder.hxx>
#include <TopoDSToStep_Tool.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRepTools.hxx>
#include <Transfer_FinderProcess.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <TCollection_HAsciiString.hxx>
//=============================================================================
// Create a FacetedBrep of StepShape from a Shell of TopoDS
//=============================================================================
TopoDSToStep_MakeFacetedBrep::
TopoDSToStep_MakeFacetedBrep(const TopoDS_Shell& aShell,
const Handle(Transfer_FinderProcess)& FP)
{
done = Standard_False;
if (aShell.Closed()) {
Handle(StepShape_TopologicalRepresentationItem) aItem;
MoniTool_DataMapOfShapeTransient aMap;
TopoDSToStep_Tool aTool(aMap, Standard_True);
TopoDSToStep_Builder StepB(aShell, aTool, FP);
TopoDSToStep::AddResult ( FP, aTool );
if (StepB.IsDone()) {
aItem = StepB.Value();
Handle(StepShape_ClosedShell) aCShell;
aCShell = Handle(StepShape_ClosedShell)::DownCast(aItem);
theFacetedBrep = new StepShape_FacetedBrep();
Handle(TCollection_HAsciiString) aName =
new TCollection_HAsciiString("");
theFacetedBrep->Init(aName, aCShell);
done = Standard_True;
}
else {
done = Standard_False;
Handle(TransferBRep_ShapeMapper) errShape =
new TransferBRep_ShapeMapper(aShell);
FP->AddWarning(errShape," Closed Shell not mapped to FacetedBrep");
}
}
else {
done = Standard_False;
Handle(TransferBRep_ShapeMapper) errShape =
new TransferBRep_ShapeMapper(aShell);
FP->AddWarning(errShape," Shell not closed; not mapped to FacetedBrep");
}
}
//=============================================================================
// Create a FacetedBrep of StepShape from a Solid of TopoDS containing
// only one closed shell
//=============================================================================
TopoDSToStep_MakeFacetedBrep::
TopoDSToStep_MakeFacetedBrep(const TopoDS_Solid& aSolid,
const Handle(Transfer_FinderProcess)& FP)
{
done = Standard_False;
// Looking for the Outer Shell
TopoDS_Shell aOuterShell = BRepTools::OuterShell(aSolid);
if (!aOuterShell.IsNull()) {
if (aOuterShell.Closed()) {
Handle(StepShape_TopologicalRepresentationItem) aItem;
MoniTool_DataMapOfShapeTransient aMap;
TopoDSToStep_Tool aTool(aMap, Standard_True);
TopoDSToStep_Builder StepB(aOuterShell, aTool, FP);
TopoDSToStep::AddResult ( FP, aTool );
if (StepB.IsDone()) {
aItem = StepB.Value();
Handle(StepShape_ClosedShell) aCShell;
aCShell = Handle(StepShape_ClosedShell)::DownCast(aItem);
theFacetedBrep = new StepShape_FacetedBrep();
Handle(TCollection_HAsciiString) aName =
new TCollection_HAsciiString("");
theFacetedBrep->Init(aName, aCShell);
done = Standard_True;
}
else {
done = Standard_False;
Handle(TransferBRep_ShapeMapper) errShape =
new TransferBRep_ShapeMapper(aOuterShell);
FP->AddWarning(errShape," Closed Outer Shell from Solid not mapped to FacetedBrep");
}
}
else {
done = Standard_False;
Handle(TransferBRep_ShapeMapper) errShape =
new TransferBRep_ShapeMapper(aOuterShell);
FP->AddWarning(errShape," Shell not closed; not mapped to FacetedBrep");
}
}
else {
done = Standard_False;
Handle(TransferBRep_ShapeMapper) errShape =
new TransferBRep_ShapeMapper(aOuterShell);
FP->AddWarning(errShape," Solid contains no Outer Shell to be mapped to FacetedBrep");
}
}
//=============================================================================
// renvoi des valeurs
//=============================================================================
const Handle(StepShape_FacetedBrep) &
TopoDSToStep_MakeFacetedBrep::Value() const
{
StdFail_NotDone_Raise_if(!done,"");
return theFacetedBrep;
}
|