-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include <Standard_Stream.hxx>
#include <GEOM_PythonDump.hxx>
#include "utilities.h"
-#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
#include <TFunction_DriverTable.hxx>
#include <TFunction_Driver.hxx>
-#include <TFunction_Logbook.hxx>
#include <TDF_Tool.hxx>
#include <TDataStd_Integer.hxx>
* constructor:
*/
//=============================================================================
-GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine, int theDocID)
-: GEOM_IOperations(theEngine, theDocID)
+GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
{
MESSAGE("GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations");
}
{
SetErrorCode(KO);
+ if ( theShapeType != TopAbs_VERTEX && theShapeType != TopAbs_EDGE &&
+ theShapeType != TopAbs_FACE && theShapeType != TopAbs_SOLID ) {
+ SetErrorCode( "Error: You could create group of only next type: vertex, edge, face or solid" );
+ return NULL;
+ }
+
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, -1);
SetErrorCode(KO);
if(theGroup.IsNull()) return;
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return;
+ }
+
Handle(GEOM_Function) aFunction = theGroup->GetLastFunction();
if(aFunction.IsNull()) return;
TopTools_IndexedMapOfShape aMapOfShapes;
TopExp::MapShapes(aMainShape, aMapOfShapes);
+ TopAbs_ShapeEnum aGroupType = GetType(theGroup);
+ TopAbs_ShapeEnum aShapeType = aMapOfShapes.FindKey(theSubShapeID).ShapeType();
+ if ( aGroupType != aShapeType ) {
+ SetErrorCode( "Error: You could perform this operation only with object the same type as the type of group." );
+ return;
+ }
+
if (theSubShapeID < 1 || aMapOfShapes.Extent() < theSubShapeID) {
SetErrorCode("Invalid sub-shape index: out of range");
return;
SetErrorCode(KO);
if(theGroup.IsNull()) return;
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return;
+ }
+
Handle(GEOM_Function) aFunction = theGroup->GetLastFunction();
if(aFunction.IsNull()) return;
SetErrorCode(KO);
if (theGroup.IsNull()) return;
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return;
+ }
+
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
//SetErrorCode("The list is empty");
SetErrorCode(KO);
if (theGroup.IsNull()) return;
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return;
+ }
+
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
//SetErrorCode("The list is empty");
SetErrorCode(KO);
if (theGroup.IsNull()) return;
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return;
+ }
+
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
//SetErrorCode("The list is empty");
SetErrorCode(KO);
if (theGroup.IsNull()) return;
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return;
+ }
+
Standard_Integer aLen = theSubShapes->Length();
if (aLen < 1) {
//SetErrorCode("The list is empty");
SetErrorCode(KO);
if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL;
+ if ( theGroup1->GetType() != GEOM_GROUP || theGroup2->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
+
// Get group type
TopAbs_ShapeEnum aType1 = GetType(theGroup1);
TopAbs_ShapeEnum aType2 = GetType(theGroup2);
SetErrorCode(KO);
if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL;
+ if ( theGroup1->GetType() != GEOM_GROUP || theGroup2->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
+
// Get group type
TopAbs_ShapeEnum aType1 = GetType(theGroup1);
TopAbs_ShapeEnum aType2 = GetType(theGroup2);
SetErrorCode(KO);
if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL;
+ if ( theGroup1->GetType() != GEOM_GROUP || theGroup2->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
+
// Get group type
TopAbs_ShapeEnum aType1 = GetType(theGroup1);
TopAbs_ShapeEnum aType2 = GetType(theGroup2);
return NULL;
}
- TopAbs_ShapeEnum aType, aType_i;
+ TopAbs_ShapeEnum aType = TopAbs_SHAPE, aType_i; // todo: refactor: aType must be initialized to avoid warning (see below)
TDF_Label aLabel, aLabel_i;
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
// Iterate on the initial groups
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i));
-
+ if ( aGr_i->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
// Get group type
aType_i = GetType(aGr_i);
if (i == 1)
aType = aType_i;
else {
if (aType_i != aType) {
- if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
+ if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) { // todo: refactor: aType must be initialized to avoid warning (see above)
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
return NULL;
}
- TopAbs_ShapeEnum aType, aType_i;
+ TopAbs_ShapeEnum aType = TopAbs_SHAPE, aType_i; // todo: refactor: aType must be initialized to avoid warning (see below)
TDF_Label aLabel, aLabel_i;
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
// Iterate on the initial groups
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i));
-
+ if ( aGr_i->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
// Get group type
aType_i = GetType(aGr_i);
if (i == 1)
aType = aType_i;
else {
if (aType_i != aType) {
- if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
+ if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) { // todo: refactor: aType must be initialized to avoid warning (see above)
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
return NULL;
}
- TopAbs_ShapeEnum aType, aType_i;
+ TopAbs_ShapeEnum aType = TopAbs_SHAPE, aType_i; // todo: refactor: aType must be initialized to avoid warning (see below)
TDF_Label aLabel, aLabel_i;
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
// 1. Collect indices to be excluded (from theGList2) into the mapIDs
for (i = 1; i <= aLen2; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList2->Value(i));
-
+ if ( aGr_i->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
// Get group type
aType_i = GetType(aGr_i);
if (i == 1)
// 2. Collect indices from theGList1, avoiding indices from theGList2 (mapIDs)
for (i = 1; i <= aLen1; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList1->Value(i));
-
+ if ( aGr_i->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
// Get group type
aType_i = GetType(aGr_i);
if (i == 1 && aLen2 < 1)
aType = aType_i;
else {
if (aType_i != aType) {
- if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
+ if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) { // todo: refactor: aType must be initialized to avoid warning (see above)
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
{
SetErrorCode(KO);
- if(theGroup.IsNull()) return NULL;
+ if (theGroup.IsNull()) return NULL;
+ if (theGroup->GetType() != GEOM_GROUP &&
+ theGroup->GetType() != GEOM_SUBSHAPE) {
+ SetErrorCode("Error: You could perform this operation only with a group or a sub-shape.");
+ return NULL;
+ }
Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1);
if (aGroupFunction.IsNull()) return NULL;
SetErrorCode(KO);
if(theGroup.IsNull()) return NULL;
-
+ if ( theGroup->GetType() != GEOM_GROUP ) {
+ SetErrorCode( "Error: You could perform this operation only with group. Please select a group." );
+ return NULL;
+ }
Handle(GEOM_Function) aFunction = theGroup->GetLastFunction();
if(aFunction.IsNull()) return NULL;