return INVALID_TAG;
}
-static TopAbs_ShapeEnum convertShapeType(const GeomAPI_Shape::ShapeType theType) {
- switch (theType) {
- case GeomAPI_Shape::VERTEX: return TopAbs_VERTEX;
- case GeomAPI_Shape::EDGE: return TopAbs_EDGE;
- case GeomAPI_Shape::WIRE: return TopAbs_WIRE;
- case GeomAPI_Shape::FACE: return TopAbs_FACE;
- case GeomAPI_Shape::SHELL: return TopAbs_SHELL;
- case GeomAPI_Shape::SOLID: return TopAbs_SOLID;
- case GeomAPI_Shape::COMPSOLID: return TopAbs_COMPSOLID;
- case GeomAPI_Shape::COMPOUND: return TopAbs_COMPOUND;
- case GeomAPI_Shape::SHAPE: return TopAbs_SHAPE;
- }
- return TopAbs_SHAPE;
-}
-
static bool isAlreadyStored(const TNaming_Builder* theBuilder,
const TopoDS_Shape& theOldShape,
const TopoDS_Shape& theNewShape)
}
}
-void Model_BodyBuilder::storeWithoutNaming(const GeomShapePtr& theShape)
-{
- std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- if (aData) {
- clean();
- if (!theShape.get())
- return; // bad shape
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
- if (aShape.IsNull())
- return; // null shape inside
- TNaming_Builder aBuilder(aData->shapeLab());
- aBuilder.Select(aShape, aShape);
- }
-}
-
void Model_BodyBuilder::clean()
{
TDF_Label aLab = std::dynamic_pointer_cast<Model_Data>(data())->shapeLab();
buildName(aTag, theName);
}
-void Model_BodyBuilder::deleted(const GeomShapePtr& theOldShape)
-{
- TopoDS_Shape aShape = theOldShape->impl<TopoDS_Shape>();
- builder(DELETED_TAG)->Delete(aShape);
-}
-
void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
}
}
-static void removeBadShapes(ListOfShape& theShapes)
-{
- ListOfShape::iterator anIt = theShapes.begin();
- while (anIt != theShapes.end()) {
- TopoDS_Shape aNewShape = (*anIt)->impl<TopoDS_Shape>();
- bool aSkip = aNewShape.IsNull()
- || (aNewShape.ShapeType() == TopAbs_EDGE && BRep_Tool::Degenerated(TopoDS::Edge(aNewShape)));
- if (aSkip) {
- ListOfShape::iterator aRemoveIt = anIt++;
- theShapes.erase(aRemoveIt);
- } else {
- ++anIt;
- }
- }
-}
-
// Keep only the shapes with minimal shape type
static void keepTopLevelShapes(ListOfShape& theShapes,
const TopoDS_Shape& theRoot,
}
}
-// returns an ancestor shape-type that used for naming-definition of the sub-type
-TopAbs_ShapeEnum typeOfAncestor(const TopAbs_ShapeEnum theSubType) {
- if (theSubType == TopAbs_VERTEX)
- return TopAbs_EDGE;
- if (theSubType == TopAbs_EDGE)
- return TopAbs_FACE;
- return TopAbs_VERTEX; // bad case
-}
-
/// Checks that shape is presented in the tree with not-selection evolution
/// In theOriginalLabel it returns label where NS of old sub-shape is stored
static bool isShapeInTree(const TDF_Label& theAccess1, const TDF_Label& theAccess2,
}
}
+// LCOV_EXCL_START
//=======================================================================
int getDangleShapes(const TopoDS_Shape& theShapeIn,
const TopAbs_ShapeEnum theGeneratedFrom,
for (; itr.More(); itr.Next())
theBuilder->Generated(itr.Key(), itr.Value());
}
+// LCOV_EXCL_STOP
//=======================================================================
void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape,
}
}
-//=======================================================================
-void Model_BodyBuilder::loadDisconnectedEdges(GeomShapePtr theShape, const std::string& theName)
-{
- if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
- TopTools_DataMapOfShapeListOfShape edgeNaborFaces;
- TopTools_ListOfShape empty;
- TopExp_Explorer explF(aShape, TopAbs_FACE);
- for (; explF.More(); explF.Next()) {
- const TopoDS_Shape& aFace = explF.Current();
- TopExp_Explorer explV(aFace, TopAbs_EDGE);
- for (; explV.More(); explV.Next()) {
- const TopoDS_Shape& anEdge = explV.Current();
- if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty);
- Standard_Boolean faceIsNew = Standard_True;
- TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge));
- for (; itrF.More(); itrF.Next()) {
- if (itrF.Value().IsSame(aFace)) {
- faceIsNew = Standard_False;
- break;
- }
- }
- if (faceIsNew)
- edgeNaborFaces.ChangeFind(anEdge).Append(aFace);
- }
- }
-
- TopTools_MapOfShape anEdgesToDelete;
- TopExp_Explorer anEx(aShape,TopAbs_EDGE);
- std::string aName;
- for(;anEx.More();anEx.Next()) {
- Standard_Boolean aC0 = Standard_False;
- TopoDS_Shape anEdge1 = anEx.Current();
- if (edgeNaborFaces.IsBound(anEdge1)) {
- const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1);
- if (aList1.Extent()<2) continue;
- TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces);
- for (; itr.More(); itr.Next()) {
- TopoDS_Shape anEdge2 = itr.Key();
- if(anEdgesToDelete.Contains(anEdge2)) continue;
- if (anEdge1.IsSame(anEdge2)) continue;
- const TopTools_ListOfShape& aList2 = itr.Value();
- // compare lists of the neighbor faces of edge1 and edge2
- if (aList1.Extent() == aList2.Extent()) {
- Standard_Integer aMatches = 0;
- for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next())
- for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next())
- if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++;
- if (aMatches == aList1.Extent()) {
- aC0=Standard_True;
- builder(myFreePrimitiveTag)->Generated(anEdge2);
- anEdgesToDelete.Add(anEdge2);
- TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
- aName = theName + "_" + aStr.ToCString();
- buildName(myFreePrimitiveTag, aName);
- ++myFreePrimitiveTag;
- }
- }
- }
- TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete);
- for(;itDelete.More();itDelete.Next())
- edgeNaborFaces.UnBind(itDelete.Key());
- edgeNaborFaces.UnBind(anEdge1);
- }
- if (aC0) {
- builder(myFreePrimitiveTag)->Generated(anEdge1);
- TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
- aName = theName + "_" + aStr.ToCString();
- buildName(myFreePrimitiveTag, aName);
- ++myFreePrimitiveTag;
- }
- }
-}
-
-void Model_BodyBuilder::loadDisconnectedVertexes(GeomShapePtr theShape,
- const std::string& theName)
-{
- if(theShape->isNull()) return;
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
- TopTools_DataMapOfShapeListOfShape vertexNaborEdges;
- TopTools_ListOfShape empty;
- TopExp_Explorer explF(aShape, TopAbs_EDGE);
- for (; explF.More(); explF.Next()) {
- const TopoDS_Shape& anEdge = explF.Current();
- TopExp_Explorer explV(anEdge, TopAbs_VERTEX);
- for (; explV.More(); explV.Next()) {
- const TopoDS_Shape& aVertex = explV.Current();
- if (!vertexNaborEdges.IsBound(aVertex)) vertexNaborEdges.Bind(aVertex, empty);
- Standard_Boolean faceIsNew = Standard_True;
- TopTools_ListIteratorOfListOfShape itrF(vertexNaborEdges.Find(aVertex));
- for (; itrF.More(); itrF.Next()) {
- if (itrF.Value().IsSame(anEdge)) {
- faceIsNew = Standard_False;
- break;
- }
- }
- if (faceIsNew) {
- vertexNaborEdges.ChangeFind(aVertex).Append(anEdge);
- }
- }
- }
- std::string aName;
- TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborEdges);
- for (; itr.More(); itr.Next()) {
- const TopTools_ListOfShape& naborEdges = itr.Value();
- if (naborEdges.Extent() < 2) {
- builder(myFreePrimitiveTag)->Generated(itr.Key());
- TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1);
- aName = theName + "_" + aStr.ToCString();
- buildName(myFreePrimitiveTag, aName);
- ++myFreePrimitiveTag;
- }
- }
-}
-
GeomShapePtr Model_BodyBuilder::shape()
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
}
return GeomShapePtr();
}
-
-bool Model_BodyBuilder::isLatestEqual(const GeomShapePtr& theShape)
-{
- if (theShape.get()) {
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
- std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- if (aData) {
- TDF_Label aShapeLab = aData->shapeLab();
- Handle(TNaming_NamedShape) aName;
- if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
- TopoDS_Shape aLatest = TNaming_Tool::CurrentShape(aName);
- if (aLatest.IsNull())
- return false;
- if (aLatest.IsEqual(aShape))
- return true;
- // check sub-shapes for comp-solids:
- for (TopExp_Explorer anExp(aShape, aLatest.ShapeType()); anExp.More(); anExp.Next()) {
- if (aLatest.IsEqual(anExp.Current()))
- return true;
- }
- }
- }
- }
- return false;
-}
const GeomShapePtr& theNewShape,
const bool theIsCleanStored = true) override;
- /// Stores the shape without naming support
- /// \param theShape shape to store
- MODEL_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
-
/// Returns the shape-result produced by this feature
MODEL_EXPORT virtual GeomShapePtr shape();
const GeomShapePtr& theNewShape,
const std::string& theName = "") override;
- /// Records the shape oldShape which was deleted from the current label.
- /// As an example, consider the case of a face removed by a Boolean operation.
- MODEL_EXPORT virtual void deleted(const GeomShapePtr& theOldShape) override;
-
/// load deleted shapes
MODEL_EXPORT
virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
const std::string& theName) override;
- /// Loads disconnected edges
- MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
- const std::string& theName) override;
-
- /// Loads disconnected vetexes
- MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
- const std::string& theName) override;
-
/// Removes the stored builders
MODEL_EXPORT virtual ~Model_BodyBuilder();
- /// Returns true if the latest modification of this body in the naming history
- // is equal to the given shape
- MODEL_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape);
-
protected:
/// Default constructor accessible only by Model_Objects
Model_BodyBuilder(ModelAPI_Object* theOwner);
}
}
-bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
-{
- if (myBuilder->isLatestEqual(theShape))
- return true;
- // also check that it is asked for sub-elements
- std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
- for(; aSubIter != mySubs.cend(); aSubIter++) {
- if (aSubIter->get() && (*aSubIter)->isLatestEqual(theShape)) {
- return true;
- }
- }
- return false;
-}
-
bool Model_ResultBody::isConnectedTopology()
{
TDF_Label aDataLab = std::dynamic_pointer_cast<Model_Data>(data())->label();
* Provides a shape that may be displayed in the viewer.
* May provide really huge results, so, working with this kind
* of result must be optimized.
-* Also provides a conainer of sub-body result in case it is compound or compsolid.
+* Also provides a container of sub-body result in case it is compound or compsolid.
*/
class Model_ResultBody : public ModelAPI_ResultBody
{
MODEL_EXPORT virtual ResultBodyPtr subResult(const int theIndex,
bool forTree = false) const;
- /// Returns true if feature or reuslt belong to this composite feature as subs
+ /// Returns true if feature or result belong to this composite feature as subs
/// Returns theIndex - zero based index of sub if found
MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const;
- /// Returns the parameters of color definition in the resources config manager
+ /// Returns the parameters of color definition in the resources configuration manager
MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
std::string& theDefault);
/// Sets all subs as concealed in the data tree (referenced by other objects)
MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
- /// Returns true if the latest modification of this body in the naming history
- // is equal to the given shape
- MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
-
/// Returns true is the topology is connected.
MODEL_EXPORT virtual bool isConnectedTopology();
void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
const bool theShapeChanged = true);
- // Checks the state of children and partents to send events of creation/erase when needed
+ // Checks the state of children and parents to send events of creation/erase when needed
void updateConcealment();
friend class Model_Objects;
const GeomShapePtr& theNewShape,
const bool theIsCleanStored = true) = 0;
- /// Stores the shape without naming support
- virtual void storeWithoutNaming(const GeomShapePtr& theShape) = 0;
-
/// Returns the shape-result produced by this feature
virtual GeomShapePtr shape() = 0;
const GeomShapePtr& theNewShape,
const std::string& theName = "") = 0;
- /// Records the shape oldShape which was deleted from the current label.
- /// As an example, consider the case of a face removed by a Boolean operation.
- virtual void deleted(const GeomShapePtr& theOldShape) = 0;
-
/// load deleted shapes
virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
virtual void loadFirstLevel(GeomShapePtr theShape,
const std::string& theName) = 0;
- /// load disconnected edges
- virtual void loadDisconnectedEdges(GeomShapePtr theShape,
- const std::string& theName) = 0;
-
- /// load disconnected vetexes
- virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
- const std::string& theName) = 0;
-
- /// Returns true if the latest modification of this body in the naming history
- // is equal to the given shape
- virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
-
protected:
/// Returns the data manager of this object: attributes
MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
protected:
- /// Deafult constructor accessible only from Model_Object
+ /// Default constructor accessible only from Model_Object
MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
ModelAPI_Object* myOwner; ///< the owner object this builder belongs to
updateSubs(theNewShape);
}
-void ModelAPI_ResultBody::storeWithoutNaming(const GeomShapePtr& theShape)
-{
- myBuilder->storeWithoutNaming(theShape);
- myConnect = ConnectionNotComputed;
-
- static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
- aECreator->sendUpdated(data()->owner(), aRedispEvent);
-}
-
GeomShapePtr ModelAPI_ResultBody::shape()
{
return myBuilder->shape();
}
-void ModelAPI_ResultBody::deleted(const GeomShapePtr& theOldShape)
-{
- myBuilder->deleted(theOldShape);
-}
-
void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
const GeomShapePtr& theOldShape,
const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
myBuilder->loadFirstLevel(theShape, theName);
}
-void ModelAPI_ResultBody::loadDisconnectedEdges(GeomShapePtr theShape,
- const std::string& theName)
-{
- myBuilder->loadDisconnectedEdges(theShape, theName);
-}
-
-void ModelAPI_ResultBody::loadDisconnectedVertexes(GeomShapePtr theShape,
- const std::string& theName)
-{
- myBuilder->loadDisconnectedVertexes(theShape, theName);
-}
-
bool ModelAPI_ResultBody::isConnectedTopology()
{
if (myConnect == ConnectionNotComputed) {
* Provides a shape that may be displayed in the viewer.
* May provide really huge results, so, working with this kind
* of result must be optimized.
-* Also provides a conainer of sub-body result in case it is compound or compsolid.
+* Also provides a container of sub-body result in case it is compound or compsolid.
*/
class ModelAPI_ResultBody : public ModelAPI_Result
{
public:
- /// Iternal enumeration for storage the information of connected topology flag
+ /// Internal enumeration for storage the information of connected topology flag
enum ConnectedTopologyFlag {
ConnectionNotComputed, ///< not yet computed
IsConnected, ///< the topology is connected
MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(
const int theIndex, bool forTree = false) const = 0;
- /// Returns true if feature or reuslt belong to this composite feature as subs
+ /// Returns true if feature or result belong to this composite feature as subs
/// Returns theIndex - zero based index of sub if found
MODELAPI_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const = 0;
const GeomShapePtr& theNewShape,
const bool theIsCleanStored = true);
- /// Stores the shape without naming support
- MODELAPI_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
-
/// Returns the shape-result produced by this feature
MODELAPI_EXPORT virtual GeomShapePtr shape();
const GeomShapePtr& theNewShape,
const std::string& theName = "");
- /// Records the shape oldShape which was deleted from the current label.
- /// As an example, consider the case of a face removed by a Boolean operation.
- MODELAPI_EXPORT virtual void deleted(const GeomShapePtr& theOldShape);
-
/// load deleted shapes
MODELAPI_EXPORT
virtual void loadDeletedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
const std::string& theName);
- /// load disconnected edges
- MODELAPI_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
- const std::string& theName);
-
- /// load disconnected vetexes
- MODELAPI_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
- const std::string& theName);
-
- /// Returns true if the latest modification of this body in the naming history
- // is equal to the given shape
- MODELAPI_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
-
/// Returns true is the topology is connected.
MODELAPI_EXPORT virtual bool isConnectedTopology() = 0;
}
}
}
-// LCOV_EXCL_START
+// LCOV_EXCL_STOP
} else // compare addresses if shapes are geometrically equal
return theShape1.TShape().get() > theShape2.TShape().get();
}