Skip to content

Commit

Permalink
fix(Output): is_saveable api (#95)
Browse files Browse the repository at this point in the history
* fix(Output): is_saveable api

* Apply prepare changes

* tidy

---------

Co-authored-by: BotellaA <BotellaA@users.noreply.github.com>
  • Loading branch information
BotellaA and BotellaA authored Oct 16, 2023
1 parent 8e97933 commit 988da86
Show file tree
Hide file tree
Showing 31 changed files with 146 additions and 184 deletions.
2 changes: 1 addition & 1 deletion bindings/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
#
# pip-compile --pre bindings/python/requirements.in
#
opengeode-core==14.*,>=14.9.1rc8
opengeode-core==14.*,>=14.9.1rc9
# via -r bindings/python/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>

#include <geode/model/representation/io/section_input.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>

#include <geode/model/representation/io/section_output.h>
Expand Down Expand Up @@ -57,6 +59,9 @@ namespace geode
}
};

bool opengeode_geosciences_explicit_api is_cross_section_saveable(
const CrossSection& cross_section, absl::string_view filename );

using CrossSectionOutputFactory =
Factory< std::string, CrossSectionOutput, absl::string_view >;
} // namespace geode
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>

#include <geode/model/representation/io/brep_input.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>

#include <geode/model/representation/io/brep_output.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/input.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/output.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/input.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/output.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/input.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/output.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/input.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/output.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/input.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#pragma once

#include <absl/strings/string_view.h>

#include <geode/basic/factory.h>
#include <geode/basic/output.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <geode/geosciences/explicit/representation/io/cross_section_input.h>

#include <absl/strings/string_view.h>

#include <geode/basic/detail/geode_input_impl.h>

#include <geode/geosciences/explicit/representation/builder/cross_section_builder.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

#include <geode/geosciences/explicit/representation/io/cross_section_output.h>

#include <absl/strings/ascii.h>
#include <absl/strings/string_view.h>

#include <geode/basic/filename.h>
#include <geode/basic/timer.h>
#include <geode/basic/detail/geode_output_impl.h>

#include <geode/geosciences/explicit/representation/core/cross_section.h>

Expand All @@ -37,25 +36,8 @@ namespace geode
{
try
{
Timer timer;
const auto extension =
absl::AsciiStrToLower( extension_from_filename( filename ) );
if( CrossSectionOutputFactory::has_creator( extension ) )
{
CrossSectionOutputFactory::create( extension, filename )
->write( cross_section );
}
else if( SectionOutputFactory::has_creator( extension ) )
{
SectionOutputFactory::create( extension, filename )
->write( cross_section );
}
else
{
throw OpenGeodeException{ "Unknown extension: ", extension };
}
Logger::info(
"CrossSection saved in ", filename, " in ", timer.duration() );
detail::geode_object_output_impl< CrossSectionOutputFactory >(
"CrossSection", cross_section, filename );
}
catch( const OpenGeodeException& e )
{
Expand All @@ -64,4 +46,13 @@ namespace geode
filename };
}
}

bool is_cross_section_saveable(
const CrossSection& cross_section, absl::string_view filename )
{
const auto output =
detail::geode_object_output_writer< CrossSectionOutputFactory >(
filename );
return output->is_saveable( cross_section );
}
} // namespace geode
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <geode/geosciences/explicit/representation/io/structural_model_input.h>

#include <absl/strings/string_view.h>

#include <geode/basic/detail/geode_input_impl.h>

#include <geode/geosciences/explicit/representation/core/structural_model.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

#include <geode/geosciences/explicit/representation/io/structural_model_output.h>

#include <absl/strings/ascii.h>
#include <absl/strings/string_view.h>

#include <geode/basic/filename.h>
#include <geode/basic/timer.h>
#include <geode/basic/detail/geode_output_impl.h>

#include <geode/geosciences/explicit/representation/core/structural_model.h>

Expand All @@ -37,25 +36,8 @@ namespace geode
{
try
{
Timer timer;
const auto extension =
absl::AsciiStrToLower( extension_from_filename( filename ) );
if( StructuralModelOutputFactory::has_creator( extension ) )
{
StructuralModelOutputFactory::create( extension, filename )
->write( structural_model );
}
else if( BRepOutputFactory::has_creator( extension ) )
{
BRepOutputFactory::create( extension, filename )
->write( structural_model );
}
else
{
throw OpenGeodeException{ "Unknown extension: ", extension };
}
Logger::info( "StructuralModel saved in ", filename, " in ",
timer.duration() );
detail::geode_object_output_impl< StructuralModelOutputFactory >(
"StructuralModel", structural_model, filename );
}
catch( const OpenGeodeException& e )
{
Expand All @@ -64,4 +46,13 @@ namespace geode
filename };
}
}

bool is_structural_model_saveable(
const StructuralModel& structural_model, absl::string_view filename )
{
const auto output =
detail::geode_object_output_writer< StructuralModelOutputFactory >(
filename );
return output->is_saveable( structural_model );
}
} // namespace geode
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <geode/geosciences/implicit/representation/io/horizons_stack_input.h>

#include <absl/strings/string_view.h>

#include <geode/basic/detail/geode_input_impl.h>

#include <geode/geosciences/implicit/representation/builder/horizons_stack_builder.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@

#include <geode/geosciences/implicit/representation/io/horizons_stack_output.h>

#include <absl/strings/ascii.h>
#include <absl/strings/string_view.h>

#include <geode/basic/filename.h>
#include <geode/basic/timer.h>
#include <geode/basic/detail/geode_output_impl.h>

#include <geode/geosciences/implicit/representation/core/horizons_stack.h>

Expand All @@ -38,18 +37,9 @@ namespace geode
{
try
{
Timer timer;
const auto extension =
absl::AsciiStrToLower( extension_from_filename( filename ) );
OPENGEODE_EXCEPTION(
HorizonsStackOutputFactory< dimension >::has_creator(
extension ),
"Unknown extension: ", extension );
HorizonsStackOutputFactory< dimension >::create(
extension, filename )
->write( horizons_stack );
Logger::info(
"HorizonsStack saved in ", filename, " in ", timer.duration() );
detail::geode_object_output_impl<
HorizonsStackOutputFactory< dimension > >(
"HorizonsStack", horizons_stack, filename );
}
catch( const OpenGeodeException& e )
{
Expand All @@ -59,8 +49,23 @@ namespace geode
}
}

template < index_t dimension >
bool is_horizons_stack_saveable(
const HorizonsStack< dimension >& horizons_stack,
absl::string_view filename )
{
const auto output = detail::geode_object_output_writer<
HorizonsStackOutputFactory< dimension > >( filename );
return output->is_saveable( horizons_stack );
}

template void opengeode_geosciences_implicit_api save_horizons_stack(
const HorizonsStack< 2 >&, absl::string_view );
template void opengeode_geosciences_implicit_api save_horizons_stack(
const HorizonsStack< 3 >&, absl::string_view );

template bool opengeode_geosciences_implicit_api is_horizons_stack_saveable(
const HorizonsStack< 2 >&, absl::string_view );
template bool opengeode_geosciences_implicit_api is_horizons_stack_saveable(
const HorizonsStack< 3 >&, absl::string_view );
} // namespace geode
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <geode/geosciences/implicit/representation/io/implicit_cross_section_input.h>

#include <absl/strings/string_view.h>

#include <geode/basic/detail/geode_input_impl.h>

#include <geode/geosciences/implicit/representation/core/implicit_cross_section.h>
Expand Down
Loading

0 comments on commit 988da86

Please sign in to comment.