Skip to content

Instantly share code, notes, and snippets.

View TNick's full-sized avatar

Nicu Tofan TNick

View GitHub Profile
@TNick
TNick / LibreCAD math
Created March 17, 2013 18:58
LibreCAD math
std::vector<double> RS_Math::quadraticSolver(const std::vector<double>& ce)
//quadratic solver for
// x^2 + ce[0] x + ce[1] =0
{
std::vector<double> ans(0,0.);
if(ce.size() != 2) return ans;
double discriminant=0.25*ce[0]*ce[0]-ce[1];
/* the discriminant may be very small and negative */
if ( qAbs(discriminant) < 0.0000000001 ){
ans.push_back(-0.5*ce[0] );
@TNick
TNick / gist:5204656
Created March 20, 2013 13:32
DRW_Text::parseDwg
bool DRW_Text::parseDwg(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing text *********************************************\n");
if (version < DRW::AC1015) {//14-
basePoint.z = buf->getBitDouble(); /* Elevation BD --- */
basePoint.x = buf->getBitDouble(); /* Insertion pt 2RD 10 */
basePoint.y = buf->getBitDouble();
@TNick
TNick / gist:5206927
Created March 20, 2013 17:59
dwgBuffer::getExtrusion
void dwgBuffer::getExtrusion(DRW_Coord *ext)
{
/*
Bit Extrusion
For R13-R14 this is 3BD.
We are asserting that the version is not R13-R14; this values should
be read by the user
*/
@TNick
TNick / gist:5207010
Created March 20, 2013 18:08
dwgBuffer::getThickness
void dwgBuffer::getThickness(bool b_R2000_style)
{
/* BitThickness
For R13-R14, this is a BD.
We are asserting that the version is not R13-R14; this value should
be read by the user
*/
if ( !b_R2000_style )
return getBitDouble();
@TNick
TNick / gist:5211158
Created March 21, 2013 06:51
DRW_MText::parseDwg()
bool DRW_MText::parseDwg(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing mtext *********************************************\n");
basePoint.x = buf->getBitDouble(); /* Insertion pt 3BD 10 - First picked point. */
basePoint.y = buf->getBitDouble(); /* (Location relative to text depends */
basePoint.z = buf->getBitDouble(); /* on attachment point (71) */
extPoint.x = buf->getBitDouble(); /* Extrusion 3BD 210 Undocumented; */
@TNick
TNick / gist:5211527
Created March 21, 2013 08:31
DRW_Vertex parseDwg
bool DRW_Vertex::parseDwg2D(DRW::Version version, dwgBuffer *buf){
bool ret = DRW_Entity::parseDwg(version, buf);
if (!ret)
return ret;
DBG("\n***************************** parsing vertex *********************************************\n");
/* Flags EC 70 NOT bit-pair-coded. */
/** @todo investigate what an EC is */ Q_ASSERT(false);
@TNick
TNick / gist:5243656
Created March 26, 2013 07:18
Changes to DRW_Entity
diff --git a/libraries/libdxfrw/src/drw_base.h b/libraries/libdxfrw/src/drw_base.h
index 416230c..00a4051 100644
--- a/libraries/libdxfrw/src/drw_base.h
+++ b/libraries/libdxfrw/src/drw_base.h
@@ -296,6 +296,59 @@ public:
}
};
+// TNick todo: wrap all elements in this namespace
+namespace libdxfrw {
@TNick
TNick / gist:5277132
Created March 30, 2013 15:37
git_stash_pop() and git_stash_apply()
int git_stash_apply(
git_repository *repo,
size_t index)
{
git_reference *stash;
const git_reflog_entry *ref_e;
git_reflog *reflog = NULL;
size_t max;
int error;
const git_oid * oidw;
cmake_minimum_required(VERSION 2.8)
project(protobufc)
include_directories(
"${PROJECT_SOURCE_DIR}"
)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
@TNick
TNick / TinyXML-CmakeLists.txt
Created December 14, 2013 15:08
Cmake file for TInyXML
cmake_minimum_required(VERSION 2.8)
project(tinyxml)
include_directories(
"${PROJECT_SOURCE_DIR}"
)
add_library (tinyxml
tinystr.cpp
tinyxml.cpp