#include <iostream>
#include <maya/MStatus.h>
#include <maya/MIOStream.h>
#include <maya/MPxNode.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MArrayDataHandle.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnCompoundAttribute.h>
#include <maya/MFloatVector.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnGeometryData.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnMesh.h>
#include <maya/MFnLatticeData.h>
#include <maya/MFnNurbsSurfaceData.h>
#include <maya/MFnNurbsSurface.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MFnLattice.h>
#include <maya/MGlobal.h>
#include <maya/MPointArray.h>
#include <maya/MMatrix.h>
#include <maya/MFnMatrixData.h>
#include <maya/MFnNumericData.h>
#include <cmath>
#include <algorithm>
{
public:
Compare();
~Compare() override;
SchedulingType
schedulingType()
const override {
return SchedulingType::kParallel; }
static void * creator();
protected:
double fEpsilon {1.0e-4};
};
Compare::Compare()
{
}
Compare::~Compare()
{
}
void* Compare::creator()
{
return new Compare();
}
{
if (!stat) { stat.
perror(
"create attribute inputA");
return stat; }
if (!stat) { stat.
perror(
"create attribute inputB");
return stat; }
if (!stat) { stat.
perror(
"create attribute precision");
return stat; }
return MS::kSuccess;
}
{
if( plug == aOutValue )
{
fEpsilon = pow(10.0,-precision);
bool same {false};
MObject curveA = handleA.asNurbsCurve();
if(handleA.type() == handleB.type())
{
{
same = checkMesh(a, b);
}
{
if (!a.lattice().isNull() && !b.lattice().isNull())
same = checkLattice(a.lattice(), b.lattice());
}
{
same = checkNurbs(a, b);
}
{
same = checkNurbs(a, b);
}
{
if(!a.object().isNull() && !b.object().isNull())
}
}
} else
return MS::kUnknownParameter;
return MS::kSuccess;
}
{
for(
int i = 0; i < aCVs.
length(); ++i){
if(!aCVs[i].isEquivalent(bCVs[i], fEpsilon)) return false;
}
for(
int i = 0; i < aKnots.
length(); ++i){
if(std::fabs(aKnots[i] - bKnots[i]) > fEpsilon) return false;
}
return true;
}
{
for(
int i = 0; i < aCVs.
length(); ++i){
if(!aCVs[i].isEquivalent(bCVs[i], fEpsilon)) return false;
}
for(
int i = 0; i < aKnots.
length(); ++i){
if(std::fabs(aKnots[i] - bKnots[i]) > fEpsilon) return false;
}
return true;
}
{
unsigned int sa,ta,ua;
unsigned int sb,tb,ub;
const_cast<MFnLattice&
>(aLattice).getDivisions(sa,ta,ua);
const_cast<MFnLattice&
>(bLattice).getDivisions(sb,tb,ub);
if(sa != sb || ta != tb || ua != ub)return false;
for(unsigned int i = 0; i < sa; ++i )
for(unsigned int j = 0; j < ta; ++j )
for(unsigned int k = 0; k < ua; ++k ){
const auto& pta =
const_cast<MFnLattice&
>(aLattice).point(i,j,k);
const auto& ptb =
const_cast<MFnLattice&
>(bLattice).point(i,j,k);
auto eps = std::max({pta[0]*fEpsilon, ptb[0]*fEpsilon, fEpsilon});
if(!pta.isEquivalent(ptb, eps))return false;
}
return true;
}
{
if (c != b.
length())
return false;
for(unsigned int i = 0; i < c; ++i){
auto pta = a[i];
auto ptb = b[i];
auto eps = std::max({pta[0]*fEpsilon, ptb[0]*fEpsilon, fEpsilon});
if (std::fabs(pta[0] - ptb[0]) > eps)
{
return false;
}
eps = std::max({pta[1]*fEpsilon, ptb[1]*fEpsilon, fEpsilon});
if (std::fabs(pta[1] - ptb[1]) > eps)
{
return false;
}
eps = std::max({pta[2]*fEpsilon, ptb[2]*fEpsilon, fEpsilon});
if (std::fabs(pta[2] - ptb[2]) > eps) {
return false;
}
}
return true;
}
{
MFnPlugin plugin( obj,
"Autodesk",
"1.0",
"Any");
Compare::creator, Compare::initialize,
return MS::kSuccess;
}
{
return MS::kSuccess;
}