+//=============================================================================
+/*!
+ * MakeChamferFacesAD
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
+ (Handle(GEOM_Object) theShape, double theD, double theAngle,
+ std::list<int> theFaces)
+{
+ SetErrorCode(KO);
+
+ //Add a new Chamfer object
+ Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
+
+ //Add a new Chamfer function
+ Handle(GEOM_Function) aFunction =
+ aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
+
+ GEOMImpl_IChamfer aCI (aFunction);
+
+ Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+ if (aRefShape.IsNull()) return NULL;
+
+ aCI.SetShape(aRefShape);
+ aCI.SetD(theD);
+ aCI.SetAngle(theAngle);
+ int aLen = theFaces.size();
+ aCI.SetLength(aLen);
+
+ int ind = 1;
+ std::list<int>::iterator it = theFaces.begin();
+ for (; it != theFaces.end(); it++, ind++) {
+ aCI.SetFace(ind, (*it));
+ }
+
+ //Compute the Chamfer value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Chamfer driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
+ << ", " << theD << ", " << theAngle << ", [";
+
+ it = theFaces.begin();
+ pd << (*it++);
+ while (it != theFaces.end()) {
+ pd << ", " << (*it++);
+ }
+ pd << "])";
+
+ SetErrorCode(OK);
+ return aChamfer;
+}
+
+//=============================================================================
+/*!
+ * MakeChamferEdges
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
+ (Handle(GEOM_Object) theShape, double theD1, double theD2,
+ std::list<int> theEdges)
+{
+ SetErrorCode(KO);
+
+ //Add a new Chamfer object
+ Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
+
+ //Add a new Chamfer function
+ Handle(GEOM_Function) aFunction =
+ aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
+ if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
+ { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
+
+ GEOMImpl_IChamfer aCI (aFunction);
+
+ Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+ if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
+
+ aCI.SetShape(aRefShape);
+ aCI.SetD1(theD1);
+ aCI.SetD2(theD2);
+ int aLen = theEdges.size();
+ aCI.SetLength(aLen);
+
+ int ind = 1;
+ std::list<int>::iterator it = theEdges.begin();
+ for (; it != theEdges.end(); it++, ind++) {
+ aCI.SetEdge(ind, (*it));
+ }
+
+ //Compute the Chamfer value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Chamfer driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
+ << ", " << theD1 << ", " << theD2 << ", [";
+
+ it = theEdges.begin();
+ pd << (*it++);
+ while (it != theEdges.end()) {
+ pd << ", " << (*it++);
+ }
+ pd << "])";
+
+ SetErrorCode(OK);
+ return aChamfer;
+}
+
+//=============================================================================
+/*!
+ * MakeChamferEdgesAD
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
+ (Handle(GEOM_Object) theShape, double theD, double theAngle,
+ std::list<int> theEdges)
+{
+ SetErrorCode(KO);
+
+ //Add a new Chamfer object
+ Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
+
+ //Add a new Chamfer function
+ Handle(GEOM_Function) aFunction =
+ aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
+ if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
+ { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
+
+ GEOMImpl_IChamfer aCI (aFunction);
+
+ Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+ if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
+
+ aCI.SetShape(aRefShape);
+ aCI.SetD(theD);
+ aCI.SetAngle(theAngle);
+ int aLen = theEdges.size();
+ aCI.SetLength(aLen);
+
+ int ind = 1;
+ std::list<int>::iterator it = theEdges.begin();
+ for (; it != theEdges.end(); it++, ind++) {
+ aCI.SetEdge(ind, (*it));
+ }
+
+ //Compute the Chamfer value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Chamfer driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
+ << ", " << theD << ", " << theAngle << ", [";
+
+ it = theEdges.begin();
+ pd << (*it++);
+ while (it != theEdges.end()) {
+ pd << ", " << (*it++);
+ }
+ pd << "])";
+
+ SetErrorCode(OK);
+ return aChamfer;
+}
+