Geometric hatch for Section face

This commit is contained in:
WandererFan
2017-01-22 08:41:04 -05:00
parent dd8eefc057
commit 60c7f2f69a
18 changed files with 427 additions and 236 deletions

View File

@@ -46,6 +46,7 @@
#include <HLRBRep_Algo.hxx>
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_HLRToShape.hxx>
#include <ShapeAnalysis.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
@@ -63,20 +64,24 @@
# include <QFileInfo>
#include <App/Application.h>
#include <App/Document.h>
#include <App/Material.h>
#include <Base/BoundBox.h>
#include <Base/Exception.h>
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Base/Parameter.h>
#include <Mod/Part/App/PartFeature.h>
#include "Geometry.h"
#include "GeometryObject.h"
#include "HatchLine.h"
#include "EdgeWalker.h"
#include "DrawUtil.h"
#include "DrawProjGroupItem.h"
#include "DrawProjectSplit.h"
#include "DrawCrosshatch.h"
#include "DrawViewSection.h"
using namespace TechDraw;
@@ -110,13 +115,18 @@ DrawViewSection::DrawViewSection()
SectionDirection.setEnums(SectionDirEnums);
ADD_PROPERTY_TYPE(SectionDirection,((long)0),sgroup, App::Prop_None, "Direction in Base View for this Section");
ADD_PROPERTY_TYPE(ShowCutSurface ,(true),fgroup,App::Prop_None,"Shade the cut surface");
ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color to shade the cut surface");
ADD_PROPERTY_TYPE(HatchCutSurface ,(false),fgroup,App::Prop_None,"Hatch the cut surface");
ADD_PROPERTY_TYPE(HatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface");
ADD_PROPERTY_TYPE(HatchColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color of the hatch pattern");
ADD_PROPERTY_TYPE(FileHatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface");
ADD_PROPERTY_TYPE(NameGeomPattern ,(""),fgroup,App::Prop_None,"The pattern name for geometric hatching");
ADD_PROPERTY_TYPE(HatchScale,(1.0),fgroup,App::Prop_None,"Hatch pattern size adjustment");
// ADD_PROPERTY_TYPE(ShowCutSurface ,(true),fgroup,App::Prop_None,"Show/hide the cut surface");
// ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color to shade the cut surface");
// ADD_PROPERTY_TYPE(HatchCutSurface ,(false),fgroup,App::Prop_None,"Hatch the cut surface");
// ADD_PROPERTY_TYPE(FileHatchPattern ,(""),fgroup,App::Prop_None,"The hatch pattern file for the cut surface");
// ADD_PROPERTY_TYPE(NameGeomPattern ,(""),fgroup,App::Prop_None,"The pattern name for geometric hatching");
// ADD_PROPERTY_TYPE(HatchColor,(0.0,0.0,0.0),fgroup,App::Prop_None,"The color of the hatch pattern");
getParameters();
}
@@ -159,6 +169,23 @@ void DrawViewSection::onChanged(const App::Property* prop)
}
}
}
if (prop == &FileHatchPattern ||
prop == &NameGeomPattern ) {
if ((!FileHatchPattern.isEmpty()) &&
(!NameGeomPattern.isEmpty())) {
std::vector<HatchLine> specs =
DrawCrosshatch::getDecodedSpecsFromFile(FileHatchPattern.getValue(),NameGeomPattern.getValue());
m_lineSets.clear();
for (auto& hl: specs) {
//hl.dump("hl from section");
LineSet ls;
ls.setHatchLine(hl);
m_lineSets.push_back(ls);
}
}
}
DrawView::onChanged(prop);
}
@@ -249,10 +276,12 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
inputCenter,
Scale.getValue());
sectionFaceWires.clear();
TopoDS_Compound newFaces;
BRep_Builder builder;
builder.MakeCompound(newFaces);
TopExp_Explorer expl(mirroredSection, TopAbs_FACE);
int idb = 0;
for (; expl.More(); expl.Next()) {
const TopoDS_Face& face = TopoDS::Face(expl.Current());
TopoDS_Face pFace = projectFace(face,
@@ -260,8 +289,9 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
Direction.getValue());
if (!pFace.IsNull()) {
builder.Add(newFaces,pFace);
sectionFaceWires.push_back(ShapeAnalysis::OuterWire(pFace));
}
idb++;
}
sectionFaces = newFaces;
}
@@ -506,6 +536,20 @@ Base::Vector3d DrawViewSection::getSectionVector (const std::string sectionName)
return adjResult;
}
std::vector<LineSet> DrawViewSection::getDrawableLines(int i)
{
std::vector<LineSet> result;
result = DrawCrosshatch::getDrawableLines(this,m_lineSets,i,HatchScale.getValue());
return result;
}
std::vector<TopoDS_Wire> DrawViewSection::getWireForFace(int idx) const
{
std::vector<TopoDS_Wire> result;
result.push_back(sectionFaceWires.at(idx));
return result;
}
void DrawViewSection::unsetupObject()
{
getBaseDVP()->touch();
@@ -534,13 +578,6 @@ TechDraw::DrawProjGroupItem* DrawViewSection::getBaseDPGI()
void DrawViewSection::getParameters()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color cutColor = App::Color((uint32_t) hGrp->GetUnsigned("CutSurfaceColor", 0xC8C8C800));
CutSurfaceColor.setValue(cutColor);
App::Color hatchColor = App::Color((uint32_t) hGrp->GetUnsigned("SectionHatchColor", 0x00000000));
HatchColor.setValue(hatchColor);
hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
std::string defaultDir = App::Application::getResourceDir() + "Mod/Drawing/patterns/";
@@ -551,9 +588,10 @@ void DrawViewSection::getParameters()
}
QFileInfo tfi(patternFileName);
if (tfi.isReadable()) {
HatchPattern.setValue(patternFileName.toUtf8().constData());
FileHatchPattern.setValue(patternFileName.toUtf8().constData());
}
std::string patternName = hGrp->GetASCII("PatternName","Diamond");
NameGeomPattern.setValue(patternName);
}
// Python Drawing feature ---------------------------------------------------------