]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixed problems with OCCT dependencies and extrusion crashes
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 28 Oct 2014 07:53:24 +0000 (10:53 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 28 Oct 2014 07:53:24 +0000 (10:53 +0300)
16 files changed:
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/boolean_widget.xml
src/FeaturesPlugin/extrusion_widget.xml
src/GeomAPI/GeomAPI_Shape.h
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/Model/Model_AttributeSelection.cpp
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_Validator.h

index ab966dff693de7c0d3dd58afa168fc35561f344c..a0886cbb16364a482cb4e6d544dab887deaa9362 100644 (file)
@@ -27,7 +27,6 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../Events
-  ${CAS_INCLUDE_DIRS}
 )
 
 SET(PROJECT_LIBRARIES
@@ -35,8 +34,6 @@ SET(PROJECT_LIBRARIES
     ModelAPI 
     GeomAPI 
     GeomAlgoAPI
-    ${CAS_KERNEL}
-    ${CAS_SHAPE}
 )
 
 ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
index b49f5885488d020c7618e28923def08d36433ae3..b32f2e97a5e09841d36fb2602636c248b78121f4 100644 (file)
 #include <ModelAPI_AttributeBoolean.h>
 #include <Events_Error.h>
 #include <GeomAlgoAPI_Extrusion.h>
-#include <TopoDS_Shape.hxx>
-#include <TopTools_DataMapOfShapeShape.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopTools_MapOfShape.hxx>
+
 using namespace std;
 #define _LATERAL_TAG 1
 #define _FIRST_TAG 2
@@ -25,6 +22,7 @@ using namespace std;
 #include <iostream>
 #include <ostream>
 #endif
+
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
 {
 }
@@ -39,7 +37,7 @@ void FeaturesPlugin_Extrusion::initAttributes()
 void FeaturesPlugin_Extrusion::execute()
 {
   boost::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = boost::dynamic_pointer_cast<
-      ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
+    ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
   if (!aFaceRef)
     return;
 
@@ -48,8 +46,19 @@ void FeaturesPlugin_Extrusion::execute()
   if (!aFace)
     return;
 
-  boost::shared_ptr<GeomAPI_Shape> aContext = 
-    boost::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->context());
+  boost::shared_ptr<GeomAPI_Shape> aContext;
+  ResultPtr aContextRes = aFaceRef->context();
+  if (aContextRes) {
+    if (aContextRes->groupName() == ModelAPI_ResultBody::group())
+      aContext = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
+    else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group())
+      aContext = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
+  }
+  if (!aContext) {
+    std::string aContextError = "The selection context is bad";
+    Events_Error::send(aContextError, this);
+    return;
+  }
 
   double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
   if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
@@ -59,24 +68,24 @@ void FeaturesPlugin_Extrusion::execute()
   //TCollection_AsciiString anError;
   GeomAlgoAPI_Extrusion aFeature(aFace, aSize);
   if(!aFeature.isDone()) {
-       std::string aFeatureError = "Extrusion algorithm failed";  
+    std::string aFeatureError = "Extrusion algorithm failed";  
     Events_Error::send(aFeatureError, this);
-       return;
+    return;
   }
 
-   // Check if shape is valid
-  if (!aFeature.shape()->impl<TopoDS_Shape>().IsNull()) {
+  // Check if shape is valid
+  if (aFeature.shape()->isNull()) {
     std::string aShapeError = "Resulting shape is Null";     
     Events_Error::send(aShapeError, this);
- #ifdef _DEBUG
+#ifdef _DEBUG
     std::cerr << aShapeError << std::endl;
- #endif
+#endif
     return;
   }
-   if(!aFeature.isValid()) {
-       std::string aFeatureError = "Warning: resulting shape is not valid";  
+  if(!aFeature.isValid()) {
+    std::string aFeatureError = "Warning: resulting shape is not valid";  
     Events_Error::send(aFeatureError, this);
-       return;
+    return;
   }  
   //LoadNamingDS
   LoadNamingDS(aFeature, aResultBody, aFace, aContext);
@@ -84,27 +93,27 @@ void FeaturesPlugin_Extrusion::execute()
   setResult(aResultBody);
 }
 
-  //============================================================================
+//============================================================================
 void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature, 
-                                    boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
-                                                                boost::shared_ptr<GeomAPI_Shape> theBasis,
-                                    boost::shared_ptr<GeomAPI_Shape> theContext)
+  boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
+  boost::shared_ptr<GeomAPI_Shape> theBasis,
+  boost::shared_ptr<GeomAPI_Shape> theContext)
 {  
 
-       
-    //load result
-       if(theBasis->impl<TopoDS_Shape>().IsEqual(theContext->impl<TopoDS_Shape>()))
-         theResultBody->store(theFeature.shape());
-       else
-         theResultBody->storeGenerated(theContext, theFeature.shape());
 
-       TopTools_DataMapOfShapeShape aSubShapes;
-       for (TopExp_Explorer Exp(theFeature.shape()->impl<TopoDS_Shape>(),TopAbs_FACE); Exp.More(); Exp.Next()) {
-         aSubShapes.Bind(Exp.Current(),Exp.Current());
-       }
+  //load result
+  if(theBasis->isEqual(theContext))
+    theResultBody->store(theFeature.shape());
+  else
+    theResultBody->storeGenerated(theContext, theFeature.shape());
+  /*
+  TopTools_DataMapOfShapeShape aSubShapes;
+  for (TopExp_Explorer Exp(theFeature.shape()->impl<TopoDS_Shape>(),TopAbs_FACE); Exp.More(); Exp.Next()) {
+    aSubShapes.Bind(Exp.Current(),Exp.Current());
+  }
 
-       //Insert lateral face : Face from Edge
-       //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
+  //Insert lateral face : Face from Edge
+  //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
 
 
   TopTools_MapOfShape aView;
@@ -112,42 +121,42 @@ void FeaturesPlugin_Extrusion::LoadNamingDS(GeomAlgoAPI_Extrusion& theFeature,
   for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
     const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
     if (!aView.Add(aRoot)) continue;
-       boost::shared_ptr<GeomAPI_Shape> aRootG(new GeomAPI_Shape());
-       aRootG->setImpl((void *)&aRoot);
-       const ListOfShape& aShapes = theFeature.generated(aRootG);
-       std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();       
-       for (; anIt != aLast; anIt++) {
+    boost::shared_ptr<GeomAPI_Shape> aRootG(new GeomAPI_Shape());
+    aRootG->setImpl((void *)&aRoot);
+    const ListOfShape& aShapes = theFeature.generated(aRootG);
+    std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aShapes.begin(), aLast = aShapes.end();          
+    for (; anIt != aLast; anIt++) {
       TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>(); 
       if (aSubShapes.IsBound(aNewShape)) {
         aNewShape.Orientation((aSubShapes(aNewShape)).Orientation());
       }
 
-         if (!aRoot.IsSame (aNewShape)) {
-               boost::shared_ptr<GeomAPI_Shape> aNew(new GeomAPI_Shape());
-           aNew->setImpl((void *)&aNewShape);
-                 theResultBody->generated(aRootG, aNew,_LATERAL_TAG); 
-         }
-       }
+      if (!aRoot.IsSame (aNewShape)) {
+        boost::shared_ptr<GeomAPI_Shape> aNew(new GeomAPI_Shape());
+        aNew->setImpl((void *)&aNewShape);
+        theResultBody->generated(aRootG, aNew,_LATERAL_TAG); 
+      }
+    }
   }
-
   //Insert bottom face
   const boost::shared_ptr<GeomAPI_Shape>& aBottomFace = theFeature.firstShape();
-  if (!aBottomFace->impl<TopoDS_Shape>().IsNull()) {
-         if (aSubShapes.IsBound(aBottomFace->impl<TopoDS_Shape>())) {
-               aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl<TopoDS_Shape>()));
-         }    
-  theResultBody->generated(aBottomFace, _FIRST_TAG);
+  if (!aBottomFace->isNull()) {
+    if (aSubShapes.IsBound(aBottomFace->impl<TopoDS_Shape>())) {
+      aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl<TopoDS_Shape>()));
+    }    
+    theResultBody->generated(aBottomFace, _FIRST_TAG);
   }
 
-  
 
- //Insert top face
+
+  //Insert top face
   boost::shared_ptr<GeomAPI_Shape> aTopFace = theFeature.lastShape();
-  if (!aTopFace->impl<TopoDS_Shape>().IsNull()) {
-       if (aSubShapes.IsBound(aTopFace->impl<TopoDS_Shape>())) {
-               aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl<TopoDS_Shape>()));
-       }
+  if (!aTopFace->isNull()) {
+    if (aSubShapes.IsBound(aTopFace->impl<TopoDS_Shape>())) {
+      aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl<TopoDS_Shape>()));
+    }
     theResultBody->generated(aTopFace, _FIRST_TAG);
   }
+  */
 
 }
index cdf8e195ef0b7b990725039730beec66023b5361..af4822c2c848784f950bbf54d3726034ccd4ccda 100644 (file)
@@ -4,12 +4,14 @@
     icon=":icons/cut_shape.png" 
     tooltip="Select an object to cut"
     shape_types="solid shell"
+    concealment="true"
   />
   <shape_selector id="tool_object" 
     label="Tool object" 
     icon=":icons/cut_tool.png" 
     tooltip="Select a tool"
     shape_types="solid"
+    concealment="true"
   />
   <choice id="bool_type" 
     label="Type" 
index 4158caaa9ccfa9530086a189f0835978c6b94cfd..c7c5f4bdd90bebae461edbd3873fae7ace5471a5 100644 (file)
@@ -6,7 +6,6 @@
     activate="true"
     shape_types="face"
     use_subshapes="true"
-    concealment="true"
   />
   <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="1" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
     <validator id="GeomValidators_Positive"/>
index 9c903d68295a10fcba2b842cf8dd6c0dd2749eb4..03f75d7453da0e4c85e475bb7e1595a2f6d44b0e 100644 (file)
@@ -33,7 +33,7 @@ class GEOMAPI_EXPORT GeomAPI_Shape : public GeomAPI_Interface
 };
 
 //! Pointer on list of shapes
-typedef std::list<boost::shared_ptr<GeomAPI_Shape>> ListOfShape;
+typedef std::list<boost::shared_ptr<GeomAPI_Shape> > ListOfShape;
 
 //! Pointer on attribute object
 typedef boost::shared_ptr<GeomAPI_Shape> GeomShapePtr;
index d5f2c4379debded24d1f39ee735f1efac3cbd172..b81b0f5fe2b1fa09b9a9150b70ac6ba4dac3f7d7 100644 (file)
 #include <Precision.hxx>
 #include <TDF_TagSource.hxx>
 #include <boost/shared_ptr.hpp>
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <TopoDS_Shape.hxx>
 
 const double tolerance = Precision::Angular();
-  // Constructor
-GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize)
-         : mySize(theSize), myBuilder(NULL), myDone(false), myShape(new GeomAPI_Shape())
-  {
-    myBasis = theBasis->impl<TopoDS_Shape>();
-       build();
-  }
-
-  //============================================================================
-  void GeomAlgoAPI_Extrusion::build()
-  {
-    bool isFirstNorm = true;
-    gp_Dir aShapeNormal;
-
-    //const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>(); 
-    Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(TopoDS::Face(myBasis)));
-    if (aPlane.IsNull())  // non-planar shapes is not supported for extrusion yet
-      return;
-
-    const gp_Dir& aNormal = aPlane->Pln().Axis().Direction();  
-    gp_Vec aVec(aNormal);
-       aVec = aVec * mySize;
-
-    myBuilder = new BRepPrimAPI_MakePrism(myBasis, aVec);
-       if(myBuilder != NULL) {
-         myDone = myBuilder->IsDone();
-         if(myDone) {
-               if(myBuilder->Shape().ShapeType() == TopAbs_COMPOUND) 
-                 myResult = GeomAlgoAPI_DFLoader::refineResult(myBuilder->Shape());
-               else
-                 myResult = myBuilder->Shape();                
-               myShape->setImpl((void *)&myResult);  
-               myFirst->setImpl((void *)&(myBuilder->FirstShape()));
-               myLast->setImpl((void *)&(myBuilder-> LastShape()));
-         }
-       }       
-  }
+// Constructor
+GeomAlgoAPI_Extrusion::GeomAlgoAPI_Extrusion(
+  boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize)
+: mySize(theSize), myDone(false),
+  myShape(new GeomAPI_Shape()), myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape())
+{
+  build(theBasis);
+}
 
-  //============================================================================
+//============================================================================
+void GeomAlgoAPI_Extrusion::build(const boost::shared_ptr<GeomAPI_Shape>& theBasis)
+{
+  bool isFirstNorm = true;
+  gp_Dir aShapeNormal;
+
+  //const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>(); 
+  TopoDS_Face aBasis = TopoDS::Face(theBasis->impl<TopoDS_Shape>());
+  Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(
+    BRep_Tool::Surface(aBasis));
+  if (aPlane.IsNull())  // non-planar shapes is not supported for extrusion yet
+    return;
+
+  const gp_Dir& aNormal = aPlane->Pln().Axis().Direction();  
+  gp_Vec aVec(aNormal);
+  aVec = aVec * mySize;
+
+  BRepPrimAPI_MakePrism* aBuilder = new BRepPrimAPI_MakePrism(aBasis, aVec);
+  if(aBuilder) {
+    setImpl(aBuilder);
+    myDone = aBuilder->IsDone() == Standard_True;
+    if (myDone) {
+      BRepCheck_Analyzer aChecker(aBuilder->Shape());
+      myDone = aChecker.IsValid() == Standard_True;
+    }
+    if(myDone) {
+      TopoDS_Shape aResult;
+      if(aBuilder->Shape().ShapeType() == TopAbs_COMPOUND) 
+        aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape());
+      else
+        aResult = aBuilder->Shape();
+      myShape->setImpl(new TopoDS_Shape(aResult));
+      myFirst->setImpl(new TopoDS_Shape(aBuilder->FirstShape()));
+      myLast->setImpl(new TopoDS_Shape(aBuilder-> LastShape()));
+    }
+  }    
+}
+
+//============================================================================
 const bool GeomAlgoAPI_Extrusion::isDone() const
 {return myDone;}
 
-  //============================================================================
+//============================================================================
 const bool GeomAlgoAPI_Extrusion::isValid() const
 {
-       bool isValid(false);
-       if(myDone && !myBuilder->Shape().IsNull()) {
-         BRepCheck_Analyzer aChecker(myBuilder->Shape());
-         isValid = aChecker.IsValid();
-       }
-       return isValid;
-  }
+  return myDone;
+}
 
-  //============================================================================
-  const bool GeomAlgoAPI_Extrusion::hasVolume() const
-  {
-       bool hasVolume(false);
-       if(isValid()) {
-         const TopoDS_Shape& aRShape = myBuilder->Shape();
-         GProp_GProps aGProp;
-      BRepGProp::VolumeProperties(aRShape, aGProp);
-      if(aGProp.Mass() > Precision::Confusion()) 
-               hasVolume = true;       
-       }
-       return hasVolume;
+//============================================================================
+const bool GeomAlgoAPI_Extrusion::hasVolume() const
+{
+  bool hasVolume(false);
+  if(isValid()) {
+    const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
+    GProp_GProps aGProp;
+    BRepGProp::VolumeProperties(aRShape, aGProp);
+    if(aGProp.Mass() > Precision::Confusion()) 
+      hasVolume = true;        
   }
+  return hasVolume;
+}
 
-  //============================================================================
+//============================================================================
 const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::shape () const 
 {return myShape;}
 
-  //============================================================================
-  const ListOfShape& GeomAlgoAPI_Extrusion::generated(const boost::shared_ptr<GeomAPI_Shape> theShape)
-  {
-       myHistory.clear();
-    if(myDone) {
-       const TopTools_ListOfShape& aList =  myBuilder->Generated(theShape->impl<TopoDS_Shape>());
+//============================================================================
+void GeomAlgoAPI_Extrusion::generated(
+  const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
+{
+  theHistory.clear();
+  if(myDone) {
+    const TopTools_ListOfShape& aList = implPtr<BRepPrimAPI_MakePrism>()
+      ->Generated(theShape->impl<TopoDS_Shape>());
     TopTools_ListIteratorOfListOfShape it(aList);
-       for(;it.More();it.Next()) {
-               boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-               aShape->setImpl(&(it.Value()));
-               myHistory.push_back(aShape);
-       }
-  }
-  return myHistory;
+    for(;it.More();it.Next()) {
+      boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      aShape->setImpl(&(it.Value()));
+      theHistory.push_back(aShape);
+    }
   }
-  
-  //============================================================================
-   const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::firstShape()
-   {
-        return myFirst;
-   }
-
-   //============================================================================
-   const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::lastShape()
-   {
-        return myLast;
-   }
-
-  //============================================================================
-   /*
-  void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
-         boost::shared_ptr<GeomAPI_Shape> theContext)
+}
+
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::firstShape()
 {
-  if(isValid()) {
-       const TopoDS_Shape& aShape = myBuilder->Shape();
-       TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aShape);
-       boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResultBody->data());
-       if (aData) {
-      const TDF_Label& aShapeLab = aData->shapeLab();
-         const Handle(TDF_TagSource)& Tagger = TDF_TagSource::Set(aShapeLab);
-         if (Tagger.IsNull()) return;
-         Tagger->Set(0);
-
-      TNaming_Builder aBuilder (aShapeLab);
-         if(myBasis.IsEqual(theContext->impl<TopoDS_Shape>()))
-           aBuilder.Generated(aResult);
-         else
-        aBuilder.Generated(theContext->impl<TopoDS_Shape>(), aResult);
-
-         TopTools_DataMapOfShapeShape aSubShapes;
-         for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
-           aSubShapes.Bind(Exp.Current(),Exp.Current());
-         }
-
-          //Insert lateral face : Face from Edge
-         TNaming_Builder  aLateralFaceBuilder(aShapeLab.NewChild());
-         GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
-
-         //Insert bottom face
-         TopoDS_Shape aBottomFace = myBuilder->FirstShape();
-      if (!aBottomFace.IsNull()) {
-               if (aBottomFace.ShapeType() != TopAbs_COMPOUND) {
-                 TNaming_Builder aBottomBuilder(aShapeLab.NewChild());  //2
-          if (aSubShapes.IsBound(aBottomFace)) {
-                       aBottomFace = aSubShapes(aBottomFace);
-                 }
-        aBottomBuilder.Generated(aBottomFace);
-               } else {
-          TopoDS_Iterator itr(aBottomFace);
-          for (; itr.More(); itr.Next()) {
-            TNaming_Builder aBottomBuilder(aShapeLab.NewChild());
-                   aBottomBuilder.Generated(itr.Value());
-                 }
-               }
-
-         }
-
-         //Insert top face
-         TopoDS_Shape aTopFace = myBuilder->LastShape();
-         if (!aTopFace.IsNull()) {
-       if (aTopFace.ShapeType() != TopAbs_COMPOUND) {
-         TNaming_Builder aTopBuilder(aShapeLab.NewChild()); //3
-         if (aSubShapes.IsBound(aTopFace)) {
-           aTopFace = aSubShapes(aTopFace);
-                }
-        aTopBuilder.Generated(aTopFace);
-          } else {
-        TopoDS_Iterator itr(aTopFace);
-        for (; itr.More(); itr.Next()) {
-          TNaming_Builder aTopBuilder(aShapeLab.NewChild());
-          aTopBuilder.Generated(itr.Value());
-               }
-          }
-         }
-       }
-  }
-  */
\ No newline at end of file
+  return myFirst;
+}
+
+//============================================================================
+const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::lastShape()
+{
+  return myLast;
+}
+
+//============================================================================
+/*
+void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr<ModelAPI_ResultBody> theResultBody, 
+boost::shared_ptr<GeomAPI_Shape> theContext)
+{
+if(isValid()) {
+const TopoDS_Shape& aShape = myBuilder->Shape();
+TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aShape);
+boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResultBody->data());
+if (aData) {
+const TDF_Label& aShapeLab = aData->shapeLab();
+const Handle(TDF_TagSource)& Tagger = TDF_TagSource::Set(aShapeLab);
+if (Tagger.IsNull()) return;
+Tagger->Set(0);
+
+TNaming_Builder aBuilder (aShapeLab);
+if(myBasis.IsEqual(theContext->impl<TopoDS_Shape>()))
+aBuilder.Generated(aResult);
+else
+aBuilder.Generated(theContext->impl<TopoDS_Shape>(), aResult);
+
+TopTools_DataMapOfShapeShape aSubShapes;
+for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
+aSubShapes.Bind(Exp.Current(),Exp.Current());
+}
+
+//Insert lateral face : Face from Edge
+TNaming_Builder  aLateralFaceBuilder(aShapeLab.NewChild());
+GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
+
+//Insert bottom face
+TopoDS_Shape aBottomFace = myBuilder->FirstShape();
+if (!aBottomFace.IsNull()) {
+if (aBottomFace.ShapeType() != TopAbs_COMPOUND) {
+TNaming_Builder aBottomBuilder(aShapeLab.NewChild());  //2
+if (aSubShapes.IsBound(aBottomFace)) {
+aBottomFace = aSubShapes(aBottomFace);
+}
+aBottomBuilder.Generated(aBottomFace);
+} else {
+TopoDS_Iterator itr(aBottomFace);
+for (; itr.More(); itr.Next()) {
+TNaming_Builder aBottomBuilder(aShapeLab.NewChild());
+aBottomBuilder.Generated(itr.Value());
+}
+}
+
+}
+
+//Insert top face
+TopoDS_Shape aTopFace = myBuilder->LastShape();
+if (!aTopFace.IsNull()) {
+if (aTopFace.ShapeType() != TopAbs_COMPOUND) {
+TNaming_Builder aTopBuilder(aShapeLab.NewChild()); //3
+if (aSubShapes.IsBound(aTopFace)) {
+aTopFace = aSubShapes(aTopFace);
+}
+aTopBuilder.Generated(aTopFace);
+} else {
+TopoDS_Iterator itr(aTopFace);
+for (; itr.More(); itr.Next()) {
+TNaming_Builder aTopBuilder(aShapeLab.NewChild());
+aTopBuilder.Generated(itr.Value());
+}
+}
+}
+}
+}
+*/
\ No newline at end of file
index 03d704d5dd6a4fdafe5276f845d0b4b16c5f924b..bebeb35f5cdbb70df4b18946f26dcbfb6ae1137a 100644 (file)
 #include <GeomAPI_Dir.h>
 #include <ModelAPI_ResultBody.h>
 #include <boost/shared_ptr.hpp>
-#include <BRepPrimAPI_MakePrism.hxx>
-#include <TopoDS_Shape.hxx>
 /**\class GeomAlgoAPI_Extrusion
  * \ingroup DataAlgo
  * \brief Allows to create the prism based on a given face and a direction
  */
 
-class GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion  
+class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
 {
  public:
 
@@ -31,39 +29,36 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion
                                                                                                                boost::shared_ptr<GeomAPI_Shape> theContext,
                                                         double theSize); */
   /// Constructor
-  GeomAlgoAPI_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion (boost::shared_ptr<GeomAPI_Shape> theBasis, double theSize);
 
   /// Returns True if algorithm succeed
-  const bool isDone() const;
+  GEOMALGOAPI_EXPORT const bool isDone() const;
 
   ///  Returns True if resulting shape is valid
-  const bool isValid() const;
+  GEOMALGOAPI_EXPORT const bool isValid() const;
 
   /// Returns True if resulting shape has volume
-  const bool hasVolume() const;
+  GEOMALGOAPI_EXPORT const bool hasVolume() const;
 
   /// Returns result of the Extrusion algorithm which may be a Solid or a Face
-  const boost::shared_ptr<GeomAPI_Shape>& shape () const;
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& shape () const;
 
   /// Returns list of shapes generated from theShape
-  const ListOfShape& generated(const boost::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
+                                    ListOfShape& theHistory);
 
   /// Returns the first shape 
-  const boost::shared_ptr<GeomAPI_Shape>& firstShape();
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& firstShape();
 
   /// returns last shape
-  const boost::shared_ptr<GeomAPI_Shape>& lastShape();  
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();       
 
 private:
   /// builds resulting shape
-  void build();
+  void build(const boost::shared_ptr<GeomAPI_Shape>& theBasis);
 
-  BRepPrimAPI_MakePrism * myBuilder;
-  TopoDS_Shape myBasis;
   double mySize;
   bool myDone;
-  TopoDS_Shape myResult;
-  ListOfShape myHistory;
   boost::shared_ptr<GeomAPI_Shape> myShape;
   boost::shared_ptr<GeomAPI_Shape> myFirst;
   boost::shared_ptr<GeomAPI_Shape> myLast;
index d743b567ab15c82663d048240e85dc207bd2d99f..679526befc0e3e94fad7d9fa0f636cd8516ac822 100644 (file)
@@ -5,54 +5,54 @@
 #include <GeomAlgoAPI_MakeShape.h>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(BRepBuilderAPI_MakeShape *  theMkShape)
-{ myBuilder = theMkShape;}
+GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
+  : GeomAPI_Interface(theMkShape)
+{}
 
-const boost::shared_ptr<GeomAPI_Shape>  GeomAlgoAPI_MakeShape::shape() const
+const boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
 {
-  boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-  if(myBuilder != NULL) 
-    aShape->setImpl(new TopoDS_Shape(myBuilder->Shape()));
-  return aShape;
+  return myShape;
 }
 
-  /// Returns the  list   of shapes generated   from the shape <theShape>
-const ListOfShape& GeomAlgoAPI_MakeShape::generated(const boost::shared_ptr<GeomAPI_Shape> theShape)
+/// Returns the  list   of shapes generated   from the shape <theShape>
+void GeomAlgoAPI_MakeShape::generated(
+  const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
 {
-  myHistory.clear();
-  if(myBuilder != NULL) {
-       const TopTools_ListOfShape& aList =  myBuilder->Generated(theShape->impl<TopoDS_Shape>());
+  BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+  if(aBuilder) {
+    const TopTools_ListOfShape& aList =  aBuilder->Generated(theShape->impl<TopoDS_Shape>());
     TopTools_ListIteratorOfListOfShape it(aList);
-       for(;it.More();it.Next()) {
-               boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-               aShape->setImpl(&(it.Value()));
-               myHistory.push_back(aShape);
-       }
+    for(;it.More();it.Next()) {
+      boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      aShape->setImpl(&(it.Value()));
+      theHistory.push_back(aShape);
+    }
   }
-  return myHistory;
 }
 
-  /// Returns the  list   of shapes modified   from the shape <theShape>
-const ListOfShape& GeomAlgoAPI_MakeShape::modified(const boost::shared_ptr<GeomAPI_Shape> theShape)
+/// Returns the  list   of shapes modified   from the shape <theShape>
+void GeomAlgoAPI_MakeShape::modified(
+  const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
 {
-  myHistory.clear();
-  if(myBuilder != NULL) {
-       const TopTools_ListOfShape& aList =  myBuilder->Modified(theShape->impl<TopoDS_Shape>());
-       TopTools_ListIteratorOfListOfShape it(aList);
-       for(;it.More();it.Next()) {
-               boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-               aShape->setImpl(&(it.Value()));
-               myHistory.push_back(aShape);
-       }
+  BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+  if(aBuilder) {
+    const TopTools_ListOfShape& aList =  aBuilder->Modified(theShape->impl<TopoDS_Shape>());
+    TopTools_ListIteratorOfListOfShape it(aList);
+    for(;it.More();it.Next()) {
+      boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+      aShape->setImpl(&(it.Value()));
+      theHistory.push_back(aShape);
+    }
   }
-  return myHistory;
 }
 
-  /// Returns whether the shape is an edge
+/// Returns whether the shape is an edge
 bool GeomAlgoAPI_MakeShape::isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape)
 {
   bool isDeleted(false);
-  if (myBuilder != NULL) 
-       isDeleted = (bool) myBuilder->IsDeleted(theShape->impl<TopoDS_Shape>());        
+  BRepBuilderAPI_MakeShape* aBuilder = implPtr<BRepBuilderAPI_MakeShape>();
+  if(aBuilder) {
+    isDeleted = aBuilder->IsDeleted(theShape->impl<TopoDS_Shape>()) == Standard_True;
+  }
   return isDeleted;
-}
\ No newline at end of file
+}
index 9357ff432d384322c222df64b44a629e67050fc2..89dae08a5458671271e8a58f8afb2bf445230a40 100644 (file)
  * \ingroup DataModel
  * \Interface to the root class of all topological shapes constructions
  */
-class GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape
+class GeomAlgoAPI_MakeShape : GeomAPI_Interface
 {
  public:
    /// Constructor
-  GeomAlgoAPI_MakeShape(BRepBuilderAPI_MakeShape * theBuilder);
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder);
   /// Returns a shape built by the shape construction algorithm
-  const boost::shared_ptr<GeomAPI_Shape>  shape() const;
+  GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>  shape() const;
 
   /// Returns the  list   of shapes generated   from the shape <theShape>
-  virtual const ListOfShape& generated(const boost::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT virtual void generated(
+    const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
 
   /// Returns the  list   of shapes modified   from the shape <theShape>
-  virtual const ListOfShape& modified(const boost::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT virtual void modified(
+    const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory);
 
   /// Returns whether the shape is an edge
-  virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
+  GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
 
   protected:
        boost::shared_ptr<GeomAPI_Shape> myShape;
-       ListOfShape myHistory;
-       BRepBuilderAPI_MakeShape * myBuilder;
 };
 
-#endif
\ No newline at end of file
+#endif
index 54a52a22a96386b1f4eb5bea7237dac30ffa1852..f502aee03ba59f3ce286eebee36505058ad38da9 100644 (file)
@@ -168,10 +168,10 @@ bool Model_AttributeSelection::update()
             }
           }
         }
-        if (aNewSelected) { // store this new selection
-          selectConstruction(aContext, aNewSelected);
-          return true;
-        }
+      }
+      if (aNewSelected) { // store this new selection
+        selectConstruction(aContext, aNewSelected);
+        return true;
       }
     }
   }
index cc3ed5ef3b003ba4390bb21cddbd6d4a1b3574e2..fe65a751d7719525fa0721b123a776b358241481 100644 (file)
@@ -16,6 +16,7 @@
 #include <Model_Events.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
+#include <ModelAPI_Validator.h>
 
 #include <GeomData_Point.h>
 #include <GeomData_Point2D.h>
@@ -356,10 +357,25 @@ int Model_Data::featureId() const
   return myLab.Father().Tag(); // tag of the feature label
 }
 
+void Model_Data::eraseBackReferences()
+{
+  myRefsToMe.clear();
+  boost::shared_ptr<ModelAPI_Result> aRes = 
+    boost::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+  if (aRes)
+    aRes->setIsConcealed(false);
+}
+
 void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID)
 {
-  // TODO: the concealment state update
   myRefsToMe.insert(theFeature->data()->attribute(theAttrID));
+  if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) {
+    boost::shared_ptr<ModelAPI_Result> aRes = 
+      boost::dynamic_pointer_cast<ModelAPI_Result>(myObject);
+    if (aRes) {
+      aRes->setIsConcealed(true);
+    }
+  }
 }
 
 void Model_Data::referencesToObjects(
index 46d50acc0080a7dc069f0a9db8198e6abd22ecc2..cb7158b75de28390da8316551c2dd3bfcfc26e1a 100644 (file)
@@ -154,7 +154,7 @@ class Model_Data : public ModelAPI_Data
 
 private:
   // removes all information about back references
-  inline void eraseBackReferences() {myRefsToMe.clear();}
+  void eraseBackReferences();
   // adds a back reference (with identifier which attribute references to this object
   void addBackReference(FeaturePtr theFeature, std::string theAttrID);
   // returns all objects referenced to this
index 05452239ceba196e3b7763f29263c154c8bf29db..cb05a7fbbf59b7af19f8125c262da3210faeafd9 100644 (file)
@@ -288,7 +288,6 @@ void Model_Document::finishOperation()
     myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();  // && (myNestedNum == -1);
     myTransactionsAfterSave++;
   }
-
 }
 
 void Model_Document::abortOperation()
@@ -793,6 +792,10 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated, const bool t
 
 void Model_Document::synchronizeBackRefs()
 {
+  boost::shared_ptr<ModelAPI_Document> aThis = 
+    Model_Application::getApplication()->getDocument(myID);
+  // keeps the concealed flags of result to catch the change and create created/deleted events
+  std::list<std::pair<ResultPtr, bool> > aConcealed;
   // first cycle: erase all data about back-references
   NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFeatures(myObjs);
   for(; aFeatures.More(); aFeatures.Next()) {
@@ -808,6 +811,7 @@ void Model_Document::synchronizeBackRefs()
       boost::shared_ptr<Model_Data> aResData = 
         boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
       if (aResData) {
+        aConcealed.push_back(std::pair<ResultPtr, bool>(*aRIter, (*aRIter)->isConcealed()));
         aResData->eraseBackReferences();
       }
     }
@@ -835,6 +839,17 @@ void Model_Document::synchronizeBackRefs()
       }
     }
   }
+  std::list<std::pair<ResultPtr, bool> >::iterator aCIter = aConcealed.begin();
+  for(; aCIter != aConcealed.end(); aCIter++) {
+    if (aCIter->first->isConcealed() != aCIter->second) { // somethign is changed => produce event
+      if (aCIter->second) { // was concealed become not => creation event
+        static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+        ModelAPI_EventCreator::get()->sendUpdated(aCIter->first, anEvent);
+      } else { // was not concealed become concealed => delete event
+        ModelAPI_EventCreator::get()->sendDeleted(aThis, aCIter->first->groupName());
+      }
+    }
+  }
 }
 
 TDF_Label Model_Document::resultLabel(
index d1adbbbe92d012f6cb37a6273a15b8354a0b8abd..eecd08b33013590344a004f9e794fc7a7031ac4a 100644 (file)
@@ -224,7 +224,18 @@ void Model_ValidatorsFactory::registerNotObligatory(std::string theFeature, std:
 
 void Model_ValidatorsFactory::registerConcealment(std::string theFeature, std::string theAttribute)
 {
-
+  std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
+  if (aFind == myConcealed.end()) {
+    std::set<std::string> aNewSet;
+    aNewSet.insert(theAttribute);
+    myConcealed[theFeature] = aNewSet;
+  } else {
+    aFind->second.insert(theAttribute);
+  }
 }
 
-
+bool Model_ValidatorsFactory::isConcealed(std::string theFeature, std::string theAttribute)
+{
+  std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
+  return aFind != myConcealed.end() && aFind->second.find(theAttribute) != aFind->second.end();
+}
index cfaeb89c5ff1369c9cb184385cb82228b2869d50..5fa3a8a9004441d4e0000a4f9eff83f25de94df5 100644 (file)
@@ -32,6 +32,10 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   std::map<std::string, AttrValidators> myFeatures;
   /// validators IDs and arguments by feature and attribute IDs
   std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
+  /// Stores the registered attributes that leads to the concealment of referenced objects in 
+  /// data tree. Map from feature kind to set of attribute IDs.
+  std::map<std::string, std::set<std::string> > myConcealed;
+
  public:
   /// Registers the instance of the validator by the ID
   MODEL_EXPORT virtual void registerValidator(const std::string& theID,
@@ -76,6 +80,9 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   /// all referenced features after execution
   virtual void registerConcealment(std::string theFeature, std::string theAttribute);
 
+  /// Returns true that it was registered that attribute conceals the referenced result
+  virtual bool isConcealed(std::string theFeature, std::string theAttribute);
+
 protected:
   void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
   /// Get instance from Session
index 940be4c4d1b879039859579c5bb2bcda33d697be..cd73508d58ecb55d3b82e1590bacc6abe6b24a51 100644 (file)
@@ -87,6 +87,9 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory
   /// all referenced features after execution
   virtual void registerConcealment(std::string theFeature, std::string theAttribute) = 0;
 
+  /// Returns true that it was registered that attribute conceals the referenced result
+  virtual bool isConcealed(std::string theFeature, std::string theAttribute) = 0;
+
  protected:
   /// Get instance from Session
   ModelAPI_ValidatorsFactory()