SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
Public Member Functions | Friends
CW::GeometryInput Class Reference

#include <GeometryInput.hpp>

Public Member Functions

 GeometryInput (SUModelRef target_model)
 
 GeometryInput (const GeometryInput &other)
 
 ~GeometryInput ()
 
GeometryInputoperator= (const GeometryInput &other)
 
SUGeometryInputRef ref () const
 
bool operator! () const
 
size_t num_faces () const
 
size_t add_face (const Face &face, bool copy_material_layer=true)
 
size_t add_face (const std::vector< Loop > &loops)
 
size_t add_faces (const std::vector< Face > &faces, bool copy_material_layer=true)
 
size_t add_edge (const Edge &edge)
 
size_t add_edges (const std::vector< Edge > &edges)
 
bool empty () const
 
size_t add_vertex (const Point3D &point)
 
void set_vertices (const std::vector< SUPoint3D > &points)
 
void set_vertices (const std::vector< Point3D > &points)
 
size_t add_edge (size_t vertex0_index, size_t vertex1_index)
 
void edge_hidden (size_t edge_index, bool hidden)
 
void edge_soft (size_t edge_index, bool soft)
 
void edge_smooth (size_t edge_index, bool smooth)
 
void edge_material (size_t edge_index, const Material &material)
 
void edge_layer (size_t edge_index, const Layer &layer)
 
size_t add_curve (const std::vector< size_t > &edge_indices)
 
std::pair< size_t, size_t > add_arc_curve (size_t start_point, size_t end_point, const Point3D &center, const Vector3D &normal, size_t num_segments)
 
size_t add_face (LoopInput &loop_input)
 
void face_reverse (size_t face_index, bool reverse)
 
void face_layer (size_t face_index, const Layer &layer)
 
void face_add_inner_loop (size_t face_index, LoopInput &inner_loop)
 
void face_front_material (size_t face_index, MaterialInput &material_input)
 
void face_back_material (size_t face_index, MaterialInput &material_input)
 
void face_hidden (size_t face_index, bool hidden)
 
std::array< size_t, 5 > counts () const
 

Friends

class Entities
 

Detailed Description

Geometry Input class is an abstraction of Sketchup C API's SUGeometryInputRef object. It allows a much easier way for programmers to build Sketchup geometry within this class, before exporting it into a built SUGeometryInputRef object. See below for an example of GeometryInput operates: GeometryInput geom_input; Entities entities; // This is the entities object that we wish to add the geometry to. std::vector<SUPoint3D> outer_loop{SUPoint3D(0.0,0.0,0.0), SUPoint3D(1.0,0.0,0.0), SUPoint3D(0.0,1.0,0.0)}; std::vector<std::vector<SUPoint3D>> inner_loops{{SUPoint3D(0.1,0.1,0.0), SUPoint3D(0.1,0.2,0.0), SUPoint3D(0.2,0.3,0.0)}}; GIFace* face = geom_input.add_face(outer_loop, inner_loops); // GeometryInput handles the interface with Sketchup C API when creating geometry. SUResult result = entities.fill(geom_input); // the geometry must be output into a SUEntitiesRef object.

Definition at line 66 of file GeometryInput.hpp.

Constructor & Destructor Documentation

CW::GeometryInput::GeometryInput ( SUModelRef  target_model)

Creates a valid, but empty GeometryInput object.

Parameters
target_model- model which will receive this GeometryInput object.

Definition at line 83 of file GeometryInput.cpp.

CW::GeometryInput::GeometryInput ( const GeometryInput other)

Copy Constructor

Definition at line 104 of file GeometryInput.cpp.

CW::GeometryInput::~GeometryInput ( )

Destructor

Definition at line 92 of file GeometryInput.cpp.

Member Function Documentation

std::pair< size_t, size_t > CW::GeometryInput::add_arc_curve ( size_t  start_point,
size_t  end_point,
const Point3D center,
const Vector3D normal,
size_t  num_segments 
)

Adds an arccurve to a geometry input object. In addition to adding an arccurve to the geometry input this method will append num_segments edges to the geometry's edge collection where control_edge_index is the index of the first new edge. Also, num_segments-1 vertices along the arc will be appended to the geometry's collection of verttices. In order to include an arccurve in a loop the user only needs add the arccurve's points to a loop using SULoopInputAddVertexIndex.

Since
SketchUp 2017 M2, API 5.2
Parameters
start_point- The index of the vertex at the start of the arc.
end_point- The index of the vertex at the end of the arc.
center- The center point of the arc's circle.
normal- The normal vector of the arc plane.
num_segments- The number of edges for the arc.
Returns
pair of size_t values:
  • first - added_curve_index - the index of the added curve.
  • second - control_edge_index - the index of the the arc's control edge which can be used to set the arc's edge properties.

Definition at line 373 of file GeometryInput.cpp.

size_t CW::GeometryInput::add_curve ( const std::vector< size_t > &  edge_indices)

Adds a curve to a geometry input object. This method is intended for specifying curves which are not associated with loop inputs. For specifying curves on faces use the SULoopInput interface.

Since
SketchUp 2017, API 5.0
Parameters
num_edges- The number of edges to be used in the curve.
edge_indices- The edge indices to be used in defining the curve.
added_curve_index(optional) If not NULL, returns the index of the added curve.

Definition at line 365 of file GeometryInput.cpp.

size_t CW::GeometryInput::add_edge ( const Edge edge)

Adds an Edge to the Geometry Input object.

Returns
index to the added edge.

Definition at line 244 of file GeometryInput.cpp.

size_t CW::GeometryInput::add_edge ( size_t  vertex0_index,
size_t  vertex1_index 
)

Adds an edge to a geometry input object. This method is intended for specifying edges which are not associated with loop inputs. For specifying edge properties on a face use the SULoopInput interface. More...

Parameters
vertex0_index- vertex index of start point of edge.
vertex1_index- vertex index of end point of edge.
Returns
index of added edge

Definition at line 325 of file GeometryInput.cpp.

size_t CW::GeometryInput::add_face ( const Face face,
bool  copy_material_layer = true 
)

Adds a face to the Geometry Input object.

Parameters
face- the face object to be copied into the GeometryInput object. Note that materials and layers will NOT be copied. This must be done manually using face_front_material(), face_back_material(), and face_layer() methods.
copy_material_layer- (optional) when true, materials and layers will be copied to the GeometryInput object. Set to false if you are copying faces from another model - you will have to add a material manually.
Returns
index to the added face.

Definition at line 157 of file GeometryInput.cpp.

size_t CW::GeometryInput::add_face ( const std::vector< Loop > &  loops)

Adds a face to the Geometry Input object using the safer LoopInput method, which can deal with inner loops.

Parameters
loops- vector of loops. The first loop in the vector is the outer loop, and all subsequent loops are the inner loops.
Returns
index to the added face.
size_t CW::GeometryInput::add_face ( LoopInput loop_input)

Adds a face to a geometry input object with a given outer loop for the face.

Parameters
outer_loop- The outer loop to be set for the face. If the function succeeds (i.e. returns SU_ERROR_NONE), this loop will be deallocated.
Returns
returns the index of the added face.

Definition at line 382 of file GeometryInput.cpp.

size_t CW::GeometryInput::add_vertex ( const Point3D point)

Adds a vertex to the GeometryInput object.

Parameters
point- the Point3D location of the vertex to add.
Returns
the index number of the added vertex

Definition at line 297 of file GeometryInput.cpp.

std::array< size_t, 5 > CW::GeometryInput::counts ( ) const

Returns all the various geometry counts.

Since
SketchUp 2018, API 6.0
Returns
array of counts:
  • [0] - vertices_count - The total count of vertices.
  • [1] - faces_count The total count of faces.
  • [2] - edge_count The total count of edges.
  • [3] - curve_count The total count of curves.
  • [4] - arc_count The total count of arcs.

Definition at line 434 of file GeometryInput.cpp.

void CW::GeometryInput::edge_hidden ( size_t  edge_index,
bool  hidden 
)

Sets the hidden flag of an edge in a geometry input object which is not associated with a loop input.

Parameters
edge_index- index of the edge to set the hidden flag.
hidden- the flag to set.

Definition at line 333 of file GeometryInput.cpp.

void CW::GeometryInput::edge_layer ( size_t  edge_index,
const Layer layer 
)

Sets the layer of an edge in the geometry input.

Since
SketchUp 2017, API 5.0
Parameters
edge_index- Index of the edge to set the layer.
layer- The layer to be set.

Definition at line 358 of file GeometryInput.cpp.

void CW::GeometryInput::edge_material ( size_t  edge_index,
const Material material 
)

Sets the material of an edge in the geometry input.

Since
SketchUp 2017, API 5.0
Parameters
edge_index- Index of the edge to set the material.
material- The material to be set.

Definition at line 351 of file GeometryInput.cpp.

void CW::GeometryInput::edge_smooth ( size_t  edge_index,
bool  smooth 
)

Sets the smooth flag of an edge in a geometry input object which is not associated with a loop input.

Since
SketchUp 2017, API 5.0
Parameters
edge_index- The zero-based index of the edge which is not associated with a loop input.
smooth- The flag to set.

Definition at line 345 of file GeometryInput.cpp.

void CW::GeometryInput::edge_soft ( size_t  edge_index,
bool  soft 
)

Sets the soft flag of an edge in a geometry input object which is not associated with a loop input.

Since
SketchUp 2017, API 5.0
Parameters
edge_index- The zero-based index of the edge which is not associated with a loop input.
soft- The flag to set.

Definition at line 339 of file GeometryInput.cpp.

bool CW::GeometryInput::empty ( ) const

Returns true if no geometry has been added to this object.

Definition at line 285 of file GeometryInput.cpp.

void CW::GeometryInput::face_add_inner_loop ( size_t  face_index,
LoopInput inner_loop 
)

Adds an inner loop to a face in the geometry input.

Parameters
face_index- Index of the face to receive the inner loop.
loop_input- The inner loop to be added. If the function succeeds (i.e. returns SU_ERROR_NONE), this loop will be deallocated.

Definition at line 404 of file GeometryInput.cpp.

void CW::GeometryInput::face_back_material ( size_t  face_index,
MaterialInput material_input 
)

Sets the back material of a face in the geometry input.

Parameters
face_index- Index of the face to receive the material.
material_input- The material input to set.

Definition at line 420 of file GeometryInput.cpp.

void CW::GeometryInput::face_front_material ( size_t  face_index,
MaterialInput material_input 
)

Sets the front material of a face in the geometry input.

Parameters
face_index- Index of the face to receive the material.
material_input- The material input to set.

Definition at line 412 of file GeometryInput.cpp.

void CW::GeometryInput::face_hidden ( size_t  face_index,
bool  hidden 
)

Sets a flag in the geometry input that, when true, will create a hidden face.

Since
SketchUp 2017, API 5.0
Parameters
face_index- Index of the face to be hidden.
hidden- The given hidden flag.

Definition at line 428 of file GeometryInput.cpp.

void CW::GeometryInput::face_layer ( size_t  face_index,
const Layer layer 
)

Sets the layer of a face in the geometry input.

Parameters
face_index- Index of the face to be reversed.
layer- The layer to be set.

Definition at line 398 of file GeometryInput.cpp.

void CW::GeometryInput::face_reverse ( size_t  face_index,
bool  reverse 
)

Sets a flag in the geometry input that, when true, will create a face by reversing the orientations of all of its loops.

Parameters
face_index- Index of the face to be reversed.
reverse- The given reverse flag.

Definition at line 392 of file GeometryInput.cpp.

size_t CW::GeometryInput::num_faces ( ) const

Returns the number of faces have been input into this GeometryInput object.

Definition at line 149 of file GeometryInput.cpp.

bool CW::GeometryInput::operator! ( ) const

Returns true if the objet is valid, false otherwise.

Definition at line 144 of file GeometryInput.cpp.

GeometryInput & CW::GeometryInput::operator= ( const GeometryInput other)

Copy assignment operator.

Definition at line 121 of file GeometryInput.cpp.

SUGeometryInputRef CW::GeometryInput::ref ( ) const

Returns Raw SUGeometryInputRef that is stored.

Definition at line 139 of file GeometryInput.cpp.

void CW::GeometryInput::set_vertices ( const std::vector< SUPoint3D > &  points)

Sets all vertices of a geometry input object. Any existing vertices will be overridden.

Parameters
points- vector of points to set as the vertices

Definition at line 305 of file GeometryInput.cpp.


The documentation for this class was generated from the following files: