- aStartAx3.Transform(aShapeStartLCS.Location().Transformation());
- aDestAx3.Transform(aShapeEndLCS.Location().Transformation());
-
- Handle(Geom_Surface) aGS2 = BRep_Tool::Surface( TopoDS::Face( aShapeEndLCS ) );
- if (!aGS2.IsNull() && aGS2->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) {
- Handle(Geom_Plane) aGPlane2 = Handle(Geom_Plane)::DownCast( aGS2 );
- gp_Pln aPln2 = aGPlane2->Pln();
- aDestAx3 = aPln2.Position();
- }
-
- if(aShapeStartLCS.ShapeType() == TopAbs_FACE) {
- Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShapeStartLCS ) );
- if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) {
- Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS );
- gp_Pln aPln = aGPlane->Pln();
- aStartAx3 = aPln.Position();
- }
- aTrsf.SetDisplacement(aStartAx3, aDestAx3);
- }
- else {
- gp_Trsf aTrsf1, aTrsf2;
- aTrsf1.SetDisplacement(aStartAx3, aDestAx3);
- BRepBuilderAPI_Transform aBT (aShapeBase, aTrsf1, Standard_False);
- TopoDS_Shape aNewShape = aBT.Shape();
-
- gp_Pnt aPnt;
- if (aNewShape.ShapeType() == TopAbs_VERTEX) {
- aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aNewShape));
- }
- else {
- GProp_GProps aSystem;
- if (aNewShape.ShapeType() == TopAbs_EDGE || aNewShape.ShapeType() == TopAbs_WIRE)
- BRepGProp::LinearProperties(aNewShape, aSystem);
- else if (aNewShape.ShapeType() == TopAbs_FACE || aNewShape.ShapeType() == TopAbs_SHELL)
- BRepGProp::SurfaceProperties(aNewShape, aSystem);
- else
- BRepGProp::VolumeProperties(aNewShape, aSystem);
-
- aPnt = aSystem.CentreOfMass();
- }
-
- gp_Vec aVec(aPnt, aDestAx3.Location());
- aTrsf2.SetTranslation(aVec);
- aTrsf = aTrsf2 * aTrsf1;
- }