Skip to content

Commit

Permalink
Clearer assertion check and comments for #227
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLevy committed Feb 12, 2025
1 parent 4aea87a commit 20df7e3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
15 changes: 9 additions & 6 deletions src/lib/geogram/basic/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ namespace GEO {
* instance by passing it by-value to a function).
* Use copy() instead.
*/
AttributesManager(const AttributesManager& rhs);
AttributesManager(const AttributesManager& rhs) = delete;

/**
* \brief Forbids copy.
Expand All @@ -1087,7 +1087,7 @@ namespace GEO {
* instance by passing it by-value to a function).
* Use copy() instead.
*/
const AttributesManager& operator=(const AttributesManager& rhs);
const AttributesManager& operator=(const AttributesManager& rhs) = delete;

private:
index_t size_;
Expand Down Expand Up @@ -1442,6 +1442,7 @@ namespace GEO {
* \return a modifiable reference to the \p i%th element
*/
T& operator[](index_t i) {
geo_debug_assert(superclass::is_bound());
geo_debug_assert(i < superclass::nb_elements());
return ((T*)(void*)superclass::base_addr_)[i];
}
Expand All @@ -1452,6 +1453,7 @@ namespace GEO {
* \return a const reference to the \p i%th element
*/
const T& operator[](index_t i) const {
geo_debug_assert(superclass::is_bound());
geo_debug_assert(i < superclass::nb_elements());
return ((const T*)(void*)superclass::base_addr_)[i];
}
Expand All @@ -1462,6 +1464,7 @@ namespace GEO {
* \param[in] val the value
*/
void fill(const T& val) {
geo_debug_assert(superclass::is_bound());
for(index_t i=0; i<superclass::nb_elements(); ++i) {
(*this)[i] = val;
}
Expand Down Expand Up @@ -1502,11 +1505,11 @@ namespace GEO {
/**
* \brief Forbids copy.
*/
Attribute(const Attribute<T>& rhs);
Attribute(const Attribute<T>& rhs) = delete;
/**
* \brief Forbids copy.
*/
Attribute<T>& operator=(const Attribute<T>& rhs);
Attribute<T>& operator=(const Attribute<T>& rhs) = delete;
};

/*********************************************************************/
Expand Down Expand Up @@ -1705,11 +1708,11 @@ namespace GEO {
/**
* \brief Forbids copy.
*/
Attribute(const Attribute<bool>& rhs);
Attribute(const Attribute<bool>& rhs) = delete;
/**
* \brief Forbids copy.
*/
Attribute<bool>& operator=(const Attribute<bool>& rhs);
Attribute<bool>& operator=(const Attribute<bool>& rhs) = delete;
} ;

/***********************************************************/
Expand Down
4 changes: 4 additions & 0 deletions src/lib/geogram/basic/geofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ namespace {

#else

// Normally it will not get there (64 bit file offsets are supported under
// Linux, Mac and Windows), but I keep the fallback here (for Android and
// Emscripten for instance).

#ifdef GEO_OS_WINDOWS
typedef GEO::Numeric::int64 ssize_t;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lib/geogram/basic/geofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ namespace GEO {
* \brief Reads a 32-bit integer from the file.
* \details Checks that I/O was completed and throws a
* GeoFileException if the file is truncated.
* \return the read integer
* \return the read integer converted to index_t
*/
index_t read_index_t_32();

Expand Down
4 changes: 3 additions & 1 deletion src/lib/geogram/mesh/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -2754,7 +2754,9 @@ namespace GEO {
* \brief Copies a mesh onto this one
* \param[in] rhs a const reference to the mesh to be copied
* \param[in] copy_attributes if true, all the attributes are
* copied.
* copied. If not set, all attributes of this mesh are
* deleted, and Attribute instances connected to this mesh
* are unbound.
* \param[in] what a combination of MESH_VERTICES, MESH_EDGES,
* MESH_FACETS, MESH_CELLS flags. Set to MESH_ALL_ELEMENTS
* to copy everything (default). If MESH_VERTICES is not set,
Expand Down
17 changes: 9 additions & 8 deletions src/lib/geogram/mesh/mesh_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ namespace GEO {
facet_tex_vertices.size() != facet_vertices.size()
) {
Logger::err("I/O")
<< "Line " << in.line_number()
<< ": some facet vertices do not have tex vertices"
<< "Line " << in.line_number() << ": "
<< "some facet vertices do not have tex vertices"
<< std::endl;
unbind_attributes();
return false;
Expand Down Expand Up @@ -3748,12 +3748,13 @@ namespace GEO {
in.current_attribute().element_type
)
) {
Logger::warn("I/O") << "Skipping attribute "
<< in.current_attribute().name
<< ":"
<< demangle(in.current_attribute().element_type)
<< " (unknown type)"
<< std::endl;
Logger::warn("I/O")
<< "Skipping attribute "
<< in.current_attribute().name
<< ":"
<< demangle(in.current_attribute().element_type)
<< " (unknown type)"
<< std::endl;
return;
}
AttributeStore* store =
Expand Down
2 changes: 1 addition & 1 deletion src/lib/geogram/numerics/multi_precision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ namespace {
// into code, indices in the article go from 1 to m, and in the
// code they go from 0 to m-1 !!!
// /!\ there is a bug in the original article,
// line 14 of the algorigthm should be h_top <= q (small q and not capital Q)
// line 14 of the algorithm should be h_top <= q (small q and not capital Q)

/**
* \brief Compresses an expansion
Expand Down

0 comments on commit 20df7e3

Please # to comment.