+
+//=============================================================================
+/*!
+ * MakeThruSections
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
+ const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
+ bool theModeSolid,
+ double thePreci,
+ bool theRuled)
+{
+ Handle(GEOM_Object) anObj;
+ SetErrorCode(KO);
+ if(theSeqSections.IsNull())
+ return anObj;
+
+ Standard_Integer nbObj = theSeqSections->Length();
+ if (!nbObj)
+ return anObj;
+
+ //Add a new ThruSections object
+ Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GEOM_THRUSECTIONS);
+
+
+ //Add a new ThruSections function
+
+ int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
+ Handle(GEOM_Function) aFunction =
+ aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
+ if (aFunction.IsNull()) return anObj;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
+
+ GEOMImpl_IThruSections aCI (aFunction);
+
+ Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
+
+ Standard_Integer i =1;
+ for( ; i <= nbObj; i++) {
+
+ Handle(Standard_Transient) anItem = theSeqSections->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!aSectObj.IsNull())
+ {
+ Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
+ if(!aRefSect.IsNull())
+ aSeqSections->Append(aRefSect);
+ }
+ }
+
+ if(!aSeqSections->Length())
+ return anObj;
+
+ aCI.SetSections(aSeqSections);
+ aCI.SetSolidMode(theModeSolid);
+ aCI.SetPrecision(thePreci);
+
+ //Compute the ThruSections value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("ThruSections driver failed");
+ return anObj;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return anObj;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+ pyDump << aThruSect << " = geompy.MakeThruSections([";
+
+ for(i =1 ; i <= nbObj; i++) {
+
+ Handle(Standard_Transient) anItem = theSeqSections->Value(i);
+ if(anItem.IsNull())
+ continue;
+
+ Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
+ if(!aSectObj.IsNull()) {
+ pyDump<< aSectObj;
+ if(i < nbObj)
+ pyDump<<", ";
+ }
+ }
+
+ pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
+
+ SetErrorCode(OK);
+ return aThruSect;
+}
+
+
+//=============================================================================
+/*!
+ * MakePipeWithDifferentSections
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient)
+ GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections
+ (const Handle(TColStd_HSequenceOfTransient) &theBases,
+ const Handle(TColStd_HSequenceOfTransient) &theLocations,
+ const Handle(GEOM_Object) &thePath,
+ const bool theWithContact,
+ const bool theWithCorrections,
+ const bool IsBySteps,
+ const bool IsGenerateGroups)
+{
+ SetErrorCode(KO);
+ if(theBases.IsNull())
+ return NULL;
+
+ Standard_Integer nbBases = theBases->Length();
+
+ if (!nbBases)
+ return NULL;
+
+ Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
+ //Add a new Pipe object
+ Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
+
+ //Add a new Pipe function
+
+ Handle(GEOM_Function) aFunction =
+ aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
+
+ GEOMImpl_IPipeDiffSect aCI (aFunction);
+
+ Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
+ if(aRefPath.IsNull())
+ return NULL;
+
+ 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 NULL;
+
+ aCI.SetBases(aSeqBases);
+ aCI.SetLocations(aSeqLocs);
+ aCI.SetPath(aRefPath);
+
+ if (!IsBySteps) {
+ aCI.SetWithContactMode(theWithContact);
+ aCI.SetWithCorrectionMode(theWithCorrections);
+ }
+
+ aCI.SetIsBySteps(IsBySteps);
+ aCI.SetGenerateGroups(IsGenerateGroups);
+
+ //Compute the Pipe value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe with different section driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ // Create the sequence of objects.
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+
+ aSeq->Append(aPipeDS);
+ createGroups(aPipeDS, &aCI, aSeq);
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+
+ if (IsGenerateGroups) {
+ pyDump << aSeq;
+ } else {
+ pyDump << aPipeDS;
+ }
+
+ if (IsBySteps) {
+ pyDump << " = geompy.MakePipeWithDifferentSectionsBySteps([";
+ } else {
+ pyDump << " = geompy.MakePipeWithDifferentSections([";
+ }
+
+ 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<< "], "<<thePath;
+
+ if (!IsBySteps) {
+ pyDump<<","<<theWithContact << "," << theWithCorrections;
+ }
+
+ if (IsGenerateGroups) {
+ pyDump << ", True";
+ }
+
+ pyDump << ")";
+
+ SetErrorCode(OK);
+ return aSeq;
+}
+
+
+//=============================================================================
+/*!
+ * MakePipeWithShellSections
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient)
+ GEOMImpl_I3DPrimOperations::MakePipeWithShellSections
+ (const Handle(TColStd_HSequenceOfTransient) &theBases,
+ const Handle(TColStd_HSequenceOfTransient) &theSubBases,
+ const Handle(TColStd_HSequenceOfTransient) &theLocations,
+ const Handle(GEOM_Object) &thePath,
+ const bool theWithContact,
+ const bool theWithCorrections,
+ const bool IsGenerateGroups)
+{
+ SetErrorCode(KO);
+ if(theBases.IsNull())
+ return NULL;
+
+ Standard_Integer nbBases = theBases->Length();
+
+ if (!nbBases)
+ return NULL;
+
+ 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(GEOM_PIPE);
+
+ //Add a new Pipe function
+
+ Handle(GEOM_Function) aFunction =
+ aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
+
+ //GEOMImpl_IPipeDiffSect aCI (aFunction);
+ GEOMImpl_IPipeShellSect aCI (aFunction);
+
+ Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
+ if(aRefPath.IsNull())
+ return NULL;
+
+ 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 NULL;
+
+ aCI.SetBases(aSeqBases);
+ aCI.SetSubBases(aSeqSubBases);
+ aCI.SetLocations(aSeqLocs);
+ aCI.SetPath(aRefPath);
+ aCI.SetWithContactMode(theWithContact);
+ aCI.SetWithCorrectionMode(theWithCorrections);
+ aCI.SetGenerateGroups(IsGenerateGroups);
+
+ //Compute the Pipe value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe with shell sections driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ // Create the sequence of objects.
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+
+ aSeq->Append(aPipeDS);
+ createGroups(aPipeDS, &aCI, aSeq);
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+
+ if (IsGenerateGroups) {
+ pyDump << aSeq;
+ } else {
+ pyDump << aPipeDS;
+ }
+
+ pyDump << " = 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;
+
+ if (IsGenerateGroups) {
+ pyDump << ", True";
+ }
+
+ pyDump << ")";
+
+ SetErrorCode(OK);
+ return aSeq;
+
+}
+
+
+//=============================================================================
+/*!
+ * MakePipeShellsWithoutPath
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient)
+ GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath
+ (const Handle(TColStd_HSequenceOfTransient) &theBases,
+ const Handle(TColStd_HSequenceOfTransient) &theLocations,
+ const bool IsGenerateGroups)
+{
+ SetErrorCode(KO);
+ if(theBases.IsNull())
+ return NULL;
+
+ Standard_Integer nbBases = theBases->Length();
+
+ if (!nbBases)
+ return NULL;
+
+ Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
+
+ //Add a new Pipe object
+ Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GEOM_PIPE);
+
+ //Add a new Pipe function
+
+ Handle(GEOM_Function) aFunction =
+ aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
+
+ 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 NULL;
+
+ aCI.SetBases(aSeqBases);
+ aCI.SetLocations(aSeqLocs);
+ aCI.SetGenerateGroups(IsGenerateGroups);
+
+ //Compute the Pipe value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe with shell sections without path driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ // Create the sequence of objects.
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+
+ aSeq->Append(aPipeDS);
+ createGroups(aPipeDS, &aCI, aSeq);
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+
+ if (IsGenerateGroups) {
+ pyDump << aSeq;
+ } else {
+ pyDump << aPipeDS;
+ }
+
+ pyDump << " = 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<< "]";
+
+ if (IsGenerateGroups) {
+ pyDump << ", True";
+ }
+
+ pyDump << ")";
+
+ SetErrorCode(OK);
+ return aSeq;
+
+}
+
+//=============================================================================
+/*!
+ * MakePipeBiNormalAlongVector
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient)
+ GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector
+ (const Handle(GEOM_Object) &theBase,
+ const Handle(GEOM_Object) &thePath,
+ const Handle(GEOM_Object) &theVec,
+ const bool IsGenerateGroups)
+{
+ SetErrorCode(KO);
+
+ if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
+
+ //Add a new Pipe object
+ Handle(GEOM_Object) aPipe = GetEngine()->AddObject(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);
+ aCI.SetGenerateGroups(IsGenerateGroups);
+
+ //Compute the Pipe value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Pipe driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ // Create the sequence of objects.
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+
+ aSeq->Append(aPipe);
+ createGroups(aPipe, &aCI, aSeq);
+
+ //Make a Python command
+ GEOM::TPythonDump pyDump(aFunction);
+
+ if (IsGenerateGroups) {
+ pyDump << aSeq;
+ } else {
+ pyDump << aPipe;
+ }
+
+ pyDump << " = geompy.MakePipeBiNormalAlongVector("
+ << theBase << ", " << thePath << ", " << theVec;
+
+ if (IsGenerateGroups) {
+ pyDump << ", True";
+ }
+
+ pyDump << ")";
+
+ SetErrorCode(OK);
+ return aSeq;
+}
+
+//=============================================================================
+/*!
+ * MakeThickening
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening
+ (Handle(GEOM_Object) theObject,
+ const Handle(TColStd_HArray1OfInteger) &theFacesIDs,
+ double theOffset,
+ bool isCopy,
+ bool theInside)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull()) return NULL;
+
+ Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
+ if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
+
+ //Add a new Offset function
+ Handle(GEOM_Function) aFunction;
+ Handle(GEOM_Object) aCopy;
+ if (isCopy)
+ {
+ //Add a new Copy object
+ aCopy = GetEngine()->AddObject(theObject->GetType());
+ aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
+ }
+ else
+ aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
+
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
+
+ GEOMImpl_IOffset aTI (aFunction);
+ aTI.SetShape(anOriginal);
+ aTI.SetValue(theOffset);
+ aTI.SetParam(theInside);
+
+ if (theFacesIDs.IsNull() == Standard_False) {
+ aTI.SetFaceIDs(theFacesIDs);
+ }
+
+ //Compute the offset
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Offset driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ Handle(GEOM_Object) aResult;
+
+ if (isCopy) {
+ pd << aCopy << " = geompy.MakeThickSolid("
+ << theObject << ", " << theOffset;
+ aResult = aCopy;
+ } else {
+ pd << "geompy.Thicken(" << theObject << ", " << theOffset;
+ aResult = theObject;
+ }
+
+ pd << ", [";
+ if (theFacesIDs.IsNull() == Standard_False) {
+ // Dump faces IDs.
+ Standard_Integer i;
+
+ for (i = theFacesIDs->Lower(); i < theFacesIDs->Upper(); ++i) {
+ pd << theFacesIDs->Value(i) << ", ";
+ }
+ // Dump the last value.
+ pd << theFacesIDs->Value(i);
+ }
+ pd << "]";
+
+ if (theInside)
+ pd << ", " << theInside;
+
+ pd << ")";
+ SetErrorCode(OK);
+
+ return aResult;
+}
+
+//=============================================================================
+/*!
+ * RestorePath
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
+ Handle(GEOM_Object) theBase1,
+ Handle(GEOM_Object) theBase2)
+{
+ SetErrorCode(KO);
+
+ if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
+
+ // Add a new Path object
+ Handle(GEOM_Object) aPath = GetEngine()->AddObject(GEOM_PIPE_PATH);
+
+ // Add a new Path function
+ Handle(GEOM_Function) aFunction =
+ aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
+ if (aFunction.IsNull()) return NULL;
+
+ // Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
+
+ GEOMImpl_IPipePath aCI (aFunction);
+
+ Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+ Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
+ Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
+
+ if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
+
+ aCI.SetShape(aRefShape);
+ aCI.SetBase1(aRefBase1);
+ aCI.SetBase2(aRefBase2);
+
+ // Compute the Path value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("PipePath driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode("RestorePath: inappropriate arguments given");
+ return NULL;
+ }
+
+ // Make a Python command
+ GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
+ << theShape << ", " << theBase1 << ", " << theBase2 << ")";
+
+ SetErrorCode(OK);
+ return aPath;
+}
+
+//=============================================================================
+/*!
+ * RestorePath
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
+ (Handle(GEOM_Object) theShape,
+ const Handle(TColStd_HSequenceOfTransient)& theBase1,
+ const Handle(TColStd_HSequenceOfTransient)& theBase2)
+{
+ SetErrorCode(KO);
+
+ if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
+
+ Standard_Integer nbBases1 = theBase1->Length();
+ Standard_Integer nbBases2 = theBase2->Length();
+
+ if (!nbBases1 || !nbBases2)
+ return NULL;
+
+ // Add a new Path object
+ Handle(GEOM_Object) aPath = GetEngine()->AddObject(GEOM_PIPE_PATH);
+
+ // Add a new Path function
+ Handle(GEOM_Function) aFunction =
+ aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
+ if (aFunction.IsNull()) return NULL;
+
+ // Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
+
+ GEOMImpl_IPipePath aCI (aFunction);
+
+ Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+ if (aRefShape.IsNull()) return NULL;
+
+ Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
+ Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
+
+ Standard_Integer i;
+ for (i = 1; i <= nbBases1; i++) {
+ Handle(Standard_Transient) anItem = theBase1->Value(i);
+ if (!anItem.IsNull()) {
+ Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
+ if (!aBase.IsNull()) {
+ Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
+ if (!aRefBase.IsNull())
+ aSeqBases1->Append(aRefBase);
+ }
+ }
+ }
+ for (i = 1; i <= nbBases2; i++) {
+ Handle(Standard_Transient) anItem = theBase2->Value(i);
+ if (!anItem.IsNull()) {
+ Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
+ if (!aBase.IsNull()) {
+ Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
+ if (!aRefBase.IsNull())
+ aSeqBases2->Append(aRefBase);
+ }
+ }
+ }
+ if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
+
+ aCI.SetShape(aRefShape);
+ aCI.SetBaseSeq1(aSeqBases1);
+ aCI.SetBaseSeq2(aSeqBases2);
+
+ // Compute the Path value
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("PipePath driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode("RestorePath: inappropriate arguments given");
+ return NULL;
+ }
+
+ // Make a Python command
+ GEOM::TPythonDump pyDump (aFunction);
+ pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
+ for (i = 1; i <= nbBases1; i++) {
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
+ if (!anObj.IsNull()) {
+ pyDump << anObj;
+ if (i < nbBases1)
+ pyDump << ", ";
+ }
+ }
+ pyDump<< "], [";
+ for (i = 1; i <= nbBases2; i++) {
+ Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
+ if (!anObj.IsNull()) {
+ pyDump << anObj;
+ if (i < nbBases2)
+ pyDump << ", ";
+ }
+ }
+ pyDump << "])";
+
+ SetErrorCode(OK);
+ return aPath;
+}
+
+//=============================================================================
+/*!
+ * createGroup
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
+ (const Handle(GEOM_Object) &theBaseObject,
+ const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
+ const TCollection_AsciiString &theName,
+ const TopTools_IndexedMapOfShape &theIndices)
+{
+ if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
+ return NULL;
+ }
+
+ // Get the Shape type.
+ const Standard_Integer anID = theGroupIDs->Value(theGroupIDs->Lower());
+ const Standard_Integer aNbShapes = theIndices.Extent();
+
+ if (anID < 1 || anID > aNbShapes) {
+ return NULL;
+ }
+
+ const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
+
+ if (aSubShape.IsNull()) {
+ return NULL;
+ }
+
+ // Create a group.
+ const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
+ Handle(GEOM_Object) aGroup =
+ myGroupOperations->CreateGroup(theBaseObject, aGroupType);
+
+ if (aGroup.IsNull() == Standard_False) {
+ aGroup->GetLastFunction()->SetDescription("");
+ aGroup->SetName(theName.ToCString());
+
+ Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
+ Standard_Integer i;
+
+ for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
+ // Get and check the index.
+ const Standard_Integer anIndex = theGroupIDs->Value(i);
+
+ if (anIndex < 1 || anIndex > aNbShapes) {
+ return NULL;
+ }
+
+ // Get and check the sub-shape.
+ const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
+
+ if (aSubShape.IsNull()) {
+ return NULL;
+ }
+
+ // Check the shape type.
+ if (aSubShape.ShapeType() != aGroupType) {
+ return NULL;
+ }
+
+ aSeqIDs->Append(anIndex);
+ }
+
+ myGroupOperations->UnionIDs(aGroup, aSeqIDs);
+ aGroup->GetLastFunction()->SetDescription("");
+ }
+
+ return aGroup;
+}
+
+//=============================================================================
+/*!
+ * createGroups
+ */
+//=============================================================================
+void GEOMImpl_I3DPrimOperations::createGroups
+ (const Handle(GEOM_Object) &theBaseObject,
+ GEOMImpl_IPipe *thePipe,
+ Handle(TColStd_HSequenceOfTransient) &theSequence)
+{
+ if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
+ return;
+ }
+
+ TopoDS_Shape aShape = theBaseObject->GetValue();
+
+ if (aShape.IsNull()) {
+ return;
+ }
+
+ TopTools_IndexedMapOfShape anIndices;
+ Handle(TColStd_HArray1OfInteger) aGroupIDs;
+ TopoDS_Shape aShapeType;
+ const Standard_Integer aNbGroups = 5;
+ Handle(GEOM_Object) aGrps[aNbGroups];
+ Standard_Integer i;
+
+ TopExp::MapShapes(aShape, anIndices);
+
+ // Create groups.
+ aGroupIDs = thePipe->GetGroupDown();
+ aGrps[0] = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
+ aGroupIDs = thePipe->GetGroupUp();
+ aGrps[1] = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
+ aGroupIDs = thePipe->GetGroupSide1();
+ aGrps[2] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
+ aGroupIDs = thePipe->GetGroupSide2();
+ aGrps[3] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
+ aGroupIDs = thePipe->GetGroupOther();
+ aGrps[4] = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
+
+ for (i = 0; i < aNbGroups; ++i) {
+ if (aGrps[i].IsNull() == Standard_False) {
+ theSequence->Append(aGrps[i]);
+ }
+ }
+}