Merge branch 'master' of github.com:FreeCAD/FreeCAD into TD-DetailWork
This commit is contained in:
@@ -703,6 +703,8 @@ def get_displacement_scale_factor(res_obj):
|
||||
z_span = abs(p_z_max - p_z_min)
|
||||
span = max(x_span, y_span, z_span)
|
||||
max_disp = max(x_max, y_max, z_max)
|
||||
if max_disp == 0.0:
|
||||
return 0.0 # avoid float division by zero
|
||||
# FIXME - add max_allowed_disp to Preferences
|
||||
max_allowed_disp = 0.01 * span
|
||||
scale = max_allowed_disp / max_disp
|
||||
|
||||
@@ -1426,6 +1426,7 @@ def build_mesh_faces_of_volume_elements(
|
||||
FreeCAD.Console.PrintLog("VolElement: {}\n".format(veID))
|
||||
vol_node_ct = len(femelement_table[veID])
|
||||
face_node_indexs = sorted(face_nodenumber_table[veID])
|
||||
node_numbers = ()
|
||||
if vol_node_ct == 10:
|
||||
FreeCAD.Console.PrintLog(" --> tetra10 --> tria6 face\n")
|
||||
# node order of face in tetra10 volume element
|
||||
@@ -1441,7 +1442,7 @@ def build_mesh_faces_of_volume_elements(
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Error in build_mesh_faces_of_volume_elements(): "
|
||||
"hexa20: face not found! {}\n"
|
||||
"tetra10: face not found! {}\n"
|
||||
.format(face_node_indexs)
|
||||
)
|
||||
elif vol_node_ct == 4:
|
||||
@@ -1459,7 +1460,7 @@ def build_mesh_faces_of_volume_elements(
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Error in build_mesh_faces_of_volume_elements(): "
|
||||
"hexa20: face not found! {}\n"
|
||||
"tetra4: face not found! {}\n"
|
||||
.format(face_node_indexs)
|
||||
)
|
||||
elif vol_node_ct == 20:
|
||||
@@ -1503,7 +1504,7 @@ def build_mesh_faces_of_volume_elements(
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Error in build_mesh_faces_of_volume_elements(): "
|
||||
"hexa20: face not found! {}\n"
|
||||
"hexa8: face not found! {}\n"
|
||||
.format(face_node_indexs)
|
||||
)
|
||||
elif vol_node_ct == 15:
|
||||
@@ -1543,7 +1544,7 @@ def build_mesh_faces_of_volume_elements(
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
"Error in build_mesh_faces_of_volume_elements(): "
|
||||
"pent6: face not found! {}\n"
|
||||
"penta6: face not found! {}\n"
|
||||
.format(face_node_indexs)
|
||||
)
|
||||
else:
|
||||
|
||||
@@ -285,9 +285,9 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
double scale = getScale();
|
||||
|
||||
BRepBuilderAPI_Copy BuilderCopy(shape);
|
||||
TopoDS_Shape copyShape = BuilderCopy.Shape();
|
||||
TopoDS_Shape myShape = BuilderCopy.Shape();
|
||||
|
||||
gp_Pnt gpCenter = TechDraw::findCentroid(copyShape,
|
||||
gp_Pnt gpCenter = TechDraw::findCentroid(myShape,
|
||||
dirDetail);
|
||||
Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z());
|
||||
m_saveCentroid = shapeCenter; //centroid of original shape
|
||||
@@ -295,7 +295,7 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
if (dvs != nullptr) {
|
||||
//section cutShape should already be on origin
|
||||
} else {
|
||||
copyShape = TechDraw::moveShape(copyShape, //centre shape on origin
|
||||
myShape = TechDraw::moveShape(myShape, //centre shape on origin
|
||||
-shapeCenter);
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
|
||||
Bnd_Box bbxSource;
|
||||
bbxSource.SetGap(0.0);
|
||||
BRepBndLib::Add(copyShape, bbxSource);
|
||||
BRepBndLib::Add(myShape, bbxSource);
|
||||
double diag = sqrt(bbxSource.SquareExtent());
|
||||
|
||||
Base::Vector3d toolPlaneOrigin = anchorOffset3d + dirDetail * diag * -1.0; //center tool about anchor
|
||||
@@ -331,33 +331,47 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
gp_Vec extrudeDir(extrudeVec.x,extrudeVec.y,extrudeVec.z);
|
||||
TopoDS_Shape tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape();
|
||||
|
||||
BRepAlgoAPI_Common mkCommon(copyShape,tool);
|
||||
if (!mkCommon.IsDone()) {
|
||||
Base::Console().Warning("DVD::execute - %s - detail cut operation failed (1)\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
if (mkCommon.Shape().IsNull()) {
|
||||
Base::Console().Warning("DVD::execute - %s - detail cut operation failed (2)\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
|
||||
//Did we get a solid?
|
||||
TopExp_Explorer xp;
|
||||
xp.Init(mkCommon.Shape(),TopAbs_SOLID);
|
||||
if (!(xp.More() == Standard_True)) {
|
||||
Base::Console().Warning("DVD::execute - mkCommon.Shape is not a solid!\n");
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound pieces;
|
||||
builder.MakeCompound(pieces);
|
||||
TopExp_Explorer expl(myShape, TopAbs_SOLID);
|
||||
int indb = 0;
|
||||
int outdb = 0;
|
||||
for (; expl.More(); expl.Next()) {
|
||||
indb++;
|
||||
const TopoDS_Solid& s = TopoDS::Solid(expl.Current());
|
||||
|
||||
BRepAlgoAPI_Common mkCommon(s,tool);
|
||||
if (!mkCommon.IsDone()) {
|
||||
// Base::Console().Warning("DVD::execute - %s - detail cut operation failed (1)\n", getNameInDocument());
|
||||
continue;
|
||||
}
|
||||
if (mkCommon.Shape().IsNull()) {
|
||||
// Base::Console().Warning("DVD::execute - %s - detail cut operation failed (2)\n", getNameInDocument());
|
||||
continue;
|
||||
}
|
||||
//this might be overkill for piecewise algo
|
||||
//Did we get at least 1 solid?
|
||||
TopExp_Explorer xp;
|
||||
xp.Init(mkCommon.Shape(),TopAbs_SOLID);
|
||||
if (!(xp.More() == Standard_True)) {
|
||||
// Base::Console().Warning("DVD::execute - mkCommon.Shape is not a solid!\n");
|
||||
continue;
|
||||
}
|
||||
builder.Add(pieces, mkCommon.Shape());
|
||||
outdb++;
|
||||
}
|
||||
TopoDS_Shape detail = mkCommon.Shape();
|
||||
|
||||
if (debugDetail()) {
|
||||
BRepTools::Write(tool, "DVDTool.brep"); //debug
|
||||
BRepTools::Write(copyShape, "DVDCopy.brep"); //debug
|
||||
BRepTools::Write(detail, "DVDCommon.brep"); //debug
|
||||
BRepTools::Write(myShape, "DVDCopy.brep"); //debug
|
||||
BRepTools::Write(pieces, "DVDCommon.brep"); //debug
|
||||
}
|
||||
|
||||
Bnd_Box testBox;
|
||||
testBox.SetGap(0.0);
|
||||
BRepBndLib::Add(detail, testBox);
|
||||
BRepBndLib::Add(pieces, testBox);
|
||||
if (testBox.IsVoid()) {
|
||||
TechDraw::GeometryObject* go = getGeometryObject();
|
||||
if (go != nullptr) {
|
||||
@@ -373,7 +387,7 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
// TopoDS_Compound Comp;
|
||||
// builder.MakeCompound(Comp);
|
||||
// builder.Add(Comp, tool);
|
||||
// builder.Add(Comp, copyShape);
|
||||
// builder.Add(Comp, myShape);
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
try {
|
||||
@@ -388,7 +402,8 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); //sb same CS as base view.
|
||||
|
||||
//center shape on origin
|
||||
TopoDS_Shape centeredShape = TechDraw::moveShape(detail,
|
||||
// TopoDS_Shape centeredShape = TechDraw::moveShape(detail,
|
||||
TopoDS_Shape centeredShape = TechDraw::moveShape(pieces,
|
||||
centroid * -1.0);
|
||||
|
||||
TopoDS_Shape scaledShape = TechDraw::scaleShape(centeredShape,
|
||||
|
||||
@@ -347,7 +347,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dvp->requestPaint(); //to refresh section line
|
||||
return DrawView::execute();
|
||||
}
|
||||
@@ -382,13 +381,26 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape)
|
||||
BRepBuilderAPI_Copy BuilderCopy(baseShape);
|
||||
TopoDS_Shape myShape = BuilderCopy.Shape();
|
||||
|
||||
BRepAlgoAPI_Cut mkCut(myShape, prism);
|
||||
if (!mkCut.IsDone()) {
|
||||
Base::Console().Warning("DVS: Section cut has failed in %s\n",getNameInDocument());
|
||||
return;
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound pieces;
|
||||
builder.MakeCompound(pieces);
|
||||
TopExp_Explorer expl(myShape, TopAbs_SOLID);
|
||||
int indb = 0;
|
||||
int outdb = 0;
|
||||
for (; expl.More(); expl.Next()) {
|
||||
indb++;
|
||||
const TopoDS_Solid& s = TopoDS::Solid(expl.Current());
|
||||
BRepAlgoAPI_Cut mkCut(s, prism);
|
||||
if (!mkCut.IsDone()) {
|
||||
Base::Console().Warning("DVS: Section cut has failed in %s\n",getNameInDocument());
|
||||
continue;
|
||||
}
|
||||
TopoDS_Shape cut = mkCut.Shape();
|
||||
builder.Add(pieces, cut);
|
||||
outdb++;
|
||||
}
|
||||
|
||||
TopoDS_Shape rawShape = mkCut.Shape();
|
||||
TopoDS_Shape rawShape = pieces;
|
||||
if (debugSection()) {
|
||||
BRepTools::Write(myShape, "DVSCopy.brep"); //debug
|
||||
BRepTools::Write(aProjFace, "DVSFace.brep"); //debug
|
||||
|
||||
Reference in New Issue
Block a user