${PROJECT_SOURCE_DIR}/src/Config
${PROJECT_SOURCE_DIR}/src/ModelAPI
${PROJECT_SOURCE_DIR}/src/GeomAPI
+ ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
${CAS_INCLUDE_DIRS}
)
#define _LATERAL_TAG 1
#define _FIRST_TAG 2
#define _LAST_TAG 3
+#define EDGE 6
#ifdef _DEBUG
#include <iostream>
#include <ostream>
aSize = -aSize;
boost::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
- //TCollection_AsciiString anError;
GeomAlgoAPI_Extrusion aFeature(aFace, aSize);
if(!aFeature.isDone()) {
std::string aFeatureError = "Extrusion algorithm failed";
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());
- }
+ theResultBody->storeGenerated(theContext, theFeature.shape());
+
+ GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
+ theFeature.mapOfShapes(*aSubShapes);
+
+ //Insert lateral face : Face from Edge
+ theResultBody->loadAndOrientGeneratedShapes(theFeature.makeShape(), theFeature.shape(), EDGE,_LATERAL_TAG, *aSubShapes);
- //Insert lateral face : Face from Edge
- //GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes(*myBuilder, myBasis, TopAbs_EDGE, aLateralFaceBuilder, aSubShapes);
-
-
- TopTools_MapOfShape aView;
- TopExp_Explorer aShapeExplorer (theFeature.shape()->impl<TopoDS_Shape>(), TopAbs_EDGE);
- 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++) {
- 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);
- }
- }
- }
//Insert bottom face
- const boost::shared_ptr<GeomAPI_Shape>& aBottomFace = theFeature.firstShape();
+ boost::shared_ptr<GeomAPI_Shape> aBottomFace = theFeature.firstShape();
if (!aBottomFace->isNull()) {
- if (aSubShapes.IsBound(aBottomFace->impl<TopoDS_Shape>())) {
- aBottomFace->setImpl((void *)&aSubShapes(aBottomFace->impl<TopoDS_Shape>()));
+ if (aSubShapes->isBound(aBottomFace)) {
+ aBottomFace = aSubShapes->find(aBottomFace);
}
theResultBody->generated(aBottomFace, _FIRST_TAG);
}
//Insert top face
boost::shared_ptr<GeomAPI_Shape> aTopFace = theFeature.lastShape();
if (!aTopFace->isNull()) {
- if (aSubShapes.IsBound(aTopFace->impl<TopoDS_Shape>())) {
- aTopFace->setImpl((void *)&aSubShapes(aTopFace->impl<TopoDS_Shape>()));
+ if (aSubShapes->isBound(aTopFace)) {
+ aTopFace = aSubShapes->find(aTopFace);
}
- theResultBody->generated(aTopFace, _FIRST_TAG);
+ theResultBody->generated(aTopFace, _LAST_TAG);
}
- */
+
}
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultBody.h>
#include <GeomAlgoAPI_Extrusion.h>
+#include <GeomAPI_Shape.h>
class FeaturesPlugin_Extrusion : public ModelAPI_Feature
{
public:
#include <GeomAPI_Shape.h>
#include <GeomAPI_DataMapOfShapeShape.h>
#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopoDS_Shape.hxx>
using namespace std;
}
/// Adds the Key <K> to the Map <me> with the Item. Returns True if the Key was not already in the map
-bool GeomAPI_DataMapOfShapeShape::bind (const boost::shared_ptr<GeomAPI_Shape>& theKey, const boost::shared_ptr<GeomAPI_Shape>& theItem)
+bool GeomAPI_DataMapOfShapeShape::bind (boost::shared_ptr<GeomAPI_Shape> theKey, boost::shared_ptr<GeomAPI_Shape> theItem)
{
bool flag(false);
if(implPtr<TopTools_DataMapOfShapeShape>()->Bind(theKey->impl<TopoDS_Shape>(), theItem->impl<TopoDS_Shape>()))
}
/// Returns true if theKey is stored in the map.
-bool GeomAPI_DataMapOfShapeShape::isBound (const boost::shared_ptr<GeomAPI_Shape>& theKey)
+bool GeomAPI_DataMapOfShapeShape::isBound (boost::shared_ptr<GeomAPI_Shape> theKey)
{
bool flag(false);
if(impl<TopTools_DataMapOfShapeShape>().IsBound(theKey->impl<TopoDS_Shape>()))
}
/// Returns the Item stored with the Key in the Map. To be checked before with isBound()
-const boost::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(const boost::shared_ptr<GeomAPI_Shape>& theKey)
+const boost::shared_ptr<GeomAPI_Shape> GeomAPI_DataMapOfShapeShape::find(boost::shared_ptr<GeomAPI_Shape> theKey)
{
boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl((void *)&(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
+ aShape->setImpl(new TopoDS_Shape(impl<TopTools_DataMapOfShapeShape>().Find(theKey->impl<TopoDS_Shape>())));
return aShape;
}
/// Removes the Key from the map. Returns true if the Key was in the Map
-bool GeomAPI_DataMapOfShapeShape::unBind(const boost::shared_ptr<GeomAPI_Shape>& theKey)
+bool GeomAPI_DataMapOfShapeShape::unBind(boost::shared_ptr<GeomAPI_Shape> theKey)
{
bool flag(false);
if(implPtr<TopTools_DataMapOfShapeShape>()->UnBind(theKey->impl<TopoDS_Shape>()))
flag = true;
return flag;
-}
\ No newline at end of file
+}
+
+ GeomAPI_DataMapOfShapeShape::~GeomAPI_DataMapOfShapeShape()
+ {
+ if (myImpl) {
+ implPtr<TopTools_DataMapOfShapeShape>()->Clear();
+ //delete myImpl;
+ }
+ }
\ No newline at end of file
void clear();
/// Adds the Key <K> to the Map <me> with the Item. Returns True if the Key was not already in the map
- bool bind (const boost::shared_ptr<GeomAPI_Shape>& theKey, const boost::shared_ptr<GeomAPI_Shape>& theItem);
+ bool bind (boost::shared_ptr<GeomAPI_Shape> theKey, boost::shared_ptr<GeomAPI_Shape> theItem);
/// Returns true if theKey is stored in the map.
- bool isBound (const boost::shared_ptr<GeomAPI_Shape>& theKey);
+ bool isBound (boost::shared_ptr<GeomAPI_Shape> theKey);
/// Returns the Item stored with the Key in the Map.
- const boost::shared_ptr<GeomAPI_Shape> find(const boost::shared_ptr<GeomAPI_Shape>& theKey);
+ const boost::shared_ptr<GeomAPI_Shape> find(boost::shared_ptr<GeomAPI_Shape> theKey);
/// Removes the Key from the map. Returns true if the Key was in the Map
- bool unBind(const boost::shared_ptr<GeomAPI_Shape>& theKey);
+ bool unBind(boost::shared_ptr<GeomAPI_Shape> theKey);
+
+ /// Destructor
+ ~GeomAPI_DataMapOfShapeShape();
};
#endif
}
return aResult;
}
-/*
-//=======================================================================
-//function : loadDeletedShapes
-//purpose : load deleted shapes in DF
-//=======================================================================
-void GeomAlgoAPI_DFLoader::loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS,
- const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theKindOfShape,
- TNaming_Builder& theBuilder)
-{
- TopTools_MapOfShape aView;
- TopExp_Explorer ShapeExplorer (theShapeIn, theKindOfShape);
- for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- if (theMS.IsDeleted (aRoot)) {
- theBuilder.Delete (aRoot);
- }
- }
-}
-
-//=======================================================================
-//function : loadAndOrientModifiedShapes
-//purpose : load modified shapes in DF with preliminary orientation adjustment
-//=======================================================================
-void GeomAlgoAPI_DFLoader::loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape& theMS,
- const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theKindOfShape,
- TNaming_Builder& theBuilder,
- const TopTools_DataMapOfShapeShape& theSubShapes)
-{
- TopTools_MapOfShape aView;
- TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- const TopTools_ListOfShape& aShapes = theMS.Modified (aRoot);
- TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes);
- for (;aShapesIterator.More (); aShapesIterator.Next ()) {
- TopoDS_Shape aNewShape = aShapesIterator.Value ();
- if (theSubShapes.IsBound(aNewShape)) {
- aNewShape.Orientation((theSubShapes(aNewShape)).Orientation());
- }
- if (!aRoot.IsSame (aNewShape)) theBuilder.Modify (aRoot, aNewShape );
- }
- }
-}
-
-//=======================================================================
-//function : loadAndOrientGeneratedShapes
-//purpose : load generated shapes in DF with preliminary orientation adjustment
-//=======================================================================
-
-void GeomAlgoAPI_DFLoader::loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape& theMS,
- const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theKindOfShape,
- TNaming_Builder& theBuilder,
- const TopTools_DataMapOfShapeShape& theSubShapes)
-{
- TopTools_MapOfShape aView;
- TopExp_Explorer aShapeExplorer (theShapeIn, theKindOfShape);
- for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
- const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
- if (!aView.Add(aRoot)) continue;
- const TopTools_ListOfShape& aShapes = theMS.Generated (aRoot);
- TopTools_ListIteratorOfListOfShape aShapesIterator (aShapes);
- for (;aShapesIterator.More (); aShapesIterator.Next ()) {
- TopoDS_Shape aNewShape = aShapesIterator.Value ();
- if (theSubShapes.IsBound(aNewShape)) {
- aNewShape.Orientation((theSubShapes(aNewShape)).Orientation());
- }
- if (!aRoot.IsSame (aNewShape)) theBuilder.Generated (aRoot,aNewShape );
- }
- }
-}
-*/
\ No newline at end of file
#ifndef GeomAlgoAPI_DFLoader_H_
#define GeomAlgoAPI_DFLoader_H_
#include <GeomAlgoAPI.h>
-//#include <boost/shared_ptr.hpp>
-#include <BRepBuilderAPI_MakeShape.hxx>
#include <TopoDS_Shape.hxx>
-#include <TNaming_Builder.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <TopTools_DataMapOfShapeShape.hxx>
/**\class GeomAlgoAPI_DFLoader
* \ingroup DataAlgo
class GEOMALGOAPI_EXPORT GeomAlgoAPI_DFLoader
{
public:
- /*
- /// Loads to DF deleted shapes
- static void loadDeletedShapes (BRepBuilderAPI_MakeShape& theMS, const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum KindOfShape, TNaming_Builder& theBuilder);
-
- /// Loads to DF generated shapes
- static void loadAndOrientGeneratedShapes (BRepBuilderAPI_MakeShape& theMS,
- const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theKindOfShape,
- TNaming_Builder& theBuilder,
- const TopTools_DataMapOfShapeShape& theSubShapes);
- /// Loads to DF modified shapes
- static void loadAndOrientModifiedShapes (BRepBuilderAPI_MakeShape& theMS,
- const TopoDS_Shape& theShapeIn,
- const TopAbs_ShapeEnum theKindOfShape,
- TNaming_Builder& theBuilder,
- const TopTools_DataMapOfShapeShape& theSubShapes);
- */
/// Refine result
static const TopoDS_Shape refineResult(const TopoDS_Shape& theShape);
};
#include <GeomAlgoAPI_Extrusion.h>
#include <GeomAlgoAPI_MakeShape.h>
#include <GeomAlgoAPI_DFLoader.h>
-#include <GeomAlgoAPI_DFLoader.h>
+#include <GeomAlgoAPI_MakeShape.h>
#include <gp_Pln.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepBuilderAPI_MakeShape.hxx>
// 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())
+: mySize(theSize), myDone(false), myShape(new GeomAPI_Shape()),
+ myFirst(new GeomAPI_Shape()), myLast(new GeomAPI_Shape())
{
build(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));
aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape());
else
aResult = aBuilder->Shape();
+
+ for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
+ boost::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
+ myMap.bind(aCurrentShape, aCurrentShape);
+ }
+
myShape->setImpl(new TopoDS_Shape(aResult));
myFirst->setImpl(new TopoDS_Shape(aBuilder->FirstShape()));
myLast->setImpl(new TopoDS_Shape(aBuilder-> LastShape()));
+ myMkShape = new GeomAlgoAPI_MakeShape (aBuilder);
}
}
}
{return myShape;}
//============================================================================
-void GeomAlgoAPI_Extrusion::generated(
+/*void GeomAlgoAPI_Extrusion::generated(
const boost::shared_ptr<GeomAPI_Shape> theShape, ListOfShape& theHistory)
{
theHistory.clear();
}
}
}
-
+*/
//============================================================================
const boost::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Extrusion::firstShape()
{
}
//============================================================================
-/*
-void GeomAlgoAPI_Extrusion::LoadNamingDS(boost::shared_ptr<ModelAPI_ResultBody> theResultBody,
-boost::shared_ptr<GeomAPI_Shape> theContext)
+void GeomAlgoAPI_Extrusion::mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const
{
-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());
-}
+ theMap = myMap;
}
+//============================================================================
+GeomAlgoAPI_MakeShape * GeomAlgoAPI_Extrusion::makeShape() const
+{
+ return myMkShape;
}
-//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
+//============================================================================
+GeomAlgoAPI_Extrusion::~GeomAlgoAPI_Extrusion()
+{
+ if (myImpl) {
+ myMap.clear();
+ //delete myImpl;
+ }
+}
\ No newline at end of file
#include <GeomAPI_Shape.h>
#include <GeomAPI_Dir.h>
#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
#include <boost/shared_ptr.hpp>
/**\class GeomAlgoAPI_Extrusion
* \ingroup DataAlgo
* \brief Allows to create the prism based on a given face and a direction
*/
-class GeomAlgoAPI_Extrusion : public GeomAPI_Interface
+class GeomAlgoAPI_Extrusion : public GeomAPI_Interface//GeomAlgoAPI_MakeShape
{
public:
GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& shape () const;
/// Returns list of shapes generated from theShape
- GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
- ListOfShape& theHistory);
+ // GEOMALGOAPI_EXPORT void generated(const boost::shared_ptr<GeomAPI_Shape> theShape,
+ // ListOfShape& theHistory);
/// Returns the first shape
GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& firstShape();
/// returns last shape
- GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();
+ GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape>& lastShape();
+
+ /// Returns map of sub-shapes of the result
+ GEOMALGOAPI_EXPORT void mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const;
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const;
+
+ GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Extrusion();
private:
/// builds resulting shape
void build(const boost::shared_ptr<GeomAPI_Shape>& theBasis);
boost::shared_ptr<GeomAPI_Shape> myShape;
boost::shared_ptr<GeomAPI_Shape> myFirst;
boost::shared_ptr<GeomAPI_Shape> myLast;
+ GeomAPI_DataMapOfShapeShape myMap;
+ GeomAlgoAPI_MakeShape * myMkShape;
};
#endif
// Author: Sergey ZARITCHNY
#include <GeomAlgoAPI_MakeShape.h>
+#include <BRepBuilderAPI_MakeShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape(void* theMkShape)
- : GeomAPI_Interface(theMkShape)
+ : GeomAPI_Interface(theMkShape),myShape(new GeomAPI_Shape())
+{
+ myShape->setImpl((void *)&implPtr<BRepBuilderAPI_MakeShape>()->Shape());
+}
+
+GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape()
+ : GeomAPI_Interface(),myShape(new GeomAPI_Shape())
{}
+void GeomAlgoAPI_MakeShape::init(void* theMkShape)
+{
+ setImpl((void *)implPtr<BRepBuilderAPI_MakeShape>());
+}
const boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_MakeShape::shape() const
{
TopTools_ListIteratorOfListOfShape it(aList);
for(;it.More();it.Next()) {
boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(&(it.Value()));
+ aShape->setImpl(new TopoDS_Shape(it.Value()));
theHistory.push_back(aShape);
}
}
TopTools_ListIteratorOfListOfShape it(aList);
for(;it.More();it.Next()) {
boost::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(&(it.Value()));
+ aShape->setImpl(new TopoDS_Shape(it.Value()));
theHistory.push_back(aShape);
}
}
#include <GeomAPI_Shape.h>
#include <boost/shared_ptr.hpp>
#include <GeomAlgoAPI.h>
-#include <BRepBuilderAPI_MakeShape.hxx>
+//#include <BRepBuilderAPI_MakeShape.hxx>
/**\class GeomAlgoAPI_MakeShape
* \ingroup DataModel
* \Interface to the root class of all topological shapes constructions
*/
-class GeomAlgoAPI_MakeShape : GeomAPI_Interface
+class GeomAlgoAPI_MakeShape : public GeomAPI_Interface
{
public:
/// Constructor
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape();
+
GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder);
+
/// Returns a shape built by the shape construction algorithm
GEOMALGOAPI_EXPORT const boost::shared_ptr<GeomAPI_Shape> shape() const;
/// Returns whether the shape is an edge
GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT void init(void* theMkShape);
+
protected:
boost::shared_ptr<GeomAPI_Shape> myShape;
};
#include <TNaming_NamedShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TDF_ChildIterator.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
#include <GeomAPI_Shape.h>
-
+#include <GeomAlgoAPI_MakeShape.h>
+// DEB
+//#include <TCollection_AsciiString.hxx>
+//#include <TDF_Tool.hxx>
Model_ResultBody::Model_ResultBody()
{
setIsConcealed(false);
TNaming_Builder* Model_ResultBody::builder(const int theTag)
{
- if (myBuilders.size() < (unsigned int)theTag) {
+ if (myBuilders.size() <= (unsigned int)theTag) {
myBuilders.insert(myBuilders.end(), theTag - myBuilders.size() + 1, NULL);
}
if (!myBuilders[theTag]) {
boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
myBuilders[theTag] = new TNaming_Builder(aData->shapeLab().FindChild(theTag));
+ //TCollection_AsciiString entry;//
+ //TDF_Tool::Entry(aData->shapeLab().FindChild(theTag), entry);
+ //cout << "Label = " <<entry.ToCString() <<endl;
}
return myBuilders[theTag];
}
TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
builder(theTag)->Delete(aShape);
}
+
+void Model_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag)
+{
+ TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+ TopTools_MapOfShape aView;
+ TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
+ for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
+ const TopoDS_Shape& aRoot = ShapeExplorer.Current ();
+ if (!aView.Add(aRoot)) continue;
+ boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+ aRShape->setImpl((new TopoDS_Shape(aRoot)));
+ if (theMS->isDeleted (aRShape)) {
+ builder(theTag)->Delete(aRoot);
+ }
+ }
+}
+
+void Model_ResultBody::loadAndOrientModifiedShapes (
+ GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+ TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+ TopTools_MapOfShape aView;
+ TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
+ for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+ const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
+ if (!aView.Add(aRoot)) continue;
+ ListOfShape aList;
+ boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+ aRShape->setImpl((new TopoDS_Shape(aRoot)));
+ theMS->generated(aRShape, aList);
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+ for (; anIt != aLast; anIt++) {
+ TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
+ if (theSubShapes.isBound(*anIt)) {
+ boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+ aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+ }
+ if (!aRoot.IsSame (aNewShape))
+ builder(theTag)->Modify(aRoot,aNewShape);
+ }
+ }
+}
+
+void Model_ResultBody::loadAndOrientGeneratedShapes (
+ GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ GeomAPI_DataMapOfShapeShape& theSubShapes)
+{
+ TopoDS_Shape aShapeIn = theShapeIn->impl<TopoDS_Shape>();
+ TopTools_MapOfShape aView;
+ TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape);
+ for (; aShapeExplorer.More(); aShapeExplorer.Next ()) {
+ const TopoDS_Shape& aRoot = aShapeExplorer.Current ();
+ if (!aView.Add(aRoot)) continue;
+ ListOfShape aList;
+ boost::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
+ aRShape->setImpl((new TopoDS_Shape(aRoot)));
+ theMS->generated(aRShape, aList);
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aList.begin(), aLast = aList.end();
+ for (; anIt != aLast; anIt++) {
+ TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
+ if (theSubShapes.isBound(*anIt)) {
+ boost::shared_ptr<GeomAPI_Shape> aMapShape(theSubShapes.find(*anIt));
+ aNewShape.Orientation(aMapShape->impl<TopoDS_Shape>().Orientation());
+ }
+ if (!aRoot.IsSame (aNewShape))
+ builder(theTag)->Generated(aRoot,aNewShape);
+ }
+ }
+}
\ No newline at end of file
#include "Model.h"
#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
#include <vector>
class TNaming_Builder;
MODEL_EXPORT virtual void deleted(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
const int theTag = 1);
+ /// load deleted shapes
+ MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag);
+ /// load and orient modified shapes
+ MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
+ GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ GeomAPI_DataMapOfShapeShape& theSubShapes);
+ /// load and orient generated shapes
+ MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
+ GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ GeomAPI_DataMapOfShapeShape& theSubShapes);
+
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_ResultBody();
../Config
../Events
../GeomAPI
+ ../GeomAlgoAPI
)
SET(CMAKE_SWIG_FLAGS "")
#include "ModelAPI_Result.h"
#include <GeomAPI_Shape.h>
-
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+#include <boost/shared_ptr.hpp>
#include <string>
/**\class ModelAPI_ResultBody
/// As an example, consider the case of a face removed by a Boolean operation.
virtual void deleted(
const boost::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
-
+
+ /// load deleted shapes
+ virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag) = 0;
+ /// load and orient modified shapes
+ virtual void loadAndOrientModifiedShapes (
+ GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
+ /// load and orient generated shapes
+ virtual void loadAndOrientGeneratedShapes (
+ GeomAlgoAPI_MakeShape* theMS,
+ boost::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag,
+ GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
protected:
};
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/ModuleBase
${PROJECT_SOURCE_DIR}/src/PartSetPlugin
+ ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
${CAS_INCLUDE_DIRS}
${SUIT_INCLUDE})