From 53b008ef0df90c10d56f8f7b6dfeb96649361e6e Mon Sep 17 00:00:00 2001 From: nge Date: Tue, 21 Jul 2009 13:13:56 +0000 Subject: [PATCH] NGE: Add Group management --- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 21 +++++ src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 13 ++-- src/PluginUtils/GeomSelectionTools.cxx | 77 ++++++++++--------- src/PluginUtils/GeomSelectionTools.h | 7 +- 4 files changed, 70 insertions(+), 48 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index a6036a3..77b603b 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -464,6 +464,27 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu MESSAGE("blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second); GeomShape = entryToShape(smIt->first); GeomType = GeomShape.ShapeType(); + MESSAGE("Geomtype is " << GeomType); + // Group Management + if (GeomType == TopAbs_COMPOUND){ + for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ + if (it.Value().ShapeType() == TopAbs_FACE){ + HasSizeMapOnFace = true; + FaceId2SizeMap[TopoDS::Face(it.Value()).HashCode(471662)] = smIt->second; + } + if (it.Value().ShapeType() == TopAbs_EDGE){ + HasSizeMapOnEdge = true; + HasSizeMapOnFace = true; + EdgeId2SizeMap[TopoDS::Edge(it.Value()).HashCode(471662)] = smIt->second; + } + if (it.Value().ShapeType() == TopAbs_VERTEX){ + HasSizeMapOnVertex = true; + HasSizeMapOnEdge = true; + HasSizeMapOnFace = true; + VertexId2SizeMap[TopoDS::Vertex(it.Value()).HashCode(471662)] = smIt->second; + } + } + } if (GeomType == TopAbs_FACE){ HasSizeMapOnFace = true; FaceId2SizeMap[TopoDS::Face(GeomShape).HashCode(471662)] = smIt->second; diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index dfaf627..4aafa29 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -724,7 +724,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData QString sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos)); that->mySMPMap[fullSizeMapList[0]] = sizeMap; MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString()); - that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShape(fullSizeMapList[0].toStdString()).ShapeType(); + that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString()); MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]); } } @@ -739,7 +739,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts ); if ( fullCustomSizeMapList.count() > 1 ) { that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1]; - that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShape(fullCustomSizeMapList[0].toStdString()).ShapeType(); + that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString()); MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString()); MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]); } @@ -754,7 +754,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts ); if ( myAttractorList.count() > 1 ) { that->mySMPMap[myAttractorList[0]] = myAttractorList[1]; - that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShape(myAttractorList[0].toStdString()).ShapeType(); + that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString()); MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString()); MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]); } @@ -1158,7 +1158,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - TopoDS_Shape S; + TopAbs_ShapeEnum shapeType; string entry, shapeName; GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool(); @@ -1174,8 +1174,9 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); entry = myGeomToolSelected->getEntryOfObject(anObject); shapeName = anObject->getName(); - S = myGeomToolSelected->entryToShape(entry); - if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked)) + shapeType = myGeomToolSelected->entryToShapeType(entry); + MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType); + if (shapeType == typeShapeAsked) { mySizeMapTable->setFocus(); QString shapeEntry; diff --git a/src/PluginUtils/GeomSelectionTools.cxx b/src/PluginUtils/GeomSelectionTools.cxx index ebe8694..1899582 100644 --- a/src/PluginUtils/GeomSelectionTools.cxx +++ b/src/PluginUtils/GeomSelectionTools.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -195,23 +196,13 @@ std::string GeomSelectionTools::getFirstSelectedComponentDataType() } /*! - * Retrieve the TopoDS shape from the first selected object - * @return the TopoDS shape from the first selected object, empty TopoDS Shape if a shape is not selected. + * Retrieve the shape type from the entry + * @return the shape type from the entry, return TopAbs_SHAPE if the object does not define a shape or a group. */ -TopoDS_Shape GeomSelectionTools::getFirstSelectedTopoDSShape() -{ - Handle(SALOME_InteractiveObject) anIO; - anIO=GeomSelectionTools::getFirstSelectedSalomeObject(); - return entryToShape(anIO->getEntry()); -} - -/*! - * Retrieve the TopoDS shape from the entry - * @return the TopoDS shape from the entry, empty TopoDS Shape if the entry does not define a shape. - */ -TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){ - MESSAGE("GeomSelectionTools::entryToShape"<FindObjectID(entry); if (aSO){ _PTR(SObject) aRefSObj; @@ -224,42 +215,53 @@ TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){ if ( strcmp(aSO->GetFatherComponent()->ComponentDataType().c_str(),"GEOM") == 0) aShape = SMESH::SObjectToInterface(aSO); if ( !aShape->_is_nil() ){ - MESSAGE("Got a Shape as Geom Object "); - - SalomeApp_Application* anApp = GetSalomeApplication(); - if (anApp) { - MESSAGE("Got Application"); - Engines::Component_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" ); - GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component); - MESSAGE("Got GEOM engine"); - GEOM_Client* aClient = new GEOM_Client(); - if ( aClient && !_geomEngine->_is_nil() ) { - MESSAGE("GEOM client is OK and GEOM engine is not null"); - S = aClient->GetShape( _geomEngine, aShape ); - } - } + MESSAGE("Got the Geom Object "); + MESSAGE("Geom Object Type "<< aShape->GetType()); + SalomeApp_Application* anApp = GetSalomeApplication(); + if (anApp) { + MESSAGE("Got Application"); + Engines::Component_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" ); + GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component); + MESSAGE("Got GEOM engine"); + // if the Geom Object is a group + if (aShape->GetType() == GEOM_GROUP){ + MESSAGE("It's a group"); + GEOM::GEOM_IGroupOperations_var aGroupOp = _geomEngine->GetIGroupOperations(myStudy->StudyId()); + ShapeType= (TopAbs_ShapeEnum)aGroupOp->GetType(aShape); + } + // if not + else { + GEOM_Client* aClient = new GEOM_Client(); + if ( aClient && !_geomEngine->_is_nil() ) { + MESSAGE("GEOM client is OK and GEOM engine is not null"); + S = aClient->GetShape( _geomEngine, aShape ); + ShapeType=S.ShapeType(); + } + } + } } } - return S; + MESSAGE("ShapeType returned is " << ShapeType); + return ShapeType; } + /*! * Gives the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape. * @return the ShapeType of the first Selected Object, return TopAbs_SHAPE if the first selected object does not define a shape. */ TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType() { - TopoDS_Shape S=getFirstSelectedTopoDSShape(); - if (!S.IsNull()) - return S.ShapeType(); - else - return TopAbs_SHAPE; + Handle(SALOME_InteractiveObject) anIO; + anIO=GeomSelectionTools::getFirstSelectedSalomeObject(); + return entryToShapeType(anIO->getEntry()); } /*! - * Print information to std output of the face (if the first selected object is a face) + * Print information to std output of the face * and return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface + * @param TopoDS_Shape S Face we want information about. * @return the OCC type of face: Plane, Cylinder,Cone, Sphere, Torus, BezierSurface,BSplineSurface, SurfaceOfRevolution,SurfaceOfExtrusion, OtherSurface * return Other_Surface if the selected face is not a face. * Information printed is : @@ -269,9 +271,8 @@ TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType() * U or V is Rational ? * */ -GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation() +GeomAbs_SurfaceType GeomSelectionTools::getFaceInformation(TopoDS_Shape S) { - TopoDS_Shape S=getFirstSelectedTopoDSShape(); GeomAbs_SurfaceType surf_type=GeomAbs_OtherSurface ; if (!S.IsNull() && S.ShapeType()==TopAbs_FACE){ TopoDS_Face f=TopoDS::Face(S); diff --git a/src/PluginUtils/GeomSelectionTools.h b/src/PluginUtils/GeomSelectionTools.h index 8abdf3c..d7adf6a 100644 --- a/src/PluginUtils/GeomSelectionTools.h +++ b/src/PluginUtils/GeomSelectionTools.h @@ -59,12 +59,11 @@ public: std::string getEntryOfObject(Handle(SALOME_InteractiveObject)); std::string getNameFromEntry(std::string); std::string getFirstSelectedComponentDataType(); - TopoDS_Shape getFirstSelectedTopoDSShape(); TopAbs_ShapeEnum getFirstSelectedShapeType(); - TopoDS_Shape entryToShape(std::string ); - GeomAbs_SurfaceType getFaceInformation(); + TopAbs_ShapeEnum entryToShapeType(std::string ); + GeomAbs_SurfaceType getFaceInformation(TopoDS_Shape); _PTR(Study) getMyStudy(); }; -#endif // _GEOMSELECTIONTOOLS_H_ \ No newline at end of file +#endif // _GEOMSELECTIONTOOLS_H_ -- 2.39.2