1 // Created on: 1993-07-23
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.ixx>
18 #include <TopoDSToStep.hxx>
19 #include <TopoDSToStep_Builder.hxx>
20 #include <TopoDSToStep_Tool.hxx>
21 #include <MoniTool_DataMapOfShapeTransient.hxx>
22 #include <StepShape_TopologicalRepresentationItem.hxx>
23 #include <StepShape_ClosedShell.hxx>
24 #include <StepShape_OrientedClosedShell.hxx>
25 #include <StepShape_HArray1OfOrientedClosedShell.hxx>
26 #include <TopoDS_Iterator.hxx>
27 #include <TopoDS_Shell.hxx>
29 #include <TColStd_SequenceOfTransient.hxx>
30 #include <BRepClass3d.hxx>
31 #include <StdFail_NotDone.hxx>
32 #include <Transfer_FinderProcess.hxx>
33 #include <TransferBRep_ShapeMapper.hxx>
34 #include <TCollection_HAsciiString.hxx>
36 //=============================================================================
37 // Create a FacetedBrepAndBrepWithVoids of StepShape from a Solid of TopoDS
38 // containing more than one closed shell
39 //=============================================================================
41 TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::
42 TopoDSToStep_MakeFacetedBrepAndBrepWithVoids(const TopoDS_Solid& aSolid,
43 const Handle(Transfer_FinderProcess)& FP)
45 done = Standard_False;
47 MoniTool_DataMapOfShapeTransient aMap;
48 TColStd_SequenceOfTransient S;
49 TopoDS_Shell aOutShell;
51 Handle(StepShape_TopologicalRepresentationItem) aItem;
52 Handle(StepShape_ClosedShell) aOuter, aCShell;
53 Handle(StepShape_OrientedClosedShell) aOCShell;
54 Handle(StepShape_HArray1OfOrientedClosedShell) aVoids;
56 aOutShell = BRepClass3d::OuterShell(aSolid);
58 TopoDSToStep_Builder StepB;
59 TopoDSToStep_Tool aTool;
61 if (!aOutShell.IsNull()) {
62 It.Initialize(aSolid);
63 for ( ; It.More(); It.Next() ) {
64 if (It.Value().ShapeType() == TopAbs_SHELL) {
65 TopoDS_Shell CurrentShell = TopoDS::Shell(It.Value());
66 if (It.Value().Closed()) {
68 aTool.Init(aMap, Standard_False);
69 StepB.Init(CurrentShell, aTool, FP);
70 TopoDSToStep::AddResult ( FP, aTool );
73 aCShell = Handle(StepShape_ClosedShell)::DownCast(StepB.Value());
74 if ( aOutShell.IsEqual(It.Value()) )
80 Handle(TransferBRep_ShapeMapper) errShape =
81 new TransferBRep_ShapeMapper(CurrentShell);
82 FP->AddWarning(errShape," Shell from Solid not mapped to FacetedBrepAndBrepWithVoids");
86 done = Standard_False;
87 Handle(TransferBRep_ShapeMapper) errShape =
88 new TransferBRep_ShapeMapper(CurrentShell);
89 FP->AddWarning(errShape," Shell from Solid not closed; not mapped to FacetedBrepAndBrepWithVoids");
94 Standard_Integer N = S.Length();
96 aVoids = new StepShape_HArray1OfOrientedClosedShell(1,N);
97 Handle(TCollection_HAsciiString) aName =
98 new TCollection_HAsciiString("");
99 for ( Standard_Integer i=1; i<=N; i++ ) {
100 aOCShell = new StepShape_OrientedClosedShell();
101 aOCShell->Init(aName, Handle(StepShape_ClosedShell)::DownCast(S.Value(i)),
103 aVoids->SetValue(i, aOCShell);
105 theFacetedBrepAndBrepWithVoids =
106 new StepShape_FacetedBrepAndBrepWithVoids();
107 theFacetedBrepAndBrepWithVoids->Init(aName, aOuter, aVoids);
108 done = Standard_True;
111 done = Standard_False;
112 Handle(TransferBRep_ShapeMapper) errShape =
113 new TransferBRep_ShapeMapper(aSolid);
114 FP->AddWarning(errShape," Solid contains no Shell to be mapped to FacetedBrepAndBrepWithVoids");
118 //=============================================================================
119 // renvoi des valeurs
120 //=============================================================================
122 const Handle(StepShape_FacetedBrepAndBrepWithVoids) &
123 TopoDSToStep_MakeFacetedBrepAndBrepWithVoids::Value() const
125 StdFail_NotDone_Raise_if(!done,"");
126 return theFacetedBrepAndBrepWithVoids;