Skip to content

Commit

Permalink
Merge pull request #156 from AliHaider93/sketchExtrude_devel_k-g
Browse files Browse the repository at this point in the history
SketchClass: beam elements with integrable cross sections
  • Loading branch information
drossberg committed Sep 26, 2024
2 parents 9d8e10c + 3d8fa73 commit 37bf7f8
Show file tree
Hide file tree
Showing 15 changed files with 1,708 additions and 61 deletions.
4 changes: 4 additions & 0 deletions src/conv/k-g/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set(k-g_SRCF
arbs.cpp
geometry.cpp
pipe.cpp
sketch.cpp
extrude.cpp
)
BRLCAD_ADDEXEC(k-g "${k-g_SRCF}" "libwdb;librt;libbu" FOLDER Conv)

Expand All @@ -17,6 +19,8 @@ set(k-g_ignore_files
arbs.h
geometry.h
pipe.h
sketch.h
extrude.h
)
CMAKEFILES(${k-g_ignore_files})

Expand Down
11 changes: 4 additions & 7 deletions src/conv/k-g/arbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ Arbs::Arbs(void):name() {}

void Arbs::setName(const char* value)
{
name = value;
if (value != nullptr)
name = value;
else
name = "";
}


Expand Down Expand Up @@ -64,12 +67,6 @@ void Arbs::addArb(
}


const char* Arbs::getName(void) const
{
return name.c_str();
}


std::map<std::string, rt_arb_internal> Arbs::getArbs(void) const
{
return arbs;
Expand Down
1 change: 0 additions & 1 deletion src/conv/k-g/arbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class Arbs {
const point_t& point7,
const point_t& point8);

const char* getName(void) const;
std::map<std::string, rt_arb_internal> getArbs(void) const;

std::vector<std::string> write(rt_wdb* wdbp);
Expand Down
5 changes: 0 additions & 5 deletions src/conv/k-g/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ void Bot::addTriangle
}


const char* Bot::getName(void) const {
return name.c_str();
}


std::vector<std::string> Bot::write
(
rt_wdb* wdbp
Expand Down
1 change: 0 additions & 1 deletion src/conv/k-g/bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class Bot {
const point_t& point2,
const point_t& point3);

const char* getName(void) const;
std::vector <std::string> write(rt_wdb* wdbp);

private:
Expand Down
86 changes: 86 additions & 0 deletions src/conv/k-g/extrude.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* E X T R U D E . C P P
* BRL-CAD
*
* Copyright (c) 2024 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file extrude.cpp
*
* LS Dyna keyword file to BRL-CAD converter:
* intermediate extrude implementation
*/

#include "extrude.h"




Extrude::Extrude(void)
{
BU_GET(m_extrude, rt_extrude_internal);
m_extrude->magic = RT_EXTRUDE_INTERNAL_MAGIC;
}


void Extrude::setName
(
const char* value
) {
if (value != nullptr)
name = value;
else
name = "";
}


void Extrude::extrudeSection(std::string sectionName,const point_t& V, vect_t h, vect_t u_vec, vect_t v_vec)
{
m_extrude->magic = RT_EXTRUDE_INTERNAL_MAGIC;
VMOVE(m_extrude->V, V);
VMOVE(m_extrude->h, h);
VMOVE(m_extrude->u_vec, u_vec);
VMOVE(m_extrude->v_vec, v_vec);
m_extrude->sketch_name = bu_strdup(sectionName.c_str());
m_extrude->skt = (struct rt_sketch_internal*)NULL;
}


std::string Extrude::write(rt_wdb* wdbp)
{
std::string ret;

rt_extrude_internal* extrude_wdb;
BU_GET(extrude_wdb, rt_extrude_internal);
extrude_wdb->magic = RT_EXTRUDE_INTERNAL_MAGIC;
extrude_wdb = m_extrude;

if ((extrude_wdb->sketch_name != nullptr) && (strlen(extrude_wdb->sketch_name) > 0 )) {
wdb_export(wdbp, name.c_str(), extrude_wdb, ID_EXTRUDE, 1);
ret = name;
}

return ret;
}


// Local Variables:
// tab-width: 8
// mode: C++
// c-basic-offset: 4
// indent-tabs-mode: t
// c-file-style: "stroustrup"
// End:
// ex: shiftwidth=4 tabstop=8
58 changes: 58 additions & 0 deletions src/conv/k-g/extrude.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* E X T R U D E . H
* BRL-CAD
*
* Copyright (c) 2024 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this file; see the file named COPYING for more
* information.
*/
/** @file extrude.h
*
* LS Dyna keyword file to BRL-CAD converter:
* intermediate extrude implementation
*/
#ifndef EXTRUDE_INCLUDED
#define EXTRUDE_INCLUDED

#include "common.h"
#include "wdb.h"



class Extrude {
public:
Extrude(void);

void setName(const char* value);

void extrudeSection(std::string sectionName,const point_t& V, vect_t h, vect_t u_vec, vect_t v_vec);

std::string write(rt_wdb* wdbp);
private:
std::string name;
rt_extrude_internal* m_extrude;
};


#endif // !EXTRUDE_INCLUDED


// Local Variables:
// tab-width: 8
// mode: C++
// c-basic-offset: 4
// indent-tabs-mode: t
// c-file-style: "stroustrup"
// End:
// ex: shiftwidth=4 tabstop=8
38 changes: 36 additions & 2 deletions src/conv/k-g/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ void Geometry::addPipePnt(pipePoint point)
}


void Geometry::addBeamResultant(std::string beamName, std::string sectionType, const point_t& node1, const point_t& node2, const point_t& node3, std::vector<double> D)
{
BeamResultant temp;
rt_sketch_internal* tempSkt;

BU_GET(tempSkt, rt_sketch_internal);
tempSkt->magic = RT_SKETCH_INTERNAL_MAGIC;

std::string sectionName = beamName;
sectionName += ".skt";
std::string extrudeName = beamName;
extrudeName += ".ext";
temp.skt.setName(sectionName.c_str());
temp.ext.setName(extrudeName.c_str());

vect_t h;
h[X] = node2[X] - node1[X];
h[Y] = node2[Y] - node1[Y];
h[Z] = node2[Z] - node1[Z];

tempSkt = temp.skt.creatSketch(sectionType, node1, node2, node3, D);

temp.ext.extrudeSection(sectionName.c_str(), node1, h, tempSkt->u_vec, tempSkt->v_vec);

m_BeamsResultant.push_back(temp);
}


const char* Geometry::getBaseName(void) const{
return name.c_str();
}
Expand All @@ -105,12 +133,18 @@ std::vector<std::string> Geometry::write
(
rt_wdb* wdbp
) {
std::vector<std::string> ret = m_bot.write(wdbp);
std::vector<std::string> arbNames = m_arbs.write(wdbp);
std::vector<std::string> ret = m_bot.write(wdbp);
std::vector<std::string> arbNames = m_arbs.write(wdbp);
std::vector<std::string> pipeName = m_pipe.write(wdbp);

for (size_t i = 0; i < m_BeamsResultant.size(); ++i) {
ret.push_back(m_BeamsResultant[i].skt.write(wdbp));
ret.push_back(m_BeamsResultant[i].ext.write(wdbp));
}

ret.insert(ret.end(), arbNames.begin(), arbNames.end());
ret.insert(ret.end(), pipeName.begin(), pipeName.end());

return ret;
}

Expand Down
24 changes: 19 additions & 5 deletions src/conv/k-g/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@
#include "bot.h"
#include "arbs.h"
#include "pipe.h"
#include "sketch.h"
#include "extrude.h"

struct BeamResultant {
Sketch skt;
Extrude ext;
};

class Geometry {
public:

void setBaseName(const char* value);
void setThickness(double value);

void addTriangle(const point_t& point1,
const point_t& point2,
const point_t& point3);
Expand All @@ -49,7 +56,13 @@ class Geometry {
const point_t& point6,
const point_t& point7,
const point_t& point8);
void addPipePnt(pipePoint point);
void addPipePnt(pipePoint point);
void addBeamResultant(const std::string beamName,
const std::string sectionType,
const point_t& node1,
const point_t& node2,
const point_t& node3,
const std::vector<double> D);

const char* getBaseName(void) const;
Bot& getBot(void);
Expand All @@ -58,10 +71,11 @@ class Geometry {

std::vector<std::string> write(rt_wdb* wdbp);
private:
std::string name;
Bot m_bot;
Arbs m_arbs;
Pipe m_pipe;
std::string name;
Bot m_bot;
Arbs m_arbs;
Pipe m_pipe;
std::vector<BeamResultant> m_BeamsResultant;
};


Expand Down
Loading

0 comments on commit 37bf7f8

Please sign in to comment.