1 // Copyright (C) 2007-2014 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 <Standard_Stream.hxx>
25 #include <Basics_OCCTVersion.hxx>
27 #include <GEOMImpl_PipePathDriver.hxx>
29 #include <GEOMImpl_IShapesOperations.hxx>
30 #include <GEOMImpl_ShapeDriver.hxx>
31 #include <GEOMImpl_IPipePath.hxx>
32 #include <GEOMImpl_Types.hxx>
33 #include <GEOM_Function.hxx>
35 #include <ShapeAnalysis_FreeBounds.hxx>
36 #include <ShapeAnalysis_Edge.hxx>
37 #include <ShapeFix_Face.hxx>
38 #include <ShapeFix_Shell.hxx>
39 #include <ShapeFix_Shape.hxx>
40 #include <ShapeFix_ShapeTolerance.hxx>
42 #include <BRep_Tool.hxx>
43 #include <BRep_Builder.hxx>
44 #include <BRepBuilderAPI_Copy.hxx>
45 #include <BRepBuilderAPI_MakeFace.hxx>
46 #include <BRepBuilderAPI_MakeWire.hxx>
47 #include <BRepBuilderAPI_Sewing.hxx>
48 #include <BRepCheck_Analyzer.hxx>
49 #include <BRepGProp.hxx>
50 #include <BRepOffsetAPI_MakePipe.hxx>
51 #include <BRepOffsetAPI_MakePipeShell.hxx>
53 #include <BRepOffsetAPI_MiddlePath.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <TopoDS_Wire.hxx>
60 #include <TopoDS_Edge.hxx>
61 #include <TopoDS_Shape.hxx>
62 #include <TopoDS_Solid.hxx>
63 #include <TopoDS_Shell.hxx>
64 #include <TopoDS_Face.hxx>
65 #include <TopoDS_Compound.hxx>
66 #include <TopTools_SequenceOfShape.hxx>
67 #include <TopTools_HSequenceOfShape.hxx>
68 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
69 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
70 #include <TopTools_ListIteratorOfListOfShape.hxx>
72 #include <GProp_GProps.hxx>
74 #include <GeomAPI_ProjectPointOnCurve.hxx>
75 #include <GeomAPI_Interpolate.hxx>
76 #include <Geom_TrimmedCurve.hxx>
77 #include <Geom_Plane.hxx>
78 #include <Geom_RectangularTrimmedSurface.hxx>
79 #include <Geom_BezierSurface.hxx>
80 #include <Geom_Line.hxx>
81 #include <Geom_Conic.hxx>
82 #include <Geom_BSplineCurve.hxx>
83 #include <Geom_BSplineSurface.hxx>
84 #include <GeomFill_BSplineCurves.hxx>
85 #include <GeomConvert_ApproxCurve.hxx>
86 #include <GeomConvert.hxx>
88 #include <TColgp_SequenceOfPnt.hxx>
89 #include <TColgp_HArray1OfPnt.hxx>
90 #include <TColgp_Array2OfPnt.hxx>
91 #include <TColStd_HSequenceOfTransient.hxx>
93 #include <Precision.hxx>
95 #include <Standard_NullObject.hxx>
96 #include <Standard_TypeMismatch.hxx>
97 #include <Standard_ConstructionError.hxx>
99 #include "utilities.h"
101 //=======================================================================
104 //=======================================================================
105 const Standard_GUID& GEOMImpl_PipePathDriver::GetID()
107 static Standard_GUID aPipePathDriver ("FF1BBB19-5D14-4df2-980B-3A668264EA17");
108 return aPipePathDriver;
111 //=======================================================================
112 //function : GEOMImpl_PipePathDriver
114 //=======================================================================
115 GEOMImpl_PipePathDriver::GEOMImpl_PipePathDriver()
119 //=======================================================================
122 //=======================================================================
123 Standard_Integer GEOMImpl_PipePathDriver::Execute (TFunction_Logbook& log) const
125 if (Label().IsNull()) return 0;
126 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
127 Standard_Integer aType = aFunction->GetType();
132 if (aType == PIPE_PATH_TWO_BASES) {
133 GEOMImpl_IPipePath aPI (aFunction);
135 Handle(GEOM_Function) aRefShape = aPI.GetShape();
136 Handle(GEOM_Function) aRefBase1 = aPI.GetBase1();
137 Handle(GEOM_Function) aRefBase2 = aPI.GetBase2();
139 TopoDS_Shape aShape = aRefShape->GetValue();
140 TopoDS_Shape aBase1 = aRefBase1->GetValue();
141 TopoDS_Shape aBase2 = aRefBase2->GetValue();
143 if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull())
144 Standard_NullObject::Raise("RestorePath aborted : null argument");
146 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2);
152 else if (aType == PIPE_PATH_TWO_SEQS) {
153 GEOMImpl_IPipePath aPI (aFunction);
155 Handle(GEOM_Function) aRefShape = aPI.GetShape();
156 TopoDS_Shape aShape = aRefShape->GetValue();
158 Handle(TColStd_HSequenceOfTransient) aBaseSeq1 = aPI.GetBaseSeq1();
159 Handle(TColStd_HSequenceOfTransient) aBaseSeq2 = aPI.GetBaseSeq2();
164 if (aBaseSeq1->Length() == 1 && aBaseSeq2->Length() == 1) {
165 Handle(GEOM_Function) aRefShape1 = Handle(GEOM_Function)::DownCast(aBaseSeq1->Value(1));
166 Handle(GEOM_Function) aRefShape2 = Handle(GEOM_Function)::DownCast(aBaseSeq2->Value(1));
167 aBase1 = aRefShape1->GetValue();
168 aBase2 = aRefShape2->GetValue();
171 aBase1 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq1, Precision::Confusion());
172 aBase2 = GEOMImpl_ShapeDriver::MakeWireFromEdges(aBaseSeq2, Precision::Confusion());
175 if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull())
176 Standard_NullObject::Raise("RestorePath aborted : null argument");
178 BRepOffsetAPI_MiddlePath aMPB (aShape, aBase1, aBase2);
187 if (aRes.IsNull()) return 0;
189 aFunction->SetValue(aRes);
190 log.SetTouched(Label());
195 //================================================================================
197 * \brief Returns a name of creation operation and names and values of creation parameters
199 //================================================================================
201 bool GEOMImpl_PipePathDriver::
202 GetCreationInformation(std::string& theOperationName,
203 std::vector<GEOM_Param>& theParams)
205 if (Label().IsNull()) return 0;
206 Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
208 GEOMImpl_IPipePath aCI( function );
209 Standard_Integer aType = function->GetType();
211 theOperationName = "PIPE_PATH";
214 case PIPE_PATH_TWO_BASES:
215 AddParam( theParams, "Pipe-like object", aCI.GetShape() );
216 AddParam( theParams, "First base", aCI.GetBase1() );
217 AddParam( theParams, "Second base", aCI.GetBase2() );
219 case PIPE_PATH_TWO_SEQS:
220 AddParam( theParams, "Pipe-like object", aCI.GetShape() );
221 AddParam( theParams, "First bases", aCI.GetBaseSeq1() );
222 AddParam( theParams, "Second bases", aCI.GetBaseSeq2() );
231 IMPLEMENT_STANDARD_HANDLE (GEOMImpl_PipePathDriver,GEOM_BaseDriver);
232 IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_PipePathDriver,GEOM_BaseDriver);