3 #include "GEOMImpl_GlueDriver.hxx"
4 #include "GEOMImpl_IGlue.hxx"
5 #include "GEOMImpl_Types.hxx"
7 #include "GEOM_Function.hxx"
9 #include "GEOMAlgo_Gluer.hxx"
11 #include "utilities.h"
13 #include <TopoDS_Shape.hxx>
14 #include <Standard_NullObject.hxx>
16 //=======================================================================
17 //function : GEOMImpl_GlueDriver
19 //=======================================================================
20 GEOMImpl_GlueDriver::GEOMImpl_GlueDriver()
24 //=======================================================================
27 //=======================================================================
28 const Standard_GUID& GEOMImpl_GlueDriver::GetID()
30 static Standard_GUID aGlueDriver("FF1BBB63-5D14-4df2-980B-3A668264EA16");
34 //=======================================================================
35 //function : GlueFaces
37 //=======================================================================
38 TopoDS_Shape GEOMImpl_GlueDriver::GlueFaces (const TopoDS_Shape& theShape,
39 const Standard_Real theTolerance)
41 Standard_Integer iErr, iWrn;
43 GEOMAlgo_Gluer aGluer;
45 aGluer.SetShape(theShape);
46 aGluer.SetTolerance(theTolerance);
47 aGluer.SetCheckGeometry(Standard_True);
51 iErr = aGluer.ErrorStatus();
55 Standard_Failure::Raise("No vertices found in source shape");
58 Standard_Failure::Raise("Source shape is Null");
61 Standard_Failure::Raise("Result shape is Null");
64 Standard_Failure::Raise("Error occured during check of geometric coincidence");
68 // description of all errors see in GEOMAlgo_Gluer.cxx
69 TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer with code ");
70 aMsg += TCollection_AsciiString(iErr);
71 Standard_Failure::Raise(aMsg.ToCString());
78 iWrn = aGluer.WarningStatus();
82 MESSAGE("Some shapes can not be glued by faces");
85 // description of all warnings see in GEOMAlgo_Gluer.cxx
86 MESSAGE("Warning in GEOMAlgo_Gluer with code " << iWrn);
91 aRes = aGluer.Result();
96 //=======================================================================
99 //=======================================================================
100 Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const
102 if (Label().IsNull()) return 0;
103 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
105 GEOMImpl_IGlue aCI (aFunction);
106 Standard_Integer aType = aFunction->GetType();
110 if (aType == GLUE_FACES) {
111 Handle(GEOM_Function) aRefBase = aCI.GetBase();
112 TopoDS_Shape aShapeBase = aRefBase->GetValue();
113 if (aShapeBase.IsNull()) {
114 Standard_NullObject::Raise("Shape for gluing is null");
117 Standard_Real tol3d = aCI.GetTolerance();
118 aShape = GlueFaces(aShapeBase, tol3d);
122 if (aShape.IsNull()) return 0;
124 aFunction->SetValue(aShape);
126 log.SetTouched(Label());
131 //=======================================================================
132 //function : GEOMImpl_GlueDriver_Type_
134 //=======================================================================
135 Standard_EXPORT Handle_Standard_Type& GEOMImpl_GlueDriver_Type_()
138 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
139 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
140 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
141 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
142 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
143 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
146 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
147 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_GlueDriver",
148 sizeof(GEOMImpl_GlueDriver),
150 (Standard_Address)_Ancestors,
151 (Standard_Address)NULL);
156 //=======================================================================
157 //function : DownCast
159 //=======================================================================
160 const Handle(GEOMImpl_GlueDriver) Handle(GEOMImpl_GlueDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
162 Handle(GEOMImpl_GlueDriver) _anOtherObject;
164 if (!AnObject.IsNull()) {
165 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_GlueDriver))) {
166 _anOtherObject = Handle(GEOMImpl_GlueDriver)((Handle(GEOMImpl_GlueDriver)&)AnObject);
170 return _anOtherObject ;