Huang
(Huang)
September 24, 2024, 2:23am
1
bool MyMorphObj(ON_Curve* crv, CRhinoObject* obj)
{
MySpaceMorph morph(0.0, true, false, crv);
return true;
}
class MySpaceMorph : public ON_SpaceMorph
{
public:
MySpaceMorph(double tolerance, bool quickpreview, bool preserveStructure, ON_Curve* crv)
{
SetTolerance(tolerance);
SetQuickPreview(quickpreview);
SetPreserveStructure(preserveStructure);
mcrv = crv;
}
virtual ON_3dPoint MorphPoint(ON_3dPoint point) const
{
double *t;
mcrv->GetClosestPoint(point, t, -1);
return mcrv->PointAt(*t);
}
private:
ON_Curve* mcrv;
};
Is this written incorrectly? Why do undeclared identifiers appear? Please provide an example. Thank you
dale
(Dale Fugier)
September 24, 2024, 11:45pm
2
Hi @Huang ,
Maybe this?
class MySpaceMorph : public ON_SpaceMorph
{
public:
MySpaceMorph(double tolerance, bool quickpreview, bool preserveStructure, ON_Curve* crv)
{
SetTolerance(tolerance);
SetQuickPreview(quickpreview);
SetPreserveStructure(preserveStructure);
mcrv = crv;
}
ON_3dPoint MorphPoint(ON_3dPoint point) const override
{
if (mcrv)
{
double t = ON_UNSET_VALUE;
if (mcrv->GetClosestPoint(point, &t))
return mcrv->PointAt(t);
}
return ON_3dPoint::UnsetPoint;
}
private:
ON_Curve* mcrv = nullptr;
};
bool MyMorphObj(ON_Curve* crv, CRhinoObject* obj)
{
MySpaceMorph morph(0.0, true, false, crv);
return true;
}
– Dale
Huang
(Huang)
September 25, 2024, 12:25am
4
Thank you very much. Allow me to ask one final question. When I call the Morph function in C # and try to read or write to protected memory, it usually indicates that other memory is damaged. Do I need to manually release the memory? I have no problem using MooseAddPoint
dale
(Dale Fugier)
September 25, 2024, 2:20am
5
Hi @Huang ,
SpaceMorph is an abstract class in RhinoCommon. Why don’t you implement your custom morphing tool there and and forget the interop stuff?
— Dale
Huang
(Huang)
September 25, 2024, 2:47am
7
I actually hope to put some things in C++, but I can’t convert the spacemorph type (including its subclasses) to intptr for C++in Rhinocommon, can I?
dale
(Dale Fugier)
September 26, 2024, 9:50pm
8
Hi @Huang ,
I don’t see a way of doing this. Again, just implement your spacemorph in RhinoCommon.
– Dale
Huang
(Huang)
September 26, 2024, 11:18pm
9
Okay, I will take your advice. Thank you for your reply. Thank you