/*************************************************************************** * Copyright (c) 2022 WandererFan #include #include #include #include "DrawViewPart.h" #include "DrawUtil.h" #include "Geometry.h" #include "DimensionReferences.h" using namespace TechDraw; TopoDS_Shape ReferenceEntry::getGeometry() const { if ( getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()) ) { TechDraw::DrawViewPart* dvp = static_cast(getObject()); std::string gType = geomType(); if (gType == "Vertex") { auto vgeom = dvp->getVertex(getSubName()); return vgeom->occVertex; } else if (gType == "Edge") { auto egeom = dvp->getEdge(getSubName()); return egeom->occEdge; } else if (gType == "Face") { auto fgeom = dvp->getFace(getSubName()); return fgeom->toOccFace(); } return TopoDS_Shape(); } Part::TopoShape shape = Part::Feature::getTopoShape(getObject()); App::GeoFeature* geoFeat = dynamic_cast(getObject()); if (geoFeat) { shape.setPlacement(geoFeat->globalPlacement()); } if (getSubName().empty()) { return shape.getShape(); } return shape.getSubShape(getSubName().c_str()); } std::string ReferenceEntry::getSubName(bool longForm) const { if (longForm) { return m_subName; } std::string workingSubName(m_subName); size_t lastDot = workingSubName.rfind('.'); if (lastDot != std::string::npos) { workingSubName = workingSubName.substr(lastDot + 1); } return workingSubName; } std::string ReferenceEntry::geomType() const { return DrawUtil::getGeomTypeFromName(getSubName()); } bool ReferenceEntry::isWholeObject() const { return getSubName().empty(); }