1 // Created on: 1993-07-23
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <TopoDSToStep_MakeManifoldSolidBrep.ixx>
23 #include <StdFail_NotDone.hxx>
24 #include <TopoDSToStep.hxx>
25 #include <TopoDSToStep_Builder.hxx>
26 #include <TopoDSToStep_Tool.hxx>
27 #include <BRepTools.hxx>
28 #include <Transfer_FinderProcess.hxx>
29 #include <TransferBRep_ShapeMapper.hxx>
30 #include <TCollection_HAsciiString.hxx>
32 #include <StepShape_ClosedShell.hxx>
33 #include <StepShape_OpenShell.hxx>
34 #include <StepShape_HArray1OfFace.hxx>
36 static Handle(StepShape_ManifoldSolidBrep) MakeManifoldSolidBrep (const TopoDS_Shell& aShell,
37 const Handle(Transfer_FinderProcess)& FP)
39 Handle(StepShape_ManifoldSolidBrep) theManifoldSolidBrep;
41 MoniTool_DataMapOfShapeTransient aMap;
42 TopoDSToStep_Tool aTool(aMap, Standard_False);
44 TopoDSToStep_Builder StepB(aShell, aTool, FP);
46 TopoDSToStep::AddResult(FP, aTool);
49 Handle(StepShape_ClosedShell) aCShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value());
50 // si OPEN on le force a CLOSED mais que c est une honte !
51 if (aCShell.IsNull()) {
52 Handle(StepShape_OpenShell) aOShell = Handle(StepShape_OpenShell)::DownCast(StepB.Value());
53 if (aOShell.IsNull()) return theManifoldSolidBrep;
55 aCShell = new StepShape_ClosedShell;
56 aCShell->Init(aOShell->Name(),aOShell->CfsFaces());
59 theManifoldSolidBrep = new StepShape_ManifoldSolidBrep();
60 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
61 theManifoldSolidBrep->Init(aName, aCShell);
64 return theManifoldSolidBrep;
67 //=============================================================================
68 // Create a ManifoldSolidBrep of StepShape from a Shell of TopoDS
69 //=============================================================================
71 TopoDSToStep_MakeManifoldSolidBrep::
72 TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Shell& aShell,
73 const Handle(Transfer_FinderProcess)& FP)
75 theManifoldSolidBrep = MakeManifoldSolidBrep(aShell, FP);
76 done = !theManifoldSolidBrep.IsNull();
78 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aShell);
79 FP->AddWarning(errShape, " Closed Shell not mapped to ManifoldSolidBrep");
83 //=============================================================================
84 // Create a ManifoldSolidBrep of StepShape from a Solid of TopoDS containing
85 // only one closed shell
86 //=============================================================================
88 TopoDSToStep_MakeManifoldSolidBrep::
89 TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Solid& aSolid,
90 const Handle(Transfer_FinderProcess)& FP)
92 TopoDS_Shell aOuterShell = BRepTools::OuterShell(aSolid);
93 if (!aOuterShell.IsNull()) {
95 theManifoldSolidBrep = MakeManifoldSolidBrep(aOuterShell, FP);
96 done = !theManifoldSolidBrep.IsNull();
98 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell);
99 FP->AddWarning(errShape, " Outer Shell of Solid not mapped to ManifoldSolidBrep");
103 Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell);
104 FP->AddWarning(errShape, " Outer Shell is null; not mapped to ManifoldSolidBrep ");
105 done = Standard_False;
109 //=============================================================================
110 // renvoi des valeurs
111 //=============================================================================
113 const Handle(StepShape_ManifoldSolidBrep) &
114 TopoDSToStep_MakeManifoldSolidBrep::Value() const
116 StdFail_NotDone_Raise_if(!done,"");
117 return theManifoldSolidBrep;