-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
450 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#include "SeamsEasyData.h" | ||
|
||
#include <maya\MArgList.h> | ||
|
||
const MTypeId SeamsEasyData::id(0x0012789D); | ||
const MString SeamsEasyData::typeName("seamsEasyData"); | ||
|
||
SeamsEasyData::SeamsEasyData(){ | ||
} | ||
|
||
SeamsEasyData::~SeamsEasyData(){ | ||
} | ||
|
||
void *SeamsEasyData::creator() | ||
{ | ||
return new SeamsEasyData; | ||
} | ||
|
||
MTypeId SeamsEasyData::typeId() const { | ||
return SeamsEasyData::id; | ||
} | ||
|
||
MString SeamsEasyData::name() const { | ||
return SeamsEasyData::typeName; | ||
} | ||
|
||
|
||
MStatus SeamsEasyData::writeASCII(std::ostream &out) | ||
{ | ||
out << edgeLoop.isReversed() << " "; | ||
if (out.fail()) | ||
return MStatus::kFailure; | ||
|
||
unsigned numberOfEdges = edgeLoop.numEdges(); | ||
out << numberOfEdges << " "; | ||
if (out.fail()) | ||
return MStatus::kFailure; | ||
|
||
for (unsigned i = 0; i < numberOfEdges; i++) | ||
{ | ||
out << edgeLoop[i] << " "; | ||
if (out.fail()) | ||
return MS::kFailure; | ||
|
||
out << edgeLoop.isFlipped(i) << " "; | ||
if (out.fail()) | ||
return MS::kFailure; | ||
} | ||
|
||
return MS::kSuccess; | ||
} | ||
|
||
MStatus SeamsEasyData::readASCII(const MArgList& args, unsigned int &end){ | ||
MStatus status; | ||
|
||
bool isReversed = args.asBool(end++, &status); | ||
edgeLoop.setReversed(isReversed); | ||
|
||
unsigned numberOfEdges = (unsigned)args.asInt(end++, &status); | ||
unsigned int numberOfArguments = args.length() - end; | ||
|
||
if (numberOfEdges*2 != numberOfArguments) | ||
return MS::kUnknownParameter; | ||
|
||
for (unsigned i = 0; i < numberOfEdges; i++) | ||
{ | ||
int index = args.asInt(end++, &status); | ||
CHECK_MSTATUS_AND_RETURN_IT(status); | ||
bool isFlipped = args.asBool(end++, &status); | ||
CHECK_MSTATUS_AND_RETURN_IT(status); | ||
|
||
edgeLoop.pushBack(index, isFlipped); | ||
} | ||
|
||
return MS::kSuccess; | ||
} | ||
|
||
MStatus SeamsEasyData::writeBinary(std::ostream &out){ | ||
|
||
bool isReversed = edgeLoop.isReversed(); | ||
out.write((char*)&isReversed, sizeof(isReversed)); | ||
if (out.fail()) | ||
return MStatus::kFailure; | ||
|
||
unsigned numberOfEdges = edgeLoop.numEdges(); | ||
out.write((char*)&numberOfEdges, sizeof(numberOfEdges)); | ||
if (out.fail()) | ||
return MStatus::kFailure; | ||
|
||
for (unsigned i = 0; i < numberOfEdges; i++) | ||
{ | ||
unsigned index = edgeLoop[i]; | ||
out.write((char*)&index, sizeof(index)); | ||
if (out.fail()) | ||
return MS::kFailure; | ||
|
||
unsigned isFlipped = edgeLoop.isFlipped(i); | ||
out.write((char*)&isFlipped, sizeof(isFlipped)); | ||
if (out.fail()) | ||
return MS::kFailure; | ||
} | ||
|
||
return MS::kSuccess; | ||
} | ||
|
||
MStatus SeamsEasyData::readBinary(std::istream &in, unsigned int length) | ||
{ | ||
MStatus status; | ||
|
||
if (length == 0) | ||
return MS::kSuccess; | ||
|
||
bool isReversed; | ||
in.read((char*)&isReversed, sizeof(isReversed)); | ||
if (in.fail()) | ||
return MS::kFailure; | ||
edgeLoop.setReversed(isReversed); | ||
|
||
unsigned numberOfEdges; | ||
in.read((char*)&numberOfEdges, sizeof(numberOfEdges)); | ||
if (in.fail()) | ||
return MS::kFailure; | ||
|
||
for (unsigned i = 0; i < numberOfEdges; i++) | ||
{ | ||
unsigned index; | ||
in.read((char*)&index, sizeof(index)); | ||
if (in.fail()) | ||
return MS::kFailure; | ||
|
||
bool isFlipped; | ||
in.read((char*)&isFlipped, sizeof(isFlipped)); | ||
if (in.fail()) | ||
return MS::kFailure; | ||
|
||
edgeLoop.pushBack(index, isFlipped); | ||
} | ||
|
||
return MS::kSuccess; | ||
} | ||
|
||
void SeamsEasyData::copy(const MPxData &other) { | ||
|
||
if (this->typeId() != other.typeId()) | ||
return; | ||
|
||
const SeamsEasyData &otherData = (const SeamsEasyData&)other; | ||
this->edgeLoop = otherData.edgeLoop; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
#include <maya\MPxData.h> | ||
#include <maya\MTypeId.h> | ||
#include <maya\MString.h> | ||
#include "SEdgeLoop.h" | ||
|
||
|
||
class SeamsEasyData : public MPxData{ | ||
public: | ||
SeamsEasyData(); | ||
virtual ~SeamsEasyData(); | ||
static void * creator(); | ||
|
||
virtual MStatus readASCII(const MArgList& argList, unsigned int &idx); | ||
virtual MStatus readBinary(istream& in, unsigned int length); | ||
virtual MStatus writeASCII(ostream& out); | ||
virtual MStatus writeBinary(ostream& out); | ||
|
||
virtual void copy(const MPxData&); | ||
|
||
virtual MTypeId typeId() const; | ||
virtual MString name() const; | ||
|
||
static const MString typeName; | ||
static const MTypeId id; | ||
|
||
SEdgeLoop edgeLoop; | ||
}; |
Oops, something went wrong.