1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <GEOMImpl_PipePathDriver.hxx>
24 #include <GEOMImpl_ShapeDriver.hxx>
25 #include <GEOMImpl_IPipePath.hxx>
26 #include <GEOMImpl_Types.hxx>
27 #include <GEOM_Function.hxx>
29 #include <BRepOffsetAPI_MiddlePath.hxx>
30 #include <TColStd_HSequenceOfTransient.hxx>
31 #include <Precision.hxx>
32 #include <Standard_NullObject.hxx>
34 //=======================================================================
37 //=======================================================================
38 const Standard_GUID& GEOMImpl_PipePathDriver::GetID()
40 static Standard_GUID aPipePathDriver ("FF1BBB19-5D14-4df2-980B-3A668264EA17");
41 return aPipePathDriver;
44 //=======================================================================
45 //function : GEOMImpl_PipePathDriver
47 //=======================================================================
48 GEOMImpl_PipePathDriver::GEOMImpl_PipePathDriver()
52 //=======================================================================
55 //=======================================================================
56 Standard_Integer GEOMImpl_PipePathDriver::Execute(LOGBOOK& log) const
58 if (Label().IsNull()) return 0;
59 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
60 Standard_Integer aType = aFunction->GetType();
65 if (aType == PIPE_PATH_TWO_BASES) {
66 GEOMImpl_IPipePath aPI (aFunction);
68 Handle(GEOM_Function) aRefShape = aPI.GetShape();
69 Handle(GEOM_Function) aRefBase1 = aPI.GetBase1();
70 Handle(GEOM_Function) aRefBase2 = aPI.GetBase2();
72 TopoDS_Shape aShape = aRefShape->GetValue();
73 TopoDS_Shape aBase1 = aRefBase1->GetValue();
74 TopoDS_Shape aBase2 = aRefBase2->GetValue();
76 if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull())
77 Standard_NullObject::Raise("RestorePath aborted : null argument");
79 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2);
85 else if (aType == PIPE_PATH_TWO_SEQS) {
86 GEOMImpl_IPipePath aPI (aFunction);
88 Handle(GEOM_Function) aRefShape = aPI.GetShape();
89 TopoDS_Shape aShape = aRefShape->GetValue();
91 Handle(TColStd_HSequenceOfTransient) aBaseSeq1 = aPI.GetBaseSeq1();
92 Handle(TColStd_HSequenceOfTransient) aBaseSeq2 = aPI.GetBaseSeq2();
97 if (aBaseSeq1->Length() == 1 && aBaseSeq2->Length() == 1) {
98 Handle(GEOM_Function) aRefShape1 = Handle(GEOM_Function)::DownCast(aBaseSeq1->Value(1));
99 Handle(GEOM_Function) aRefShape2 = Handle(GEOM_Function)::DownCast(aBaseSeq2->Value(1));
100 aBase1 = aRefShape1->GetValue();
101 aBase2 = aRefShape2->GetValue();
104 aBase1 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq1, Precision::Confusion());
105 aBase2 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq2, Precision::Confusion());
108 if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull())
109 Standard_NullObject::Raise("RestorePath aborted : null argument");
111 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2);
120 if (aRes.IsNull()) return 0;
122 aFunction->SetValue(aRes);
123 #if OCC_VERSION_MAJOR < 7
124 log.SetTouched(Label());
126 log->SetTouched(Label());
132 //================================================================================
134 * \brief Returns a name of creation operation and names and values of creation parameters
136 //================================================================================
138 bool GEOMImpl_PipePathDriver::
139 GetCreationInformation(std::string& theOperationName,
140 std::vector<GEOM_Param>& theParams)
142 if (Label().IsNull()) return 0;
143 Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
145 GEOMImpl_IPipePath aCI( function );
146 Standard_Integer aType = function->GetType();
148 theOperationName = "PIPE_PATH";
151 case PIPE_PATH_TWO_BASES:
152 AddParam( theParams, "Pipe-like object", aCI.GetShape() );
153 AddParam( theParams, "First base", aCI.GetBase1() );
154 AddParam( theParams, "Second base", aCI.GetBase2() );
156 case PIPE_PATH_TWO_SEQS:
157 AddParam( theParams, "Pipe-like object", aCI.GetShape() );
158 AddParam( theParams, "First bases", aCI.GetBaseSeq1() );
159 AddParam( theParams, "Second bases", aCI.GetBaseSeq2() );
168 OCCT_IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PipePathDriver,GEOM_BaseDriver);