#include <GEOMImpl_IDisk.hxx>
#include <GEOMImpl_ICylinder.hxx>
#include <GEOMImpl_ICone.hxx>
+#include <GEOMImpl_IGroupOperations.hxx>
#include <GEOMImpl_ISphere.hxx>
#include <GEOMImpl_ITorus.hxx>
#include <GEOMImpl_IPrism.hxx>
#include <GEOMImpl_IPipePath.hxx>
#include <Precision.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
: GEOM_IOperations(theEngine, theDocID)
{
MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
+ myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
}
//=============================================================================
GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
{
MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
+ delete myGroupOperations;
}
aCI.SetBase(aRefBase);
aCI.SetPath(aRefPath);
+ aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value
try {
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);
aCI.SetPath(aRefPath);
aCI.SetWithContactMode(theWithContact);
aCI.SetWithCorrectionMode(theWithCorrections);
+ aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value
try {
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);
aCI.SetPath(aRefPath);
aCI.SetWithContactMode(theWithContact);
aCI.SetWithCorrectionMode(theWithCorrections);
+ aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value
try {
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);
aCI.SetBases(aSeqBases);
aCI.SetLocations(aSeqLocs);
+ aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value
try {
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);
aCI.SetBase(aRefBase);
aCI.SetPath(aRefPath);
aCI.SetVector(aRefVec);
+ aCI.SetGenerateGroups(IsGenerateGroups);
//Compute the Pipe value
try {
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);
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]);
+ }
+ }
+}
#include "GEOM_Function.hxx"
-#define PIPE_ARG_BASE 1
-#define PIPE_ARG_PATH 2
+#include <TColStd_HArray1OfInteger.hxx>
+
+// ---- GEOMImpl_IPipe
+#define PIPE_ARG_BASE 1
+#define PIPE_ARG_PATH 2
+
+// ---- GEOMImpl_IPipeBiNormal
+#define PIPE_ARG_VEC 3
+
+// ---- GEOMImpl_IPipeDiffSect
+#define PIPEDS_LIST_BASES 1
+//#define PIPEDS_ARG_PATH 2
+#define PIPEDS_LIST_LOCATIONS 3
+#define PIPEDS_ARG_WITHCONTACT 4
+#define PIPEDS_ARG_WITHCORRECT 5
+
+// ---- GEOMImpl_IPipeShellSect
+#define PIPEDS_LIST_SUBBASES 6
+
+// ---- Generate groups block (common)
+#define PIPE_GENERATE_GROUPS 7
+#define PIPE_GROUP_DOWN 8
+#define PIPE_GROUP_UP 9
+#define PIPE_GROUP_SIDE1 10
+#define PIPE_GROUP_SIDE2 11
+#define PIPE_GROUP_OTHER 12
+
class GEOMImpl_IPipe
{
public:
GEOMImpl_IPipe(Handle(GEOM_Function) theFunction): _func(theFunction) {}
+ virtual ~GEOMImpl_IPipe() {}
void SetBase (Handle(GEOM_Function) theBase) { _func->SetReference(PIPE_ARG_BASE, theBase); }
void SetPath (Handle(GEOM_Function) thePath) { _func->SetReference(PIPE_ARG_PATH, thePath); }
+ void SetGenerateGroups (int theGenerateGroups)
+ { _func->SetInteger(PIPE_GENERATE_GROUPS, theGenerateGroups); }
+ void SetGroupDown (const Handle(TColStd_HArray1OfInteger) &theGroup)
+ { _func->SetIntegerArray(PIPE_GROUP_DOWN, theGroup); }
+ void SetGroupUp (const Handle(TColStd_HArray1OfInteger) &theGroup)
+ { _func->SetIntegerArray(PIPE_GROUP_UP, theGroup); }
+ void SetGroupSide1 (const Handle(TColStd_HArray1OfInteger) &theGroup)
+ { _func->SetIntegerArray(PIPE_GROUP_SIDE1, theGroup); }
+ void SetGroupSide2 (const Handle(TColStd_HArray1OfInteger) &theGroup)
+ { _func->SetIntegerArray(PIPE_GROUP_SIDE2, theGroup); }
+ void SetGroupOther (const Handle(TColStd_HArray1OfInteger) &theGroup)
+ { _func->SetIntegerArray(PIPE_GROUP_OTHER, theGroup); }
Handle(GEOM_Function) GetBase() { return _func->GetReference(PIPE_ARG_BASE); }
Handle(GEOM_Function) GetPath() { return _func->GetReference(PIPE_ARG_PATH); }
+ int GetGenerateGroups () { return _func->GetInteger(PIPE_GENERATE_GROUPS); }
+ Handle(TColStd_HArray1OfInteger) GetGroupDown ()
+ { return _func->GetIntegerArray(PIPE_GROUP_DOWN); }
+ Handle(TColStd_HArray1OfInteger) GetGroupUp ()
+ { return _func->GetIntegerArray(PIPE_GROUP_UP); }
+ Handle(TColStd_HArray1OfInteger) GetGroupSide1 ()
+ { return _func->GetIntegerArray(PIPE_GROUP_SIDE1); }
+ Handle(TColStd_HArray1OfInteger) GetGroupSide2 ()
+ { return _func->GetIntegerArray(PIPE_GROUP_SIDE2); }
+ Handle(TColStd_HArray1OfInteger) GetGroupOther ()
+ { return _func->GetIntegerArray(PIPE_GROUP_OTHER); }
protected: