SUAPI-CppWrapper
C++WrapperforSketchUpCAPI
|
Public Member Functions | |
Entities (SUEntitiesRef entities, const SUModelRef model) | |
Entities () | |
SUResult | fill (GeometryInput &geom_input) |
std::vector< Face > | faces () const |
std::vector< Edge > | edges (bool stray_only=true) const |
std::vector< ComponentInstance > | instances () const |
std::vector< Group > | groups () const |
BoundingBox3D | bounding_box () const |
size_t | size () const |
void | add (const Entities &other) |
std::vector< Face > | add_faces (std::vector< Face > &faces) |
Face | add_face (Face &face) |
std::vector< Edge > | add_edges (std::vector< Edge > &edges) |
Edge | add_edge (Edge &edge) |
void | add_instance (ComponentInstance &instance) |
ComponentInstance | add_instance (const ComponentDefinition &definition, const Transformation &transformation, const String &name="") |
Group | add_group (const ComponentDefinition &definition, const Transformation &transformation) |
Group | add_group () |
bool | transform_entities (std::vector< Entity > &elems, const Transformation &transform) |
bool | transform_entities (std::vector< Entity > &elems, std::vector< Transformation > &transforms) |
Model | model () const |
operator SUEntitiesRef () | |
Definition at line 56 of file Entities.hpp.
CW::Entities::Entities | ( | SUEntitiesRef | entities, |
const SUModelRef | model | ||
) |
Default constructor.
model | - SUModelRef object that this entities object resides in. Used for checking that entities added to the entities object is valid for adding to this model. |
Definition at line 50 of file Entities.cpp.
CW::Entities::Entities | ( | ) |
Null Entities object
Definition at line 55 of file Entities.cpp.
void CW::Entities::add | ( | const Entities & | other | ) |
Adds the contents of an entities object into this one.
Definition at line 185 of file Entities.cpp.
BoundingBox3D CW::Entities::bounding_box | ( | ) | const |
Return the BoundingBox of the Entities object.
Definition at line 149 of file Entities.cpp.
SUResult CW::Entities::fill | ( | GeometryInput & | geom_input | ) |
Fills an Entities object with geometry in GeometryInput object.
Now add other data that SUEntitiesFill cannot add to the entities. Apply properties to Faces TODO: there is an assumption that the faces added to an Entities object is added in sequence, according to the index number. So that (num_faces_before + face_index_of_geom_input) correspond to the Face number in the Entities object. This needs to be tested. size_t num_faces_after = 0; res = SUEntitiesGetNumFaces(m_entities, &num_faces_after); assert(res == SU_ERROR_NONE); std::vector<std::pair<size_t, Face>> faces_to_add = geom_input.faces(); If all of the faces in the geom_input were not added, it will not be possible to find the added face by looking at its index. assert((num_faces_after-num_faces_before) == geom_input.num_faces()); Copy any attributes to the added faces std::vector<Face> faces_after = this->faces(); for (size_t i=0; i < faces_to_add.size(); ++i) { assert(this->model().material_exists(faces_to_add[i].second.material())); size_t new_face_index = faces_to_add[i].first; size_t after_face_index = num_faces_before + new_face_index; faces_after[after_face_index].copy_attributes_from(faces_to_add[i].second); Set attributes for the edges that bound the face. std::vector<Loop> loops = faces_to_add[i].second.loops(); std::vector<Loop> new_loops = faces_after[after_face_index].loops(); for (size_t j=0; j < loops.size(); ++j) { std::vector<Edge> old_edges = loops[j].edges(); std::vector<Edge> new_edges = new_loops[j].edges(); If there are more new edges, then it means that some edges have been split during a merging operation. The trick to find these is to see if the end location of the new and old edges match. size_t new_edge_index = 0; size_t old_edge_index = 0; while( old_edge_index < old_edges.size()) { do { new_edges[new_edge_index].copy_attributes_from(old_edges[old_edge_index]); ++new_edge_index; } while ((old_edges.size() < new_edges.size()) && (new_edge_index < new_edges.size()) && (new_edges[new_edge_index-1].end().position() != old_edges[old_edge_index+1].end().position())); ++old_edge_index; } } }
Definition at line 209 of file Entities.cpp.
Model CW::Entities::model | ( | ) | const |
Returns the model object that conrtains this entities object.
Definition at line 449 of file Entities.cpp.
size_t CW::Entities::size | ( | ) | const |
Returns the number of entities that exist in the entities object.
Definition at line 160 of file Entities.cpp.
bool CW::Entities::transform_entities | ( | std::vector< Entity > & | elems, |
const Transformation & | transform | ||
) |
Transforms given entities by the transformation object
elems | - vector array of Entity objects |
transform | - the transformation to apply to the elements. |
Definition at line 413 of file Entities.cpp.
bool CW::Entities::transform_entities | ( | std::vector< Entity > & | elems, |
std::vector< Transformation > & | transforms | ||
) |
Transforms given entities each by their transformation objects.
elems | - vector array of Entity objects |
transforms | - the vector array of transformations to apply to the elements. The number of Transformation objects must match the number of elements given. |
Definition at line 430 of file Entities.cpp.