From b817ade2a888d94643a0e6c57af21ec667185024 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 4 Jun 2021 00:55:50 +0200 Subject: [PATCH 1/5] [TD] comment the new centerline behavior add missing info to understand the new centerline behavior as introduced with commit b981f905 --- src/Mod/TechDraw/App/Cosmetic.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index c803dab88d..10fc61f8ff 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -980,12 +980,16 @@ std::pair CenterLine::calcEndPoints(DrawViewPart bool CenterLine::Circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C) { + // the determinant of this matrix calculates the aread of a triangle, see + // https://en.wikipedia.org/wiki/Triangle#Using_coordinates + // a 3x3 matrix would also do the job, but FC supports only 4x4 matrixes Base::Matrix4D CircMatrix( A.x, A.y, 1, 0, B.x, B.y, 1, 0, C.x, C.y, 1, 0, 0, 0, 0, 1); + // the sign delivers the dicrection of travel along the triangle edges if (CircMatrix.determinant() > 0) return true; else @@ -1034,8 +1038,10 @@ std::pair CenterLine::calcEndPoints2Lines(DrawVi Base::Vector3d l2p2 = edges.back()->getEndPoint(); // The centerline is drawn using the midpoints of the two lines that connect l1p1-l2p1 and l1p2-l2p2. - // However, we don't know which point should be l1p1 to get a geometrically correct result. - // Thus we test this by a circulation test. + // However, we don't know which point should be l1p1 to get a geometrically correct result, see + // https://wiki.freecadweb.org/File:TD-CenterLineFlip.png for an illustration of the problem. + // Thus we test this by a circulation test, see this post for a brief explanation: + // https://forum.freecadweb.org/viewtopic.php?p=505733#p505615 if (Circulation(l1p1, l1p2, l2p1) != Circulation(l1p2, l2p2, l2p1)) { Base::Vector3d temp; // reverse line 1 temp = l1p1; From f5aea33548dd2de110c3d5286efe15a23a2a9819 Mon Sep 17 00:00:00 2001 From: Uwe Date: Fri, 4 Jun 2021 17:49:57 +0200 Subject: [PATCH 2/5] Update src/Mod/TechDraw/App/Cosmetic.cpp Co-authored-by: 0penBrain <48731257+0penBrain@users.noreply.github.com> --- src/Mod/TechDraw/App/Cosmetic.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index 10fc61f8ff..dbb048f2ef 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -980,7 +980,7 @@ std::pair CenterLine::calcEndPoints(DrawViewPart bool CenterLine::Circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C) { - // the determinant of this matrix calculates the aread of a triangle, see + // the determinant of this matrix calculates the area of a triangle, see // https://en.wikipedia.org/wiki/Triangle#Using_coordinates // a 3x3 matrix would also do the job, but FC supports only 4x4 matrixes Base::Matrix4D CircMatrix( @@ -1687,4 +1687,3 @@ bool CosmeticVertex::restoreCosmetic(void) return result; } - From 053dd7f3b8f532fd27c09db29f30711d41072823 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 3 Aug 2021 16:44:15 +0200 Subject: [PATCH 3/5] Arch: Don't add spaces to BuildingPArt's shape --- src/Mod/Arch/ArchBuildingPart.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Mod/Arch/ArchBuildingPart.py b/src/Mod/Arch/ArchBuildingPart.py index 277d7f289d..86e3957def 100644 --- a/src/Mod/Arch/ArchBuildingPart.py +++ b/src/Mod/Arch/ArchBuildingPart.py @@ -431,9 +431,7 @@ class BuildingPart(ArchIFC.IfcProduct): area = 0 if hasattr(obj,"Group"): for child in obj.Group: - if hasattr(child,"Area") and hasattr(child,"IfcType"): - # only add arch objects that have an Area property - # TODO only spaces? ATM only spaces and windows have an Area property + if (Draft.get_type(child) in ["Space","BuildingPart"]) and hasattr(child,"IfcType"): area += child.Area.Value return area @@ -443,8 +441,9 @@ class BuildingPart(ArchIFC.IfcProduct): shapes = [] for child in Draft.get_group_contents(obj): - if hasattr(child,'Shape'): - shapes.extend(child.Shape.Faces) + if not Draft.get_type(child) in ["Space"]: + if hasattr(child,'Shape'): + shapes.extend(child.Shape.Faces) return shapes def getSpaces(self,obj): From 2c940e3a9891eed44a439308b688c149b09629f0 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 3 Aug 2021 16:45:07 +0200 Subject: [PATCH 4/5] Arch: Remember wall alignment when creating from existing wires --- src/Mod/Arch/ArchWall.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Mod/Arch/ArchWall.py b/src/Mod/Arch/ArchWall.py index 52684faeda..4e4a37ef04 100644 --- a/src/Mod/Arch/ArchWall.py +++ b/src/Mod/Arch/ArchWall.py @@ -57,7 +57,7 @@ __title__ = "FreeCAD Wall" __author__ = "Yorik van Havre" __url__ = "https://www.freecadweb.org" -def makeWall(baseobj=None,height=None,length=None,width=None,align="Center",face=None,name=None): +def makeWall(baseobj=None,height=None,length=None,width=None,align=None,face=None,name=None): """Create a wall based on a given object, and returns the generated wall. TODO: It is unclear what defines which units this function uses. @@ -128,7 +128,10 @@ def makeWall(baseobj=None,height=None,length=None,width=None,align="Center",face obj.Height = height else: obj.Height = p.GetFloat("WallHeight",3000) - obj.Align = align + if align: + obj.Align = align + else: + obj.Align = ["Center","Left","Right"][p.GetInt("WallAlignment",0)] if obj.Base and FreeCAD.GuiUp: if Draft.getType(obj.Base) != "Space": obj.Base.ViewObject.hide() From a74792e3f66a1c7faf2c12643ea883dfa714aaea Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 3 Aug 2021 16:45:43 +0200 Subject: [PATCH 5/5] Draft: Allow to stretch more complex Arch objects --- src/Mod/Draft/draftguitools/gui_stretch.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mod/Draft/draftguitools/gui_stretch.py b/src/Mod/Draft/draftguitools/gui_stretch.py index 8b4befe842..79cf56e59a 100644 --- a/src/Mod/Draft/draftguitools/gui_stretch.py +++ b/src/Mod/Draft/draftguitools/gui_stretch.py @@ -101,6 +101,10 @@ class Stretch(gui_base_original.Modifier): if base: if utils.getType(base) in supported: self.sel.append([base, obj.Placement.multiply(obj.Base.Placement)]) + elif hasattr(obj.Base, "Base"): + if obj.Base.Base: + if utils.getType(obj.Base.Base) in supported: + self.sel.append([obj.Base.Base, obj.Placement.multiply(obj.Base.Placement)]) elif utils.getType(obj) in ["Offset2D", "Array"]: base = None if hasattr(obj, "Source") and obj.Source: