Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part: Add ParallelPlane attachment mode #1014

Open
wants to merge 1 commit into
base: LinkStable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/Mod/Part/App/Attacher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# include <BRepGProp.hxx>
# include <BRepIntCurveSurface_Inter.hxx>
# include <BRepLProp_SLProps.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <GeomAdaptor.hxx>
# include <GeomAPI.hxx>
Expand Down Expand Up @@ -134,6 +135,8 @@ const char* AttachEngine::eMapModeStrings[]= {
"OYZ",
"OYX",

"ParallelPlane",

nullptr};

//this list must be in sync with eRefType enum.
Expand Down Expand Up @@ -1002,6 +1005,11 @@ AttachEngine3D::AttachEngine3D()
modeRefTypes[mmObjectXZ] = ss;
modeRefTypes[mmObjectYZ] = ss;

modeRefTypes[mmParallelPlane].push_back(
cat(eRefType(rtFlatFace | rtFlagHasPlacement), rtVertex));
modeRefTypes[mmParallelPlane].push_back(
cat(eRefType(rtAnything | rtFlagHasPlacement), rtVertex));

modeRefTypes[mmInertialCS].push_back(cat(rtAnything));
modeRefTypes[mmInertialCS].push_back(cat(rtAnything,rtAnything));
modeRefTypes[mmInertialCS].push_back(cat(rtAnything,rtAnything,rtAnything));
Expand Down Expand Up @@ -1146,7 +1154,8 @@ Base::Placement AttachEngine3D::_calculateAttachedPlacement(
} break;
case mmObjectXY:
case mmObjectXZ:
case mmObjectYZ:{
case mmObjectYZ:
case mmParallelPlane: {
//DeepSOIC: could have been done much more efficiently, but I'm lazy...
gp_Dir dirX, dirY, dirZ;
if (types[0] & rtFlagHasPlacement) {
Expand Down Expand Up @@ -1199,6 +1208,26 @@ Base::Placement AttachEngine3D::_calculateAttachedPlacement(
SketchNormal = dirX;
SketchXAxis = gp_Vec(dirY);
break;
case mmParallelPlane: {
if (shapes.size() < 2) {
throw Base::ValueError("AttachEngine3D::calculateAttachedPlacement: not "
"enough subshapes (need one plane and one vertex).");
}

TopoDS_Vertex vertex;
try { vertex = TopoDS::Vertex(*(shapes[1])); } catch(...) {}
if (vertex.IsNull())
throw Base::ValueError("Null vertex in AttachEngine3D::calculateAttachedPlacement()!");

SketchNormal = dirZ;
SketchXAxis = gp_Vec(dirX);

// The new origin will be the vertex projected onto the normal.
Handle(Geom_Line) hCurve(new Geom_Line(SketchBasePoint, dirZ));
gp_Pnt p = BRep_Tool::Pnt(vertex);
GeomAPI_ProjectPointOnCurve projector(p, hCurve);
SketchBasePoint = projector.NearestPoint();
} break;
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/App/Attacher.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ enum eMapMode {
mmOYZ,
mmOYX,

mmParallelPlane,

mmDummy_NumberOfModes//a value useful to check the validity of mode value
};//see also eMapModeStrings[] definition in .cpp

Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Part/Gui/AttacherTexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ TextSet getUIStrings(Base::Type attacherType, eMapMode mmode)
case mmObjectYZ:
return TwoStrings(qApp->translate("Attacher3D", "Object's Y Z X","Attachment3D mode caption"),
qApp->translate("Attacher3D", "X', Y', Z' axes are matched with object's local Y, Z, X, respectively.","Attachment3D mode tooltip"));
case mmParallelPlane:
return TwoStrings(qApp->translate("Attacher3D", "XY parallel to plane","Attachment3D mode caption"),
qApp->translate("Attacher3D", "X' Y' plane is parallel to the plane (object's XY) and passes through the vertex.","Attachment3D mode tooltip"));
case mmFlatFace:
return TwoStrings(qApp->translate("Attacher3D", "XY on plane","Attachment3D mode caption"),
qApp->translate("Attacher3D", "X' Y' plane is aligned to coincide planar face.","Attachment3D mode tooltip"));
Expand Down Expand Up @@ -138,6 +141,9 @@ TextSet getUIStrings(Base::Type attacherType, eMapMode mmode)
case mmObjectYZ:
return TwoStrings(qApp->translate("Attacher2D", "Object's YZ","AttachmentPlane mode caption"),
qApp->translate("Attacher2D", "Plane is aligned to YZ local plane of linked object.","AttachmentPlane mode tooltip"));
case mmParallelPlane:
return TwoStrings(qApp->translate("Attacher2D", "XY parallel to plane","AttachmentPlane mode caption"),
qApp->translate("Attacher2D", "X' Y' plane is parallel to the plane (object's XY) and passes through the vertex","AttachmentPlane mode tooltip"));
case mmFlatFace:
return TwoStrings(qApp->translate("Attacher2D", "Plane face","AttachmentPlane mode caption"),
qApp->translate("Attacher2D", "Plane is aligned to coincide planar face.","AttachmentPlane mode tooltip"));
Expand Down
Loading