Skip to content

Commit 7e909d1

Browse files
committed
improve CMemoryDwgFiler
1 parent c98974b commit 7e909d1

3 files changed

Lines changed: 17 additions & 37 deletions

File tree

PyRxCore/PyDbEval.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ class PyDbEvalExpr : public PyDbObject
181181
#endif
182182

183183
//-----------------------------------------------------------------------------------------
184-
//PyDbDbBlockUserParameter
184+
// PyDbDbBlockUserParameter
185+
// ...
186+
// This Class is not exposed in ARX, we use dwgOutFields, dwgInFields
187+
// to read/write to members
185188
void makePyDbDbBlockUserParameterWrapper();
186189

187190
#if defined(_ARXTARGET)

PyRxCore/PyDbFiler.cpp

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ boost::python::object PyDbSnoopDxfFiler::getitem(int idx)
580580

581581
//-----------------------------------------------------------------------------------------
582582
//CMemoryDwgFiler
583-
//
584583
CMemoryDwgFiler::CMemoryDwgFiler()
585584
: m_stat(Acad::eOk), m_filerType(AcDb::kCopyFiler), m_index(0)
586585
{
@@ -655,15 +654,7 @@ Acad::ErrorStatus CMemoryDwgFiler::readSoftPointerId(AcDbSoftPointerId* pVal) {
655654
Acad::ErrorStatus CMemoryDwgFiler::writeSoftPointerId(const AcDbSoftPointerId& val) { return writeToken(FilerToken::Type::kSoftPointerId, val); }
656655

657656
// --- Primitive Integer Implementations ---
658-
Acad::ErrorStatus CMemoryDwgFiler::readInt8(Adesk::Int8* pVal)
659-
{
660-
if (pVal == nullptr) return Acad::eInvalidInput;
661-
Adesk::UInt8 val;
662-
Acad::ErrorStatus es = readToken(FilerToken::Type::kUInt8, &val);
663-
if (es == Acad::eOk) *pVal = static_cast<Adesk::Int8>(val);
664-
return es;
665-
}
666-
657+
Acad::ErrorStatus CMemoryDwgFiler::readInt8(Adesk::Int8* pVal) { return readToken(FilerToken::Type::kInt8, pVal); }
667658
Acad::ErrorStatus CMemoryDwgFiler::writeInt8(Adesk::Int8 val) { return writeToken(FilerToken::Type::kUInt8, static_cast<Adesk::UInt8>(val)); }
668659
Acad::ErrorStatus CMemoryDwgFiler::readInt16(Adesk::Int16* pVal) { return readToken(FilerToken::Type::kInt16, pVal); }
669660
Acad::ErrorStatus CMemoryDwgFiler::writeInt16(Adesk::Int16 val) { return writeToken(FilerToken::Type::kInt16, val); }
@@ -682,14 +673,14 @@ Acad::ErrorStatus CMemoryDwgFiler::writeUInt8(Adesk::UInt8 val) { return writeTo
682673
Acad::ErrorStatus CMemoryDwgFiler::readBool(bool* pVal) { return readToken(FilerToken::Type::kBoolean, pVal); }
683674
Acad::ErrorStatus CMemoryDwgFiler::writeBool(bool val) { return writeToken(FilerToken::Type::kBoolean, val); }
684675

685-
Acad::ErrorStatus CMemoryDwgFiler::writeBoolean(Adesk::Boolean val) {
686-
return writeBool(val ? true : false);
687-
}
676+
Acad::ErrorStatus CMemoryDwgFiler::writeBoolean(Adesk::Boolean val) {return writeBool(val ? true : false);}
688677
Acad::ErrorStatus CMemoryDwgFiler::readBoolean(Adesk::Boolean* pVal) {
689-
if (!pVal) return Acad::eInvalidInput;
678+
if (!pVal)
679+
return Acad::eInvalidInput;
690680
bool val;
691681
Acad::ErrorStatus es = readBool(&val);
692-
if (es == Acad::eOk) *pVal = val ? Adesk::kTrue : Adesk::kFalse;
682+
if (es == Acad::eOk)
683+
*pVal = val ? Adesk::kTrue : Adesk::kFalse;
693684
return es;
694685
}
695686

@@ -703,32 +694,14 @@ Acad::ErrorStatus CMemoryDwgFiler::readVector2d(AcGeVector2d* pVal) { return rea
703694
Acad::ErrorStatus CMemoryDwgFiler::writeVector2d(const AcGeVector2d& val) { return writeToken(FilerToken::Type::kVector2d, val); }
704695
Acad::ErrorStatus CMemoryDwgFiler::readVector3d(AcGeVector3d* pVal) { return readToken(FilerToken::Type::kVector3d, pVal); }
705696
Acad::ErrorStatus CMemoryDwgFiler::writeVector3d(const AcGeVector3d& val) { return writeToken(FilerToken::Type::kVector3d, val); }
706-
707-
// Scale3d acts as a composite wrapper for a vector mapping
708-
Acad::ErrorStatus CMemoryDwgFiler::writeScale3d(const AcGeScale3d& val) {
709-
return writeVector3d(AcGeVector3d(val.sx, val.sy, val.sz));
710-
}
711-
Acad::ErrorStatus CMemoryDwgFiler::readScale3d(AcGeScale3d* pVal) {
712-
if (!pVal) return Acad::eInvalidInput;
713-
AcGeVector3d vec;
714-
Acad::ErrorStatus es = readVector3d(&vec);
715-
if (es == Acad::eOk) {
716-
pVal->set(vec.x, vec.y, vec.z);
717-
}
718-
return es;
719-
}
720-
697+
Acad::ErrorStatus CMemoryDwgFiler::readScale3d(AcGeScale3d* pVal) { return readToken(FilerToken::Type::kScale3d, pVal); }
698+
Acad::ErrorStatus CMemoryDwgFiler::writeScale3d(const AcGeScale3d& val) { return writeToken(FilerToken::Type::kScale3d, val); }
721699
Acad::ErrorStatus CMemoryDwgFiler::readAcDbHandle(AcDbHandle* pVal) { return readToken(FilerToken::Type::kHandle, pVal); }
722700
Acad::ErrorStatus CMemoryDwgFiler::writeAcDbHandle(const AcDbHandle& val) { return writeToken(FilerToken::Type::kHandle, val); }
723701

724702
// --- String Fields Handling ---
725-
Acad::ErrorStatus CMemoryDwgFiler::readString(AcString& val) {
726-
return readToken(FilerToken::Type::kString, &val);
727-
}
728-
703+
Acad::ErrorStatus CMemoryDwgFiler::readString(AcString& val) {return readToken(FilerToken::Type::kString, &val);}
729704
Acad::ErrorStatus CMemoryDwgFiler::writeString(const AcString& val) { return writeToken(FilerToken::Type::kString, val); }
730-
731-
732705
Acad::ErrorStatus CMemoryDwgFiler::writeString(const ACHAR* pVal) {
733706
if (pVal == nullptr) return Acad::eInvalidInput;
734707
return writeString(AcString(pVal));

PyRxCore/PyDbFiler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ struct FilerToken
147147

148148
enum class Type
149149
{
150+
kInt8,
150151
kUInt8,
151152
kInt16,
152153
kUInt16,
@@ -165,12 +166,14 @@ struct FilerToken
165166
kPoint3d,
166167
kVector2d,
167168
kVector3d,
169+
kScale3d,
168170
kHandle,
169171
kBytes
170172
};
171173

172174
Type type;
173175
std::variant <
176+
Adesk::Int8,
174177
Adesk::UInt8,
175178
Adesk::Int16,
176179
Adesk::UInt16,
@@ -189,6 +192,7 @@ struct FilerToken
189192
AcGePoint3d,
190193
AcGeVector2d,
191194
AcGeVector3d,
195+
AcGeScale3d,
192196
AcDbHandle,
193197
ByteBuffer
194198
> value;

0 commit comments

Comments
 (0)