1 // File: TopoDSToStep_MakeManifoldSolidBrep.cxx
2 // Created: Fri Jul 23 15:31:00 1993
3 // Author: Martine LANGLOIS
6 #include <TopoDSToStep_MakeManifoldSolidBrep.ixx>
7 #include <StdFail_NotDone.hxx>
8 #include <TopoDSToStep.hxx>
9 #include <TopoDSToStep_Builder.hxx>
10 #include <TopoDSToStep_Tool.hxx>
11 #include <BRepTools.hxx>
12 #include <Transfer_FinderProcess.hxx>
13 #include <TransferBRep_ShapeMapper.hxx>
14 #include <TCollection_HAsciiString.hxx>
16 #include <StepShape_ClosedShell.hxx>
17 #include <StepShape_OpenShell.hxx>
18 #include <StepShape_HArray1OfFace.hxx>
20 static Handle(StepShape_ManifoldSolidBrep) MakeManifoldSolidBrep (const TopoDS_Shell& aShell,
21 const Handle(Transfer_FinderProcess)& FP)
23 Handle(StepShape_ManifoldSolidBrep) theManifoldSolidBrep;
25 MoniTool_DataMapOfShapeTransient aMap;
26 TopoDSToStep_Tool aTool(aMap, Standard_False);
28 TopoDSToStep_Builder StepB(aShell, aTool, FP);
30 TopoDSToStep::AddResult(FP, aTool);
33 Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value());
34 // si OPEN on le force a CLOSED mais que c est une honte !
35 if (aCShell.IsNull()) {
36 Handle(StepShape_OpenShell) aOShell = Handle(StepShape_OpenShell)::DownCast(StepB.Value());
37 if (aOShell.IsNull()) return theManifoldSolidBrep;
39 aCShell = new StepShape_ClosedShell;
40 aCShell->Init(aOShell->Name(),aOShell->CfsFaces());
43 theManifoldSolidBrep = new StepShape_ManifoldSolidBrep();
44 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
45 theManifoldSolidBrep->Init(aName, aCShell);
48 return theManifoldSolidBrep;
51 //=============================================================================
52 // Create a ManifoldSolidBrep of StepShape from a Shell of TopoDS
53 //=============================================================================
55 TopoDSToStep_MakeManifoldSolidBrep::
56 TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Shell& aShell,
57 const Handle(Transfer_FinderProcess)& FP)
59 theManifoldSolidBrep = MakeManifoldSolidBrep(aShell, FP);
60 done = !theManifoldSolidBrep.IsNull();
62 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aShell);
63 FP->AddWarning(errShape, " Closed Shell not mapped to ManifoldSolidBrep");
67 //=============================================================================
68 // Create a ManifoldSolidBrep of StepShape from a Solid of TopoDS containing
69 // only one closed shell
70 //=============================================================================
72 TopoDSToStep_MakeManifoldSolidBrep::
73 TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Solid& aSolid,
74 const Handle(Transfer_FinderProcess)& FP)
76 TopoDS_Shell aOuterShell = BRepTools::OuterShell(aSolid);
77 if (!aOuterShell.IsNull()) {
79 theManifoldSolidBrep = MakeManifoldSolidBrep(aOuterShell, FP);
80 done = !theManifoldSolidBrep.IsNull();
82 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell);
83 FP->AddWarning(errShape, " Outer Shell of Solid not mapped to ManifoldSolidBrep");
87 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell);
88 FP->AddWarning(errShape, " Outer Shell is null; not mapped to ManifoldSolidBrep ");
89 done = Standard_False;
93 //=============================================================================
95 //=============================================================================
97 const Handle(StepShape_ManifoldSolidBrep) &
98 TopoDSToStep_MakeManifoldSolidBrep::Value() const
100 StdFail_NotDone_Raise_if(!done,"");
101 return theManifoldSolidBrep;