| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| |
|
| |
|
| | #include <HLRBRep_Algo.hxx> |
| | #include <HLRAlgo_Projector.hxx> |
| | #include <HLRBRep_HLRToShape.hxx> |
| | #include <BRep_Builder.hxx> |
| | #include <BRepBuilderAPI_Transform.hxx> |
| |
|
| |
|
| | #include <App/DocumentObject.h> |
| | #include <Base/Placement.h> |
| | #include <Base/Vector3D.h> |
| |
|
| | #include <Mod/Part/App/PartFeature.h> |
| |
|
| | #include "SketchExportHelper.h" |
| |
|
| | using namespace Import; |
| |
|
| | |
| | |
| | |
| | |
| | TopoDS_Shape SketchExportHelper::projectShape(const TopoDS_Shape& inShape, const gp_Ax2& projectionCS) |
| | { |
| | Handle(HLRBRep_Algo) brep_hlr = new HLRBRep_Algo(); |
| | brep_hlr->Add(inShape); |
| | HLRAlgo_Projector projector(projectionCS); |
| | brep_hlr->Projector(projector); |
| | brep_hlr->Update(); |
| | brep_hlr->Hide(); |
| | HLRBRep_HLRToShape hlrToShape(brep_hlr); |
| | BRep_Builder builder; |
| | TopoDS_Compound comp; |
| | builder.MakeCompound(comp); |
| | if (!hlrToShape.VCompound().IsNull()) { |
| | builder.Add(comp, hlrToShape.VCompound()); |
| | } |
| | if (!hlrToShape.OutLineVCompound().IsNull()) { |
| | builder.Add(comp, hlrToShape.OutLineVCompound()); |
| | } |
| | return comp; |
| | } |
| |
|
| |
|
| | |
| | bool SketchExportHelper::isSketch(App::DocumentObject* obj) |
| | { |
| | |
| | return obj->isDerivedFrom(Base::Type::fromName("Sketcher::SketchObject")); |
| | } |
| |
|
| |
|
| | |
| | |
| | TopoDS_Shape SketchExportHelper::getFlatSketchXY(App::DocumentObject* obj) |
| | { |
| | |
| | |
| | auto sketch = dynamic_cast<Part::Feature*>(obj); |
| | if (!sketch || !isSketch(obj)) { |
| | return {}; |
| | } |
| |
|
| | auto plm = sketch->Placement.getValue(); |
| | Base::Rotation rot = plm.getRotation(); |
| |
|
| | |
| | Base::Vector3d stdZ {0.0, 0.0, 1.0}; |
| | Base::Vector3d sketchNormal; |
| | rot.multVec(stdZ, sketchNormal); |
| | Base::Vector3d stdX {1.0, 0.0, 0.0}; |
| | Base::Vector3d sketchX; |
| | rot.multVec(stdX, sketchX); |
| |
|
| | |
| | Base::Vector3d position = plm.getPosition(); |
| | gp_Ax2 projectionCS( |
| | gp_Pnt(position.x, position.y, position.z), |
| | gp_Dir(sketchNormal.x, sketchNormal.y, sketchNormal.z), |
| | gp_Dir(sketchX.x, sketchX.y, sketchX.z) |
| | ); |
| | const TopoDS_Shape& shape = sketch->Shape.getValue(); |
| | return projectShape(shape, projectionCS); |
| | } |
| |
|