Skip to content

Commit

Permalink
Merge pull request #22 from codelibs/revert-19-ss-patches
Browse files Browse the repository at this point in the history
Revert "Patches from SolveSpace"
  • Loading branch information
marevol authored Apr 15, 2024
2 parents 8c57f68 + 16b8bd1 commit 0bde851
Show file tree
Hide file tree
Showing 33 changed files with 409 additions and 477 deletions.
84 changes: 11 additions & 73 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,82 +1,20 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(libdxfrw)
if(MSVC)
# Disable some overly strict MSVC warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4244 -wd4800 -wd4805")
endif()

set(intern_HEADERS
src/intern/drw_cptable932.h
src/intern/drw_cptable936.h
src/intern/drw_cptable949.h
src/intern/drw_cptable950.h
src/intern/drw_cptables.h
src/intern/drw_dbg.h
src/intern/drw_textcodec.h
src/intern/dwgbuffer.h
src/intern/dwgreader15.h
src/intern/dwgreader18.h
src/intern/dwgreader21.h
src/intern/dwgreader24.h
src/intern/dwgreader27.h
src/intern/dwgreader.h
src/intern/dwgutil.h
src/intern/dxfreader.h
src/intern/dxfwriter.h
src/intern/rscodec.h)

set(intern_SOURCES
src/intern/drw_dbg.cpp
src/intern/drw_textcodec.cpp
src/intern/dwgbuffer.cpp
src/intern/dwgreader15.cpp
src/intern/dwgreader18.cpp
src/intern/dwgreader21.cpp
src/intern/dwgreader24.cpp
src/intern/dwgreader27.cpp
src/intern/dwgreader.cpp
src/intern/dwgutil.cpp
src/intern/dxfreader.cpp
src/intern/dxfwriter.cpp
src/intern/rscodec.cpp)

set(libdxfrw_HEADERS
src/drw_base.h
src/drw_interface.h
src/drw_header.h
src/drw_classes.h
src/drw_entities.h
src/drw_objects.h
src/libdxfrw.h)

set(libdxfrw_SOURCES
src/drw_header.cpp
src/drw_classes.cpp
src/drw_entities.cpp
src/drw_objects.cpp
src/libdxfrw.cpp)

set(libdwgr_HEADERS
src/libdwgr.h)
file(GLOB libdxfrw_sources src/*.cpp)
file(GLOB libdxfrw_headers include/*.h)
file(GLOB libdxfrw_intern_sources src/intern/*.cpp)

set(libdwgr_SOURCES
src/libdwgr.cpp)

add_library(dxfrw STATIC
${intern_HEADERS}
${intern_SOURCES}
${libdxfrw_HEADERS}
${libdxfrw_SOURCES}
${libdwgr_HEADERS}
${libdwgr_SOURCES})
if(WIN32)

target_include_directories(dxfrw PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/intern/)
include_directories(vs2013/packages/libiconv.1.14.0.11/build/native/include)
link_directories(vs2013/packages/libiconv.1.14.0.11/build/native/lib)
endif()
include_directories(include)

target_include_directories(dxfrw PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/)
add_library(dxfrw STATIC ${libdxfrw_sources} ${libdxfrw_intern_sources})

install(FILES ${libdxfrw_HEADERS} DESTINATION include)
install(FILES ${libdxfrw_headers} DESTINATION include)

if(WIN32)
install(TARGETS dxfrw
Expand All @@ -91,4 +29,4 @@ else()
install(TARGETS dxfrw
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
endif()
33 changes: 10 additions & 23 deletions src/drw_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,8 @@ enum DBG_LEVEL {

//! Special codes for colors
enum ColorCodes {
ColorByBlock = 0,
Red = 1,
Yellow = 2,
Green = 3,
Cyan = 4,
Blue = 5,
Magenta = 6,
White = 7,
Gray = 8,
Brown = 15,
LRed = 23,
LGreen = 121,
LCyan = 131,
LBlue = 163,
LMagenta = 221,
Black = 250,
LGray = 252,
ColorByLayer = 256,

ColorByBlock = 0
};

//! Spaces
Expand Down Expand Up @@ -168,10 +151,14 @@ enum TransparencyCodes {
*/
class DRW_Coord {
public:
DRW_Coord() = default;
DRW_Coord():x(0), y(0),z(0) {}
DRW_Coord(double ix, double iy, double iz): x(ix), y(iy),z(iz){}

/*! convert to unitary vector */
DRW_Coord& operator = (const DRW_Coord& data) {
x = data.x; y = data.y; z = data.z;
return *this;
}
/*!< convert to unitary vector */
void unitize(){
double dist;
dist = sqrt(x*x + y*y + z*z);
Expand All @@ -183,9 +170,9 @@ class DRW_Coord {
}

public:
double x = 0;
double y = 0;
double z = 0;
double x;
double y;
double z;
};


Expand Down
98 changes: 16 additions & 82 deletions src/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "intern/drw_dbg.h"


//! Calculate arbitrary axis
//! Calculate arbitary axis
/*!
* Calculate arbitrary axis for apply extrusions
* Calculate arbitary axis for apply extrusions
* @author Rallaz
*/
void DRW_Entity::calculateAxis(DRW_Coord extPoint){
Expand Down Expand Up @@ -50,9 +50,9 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
extAxisY.unitize();
}

//! Extrude a point using arbitrary axis
//! Extrude a point using arbitary axis
/*!
* apply extrusion in a point using arbitrary axis (previous calculated)
* apply extrusion in a point using arbitary axis (previous calculated)
* @author Rallaz
*/
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point){
Expand Down Expand Up @@ -1332,10 +1332,10 @@ bool DRW_Text::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
return ret;
DRW_DBG("\n***************************** parsing text *********************************************\n");

// DataFlags RC Used to determine presence of subsequent data, set to 0xFF for R14-
// DataFlags RC Used to determine presence of subsquent data, set to 0xFF for R14-
duint8 data_flags = 0x00;
if (version > DRW::AC1014) {//2000+
data_flags = buf->getRawChar8(); /* DataFlags RC Used to determine presence of subsequent data */
data_flags = buf->getRawChar8(); /* DataFlags RC Used to determine presence of subsquent data */
DRW_DBG("data_flags: "); DRW_DBG(data_flags); DRW_DBG("\n");
if ( !(data_flags & 0x01) ) { /* Elevation RD --- present if !(DataFlags & 0x01) */
basePoint.z = buf->getRawDouble();
Expand Down Expand Up @@ -1427,59 +1427,6 @@ void DRW_MText::parseCode(int code, dxfReader *reader){
case 44:
interlin = reader->getDouble();
break;
case 71: {
// Attachment point
Attach a = (Attach)reader->getInt32();

switch(a) {
case TopLeft:
alignV = VTop;
alignH = HLeft;
break;
case TopCenter:
alignV = VTop;
alignH = HCenter;
break;
case TopRight:
alignV = VTop;
alignH = HRight;
break;
case MiddleLeft:
alignV = VMiddle;
alignH = HLeft;
break;
case MiddleCenter:
alignV = VMiddle;
alignH = HCenter;
break;
case MiddleRight:
alignV = VMiddle;
alignH = HRight;
break;
case BottomLeft:
alignV = VBottom;
alignH = HLeft;
break;
case BottomCenter:
alignV = VBottom;
alignH = HCenter;
break;
case BottomRight:
alignV = VBottom;
alignH = HRight;
break;
}
} break;
case 72:
// To prevent redirection to DRW_Text::parseCode.
// This code meaning is different for MTEXT.
// Actually: Drawing direction
break;
case 73:
// To prevent redirection to DRW_Text::parseCode.
// This code meaning is different for MTEXT.
// Actually: Mtext line spacing style
break;
default:
DRW_Text::parseCode(code, reader);
break;
Expand Down Expand Up @@ -1517,7 +1464,7 @@ bool DRW_MText::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_UNUSED(ext_ht);
/* Extents wid BD Undocumented and not present in DXF or entget The extents
rectangle, when rotated the same as the text, fits the actual text image on
the screen (although we've seen it include an extra row of text in height). */
the screen (altough we've seen it include an extra row of text in height). */
double ext_wid = buf->getBitDouble();
DRW_UNUSED(ext_wid);
/* Text TV 1 All text in one long string (without '\n's 3 for line wrapping).
Expand Down Expand Up @@ -1965,7 +1912,8 @@ bool DRW_Hatch::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
}
for (dint32 j = 0; j < spline->ncontrol;++j){
// pt0 2RD 10 control point
DRW_Coord *crd = new DRW_Coord(buf->get2RawDouble());
DRW_Coord* crd = new DRW_Coord(buf->get2RawDouble());
spline->controllist.push_back(crd);
if(isRational)
crd->z = buf->getBitDouble(); //RLZ: investigate how store weight
spline->controllist.push_back(crd);
Expand Down Expand Up @@ -2023,8 +1971,8 @@ bool DRW_Hatch::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_DBG("\ndef line: "); DRW_DBG(angleL); DRW_DBG(","); DRW_DBG(ptL.x); DRW_DBG(","); DRW_DBG(ptL.y);
DRW_DBG(","); DRW_DBG(offL.x); DRW_DBG(","); DRW_DBG(offL.y); DRW_DBG(","); DRW_DBG(angleL);
for (duint16 i = 0 ; i < numDashL; ++i){
double lengthL = buf->getBitDouble();
DRW_DBG(","); DRW_DBG(lengthL);
double lenghtL = buf->getBitDouble();
DRW_DBG(","); DRW_DBG(lenghtL);
}
}//end deflines
} //end not solid
Expand Down Expand Up @@ -2140,9 +2088,8 @@ void DRW_Spline::parseCode(int code, dxfReader *reader){
case 40:
knotslist.push_back(reader->getDouble());
break;
case 41:
weightlist.push_back(reader->getDouble());
break;
// case 41:
// break;
default:
DRW_Entity::parseCode(code, reader);
break;
Expand Down Expand Up @@ -2419,10 +2366,6 @@ void DRW_Dimension::parseCode(int code, dxfReader *reader){
case 41:
linefactor = reader->getDouble();
break;
case 42:
actual = reader->getDouble();
hasActual = (actual != 0.0);
break;
case 53:
rot = reader->getDouble();
break;
Expand All @@ -2438,15 +2381,6 @@ void DRW_Dimension::parseCode(int code, dxfReader *reader){
case 51:
hdir = reader->getDouble();
break;
case 210:
extPoint.x = reader->getDouble();
break;
case 220:
extPoint.y = reader->getDouble();
break;
case 230:
extPoint.z = reader->getDouble();
break;
default:
DRW_Entity::parseCode(code, reader);
break;
Expand Down Expand Up @@ -3012,7 +2946,7 @@ bool DRW_Viewport::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
frozenLyCount = buf->getBitLong();
DRW_DBG("Frozen Layer count?: "); DRW_DBG(frozenLyCount); DRW_DBG("\n");
DRW_DBG("Status Flags?: "); DRW_DBG(buf->getBitLong()); DRW_DBG("\n");
//RLZ: Warning needed separate string buffer
//RLZ: Warning needed separate string bufer
DRW_DBG("Style sheet?: "); DRW_DBG(sBuf->getVariableText(version, false)); DRW_DBG("\n");
DRW_DBG("Render mode?: "); DRW_DBG(buf->getRawChar8()); DRW_DBG("\n");
DRW_DBG("UCS OMore...: "); DRW_DBG(buf->getBit()); DRW_DBG("\n");
Expand All @@ -3027,8 +2961,8 @@ bool DRW_Viewport::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_DBG("ShadePlot Mode...: "); DRW_DBG(buf->getBitShort()); DRW_DBG("\n");
}
if (version > DRW::AC1018) {//2007+
DRW_DBG("Use def Light...: "); DRW_DBG(buf->getBit()); DRW_DBG("\n");
DRW_DBG("Def light type?: "); DRW_DBG(buf->getRawChar8()); DRW_DBG("\n");
DRW_DBG("Use def Ligth...: "); DRW_DBG(buf->getBit()); DRW_DBG("\n");
DRW_DBG("Def ligth tipe?: "); DRW_DBG(buf->getRawChar8()); DRW_DBG("\n");
DRW_DBG("Brightness: "); DRW_DBG(buf->getBitDouble()); DRW_DBG("\n");
DRW_DBG("Contrast: "); DRW_DBG(buf->getBitDouble()); DRW_DBG("\n");
// DRW_DBG("Ambient Cmc or Enc: "); DRW_DBG(buf->getCmColor(version)); DRW_DBG("\n");
Expand Down
Loading

0 comments on commit 0bde851

Please sign in to comment.