+}
+
+
+//=============================================================================
+/*!
+ * MakePipeWithShellSections
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
+ const Handle(TColStd_HSequenceOfTransient)& theBases,
+ const Handle(TColStd_HSequenceOfTransient)& theSubBases,
+ const Handle(TColStd_HSequenceOfTransient)& theLocations,
+ const Handle(GEOM_Object)& thePath,
+ bool theWithContact,
+ bool theWithCorrections)
+{
+ Handle(GEOM_Object) anObj;
+ SetErrorCode(KO);
+ if(theBases.IsNull())
+ return anObj;
+
+ Standard_Integer nbBases = theBases->Length();
+
+ if (!nbBases)
+ return anObj;
+
+ Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
+
+ Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
+
+ //Add a new Pipe object
+ Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
+
+ //Add a new Pipe function
+
+ Handle(GEOM_Function) aFunction =
+ aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
+ if (aFunction.IsNull()) return anObj;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
+
+ //GEOMImpl_IPipeDiffSect aCI (aFunction);
+ GEOMImpl_IPipeShellSect aCI (aFunction);
+
+ Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
+ if(aRefPath.IsNull())
+ return anObj;
+
+ Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
+ Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
+ Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
+
+ Standard_Integer i =1;
+ for( ; i <= nbBases; i++) {
+
+ Handle(Standard_Transient) anItem = theBases->Value(i);
+ if(anItem.IsNull())
+ continue;
+ Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
+ if(aBase.IsNull())
+ continue;
+ Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
+ if(aRefBase.IsNull())
+ continue;
+
+ if( nbSubBases >= nbBases ) {
+ Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
+ if(aSubItem.IsNull())
+ continue;
+ Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
+ if(aSubBase.IsNull())
+ continue;
+ Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
+ if(aRefSubBase.IsNull())
+ continue;
+ aSeqSubBases->Append(aRefSubBase);
+ }
+
+ if(nbLocs) {
+ Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
+ if(anItemLoc.IsNull())
+ continue;
+ Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
+ if(aLoc.IsNull())
+ continue;
+ Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
+ if(aRefLoc.IsNull())
+ continue;
+ aSeqLocs->Append(aRefLoc);
+ }
+
+ aSeqBases->Append(aRefBase);
+ }
+
+ if(!aSeqBases->Length())
+ return anObj;
+
+ aCI.SetBases(aSeqBases);
+ aCI.SetSubBases(aSeqSubBases);
+ aCI.SetLocations(aSeqLocs);
+ aCI.SetPath(aRefPath);
+ aCI.SetWithContactMode(theWithContact);
+ aCI.SetWithCorrectionMode(theWithCorrections);
+
+ //Compute the Pipe value
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe with shell sections driver failed");
+ return anObj;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return anObj;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+ pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
+
+ for(i =1 ; i <= nbBases; i++) {
+
+ Handle(Standard_Transient) anItem = theBases->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!anObj.IsNull()) {
+ pyDump<< anObj;
+ if(i < nbBases)
+ pyDump<<", ";
+ }
+ }
+
+ pyDump<< "], [";
+
+ for(i =1 ; i <= nbSubBases; i++) {
+
+ Handle(Standard_Transient) anItem = theSubBases->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!anObj.IsNull()) {
+ pyDump<< anObj;
+ if(i < nbBases)
+ pyDump<<", ";
+ }
+ }
+
+ pyDump<< "], [";
+
+ for(i =1 ; i <= nbLocs; i++) {
+
+ Handle(Standard_Transient) anItem = theLocations->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!anObj.IsNull()) {
+ pyDump<< anObj;
+ if(i < nbLocs)
+ pyDump<<", ";
+ }
+ }
+
+ pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
+
+ SetErrorCode(OK);
+ return aPipeDS;
+
+}
+
+
+//=============================================================================
+/*!
+ * MakePipeShellsWithoutPath
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
+ const Handle(TColStd_HSequenceOfTransient)& theBases,
+ const Handle(TColStd_HSequenceOfTransient)& theLocations)
+{
+ Handle(GEOM_Object) anObj;
+ SetErrorCode(KO);
+ if(theBases.IsNull())
+ return anObj;
+
+ Standard_Integer nbBases = theBases->Length();
+
+ if (!nbBases)
+ return anObj;
+
+ Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
+
+ //Add a new Pipe object
+ Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
+
+ //Add a new Pipe function
+
+ Handle(GEOM_Function) aFunction =
+ aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
+ if (aFunction.IsNull()) return anObj;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
+
+ GEOMImpl_IPipeShellSect aCI (aFunction);
+
+ Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
+ Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
+
+ Standard_Integer i =1;
+ for( ; i <= nbBases; i++) {
+
+ Handle(Standard_Transient) anItem = theBases->Value(i);
+ if(anItem.IsNull())
+ continue;
+ Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
+ if(aBase.IsNull())
+ continue;
+ Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
+ if(aRefBase.IsNull())
+ continue;
+
+ if(nbLocs) {
+ Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
+ if(anItemLoc.IsNull())
+ continue;
+ Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
+ if(aLoc.IsNull())
+ continue;
+ Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
+ if(aRefLoc.IsNull())
+ continue;
+ aSeqLocs->Append(aRefLoc);
+ }
+
+ aSeqBases->Append(aRefBase);
+ }
+
+ if(!aSeqBases->Length())
+ return anObj;
+
+ aCI.SetBases(aSeqBases);
+ aCI.SetLocations(aSeqLocs);
+
+ //Compute the Pipe value
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe with shell sections without path driver failed");
+ return anObj;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return anObj;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+ pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
+
+ for(i =1 ; i <= nbBases; i++) {
+
+ Handle(Standard_Transient) anItem = theBases->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!anObj.IsNull()) {
+ pyDump<< anObj;
+ if(i < nbBases)
+ pyDump<<", ";
+ }
+ }
+
+ pyDump<< "], [";
+
+ for(i =1 ; i <= nbLocs; i++) {
+
+ Handle(Standard_Transient) anItem = theLocations->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!anObj.IsNull()) {
+ pyDump<< anObj;
+ if(i < nbLocs)
+ pyDump<<", ";
+ }
+ }
+
+ pyDump<< "])";
+
+ SetErrorCode(OK);
+ return aPipeDS;
+
+}
+
+
+//=============================================================================
+/*!
+ * MakePipeBiNormalAlongVector
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
+ Handle(GEOM_Object) thePath,
+ Handle(GEOM_Object) theVec)
+{
+ SetErrorCode(KO);
+
+ if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
+
+ //Add a new Pipe object
+ Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
+
+ //Add a new Pipe function
+ Handle(GEOM_Function) aFunction =
+ aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
+
+ GEOMImpl_IPipeBiNormal aCI (aFunction);
+
+ Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
+ Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
+ Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
+
+ if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
+
+ aCI.SetBase(aRefBase);
+ aCI.SetPath(aRefPath);
+ aCI.SetVector(aRefVec);
+
+ //Compute the Pipe value
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
+ << theBase << ", " << thePath << ", " << theVec << ")";
+
+ SetErrorCode(OK);
+ return aPipe;