3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
tube.cpp

This example generates the surface figure that consists of tube

// This example generates the surface figure that consists of tube
#include <CoreAPI.h>
//@config: Debug
class TubePrim:public BaseClass {
public:
TubePrim() {
Radius2 = 30;
Radius1 = 30;
Thickness = 8;
Height = 200;
Fillet = 0.0;
}
float Radius2;
float Radius1;
float Thickness;
float Height;
float Fillet;
// this is class registration, look dialogs example
SERIALIZE() {
FSLIDER(Radius1, "%Radius1", 10, 100, 20, false);
FSLIDER(Radius2, "%Radius2", 10, 100, 20, false);
FSLIDER(Thickness, "%Thickness", 5, 40, 10, false);
FSLIDER(Height, "%Height", 20, 200.0, 100, false);
FSLIDER(Fillet, "%Fillet", 0.1, 10.0, 1, false);
}
void build() {
auto current = coat::Scene::sculptRoot().addChild("Tube"+coat::str::ToString(voxId));
auto volume = current.Volume();
volume.toSurface();
coat::tube tube;
tube.height(Height)
.radiusTop(Radius2)
.radiusBottom(Radius1)
.thickness(Thickness)
.fillet(Fillet)
.details(0.2)
.add(volume);
}
};
EXPORT
int main() {
// get to sculpt room
coat::ui::toRoom("Sculpt");
TubePrim tubePrim;
// load settings if exist
tubePrim.ReadFromFile("data/Temp/tube.json");
if(dlg.ok().cancel().params(&tubePrim).show() == 1) {// ok pressed, buttons start from 1
// save settings
tubePrim.WriteToFile("data/Temp/tube.json");
// build the figure
tubePrim.build();
};
return 0;
}
Use this class for build a class for UI or serialization. see class_reg.h for details about the class...
Definition BaseClass.h:91
int childCount() const
returns the child elements count
SceneElement addChild(const char *name) const
add the child element of the same nature
static SceneElement sculptRoot()
get the root of all sculpt objects
cylinder & radiusBottom(const float &r)
set the bottom radius.
cylinder & height(const float &_height)
set the height in the z-axis.
cylinder & radiusTop(const float &r)
set the top radius.
the rich dialog. You may customize it, show your custom parameters and custom buttons.
Definition CoreAPI.h:3821
dialog & params(BaseClass *params)
The important core feature. BaseClass allows to create the custom controls in the dialog....
dialog & ok()
add Ok button
dialog & cancel()
add Cancel button
int show()
Show the dialog. This is usually the last command in the chain.
prim & details(const float det_level)
set the detail level
prim & fillet(float radius)
set the fillet
T & Obj()
Get the primitive object reference.
Definition CorePrimAPI.h:264
void add(Volume &v)
add the prim into scene
The tube.
Definition CorePrimAPI.h:1169
static void toRoom(const char *name, bool Force=false)
switch to the room