+//=============================================================================
+/*!
+ * DivideEdgeByPoint
+ */
+//=============================================================================
+Handle(GEOM_Object)
+GEOMImpl_IHealingOperations::DivideEdgeByPoint (Handle(GEOM_Object) theObject,
+ int theIndex,
+ std::list< Handle(GEOM_Object)> & thePoints)
+{
+ // set error code, check parameters
+ SetErrorCode(KO);
+
+ if (theObject.IsNull() || thePoints.empty() )
+ return NULL;
+
+ Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
+ if (aLastFunction.IsNull() )
+ return NULL; //There is no function which creates an object to be processed
+
+ Handle(TColStd_HSequenceOfTransient) aPointFunc = GEOM_Object::GetLastFunctions( thePoints );
+ if ( aPointFunc.IsNull() || aPointFunc->IsEmpty() ) {
+ SetErrorCode("NULL argument points");
+ return NULL;
+ }
+
+ // Add a new object
+ Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GEOM_COPY );
+
+ //Add the function
+ aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE_BY_POINT);
+
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
+
+ // prepare "data container" class IHealing
+ GEOMImpl_IHealing HI(aFunction);
+ HI.SetIndex ( theIndex );
+ HI.SetOriginal ( aLastFunction );
+ HI.SetShapes ( aPointFunc );
+
+ HI.SetStatistics( myModifStats );
+
+ //Compute the translation
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Healing driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction)
+ << aNewObject << " = geompy.DivideEdgeByPoint(" << theObject
+ << ", " << theIndex << ", " << thePoints << ")";
+
+ SetErrorCode(OK);
+ return aNewObject;
+}
+
+//=============================================================================
+/*!
+ * FuseCollinearEdgesWithinWire
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IHealingOperations::FuseCollinearEdgesWithinWire
+ (Handle(GEOM_Object) theWire,
+ std::list<Handle(GEOM_Object)> theVertices)
+{
+ SetErrorCode(KO);
+
+ if (theWire.IsNull()) return NULL;
+
+ // Add a new object
+ Handle(GEOM_Object) aRes = GetEngine()->AddObject(theWire->GetType());
+
+ // Add a new function
+ Handle(GEOM_Function) aFunction;
+ aFunction = aRes->AddFunction(GEOMImpl_HealingDriver::GetID(), FUSE_COLLINEAR_EDGES);
+ if (aFunction.IsNull()) return NULL;
+
+ // Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
+
+ GEOMImpl_IHealing aCI (aFunction);
+ aCI.SetStatistics( myModifStats );
+
+ Handle(GEOM_Function) aRefShape = theWire->GetLastFunction();
+ if (aRefShape.IsNull()) return NULL;
+ aCI.SetOriginal(aRefShape);
+
+ Handle(TColStd_HSequenceOfTransient) aVertices = new TColStd_HSequenceOfTransient;
+ std::list<Handle(GEOM_Object)>::iterator it = theVertices.begin();
+ for (; it != theVertices.end(); it++) {
+ Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
+ if (aRefSh.IsNull()) {
+ SetErrorCode("NULL argument shape for the shape construction");
+ return NULL;
+ }
+ aVertices->Append(aRefSh);
+ }
+ aCI.SetShapes(aVertices);
+
+ // Compute the new wire
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Healing driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ // Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ pd << aRes << " = geompy.FuseCollinearEdgesWithinWire(" << theWire << ", [";
+ // Vertices
+ it = theVertices.begin();
+ if (it != theVertices.end()) {
+ pd << (*it++);
+ while (it != theVertices.end()) {
+ pd << ", " << (*it++);
+ }
+ }
+ pd << "])";
+
+ SetErrorCode(OK);
+ return aRes;
+}
+