1 // Copyright (C) 2007-2012 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.
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
22 #include <Standard_Stream.hxx>
24 #include <Basics_OCCTVersion.hxx>
26 #include <GEOMImpl_PipePathDriver.hxx>
28 #include <GEOMImpl_IShapesOperations.hxx>
29 #include <GEOMImpl_ShapeDriver.hxx>
30 #include <GEOMImpl_IPipePath.hxx>
31 #include <GEOMImpl_Types.hxx>
32 #include <GEOM_Function.hxx>
34 #include <ShapeAnalysis_FreeBounds.hxx>
35 #include <ShapeAnalysis_Edge.hxx>
36 #include <ShapeFix_Face.hxx>
37 #include <ShapeFix_Shell.hxx>
38 #include <ShapeFix_Shape.hxx>
39 #include <ShapeFix_ShapeTolerance.hxx>
41 #include <BRep_Tool.hxx>
42 #include <BRep_Builder.hxx>
43 #include <BRepBuilderAPI_Copy.hxx>
44 #include <BRepBuilderAPI_MakeFace.hxx>
45 #include <BRepBuilderAPI_MakeWire.hxx>
46 #include <BRepBuilderAPI_Sewing.hxx>
47 #include <BRepCheck_Analyzer.hxx>
48 #include <BRepGProp.hxx>
49 #include <BRepOffsetAPI_MakePipe.hxx>
50 #include <BRepOffsetAPI_MakePipeShell.hxx>
52 #if OCC_VERSION_LARGE > 0x06050300
53 #include <BRepOffsetAPI_MiddlePath.hxx>
58 #include <TopExp_Explorer.hxx>
60 #include <TopoDS_Wire.hxx>
61 #include <TopoDS_Edge.hxx>
62 #include <TopoDS_Shape.hxx>
63 #include <TopoDS_Solid.hxx>
64 #include <TopoDS_Shell.hxx>
65 #include <TopoDS_Face.hxx>
66 #include <TopoDS_Compound.hxx>
67 #include <TopTools_SequenceOfShape.hxx>
68 #include <TopTools_HSequenceOfShape.hxx>
69 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
70 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
71 #include <TopTools_ListIteratorOfListOfShape.hxx>
73 #include <GProp_GProps.hxx>
75 #include <GeomAPI_ProjectPointOnCurve.hxx>
76 #include <GeomAPI_Interpolate.hxx>
77 #include <Geom_TrimmedCurve.hxx>
78 #include <Geom_Plane.hxx>
79 #include <Geom_RectangularTrimmedSurface.hxx>
80 #include <Geom_BezierSurface.hxx>
81 #include <Geom_Line.hxx>
82 #include <Geom_Conic.hxx>
83 #include <Geom_BSplineCurve.hxx>
84 #include <Geom_BSplineSurface.hxx>
85 #include <GeomFill_BSplineCurves.hxx>
86 #include <GeomConvert_ApproxCurve.hxx>
87 #include <GeomConvert.hxx>
89 #include <TColgp_SequenceOfPnt.hxx>
90 #include <TColgp_HArray1OfPnt.hxx>
91 #include <TColgp_Array2OfPnt.hxx>
92 #include <TColStd_HSequenceOfTransient.hxx>
94 #include <Precision.hxx>
96 #include <Standard_NullObject.hxx>
97 #include <Standard_TypeMismatch.hxx>
98 #include <Standard_ConstructionError.hxx>
100 #include "utilities.h"
102 //=======================================================================
105 //=======================================================================
106 const Standard_GUID& GEOMImpl_PipePathDriver::GetID()
108 static Standard_GUID aPipePathDriver ("FF1BBB19-5D14-4df2-980B-3A668264EA17");
109 return aPipePathDriver;
112 //=======================================================================
113 //function : GEOMImpl_PipePathDriver
115 //=======================================================================
116 GEOMImpl_PipePathDriver::GEOMImpl_PipePathDriver()
120 //=======================================================================
123 //=======================================================================
124 Standard_Integer GEOMImpl_PipePathDriver::Execute (TFunction_Logbook& log) const
126 if (Label().IsNull()) return 0;
127 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
128 Standard_Integer aType = aFunction->GetType();
133 if (aType == PIPE_PATH_TWO_BASES) {
134 GEOMImpl_IPipePath aPI (aFunction);
136 Handle(GEOM_Function) aRefShape = aPI.GetShape();
137 Handle(GEOM_Function) aRefBase1 = aPI.GetBase1();
138 Handle(GEOM_Function) aRefBase2 = aPI.GetBase2();
140 TopoDS_Shape aShape = aRefShape->GetValue();
141 TopoDS_Shape aBase1 = aRefBase1->GetValue();
142 TopoDS_Shape aBase2 = aRefBase2->GetValue();
144 if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull())
145 Standard_NullObject::Raise("RestorePath aborted : null argument");
147 #if OCC_VERSION_LARGE > 0x06050300
148 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2);
154 Standard_NullObject::Raise("RestorePath is not implemented in used OCCT version");
157 else if (aType == PIPE_PATH_TWO_SEQS) {
158 GEOMImpl_IPipePath aPI (aFunction);
160 Handle(GEOM_Function) aRefShape = aPI.GetShape();
161 TopoDS_Shape aShape = aRefShape->GetValue();
163 Handle(TColStd_HSequenceOfTransient) aBaseSeq1 = aPI.GetBaseSeq1();
164 Handle(TColStd_HSequenceOfTransient) aBaseSeq2 = aPI.GetBaseSeq2();
169 if (aBaseSeq1->Length() == 1 && aBaseSeq2->Length() == 1) {
170 Handle(GEOM_Function) aRefShape1 = Handle(GEOM_Function)::DownCast(aBaseSeq1->Value(1));
171 Handle(GEOM_Function) aRefShape2 = Handle(GEOM_Function)::DownCast(aBaseSeq2->Value(1));
172 aBase1 = aRefShape1->GetValue();
173 aBase2 = aRefShape2->GetValue();
176 aBase1 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq1, Precision::Confusion());
177 aBase2 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq2, Precision::Confusion());
180 if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull())
181 Standard_NullObject::Raise("RestorePath aborted : null argument");
183 #if OCC_VERSION_LARGE > 0x06050300
184 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2);
190 Standard_NullObject::Raise("RestorePath is not implemented in used OCCT version");
196 if (aRes.IsNull()) return 0;
198 aFunction->SetValue(aRes);
199 log.SetTouched(Label());
204 //=======================================================================
205 //function : GEOMImpl_PipePathDriver_Type_
207 //=======================================================================
208 Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipePathDriver_Type_()
210 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
211 if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
212 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
213 if (aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
214 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
215 if (aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
217 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
218 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_PipePathDriver",
219 sizeof(GEOMImpl_PipePathDriver),
221 (Standard_Address)_Ancestors,
222 (Standard_Address)NULL);
227 //=======================================================================
228 //function : DownCast
230 //=======================================================================
231 const Handle(GEOMImpl_PipePathDriver) Handle(GEOMImpl_PipePathDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
233 Handle(GEOMImpl_PipePathDriver) _anOtherObject;
235 if (!AnObject.IsNull()) {
236 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PipePathDriver))) {
237 _anOtherObject = Handle(GEOMImpl_PipePathDriver)((Handle(GEOMImpl_PipePathDriver)&)AnObject);
241 return _anOtherObject;