b311480e |
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 |
5 | // |
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. |
10 | // |
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. |
13 | // |
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. |
20 | |
7fd59977 |
21 | |
22 | #include <TopoDSToStep_MakeManifoldSolidBrep.ixx> |
23 | #include <StdFail_NotDone.hxx> |
24 | #include <TopoDSToStep.hxx> |
25 | #include <TopoDSToStep_Builder.hxx> |
26 | #include <TopoDSToStep_Tool.hxx> |
2f0109b7 |
27 | #include <BRepClass3d.hxx> |
7fd59977 |
28 | #include <Transfer_FinderProcess.hxx> |
29 | #include <TransferBRep_ShapeMapper.hxx> |
30 | #include <TCollection_HAsciiString.hxx> |
31 | |
32 | #include <StepShape_ClosedShell.hxx> |
33 | #include <StepShape_OpenShell.hxx> |
34 | #include <StepShape_HArray1OfFace.hxx> |
35 | |
36 | static Handle(StepShape_ManifoldSolidBrep) MakeManifoldSolidBrep (const TopoDS_Shell& aShell, |
37 | const Handle(Transfer_FinderProcess)& FP) |
38 | { |
39 | Handle(StepShape_ManifoldSolidBrep) theManifoldSolidBrep; |
40 | |
41 | MoniTool_DataMapOfShapeTransient aMap; |
42 | TopoDSToStep_Tool aTool(aMap, Standard_False); |
43 | |
44 | TopoDSToStep_Builder StepB(aShell, aTool, FP); |
45 | |
46 | TopoDSToStep::AddResult(FP, aTool); |
47 | |
48 | if (StepB.IsDone()) { |
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; |
54 | else { |
55 | aCShell = new StepShape_ClosedShell; |
56 | aCShell->Init(aOShell->Name(),aOShell->CfsFaces()); |
57 | } |
58 | } |
59 | theManifoldSolidBrep = new StepShape_ManifoldSolidBrep(); |
60 | Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(""); |
61 | theManifoldSolidBrep->Init(aName, aCShell); |
62 | } |
63 | |
64 | return theManifoldSolidBrep; |
65 | } |
66 | |
67 | //============================================================================= |
68 | // Create a ManifoldSolidBrep of StepShape from a Shell of TopoDS |
69 | //============================================================================= |
70 | |
71 | TopoDSToStep_MakeManifoldSolidBrep:: |
72 | TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Shell& aShell, |
73 | const Handle(Transfer_FinderProcess)& FP) |
74 | { |
75 | theManifoldSolidBrep = MakeManifoldSolidBrep(aShell, FP); |
76 | done = !theManifoldSolidBrep.IsNull(); |
77 | if (!done) { |
78 | Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aShell); |
79 | FP->AddWarning(errShape, " Closed Shell not mapped to ManifoldSolidBrep"); |
80 | } |
81 | } |
82 | |
83 | //============================================================================= |
84 | // Create a ManifoldSolidBrep of StepShape from a Solid of TopoDS containing |
85 | // only one closed shell |
86 | //============================================================================= |
87 | |
88 | TopoDSToStep_MakeManifoldSolidBrep:: |
89 | TopoDSToStep_MakeManifoldSolidBrep(const TopoDS_Solid& aSolid, |
90 | const Handle(Transfer_FinderProcess)& FP) |
91 | { |
2f0109b7 |
92 | TopoDS_Shell aOuterShell = BRepClass3d::OuterShell(aSolid); |
7fd59977 |
93 | if (!aOuterShell.IsNull()) { |
94 | |
95 | theManifoldSolidBrep = MakeManifoldSolidBrep(aOuterShell, FP); |
96 | done = !theManifoldSolidBrep.IsNull(); |
97 | if (!done) { |
98 | Handle(TransferBRep_ShapeMapper) errShape = new TransferBRep_ShapeMapper(aOuterShell); |
99 | FP->AddWarning(errShape, " Outer Shell of Solid not mapped to ManifoldSolidBrep"); |
100 | } |
101 | } |
102 | else { |
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; |
106 | } |
107 | } |
108 | |
109 | //============================================================================= |
110 | // renvoi des valeurs |
111 | //============================================================================= |
112 | |
113 | const Handle(StepShape_ManifoldSolidBrep) & |
114 | TopoDSToStep_MakeManifoldSolidBrep::Value() const |
115 | { |
116 | StdFail_NotDone_Raise_if(!done,""); |
117 | return theManifoldSolidBrep; |
118 | } |