]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Compsolid: 1. a define to process the first shape as a shape of compsolid[debug purpo...
authornds <natalia.donis@opencascade.com>
Fri, 31 Jul 2015 10:32:28 +0000 (13:32 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 31 Jul 2015 10:32:28 +0000 (13:32 +0300)
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/Model/Model_ResultCompSolid.cpp
src/XGUI/XGUI_Workshop.cpp

index 4b57ee2b728ad8858d90dc0b418b0a3aeaf43920..092b3740641c66e42421f35e341f1ca09bd20073 100644 (file)
@@ -29,6 +29,7 @@
 #define EDGE 6
 
 #define DEBUG_COMPSOLID
+//#define DEBUG_COMPSOLID_SHAPE
 
 //=================================================================================================
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
@@ -103,6 +104,11 @@ void FeaturesPlugin_Extrusion::execute()
   ResultCompSolidPtr aCompSolidResult = document()->createCompSolid(data(), aResultIndex);
   setResult(aCompSolidResult, aResultIndex);
   aResultIndex++;
+#endif
+#ifdef DEBUG_COMPSOLID_SHAPE
+  bool aFirstShapeInCompsolid = aFaceRefs->size() > 0;
+  if (aFirstShapeInCompsolid)
+    aResultIndex--;
 #endif
   for(; anIndex < aFaceRefs->size(); anIndex++) {
     std::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = aFaceRefs->value(anIndex);
@@ -128,10 +134,22 @@ void FeaturesPlugin_Extrusion::execute()
       }
     }
     for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
+      ResultBodyPtr aResultBody;
+
+#ifdef DEBUG_COMPSOLID_SHAPE
+      if (aFirstShapeInCompsolid && anIndex == 0)
+        aResultBody = aCompSolidResult;
+      else {
+#endif
+
 #ifdef DEBUG_COMPSOLID
-      ResultBodyPtr aResultBody = aCompSolidResult->addResult(aResultIndex);
+      aResultBody = aCompSolidResult->addResult(aResultIndex);
 #else
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+      aResultBody = document()->createBody(data(), aResultIndex);
+#endif
+
+#ifdef DEBUG_COMPSOLID_SHAPE
+      }
 #endif
       std::shared_ptr<GeomAPI_Shape> aBaseShape;
       if (aFacesNum == -1) {
index 2472d68e2dfceef6066823af2a8993d07836ecc8..5cb50556c6339dce0a8057f02c601b8804eaea31 100755 (executable)
@@ -38,7 +38,9 @@ std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::addResult(const int
 
 int Model_ResultCompSolid::numberOfSubs(bool forTree) const
 {
-  return 0;
+  if (forTree)
+    return 0;
+  return data()->reflist(Model_ResultCompSolid::BODIES_ID())->size();
 }
 
 std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::subResult(const int theIndex,
index 0ce4e96c455a225dfb4c9360a424ab462d081cae..95db6cca3be195be5c7305ad586f47b054b6fe47 100644 (file)
@@ -42,6 +42,7 @@
 #include <ModelAPI_ResultParameter.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultCompSolid.h>
 
 //#include <PartSetPlugin_Part.h>
 
@@ -1327,8 +1328,9 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   std::vector<int> aColor;
   foreach(ObjectPtr anObject, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-    if (aResult.get())
+    if (aResult.get()) {
       XGUI_CustomPrs::getResultColor(aResult, aColor);
+    }
     else {
       // TODO: remove the obtaining a color from the AIS object
       // this does not happen never because:
@@ -1365,10 +1367,18 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   }
 
   // 4. set the value to all results
+  std::vector<int> aColorResult = aDlg->getColor();
   foreach(ObjectPtr anObj, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
     if (aResult.get() != NULL) {
-      std::vector<int> aColorResult = aDlg->getColor();
+      ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+      if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
+        for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
+          ResultPtr aSubResult = aCompsolidResult->subResult(i);
+          if (aSubResult.get())
+            setColor(aSubResult, aColorResult);
+        }
+      }
       setColor(aResult, aColorResult);
     }
   }