Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions include/geode/model/helpers/external_time_series_helpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2019 - 2026 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#pragma once

#include <memory>
#include <string_view>

#include <geode/basic/pimpl.hpp>

#include <geode/model/common.hpp>

namespace bitsery
{
class Access;
} // namespace bitsery

namespace geode
{
FORWARD_DECLARATION_DIMENSION_CLASS( PointSet );
ALIAS_3D( PointSet );
class BRep;
} // namespace geode

namespace geode
{
/*!
* Time series computed outside of a BRep (e.g. by a simulator), stored
* apart from the model and written on it on demand.
* Values are stored as vertex attributes of two point sets: the
* simulation unique vertices (one point per colocated position) and the
* simulation cell barycenters. They are matched geometrically with the
* Block vertices and polyhedra of a BRep when applied.
* Time series are expected to be created as time step attributes (see
* AttributeManager::create_time_step_attribute), but any transferable
* attribute is stored and applied the same way.
* The native file can be loaded onto a BRep with load_brep_time_series.
*/
class opengeode_model_api ExternalTimeSeriesHelpers
{
OPENGEODE_DISABLE_COPY( ExternalTimeSeriesHelpers );

public:
ExternalTimeSeriesHelpers();
ExternalTimeSeriesHelpers( ExternalTimeSeriesHelpers&& other ) noexcept;
ExternalTimeSeriesHelpers& operator=(
ExternalTimeSeriesHelpers&& other ) noexcept;
~ExternalTimeSeriesHelpers();

[[nodiscard]] static std::string_view native_extension_static()
{
return "og_ets";
}

[[nodiscard]] std::string_view native_extension() const
{
return native_extension_static();
}

/*!
* Set the simulation unique vertices, carrying the vertex values as
* vertex attributes
* @exception OpenGeodeException if the point set is null
*/
void set_unique_vertices( std::unique_ptr< PointSet3D > vertices );

/*!
* Set the simulation cell barycenters, carrying the cell values as
* vertex attributes
* @exception OpenGeodeException if the point set is null
*/
void set_cell_barycenters( std::unique_ptr< PointSet3D > barycenters );

/*!
* Write the transferable attributes on the Block meshes of the model:
* each unique vertex on the closest model unique vertex (on all its
* Block vertices), each cell barycenter on the Block polyhedron with
* the closest barycenter. Block elements matched with no point keep
* no value, Blocks matched with no point are left untouched.
* Attribute ids and properties (time steps included) are kept. A
* Block time step with the same name and time as an applied one is
* replaced.
* The matching tolerance is GLOBAL_EPSILON relative to the largest
* absolute coordinate of the points (when larger than 1), to accept
* points rounded by the simulator (e.g. stored in single precision).
* @exception OpenGeodeException if a point is farther than the
* tolerance from its closest Block element
*/
void apply_to( BRep& model ) const;

private:
friend class bitsery::Access;
template < typename Archive >
void serialize( Archive& archive );

private:
IMPLEMENTATION_MEMBER( impl_ );
};
} // namespace geode
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2019 - 2026 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#pragma once

#include <string_view>

#include <geode/model/common.hpp>

namespace geode
{
class ExternalTimeSeriesHelpers;
} // namespace geode

namespace geode
{
/*!
* Load an ExternalTimeSeriesHelpers from a native file
* (ExternalTimeSeriesHelpers::native_extension_static()).
* @param[in] filename Path to the file to load.
* @exception OpenGeodeException if the file has another extension or
* cannot be read
*/
[[nodiscard]] ExternalTimeSeriesHelpers opengeode_model_api
load_external_time_series_helpers( std::string_view filename );
} // namespace geode
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2019 - 2026 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#pragma once

#include <string_view>

#include <geode/model/common.hpp>

namespace geode
{
class ExternalTimeSeriesHelpers;
} // namespace geode

namespace geode
{
/*!
* Save an ExternalTimeSeriesHelpers in a native file
* (ExternalTimeSeriesHelpers::native_extension_static()).
* @param[in] helpers ExternalTimeSeriesHelpers to save.
* @param[in] filename Path to the file where save the
* ExternalTimeSeriesHelpers.
* @exception OpenGeodeException if the file has another extension or
* cannot be written
*/
void opengeode_model_api save_external_time_series_helpers(
const ExternalTimeSeriesHelpers& helpers, std::string_view filename );
} // namespace geode
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2019 - 2026 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#pragma once

#include <geode/model/helpers/external_time_series_helpers.hpp>
#include <geode/model/representation/io/brep_time_series_input.hpp>

namespace geode
{
class opengeode_model_api OpenGeodeBRepTimeSeriesInput final
: public BRepTimeSeriesInput
{
public:
explicit OpenGeodeBRepTimeSeriesInput( std::string_view filename )
: BRepTimeSeriesInput{ filename }
{
}

[[nodiscard]] static std::string_view extension()
{
return ExternalTimeSeriesHelpers::native_extension_static();
}

[[nodiscard]] AdditionalFiles additional_files() const final
{
return {};
}

[[nodiscard]] Percentage is_loadable() const final
{
return Percentage{ 1 };
}

void read( BRep& brep ) final;
};
} // namespace geode
8 changes: 8 additions & 0 deletions src/geode/model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ add_geode_library(
"helpers/convert_model_meshes.cpp"
"helpers/convert_to_mesh.cpp"
"helpers/create_coordinate_system.cpp"
"helpers/external_time_series_helpers.cpp"
"helpers/model_component_filter.cpp"
"helpers/model_concatener.cpp"
"helpers/model_coordinate_reference_system.cpp"
Expand Down Expand Up @@ -97,11 +98,14 @@ add_geode_library(
"representation/core/section.cpp"
"representation/io/brep_input.cpp"
"representation/io/brep_time_series_input.cpp"
"representation/io/external_time_series_helpers_input.cpp"
"representation/io/external_time_series_helpers_output.cpp"
"representation/io/section_input.cpp"
"representation/io/brep_output.cpp"
"representation/io/section_output.cpp"
"representation/io/geode/geode_brep_input.cpp"
"representation/io/geode/geode_brep_output.cpp"
"representation/io/geode/geode_brep_time_series_input.cpp"
"representation/io/geode/geode_section_input.cpp"
"representation/io/geode/geode_section_output.cpp"
PUBLIC_HEADERS
Expand All @@ -117,6 +121,7 @@ add_geode_library(
"helpers/convert_model_meshes.hpp"
"helpers/convert_to_mesh.hpp"
"helpers/create_coordinate_system.hpp"
"helpers/external_time_series_helpers.hpp"
"helpers/model_component_filter.hpp"
"helpers/model_concatener.hpp"
"helpers/model_coordinate_reference_system.hpp"
Expand Down Expand Up @@ -173,12 +178,15 @@ add_geode_library(
"representation/core/mapping.hpp"
"representation/io/brep_input.hpp"
"representation/io/brep_time_series_input.hpp"
"representation/io/external_time_series_helpers_input.hpp"
"representation/io/external_time_series_helpers_output.hpp"
"representation/io/section_input.hpp"
"representation/io/brep_output.hpp"
"representation/io/section_output.hpp"
"representation/io/geode/geode_brep_input.hpp"
"representation/io/geode/geode_section_input.hpp"
"representation/io/geode/geode_brep_output.hpp"
"representation/io/geode/geode_brep_time_series_input.hpp"
"representation/io/geode/geode_section_output.hpp"
ADVANCED_HEADERS
"helpers/detail/build_model_boundaries.hpp"
Expand Down
9 changes: 9 additions & 0 deletions src/geode/model/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <geode/model/mixin/core/bitsery_archive.hpp>
#include <geode/model/representation/io/geode/geode_brep_input.hpp>
#include <geode/model/representation/io/geode/geode_brep_output.hpp>
#include <geode/model/representation/io/geode/geode_brep_time_series_input.hpp>
#include <geode/model/representation/io/geode/geode_section_input.hpp>
#include <geode/model/representation/io/geode/geode_section_output.hpp>

Expand All @@ -36,28 +37,35 @@
void register_brep_input()
{
geode::BRepInputFactory::register_creator< geode::OpenGeodeBRepInput >(
geode::OpenGeodeBRepOutput::extension().data() );

Check warning on line 40 in src/geode/model/common.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/common.cpp:40:53 [bugprone-suspicious-stringview-data-usage]

result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues
}

void register_section_input()
{
geode::SectionInputFactory::register_creator<
geode::OpenGeodeSectionInput >(
geode::OpenGeodeSectionOutput::extension().data() );

Check warning on line 47 in src/geode/model/common.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/common.cpp:47:56 [bugprone-suspicious-stringview-data-usage]

result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues
}

void register_brep_time_series_input()
{
geode::BRepTimeSeriesInputFactory::register_creator<
geode::OpenGeodeBRepTimeSeriesInput >(
geode::OpenGeodeBRepTimeSeriesInput::extension().data() );

Check warning on line 54 in src/geode/model/common.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/common.cpp:54:62 [bugprone-suspicious-stringview-data-usage]

result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues
}

void register_brep_output()
{
geode::BRepOutputFactory::register_creator<
geode::OpenGeodeBRepOutput >(
geode::OpenGeodeBRepOutput::extension().data() );

Check warning on line 61 in src/geode/model/common.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/common.cpp:61:53 [bugprone-suspicious-stringview-data-usage]

result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues
}

void register_section_output()
{
geode::SectionOutputFactory::register_creator<
geode::OpenGeodeSectionOutput >(
geode::OpenGeodeSectionOutput::extension().data() );

Check warning on line 68 in src/geode/model/common.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/model/common.cpp:68:56 [bugprone-suspicious-stringview-data-usage]

result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues
}
} // namespace

Expand All @@ -68,6 +76,7 @@
OpenGeodeMeshLibrary::initialize();
register_brep_input();
register_section_input();
register_brep_time_series_input();
register_brep_output();
register_section_output();
BitseryExtensions::register_functions(
Expand Down
Loading
Loading