[TD]improve handling of Assembly4 Models
This commit is contained in:
@@ -133,6 +133,8 @@ SET(TechDraw_SRCS
|
||||
AppTechDrawPy.cpp
|
||||
DrawUtil.cpp
|
||||
DrawUtil.h
|
||||
ShapeExtractor.cpp
|
||||
ShapeExtractor.h
|
||||
HatchLine.cpp
|
||||
HatchLine.h
|
||||
PreCompiled.cpp
|
||||
|
||||
@@ -28,47 +28,47 @@
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLProp_CurveTool.hxx>
|
||||
#include <BRepLProp_CLProps.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLProp_CLProps.hxx>
|
||||
#include <BRepLProp_CurveTool.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <GeomLib_Tool.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <HLRBRep_Algo.hxx>
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <HLRBRep_ShapeBounds.hxx>
|
||||
#include <HLRBRep_Algo.hxx>
|
||||
#include <HLRBRep_HLRToShape.hxx>
|
||||
#include <ShapeFix_ShapeTolerance.hxx>
|
||||
#include <HLRBRep_ShapeBounds.hxx>
|
||||
#include <ShapeExtend_WireData.hxx>
|
||||
#include <ShapeFix_ShapeTolerance.hxx>
|
||||
#include <ShapeFix_Wire.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <GeomLib_Tool.hxx>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -87,22 +87,24 @@
|
||||
#include <Base/Parameter.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawViewSection.h"
|
||||
#include "DrawProjectSplit.h"
|
||||
#include "Geometry.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawHatch.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "DrawGeomHatch.h"
|
||||
#include "DrawViewDimension.h"
|
||||
#include "DrawHatch.h"
|
||||
#include "DrawPage.h"
|
||||
#include "DrawProjectSplit.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawViewBalloon.h"
|
||||
#include "DrawViewDetail.h"
|
||||
#include "DrawPage.h"
|
||||
#include "DrawViewDimension.h"
|
||||
#include "DrawViewPart.h"
|
||||
#include "DrawViewSection.h"
|
||||
#include "EdgeWalker.h"
|
||||
#include "Geometry.h"
|
||||
#include "GeometryObject.h"
|
||||
#include "LineGroup.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "ShapeExtractor.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewPartPy.h> // generated from DrawViewPartPy.xml
|
||||
|
||||
@@ -178,108 +180,28 @@ TopoDS_Shape DrawViewPart::getSourceShape(void) const
|
||||
getNameInDocument());
|
||||
}
|
||||
} else {
|
||||
std::vector<TopoDS_Shape> sourceShapes;
|
||||
for (auto& l:links) {
|
||||
auto shape = Part::Feature::getShape(l);
|
||||
if(!shape.IsNull())
|
||||
sourceShapes.push_back(shape);
|
||||
else {
|
||||
std::vector<TopoDS_Shape> shapeList = getShapesFromObject(l);
|
||||
sourceShapes.insert(sourceShapes.end(),shapeList.begin(),shapeList.end());
|
||||
}
|
||||
}
|
||||
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound comp;
|
||||
builder.MakeCompound(comp);
|
||||
bool found = false;
|
||||
for (auto& s:sourceShapes) {
|
||||
if (s.IsNull()) {
|
||||
continue; //has no shape
|
||||
}
|
||||
found = true;
|
||||
BRepBuilderAPI_Copy BuilderCopy(s);
|
||||
TopoDS_Shape shape = BuilderCopy.Shape();
|
||||
builder.Add(comp, shape);
|
||||
}
|
||||
//it appears that an empty compound is !IsNull(), so we need to check a different way
|
||||
//if we added anything to the compound.
|
||||
if (!found) {
|
||||
Base::Console().Error("DVP::getSourceShapes - source shape is empty!\n");
|
||||
} else {
|
||||
result = comp;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Shape> DrawViewPart::getShapesFromObject(App::DocumentObject* docObj) const
|
||||
{
|
||||
std::vector<TopoDS_Shape> result;
|
||||
App::GroupExtension* gex = dynamic_cast<App::GroupExtension*>(docObj);
|
||||
App::Property* gProp = docObj->getPropertyByName("Group");
|
||||
App::Property* sProp = docObj->getPropertyByName("Shape");
|
||||
if (docObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
Part::Feature* pf = static_cast<Part::Feature*>(docObj);
|
||||
Part::TopoShape ts = pf->Shape.getShape();
|
||||
ts.setPlacement(pf->globalPlacement());
|
||||
result.push_back(ts.getShape());
|
||||
} else if (gex != nullptr) { //is a group extension
|
||||
std::vector<App::DocumentObject*> objs = gex->Group.getValues();
|
||||
std::vector<TopoDS_Shape> shapes;
|
||||
for (auto& d: objs) {
|
||||
shapes = getShapesFromObject(d);
|
||||
if (!shapes.empty()) {
|
||||
result.insert(result.end(),shapes.begin(),shapes.end());
|
||||
}
|
||||
}
|
||||
//the next 2 bits are mostly for Arch module objects
|
||||
} else if (gProp != nullptr) { //has a Group property
|
||||
App::PropertyLinkList* list = dynamic_cast<App::PropertyLinkList*>(gProp);
|
||||
if (list != nullptr) {
|
||||
std::vector<App::DocumentObject*> objs = list->getValues();
|
||||
std::vector<TopoDS_Shape> shapes;
|
||||
for (auto& d: objs) {
|
||||
shapes = getShapesFromObject(d);
|
||||
if (!shapes.empty()) {
|
||||
result.insert(result.end(),shapes.begin(),shapes.end());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Base::Console().Log("DVP::getShapesFromObject - Group is not a PropertyLinkList!\n");
|
||||
}
|
||||
} else if (sProp != nullptr) { //has a Shape property
|
||||
Part::PropertyPartShape* shape = dynamic_cast<Part::PropertyPartShape*>(sProp);
|
||||
if (shape != nullptr) {
|
||||
TopoDS_Shape occShape = shape->getValue();
|
||||
result.push_back(occShape);
|
||||
} else {
|
||||
Base::Console().Log("DVP::getShapesFromObject - Shape is not a PropertyPartShape!\n");
|
||||
}
|
||||
result = ShapeExtractor::getShapes(links);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const
|
||||
{
|
||||
TopoDS_Shape baseShape = getSourceShape();
|
||||
if (!baseShape.IsNull()) {
|
||||
TopoDS_Iterator it(baseShape);
|
||||
TopoDS_Shape fusedShape = it.Value();
|
||||
it.Next();
|
||||
for (; it.More(); it.Next()) {
|
||||
const TopoDS_Shape& aChild = it.Value();
|
||||
BRepAlgoAPI_Fuse mkFuse(fusedShape, aChild);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone()) {
|
||||
Base::Console().Error("DVP - Fusion failed - %s\n",getNameInDocument());
|
||||
return baseShape;
|
||||
}
|
||||
fusedShape = mkFuse.Shape();
|
||||
TopoDS_Shape result;
|
||||
const std::vector<App::DocumentObject*>& links = Source.getValues();
|
||||
if (links.empty()) {
|
||||
bool isRestoring = getDocument()->testStatus(App::Document::Status::Restoring);
|
||||
if (isRestoring) {
|
||||
Base::Console().Warning("DVP::getSourceShape - No Sources (but document is restoring) - %s\n",
|
||||
getNameInDocument());
|
||||
} else {
|
||||
Base::Console().Error("Error: DVP::getSourceShape - No Source(s) linked. - %s\n",
|
||||
getNameInDocument());
|
||||
}
|
||||
baseShape = fusedShape;
|
||||
} else {
|
||||
result = ShapeExtractor::getShapesFused(links);
|
||||
}
|
||||
return baseShape;
|
||||
return result;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
@@ -303,7 +225,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
TopoDS_Shape shape = getSourceShape(); //if shape is null, it is probably(?) obj creation time.
|
||||
TopoDS_Shape shape = getSourceShape();
|
||||
if (shape.IsNull()) {
|
||||
if (isRestoring) {
|
||||
Base::Console().Warning("DVP::execute - source shape is invalid - (but document is restoring) - %s\n",
|
||||
@@ -319,7 +241,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
|
||||
inputCenter = TechDraw::findCentroid(shape,
|
||||
getViewAxis(stdOrg,Direction.getValue()));
|
||||
getViewAxis(stdOrg,Direction.getValue()));
|
||||
|
||||
shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z());
|
||||
TopoDS_Shape mirroredShape;
|
||||
@@ -347,11 +269,8 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
}
|
||||
|
||||
//add the cosmetic vertices to the geometry vertices list
|
||||
addCosmeticVertexesToGeom();
|
||||
//add the cosmetic Edges to geometry Edges list
|
||||
addCosmeticEdgesToGeom();
|
||||
//add centerlines to geometry edges list
|
||||
addCenterLinesToGeom();
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
@@ -161,9 +161,12 @@ public:
|
||||
|
||||
gp_Pln getProjPlane(void) const;
|
||||
virtual std::vector<TopoDS_Wire> getWireForFace(int idx) const;
|
||||
|
||||
virtual TopoDS_Shape getSourceShape(void) const;
|
||||
virtual std::vector<TopoDS_Shape> getShapesFromObject(App::DocumentObject* docObj) const;
|
||||
/* virtual std::vector<TopoDS_Shape> getShapesFromObject(App::DocumentObject* docObj) const; */
|
||||
virtual TopoDS_Shape getSourceShapeFused(void) const;
|
||||
/* std::vector<TopoDS_Shape> extractDrawableShapes(TopoDS_Shape shapeIn) const;*/
|
||||
|
||||
bool isIso(void) const;
|
||||
|
||||
virtual int addCosmeticVertex(Base::Vector3d pos);
|
||||
|
||||
@@ -265,7 +265,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
}
|
||||
|
||||
TopoDS_Shape rawShape = mkCut.Shape();
|
||||
|
||||
// BRepTools::Write(myShape, "DVSCopy.brep"); //debug
|
||||
// BRepTools::Write(prism, "DVSTool.brep"); //debug
|
||||
// BRepTools::Write(rawShape, "DVSResult.brep"); //debug
|
||||
@@ -281,7 +280,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
m_cutShape = rawShape;
|
||||
m_cutShape = TechDraw::moveShape(m_cutShape, //centre on origin
|
||||
-SectionOrigin.getValue());
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
gp_Ax2 viewAxis;
|
||||
try {
|
||||
|
||||
@@ -193,6 +193,7 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
|
||||
throw Base::RuntimeError("GeometryObject::projectShape - unknown error occurred while projecting shape");
|
||||
// Standard_Failure::Raise("GeometryObject::projectShape - error occurred while projecting shape");
|
||||
}
|
||||
|
||||
auto end = chrono::high_resolution_clock::now();
|
||||
auto diff = end - start;
|
||||
double diffOut = chrono::duration <double, milli> (diff).count();
|
||||
|
||||
186
src/Mod/TechDraw/App/ShapeExtractor.cpp
Normal file
186
src/Mod/TechDraw/App/ShapeExtractor.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/GroupExtension.h>
|
||||
#include <App/Part.h>
|
||||
|
||||
#include <Base/BoundBox.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
#include <Mod/Part/App/PropertyTopoShape.h>
|
||||
|
||||
#include "ShapeExtractor.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> links)
|
||||
{
|
||||
TopoDS_Shape result;
|
||||
std::vector<TopoDS_Shape> sourceShapes;
|
||||
|
||||
for (auto& l:links) {
|
||||
auto shape = Part::Feature::getShape(l); //finds shape within DocObj??
|
||||
if(!shape.IsNull()) {
|
||||
// BRepTools::Write(shape, "DVPgetShape.brep"); //debug
|
||||
if (shape.ShapeType() > TopAbs_COMPSOLID) {
|
||||
sourceShapes.push_back(shape);
|
||||
} else {
|
||||
std::vector<TopoDS_Shape> drawable = extractDrawableShapes(shape);
|
||||
if (!drawable.empty()) {
|
||||
sourceShapes.insert(sourceShapes.end(),drawable.begin(),drawable.end());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::vector<TopoDS_Shape> shapeList = getShapesFromObject(l);
|
||||
sourceShapes.insert(sourceShapes.end(),shapeList.begin(),shapeList.end());
|
||||
}
|
||||
}
|
||||
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound comp;
|
||||
builder.MakeCompound(comp);
|
||||
bool found = false;
|
||||
for (auto& s:sourceShapes) {
|
||||
if (s.IsNull()) {
|
||||
continue; //has no shape
|
||||
}
|
||||
found = true;
|
||||
BRepBuilderAPI_Copy BuilderCopy(s);
|
||||
TopoDS_Shape shape = BuilderCopy.Shape();
|
||||
builder.Add(comp, shape);
|
||||
}
|
||||
//it appears that an empty compound is !IsNull(), so we need to check a different way
|
||||
//if we added anything to the compound.
|
||||
if (!found) {
|
||||
Base::Console().Error("SE::getSourceShapes - source shape is empty!\n");
|
||||
} else {
|
||||
result = comp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::DocumentObject* docObj)
|
||||
{
|
||||
std::vector<TopoDS_Shape> result;
|
||||
|
||||
const App::GroupExtension* gex = dynamic_cast<const App::GroupExtension*>(docObj);
|
||||
App::Property* gProp = docObj->getPropertyByName("Group");
|
||||
App::Property* sProp = docObj->getPropertyByName("Shape");
|
||||
if (docObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
const Part::Feature* pf = static_cast<const Part::Feature*>(docObj);
|
||||
Part::TopoShape ts = pf->Shape.getShape();
|
||||
ts.setPlacement(pf->globalPlacement());
|
||||
result.push_back(ts.getShape());
|
||||
} else if (gex != nullptr) { //is a group extension
|
||||
std::vector<App::DocumentObject*> objs = gex->Group.getValues();
|
||||
std::vector<TopoDS_Shape> shapes;
|
||||
for (auto& d: objs) {
|
||||
shapes = getShapesFromObject(d);
|
||||
if (!shapes.empty()) {
|
||||
result.insert(result.end(),shapes.begin(),shapes.end());
|
||||
}
|
||||
}
|
||||
//the next 2 bits are mostly for Arch module objects
|
||||
} else if (gProp != nullptr) { //has a Group property
|
||||
App::PropertyLinkList* list = dynamic_cast<App::PropertyLinkList*>(gProp);
|
||||
if (list != nullptr) {
|
||||
std::vector<App::DocumentObject*> objs = list->getValues();
|
||||
std::vector<TopoDS_Shape> shapes;
|
||||
for (auto& d: objs) {
|
||||
shapes = getShapesFromObject(d);
|
||||
if (!shapes.empty()) {
|
||||
result.insert(result.end(),shapes.begin(),shapes.end());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Base::Console().Log("SE::getShapesFromObject - Group is not a PropertyLinkList!\n");
|
||||
}
|
||||
} else if (sProp != nullptr) { //has a Shape property
|
||||
Part::PropertyPartShape* shape = dynamic_cast<Part::PropertyPartShape*>(sProp);
|
||||
if (shape != nullptr) {
|
||||
TopoDS_Shape occShape = shape->getValue();
|
||||
result.push_back(occShape);
|
||||
} else {
|
||||
Base::Console().Log("SE::getShapesFromObject - Shape is not a PropertyPartShape!\n");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObject*> links)
|
||||
{
|
||||
TopoDS_Shape baseShape = getShapes(links);
|
||||
if (!baseShape.IsNull()) {
|
||||
TopoDS_Iterator it(baseShape);
|
||||
TopoDS_Shape fusedShape = it.Value();
|
||||
it.Next();
|
||||
for (; it.More(); it.Next()) {
|
||||
const TopoDS_Shape& aChild = it.Value();
|
||||
BRepAlgoAPI_Fuse mkFuse(fusedShape, aChild);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone()) {
|
||||
Base::Console().Error("SE - Fusion failed\n");
|
||||
return baseShape;
|
||||
}
|
||||
fusedShape = mkFuse.Shape();
|
||||
}
|
||||
baseShape = fusedShape;
|
||||
}
|
||||
return baseShape;
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes(const TopoDS_Shape shapeIn)
|
||||
{
|
||||
//this pulls solids out of compound
|
||||
//should it pull Shells, Faces, Wires, Edges, Vertexes too???
|
||||
std::vector<TopoDS_Shape> result;
|
||||
if ( (shapeIn.ShapeType() == TopAbs_COMPOUND) ||
|
||||
(shapeIn.ShapeType() == TopAbs_COMPSOLID) ) { //not sure about this one
|
||||
TopExp_Explorer expSolid(shapeIn, TopAbs_SOLID);
|
||||
for (int i = 1; expSolid.More(); expSolid.Next(), i++) {
|
||||
TopoDS_Solid s = TopoDS::Solid(expSolid.Current());
|
||||
if (!s.IsNull()) {
|
||||
result.push_back(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
59
src/Mod/TechDraw/App/ShapeExtractor.h
Normal file
59
src/Mod/TechDraw/App/ShapeExtractor.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _ShapeExtractor_h_
|
||||
#define _ShapeExtractor_h_
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/FeaturePython.h>
|
||||
#include <App/GroupExtension.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class TechDrawExport ShapeExtractor
|
||||
{
|
||||
public:
|
||||
static TopoDS_Shape getShapes(const std::vector<App::DocumentObject*> links);
|
||||
static std::vector<TopoDS_Shape> getShapesFromObject(const App::DocumentObject* docObj);
|
||||
static TopoDS_Shape getShapesFused(const std::vector<App::DocumentObject*> links);
|
||||
static std::vector<TopoDS_Shape> extractDrawableShapes(const TopoDS_Shape shapeIn);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
} //namespace TechDraw
|
||||
|
||||
#endif // #ifndef _ShapeExtractor_h_
|
||||
Reference in New Issue
Block a user