Dear AnyBody community
I have a question regarding morphing the pelvis. I followed the tutorial 'Personalizing Your Model' and managed to morph both the (left and right) thigh and the shank. However, for the pelvis when I want to check the morphing, the scaled mesh and the target mesh do not overlay properly (similar to the problem noticed by max in Custom scaling of the pelvis? - #6 by toerholm).
Nevertheless, I already included
&Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.Scale_Trunk_Pelvis.ScaleAfterInterfaceMorphingDef.Scale.T1_Inv
in the transformation.
I also read the following (Morphing of the pelvis - #3 by CDzialo) forum post but did not manage to solve my problem.
I included the morphing by adding 4 anyscripts:
PersonScaling.any:
HumanModel.Scaling.GeometricalScaling = {
#include "PelvisScaling.any"
#include "CheckPelvisMorphing.any"
#include "FemurScaling.any"
#include "CheckFemurMorphing.any"
#include "TibiaScaling.any"
#include "CheckTibiaMorphing.any"
};
With PelvisScaling.any:
// Generic AnyBody bone created from a template mesh
#ifndef SOURCE_PELVIS
#path SOURCE_PELVIS "pelvisammr2.stl"
#endif
// Target bone created from the same template mesh
#ifndef TARGET_PELVIS
#path TARGET_PELVIS "D:\AnyBody\gm-foot\PersonScaling\N19\Pelvis_SSM.stl"
#endif
#define CUSTOM_SCALING_PelvisSeg
PelvisSeg = {
#include "ScaleFunctionPelvis2.any"
AnyFunTransform3D &ScaleFunction = MyScalingFunctionPelvis;
};
ScaleFunctionPelvis2.any
// Finding source and target landmarks automatically from provided STL of the same topoolgy
AnyFile src = SOURCE_PELVIS;
AnyFile trg = TARGET_PELVIS;
AnyInt size = STL_Size(src, 1); // get size of the stl
AnyInt VertNum = 1000; // specify number of landmarks to be extracted automatically
//AnyInt VertNum = 10000;
AnyInt vertices = iarr(1,VertNum)*floor(size[0]/VertNum);// evenly space landmarks in the index field
AnyMatrix P0 = STL_Vertices(src, vertices , 1); // extract vertices with given indices
AnyMatrix P1 = 0.001*STL_Vertices(trg, vertices , 1); // conversion from mm to m
// AnyFunTransform3D &TSeg2ScaleFrame = Main.HumanModel.Scaling.GeometricalScaling.PelvisSeg.TSeg2ScaleFrame;
//Linear Affine transformation
AnyFunTransform3DLin2 reg =
{
// Points0 = .Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.Scale_Trunk_Pelvis.ScaleAfterInterfaceMorphingDef.Scale.T0(.P0);
// Points0 = .TSeg2ScaleFrame(.P0);
Points0 = .TSeg2ScaleFrame(.P0);
Points1 = .P1;
Mode = VTK_LANDMARK_AFFINE;
};
// Non-linear transformation --> Radial Basis Functions (RBF)
// Need to optimize these settings
AnyFunTransform3DRBF rbf =
{
PreTransforms = {&.reg};
RBFDef.Type = RBF_Triharmonic;
PolynomDegree = 1;
Points0 = .reg.Points0;
Points1 = .reg.Points1;
BoundingBoxOnOff = On;
BoundingBox.Type = BB_Cartesian;
BoundingBox.ScaleXYZ={1,2,2}*1.2;
BoundingBox.DivisionFactorXYZ ={1,1,1}*3;
};
//STL To STL
//Morphing using the surface information --> will deform all related soft tissue attachment points
AnyFunTransform3DSTL STLTransform =
{
PreTransforms = {&.rbf};
PolynomDegree = 1;
RBFDef.Type = RBF_Triharmonic;
AnyFixedRefFrame Input = {
AnySurfSTL SourceSurf = {
FileName = ...src;
ScaleXYZ = {1, 1, 1};
AnyFunTransform3D&pre = ...TSeg2ScaleFrame;
};
AnySurfSTL TargetSurf = {
FileName = ...trg;
ScaleXYZ = 0.001*{1, 1, 1};
};
};
SurfaceObjects0 = {&Input.SourceSurf};
SurfaceObjects1 = {&Input.TargetSurf};
NumPoints = 1500;
BoundingBox.ScaleXYZ = {2,2,2};
BoundingBox.DivisionFactorXYZ = {1,1,1};
BoundingBoxOnOff = On;
};
AnyFunTransform3DLin2 ReverseTransform =
{
Points0 = .reg.Points1;
Points1 = .reg.Points0;
Mode = VTK_LANDMARK_RIGIDBODY;
};
AnyFunTransform3DIdentity MyScalingFunctionPelvis = {
PreTransforms = {&.STLTransform, &.ReverseTransform};
};
and finally to check the morphing CheckPelvisMorphing.any
Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg = {
AnyRefNode targetstl = {
AnyFunTransform3DIdentity RegistrationTranform = {
PreTransforms = {&Main.HumanModel.Scaling.GeometricalScaling.PelvisSeg.ReverseTransform,
&Main.HumanModel.BodyModel.Trunk.SegmentsLumbar.PelvisSeg.Scale_Trunk_Pelvis.ScaleAfterInterfaceMorphingDef.Scale.T1_Inv};
};
AnyDrawSurf target_pelvis = {
FileName=TARGET_PELVIS;
ScaleXYZ={0.001,0.001,0.001};
RGB={0,1,0};
AnyFunTransform3D ® = .RegistrationTranform;
};
};
};
I added the used pelvis stl (pelvisammr2.stl).
I also tried to use the stl provided by Christine in following forum post (Morphing of the pelvis - #3 by CDzialo). However, then I ended up with a completely wrong morphed pelvis (see below):
Is there anyone who experienced a similar problem before? Any ideas how I could solve this problem?
Kind regards
Kate
pelvisammr2.zip (2.7 MB)